@xopcai/xopc 0.0.404 → 0.0.406
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-CdwFK70g.js → agent-avatar-dicebear-BE3ci_lj.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-BMj9HwIQ.js → agent-defaults-settings-panel-DzDaum4Y.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-hrm6V8Dp.js → agents-BfC3FYYe.js} +3 -3
- package/dist/gateway/static/root/assets/{app-management-settings-panel-Rg9jOmoj.js → app-management-settings-panel-BDbJKxa-.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-S3yp0GUO.js → appearance-settings-CEOOrVYb.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-ChrJSB_2.js → apps-page-CpoG_3PG.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-J7hwA5cs.js → archive-plugin-B7pzPErg.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-Cesz1cjw.js → automations-page-CcQjEiqk.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-DdopDyED.js → automations-workspace-BVTP3pzt.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-Bg4Se8Kg.js → binary-plugins-D5kTu6gH.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-Bw1sO9YH.js → block-editor-CnW6rF_e.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automation-inputs-Y46Mf8aY.js → browser-automation-inputs-CAcUtInP.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-BcNjBdFQ.js → browser-automations-page-DT7-lnPN.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-ByeqxrSF.js → browser-settings-page-ByK8znt2.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-CIv3LUQk.js → capabilities-Dl3LttAm.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-page-BUTQSo3A.js → capabilities-page-C8tv6M_O.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-B-Uwmjbo.js → capabilities-settings-panel-OVLgL6yL.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-header-actions-BGGJKzPL.js → capability-header-actions-jztljvVW.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-z6iuM4HE.js → channels-D8BKMMPW.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-oMmP0flJ.js → chat-terminal-dock-BVlFOKJj.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-CERhSG5W.js → computer-settings-page-CvQgrTwb.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-DyW3mLTh.js → connector-service-page-BNcTUa99.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-CdMwhiio.js → connectors-page-CWlLRQpK.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-CO3Jhdzg.js → date-picker-BKUmdSp7.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-DbyMpo5J.js → dependency-picker-BarQvwoO.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-DJ9OAPJs.js → desktop-pet-IvADYxyi.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-CNrNXWlk.js → desktop-pet-settings-y6WzhGEK.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-TzK-VCuf.js → device-pairing-wizard-D3IUZ8xW.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-BmFgRA8G.js → directory-picker-path-field-DnEvwMTm.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-C3ZpHHYc.js → extension-debug-page-CCvuK1m0.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-gfOwpT2R.js → extension-page-DegRwY3R.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-BS7cDqZJ.js → extension-settings-page-B8UQgGgZ.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-UB6hyqcj.js → gateway-settings-DlLyLsXY.js} +1 -1
- package/dist/gateway/static/root/assets/{highlighted-body-KQOG7T2V-BRfDRn2k.js → highlighted-body-KQOG7T2V-MjAoJQJX.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-DBUnR1DO.js → home-page-DAYtNK3o.js} +1 -1
- package/dist/gateway/static/root/assets/{image-generation-api-BoMWmqwF.js → image-generation-api-SQDixWjO.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-CPiPsiEP.js → imports-page-1ZId0Ng0.js} +1 -1
- package/dist/gateway/static/root/assets/{index-DmURUvvA.js → index-K2cy4f-3.js} +116 -116
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-D9y8h4dR.js → keyboard-shortcuts-settings-yMwBt1Sv.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-DoAmV6on.js → local-app-workbench-page-a7J0NPIs.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-CE6Ag8oQ.js → local-apps-page-CF6_kS9C.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-DFysUb2k.js → logs-page-C8y5yhoM.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-CmXPsu0I.js → management-settings-C7dL_jNu.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-DvfdiczR.js → media-plugins-UYX1YivF.js} +1 -1
- package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-7zpLTDLZ.js +1 -0
- package/dist/gateway/static/root/assets/{note-detail-panel-BpddDFQt.js → note-detail-panel-Bxm523Up.js} +3 -3
- package/dist/gateway/static/root/assets/note-image-lightbox-B7ARnjnB.js +1 -0
- package/dist/gateway/static/root/assets/{notes-page-DQ4KZsWt.js → notes-page-BOeS2v6x.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-BcxVEGa2.js → page-context-capture-button-DOrPS73o.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-page-CCQDxb7E.js → personal-page-BujiHops.js} +1 -1
- package/dist/gateway/static/root/assets/{plugin-details-dialog-CGFQ_-bG.js → plugin-details-dialog-XOzQrJQN.js} +1 -1
- package/dist/gateway/static/root/assets/{plugin-presentation-DF1gfuGf.js → plugin-presentation-CPEwVLd4.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-CXjjpXVx.js → preview-open-alternatives-BP9C0kH3.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-DqiyvM4c.js → product-open-page-D151rJVy.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-content-f7Q4giA3.js → product-preview-content-CAo0XpP-.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-CxB_kF0F.js +1 -0
- package/dist/gateway/static/root/assets/{projects-page-DO_pIhy-.js → projects-page-Dvu_3c2g.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-BFtELmg0.js → remote-access-hub-CbzBV_BL.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-B9Beu-oK.js → runtime-tools-settings-panel-DyLxlqWV.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-ZAX7C5uI.js → schema-form-ClP4uPSj.js} +1 -1
- package/dist/gateway/static/root/assets/{session-manager-BUMUjup5.js → session-manager-DMDBMYfh.js} +2 -2
- package/dist/gateway/static/root/assets/{sessions-page-D27knqOl.js → sessions-page-CvfoPeM6.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BOkrHL8q.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-BTUFu5KS.js → settings-form-section-B4NShgv-.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-YFr6zzh7.js → settings-page-C54bw5J9.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-C5Jszsd1.js → setup-status-panel-BVKQ2inq.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-CsfrvY_G.js → share-preview-page-BxN9t3MD.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-BW6BNot0.js → shares-settings-BOa9NAUc.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-api-o3HSgF_K.js → skill-api-E0E-MH1S.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-BJsPnE87.js → skill-reload-api-DEN6tOwG.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-Kuf2t7MG.js → skills-page-CeNVBQG9.js} +1 -1
- package/dist/gateway/static/root/assets/{style-DOz6lLJB.js → style-Bs9x3WBj.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-B69rR6vw.js → system-settings-panel-DpQPaJId.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-DzK53B5p.js +2 -0
- package/dist/gateway/static/root/assets/{task-expandable-content-BZCJqajv.js → task-expandable-content-BoGtWYbk.js} +1 -1
- package/dist/gateway/static/root/assets/{tasks-PuIUgF9L.js → tasks-B4bZpO6O.js} +1 -1
- package/dist/gateway/static/root/assets/{tracing-settings-page-BIq3Ayeg.js → tracing-settings-page-BUUnZfZW.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-V9pJ8fUo.js → tunnel-api-3GopOQ_S.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-DZdpti28.js → usage-page-B8j47CWQ.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-BnMIUc_5.js → use-autosave-CYIuWnRn.js} +1 -1
- package/dist/gateway/static/root/assets/{user-model-page-BEgJ97hp.js → user-model-page-DxcH74eP.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-1h6fMaZL.js → voice-api-key-field-BN37Lklj.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-CVNqSNz8.js → work-discovery-overlay-C_bcAAX6.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Dq63AthQ.js → workflow-run-setup-panel-B5oKCzTn.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-CfA1iwZu.js → workflows-page-Bo5b5t_9.js} +1 -1
- package/dist/gateway/static/root/assets/{xopc-cloud-account-card-BsW2acj1.js → xopc-cloud-account-card-DGGi4zVC.js} +1 -1
- package/dist/gateway/static/root/index.html +4 -4
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/tasks.js +27 -8
- package/dist/src/agent/agent-manager.js +1 -1
- package/dist/src/agent/background-review/run-background-review.js +1 -1
- package/dist/src/agent/external-tools/cliProvider.js +2 -2
- package/dist/src/agent/external-tools/composio-provider.js +2 -2
- package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
- package/dist/src/agent/service.js +1 -1
- package/dist/src/agent/skills/index.js +1 -1
- package/dist/src/agent/skills/managed-store.js +1 -1
- package/dist/src/agent/skills/skill-manage-ops.js +1 -1
- package/dist/src/agent/tools/personal-read-tool.js +1 -1
- package/dist/src/agent/tools/xopc-use-tool.js +2 -2
- package/dist/src/agent-catalog/capabilities.js +2 -2
- package/dist/src/agent-catalog/migrations/legacy-config-cutover.js +1 -1
- package/dist/src/agent-catalog/repository.js +1 -1
- package/dist/src/automations/capabilities/drafts.js +1 -1
- package/dist/src/automations/capabilities/write.d.ts +14 -0
- package/dist/src/automations/domain/validation.d.ts +28 -0
- package/dist/src/automations/draft/automation-draft-validator.d.ts +2 -1
- package/dist/src/bootstrap/application-state.js +1 -1
- package/dist/src/browser/providers/browser-ext-install.js +1 -1
- package/dist/src/capabilities/runtime/dispatcher.js +1 -1
- package/dist/src/capabilities/runtime/product.js +1 -1
- package/dist/src/cli/commands/agents.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +2 -2
- package/dist/src/cli/commands/extension.js +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/onboard/model.js +1 -1
- package/dist/src/cli/commands/onboard.js +1 -1
- package/dist/src/cli/utils/init-workspace-core.js +1 -1
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/execution-environments/local-worktree-manager.js +1 -1
- package/dist/src/extensions/agent-plugins/skill-catalog.js +1 -1
- package/dist/src/extensions/agent-plugins/validation.js +1 -1
- package/dist/src/extensions/update.js +1 -1
- package/dist/src/gateway/agents-admin.js +2 -2
- package/dist/src/gateway/hono/routes/agents.js +1 -1
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
- package/dist/src/gateway/hono/routes/config.js +1 -1
- package/dist/src/gateway/hono/routes/notes.js +2 -2
- package/dist/src/gateway/hono/routes/projects.js +2 -2
- package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
- package/dist/src/gateway/hono/routes/tasks.js +3 -2
- package/dist/src/gateway/image-generation-setup.js +1 -1
- package/dist/src/gateway/service/config-coordinator.js +1 -1
- package/dist/src/gateway/service/run-gateway-agent.js +1 -0
- package/dist/src/gateway/service.js +6 -6
- package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
- package/dist/src/home-intelligence/host.js +2 -2
- package/dist/src/imports/importService.js +1 -1
- package/dist/src/infra/update-runner.js +1 -1
- package/dist/src/local-apps/service.js +1 -1
- package/dist/src/personal-agent/service.js +1 -1
- package/dist/src/providers/prompt-cache-lifecycle.d.ts +1 -1
- package/dist/src/providers/prompt-cache-lifecycle.js +1 -1
- package/dist/src/runtime-tools/archive.js +1 -1
- package/dist/src/storage/sqlite/migrations/258_task_phase_changes.sql +20 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/tasks/capabilities/read.js +3 -2
- package/dist/src/tasks/capabilities/write.js +3 -3
- package/dist/src/tasks/task-application-service.d.ts +2 -1
- package/dist/src/tasks/task-application-service.js +80 -12
- package/dist/src/tasks/task-collaboration-delivery.js +2 -1
- package/dist/src/tasks/task-context-assembler.js +2 -1
- package/dist/src/tasks/task-read-model-projector.js +13 -5
- package/dist/src/tasks/task-repository.d.ts +11 -1
- package/dist/src/tasks/task-repository.js +42 -7
- package/dist/src/tasks/task-run-coordinator.d.ts +2 -0
- package/dist/src/tasks/task-run-coordinator.js +26 -17
- package/dist/src/tasks/task-run-repository.js +5 -2
- package/dist/src/tui/backends/embedded-backend.js +1 -1
- package/dist/src/voice/realtime/persona-context.js +1 -1
- package/package.json +4 -4
- package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-SuiLTd5Y.js +0 -1
- package/dist/gateway/static/root/assets/note-image-lightbox-CMLVzPsQ.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-PBK7vXK5.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-CDzdr1zW.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-DOb97OLI.js +0 -2
package/dist/gateway/static/root/assets/{personal-page-CCQDxb7E.js → personal-page-BujiHops.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./check-DUBLcKHA.js";import{F as o}from"./markdown-view-CthsQiiO.js";import{t as s}from"./x-B_N4OPjy.js";import{t as c}from"./messages-Bwv-AOYl.js";import{a as l,n as u,r as d}from"./locale-store-D5h-Ha6-.js";import{T as f,d as p,ot as m,t as h}from"./session-manager-BUMUjup5.js";import{Af as g,Ao as _,Cs as v,Cu as y,Ds as b,Es as x,Go as S,Hs as C,J as w,Mi as T,Mo as E,Of as D,Qi as O,Rc as k,Ro as A,Ts as j,Wl as M,Y as N,Zu as P,ac as ee,et as te,kf as ne,kl as re,n as ie,nu as ae,qs as oe,rc as F,us as I,ws as L,xs as se,yu as R}from"./index-DmURUvvA.js";import{l as z,n as ce,t as le}from"./voice-config-api-CRjdZdJF.js";var B=n(),V=e(t(),1),H=r();function ue(){try{return[`UTC`,...Intl.supportedValuesOf(`timeZone`)]}catch{return[`UTC`,`Asia/Shanghai`,`Asia/Hong_Kong`,`Asia/Taipei`,`Asia/Tokyo`,`Asia/Seoul`,`Asia/Singapore`,`Asia/Kolkata`,`Asia/Dubai`,`Europe/London`,`Europe/Paris`,`Europe/Berlin`,`America/New_York`,`America/Chicago`,`America/Denver`,`America/Los_Angeles`,`Australia/Sydney`,`Pacific/Auckland`]}}var de=ue();function fe({zh:e}){let[t,n]=(0,V.useState)(),[r,i]=(0,V.useState)(``),[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(``),u=s.trim().toLowerCase().replaceAll(`_`,` `),f=[...new Set([...de,t?.timezone].filter(e=>!!e))].sort().filter(e=>e.replaceAll(`_`,` `).toLowerCase().includes(u)).map(e=>({value:e,label:e.replaceAll(`_`,` `),group:e.split(`/`)[0]}));(0,V.useEffect)(()=>{let e=!0;return l(d(`/api/personal-agent/proactivity`)).then(t=>{e&&t.ok&&n(m.parse(t.payload))}).catch(t=>{e&&i(String(t))}),()=>{e=!1}},[]);async function p(e){if(!(!t||a)){o(!0),i(``);try{let r=await l(d(`/api/personal-agent/proactivity`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t,...e})});r.ok&&n(m.parse(r.payload))}catch(e){i(String(e));let t=await l(d(`/api/personal-agent/proactivity`)).catch(()=>null);t?.ok&&n(m.parse(t.payload))}finally{o(!1)}}}return(0,H.jsxs)(`section`,{className:`space-y-3 border-t border-edge pt-5`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:e?`主动联系`:`Proactive messages`}),!t&&!r?(0,H.jsx)(k,{className:`h-9 w-full`}):t&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(I,{placeholder:e?`选择主动方式`:`Choose participation`,value:t.mode,disabled:a,allowEmpty:!1,options:[{value:`off`,label:e?`关闭主动联系`:`Off`},{value:`follow_up`,label:e?`仅明确跟进`:`Requested follow-ups`},{value:`balanced`,label:e?`适度主动`:`Thoughtful participation`}],onChange:e=>void p({mode:e})}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,H.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[e?`静默开始`:`Quiet from`,(0,H.jsx)(I,{placeholder:e?`选择时间`:`Choose time`,value:String(t.quietStart),disabled:a,allowEmpty:!1,options:Array.from({length:24},(e,t)=>({value:String(t),label:`${String(t).padStart(2,`0`)}:00`})),onChange:e=>void p({quietStart:Number(e)})})]}),(0,H.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[e?`静默结束`:`Quiet until`,(0,H.jsx)(I,{placeholder:e?`选择时间`:`Choose time`,value:String(t.quietEnd),disabled:a,allowEmpty:!1,options:Array.from({length:24},(e,t)=>({value:String(t),label:`${String(t).padStart(2,`0`)}:00`})),onChange:e=>void p({quietEnd:Number(e)})})]})]}),(0,H.jsxs)(`label`,{className:`block text-xs text-fg-muted`,children:[e?`时区`:`Timezone`,(0,H.jsx)(I,{placeholder:e?`选择时区`:`Choose timezone`,ariaLabel:e?`时区`:`Timezone`,value:t.timezone,selectedLabel:t.timezone.replaceAll(`_`,` `),options:f,disabled:a,allowEmpty:!1,triggerClassName:`mt-1`,searchPlaceholder:e?`搜索时区或城市`:`Search timezone or city`,searchValue:s,onSearchChange:c,statusMessage:f.length?void 0:e?`没有匹配的时区`:`No matching timezones`,onChange:e=>{c(``),e!==t.timezone&&p({timezone:e})}})]}),(0,H.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e?`有值得交流的进展时,在聊天里留下消息。明确请求的结果会照常交付。`:`Useful developments appear in this chat. Requested results are delivered as usual.`})]}),r&&(0,H.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r})]})}var U=[`intro`,`identity`,`voice`,`connections`],pe=[{id:`loopi`,zh:`Loopi`,en:`Loopi`},{id:`loopi-curious`,zh:`好奇`,en:`Curious`},{id:`loopi-care`,zh:`温和`,en:`Gentle`}];function me(e){return!!(e?.enabled&&(e.status===`connected`||e.connectionStatus===`connected`||e.authStatus===`connected`))}async function he(e,t){let n=await new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(t)});await l(d(`/api/agents/${encodeURIComponent(e)}/avatar`),{method:`PUT`,body:JSON.stringify({base64:n.slice(n.indexOf(`,`)+1),mimeType:t.type})}),A(e)}function ge({modelsAvailable:e,onCreated:t}){let n=u(e=>e.language)===`zh`,r=u(e=>e.language),[o,s]=(0,V.useState)(`intro`),[f,p]=(0,V.useState)({displayName:`Ada`,appearance:`loopi`,voice:null}),[m,h]=(0,V.useState)(!1),[_,v]=(0,V.useState)(!1),[y,b]=(0,V.useState)(null),[x,S]=(0,V.useState)(null),[C,T]=(0,V.useState)(null),[D,O]=(0,V.useState)(null),[A,j]=(0,V.useState)(!0),[M,P]=(0,V.useState)([]),[ie,ae]=(0,V.useState)(null),I=(0,V.useRef)(null),L=(0,V.useRef)(null),[se,B]=(0,V.useState)([]),[ue,de]=(0,V.useState)(!0),[fe,ge]=(0,V.useState)([]),[_e,W]=(0,V.useState)(null);(0,V.useEffect)(()=>{let e=!1;return l(d(`/api/personal-agent/onboarding`)).then(t=>{e||(s(t.payload.step),p(t.payload.draft))}).catch(t=>{e||b(t instanceof Error?t.message:String(t))}).finally(()=>{e||h(!0)}),()=>{e=!0}},[]),(0,V.useEffect)(()=>{if(!m)return;let e=window.setTimeout(()=>{l(d(`/api/personal-agent/onboarding`),{method:`PUT`,body:JSON.stringify({step:o,draft:f})}).catch(()=>{})},350);return()=>window.clearTimeout(e)},[f,m,o]),(0,V.useEffect)(()=>{let e=!1;return le().then(t=>{e||(t.tts&&t.enabled?O({provider:t.tts.provider,model:t.tts.model,enabled:!0}):j(!1))}).catch(()=>{e||j(!1)}),()=>{e=!0}},[]),(0,V.useEffect)(()=>{if(!D?.enabled)return;let e=!1;return ce(D.provider,D.model,`realtime`).then(t=>{e||P(t.slice(0,12))}).catch(()=>{}).finally(()=>{e||j(!1)}),()=>{e=!0}},[D]),(0,V.useEffect)(()=>{if(o!==`connections`)return;let e=!1;return de(!0),Promise.allSettled([F({page:1,pageSize:24,verification:`verified`}),ee()]).then(([t,n])=>{if(!e){if(t.status===`fulfilled`){let e=[`gmail`,`googlecalendar`,`googledrive`,`github`,`linear`];B(t.value.connectors.filter(t=>t.runtime.type===`composio`&&e.includes(t.runtime.toolkit)).sort((t,n)=>e.indexOf(t.runtime.type===`composio`?t.runtime.toolkit:``)-e.indexOf(n.runtime.type===`composio`?n.runtime.toolkit:``)))}n.status===`fulfilled`&&ge(n.value),de(!1)}}),()=>{e=!0}},[o]),(0,V.useEffect)(()=>()=>{L.current?.abort(),I.current?.close()},[]),(0,V.useEffect)(()=>()=>{C&&URL.revokeObjectURL(C)},[C]);let ve=async(e,t=f)=>{await l(d(`/api/personal-agent/onboarding`),{method:`PUT`,body:JSON.stringify({step:e,draft:t})}),s(e)},G=async e=>{b(null);let t=U[Math.max(0,Math.min(U.length-1,U.indexOf(o)+e))];try{await ve(t)}catch(e){b(e instanceof Error?e.message:String(e))}},ye=async(n=!1)=>{if(!(!e||_)){v(!0),b(null);try{let e=n?{displayName:`Ada`,appearance:`loopi`,voice:null}:f,r=e.voice&&D?.enabled&&M.some(t=>t.id===e.voice)?{provider:D.provider,model:D.model,voice:e.voice}:void 0,i=(await l(d(`/api/personal-agent`),{method:`POST`,body:JSON.stringify({displayName:e.displayName.trim()||`Ada`,appearance:e.appearance,...r?{voicePreference:r}:{}})})).payload,a=!1;if(!n&&x)try{await he(i.agentId,x),i=(await l(d(`/api/personal-agent/profile`),{method:`PATCH`,body:JSON.stringify({revision:i.revision,displayName:i.displayName,appearance:`custom`,preferences:i.preferences})})).payload}catch{a=!0}t(i,a)}catch(e){b(e instanceof Error?e.message:String(e))}finally{v(!1)}}},be=(0,V.useCallback)(async e=>{L.current?.abort(),I.current?.close();let t=new AbortController;L.current=t,ae(e),b(null);try{let n=new oe;I.current=n,await n.start();let r=await z(t.signal,e);if(t.signal.aborted)return;n.enqueue(r,()=>ae(null))}catch(e){t.signal.aborted||b(e instanceof Error?e.message:String(e)),ae(null)}},[]);if(!m)return(0,H.jsxs)(`div`,{className:`mx-auto w-full max-w-xl space-y-4 px-6 py-14`,children:[(0,H.jsx)(k,{className:`h-10 w-2/3`}),(0,H.jsx)(k,{className:`h-64 w-full rounded-2xl`}),(0,H.jsx)(k,{className:`h-12 w-full rounded-xl`})]});let K=U.indexOf(o),xe={intro:n?`创建一个和你一起做事的助手`:`Create an assistant to work with you`,identity:n?`先给它一个形象和名字`:`Choose a look and a name`,voice:n?`想让我用什么声音回应?`:`How should your assistant sound?`,connections:n?`要让我了解哪些信息?`:`What information can your assistant use?`}[o];return(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-surface-base`,children:[(0,H.jsx)(`header`,{className:`shrink-0 px-5 pt-5 sm:px-8 sm:pt-7`,children:(0,H.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl`,children:[(0,H.jsxs)(`div`,{className:`flex min-h-10 items-center justify-between gap-4`,children:[K>0?(0,H.jsxs)(`button`,{type:`button`,disabled:_,onClick:()=>void G(-1),className:`-ml-2 inline-flex min-h-10 items-center gap-1.5 rounded-lg px-2 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-40`,children:[(0,H.jsx)(g,{className:`size-4`}),n?`上一步`:`Back`]}):(0,H.jsx)(`span`,{className:`text-sm font-medium text-fg-muted`,children:n?`设置我的助手`:`Set up my assistant`}),(0,H.jsx)(i,{to:`/chat`,className:`-mr-2 inline-flex min-h-10 items-center rounded-lg px-2 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`稍后继续`:`Finish later`})]}),(0,H.jsx)(`div`,{className:`mt-4 grid grid-cols-4 gap-1.5`,role:`progressbar`,"aria-label":n?`设置进度`:`Setup progress`,"aria-valuenow":K+1,"aria-valuemin":1,"aria-valuemax":U.length,children:U.map((e,t)=>(0,H.jsx)(`span`,{className:`h-1 rounded-full transition-colors duration-200 ${t<=K?`bg-accent`:`bg-surface-active`}`},e))})]})}),(0,H.jsx)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-8 sm:px-8`,children:(0,H.jsxs)(`div`,{className:`mx-auto my-auto w-full max-w-2xl py-6 motion-safe:animate-[page-enter_220ms_ease-out]`,children:[(0,H.jsxs)(`div`,{className:`mb-8 flex items-center gap-4`,children:[(0,H.jsx)(`span`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl bg-surface-hover`,children:C?(0,H.jsx)(`img`,{src:C,alt:``,className:`size-14 rounded-xl object-cover`}):(0,H.jsx)(E,{appearance:f.appearance,className:`size-14`})}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`我的助手`:`My assistant`}),(0,H.jsx)(`p`,{className:`mt-1 text-lg font-semibold text-fg`,children:f.displayName||`Ada`})]})]}),(0,H.jsx)(`p`,{className:`mb-3 text-xs font-medium tracking-wide text-fg-subtle`,children:n?`第 ${K+1} 步 · 共 ${U.length} 步`:`Step ${K+1} of ${U.length}`}),(0,H.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-fg sm:text-3xl`,children:xe}),o===`intro`&&(0,H.jsxs)(`div`,{className:`mt-6 max-w-xl space-y-3 text-base leading-8 text-fg-muted`,children:[(0,H.jsx)(`p`,{children:n?`你可以找它讨论问题,也可以交给它一件要推进的事。`:`Talk through a question or give it something to move forward.`}),(0,H.jsx)(`p`,{children:n?`需要深入处理时,它会找合适的 Agent,并把进展带回对话。`:`It can ask a suitable Agent for deeper work and bring the progress back.`}),(0,H.jsx)(`p`,{children:n?`它能使用哪些数据和设备,由你决定。`:`You choose which data and devices it can use.`})]}),o===`identity`&&(0,H.jsxs)(`div`,{className:`mt-7 space-y-7`,children:[(0,H.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[n?`助手名字`:`Assistant name`,(0,H.jsx)(`input`,{value:f.displayName,maxLength:60,onChange:e=>p(t=>({...t,displayName:e.target.value})),onBlur:()=>p(e=>({...e,displayName:e.displayName.trim()||`Ada`})),className:`mt-2 block w-full rounded-xl border border-edge bg-surface-panel px-4 py-3 text-fg outline-none focus-visible:ring-2 focus-visible:ring-accent`})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`选择头像`:`Choose an avatar`}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[pe.map(e=>(0,H.jsxs)(`button`,{type:`button`,"aria-pressed":!x&&f.appearance===e.id,onClick:()=>{S(null),T(null),p(t=>({...t,appearance:e.id}))},className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-2xl p-3 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${!x&&f.appearance===e.id?`bg-accent/10 text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:[(0,H.jsx)(E,{appearance:e.id,className:`size-14`}),n?e.zh:e.en]},e.id)),(0,H.jsxs)(`label`,{className:`flex min-h-28 cursor-pointer flex-col items-center justify-center gap-2 rounded-2xl p-3 text-sm transition-colors focus-within:ring-2 focus-within:ring-accent ${x?`bg-accent/10 text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:[(0,H.jsx)(re,{className:`size-6`}),n?`上传图片`:`Upload image`,(0,H.jsx)(`input`,{className:`sr-only`,type:`file`,accept:`image/png,image/jpeg,image/webp`,onChange:e=>{let t=e.target.files?.[0];if(t){if(t.size>512*1024||![`image/png`,`image/jpeg`,`image/webp`].includes(t.type)){b(n?`请选择不超过 512 KB 的 PNG、JPEG 或 WebP 图片。`:`Choose a PNG, JPEG, or WebP image under 512 KB.`);return}S(t),T(URL.createObjectURL(t))}}})]})]}),(0,H.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:n?`自定义图片在创建助手时上传;刷新后需要重新选择。`:`Custom images upload when you create the assistant; select again after a refresh.`})]})]}),o===`voice`&&(0,H.jsxs)(`div`,{className:`mt-5`,children:[(0,H.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:n?`用于这个助手的语音通话;文字回答不受影响。试听不会使用麦克风。`:`This affects calls with this assistant. Text stays the same. Preview does not use your microphone.`}),A?(0,H.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[(0,H.jsx)(k,{className:`h-20 rounded-xl`}),(0,H.jsx)(k,{className:`h-20 rounded-xl`})]}):D?.enabled&&M.length>0?(0,H.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[(0,H.jsx)(`button`,{type:`button`,"aria-pressed":!f.voice,onClick:()=>p(e=>({...e,voice:null})),className:`rounded-xl p-4 text-left text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${f.voice?`bg-surface-panel text-fg-muted hover:bg-surface-hover`:`bg-accent/10 text-fg ring-1 ring-accent/40`}`,children:n?`使用默认声音`:`Use the default voice`}),M.map(e=>(0,H.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl p-3 transition-colors ${f.voice===e.id?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 rounded-lg text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-pressed":f.voice===e.id,onClick:()=>p(t=>({...t,voice:e.id})),children:[(0,H.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.name}),(0,H.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e.description||e.style||(n?`点击选择`:`Select this voice`)})]}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>void be(e.id),className:`flex size-9 shrink-0 items-center justify-center rounded-full bg-surface-hover text-fg hover:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`试听${e.name}`:`Preview ${e.name}`,children:(0,H.jsx)(R,{className:`size-4 ${ie===e.id?`text-accent`:``}`})})]},e.id))]}):(0,H.jsxs)(`div`,{className:`mt-5 rounded-xl bg-surface-panel p-5 text-sm text-fg-muted`,children:[(0,H.jsx)(`p`,{children:n?`当前没有可试听的语音。你可以先用文字对话,稍后再设置。`:`No voice is ready to preview. You can start with text and set it up later.`}),(0,H.jsx)(i,{to:`/settings/capabilities/models?configure=speech&returnTo=%2Fpersonal`,className:`mt-3 inline-block text-accent hover:underline`,children:n?`设置语音服务`:`Set up voice`})]})]}),o===`connections`&&(0,H.jsxs)(`div`,{className:`mt-5`,children:[(0,H.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:n?`现在连接,或进入对话后再添加。连接不会自动读取历史数据或创建持续关注。`:`Connect now or add sources later. Connecting does not automatically scan history or create ongoing monitoring.`}),ue?(0,H.jsxs)(`div`,{className:`mt-5 space-y-2`,children:[(0,H.jsx)(k,{className:`h-18 rounded-xl`}),(0,H.jsx)(k,{className:`h-18 rounded-xl`})]}):(0,H.jsx)(`div`,{className:`mt-5 space-y-2`,children:se.length?se.map(e=>{let t=me(fe.find(t=>t.connectorId===e.id));return(0,H.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-surface-panel p-4`,children:[(0,H.jsx)(te,{connector:e,size:`sm`}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.displayName}),(0,H.jsx)(`p`,{className:`line-clamp-2 text-xs text-fg-muted`,children:e.description})]}),t?(0,H.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-success`,children:[(0,H.jsx)(a,{className:`size-4`}),n?`已连接`:`Connected`]}):(0,H.jsx)(`button`,{type:`button`,onClick:()=>W(w(e)),className:`rounded-lg bg-surface-hover px-3 py-2 text-xs text-fg transition-colors hover:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`连接`:`Connect`})]},e.id)}):(0,H.jsx)(`p`,{className:`rounded-xl bg-surface-panel p-5 text-sm text-fg-muted`,children:n?`暂无可用的推荐服务;你仍可直接进入对话。`:`No suggested services are available. You can continue to chat.`})})]}),!e&&(0,H.jsxs)(`p`,{className:`mt-5 rounded-xl bg-warning/5 p-4 text-sm text-fg-muted`,children:[n?`开始前需要一个可用模型。`:`A compatible model is required before you start.`,` `,(0,H.jsx)(i,{to:`/settings/capabilities/models`,className:`text-accent underline`,children:n?`配置模型`:`Set up a model`})]}),y&&(0,H.jsx)(`p`,{role:`alert`,className:`mt-5 text-sm text-danger`,children:y})]},o)}),(0,H.jsx)(`footer`,{className:`shrink-0 px-5 pb-6 pt-3 sm:px-8 sm:pb-9`,children:(0,H.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col-reverse gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,H.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n?`这些选择以后都能调整`:`You can change these choices later`}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[o===`intro`&&(0,H.jsx)(`button`,{type:`button`,disabled:!e||_,onClick:()=>void ye(!0),className:`min-h-11 rounded-lg px-3 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-40`,children:n?`用默认设置开始`:`Use defaults`}),o===`voice`&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>{let e={...f,voice:null};p(e),b(null),ve(`connections`,e).catch(e=>b(e instanceof Error?e.message:String(e)))},className:`min-h-11 rounded-lg px-3 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`跳过`:`Skip`}),(0,H.jsxs)(`button`,{type:`button`,disabled:_||o===`connections`&&!e,onClick:()=>o===`connections`?void ye():void G(1),className:`flex min-h-11 items-center gap-2 rounded-xl bg-accent px-5 text-sm font-medium text-on-accent transition-colors hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 disabled:opacity-40`,children:[_?n?`正在创建…`:`Creating…`:o===`connections`?n?`进入对话`:`Start chatting`:n?`继续`:`Continue`,` `,!_&&(0,H.jsx)(ne,{className:`size-4`})]})]})]})}),_e&&(0,H.jsx)(N,{draft:_e,onChange:W,onClose:()=>W(null),t:c(r).connectorsSettings,onInstalled:async()=>{ge(await ee()),W(null)}})]})}function _e({record:e,zh:t,onSelectVoice:n,onGreetingChange:r}){let[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(!0),[l,u]=(0,V.useState)(``),[d,f]=(0,V.useState)(null),[p,m]=(0,V.useState)([]),[h,g]=(0,V.useState)(e.voicePreference?.voice??``),[_,v]=(0,V.useState)(!1),[y,b]=(0,V.useState)(null),[x,S]=(0,V.useState)(null),C=(0,V.useRef)(null),w=(0,V.useRef)(null);(0,V.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await le();if(e||(o(t.openingGreeting===!0),!t.enabled||!t.tts))return;let n={provider:t.tts.provider,model:t.tts.model};f(n);let r=await ce(n.provider,n.model,`realtime`);e||m(r)}catch(t){e||b(t instanceof Error?t.message:String(t))}finally{e||c(!1)}})(),()=>{e=!0}},[]),(0,V.useEffect)(()=>()=>{w.current?.abort(),C.current?.close()},[]);let T=()=>{w.current?.abort(),w.current=null,C.current?.close(),C.current=null,S(null)},E=async e=>{if(x!==null){T();return}T(),b(null);let n=new AbortController;w.current=n,S(e);try{let t=new oe;C.current=t,await t.start();let r=await z(n.signal,e);n.signal.aborted||t.enqueue(r,()=>{w.current===n&&(S(null),w.current=null,C.current=null,t.close())})}catch(e){if(!n.signal.aborted){let n=e?.body?.error?.code;b(t&&n===`unsupported_voice`?`当前音色暂不可用,请刷新语音目录或选择其他音色。`:e instanceof Error?e.message:String(e))}w.current===n&&T()}},D=async e=>{if(_||e===h)return;T();let t=h;g(e),u(``),v(!0),b(null);try{await n(e&&d?{provider:d.provider,model:d.model,voice:e}:null)||g(t)}catch(e){g(t),b(e instanceof Error?e.message:String(e))}finally{v(!1)}},O=p.find(e=>e.id===h),A=t?`默认声音`:`Default voice`,j=O?.name||(h?t?`当前音色不可用`:`Current voice unavailable`:A),N=l.trim().toLocaleLowerCase(),P=p.filter(e=>!N||`${e.name} ${e.description??``} ${e.style??``}`.toLocaleLowerCase().includes(N)).map(e=>({value:e.id,label:e.name}));return(0,H.jsxs)(`section`,{className:`border-t border-edge pt-5`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:t?`通话声音`:`Call voice`}),s?(0,H.jsx)(`div`,{className:`mt-3`,"aria-busy":`true`,children:(0,H.jsx)(k,{className:`h-10 w-full`})}):d&&p.length?(0,H.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,H.jsx)(I,{value:h,selectedLabel:j,options:P,placeholder:A,emptyLabel:A,ariaLabel:t?`选择通话音色`:`Choose call voice`,disabled:_,onChange:e=>void D(e),searchPlaceholder:p.length>8?t?`搜索音色`:`Search voices`:void 0,searchValue:l,onSearchChange:u,statusMessage:N&&!P.length?t?`没有匹配的音色`:`No matching voices`:void 0})}),(0,H.jsxs)(`button`,{type:`button`,disabled:_||!!(h&&!O),onClick:()=>void E(h),className:`touch-target flex h-10 shrink-0 items-center justify-center gap-1.5 rounded-lg border border-edge px-3 text-sm text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,title:x===null?t?`试听${j}`:`Preview ${j}`:t?`停止试听`:`Stop preview`,"aria-label":x===null?t?`试听${j}`:`Preview ${j}`:t?`停止试听`:`Stop preview`,children:[x===null?(0,H.jsx)(R,{className:`size-4`,"aria-hidden":!0}):(0,H.jsx)(M,{className:`size-4 text-accent`,"aria-hidden":!0}),x===null?t?`试听`:`Preview`:t?`停止`:`Stop`]})]}),(0,H.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:O?.description||O?.style||(h?t?`选择后自动保存,用于之后的语音通话。`:`Saved automatically for future voice calls.`:t?`跟随语音服务的默认音色。`:`Uses the voice service’s default voice.`)})]}):(0,H.jsxs)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:[t?`当前没有可用音色。`:`No voice is ready.`,` `,(0,H.jsx)(i,{to:`/settings/capabilities/models?configure=speech&returnTo=%2Fpersonal`,className:`text-accent underline`,children:t?`设置语音服务`:`Set up voice`})]}),r&&a&&(0,H.jsxs)(`label`,{className:`mt-4 flex items-center justify-between gap-3 text-sm text-fg`,children:[t?`连接时打招呼`:`Greet me when connected`,(0,H.jsx)(`input`,{type:`checkbox`,checked:e.voiceCallPreferences?.openingGreetingEnabled??!0,disabled:_,onChange:e=>{let t=e.target.checked;v(!0),r(t).catch(e=>b(String(e))).finally(()=>v(!1))}})]}),y&&(0,H.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:y})]})}var W=new h;function ve({conversationId:e,zh:t,onSaved:n}){let r=f(t=>t.sessions[e]),[i,a]=(0,V.useState)(!0),[o,s]=(0,V.useState)(``);(0,V.useEffect)(()=>{let t=!0;return W.loadSessionAgentConfig(e).then(n=>{t&&p(e,n)}).catch(e=>{t&&s(String(e))}).finally(()=>{t&&a(!1)}),()=>{t=!1}},[e]);let l=!!r?.modelConfigSaving;async function u(t,i){f.getState().patchSessionMeta(e,{modelConfigSaving:!0});try{p(e,await W.patchSessionAgentConfig(e,{model:t,thinkingLevel:i,configVersion:r?.configVersion})),await n()}catch(t){let n=await W.loadSessionAgentConfig(e).catch(()=>null);throw n&&p(e,n),t}finally{f.getState().patchSessionMeta(e,{modelConfigSaving:!1})}}return(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:t?`对话模型与思考强度`:`Conversation model and thinking`}),i?(0,H.jsx)(k,{className:`h-9 w-full`}):(0,H.jsx)(O,{chat:c(t?`zh`:`en`).chat,sessionModel:r?.model??``,thinkingLevel:r?.thinkingLevel??`off`,modelDisabled:l,thinkingDisabled:l,onModelChange:u,onThinkingChange:e=>u(r?.model??``,e)}),o&&(0,H.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:o})]})}var G=5;function ye(e){let t=e.replace(/\s+/g,` `).trim();if(t.length<=58)return t;let n=t.replace(/([^)]{1,80})|\([^)]{1,80}\)/g,``).replace(/([A-Za-z0-9])(?=[\u4e00-\u9fff])/g,`$1 `).replace(/\s+/g,` `).trim(),r=n.split(/[。!?;;,]/,1)[0]?.trim()||n;return r.length>58?`${r.slice(0,57).trimEnd()}…`:r}function be(e,t){if(e.phase===`closed`)return{label:t?`已结束`:`Finished`,tone:`bg-fg-subtle`};let n=e.operationalState??e.runStatus;return n===`running`?{label:t?`正在执行`:`Working`,tone:`bg-accent`}:n===`queued`?{label:t?`等待开始`:`Queued`,tone:`bg-fg-subtle`}:n===`failed`?{label:t?`执行失败`:`Failed`,tone:`bg-danger`}:n===`waiting`?{label:t?`等待继续`:`Waiting`,tone:`bg-warning`}:n===`blocked`?{label:t?`已阻塞`:`Blocked`,tone:`bg-warning`}:n===`verifying`?{label:t?`正在验证`:`Verifying`,tone:`bg-accent`}:n===`cancelled`?{label:t?`执行已取消`:`Cancelled`,tone:`bg-fg-subtle`}:e.phase===`review`?{label:t?`等待验收`:`In review`,tone:`bg-warning`}:e.phase===`active`?{label:t?`正在推进`:`In progress`,tone:`bg-accent`}:e.phase===`ready`?{label:t?`准备开始`:`Ready`,tone:`bg-fg-subtle`}:{label:t?`待处理`:`Planned`,tone:`bg-fg-subtle`}}function K(e){let t=(0,B.c)(30),{item:n,zh:r}=e,a;t[0]!==n||t[1]!==r?(a=be(n,r),t[0]=n,t[1]=r,t[2]=a):a=t[2];let s=a,c;t[3]===n.id?c=t[4]:(c=o(`/personal`,n.id),t[3]=n.id,t[4]=c);let l=`mt-2 size-1.5 shrink-0 rounded-full ${s.tone}`,u;t[5]===l?u=t[6]:(u=(0,H.jsx)(`span`,{className:l,"aria-hidden":!0}),t[5]=l,t[6]=u);let d;t[7]===n.title?d=t[8]:(d=ye(n.title),t[7]=n.title,t[8]=d);let f;t[9]===d?f=t[10]:(f=(0,H.jsx)(`span`,{className:`line-clamp-2 break-words text-sm font-medium leading-5 text-fg`,children:d}),t[9]=d,t[10]=f);let p;t[11]===s.label?p=t[12]:(p=(0,H.jsx)(`span`,{children:s.label}),t[11]=s.label,t[12]=p);let m;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,H.jsx)(`span`,{className:`text-fg-subtle`,"aria-hidden":!0,children:`·`}),t[13]=m):m=t[13];let h=r?`zh`:`en`,g;t[14]!==n.updatedAt||t[15]!==h?(g=T(n.updatedAt,h),t[14]=n.updatedAt,t[15]=h,t[16]=g):g=t[16];let _;t[17]===g?_=t[18]:(_=(0,H.jsx)(`span`,{children:g}),t[17]=g,t[18]=_);let v;t[19]!==_||t[20]!==p?(v=(0,H.jsxs)(`span`,{className:`mt-1.5 flex items-center gap-2 text-xs text-fg-muted`,children:[p,m,_]}),t[19]=_,t[20]=p,t[21]=v):v=t[21];let y;t[22]!==v||t[23]!==f?(y=(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[f,v]}),t[22]=v,t[23]=f,t[24]=y):y=t[24];let b;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,H.jsx)(D,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle opacity-0 transition-opacity duration-150 group-hover:opacity-100 group-focus-visible:opacity-100`,"aria-hidden":!0}),t[25]=b):b=t[25];let x;return t[26]!==y||t[27]!==c||t[28]!==u?(x=(0,H.jsxs)(i,{to:c,className:`group flex min-w-0 items-start gap-3 rounded-2xl bg-surface-panel px-4 py-4 transition-colors duration-150 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[u,y,b]}),t[26]=y,t[27]=c,t[28]=u,t[29]=x):x=t[29],x}var xe=[{id:`direct`,warmth:`reserved`,zh:`直接`,en:`Direct`},{id:`natural`,warmth:`balanced`,zh:`自然`,en:`Natural`},{id:`gentle`,warmth:`gentle`,zh:`温和`,en:`Gentle`}],Se=[{id:`loopi`,zh:`Loopi`,en:`Loopi`,color:`bg-slate-100/50 dark:bg-slate-400/10`},{id:`loopi-curious`,zh:`好奇`,en:`Curious`,color:`bg-blue-100/50 dark:bg-blue-400/10`},{id:`loopi-care`,zh:`温和`,en:`Gentle`,color:`bg-violet-100/50 dark:bg-violet-400/10`}];function Ce(e,t){return e.warmth===`reserved`?t?`你可以直接说目标或问题。我会先给结论,需要时再展开。`:`Tell me the goal or question. I’ll lead with the answer and expand when useful.`:e.warmth===`gentle`?t?`想聊一件事,或让我帮你推进工作,都可以从这里开始。我会认真听,也会把下一步说清楚。`:`You can talk something through or ask me to move work forward. I’ll listen carefully and make the next step clear.`:t?`有什么想讨论或推进的事?直接告诉我就好。`:`What would you like to discuss or move forward? Just tell me what is on your mind.`}function we(e){return xe.find(t=>t.warmth===e.warmth)?.id??`natural`}function Te(){let e=C(),t=(0,V.useRef)(e);t.current=e;let n=u(e=>e.language)===`zh`,r=S(e=>e.setPageHeader),i=S(e=>e.clearPageHeader),[a,o]=(0,V.useState)(null),c=(0,V.useRef)(null),f=(0,V.useRef)(Promise.resolve()),[p,m]=(0,V.useState)([]),[h,g]=(0,V.useState)(!0),[w,T]=(0,V.useState)(0),[D,O]=(0,V.useState)(null),[M,N]=(0,V.useState)(!0),[ee,te]=(0,V.useState)(!1),[ne,oe]=(0,V.useState)(`natural`),[F,R]=(0,V.useState)(`loopi`),[z,ce]=(0,V.useState)(!1),le=(0,V.useRef)(null),B=(0,V.useRef)(null),ue=(0,V.useRef)(null),[de,U]=(0,V.useState)(``),[pe,me]=(0,V.useState)(`untangle`),[he,W]=(0,V.useState)(`none`),[ye,be]=(0,V.useState)(`balanced`),[Te,Ee]=(0,V.useState)(`decisions`),[De,Oe]=(0,V.useState)(!1),[ke,q]=(0,V.useState)(!1),[J,Ae]=(0,V.useState)(!1),[Y,je]=(0,V.useState)(null),[Me,Ne]=(0,V.useState)(!1),[X,Pe]=(0,V.useState)(!1),[Fe,Ie]=(0,V.useState)(!1),[Z,Le]=(0,V.useState)(0),Q=(0,V.useRef)(0),Re=(0,V.useCallback)(()=>{Ae(!1),q(!1),Oe(!0)},[]),ze=(0,V.useCallback)(()=>{Ae(!1),q(!1),Oe(e=>!e)},[]),Be=(0,V.useCallback)(async()=>{try{let[e,t]=await Promise.all([l(d(`/api/personal-agent`)),l(d(`/api/personal-agent/models`))]);if(c.current=e.payload,o(e.payload),e.payload?.state===`ready`){let e=await l(d(`/api/personal-agent/onboarding`));N(!e.payload.completed||e.payload.welcomeDone)}window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:e.payload})),e.payload&&window.dispatchEvent(new Event(`session-updated`)),m(t.payload),e.payload&&(U(e.payload.displayName),R(e.payload.appearance),oe(we(e.payload.preferences)),me(e.payload.preferences.supportMode??`untangle`),W(e.payload.preferences.humor??`none`),be(e.payload.preferences.detailLevel??`balanced`),Ee(e.payload.preferences.proactivity??`decisions`))}catch(e){O(e instanceof Error?e.message:String(e))}finally{g(!1)}},[]);(0,V.useEffect)(()=>{Be()},[Be]);let $=(0,V.useCallback)(e=>{T(e=>e+1),O(null);let t=f.current.then(async()=>{let t=c.current;if(!t)return!1;let n=e.displayName?.trim()||t.displayName,r=e.appearance??t.appearance,i={...t.preferences,...e.preferences},a=e.voicePreference===void 0?t.voicePreference:e.voicePreference;if(n===t.displayName&&r===t.appearance&&JSON.stringify(i)===JSON.stringify(t.preferences)&&JSON.stringify(a)===JSON.stringify(t.voicePreference)&&(!e.voiceCallPreferences||JSON.stringify(e.voiceCallPreferences)===JSON.stringify(t.voiceCallPreferences)))return!0;try{let s=await l(d(`/api/personal-agent/profile`),{method:`PATCH`,body:JSON.stringify({revision:t.revision,displayName:n,appearance:r,preferences:i,...e.voicePreference===void 0?{}:{voicePreference:a},...e.voiceCallPreferences?{voiceCallPreferences:e.voiceCallPreferences}:{}})});return c.current=s.payload,o(s.payload),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:s.payload})),!0}catch(e){return O(e instanceof Error?e.message:String(e)),!1}}).finally(()=>T(e=>e-1));return f.current=t,t},[]),Ve=async e=>{if(a){O(null);try{if(e){let t=await l(d(`/api/personal-agent/profile`),{method:`PATCH`,body:JSON.stringify({revision:a.revision,displayName:a.displayName,appearance:a.appearance,preferences:{...a.preferences,supportMode:e}})});c.current=t.payload,o(t.payload)}await l(d(`/api/personal-agent/onboarding/welcome`),{method:`POST`,body:`{}`}),N(!0)}catch(e){O(e instanceof Error?e.message:String(e))}}},He=(0,V.useCallback)(async()=>{let e=++Q.current;Ae(!0),je(null),Ne(!1),Pe(!1),Ie(!1),Le(0);try{let t=await l(d(`/api/personal-agent/activity?limit=${G}&offset=0`));if(e!==Q.current)return;je(t.payload),Le(t.payload.items.length)}catch{e===Q.current&&Ne(!0)}},[]),Ue=(0,V.useCallback)(async()=>{if(!Y||X||Z>=Y.total)return;let e=Q.current;Pe(!0),Ie(!1);try{let t=await l(d(`/api/personal-agent/activity?limit=${G}&offset=${Z}`));if(e!==Q.current)return;je(e=>e?{total:t.payload.total,items:[...e.items,...t.payload.items.filter(t=>!e.items.some(e=>e.id===t.id))]}:t.payload),Le(e=>e+t.payload.items.length)}catch{e===Q.current&&Ie(!0)}finally{e===Q.current&&Pe(!1)}},[Y,Z,X]);(0,V.useEffect)(()=>{if(!J||!Y||X)return;let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(async()=>{let e=Q.current;try{let t=await l(d(`/api/personal-agent/activity?limit=${Math.max(G,Math.min(100,Z))}&offset=0`));if(e!==Q.current)return;je(t.payload),Le(t.payload.items.length)}catch{}},120)},n=window.setInterval(t,5e3);return window.addEventListener(`task-changed-v2`,t),window.addEventListener(`gateway-realtime-connected`,t),()=>{window.clearTimeout(e),window.clearInterval(n),window.removeEventListener(`task-changed-v2`,t),window.removeEventListener(`gateway-realtime-connected`,t)}},[Y,Z,X,J]);let We=async e=>{if(!a||![`image/png`,`image/jpeg`,`image/webp`].includes(e.type)){O(n?`请选择 PNG、JPEG 或 WebP 图片。`:`Choose a PNG, JPEG, or WebP image.`);return}if(e.size===0||e.size>512*1024){O(n?`图片大小不能超过 512 KB。`:`Image must be 512 KB or smaller.`);return}ce(!0),O(null);try{let t=await new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(e)});await l(d(`/api/agents/${encodeURIComponent(a.agentId)}/avatar`),{method:`PUT`,body:JSON.stringify({base64:t.slice(t.indexOf(`,`)+1),mimeType:e.type})}),A(a.agentId),R(`custom`),q(!1),await $({appearance:`custom`})}catch(e){O(e instanceof Error?e.message:String(e))}finally{ce(!1)}};(0,V.useLayoutEffect)(()=>{let o=a?.state===`ready`,c=o?a.appearance:F,l=o?a.displayName:`Ada`;return r({startExtra:null,main:(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[o?(0,H.jsx)(`button`,{ref:ue,type:`button`,onClick:ze,"aria-expanded":De,className:`touch-target -m-1 shrink-0 rounded-full p-1 transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`编辑${l}的资料`:`Edit ${l}'s profile`,title:n?`资料`:`Profile`,children:(0,H.jsx)(`span`,{className:`flex size-8 items-center justify-center`,children:(0,H.jsx)(E,{appearance:c,agentId:a?.agentId,className:`size-8`})})}):(0,H.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center`,children:(0,H.jsx)(E,{appearance:c,agentId:a?.agentId,className:`size-8`})}),(0,H.jsx)(`h1`,{className:`min-w-0 truncate text-sm font-semibold text-fg sm:text-base`,children:l})]}),end:o?(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`button`,{type:`button`,disabled:e.active,onClick:()=>{a?.state===`ready`&&t.current.open({conversationId:a.conversationId,name:a.displayName,mode:`assistant`})},className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50`,"aria-label":n?`语音通话`:`Voice call`,title:n?`语音通话`:`Voice call`,children:(0,H.jsx)(y,{className:`size-5`})}),(0,H.jsxs)(x,{open:J,onOpenChange:e=>{e?He():Ae(!1)},children:[(0,H.jsx)(b,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,"aria-pressed":J,className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":n?`正在做的事`:`Activity`,children:(0,H.jsx)(P,{className:`size-5`})})}),(0,H.jsx)(j,{children:(0,H.jsxs)(L,{side:`bottom`,align:`end`,sideOffset:8,collisionPadding:8,"aria-label":n?`派发的任务`:`Delegated tasks`,className:`z-50 flex h-[min(34rem,calc(100dvh-6rem))] w-[min(25rem,calc(100vw-1rem))] min-h-0 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-xl focus:outline-none`,children:[(0,H.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 px-6 pb-3 pt-6`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-fg`,children:n?`交给我推进的事`:`Delegated work`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:Y?n?`最近更新 · 共 ${Y.total} 项`:`Recently updated · ${Y.total} total`:n?`查看任务进展与结果`:`Follow progress and results`})]}),(0,H.jsx)(v,{className:`touch-target -mr-2 -mt-1 rounded-lg p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`关闭活动`:`Close activity`,children:(0,H.jsx)(s,{className:`size-4`})})]}),(0,H.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 pb-5 pt-3`,children:[!Y&&!Me&&(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(k,{className:`h-18 rounded-2xl`}),(0,H.jsx)(k,{className:`h-18 rounded-2xl`}),(0,H.jsx)(k,{className:`h-18 rounded-2xl`})]}),Me&&(0,H.jsxs)(`div`,{className:`px-5 py-12 text-center`,children:[(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`暂时无法读取任务`:`Could not load tasks`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>void He(),className:`mt-3 rounded-lg px-3 py-2 text-sm text-accent hover:bg-surface-hover`,children:n?`重试`:`Try again`})]}),Y?.items.length===0&&(0,H.jsxs)(`div`,{className:`px-5 py-16 text-center`,children:[(0,H.jsx)(P,{className:`mx-auto size-7 text-fg-subtle`,"aria-hidden":!0}),(0,H.jsx)(`p`,{className:`mt-4 text-sm font-medium text-fg`,children:n?`还没有派发的任务`:`No delegated work yet`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n?`你可以在对话里直接告诉我想推进的事。`:`Tell me what you would like to move forward in chat.`})]}),Y&&Y.items.length>0&&(0,H.jsx)(`div`,{className:`space-y-2`,children:Y.items.map(e=>(0,H.jsx)(K,{item:e,zh:n},e.id))}),Y&&Z<Y.total&&(0,H.jsxs)(`div`,{className:`pt-4 text-center`,children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>void Ue(),disabled:X,className:`min-h-10 rounded-xl bg-surface-panel px-5 text-sm font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:opacity-50`,children:X?n?`正在加载…`:`Loading…`:n?`加载更多`:`Load more`}),Fe&&(0,H.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:n?`加载失败,请重试`:`Could not load more. Try again.`})]})]})]})})]}),(0,H.jsx)(`button`,{ref:B,type:`button`,onClick:ze,"aria-expanded":De,className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":n?`回应偏好`:`Response preferences`,children:(0,H.jsx)(ae,{className:`size-5`})})]}):null}),()=>i()},[Y,Me,Z,X,Fe,F,i,Ue,He,a,r,J,De,ze,e.active,n]);function Ge(){return a?(0,H.jsxs)(x,{open:De,onOpenChange:e=>{Oe(e),e||q(!1)},children:[(0,H.jsx)(se,{virtualRef:B}),(0,H.jsx)(j,{children:(0,H.jsxs)(L,{side:`bottom`,align:`end`,sideOffset:8,collisionPadding:8,"aria-label":n?`编辑 Personal AI`:`Edit Personal AI`,onInteractOutside:e=>{e.target instanceof Node&&(B.current?.contains(e.target)||ue.current?.contains(e.target))&&e.preventDefault()},className:`z-50 flex h-[min(38rem,calc(100dvh-6rem))] w-[min(28rem,calc(100vw-1rem))] min-h-0 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-xl outline-none`,children:[(0,H.jsxs)(`div`,{className:`relative flex shrink-0 flex-col items-center px-5 pt-5 text-center`,children:[(0,H.jsx)(`button`,{type:`button`,disabled:z,onClick:()=>q(e=>!e),"aria-expanded":ke,"aria-controls":`personal-appearance-options`,"aria-label":n?`选择头像`:`Choose avatar`,className:`rounded-full transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,H.jsx)(E,{appearance:F,agentId:a.agentId,className:`size-20`})}),(0,H.jsx)(`input`,{id:`personal-name`,"aria-label":n?`助手名称`:`Assistant name`,value:de,onChange:e=>U(e.target.value),onBlur:e=>{let t=e.currentTarget.value.trim();t?(U(t),$({displayName:t})):U(c.current?.displayName??``)},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.currentTarget.value=c.current?.displayName??``,U(e.currentTarget.value),e.currentTarget.blur())},maxLength:60,placeholder:`Ada`,className:`mt-3 w-full min-w-0 rounded-lg border border-transparent bg-transparent px-2 py-1 text-center text-lg font-semibold text-fg outline-none transition-colors hover:border-edge focus:border-edge focus:bg-surface-base focus-visible:ring-2 focus-visible:ring-accent`}),w>0&&(0,H.jsx)(`span`,{className:`absolute right-4 top-4 text-xs text-fg-muted`,children:n?`正在保存…`:`Saving…`})]}),(0,H.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-6 overflow-y-auto overscroll-contain px-5 py-5`,children:[D&&(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:D}),ke&&(0,H.jsxs)(`section`,{id:`personal-appearance-options`,children:[(0,H.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`形象`:`Appearance`}),(0,H.jsxs)(`div`,{className:`grid grid-cols-4 gap-2`,children:[Se.map(e=>(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{R(e.id),q(!1),$({appearance:e.id})},"aria-pressed":F===e.id,className:`flex min-w-0 flex-col items-center gap-1.5 rounded-xl px-1 py-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${F===e.id?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,H.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full ${e.color}`,children:(0,H.jsx)(E,{appearance:e.id,className:`size-8`})}),(0,H.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:n?e.zh:e.en})]},e.id)),(0,H.jsx)(`input`,{ref:le,type:`file`,accept:`image/png,image/jpeg,image/webp`,className:`sr-only`,"aria-label":n?`上传头像`:`Upload avatar`,onChange:e=>{let t=e.currentTarget.files?.[0];t&&We(t),e.currentTarget.value=``}}),(0,H.jsxs)(`button`,{type:`button`,disabled:z,onClick:()=>le.current?.click(),"aria-pressed":F===`custom`,className:`flex min-w-0 flex-col items-center gap-1.5 rounded-xl px-1 py-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50 ${F===`custom`?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,H.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full bg-surface-panel`,children:F===`custom`?(0,H.jsx)(E,{appearance:`custom`,agentId:a.agentId,className:`size-8`}):(0,H.jsx)(re,{className:`size-4 text-fg-muted`,"aria-hidden":!0})}),(0,H.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:z?n?`上传中…`:`Uploading…`:n?`上传`:`Upload`})]})]})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`语气`:`Tone`}),(0,H.jsx)(_,{className:`grid grid-cols-3 gap-2`,role:`group`,"aria-label":n?`语气`:`Tone`,indicatorClassName:`rounded-xl bg-accent/10 ring-1 ring-accent/40`,children:xe.map(e=>(0,H.jsx)(`button`,{type:`button`,onClick:()=>{oe(e.id),$({preferences:{warmth:e.warmth}})},"aria-pressed":ne===e.id,className:`min-h-10 rounded-xl px-2 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${ne===e.id?`bg-accent/10 font-medium text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:n?e.zh:e.en},e.id))})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`棘手时`:`When things get tricky`}),(0,H.jsx)(_,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":n?`棘手时`:`When things get tricky`,indicatorClassName:`rounded-full bg-accent/10 ring-1 ring-accent/40`,children:[[`listen`,n?`先听`:`Listen`],[`untangle`,n?`理清`:`Untangle`],[`solutions`,n?`给办法`:`Suggest`]].map(([e,t])=>(0,H.jsx)(`button`,{type:`button`,"aria-pressed":pe===e,onClick:()=>{me(e),$({preferences:{supportMode:e}})},className:`min-h-9 rounded-full px-3 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${pe===e?`bg-accent/10 text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:t},e))})]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`mb-2 text-sm font-medium text-fg`,children:n?`回答长度`:`Length`}),(0,H.jsx)(I,{value:ye??`balanced`,options:[{value:`brief`,label:n?`简短`:`Brief`},{value:`balanced`,label:n?`适中`:`Balanced`},{value:`detailed`,label:n?`详细`:`Detailed`}],placeholder:n?`选择长度`:`Choose length`,allowEmpty:!1,onChange:e=>{let t=e;be(t),$({preferences:{detailLevel:t}})}})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`mb-2 text-sm font-medium text-fg`,children:n?`主动更新`:`Updates`}),(0,H.jsx)(I,{value:Te??`decisions`,options:[{value:`decisions`,label:n?`结果与决定`:`Results only`},{value:`important`,label:n?`重要进展`:`Milestones`},{value:`open`,label:n?`多提建议`:`Suggestions`}],placeholder:n?`选择频率`:`Choose frequency`,allowEmpty:!1,onChange:e=>{let t=e;Ee(t),$({preferences:{proactivity:t}})}})]})]}),(0,H.jsxs)(`details`,{className:`text-sm text-fg-muted`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer select-none`,children:n?`更多偏好`:`More preferences`}),(0,H.jsxs)(`div`,{className:`mt-3`,children:[(0,H.jsx)(`p`,{className:`mb-2 font-medium text-fg`,children:n?`轻松程度`:`Humor`}),(0,H.jsx)(I,{value:he??`none`,options:[{value:`none`,label:n?`不加玩笑`:`None`},{value:`occasional`,label:n?`偶尔轻松`:`Sometimes`},{value:`playful`,label:n?`活泼`:`Playful`}],placeholder:n?`选择程度`:`Choose level`,allowEmpty:!1,onChange:e=>{let t=e;W(t),$({preferences:{humor:t}})}})]})]}),(0,H.jsx)(fe,{zh:n}),(0,H.jsx)(_e,{onGreetingChange:e=>$({voiceCallPreferences:{openingGreetingEnabled:e}}),record:a,zh:n,onSelectVoice:e=>$({voicePreference:e})}),(0,H.jsx)(`div`,{className:`border-t border-edge pt-5`,children:(0,H.jsx)(ve,{conversationId:a.conversationId,zh:n,onSaved:async()=>{let e=await l(d(`/api/personal-agent`));e.ok&&e.payload&&(c.current=e.payload,o(e.payload))}})})]})]})})]}):null}return h?(0,H.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl space-y-5 px-6 py-12`,children:[(0,H.jsx)(k,{className:`h-20 w-20 rounded-full`}),(0,H.jsx)(k,{className:`h-9 w-72`}),(0,H.jsx)(k,{className:`h-44 w-full rounded-2xl`})]}):a?.state===`ready`?(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col bg-surface-panel`,children:[ee&&(0,H.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 items-center justify-between gap-3 border-b border-warning/30 bg-warning/5 px-5 py-3 text-sm text-fg-muted`,children:[(0,H.jsx)(`span`,{children:n?`助手已创建,头像上传未完成。可在资料设置中重新上传。`:`Your assistant is ready. Upload the avatar again in profile settings.`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>{te(!1),Re()},className:`shrink-0 text-accent hover:underline`,children:n?`打开设置`:`Open settings`})]}),(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,H.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,H.jsx)(ie,{embedded:!0,personal:!0,personalWelcome:{name:a.displayName,addressAs:a.userCallName??void 0,avatar:(0,H.jsx)(E,{appearance:a.appearance,agentId:a.agentId,className:`size-14`}),opening:Ce(a.preferences,n),showSupportChoice:!M,onChooseSupport:e=>void Ve(e),onSkipSupport:()=>void Ve(),supportChoiceError:D},conversationId:a.conversationId})})}),Ge()]}):(0,H.jsx)(ge,{modelsAvailable:p.length>0,onCreated:(e,t)=>{c.current=e,o(e),U(e.displayName),N(!1),te(t),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:e})),window.dispatchEvent(new Event(`session-updated`))}})}export{Te as PersonalPage};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./check-DUBLcKHA.js";import{F as o}from"./markdown-view-CthsQiiO.js";import{t as s}from"./x-B_N4OPjy.js";import{t as c}from"./messages-Bwv-AOYl.js";import{a as l,n as u,r as d}from"./locale-store-D5h-Ha6-.js";import{T as f,d as p,ot as m,t as h}from"./session-manager-DMDBMYfh.js";import{Af as g,Ao as _,Cs as v,Cu as y,Ds as b,Es as x,Go as S,Hs as C,J as w,Mi as T,Mo as E,Of as D,Qi as O,Rc as k,Ro as A,Ts as j,Wl as M,Y as N,Zu as P,ac as ee,et as te,kf as ne,kl as re,n as ie,nu as ae,qs as oe,rc as F,us as I,ws as L,xs as se,yu as R}from"./index-K2cy4f-3.js";import{l as z,n as ce,t as le}from"./voice-config-api-CRjdZdJF.js";var B=n(),V=e(t(),1),H=r();function ue(){try{return[`UTC`,...Intl.supportedValuesOf(`timeZone`)]}catch{return[`UTC`,`Asia/Shanghai`,`Asia/Hong_Kong`,`Asia/Taipei`,`Asia/Tokyo`,`Asia/Seoul`,`Asia/Singapore`,`Asia/Kolkata`,`Asia/Dubai`,`Europe/London`,`Europe/Paris`,`Europe/Berlin`,`America/New_York`,`America/Chicago`,`America/Denver`,`America/Los_Angeles`,`Australia/Sydney`,`Pacific/Auckland`]}}var de=ue();function fe({zh:e}){let[t,n]=(0,V.useState)(),[r,i]=(0,V.useState)(``),[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(``),u=s.trim().toLowerCase().replaceAll(`_`,` `),f=[...new Set([...de,t?.timezone].filter(e=>!!e))].sort().filter(e=>e.replaceAll(`_`,` `).toLowerCase().includes(u)).map(e=>({value:e,label:e.replaceAll(`_`,` `),group:e.split(`/`)[0]}));(0,V.useEffect)(()=>{let e=!0;return l(d(`/api/personal-agent/proactivity`)).then(t=>{e&&t.ok&&n(m.parse(t.payload))}).catch(t=>{e&&i(String(t))}),()=>{e=!1}},[]);async function p(e){if(!(!t||a)){o(!0),i(``);try{let r=await l(d(`/api/personal-agent/proactivity`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t,...e})});r.ok&&n(m.parse(r.payload))}catch(e){i(String(e));let t=await l(d(`/api/personal-agent/proactivity`)).catch(()=>null);t?.ok&&n(m.parse(t.payload))}finally{o(!1)}}}return(0,H.jsxs)(`section`,{className:`space-y-3 border-t border-edge pt-5`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:e?`主动联系`:`Proactive messages`}),!t&&!r?(0,H.jsx)(k,{className:`h-9 w-full`}):t&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(I,{placeholder:e?`选择主动方式`:`Choose participation`,value:t.mode,disabled:a,allowEmpty:!1,options:[{value:`off`,label:e?`关闭主动联系`:`Off`},{value:`follow_up`,label:e?`仅明确跟进`:`Requested follow-ups`},{value:`balanced`,label:e?`适度主动`:`Thoughtful participation`}],onChange:e=>void p({mode:e})}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,H.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[e?`静默开始`:`Quiet from`,(0,H.jsx)(I,{placeholder:e?`选择时间`:`Choose time`,value:String(t.quietStart),disabled:a,allowEmpty:!1,options:Array.from({length:24},(e,t)=>({value:String(t),label:`${String(t).padStart(2,`0`)}:00`})),onChange:e=>void p({quietStart:Number(e)})})]}),(0,H.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[e?`静默结束`:`Quiet until`,(0,H.jsx)(I,{placeholder:e?`选择时间`:`Choose time`,value:String(t.quietEnd),disabled:a,allowEmpty:!1,options:Array.from({length:24},(e,t)=>({value:String(t),label:`${String(t).padStart(2,`0`)}:00`})),onChange:e=>void p({quietEnd:Number(e)})})]})]}),(0,H.jsxs)(`label`,{className:`block text-xs text-fg-muted`,children:[e?`时区`:`Timezone`,(0,H.jsx)(I,{placeholder:e?`选择时区`:`Choose timezone`,ariaLabel:e?`时区`:`Timezone`,value:t.timezone,selectedLabel:t.timezone.replaceAll(`_`,` `),options:f,disabled:a,allowEmpty:!1,triggerClassName:`mt-1`,searchPlaceholder:e?`搜索时区或城市`:`Search timezone or city`,searchValue:s,onSearchChange:c,statusMessage:f.length?void 0:e?`没有匹配的时区`:`No matching timezones`,onChange:e=>{c(``),e!==t.timezone&&p({timezone:e})}})]}),(0,H.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e?`有值得交流的进展时,在聊天里留下消息。明确请求的结果会照常交付。`:`Useful developments appear in this chat. Requested results are delivered as usual.`})]}),r&&(0,H.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r})]})}var U=[`intro`,`identity`,`voice`,`connections`],pe=[{id:`loopi`,zh:`Loopi`,en:`Loopi`},{id:`loopi-curious`,zh:`好奇`,en:`Curious`},{id:`loopi-care`,zh:`温和`,en:`Gentle`}];function me(e){return!!(e?.enabled&&(e.status===`connected`||e.connectionStatus===`connected`||e.authStatus===`connected`))}async function he(e,t){let n=await new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(t)});await l(d(`/api/agents/${encodeURIComponent(e)}/avatar`),{method:`PUT`,body:JSON.stringify({base64:n.slice(n.indexOf(`,`)+1),mimeType:t.type})}),A(e)}function ge({modelsAvailable:e,onCreated:t}){let n=u(e=>e.language)===`zh`,r=u(e=>e.language),[o,s]=(0,V.useState)(`intro`),[f,p]=(0,V.useState)({displayName:`Ada`,appearance:`loopi`,voice:null}),[m,h]=(0,V.useState)(!1),[_,v]=(0,V.useState)(!1),[y,b]=(0,V.useState)(null),[x,S]=(0,V.useState)(null),[C,T]=(0,V.useState)(null),[D,O]=(0,V.useState)(null),[A,j]=(0,V.useState)(!0),[M,P]=(0,V.useState)([]),[ie,ae]=(0,V.useState)(null),I=(0,V.useRef)(null),L=(0,V.useRef)(null),[se,B]=(0,V.useState)([]),[ue,de]=(0,V.useState)(!0),[fe,ge]=(0,V.useState)([]),[_e,W]=(0,V.useState)(null);(0,V.useEffect)(()=>{let e=!1;return l(d(`/api/personal-agent/onboarding`)).then(t=>{e||(s(t.payload.step),p(t.payload.draft))}).catch(t=>{e||b(t instanceof Error?t.message:String(t))}).finally(()=>{e||h(!0)}),()=>{e=!0}},[]),(0,V.useEffect)(()=>{if(!m)return;let e=window.setTimeout(()=>{l(d(`/api/personal-agent/onboarding`),{method:`PUT`,body:JSON.stringify({step:o,draft:f})}).catch(()=>{})},350);return()=>window.clearTimeout(e)},[f,m,o]),(0,V.useEffect)(()=>{let e=!1;return le().then(t=>{e||(t.tts&&t.enabled?O({provider:t.tts.provider,model:t.tts.model,enabled:!0}):j(!1))}).catch(()=>{e||j(!1)}),()=>{e=!0}},[]),(0,V.useEffect)(()=>{if(!D?.enabled)return;let e=!1;return ce(D.provider,D.model,`realtime`).then(t=>{e||P(t.slice(0,12))}).catch(()=>{}).finally(()=>{e||j(!1)}),()=>{e=!0}},[D]),(0,V.useEffect)(()=>{if(o!==`connections`)return;let e=!1;return de(!0),Promise.allSettled([F({page:1,pageSize:24,verification:`verified`}),ee()]).then(([t,n])=>{if(!e){if(t.status===`fulfilled`){let e=[`gmail`,`googlecalendar`,`googledrive`,`github`,`linear`];B(t.value.connectors.filter(t=>t.runtime.type===`composio`&&e.includes(t.runtime.toolkit)).sort((t,n)=>e.indexOf(t.runtime.type===`composio`?t.runtime.toolkit:``)-e.indexOf(n.runtime.type===`composio`?n.runtime.toolkit:``)))}n.status===`fulfilled`&&ge(n.value),de(!1)}}),()=>{e=!0}},[o]),(0,V.useEffect)(()=>()=>{L.current?.abort(),I.current?.close()},[]),(0,V.useEffect)(()=>()=>{C&&URL.revokeObjectURL(C)},[C]);let ve=async(e,t=f)=>{await l(d(`/api/personal-agent/onboarding`),{method:`PUT`,body:JSON.stringify({step:e,draft:t})}),s(e)},G=async e=>{b(null);let t=U[Math.max(0,Math.min(U.length-1,U.indexOf(o)+e))];try{await ve(t)}catch(e){b(e instanceof Error?e.message:String(e))}},ye=async(n=!1)=>{if(!(!e||_)){v(!0),b(null);try{let e=n?{displayName:`Ada`,appearance:`loopi`,voice:null}:f,r=e.voice&&D?.enabled&&M.some(t=>t.id===e.voice)?{provider:D.provider,model:D.model,voice:e.voice}:void 0,i=(await l(d(`/api/personal-agent`),{method:`POST`,body:JSON.stringify({displayName:e.displayName.trim()||`Ada`,appearance:e.appearance,...r?{voicePreference:r}:{}})})).payload,a=!1;if(!n&&x)try{await he(i.agentId,x),i=(await l(d(`/api/personal-agent/profile`),{method:`PATCH`,body:JSON.stringify({revision:i.revision,displayName:i.displayName,appearance:`custom`,preferences:i.preferences})})).payload}catch{a=!0}t(i,a)}catch(e){b(e instanceof Error?e.message:String(e))}finally{v(!1)}}},be=(0,V.useCallback)(async e=>{L.current?.abort(),I.current?.close();let t=new AbortController;L.current=t,ae(e),b(null);try{let n=new oe;I.current=n,await n.start();let r=await z(t.signal,e);if(t.signal.aborted)return;n.enqueue(r,()=>ae(null))}catch(e){t.signal.aborted||b(e instanceof Error?e.message:String(e)),ae(null)}},[]);if(!m)return(0,H.jsxs)(`div`,{className:`mx-auto w-full max-w-xl space-y-4 px-6 py-14`,children:[(0,H.jsx)(k,{className:`h-10 w-2/3`}),(0,H.jsx)(k,{className:`h-64 w-full rounded-2xl`}),(0,H.jsx)(k,{className:`h-12 w-full rounded-xl`})]});let K=U.indexOf(o),xe={intro:n?`创建一个和你一起做事的助手`:`Create an assistant to work with you`,identity:n?`先给它一个形象和名字`:`Choose a look and a name`,voice:n?`想让我用什么声音回应?`:`How should your assistant sound?`,connections:n?`要让我了解哪些信息?`:`What information can your assistant use?`}[o];return(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-surface-base`,children:[(0,H.jsx)(`header`,{className:`shrink-0 px-5 pt-5 sm:px-8 sm:pt-7`,children:(0,H.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl`,children:[(0,H.jsxs)(`div`,{className:`flex min-h-10 items-center justify-between gap-4`,children:[K>0?(0,H.jsxs)(`button`,{type:`button`,disabled:_,onClick:()=>void G(-1),className:`-ml-2 inline-flex min-h-10 items-center gap-1.5 rounded-lg px-2 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-40`,children:[(0,H.jsx)(g,{className:`size-4`}),n?`上一步`:`Back`]}):(0,H.jsx)(`span`,{className:`text-sm font-medium text-fg-muted`,children:n?`设置我的助手`:`Set up my assistant`}),(0,H.jsx)(i,{to:`/chat`,className:`-mr-2 inline-flex min-h-10 items-center rounded-lg px-2 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`稍后继续`:`Finish later`})]}),(0,H.jsx)(`div`,{className:`mt-4 grid grid-cols-4 gap-1.5`,role:`progressbar`,"aria-label":n?`设置进度`:`Setup progress`,"aria-valuenow":K+1,"aria-valuemin":1,"aria-valuemax":U.length,children:U.map((e,t)=>(0,H.jsx)(`span`,{className:`h-1 rounded-full transition-colors duration-200 ${t<=K?`bg-accent`:`bg-surface-active`}`},e))})]})}),(0,H.jsx)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-8 sm:px-8`,children:(0,H.jsxs)(`div`,{className:`mx-auto my-auto w-full max-w-2xl py-6 motion-safe:animate-[page-enter_220ms_ease-out]`,children:[(0,H.jsxs)(`div`,{className:`mb-8 flex items-center gap-4`,children:[(0,H.jsx)(`span`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl bg-surface-hover`,children:C?(0,H.jsx)(`img`,{src:C,alt:``,className:`size-14 rounded-xl object-cover`}):(0,H.jsx)(E,{appearance:f.appearance,className:`size-14`})}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`我的助手`:`My assistant`}),(0,H.jsx)(`p`,{className:`mt-1 text-lg font-semibold text-fg`,children:f.displayName||`Ada`})]})]}),(0,H.jsx)(`p`,{className:`mb-3 text-xs font-medium tracking-wide text-fg-subtle`,children:n?`第 ${K+1} 步 · 共 ${U.length} 步`:`Step ${K+1} of ${U.length}`}),(0,H.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-fg sm:text-3xl`,children:xe}),o===`intro`&&(0,H.jsxs)(`div`,{className:`mt-6 max-w-xl space-y-3 text-base leading-8 text-fg-muted`,children:[(0,H.jsx)(`p`,{children:n?`你可以找它讨论问题,也可以交给它一件要推进的事。`:`Talk through a question or give it something to move forward.`}),(0,H.jsx)(`p`,{children:n?`需要深入处理时,它会找合适的 Agent,并把进展带回对话。`:`It can ask a suitable Agent for deeper work and bring the progress back.`}),(0,H.jsx)(`p`,{children:n?`它能使用哪些数据和设备,由你决定。`:`You choose which data and devices it can use.`})]}),o===`identity`&&(0,H.jsxs)(`div`,{className:`mt-7 space-y-7`,children:[(0,H.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[n?`助手名字`:`Assistant name`,(0,H.jsx)(`input`,{value:f.displayName,maxLength:60,onChange:e=>p(t=>({...t,displayName:e.target.value})),onBlur:()=>p(e=>({...e,displayName:e.displayName.trim()||`Ada`})),className:`mt-2 block w-full rounded-xl border border-edge bg-surface-panel px-4 py-3 text-fg outline-none focus-visible:ring-2 focus-visible:ring-accent`})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`选择头像`:`Choose an avatar`}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[pe.map(e=>(0,H.jsxs)(`button`,{type:`button`,"aria-pressed":!x&&f.appearance===e.id,onClick:()=>{S(null),T(null),p(t=>({...t,appearance:e.id}))},className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-2xl p-3 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${!x&&f.appearance===e.id?`bg-accent/10 text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:[(0,H.jsx)(E,{appearance:e.id,className:`size-14`}),n?e.zh:e.en]},e.id)),(0,H.jsxs)(`label`,{className:`flex min-h-28 cursor-pointer flex-col items-center justify-center gap-2 rounded-2xl p-3 text-sm transition-colors focus-within:ring-2 focus-within:ring-accent ${x?`bg-accent/10 text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:[(0,H.jsx)(re,{className:`size-6`}),n?`上传图片`:`Upload image`,(0,H.jsx)(`input`,{className:`sr-only`,type:`file`,accept:`image/png,image/jpeg,image/webp`,onChange:e=>{let t=e.target.files?.[0];if(t){if(t.size>512*1024||![`image/png`,`image/jpeg`,`image/webp`].includes(t.type)){b(n?`请选择不超过 512 KB 的 PNG、JPEG 或 WebP 图片。`:`Choose a PNG, JPEG, or WebP image under 512 KB.`);return}S(t),T(URL.createObjectURL(t))}}})]})]}),(0,H.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:n?`自定义图片在创建助手时上传;刷新后需要重新选择。`:`Custom images upload when you create the assistant; select again after a refresh.`})]})]}),o===`voice`&&(0,H.jsxs)(`div`,{className:`mt-5`,children:[(0,H.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:n?`用于这个助手的语音通话;文字回答不受影响。试听不会使用麦克风。`:`This affects calls with this assistant. Text stays the same. Preview does not use your microphone.`}),A?(0,H.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[(0,H.jsx)(k,{className:`h-20 rounded-xl`}),(0,H.jsx)(k,{className:`h-20 rounded-xl`})]}):D?.enabled&&M.length>0?(0,H.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[(0,H.jsx)(`button`,{type:`button`,"aria-pressed":!f.voice,onClick:()=>p(e=>({...e,voice:null})),className:`rounded-xl p-4 text-left text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${f.voice?`bg-surface-panel text-fg-muted hover:bg-surface-hover`:`bg-accent/10 text-fg ring-1 ring-accent/40`}`,children:n?`使用默认声音`:`Use the default voice`}),M.map(e=>(0,H.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl p-3 transition-colors ${f.voice===e.id?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 rounded-lg text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-pressed":f.voice===e.id,onClick:()=>p(t=>({...t,voice:e.id})),children:[(0,H.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.name}),(0,H.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e.description||e.style||(n?`点击选择`:`Select this voice`)})]}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>void be(e.id),className:`flex size-9 shrink-0 items-center justify-center rounded-full bg-surface-hover text-fg hover:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`试听${e.name}`:`Preview ${e.name}`,children:(0,H.jsx)(R,{className:`size-4 ${ie===e.id?`text-accent`:``}`})})]},e.id))]}):(0,H.jsxs)(`div`,{className:`mt-5 rounded-xl bg-surface-panel p-5 text-sm text-fg-muted`,children:[(0,H.jsx)(`p`,{children:n?`当前没有可试听的语音。你可以先用文字对话,稍后再设置。`:`No voice is ready to preview. You can start with text and set it up later.`}),(0,H.jsx)(i,{to:`/settings/capabilities/models?configure=speech&returnTo=%2Fpersonal`,className:`mt-3 inline-block text-accent hover:underline`,children:n?`设置语音服务`:`Set up voice`})]})]}),o===`connections`&&(0,H.jsxs)(`div`,{className:`mt-5`,children:[(0,H.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:n?`现在连接,或进入对话后再添加。连接不会自动读取历史数据或创建持续关注。`:`Connect now or add sources later. Connecting does not automatically scan history or create ongoing monitoring.`}),ue?(0,H.jsxs)(`div`,{className:`mt-5 space-y-2`,children:[(0,H.jsx)(k,{className:`h-18 rounded-xl`}),(0,H.jsx)(k,{className:`h-18 rounded-xl`})]}):(0,H.jsx)(`div`,{className:`mt-5 space-y-2`,children:se.length?se.map(e=>{let t=me(fe.find(t=>t.connectorId===e.id));return(0,H.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-surface-panel p-4`,children:[(0,H.jsx)(te,{connector:e,size:`sm`}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.displayName}),(0,H.jsx)(`p`,{className:`line-clamp-2 text-xs text-fg-muted`,children:e.description})]}),t?(0,H.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-success`,children:[(0,H.jsx)(a,{className:`size-4`}),n?`已连接`:`Connected`]}):(0,H.jsx)(`button`,{type:`button`,onClick:()=>W(w(e)),className:`rounded-lg bg-surface-hover px-3 py-2 text-xs text-fg transition-colors hover:bg-surface-active focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`连接`:`Connect`})]},e.id)}):(0,H.jsx)(`p`,{className:`rounded-xl bg-surface-panel p-5 text-sm text-fg-muted`,children:n?`暂无可用的推荐服务;你仍可直接进入对话。`:`No suggested services are available. You can continue to chat.`})})]}),!e&&(0,H.jsxs)(`p`,{className:`mt-5 rounded-xl bg-warning/5 p-4 text-sm text-fg-muted`,children:[n?`开始前需要一个可用模型。`:`A compatible model is required before you start.`,` `,(0,H.jsx)(i,{to:`/settings/capabilities/models`,className:`text-accent underline`,children:n?`配置模型`:`Set up a model`})]}),y&&(0,H.jsx)(`p`,{role:`alert`,className:`mt-5 text-sm text-danger`,children:y})]},o)}),(0,H.jsx)(`footer`,{className:`shrink-0 px-5 pb-6 pt-3 sm:px-8 sm:pb-9`,children:(0,H.jsxs)(`div`,{className:`mx-auto flex w-full max-w-2xl flex-col-reverse gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,H.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n?`这些选择以后都能调整`:`You can change these choices later`}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[o===`intro`&&(0,H.jsx)(`button`,{type:`button`,disabled:!e||_,onClick:()=>void ye(!0),className:`min-h-11 rounded-lg px-3 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-40`,children:n?`用默认设置开始`:`Use defaults`}),o===`voice`&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>{let e={...f,voice:null};p(e),b(null),ve(`connections`,e).catch(e=>b(e instanceof Error?e.message:String(e)))},className:`min-h-11 rounded-lg px-3 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`跳过`:`Skip`}),(0,H.jsxs)(`button`,{type:`button`,disabled:_||o===`connections`&&!e,onClick:()=>o===`connections`?void ye():void G(1),className:`flex min-h-11 items-center gap-2 rounded-xl bg-accent px-5 text-sm font-medium text-on-accent transition-colors hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 disabled:opacity-40`,children:[_?n?`正在创建…`:`Creating…`:o===`connections`?n?`进入对话`:`Start chatting`:n?`继续`:`Continue`,` `,!_&&(0,H.jsx)(ne,{className:`size-4`})]})]})]})}),_e&&(0,H.jsx)(N,{draft:_e,onChange:W,onClose:()=>W(null),t:c(r).connectorsSettings,onInstalled:async()=>{ge(await ee()),W(null)}})]})}function _e({record:e,zh:t,onSelectVoice:n,onGreetingChange:r}){let[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(!0),[l,u]=(0,V.useState)(``),[d,f]=(0,V.useState)(null),[p,m]=(0,V.useState)([]),[h,g]=(0,V.useState)(e.voicePreference?.voice??``),[_,v]=(0,V.useState)(!1),[y,b]=(0,V.useState)(null),[x,S]=(0,V.useState)(null),C=(0,V.useRef)(null),w=(0,V.useRef)(null);(0,V.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await le();if(e||(o(t.openingGreeting===!0),!t.enabled||!t.tts))return;let n={provider:t.tts.provider,model:t.tts.model};f(n);let r=await ce(n.provider,n.model,`realtime`);e||m(r)}catch(t){e||b(t instanceof Error?t.message:String(t))}finally{e||c(!1)}})(),()=>{e=!0}},[]),(0,V.useEffect)(()=>()=>{w.current?.abort(),C.current?.close()},[]);let T=()=>{w.current?.abort(),w.current=null,C.current?.close(),C.current=null,S(null)},E=async e=>{if(x!==null){T();return}T(),b(null);let n=new AbortController;w.current=n,S(e);try{let t=new oe;C.current=t,await t.start();let r=await z(n.signal,e);n.signal.aborted||t.enqueue(r,()=>{w.current===n&&(S(null),w.current=null,C.current=null,t.close())})}catch(e){if(!n.signal.aborted){let n=e?.body?.error?.code;b(t&&n===`unsupported_voice`?`当前音色暂不可用,请刷新语音目录或选择其他音色。`:e instanceof Error?e.message:String(e))}w.current===n&&T()}},D=async e=>{if(_||e===h)return;T();let t=h;g(e),u(``),v(!0),b(null);try{await n(e&&d?{provider:d.provider,model:d.model,voice:e}:null)||g(t)}catch(e){g(t),b(e instanceof Error?e.message:String(e))}finally{v(!1)}},O=p.find(e=>e.id===h),A=t?`默认声音`:`Default voice`,j=O?.name||(h?t?`当前音色不可用`:`Current voice unavailable`:A),N=l.trim().toLocaleLowerCase(),P=p.filter(e=>!N||`${e.name} ${e.description??``} ${e.style??``}`.toLocaleLowerCase().includes(N)).map(e=>({value:e.id,label:e.name}));return(0,H.jsxs)(`section`,{className:`border-t border-edge pt-5`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:t?`通话声音`:`Call voice`}),s?(0,H.jsx)(`div`,{className:`mt-3`,"aria-busy":`true`,children:(0,H.jsx)(k,{className:`h-10 w-full`})}):d&&p.length?(0,H.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,H.jsx)(I,{value:h,selectedLabel:j,options:P,placeholder:A,emptyLabel:A,ariaLabel:t?`选择通话音色`:`Choose call voice`,disabled:_,onChange:e=>void D(e),searchPlaceholder:p.length>8?t?`搜索音色`:`Search voices`:void 0,searchValue:l,onSearchChange:u,statusMessage:N&&!P.length?t?`没有匹配的音色`:`No matching voices`:void 0})}),(0,H.jsxs)(`button`,{type:`button`,disabled:_||!!(h&&!O),onClick:()=>void E(h),className:`touch-target flex h-10 shrink-0 items-center justify-center gap-1.5 rounded-lg border border-edge px-3 text-sm text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,title:x===null?t?`试听${j}`:`Preview ${j}`:t?`停止试听`:`Stop preview`,"aria-label":x===null?t?`试听${j}`:`Preview ${j}`:t?`停止试听`:`Stop preview`,children:[x===null?(0,H.jsx)(R,{className:`size-4`,"aria-hidden":!0}):(0,H.jsx)(M,{className:`size-4 text-accent`,"aria-hidden":!0}),x===null?t?`试听`:`Preview`:t?`停止`:`Stop`]})]}),(0,H.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:O?.description||O?.style||(h?t?`选择后自动保存,用于之后的语音通话。`:`Saved automatically for future voice calls.`:t?`跟随语音服务的默认音色。`:`Uses the voice service’s default voice.`)})]}):(0,H.jsxs)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:[t?`当前没有可用音色。`:`No voice is ready.`,` `,(0,H.jsx)(i,{to:`/settings/capabilities/models?configure=speech&returnTo=%2Fpersonal`,className:`text-accent underline`,children:t?`设置语音服务`:`Set up voice`})]}),r&&a&&(0,H.jsxs)(`label`,{className:`mt-4 flex items-center justify-between gap-3 text-sm text-fg`,children:[t?`连接时打招呼`:`Greet me when connected`,(0,H.jsx)(`input`,{type:`checkbox`,checked:e.voiceCallPreferences?.openingGreetingEnabled??!0,disabled:_,onChange:e=>{let t=e.target.checked;v(!0),r(t).catch(e=>b(String(e))).finally(()=>v(!1))}})]}),y&&(0,H.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:y})]})}var W=new h;function ve({conversationId:e,zh:t,onSaved:n}){let r=f(t=>t.sessions[e]),[i,a]=(0,V.useState)(!0),[o,s]=(0,V.useState)(``);(0,V.useEffect)(()=>{let t=!0;return W.loadSessionAgentConfig(e).then(n=>{t&&p(e,n)}).catch(e=>{t&&s(String(e))}).finally(()=>{t&&a(!1)}),()=>{t=!1}},[e]);let l=!!r?.modelConfigSaving;async function u(t,i){f.getState().patchSessionMeta(e,{modelConfigSaving:!0});try{p(e,await W.patchSessionAgentConfig(e,{model:t,thinkingLevel:i,configVersion:r?.configVersion})),await n()}catch(t){let n=await W.loadSessionAgentConfig(e).catch(()=>null);throw n&&p(e,n),t}finally{f.getState().patchSessionMeta(e,{modelConfigSaving:!1})}}return(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:t?`对话模型与思考强度`:`Conversation model and thinking`}),i?(0,H.jsx)(k,{className:`h-9 w-full`}):(0,H.jsx)(O,{chat:c(t?`zh`:`en`).chat,sessionModel:r?.model??``,thinkingLevel:r?.thinkingLevel??`off`,modelDisabled:l,thinkingDisabled:l,onModelChange:u,onThinkingChange:e=>u(r?.model??``,e)}),o&&(0,H.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:o})]})}var G=5;function ye(e){let t=e.replace(/\s+/g,` `).trim();if(t.length<=58)return t;let n=t.replace(/([^)]{1,80})|\([^)]{1,80}\)/g,``).replace(/([A-Za-z0-9])(?=[\u4e00-\u9fff])/g,`$1 `).replace(/\s+/g,` `).trim(),r=n.split(/[。!?;;,]/,1)[0]?.trim()||n;return r.length>58?`${r.slice(0,57).trimEnd()}…`:r}function be(e,t){if(e.phase===`closed`)return{label:t?`已结束`:`Finished`,tone:`bg-fg-subtle`};let n=e.operationalState??e.runStatus;return n===`running`?{label:t?`正在执行`:`Working`,tone:`bg-accent`}:n===`queued`?{label:t?`等待开始`:`Queued`,tone:`bg-fg-subtle`}:n===`failed`?{label:t?`执行失败`:`Failed`,tone:`bg-danger`}:n===`waiting`?{label:t?`等待继续`:`Waiting`,tone:`bg-warning`}:n===`blocked`?{label:t?`已阻塞`:`Blocked`,tone:`bg-warning`}:n===`verifying`?{label:t?`正在验证`:`Verifying`,tone:`bg-accent`}:n===`cancelled`?{label:t?`执行已取消`:`Cancelled`,tone:`bg-fg-subtle`}:e.phase===`review`?{label:t?`等待验收`:`In review`,tone:`bg-warning`}:e.phase===`active`?{label:t?`正在推进`:`In progress`,tone:`bg-accent`}:e.phase===`ready`?{label:t?`准备开始`:`Ready`,tone:`bg-fg-subtle`}:{label:t?`待处理`:`Planned`,tone:`bg-fg-subtle`}}function K(e){let t=(0,B.c)(30),{item:n,zh:r}=e,a;t[0]!==n||t[1]!==r?(a=be(n,r),t[0]=n,t[1]=r,t[2]=a):a=t[2];let s=a,c;t[3]===n.id?c=t[4]:(c=o(`/personal`,n.id),t[3]=n.id,t[4]=c);let l=`mt-2 size-1.5 shrink-0 rounded-full ${s.tone}`,u;t[5]===l?u=t[6]:(u=(0,H.jsx)(`span`,{className:l,"aria-hidden":!0}),t[5]=l,t[6]=u);let d;t[7]===n.title?d=t[8]:(d=ye(n.title),t[7]=n.title,t[8]=d);let f;t[9]===d?f=t[10]:(f=(0,H.jsx)(`span`,{className:`line-clamp-2 break-words text-sm font-medium leading-5 text-fg`,children:d}),t[9]=d,t[10]=f);let p;t[11]===s.label?p=t[12]:(p=(0,H.jsx)(`span`,{children:s.label}),t[11]=s.label,t[12]=p);let m;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,H.jsx)(`span`,{className:`text-fg-subtle`,"aria-hidden":!0,children:`·`}),t[13]=m):m=t[13];let h=r?`zh`:`en`,g;t[14]!==n.updatedAt||t[15]!==h?(g=T(n.updatedAt,h),t[14]=n.updatedAt,t[15]=h,t[16]=g):g=t[16];let _;t[17]===g?_=t[18]:(_=(0,H.jsx)(`span`,{children:g}),t[17]=g,t[18]=_);let v;t[19]!==_||t[20]!==p?(v=(0,H.jsxs)(`span`,{className:`mt-1.5 flex items-center gap-2 text-xs text-fg-muted`,children:[p,m,_]}),t[19]=_,t[20]=p,t[21]=v):v=t[21];let y;t[22]!==v||t[23]!==f?(y=(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[f,v]}),t[22]=v,t[23]=f,t[24]=y):y=t[24];let b;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,H.jsx)(D,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle opacity-0 transition-opacity duration-150 group-hover:opacity-100 group-focus-visible:opacity-100`,"aria-hidden":!0}),t[25]=b):b=t[25];let x;return t[26]!==y||t[27]!==c||t[28]!==u?(x=(0,H.jsxs)(i,{to:c,className:`group flex min-w-0 items-start gap-3 rounded-2xl bg-surface-panel px-4 py-4 transition-colors duration-150 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[u,y,b]}),t[26]=y,t[27]=c,t[28]=u,t[29]=x):x=t[29],x}var xe=[{id:`direct`,warmth:`reserved`,zh:`直接`,en:`Direct`},{id:`natural`,warmth:`balanced`,zh:`自然`,en:`Natural`},{id:`gentle`,warmth:`gentle`,zh:`温和`,en:`Gentle`}],Se=[{id:`loopi`,zh:`Loopi`,en:`Loopi`,color:`bg-slate-100/50 dark:bg-slate-400/10`},{id:`loopi-curious`,zh:`好奇`,en:`Curious`,color:`bg-blue-100/50 dark:bg-blue-400/10`},{id:`loopi-care`,zh:`温和`,en:`Gentle`,color:`bg-violet-100/50 dark:bg-violet-400/10`}];function Ce(e,t){return e.warmth===`reserved`?t?`你可以直接说目标或问题。我会先给结论,需要时再展开。`:`Tell me the goal or question. I’ll lead with the answer and expand when useful.`:e.warmth===`gentle`?t?`想聊一件事,或让我帮你推进工作,都可以从这里开始。我会认真听,也会把下一步说清楚。`:`You can talk something through or ask me to move work forward. I’ll listen carefully and make the next step clear.`:t?`有什么想讨论或推进的事?直接告诉我就好。`:`What would you like to discuss or move forward? Just tell me what is on your mind.`}function we(e){return xe.find(t=>t.warmth===e.warmth)?.id??`natural`}function Te(){let e=C(),t=(0,V.useRef)(e);t.current=e;let n=u(e=>e.language)===`zh`,r=S(e=>e.setPageHeader),i=S(e=>e.clearPageHeader),[a,o]=(0,V.useState)(null),c=(0,V.useRef)(null),f=(0,V.useRef)(Promise.resolve()),[p,m]=(0,V.useState)([]),[h,g]=(0,V.useState)(!0),[w,T]=(0,V.useState)(0),[D,O]=(0,V.useState)(null),[M,N]=(0,V.useState)(!0),[ee,te]=(0,V.useState)(!1),[ne,oe]=(0,V.useState)(`natural`),[F,R]=(0,V.useState)(`loopi`),[z,ce]=(0,V.useState)(!1),le=(0,V.useRef)(null),B=(0,V.useRef)(null),ue=(0,V.useRef)(null),[de,U]=(0,V.useState)(``),[pe,me]=(0,V.useState)(`untangle`),[he,W]=(0,V.useState)(`none`),[ye,be]=(0,V.useState)(`balanced`),[Te,Ee]=(0,V.useState)(`decisions`),[De,Oe]=(0,V.useState)(!1),[ke,q]=(0,V.useState)(!1),[J,Ae]=(0,V.useState)(!1),[Y,je]=(0,V.useState)(null),[Me,Ne]=(0,V.useState)(!1),[X,Pe]=(0,V.useState)(!1),[Fe,Ie]=(0,V.useState)(!1),[Z,Le]=(0,V.useState)(0),Q=(0,V.useRef)(0),Re=(0,V.useCallback)(()=>{Ae(!1),q(!1),Oe(!0)},[]),ze=(0,V.useCallback)(()=>{Ae(!1),q(!1),Oe(e=>!e)},[]),Be=(0,V.useCallback)(async()=>{try{let[e,t]=await Promise.all([l(d(`/api/personal-agent`)),l(d(`/api/personal-agent/models`))]);if(c.current=e.payload,o(e.payload),e.payload?.state===`ready`){let e=await l(d(`/api/personal-agent/onboarding`));N(!e.payload.completed||e.payload.welcomeDone)}window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:e.payload})),e.payload&&window.dispatchEvent(new Event(`session-updated`)),m(t.payload),e.payload&&(U(e.payload.displayName),R(e.payload.appearance),oe(we(e.payload.preferences)),me(e.payload.preferences.supportMode??`untangle`),W(e.payload.preferences.humor??`none`),be(e.payload.preferences.detailLevel??`balanced`),Ee(e.payload.preferences.proactivity??`decisions`))}catch(e){O(e instanceof Error?e.message:String(e))}finally{g(!1)}},[]);(0,V.useEffect)(()=>{Be()},[Be]);let $=(0,V.useCallback)(e=>{T(e=>e+1),O(null);let t=f.current.then(async()=>{let t=c.current;if(!t)return!1;let n=e.displayName?.trim()||t.displayName,r=e.appearance??t.appearance,i={...t.preferences,...e.preferences},a=e.voicePreference===void 0?t.voicePreference:e.voicePreference;if(n===t.displayName&&r===t.appearance&&JSON.stringify(i)===JSON.stringify(t.preferences)&&JSON.stringify(a)===JSON.stringify(t.voicePreference)&&(!e.voiceCallPreferences||JSON.stringify(e.voiceCallPreferences)===JSON.stringify(t.voiceCallPreferences)))return!0;try{let s=await l(d(`/api/personal-agent/profile`),{method:`PATCH`,body:JSON.stringify({revision:t.revision,displayName:n,appearance:r,preferences:i,...e.voicePreference===void 0?{}:{voicePreference:a},...e.voiceCallPreferences?{voiceCallPreferences:e.voiceCallPreferences}:{}})});return c.current=s.payload,o(s.payload),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:s.payload})),!0}catch(e){return O(e instanceof Error?e.message:String(e)),!1}}).finally(()=>T(e=>e-1));return f.current=t,t},[]),Ve=async e=>{if(a){O(null);try{if(e){let t=await l(d(`/api/personal-agent/profile`),{method:`PATCH`,body:JSON.stringify({revision:a.revision,displayName:a.displayName,appearance:a.appearance,preferences:{...a.preferences,supportMode:e}})});c.current=t.payload,o(t.payload)}await l(d(`/api/personal-agent/onboarding/welcome`),{method:`POST`,body:`{}`}),N(!0)}catch(e){O(e instanceof Error?e.message:String(e))}}},He=(0,V.useCallback)(async()=>{let e=++Q.current;Ae(!0),je(null),Ne(!1),Pe(!1),Ie(!1),Le(0);try{let t=await l(d(`/api/personal-agent/activity?limit=${G}&offset=0`));if(e!==Q.current)return;je(t.payload),Le(t.payload.items.length)}catch{e===Q.current&&Ne(!0)}},[]),Ue=(0,V.useCallback)(async()=>{if(!Y||X||Z>=Y.total)return;let e=Q.current;Pe(!0),Ie(!1);try{let t=await l(d(`/api/personal-agent/activity?limit=${G}&offset=${Z}`));if(e!==Q.current)return;je(e=>e?{total:t.payload.total,items:[...e.items,...t.payload.items.filter(t=>!e.items.some(e=>e.id===t.id))]}:t.payload),Le(e=>e+t.payload.items.length)}catch{e===Q.current&&Ie(!0)}finally{e===Q.current&&Pe(!1)}},[Y,Z,X]);(0,V.useEffect)(()=>{if(!J||!Y||X)return;let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(async()=>{let e=Q.current;try{let t=await l(d(`/api/personal-agent/activity?limit=${Math.max(G,Math.min(100,Z))}&offset=0`));if(e!==Q.current)return;je(t.payload),Le(t.payload.items.length)}catch{}},120)},n=window.setInterval(t,5e3);return window.addEventListener(`task-changed-v2`,t),window.addEventListener(`gateway-realtime-connected`,t),()=>{window.clearTimeout(e),window.clearInterval(n),window.removeEventListener(`task-changed-v2`,t),window.removeEventListener(`gateway-realtime-connected`,t)}},[Y,Z,X,J]);let We=async e=>{if(!a||![`image/png`,`image/jpeg`,`image/webp`].includes(e.type)){O(n?`请选择 PNG、JPEG 或 WebP 图片。`:`Choose a PNG, JPEG, or WebP image.`);return}if(e.size===0||e.size>512*1024){O(n?`图片大小不能超过 512 KB。`:`Image must be 512 KB or smaller.`);return}ce(!0),O(null);try{let t=await new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(e)});await l(d(`/api/agents/${encodeURIComponent(a.agentId)}/avatar`),{method:`PUT`,body:JSON.stringify({base64:t.slice(t.indexOf(`,`)+1),mimeType:e.type})}),A(a.agentId),R(`custom`),q(!1),await $({appearance:`custom`})}catch(e){O(e instanceof Error?e.message:String(e))}finally{ce(!1)}};(0,V.useLayoutEffect)(()=>{let o=a?.state===`ready`,c=o?a.appearance:F,l=o?a.displayName:`Ada`;return r({startExtra:null,main:(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[o?(0,H.jsx)(`button`,{ref:ue,type:`button`,onClick:ze,"aria-expanded":De,className:`touch-target -m-1 shrink-0 rounded-full p-1 transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`编辑${l}的资料`:`Edit ${l}'s profile`,title:n?`资料`:`Profile`,children:(0,H.jsx)(`span`,{className:`flex size-8 items-center justify-center`,children:(0,H.jsx)(E,{appearance:c,agentId:a?.agentId,className:`size-8`})})}):(0,H.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center`,children:(0,H.jsx)(E,{appearance:c,agentId:a?.agentId,className:`size-8`})}),(0,H.jsx)(`h1`,{className:`min-w-0 truncate text-sm font-semibold text-fg sm:text-base`,children:l})]}),end:o?(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`button`,{type:`button`,disabled:e.active,onClick:()=>{a?.state===`ready`&&t.current.open({conversationId:a.conversationId,name:a.displayName,mode:`assistant`})},className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50`,"aria-label":n?`语音通话`:`Voice call`,title:n?`语音通话`:`Voice call`,children:(0,H.jsx)(y,{className:`size-5`})}),(0,H.jsxs)(x,{open:J,onOpenChange:e=>{e?He():Ae(!1)},children:[(0,H.jsx)(b,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,"aria-pressed":J,className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":n?`正在做的事`:`Activity`,children:(0,H.jsx)(P,{className:`size-5`})})}),(0,H.jsx)(j,{children:(0,H.jsxs)(L,{side:`bottom`,align:`end`,sideOffset:8,collisionPadding:8,"aria-label":n?`派发的任务`:`Delegated tasks`,className:`z-50 flex h-[min(34rem,calc(100dvh-6rem))] w-[min(25rem,calc(100vw-1rem))] min-h-0 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-xl focus:outline-none`,children:[(0,H.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 px-6 pb-3 pt-6`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-fg`,children:n?`交给我推进的事`:`Delegated work`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:Y?n?`最近更新 · 共 ${Y.total} 项`:`Recently updated · ${Y.total} total`:n?`查看任务进展与结果`:`Follow progress and results`})]}),(0,H.jsx)(v,{className:`touch-target -mr-2 -mt-1 rounded-lg p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n?`关闭活动`:`Close activity`,children:(0,H.jsx)(s,{className:`size-4`})})]}),(0,H.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 pb-5 pt-3`,children:[!Y&&!Me&&(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(k,{className:`h-18 rounded-2xl`}),(0,H.jsx)(k,{className:`h-18 rounded-2xl`}),(0,H.jsx)(k,{className:`h-18 rounded-2xl`})]}),Me&&(0,H.jsxs)(`div`,{className:`px-5 py-12 text-center`,children:[(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`暂时无法读取任务`:`Could not load tasks`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>void He(),className:`mt-3 rounded-lg px-3 py-2 text-sm text-accent hover:bg-surface-hover`,children:n?`重试`:`Try again`})]}),Y?.items.length===0&&(0,H.jsxs)(`div`,{className:`px-5 py-16 text-center`,children:[(0,H.jsx)(P,{className:`mx-auto size-7 text-fg-subtle`,"aria-hidden":!0}),(0,H.jsx)(`p`,{className:`mt-4 text-sm font-medium text-fg`,children:n?`还没有派发的任务`:`No delegated work yet`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n?`你可以在对话里直接告诉我想推进的事。`:`Tell me what you would like to move forward in chat.`})]}),Y&&Y.items.length>0&&(0,H.jsx)(`div`,{className:`space-y-2`,children:Y.items.map(e=>(0,H.jsx)(K,{item:e,zh:n},e.id))}),Y&&Z<Y.total&&(0,H.jsxs)(`div`,{className:`pt-4 text-center`,children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>void Ue(),disabled:X,className:`min-h-10 rounded-xl bg-surface-panel px-5 text-sm font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:opacity-50`,children:X?n?`正在加载…`:`Loading…`:n?`加载更多`:`Load more`}),Fe&&(0,H.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:n?`加载失败,请重试`:`Could not load more. Try again.`})]})]})]})})]}),(0,H.jsx)(`button`,{ref:B,type:`button`,onClick:ze,"aria-expanded":De,className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":n?`回应偏好`:`Response preferences`,children:(0,H.jsx)(ae,{className:`size-5`})})]}):null}),()=>i()},[Y,Me,Z,X,Fe,F,i,Ue,He,a,r,J,De,ze,e.active,n]);function Ge(){return a?(0,H.jsxs)(x,{open:De,onOpenChange:e=>{Oe(e),e||q(!1)},children:[(0,H.jsx)(se,{virtualRef:B}),(0,H.jsx)(j,{children:(0,H.jsxs)(L,{side:`bottom`,align:`end`,sideOffset:8,collisionPadding:8,"aria-label":n?`编辑 Personal AI`:`Edit Personal AI`,onInteractOutside:e=>{e.target instanceof Node&&(B.current?.contains(e.target)||ue.current?.contains(e.target))&&e.preventDefault()},className:`z-50 flex h-[min(38rem,calc(100dvh-6rem))] w-[min(28rem,calc(100vw-1rem))] min-h-0 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-xl outline-none`,children:[(0,H.jsxs)(`div`,{className:`relative flex shrink-0 flex-col items-center px-5 pt-5 text-center`,children:[(0,H.jsx)(`button`,{type:`button`,disabled:z,onClick:()=>q(e=>!e),"aria-expanded":ke,"aria-controls":`personal-appearance-options`,"aria-label":n?`选择头像`:`Choose avatar`,className:`rounded-full transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,H.jsx)(E,{appearance:F,agentId:a.agentId,className:`size-20`})}),(0,H.jsx)(`input`,{id:`personal-name`,"aria-label":n?`助手名称`:`Assistant name`,value:de,onChange:e=>U(e.target.value),onBlur:e=>{let t=e.currentTarget.value.trim();t?(U(t),$({displayName:t})):U(c.current?.displayName??``)},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.currentTarget.value=c.current?.displayName??``,U(e.currentTarget.value),e.currentTarget.blur())},maxLength:60,placeholder:`Ada`,className:`mt-3 w-full min-w-0 rounded-lg border border-transparent bg-transparent px-2 py-1 text-center text-lg font-semibold text-fg outline-none transition-colors hover:border-edge focus:border-edge focus:bg-surface-base focus-visible:ring-2 focus-visible:ring-accent`}),w>0&&(0,H.jsx)(`span`,{className:`absolute right-4 top-4 text-xs text-fg-muted`,children:n?`正在保存…`:`Saving…`})]}),(0,H.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-6 overflow-y-auto overscroll-contain px-5 py-5`,children:[D&&(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:D}),ke&&(0,H.jsxs)(`section`,{id:`personal-appearance-options`,children:[(0,H.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`形象`:`Appearance`}),(0,H.jsxs)(`div`,{className:`grid grid-cols-4 gap-2`,children:[Se.map(e=>(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{R(e.id),q(!1),$({appearance:e.id})},"aria-pressed":F===e.id,className:`flex min-w-0 flex-col items-center gap-1.5 rounded-xl px-1 py-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${F===e.id?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,H.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full ${e.color}`,children:(0,H.jsx)(E,{appearance:e.id,className:`size-8`})}),(0,H.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:n?e.zh:e.en})]},e.id)),(0,H.jsx)(`input`,{ref:le,type:`file`,accept:`image/png,image/jpeg,image/webp`,className:`sr-only`,"aria-label":n?`上传头像`:`Upload avatar`,onChange:e=>{let t=e.currentTarget.files?.[0];t&&We(t),e.currentTarget.value=``}}),(0,H.jsxs)(`button`,{type:`button`,disabled:z,onClick:()=>le.current?.click(),"aria-pressed":F===`custom`,className:`flex min-w-0 flex-col items-center gap-1.5 rounded-xl px-1 py-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50 ${F===`custom`?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,H.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full bg-surface-panel`,children:F===`custom`?(0,H.jsx)(E,{appearance:`custom`,agentId:a.agentId,className:`size-8`}):(0,H.jsx)(re,{className:`size-4 text-fg-muted`,"aria-hidden":!0})}),(0,H.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:z?n?`上传中…`:`Uploading…`:n?`上传`:`Upload`})]})]})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`语气`:`Tone`}),(0,H.jsx)(_,{className:`grid grid-cols-3 gap-2`,role:`group`,"aria-label":n?`语气`:`Tone`,indicatorClassName:`rounded-xl bg-accent/10 ring-1 ring-accent/40`,children:xe.map(e=>(0,H.jsx)(`button`,{type:`button`,onClick:()=>{oe(e.id),$({preferences:{warmth:e.warmth}})},"aria-pressed":ne===e.id,className:`min-h-10 rounded-xl px-2 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${ne===e.id?`bg-accent/10 font-medium text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:n?e.zh:e.en},e.id))})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`棘手时`:`When things get tricky`}),(0,H.jsx)(_,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":n?`棘手时`:`When things get tricky`,indicatorClassName:`rounded-full bg-accent/10 ring-1 ring-accent/40`,children:[[`listen`,n?`先听`:`Listen`],[`untangle`,n?`理清`:`Untangle`],[`solutions`,n?`给办法`:`Suggest`]].map(([e,t])=>(0,H.jsx)(`button`,{type:`button`,"aria-pressed":pe===e,onClick:()=>{me(e),$({preferences:{supportMode:e}})},className:`min-h-9 rounded-full px-3 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${pe===e?`bg-accent/10 text-fg ring-1 ring-accent/40`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`}`,children:t},e))})]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`mb-2 text-sm font-medium text-fg`,children:n?`回答长度`:`Length`}),(0,H.jsx)(I,{value:ye??`balanced`,options:[{value:`brief`,label:n?`简短`:`Brief`},{value:`balanced`,label:n?`适中`:`Balanced`},{value:`detailed`,label:n?`详细`:`Detailed`}],placeholder:n?`选择长度`:`Choose length`,allowEmpty:!1,onChange:e=>{let t=e;be(t),$({preferences:{detailLevel:t}})}})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`mb-2 text-sm font-medium text-fg`,children:n?`主动更新`:`Updates`}),(0,H.jsx)(I,{value:Te??`decisions`,options:[{value:`decisions`,label:n?`结果与决定`:`Results only`},{value:`important`,label:n?`重要进展`:`Milestones`},{value:`open`,label:n?`多提建议`:`Suggestions`}],placeholder:n?`选择频率`:`Choose frequency`,allowEmpty:!1,onChange:e=>{let t=e;Ee(t),$({preferences:{proactivity:t}})}})]})]}),(0,H.jsxs)(`details`,{className:`text-sm text-fg-muted`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer select-none`,children:n?`更多偏好`:`More preferences`}),(0,H.jsxs)(`div`,{className:`mt-3`,children:[(0,H.jsx)(`p`,{className:`mb-2 font-medium text-fg`,children:n?`轻松程度`:`Humor`}),(0,H.jsx)(I,{value:he??`none`,options:[{value:`none`,label:n?`不加玩笑`:`None`},{value:`occasional`,label:n?`偶尔轻松`:`Sometimes`},{value:`playful`,label:n?`活泼`:`Playful`}],placeholder:n?`选择程度`:`Choose level`,allowEmpty:!1,onChange:e=>{let t=e;W(t),$({preferences:{humor:t}})}})]})]}),(0,H.jsx)(fe,{zh:n}),(0,H.jsx)(_e,{onGreetingChange:e=>$({voiceCallPreferences:{openingGreetingEnabled:e}}),record:a,zh:n,onSelectVoice:e=>$({voicePreference:e})}),(0,H.jsx)(`div`,{className:`border-t border-edge pt-5`,children:(0,H.jsx)(ve,{conversationId:a.conversationId,zh:n,onSaved:async()=>{let e=await l(d(`/api/personal-agent`));e.ok&&e.payload&&(c.current=e.payload,o(e.payload))}})})]})]})})]}):null}return h?(0,H.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl space-y-5 px-6 py-12`,children:[(0,H.jsx)(k,{className:`h-20 w-20 rounded-full`}),(0,H.jsx)(k,{className:`h-9 w-72`}),(0,H.jsx)(k,{className:`h-44 w-full rounded-2xl`})]}):a?.state===`ready`?(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col bg-surface-panel`,children:[ee&&(0,H.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 items-center justify-between gap-3 border-b border-warning/30 bg-warning/5 px-5 py-3 text-sm text-fg-muted`,children:[(0,H.jsx)(`span`,{children:n?`助手已创建,头像上传未完成。可在资料设置中重新上传。`:`Your assistant is ready. Upload the avatar again in profile settings.`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>{te(!1),Re()},className:`shrink-0 text-accent hover:underline`,children:n?`打开设置`:`Open settings`})]}),(0,H.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,H.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,H.jsx)(ie,{embedded:!0,personal:!0,personalWelcome:{name:a.displayName,addressAs:a.userCallName??void 0,avatar:(0,H.jsx)(E,{appearance:a.appearance,agentId:a.agentId,className:`size-14`}),opening:Ce(a.preferences,n),showSupportChoice:!M,onChooseSupport:e=>void Ve(e),onSkipSupport:()=>void Ve(),supportChoiceError:D},conversationId:a.conversationId})})}),Ge()]}):(0,H.jsx)(ge,{modelsAvailable:p.length>0,onCreated:(e,t)=>{c.current=e,o(e),U(e.displayName),N(!1),te(t),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:e})),window.dispatchEvent(new Event(`session-updated`))}})}export{Te as PersonalPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./x-B_N4OPjy.js";import{a as o,n as s,r as c}from"./locale-store-D5h-Ha6-.js";import{a as l,i as u,n as d,o as ee,r as te,s as ne,t as re}from"./dist-BGTk37IG.js";import{a as ie,i as ae}from"./vendor-swr-BIWyz7Rc.js";import{Au as oe,Kc as f,Rc as p}from"./index-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./x-B_N4OPjy.js";import{a as o,n as s,r as c}from"./locale-store-D5h-Ha6-.js";import{a as l,i as u,n as d,o as ee,r as te,s as ne,t as re}from"./dist-BGTk37IG.js";import{a as ie,i as ae}from"./vendor-swr-BIWyz7Rc.js";import{Au as oe,Kc as f,Rc as p}from"./index-K2cy4f-3.js";import{n as se}from"./capability-links-DzQWK1Fh.js";import{t as ce}from"./capability-icon-DVoZxEgW.js";import{a as le,i as m,n as h,t as g}from"./plugin-presentation-CPEwVLd4.js";var _=n(),v=e(t(),1),y=r();function b(e){let t=(0,_.c)(61),{pluginId:n,initialConnect:r,onClose:b}=e,x=r===void 0?!1:r,S=s(ue).startsWith(`zh`),{mutate:C}=ie(),[w,T]=(0,v.useState)(!1),E=(0,v.useRef)(document.activeElement instanceof HTMLElement?document.activeElement:null),D;t[0]===n?D=t[1]:(D=async()=>{let e=await o(c(`/api/extensions/agent-plugins/${encodeURIComponent(n)}`));if(!e.ok)throw Error(e.error??`Plugin not found`);return e.payload},t[0]=n,t[1]=D);let O;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(O={revalidateOnFocus:!0},t[2]=O):O=t[2];let{data:k,error:A,mutate:j}=ae(`plugin-details:${n}`,D,O),M=k?h(k,S):S?`插件详情`:`Plugin details`,N=k?.localizations?.[S?`zh-CN`:`en`]?.description??k?.description;if(w&&k){let e;t[3]!==j||t[4]!==T?(e=()=>{T(!1),j()},t[3]=j,t[4]=T,t[5]=e):e=t[5];let n;return t[6]!==k||t[7]!==b||t[8]!==e?(n=(0,y.jsx)(m,{extension:k,onUninstalled:b,onClose:e}),t[6]=k,t[7]=b,t[8]=e,t[9]=n):n=t[9],n}let P;t[10]===b?P=t[11]:(P=e=>{e||b()},t[10]=b,t[11]=P);let F;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,y.jsx)(l,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[12]=F):F=t[12];let I;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(I=e=>{E.current?.isConnected&&(e.preventDefault(),E.current.focus({preventScroll:!0}))},t[13]=I):I=t[13];let L=k?.branding?.iconUrl,R;t[14]===L?R=t[15]:(R=(0,y.jsx)(ce,{iconUrl:L,fallback:oe}),t[14]=L,t[15]=R);let z;t[16]===M?z=t[17]:(z=(0,y.jsx)(ne,{className:`truncate text-base font-semibold text-fg`,children:M}),t[16]=M,t[17]=z);let B;t[18]===k?B=t[19]:(B=k?(0,y.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:[k.version,` · `,k.name]}):null,t[18]=k,t[19]=B);let V;t[20]!==B||t[21]!==z?(V=(0,y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[z,B]}),t[20]=B,t[21]=z,t[22]=V):V=t[22];let H=S?`关闭插件详情`:`Close plugin details`,U;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,y.jsx)(a,{className:`size-5`,"aria-hidden":!0}),t[23]=U):U=t[23];let W;t[24]===H?W=t[25]:(W=(0,y.jsx)(d,{asChild:!0,children:(0,y.jsx)(f,{variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":H,children:U})}),t[24]=H,t[25]=W);let G;t[26]!==V||t[27]!==W||t[28]!==R?(G=(0,y.jsxs)(`header`,{className:`flex shrink-0 items-center gap-3 border-b border-edge px-5 py-4`,children:[R,V,W]}),t[26]=V,t[27]=W,t[28]=R,t[29]=G):G=t[29];let K=S?`查看插件能力、管理账号连接与授权。关闭后返回原来的列表。`:`View plugin capabilities and manage account connections. Close to return to the list.`,q;t[30]===K?q=t[31]:(q=(0,y.jsx)(u,{className:`sr-only`,children:K}),t[30]=K,t[31]=q);let J;t[32]!==k||t[33]!==N||t[34]!==A||t[35]!==x||t[36]!==C||t[37]!==b||t[38]!==n||t[39]!==j||t[40]!==S?(J=(0,y.jsx)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto p-5`,children:A?(0,y.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:String(A)}):k?(0,y.jsxs)(y.Fragment,{children:[N?(0,y.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:N}):null,(0,y.jsx)(le,{initialConnect:x,extension:k,zh:S,onChanged:async()=>{await j(),await C(`gateway-extensions-list`)}},n),k.components?.skills.length?(0,y.jsxs)(`section`,{className:`space-y-3 border-t border-edge pt-5`,children:[(0,y.jsx)(`h3`,{className:`text-sm font-medium`,children:S?`技能(${k.components.skills.length})`:`Skills (${k.components.skills.length})`}),(0,y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:k.components.skills.map(e=>(0,y.jsx)(i,{onClick:b,to:`/capabilities/skills?${new URLSearchParams({tab:`installed`,source:`plugin`,q:k.dialect===`portable`?e.name:`${n}.${e.name}`})}`,className:`max-w-full break-words rounded-lg border border-edge px-3 py-2 text-sm text-accent hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:e.name},e.name))})]}):null]}):(0,y.jsxs)(`div`,{className:`space-y-4`,"aria-busy":`true`,children:[(0,y.jsx)(p,{className:`h-14 w-full`}),(0,y.jsx)(p,{className:`h-28 w-full`}),(0,y.jsx)(p,{className:`h-40 w-full`})]})}),t[32]=k,t[33]=N,t[34]=A,t[35]=x,t[36]=C,t[37]=b,t[38]=n,t[39]=j,t[40]=S,t[41]=J):J=t[41];let Y;t[42]!==k||t[43]!==T||t[44]!==S?(Y=k?(0,y.jsx)(f,{variant:`ghost`,onClick:()=>T(!0),children:S?`管理插件`:`Manage plugin`}):(0,y.jsx)(`span`,{}),t[42]=k,t[43]=T,t[44]=S,t[45]=Y):Y=t[45];let X;t[46]!==k||t[47]!==M||t[48]!==S?(X=k&&g(k)?(0,y.jsx)(f,{asChild:!0,children:(0,y.jsx)(i,{to:se(M,S),children:S?`开始使用`:`Start using`})}):(0,y.jsx)(d,{asChild:!0,children:(0,y.jsx)(f,{variant:`secondary`,children:S?`完成`:`Done`})}),t[46]=k,t[47]=M,t[48]=S,t[49]=X):X=t[49];let Z;t[50]!==Y||t[51]!==X?(Z=(0,y.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 border-t border-edge px-5 py-4`,children:[Y,X]}),t[50]=Y,t[51]=X,t[52]=Z):Z=t[52];let Q;t[53]!==G||t[54]!==q||t[55]!==J||t[56]!==Z?(Q=(0,y.jsxs)(ee,{children:[F,(0,y.jsxs)(te,{onCloseAutoFocus:I,className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[131] flex h-[min(38rem,calc(100dvh-2rem))] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover`,children:[G,q,J,Z]})]}),t[53]=G,t[54]=q,t[55]=J,t[56]=Z,t[57]=Q):Q=t[57];let $;return t[58]!==Q||t[59]!==P?($=(0,y.jsx)(re,{open:!0,onOpenChange:P,children:Q}),t[58]=Q,t[59]=P,t[60]=$):$=t[60],$}function ue(e){return e.language}export{b as PluginDetailsDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,f as a,t as o}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as ee}from"./circle-check-C23XjkUj.js";import{t as s}from"./folder-open-CyzJ19I9.js";import{t as c}from"./messages-Bwv-AOYl.js";import{t as l}from"./cn-0WouolD0.js";import{a as u,n as te,r as d}from"./locale-store-D5h-Ha6-.js";import{a as f,i as p,o as m,r as ne,s as re,t as h}from"./dist-BGTk37IG.js";import{a as g}from"./vendor-swr-BIWyz7Rc.js";import{$a as ie,$l as _,Af as v,Au as y,Ju as ae,Kc as b,Rc as oe,Rd as x,kl as S,nf as C,pf as w,uf as T}from"./index-DmURUvvA.js";import{t as se}from"./capability-links-DzQWK1Fh.js";import{t as E}from"./capability-icon-DVoZxEgW.js";import{t as D}from"./browser-BLJWD7WI.js";var ce=n(),O=e(D(),1),k=e(t(),1),A=r();function j(e){let t=(0,ce.c)(6),{fields:n,values:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=Object.entries(n),t[0]=n,t[1]=a);let o;return t[2]!==i||t[3]!==a||t[4]!==r?(o=(0,A.jsx)(A.Fragment,{children:a.map(e=>{let[t,n]=e;return(0,A.jsxs)(`label`,{className:`block space-y-1.5 text-sm`,children:[(0,A.jsxs)(`span`,{children:[n.title,n.required?` *`:``]}),n.type===`boolean`?(0,A.jsx)(`input`,{type:`checkbox`,checked:r[t]===!0,onChange:e=>i({...r,[t]:e.target.checked})}):(0,A.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-inset px-3 py-2.5`,type:n.sensitive?`password`:n.type===`number`?`number`:`text`,required:n.required,autoComplete:`off`,value:String(r[t]??``),onChange:e=>i({...r,[t]:n.type===`number`?Number(e.target.value):e.target.value})})]},t)})}),t[2]=i,t[3]=a,t[4]=r,t[5]=o):o=t[5],o}function M(e){let t=(0,ce.c)(62),{account:n,fields:r,zh:i,busy:a,attempt:o,initialMethod:ee,onBack:s,onConnect:c,onSave:l,onRedirect:u,onSkip:te}=e,[d,f]=(0,k.useState)(ee&&n.methods.some(e=>e.id===ee)?ee:n.methods[0]?.id??``),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p={},t[0]=p):p=t[0];let[m,ne]=(0,k.useState)(p),[re,h]=(0,k.useState)(``),[g,ie]=(0,k.useState)(),_;t[1]===d?_=t[2]:(_=e=>e.id===d,t[1]=d,t[2]=_);let y=n.methods.find(_),x;t[3]===i?x=t[4]:(x=(e,t)=>i?e:t,t[3]=i,t[4]=x);let S=x,C=o?.challenge?.type===`qr`?o.challenge.url:void 0,w,T;t[5]===C?(w=t[6],T=t[7]):(w=()=>{let e=!1;return ie(void 0),C&&O.toDataURL(C,{width:240,margin:2}).then(t=>{e||ie(t)}).catch(P),()=>{e=!0}},T=[C],t[5]=C,t[6]=w,t[7]=T),(0,k.useEffect)(w,T);let se;t[8]===o?se=t[9]:(se=o&&![`cancelled`,`error`,`connected`].includes(o.state),t[8]=o,t[9]=se);let E=se,D=o?.authorizationUrl??o?.challenge?.url,M=`连接 ${n.title}`,F=`Connect ${n.title}`,I;t[10]!==S||t[11]!==M||t[12]!==F?(I=S(M,F),t[10]=S,t[11]=M,t[12]=F,t[13]=I):I=t[13];let L;t[14]===S?L=t[15]:(L=S(`返回插件详情`,`Back to plugin details`),t[14]=S,t[15]=L);let R;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,A.jsx)(v,{className:`size-4`}),t[16]=R):R=t[16];let z;t[17]!==s||t[18]!==L?(z=(0,A.jsx)(b,{variant:`ghost`,className:`shrink-0`,onClick:s,"aria-label":L,children:R}),t[17]=s,t[18]=L,t[19]=z):z=t[19];let B;t[20]===S?B=t[21]:(B=S(`连接 `,`Connect `),t[20]=S,t[21]=B);let V;t[22]!==n.title||t[23]!==B?(V=(0,A.jsxs)(`h3`,{className:`text-base font-semibold`,children:[B,n.title]}),t[22]=n.title,t[23]=B,t[24]=V):V=t[24];let H;t[25]!==n.description||t[26]!==S?(H=n.description??S(`完成授权后自动检查连接。也可以稍后在详情页继续。`,`The connection is checked after authorization. You can also continue later in plugin details.`),t[25]=n.description,t[26]=S,t[27]=H):H=t[27];let U;t[28]===H?U=t[29]:(U=(0,A.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:H}),t[28]=H,t[29]=U);let W;t[30]!==V||t[31]!==U?(W=(0,A.jsxs)(`div`,{children:[V,U]}),t[30]=V,t[31]=U,t[32]=W):W=t[32];let G;t[33]!==z||t[34]!==W?(G=(0,A.jsxs)(`div`,{className:`flex items-start gap-3`,children:[z,W]}),t[33]=z,t[34]=W,t[35]=G):G=t[35];let K;t[36]!==n.methods||t[37]!==E||t[38]!==a||t[39]!==d||t[40]!==S?(K=n.methods.length>1?(0,A.jsx)(`div`,{role:`tablist`,"aria-label":S(`授权方式`,`Authorization methods`),className:`flex flex-wrap gap-2 rounded-lg bg-surface-inset p-1.5`,children:n.methods.map(e=>(0,A.jsx)(`button`,{role:`tab`,type:`button`,"aria-selected":d===e.id,className:`min-h-10 rounded-md px-3 text-sm ${d===e.id?`bg-surface-panel font-medium text-fg`:`text-fg-muted`}`,disabled:a||!!E,onClick:()=>{f(e.id),ne({})},children:e.title},e.id))}):null,t[36]=n.methods,t[37]=E,t[38]=a,t[39]=d,t[40]=S,t[41]=K):K=t[41];let q=y?.instructions?.length||y?.helpUrl?(0,A.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-edge bg-surface-inset p-4 text-sm text-fg-muted`,children:[y.instructions?.length?(0,A.jsx)(`ol`,{className:`list-decimal space-y-2 pl-5`,children:y.instructions.map(N)}):null,y.helpUrl?(0,A.jsx)(`a`,{className:`text-accent underline`,href:y.helpUrl,target:`_blank`,rel:`noopener noreferrer`,children:S(`打开官方配置说明`,`Open setup instructions`)}):null]}):null,J=(y?.type===`form`||y?.fields?.length)&&!E?(0,A.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),l(y.id,m)},children:[(0,A.jsx)(j,{fields:Object.fromEntries((y.fields??[]).filter(e=>r[e]).map(e=>[e,{...r[e],required:!0}])),values:m,onChange:ne}),(0,A.jsxs)(b,{type:`submit`,disabled:a||!y.fields?.every(e=>m[e]!==void 0&&m[e]!==``),children:[a?(0,A.jsx)(ae,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,S(`保存并连接`,`Save and connect`)]})]}):(0,A.jsxs)(`div`,{className:`space-y-4`,children:[E?null:(0,A.jsx)(b,{disabled:a,onClick:()=>c(d),children:S(`连接账号`,`Connect account`)}),E?(0,A.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:o.challenge?.message??(o.state===`preparing`?S(`正在准备登录…`,`Preparing sign-in…`):S(`请完成登录,返回后会自动继续。`,`Finish signing in. Installation continues automatically.`))}):null,C&&E?g?(0,A.jsx)(`img`,{src:g,alt:S(`使用 ${n.title} 扫码授权`,`Scan to authorize ${n.title}`),className:`mx-auto size-60 max-w-full rounded-lg`}):(0,A.jsx)(oe,{className:`mx-auto size-60`}):null,D&&E?(0,A.jsx)(`a`,{href:D,target:`_blank`,rel:`noopener noreferrer`,className:`inline-block text-sm text-accent underline`,children:C?S(`也可以打开授权页面`,`Or open the authorization page`):S(`打开登录页面`,`Open sign-in page`)}):null,o?.expiresAt&&E?(0,A.jsxs)(`p`,{className:`text-center text-xs text-fg-muted`,children:[S(`本次授权有效期至 `,`This sign-in expires at `),new Date(o.expiresAt).toLocaleTimeString()]}):null,o?.error?(0,A.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:o.error}):null,o?.acceptsRedirect&&E?(0,A.jsxs)(`details`,{className:`text-sm`,children:[(0,A.jsx)(`summary`,{className:`cursor-pointer text-fg-muted`,children:S(`登录后没有自动返回?`,`Did sign-in not return automatically?`)}),(0,A.jsxs)(`form`,{className:`mt-3 space-y-3`,onSubmit:e=>{e.preventDefault(),u(re)},children:[(0,A.jsxs)(`label`,{children:[S(`登录回调地址`,`Sign-in callback URL`),(0,A.jsx)(`input`,{value:re,onChange:e=>h(e.target.value),className:`mt-1 w-full rounded-lg border border-edge bg-surface-inset p-2`})]}),(0,A.jsx)(b,{type:`submit`,disabled:a||!re,children:S(`继续登录`,`Continue sign-in`)})]})]}):null]}),Y;t[42]===S?Y=t[43]:(Y=S(`暂时跳过`,`Skip for now`),t[42]=S,t[43]=Y);let X;t[44]!==a||t[45]!==te||t[46]!==Y?(X=(0,A.jsx)(b,{variant:`secondary`,disabled:a,onClick:te,children:Y}),t[44]=a,t[45]=te,t[46]=Y,t[47]=X):X=t[47];let Z;t[48]===S?Z=t[49]:(Z=S(`相关功能暂不可用,可随时在插件详情中授权。`,`Features requiring this account stay unavailable. Connect later in plugin details.`),t[48]=S,t[49]=Z);let le;t[50]===Z?le=t[51]:(le=(0,A.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:Z}),t[50]=Z,t[51]=le);let ue;t[52]!==X||t[53]!==le?(ue=(0,A.jsxs)(`div`,{className:`border-t border-edge pt-4`,children:[X,le]}),t[52]=X,t[53]=le,t[54]=ue):ue=t[54];let Q;return t[55]!==I||t[56]!==G||t[57]!==K||t[58]!==q||t[59]!==J||t[60]!==ue?(Q=(0,A.jsxs)(`section`,{className:`space-y-5`,"aria-label":I,children:[G,K,q,J,ue]}),t[55]=I,t[56]=G,t[57]=K,t[58]=q,t[59]=J,t[60]=ue,t[61]=Q):Q=t[61],Q}function N(e,t){return(0,A.jsx)(`li`,{children:e},t)}function P(){}async function F(e,t=`GET`,n){let r=await u(d(e),{method:t,...n===void 0?{}:{body:JSON.stringify(n)}});if(!r.ok)throw Error(r.error??`Request failed`);return r.payload}function I({extension:e,zh:t,onChanged:n,onStart:r,onInstalled:i,initialConnect:a=!1}){let s=`/api/extensions/agent-plugins/${encodeURIComponent(e.pluginId)}`,[c,l]=(0,k.useState)(),[u,te]=(0,k.useState)({}),[d,f]=(0,k.useState)(!1),[p,m]=(0,k.useState)(``),[ne,re]=(0,k.useState)({}),[h,g]=(0,k.useState)(null),[ie,_]=(0,k.useState)(``),[v,y]=(0,k.useState)(null),[x,S]=(0,k.useState)(!1),w=(0,k.useRef)(new Set),se=(0,k.useRef)(new Set),E=(0,k.useRef)(void 0),D=(0,k.useRef)(null),ce=(0,k.useRef)(new Set),O=(e,n)=>t?e:n,N=e.setup?.authorizations??[],P=new Set(N.flatMap(e=>e.servers)),I=[...N,...(c?.connections??[]).filter(t=>!P.has(t.name)&&(e.components?.mcp.find(e=>e.name===t.name)?.type!==`stdio`||t.state===`token_required`)).map(t=>{let n=t.state===`token_required`||e.components?.mcp.find(e=>e.name===t.name)?.connectionAuth?.mode===`api-key`;return{id:t.name,title:t.name,servers:[t.name],methods:[{id:n?`api-key`:`oauth`,title:n?O(`访问令牌`,`Access token`):O(`浏览器登录`,`Browser sign-in`),type:n?`form`:`oauth`,...n?{fields:[`__apiKey`]}:{server:t.name}}]}})],L=e=>e.servers.every(e=>c?.connections.find(t=>t.name===e)?.state===`connected`)&&(!N.some(t=>t.id===e.id)||c?.authorizations?.find(t=>t.id===e.id)?.state===`connected`),R=(c?.authorizations??[]).flatMap(e=>(e.issues??[]).map(t=>({...t,account:I.find(t=>t.id===e.id)}))),z=I.filter(e=>!L(e)),B=c?.installed||c?.state===`completed`,V=e.setup?.userConfig??{},H=new Set(N.flatMap(e=>e.methods.flatMap(e=>e.fields??[]))),U=Object.fromEntries(Object.entries(V).filter(([e])=>!H.has(e))),W=c?.error===`Connection verification failed. Check the credentials or login status and try again.`?O(`连接验证未通过,请检查凭据或登录状态后重试。`,c.error):c?.error,G=Object.fromEntries(Object.entries(V).filter(([e])=>c?.missingConfig?.includes(e))),K=d||c?.state===`running`,q=I.find(e=>e.id===v);(0,k.useEffect)(()=>{let e=!1;return F(`${s}/setup`).then(t=>{e||l(t)}).catch(t=>{e||(l(null),m(String(t)))}),()=>{e=!0}},[s]),(0,k.useEffect)(()=>{if(c?.state!==`running`)return;let e=!1,t=!1,r=setInterval(()=>{t||(t=!0,F(`${s}/setup`).then(t=>{e||(l(t),t?.state!==`running`&&n())}).catch(t=>{e||m(String(t))}).finally(()=>{t=!1}))},750);return()=>{e=!0,clearInterval(r)}},[s,c?.state]),(0,k.useEffect)(()=>{if(!c||!c.connections.some(e=>[`oauth_required`,`error`].includes(e.state)))return;let e=!1;return F(`${s}/setup/reusable`).then(t=>{e||re(t)}).catch(()=>{e||re({})}),()=>{e=!0}},[s,c?.revision]),(0,k.useEffect)(()=>{if(!ie||c?.state===`completed`)return;let e=!1,t=!1,n=async()=>{if(!t){t=!0;try{let t=await F(`${s}/setup/auth/${encodeURIComponent(ie)}`);e||g(t)}catch(t){e||m(String(t))}finally{t=!1}}};n();let r=setInterval(()=>void n(),1500),i=()=>void n();return window.addEventListener(`focus`,i),()=>{e=!0,clearInterval(r),window.removeEventListener(`focus`,i)}},[s,ie,c?.state]),(0,k.useEffect)(()=>{let e=h?.authorizationUrl??(h?.challenge?.type===`url`?h.challenge.url:void 0);if(!h)return;if(h.error||[`cancelled`,`error`,`connected`].includes(h.state)){D.current?.close(),D.current=null;return}if(!e){h.challenge?.type===`qr`&&(D.current?.close(),D.current=null);return}let t=`${h.id}:${e}`;if(ce.current.has(t))return;ce.current.add(t);let n=D.current;D.current=null,n&&!n.closed?n.location.replace(e):window.open(e,`_blank`,`noopener,noreferrer`)},[h]);async function J(e,t={},r=c?.revision){f(!0),m(``);try{let a=await F(`${s}/setup`,`POST`,{action:e,expectedRevision:r,...e===`start`?{}:{idempotencyKey:crypto.randomUUID()},...t}),o=e===`configure`&&N.find(e=>e.id===t.authorization)?.methods.some(e=>e.id===t.method&&e.type===`cli`);return([`reuse`,`start`].includes(e)||e===`configure`&&!o)&&(te({}),S(!1),a=await F(`${s}/setup`,`POST`,{action:`prepare`,expectedRevision:a.revision,idempotencyKey:crypto.randomUUID()})),l(a),await n(),[`complete`,`defer`].includes(e)&&(y(null),g(null),_(``),D.current?.close(),D.current=null,i?.()),a}catch(e){m(e instanceof Error?e.message:String(e));try{l(await F(`${s}/setup`))}catch{}return null}finally{f(!1)}}(0,k.useEffect)(()=>{if(!c||K||p||[`cancelled`,`running`,`failed`].includes(c.state)||c.state===`completed`)return;let e,t=``;if(c.state===`pending`?(e=`prepare`,t=`prepare:${s}:${c.revision}`):h?.state===`connected`&&(e=`prepare`,t=`auth:${s}:${h.id}`),e&&!w.current.has(t)){w.current.add(t),J(e);return}c.resources===`ready`&&!c.missingConfig?.length&&!c.partial&&c.connections.every(e=>e.state===`connected`)&&(c.authorizations??[]).every(e=>e.state===`connected`)&&(t=`complete:${s}:${c.revision}`,w.current.has(t)||(w.current.add(t),J(`complete`)))},[c,h,K,p,s]),(0,k.useEffect)(()=>{K||!c||c.state===`cancelled`||(q&&c.revision!==E.current&&L(q)?(y(null),g(null),_(``)):(!B||a)&&c.resources===`ready`&&(!c.missingConfig?.length||a&&!c.missingConfig.some(e=>e in U))&&!v&&z[0]&&!se.current.has(z[0].id)&&(se.current.add(z[0].id),E.current=c.revision,y(z[0].id)))},[c,K,B,v,a]);function Y(e,t){let n=e.methods.find(e=>e.id===t),r=n?.type===`oauth`||n?.type===`cli`?window.open(`about:blank`,`_blank`):null;r&&(r.opener=null),D.current=r,g(null),J(`authorize`,{server:e.id,...N.some(t=>t.id===e.id)?{method:t}:{}}).then(t=>{t?_(e.id):(r?.close(),D.current=null)})}async function X(t,n,r){if(n===`api-key`&&!N.some(e=>e.id===t.id)){f(!0),m(``);try{let n=e.components?.mcp.find(e=>e.name===t.id);await F(`${s}/mcp/${encodeURIComponent(t.id)}/auth`,`PUT`,{mode:`api-key`,secrets:[{target:n.type===`stdio`?`env`:`headers`,key:n.connectionAuth?.headerName??(n.type===`stdio`?`API_KEY`:`Authorization`),prefix:n.connectionAuth?.prefix??(n.type===`stdio`?``:`Bearer `),value:r.__apiKey}]});let i=await F(`${s}/setup`);l(i),f(!1),await J(`prepare`,{},i.revision);return}catch(e){m(String(e)),f(!1);return}f(!1)}else if(t.methods.find(e=>e.id===n)?.type===`cli`){let e=window.open(`about:blank`,`_blank`);e&&(e.opener=null),D.current=e,g(null);let i=await J(`configure`,{authorization:t.id,method:n,values:r},c?.revision);i&&await J(`authorize`,{server:t.id,method:n},i.revision)?_(t.id):(e?.close(),D.current=null)}else await J(`configure`,{authorization:t.id,method:n,values:r})}if(c===void 0)return(0,A.jsx)(oe,{className:`h-40 w-full`});let Z=()=>{J(`defer`)};return q?(0,A.jsxs)(`div`,{className:`space-y-3`,children:[(0,A.jsx)(M,{initialMethod:c?.authorizations?.find(e=>e.id===q.id)?.method,account:q,fields:{...V,__apiKey:{type:`string`,title:O(`访问令牌`,`Access token`),required:!0,sensitive:!0}},zh:t,busy:K,attempt:h,onBack:()=>y(null),onConnect:e=>Y(q,e),onSave:(e,t)=>void X(q,e,t),onRedirect:e=>{f(!0),F(`${s}/setup/auth/${encodeURIComponent(ie)}/redirect`,`POST`,{url:e}).catch(e=>m(String(e))).finally(()=>f(!1))},onSkip:Z},`${q.id}:${c?.authorizations?.find(e=>e.id===q.id)?.method??``}`),ne[q.id]?.map(e=>(0,A.jsxs)(b,{disabled:K,variant:`secondary`,onClick:()=>void J(`reuse`,{server:q.id,sourceServerId:e.id}),children:[O(`使用已登录账号:`,`Use signed-in account: `),e.name]},e.id)),p||W&&q.servers.some(e=>c?.connections.find(t=>t.name===e)?.state===`error`)?(0,A.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:p||W}):null]}):(0,A.jsxs)(`section`,{className:`space-y-5`,"aria-label":O(`插件安装与授权`,`Plugin setup`),children:[B?(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h3`,{className:`font-medium`,children:O(`安装完成`,`Installation complete`)}),(0,A.jsx)(`p`,{role:`status`,className:`mt-1 text-sm text-fg-muted`,children:e.activationEligible===!1?O(`插件已停用。`,`Plugin is disabled.`):c?.partial||z.length||R.length||c?.missingConfig?.length?O(`插件已安装,部分功能仍需要授权。`,`Plugin installed. Some features still need authorization.`):O(`所有 Agent 均可使用。可在 Agent 设置中单独调整。`,`Available to all agents. Customize individual agents in Agent settings.`)})]}):(0,A.jsxs)(`div`,{className:`rounded-xl border border-edge p-4`,children:[(0,A.jsx)(`h3`,{className:`font-medium`,children:O(`安装准备`,`Installation setup`)}),(0,A.jsx)(`ol`,{className:`mt-4 space-y-4 text-sm`,"aria-live":`polite`,children:[{name:O(`准备资源`,`Prepare resources`),done:c?.resources===`ready`,running:K&&c?.resources!==`ready`},{name:O(`授权账号`,`Authorize accounts`),done:c?.resources===`ready`&&!c?.missingConfig?.length&&z.length===0,running:!1},{name:O(`加载可用工具`,`Load available tools`),done:!1,running:K&&c?.resources===`ready`}].map(e=>(0,A.jsxs)(`li`,{className:`flex items-center gap-3`,children:[e.done?(0,A.jsx)(ee,{className:`size-5 text-accent`,"aria-hidden":!0}):e.running?(0,A.jsx)(ae,{className:`size-5 animate-spin text-accent`,"aria-hidden":!0}):(0,A.jsx)(C,{className:`size-5 text-fg-muted`,"aria-hidden":!0}),e.name]},e.name))}),(0,A.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:O(`安装后所有 Agent 均可使用,可在各自的设置中调整。`,`Available to all agents after installation. Customize individual agents in Agent settings.`)})]}),!c||c.state===`cancelled`?(0,A.jsx)(b,{disabled:d||e.readiness===`blocked`,onClick:()=>void J(`start`),children:O(`继续安装`,`Continue installation`)}):(0,A.jsxs)(A.Fragment,{children:[c.missingConfig?.length||x?(0,A.jsxs)(`form`,{className:`space-y-4 rounded-xl border border-edge p-4`,onSubmit:e=>{e.preventDefault(),J(`configure`,{values:u})},children:[(0,A.jsx)(`h4`,{className:`font-medium`,children:O(`补充配置`,`Required configuration`)}),(0,A.jsx)(j,{fields:x?U:G,values:u,onChange:te}),(0,A.jsx)(b,{type:`submit`,disabled:K||!Object.keys(u).length,children:O(`继续`,`Continue`)})]}):null,B&&(z.length||c.missingConfig?.length)?(0,A.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl border border-amber-500/30 bg-amber-500/10 p-4 text-sm`,children:[(0,A.jsx)(T,{className:`mt-0.5 size-5 shrink-0`,"aria-hidden":!0}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`font-medium`,children:O(`需要授权`,`Authorization required`)}),(0,A.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:O(`授权后即可使用相关功能。已就绪的功能可继续使用。`,`Connect these accounts to use their features. Ready features remain available.`)})]})]}):null,R.length?(0,A.jsx)(`div`,{className:`space-y-3`,"aria-label":O(`需要补充权限`,`Additional permissions required`),children:R.map(e=>(0,A.jsxs)(`div`,{role:`alert`,className:`space-y-3 rounded-xl border border-amber-500/30 bg-amber-500/10 p-4 text-sm`,children:[(0,A.jsx)(`p`,{className:`font-medium`,children:e.title}),(0,A.jsx)(`p`,{className:`text-fg-muted`,children:O(`账号已连接,以下权限尚未就绪;其他已授权功能可继续使用。`,`Account connected. These permissions are not ready; other authorized features remain available.`)}),e.scopes.length?(0,A.jsx)(`p`,{className:`break-all font-mono text-xs`,children:e.scopes.join(`, `)}):null,(0,A.jsx)(`ol`,{className:`list-inside list-decimal space-y-1 text-fg-muted`,children:e.instructions.map(e=>(0,A.jsx)(`li`,{children:e},e))}),(0,A.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.helpUrl?(0,A.jsx)(b,{variant:`secondary`,asChild:!0,children:(0,A.jsx)(`a`,{href:e.helpUrl,target:`_blank`,rel:`noopener noreferrer`,children:O(`前往开通应用权限`,`Open application permissions`)})}):null,e.method&&e.account?(0,A.jsx)(b,{disabled:K,onClick:()=>{E.current=c.revision,y(e.account.id),Y(e.account,e.method)},children:O(`补充授权`,`Grant missing permissions`)}):null,(0,A.jsx)(b,{variant:`secondary`,disabled:K,onClick:()=>void J(`prepare`),children:O(`重新检查权限`,`Check permissions again`)})]})]},`${e.account?.id}:${e.id}`))}):null,I.length?(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(`h4`,{className:`text-sm font-medium`,children:O(`账号与连接`,`Accounts and connections`)}),I.map(e=>(0,A.jsxs)(`div`,{role:`group`,"aria-label":e.title,className:`flex items-center justify-between gap-3 rounded-lg border border-edge p-3`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`p`,{className:`text-sm font-medium`,children:e.title}),(0,A.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:L(e)?O(`已连接`,`Connected`):O(`需要授权`,`Authorization required`)})]}),(0,A.jsx)(b,{variant:L(e)?`secondary`:`primary`,disabled:K||c.resources!==`ready`,onClick:()=>{g(null),_(``),E.current=c.revision,y(e.id)},children:L(e)?O(`重新授权`,`Reconnect`):O(`连接账号`,`Connect account`)})]},e.id))]}):null,!B&&c.resources===`ready`?(0,A.jsxs)(`div`,{children:[(0,A.jsx)(b,{variant:`secondary`,disabled:K,onClick:Z,children:O(`暂时跳过`,`Skip for now`)}),(0,A.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:O(`先完成安装,稍后在详情页授权。未授权的功能暂不可用。`,`Finish installation and connect later in plugin details. Unauthenticated features remain unavailable.`)})]}):null,B&&Object.keys(U).length&&!x?(0,A.jsx)(b,{variant:`ghost`,disabled:K,onClick:()=>S(!0),children:O(`修改插件配置`,`Edit plugin configuration`)}):null,B&&!R.length&&N.some(e=>e.methods.some(e=>e.type===`cli`))?(0,A.jsx)(b,{variant:`secondary`,disabled:K,onClick:()=>void J(`prepare`),children:O(`检查连接与权限`,`Check connection and permissions`)}):null,!K&&(p||[`failed`,`interrupted`].includes(c.state)||c.connections.some(e=>e.state===`error`))?(0,A.jsx)(b,{variant:`secondary`,onClick:()=>void J(`prepare`),children:O(`重试检查`,`Retry checks`)}):null,B?null:(0,A.jsx)(b,{variant:`ghost`,disabled:d,onClick:()=>void J(`cancel`),children:O(`取消安装`,`Cancel installation`)}),B&&!z.length&&!c.missingConfig?.length?e.setup?.tasks?.map(t=>(0,A.jsxs)(`div`,{className:`space-y-3 rounded-lg bg-surface-inset p-4 text-sm`,children:[(0,A.jsx)(`p`,{children:t}),(0,A.jsx)(b,{asChild:!0,disabled:!e.active,children:(0,A.jsx)(o,{to:`/chat/new?${new URLSearchParams({draft:t,projectScope:`none`})}`,state:{forceNewChat:!0},onClick:t=>{e.active?r?.():t.preventDefault()},children:O(`开始这个任务`,`Start this task`)})})]},t)):null]}),K?(0,A.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:O(`正在准备,可关闭后继续。`,`Preparing. You can close this window and resume.`)}):null,c?.error&&!c.deferred&&!c.missingConfig?.length?(0,A.jsx)(`p`,{className:`text-sm text-fg-muted`,children:W}):null,p?(0,A.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:p}):null]})}var L=`w-full rounded-lg border border-edge bg-surface-inset px-3 py-2 text-sm text-fg`;function R(e,t){if(e.startsWith(`content.skills:`)){let n=e.slice(15);return t?`提供技能:${n}`:`Add skill: ${n}`}if(e.startsWith(`runtime.mcp.stdio:`)){let n=e.slice(18).split(`:`,1)[0];return t?`在 Gateway 上运行工具服务:${n}`:`Run a tool service on the Gateway: ${n}`}if(e.startsWith(`network.mcp:`)){let n=e.slice(12).split(`:`,1)[0];return t?`连接外部工具服务:${n}`:`Connect to an external tool service: ${n}`}return e.startsWith(`runtime.capability-access:`)?t?`按账号授权启用相关技能和工具`:`Enable skills and tools according to account authorization`:e.startsWith(`runtime.authorization:`)?t?`在本机运行账号登录程序:${e.split(`:`)[1]}`:`Run account sign-in locally: ${e.split(`:`)[1]}`:e.startsWith(`runtime.resource:`)?t?`下载可执行资源:${e.split(`:`)[1]}`:`Download executable resource: ${e.split(`:`)[1]}`:e.startsWith(`network.resource:`)?t?`下载并校验资源:${e.split(`:`)[1]}`:`Download and verify resource: ${e.split(`:`)[1]}`:e}function z(e,t){return t?.publisher?.verification!==`verified`||t.latestVersion.riskTier&&t.latestVersion.riskTier!==`content`?!0:e.addedCapabilities.some(e=>!e.startsWith(`content.skills:`))}async function B(e,t,n){let r=await u(d(e),{method:t,...n===void 0?{}:{body:JSON.stringify(n)}});if(!r.ok)throw Error(r.error??`Request failed`);return r.payload}function V({extension:e,onClose:t,onUninstalled:n,initialSource:r=``,marketplace:o,autoInstall:u=!1}){let d=te(e=>e.language),v=d.startsWith(`zh`),oe=o?.localizations?.[v?`zh-CN`:`en`],C=oe?.displayName??o?.name,T=oe?.description??o?.description,D=(0,k.useId)(),{mutate:ce}=g(),[O,j]=(0,k.useState)(e),[M,N]=(0,k.useState)(r||e?.installationSource||``),[P,F]=(0,k.useState)(null),[V,H]=(0,k.useState)([]),[U,W]=(0,k.useState)(!1),[G,K]=(0,k.useState)(``),[q,J]=(0,k.useState)(!1),[Y,X]=(0,k.useState)(!1),[Z,le]=(0,k.useState)(!1),[ue,Q]=(0,k.useState)(!1),[de,fe]=(0,k.useState)(!1),[pe,me]=(0,k.useState)(!1),he=a(),ge=i(),[_e,ve]=(0,k.useState)(!1),ye=(0,k.useRef)(!1),be=`/api/extensions/agent-plugins/${encodeURIComponent(O?.pluginId??``)}`,xe=M.trim().startsWith(`store:`),Se=()=>ce(`gateway-extensions-list`);async function $(e){W(!0),K(``);try{await e()}catch(e){K(e instanceof Error?e.message:String(e))}finally{W(!1)}}function Ce(e){N(e),F(null),H([]),K(``)}let we=typeof window<`u`?window.electronAPI?.file:void 0,Te=/^(?:\/|[A-Za-z]:[\\/])/.test(M.trim())?M.trim():void 0;async function Ee(){if(!we?.openDirectory){fe(!0);return}let e=await we.openDirectory(Te?{defaultPath:Te}:void 0);e&&Ce(e)}async function De(){if(!we?.openFile){fe(!0);return}let e=await we.openFile({...Te?{defaultPath:Te}:{},extensions:[`zip`]});e&&Ce(e)}function Oe(e){return[...e.dataTransfer.types].some(e=>e===`Files`||e===`text/plain`||e===`text/uri-list`)}function ke(e){if(!Oe(e))return;e.preventDefault(),Q(!1);let t=Array.from(e.dataTransfer.files);if(t.length){if(t.length>1){K(v?`一次只能选择一个插件目录或 ZIP。`:`Choose one plugin directory or ZIP at a time.`);return}let e=we?.getPathForFile?.(t[0]);e?Ce(e):K(v?`浏览器无法读取本机文件路径,请使用“选择文件或目录”选择安装包。`:`The browser cannot read local file paths. Use Choose file or folder to select the package.`);return}let n=e.dataTransfer.getData(`text/uri-list`)||e.dataTransfer.getData(`text/plain`);n.trim()&&Ce(n.trim().split(/\r?\n/)[0])}async function Ae(e){j(await B(`${be}/activation`,`POST`,{enabled:e})),await Se()}async function je(e){let t=!O,n=await B(t?`/api/extensions/install`:`${be}/update`,`POST`,{source:M,reviewHash:e.reviewHash,...e.layout?{setup:!0}:{}});j(n),await Se(),!e.layout&&t&&!n.activationEligible&&n.readiness!==`blocked`&&n.pluginId&&(n=await B(`/api/extensions/agent-plugins/${encodeURIComponent(n.pluginId)}/activation`,`POST`,{enabled:!0}),j(n),await Se()),F(null),ve(!e.layout&&t&&n.activationEligible===!0)}async function Me(){let e=await B(`/api/extensions/inspect`,`POST`,{source:M});if(z(e,o)){F(e);return}await je(e)}(0,k.useEffect)(()=>{e&&!e.setup&&j(e)},[e]),(0,k.useEffect)(()=>{if(!e?.setup||!e.pluginId)return;let t=!1;return B(`/api/extensions/agent-plugins/${encodeURIComponent(e.pluginId)}`,`GET`).then(e=>{t||j(e)}).catch(()=>{}),()=>{t=!0}},[e?.pluginId]),(0,k.useEffect)(()=>{!u||O||!xe||ye.current||(ye.current=!0,$(Me))},[u,O,xe]);let Ne=u&&!O&&xe&&!ye.current;return(0,A.jsx)(h,{defaultOpen:!0,onOpenChange:e=>!e&&t(),children:(0,A.jsxs)(m,{children:[(0,A.jsx)(f,{className:`fixed inset-0 z-[130] bg-scrim`}),(0,A.jsxs)(ne,{className:`fixed left-1/2 top-1/2 z-[131] flex h-[min(82vh,42rem)] w-[min(38rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover`,children:[(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge p-4`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,A.jsx)(E,{iconUrl:O?.branding?.iconUrl??o?.branding?.iconUrl,fallback:y}),(0,A.jsx)(re,{className:`font-semibold`,children:O?.name??C??(v?`安装插件`:`Install plugin`)})]}),(0,A.jsx)(b,{variant:`ghost`,onClick:t,children:v?`关闭`:`Close`})]}),(0,A.jsx)(p,{className:`sr-only`,children:v?`安装、组件、账号连接和权限`:`Installation, components, connections and permissions`}),(0,A.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto p-4`,children:[!O&&xe?(0,A.jsxs)(`section`,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:[(0,A.jsx)(_,{className:`mt-0.5 size-5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`p`,{className:`font-medium text-fg`,children:C??P?.manifest.name??M.slice(6)}),T?(0,A.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:T}):null,(0,A.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:o?.publisher?.verification===`verified`?v?`已认证发布者 · 安装后所有 Agent 均可使用`:`Verified publisher · available to all agents after installation`:v?`安装前会检查来源和所需权限`:`Source and required permissions are checked before installation`})]})]}),P?null:(0,A.jsxs)(b,{className:`w-full`,disabled:U||Ne,onClick:()=>void $(Me),children:[U||Ne?(0,A.jsx)(ae,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,U||Ne?v?`正在安全检查并安装…`:`Checking and installing…`:v?`一键安装`:`Install`]})]}):null,O?(0,A.jsxs)(A.Fragment,{children:[_e?(0,A.jsxs)(`div`,{role:`status`,className:`flex items-start gap-3 rounded-lg border border-emerald-500/25 bg-emerald-500/10 p-4`,children:[(0,A.jsx)(ee,{className:`mt-0.5 size-5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`font-medium text-fg`,children:v?`插件已安装并启用`:`Plugin installed and enabled`}),(0,A.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:v?`现在可以直接在对话中使用它。`:`It is ready to use in your conversations.`})]})]}):null,(!O.setup||O.readiness!==`setup_required`)&&!O.activationEligible?(0,A.jsxs)(`div`,{role:`status`,className:`space-y-3 rounded-lg border border-accent/25 bg-accent-soft p-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`font-medium text-accent-fg`,children:v?`插件已安装,当前尚未启用`:`Plugin installed. It is not enabled yet.`}),(0,A.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:v?`启用后,Skills 和 MCP 才会加入 Agent 运行时。`:`Enable it to make its skills and MCP servers available to the Agent runtime.`})]}),(0,A.jsx)(b,{disabled:U||O.readiness===`blocked`,onClick:()=>void $(()=>Ae(!0)),children:v?`启用插件`:`Enable plugin`})]}):null,O.setup?(0,A.jsx)(I,{extension:O,zh:v,onStart:t,onInstalled:()=>{t(),he(se(O.pluginId,`installed`,!1,ge.pathname+ge.search))},onChanged:async()=>{j(await B(`${be}`,`GET`)),await Se()}}):null,(0,A.jsxs)(`details`,{className:`rounded-lg border border-edge p-3`,children:[(0,A.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:v?`插件详情`:`Plugin details`}),(0,A.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,A.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[v?`插件`:`Plugin`,` · `,O.version,` · `,O.readiness&&{ready:v?`已就绪`:`Ready`,setup_required:v?`待连接`:`Setup required`,degraded:v?`部分不可用`:`Partially available`,blocked:v?`已阻止`:`Blocked`}[O.readiness]]}),O.provenance?(0,A.jsxs)(`p`,{className:`break-words text-xs text-fg-muted`,children:[O.provenance.publisherVerification===`verified`?v?`已认证发布者`:`Verified publisher`:v?`社区发布者`:`Community publisher`,` · `,O.provenance.packageName,`@`,O.provenance.version,` · SHA-256 `,O.provenance.sha256.slice(0,12),`…`,O.provenance.riskTier?` · ${O.provenance.riskTier}`:``]}):null,(0,A.jsx)(`p`,{className:`text-sm`,children:O.description}),O.installationSource?(0,A.jsxs)(`p`,{className:`break-all text-xs text-fg-muted`,children:[v?`来源:`:`Source: `,O.installationSource,O.resolvedCommit?` · ${O.resolvedCommit.slice(0,12)}`:``]}):null,O.activationEligible?(0,A.jsx)(b,{disabled:U,variant:`secondary`,onClick:()=>void $(()=>Ae(!1)),children:v?`停用`:`Disable`}):null,O.canRollback?(0,A.jsx)(b,{disabled:U,variant:`secondary`,onClick:()=>void $(async()=>{j(await B(`${be}/rollback`,`POST`)),await Se()}),children:v?`回滚上一版本`:`Roll back`}):null]})]}),O.diagnostics?.map((e,t)=>(0,A.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[e.component,`: `,e.message]},t))]}):null,O?(0,A.jsxs)(b,{variant:`ghost`,className:`px-0`,"aria-expanded":pe,onClick:()=>me(e=>!e),children:[(0,A.jsx)(w,{className:l(`size-4 transition-transform motion-reduce:transition-none`,pe&&`rotate-180`),"aria-hidden":!0}),v?`高级操作`:`Advanced actions`]}):null,!O&&!xe||pe?(0,A.jsxs)(`form`,{className:l(`space-y-3`,O&&`border-t border-edge pt-4`),onSubmit:e=>{e.preventDefault(),$(async()=>{let e=await B(`/api/extensions/inspect`,`POST`,{source:M});e.candidates?(H(e.candidates),F(null)):(H([]),F(e))})},children:[(0,A.jsxs)(`div`,{"data-testid":`plugin-source-dropzone`,className:l(`rounded-xl border border-dashed p-3 transition-colors`,ue?`border-accent bg-accent-soft`:`border-edge bg-surface-inset/40`),onDragEnter:e=>{Oe(e)&&(e.preventDefault(),Q(!0))},onDragOver:e=>{Oe(e)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,Q(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||Q(!1)},onDrop:ke,children:[(0,A.jsxs)(`div`,{className:`mb-2 flex items-start gap-2`,children:[(0,A.jsx)(S,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{htmlFor:D,className:`block text-sm font-medium`,children:O?v?`更新包来源`:`Update package source`:v?`安装包来源`:`Package source`}),(0,A.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:v?`输入 github:组织/仓库、Git / ZIP 地址或宿主目录;marketplace 可选择插件。`:`Enter github:owner/repo, a Git / ZIP URL or a Gateway directory. Marketplaces let you choose a plugin.`})]})]}),(0,A.jsx)(`input`,{id:D,className:L,value:M,onChange:e=>Ce(e.target.value),placeholder:v?`/插件目录/或/插件.zip`:`/plugin/folder/or/plugin.zip`,autoComplete:`off`,spellCheck:!1,required:!0}),(0,A.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:we?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(b,{type:`button`,variant:`secondary`,disabled:U,onClick:()=>void $(Ee),children:[(0,A.jsx)(s,{className:`size-4`,"aria-hidden":!0}),v?`选择目录`:`Choose directory`]}),(0,A.jsxs)(b,{type:`button`,variant:`secondary`,disabled:U,onClick:()=>void $(De),children:[(0,A.jsx)(x,{className:`size-4`,"aria-hidden":!0}),v?`选择 ZIP`:`Choose ZIP`]})]}):(0,A.jsxs)(b,{type:`button`,variant:`secondary`,disabled:U,onClick:()=>fe(!0),children:[(0,A.jsx)(s,{className:`size-4`,"aria-hidden":!0}),v?`选择文件或目录`:`Choose file or folder`]})})]}),(0,A.jsx)(b,{type:`submit`,variant:`secondary`,disabled:U||!M,children:v?`检查安装包`:`Inspect package`})]}):null,V.length?(0,A.jsx)(`div`,{className:`space-y-2`,"aria-label":v?`选择插件`:`Choose a plugin`,children:V.map(e=>(0,A.jsx)(b,{variant:`secondary`,className:`w-full justify-start`,onClick:()=>{Ce(e.source),$(async()=>F(await B(`/api/extensions/inspect`,`POST`,{source:e.source})))},children:e.name},e.source))}):null,P?(0,A.jsxs)(`div`,{role:`region`,"aria-labelledby":`plugin-authorization-title`,className:`space-y-3 rounded-xl border border-amber-500/30 bg-amber-500/10 p-4 text-sm`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,A.jsx)(_,{className:`mt-0.5 size-5 shrink-0 text-amber-700 dark:text-amber-300`,"aria-hidden":!0}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{id:`plugin-authorization-title`,className:`font-medium text-fg`,children:v?`需要你的授权`:`Your authorization is required`}),(0,A.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:v?`此插件需要以下新增能力。确认后自动准备资源,按需登录账号,所有 Agent 均可使用。`:`Review these capabilities. Resources are prepared automatically; sign in if needed. Available to all agents.`})]})]}),(0,A.jsx)(`ul`,{tabIndex:0,"aria-label":v?`插件新增能力`:`Added plugin capabilities`,className:`max-h-[min(28vh,14rem)] space-y-2 overflow-y-auto overscroll-contain rounded-lg border border-edge bg-surface-panel p-3 break-words focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:P.addedCapabilities.map(e=>(0,A.jsxs)(`li`,{className:`flex gap-2`,children:[(0,A.jsx)(`span`,{"aria-hidden":!0,children:`•`}),(0,A.jsx)(`span`,{children:R(e,v)})]},e))}),P.capabilities.some(e=>e.startsWith(`runtime.`))?(0,A.jsxs)(`details`,{children:[(0,A.jsx)(`summary`,{className:`cursor-pointer text-fg-muted`,children:v?`查看执行内容`:`View execution details`}),(0,A.jsx)(`ul`,{tabIndex:0,"aria-label":v?`插件执行内容`:`Plugin execution details`,className:`mt-2 max-h-40 space-y-2 overflow-y-auto overscroll-contain break-all font-mono text-xs`,children:P.capabilities.filter(e=>e.startsWith(`runtime.`)).map(e=>(0,A.jsx)(`li`,{children:e},e))})]}):null,P.diagnostics.map((e,t)=>(0,A.jsxs)(`p`,{children:[e.component,`: `,e.message]},t))]}):null,O&&pe?(0,A.jsx)(`div`,{className:`border-t border-edge pt-4`,children:Z?(0,A.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,A.jsx)(`p`,{children:v?`卸载保留账号凭据;服务端授权需到相应服务撤销。`:`Credentials are retained. Revoke provider authorization in the service itself.`}),(0,A.jsxs)(`label`,{className:`flex gap-2`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:q,onChange:e=>J(e.target.checked)}),v?`同时删除插件数据`:`Also delete plugin data`]}),(0,A.jsxs)(`label`,{className:`flex gap-2`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:Y,onChange:e=>X(e.target.checked)}),v?`同时删除本地凭据`:`Also delete local credentials`]}),(0,A.jsx)(b,{disabled:U,onClick:()=>void $(async()=>{await B(be,`DELETE`,{removeData:q,removeCredentials:Y}),await Se(),(n??t)()}),children:v?`确认卸载`:`Confirm uninstall`})]}):(0,A.jsx)(b,{variant:`ghost`,disabled:U,onClick:()=>le(!0),children:v?`卸载插件`:`Uninstall`})}):null,G?(0,A.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-fg-muted`,children:G}):null]}),P?(0,A.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge p-4`,children:[(0,A.jsx)(b,{variant:`ghost`,disabled:U,onClick:()=>F(null),children:v?`取消`:`Cancel`}),(0,A.jsxs)(b,{disabled:U||!!O&&P.manifest.name!==O.name,onClick:()=>void $(()=>je(P)),children:[U?(0,A.jsx)(ae,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,v?`授权并安装`:`Authorize and install`]})]}):null]}),we?null:(0,A.jsx)(ie,{open:de,onOpenChange:fe,initialAbsolutePath:Te,onConfirm:async e=>Ce(e),wd:c(d).chat.workingDirectory,selectKind:`file-or-directory`,fileExtensions:[`zip`],title:v?`选择插件安装包`:`Choose plugin package`,description:v?`选择插件目录或 ZIP 文件。`:`Choose a plugin directory or ZIP file.`,confirmLabel:v?`使用此来源`:`Use this source`,nested:!0})]})})}function H(e,t){return e.localizations?.[t?`zh-CN`:`en`]?.displayName??(e.setup?.authorizations?.length===1?e.setup.authorizations[0].title:e.name)}function U(e){return e.authorizationStatus===`required`||!!e.setup?.authorizations?.length&&e.authorizationStatus!==`connected`}function W(e){return e.active&&!U(e)&&(e.authorizationStatus===`connected`||e.authorizationStatus===`not_required`)}export{I as a,V as i,H as n,U as r,W as t};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,f as a,t as o}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as ee}from"./circle-check-C23XjkUj.js";import{t as s}from"./folder-open-CyzJ19I9.js";import{t as c}from"./messages-Bwv-AOYl.js";import{t as l}from"./cn-0WouolD0.js";import{a as u,n as te,r as d}from"./locale-store-D5h-Ha6-.js";import{a as f,i as p,o as m,r as ne,s as re,t as h}from"./dist-BGTk37IG.js";import{a as g}from"./vendor-swr-BIWyz7Rc.js";import{$a as ie,$l as _,Af as v,Au as y,Ju as ae,Kc as b,Rc as oe,Rd as x,kl as S,nf as C,pf as w,uf as T}from"./index-K2cy4f-3.js";import{t as se}from"./capability-links-DzQWK1Fh.js";import{t as E}from"./capability-icon-DVoZxEgW.js";import{t as D}from"./browser-BLJWD7WI.js";var ce=n(),O=e(D(),1),k=e(t(),1),A=r();function j(e){let t=(0,ce.c)(6),{fields:n,values:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=Object.entries(n),t[0]=n,t[1]=a);let o;return t[2]!==i||t[3]!==a||t[4]!==r?(o=(0,A.jsx)(A.Fragment,{children:a.map(e=>{let[t,n]=e;return(0,A.jsxs)(`label`,{className:`block space-y-1.5 text-sm`,children:[(0,A.jsxs)(`span`,{children:[n.title,n.required?` *`:``]}),n.type===`boolean`?(0,A.jsx)(`input`,{type:`checkbox`,checked:r[t]===!0,onChange:e=>i({...r,[t]:e.target.checked})}):(0,A.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-inset px-3 py-2.5`,type:n.sensitive?`password`:n.type===`number`?`number`:`text`,required:n.required,autoComplete:`off`,value:String(r[t]??``),onChange:e=>i({...r,[t]:n.type===`number`?Number(e.target.value):e.target.value})})]},t)})}),t[2]=i,t[3]=a,t[4]=r,t[5]=o):o=t[5],o}function M(e){let t=(0,ce.c)(62),{account:n,fields:r,zh:i,busy:a,attempt:o,initialMethod:ee,onBack:s,onConnect:c,onSave:l,onRedirect:u,onSkip:te}=e,[d,f]=(0,k.useState)(ee&&n.methods.some(e=>e.id===ee)?ee:n.methods[0]?.id??``),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p={},t[0]=p):p=t[0];let[m,ne]=(0,k.useState)(p),[re,h]=(0,k.useState)(``),[g,ie]=(0,k.useState)(),_;t[1]===d?_=t[2]:(_=e=>e.id===d,t[1]=d,t[2]=_);let y=n.methods.find(_),x;t[3]===i?x=t[4]:(x=(e,t)=>i?e:t,t[3]=i,t[4]=x);let S=x,C=o?.challenge?.type===`qr`?o.challenge.url:void 0,w,T;t[5]===C?(w=t[6],T=t[7]):(w=()=>{let e=!1;return ie(void 0),C&&O.toDataURL(C,{width:240,margin:2}).then(t=>{e||ie(t)}).catch(P),()=>{e=!0}},T=[C],t[5]=C,t[6]=w,t[7]=T),(0,k.useEffect)(w,T);let se;t[8]===o?se=t[9]:(se=o&&![`cancelled`,`error`,`connected`].includes(o.state),t[8]=o,t[9]=se);let E=se,D=o?.authorizationUrl??o?.challenge?.url,M=`连接 ${n.title}`,F=`Connect ${n.title}`,I;t[10]!==S||t[11]!==M||t[12]!==F?(I=S(M,F),t[10]=S,t[11]=M,t[12]=F,t[13]=I):I=t[13];let L;t[14]===S?L=t[15]:(L=S(`返回插件详情`,`Back to plugin details`),t[14]=S,t[15]=L);let R;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,A.jsx)(v,{className:`size-4`}),t[16]=R):R=t[16];let z;t[17]!==s||t[18]!==L?(z=(0,A.jsx)(b,{variant:`ghost`,className:`shrink-0`,onClick:s,"aria-label":L,children:R}),t[17]=s,t[18]=L,t[19]=z):z=t[19];let B;t[20]===S?B=t[21]:(B=S(`连接 `,`Connect `),t[20]=S,t[21]=B);let V;t[22]!==n.title||t[23]!==B?(V=(0,A.jsxs)(`h3`,{className:`text-base font-semibold`,children:[B,n.title]}),t[22]=n.title,t[23]=B,t[24]=V):V=t[24];let H;t[25]!==n.description||t[26]!==S?(H=n.description??S(`完成授权后自动检查连接。也可以稍后在详情页继续。`,`The connection is checked after authorization. You can also continue later in plugin details.`),t[25]=n.description,t[26]=S,t[27]=H):H=t[27];let U;t[28]===H?U=t[29]:(U=(0,A.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:H}),t[28]=H,t[29]=U);let W;t[30]!==V||t[31]!==U?(W=(0,A.jsxs)(`div`,{children:[V,U]}),t[30]=V,t[31]=U,t[32]=W):W=t[32];let G;t[33]!==z||t[34]!==W?(G=(0,A.jsxs)(`div`,{className:`flex items-start gap-3`,children:[z,W]}),t[33]=z,t[34]=W,t[35]=G):G=t[35];let K;t[36]!==n.methods||t[37]!==E||t[38]!==a||t[39]!==d||t[40]!==S?(K=n.methods.length>1?(0,A.jsx)(`div`,{role:`tablist`,"aria-label":S(`授权方式`,`Authorization methods`),className:`flex flex-wrap gap-2 rounded-lg bg-surface-inset p-1.5`,children:n.methods.map(e=>(0,A.jsx)(`button`,{role:`tab`,type:`button`,"aria-selected":d===e.id,className:`min-h-10 rounded-md px-3 text-sm ${d===e.id?`bg-surface-panel font-medium text-fg`:`text-fg-muted`}`,disabled:a||!!E,onClick:()=>{f(e.id),ne({})},children:e.title},e.id))}):null,t[36]=n.methods,t[37]=E,t[38]=a,t[39]=d,t[40]=S,t[41]=K):K=t[41];let q=y?.instructions?.length||y?.helpUrl?(0,A.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-edge bg-surface-inset p-4 text-sm text-fg-muted`,children:[y.instructions?.length?(0,A.jsx)(`ol`,{className:`list-decimal space-y-2 pl-5`,children:y.instructions.map(N)}):null,y.helpUrl?(0,A.jsx)(`a`,{className:`text-accent underline`,href:y.helpUrl,target:`_blank`,rel:`noopener noreferrer`,children:S(`打开官方配置说明`,`Open setup instructions`)}):null]}):null,J=(y?.type===`form`||y?.fields?.length)&&!E?(0,A.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),l(y.id,m)},children:[(0,A.jsx)(j,{fields:Object.fromEntries((y.fields??[]).filter(e=>r[e]).map(e=>[e,{...r[e],required:!0}])),values:m,onChange:ne}),(0,A.jsxs)(b,{type:`submit`,disabled:a||!y.fields?.every(e=>m[e]!==void 0&&m[e]!==``),children:[a?(0,A.jsx)(ae,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,S(`保存并连接`,`Save and connect`)]})]}):(0,A.jsxs)(`div`,{className:`space-y-4`,children:[E?null:(0,A.jsx)(b,{disabled:a,onClick:()=>c(d),children:S(`连接账号`,`Connect account`)}),E?(0,A.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:o.challenge?.message??(o.state===`preparing`?S(`正在准备登录…`,`Preparing sign-in…`):S(`请完成登录,返回后会自动继续。`,`Finish signing in. Installation continues automatically.`))}):null,C&&E?g?(0,A.jsx)(`img`,{src:g,alt:S(`使用 ${n.title} 扫码授权`,`Scan to authorize ${n.title}`),className:`mx-auto size-60 max-w-full rounded-lg`}):(0,A.jsx)(oe,{className:`mx-auto size-60`}):null,D&&E?(0,A.jsx)(`a`,{href:D,target:`_blank`,rel:`noopener noreferrer`,className:`inline-block text-sm text-accent underline`,children:C?S(`也可以打开授权页面`,`Or open the authorization page`):S(`打开登录页面`,`Open sign-in page`)}):null,o?.expiresAt&&E?(0,A.jsxs)(`p`,{className:`text-center text-xs text-fg-muted`,children:[S(`本次授权有效期至 `,`This sign-in expires at `),new Date(o.expiresAt).toLocaleTimeString()]}):null,o?.error?(0,A.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:o.error}):null,o?.acceptsRedirect&&E?(0,A.jsxs)(`details`,{className:`text-sm`,children:[(0,A.jsx)(`summary`,{className:`cursor-pointer text-fg-muted`,children:S(`登录后没有自动返回?`,`Did sign-in not return automatically?`)}),(0,A.jsxs)(`form`,{className:`mt-3 space-y-3`,onSubmit:e=>{e.preventDefault(),u(re)},children:[(0,A.jsxs)(`label`,{children:[S(`登录回调地址`,`Sign-in callback URL`),(0,A.jsx)(`input`,{value:re,onChange:e=>h(e.target.value),className:`mt-1 w-full rounded-lg border border-edge bg-surface-inset p-2`})]}),(0,A.jsx)(b,{type:`submit`,disabled:a||!re,children:S(`继续登录`,`Continue sign-in`)})]})]}):null]}),Y;t[42]===S?Y=t[43]:(Y=S(`暂时跳过`,`Skip for now`),t[42]=S,t[43]=Y);let X;t[44]!==a||t[45]!==te||t[46]!==Y?(X=(0,A.jsx)(b,{variant:`secondary`,disabled:a,onClick:te,children:Y}),t[44]=a,t[45]=te,t[46]=Y,t[47]=X):X=t[47];let Z;t[48]===S?Z=t[49]:(Z=S(`相关功能暂不可用,可随时在插件详情中授权。`,`Features requiring this account stay unavailable. Connect later in plugin details.`),t[48]=S,t[49]=Z);let le;t[50]===Z?le=t[51]:(le=(0,A.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:Z}),t[50]=Z,t[51]=le);let ue;t[52]!==X||t[53]!==le?(ue=(0,A.jsxs)(`div`,{className:`border-t border-edge pt-4`,children:[X,le]}),t[52]=X,t[53]=le,t[54]=ue):ue=t[54];let Q;return t[55]!==I||t[56]!==G||t[57]!==K||t[58]!==q||t[59]!==J||t[60]!==ue?(Q=(0,A.jsxs)(`section`,{className:`space-y-5`,"aria-label":I,children:[G,K,q,J,ue]}),t[55]=I,t[56]=G,t[57]=K,t[58]=q,t[59]=J,t[60]=ue,t[61]=Q):Q=t[61],Q}function N(e,t){return(0,A.jsx)(`li`,{children:e},t)}function P(){}async function F(e,t=`GET`,n){let r=await u(d(e),{method:t,...n===void 0?{}:{body:JSON.stringify(n)}});if(!r.ok)throw Error(r.error??`Request failed`);return r.payload}function I({extension:e,zh:t,onChanged:n,onStart:r,onInstalled:i,initialConnect:a=!1}){let s=`/api/extensions/agent-plugins/${encodeURIComponent(e.pluginId)}`,[c,l]=(0,k.useState)(),[u,te]=(0,k.useState)({}),[d,f]=(0,k.useState)(!1),[p,m]=(0,k.useState)(``),[ne,re]=(0,k.useState)({}),[h,g]=(0,k.useState)(null),[ie,_]=(0,k.useState)(``),[v,y]=(0,k.useState)(null),[x,S]=(0,k.useState)(!1),w=(0,k.useRef)(new Set),se=(0,k.useRef)(new Set),E=(0,k.useRef)(void 0),D=(0,k.useRef)(null),ce=(0,k.useRef)(new Set),O=(e,n)=>t?e:n,N=e.setup?.authorizations??[],P=new Set(N.flatMap(e=>e.servers)),I=[...N,...(c?.connections??[]).filter(t=>!P.has(t.name)&&(e.components?.mcp.find(e=>e.name===t.name)?.type!==`stdio`||t.state===`token_required`)).map(t=>{let n=t.state===`token_required`||e.components?.mcp.find(e=>e.name===t.name)?.connectionAuth?.mode===`api-key`;return{id:t.name,title:t.name,servers:[t.name],methods:[{id:n?`api-key`:`oauth`,title:n?O(`访问令牌`,`Access token`):O(`浏览器登录`,`Browser sign-in`),type:n?`form`:`oauth`,...n?{fields:[`__apiKey`]}:{server:t.name}}]}})],L=e=>e.servers.every(e=>c?.connections.find(t=>t.name===e)?.state===`connected`)&&(!N.some(t=>t.id===e.id)||c?.authorizations?.find(t=>t.id===e.id)?.state===`connected`),R=(c?.authorizations??[]).flatMap(e=>(e.issues??[]).map(t=>({...t,account:I.find(t=>t.id===e.id)}))),z=I.filter(e=>!L(e)),B=c?.installed||c?.state===`completed`,V=e.setup?.userConfig??{},H=new Set(N.flatMap(e=>e.methods.flatMap(e=>e.fields??[]))),U=Object.fromEntries(Object.entries(V).filter(([e])=>!H.has(e))),W=c?.error===`Connection verification failed. Check the credentials or login status and try again.`?O(`连接验证未通过,请检查凭据或登录状态后重试。`,c.error):c?.error,G=Object.fromEntries(Object.entries(V).filter(([e])=>c?.missingConfig?.includes(e))),K=d||c?.state===`running`,q=I.find(e=>e.id===v);(0,k.useEffect)(()=>{let e=!1;return F(`${s}/setup`).then(t=>{e||l(t)}).catch(t=>{e||(l(null),m(String(t)))}),()=>{e=!0}},[s]),(0,k.useEffect)(()=>{if(c?.state!==`running`)return;let e=!1,t=!1,r=setInterval(()=>{t||(t=!0,F(`${s}/setup`).then(t=>{e||(l(t),t?.state!==`running`&&n())}).catch(t=>{e||m(String(t))}).finally(()=>{t=!1}))},750);return()=>{e=!0,clearInterval(r)}},[s,c?.state]),(0,k.useEffect)(()=>{if(!c||!c.connections.some(e=>[`oauth_required`,`error`].includes(e.state)))return;let e=!1;return F(`${s}/setup/reusable`).then(t=>{e||re(t)}).catch(()=>{e||re({})}),()=>{e=!0}},[s,c?.revision]),(0,k.useEffect)(()=>{if(!ie||c?.state===`completed`)return;let e=!1,t=!1,n=async()=>{if(!t){t=!0;try{let t=await F(`${s}/setup/auth/${encodeURIComponent(ie)}`);e||g(t)}catch(t){e||m(String(t))}finally{t=!1}}};n();let r=setInterval(()=>void n(),1500),i=()=>void n();return window.addEventListener(`focus`,i),()=>{e=!0,clearInterval(r),window.removeEventListener(`focus`,i)}},[s,ie,c?.state]),(0,k.useEffect)(()=>{let e=h?.authorizationUrl??(h?.challenge?.type===`url`?h.challenge.url:void 0);if(!h)return;if(h.error||[`cancelled`,`error`,`connected`].includes(h.state)){D.current?.close(),D.current=null;return}if(!e){h.challenge?.type===`qr`&&(D.current?.close(),D.current=null);return}let t=`${h.id}:${e}`;if(ce.current.has(t))return;ce.current.add(t);let n=D.current;D.current=null,n&&!n.closed?n.location.replace(e):window.open(e,`_blank`,`noopener,noreferrer`)},[h]);async function J(e,t={},r=c?.revision){f(!0),m(``);try{let a=await F(`${s}/setup`,`POST`,{action:e,expectedRevision:r,...e===`start`?{}:{idempotencyKey:crypto.randomUUID()},...t}),o=e===`configure`&&N.find(e=>e.id===t.authorization)?.methods.some(e=>e.id===t.method&&e.type===`cli`);return([`reuse`,`start`].includes(e)||e===`configure`&&!o)&&(te({}),S(!1),a=await F(`${s}/setup`,`POST`,{action:`prepare`,expectedRevision:a.revision,idempotencyKey:crypto.randomUUID()})),l(a),await n(),[`complete`,`defer`].includes(e)&&(y(null),g(null),_(``),D.current?.close(),D.current=null,i?.()),a}catch(e){m(e instanceof Error?e.message:String(e));try{l(await F(`${s}/setup`))}catch{}return null}finally{f(!1)}}(0,k.useEffect)(()=>{if(!c||K||p||[`cancelled`,`running`,`failed`].includes(c.state)||c.state===`completed`)return;let e,t=``;if(c.state===`pending`?(e=`prepare`,t=`prepare:${s}:${c.revision}`):h?.state===`connected`&&(e=`prepare`,t=`auth:${s}:${h.id}`),e&&!w.current.has(t)){w.current.add(t),J(e);return}c.resources===`ready`&&!c.missingConfig?.length&&!c.partial&&c.connections.every(e=>e.state===`connected`)&&(c.authorizations??[]).every(e=>e.state===`connected`)&&(t=`complete:${s}:${c.revision}`,w.current.has(t)||(w.current.add(t),J(`complete`)))},[c,h,K,p,s]),(0,k.useEffect)(()=>{K||!c||c.state===`cancelled`||(q&&c.revision!==E.current&&L(q)?(y(null),g(null),_(``)):(!B||a)&&c.resources===`ready`&&(!c.missingConfig?.length||a&&!c.missingConfig.some(e=>e in U))&&!v&&z[0]&&!se.current.has(z[0].id)&&(se.current.add(z[0].id),E.current=c.revision,y(z[0].id)))},[c,K,B,v,a]);function Y(e,t){let n=e.methods.find(e=>e.id===t),r=n?.type===`oauth`||n?.type===`cli`?window.open(`about:blank`,`_blank`):null;r&&(r.opener=null),D.current=r,g(null),J(`authorize`,{server:e.id,...N.some(t=>t.id===e.id)?{method:t}:{}}).then(t=>{t?_(e.id):(r?.close(),D.current=null)})}async function X(t,n,r){if(n===`api-key`&&!N.some(e=>e.id===t.id)){f(!0),m(``);try{let n=e.components?.mcp.find(e=>e.name===t.id);await F(`${s}/mcp/${encodeURIComponent(t.id)}/auth`,`PUT`,{mode:`api-key`,secrets:[{target:n.type===`stdio`?`env`:`headers`,key:n.connectionAuth?.headerName??(n.type===`stdio`?`API_KEY`:`Authorization`),prefix:n.connectionAuth?.prefix??(n.type===`stdio`?``:`Bearer `),value:r.__apiKey}]});let i=await F(`${s}/setup`);l(i),f(!1),await J(`prepare`,{},i.revision);return}catch(e){m(String(e)),f(!1);return}f(!1)}else if(t.methods.find(e=>e.id===n)?.type===`cli`){let e=window.open(`about:blank`,`_blank`);e&&(e.opener=null),D.current=e,g(null);let i=await J(`configure`,{authorization:t.id,method:n,values:r},c?.revision);i&&await J(`authorize`,{server:t.id,method:n},i.revision)?_(t.id):(e?.close(),D.current=null)}else await J(`configure`,{authorization:t.id,method:n,values:r})}if(c===void 0)return(0,A.jsx)(oe,{className:`h-40 w-full`});let Z=()=>{J(`defer`)};return q?(0,A.jsxs)(`div`,{className:`space-y-3`,children:[(0,A.jsx)(M,{initialMethod:c?.authorizations?.find(e=>e.id===q.id)?.method,account:q,fields:{...V,__apiKey:{type:`string`,title:O(`访问令牌`,`Access token`),required:!0,sensitive:!0}},zh:t,busy:K,attempt:h,onBack:()=>y(null),onConnect:e=>Y(q,e),onSave:(e,t)=>void X(q,e,t),onRedirect:e=>{f(!0),F(`${s}/setup/auth/${encodeURIComponent(ie)}/redirect`,`POST`,{url:e}).catch(e=>m(String(e))).finally(()=>f(!1))},onSkip:Z},`${q.id}:${c?.authorizations?.find(e=>e.id===q.id)?.method??``}`),ne[q.id]?.map(e=>(0,A.jsxs)(b,{disabled:K,variant:`secondary`,onClick:()=>void J(`reuse`,{server:q.id,sourceServerId:e.id}),children:[O(`使用已登录账号:`,`Use signed-in account: `),e.name]},e.id)),p||W&&q.servers.some(e=>c?.connections.find(t=>t.name===e)?.state===`error`)?(0,A.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:p||W}):null]}):(0,A.jsxs)(`section`,{className:`space-y-5`,"aria-label":O(`插件安装与授权`,`Plugin setup`),children:[B?(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h3`,{className:`font-medium`,children:O(`安装完成`,`Installation complete`)}),(0,A.jsx)(`p`,{role:`status`,className:`mt-1 text-sm text-fg-muted`,children:e.activationEligible===!1?O(`插件已停用。`,`Plugin is disabled.`):c?.partial||z.length||R.length||c?.missingConfig?.length?O(`插件已安装,部分功能仍需要授权。`,`Plugin installed. Some features still need authorization.`):O(`所有 Agent 均可使用。可在 Agent 设置中单独调整。`,`Available to all agents. Customize individual agents in Agent settings.`)})]}):(0,A.jsxs)(`div`,{className:`rounded-xl border border-edge p-4`,children:[(0,A.jsx)(`h3`,{className:`font-medium`,children:O(`安装准备`,`Installation setup`)}),(0,A.jsx)(`ol`,{className:`mt-4 space-y-4 text-sm`,"aria-live":`polite`,children:[{name:O(`准备资源`,`Prepare resources`),done:c?.resources===`ready`,running:K&&c?.resources!==`ready`},{name:O(`授权账号`,`Authorize accounts`),done:c?.resources===`ready`&&!c?.missingConfig?.length&&z.length===0,running:!1},{name:O(`加载可用工具`,`Load available tools`),done:!1,running:K&&c?.resources===`ready`}].map(e=>(0,A.jsxs)(`li`,{className:`flex items-center gap-3`,children:[e.done?(0,A.jsx)(ee,{className:`size-5 text-accent`,"aria-hidden":!0}):e.running?(0,A.jsx)(ae,{className:`size-5 animate-spin text-accent`,"aria-hidden":!0}):(0,A.jsx)(C,{className:`size-5 text-fg-muted`,"aria-hidden":!0}),e.name]},e.name))}),(0,A.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:O(`安装后所有 Agent 均可使用,可在各自的设置中调整。`,`Available to all agents after installation. Customize individual agents in Agent settings.`)})]}),!c||c.state===`cancelled`?(0,A.jsx)(b,{disabled:d||e.readiness===`blocked`,onClick:()=>void J(`start`),children:O(`继续安装`,`Continue installation`)}):(0,A.jsxs)(A.Fragment,{children:[c.missingConfig?.length||x?(0,A.jsxs)(`form`,{className:`space-y-4 rounded-xl border border-edge p-4`,onSubmit:e=>{e.preventDefault(),J(`configure`,{values:u})},children:[(0,A.jsx)(`h4`,{className:`font-medium`,children:O(`补充配置`,`Required configuration`)}),(0,A.jsx)(j,{fields:x?U:G,values:u,onChange:te}),(0,A.jsx)(b,{type:`submit`,disabled:K||!Object.keys(u).length,children:O(`继续`,`Continue`)})]}):null,B&&(z.length||c.missingConfig?.length)?(0,A.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl border border-amber-500/30 bg-amber-500/10 p-4 text-sm`,children:[(0,A.jsx)(T,{className:`mt-0.5 size-5 shrink-0`,"aria-hidden":!0}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`font-medium`,children:O(`需要授权`,`Authorization required`)}),(0,A.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:O(`授权后即可使用相关功能。已就绪的功能可继续使用。`,`Connect these accounts to use their features. Ready features remain available.`)})]})]}):null,R.length?(0,A.jsx)(`div`,{className:`space-y-3`,"aria-label":O(`需要补充权限`,`Additional permissions required`),children:R.map(e=>(0,A.jsxs)(`div`,{role:`alert`,className:`space-y-3 rounded-xl border border-amber-500/30 bg-amber-500/10 p-4 text-sm`,children:[(0,A.jsx)(`p`,{className:`font-medium`,children:e.title}),(0,A.jsx)(`p`,{className:`text-fg-muted`,children:O(`账号已连接,以下权限尚未就绪;其他已授权功能可继续使用。`,`Account connected. These permissions are not ready; other authorized features remain available.`)}),e.scopes.length?(0,A.jsx)(`p`,{className:`break-all font-mono text-xs`,children:e.scopes.join(`, `)}):null,(0,A.jsx)(`ol`,{className:`list-inside list-decimal space-y-1 text-fg-muted`,children:e.instructions.map(e=>(0,A.jsx)(`li`,{children:e},e))}),(0,A.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.helpUrl?(0,A.jsx)(b,{variant:`secondary`,asChild:!0,children:(0,A.jsx)(`a`,{href:e.helpUrl,target:`_blank`,rel:`noopener noreferrer`,children:O(`前往开通应用权限`,`Open application permissions`)})}):null,e.method&&e.account?(0,A.jsx)(b,{disabled:K,onClick:()=>{E.current=c.revision,y(e.account.id),Y(e.account,e.method)},children:O(`补充授权`,`Grant missing permissions`)}):null,(0,A.jsx)(b,{variant:`secondary`,disabled:K,onClick:()=>void J(`prepare`),children:O(`重新检查权限`,`Check permissions again`)})]})]},`${e.account?.id}:${e.id}`))}):null,I.length?(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(`h4`,{className:`text-sm font-medium`,children:O(`账号与连接`,`Accounts and connections`)}),I.map(e=>(0,A.jsxs)(`div`,{role:`group`,"aria-label":e.title,className:`flex items-center justify-between gap-3 rounded-lg border border-edge p-3`,children:[(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`p`,{className:`text-sm font-medium`,children:e.title}),(0,A.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:L(e)?O(`已连接`,`Connected`):O(`需要授权`,`Authorization required`)})]}),(0,A.jsx)(b,{variant:L(e)?`secondary`:`primary`,disabled:K||c.resources!==`ready`,onClick:()=>{g(null),_(``),E.current=c.revision,y(e.id)},children:L(e)?O(`重新授权`,`Reconnect`):O(`连接账号`,`Connect account`)})]},e.id))]}):null,!B&&c.resources===`ready`?(0,A.jsxs)(`div`,{children:[(0,A.jsx)(b,{variant:`secondary`,disabled:K,onClick:Z,children:O(`暂时跳过`,`Skip for now`)}),(0,A.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:O(`先完成安装,稍后在详情页授权。未授权的功能暂不可用。`,`Finish installation and connect later in plugin details. Unauthenticated features remain unavailable.`)})]}):null,B&&Object.keys(U).length&&!x?(0,A.jsx)(b,{variant:`ghost`,disabled:K,onClick:()=>S(!0),children:O(`修改插件配置`,`Edit plugin configuration`)}):null,B&&!R.length&&N.some(e=>e.methods.some(e=>e.type===`cli`))?(0,A.jsx)(b,{variant:`secondary`,disabled:K,onClick:()=>void J(`prepare`),children:O(`检查连接与权限`,`Check connection and permissions`)}):null,!K&&(p||[`failed`,`interrupted`].includes(c.state)||c.connections.some(e=>e.state===`error`))?(0,A.jsx)(b,{variant:`secondary`,onClick:()=>void J(`prepare`),children:O(`重试检查`,`Retry checks`)}):null,B?null:(0,A.jsx)(b,{variant:`ghost`,disabled:d,onClick:()=>void J(`cancel`),children:O(`取消安装`,`Cancel installation`)}),B&&!z.length&&!c.missingConfig?.length?e.setup?.tasks?.map(t=>(0,A.jsxs)(`div`,{className:`space-y-3 rounded-lg bg-surface-inset p-4 text-sm`,children:[(0,A.jsx)(`p`,{children:t}),(0,A.jsx)(b,{asChild:!0,disabled:!e.active,children:(0,A.jsx)(o,{to:`/chat/new?${new URLSearchParams({draft:t,projectScope:`none`})}`,state:{forceNewChat:!0},onClick:t=>{e.active?r?.():t.preventDefault()},children:O(`开始这个任务`,`Start this task`)})})]},t)):null]}),K?(0,A.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:O(`正在准备,可关闭后继续。`,`Preparing. You can close this window and resume.`)}):null,c?.error&&!c.deferred&&!c.missingConfig?.length?(0,A.jsx)(`p`,{className:`text-sm text-fg-muted`,children:W}):null,p?(0,A.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:p}):null]})}var L=`w-full rounded-lg border border-edge bg-surface-inset px-3 py-2 text-sm text-fg`;function R(e,t){if(e.startsWith(`content.skills:`)){let n=e.slice(15);return t?`提供技能:${n}`:`Add skill: ${n}`}if(e.startsWith(`runtime.mcp.stdio:`)){let n=e.slice(18).split(`:`,1)[0];return t?`在 Gateway 上运行工具服务:${n}`:`Run a tool service on the Gateway: ${n}`}if(e.startsWith(`network.mcp:`)){let n=e.slice(12).split(`:`,1)[0];return t?`连接外部工具服务:${n}`:`Connect to an external tool service: ${n}`}return e.startsWith(`runtime.capability-access:`)?t?`按账号授权启用相关技能和工具`:`Enable skills and tools according to account authorization`:e.startsWith(`runtime.authorization:`)?t?`在本机运行账号登录程序:${e.split(`:`)[1]}`:`Run account sign-in locally: ${e.split(`:`)[1]}`:e.startsWith(`runtime.resource:`)?t?`下载可执行资源:${e.split(`:`)[1]}`:`Download executable resource: ${e.split(`:`)[1]}`:e.startsWith(`network.resource:`)?t?`下载并校验资源:${e.split(`:`)[1]}`:`Download and verify resource: ${e.split(`:`)[1]}`:e}function z(e,t){return t?.publisher?.verification!==`verified`||t.latestVersion.riskTier&&t.latestVersion.riskTier!==`content`?!0:e.addedCapabilities.some(e=>!e.startsWith(`content.skills:`))}async function B(e,t,n){let r=await u(d(e),{method:t,...n===void 0?{}:{body:JSON.stringify(n)}});if(!r.ok)throw Error(r.error??`Request failed`);return r.payload}function V({extension:e,onClose:t,onUninstalled:n,initialSource:r=``,marketplace:o,autoInstall:u=!1}){let d=te(e=>e.language),v=d.startsWith(`zh`),oe=o?.localizations?.[v?`zh-CN`:`en`],C=oe?.displayName??o?.name,T=oe?.description??o?.description,D=(0,k.useId)(),{mutate:ce}=g(),[O,j]=(0,k.useState)(e),[M,N]=(0,k.useState)(r||e?.installationSource||``),[P,F]=(0,k.useState)(null),[V,H]=(0,k.useState)([]),[U,W]=(0,k.useState)(!1),[G,K]=(0,k.useState)(``),[q,J]=(0,k.useState)(!1),[Y,X]=(0,k.useState)(!1),[Z,le]=(0,k.useState)(!1),[ue,Q]=(0,k.useState)(!1),[de,fe]=(0,k.useState)(!1),[pe,me]=(0,k.useState)(!1),he=a(),ge=i(),[_e,ve]=(0,k.useState)(!1),ye=(0,k.useRef)(!1),be=`/api/extensions/agent-plugins/${encodeURIComponent(O?.pluginId??``)}`,xe=M.trim().startsWith(`store:`),Se=()=>ce(`gateway-extensions-list`);async function $(e){W(!0),K(``);try{await e()}catch(e){K(e instanceof Error?e.message:String(e))}finally{W(!1)}}function Ce(e){N(e),F(null),H([]),K(``)}let we=typeof window<`u`?window.electronAPI?.file:void 0,Te=/^(?:\/|[A-Za-z]:[\\/])/.test(M.trim())?M.trim():void 0;async function Ee(){if(!we?.openDirectory){fe(!0);return}let e=await we.openDirectory(Te?{defaultPath:Te}:void 0);e&&Ce(e)}async function De(){if(!we?.openFile){fe(!0);return}let e=await we.openFile({...Te?{defaultPath:Te}:{},extensions:[`zip`]});e&&Ce(e)}function Oe(e){return[...e.dataTransfer.types].some(e=>e===`Files`||e===`text/plain`||e===`text/uri-list`)}function ke(e){if(!Oe(e))return;e.preventDefault(),Q(!1);let t=Array.from(e.dataTransfer.files);if(t.length){if(t.length>1){K(v?`一次只能选择一个插件目录或 ZIP。`:`Choose one plugin directory or ZIP at a time.`);return}let e=we?.getPathForFile?.(t[0]);e?Ce(e):K(v?`浏览器无法读取本机文件路径,请使用“选择文件或目录”选择安装包。`:`The browser cannot read local file paths. Use Choose file or folder to select the package.`);return}let n=e.dataTransfer.getData(`text/uri-list`)||e.dataTransfer.getData(`text/plain`);n.trim()&&Ce(n.trim().split(/\r?\n/)[0])}async function Ae(e){j(await B(`${be}/activation`,`POST`,{enabled:e})),await Se()}async function je(e){let t=!O,n=await B(t?`/api/extensions/install`:`${be}/update`,`POST`,{source:M,reviewHash:e.reviewHash,...e.layout?{setup:!0}:{}});j(n),await Se(),!e.layout&&t&&!n.activationEligible&&n.readiness!==`blocked`&&n.pluginId&&(n=await B(`/api/extensions/agent-plugins/${encodeURIComponent(n.pluginId)}/activation`,`POST`,{enabled:!0}),j(n),await Se()),F(null),ve(!e.layout&&t&&n.activationEligible===!0)}async function Me(){let e=await B(`/api/extensions/inspect`,`POST`,{source:M});if(z(e,o)){F(e);return}await je(e)}(0,k.useEffect)(()=>{e&&!e.setup&&j(e)},[e]),(0,k.useEffect)(()=>{if(!e?.setup||!e.pluginId)return;let t=!1;return B(`/api/extensions/agent-plugins/${encodeURIComponent(e.pluginId)}`,`GET`).then(e=>{t||j(e)}).catch(()=>{}),()=>{t=!0}},[e?.pluginId]),(0,k.useEffect)(()=>{!u||O||!xe||ye.current||(ye.current=!0,$(Me))},[u,O,xe]);let Ne=u&&!O&&xe&&!ye.current;return(0,A.jsx)(h,{defaultOpen:!0,onOpenChange:e=>!e&&t(),children:(0,A.jsxs)(m,{children:[(0,A.jsx)(f,{className:`fixed inset-0 z-[130] bg-scrim`}),(0,A.jsxs)(ne,{className:`fixed left-1/2 top-1/2 z-[131] flex h-[min(82vh,42rem)] w-[min(38rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover`,children:[(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge p-4`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,A.jsx)(E,{iconUrl:O?.branding?.iconUrl??o?.branding?.iconUrl,fallback:y}),(0,A.jsx)(re,{className:`font-semibold`,children:O?.name??C??(v?`安装插件`:`Install plugin`)})]}),(0,A.jsx)(b,{variant:`ghost`,onClick:t,children:v?`关闭`:`Close`})]}),(0,A.jsx)(p,{className:`sr-only`,children:v?`安装、组件、账号连接和权限`:`Installation, components, connections and permissions`}),(0,A.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto p-4`,children:[!O&&xe?(0,A.jsxs)(`section`,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:[(0,A.jsx)(_,{className:`mt-0.5 size-5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`p`,{className:`font-medium text-fg`,children:C??P?.manifest.name??M.slice(6)}),T?(0,A.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:T}):null,(0,A.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:o?.publisher?.verification===`verified`?v?`已认证发布者 · 安装后所有 Agent 均可使用`:`Verified publisher · available to all agents after installation`:v?`安装前会检查来源和所需权限`:`Source and required permissions are checked before installation`})]})]}),P?null:(0,A.jsxs)(b,{className:`w-full`,disabled:U||Ne,onClick:()=>void $(Me),children:[U||Ne?(0,A.jsx)(ae,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,U||Ne?v?`正在安全检查并安装…`:`Checking and installing…`:v?`一键安装`:`Install`]})]}):null,O?(0,A.jsxs)(A.Fragment,{children:[_e?(0,A.jsxs)(`div`,{role:`status`,className:`flex items-start gap-3 rounded-lg border border-emerald-500/25 bg-emerald-500/10 p-4`,children:[(0,A.jsx)(ee,{className:`mt-0.5 size-5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`font-medium text-fg`,children:v?`插件已安装并启用`:`Plugin installed and enabled`}),(0,A.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:v?`现在可以直接在对话中使用它。`:`It is ready to use in your conversations.`})]})]}):null,(!O.setup||O.readiness!==`setup_required`)&&!O.activationEligible?(0,A.jsxs)(`div`,{role:`status`,className:`space-y-3 rounded-lg border border-accent/25 bg-accent-soft p-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`font-medium text-accent-fg`,children:v?`插件已安装,当前尚未启用`:`Plugin installed. It is not enabled yet.`}),(0,A.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:v?`启用后,Skills 和 MCP 才会加入 Agent 运行时。`:`Enable it to make its skills and MCP servers available to the Agent runtime.`})]}),(0,A.jsx)(b,{disabled:U||O.readiness===`blocked`,onClick:()=>void $(()=>Ae(!0)),children:v?`启用插件`:`Enable plugin`})]}):null,O.setup?(0,A.jsx)(I,{extension:O,zh:v,onStart:t,onInstalled:()=>{t(),he(se(O.pluginId,`installed`,!1,ge.pathname+ge.search))},onChanged:async()=>{j(await B(`${be}`,`GET`)),await Se()}}):null,(0,A.jsxs)(`details`,{className:`rounded-lg border border-edge p-3`,children:[(0,A.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:v?`插件详情`:`Plugin details`}),(0,A.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,A.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[v?`插件`:`Plugin`,` · `,O.version,` · `,O.readiness&&{ready:v?`已就绪`:`Ready`,setup_required:v?`待连接`:`Setup required`,degraded:v?`部分不可用`:`Partially available`,blocked:v?`已阻止`:`Blocked`}[O.readiness]]}),O.provenance?(0,A.jsxs)(`p`,{className:`break-words text-xs text-fg-muted`,children:[O.provenance.publisherVerification===`verified`?v?`已认证发布者`:`Verified publisher`:v?`社区发布者`:`Community publisher`,` · `,O.provenance.packageName,`@`,O.provenance.version,` · SHA-256 `,O.provenance.sha256.slice(0,12),`…`,O.provenance.riskTier?` · ${O.provenance.riskTier}`:``]}):null,(0,A.jsx)(`p`,{className:`text-sm`,children:O.description}),O.installationSource?(0,A.jsxs)(`p`,{className:`break-all text-xs text-fg-muted`,children:[v?`来源:`:`Source: `,O.installationSource,O.resolvedCommit?` · ${O.resolvedCommit.slice(0,12)}`:``]}):null,O.activationEligible?(0,A.jsx)(b,{disabled:U,variant:`secondary`,onClick:()=>void $(()=>Ae(!1)),children:v?`停用`:`Disable`}):null,O.canRollback?(0,A.jsx)(b,{disabled:U,variant:`secondary`,onClick:()=>void $(async()=>{j(await B(`${be}/rollback`,`POST`)),await Se()}),children:v?`回滚上一版本`:`Roll back`}):null]})]}),O.diagnostics?.map((e,t)=>(0,A.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[e.component,`: `,e.message]},t))]}):null,O?(0,A.jsxs)(b,{variant:`ghost`,className:`px-0`,"aria-expanded":pe,onClick:()=>me(e=>!e),children:[(0,A.jsx)(w,{className:l(`size-4 transition-transform motion-reduce:transition-none`,pe&&`rotate-180`),"aria-hidden":!0}),v?`高级操作`:`Advanced actions`]}):null,!O&&!xe||pe?(0,A.jsxs)(`form`,{className:l(`space-y-3`,O&&`border-t border-edge pt-4`),onSubmit:e=>{e.preventDefault(),$(async()=>{let e=await B(`/api/extensions/inspect`,`POST`,{source:M});e.candidates?(H(e.candidates),F(null)):(H([]),F(e))})},children:[(0,A.jsxs)(`div`,{"data-testid":`plugin-source-dropzone`,className:l(`rounded-xl border border-dashed p-3 transition-colors`,ue?`border-accent bg-accent-soft`:`border-edge bg-surface-inset/40`),onDragEnter:e=>{Oe(e)&&(e.preventDefault(),Q(!0))},onDragOver:e=>{Oe(e)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,Q(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||Q(!1)},onDrop:ke,children:[(0,A.jsxs)(`div`,{className:`mb-2 flex items-start gap-2`,children:[(0,A.jsx)(S,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{htmlFor:D,className:`block text-sm font-medium`,children:O?v?`更新包来源`:`Update package source`:v?`安装包来源`:`Package source`}),(0,A.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:v?`输入 github:组织/仓库、Git / ZIP 地址或宿主目录;marketplace 可选择插件。`:`Enter github:owner/repo, a Git / ZIP URL or a Gateway directory. Marketplaces let you choose a plugin.`})]})]}),(0,A.jsx)(`input`,{id:D,className:L,value:M,onChange:e=>Ce(e.target.value),placeholder:v?`/插件目录/或/插件.zip`:`/plugin/folder/or/plugin.zip`,autoComplete:`off`,spellCheck:!1,required:!0}),(0,A.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:we?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(b,{type:`button`,variant:`secondary`,disabled:U,onClick:()=>void $(Ee),children:[(0,A.jsx)(s,{className:`size-4`,"aria-hidden":!0}),v?`选择目录`:`Choose directory`]}),(0,A.jsxs)(b,{type:`button`,variant:`secondary`,disabled:U,onClick:()=>void $(De),children:[(0,A.jsx)(x,{className:`size-4`,"aria-hidden":!0}),v?`选择 ZIP`:`Choose ZIP`]})]}):(0,A.jsxs)(b,{type:`button`,variant:`secondary`,disabled:U,onClick:()=>fe(!0),children:[(0,A.jsx)(s,{className:`size-4`,"aria-hidden":!0}),v?`选择文件或目录`:`Choose file or folder`]})})]}),(0,A.jsx)(b,{type:`submit`,variant:`secondary`,disabled:U||!M,children:v?`检查安装包`:`Inspect package`})]}):null,V.length?(0,A.jsx)(`div`,{className:`space-y-2`,"aria-label":v?`选择插件`:`Choose a plugin`,children:V.map(e=>(0,A.jsx)(b,{variant:`secondary`,className:`w-full justify-start`,onClick:()=>{Ce(e.source),$(async()=>F(await B(`/api/extensions/inspect`,`POST`,{source:e.source})))},children:e.name},e.source))}):null,P?(0,A.jsxs)(`div`,{role:`region`,"aria-labelledby":`plugin-authorization-title`,className:`space-y-3 rounded-xl border border-amber-500/30 bg-amber-500/10 p-4 text-sm`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,A.jsx)(_,{className:`mt-0.5 size-5 shrink-0 text-amber-700 dark:text-amber-300`,"aria-hidden":!0}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{id:`plugin-authorization-title`,className:`font-medium text-fg`,children:v?`需要你的授权`:`Your authorization is required`}),(0,A.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:v?`此插件需要以下新增能力。确认后自动准备资源,按需登录账号,所有 Agent 均可使用。`:`Review these capabilities. Resources are prepared automatically; sign in if needed. Available to all agents.`})]})]}),(0,A.jsx)(`ul`,{tabIndex:0,"aria-label":v?`插件新增能力`:`Added plugin capabilities`,className:`max-h-[min(28vh,14rem)] space-y-2 overflow-y-auto overscroll-contain rounded-lg border border-edge bg-surface-panel p-3 break-words focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:P.addedCapabilities.map(e=>(0,A.jsxs)(`li`,{className:`flex gap-2`,children:[(0,A.jsx)(`span`,{"aria-hidden":!0,children:`•`}),(0,A.jsx)(`span`,{children:R(e,v)})]},e))}),P.capabilities.some(e=>e.startsWith(`runtime.`))?(0,A.jsxs)(`details`,{children:[(0,A.jsx)(`summary`,{className:`cursor-pointer text-fg-muted`,children:v?`查看执行内容`:`View execution details`}),(0,A.jsx)(`ul`,{tabIndex:0,"aria-label":v?`插件执行内容`:`Plugin execution details`,className:`mt-2 max-h-40 space-y-2 overflow-y-auto overscroll-contain break-all font-mono text-xs`,children:P.capabilities.filter(e=>e.startsWith(`runtime.`)).map(e=>(0,A.jsx)(`li`,{children:e},e))})]}):null,P.diagnostics.map((e,t)=>(0,A.jsxs)(`p`,{children:[e.component,`: `,e.message]},t))]}):null,O&&pe?(0,A.jsx)(`div`,{className:`border-t border-edge pt-4`,children:Z?(0,A.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,A.jsx)(`p`,{children:v?`卸载保留账号凭据;服务端授权需到相应服务撤销。`:`Credentials are retained. Revoke provider authorization in the service itself.`}),(0,A.jsxs)(`label`,{className:`flex gap-2`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:q,onChange:e=>J(e.target.checked)}),v?`同时删除插件数据`:`Also delete plugin data`]}),(0,A.jsxs)(`label`,{className:`flex gap-2`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:Y,onChange:e=>X(e.target.checked)}),v?`同时删除本地凭据`:`Also delete local credentials`]}),(0,A.jsx)(b,{disabled:U,onClick:()=>void $(async()=>{await B(be,`DELETE`,{removeData:q,removeCredentials:Y}),await Se(),(n??t)()}),children:v?`确认卸载`:`Confirm uninstall`})]}):(0,A.jsx)(b,{variant:`ghost`,disabled:U,onClick:()=>le(!0),children:v?`卸载插件`:`Uninstall`})}):null,G?(0,A.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-fg-muted`,children:G}):null]}),P?(0,A.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge p-4`,children:[(0,A.jsx)(b,{variant:`ghost`,disabled:U,onClick:()=>F(null),children:v?`取消`:`Cancel`}),(0,A.jsxs)(b,{disabled:U||!!O&&P.manifest.name!==O.name,onClick:()=>void $(()=>je(P)),children:[U?(0,A.jsx)(ae,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,v?`授权并安装`:`Authorize and install`]})]}):null]}),we?null:(0,A.jsx)(ie,{open:de,onOpenChange:fe,initialAbsolutePath:Te,onConfirm:async e=>Ce(e),wd:c(d).chat.workingDirectory,selectKind:`file-or-directory`,fileExtensions:[`zip`],title:v?`选择插件安装包`:`Choose plugin package`,description:v?`选择插件目录或 ZIP 文件。`:`Choose a plugin directory or ZIP file.`,confirmLabel:v?`使用此来源`:`Use this source`,nested:!0})]})})}function H(e,t){return e.localizations?.[t?`zh-CN`:`en`]?.displayName??(e.setup?.authorizations?.length===1?e.setup.authorizations[0].title:e.name)}function U(e){return e.authorizationStatus===`required`||!!e.setup?.authorizations?.length&&e.authorizationStatus!==`connected`}function W(e){return e.active&&!U(e)&&(e.authorizationStatus===`connected`||e.authorizationStatus===`not_required`)}export{I as a,V as i,H as n,U as r,W as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./download-Dk-ZjtO6.js";import{t as r}from"./external-link-DjqjBmc3.js";import{t as i}from"./cn-0WouolD0.js";import{Ic as a,os as o}from"./index-
|
|
1
|
+
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./download-Dk-ZjtO6.js";import{t as r}from"./external-link-DjqjBmc3.js";import{t as i}from"./cn-0WouolD0.js";import{Ic as a,os as o}from"./index-K2cy4f-3.js";var s=e(),c=t();function l(e){let t=(0,s.c)(31),{message:l,downloadLabel:u,onDownload:d,openSystemLabel:f,onOpenWithSystemApp:p,chooseAppLabel:m,onChooseOpenWithApp:h,canOpenWithSystemApp:g,canChooseOpenWithApp:_}=e,v=g===void 0?!0:g,y=_===void 0?!0:_,b;t[0]!==v||t[1]!==p||t[2]!==f?(b=o()&&v&&typeof p==`function`&&typeof f==`string`&&f.length>0,t[0]=v,t[1]=p,t[2]=f,t[3]=b):b=t[3];let x=b,S;t[4]!==y||t[5]!==m||t[6]!==h?(S=o()&&y&&typeof h==`function`&&typeof m==`string`&&m.length>0,t[4]=y,t[5]=m,t[6]=h,t[7]=S):S=t[7];let C=S,w;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(w=i(`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-hover/60 p-3 sm:flex-row sm:items-center sm:justify-between dark:border-edge`),t[8]=w):w=t[8];let T;t[9]===l?T=t[10]:(T=(0,c.jsx)(`p`,{className:`min-w-0 text-xs leading-relaxed text-fg-muted`,children:l}),t[9]=l,t[10]=T);let E;t[11]!==p||t[12]!==f||t[13]!==x?(E=x?(0,c.jsxs)(`button`,{type:`button`,className:i(`inline-flex items-center gap-1.5 rounded-md border border-edge bg-surface-panel px-3 py-1.5 text-xs font-medium text-fg shadow-sm dark:border-edge`,a.transition,a.press,a.focusRingPanel),onClick:()=>void p?.(),children:[(0,c.jsx)(r,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),f]}):null,t[11]=p,t[12]=f,t[13]=x,t[14]=E):E=t[14];let D;t[15]!==m||t[16]!==h||t[17]!==C?(D=C?(0,c.jsxs)(`button`,{type:`button`,className:i(`inline-flex items-center gap-1.5 rounded-md border border-edge bg-surface-panel px-3 py-1.5 text-xs font-medium text-fg shadow-sm dark:border-edge`,a.transition,a.press,a.focusRingPanel),onClick:()=>void h?.(),children:[(0,c.jsx)(r,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),m]}):null,t[15]=m,t[16]=h,t[17]=C,t[18]=D):D=t[18];let O;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(O=i(`inline-flex items-center gap-1.5 rounded-md border border-accent bg-accent px-3 py-1.5 text-xs font-medium text-on-accent shadow-sm`,a.transition,a.press,a.focusRingPanel),t[19]=O):O=t[19];let k;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,c.jsx)(n,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[20]=k):k=t[20];let A;t[21]!==u||t[22]!==d?(A=(0,c.jsxs)(`button`,{type:`button`,className:O,onClick:d,children:[k,u]}),t[21]=u,t[22]=d,t[23]=A):A=t[23];let j;t[24]!==A||t[25]!==E||t[26]!==D?(j=(0,c.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[E,D,A]}),t[24]=A,t[25]=E,t[26]=D,t[27]=j):j=t[27];let M;return t[28]!==j||t[29]!==T?(M=(0,c.jsxs)(`div`,{className:w,children:[T,j]}),t[28]=j,t[29]=T,t[30]=M):M=t[30],M}export{l as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{d as n,r,t as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{n as a}from"./locale-store-D5h-Ha6-.js";import{a as o,r as s}from"./product-delivery-DwmnNJvk.js";import{i as c}from"./vendor-swr-BIWyz7Rc.js";import{Hr as l,Rc as u}from"./index-
|
|
1
|
+
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{d as n,r,t as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{n as a}from"./locale-store-D5h-Ha6-.js";import{a as o,r as s}from"./product-delivery-DwmnNJvk.js";import{i as c}from"./vendor-swr-BIWyz7Rc.js";import{Hr as l,Rc as u}from"./index-K2cy4f-3.js";import{t as d}from"./open-route-MyZ2sB9C.js";var f=e(),p=t();function m(){let e=(0,f.c)(14),t=n(),i=a(h)===`zh`,m=s(`xopc://open${t.search}`),_=m?.kind===`local_app`?m.id:null,{data:v,error:y}=c(_?[`local-app-open`,_]:null,()=>l(_));if(!m){let t=i?`这个打开链接无效。`:`This open link is invalid.`,n;return e[0]!==t||e[1]!==i?(n=(0,p.jsx)(g,{message:t,zh:i}),e[0]=t,e[1]=i,e[2]=n):n=e[2],n}if(m.kind!==`local_app`){let t=o({...m,title:m.id,capabilities:[`open`]}),n;return e[3]!==t||e[4]!==i?(n=t?(0,p.jsx)(r,{to:t,replace:!0}):(0,p.jsx)(g,{message:i?`这个内容无法在应用中打开。`:`This content cannot be opened in the app.`,zh:i}),e[3]=t,e[4]=i,e[5]=n):n=e[5],n}if(y){let t=typeof y==`object`&&y&&`status`in y&&y.status===404?i?`找不到这个应用,它可能已被删除。`:`This app was not found and may have been deleted.`:y instanceof Error?y.message:i?`无法打开这个应用。`:`Unable to open this app.`,n;return e[6]!==t||e[7]!==i?(n=(0,p.jsx)(g,{message:t,zh:i}),e[6]=t,e[7]=i,e[8]=n):n=e[8],n}if(v){let t;e[9]===v?t=e[10]:(t=d(v),e[9]=v,e[10]=t);let n;return e[11]===t?n=e[12]:(n=(0,p.jsx)(r,{to:t,replace:!0}),e[11]=t,e[12]=n),n}let b;return e[13]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,p.jsxs)(`div`,{className:`flex w-full flex-col gap-4 px-3 py-6 sm:px-5 xl:px-6`,"aria-busy":!0,children:[(0,p.jsx)(u,{className:`h-6 w-48`}),(0,p.jsx)(u,{className:`h-32 rounded-xl`})]}),e[13]=b):b=e[13],b}function h(e){return e.language}function g(e){let t=(0,f.c)(7),{message:n,zh:r}=e,a;t[0]===n?a=t[1]:(a=(0,p.jsx)(`p`,{children:n}),t[0]=n,t[1]=a);let o=r?`查看应用`:`View apps`,s;t[2]===o?s=t[3]:(s=(0,p.jsx)(i,{className:`mt-3 inline-flex font-medium text-accent hover:underline`,to:`/local-apps`,children:o}),t[2]=o,t[3]=s);let c;return t[4]!==a||t[5]!==s?(c=(0,p.jsxs)(`div`,{className:`m-6 rounded-xl border border-danger/30 bg-danger-soft p-4 text-sm text-danger`,role:`alert`,children:[a,s]}),t[4]=a,t[5]=s,t[6]=c):c=t[6],c}export{m as ProductOpenPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as r}from"./markdown-view-CthsQiiO.js";import{t as i}from"./messages-Bwv-AOYl.js";import{c as a,n as o,r as s}from"./locale-store-D5h-Ha6-.js";import{i as c}from"./vendor-swr-BIWyz7Rc.js";import{Hr as l,Pn as u,Wr as d,_o as f,fi as p,h as m,ji as h,l as g,v as _,vi as v}from"./index-DmURUvvA.js";import{i as y}from"./automation-display-DCkjVzA0.js";import{t as b}from"./open-route-MyZ2sB9C.js";var x=e(),S=t();async function C(e){switch(e.kind){case`project`:return{kind:e.kind,value:await f(e.id)};case`workflow_run`:return{kind:e.kind,value:await m(e.id,{ownerAgentId:e.ownerAgentId})};case`workflow_definition`:{let t=await _();return{kind:e.kind,value:t.find(t=>t.id===e.id||t.name===e.id)}}case`automation`:{let[t,n]=await Promise.all([g.list(),g.runs(5,e.id)]);return{kind:e.kind,value:t.automations.find(t=>t.id===e.id),runs:n.runs}}case`local_app`:{let t=await l(e.id),n=e.sourceHash?await d(e.id,e.sourceHash):void 0;return{kind:e.kind,value:t,previewUrl:n?.previewUrl||t.draftPreviewUrl}}}}var w={pending:[`等待中`,`Pending`],planned:[`计划中`,`Planned`],active:[`进行中`,`Active`],paused:[`已暂停`,`Paused`],completed:[`已完成`,`Completed`],cancelled:[`已取消`,`Cancelled`],archived:[`已归档`,`Archived`],queued:[`排队中`,`Queued`],running:[`运行中`,`Running`],succeeded:[`成功`,`Succeeded`],failed:[`失败`,`Failed`],timeout:[`超时`,`Timed out`],cancelling:[`取消中`,`Cancelling`],unknown:[`尚未评估`,`Not assessed`],on_track:[`进展正常`,`On track`],at_risk:[`存在风险`,`At risk`],off_track:[`偏离计划`,`Off track`]};function T(e){let t=(0,x.c)(138),{target:r}=e,l=a(A),d=o(k),f=d===`zh`,m=i(d),g;t[0]===f?g=t[1]:(g=e=>w[e]?.[+!f]||e,t[0]=f,t[1]=g);let _=g,T;t[2]!==r.href||t[3]!==l?(T=[`chat-product-preview`,r.href,l],t[2]=r.href,t[3]=l,t[4]=T):T=t[4];let j;t[5]===r?j=t[6]:(j=()=>C(r),t[5]=r,t[6]=j);let M;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(M={shouldRetryOnError:!1,refreshInterval:O},t[7]=M):M=t[7];let{data:N,error:P,isLoading:F}=c(T,j,M);if(F){let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,S.jsx)(u,{}),t[8]=e):e=t[8],e}if(P){let e=f?`无法加载内容,它可能已删除或暂时不可用。`:`Unable to load this content. It may have been deleted or be temporarily unavailable.`,n;return t[9]===e?n=t[10]:(n=(0,S.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:e}),t[9]=e,t[10]=n),n}if(!N?.value){let e=f?`内容不存在或已删除。`:`This content is unavailable or has been deleted.`,n;return t[11]===e?n=t[12]:(n=(0,S.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[11]=e,t[12]=n),n}let I=D;if(N.kind===`project`){let e=N.value,n;t[13]===e.name?n=t[14]:(n=(0,S.jsx)(`h2`,{className:`break-words text-lg font-semibold text-fg`,children:e.name}),t[13]=e.name,t[14]=n);let r;t[15]!==e.status||t[16]!==_?(r=_(e.status),t[15]=e.status,t[16]=_,t[17]=r):r=t[17];let i;t[18]!==e.health||t[19]!==_?(i=_(e.health),t[18]=e.health,t[19]=_,t[20]=i):i=t[20];let a;t[21]!==r||t[22]!==i?(a=(0,S.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[r,` · `,i]}),t[21]=r,t[22]=i,t[23]=a):a=t[23];let o;t[24]!==I||t[25]!==e.description?(o=I(e.description),t[24]=I,t[25]=e.description,t[26]=o):o=t[26];let s;t[27]!==I||t[28]!==e.brief?(s=I(e.brief),t[27]=I,t[28]=e.brief,t[29]=s):s=t[29];let c;t[30]!==I||t[31]!==e.outcome?(c=I(e.outcome),t[30]=I,t[31]=e.outcome,t[32]=c):c=t[32];let l;t[33]!==s||t[34]!==c||t[35]!==n||t[36]!==a||t[37]!==o?(l=(0,S.jsxs)(`div`,{className:`space-y-3`,children:[n,a,o,s,c]}),t[33]=s,t[34]=c,t[35]=n,t[36]=a,t[37]=o,t[38]=l):l=t[38];let u;t[39]!==e.successCriteria||t[40]!==f?(u=e.successCriteria?.length>0&&(0,S.jsxs)(`section`,{className:`space-y-3`,children:[(0,S.jsx)(`h3`,{className:`font-medium text-fg`,children:f?`完成标准`:`Success criteria`}),(0,S.jsx)(`ul`,{className:`list-disc space-y-2 pl-5 text-sm text-fg`,children:e.successCriteria.map(E)})]}),t[39]=e.successCriteria,t[40]=f,t[41]=u):u=t[41];let d;t[42]!==e.milestones||t[43]!==_||t[44]!==f?(d=e.milestones?.length>0&&(0,S.jsxs)(`section`,{className:`space-y-3`,children:[(0,S.jsx)(`h3`,{className:`font-medium text-fg`,children:f?`里程碑`:`Milestones`}),e.milestones.slice(0,8).map(e=>(0,S.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[e.title,` · `,_(e.status)]},e.id))]}),t[42]=e.milestones,t[43]=_,t[44]=f,t[45]=d):d=t[45];let p;t[46]!==I||t[47]!==e.recentUpdates||t[48]!==f?(p=e.recentUpdates?.[0]&&(0,S.jsxs)(`section`,{className:`space-y-3`,children:[(0,S.jsx)(`h3`,{className:`font-medium text-fg`,children:f?`最近进展`:`Latest update`}),I(e.recentUpdates[0].summary)]}),t[46]=I,t[47]=e.recentUpdates,t[48]=f,t[49]=p):p=t[49];let m;return t[50]!==l||t[51]!==u||t[52]!==d||t[53]!==p?(m=(0,S.jsxs)(`div`,{className:`space-y-6`,children:[l,u,d,p]}),t[50]=l,t[51]=u,t[52]=d,t[53]=p,t[54]=m):m=t[54],m}if(N.kind===`workflow_run`){let{run:e,phases:n}=N.value,r;t[55]===e.title?r=t[56]:(r=(0,S.jsx)(`h2`,{className:`break-words text-lg font-semibold text-fg`,children:e.title}),t[55]=e.title,t[56]=r);let i;t[57]!==e.status||t[58]!==_?(i=_(e.status),t[57]=e.status,t[58]=_,t[59]=i):i=t[59];let a=e.metrics?` · ${e.metrics.doneAgentCount}/${e.metrics.agentCount} ${f?`执行单元完成`:`agents completed`}`:``,o;t[60]!==i||t[61]!==a?(o=(0,S.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[i,a]}),t[60]=i,t[61]=a,t[62]=o):o=t[62];let s;t[63]!==r||t[64]!==o?(s=(0,S.jsxs)(`div`,{className:`space-y-3`,children:[r,o]}),t[63]=r,t[64]=o,t[65]=s):s=t[65];let c;t[66]===e.error?c=t[67]:(c=e.error&&(0,S.jsx)(`p`,{role:`alert`,className:`rounded-lg border border-edge p-3 text-sm text-danger`,children:e.error.message}),t[66]=e.error,t[67]=c);let l;t[68]!==I||t[69]!==e.result||t[70]!==f?(l=p(e.result)?I(v(e.result)):(0,S.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f?`尚无运行结果。`:`No result yet.`}),t[68]=I,t[69]=e.result,t[70]=f,t[71]=l):l=t[71];let u;t[72]!==n||t[73]!==_||t[74]!==f?(u=n.length>0&&(0,S.jsxs)(`section`,{className:`space-y-3`,children:[(0,S.jsx)(`h3`,{className:`font-medium text-fg`,children:f?`运行进度`:`Progress`}),n.map(e=>(0,S.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[e.title,` · `,_(e.status)]},e.id))]}),t[72]=n,t[73]=_,t[74]=f,t[75]=u):u=t[75];let d;return t[76]!==c||t[77]!==l||t[78]!==u||t[79]!==s?(d=(0,S.jsxs)(`div`,{className:`space-y-6`,children:[s,c,l,u]}),t[76]=c,t[77]=l,t[78]=u,t[79]=s,t[80]=d):d=t[80],d}if(N.kind===`workflow_definition`){let e=N.value,n,r,i,a;if(t[81]!==e||t[82]!==d||t[83]!==I){let o=h(e,d);n=`space-y-6`,r=(0,S.jsx)(`h2`,{className:`break-words text-lg font-semibold text-fg`,children:o.title}),i=I(o.description),a=I(o.whenToUse),t[81]=e,t[82]=d,t[83]=I,t[84]=n,t[85]=r,t[86]=i,t[87]=a}else n=t[84],r=t[85],i=t[86],a=t[87];let o;t[88]!==e.phases||t[89]!==I||t[90]!==f?(o=e.phases.length>0&&(0,S.jsxs)(`section`,{className:`space-y-3`,children:[(0,S.jsx)(`h3`,{className:`font-medium text-fg`,children:f?`执行阶段`:`Phases`}),e.phases.map(e=>(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:e.title}),I(e.description)]},e.id))]}),t[88]=e.phases,t[89]=I,t[90]=f,t[91]=o):o=t[91];let s;return t[92]!==n||t[93]!==r||t[94]!==i||t[95]!==a||t[96]!==o?(s=(0,S.jsxs)(`div`,{className:n,children:[r,i,a,o]}),t[92]=n,t[93]=r,t[94]=i,t[95]=a,t[96]=o,t[97]=s):s=t[97],s}if(N.kind===`automation`){let e=N.value,n=e.action.kind===`agent`?e.action.instruction:e.action.kind===`workflow`?e.action.goal:void 0,r;t[98]===e.name?r=t[99]:(r=(0,S.jsx)(`h2`,{className:`break-words text-lg font-semibold text-fg`,children:e.name}),t[98]=e.name,t[99]=r);let i;t[100]!==e.description||t[101]!==I?(i=I(e.description),t[100]=e.description,t[101]=I,t[102]=i):i=t[102];let a;t[103]!==n||t[104]!==I?(a=I(n),t[103]=n,t[104]=I,t[105]=a):a=t[105];let o;t[106]!==e.state.nextRunAtMs||t[107]!==f?(o=e.state.nextRunAtMs&&(0,S.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[f?`下次运行`:`Next run`,` · `,new Date(e.state.nextRunAtMs).toLocaleString(f?`zh-CN`:`en-US`)]}),t[106]=e.state.nextRunAtMs,t[107]=f,t[108]=o):o=t[108];let s;t[109]===e.state.lastError?s=t[110]:(s=e.state.lastError&&(0,S.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:e.state.lastError}),t[109]=e.state.lastError,t[110]=s);let c=f?`最近运行`:`Recent runs`,l;t[111]===c?l=t[112]:(l=(0,S.jsx)(`h3`,{className:`font-medium text-fg`,children:c}),t[111]=c,t[112]=l);let u;t[113]!==N.runs||t[114]!==I||t[115]!==_||t[116]!==f?(u=N.runs.length?N.runs.map(e=>(0,S.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-edge p-3`,children:[(0,S.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[_(e.status),` · `,new Date(e.createdAtMs).toLocaleString(f?`zh-CN`:`en-US`)]}),I(e.summary),e.error&&(0,S.jsx)(`p`,{className:`text-sm text-danger`,children:e.error})]},e.id)):(0,S.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f?`暂无运行记录。`:`No runs yet.`}),t[113]=N.runs,t[114]=I,t[115]=_,t[116]=f,t[117]=u):u=t[117];let p;return t[118]!==l||t[119]!==u?(p=(0,S.jsxs)(`section`,{className:`space-y-3`,children:[l,u]}),t[118]=l,t[119]=u,t[120]=p):p=t[120],(0,S.jsxs)(`div`,{className:`space-y-6`,children:[(0,S.jsxs)(`div`,{className:`space-y-3`,children:[r,(0,S.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[e.enabled?f?`已启用`:`Enabled`:f?`已停用`:`Disabled`,` · `,y(e.trigger,m.automations,m.cron,d)]}),i,a,o,s]}),p]})}let L=N.value,R;t[121]===L.name?R=t[122]:(R=(0,S.jsx)(`h2`,{className:`break-words text-lg font-semibold text-fg`,children:L.name}),t[121]=L.name,t[122]=R);let z=L.description||L.idea,B;t[123]!==I||t[124]!==z?(B=I(z),t[123]=I,t[124]=z,t[125]=B):B=t[125];let V;t[126]!==L.name||t[127]!==N.previewUrl||t[128]!==f?(V=N.previewUrl&&(0,S.jsx)(`iframe`,{title:f?`${L.name} 交互预览`:`${L.name} interactive preview`,src:s(N.previewUrl),sandbox:`allow-scripts allow-forms`,className:`h-[min(30rem,55dvh)] w-full rounded-lg border border-edge bg-white`}),t[126]=L.name,t[127]=N.previewUrl,t[128]=f,t[129]=V):V=t[129];let H;t[130]!==L||t[131]!==f?(H=L.installationState===`installed`&&L.enabled&&L.status===`installed`&&(0,S.jsx)(n,{to:b(L),className:`inline-flex rounded-lg bg-accent px-3 py-2 text-sm text-white focus-visible:ring-2 focus-visible:ring-accent`,children:f?`使用应用`:`Use app`}),t[130]=L,t[131]=f,t[132]=H):H=t[132];let U;return t[133]!==R||t[134]!==B||t[135]!==V||t[136]!==H?(U=(0,S.jsxs)(`div`,{className:`space-y-5`,children:[R,B,V,H]}),t[133]=R,t[134]=B,t[135]=V,t[136]=H,t[137]=U):U=t[137],U}function E(e,t){return(0,S.jsx)(`li`,{children:e},t)}function D(e){return e?.trim()?(0,S.jsx)(r,{content:e,mermaidActions:!1}):null}function O(e){return e?.kind===`workflow_run`&&[`queued`,`running`].includes(e.value.run.status)||e?.kind===`automation`&&e.value?.state.runningRunId?3e3:0}function k(e){return e.language}function A(e){return e.conversationId}export{T as default};
|
|
1
|
+
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as r}from"./markdown-view-CthsQiiO.js";import{t as i}from"./messages-Bwv-AOYl.js";import{c as a,n as o,r as s}from"./locale-store-D5h-Ha6-.js";import{i as c}from"./vendor-swr-BIWyz7Rc.js";import{Hr as l,Pn as u,Wr as d,_o as f,fi as p,h as m,ji as h,l as g,v as _,vi as v}from"./index-K2cy4f-3.js";import{i as y}from"./automation-display-DCkjVzA0.js";import{t as b}from"./open-route-MyZ2sB9C.js";var x=e(),S=t();async function C(e){switch(e.kind){case`project`:return{kind:e.kind,value:await f(e.id)};case`workflow_run`:return{kind:e.kind,value:await m(e.id,{ownerAgentId:e.ownerAgentId})};case`workflow_definition`:{let t=await _();return{kind:e.kind,value:t.find(t=>t.id===e.id||t.name===e.id)}}case`automation`:{let[t,n]=await Promise.all([g.list(),g.runs(5,e.id)]);return{kind:e.kind,value:t.automations.find(t=>t.id===e.id),runs:n.runs}}case`local_app`:{let t=await l(e.id),n=e.sourceHash?await d(e.id,e.sourceHash):void 0;return{kind:e.kind,value:t,previewUrl:n?.previewUrl||t.draftPreviewUrl}}}}var w={pending:[`等待中`,`Pending`],planned:[`计划中`,`Planned`],active:[`进行中`,`Active`],paused:[`已暂停`,`Paused`],completed:[`已完成`,`Completed`],cancelled:[`已取消`,`Cancelled`],archived:[`已归档`,`Archived`],queued:[`排队中`,`Queued`],running:[`运行中`,`Running`],succeeded:[`成功`,`Succeeded`],failed:[`失败`,`Failed`],timeout:[`超时`,`Timed out`],cancelling:[`取消中`,`Cancelling`],unknown:[`尚未评估`,`Not assessed`],on_track:[`进展正常`,`On track`],at_risk:[`存在风险`,`At risk`],off_track:[`偏离计划`,`Off track`]};function T(e){let t=(0,x.c)(138),{target:r}=e,l=a(A),d=o(k),f=d===`zh`,m=i(d),g;t[0]===f?g=t[1]:(g=e=>w[e]?.[+!f]||e,t[0]=f,t[1]=g);let _=g,T;t[2]!==r.href||t[3]!==l?(T=[`chat-product-preview`,r.href,l],t[2]=r.href,t[3]=l,t[4]=T):T=t[4];let j;t[5]===r?j=t[6]:(j=()=>C(r),t[5]=r,t[6]=j);let M;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(M={shouldRetryOnError:!1,refreshInterval:O},t[7]=M):M=t[7];let{data:N,error:P,isLoading:F}=c(T,j,M);if(F){let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,S.jsx)(u,{}),t[8]=e):e=t[8],e}if(P){let e=f?`无法加载内容,它可能已删除或暂时不可用。`:`Unable to load this content. It may have been deleted or be temporarily unavailable.`,n;return t[9]===e?n=t[10]:(n=(0,S.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:e}),t[9]=e,t[10]=n),n}if(!N?.value){let e=f?`内容不存在或已删除。`:`This content is unavailable or has been deleted.`,n;return t[11]===e?n=t[12]:(n=(0,S.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[11]=e,t[12]=n),n}let I=D;if(N.kind===`project`){let e=N.value,n;t[13]===e.name?n=t[14]:(n=(0,S.jsx)(`h2`,{className:`break-words text-lg font-semibold text-fg`,children:e.name}),t[13]=e.name,t[14]=n);let r;t[15]!==e.status||t[16]!==_?(r=_(e.status),t[15]=e.status,t[16]=_,t[17]=r):r=t[17];let i;t[18]!==e.health||t[19]!==_?(i=_(e.health),t[18]=e.health,t[19]=_,t[20]=i):i=t[20];let a;t[21]!==r||t[22]!==i?(a=(0,S.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[r,` · `,i]}),t[21]=r,t[22]=i,t[23]=a):a=t[23];let o;t[24]!==I||t[25]!==e.description?(o=I(e.description),t[24]=I,t[25]=e.description,t[26]=o):o=t[26];let s;t[27]!==I||t[28]!==e.brief?(s=I(e.brief),t[27]=I,t[28]=e.brief,t[29]=s):s=t[29];let c;t[30]!==I||t[31]!==e.outcome?(c=I(e.outcome),t[30]=I,t[31]=e.outcome,t[32]=c):c=t[32];let l;t[33]!==s||t[34]!==c||t[35]!==n||t[36]!==a||t[37]!==o?(l=(0,S.jsxs)(`div`,{className:`space-y-3`,children:[n,a,o,s,c]}),t[33]=s,t[34]=c,t[35]=n,t[36]=a,t[37]=o,t[38]=l):l=t[38];let u;t[39]!==e.successCriteria||t[40]!==f?(u=e.successCriteria?.length>0&&(0,S.jsxs)(`section`,{className:`space-y-3`,children:[(0,S.jsx)(`h3`,{className:`font-medium text-fg`,children:f?`完成标准`:`Success criteria`}),(0,S.jsx)(`ul`,{className:`list-disc space-y-2 pl-5 text-sm text-fg`,children:e.successCriteria.map(E)})]}),t[39]=e.successCriteria,t[40]=f,t[41]=u):u=t[41];let d;t[42]!==e.milestones||t[43]!==_||t[44]!==f?(d=e.milestones?.length>0&&(0,S.jsxs)(`section`,{className:`space-y-3`,children:[(0,S.jsx)(`h3`,{className:`font-medium text-fg`,children:f?`里程碑`:`Milestones`}),e.milestones.slice(0,8).map(e=>(0,S.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[e.title,` · `,_(e.status)]},e.id))]}),t[42]=e.milestones,t[43]=_,t[44]=f,t[45]=d):d=t[45];let p;t[46]!==I||t[47]!==e.recentUpdates||t[48]!==f?(p=e.recentUpdates?.[0]&&(0,S.jsxs)(`section`,{className:`space-y-3`,children:[(0,S.jsx)(`h3`,{className:`font-medium text-fg`,children:f?`最近进展`:`Latest update`}),I(e.recentUpdates[0].summary)]}),t[46]=I,t[47]=e.recentUpdates,t[48]=f,t[49]=p):p=t[49];let m;return t[50]!==l||t[51]!==u||t[52]!==d||t[53]!==p?(m=(0,S.jsxs)(`div`,{className:`space-y-6`,children:[l,u,d,p]}),t[50]=l,t[51]=u,t[52]=d,t[53]=p,t[54]=m):m=t[54],m}if(N.kind===`workflow_run`){let{run:e,phases:n}=N.value,r;t[55]===e.title?r=t[56]:(r=(0,S.jsx)(`h2`,{className:`break-words text-lg font-semibold text-fg`,children:e.title}),t[55]=e.title,t[56]=r);let i;t[57]!==e.status||t[58]!==_?(i=_(e.status),t[57]=e.status,t[58]=_,t[59]=i):i=t[59];let a=e.metrics?` · ${e.metrics.doneAgentCount}/${e.metrics.agentCount} ${f?`执行单元完成`:`agents completed`}`:``,o;t[60]!==i||t[61]!==a?(o=(0,S.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[i,a]}),t[60]=i,t[61]=a,t[62]=o):o=t[62];let s;t[63]!==r||t[64]!==o?(s=(0,S.jsxs)(`div`,{className:`space-y-3`,children:[r,o]}),t[63]=r,t[64]=o,t[65]=s):s=t[65];let c;t[66]===e.error?c=t[67]:(c=e.error&&(0,S.jsx)(`p`,{role:`alert`,className:`rounded-lg border border-edge p-3 text-sm text-danger`,children:e.error.message}),t[66]=e.error,t[67]=c);let l;t[68]!==I||t[69]!==e.result||t[70]!==f?(l=p(e.result)?I(v(e.result)):(0,S.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f?`尚无运行结果。`:`No result yet.`}),t[68]=I,t[69]=e.result,t[70]=f,t[71]=l):l=t[71];let u;t[72]!==n||t[73]!==_||t[74]!==f?(u=n.length>0&&(0,S.jsxs)(`section`,{className:`space-y-3`,children:[(0,S.jsx)(`h3`,{className:`font-medium text-fg`,children:f?`运行进度`:`Progress`}),n.map(e=>(0,S.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[e.title,` · `,_(e.status)]},e.id))]}),t[72]=n,t[73]=_,t[74]=f,t[75]=u):u=t[75];let d;return t[76]!==c||t[77]!==l||t[78]!==u||t[79]!==s?(d=(0,S.jsxs)(`div`,{className:`space-y-6`,children:[s,c,l,u]}),t[76]=c,t[77]=l,t[78]=u,t[79]=s,t[80]=d):d=t[80],d}if(N.kind===`workflow_definition`){let e=N.value,n,r,i,a;if(t[81]!==e||t[82]!==d||t[83]!==I){let o=h(e,d);n=`space-y-6`,r=(0,S.jsx)(`h2`,{className:`break-words text-lg font-semibold text-fg`,children:o.title}),i=I(o.description),a=I(o.whenToUse),t[81]=e,t[82]=d,t[83]=I,t[84]=n,t[85]=r,t[86]=i,t[87]=a}else n=t[84],r=t[85],i=t[86],a=t[87];let o;t[88]!==e.phases||t[89]!==I||t[90]!==f?(o=e.phases.length>0&&(0,S.jsxs)(`section`,{className:`space-y-3`,children:[(0,S.jsx)(`h3`,{className:`font-medium text-fg`,children:f?`执行阶段`:`Phases`}),e.phases.map(e=>(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:e.title}),I(e.description)]},e.id))]}),t[88]=e.phases,t[89]=I,t[90]=f,t[91]=o):o=t[91];let s;return t[92]!==n||t[93]!==r||t[94]!==i||t[95]!==a||t[96]!==o?(s=(0,S.jsxs)(`div`,{className:n,children:[r,i,a,o]}),t[92]=n,t[93]=r,t[94]=i,t[95]=a,t[96]=o,t[97]=s):s=t[97],s}if(N.kind===`automation`){let e=N.value,n=e.action.kind===`agent`?e.action.instruction:e.action.kind===`workflow`?e.action.goal:void 0,r;t[98]===e.name?r=t[99]:(r=(0,S.jsx)(`h2`,{className:`break-words text-lg font-semibold text-fg`,children:e.name}),t[98]=e.name,t[99]=r);let i;t[100]!==e.description||t[101]!==I?(i=I(e.description),t[100]=e.description,t[101]=I,t[102]=i):i=t[102];let a;t[103]!==n||t[104]!==I?(a=I(n),t[103]=n,t[104]=I,t[105]=a):a=t[105];let o;t[106]!==e.state.nextRunAtMs||t[107]!==f?(o=e.state.nextRunAtMs&&(0,S.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[f?`下次运行`:`Next run`,` · `,new Date(e.state.nextRunAtMs).toLocaleString(f?`zh-CN`:`en-US`)]}),t[106]=e.state.nextRunAtMs,t[107]=f,t[108]=o):o=t[108];let s;t[109]===e.state.lastError?s=t[110]:(s=e.state.lastError&&(0,S.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:e.state.lastError}),t[109]=e.state.lastError,t[110]=s);let c=f?`最近运行`:`Recent runs`,l;t[111]===c?l=t[112]:(l=(0,S.jsx)(`h3`,{className:`font-medium text-fg`,children:c}),t[111]=c,t[112]=l);let u;t[113]!==N.runs||t[114]!==I||t[115]!==_||t[116]!==f?(u=N.runs.length?N.runs.map(e=>(0,S.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-edge p-3`,children:[(0,S.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[_(e.status),` · `,new Date(e.createdAtMs).toLocaleString(f?`zh-CN`:`en-US`)]}),I(e.summary),e.error&&(0,S.jsx)(`p`,{className:`text-sm text-danger`,children:e.error})]},e.id)):(0,S.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f?`暂无运行记录。`:`No runs yet.`}),t[113]=N.runs,t[114]=I,t[115]=_,t[116]=f,t[117]=u):u=t[117];let p;return t[118]!==l||t[119]!==u?(p=(0,S.jsxs)(`section`,{className:`space-y-3`,children:[l,u]}),t[118]=l,t[119]=u,t[120]=p):p=t[120],(0,S.jsxs)(`div`,{className:`space-y-6`,children:[(0,S.jsxs)(`div`,{className:`space-y-3`,children:[r,(0,S.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[e.enabled?f?`已启用`:`Enabled`:f?`已停用`:`Disabled`,` · `,y(e.trigger,m.automations,m.cron,d)]}),i,a,o,s]}),p]})}let L=N.value,R;t[121]===L.name?R=t[122]:(R=(0,S.jsx)(`h2`,{className:`break-words text-lg font-semibold text-fg`,children:L.name}),t[121]=L.name,t[122]=R);let z=L.description||L.idea,B;t[123]!==I||t[124]!==z?(B=I(z),t[123]=I,t[124]=z,t[125]=B):B=t[125];let V;t[126]!==L.name||t[127]!==N.previewUrl||t[128]!==f?(V=N.previewUrl&&(0,S.jsx)(`iframe`,{title:f?`${L.name} 交互预览`:`${L.name} interactive preview`,src:s(N.previewUrl),sandbox:`allow-scripts allow-forms`,className:`h-[min(30rem,55dvh)] w-full rounded-lg border border-edge bg-white`}),t[126]=L.name,t[127]=N.previewUrl,t[128]=f,t[129]=V):V=t[129];let H;t[130]!==L||t[131]!==f?(H=L.installationState===`installed`&&L.enabled&&L.status===`installed`&&(0,S.jsx)(n,{to:b(L),className:`inline-flex rounded-lg bg-accent px-3 py-2 text-sm text-white focus-visible:ring-2 focus-visible:ring-accent`,children:f?`使用应用`:`Use app`}),t[130]=L,t[131]=f,t[132]=H):H=t[132];let U;return t[133]!==R||t[134]!==B||t[135]!==V||t[136]!==H?(U=(0,S.jsxs)(`div`,{className:`space-y-5`,children:[R,B,V,H]}),t[133]=R,t[134]=B,t[135]=V,t[136]=H,t[137]=U):U=t[137],U}function E(e,t){return(0,S.jsx)(`li`,{children:e},t)}function D(e){return e?.trim()?(0,S.jsx)(r,{content:e,mermaidActions:!1}):null}function O(e){return e?.kind===`workflow_run`&&[`queued`,`running`].includes(e.value.run.status)||e?.kind===`automation`&&e.value?.state.runningRunId?3e3:0}function k(e){return e.language}function A(e){return e.conversationId}export{T as default};
|