@xopcai/xopc 0.0.256 → 0.0.257
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/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BZJZvmYw.js → agent-avatar-dicebear-CcHiwo90.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-Bq7GNF1L.js → agent-defaults-settings-panel--9gWwnRC.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-1vtaw07m.js → agents-mRWuin4I.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-DG64SQsx.js → app-management-settings-panel-5kVaSzfB.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-BRWQdIIy.js → appearance-settings-CUBqIGU_.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-D3ziBisx.js → apps-page-f6kxf54f.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-D3FQ9VzV.js → archive-plugin-CfwtYKfh.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-Cid3dBaW.js → attachment-load-BpVTMe-n.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-BUTNaZtj.js → automations-page-dfkTIf80.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-DqBpAhE4.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-BSYMCuaB.js → binary-plugins-CPJDU5qY.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-qDlC3t7b.js → block-editor-CqGeWU9b.js} +3 -3
- package/dist/gateway/static/root/assets/{browser-automations-page-Du1KVE01.js → browser-automations-page-B6onskD_.js} +2 -2
- package/dist/gateway/static/root/assets/{browser-settings-page-WZ0Jt5Hp.js → browser-settings-page-y0F3V4PE.js} +3 -3
- package/dist/gateway/static/root/assets/capabilities-settings-panel-BBxe6mhG.js +7 -0
- package/dist/gateway/static/root/assets/{channels-settings-CZnlYu2L.js → channels-settings-Di9SHb0T.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-CY-I_bCe.js → chat-terminal-dock-47NtjjCX.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-CkH3gaqs.js → connectors-page-gnO6oteJ.js} +2 -2
- package/dist/gateway/static/root/assets/{cron-expression-z4WOWyBU.js → cron-expression-B4r3qBHG.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-vKUcJeQZ.js → date-picker-ClaFWvUv.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-BpZ9A2gi.js → dependency-picker-NMEdb127.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-ClrAMqgn.js → desktop-pet-D9Eem9g_.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-DKNKGiEG.js → desktop-pet-settings-Bc0xgDAG.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-C39hFkJm.js → extension-debug-page-CS0f4Rwe.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DkqVsWB7.js → extension-page-DB1Yd9gB.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-Be4lFw8f.js → extension-settings-page-DogSZfp4.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-HIHGY-0Y.js → gateway-settings-CaKhNsGs.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-DiYjWa1F.js → heartbeat-settings-hP1sHX8G.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-vaJbtRFl.js +1 -0
- package/dist/gateway/static/root/assets/index-Duj4WYOB.js +76 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-ge76J038.js → keyboard-shortcuts-settings-BtReIwcC.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-E47xrPDI.js → local-app-workbench-page-B9uagY6F.js} +2 -2
- package/dist/gateway/static/root/assets/{local-apps-page-gkw7VRL4.js → local-apps-page-DNc0MOE3.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-HHtDMSUW.js → logs-page-Had-beIO.js} +2 -2
- package/dist/gateway/static/root/assets/{management-settings-DOfCSojd.js → management-settings-Dtffn9i3.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-D8wMcUtB.js → media-plugins-DRWqSGyJ.js} +1 -1
- package/dist/gateway/static/root/assets/{mobile-pairing-wizard-B4Ewewwr.js → mobile-pairing-wizard-B0w0psOx.js} +1 -1
- package/dist/gateway/static/root/assets/note-detail-panel-DsYO1fRI.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-CHwT_ijJ.js +8 -0
- package/dist/gateway/static/root/assets/{page-tabs-DoxnT3X4.js → page-tabs-CB9dmnXZ.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-D4oL1yua.js → preview-open-alternatives-D-Dt5xu4.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-DKvtW-Dz.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-io37-OOk.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-B_riktSI.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-CrOpchy5.js → runtime-tools-settings-panel-D_MPP9i5.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-Dk52v4cQ.js → schema-form-BzDq-ZuC.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-BzewHzkk.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-j9MLH-tY.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-dvGi1APN.js → settings-form-section-sGMIA3ks.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-CEYjEm2D.js → settings-page-BC-zLjeS.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-CDs0s_bL.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-DP4Qgsv6.js → share-preview-page-DsrD7e8n.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-C8WKRIAw.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-DRWPnXzw.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-Dlr1Ue1w.js → skills-page-C-zN0B5y.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-I1wcnceD.js → skills-page.utils-BxEl68ey.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-DIaFAHT0.js → system-settings-panel-BgqbBWbr.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-LikAblth.js +1 -0
- package/dist/gateway/static/root/assets/{tunnel-api-DAXx1rHF.js → tunnel-api-DFqaGc8E.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-BwEFbveP.js → use-autosave-BXwKb7uc.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-D_cuGnay.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-C-WbC2fM.js → voice-api-key-field-BzJcgV49.js} +1 -1
- package/dist/gateway/static/root/assets/work-discovery-overlay-Dvg92rT8.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BIU2wg99.js → workflow-run-setup-panel-BiN-2TYW.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-BH8VXmPP.js +6 -0
- package/dist/gateway/static/root/index.html +1 -1
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/notifications.js +8 -1
- package/dist/src/gateway/hono/routes/user-model.js +17 -1
- package/dist/src/notifications/planner.js +35 -0
- package/dist/src/notifications/service.js +2 -0
- package/package.json +4 -4
- package/dist/gateway/static/root/assets/automations-workspace-D4NJSE8l.js +0 -6
- package/dist/gateway/static/root/assets/capabilities-settings-panel-D1AYoRx4.js +0 -7
- package/dist/gateway/static/root/assets/home-page-BLZNEVmk.js +0 -1
- package/dist/gateway/static/root/assets/index-BWdn9NaX.js +0 -76
- package/dist/gateway/static/root/assets/note-detail-panel-DPd5L2A9.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-CE_De-iQ.js +0 -8
- package/dist/gateway/static/root/assets/project-detail-page-DXhBJzJy.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-CcqhmZoX.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-ulmJT_Ac.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-RM0kAsNa.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BfLbu67w.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-BZ4i0CYX.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-B5yHTrGO.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-BicZK04u.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-4_5g-V8B.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-CQnXw4ba.js +0 -2
- package/dist/gateway/static/root/assets/work-discovery-overlay-DiGw5KKj.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-D3Z7JVHH.js +0 -6
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{d as r}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{n as i}from"./locale-store-DJPCr2mb.js";import{t as a}from"./button-CtTvuElV.js";import{t as o}from"./skeleton-BwbyijEw.js";import{Ac as s,Bl as c,Ec as l,Hs as u,
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{d as r}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{n as i}from"./locale-store-DJPCr2mb.js";import{t as a}from"./button-CtTvuElV.js";import{t as o}from"./skeleton-BwbyijEw.js";import{Ac as s,Bl as c,Ec as l,Hs as u,Na as d,Qs as f,Xl as p,_u as m,iu as h,ru as g}from"./index-Duj4WYOB.js";import{i as _,n as v,r as y,t as b}from"./browser-automation-inputs-rA2QROKe.js";var x=e(t(),1),S=n(),C={en:{title:`Browser automations`,subtitle:`Let your assistant repeat routine actions on the web.`,emptyTitle:`No browser automations yet`,emptyBody:`Tell your assistant what to do on the web. Once it works, save it and run it again whenever you need.`,create:`Create with assistant`,edit:`Edit with assistant`,run:`Run now`,stop:`Stop`,enable:`Enable`,pause:`Pause`,enabled:`Enabled`,paused:`Paused`,inputs:`Before running`,noInputs:`This automation is ready to run.`,history:`Recent activity`,delete:`Delete automation`,confirmDelete:`Delete this browser automation?`,required:`Please complete all required fields.`,queued:`Waiting to start`,running:`Running`,succeeded:`Completed`,failed:`Needs attention`,cancelled:`Stopped`,result:`Result`,read:`Reads information`,draft:`Edits the page locally`,external_effect:`Affects an external system`,destructive:`Destructive action`,sensitive:`Sensitive action`,createPrompt:`Help me create a reusable browser automation. Ask what I want the browser to do, perform it once with me, then save the successful steps. Keep all technical details hidden.`,editPrompt:`Help me update the browser automation "{name}" (id: {id}). Ask what should change, test the new browser steps, then save it.`},zh:{title:`浏览器自动化`,subtitle:`让助手自动重复完成网页上的固定操作。`,emptyTitle:`还没有浏览器自动化`,emptyBody:`告诉助手你希望在网页上自动完成什么。成功执行一次后,即可保存并重复运行。`,create:`让助手帮我创建`,edit:`让助手帮我修改`,run:`立即运行`,stop:`停止`,enable:`启用`,pause:`暂停`,enabled:`已启用`,paused:`已暂停`,inputs:`运行前需要填写`,noInputs:`这个自动化可以直接运行。`,history:`最近运行`,delete:`删除自动化`,confirmDelete:`确定删除这个浏览器自动化吗?`,required:`请填写所有必填内容。`,queued:`等待开始`,running:`正在运行`,succeeded:`已完成`,failed:`需要处理`,cancelled:`已停止`,result:`运行结果`,read:`仅读取信息`,draft:`仅在页面内编辑`,external_effect:`会影响外部系统`,destructive:`破坏性操作`,sensitive:`包含敏感操作`,createPrompt:`请帮我创建一个可重复运行的浏览器自动化。先询问我希望浏览器完成什么,陪我实际执行成功一次,然后保存成功步骤。不要让我处理技术细节。`,editPrompt:`请帮我修改浏览器自动化“{name}”(id:{id})。先询问我要修改什么,实际测试新的浏览器步骤,然后保存。`}};function w(e){return e!==`queued`&&e!==`running`}function T(e){return e==null?`-`:typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?e.map(e=>`• ${T(e)}`).join(`
|
|
2
2
|
`):typeof e==`object`?Object.entries(e).map(([e,t])=>`${e}: ${T(t)}`).join(`
|
|
3
|
-
`):String(e)}function E(){let e=i(e=>e.language),t=C[e],n=r(),E=
|
|
3
|
+
`):String(e)}function E(){let e=i(e=>e.language),t=C[e],n=r(),E=d(e=>e.setPageHeader),D=d(e=>e.clearPageHeader),[O,k]=(0,x.useState)(null),[A,j]=(0,x.useState)(),[M,N]=(0,x.useState)({}),[P,F]=(0,x.useState)([]),[I,L]=(0,x.useState)(),[R,z]=(0,x.useState)(``),[B,V]=(0,x.useState)(!1),H=(0,x.useMemo)(()=>O?.find(e=>e.id===A),[A,O]),U=(0,x.useCallback)(async()=>{let e=await _.list();k(e.automations),j(t=>t&&e.automations.some(e=>e.id===t)?t:e.automations[0]?.id)},[]);(0,x.useEffect)(()=>{U().catch(e=>z(String(e)))},[U]),(0,x.useEffect)(()=>{H&&(N(y(H)),L(void 0),z(``),_.listRuns(H.id).then(e=>F(e.runs)).catch(e=>z(String(e))))},[H]),(0,x.useEffect)(()=>{if(!I||w(I.status))return;let e=window.setInterval(()=>{_.getRun(I.id).then(({run:e})=>{L(e),w(e.status)&&H&&_.listRuns(H.id).then(e=>F(e.runs))}).catch(e=>z(String(e)))},700);return()=>window.clearInterval(e)},[I,H]);let W=(0,x.useCallback)(e=>{n(`/chat/new?draft=${encodeURIComponent(e)}`)},[n]),G=(0,x.useMemo)(()=>(0,S.jsxs)(a,{onClick:()=>W(t.createPrompt),children:[(0,S.jsx)(m,{className:`size-4`}),t.create]}),[W,t.create,t.createPrompt]);(0,x.useLayoutEffect)(()=>(E({startExtra:null,main:(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),(0,S.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:t.subtitle})]}),end:G}),()=>D()),[D,G,E,t.subtitle,t.title]);let K=async()=>{if(H){V(!0);try{await _.setEnabled(H.id,!H.enabled),await U()}catch(e){z(String(e))}finally{V(!1)}}},q=async()=>{if(H){if(!v(H,M)){z(t.required);return}V(!0);try{let{run:e}=await _.run(H.id,M);L(e),z(``)}catch(e){z(String(e))}finally{V(!1)}}},J=async()=>{if(!(!H||!window.confirm(t.confirmDelete))){V(!0);try{await _.remove(H.id),j(void 0),F([]),await U()}catch(e){z(String(e))}finally{V(!1)}}};return O===null?(0,S.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel p-4 sm:p-6`,children:(0,S.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[280px_minmax(0,1fr)]`,children:[(0,S.jsx)(o,{className:`h-[420px] rounded-xl`}),(0,S.jsx)(o,{className:`h-[420px] rounded-xl`})]})}):O.length===0?(0,S.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel p-4 sm:p-6`,children:(0,S.jsxs)(`div`,{className:`m-auto max-w-md rounded-2xl border border-edge bg-surface-base p-8 text-center`,children:[(0,S.jsx)(m,{className:`mx-auto size-10 text-accent`}),(0,S.jsx)(`h2`,{className:`mt-4 text-lg font-semibold text-fg`,children:t.emptyTitle}),(0,S.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:t.emptyBody}),(0,S.jsxs)(a,{className:`mt-5`,onClick:()=>W(t.createPrompt),children:[(0,S.jsx)(m,{className:`size-4`}),t.create]})]})}):(0,S.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel p-4 sm:p-6`,children:(0,S.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-4 lg:grid-cols-[280px_minmax(0,1fr)]`,children:[(0,S.jsx)(`aside`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge bg-surface-base p-2`,children:O.map(e=>(0,S.jsxs)(`button`,{onClick:()=>j(e.id),className:`mb-1 w-full rounded-lg p-3 text-left ${A===e.id?`bg-accent-soft text-accent-fg`:`hover:bg-surface-hover`}`,children:[(0,S.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.name}),(0,S.jsxs)(`span`,{className:`mt-1 flex items-center gap-1.5 text-xs text-fg-muted`,children:[e.enabled?(0,S.jsx)(g,{className:`size-3.5 text-emerald-600`}):(0,S.jsx)(h,{className:`size-3.5`}),e.enabled?t.enabled:t.paused]})]},e.id))}),H&&(0,S.jsxs)(`main`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge bg-surface-base p-5 sm:p-6`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:H.name}),H.description&&(0,S.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:H.description}),(0,S.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs`,children:[(0,S.jsx)(`span`,{className:`rounded-full bg-surface-subtle px-2.5 py-1 text-fg-muted`,children:t[H.risk]}),H.domains.map(e=>(0,S.jsxs)(`span`,{className:`flex items-center gap-1 rounded-full bg-surface-subtle px-2.5 py-1 text-fg-muted`,children:[(0,S.jsx)(c,{className:`size-3`}),e]},e))]})]}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsxs)(a,{variant:`secondary`,disabled:B,onClick:()=>void K(),children:[H.enabled?(0,S.jsx)(h,{className:`size-4`}):(0,S.jsx)(g,{className:`size-4`}),H.enabled?t.pause:t.enable]}),(0,S.jsxs)(a,{variant:`secondary`,onClick:()=>W(t.editPrompt.replace(`{name}`,H.name).replace(`{id}`,H.id)),children:[(0,S.jsx)(s,{className:`size-4`}),t.edit]})]})]}),(0,S.jsxs)(`section`,{className:`mt-7 max-w-xl`,children:[(0,S.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.inputs}),Object.keys(H.inputs).length===0?(0,S.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:t.noInputs}):(0,S.jsx)(`div`,{className:`mt-3`,children:(0,S.jsx)(b,{automation:H,values:M,language:e,onChange:N})}),(0,S.jsxs)(`div`,{className:`mt-5 flex gap-2`,children:[(0,S.jsxs)(a,{variant:`primary`,disabled:!H.enabled||B||!!(I&&!w(I.status)),onClick:()=>void q(),children:[(0,S.jsx)(l,{className:`size-4`}),t.run]}),I&&!w(I.status)&&(0,S.jsxs)(a,{variant:`secondary`,onClick:()=>void _.cancel(I.id),children:[(0,S.jsx)(f,{className:`size-4`}),t.stop]})]}),R&&(0,S.jsx)(`p`,{className:`mt-3 text-sm text-red-700 dark:text-red-300`,children:R})]}),I&&(0,S.jsxs)(`section`,{className:`mt-7 rounded-xl border border-edge bg-surface-subtle p-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,S.jsx)(p,{className:`size-4`}),t[I.status]]}),I.error&&(0,S.jsx)(`p`,{className:`mt-2 text-sm text-red-700 dark:text-red-300`,children:I.error}),I.status===`succeeded`&&I.result!==void 0&&(0,S.jsxs)(`div`,{className:`mt-3`,children:[(0,S.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:t.result}),(0,S.jsx)(`pre`,{className:`mt-2 max-h-64 overflow-auto whitespace-pre-wrap text-sm text-fg`,children:T(I.result)})]})]}),(0,S.jsxs)(`section`,{className:`mt-8`,children:[(0,S.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.history}),(0,S.jsx)(`div`,{className:`mt-2 divide-y divide-edge`,children:P.slice(0,10).map(e=>(0,S.jsxs)(`button`,{className:`flex w-full items-center justify-between gap-3 py-3 text-left text-sm hover:text-accent`,onClick:()=>L(e),children:[(0,S.jsx)(`span`,{children:t[e.status]}),(0,S.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[new Date(e.createdAtMs).toLocaleString(),e.durationMs?` · ${Math.max(1,Math.round(e.durationMs/1e3))}s`:``]})]},e.id))})]}),(0,S.jsx)(`div`,{className:`mt-8 border-t border-edge pt-4`,children:(0,S.jsxs)(a,{variant:`ghost`,className:`text-red-700 dark:text-red-300`,disabled:B,onClick:()=>void J(),children:[(0,S.jsx)(u,{className:`size-4`}),t.delete]})})]})]})})}export{E as BrowserAutomationsPage};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{h as i}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as a}from"./popover-select-CKBYnT3c.js";import{t as o}from"./circle-check-C23XjkUj.js";import{t as s}from"./download-Dk-ZjtO6.js";import{t as c}from"./external-link-DjqjBmc3.js";import{t as l}from"./loader-circle-CifKLtgG.js";import{t as u}from"./messages-BeIiRpmk.js";import{a as d,i as f,n as p,r as m,s as h}from"./locale-store-DJPCr2mb.js";import{i as g}from"./vendor-swr-BIWyz7Rc.js";import{t as _}from"./button-CtTvuElV.js";import{n as v,r as y}from"./gateway-config-swr-DEKSw3d-.js";import{t as b}from"./skeleton-BwbyijEw.js";import{Dc as x,Hl as S,Jc as C,Ll as w,Ol as ee,Tl as T,Vs as E,
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{h as i}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as a}from"./popover-select-CKBYnT3c.js";import{t as o}from"./circle-check-C23XjkUj.js";import{t as s}from"./download-Dk-ZjtO6.js";import{t as c}from"./external-link-DjqjBmc3.js";import{t as l}from"./loader-circle-CifKLtgG.js";import{t as u}from"./messages-BeIiRpmk.js";import{a as d,i as f,n as p,r as m,s as h}from"./locale-store-DJPCr2mb.js";import{i as g}from"./vendor-swr-BIWyz7Rc.js";import{t as _}from"./button-CtTvuElV.js";import{n as v,r as y}from"./gateway-config-swr-DEKSw3d-.js";import{t as b}from"./skeleton-BwbyijEw.js";import{Dc as x,Hl as S,Jc as C,Ll as w,Ol as ee,Tl as T,Vs as E,da as D,ua as O,vc as k,zc as A}from"./index-Duj4WYOB.js";import{n as j,r as M}from"./settings-page-layout-BRQNel6r.js";import{n as N}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as P,t as te}from"./use-autosave-BXwKb7uc.js";var F=e(t(),1),I=n();function L(){return d(m(`/api/browser/status`))}function R(){return d(m(`/api/browser/test`),{method:`POST`})}function ne(e=!1){return d(m(`/api/browser/extension/install`),{method:`POST`,body:JSON.stringify({force:e})})}function z(e){return d(m(`/api/browser/extension/open`),{method:`POST`,body:JSON.stringify({action:e})})}async function B(e,t){let n=await f(m(`/api/browser/playwright/install/stream`),{method:`POST`,headers:{Accept:`text/event-stream`},signal:t});if(!n.ok||!n.body)throw Error(`Chromium install request failed (HTTP ${n.status}).`);let r=n.body.getReader(),i=new TextDecoder,a=``,o;try{for(;!o;){let t=await r.read();if(t.done)break;a+=i.decode(t.value,{stream:!0}),a=a.replace(/\r\n/g,`
|
|
2
2
|
`);let n=a.split(`
|
|
3
3
|
|
|
4
4
|
`);a=n.pop()??``;for(let t of n){let n=t.split(`
|
|
5
5
|
`).find(e=>e.startsWith(`event:`))?.slice(6).trim(),r=t.split(`
|
|
6
|
-
`).filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trimStart()).join(``);r&&(n===`progress`&&e(JSON.parse(r)),n===`result`&&(o=JSON.parse(r)))}}}finally{r.releaseLock()}if(!o)throw Error(`Chromium installer ended without a result.`);return o}async function V(){await d(m(`/api/browser/playwright/install/cancel`),{method:`POST`})}function H(e){let[t,n]=(0,F.useState)(!1),[r,i]=(0,F.useState)(!1),[a,o]=(0,F.useState)(null),[s,c]=(0,F.useState)(null),l=(0,F.useRef)(null);return{running:t,cancelling:r,progress:a,error:s,install:(0,F.useCallback)(async()=>{if(l.current)return;let t=new AbortController;l.current=t,n(!0),o(null),c(null);try{let n=await B(o,t.signal);if(!n.ok){n.error!==`cancelled`&&c(n.message??n.error);return}e()}catch(e){t.signal.aborted||c(e instanceof Error?e.message:String(e))}finally{l.current===t&&(l.current=null),n(!1),i(!1)}},[e]),cancel:(0,F.useCallback)(async()=>{l.current&&(i(!0),await V().catch(()=>{}),l.current.abort())},[])}}var U=r(),W={extension:`Chrome extension`,playwright:`Playwright Chromium`,cdp:`CDP`,remote:`Remote browser`};function G(e){let{enabled:t,driverKind:n,autosaveStatus:r,zh:i}=e,a=g(t?[`browser-control-status`,n]:null,L,{revalidateOnFocus:!0,refreshInterval:n===`extension`?3e3:0}),[s,c]=(0,F.useState)(null),[u,d]=(0,F.useState)(null),[f,p]=(0,F.useState)(null),m=r===`dirty`||r===`saving`;(0,F.useEffect)(()=>{r===`saved`&&a.mutate()},[r,a.mutate]);let h=(0,F.useCallback)(async(e,t,n)=>{c(e),d(null),p(null);try{await t(),p(n),await a.mutate()}catch(e){d(e instanceof Error?e.message:String(e))}finally{c(null)}},[a.mutate]),v=H((0,F.useCallback)(()=>{p(i?`Chromium 已安装,可以开始连接测试。`:`Chromium is installed and ready to test.`),a.mutate()},[a.mutate,i])),y=a.data?.payload,S=y?.driverKind===n,C=t?m||!S?`syncing`:y?.state:`disabled`;return(0,U.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-5`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(C===`ready`?o:C===`syncing`?l:E,{className:`size-4 shrink-0 ${C===`ready`?`text-success`:C===`syncing`?`animate-spin text-fg-muted`:C===`disabled`?`text-fg-subtle`:`text-warning`}`}),(0,U.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:i?`浏览器就绪状态`:`Browser readiness`}),(0,U.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-xs ${C===`ready`?`bg-success-soft text-success`:C===`disabled`?`bg-surface-hover text-fg-muted`:`bg-warning-soft text-warning`}`,children:C===`ready`?i?`已就绪`:`Ready`:C===`disabled`?i?`未启用`:`Disabled`:C===`syncing`?i?`正在应用配置`:`Applying configuration`:i?`需要处理`:`Needs attention`})]}),(0,U.jsxs)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:[W[n],y?.detail&&S?` · ${y.detail}`:``]})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,U.jsxs)(_,{variant:`ghost`,className:`h-9`,onClick:()=>void a.mutate(),disabled:a.isValidating,children:[(0,U.jsx)(O,{className:`size-3.5 ${a.isValidating?`animate-spin`:``}`}),i?`刷新`:`Refresh`]}),(0,U.jsxs)(_,{variant:`secondary`,className:`h-9`,disabled:!t||m||s!==null||v.running,onClick:()=>void h(`test`,R,i?`连接测试成功。`:`Connection test passed.`),children:[s===`test`?(0,U.jsx)(l,{className:`size-3.5 animate-spin`}):(0,U.jsx)(x,{className:`size-3.5`}),i?`测试连接`:`Test connection`]})]})]}),t&&a.isLoading?(0,U.jsxs)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-3`,children:[(0,U.jsx)(b,{className:`h-12`}),(0,U.jsx)(b,{className:`h-12`}),(0,U.jsx)(b,{className:`h-12`})]}):null,t&&a.error?(0,U.jsx)(se,{tone:`error`,children:a.error instanceof Error?a.error.message:String(a.error)}):null,u||v.error?(0,U.jsx)(se,{tone:`error`,children:u??v.error}):null,f?(0,U.jsx)(se,{tone:`success`,children:f}):null,t&&n===`extension`&&S?(0,U.jsx)(re,{status:y?.driverStatus,zh:i,busy:s,run:h}):null,t&&n===`playwright`&&S?(0,U.jsx)(oe,{status:y?.driverStatus,zh:i,installer:v}):null,t&&n===`cdp`?(0,U.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-subtle px-3 py-2 text-xs leading-5 text-fg-muted`,children:i?`连接测试会验证已保存的 CDP 地址,并复用浏览器中现有的标签页和登录状态。`:`The connection test verifies the saved CDP endpoint and reuses that browser’s existing tabs and signed-in state.`}):null,t&&n===`remote`?(0,U.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-subtle px-3 py-2 text-xs leading-5 text-fg-muted`,children:i?`连接测试会在服务商侧创建一个临时浏览器会话,并在测试结束后立即关闭。`:`The connection test creates a temporary provider session and closes it immediately after the test.`}):null]})}function re(e){let t=(0,I.c)(59),{status:n,zh:r,busy:i,run:a}=e,o=n?.artifacts,u=r?`扩展文件`:`Extension files`,d=o?.installed===!0,f=o?.installed?r?`已安装`:`Installed`:r?`未安装或需更新`:`Install or update required`,p;t[0]!==u||t[1]!==d||t[2]!==f?(p=(0,U.jsx)(K,{label:u,ok:d,value:f}),t[0]=u,t[1]=d,t[2]=f,t[3]=p):p=t[3];let m=r?`本地桥接`:`Local bridge`,h=n?.running===!0,g=n?.running?r?`运行中`:`Running`:r?`未运行`:`Stopped`,v;t[4]!==m||t[5]!==h||t[6]!==g?(v=(0,U.jsx)(K,{label:m,ok:h,value:g}),t[4]=m,t[5]=h,t[6]=g,t[7]=v):v=t[7];let y=r?`Chrome 连接`:`Chrome connection`,b=n?.connected===!0,x=n?.connected?r?`已连接`:`Connected`:n?.socketConnected?r?`需要重新加载扩展`:`Reload extension`:r?`等待扩展连接`:`Waiting for extension`,S;t[8]!==x||t[9]!==y||t[10]!==b?(S=(0,U.jsx)(K,{label:y,ok:b,value:x}),t[8]=x,t[9]=y,t[10]=b,t[11]=S):S=t[11];let C;t[12]!==S||t[13]!==p||t[14]!==v?(C=(0,U.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[p,v,S]}),t[12]=S,t[13]=p,t[14]=v,t[15]=C):C=t[15];let w=o?.extensionDir??`127.0.0.1:19820`,T;t[16]===w?T=t[17]:(T=(0,U.jsx)(`p`,{className:`mt-3 break-all text-xs text-fg-subtle`,children:w}),t[16]=w,t[17]=T);let E=o?.installed?`secondary`:`primary`,D=i!==null,O;t[18]!==o?.installed||t[19]!==a||t[20]!==r?(O=()=>void a(`extension-install`,()=>ne(!!o?.installed),r?`扩展文件已准备好。`:`Extension files are ready.`),t[18]=o?.installed,t[19]=a,t[20]=r,t[21]=O):O=t[21];let k;t[22]===i?k=t[23]:(k=i===`extension-install`?(0,U.jsx)(l,{className:`size-3.5 animate-spin`}):(0,U.jsx)(s,{className:`size-3.5`}),t[22]=i,t[23]=k);let A=o?.installed?r?`刷新扩展文件`:`Refresh files`:r?`安装扩展文件`:`Install extension`,j;t[24]!==E||t[25]!==D||t[26]!==O||t[27]!==k||t[28]!==A?(j=(0,U.jsxs)(_,{className:`h-9`,variant:E,disabled:D,onClick:O,children:[k,A]}),t[24]=E,t[25]=D,t[26]=O,t[27]=k,t[28]=A,t[29]=j):j=t[29];let M=!o?.installed||i!==null,N;t[30]!==a||t[31]!==r?(N=()=>void a(`extension-open`,ae,r?`已打开 Chrome 扩展页。`:`Chrome extensions opened.`),t[30]=a,t[31]=r,t[32]=N):N=t[32];let P;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,U.jsx)(c,{className:`size-3.5`}),t[33]=P):P=t[33];let te=r?`打开扩展页`:`Open extensions`,F;t[34]!==M||t[35]!==N||t[36]!==te?(F=(0,U.jsxs)(_,{className:`h-9`,variant:`secondary`,disabled:M,onClick:N,children:[P,te]}),t[34]=M,t[35]=N,t[36]=te,t[37]=F):F=t[37];let L=!o?.installed||i!==null,R;t[38]!==a||t[39]!==r?(R=()=>void a(`extension-folder`,ie,r?`已打开扩展目录。`:`Extension folder opened.`),t[38]=a,t[39]=r,t[40]=R):R=t[40];let z;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,U.jsx)(ee,{className:`size-3.5`}),t[41]=z):z=t[41];let B=r?`打开扩展目录`:`Open folder`,V;t[42]!==L||t[43]!==R||t[44]!==B?(V=(0,U.jsxs)(_,{className:`h-9`,variant:`ghost`,disabled:L,onClick:R,children:[z,B]}),t[42]=L,t[43]=R,t[44]=B,t[45]=V):V=t[45];let H;t[46]!==j||t[47]!==F||t[48]!==V?(H=(0,U.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[j,F,V]}),t[46]=j,t[47]=F,t[48]=V,t[49]=H):H=t[49];let W;t[50]!==n?.connected||t[51]!==n?.socketConnected||t[52]!==r?(W=n?.connected?null:(0,U.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-muted`,children:n?.socketConnected?r?`扩展仍在运行旧协议。请打开 Chrome 扩展页,找到 xopc Browser Bridge 并点击“重新加载”,然后刷新状态。`:`The extension is still running an older protocol. Open Chrome Extensions, find xopc Browser Bridge, click Reload, then refresh status.`:r?`首次使用:打开 Chrome 扩展页,开启“开发者模式”,选择“加载已解压的扩展程序”,然后选择上面的扩展目录。`:`First use: open Chrome Extensions, enable Developer mode, choose Load unpacked, then select the extension folder shown above.`}),t[50]=n?.connected,t[51]=n?.socketConnected,t[52]=r,t[53]=W):W=t[53];let G;return t[54]!==C||t[55]!==T||t[56]!==H||t[57]!==W?(G=(0,U.jsxs)(`div`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[C,T,H,W]}),t[54]=C,t[55]=T,t[56]=H,t[57]=W,t[58]=G):G=t[58],G}function ie(){return z(`folder`)}function ae(){return z(`chrome`)}function oe(e){let t=(0,I.c)(28),{status:n,zh:r,installer:i}=e,a=n?.installed===!0,o=n?.installed?r?`已安装`:`Installed`:n?.reason??(r?`未安装`:`Not installed`),c;t[0]!==a||t[1]!==o?(c=(0,U.jsx)(K,{label:`Chromium`,ok:a,value:o}),t[0]=a,t[1]=o,t[2]=c):c=t[2];let u;t[3]===n?u=t[4]:(u=n?.executablePath?(0,U.jsx)(`p`,{className:`mt-2 break-all text-xs text-fg-subtle`,children:n.executablePath}):null,t[3]=n,t[4]=u);let d;t[5]===i.progress?d=t[6]:(d=i.progress?(0,U.jsxs)(`div`,{className:`mt-3`,children:[(0,U.jsxs)(`div`,{className:`flex justify-between text-xs text-fg-muted`,children:[(0,U.jsx)(`span`,{children:i.progress.message??i.progress.phase}),(0,U.jsx)(`span`,{children:i.progress.percent==null?``:`${Math.round(i.progress.percent)}%`})]}),(0,U.jsx)(`div`,{className:`mt-1 h-1.5 overflow-hidden rounded-full bg-surface-hover`,children:(0,U.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width]`,style:{width:`${i.progress.percent??8}%`}})})]}):null,t[5]=i.progress,t[6]=d);let f=n?.installed?`secondary`:`primary`,p;t[7]===i?p=t[8]:(p=()=>void i.install(),t[7]=i,t[8]=p);let m;t[9]===i.running?m=t[10]:(m=i.running?(0,U.jsx)(l,{className:`size-3.5 animate-spin`}):(0,U.jsx)(s,{className:`size-3.5`}),t[9]=i.running,t[10]=m);let h=n?.installed?r?`重新安装 Chromium`:`Reinstall Chromium`:r?`安装 Chromium`:`Install Chromium`,g;t[11]!==i.running||t[12]!==f||t[13]!==p||t[14]!==m||t[15]!==h?(g=(0,U.jsxs)(_,{variant:f,className:`h-9`,disabled:i.running,onClick:p,children:[m,h]}),t[11]=i.running,t[12]=f,t[13]=p,t[14]=m,t[15]=h,t[16]=g):g=t[16];let v;t[17]!==i||t[18]!==r?(v=i.running?(0,U.jsx)(_,{variant:`ghost`,className:`h-9`,disabled:i.cancelling,onClick:()=>void i.cancel(),children:i.cancelling?r?`正在取消…`:`Cancelling…`:r?`取消`:`Cancel`}):null,t[17]=i,t[18]=r,t[19]=v):v=t[19];let y;t[20]!==v||t[21]!==g?(y=(0,U.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[g,v]}),t[20]=v,t[21]=g,t[22]=y):y=t[22];let b;return t[23]!==y||t[24]!==c||t[25]!==u||t[26]!==d?(b=(0,U.jsxs)(`div`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[c,u,d,y]}),t[23]=y,t[24]=c,t[25]=u,t[26]=d,t[27]=b):b=t[27],b}function K(e){let t=(0,I.c)(11),{label:n,ok:r,value:i}=e,a;t[0]===n?a=t[1]:(a=(0,U.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n}),t[0]=n,t[1]=a);let o=`mt-1 flex items-center gap-1.5 text-sm ${r?`text-success`:`text-fg-muted`}`,s=`size-1.5 rounded-full ${r?`bg-success`:`bg-warning`}`,c;t[2]===s?c=t[3]:(c=(0,U.jsx)(`span`,{className:s}),t[2]=s,t[3]=c);let l;t[4]!==o||t[5]!==c||t[6]!==i?(l=(0,U.jsxs)(`p`,{className:o,children:[c,i]}),t[4]=o,t[5]=c,t[6]=i,t[7]=l):l=t[7];let u;return t[8]!==a||t[9]!==l?(u=(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-subtle px-3 py-2`,children:[a,l]}),t[8]=a,t[9]=l,t[10]=u):u=t[10],u}function se(e){let t=(0,I.c)(4),{tone:n,children:r}=e,i=`mt-3 rounded-lg px-3 py-2 text-xs ${n===`success`?`bg-success-soft text-success`:`bg-danger-soft text-danger`}`,a=n===`error`?`alert`:`status`,o;return t[0]!==r||t[1]!==i||t[2]!==a?(o=(0,U.jsx)(`p`,{className:i,role:a,children:r}),t[0]=r,t[1]=i,t[2]=a,t[3]=o):o=t[3],o}function ce(e){let t=(0,I.c)(40),{sectionId:n,intro:r,vm:i,children:a,tabbed:o}=e,s=o===void 0?!1:o,c=p(le),l;t[0]===c?l=t[1]:(l=u(c),t[0]=c,t[1]=l);let d=l,f=d.agentSettings,m=d.settingsSections[n]??n;if(!i.hasToken){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,U.jsx)(S,{className:`mt-0.5 size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75}),t[2]=e):e=t[2];let n;t[3]===m?n=t[4]:(n=(0,U.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:m}),t[3]=m,t[4]=n);let r;t[5]===f.needToken?r=t[6]:(r=(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:f.needToken}),t[5]=f.needToken,t[6]=r);let i;return t[7]!==n||t[8]!==r?(i=(0,U.jsx)(M,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:(0,U.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl bg-surface-base p-6`,children:[e,(0,U.jsxs)(`div`,{children:[n,r]})]})}),t[7]=n,t[8]=r,t[9]=i):i=t[9],i}if(i.loading){let e;return t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,U.jsx)(M,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,U.jsx)(N,{sections:1})}),t[10]=e):e=t[10],e}if(!i.form){let e=i.error??i.fetchError??f.loadError,n;t[11]===e?n=t[12]:(n=(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[11]=e,t[12]=n);let r;t[13]===i?r=t[14]:(r=()=>void i.mutate(),t[13]=i,t[14]=r);let a;t[15]!==d.logs.refresh||t[16]!==r?(a=(0,U.jsx)(_,{type:`button`,variant:`secondary`,onClick:r,children:d.logs.refresh}),t[15]=d.logs.refresh,t[16]=r,t[17]=a):a=t[17];let o;return t[18]!==n||t[19]!==a?(o=(0,U.jsxs)(M,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:[n,a]}),t[18]=n,t[19]=a,t[20]=o):o=t[20],o}let h=s?void 0:r,g;t[21]===f.sectionDesc?g=t[22]:(g=(0,U.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:f.sectionDesc}),t[21]=f.sectionDesc,t[22]=g);let v;t[23]!==i.autosaveStatus||t[24]!==i.error?(v=(0,U.jsx)(P,{status:i.autosaveStatus,error:i.error}),t[23]=i.autosaveStatus,t[24]=i.error,t[25]=v):v=t[25];let y;t[26]!==m||t[27]!==h||t[28]!==g||t[29]!==v?(y=(0,U.jsx)(j,{title:m,subtitle:h,meta:g,actions:v}),t[26]=m,t[27]=h,t[28]=g,t[29]=v,t[30]=y):y=t[30];let b;t[31]===i.error?b=t[32]:(b=i.error?(0,U.jsx)(`div`,{className:`rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/50 dark:bg-red-950/50 dark:text-red-400`,role:`alert`,children:i.error}):null,t[31]=i.error,t[32]=b);let x;t[33]===a?x=t[34]:(x=(0,U.jsx)(`div`,{className:`flex min-w-0 flex-col gap-5 pb-8`,children:a}),t[33]=a,t[34]=x);let C;return t[35]!==y||t[36]!==b||t[37]!==x||t[38]!==i.onBlurCapture?(C=(0,U.jsxs)(M,{gap:`gap-6`,onBlurCapture:i.onBlurCapture,children:[y,b,x]}),t[35]=y,t[36]=b,t[37]=x,t[38]=i.onBlurCapture,t[39]=C):C=t[39],C}function le(e){return e.language}var q={enabled:!0,driverKind:`extension`,headless:!1,executablePath:``,cdpEndpoint:`http://127.0.0.1:9222`,remoteProvider:`browserbase`,remoteApiKey:``,remoteProjectId:``,remoteRegion:``,maxNodes:180,maxCharacters:12e3,visualFallback:!0,actionTimeoutMs:3e4,sessionTimeoutMs:9e5,maxSequenceLength:5,allowedPrivateHosts:``,crossDomainNavigation:`ask`,uploads:`ask`,consequentialActions:`ask`};function ue(e){let t=J(J(e).browser),n=J(t.driver),r=J(t.observation),i=J(t.limits),a=J(t.security),o=n.kind;return{...q,enabled:t.enabled!==!1,driverKind:o===`playwright`||o===`cdp`||o===`remote`?o:`extension`,headless:n.headless===!0,executablePath:Y(n.executablePath,``),cdpEndpoint:Y(n.endpoint,q.cdpEndpoint),remoteProvider:n.provider===`browser-use`?`browser-use`:`browserbase`,remoteApiKey:Y(n.apiKey,``),remoteProjectId:Y(n.projectId,``),remoteRegion:Y(n.region,``),maxNodes:X(r.maxNodes,q.maxNodes),maxCharacters:X(r.maxCharacters,q.maxCharacters),visualFallback:r.visualFallback!==!1,actionTimeoutMs:X(i.actionTimeoutMs,q.actionTimeoutMs),sessionTimeoutMs:X(i.sessionTimeoutMs,q.sessionTimeoutMs),maxSequenceLength:X(i.maxSequenceLength,q.maxSequenceLength),allowedPrivateHosts:Array.isArray(a.allowedPrivateHosts)?a.allowedPrivateHosts.filter(e=>typeof e==`string`).join(`
|
|
6
|
+
`).filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trimStart()).join(``);r&&(n===`progress`&&e(JSON.parse(r)),n===`result`&&(o=JSON.parse(r)))}}}finally{r.releaseLock()}if(!o)throw Error(`Chromium installer ended without a result.`);return o}async function V(){await d(m(`/api/browser/playwright/install/cancel`),{method:`POST`})}function H(e){let[t,n]=(0,F.useState)(!1),[r,i]=(0,F.useState)(!1),[a,o]=(0,F.useState)(null),[s,c]=(0,F.useState)(null),l=(0,F.useRef)(null);return{running:t,cancelling:r,progress:a,error:s,install:(0,F.useCallback)(async()=>{if(l.current)return;let t=new AbortController;l.current=t,n(!0),o(null),c(null);try{let n=await B(o,t.signal);if(!n.ok){n.error!==`cancelled`&&c(n.message??n.error);return}e()}catch(e){t.signal.aborted||c(e instanceof Error?e.message:String(e))}finally{l.current===t&&(l.current=null),n(!1),i(!1)}},[e]),cancel:(0,F.useCallback)(async()=>{l.current&&(i(!0),await V().catch(()=>{}),l.current.abort())},[])}}var U=r(),W={extension:`Chrome extension`,playwright:`Playwright Chromium`,cdp:`CDP`,remote:`Remote browser`};function G(e){let{enabled:t,driverKind:n,autosaveStatus:r,zh:i}=e,a=g(t?[`browser-control-status`,n]:null,L,{revalidateOnFocus:!0,refreshInterval:n===`extension`?3e3:0}),[s,c]=(0,F.useState)(null),[u,d]=(0,F.useState)(null),[f,p]=(0,F.useState)(null),m=r===`dirty`||r===`saving`;(0,F.useEffect)(()=>{r===`saved`&&a.mutate()},[r,a.mutate]);let h=(0,F.useCallback)(async(e,t,n)=>{c(e),d(null),p(null);try{await t(),p(n),await a.mutate()}catch(e){d(e instanceof Error?e.message:String(e))}finally{c(null)}},[a.mutate]),v=H((0,F.useCallback)(()=>{p(i?`Chromium 已安装,可以开始连接测试。`:`Chromium is installed and ready to test.`),a.mutate()},[a.mutate,i])),y=a.data?.payload,S=y?.driverKind===n,C=t?m||!S?`syncing`:y?.state:`disabled`;return(0,U.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-5`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(C===`ready`?o:C===`syncing`?l:E,{className:`size-4 shrink-0 ${C===`ready`?`text-success`:C===`syncing`?`animate-spin text-fg-muted`:C===`disabled`?`text-fg-subtle`:`text-warning`}`}),(0,U.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:i?`浏览器就绪状态`:`Browser readiness`}),(0,U.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-xs ${C===`ready`?`bg-success-soft text-success`:C===`disabled`?`bg-surface-hover text-fg-muted`:`bg-warning-soft text-warning`}`,children:C===`ready`?i?`已就绪`:`Ready`:C===`disabled`?i?`未启用`:`Disabled`:C===`syncing`?i?`正在应用配置`:`Applying configuration`:i?`需要处理`:`Needs attention`})]}),(0,U.jsxs)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:[W[n],y?.detail&&S?` · ${y.detail}`:``]})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,U.jsxs)(_,{variant:`ghost`,className:`h-9`,onClick:()=>void a.mutate(),disabled:a.isValidating,children:[(0,U.jsx)(k,{className:`size-3.5 ${a.isValidating?`animate-spin`:``}`}),i?`刷新`:`Refresh`]}),(0,U.jsxs)(_,{variant:`secondary`,className:`h-9`,disabled:!t||m||s!==null||v.running,onClick:()=>void h(`test`,R,i?`连接测试成功。`:`Connection test passed.`),children:[s===`test`?(0,U.jsx)(l,{className:`size-3.5 animate-spin`}):(0,U.jsx)(x,{className:`size-3.5`}),i?`测试连接`:`Test connection`]})]})]}),t&&a.isLoading?(0,U.jsxs)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-3`,children:[(0,U.jsx)(b,{className:`h-12`}),(0,U.jsx)(b,{className:`h-12`}),(0,U.jsx)(b,{className:`h-12`})]}):null,t&&a.error?(0,U.jsx)(se,{tone:`error`,children:a.error instanceof Error?a.error.message:String(a.error)}):null,u||v.error?(0,U.jsx)(se,{tone:`error`,children:u??v.error}):null,f?(0,U.jsx)(se,{tone:`success`,children:f}):null,t&&n===`extension`&&S?(0,U.jsx)(re,{status:y?.driverStatus,zh:i,busy:s,run:h}):null,t&&n===`playwright`&&S?(0,U.jsx)(oe,{status:y?.driverStatus,zh:i,installer:v}):null,t&&n===`cdp`?(0,U.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-subtle px-3 py-2 text-xs leading-5 text-fg-muted`,children:i?`连接测试会验证已保存的 CDP 地址,并复用浏览器中现有的标签页和登录状态。`:`The connection test verifies the saved CDP endpoint and reuses that browser’s existing tabs and signed-in state.`}):null,t&&n===`remote`?(0,U.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-subtle px-3 py-2 text-xs leading-5 text-fg-muted`,children:i?`连接测试会在服务商侧创建一个临时浏览器会话,并在测试结束后立即关闭。`:`The connection test creates a temporary provider session and closes it immediately after the test.`}):null]})}function re(e){let t=(0,I.c)(59),{status:n,zh:r,busy:i,run:a}=e,o=n?.artifacts,u=r?`扩展文件`:`Extension files`,d=o?.installed===!0,f=o?.installed?r?`已安装`:`Installed`:r?`未安装或需更新`:`Install or update required`,p;t[0]!==u||t[1]!==d||t[2]!==f?(p=(0,U.jsx)(K,{label:u,ok:d,value:f}),t[0]=u,t[1]=d,t[2]=f,t[3]=p):p=t[3];let m=r?`本地桥接`:`Local bridge`,h=n?.running===!0,g=n?.running?r?`运行中`:`Running`:r?`未运行`:`Stopped`,v;t[4]!==m||t[5]!==h||t[6]!==g?(v=(0,U.jsx)(K,{label:m,ok:h,value:g}),t[4]=m,t[5]=h,t[6]=g,t[7]=v):v=t[7];let y=r?`Chrome 连接`:`Chrome connection`,b=n?.connected===!0,x=n?.connected?r?`已连接`:`Connected`:n?.socketConnected?r?`需要重新加载扩展`:`Reload extension`:r?`等待扩展连接`:`Waiting for extension`,S;t[8]!==x||t[9]!==y||t[10]!==b?(S=(0,U.jsx)(K,{label:y,ok:b,value:x}),t[8]=x,t[9]=y,t[10]=b,t[11]=S):S=t[11];let C;t[12]!==S||t[13]!==p||t[14]!==v?(C=(0,U.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[p,v,S]}),t[12]=S,t[13]=p,t[14]=v,t[15]=C):C=t[15];let w=o?.extensionDir??`127.0.0.1:19820`,T;t[16]===w?T=t[17]:(T=(0,U.jsx)(`p`,{className:`mt-3 break-all text-xs text-fg-subtle`,children:w}),t[16]=w,t[17]=T);let E=o?.installed?`secondary`:`primary`,D=i!==null,O;t[18]!==o?.installed||t[19]!==a||t[20]!==r?(O=()=>void a(`extension-install`,()=>ne(!!o?.installed),r?`扩展文件已准备好。`:`Extension files are ready.`),t[18]=o?.installed,t[19]=a,t[20]=r,t[21]=O):O=t[21];let k;t[22]===i?k=t[23]:(k=i===`extension-install`?(0,U.jsx)(l,{className:`size-3.5 animate-spin`}):(0,U.jsx)(s,{className:`size-3.5`}),t[22]=i,t[23]=k);let A=o?.installed?r?`刷新扩展文件`:`Refresh files`:r?`安装扩展文件`:`Install extension`,j;t[24]!==E||t[25]!==D||t[26]!==O||t[27]!==k||t[28]!==A?(j=(0,U.jsxs)(_,{className:`h-9`,variant:E,disabled:D,onClick:O,children:[k,A]}),t[24]=E,t[25]=D,t[26]=O,t[27]=k,t[28]=A,t[29]=j):j=t[29];let M=!o?.installed||i!==null,N;t[30]!==a||t[31]!==r?(N=()=>void a(`extension-open`,ae,r?`已打开 Chrome 扩展页。`:`Chrome extensions opened.`),t[30]=a,t[31]=r,t[32]=N):N=t[32];let P;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,U.jsx)(c,{className:`size-3.5`}),t[33]=P):P=t[33];let te=r?`打开扩展页`:`Open extensions`,F;t[34]!==M||t[35]!==N||t[36]!==te?(F=(0,U.jsxs)(_,{className:`h-9`,variant:`secondary`,disabled:M,onClick:N,children:[P,te]}),t[34]=M,t[35]=N,t[36]=te,t[37]=F):F=t[37];let L=!o?.installed||i!==null,R;t[38]!==a||t[39]!==r?(R=()=>void a(`extension-folder`,ie,r?`已打开扩展目录。`:`Extension folder opened.`),t[38]=a,t[39]=r,t[40]=R):R=t[40];let z;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,U.jsx)(ee,{className:`size-3.5`}),t[41]=z):z=t[41];let B=r?`打开扩展目录`:`Open folder`,V;t[42]!==L||t[43]!==R||t[44]!==B?(V=(0,U.jsxs)(_,{className:`h-9`,variant:`ghost`,disabled:L,onClick:R,children:[z,B]}),t[42]=L,t[43]=R,t[44]=B,t[45]=V):V=t[45];let H;t[46]!==j||t[47]!==F||t[48]!==V?(H=(0,U.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[j,F,V]}),t[46]=j,t[47]=F,t[48]=V,t[49]=H):H=t[49];let W;t[50]!==n?.connected||t[51]!==n?.socketConnected||t[52]!==r?(W=n?.connected?null:(0,U.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-muted`,children:n?.socketConnected?r?`扩展仍在运行旧协议。请打开 Chrome 扩展页,找到 xopc Browser Bridge 并点击“重新加载”,然后刷新状态。`:`The extension is still running an older protocol. Open Chrome Extensions, find xopc Browser Bridge, click Reload, then refresh status.`:r?`首次使用:打开 Chrome 扩展页,开启“开发者模式”,选择“加载已解压的扩展程序”,然后选择上面的扩展目录。`:`First use: open Chrome Extensions, enable Developer mode, choose Load unpacked, then select the extension folder shown above.`}),t[50]=n?.connected,t[51]=n?.socketConnected,t[52]=r,t[53]=W):W=t[53];let G;return t[54]!==C||t[55]!==T||t[56]!==H||t[57]!==W?(G=(0,U.jsxs)(`div`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[C,T,H,W]}),t[54]=C,t[55]=T,t[56]=H,t[57]=W,t[58]=G):G=t[58],G}function ie(){return z(`folder`)}function ae(){return z(`chrome`)}function oe(e){let t=(0,I.c)(28),{status:n,zh:r,installer:i}=e,a=n?.installed===!0,o=n?.installed?r?`已安装`:`Installed`:n?.reason??(r?`未安装`:`Not installed`),c;t[0]!==a||t[1]!==o?(c=(0,U.jsx)(K,{label:`Chromium`,ok:a,value:o}),t[0]=a,t[1]=o,t[2]=c):c=t[2];let u;t[3]===n?u=t[4]:(u=n?.executablePath?(0,U.jsx)(`p`,{className:`mt-2 break-all text-xs text-fg-subtle`,children:n.executablePath}):null,t[3]=n,t[4]=u);let d;t[5]===i.progress?d=t[6]:(d=i.progress?(0,U.jsxs)(`div`,{className:`mt-3`,children:[(0,U.jsxs)(`div`,{className:`flex justify-between text-xs text-fg-muted`,children:[(0,U.jsx)(`span`,{children:i.progress.message??i.progress.phase}),(0,U.jsx)(`span`,{children:i.progress.percent==null?``:`${Math.round(i.progress.percent)}%`})]}),(0,U.jsx)(`div`,{className:`mt-1 h-1.5 overflow-hidden rounded-full bg-surface-hover`,children:(0,U.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width]`,style:{width:`${i.progress.percent??8}%`}})})]}):null,t[5]=i.progress,t[6]=d);let f=n?.installed?`secondary`:`primary`,p;t[7]===i?p=t[8]:(p=()=>void i.install(),t[7]=i,t[8]=p);let m;t[9]===i.running?m=t[10]:(m=i.running?(0,U.jsx)(l,{className:`size-3.5 animate-spin`}):(0,U.jsx)(s,{className:`size-3.5`}),t[9]=i.running,t[10]=m);let h=n?.installed?r?`重新安装 Chromium`:`Reinstall Chromium`:r?`安装 Chromium`:`Install Chromium`,g;t[11]!==i.running||t[12]!==f||t[13]!==p||t[14]!==m||t[15]!==h?(g=(0,U.jsxs)(_,{variant:f,className:`h-9`,disabled:i.running,onClick:p,children:[m,h]}),t[11]=i.running,t[12]=f,t[13]=p,t[14]=m,t[15]=h,t[16]=g):g=t[16];let v;t[17]!==i||t[18]!==r?(v=i.running?(0,U.jsx)(_,{variant:`ghost`,className:`h-9`,disabled:i.cancelling,onClick:()=>void i.cancel(),children:i.cancelling?r?`正在取消…`:`Cancelling…`:r?`取消`:`Cancel`}):null,t[17]=i,t[18]=r,t[19]=v):v=t[19];let y;t[20]!==v||t[21]!==g?(y=(0,U.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[g,v]}),t[20]=v,t[21]=g,t[22]=y):y=t[22];let b;return t[23]!==y||t[24]!==c||t[25]!==u||t[26]!==d?(b=(0,U.jsxs)(`div`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[c,u,d,y]}),t[23]=y,t[24]=c,t[25]=u,t[26]=d,t[27]=b):b=t[27],b}function K(e){let t=(0,I.c)(11),{label:n,ok:r,value:i}=e,a;t[0]===n?a=t[1]:(a=(0,U.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n}),t[0]=n,t[1]=a);let o=`mt-1 flex items-center gap-1.5 text-sm ${r?`text-success`:`text-fg-muted`}`,s=`size-1.5 rounded-full ${r?`bg-success`:`bg-warning`}`,c;t[2]===s?c=t[3]:(c=(0,U.jsx)(`span`,{className:s}),t[2]=s,t[3]=c);let l;t[4]!==o||t[5]!==c||t[6]!==i?(l=(0,U.jsxs)(`p`,{className:o,children:[c,i]}),t[4]=o,t[5]=c,t[6]=i,t[7]=l):l=t[7];let u;return t[8]!==a||t[9]!==l?(u=(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-subtle px-3 py-2`,children:[a,l]}),t[8]=a,t[9]=l,t[10]=u):u=t[10],u}function se(e){let t=(0,I.c)(4),{tone:n,children:r}=e,i=`mt-3 rounded-lg px-3 py-2 text-xs ${n===`success`?`bg-success-soft text-success`:`bg-danger-soft text-danger`}`,a=n===`error`?`alert`:`status`,o;return t[0]!==r||t[1]!==i||t[2]!==a?(o=(0,U.jsx)(`p`,{className:i,role:a,children:r}),t[0]=r,t[1]=i,t[2]=a,t[3]=o):o=t[3],o}function ce(e){let t=(0,I.c)(40),{sectionId:n,intro:r,vm:i,children:a,tabbed:o}=e,s=o===void 0?!1:o,c=p(le),l;t[0]===c?l=t[1]:(l=u(c),t[0]=c,t[1]=l);let d=l,f=d.agentSettings,m=d.settingsSections[n]??n;if(!i.hasToken){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,U.jsx)(S,{className:`mt-0.5 size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75}),t[2]=e):e=t[2];let n;t[3]===m?n=t[4]:(n=(0,U.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:m}),t[3]=m,t[4]=n);let r;t[5]===f.needToken?r=t[6]:(r=(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:f.needToken}),t[5]=f.needToken,t[6]=r);let i;return t[7]!==n||t[8]!==r?(i=(0,U.jsx)(M,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:(0,U.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl bg-surface-base p-6`,children:[e,(0,U.jsxs)(`div`,{children:[n,r]})]})}),t[7]=n,t[8]=r,t[9]=i):i=t[9],i}if(i.loading){let e;return t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,U.jsx)(M,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,U.jsx)(N,{sections:1})}),t[10]=e):e=t[10],e}if(!i.form){let e=i.error??i.fetchError??f.loadError,n;t[11]===e?n=t[12]:(n=(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[11]=e,t[12]=n);let r;t[13]===i?r=t[14]:(r=()=>void i.mutate(),t[13]=i,t[14]=r);let a;t[15]!==d.logs.refresh||t[16]!==r?(a=(0,U.jsx)(_,{type:`button`,variant:`secondary`,onClick:r,children:d.logs.refresh}),t[15]=d.logs.refresh,t[16]=r,t[17]=a):a=t[17];let o;return t[18]!==n||t[19]!==a?(o=(0,U.jsxs)(M,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:[n,a]}),t[18]=n,t[19]=a,t[20]=o):o=t[20],o}let h=s?void 0:r,g;t[21]===f.sectionDesc?g=t[22]:(g=(0,U.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:f.sectionDesc}),t[21]=f.sectionDesc,t[22]=g);let v;t[23]!==i.autosaveStatus||t[24]!==i.error?(v=(0,U.jsx)(P,{status:i.autosaveStatus,error:i.error}),t[23]=i.autosaveStatus,t[24]=i.error,t[25]=v):v=t[25];let y;t[26]!==m||t[27]!==h||t[28]!==g||t[29]!==v?(y=(0,U.jsx)(j,{title:m,subtitle:h,meta:g,actions:v}),t[26]=m,t[27]=h,t[28]=g,t[29]=v,t[30]=y):y=t[30];let b;t[31]===i.error?b=t[32]:(b=i.error?(0,U.jsx)(`div`,{className:`rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/50 dark:bg-red-950/50 dark:text-red-400`,role:`alert`,children:i.error}):null,t[31]=i.error,t[32]=b);let x;t[33]===a?x=t[34]:(x=(0,U.jsx)(`div`,{className:`flex min-w-0 flex-col gap-5 pb-8`,children:a}),t[33]=a,t[34]=x);let C;return t[35]!==y||t[36]!==b||t[37]!==x||t[38]!==i.onBlurCapture?(C=(0,U.jsxs)(M,{gap:`gap-6`,onBlurCapture:i.onBlurCapture,children:[y,b,x]}),t[35]=y,t[36]=b,t[37]=x,t[38]=i.onBlurCapture,t[39]=C):C=t[39],C}function le(e){return e.language}var q={enabled:!0,driverKind:`extension`,headless:!1,executablePath:``,cdpEndpoint:`http://127.0.0.1:9222`,remoteProvider:`browserbase`,remoteApiKey:``,remoteProjectId:``,remoteRegion:``,maxNodes:180,maxCharacters:12e3,visualFallback:!0,actionTimeoutMs:3e4,sessionTimeoutMs:9e5,maxSequenceLength:5,allowedPrivateHosts:``,crossDomainNavigation:`ask`,uploads:`ask`,consequentialActions:`ask`};function ue(e){let t=J(J(e).browser),n=J(t.driver),r=J(t.observation),i=J(t.limits),a=J(t.security),o=n.kind;return{...q,enabled:t.enabled!==!1,driverKind:o===`playwright`||o===`cdp`||o===`remote`?o:`extension`,headless:n.headless===!0,executablePath:Y(n.executablePath,``),cdpEndpoint:Y(n.endpoint,q.cdpEndpoint),remoteProvider:n.provider===`browser-use`?`browser-use`:`browserbase`,remoteApiKey:Y(n.apiKey,``),remoteProjectId:Y(n.projectId,``),remoteRegion:Y(n.region,``),maxNodes:X(r.maxNodes,q.maxNodes),maxCharacters:X(r.maxCharacters,q.maxCharacters),visualFallback:r.visualFallback!==!1,actionTimeoutMs:X(i.actionTimeoutMs,q.actionTimeoutMs),sessionTimeoutMs:X(i.sessionTimeoutMs,q.sessionTimeoutMs),maxSequenceLength:X(i.maxSequenceLength,q.maxSequenceLength),allowedPrivateHosts:Array.isArray(a.allowedPrivateHosts)?a.allowedPrivateHosts.filter(e=>typeof e==`string`).join(`
|
|
7
7
|
`):``,crossDomainNavigation:me(a.crossDomainNavigation),uploads:me(a.uploads),consequentialActions:me(a.consequentialActions)}}function de(e){let t=e.driverKind===`extension`?{kind:`extension`}:e.driverKind===`playwright`?{kind:`playwright`,headless:e.headless,...e.executablePath.trim()?{executablePath:e.executablePath.trim()}:{}}:e.driverKind===`cdp`?{kind:`cdp`,endpoint:e.cdpEndpoint.trim()}:{kind:`remote`,provider:e.remoteProvider,...e.remoteApiKey.trim()?{apiKey:e.remoteApiKey.trim()}:{},...e.remoteProjectId.trim()?{projectId:e.remoteProjectId.trim()}:{},...e.remoteRegion.trim()?{region:e.remoteRegion.trim()}:{}};return{enabled:e.enabled,driver:t,observation:{maxNodes:e.maxNodes,maxCharacters:e.maxCharacters,visualFallback:e.visualFallback},limits:{actionTimeoutMs:e.actionTimeoutMs,sessionTimeoutMs:e.sessionTimeoutMs,maxSequenceLength:e.maxSequenceLength},security:{privateNetworks:`deny`,allowedPrivateHosts:e.allowedPrivateHosts.split(`
|
|
8
|
-
`).map(e=>e.trim()).filter(Boolean),crossDomainNavigation:e.crossDomainNavigation,uploads:e.uploads,consequentialActions:e.consequentialActions}}}function fe(e){if(e.driverKind===`cdp`)try{let t=new URL(e.cdpEndpoint);if(t.protocol!==`http:`&&t.protocol!==`https:`&&t.protocol!==`ws:`&&t.protocol!==`wss:`)return`CDP endpoint must use http, https, ws, or wss.`}catch{return`Enter a valid CDP endpoint URL.`}return!Number.isInteger(e.maxNodes)||e.maxNodes<20||e.maxNodes>500?`Max nodes must be between 20 and 500.`:!Number.isInteger(e.maxCharacters)||e.maxCharacters<1e3||e.maxCharacters>5e4?`Max characters must be between 1,000 and 50,000.`:!Number.isInteger(e.actionTimeoutMs)||e.actionTimeoutMs<1e3||e.actionTimeoutMs>12e4?`Action timeout must be between 1,000 and 120,000 ms.`:!Number.isInteger(e.sessionTimeoutMs)||e.sessionTimeoutMs<6e4||e.sessionTimeoutMs>36e5?`Session timeout must be between 60,000 and 3,600,000 ms.`:!Number.isInteger(e.maxSequenceLength)||e.maxSequenceLength<1||e.maxSequenceLength>10?`Sequence length must be between 1 and 10.`:null}async function pe(e){await d(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({browser:de(e)})}),v()}function J(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Y(e,t){return typeof e==`string`?e:t}function X(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}function me(e){return e===`allow`||e===`deny`?e:`ask`}var he=D();function ge(e){let t=!!h(e=>e.token),[n,r]=(0,F.useReducer)(he,{form:null,baseline:null}),i=n.form,a=n.baseline,o=(0,F.useRef)(!1),s=(0,F.useRef)(i);s.current=i;let c=(0,F.useRef)(null),{data:l,error:u,isLoading:d,mutate:f}=y(t);k({enabled:t,parsed:(0,F.useMemo)(()=>l?.payload?.config===void 0?null:ue(l.payload.config),[l]),dirty:o.current,trackedParsedRef:c,dispatch:r,onResetDirty:()=>{o.current=!1}});let p=!!(t&&d&&l===void 0&&!u),m=u instanceof Error?u.message:u?String(u):null,g=(0,F.useMemo)(()=>!i||!a?!1:JSON.stringify(i)!==JSON.stringify(a),[i,a]),_=(0,F.useCallback)(e=>{o.current=!0,r({type:`patch`,patch:e})},[]),v=te({value:i,dirty:g,onSave:(0,F.useCallback)(async t=>{try{await pe(t),r({type:`saved`,value:t}),o.current=!!(s.current&&JSON.stringify(s.current)!==JSON.stringify(t))}catch(t){throw Error(t instanceof Error?t.message:e.saveError)}},[e.saveError]),validate:fe});return{hasToken:t,loading:p,fetchError:m,form:i,update:_,autosaveStatus:v.status,error:v.error,onBlurCapture:v.onBlurCapture,mutate:f}}var _e=[`extension`,`playwright`,`cdp`,`remote`];function ve(){let e=(0,I.c)(30),t=p(ye),n;e[0]===t?n=e[1]:(n=u(t),e[0]=t,e[1]=n);let r=ge(n.agentSettings),o=r.form,s=t===`zh`,[c]=i(),l=(0,F.useRef)(!1),d;e[2]!==o||e[3]!==c||e[4]!==r?(d=()=>{if(!o||l.current)return;l.current=!0;let e=c.get(`driver`);_e.includes(e)&&e!==o.driverKind&&r.update({driverKind:e})},e[2]=o,e[3]=c,e[4]=r,e[5]=d):d=e[5];let f;e[6]!==o||e[7]!==c||e[8]!==r.update?(f=[o,c,r.update],e[6]=o,e[7]=c,e[8]=r.update,e[9]=f):f=e[9],(0,F.useEffect)(d,f);let m=s?`Chrome 扩展(推荐)`:`Chrome extension (recommended)`,h;e[10]===m?h=e[11]:(h={value:`extension`,label:m},e[10]=m,e[11]=h);let g;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(g={value:`playwright`,label:`Playwright Chromium`},e[12]=g):g=e[12];let _=s?`CDP 已有浏览器`:`Existing browser over CDP`,v;e[13]===_?v=e[14]:(v={value:`cdp`,label:_},e[13]=_,e[14]=v);let y=s?`远程浏览器`:`Remote browser`,b;e[15]===y?b=e[16]:(b={value:`remote`,label:y},e[15]=y,e[16]=b);let x;e[17]!==h||e[18]!==v||e[19]!==b?(x=[h,g,v,b],e[17]=h,e[18]=v,e[19]=b,e[20]=x):x=e[20];let S=x,ee=s?`让 Agent 读取网页结构并可靠地点击、输入和切换标签页;仅在语义信息不足时使用截图。`:`Let the agent read page structure and reliably click, type, and switch tabs. Screenshots are used only when semantic data is insufficient.`,E;e[21]!==S||e[22]!==o||e[23]!==r||e[24]!==s?(E=o?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(G,{enabled:o.enabled,driverKind:o.driverKind,autosaveStatus:r.autosaveStatus,zh:s}),(0,U.jsxs)(xe,{title:s?`运行方式`:`Connection`,description:s?`选择 Agent 在哪里操作浏览器。配置会自动保存,状态卡会验证实际连接。`:`Choose where the agent operates the browser. Settings save automatically; the readiness card verifies the real connection.`,icon:(0,U.jsx)(A,{className:`size-4`}),children:[(0,U.jsx)(Se,{label:s?`启用浏览器控制`:`Enable browser control`,description:s?`启用后向 Agent 提供 browser_use 工具。`:`Makes the browser_use tool available to the agent.`,checked:o.enabled,onChange:e=>r.update({enabled:e})}),(0,U.jsx)(Z,{label:s?`浏览器连接`:`Browser connection`,children:(0,U.jsx)(a,{value:o.driverKind,options:S,placeholder:s?`选择连接方式`:`Choose a connection`,allowEmpty:!1,onChange:e=>r.update({driverKind:e})})}),(0,U.jsx)(be,{kind:o.driverKind,zh:s}),o.driverKind===`playwright`?(0,U.jsxs)(`div`,{className:`space-y-4 rounded-lg bg-surface-subtle p-4`,children:[(0,U.jsx)(Se,{label:s?`无头模式`:`Headless mode`,description:s?`后台运行,不显示浏览器窗口。关闭后可观察 Agent 的操作过程。`:`Run in the background without a visible window. Turn off to watch the agent work.`,checked:o.headless,onChange:e=>r.update({headless:e})}),(0,U.jsx)(Q,{label:s?`Chromium 可执行文件(可选)`:`Chromium executable (optional)`,description:s?`留空时使用由 xopc 安装的 Chromium。`:`Leave empty to use Chromium installed by xopc.`,value:o.executablePath,onChange:e=>r.update({executablePath:e})})]}):null,o.driverKind===`cdp`?(0,U.jsx)(`div`,{className:`rounded-lg bg-surface-subtle p-4`,children:(0,U.jsx)(Q,{label:`CDP endpoint`,description:s?`例如 http://127.0.0.1:9222。Chrome 需要开启 remote debugging。`:`For example http://127.0.0.1:9222. Chrome must be started with remote debugging enabled.`,value:o.cdpEndpoint,onChange:e=>r.update({cdpEndpoint:e})})}):null,o.driverKind===`remote`?(0,U.jsxs)(`div`,{className:`space-y-4 rounded-lg bg-surface-subtle p-4`,children:[(0,U.jsx)(Z,{label:s?`服务商`:`Provider`,children:(0,U.jsx)(a,{value:o.remoteProvider,options:[{value:`browserbase`,label:`Browserbase`},{value:`browser-use`,label:`Browser Use`}],placeholder:s?`选择服务商`:`Choose a provider`,allowEmpty:!1,onChange:e=>r.update({remoteProvider:e})})}),(0,U.jsx)(Q,{label:`API key`,type:`password`,autoComplete:`off`,value:o.remoteApiKey,onChange:e=>r.update({remoteApiKey:e})}),(0,U.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,U.jsx)(Q,{label:`Project ID`,value:o.remoteProjectId,onChange:e=>r.update({remoteProjectId:e})}),(0,U.jsx)(Q,{label:`Region`,value:o.remoteRegion,onChange:e=>r.update({remoteRegion:e})})]})]}):null]}),(0,U.jsxs)(xe,{title:s?`页面理解与 Token`:`Page understanding and tokens`,description:s?`默认发送可交互元素和正文摘要,比整页截图更省 Token;视觉回退只处理语义无法覆盖的页面。`:`By default the model receives interactive elements and a text summary, which costs fewer tokens than full-page screenshots. Visual fallback covers pages that semantics cannot.`,icon:(0,U.jsx)(w,{className:`size-4`}),children:[(0,U.jsx)(Se,{label:s?`语义信息不足时附加截图`:`Attach a screenshot when semantics are insufficient`,description:s?`推荐开启。正常网页不会每一步都发送截图。`:`Recommended. Normal pages do not send a screenshot on every step.`,checked:o.visualFallback,onChange:e=>r.update({visualFallback:e})}),(0,U.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,U.jsx)($,{label:s?`最大语义节点`:`Maximum semantic nodes`,description:`20–500`,min:20,max:500,value:o.maxNodes,onChange:e=>r.update({maxNodes:e})}),(0,U.jsx)($,{label:s?`最大文本字符`:`Maximum text characters`,description:`1,000–50,000`,min:1e3,max:5e4,step:1e3,value:o.maxCharacters,onChange:e=>r.update({maxCharacters:e})})]})]}),(0,U.jsx)(xe,{title:s?`执行限制`:`Execution limits`,description:s?`限制单次操作、浏览器会话和批量步骤,避免页面卡住时无限等待。`:`Bound individual actions, browser sessions, and action sequences so a stuck page cannot wait indefinitely.`,icon:(0,U.jsx)(T,{className:`size-4`}),children:(0,U.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,U.jsx)($,{label:s?`操作超时(毫秒)`:`Action timeout (ms)`,min:1e3,max:12e4,step:1e3,value:o.actionTimeoutMs,onChange:e=>r.update({actionTimeoutMs:e})}),(0,U.jsx)($,{label:s?`会话超时(毫秒)`:`Session timeout (ms)`,min:6e4,max:36e5,step:6e4,value:o.sessionTimeoutMs,onChange:e=>r.update({sessionTimeoutMs:e})}),(0,U.jsx)($,{label:s?`批量步骤上限`:`Sequence step limit`,min:1,max:10,value:o.maxSequenceLength,onChange:e=>r.update({maxSequenceLength:e})})]})}),(0,U.jsxs)(xe,{title:s?`安全与审批`:`Safety and approvals`,description:s?`私网访问始终拒绝,只有下面明确列出的主机例外。敏感动作可逐次询问、允许或拒绝。`:`Private-network access is always denied except for exact hosts listed below. Sensitive actions can ask each time, be allowed, or be denied.`,icon:(0,U.jsx)(C,{className:`size-4`}),children:[(0,U.jsx)(Q,{label:s?`允许访问的私网主机`:`Allowed private hosts`,description:s?`每行一个精确的小写主机名或 IP,不支持通配符。`:`One exact lowercase hostname or IP per line. Wildcards are not supported.`,multiline:!0,value:o.allowedPrivateHosts,onChange:e=>r.update({allowedPrivateHosts:e})}),(0,U.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,U.jsx)(Ce,{zh:s,label:s?`跨域导航`:`Cross-domain navigation`,value:o.crossDomainNavigation,onChange:e=>r.update({crossDomainNavigation:e})}),(0,U.jsx)(Ce,{zh:s,label:s?`高影响动作`:`Consequential actions`,value:o.consequentialActions,onChange:e=>r.update({consequentialActions:e})}),(0,U.jsx)(Ce,{zh:s,label:s?`文件上传`:`File uploads`,value:o.uploads,onChange:e=>r.update({uploads:e})})]})]})]}):null,e[21]=S,e[22]=o,e[23]=r,e[24]=s,e[25]=E):E=e[25];let D;return e[26]!==ee||e[27]!==E||e[28]!==r?(D=(0,U.jsx)(ce,{sectionId:`agent-browser`,intro:ee,vm:r,children:E}),e[26]=ee,e[27]=E,e[28]=r,e[29]=D):D=e[29],D}function ye(e){return e.language}function be(e){let t=(0,I.c)(7),{kind:n,zh:r}=e,i=r?`直接操作你正在使用的 Chrome,保留登录状态和现有标签页;最适合日常协作。`:`Operate your current Chrome with its signed-in state and existing tabs; best for daily collaboration.`,a=r?`由 xopc 启动独立 Chromium,环境隔离、自动化稳定,适合无人值守任务。`:`Let xopc launch an isolated Chromium; stable for unattended automation.`,o=r?`连接已开启远程调试的 Chrome 或 Chromium,适合自定义浏览器启动方式。`:`Connect to Chrome or Chromium already running with remote debugging.`,s=r?`使用 Browserbase 或 Browser Use 的云端浏览器,适合服务器环境和长任务。`:`Use a Browserbase or Browser Use cloud browser for servers and long-running tasks.`,c;t[0]!==i||t[1]!==a||t[2]!==o||t[3]!==s?(c={extension:i,playwright:a,cdp:o,remote:s},t[0]=i,t[1]=a,t[2]=o,t[3]=s,t[4]=c):c=t[4];let l=c[n],u;return t[5]===l?u=t[6]:(u=(0,U.jsx)(`p`,{className:`rounded-lg bg-surface-subtle px-3 py-2 text-xs leading-5 text-fg-muted`,children:l}),t[5]=l,t[6]=u),u}function xe(e){let t=(0,I.c)(17),{title:n,description:r,icon:i,children:a}=e,o;t[0]===i?o=t[1]:(o=(0,U.jsx)(`span`,{className:`mt-0.5 text-fg-subtle`,children:i}),t[0]=i,t[1]=o);let s;t[2]===n?s=t[3]:(s=(0,U.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n}),t[2]=n,t[3]=s);let c;t[4]===r?c=t[5]:(c=r?(0,U.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:r}):null,t[4]=r,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,U.jsxs)(`div`,{children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]!==o||t[10]!==l?(u=(0,U.jsxs)(`div`,{className:`mb-4 flex items-start gap-2`,children:[o,l]}),t[9]=o,t[10]=l,t[11]=u):u=t[11];let d;t[12]===a?d=t[13]:(d=(0,U.jsx)(`div`,{className:`space-y-4`,children:a}),t[12]=a,t[13]=d);let f;return t[14]!==u||t[15]!==d?(f=(0,U.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-5`,children:[u,d]}),t[14]=u,t[15]=d,t[16]=f):f=t[16],f}function Z(e){let t=(0,I.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,U.jsx)(`span`,{className:`mb-1.5 block font-medium`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=r?(0,U.jsx)(`span`,{className:`mt-1.5 block text-xs leading-5 text-fg-subtle`,children:r}):null,t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,U.jsxs)(`label`,{className:`block text-sm text-fg`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Q(e){let t=(0,I.c)(10),{label:n,description:r,value:i,onChange:a,type:o,multiline:s,autoComplete:c}=e,l=o===void 0?`text`:o,u=s===void 0?!1:s,d;t[0]!==c||t[1]!==u||t[2]!==a||t[3]!==l||t[4]!==i?(d=u?(0,U.jsx)(`textarea`,{rows:3,value:i,onChange:e=>a(e.target.value),className:`w-full rounded-lg border border-edge bg-surface-subtle px-3 py-2 text-sm text-fg outline-none focus:border-accent`}):(0,U.jsx)(`input`,{type:l,autoComplete:c,value:i,onChange:e=>a(e.target.value),className:`w-full rounded-lg border border-edge bg-surface-subtle px-3 py-2 text-sm text-fg outline-none focus:border-accent`}),t[0]=c,t[1]=u,t[2]=a,t[3]=l,t[4]=i,t[5]=d):d=t[5];let f;return t[6]!==r||t[7]!==n||t[8]!==d?(f=(0,U.jsx)(Z,{label:n,description:r,children:d}),t[6]=r,t[7]=n,t[8]=d,t[9]=f):f=t[9],f}function $(e){let t=(0,I.c)(12),{label:n,description:r,value:i,onChange:a,min:o,max:s,step:c}=e,l=c===void 0?1:c,u;t[0]===a?u=t[1]:(u=e=>{let t=Number(e.target.value);Number.isFinite(t)&&a(t)},t[0]=a,t[1]=u);let d;t[2]!==s||t[3]!==o||t[4]!==l||t[5]!==u||t[6]!==i?(d=(0,U.jsx)(`input`,{type:`number`,min:o,max:s,step:l,value:i,onChange:u,className:`h-10 w-full rounded-lg border border-edge bg-surface-subtle px-3 text-sm text-fg outline-none focus:border-accent`}),t[2]=s,t[3]=o,t[4]=l,t[5]=u,t[6]=i,t[7]=d):d=t[7];let f;return t[8]!==r||t[9]!==n||t[10]!==d?(f=(0,U.jsx)(Z,{label:n,description:r,children:d}),t[8]=r,t[9]=n,t[10]=d,t[11]=f):f=t[11],f}function Se(e){let t=(0,I.c)(15),{label:n,description:r,checked:i,onChange:a}=e,o;t[0]===a?o=t[1]:(o=e=>a(e.target.checked),t[0]=a,t[1]=o);let s;t[2]!==i||t[3]!==o?(s=(0,U.jsx)(`input`,{type:`checkbox`,checked:i,onChange:o,className:`mt-0.5 size-4 accent-accent`}),t[2]=i,t[3]=o,t[4]=s):s=t[4];let c;t[5]===n?c=t[6]:(c=(0,U.jsx)(`span`,{className:`block font-medium`,children:n}),t[5]=n,t[6]=c);let l;t[7]===r?l=t[8]:(l=r?(0,U.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-subtle`,children:r}):null,t[7]=r,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,U.jsxs)(`span`,{children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;return t[12]!==s||t[13]!==u?(d=(0,U.jsxs)(`label`,{className:`flex items-start gap-3 text-sm text-fg`,children:[s,u]}),t[12]=s,t[13]=u,t[14]=d):d=t[14],d}function Ce(e){let t=(0,I.c)(20),{zh:n,label:r,value:i,onChange:o}=e,s=n?`每次询问`:`Ask each time`,c;t[0]===s?c=t[1]:(c={value:`ask`,label:s},t[0]=s,t[1]=c);let l=n?`允许`:`Allow`,u;t[2]===l?u=t[3]:(u={value:`allow`,label:l},t[2]=l,t[3]=u);let d=n?`拒绝`:`Deny`,f;t[4]===d?f=t[5]:(f={value:`deny`,label:d},t[4]=d,t[5]=f);let p;t[6]!==c||t[7]!==u||t[8]!==f?(p=[c,u,f],t[6]=c,t[7]=u,t[8]=f,t[9]=p):p=t[9];let m=p,h=n?`选择策略`:`Choose a policy`,g;t[10]===o?g=t[11]:(g=e=>o(e),t[10]=o,t[11]=g);let _;t[12]!==m||t[13]!==h||t[14]!==g||t[15]!==i?(_=(0,U.jsx)(a,{value:i,options:m,placeholder:h,allowEmpty:!1,onChange:g}),t[12]=m,t[13]=h,t[14]=g,t[15]=i,t[16]=_):_=t[16];let v;return t[17]!==r||t[18]!==_?(v=(0,U.jsx)(Z,{label:r,children:_}),t[17]=r,t[18]=_,t[19]=v):v=t[19],v}export{ve as AgentBrowserSettingsPage};
|
|
8
|
+
`).map(e=>e.trim()).filter(Boolean),crossDomainNavigation:e.crossDomainNavigation,uploads:e.uploads,consequentialActions:e.consequentialActions}}}function fe(e){if(e.driverKind===`cdp`)try{let t=new URL(e.cdpEndpoint);if(t.protocol!==`http:`&&t.protocol!==`https:`&&t.protocol!==`ws:`&&t.protocol!==`wss:`)return`CDP endpoint must use http, https, ws, or wss.`}catch{return`Enter a valid CDP endpoint URL.`}return!Number.isInteger(e.maxNodes)||e.maxNodes<20||e.maxNodes>500?`Max nodes must be between 20 and 500.`:!Number.isInteger(e.maxCharacters)||e.maxCharacters<1e3||e.maxCharacters>5e4?`Max characters must be between 1,000 and 50,000.`:!Number.isInteger(e.actionTimeoutMs)||e.actionTimeoutMs<1e3||e.actionTimeoutMs>12e4?`Action timeout must be between 1,000 and 120,000 ms.`:!Number.isInteger(e.sessionTimeoutMs)||e.sessionTimeoutMs<6e4||e.sessionTimeoutMs>36e5?`Session timeout must be between 60,000 and 3,600,000 ms.`:!Number.isInteger(e.maxSequenceLength)||e.maxSequenceLength<1||e.maxSequenceLength>10?`Sequence length must be between 1 and 10.`:null}async function pe(e){await d(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({browser:de(e)})}),v()}function J(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Y(e,t){return typeof e==`string`?e:t}function X(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}function me(e){return e===`allow`||e===`deny`?e:`ask`}var he=O();function ge(e){let t=!!h(e=>e.token),[n,r]=(0,F.useReducer)(he,{form:null,baseline:null}),i=n.form,a=n.baseline,o=(0,F.useRef)(!1),s=(0,F.useRef)(i);s.current=i;let c=(0,F.useRef)(null),{data:l,error:u,isLoading:d,mutate:f}=y(t);D({enabled:t,parsed:(0,F.useMemo)(()=>l?.payload?.config===void 0?null:ue(l.payload.config),[l]),dirty:o.current,trackedParsedRef:c,dispatch:r,onResetDirty:()=>{o.current=!1}});let p=!!(t&&d&&l===void 0&&!u),m=u instanceof Error?u.message:u?String(u):null,g=(0,F.useMemo)(()=>!i||!a?!1:JSON.stringify(i)!==JSON.stringify(a),[i,a]),_=(0,F.useCallback)(e=>{o.current=!0,r({type:`patch`,patch:e})},[]),v=te({value:i,dirty:g,onSave:(0,F.useCallback)(async t=>{try{await pe(t),r({type:`saved`,value:t}),o.current=!!(s.current&&JSON.stringify(s.current)!==JSON.stringify(t))}catch(t){throw Error(t instanceof Error?t.message:e.saveError)}},[e.saveError]),validate:fe});return{hasToken:t,loading:p,fetchError:m,form:i,update:_,autosaveStatus:v.status,error:v.error,onBlurCapture:v.onBlurCapture,mutate:f}}var _e=[`extension`,`playwright`,`cdp`,`remote`];function ve(){let e=(0,I.c)(30),t=p(ye),n;e[0]===t?n=e[1]:(n=u(t),e[0]=t,e[1]=n);let r=ge(n.agentSettings),o=r.form,s=t===`zh`,[c]=i(),l=(0,F.useRef)(!1),d;e[2]!==o||e[3]!==c||e[4]!==r?(d=()=>{if(!o||l.current)return;l.current=!0;let e=c.get(`driver`);_e.includes(e)&&e!==o.driverKind&&r.update({driverKind:e})},e[2]=o,e[3]=c,e[4]=r,e[5]=d):d=e[5];let f;e[6]!==o||e[7]!==c||e[8]!==r.update?(f=[o,c,r.update],e[6]=o,e[7]=c,e[8]=r.update,e[9]=f):f=e[9],(0,F.useEffect)(d,f);let m=s?`Chrome 扩展(推荐)`:`Chrome extension (recommended)`,h;e[10]===m?h=e[11]:(h={value:`extension`,label:m},e[10]=m,e[11]=h);let g;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(g={value:`playwright`,label:`Playwright Chromium`},e[12]=g):g=e[12];let _=s?`CDP 已有浏览器`:`Existing browser over CDP`,v;e[13]===_?v=e[14]:(v={value:`cdp`,label:_},e[13]=_,e[14]=v);let y=s?`远程浏览器`:`Remote browser`,b;e[15]===y?b=e[16]:(b={value:`remote`,label:y},e[15]=y,e[16]=b);let x;e[17]!==h||e[18]!==v||e[19]!==b?(x=[h,g,v,b],e[17]=h,e[18]=v,e[19]=b,e[20]=x):x=e[20];let S=x,ee=s?`让 Agent 读取网页结构并可靠地点击、输入和切换标签页;仅在语义信息不足时使用截图。`:`Let the agent read page structure and reliably click, type, and switch tabs. Screenshots are used only when semantic data is insufficient.`,E;e[21]!==S||e[22]!==o||e[23]!==r||e[24]!==s?(E=o?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(G,{enabled:o.enabled,driverKind:o.driverKind,autosaveStatus:r.autosaveStatus,zh:s}),(0,U.jsxs)(xe,{title:s?`运行方式`:`Connection`,description:s?`选择 Agent 在哪里操作浏览器。配置会自动保存,状态卡会验证实际连接。`:`Choose where the agent operates the browser. Settings save automatically; the readiness card verifies the real connection.`,icon:(0,U.jsx)(A,{className:`size-4`}),children:[(0,U.jsx)(Se,{label:s?`启用浏览器控制`:`Enable browser control`,description:s?`启用后向 Agent 提供 browser_use 工具。`:`Makes the browser_use tool available to the agent.`,checked:o.enabled,onChange:e=>r.update({enabled:e})}),(0,U.jsx)(Z,{label:s?`浏览器连接`:`Browser connection`,children:(0,U.jsx)(a,{value:o.driverKind,options:S,placeholder:s?`选择连接方式`:`Choose a connection`,allowEmpty:!1,onChange:e=>r.update({driverKind:e})})}),(0,U.jsx)(be,{kind:o.driverKind,zh:s}),o.driverKind===`playwright`?(0,U.jsxs)(`div`,{className:`space-y-4 rounded-lg bg-surface-subtle p-4`,children:[(0,U.jsx)(Se,{label:s?`无头模式`:`Headless mode`,description:s?`后台运行,不显示浏览器窗口。关闭后可观察 Agent 的操作过程。`:`Run in the background without a visible window. Turn off to watch the agent work.`,checked:o.headless,onChange:e=>r.update({headless:e})}),(0,U.jsx)(Q,{label:s?`Chromium 可执行文件(可选)`:`Chromium executable (optional)`,description:s?`留空时使用由 xopc 安装的 Chromium。`:`Leave empty to use Chromium installed by xopc.`,value:o.executablePath,onChange:e=>r.update({executablePath:e})})]}):null,o.driverKind===`cdp`?(0,U.jsx)(`div`,{className:`rounded-lg bg-surface-subtle p-4`,children:(0,U.jsx)(Q,{label:`CDP endpoint`,description:s?`例如 http://127.0.0.1:9222。Chrome 需要开启 remote debugging。`:`For example http://127.0.0.1:9222. Chrome must be started with remote debugging enabled.`,value:o.cdpEndpoint,onChange:e=>r.update({cdpEndpoint:e})})}):null,o.driverKind===`remote`?(0,U.jsxs)(`div`,{className:`space-y-4 rounded-lg bg-surface-subtle p-4`,children:[(0,U.jsx)(Z,{label:s?`服务商`:`Provider`,children:(0,U.jsx)(a,{value:o.remoteProvider,options:[{value:`browserbase`,label:`Browserbase`},{value:`browser-use`,label:`Browser Use`}],placeholder:s?`选择服务商`:`Choose a provider`,allowEmpty:!1,onChange:e=>r.update({remoteProvider:e})})}),(0,U.jsx)(Q,{label:`API key`,type:`password`,autoComplete:`off`,value:o.remoteApiKey,onChange:e=>r.update({remoteApiKey:e})}),(0,U.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,U.jsx)(Q,{label:`Project ID`,value:o.remoteProjectId,onChange:e=>r.update({remoteProjectId:e})}),(0,U.jsx)(Q,{label:`Region`,value:o.remoteRegion,onChange:e=>r.update({remoteRegion:e})})]})]}):null]}),(0,U.jsxs)(xe,{title:s?`页面理解与 Token`:`Page understanding and tokens`,description:s?`默认发送可交互元素和正文摘要,比整页截图更省 Token;视觉回退只处理语义无法覆盖的页面。`:`By default the model receives interactive elements and a text summary, which costs fewer tokens than full-page screenshots. Visual fallback covers pages that semantics cannot.`,icon:(0,U.jsx)(w,{className:`size-4`}),children:[(0,U.jsx)(Se,{label:s?`语义信息不足时附加截图`:`Attach a screenshot when semantics are insufficient`,description:s?`推荐开启。正常网页不会每一步都发送截图。`:`Recommended. Normal pages do not send a screenshot on every step.`,checked:o.visualFallback,onChange:e=>r.update({visualFallback:e})}),(0,U.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,U.jsx)($,{label:s?`最大语义节点`:`Maximum semantic nodes`,description:`20–500`,min:20,max:500,value:o.maxNodes,onChange:e=>r.update({maxNodes:e})}),(0,U.jsx)($,{label:s?`最大文本字符`:`Maximum text characters`,description:`1,000–50,000`,min:1e3,max:5e4,step:1e3,value:o.maxCharacters,onChange:e=>r.update({maxCharacters:e})})]})]}),(0,U.jsx)(xe,{title:s?`执行限制`:`Execution limits`,description:s?`限制单次操作、浏览器会话和批量步骤,避免页面卡住时无限等待。`:`Bound individual actions, browser sessions, and action sequences so a stuck page cannot wait indefinitely.`,icon:(0,U.jsx)(T,{className:`size-4`}),children:(0,U.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,U.jsx)($,{label:s?`操作超时(毫秒)`:`Action timeout (ms)`,min:1e3,max:12e4,step:1e3,value:o.actionTimeoutMs,onChange:e=>r.update({actionTimeoutMs:e})}),(0,U.jsx)($,{label:s?`会话超时(毫秒)`:`Session timeout (ms)`,min:6e4,max:36e5,step:6e4,value:o.sessionTimeoutMs,onChange:e=>r.update({sessionTimeoutMs:e})}),(0,U.jsx)($,{label:s?`批量步骤上限`:`Sequence step limit`,min:1,max:10,value:o.maxSequenceLength,onChange:e=>r.update({maxSequenceLength:e})})]})}),(0,U.jsxs)(xe,{title:s?`安全与审批`:`Safety and approvals`,description:s?`私网访问始终拒绝,只有下面明确列出的主机例外。敏感动作可逐次询问、允许或拒绝。`:`Private-network access is always denied except for exact hosts listed below. Sensitive actions can ask each time, be allowed, or be denied.`,icon:(0,U.jsx)(C,{className:`size-4`}),children:[(0,U.jsx)(Q,{label:s?`允许访问的私网主机`:`Allowed private hosts`,description:s?`每行一个精确的小写主机名或 IP,不支持通配符。`:`One exact lowercase hostname or IP per line. Wildcards are not supported.`,multiline:!0,value:o.allowedPrivateHosts,onChange:e=>r.update({allowedPrivateHosts:e})}),(0,U.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,U.jsx)(Ce,{zh:s,label:s?`跨域导航`:`Cross-domain navigation`,value:o.crossDomainNavigation,onChange:e=>r.update({crossDomainNavigation:e})}),(0,U.jsx)(Ce,{zh:s,label:s?`高影响动作`:`Consequential actions`,value:o.consequentialActions,onChange:e=>r.update({consequentialActions:e})}),(0,U.jsx)(Ce,{zh:s,label:s?`文件上传`:`File uploads`,value:o.uploads,onChange:e=>r.update({uploads:e})})]})]})]}):null,e[21]=S,e[22]=o,e[23]=r,e[24]=s,e[25]=E):E=e[25];let D;return e[26]!==ee||e[27]!==E||e[28]!==r?(D=(0,U.jsx)(ce,{sectionId:`agent-browser`,intro:ee,vm:r,children:E}),e[26]=ee,e[27]=E,e[28]=r,e[29]=D):D=e[29],D}function ye(e){return e.language}function be(e){let t=(0,I.c)(7),{kind:n,zh:r}=e,i=r?`直接操作你正在使用的 Chrome,保留登录状态和现有标签页;最适合日常协作。`:`Operate your current Chrome with its signed-in state and existing tabs; best for daily collaboration.`,a=r?`由 xopc 启动独立 Chromium,环境隔离、自动化稳定,适合无人值守任务。`:`Let xopc launch an isolated Chromium; stable for unattended automation.`,o=r?`连接已开启远程调试的 Chrome 或 Chromium,适合自定义浏览器启动方式。`:`Connect to Chrome or Chromium already running with remote debugging.`,s=r?`使用 Browserbase 或 Browser Use 的云端浏览器,适合服务器环境和长任务。`:`Use a Browserbase or Browser Use cloud browser for servers and long-running tasks.`,c;t[0]!==i||t[1]!==a||t[2]!==o||t[3]!==s?(c={extension:i,playwright:a,cdp:o,remote:s},t[0]=i,t[1]=a,t[2]=o,t[3]=s,t[4]=c):c=t[4];let l=c[n],u;return t[5]===l?u=t[6]:(u=(0,U.jsx)(`p`,{className:`rounded-lg bg-surface-subtle px-3 py-2 text-xs leading-5 text-fg-muted`,children:l}),t[5]=l,t[6]=u),u}function xe(e){let t=(0,I.c)(17),{title:n,description:r,icon:i,children:a}=e,o;t[0]===i?o=t[1]:(o=(0,U.jsx)(`span`,{className:`mt-0.5 text-fg-subtle`,children:i}),t[0]=i,t[1]=o);let s;t[2]===n?s=t[3]:(s=(0,U.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n}),t[2]=n,t[3]=s);let c;t[4]===r?c=t[5]:(c=r?(0,U.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:r}):null,t[4]=r,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,U.jsxs)(`div`,{children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]!==o||t[10]!==l?(u=(0,U.jsxs)(`div`,{className:`mb-4 flex items-start gap-2`,children:[o,l]}),t[9]=o,t[10]=l,t[11]=u):u=t[11];let d;t[12]===a?d=t[13]:(d=(0,U.jsx)(`div`,{className:`space-y-4`,children:a}),t[12]=a,t[13]=d);let f;return t[14]!==u||t[15]!==d?(f=(0,U.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-5`,children:[u,d]}),t[14]=u,t[15]=d,t[16]=f):f=t[16],f}function Z(e){let t=(0,I.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,U.jsx)(`span`,{className:`mb-1.5 block font-medium`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=r?(0,U.jsx)(`span`,{className:`mt-1.5 block text-xs leading-5 text-fg-subtle`,children:r}):null,t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,U.jsxs)(`label`,{className:`block text-sm text-fg`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Q(e){let t=(0,I.c)(10),{label:n,description:r,value:i,onChange:a,type:o,multiline:s,autoComplete:c}=e,l=o===void 0?`text`:o,u=s===void 0?!1:s,d;t[0]!==c||t[1]!==u||t[2]!==a||t[3]!==l||t[4]!==i?(d=u?(0,U.jsx)(`textarea`,{rows:3,value:i,onChange:e=>a(e.target.value),className:`w-full rounded-lg border border-edge bg-surface-subtle px-3 py-2 text-sm text-fg outline-none focus:border-accent`}):(0,U.jsx)(`input`,{type:l,autoComplete:c,value:i,onChange:e=>a(e.target.value),className:`w-full rounded-lg border border-edge bg-surface-subtle px-3 py-2 text-sm text-fg outline-none focus:border-accent`}),t[0]=c,t[1]=u,t[2]=a,t[3]=l,t[4]=i,t[5]=d):d=t[5];let f;return t[6]!==r||t[7]!==n||t[8]!==d?(f=(0,U.jsx)(Z,{label:n,description:r,children:d}),t[6]=r,t[7]=n,t[8]=d,t[9]=f):f=t[9],f}function $(e){let t=(0,I.c)(12),{label:n,description:r,value:i,onChange:a,min:o,max:s,step:c}=e,l=c===void 0?1:c,u;t[0]===a?u=t[1]:(u=e=>{let t=Number(e.target.value);Number.isFinite(t)&&a(t)},t[0]=a,t[1]=u);let d;t[2]!==s||t[3]!==o||t[4]!==l||t[5]!==u||t[6]!==i?(d=(0,U.jsx)(`input`,{type:`number`,min:o,max:s,step:l,value:i,onChange:u,className:`h-10 w-full rounded-lg border border-edge bg-surface-subtle px-3 text-sm text-fg outline-none focus:border-accent`}),t[2]=s,t[3]=o,t[4]=l,t[5]=u,t[6]=i,t[7]=d):d=t[7];let f;return t[8]!==r||t[9]!==n||t[10]!==d?(f=(0,U.jsx)(Z,{label:n,description:r,children:d}),t[8]=r,t[9]=n,t[10]=d,t[11]=f):f=t[11],f}function Se(e){let t=(0,I.c)(15),{label:n,description:r,checked:i,onChange:a}=e,o;t[0]===a?o=t[1]:(o=e=>a(e.target.checked),t[0]=a,t[1]=o);let s;t[2]!==i||t[3]!==o?(s=(0,U.jsx)(`input`,{type:`checkbox`,checked:i,onChange:o,className:`mt-0.5 size-4 accent-accent`}),t[2]=i,t[3]=o,t[4]=s):s=t[4];let c;t[5]===n?c=t[6]:(c=(0,U.jsx)(`span`,{className:`block font-medium`,children:n}),t[5]=n,t[6]=c);let l;t[7]===r?l=t[8]:(l=r?(0,U.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-subtle`,children:r}):null,t[7]=r,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,U.jsxs)(`span`,{children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;return t[12]!==s||t[13]!==u?(d=(0,U.jsxs)(`label`,{className:`flex items-start gap-3 text-sm text-fg`,children:[s,u]}),t[12]=s,t[13]=u,t[14]=d):d=t[14],d}function Ce(e){let t=(0,I.c)(20),{zh:n,label:r,value:i,onChange:o}=e,s=n?`每次询问`:`Ask each time`,c;t[0]===s?c=t[1]:(c={value:`ask`,label:s},t[0]=s,t[1]=c);let l=n?`允许`:`Allow`,u;t[2]===l?u=t[3]:(u={value:`allow`,label:l},t[2]=l,t[3]=u);let d=n?`拒绝`:`Deny`,f;t[4]===d?f=t[5]:(f={value:`deny`,label:d},t[4]=d,t[5]=f);let p;t[6]!==c||t[7]!==u||t[8]!==f?(p=[c,u,f],t[6]=c,t[7]=u,t[8]=f,t[9]=p):p=t[9];let m=p,h=n?`选择策略`:`Choose a policy`,g;t[10]===o?g=t[11]:(g=e=>o(e),t[10]=o,t[11]=g);let _;t[12]!==m||t[13]!==h||t[14]!==g||t[15]!==i?(_=(0,U.jsx)(a,{value:i,options:m,placeholder:h,allowEmpty:!1,onChange:g}),t[12]=m,t[13]=h,t[14]=g,t[15]=i,t[16]=_):_=t[16];let v;return t[17]!==r||t[18]!==_?(v=(0,U.jsx)(Z,{label:r,children:_}),t[17]=r,t[18]=_,t[19]=v):v=t[19],v}export{ve as AgentBrowserSettingsPage};
|