@xopcai/xopc 0.0.376 → 0.0.377
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/{activity-store-CvR3rjdp.js → activity-store-BVtU6S1w.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-B6OsxiBw.js → agent-avatar-dicebear-BD63ce58.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-MB_QmjX-.js → agent-defaults-settings-panel-Ch07F4uX.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-plugin-dialog-Bpcf0zhP.js → agent-plugin-dialog-CdCVOg5e.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-BQ7ag_R3.js → agents-D2__mhy8.js} +3 -3
- package/dist/gateway/static/root/assets/{agents-admin-api-DsXvJeqd.js → agents-admin-api-DgQph1Pu.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-9JzhRHSD.js → app-management-settings-panel-B0yP8rNC.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-CoyZuGAt.js → appearance-settings-Bnq1nzDX.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-CcbCxZaw.js → apps-page-CSIFuEnj.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-kfDRSd7K.js → archive-plugin-FBVMH4ym.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-DZJKbmlm.js → automations-page-qsg6pZlF.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-ChKT1JN6.js → automations-workspace-DqBWLl61.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-d4QP_iyy.js → binary-plugins-B0qGhVNs.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-DraiSml9.js → block-editor-CjQv4zlo.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automation-inputs-BAiaU9gl.js → browser-automation-inputs-DSbRHrG7.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-Bo40qRor.js → browser-automations-page-CzEWM_ie.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-Dg4S7ph5.js → browser-settings-page-CsDck88G.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-B-vsqiw2.js → capabilities-HaRLmYU1.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-DQEeiNq_.js → capabilities-LpGa-olH.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-page-CuHSjBDG.js → capabilities-page-BeQ-Yj3_.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-bxxADxzW.js → capabilities-settings-panel-BQ-I3L-C.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-header-actions-CaH0L2sV.js → capability-header-actions-DuBac0EK.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-Drx78hEY.js → channels-1wUJcCxP.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-hZnKhClF.js → chat-terminal-dock-CQc1mqZM.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-CYEA9B-G.js → computer-settings-page-BIwOemaK.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-DXi2Bx2u.js → connector-service-page-CG9KKuXq.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-BCWPY5hs.js → connectors-page-BFzjGpKE.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-BW_xBw2L.js → date-picker-DoZGE2hF.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-ByRPupfC.js → dependency-picker-hrz7p1Lv.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-DTcVMPlC.js → desktop-pet-C1bTu_dG.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-BkMP5pdR.js → desktop-pet-settings-C2xCFimg.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-5kYuK9oW.js → device-pairing-wizard-CZ5Wmq5U.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-DIYIejyX.js → directory-picker-path-field-BaHQhI4z.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-QCUvXcP2.js → extension-debug-page-B1uMVNGe.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-BMeQveJ_.js → extension-page-850m5tOc.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-CDOEBj7F.js → extension-provider-B-_CkaD2.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-D-M7P4HQ.js → extension-settings-page-P3FNAW0n.js} +1 -1
- package/dist/gateway/static/root/assets/{fallback-models-5DaUVrLS.js → fallback-models-BoJZA9Cm.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-CWIVt5XM.js → gateway-config-swr-siY2J0hx.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-realtime-DC8N3fNU.js → gateway-realtime-Biz18NiE.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-BazlseY_.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-settings-DK2NzPkL.js → gateway-settings-BG1zXG8B.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-pVqdX0dO.js → gateway-startup-retry-CeL1OFDZ.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-A3oTV3Vq.js → home-page-B8RmZbDw.js} +1 -1
- package/dist/gateway/static/root/assets/{image-generation-api-CX6__We2.js → image-generation-api-CeDrok06.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-b0ILSTz1.js → imports-page-C9FTl2dW.js} +1 -1
- package/dist/gateway/static/root/assets/index-CGVecvp4.css +1 -0
- package/dist/gateway/static/root/assets/{index-Cz75qf5b.js → index-DU5FmDQh.js} +28 -28
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DGl7wSHG.js → keyboard-shortcuts-settings-Dx-36I-c.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page--W2QjBqz.js → local-app-workbench-page-Cg4gdTwm.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-8SQ85WLr.js → local-apps-page-3GKgu7at.js} +1 -1
- package/dist/gateway/static/root/assets/{local-session-drafts-LCEmswHW.js → local-session-drafts-DnSw14fE.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-UEl-U1DO.js → locale-store-DSsLH7JO.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-BAQeHGd4.js → logs-page-CApZnDPi.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-DoXDsSSN.js → management-settings-DcgCzPd-.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-DUo9Tl3H.js → markdown-view-2rwSrMXW.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-8zr2wlMR.js → media-plugins-CjGiKLFo.js} +1 -1
- package/dist/gateway/static/root/assets/messages-Cn25s55n.js +3 -0
- package/dist/gateway/static/root/assets/models-hub-cache-DaqiLHPe.js +1 -0
- package/dist/gateway/static/root/assets/{note-detail-panel-Cg65uYJ3.js → note-detail-panel-CncL3xmy.js} +3 -3
- package/dist/gateway/static/root/assets/{notes-api-bDQOslzF.js → notes-api-D9fGUbkK.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-DDUlWJOk.js → notes-page-D9romxNU.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-o-i2_7Jz.js → page-context-capture-button-CKqYL9AQ.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-page-E9-LBR1_.js → personal-page-DoG-2fru.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-DWgjStlK.js → product-open-page-DFu_ZT2h.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-content-BWQRI242.js → product-preview-content-tPBCFa7L.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-FjGobz6n.js → project-detail-page-C9Bt5toA.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-CVhXJp7f.js → projects-page-Bu3jZa3A.js} +1 -1
- package/dist/gateway/static/root/assets/{registry-api-CftkuRz7.js → registry-api-ZhIt79wL.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-B2AcKWlb.js → remote-access-hub-C9MNGl2t.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DmOfq9ay.js → runtime-tools-settings-panel-BYQuPsWk.js} +1 -1
- package/dist/gateway/static/root/assets/{scenes-page-QQ2CiTee.js → scenes-page-7LjR8Aek.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-TbUx_9NF.js → schema-form-GwVc8KsT.js} +1 -1
- package/dist/gateway/static/root/assets/{send-session-input-D4c72mD6.js → send-session-input-B64q4_6R.js} +1 -1
- package/dist/gateway/static/root/assets/{session-api-DtpzfFNw.js → session-api-BUa3BaGX.js} +1 -1
- package/dist/gateway/static/root/assets/session-manager-BWLIDok4.js +16 -0
- package/dist/gateway/static/root/assets/{sessions-page-CquSXQHo.js → sessions-page-CzbNB_RT.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-CmNe5RJ4.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-NncRVc1e.js → settings-page-DAvi3P8Q.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-t1vcGUsK.js → setup-status-panel-DoAn6P_k.js} +1 -1
- package/dist/gateway/static/root/assets/{share-link-dialog-DGUiTTZ3.js → share-link-dialog-CbkS1cj-.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-BDl6XGKm.js → share-preview-page-DicRCB4L.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-api-BIx5ji2U.js → shares-api-BUGeqXCG.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-DVM6xJuW.js → shares-settings-Bbkz0xuD.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-api-Crld1PEV.js → skill-api-DpTUuYWk.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-D2HAboLP.js → skill-reload-api-CII18PA5.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-DdD6C_Z8.js → skills-page-BuBSAOOd.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-DUro5X0b.js → system-settings-panel-DlNaQp-l.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-BYNcWubZ.js → task-detail-page-DeElbs6T.js} +1 -1
- package/dist/gateway/static/root/assets/{task-expandable-content-BKa2YEJy.js → task-expandable-content-sONbgbwR.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-ByAapAD7.js → theme-store-Kz0VUMSb.js} +1 -1
- package/dist/gateway/static/root/assets/{tracing-settings-page-Dv-XBvpD.js → tracing-settings-page-CZHhm1Nn.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-C2_SEpMa.js → tunnel-api-sUbAaSX6.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-CqMzyGiK.js → usage-page-NPLApyNj.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-BhsYFV0o.js → use-autosave-CZzYhcAl.js} +1 -1
- package/dist/gateway/static/root/assets/{use-composer-attachments-Bv4umde0.js → use-composer-attachments-Bb_Hqqry.js} +1 -1
- package/dist/gateway/static/root/assets/{use-file-preview-expanded-CBVymo3h.js → use-file-preview-expanded-D4WI5JDn.js} +2 -2
- package/dist/gateway/static/root/assets/{user-model-page-EMn_nA9w.js → user-model-page-DAEiJzNV.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-DRoGFFs6.js → voice-api-key-field-CIIGmtHR.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-BwLiaw5J.js → voice-config-api-BtWFziQc.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-DbH62mtI.js → work-discovery-overlay-DxRDLQvs.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BYfytB9q.js → workflow-run-setup-panel-Be_Rey6d.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-rJqJ9dQo.js → workflows-page-wJk7l1_H.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-api-BHy2a_hm.js → workspace-api-B5ssQs4p.js} +2 -2
- package/dist/gateway/static/root/assets/{xopc-cloud-account-card-DrAX_9m_.js → xopc-cloud-account-card-D7Rtu5eI.js} +1 -1
- package/dist/gateway/static/root/index.html +27 -27
- package/dist/package.js +1 -1
- package/dist/src/agent/session/session-config-service.js +2 -4
- package/dist/src/browser/native-messaging-host.js +1 -1
- package/dist/src/browser/providers/browser-ext-install.js +2 -2
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/onboard.js +1 -1
- package/dist/src/gateway/hono/app.js +1 -1
- package/dist/src/gateway/hono/routes/browser-install.js +1 -1
- package/dist/src/gateway/service/session-command-service.js +1 -1
- package/dist/src/gateway/service.js +4 -4
- package/dist/src/home-intelligence/host.js +2 -2
- package/dist/src/personal-agent/service.js +1 -11
- package/dist/src/providers/prompt-cache-payload.js +18 -22
- package/dist/src/session/config-store.js +1 -2
- package/dist/src/storage/sqlite/device-pairing-approval.js +1 -1
- package/dist/src/storage/sqlite/migrations/246_personal_session_thinking.sql +22 -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/package.json +3 -3
- package/dist/gateway/static/root/assets/gateway-realtime-store-BkE2mHog.js +0 -1
- package/dist/gateway/static/root/assets/index-BGBkIIzM.css +0 -1
- package/dist/gateway/static/root/assets/messages-Uqz0xpsK.js +0 -3
- package/dist/gateway/static/root/assets/models-hub-cache-3HOFy11k.js +0 -1
- package/dist/gateway/static/root/assets/session-manager-De46GeR0.js +0 -16
- package/dist/gateway/static/root/assets/settings-advanced-gate-BOHKIN4t.js +0 -1
- package/dist/src/personal-agent/model-config.d.ts +0 -5
- package/dist/src/personal-agent/model-config.js +0 -59
package/dist/gateway/static/root/assets/{personal-page-E9-LBR1_.js → personal-page-DoG-2fru.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-BMYIfy9x.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./popover-select-BgSdSbCL.js";import{x as s}from"./markdown-view-DUo9Tl3H.js";import{t as c}from"./play-kxZvpBg8.js";import{t as l}from"./settings-2-D-csvaET.js";import{t as u}from"./x-B_N4OPjy.js";import{t as d}from"./messages-Uqz0xpsK.js";import{a as f,n as p,r as m}from"./locale-store-UEl-U1DO.js";import{nt as h,t as g,u as _,w as v}from"./session-manager-De46GeR0.js";import{a as y,i as b,o as x,r as S,s as C,t as w}from"./dist-C3DSFZCi.js";import{t as T}from"./skeleton-BwbyijEw.js";import{t as E}from"./date-formatters-CUZAyDEg.js";import{$i as D,Bc as O,Do as k,Ji as A,Jr as j,K as M,Q as N,Rc as P,Sa as F,da as ee,ea as te,es as ne,fo as re,ha as ie,n as ae,q as oe,wa as I,xs as L,zc as se}from"./index-Cz75qf5b.js";import{l as R,n as ce,t as le}from"./voice-config-api-BwLiaw5J.js";var z=n(),B=e(t(),1),V=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,B.useState)(),[r,i]=(0,B.useState)(``),[a,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(``),u=c.trim().toLowerCase().replaceAll(`_`,` `),d=[...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,B.useEffect)(()=>{let e=!0;return f(m(`/api/personal-agent/proactivity`)).then(t=>{e&&t.ok&&n(h.parse(t.payload))}).catch(t=>{e&&i(String(t))}),()=>{e=!1}},[]);async function p(e){if(!(!t||a)){s(!0),i(``);try{let r=await f(m(`/api/personal-agent/proactivity`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t,...e})});r.ok&&n(h.parse(r.payload))}catch(e){i(String(e));let t=await f(m(`/api/personal-agent/proactivity`)).catch(()=>null);t?.ok&&n(h.parse(t.payload))}finally{s(!1)}}}return(0,V.jsxs)(`section`,{className:`space-y-3 border-t border-edge pt-5`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:e?`主动联系`:`Proactive messages`}),!t&&!r?(0,V.jsx)(T,{className:`h-9 w-full`}):t&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(o,{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,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[e?`静默开始`:`Quiet from`,(0,V.jsx)(o,{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,V.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[e?`静默结束`:`Quiet until`,(0,V.jsx)(o,{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,V.jsxs)(`label`,{className:`block text-xs text-fg-muted`,children:[e?`时区`:`Timezone`,(0,V.jsx)(o,{placeholder:e?`选择时区`:`Choose timezone`,ariaLabel:e?`时区`:`Timezone`,value:t.timezone,selectedLabel:t.timezone.replaceAll(`_`,` `),options:d,disabled:a,allowEmpty:!1,triggerClassName:`mt-1`,searchPlaceholder:e?`搜索时区或城市`:`Search timezone or city`,searchValue:c,onSearchChange:l,statusMessage:d.length?void 0:e?`没有匹配的时区`:`No matching timezones`,onChange:e=>{l(``),e!==t.timezone&&p({timezone:e})}})]}),(0,V.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e?`有值得交流的进展时,在聊天里留下消息。明确请求的结果会照常交付。`:`Useful developments appear in this chat. Requested results are delivered as usual.`})]}),r&&(0,V.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r})]})}var H=[`intro`,`identity`,`voice`,`connections`],pe=[{id:`loopi`,zh:`小环`,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 f(m(`/api/agents/${encodeURIComponent(e)}/avatar`),{method:`PUT`,body:JSON.stringify({base64:n.slice(n.indexOf(`,`)+1),mimeType:t.type})}),D(e)}function ge({modelsAvailable:e,onCreated:t}){let n=p(e=>e.language)===`zh`,r=p(e=>e.language),[o,s]=(0,B.useState)(`intro`),[l,u]=(0,B.useState)({displayName:`Ada`,appearance:`loopi`,voice:null}),[h,g]=(0,B.useState)(!1),[_,v]=(0,B.useState)(!1),[y,b]=(0,B.useState)(null),[x,S]=(0,B.useState)(null),[C,w]=(0,B.useState)(null),[E,D]=(0,B.useState)(null),[k,j]=(0,B.useState)(!0),[P,ee]=(0,B.useState)([]),[te,ne]=(0,B.useState)(null),ae=(0,B.useRef)(null),L=(0,B.useRef)(null),[z,ue]=(0,B.useState)([]),[de,fe]=(0,B.useState)(!0),[ge,_e]=(0,B.useState)([]),[U,W]=(0,B.useState)(null);(0,B.useEffect)(()=>{let e=!1;return f(m(`/api/personal-agent/onboarding`)).then(t=>{e||(s(t.payload.step),u(t.payload.draft))}).catch(t=>{e||b(t instanceof Error?t.message:String(t))}).finally(()=>{e||g(!0)}),()=>{e=!0}},[]),(0,B.useEffect)(()=>{if(!h)return;let e=window.setTimeout(()=>{f(m(`/api/personal-agent/onboarding`),{method:`PUT`,body:JSON.stringify({step:o,draft:l})}).catch(()=>{})},350);return()=>window.clearTimeout(e)},[l,h,o]),(0,B.useEffect)(()=>{let e=!1;return le().then(t=>{e||(t.tts&&t.enabled?D({provider:t.tts.provider,model:t.tts.model,enabled:!0}):j(!1))}).catch(()=>{e||j(!1)}),()=>{e=!0}},[]),(0,B.useEffect)(()=>{if(!E?.enabled)return;let e=!1;return ce(E.provider,E.model,`realtime`).then(t=>{e||ee(t.slice(0,12))}).catch(()=>{}).finally(()=>{e||j(!1)}),()=>{e=!0}},[E]),(0,B.useEffect)(()=>{if(o!==`connections`)return;let e=!1;return fe(!0),Promise.allSettled([F({page:1,pageSize:24,verification:`verified`}),I()]).then(([t,n])=>{if(!e){if(t.status===`fulfilled`){let e=[`gmail`,`googlecalendar`,`googledrive`,`github`,`linear`];ue(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`&&_e(n.value),fe(!1)}}),()=>{e=!0}},[o]),(0,B.useEffect)(()=>()=>{L.current?.abort(),ae.current?.close()},[]),(0,B.useEffect)(()=>()=>{C&&URL.revokeObjectURL(C)},[C]);let G=async(e,t=l)=>{await f(m(`/api/personal-agent/onboarding`),{method:`PUT`,body:JSON.stringify({step:e,draft:t})}),s(e)},ve=async e=>{b(null);let t=H[Math.max(0,Math.min(H.length-1,H.indexOf(o)+e))];try{await G(t)}catch(e){b(e instanceof Error?e.message:String(e))}},K=async(n=!1)=>{if(!(!e||_)){v(!0),b(null);try{let e=n?{displayName:`Ada`,appearance:`loopi`,voice:null}:l,r=e.voice&&E?.enabled&&P.some(t=>t.id===e.voice)?{provider:E.provider,model:E.model,voice:e.voice}:void 0,i=(await f(m(`/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 f(m(`/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)}}},ye=(0,B.useCallback)(async e=>{L.current?.abort(),ae.current?.close();let t=new AbortController;L.current=t,ne(e),b(null);try{let n=new ie;ae.current=n,await n.start();let r=await R(t.signal,e);if(t.signal.aborted)return;n.enqueue(r,()=>ne(null))}catch(e){t.signal.aborted||b(e instanceof Error?e.message:String(e)),ne(null)}},[]);if(!h)return(0,V.jsxs)(`div`,{className:`mx-auto w-full max-w-xl space-y-4 px-6 py-14`,children:[(0,V.jsx)(T,{className:`h-10 w-2/3`}),(0,V.jsx)(T,{className:`h-64 w-full rounded-2xl`}),(0,V.jsx)(T,{className:`h-12 w-full rounded-xl`})]});let q=H.indexOf(o),be={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,V.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-surface-base`,children:[(0,V.jsx)(`header`,{className:`shrink-0 px-5 pt-5 sm:px-8 sm:pt-7`,children:(0,V.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl`,children:[(0,V.jsxs)(`div`,{className:`flex min-h-10 items-center justify-between gap-4`,children:[q>0?(0,V.jsxs)(`button`,{type:`button`,disabled:_,onClick:()=>void ve(-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,V.jsx)(O,{className:`size-4`}),n?`上一步`:`Back`]}):(0,V.jsx)(`span`,{className:`text-sm font-medium text-fg-muted`,children:n?`设置我的助手`:`Set up my assistant`}),(0,V.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,V.jsx)(`div`,{className:`mt-4 grid grid-cols-4 gap-1.5`,role:`progressbar`,"aria-label":n?`设置进度`:`Setup progress`,"aria-valuenow":q+1,"aria-valuemin":1,"aria-valuemax":H.length,children:H.map((e,t)=>(0,V.jsx)(`span`,{className:`h-1 rounded-full transition-colors duration-200 ${t<=q?`bg-accent`:`bg-surface-active`}`},e))})]})}),(0,V.jsx)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-8 sm:px-8`,children:(0,V.jsxs)(`div`,{className:`mx-auto my-auto w-full max-w-2xl py-6 motion-safe:animate-[page-enter_220ms_ease-out]`,children:[(0,V.jsxs)(`div`,{className:`mb-8 flex items-center gap-4`,children:[(0,V.jsx)(`span`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl bg-surface-hover`,children:C?(0,V.jsx)(`img`,{src:C,alt:``,className:`size-14 rounded-xl object-cover`}):(0,V.jsx)(A,{appearance:l.appearance,className:`size-14`})}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`我的助手`:`My assistant`}),(0,V.jsx)(`p`,{className:`mt-1 text-lg font-semibold text-fg`,children:l.displayName||`Ada`})]})]}),(0,V.jsx)(`p`,{className:`mb-3 text-xs font-medium tracking-wide text-fg-subtle`,children:n?`第 ${q+1} 步 · 共 ${H.length} 步`:`Step ${q+1} of ${H.length}`}),(0,V.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-fg sm:text-3xl`,children:be}),o===`intro`&&(0,V.jsxs)(`div`,{className:`mt-6 max-w-xl space-y-3 text-base leading-8 text-fg-muted`,children:[(0,V.jsx)(`p`,{children:n?`你可以找它讨论问题,也可以交给它一件要推进的事。`:`Talk through a question or give it something to move forward.`}),(0,V.jsx)(`p`,{children:n?`需要深入处理时,它会找合适的 Agent,并把进展带回对话。`:`It can ask a suitable Agent for deeper work and bring the progress back.`}),(0,V.jsx)(`p`,{children:n?`它能使用哪些数据和设备,由你决定。`:`You choose which data and devices it can use.`})]}),o===`identity`&&(0,V.jsxs)(`div`,{className:`mt-7 space-y-7`,children:[(0,V.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[n?`助手名字`:`Assistant name`,(0,V.jsx)(`input`,{value:l.displayName,maxLength:60,onChange:e=>u(t=>({...t,displayName:e.target.value})),onBlur:()=>u(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,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`选择头像`:`Choose an avatar`}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[pe.map(e=>(0,V.jsxs)(`button`,{type:`button`,"aria-pressed":!x&&l.appearance===e.id,onClick:()=>{S(null),w(null),u(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&&l.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,V.jsx)(A,{appearance:e.id,className:`size-14`}),n?e.zh:e.en]},e.id)),(0,V.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,V.jsx)(re,{className:`size-6`}),n?`上传图片`:`Upload image`,(0,V.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),w(URL.createObjectURL(t))}}})]})]}),(0,V.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,V.jsxs)(`div`,{className:`mt-5`,children:[(0,V.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.`}),k?(0,V.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[(0,V.jsx)(T,{className:`h-20 rounded-xl`}),(0,V.jsx)(T,{className:`h-20 rounded-xl`})]}):E?.enabled&&P.length>0?(0,V.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[(0,V.jsx)(`button`,{type:`button`,"aria-pressed":!l.voice,onClick:()=>u(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 ${l.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`}),P.map(e=>(0,V.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl p-3 transition-colors ${l.voice===e.id?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,V.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":l.voice===e.id,onClick:()=>u(t=>({...t,voice:e.id})),children:[(0,V.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.name}),(0,V.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e.description||e.style||(n?`点击选择`:`Select this voice`)})]}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>void ye(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,V.jsx)(c,{className:`size-4 ${te===e.id?`text-accent`:``}`})})]},e.id))]}):(0,V.jsxs)(`div`,{className:`mt-5 rounded-xl bg-surface-panel p-5 text-sm text-fg-muted`,children:[(0,V.jsx)(`p`,{children:n?`当前没有可试听的语音。你可以先用文字对话,稍后再设置。`:`No voice is ready to preview. You can start with text and set it up later.`}),(0,V.jsx)(i,{to:`/settings/capabilities/voice?returnTo=%2Fpersonal`,className:`mt-3 inline-block text-accent hover:underline`,children:n?`设置语音服务`:`Set up voice`})]})]}),o===`connections`&&(0,V.jsxs)(`div`,{className:`mt-5`,children:[(0,V.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.`}),de?(0,V.jsxs)(`div`,{className:`mt-5 space-y-2`,children:[(0,V.jsx)(T,{className:`h-18 rounded-xl`}),(0,V.jsx)(T,{className:`h-18 rounded-xl`})]}):(0,V.jsx)(`div`,{className:`mt-5 space-y-2`,children:z.length?z.map(e=>{let t=me(ge.find(t=>t.connectorId===e.id));return(0,V.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-surface-panel p-4`,children:[(0,V.jsx)(N,{connector:e,size:`sm`}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.displayName}),(0,V.jsx)(`p`,{className:`line-clamp-2 text-xs text-fg-muted`,children:e.description})]}),t?(0,V.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-success`,children:[(0,V.jsx)(a,{className:`size-4`}),n?`已连接`:`Connected`]}):(0,V.jsx)(`button`,{type:`button`,onClick:()=>W(M(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,V.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,V.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,V.jsx)(i,{to:`/settings/capabilities/models`,className:`text-accent underline`,children:n?`配置模型`:`Set up a model`})]}),y&&(0,V.jsx)(`p`,{role:`alert`,className:`mt-5 text-sm text-danger`,children:y})]},o)}),(0,V.jsx)(`footer`,{className:`shrink-0 px-5 pb-6 pt-3 sm:px-8 sm:pb-9`,children:(0,V.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,V.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n?`这些选择以后都能调整`:`You can change these choices later`}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[o===`intro`&&(0,V.jsx)(`button`,{type:`button`,disabled:!e||_,onClick:()=>void K(!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,V.jsx)(`button`,{type:`button`,onClick:()=>{let e={...l,voice:null};u(e),b(null),G(`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,V.jsxs)(`button`,{type:`button`,disabled:_||o===`connections`&&!e,onClick:()=>o===`connections`?void K():void ve(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,V.jsx)(se,{className:`size-4`})]})]})]})}),U&&(0,V.jsx)(oe,{draft:U,onChange:W,onClose:()=>W(null),t:d(r).connectorsSettings,onInstalled:async()=>{_e(await I()),W(null)}})]})}function _e({record:e,zh:t,onSelectVoice:n,onGreetingChange:r}){let[a,s]=(0,B.useState)(!1),[l,u]=(0,B.useState)(!0),[d,f]=(0,B.useState)(``),[p,m]=(0,B.useState)(null),[h,g]=(0,B.useState)([]),[_,v]=(0,B.useState)(e.voicePreference?.voice??``),[y,b]=(0,B.useState)(!1),[x,S]=(0,B.useState)(null),[C,w]=(0,B.useState)(null),E=(0,B.useRef)(null),D=(0,B.useRef)(null);(0,B.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await le();if(e||(s(t.openingGreeting===!0),!t.enabled||!t.tts))return;let n={provider:t.tts.provider,model:t.tts.model};m(n);let r=await ce(n.provider,n.model,`realtime`);e||g(r)}catch(t){e||S(t instanceof Error?t.message:String(t))}finally{e||u(!1)}})(),()=>{e=!0}},[]),(0,B.useEffect)(()=>()=>{D.current?.abort(),E.current?.close()},[]);let O=()=>{D.current?.abort(),D.current=null,E.current?.close(),E.current=null,w(null)},A=async e=>{if(C!==null){O();return}O(),S(null);let t=new AbortController;D.current=t,w(e);try{let n=new ie;E.current=n,await n.start();let r=await R(t.signal,e);t.signal.aborted||n.enqueue(r,()=>{D.current===t&&(w(null),D.current=null,E.current=null,n.close())})}catch(e){t.signal.aborted||S(e instanceof Error?e.message:String(e)),D.current===t&&O()}},j=async e=>{if(y||e===_)return;O();let t=_;v(e),f(``),b(!0),S(null);try{await n(e&&p?{provider:p.provider,model:p.model,voice:e}:null)||v(t)}catch(e){v(t),S(e instanceof Error?e.message:String(e))}finally{b(!1)}},M=h.find(e=>e.id===_),N=t?`默认声音`:`Default voice`,P=M?.name||(_?t?`当前音色不可用`:`Current voice unavailable`:N),F=d.trim().toLocaleLowerCase(),ee=h.filter(e=>!F||`${e.name} ${e.description??``} ${e.style??``}`.toLocaleLowerCase().includes(F)).map(e=>({value:e.id,label:e.name}));return(0,V.jsxs)(`section`,{className:`border-t border-edge pt-5`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:t?`通话声音`:`Call voice`}),l?(0,V.jsx)(`div`,{className:`mt-3`,"aria-busy":`true`,children:(0,V.jsx)(T,{className:`h-10 w-full`})}):p&&h.length?(0,V.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,V.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,V.jsx)(o,{value:_,selectedLabel:P,options:ee,placeholder:N,emptyLabel:N,ariaLabel:t?`选择通话音色`:`Choose call voice`,disabled:y,onChange:e=>void j(e),searchPlaceholder:h.length>8?t?`搜索音色`:`Search voices`:void 0,searchValue:d,onSearchChange:f,statusMessage:F&&!ee.length?t?`没有匹配的音色`:`No matching voices`:void 0})}),(0,V.jsxs)(`button`,{type:`button`,disabled:y||!!(_&&!M),onClick:()=>void A(_),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:C===null?t?`试听${P}`:`Preview ${P}`:t?`停止试听`:`Stop preview`,"aria-label":C===null?t?`试听${P}`:`Preview ${P}`:t?`停止试听`:`Stop preview`,children:[C===null?(0,V.jsx)(c,{className:`size-4`,"aria-hidden":!0}):(0,V.jsx)(k,{className:`size-4 text-accent`,"aria-hidden":!0}),C===null?t?`试听`:`Preview`:t?`停止`:`Stop`]})]}),(0,V.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:M?.description||M?.style||(_?t?`选择后自动保存,用于之后的语音通话。`:`Saved automatically for future voice calls.`:t?`跟随语音服务的默认音色。`:`Uses the voice service’s default voice.`)})]}):(0,V.jsxs)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:[t?`当前没有可用音色。`:`No voice is ready.`,` `,(0,V.jsx)(i,{to:`/settings/capabilities/voice?returnTo=%2Fpersonal`,className:`text-accent underline`,children:t?`设置语音服务`:`Set up voice`})]}),r&&a&&(0,V.jsxs)(`label`,{className:`mt-4 flex items-center justify-between gap-3 text-sm text-fg`,children:[t?`连接时打招呼`:`Greet me when connected`,(0,V.jsx)(`input`,{type:`checkbox`,checked:e.voiceCallPreferences?.openingGreetingEnabled??!0,disabled:y,onChange:e=>{let t=e.target.checked;b(!0),r(t).catch(e=>S(String(e))).finally(()=>b(!1))}})]}),x&&(0,V.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:x})]})}var U=new g;function W({conversationId:e,zh:t,onSaved:n}){let r=v(t=>t.sessions[e]),[i,a]=(0,B.useState)(!0),[o,s]=(0,B.useState)(``);(0,B.useEffect)(()=>{let t=!0;return U.loadSessionAgentConfig(e).then(n=>{t&&_(e,n)}).catch(e=>{t&&s(String(e))}).finally(()=>{t&&a(!1)}),()=>{t=!1}},[e]);let c=!!(r?.sending||r?.streaming||r?.modelConfigSaving);async function l(t,i){v.getState().patchSessionMeta(e,{modelConfigSaving:!0});try{_(e,await U.patchSessionAgentConfig(e,{model:t,thinkingLevel:i,configVersion:r?.configVersion})),await n()}catch(t){let n=await U.loadSessionAgentConfig(e).catch(()=>null);throw n&&_(e,n),t}finally{v.getState().patchSessionMeta(e,{modelConfigSaving:!1})}}return(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:t?`对话模型与思考强度`:`Conversation model and thinking`}),i?(0,V.jsx)(T,{className:`h-9 w-full`}):(0,V.jsx)(j,{chat:d(t?`zh`:`en`).chat,sessionModel:r?.model??``,thinkingLevel:r?.thinkingLevel??`off`,modelDisabled:c,thinkingDisabled:c,onModelChange:l,onThinkingChange:e=>l(r?.model??``,e)}),o&&(0,V.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:o})]})}var G=5;function ve(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 K(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 ye(e){let t=(0,z.c)(30),{item:n,zh:r}=e,a;t[0]!==n||t[1]!==r?(a=K(n,r),t[0]=n,t[1]=r,t[2]=a):a=t[2];let o=a,c;t[3]===n.id?c=t[4]:(c=s(`/personal`,n.id),t[3]=n.id,t[4]=c);let l=`mt-2 size-1.5 shrink-0 rounded-full ${o.tone}`,u;t[5]===l?u=t[6]:(u=(0,V.jsx)(`span`,{className:l,"aria-hidden":!0}),t[5]=l,t[6]=u);let d;t[7]===n.title?d=t[8]:(d=ve(n.title),t[7]=n.title,t[8]=d);let f;t[9]===d?f=t[10]:(f=(0,V.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]===o.label?p=t[12]:(p=(0,V.jsx)(`span`,{children:o.label}),t[11]=o.label,t[12]=p);let m;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,V.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=E(n.updatedAt,h),t[14]=n.updatedAt,t[15]=h,t[16]=g):g=t[16];let _;t[17]===g?_=t[18]:(_=(0,V.jsx)(`span`,{children:g}),t[17]=g,t[18]=_);let v;t[19]!==_||t[20]!==p?(v=(0,V.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,V.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,V.jsx)(P,{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,V.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 q=[{id:`direct`,warmth:`reserved`,zh:`直接`,en:`Direct`},{id:`natural`,warmth:`balanced`,zh:`自然`,en:`Natural`},{id:`gentle`,warmth:`gentle`,zh:`温和`,en:`Gentle`}],be=[{id:`loopi`,zh:`小环`,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 xe(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 Se(e){return q.find(t=>t.warmth===e.warmth)?.id??`natural`}function Ce(){let e=ee(),t=(0,B.useRef)(e);t.current=e;let n=p(e=>e.language)===`zh`,r=te(e=>e.setPageHeader),i=te(e=>e.clearPageHeader),[a,s]=(0,B.useState)(null),c=(0,B.useRef)(null),d=(0,B.useRef)(Promise.resolve()),[h,g]=(0,B.useState)([]),[_,v]=(0,B.useState)(!0),[E,O]=(0,B.useState)(0),[k,j]=(0,B.useState)(null),[M,N]=(0,B.useState)(!0),[P,F]=(0,B.useState)(!1),[ie,oe]=(0,B.useState)(`natural`),[I,se]=(0,B.useState)(`loopi`),[R,ce]=(0,B.useState)(!1),le=(0,B.useRef)(null),z=(0,B.useRef)(null),ue=(0,B.useRef)(null),[de,H]=(0,B.useState)(``),[pe,me]=(0,B.useState)(`untangle`),[he,U]=(0,B.useState)(`none`),[ve,K]=(0,B.useState)(`balanced`),[Ce,we]=(0,B.useState)(`decisions`),[Te,Ee]=(0,B.useState)(!1),[De,J]=(0,B.useState)(!1),[Oe,ke]=(0,B.useState)(!1),[Y,Ae]=(0,B.useState)(null),[je,Me]=(0,B.useState)(!1),[X,Ne]=(0,B.useState)(!1),[Pe,Fe]=(0,B.useState)(!1),[Z,Ie]=(0,B.useState)(0),Q=(0,B.useRef)(0),Le=(0,B.useCallback)(()=>{ke(!1),J(!1),Ee(!0)},[]),Re=(0,B.useCallback)(()=>{ke(!1),J(!1),Ee(e=>!e)},[]),ze=(0,B.useCallback)(async()=>{try{let[e,t]=await Promise.all([f(m(`/api/personal-agent`)),f(m(`/api/personal-agent/models`))]);if(c.current=e.payload,s(e.payload),e.payload?.state===`ready`){let e=await f(m(`/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`)),g(t.payload),e.payload&&(H(e.payload.displayName),se(e.payload.appearance),oe(Se(e.payload.preferences)),me(e.payload.preferences.supportMode??`untangle`),U(e.payload.preferences.humor??`none`),K(e.payload.preferences.detailLevel??`balanced`),we(e.payload.preferences.proactivity??`decisions`))}catch(e){j(e instanceof Error?e.message:String(e))}finally{v(!1)}},[]);(0,B.useEffect)(()=>{ze()},[ze]);let $=(0,B.useCallback)(e=>{O(e=>e+1),j(null);let t=d.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 o=await f(m(`/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=o.payload,s(o.payload),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:o.payload})),!0}catch(e){return j(e instanceof Error?e.message:String(e)),!1}}).finally(()=>O(e=>e-1));return d.current=t,t},[]),Be=async e=>{if(a){j(null);try{if(e){let t=await f(m(`/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,s(t.payload)}await f(m(`/api/personal-agent/onboarding/welcome`),{method:`POST`,body:`{}`}),N(!0)}catch(e){j(e instanceof Error?e.message:String(e))}}},Ve=(0,B.useCallback)(async()=>{let e=++Q.current;ke(!0),Ae(null),Me(!1),Ne(!1),Fe(!1),Ie(0);try{let t=await f(m(`/api/personal-agent/activity?limit=${G}&offset=0`));if(e!==Q.current)return;Ae(t.payload),Ie(t.payload.items.length)}catch{e===Q.current&&Me(!0)}},[]),He=(0,B.useCallback)(async()=>{if(!Y||X||Z>=Y.total)return;let e=Q.current;Ne(!0),Fe(!1);try{let t=await f(m(`/api/personal-agent/activity?limit=${G}&offset=${Z}`));if(e!==Q.current)return;Ae(e=>e?{total:t.payload.total,items:[...e.items,...t.payload.items.filter(t=>!e.items.some(e=>e.id===t.id))]}:t.payload),Ie(e=>e+t.payload.items.length)}catch{e===Q.current&&Fe(!0)}finally{e===Q.current&&Ne(!1)}},[Y,Z,X]);(0,B.useEffect)(()=>{if(!Oe||!Y||X)return;let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(async()=>{let e=Q.current;try{let t=await f(m(`/api/personal-agent/activity?limit=${Math.max(G,Math.min(100,Z))}&offset=0`));if(e!==Q.current)return;Ae(t.payload),Ie(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,Oe]);let Ue=async e=>{if(!a||![`image/png`,`image/jpeg`,`image/webp`].includes(e.type)){j(n?`请选择 PNG、JPEG 或 WebP 图片。`:`Choose a PNG, JPEG, or WebP image.`);return}if(e.size===0||e.size>512*1024){j(n?`图片大小不能超过 512 KB。`:`Image must be 512 KB or smaller.`);return}ce(!0),j(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 f(m(`/api/agents/${encodeURIComponent(a.agentId)}/avatar`),{method:`PUT`,body:JSON.stringify({base64:t.slice(t.indexOf(`,`)+1),mimeType:e.type})}),D(a.agentId),se(`custom`),J(!1),await $({appearance:`custom`})}catch(e){j(e instanceof Error?e.message:String(e))}finally{ce(!1)}};(0,B.useLayoutEffect)(()=>{let o=a?.state===`ready`,s=o?a.appearance:I,c=o?a.displayName:`Ada`;return r({startExtra:null,main:(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[o?(0,V.jsx)(`button`,{ref:ue,type:`button`,onClick:Re,"aria-expanded":Te,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?`编辑${c}的资料`:`Edit ${c}'s profile`,title:n?`资料`:`Profile`,children:(0,V.jsx)(`span`,{className:`flex size-8 items-center justify-center`,children:(0,V.jsx)(A,{appearance:s,agentId:a?.agentId,className:`size-8`})})}):(0,V.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center`,children:(0,V.jsx)(A,{appearance:s,agentId:a?.agentId,className:`size-8`})}),(0,V.jsx)(`h1`,{className:`min-w-0 truncate text-sm font-semibold text-fg sm:text-base`,children:c})]}),end:o?(0,V.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,V.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,V.jsx)(ne,{className:`size-5`})}),(0,V.jsxs)(x,{open:Oe,onOpenChange:e=>{e?Ve():ke(!1)},children:[(0,V.jsx)(C,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-pressed":Oe,className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":n?`正在做的事`:`Activity`,children:(0,V.jsx)(L,{className:`size-5`})})}),(0,V.jsx)(y,{children:(0,V.jsxs)(b,{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-inset shadow-xl focus:outline-none`,children:[(0,V.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 px-6 pb-3 pt-6`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-fg`,children:n?`交给我推进的事`:`Delegated work`}),(0,V.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,V.jsx)(S,{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,V.jsx)(u,{className:`size-4`})})]}),(0,V.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 pb-5 pt-3`,children:[!Y&&!je&&(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(T,{className:`h-18 rounded-2xl`}),(0,V.jsx)(T,{className:`h-18 rounded-2xl`}),(0,V.jsx)(T,{className:`h-18 rounded-2xl`})]}),je&&(0,V.jsxs)(`div`,{className:`px-5 py-12 text-center`,children:[(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`暂时无法读取任务`:`Could not load tasks`}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>void Ve(),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,V.jsxs)(`div`,{className:`px-5 py-16 text-center`,children:[(0,V.jsx)(L,{className:`mx-auto size-7 text-fg-subtle`,"aria-hidden":!0}),(0,V.jsx)(`p`,{className:`mt-4 text-sm font-medium text-fg`,children:n?`还没有派发的任务`:`No delegated work yet`}),(0,V.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,V.jsx)(`div`,{className:`space-y-2`,children:Y.items.map(e=>(0,V.jsx)(ye,{item:e,zh:n},e.id))}),Y&&Z<Y.total&&(0,V.jsxs)(`div`,{className:`pt-4 text-center`,children:[(0,V.jsx)(`button`,{type:`button`,onClick:()=>void He(),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`}),Pe&&(0,V.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:n?`加载失败,请重试`:`Could not load more. Try again.`})]})]})]})})]}),(0,V.jsx)(`button`,{ref:z,type:`button`,onClick:Re,"aria-expanded":Te,className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":n?`回应偏好`:`Response preferences`,children:(0,V.jsx)(l,{className:`size-5`})})]}):null}),()=>i()},[Y,je,Z,X,Pe,I,i,He,Ve,a,r,Oe,Te,Re,e.active,n]);function We(){return a?(0,V.jsxs)(x,{open:Te,onOpenChange:e=>{Ee(e),e||J(!1)},children:[(0,V.jsx)(w,{virtualRef:z}),(0,V.jsx)(y,{children:(0,V.jsxs)(b,{side:`bottom`,align:`end`,sideOffset:8,collisionPadding:8,"aria-label":n?`编辑 Personal AI`:`Edit Personal AI`,onInteractOutside:e=>{e.target instanceof Node&&(z.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,V.jsxs)(`div`,{className:`relative flex shrink-0 flex-col items-center px-5 pt-5 text-center`,children:[(0,V.jsx)(`button`,{type:`button`,disabled:R,onClick:()=>J(e=>!e),"aria-expanded":De,"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,V.jsx)(A,{appearance:I,agentId:a.agentId,className:`size-20`})}),(0,V.jsx)(`input`,{id:`personal-name`,"aria-label":n?`助手名称`:`Assistant name`,value:de,onChange:e=>H(e.target.value),onBlur:e=>{let t=e.currentTarget.value.trim();t?(H(t),$({displayName:t})):H(c.current?.displayName??``)},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.currentTarget.value=c.current?.displayName??``,H(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`}),E>0&&(0,V.jsx)(`span`,{className:`absolute right-4 top-4 text-xs text-fg-muted`,children:n?`正在保存…`:`Saving…`})]}),(0,V.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-6 overflow-y-auto overscroll-contain px-5 py-5`,children:[k&&(0,V.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:k}),De&&(0,V.jsxs)(`section`,{id:`personal-appearance-options`,children:[(0,V.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`形象`:`Appearance`}),(0,V.jsxs)(`div`,{className:`grid grid-cols-4 gap-2`,children:[be.map(e=>(0,V.jsxs)(`button`,{type:`button`,onClick:()=>{se(e.id),J(!1),$({appearance:e.id})},"aria-pressed":I===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 ${I===e.id?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,V.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full ${e.color}`,children:(0,V.jsx)(A,{appearance:e.id,className:`size-8`})}),(0,V.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:n?e.zh:e.en})]},e.id)),(0,V.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&&Ue(t),e.currentTarget.value=``}}),(0,V.jsxs)(`button`,{type:`button`,disabled:R,onClick:()=>le.current?.click(),"aria-pressed":I===`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 ${I===`custom`?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,V.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full bg-surface-panel`,children:I===`custom`?(0,V.jsx)(A,{appearance:`custom`,agentId:a.agentId,className:`size-8`}):(0,V.jsx)(re,{className:`size-4 text-fg-muted`,"aria-hidden":!0})}),(0,V.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:R?n?`上传中…`:`Uploading…`:n?`上传`:`Upload`})]})]})]}),(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`语气`:`Tone`}),(0,V.jsx)(`div`,{className:`grid grid-cols-3 gap-2`,children:q.map(e=>(0,V.jsx)(`button`,{type:`button`,onClick:()=>{oe(e.id),$({preferences:{warmth:e.warmth}})},"aria-pressed":ie===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 ${ie===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,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`棘手时`:`When things get tricky`}),(0,V.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[[`listen`,n?`先听`:`Listen`],[`untangle`,n?`理清`:`Untangle`],[`solutions`,n?`给办法`:`Suggest`]].map(([e,t])=>(0,V.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,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`mb-2 text-sm font-medium text-fg`,children:n?`回答长度`:`Length`}),(0,V.jsx)(o,{value:ve??`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;K(t),$({preferences:{detailLevel:t}})}})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`mb-2 text-sm font-medium text-fg`,children:n?`主动更新`:`Updates`}),(0,V.jsx)(o,{value:Ce??`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;we(t),$({preferences:{proactivity:t}})}})]})]}),(0,V.jsxs)(`details`,{className:`text-sm text-fg-muted`,children:[(0,V.jsx)(`summary`,{className:`cursor-pointer select-none`,children:n?`更多偏好`:`More preferences`}),(0,V.jsxs)(`div`,{className:`mt-3`,children:[(0,V.jsx)(`p`,{className:`mb-2 font-medium text-fg`,children:n?`轻松程度`:`Humor`}),(0,V.jsx)(o,{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;U(t),$({preferences:{humor:t}})}})]})]}),(0,V.jsx)(fe,{zh:n}),(0,V.jsx)(_e,{onGreetingChange:e=>$({voiceCallPreferences:{openingGreetingEnabled:e}}),record:a,zh:n,onSelectVoice:e=>$({voicePreference:e})}),(0,V.jsx)(`div`,{className:`border-t border-edge pt-5`,children:(0,V.jsx)(W,{conversationId:a.conversationId,zh:n,onSaved:async()=>{let e=await f(m(`/api/personal-agent`));e.ok&&e.payload&&(c.current=e.payload,s(e.payload))}})})]})]})})]}):null}return _?(0,V.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl space-y-5 px-6 py-12`,children:[(0,V.jsx)(T,{className:`h-20 w-20 rounded-full`}),(0,V.jsx)(T,{className:`h-9 w-72`}),(0,V.jsx)(T,{className:`h-44 w-full rounded-2xl`})]}):a?.state===`ready`?(0,V.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col bg-surface-panel`,children:[P&&(0,V.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,V.jsx)(`span`,{children:n?`助手已创建,头像上传未完成。可在资料设置中重新上传。`:`Your assistant is ready. Upload the avatar again in profile settings.`}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>{F(!1),Le()},className:`shrink-0 text-accent hover:underline`,children:n?`打开设置`:`Open settings`})]}),(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,V.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,V.jsx)(ae,{embedded:!0,personal:!0,personalWelcome:{name:a.displayName,addressAs:a.userCallName??void 0,avatar:(0,V.jsx)(A,{appearance:a.appearance,agentId:a.agentId,className:`size-14`}),opening:xe(a.preferences,n),showSupportChoice:!M,onChooseSupport:e=>void Be(e),onSkipSupport:()=>void Be(),supportChoiceError:k},conversationId:a.conversationId})})}),We()]}):(0,V.jsx)(ge,{modelsAvailable:h.length>0,onCreated:(e,t)=>{c.current=e,s(e),H(e.displayName),N(!1),F(t),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:e})),window.dispatchEvent(new Event(`session-updated`))}})}export{Ce 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-BMYIfy9x.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./popover-select-BgSdSbCL.js";import{x as s}from"./markdown-view-2rwSrMXW.js";import{t as c}from"./play-kxZvpBg8.js";import{t as l}from"./settings-2-D-csvaET.js";import{t as u}from"./x-B_N4OPjy.js";import{t as d}from"./messages-Cn25s55n.js";import{a as f,n as p,r as m}from"./locale-store-DSsLH7JO.js";import{C as h,t as g,tt as _,u as v}from"./session-manager-BWLIDok4.js";import{a as y,i as b,o as x,r as S,s as C,t as w}from"./dist-C3DSFZCi.js";import{t as T}from"./skeleton-BwbyijEw.js";import{t as E}from"./date-formatters-CUZAyDEg.js";import{$i as D,Bc as O,Do as k,Ji as A,Jr as j,K as M,Q as N,Rc as P,Sa as F,da as ee,ea as te,es as ne,fo as re,ha as ie,n as ae,q as oe,wa as I,xs as L,zc as se}from"./index-DU5FmDQh.js";import{l as R,n as ce,t as le}from"./voice-config-api-BtWFziQc.js";var z=n(),B=e(t(),1),V=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,B.useState)(),[r,i]=(0,B.useState)(``),[a,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(``),u=c.trim().toLowerCase().replaceAll(`_`,` `),d=[...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,B.useEffect)(()=>{let e=!0;return f(m(`/api/personal-agent/proactivity`)).then(t=>{e&&t.ok&&n(_.parse(t.payload))}).catch(t=>{e&&i(String(t))}),()=>{e=!1}},[]);async function p(e){if(!(!t||a)){s(!0),i(``);try{let r=await f(m(`/api/personal-agent/proactivity`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t,...e})});r.ok&&n(_.parse(r.payload))}catch(e){i(String(e));let t=await f(m(`/api/personal-agent/proactivity`)).catch(()=>null);t?.ok&&n(_.parse(t.payload))}finally{s(!1)}}}return(0,V.jsxs)(`section`,{className:`space-y-3 border-t border-edge pt-5`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:e?`主动联系`:`Proactive messages`}),!t&&!r?(0,V.jsx)(T,{className:`h-9 w-full`}):t&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(o,{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,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[e?`静默开始`:`Quiet from`,(0,V.jsx)(o,{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,V.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[e?`静默结束`:`Quiet until`,(0,V.jsx)(o,{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,V.jsxs)(`label`,{className:`block text-xs text-fg-muted`,children:[e?`时区`:`Timezone`,(0,V.jsx)(o,{placeholder:e?`选择时区`:`Choose timezone`,ariaLabel:e?`时区`:`Timezone`,value:t.timezone,selectedLabel:t.timezone.replaceAll(`_`,` `),options:d,disabled:a,allowEmpty:!1,triggerClassName:`mt-1`,searchPlaceholder:e?`搜索时区或城市`:`Search timezone or city`,searchValue:c,onSearchChange:l,statusMessage:d.length?void 0:e?`没有匹配的时区`:`No matching timezones`,onChange:e=>{l(``),e!==t.timezone&&p({timezone:e})}})]}),(0,V.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e?`有值得交流的进展时,在聊天里留下消息。明确请求的结果会照常交付。`:`Useful developments appear in this chat. Requested results are delivered as usual.`})]}),r&&(0,V.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r})]})}var H=[`intro`,`identity`,`voice`,`connections`],pe=[{id:`loopi`,zh:`小环`,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 f(m(`/api/agents/${encodeURIComponent(e)}/avatar`),{method:`PUT`,body:JSON.stringify({base64:n.slice(n.indexOf(`,`)+1),mimeType:t.type})}),D(e)}function ge({modelsAvailable:e,onCreated:t}){let n=p(e=>e.language)===`zh`,r=p(e=>e.language),[o,s]=(0,B.useState)(`intro`),[l,u]=(0,B.useState)({displayName:`Ada`,appearance:`loopi`,voice:null}),[h,g]=(0,B.useState)(!1),[_,v]=(0,B.useState)(!1),[y,b]=(0,B.useState)(null),[x,S]=(0,B.useState)(null),[C,w]=(0,B.useState)(null),[E,D]=(0,B.useState)(null),[k,j]=(0,B.useState)(!0),[P,ee]=(0,B.useState)([]),[te,ne]=(0,B.useState)(null),ae=(0,B.useRef)(null),L=(0,B.useRef)(null),[z,ue]=(0,B.useState)([]),[de,fe]=(0,B.useState)(!0),[ge,_e]=(0,B.useState)([]),[U,W]=(0,B.useState)(null);(0,B.useEffect)(()=>{let e=!1;return f(m(`/api/personal-agent/onboarding`)).then(t=>{e||(s(t.payload.step),u(t.payload.draft))}).catch(t=>{e||b(t instanceof Error?t.message:String(t))}).finally(()=>{e||g(!0)}),()=>{e=!0}},[]),(0,B.useEffect)(()=>{if(!h)return;let e=window.setTimeout(()=>{f(m(`/api/personal-agent/onboarding`),{method:`PUT`,body:JSON.stringify({step:o,draft:l})}).catch(()=>{})},350);return()=>window.clearTimeout(e)},[l,h,o]),(0,B.useEffect)(()=>{let e=!1;return le().then(t=>{e||(t.tts&&t.enabled?D({provider:t.tts.provider,model:t.tts.model,enabled:!0}):j(!1))}).catch(()=>{e||j(!1)}),()=>{e=!0}},[]),(0,B.useEffect)(()=>{if(!E?.enabled)return;let e=!1;return ce(E.provider,E.model,`realtime`).then(t=>{e||ee(t.slice(0,12))}).catch(()=>{}).finally(()=>{e||j(!1)}),()=>{e=!0}},[E]),(0,B.useEffect)(()=>{if(o!==`connections`)return;let e=!1;return fe(!0),Promise.allSettled([F({page:1,pageSize:24,verification:`verified`}),I()]).then(([t,n])=>{if(!e){if(t.status===`fulfilled`){let e=[`gmail`,`googlecalendar`,`googledrive`,`github`,`linear`];ue(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`&&_e(n.value),fe(!1)}}),()=>{e=!0}},[o]),(0,B.useEffect)(()=>()=>{L.current?.abort(),ae.current?.close()},[]),(0,B.useEffect)(()=>()=>{C&&URL.revokeObjectURL(C)},[C]);let G=async(e,t=l)=>{await f(m(`/api/personal-agent/onboarding`),{method:`PUT`,body:JSON.stringify({step:e,draft:t})}),s(e)},ve=async e=>{b(null);let t=H[Math.max(0,Math.min(H.length-1,H.indexOf(o)+e))];try{await G(t)}catch(e){b(e instanceof Error?e.message:String(e))}},K=async(n=!1)=>{if(!(!e||_)){v(!0),b(null);try{let e=n?{displayName:`Ada`,appearance:`loopi`,voice:null}:l,r=e.voice&&E?.enabled&&P.some(t=>t.id===e.voice)?{provider:E.provider,model:E.model,voice:e.voice}:void 0,i=(await f(m(`/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 f(m(`/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)}}},ye=(0,B.useCallback)(async e=>{L.current?.abort(),ae.current?.close();let t=new AbortController;L.current=t,ne(e),b(null);try{let n=new ie;ae.current=n,await n.start();let r=await R(t.signal,e);if(t.signal.aborted)return;n.enqueue(r,()=>ne(null))}catch(e){t.signal.aborted||b(e instanceof Error?e.message:String(e)),ne(null)}},[]);if(!h)return(0,V.jsxs)(`div`,{className:`mx-auto w-full max-w-xl space-y-4 px-6 py-14`,children:[(0,V.jsx)(T,{className:`h-10 w-2/3`}),(0,V.jsx)(T,{className:`h-64 w-full rounded-2xl`}),(0,V.jsx)(T,{className:`h-12 w-full rounded-xl`})]});let q=H.indexOf(o),be={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,V.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-surface-base`,children:[(0,V.jsx)(`header`,{className:`shrink-0 px-5 pt-5 sm:px-8 sm:pt-7`,children:(0,V.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl`,children:[(0,V.jsxs)(`div`,{className:`flex min-h-10 items-center justify-between gap-4`,children:[q>0?(0,V.jsxs)(`button`,{type:`button`,disabled:_,onClick:()=>void ve(-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,V.jsx)(O,{className:`size-4`}),n?`上一步`:`Back`]}):(0,V.jsx)(`span`,{className:`text-sm font-medium text-fg-muted`,children:n?`设置我的助手`:`Set up my assistant`}),(0,V.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,V.jsx)(`div`,{className:`mt-4 grid grid-cols-4 gap-1.5`,role:`progressbar`,"aria-label":n?`设置进度`:`Setup progress`,"aria-valuenow":q+1,"aria-valuemin":1,"aria-valuemax":H.length,children:H.map((e,t)=>(0,V.jsx)(`span`,{className:`h-1 rounded-full transition-colors duration-200 ${t<=q?`bg-accent`:`bg-surface-active`}`},e))})]})}),(0,V.jsx)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-8 sm:px-8`,children:(0,V.jsxs)(`div`,{className:`mx-auto my-auto w-full max-w-2xl py-6 motion-safe:animate-[page-enter_220ms_ease-out]`,children:[(0,V.jsxs)(`div`,{className:`mb-8 flex items-center gap-4`,children:[(0,V.jsx)(`span`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl bg-surface-hover`,children:C?(0,V.jsx)(`img`,{src:C,alt:``,className:`size-14 rounded-xl object-cover`}):(0,V.jsx)(A,{appearance:l.appearance,className:`size-14`})}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`我的助手`:`My assistant`}),(0,V.jsx)(`p`,{className:`mt-1 text-lg font-semibold text-fg`,children:l.displayName||`Ada`})]})]}),(0,V.jsx)(`p`,{className:`mb-3 text-xs font-medium tracking-wide text-fg-subtle`,children:n?`第 ${q+1} 步 · 共 ${H.length} 步`:`Step ${q+1} of ${H.length}`}),(0,V.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-fg sm:text-3xl`,children:be}),o===`intro`&&(0,V.jsxs)(`div`,{className:`mt-6 max-w-xl space-y-3 text-base leading-8 text-fg-muted`,children:[(0,V.jsx)(`p`,{children:n?`你可以找它讨论问题,也可以交给它一件要推进的事。`:`Talk through a question or give it something to move forward.`}),(0,V.jsx)(`p`,{children:n?`需要深入处理时,它会找合适的 Agent,并把进展带回对话。`:`It can ask a suitable Agent for deeper work and bring the progress back.`}),(0,V.jsx)(`p`,{children:n?`它能使用哪些数据和设备,由你决定。`:`You choose which data and devices it can use.`})]}),o===`identity`&&(0,V.jsxs)(`div`,{className:`mt-7 space-y-7`,children:[(0,V.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[n?`助手名字`:`Assistant name`,(0,V.jsx)(`input`,{value:l.displayName,maxLength:60,onChange:e=>u(t=>({...t,displayName:e.target.value})),onBlur:()=>u(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,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`选择头像`:`Choose an avatar`}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[pe.map(e=>(0,V.jsxs)(`button`,{type:`button`,"aria-pressed":!x&&l.appearance===e.id,onClick:()=>{S(null),w(null),u(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&&l.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,V.jsx)(A,{appearance:e.id,className:`size-14`}),n?e.zh:e.en]},e.id)),(0,V.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,V.jsx)(re,{className:`size-6`}),n?`上传图片`:`Upload image`,(0,V.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),w(URL.createObjectURL(t))}}})]})]}),(0,V.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,V.jsxs)(`div`,{className:`mt-5`,children:[(0,V.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.`}),k?(0,V.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[(0,V.jsx)(T,{className:`h-20 rounded-xl`}),(0,V.jsx)(T,{className:`h-20 rounded-xl`})]}):E?.enabled&&P.length>0?(0,V.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[(0,V.jsx)(`button`,{type:`button`,"aria-pressed":!l.voice,onClick:()=>u(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 ${l.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`}),P.map(e=>(0,V.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl p-3 transition-colors ${l.voice===e.id?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,V.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":l.voice===e.id,onClick:()=>u(t=>({...t,voice:e.id})),children:[(0,V.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.name}),(0,V.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e.description||e.style||(n?`点击选择`:`Select this voice`)})]}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>void ye(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,V.jsx)(c,{className:`size-4 ${te===e.id?`text-accent`:``}`})})]},e.id))]}):(0,V.jsxs)(`div`,{className:`mt-5 rounded-xl bg-surface-panel p-5 text-sm text-fg-muted`,children:[(0,V.jsx)(`p`,{children:n?`当前没有可试听的语音。你可以先用文字对话,稍后再设置。`:`No voice is ready to preview. You can start with text and set it up later.`}),(0,V.jsx)(i,{to:`/settings/capabilities/voice?returnTo=%2Fpersonal`,className:`mt-3 inline-block text-accent hover:underline`,children:n?`设置语音服务`:`Set up voice`})]})]}),o===`connections`&&(0,V.jsxs)(`div`,{className:`mt-5`,children:[(0,V.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.`}),de?(0,V.jsxs)(`div`,{className:`mt-5 space-y-2`,children:[(0,V.jsx)(T,{className:`h-18 rounded-xl`}),(0,V.jsx)(T,{className:`h-18 rounded-xl`})]}):(0,V.jsx)(`div`,{className:`mt-5 space-y-2`,children:z.length?z.map(e=>{let t=me(ge.find(t=>t.connectorId===e.id));return(0,V.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl bg-surface-panel p-4`,children:[(0,V.jsx)(N,{connector:e,size:`sm`}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.displayName}),(0,V.jsx)(`p`,{className:`line-clamp-2 text-xs text-fg-muted`,children:e.description})]}),t?(0,V.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-success`,children:[(0,V.jsx)(a,{className:`size-4`}),n?`已连接`:`Connected`]}):(0,V.jsx)(`button`,{type:`button`,onClick:()=>W(M(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,V.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,V.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,V.jsx)(i,{to:`/settings/capabilities/models`,className:`text-accent underline`,children:n?`配置模型`:`Set up a model`})]}),y&&(0,V.jsx)(`p`,{role:`alert`,className:`mt-5 text-sm text-danger`,children:y})]},o)}),(0,V.jsx)(`footer`,{className:`shrink-0 px-5 pb-6 pt-3 sm:px-8 sm:pb-9`,children:(0,V.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,V.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n?`这些选择以后都能调整`:`You can change these choices later`}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[o===`intro`&&(0,V.jsx)(`button`,{type:`button`,disabled:!e||_,onClick:()=>void K(!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,V.jsx)(`button`,{type:`button`,onClick:()=>{let e={...l,voice:null};u(e),b(null),G(`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,V.jsxs)(`button`,{type:`button`,disabled:_||o===`connections`&&!e,onClick:()=>o===`connections`?void K():void ve(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,V.jsx)(se,{className:`size-4`})]})]})]})}),U&&(0,V.jsx)(oe,{draft:U,onChange:W,onClose:()=>W(null),t:d(r).connectorsSettings,onInstalled:async()=>{_e(await I()),W(null)}})]})}function _e({record:e,zh:t,onSelectVoice:n,onGreetingChange:r}){let[a,s]=(0,B.useState)(!1),[l,u]=(0,B.useState)(!0),[d,f]=(0,B.useState)(``),[p,m]=(0,B.useState)(null),[h,g]=(0,B.useState)([]),[_,v]=(0,B.useState)(e.voicePreference?.voice??``),[y,b]=(0,B.useState)(!1),[x,S]=(0,B.useState)(null),[C,w]=(0,B.useState)(null),E=(0,B.useRef)(null),D=(0,B.useRef)(null);(0,B.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await le();if(e||(s(t.openingGreeting===!0),!t.enabled||!t.tts))return;let n={provider:t.tts.provider,model:t.tts.model};m(n);let r=await ce(n.provider,n.model,`realtime`);e||g(r)}catch(t){e||S(t instanceof Error?t.message:String(t))}finally{e||u(!1)}})(),()=>{e=!0}},[]),(0,B.useEffect)(()=>()=>{D.current?.abort(),E.current?.close()},[]);let O=()=>{D.current?.abort(),D.current=null,E.current?.close(),E.current=null,w(null)},A=async e=>{if(C!==null){O();return}O(),S(null);let t=new AbortController;D.current=t,w(e);try{let n=new ie;E.current=n,await n.start();let r=await R(t.signal,e);t.signal.aborted||n.enqueue(r,()=>{D.current===t&&(w(null),D.current=null,E.current=null,n.close())})}catch(e){t.signal.aborted||S(e instanceof Error?e.message:String(e)),D.current===t&&O()}},j=async e=>{if(y||e===_)return;O();let t=_;v(e),f(``),b(!0),S(null);try{await n(e&&p?{provider:p.provider,model:p.model,voice:e}:null)||v(t)}catch(e){v(t),S(e instanceof Error?e.message:String(e))}finally{b(!1)}},M=h.find(e=>e.id===_),N=t?`默认声音`:`Default voice`,P=M?.name||(_?t?`当前音色不可用`:`Current voice unavailable`:N),F=d.trim().toLocaleLowerCase(),ee=h.filter(e=>!F||`${e.name} ${e.description??``} ${e.style??``}`.toLocaleLowerCase().includes(F)).map(e=>({value:e.id,label:e.name}));return(0,V.jsxs)(`section`,{className:`border-t border-edge pt-5`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:t?`通话声音`:`Call voice`}),l?(0,V.jsx)(`div`,{className:`mt-3`,"aria-busy":`true`,children:(0,V.jsx)(T,{className:`h-10 w-full`})}):p&&h.length?(0,V.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,V.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,V.jsx)(o,{value:_,selectedLabel:P,options:ee,placeholder:N,emptyLabel:N,ariaLabel:t?`选择通话音色`:`Choose call voice`,disabled:y,onChange:e=>void j(e),searchPlaceholder:h.length>8?t?`搜索音色`:`Search voices`:void 0,searchValue:d,onSearchChange:f,statusMessage:F&&!ee.length?t?`没有匹配的音色`:`No matching voices`:void 0})}),(0,V.jsxs)(`button`,{type:`button`,disabled:y||!!(_&&!M),onClick:()=>void A(_),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:C===null?t?`试听${P}`:`Preview ${P}`:t?`停止试听`:`Stop preview`,"aria-label":C===null?t?`试听${P}`:`Preview ${P}`:t?`停止试听`:`Stop preview`,children:[C===null?(0,V.jsx)(c,{className:`size-4`,"aria-hidden":!0}):(0,V.jsx)(k,{className:`size-4 text-accent`,"aria-hidden":!0}),C===null?t?`试听`:`Preview`:t?`停止`:`Stop`]})]}),(0,V.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:M?.description||M?.style||(_?t?`选择后自动保存,用于之后的语音通话。`:`Saved automatically for future voice calls.`:t?`跟随语音服务的默认音色。`:`Uses the voice service’s default voice.`)})]}):(0,V.jsxs)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:[t?`当前没有可用音色。`:`No voice is ready.`,` `,(0,V.jsx)(i,{to:`/settings/capabilities/voice?returnTo=%2Fpersonal`,className:`text-accent underline`,children:t?`设置语音服务`:`Set up voice`})]}),r&&a&&(0,V.jsxs)(`label`,{className:`mt-4 flex items-center justify-between gap-3 text-sm text-fg`,children:[t?`连接时打招呼`:`Greet me when connected`,(0,V.jsx)(`input`,{type:`checkbox`,checked:e.voiceCallPreferences?.openingGreetingEnabled??!0,disabled:y,onChange:e=>{let t=e.target.checked;b(!0),r(t).catch(e=>S(String(e))).finally(()=>b(!1))}})]}),x&&(0,V.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:x})]})}var U=new g;function W({conversationId:e,zh:t,onSaved:n}){let r=h(t=>t.sessions[e]),[i,a]=(0,B.useState)(!0),[o,s]=(0,B.useState)(``);(0,B.useEffect)(()=>{let t=!0;return U.loadSessionAgentConfig(e).then(n=>{t&&v(e,n)}).catch(e=>{t&&s(String(e))}).finally(()=>{t&&a(!1)}),()=>{t=!1}},[e]);let c=!!(r?.sending||r?.streaming||r?.modelConfigSaving);async function l(t,i){h.getState().patchSessionMeta(e,{modelConfigSaving:!0});try{v(e,await U.patchSessionAgentConfig(e,{model:t,thinkingLevel:i,configVersion:r?.configVersion})),await n()}catch(t){let n=await U.loadSessionAgentConfig(e).catch(()=>null);throw n&&v(e,n),t}finally{h.getState().patchSessionMeta(e,{modelConfigSaving:!1})}}return(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:t?`对话模型与思考强度`:`Conversation model and thinking`}),i?(0,V.jsx)(T,{className:`h-9 w-full`}):(0,V.jsx)(j,{chat:d(t?`zh`:`en`).chat,sessionModel:r?.model??``,thinkingLevel:r?.thinkingLevel??`off`,modelDisabled:c,thinkingDisabled:c,onModelChange:l,onThinkingChange:e=>l(r?.model??``,e)}),o&&(0,V.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:o})]})}var G=5;function ve(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 K(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 ye(e){let t=(0,z.c)(30),{item:n,zh:r}=e,a;t[0]!==n||t[1]!==r?(a=K(n,r),t[0]=n,t[1]=r,t[2]=a):a=t[2];let o=a,c;t[3]===n.id?c=t[4]:(c=s(`/personal`,n.id),t[3]=n.id,t[4]=c);let l=`mt-2 size-1.5 shrink-0 rounded-full ${o.tone}`,u;t[5]===l?u=t[6]:(u=(0,V.jsx)(`span`,{className:l,"aria-hidden":!0}),t[5]=l,t[6]=u);let d;t[7]===n.title?d=t[8]:(d=ve(n.title),t[7]=n.title,t[8]=d);let f;t[9]===d?f=t[10]:(f=(0,V.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]===o.label?p=t[12]:(p=(0,V.jsx)(`span`,{children:o.label}),t[11]=o.label,t[12]=p);let m;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,V.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=E(n.updatedAt,h),t[14]=n.updatedAt,t[15]=h,t[16]=g):g=t[16];let _;t[17]===g?_=t[18]:(_=(0,V.jsx)(`span`,{children:g}),t[17]=g,t[18]=_);let v;t[19]!==_||t[20]!==p?(v=(0,V.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,V.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,V.jsx)(P,{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,V.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 q=[{id:`direct`,warmth:`reserved`,zh:`直接`,en:`Direct`},{id:`natural`,warmth:`balanced`,zh:`自然`,en:`Natural`},{id:`gentle`,warmth:`gentle`,zh:`温和`,en:`Gentle`}],be=[{id:`loopi`,zh:`小环`,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 xe(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 Se(e){return q.find(t=>t.warmth===e.warmth)?.id??`natural`}function Ce(){let e=ee(),t=(0,B.useRef)(e);t.current=e;let n=p(e=>e.language)===`zh`,r=te(e=>e.setPageHeader),i=te(e=>e.clearPageHeader),[a,s]=(0,B.useState)(null),c=(0,B.useRef)(null),d=(0,B.useRef)(Promise.resolve()),[h,g]=(0,B.useState)([]),[_,v]=(0,B.useState)(!0),[E,O]=(0,B.useState)(0),[k,j]=(0,B.useState)(null),[M,N]=(0,B.useState)(!0),[P,F]=(0,B.useState)(!1),[ie,oe]=(0,B.useState)(`natural`),[I,se]=(0,B.useState)(`loopi`),[R,ce]=(0,B.useState)(!1),le=(0,B.useRef)(null),z=(0,B.useRef)(null),ue=(0,B.useRef)(null),[de,H]=(0,B.useState)(``),[pe,me]=(0,B.useState)(`untangle`),[he,U]=(0,B.useState)(`none`),[ve,K]=(0,B.useState)(`balanced`),[Ce,we]=(0,B.useState)(`decisions`),[Te,Ee]=(0,B.useState)(!1),[De,J]=(0,B.useState)(!1),[Oe,ke]=(0,B.useState)(!1),[Y,Ae]=(0,B.useState)(null),[je,Me]=(0,B.useState)(!1),[X,Ne]=(0,B.useState)(!1),[Pe,Fe]=(0,B.useState)(!1),[Z,Ie]=(0,B.useState)(0),Q=(0,B.useRef)(0),Le=(0,B.useCallback)(()=>{ke(!1),J(!1),Ee(!0)},[]),Re=(0,B.useCallback)(()=>{ke(!1),J(!1),Ee(e=>!e)},[]),ze=(0,B.useCallback)(async()=>{try{let[e,t]=await Promise.all([f(m(`/api/personal-agent`)),f(m(`/api/personal-agent/models`))]);if(c.current=e.payload,s(e.payload),e.payload?.state===`ready`){let e=await f(m(`/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`)),g(t.payload),e.payload&&(H(e.payload.displayName),se(e.payload.appearance),oe(Se(e.payload.preferences)),me(e.payload.preferences.supportMode??`untangle`),U(e.payload.preferences.humor??`none`),K(e.payload.preferences.detailLevel??`balanced`),we(e.payload.preferences.proactivity??`decisions`))}catch(e){j(e instanceof Error?e.message:String(e))}finally{v(!1)}},[]);(0,B.useEffect)(()=>{ze()},[ze]);let $=(0,B.useCallback)(e=>{O(e=>e+1),j(null);let t=d.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 o=await f(m(`/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=o.payload,s(o.payload),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:o.payload})),!0}catch(e){return j(e instanceof Error?e.message:String(e)),!1}}).finally(()=>O(e=>e-1));return d.current=t,t},[]),Be=async e=>{if(a){j(null);try{if(e){let t=await f(m(`/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,s(t.payload)}await f(m(`/api/personal-agent/onboarding/welcome`),{method:`POST`,body:`{}`}),N(!0)}catch(e){j(e instanceof Error?e.message:String(e))}}},Ve=(0,B.useCallback)(async()=>{let e=++Q.current;ke(!0),Ae(null),Me(!1),Ne(!1),Fe(!1),Ie(0);try{let t=await f(m(`/api/personal-agent/activity?limit=${G}&offset=0`));if(e!==Q.current)return;Ae(t.payload),Ie(t.payload.items.length)}catch{e===Q.current&&Me(!0)}},[]),He=(0,B.useCallback)(async()=>{if(!Y||X||Z>=Y.total)return;let e=Q.current;Ne(!0),Fe(!1);try{let t=await f(m(`/api/personal-agent/activity?limit=${G}&offset=${Z}`));if(e!==Q.current)return;Ae(e=>e?{total:t.payload.total,items:[...e.items,...t.payload.items.filter(t=>!e.items.some(e=>e.id===t.id))]}:t.payload),Ie(e=>e+t.payload.items.length)}catch{e===Q.current&&Fe(!0)}finally{e===Q.current&&Ne(!1)}},[Y,Z,X]);(0,B.useEffect)(()=>{if(!Oe||!Y||X)return;let e,t=()=>{window.clearTimeout(e),e=window.setTimeout(async()=>{let e=Q.current;try{let t=await f(m(`/api/personal-agent/activity?limit=${Math.max(G,Math.min(100,Z))}&offset=0`));if(e!==Q.current)return;Ae(t.payload),Ie(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,Oe]);let Ue=async e=>{if(!a||![`image/png`,`image/jpeg`,`image/webp`].includes(e.type)){j(n?`请选择 PNG、JPEG 或 WebP 图片。`:`Choose a PNG, JPEG, or WebP image.`);return}if(e.size===0||e.size>512*1024){j(n?`图片大小不能超过 512 KB。`:`Image must be 512 KB or smaller.`);return}ce(!0),j(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 f(m(`/api/agents/${encodeURIComponent(a.agentId)}/avatar`),{method:`PUT`,body:JSON.stringify({base64:t.slice(t.indexOf(`,`)+1),mimeType:e.type})}),D(a.agentId),se(`custom`),J(!1),await $({appearance:`custom`})}catch(e){j(e instanceof Error?e.message:String(e))}finally{ce(!1)}};(0,B.useLayoutEffect)(()=>{let o=a?.state===`ready`,s=o?a.appearance:I,c=o?a.displayName:`Ada`;return r({startExtra:null,main:(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[o?(0,V.jsx)(`button`,{ref:ue,type:`button`,onClick:Re,"aria-expanded":Te,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?`编辑${c}的资料`:`Edit ${c}'s profile`,title:n?`资料`:`Profile`,children:(0,V.jsx)(`span`,{className:`flex size-8 items-center justify-center`,children:(0,V.jsx)(A,{appearance:s,agentId:a?.agentId,className:`size-8`})})}):(0,V.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center`,children:(0,V.jsx)(A,{appearance:s,agentId:a?.agentId,className:`size-8`})}),(0,V.jsx)(`h1`,{className:`min-w-0 truncate text-sm font-semibold text-fg sm:text-base`,children:c})]}),end:o?(0,V.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,V.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,V.jsx)(ne,{className:`size-5`})}),(0,V.jsxs)(x,{open:Oe,onOpenChange:e=>{e?Ve():ke(!1)},children:[(0,V.jsx)(C,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"aria-pressed":Oe,className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":n?`正在做的事`:`Activity`,children:(0,V.jsx)(L,{className:`size-5`})})}),(0,V.jsx)(y,{children:(0,V.jsxs)(b,{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-inset shadow-xl focus:outline-none`,children:[(0,V.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 px-6 pb-3 pt-6`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-fg`,children:n?`交给我推进的事`:`Delegated work`}),(0,V.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,V.jsx)(S,{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,V.jsx)(u,{className:`size-4`})})]}),(0,V.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 pb-5 pt-3`,children:[!Y&&!je&&(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(T,{className:`h-18 rounded-2xl`}),(0,V.jsx)(T,{className:`h-18 rounded-2xl`}),(0,V.jsx)(T,{className:`h-18 rounded-2xl`})]}),je&&(0,V.jsxs)(`div`,{className:`px-5 py-12 text-center`,children:[(0,V.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`暂时无法读取任务`:`Could not load tasks`}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>void Ve(),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,V.jsxs)(`div`,{className:`px-5 py-16 text-center`,children:[(0,V.jsx)(L,{className:`mx-auto size-7 text-fg-subtle`,"aria-hidden":!0}),(0,V.jsx)(`p`,{className:`mt-4 text-sm font-medium text-fg`,children:n?`还没有派发的任务`:`No delegated work yet`}),(0,V.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,V.jsx)(`div`,{className:`space-y-2`,children:Y.items.map(e=>(0,V.jsx)(ye,{item:e,zh:n},e.id))}),Y&&Z<Y.total&&(0,V.jsxs)(`div`,{className:`pt-4 text-center`,children:[(0,V.jsx)(`button`,{type:`button`,onClick:()=>void He(),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`}),Pe&&(0,V.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:n?`加载失败,请重试`:`Could not load more. Try again.`})]})]})]})})]}),(0,V.jsx)(`button`,{ref:z,type:`button`,onClick:Re,"aria-expanded":Te,className:`touch-target rounded-lg p-2 text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":n?`回应偏好`:`Response preferences`,children:(0,V.jsx)(l,{className:`size-5`})})]}):null}),()=>i()},[Y,je,Z,X,Pe,I,i,He,Ve,a,r,Oe,Te,Re,e.active,n]);function We(){return a?(0,V.jsxs)(x,{open:Te,onOpenChange:e=>{Ee(e),e||J(!1)},children:[(0,V.jsx)(w,{virtualRef:z}),(0,V.jsx)(y,{children:(0,V.jsxs)(b,{side:`bottom`,align:`end`,sideOffset:8,collisionPadding:8,"aria-label":n?`编辑 Personal AI`:`Edit Personal AI`,onInteractOutside:e=>{e.target instanceof Node&&(z.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,V.jsxs)(`div`,{className:`relative flex shrink-0 flex-col items-center px-5 pt-5 text-center`,children:[(0,V.jsx)(`button`,{type:`button`,disabled:R,onClick:()=>J(e=>!e),"aria-expanded":De,"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,V.jsx)(A,{appearance:I,agentId:a.agentId,className:`size-20`})}),(0,V.jsx)(`input`,{id:`personal-name`,"aria-label":n?`助手名称`:`Assistant name`,value:de,onChange:e=>H(e.target.value),onBlur:e=>{let t=e.currentTarget.value.trim();t?(H(t),$({displayName:t})):H(c.current?.displayName??``)},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.currentTarget.value=c.current?.displayName??``,H(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`}),E>0&&(0,V.jsx)(`span`,{className:`absolute right-4 top-4 text-xs text-fg-muted`,children:n?`正在保存…`:`Saving…`})]}),(0,V.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-6 overflow-y-auto overscroll-contain px-5 py-5`,children:[k&&(0,V.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:k}),De&&(0,V.jsxs)(`section`,{id:`personal-appearance-options`,children:[(0,V.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`形象`:`Appearance`}),(0,V.jsxs)(`div`,{className:`grid grid-cols-4 gap-2`,children:[be.map(e=>(0,V.jsxs)(`button`,{type:`button`,onClick:()=>{se(e.id),J(!1),$({appearance:e.id})},"aria-pressed":I===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 ${I===e.id?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,V.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full ${e.color}`,children:(0,V.jsx)(A,{appearance:e.id,className:`size-8`})}),(0,V.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:n?e.zh:e.en})]},e.id)),(0,V.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&&Ue(t),e.currentTarget.value=``}}),(0,V.jsxs)(`button`,{type:`button`,disabled:R,onClick:()=>le.current?.click(),"aria-pressed":I===`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 ${I===`custom`?`bg-accent/10 ring-1 ring-accent/40`:`bg-surface-panel hover:bg-surface-hover`}`,children:[(0,V.jsx)(`span`,{className:`flex size-8 items-center justify-center rounded-full bg-surface-panel`,children:I===`custom`?(0,V.jsx)(A,{appearance:`custom`,agentId:a.agentId,className:`size-8`}):(0,V.jsx)(re,{className:`size-4 text-fg-muted`,"aria-hidden":!0})}),(0,V.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:R?n?`上传中…`:`Uploading…`:n?`上传`:`Upload`})]})]})]}),(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`语气`:`Tone`}),(0,V.jsx)(`div`,{className:`grid grid-cols-3 gap-2`,children:q.map(e=>(0,V.jsx)(`button`,{type:`button`,onClick:()=>{oe(e.id),$({preferences:{warmth:e.warmth}})},"aria-pressed":ie===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 ${ie===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,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-fg`,children:n?`棘手时`:`When things get tricky`}),(0,V.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[[`listen`,n?`先听`:`Listen`],[`untangle`,n?`理清`:`Untangle`],[`solutions`,n?`给办法`:`Suggest`]].map(([e,t])=>(0,V.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,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`mb-2 text-sm font-medium text-fg`,children:n?`回答长度`:`Length`}),(0,V.jsx)(o,{value:ve??`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;K(t),$({preferences:{detailLevel:t}})}})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`mb-2 text-sm font-medium text-fg`,children:n?`主动更新`:`Updates`}),(0,V.jsx)(o,{value:Ce??`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;we(t),$({preferences:{proactivity:t}})}})]})]}),(0,V.jsxs)(`details`,{className:`text-sm text-fg-muted`,children:[(0,V.jsx)(`summary`,{className:`cursor-pointer select-none`,children:n?`更多偏好`:`More preferences`}),(0,V.jsxs)(`div`,{className:`mt-3`,children:[(0,V.jsx)(`p`,{className:`mb-2 font-medium text-fg`,children:n?`轻松程度`:`Humor`}),(0,V.jsx)(o,{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;U(t),$({preferences:{humor:t}})}})]})]}),(0,V.jsx)(fe,{zh:n}),(0,V.jsx)(_e,{onGreetingChange:e=>$({voiceCallPreferences:{openingGreetingEnabled:e}}),record:a,zh:n,onSelectVoice:e=>$({voicePreference:e})}),(0,V.jsx)(`div`,{className:`border-t border-edge pt-5`,children:(0,V.jsx)(W,{conversationId:a.conversationId,zh:n,onSaved:async()=>{let e=await f(m(`/api/personal-agent`));e.ok&&e.payload&&(c.current=e.payload,s(e.payload))}})})]})]})})]}):null}return _?(0,V.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl space-y-5 px-6 py-12`,children:[(0,V.jsx)(T,{className:`h-20 w-20 rounded-full`}),(0,V.jsx)(T,{className:`h-9 w-72`}),(0,V.jsx)(T,{className:`h-44 w-full rounded-2xl`})]}):a?.state===`ready`?(0,V.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col bg-surface-panel`,children:[P&&(0,V.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,V.jsx)(`span`,{children:n?`助手已创建,头像上传未完成。可在资料设置中重新上传。`:`Your assistant is ready. Upload the avatar again in profile settings.`}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>{F(!1),Le()},className:`shrink-0 text-accent hover:underline`,children:n?`打开设置`:`Open settings`})]}),(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,V.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,V.jsx)(ae,{embedded:!0,personal:!0,personalWelcome:{name:a.displayName,addressAs:a.userCallName??void 0,avatar:(0,V.jsx)(A,{appearance:a.appearance,agentId:a.agentId,className:`size-14`}),opening:xe(a.preferences,n),showSupportChoice:!M,onChooseSupport:e=>void Be(e),onSkipSupport:()=>void Be(),supportChoiceError:k},conversationId:a.conversationId})})}),We()]}):(0,V.jsx)(ge,{modelsAvailable:h.length>0,onCreated:(e,t)=>{c.current=e,s(e),H(e.displayName),N(!1),F(t),window.dispatchEvent(new CustomEvent(`personal-agent-updated`,{detail:e})),window.dispatchEvent(new Event(`session-updated`))}})}export{Ce as PersonalPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{r as n,t as r,u as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{n as a}from"./locale-store-
|
|
1
|
+
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{r as n,t as r,u as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{n as a}from"./locale-store-DSsLH7JO.js";import{a as o,r as s}from"./product-delivery-BAks11S4.js";import{i as c}from"./vendor-swr-BIWyz7Rc.js";import{t as l}from"./skeleton-BwbyijEw.js";import{Gn as u}from"./index-DU5FmDQh.js";import{t as d}from"./open-route-MyZ2sB9C.js";var f=e(),p=t();function m(){let e=(0,f.c)(14),t=i(),r=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,()=>u(_));if(!m){let t=r?`这个打开链接无效。`:`This open link is invalid.`,n;return e[0]!==t||e[1]!==r?(n=(0,p.jsx)(g,{message:t,zh:r}),e[0]=t,e[1]=r,e[2]=n):n=e[2],n}if(m.kind!==`local_app`){let t=o({...m,title:m.id,capabilities:[`open`]}),i;return e[3]!==t||e[4]!==r?(i=t?(0,p.jsx)(n,{to:t,replace:!0}):(0,p.jsx)(g,{message:r?`这个内容无法在应用中打开。`:`This content cannot be opened in the app.`,zh:r}),e[3]=t,e[4]=r,e[5]=i):i=e[5],i}if(y){let t=typeof y==`object`&&y&&`status`in y&&y.status===404?r?`找不到这个应用,它可能已被删除。`:`This app was not found and may have been deleted.`:y instanceof Error?y.message:r?`无法打开这个应用。`:`Unable to open this app.`,n;return e[6]!==t||e[7]!==r?(n=(0,p.jsx)(g,{message:t,zh:r}),e[6]=t,e[7]=r,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 r;return e[11]===t?r=e[12]:(r=(0,p.jsx)(n,{to:t,replace:!0}),e[11]=t,e[12]=r),r}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)(l,{className:`h-6 w-48`}),(0,p.jsx)(l,{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:i}=e,a;t[0]===n?a=t[1]:(a=(0,p.jsx)(`p`,{children:n}),t[0]=n,t[1]=a);let o=i?`查看应用`:`View apps`,s;t[2]===o?s=t[3]:(s=(0,p.jsx)(r,{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-BMYIfy9x.js";import{t as r}from"./markdown-view-DUo9Tl3H.js";import{t as i}from"./messages-Uqz0xpsK.js";import{c as a,n as o,r as s}from"./locale-store-UEl-U1DO.js";import{i as c}from"./vendor-swr-BIWyz7Rc.js";import{Gn as l,Si as u,h as d,hn as f,l as p,pr as m,qn as h,v as g,yr as _}from"./index-Cz75qf5b.js";import{i as v}from"./automation-display-DCkjVzA0.js";import{t as y}from"./open-route-MyZ2sB9C.js";var b=e(),x=t();async function S(e){switch(e.kind){case`project`:return{kind:e.kind,value:await u(e.id)};case`workflow_run`:return{kind:e.kind,value:await d(e.id,{ownerAgentId:e.ownerAgentId})};case`workflow_definition`:{let t=await g();return{kind:e.kind,value:t.find(t=>t.id===e.id||t.name===e.id)}}case`automation`:{let[t,n]=await Promise.all([p.list(),p.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 h(e.id,e.sourceHash):void 0;return{kind:e.kind,value:t,previewUrl:n?.previewUrl||t.draftPreviewUrl}}}}var C={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 w(e){let t=(0,b.c)(138),{target:r}=e,l=a(k),u=o(O),d=u===`zh`,p=i(u),h;t[0]===d?h=t[1]:(h=e=>C[e]?.[+!d]||e,t[0]=d,t[1]=h);let g=h,w;t[2]!==r.href||t[3]!==l?(w=[`chat-product-preview`,r.href,l],t[2]=r.href,t[3]=l,t[4]=w):w=t[4];let A;t[5]===r?A=t[6]:(A=()=>S(r),t[5]=r,t[6]=A);let j;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(j={shouldRetryOnError:!1,refreshInterval:D},t[7]=j):j=t[7];let{data:M,error:N,isLoading:P}=c(w,A,j);if(P){let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,x.jsx)(f,{}),t[8]=e):e=t[8],e}if(N){let e=d?`无法加载内容,它可能已删除或暂时不可用。`:`Unable to load this content. It may have been deleted or be temporarily unavailable.`,n;return t[9]===e?n=t[10]:(n=(0,x.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:e}),t[9]=e,t[10]=n),n}if(!M?.value){let e=d?`内容不存在或已删除。`:`This content is unavailable or has been deleted.`,n;return t[11]===e?n=t[12]:(n=(0,x.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[11]=e,t[12]=n),n}let F=E;if(M.kind===`project`){let e=M.value,n;t[13]===e.name?n=t[14]:(n=(0,x.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]!==g?(r=g(e.status),t[15]=e.status,t[16]=g,t[17]=r):r=t[17];let i;t[18]!==e.health||t[19]!==g?(i=g(e.health),t[18]=e.health,t[19]=g,t[20]=i):i=t[20];let a;t[21]!==r||t[22]!==i?(a=(0,x.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]!==F||t[25]!==e.description?(o=F(e.description),t[24]=F,t[25]=e.description,t[26]=o):o=t[26];let s;t[27]!==F||t[28]!==e.brief?(s=F(e.brief),t[27]=F,t[28]=e.brief,t[29]=s):s=t[29];let c;t[30]!==F||t[31]!==e.outcome?(c=F(e.outcome),t[30]=F,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,x.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]!==d?(u=e.successCriteria?.length>0&&(0,x.jsxs)(`section`,{className:`space-y-3`,children:[(0,x.jsx)(`h3`,{className:`font-medium text-fg`,children:d?`完成标准`:`Success criteria`}),(0,x.jsx)(`ul`,{className:`list-disc space-y-2 pl-5 text-sm text-fg`,children:e.successCriteria.map(T)})]}),t[39]=e.successCriteria,t[40]=d,t[41]=u):u=t[41];let f;t[42]!==e.milestones||t[43]!==g||t[44]!==d?(f=e.milestones?.length>0&&(0,x.jsxs)(`section`,{className:`space-y-3`,children:[(0,x.jsx)(`h3`,{className:`font-medium text-fg`,children:d?`里程碑`:`Milestones`}),e.milestones.slice(0,8).map(e=>(0,x.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[e.title,` · `,g(e.status)]},e.id))]}),t[42]=e.milestones,t[43]=g,t[44]=d,t[45]=f):f=t[45];let p;t[46]!==F||t[47]!==e.recentUpdates||t[48]!==d?(p=e.recentUpdates?.[0]&&(0,x.jsxs)(`section`,{className:`space-y-3`,children:[(0,x.jsx)(`h3`,{className:`font-medium text-fg`,children:d?`最近进展`:`Latest update`}),F(e.recentUpdates[0].summary)]}),t[46]=F,t[47]=e.recentUpdates,t[48]=d,t[49]=p):p=t[49];let m;return t[50]!==l||t[51]!==u||t[52]!==f||t[53]!==p?(m=(0,x.jsxs)(`div`,{className:`space-y-6`,children:[l,u,f,p]}),t[50]=l,t[51]=u,t[52]=f,t[53]=p,t[54]=m):m=t[54],m}if(M.kind===`workflow_run`){let{run:e,phases:n}=M.value,r;t[55]===e.title?r=t[56]:(r=(0,x.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]!==g?(i=g(e.status),t[57]=e.status,t[58]=g,t[59]=i):i=t[59];let a=e.metrics?` · ${e.metrics.doneAgentCount}/${e.metrics.agentCount} ${d?`执行单元完成`:`agents completed`}`:``,o;t[60]!==i||t[61]!==a?(o=(0,x.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,x.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,x.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]!==F||t[69]!==e.result||t[70]!==d?(l=m(e.result)?F(_(e.result)):(0,x.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d?`尚无运行结果。`:`No result yet.`}),t[68]=F,t[69]=e.result,t[70]=d,t[71]=l):l=t[71];let u;t[72]!==n||t[73]!==g||t[74]!==d?(u=n.length>0&&(0,x.jsxs)(`section`,{className:`space-y-3`,children:[(0,x.jsx)(`h3`,{className:`font-medium text-fg`,children:d?`运行进度`:`Progress`}),n.map(e=>(0,x.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[e.title,` · `,g(e.status)]},e.id))]}),t[72]=n,t[73]=g,t[74]=d,t[75]=u):u=t[75];let f;return t[76]!==c||t[77]!==l||t[78]!==u||t[79]!==s?(f=(0,x.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]=f):f=t[80],f}if(M.kind===`workflow_definition`){let e=M.value,n=e.title||e.name,r;t[81]===n?r=t[82]:(r=(0,x.jsx)(`h2`,{className:`break-words text-lg font-semibold text-fg`,children:n}),t[81]=n,t[82]=r);let i;t[83]!==e.description||t[84]!==F?(i=F(e.description),t[83]=e.description,t[84]=F,t[85]=i):i=t[85];let a=e.metadata?.whenToUse,o;t[86]!==F||t[87]!==a?(o=F(a),t[86]=F,t[87]=a,t[88]=o):o=t[88];let s;t[89]!==e.phases||t[90]!==F||t[91]!==d?(s=e.phases.length>0&&(0,x.jsxs)(`section`,{className:`space-y-3`,children:[(0,x.jsx)(`h3`,{className:`font-medium text-fg`,children:d?`执行阶段`:`Phases`}),e.phases.map(e=>(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:e.title}),F(e.description)]},e.id))]}),t[89]=e.phases,t[90]=F,t[91]=d,t[92]=s):s=t[92];let c;return t[93]!==s||t[94]!==r||t[95]!==i||t[96]!==o?(c=(0,x.jsxs)(`div`,{className:`space-y-6`,children:[r,i,o,s]}),t[93]=s,t[94]=r,t[95]=i,t[96]=o,t[97]=c):c=t[97],c}if(M.kind===`automation`){let e=M.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,x.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]!==F?(i=F(e.description),t[100]=e.description,t[101]=F,t[102]=i):i=t[102];let a;t[103]!==n||t[104]!==F?(a=F(n),t[103]=n,t[104]=F,t[105]=a):a=t[105];let o;t[106]!==e.state.nextRunAtMs||t[107]!==d?(o=e.state.nextRunAtMs&&(0,x.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[d?`下次运行`:`Next run`,` · `,new Date(e.state.nextRunAtMs).toLocaleString(d?`zh-CN`:`en-US`)]}),t[106]=e.state.nextRunAtMs,t[107]=d,t[108]=o):o=t[108];let s;t[109]===e.state.lastError?s=t[110]:(s=e.state.lastError&&(0,x.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:e.state.lastError}),t[109]=e.state.lastError,t[110]=s);let c=d?`最近运行`:`Recent runs`,l;t[111]===c?l=t[112]:(l=(0,x.jsx)(`h3`,{className:`font-medium text-fg`,children:c}),t[111]=c,t[112]=l);let f;t[113]!==M.runs||t[114]!==F||t[115]!==g||t[116]!==d?(f=M.runs.length?M.runs.map(e=>(0,x.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-edge p-3`,children:[(0,x.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[g(e.status),` · `,new Date(e.createdAtMs).toLocaleString(d?`zh-CN`:`en-US`)]}),F(e.summary),e.error&&(0,x.jsx)(`p`,{className:`text-sm text-danger`,children:e.error})]},e.id)):(0,x.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d?`暂无运行记录。`:`No runs yet.`}),t[113]=M.runs,t[114]=F,t[115]=g,t[116]=d,t[117]=f):f=t[117];let m;return t[118]!==l||t[119]!==f?(m=(0,x.jsxs)(`section`,{className:`space-y-3`,children:[l,f]}),t[118]=l,t[119]=f,t[120]=m):m=t[120],(0,x.jsxs)(`div`,{className:`space-y-6`,children:[(0,x.jsxs)(`div`,{className:`space-y-3`,children:[r,(0,x.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[e.enabled?d?`已启用`:`Enabled`:d?`已停用`:`Disabled`,` · `,v(e.trigger,p.automations,p.cron,u)]}),i,a,o,s]}),m]})}let I=M.value,L;t[121]===I.name?L=t[122]:(L=(0,x.jsx)(`h2`,{className:`break-words text-lg font-semibold text-fg`,children:I.name}),t[121]=I.name,t[122]=L);let R=I.description||I.idea,z;t[123]!==F||t[124]!==R?(z=F(R),t[123]=F,t[124]=R,t[125]=z):z=t[125];let B;t[126]!==I.name||t[127]!==M.previewUrl||t[128]!==d?(B=M.previewUrl&&(0,x.jsx)(`iframe`,{title:d?`${I.name} 交互预览`:`${I.name} interactive preview`,src:s(M.previewUrl),sandbox:`allow-scripts allow-forms`,className:`h-[min(30rem,55dvh)] w-full rounded-lg border border-edge bg-white`}),t[126]=I.name,t[127]=M.previewUrl,t[128]=d,t[129]=B):B=t[129];let V;t[130]!==I||t[131]!==d?(V=I.installationState===`installed`&&I.enabled&&I.status===`installed`&&(0,x.jsx)(n,{to:y(I),className:`inline-flex rounded-lg bg-accent px-3 py-2 text-sm text-white focus-visible:ring-2 focus-visible:ring-accent`,children:d?`使用应用`:`Use app`}),t[130]=I,t[131]=d,t[132]=V):V=t[132];let H;return t[133]!==L||t[134]!==z||t[135]!==B||t[136]!==V?(H=(0,x.jsxs)(`div`,{className:`space-y-5`,children:[L,z,B,V]}),t[133]=L,t[134]=z,t[135]=B,t[136]=V,t[137]=H):H=t[137],H}function T(e,t){return(0,x.jsx)(`li`,{children:e},t)}function E(e){return e?.trim()?(0,x.jsx)(r,{content:e,mermaidActions:!1}):null}function D(e){return e?.kind===`workflow_run`&&[`queued`,`running`].includes(e.value.run.status)||e?.kind===`automation`&&e.value?.state.runningRunId?3e3:0}function O(e){return e.language}function k(e){return e.conversationId}export{w as default};
|
|
1
|
+
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as r}from"./markdown-view-2rwSrMXW.js";import{t as i}from"./messages-Cn25s55n.js";import{c as a,n as o,r as s}from"./locale-store-DSsLH7JO.js";import{i as c}from"./vendor-swr-BIWyz7Rc.js";import{Gn as l,Si as u,h as d,hn as f,l as p,pr as m,qn as h,v as g,yr as _}from"./index-DU5FmDQh.js";import{i as v}from"./automation-display-DCkjVzA0.js";import{t as y}from"./open-route-MyZ2sB9C.js";var b=e(),x=t();async function S(e){switch(e.kind){case`project`:return{kind:e.kind,value:await u(e.id)};case`workflow_run`:return{kind:e.kind,value:await d(e.id,{ownerAgentId:e.ownerAgentId})};case`workflow_definition`:{let t=await g();return{kind:e.kind,value:t.find(t=>t.id===e.id||t.name===e.id)}}case`automation`:{let[t,n]=await Promise.all([p.list(),p.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 h(e.id,e.sourceHash):void 0;return{kind:e.kind,value:t,previewUrl:n?.previewUrl||t.draftPreviewUrl}}}}var C={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 w(e){let t=(0,b.c)(138),{target:r}=e,l=a(k),u=o(O),d=u===`zh`,p=i(u),h;t[0]===d?h=t[1]:(h=e=>C[e]?.[+!d]||e,t[0]=d,t[1]=h);let g=h,w;t[2]!==r.href||t[3]!==l?(w=[`chat-product-preview`,r.href,l],t[2]=r.href,t[3]=l,t[4]=w):w=t[4];let A;t[5]===r?A=t[6]:(A=()=>S(r),t[5]=r,t[6]=A);let j;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(j={shouldRetryOnError:!1,refreshInterval:D},t[7]=j):j=t[7];let{data:M,error:N,isLoading:P}=c(w,A,j);if(P){let e;return t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,x.jsx)(f,{}),t[8]=e):e=t[8],e}if(N){let e=d?`无法加载内容,它可能已删除或暂时不可用。`:`Unable to load this content. It may have been deleted or be temporarily unavailable.`,n;return t[9]===e?n=t[10]:(n=(0,x.jsx)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:e}),t[9]=e,t[10]=n),n}if(!M?.value){let e=d?`内容不存在或已删除。`:`This content is unavailable or has been deleted.`,n;return t[11]===e?n=t[12]:(n=(0,x.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[11]=e,t[12]=n),n}let F=E;if(M.kind===`project`){let e=M.value,n;t[13]===e.name?n=t[14]:(n=(0,x.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]!==g?(r=g(e.status),t[15]=e.status,t[16]=g,t[17]=r):r=t[17];let i;t[18]!==e.health||t[19]!==g?(i=g(e.health),t[18]=e.health,t[19]=g,t[20]=i):i=t[20];let a;t[21]!==r||t[22]!==i?(a=(0,x.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]!==F||t[25]!==e.description?(o=F(e.description),t[24]=F,t[25]=e.description,t[26]=o):o=t[26];let s;t[27]!==F||t[28]!==e.brief?(s=F(e.brief),t[27]=F,t[28]=e.brief,t[29]=s):s=t[29];let c;t[30]!==F||t[31]!==e.outcome?(c=F(e.outcome),t[30]=F,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,x.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]!==d?(u=e.successCriteria?.length>0&&(0,x.jsxs)(`section`,{className:`space-y-3`,children:[(0,x.jsx)(`h3`,{className:`font-medium text-fg`,children:d?`完成标准`:`Success criteria`}),(0,x.jsx)(`ul`,{className:`list-disc space-y-2 pl-5 text-sm text-fg`,children:e.successCriteria.map(T)})]}),t[39]=e.successCriteria,t[40]=d,t[41]=u):u=t[41];let f;t[42]!==e.milestones||t[43]!==g||t[44]!==d?(f=e.milestones?.length>0&&(0,x.jsxs)(`section`,{className:`space-y-3`,children:[(0,x.jsx)(`h3`,{className:`font-medium text-fg`,children:d?`里程碑`:`Milestones`}),e.milestones.slice(0,8).map(e=>(0,x.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[e.title,` · `,g(e.status)]},e.id))]}),t[42]=e.milestones,t[43]=g,t[44]=d,t[45]=f):f=t[45];let p;t[46]!==F||t[47]!==e.recentUpdates||t[48]!==d?(p=e.recentUpdates?.[0]&&(0,x.jsxs)(`section`,{className:`space-y-3`,children:[(0,x.jsx)(`h3`,{className:`font-medium text-fg`,children:d?`最近进展`:`Latest update`}),F(e.recentUpdates[0].summary)]}),t[46]=F,t[47]=e.recentUpdates,t[48]=d,t[49]=p):p=t[49];let m;return t[50]!==l||t[51]!==u||t[52]!==f||t[53]!==p?(m=(0,x.jsxs)(`div`,{className:`space-y-6`,children:[l,u,f,p]}),t[50]=l,t[51]=u,t[52]=f,t[53]=p,t[54]=m):m=t[54],m}if(M.kind===`workflow_run`){let{run:e,phases:n}=M.value,r;t[55]===e.title?r=t[56]:(r=(0,x.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]!==g?(i=g(e.status),t[57]=e.status,t[58]=g,t[59]=i):i=t[59];let a=e.metrics?` · ${e.metrics.doneAgentCount}/${e.metrics.agentCount} ${d?`执行单元完成`:`agents completed`}`:``,o;t[60]!==i||t[61]!==a?(o=(0,x.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,x.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,x.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]!==F||t[69]!==e.result||t[70]!==d?(l=m(e.result)?F(_(e.result)):(0,x.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d?`尚无运行结果。`:`No result yet.`}),t[68]=F,t[69]=e.result,t[70]=d,t[71]=l):l=t[71];let u;t[72]!==n||t[73]!==g||t[74]!==d?(u=n.length>0&&(0,x.jsxs)(`section`,{className:`space-y-3`,children:[(0,x.jsx)(`h3`,{className:`font-medium text-fg`,children:d?`运行进度`:`Progress`}),n.map(e=>(0,x.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[e.title,` · `,g(e.status)]},e.id))]}),t[72]=n,t[73]=g,t[74]=d,t[75]=u):u=t[75];let f;return t[76]!==c||t[77]!==l||t[78]!==u||t[79]!==s?(f=(0,x.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]=f):f=t[80],f}if(M.kind===`workflow_definition`){let e=M.value,n=e.title||e.name,r;t[81]===n?r=t[82]:(r=(0,x.jsx)(`h2`,{className:`break-words text-lg font-semibold text-fg`,children:n}),t[81]=n,t[82]=r);let i;t[83]!==e.description||t[84]!==F?(i=F(e.description),t[83]=e.description,t[84]=F,t[85]=i):i=t[85];let a=e.metadata?.whenToUse,o;t[86]!==F||t[87]!==a?(o=F(a),t[86]=F,t[87]=a,t[88]=o):o=t[88];let s;t[89]!==e.phases||t[90]!==F||t[91]!==d?(s=e.phases.length>0&&(0,x.jsxs)(`section`,{className:`space-y-3`,children:[(0,x.jsx)(`h3`,{className:`font-medium text-fg`,children:d?`执行阶段`:`Phases`}),e.phases.map(e=>(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:e.title}),F(e.description)]},e.id))]}),t[89]=e.phases,t[90]=F,t[91]=d,t[92]=s):s=t[92];let c;return t[93]!==s||t[94]!==r||t[95]!==i||t[96]!==o?(c=(0,x.jsxs)(`div`,{className:`space-y-6`,children:[r,i,o,s]}),t[93]=s,t[94]=r,t[95]=i,t[96]=o,t[97]=c):c=t[97],c}if(M.kind===`automation`){let e=M.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,x.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]!==F?(i=F(e.description),t[100]=e.description,t[101]=F,t[102]=i):i=t[102];let a;t[103]!==n||t[104]!==F?(a=F(n),t[103]=n,t[104]=F,t[105]=a):a=t[105];let o;t[106]!==e.state.nextRunAtMs||t[107]!==d?(o=e.state.nextRunAtMs&&(0,x.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[d?`下次运行`:`Next run`,` · `,new Date(e.state.nextRunAtMs).toLocaleString(d?`zh-CN`:`en-US`)]}),t[106]=e.state.nextRunAtMs,t[107]=d,t[108]=o):o=t[108];let s;t[109]===e.state.lastError?s=t[110]:(s=e.state.lastError&&(0,x.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:e.state.lastError}),t[109]=e.state.lastError,t[110]=s);let c=d?`最近运行`:`Recent runs`,l;t[111]===c?l=t[112]:(l=(0,x.jsx)(`h3`,{className:`font-medium text-fg`,children:c}),t[111]=c,t[112]=l);let f;t[113]!==M.runs||t[114]!==F||t[115]!==g||t[116]!==d?(f=M.runs.length?M.runs.map(e=>(0,x.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-edge p-3`,children:[(0,x.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[g(e.status),` · `,new Date(e.createdAtMs).toLocaleString(d?`zh-CN`:`en-US`)]}),F(e.summary),e.error&&(0,x.jsx)(`p`,{className:`text-sm text-danger`,children:e.error})]},e.id)):(0,x.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d?`暂无运行记录。`:`No runs yet.`}),t[113]=M.runs,t[114]=F,t[115]=g,t[116]=d,t[117]=f):f=t[117];let m;return t[118]!==l||t[119]!==f?(m=(0,x.jsxs)(`section`,{className:`space-y-3`,children:[l,f]}),t[118]=l,t[119]=f,t[120]=m):m=t[120],(0,x.jsxs)(`div`,{className:`space-y-6`,children:[(0,x.jsxs)(`div`,{className:`space-y-3`,children:[r,(0,x.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[e.enabled?d?`已启用`:`Enabled`:d?`已停用`:`Disabled`,` · `,v(e.trigger,p.automations,p.cron,u)]}),i,a,o,s]}),m]})}let I=M.value,L;t[121]===I.name?L=t[122]:(L=(0,x.jsx)(`h2`,{className:`break-words text-lg font-semibold text-fg`,children:I.name}),t[121]=I.name,t[122]=L);let R=I.description||I.idea,z;t[123]!==F||t[124]!==R?(z=F(R),t[123]=F,t[124]=R,t[125]=z):z=t[125];let B;t[126]!==I.name||t[127]!==M.previewUrl||t[128]!==d?(B=M.previewUrl&&(0,x.jsx)(`iframe`,{title:d?`${I.name} 交互预览`:`${I.name} interactive preview`,src:s(M.previewUrl),sandbox:`allow-scripts allow-forms`,className:`h-[min(30rem,55dvh)] w-full rounded-lg border border-edge bg-white`}),t[126]=I.name,t[127]=M.previewUrl,t[128]=d,t[129]=B):B=t[129];let V;t[130]!==I||t[131]!==d?(V=I.installationState===`installed`&&I.enabled&&I.status===`installed`&&(0,x.jsx)(n,{to:y(I),className:`inline-flex rounded-lg bg-accent px-3 py-2 text-sm text-white focus-visible:ring-2 focus-visible:ring-accent`,children:d?`使用应用`:`Use app`}),t[130]=I,t[131]=d,t[132]=V):V=t[132];let H;return t[133]!==L||t[134]!==z||t[135]!==B||t[136]!==V?(H=(0,x.jsxs)(`div`,{className:`space-y-5`,children:[L,z,B,V]}),t[133]=L,t[134]=z,t[135]=B,t[136]=V,t[137]=H):H=t[137],H}function T(e,t){return(0,x.jsx)(`li`,{children:e},t)}function E(e){return e?.trim()?(0,x.jsx)(r,{content:e,mermaidActions:!1}):null}function D(e){return e?.kind===`workflow_run`&&[`queued`,`running`].includes(e.value.run.status)||e?.kind===`automation`&&e.value?.state.runningRunId?3e3:0}function O(e){return e.language}function k(e){return e.conversationId}export{w as default};
|