@xopcai/xopc 0.0.404 → 0.0.405
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/feishu/src/transport/socket-mode/monitor.js +1 -1
- package/dist/extensions/feishu/src/transport/webhook/monitor.js +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CdwFK70g.js → agent-avatar-dicebear-wc__VG7A.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-BMj9HwIQ.js → agent-defaults-settings-panel-DRgnm9A5.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-hrm6V8Dp.js → agents-sIMLDv80.js} +3 -3
- package/dist/gateway/static/root/assets/{app-management-settings-panel-Rg9jOmoj.js → app-management-settings-panel-DnQKk3ql.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-S3yp0GUO.js → appearance-settings-CoL67S5e.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-ChrJSB_2.js → apps-page-CRAr0xnF.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-J7hwA5cs.js → archive-plugin-CgKj53U1.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-Cesz1cjw.js → automations-page-Cr_WMoqc.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-DdopDyED.js → automations-workspace-BGpO47Sw.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-Bg4Se8Kg.js → binary-plugins-C_h3FTTz.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-Bw1sO9YH.js → block-editor-lnkSRbxE.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automation-inputs-Y46Mf8aY.js → browser-automation-inputs-FsIEAlnO.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-BcNjBdFQ.js → browser-automations-page-Dwhk5TFz.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-ByeqxrSF.js → browser-settings-page-B1Mfsw2n.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-CIv3LUQk.js → capabilities-Dl3LttAm.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-page-BUTQSo3A.js → capabilities-page-lfNS8DDp.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-B-Uwmjbo.js → capabilities-settings-panel-DLL614DS.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-header-actions-BGGJKzPL.js → capability-header-actions-wTmkMFS8.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-z6iuM4HE.js → channels-W60IrDrt.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-oMmP0flJ.js → chat-terminal-dock-DJjZ0p_B.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-CERhSG5W.js → computer-settings-page-BYYgEEdX.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-DyW3mLTh.js → connector-service-page-DavOiSs1.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-CdMwhiio.js → connectors-page-BUTj6vNY.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-CO3Jhdzg.js → date-picker-cGUcobcp.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-DbyMpo5J.js → dependency-picker-BvEoPDqz.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-DJ9OAPJs.js → desktop-pet-DL330r9w.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-CNrNXWlk.js → desktop-pet-settings-BkBrKnpR.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-TzK-VCuf.js → device-pairing-wizard-BYUl_dNS.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-BmFgRA8G.js → directory-picker-path-field-Bq5EumS7.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-C3ZpHHYc.js → extension-debug-page-BcNqrM44.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-gfOwpT2R.js → extension-page-BIOXclKZ.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-BS7cDqZJ.js → extension-settings-page-BdLmNW7c.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-UB6hyqcj.js → gateway-settings-C1vgqKYa.js} +1 -1
- package/dist/gateway/static/root/assets/{highlighted-body-KQOG7T2V-BRfDRn2k.js → highlighted-body-KQOG7T2V-BJBmXHUI.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-DBUnR1DO.js → home-page-Cd4MHgKf.js} +1 -1
- package/dist/gateway/static/root/assets/{image-generation-api-BoMWmqwF.js → image-generation-api-vO5_70v-.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-CPiPsiEP.js → imports-page-xvg0vgTo.js} +1 -1
- package/dist/gateway/static/root/assets/{index-DmURUvvA.js → index-DdJ_djQt.js} +116 -116
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-D9y8h4dR.js → keyboard-shortcuts-settings-D-jHSG1c.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-DoAmV6on.js → local-app-workbench-page-ER7_0M_4.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-CE6Ag8oQ.js → local-apps-page-DQOK34TS.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-DFysUb2k.js → logs-page-_v_abG4D.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-CmXPsu0I.js → management-settings-CWojbrEe.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-DvfdiczR.js → media-plugins-4_OqZkJo.js} +1 -1
- package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-BXiiOI72.js +1 -0
- package/dist/gateway/static/root/assets/{note-detail-panel-BpddDFQt.js → note-detail-panel-tHYUDAgB.js} +3 -3
- package/dist/gateway/static/root/assets/note-image-lightbox-DwVH-T8-.js +1 -0
- package/dist/gateway/static/root/assets/{notes-page-DQ4KZsWt.js → notes-page-BQqxqB3t.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-BcxVEGa2.js → page-context-capture-button-DkFhXsZj.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-page-CCQDxb7E.js → personal-page-DyKbVh4z.js} +1 -1
- package/dist/gateway/static/root/assets/{plugin-details-dialog-CGFQ_-bG.js → plugin-details-dialog-CVbHabgS.js} +1 -1
- package/dist/gateway/static/root/assets/{plugin-presentation-DF1gfuGf.js → plugin-presentation-BfVM-8kL.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-CXjjpXVx.js → preview-open-alternatives-Bz7-AqIY.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-DqiyvM4c.js → product-open-page-uAU6q84_.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-content-f7Q4giA3.js → product-preview-content-DsPKx_gw.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-BpUxpCUt.js +1 -0
- package/dist/gateway/static/root/assets/{projects-page-DO_pIhy-.js → projects-page-BWrQ05az.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-BFtELmg0.js → remote-access-hub-D4k7snPU.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-B9Beu-oK.js → runtime-tools-settings-panel-D2VV6nm2.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-ZAX7C5uI.js → schema-form-gO0zayZd.js} +1 -1
- package/dist/gateway/static/root/assets/{session-manager-BUMUjup5.js → session-manager-BMEW_eS_.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-D27knqOl.js → sessions-page-DPrI8ql2.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BYXPsUzS.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-BTUFu5KS.js → settings-form-section-CihKQYlF.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-YFr6zzh7.js → settings-page-BYP_I9AF.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-C5Jszsd1.js → setup-status-panel-BWVb5uxa.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-CsfrvY_G.js → share-preview-page-Dg0mhito.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-BW6BNot0.js → shares-settings-q0E4FYlf.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-api-o3HSgF_K.js → skill-api-CrNz0Fi0.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-BJsPnE87.js → skill-reload-api-BNCLOlJs.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-Kuf2t7MG.js → skills-page-CYwH8kim.js} +1 -1
- package/dist/gateway/static/root/assets/{style-DOz6lLJB.js → style-CuYP4CAT.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-B69rR6vw.js → system-settings-panel-DGFMkic_.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-CTqBd0eY.js +2 -0
- package/dist/gateway/static/root/assets/{task-expandable-content-BZCJqajv.js → task-expandable-content-BoGtWYbk.js} +1 -1
- package/dist/gateway/static/root/assets/{tasks-PuIUgF9L.js → tasks-B4bZpO6O.js} +1 -1
- package/dist/gateway/static/root/assets/{tracing-settings-page-BIq3Ayeg.js → tracing-settings-page-0CvZ40sA.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-V9pJ8fUo.js → tunnel-api-CnLkQQGi.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-DZdpti28.js → usage-page-BInqKKdE.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-BnMIUc_5.js → use-autosave-0dTfTmCk.js} +1 -1
- package/dist/gateway/static/root/assets/{user-model-page-BEgJ97hp.js → user-model-page-3Dr0YRDG.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-1h6fMaZL.js → voice-api-key-field-BpOvEhu7.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-CVNqSNz8.js → work-discovery-overlay-Br-XaBAW.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Dq63AthQ.js → workflow-run-setup-panel-B8E6qBkL.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-CfA1iwZu.js → workflows-page-CqC45_Fd.js} +1 -1
- package/dist/gateway/static/root/assets/{xopc-cloud-account-card-BsW2acj1.js → xopc-cloud-account-card-BARP73BX.js} +1 -1
- package/dist/gateway/static/root/index.html +4 -4
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/tasks.js +27 -8
- package/dist/src/automations/capabilities/write.d.ts +14 -0
- package/dist/src/automations/domain/validation.d.ts +28 -0
- package/dist/src/automations/draft/automation-draft-validator.d.ts +2 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +2 -2
- package/dist/src/cli/commands/extension.js +1 -1
- package/dist/src/cli/commands/onboard.js +1 -1
- package/dist/src/extensions/update.js +1 -1
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
- package/dist/src/gateway/hono/routes/config.js +1 -1
- package/dist/src/gateway/hono/routes/tasks.js +2 -1
- package/dist/src/gateway/service/config-coordinator.js +1 -1
- package/dist/src/gateway/service/run-gateway-agent.js +1 -0
- package/dist/src/gateway/service.js +2 -2
- package/dist/src/infra/update-runner.js +1 -1
- package/dist/src/providers/prompt-cache-lifecycle.d.ts +1 -1
- package/dist/src/providers/prompt-cache-lifecycle.js +1 -1
- package/dist/src/storage/sqlite/migrations/258_task_phase_changes.sql +20 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/tasks/capabilities/read.js +1 -0
- package/dist/src/tasks/capabilities/write.js +2 -2
- package/dist/src/tasks/task-application-service.d.ts +2 -1
- package/dist/src/tasks/task-application-service.js +80 -12
- package/dist/src/tasks/task-collaboration-delivery.js +2 -1
- package/dist/src/tasks/task-context-assembler.js +2 -1
- package/dist/src/tasks/task-read-model-projector.js +13 -5
- package/dist/src/tasks/task-repository.d.ts +11 -1
- package/dist/src/tasks/task-repository.js +42 -7
- package/dist/src/tasks/task-run-coordinator.d.ts +2 -0
- package/dist/src/tasks/task-run-coordinator.js +26 -17
- package/dist/src/tasks/task-run-repository.js +5 -2
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-SuiLTd5Y.js +0 -1
- package/dist/gateway/static/root/assets/note-image-lightbox-CMLVzPsQ.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-PBK7vXK5.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-CDzdr1zW.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-DOb97OLI.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./external-link-DjqjBmc3.js";import{t as i}from"./messages-Bwv-AOYl.js";import{t as a}from"./cn-0WouolD0.js";import{n as o}from"./locale-store-D5h-Ha6-.js";import{Ic as s,Tf as c,Zl as l,du as u,en as d,nn as f,no as p,os as m,rn as h,tn as g}from"./index-DmURUvvA.js";import{n as _,r as v}from"./settings-page-layout-Dx5S-Msc.js";import{r as y,t as b}from"./settings-form-section-BTUFu5KS.js";var x=e(t(),1);async function S(e,t){let n=window.electronAPI?.system;if(!m()||!n?.requestNotifications)return`unsupported`;let r=await n.requestNotifications();if(r.status!==`granted`)return r.outcome===`opened-settings`||r.status===`denied`?`denied`:`default`;await n.setBehavior({notifyEnabled:!0});let i=await n.showEndpointNotification({title:e,body:t});return i.ok||await n.setBehavior({notifyEnabled:!1}),i.ok?`enabled`:`default`}var C=n();function w(){let e=i(o(e=>e.language)).systemSettings.browserNotify,[t,n]=(0,x.useState)(f),[r,a]=(0,x.useState)(null),[s,l]=(0,x.useState)(!1),u=async t=>{if(!t){n(h({enabled:!1})),a(null);return}l(!0);try{let t=await d();if(t!==`granted`){a(t===`unsupported`?e.unsupported:e.denied);return}n(h({enabled:!0})),a(await g(e.testTitle,e.testBody)?e.testShown:e.failed)}finally{l(!1)}},p=e=>{n(h(e))};return(0,C.jsxs)(v,{gap:`gap-6`,children:[(0,C.jsx)(_,{title:e.pageTitle}),(0,C.jsxs)(b,{children:[(0,C.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,C.jsx)(c,{className:`size-4 text-accent`,strokeWidth:1.75}),e.title]}),(0,C.jsx)(`p`,{className:`mb-4 text-sm text-fg-muted`,children:e.description}),(0,C.jsx)(`div`,{className:`space-y-2`,children:[[`enabled`,e.enabled,e.enabledDesc],[`completed`,e.completed,e.completedDesc],[`failed`,e.failedRuns,e.failedRunsDesc],[`needsInput`,e.needsInput,e.needsInputDesc]].map(([e,n,r])=>(0,C.jsxs)(`label`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`span`,{children:[(0,C.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n}),(0,C.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:r})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:s||e!==`enabled`&&!t.enabled,checked:t[e],onChange:t=>{e===`enabled`?u(t.target.checked):p({[e]:t.target.checked})}})]},e))}),r?(0,C.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,role:`status`,children:r}):null,(0,C.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:e.limitation})]})]})}async function T(){if(typeof navigator>`u`||!navigator.mediaDevices?.getUserMedia)return!1;try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});for(let t of e.getTracks())t.stop();return!0}catch{return!1}}function E(e,t,n){return e.outcome===`opened-settings`?n.openedSettings:e.status===`granted`&&t?e.outcome===`already-granted`?n.alreadyGranted:n.granted:t?e.status===`denied`?n.denied:n.prompted:n.rendererDenied}function D(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:t.denied}function O(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:e.status===`denied`?t.denied:t.prompted}function k(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:e.status===`denied`?t.denied:t.prompted}var A=new Set([`microphone`,`accessibility`,`notifications`,`screen`]);function j(e,t,n){return t===`granted`?!1:e===`accessibility`&&(n===`darwin`||n===`win32`||n===`linux`)||e===`screen`&&(n===`darwin`||n===`win32`)||A.has(e)?t===`unknown`:!1}function M(e,t,n){return e===`accessibility`?!1:e===`screen`&&n===`linux`?!0:A.has(e)?t===`denied`:!0}var N=[{key:`fullDisk`,pane:`fullDisk`,platforms:[`darwin`]},{key:`screen`,pane:`screen`},{key:`microphone`,pane:`microphone`},{key:`accessibility`,pane:`accessibility`},{key:`automation`,pane:`automation`},{key:`notifications`,pane:`notifications`},{key:`location`,pane:`location`}];function P(e){return e===`linux`?N:N.filter(t=>!t.platforms||t.platforms.includes(e))}function F(e,t){let n=i(e).systemSettings.status;return t===`granted`?{label:n.granted,className:`text-emerald-600 dark:text-emerald-400`}:t===`denied`?{label:n.denied,className:`text-amber-600 dark:text-amber-400`}:{label:n.unknown,className:`text-fg-muted`}}function I(e,t,n){let r=i(e).systemSettings.permUnknown?.[t];return r?n===`darwin`&&r.darwin?r.darwin:n===`win32`&&r.win32?r.win32:n===`linux`&&r.linux?r.linux:null:null}var L={behavior:null,perms:null,loadError:null,permFeedback:null,permBusy:!1,refreshing:!1};function R(){let e=o(e=>e.language),t=i(e),n=t.systemSettings,[c,d]=(0,x.useReducer)(p,L),{behavior:f,perms:h,loadError:g,permFeedback:A,permBusy:N,refreshing:R}=c,z=typeof window<`u`?window.electronAPI?.system:void 0,B=(0,x.useCallback)(async e=>{if(z){d({type:`patch`,patch:{loadError:null}});try{d({type:`patch`,patch:{behavior:await z.getBehavior(),perms:await z.getPermissions({probe:e?.showRefreshFeedback}),...e?.showRefreshFeedback?{permFeedback:n.refreshDone}:{}}})}catch(t){d({type:`patch`,patch:{loadError:t instanceof Error?t.message:String(t),...e?.showRefreshFeedback?{permFeedback:null}:{}}})}}},[z,n.refreshDone]),V=(0,x.useCallback)(async()=>{if(!(R||N)){d({type:`patch`,patch:{refreshing:!0}});try{await B({showRefreshFeedback:!0})}finally{d({type:`patch`,patch:{refreshing:!1}})}}},[B,N,R]);if((0,x.useEffect)(()=>{let e=new Set([n.refreshDone,n.openSettingsDone,n.openSettingsFailed,n.desktopNotify.testShown]);if(!A||!e.has(A))return;let t=window.setTimeout(()=>{d({type:`patch`,patch:{permFeedback:null}})},3e3);return()=>window.clearTimeout(t)},[A,n.openSettingsDone,n.openSettingsFailed,n.refreshDone,n.desktopNotify.testShown]),(0,x.useEffect)(()=>{m()&&z&&B()},[z,B]),!m()||!z)return(0,C.jsx)(w,{});let H=async e=>{try{let{behavior:t}=await z.setBehavior(e);d({type:`patch`,patch:{behavior:t}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},U=async e=>{if(!e){await H({notifyEnabled:!1});return}d({type:`patch`,patch:{permBusy:!0,permFeedback:null}});try{let e=await S(n.desktopNotify.testTitle,n.desktopNotify.testBody);if(e===`unsupported`){d({type:`patch`,patch:{permFeedback:n.notificationsFeedback.unsupported}});return}if(e===`denied`){d({type:`patch`,patch:{permFeedback:n.desktopNotify.denied}});return}if(e==="default"){d({type:`patch`,patch:{permFeedback:n.notificationsFeedback.default}});return}await H({notifyEnabled:!0}),d({type:`patch`,patch:{perms:await z.getPermissions()}}),d({type:`patch`,patch:{permFeedback:n.desktopNotify.testShown}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{d({type:`patch`,patch:{permBusy:!1}})}},W=async e=>{d({type:`patch`,patch:{permFeedback:null}}),d({type:`patch`,patch:{loadError:null}});try{(await z.openPrivacy(e)).ok?d({type:`patch`,patch:{permFeedback:n.openSettingsDone}}):d({type:`patch`,patch:{permFeedback:n.openSettingsFailed}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},G=async()=>{d({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),d({type:`patch`,patch:{loadError:null}});try{let e=await z.requestMicrophone(),t=e.outcome===`opened-settings`||e.status===`denied`?!1:await T();d({type:`patch`,patch:{perms:await z.getPermissions()}}),d({type:`patch`,patch:{permFeedback:E(e,t,n.permFeedback)}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{d({type:`patch`,patch:{permBusy:!1}})}},K=async()=>{if(z.requestAccessibility){d({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),d({type:`patch`,patch:{loadError:null}});try{let e=await z.requestAccessibility();d({type:`patch`,patch:{perms:await z.getPermissions()}}),d({type:`patch`,patch:{permFeedback:D(e,n.accessibilityFeedback)}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{d({type:`patch`,patch:{permBusy:!1}})}}},q=async()=>{if(z.requestNotifications){d({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),d({type:`patch`,patch:{loadError:null}});try{let e=await z.requestNotifications();d({type:`patch`,patch:{perms:await z.getPermissions()}}),d({type:`patch`,patch:{permFeedback:O(e,n.notificationsFeedback)}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{d({type:`patch`,patch:{permBusy:!1}})}}},J=async()=>{if(z.requestScreen){d({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),d({type:`patch`,patch:{loadError:null}});try{let e=await z.requestScreen();d({type:`patch`,patch:{perms:await z.getPermissions()}}),d({type:`patch`,patch:{permFeedback:k(e,n.screenFeedback)}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{d({type:`patch`,patch:{permBusy:!1}})}}},Y=f?f.platform===`win32`?n.permissionsHintWin:f.platform===`linux`?n.permissionsHintLinux:f.platform===`darwin`?n.permissionsHintDarwin:n.permissionsHint:n.permissionsHint;return(0,C.jsxs)(v,{gap:`gap-6`,children:[(0,C.jsx)(_,{title:n.title}),g?(0,C.jsx)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:g}):null,A?(0,C.jsx)(`p`,{className:a(`text-sm`,A===n.refreshDone||A===n.openSettingsDone||A===n.permFeedback.granted||A===n.permFeedback.alreadyGranted||A===n.accessibilityFeedback.granted||A===n.accessibilityFeedback.alreadyGranted||A===n.notificationsFeedback.granted||A===n.notificationsFeedback.alreadyGranted||A===n.screenFeedback.granted||A===n.screenFeedback.alreadyGranted||A===n.desktopNotify.testShown?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`),role:`status`,"aria-live":`polite`,children:A}):null,(0,C.jsxs)(b,{children:[(0,C.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,C.jsx)(l,{className:`size-4 text-accent`,strokeWidth:1.75}),n.behaviorGroup]}),(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(0,C.jsxs)(`label`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.endpointToolsSettings.deviceAccess.background}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.endpointToolsSettings.deviceAccess.sleep})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f?.backgroundSupported,checked:!!f?.runInBackground,onChange:e=>void H({runInBackground:e.target.checked})})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.toggles.openAtLogin}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.openAtLoginDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f,checked:!!f?.openAtLogin,onChange:e=>{H({openAtLogin:e.target.checked})}})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.toggles.keepAwake}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.keepAwakeDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f,checked:!!f?.keepAwakePreferred,onChange:e=>{H({keepAwakePreferred:e.target.checked})}})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.toggles.notifyDesktop}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.notifyDesktopDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f||N,checked:!!f?.notifyEnabled,onChange:e=>{U(e.target.checked)}})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.toggles.notifySound}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.notifySoundDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f,checked:!!f?.notifySoundEnabled,onChange:e=>{H({notifySoundEnabled:e.target.checked})}})]})]})]}),f&&h?(0,C.jsxs)(`section`,{className:y(),children:[(0,C.jsxs)(`div`,{className:`mb-4 flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.permissionsTitle}),(0,C.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:Y}),f.platform===`darwin`&&!f.packaged?(0,C.jsx)(`p`,{className:`mt-1 text-xs text-amber-600 dark:text-amber-400`,children:n.permissionsHintDevDarwin}):null]}),(0,C.jsxs)(`button`,{type:`button`,disabled:R||N,"aria-busy":R,className:a(`mt-2 inline-flex max-w-full items-center justify-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-3 py-1.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover disabled:opacity-50 sm:mt-0`,s.press),onClick:()=>void V(),children:[(0,C.jsx)(u,{className:a(`size-3.5`,R&&`animate-spin`),strokeWidth:1.75,"aria-hidden":!0}),R?n.refreshing:n.refresh]})]}),(0,C.jsx)(`ul`,{className:`space-y-3`,children:P(f.platform).map(({key:t,pane:i})=>{let o=F(e,h[t]),c=n.perm[t],l=h[t]===`unknown`?I(e,t,f.platform):null;return c?(0,C.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-xl bg-surface-panel/70 p-3 shadow-surface sm:flex-row sm:items-center sm:justify-between`,children:[(0,C.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:c.title}),(0,C.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:c.desc}),(0,C.jsx)(`p`,{className:`mt-1 text-xs font-medium ${o.className}`,children:o.label}),l?(0,C.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:l}):null]}),(0,C.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[t===`notifications`&&j(t,h[t],f.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:a(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,s.press),onClick:()=>void q(),children:n.requestAccess}):null,t===`microphone`&&j(t,h[t],f.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:a(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,s.press),onClick:()=>void G(),children:n.requestAccess}):null,t===`accessibility`&&j(t,h[t],f.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:a(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,s.press),onClick:()=>void K(),children:n.requestAccess}):null,t===`screen`&&j(t,h[t],f.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:a(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,s.press),onClick:()=>void J(),children:n.requestAccess}):null,M(t,h[t],f.platform)?(0,C.jsxs)(`button`,{type:`button`,className:a(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,s.press),onClick:()=>void W(i),children:[n.openSettings,(0,C.jsx)(r,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})]}):null]})]},t):null})})]}):null]})}export{R as SystemSettingsPanel};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./external-link-DjqjBmc3.js";import{t as i}from"./messages-Bwv-AOYl.js";import{t as a}from"./cn-0WouolD0.js";import{n as o}from"./locale-store-D5h-Ha6-.js";import{Ic as s,Tf as c,Zl as l,du as u,en as d,nn as f,no as p,os as m,rn as h,tn as g}from"./index-DdJ_djQt.js";import{n as _,r as v}from"./settings-page-layout-Dx5S-Msc.js";import{r as y,t as b}from"./settings-form-section-CihKQYlF.js";var x=e(t(),1);async function S(e,t){let n=window.electronAPI?.system;if(!m()||!n?.requestNotifications)return`unsupported`;let r=await n.requestNotifications();if(r.status!==`granted`)return r.outcome===`opened-settings`||r.status===`denied`?`denied`:`default`;await n.setBehavior({notifyEnabled:!0});let i=await n.showEndpointNotification({title:e,body:t});return i.ok||await n.setBehavior({notifyEnabled:!1}),i.ok?`enabled`:`default`}var C=n();function w(){let e=i(o(e=>e.language)).systemSettings.browserNotify,[t,n]=(0,x.useState)(f),[r,a]=(0,x.useState)(null),[s,l]=(0,x.useState)(!1),u=async t=>{if(!t){n(h({enabled:!1})),a(null);return}l(!0);try{let t=await d();if(t!==`granted`){a(t===`unsupported`?e.unsupported:e.denied);return}n(h({enabled:!0})),a(await g(e.testTitle,e.testBody)?e.testShown:e.failed)}finally{l(!1)}},p=e=>{n(h(e))};return(0,C.jsxs)(v,{gap:`gap-6`,children:[(0,C.jsx)(_,{title:e.pageTitle}),(0,C.jsxs)(b,{children:[(0,C.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,C.jsx)(c,{className:`size-4 text-accent`,strokeWidth:1.75}),e.title]}),(0,C.jsx)(`p`,{className:`mb-4 text-sm text-fg-muted`,children:e.description}),(0,C.jsx)(`div`,{className:`space-y-2`,children:[[`enabled`,e.enabled,e.enabledDesc],[`completed`,e.completed,e.completedDesc],[`failed`,e.failedRuns,e.failedRunsDesc],[`needsInput`,e.needsInput,e.needsInputDesc]].map(([e,n,r])=>(0,C.jsxs)(`label`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`span`,{children:[(0,C.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n}),(0,C.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:r})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:s||e!==`enabled`&&!t.enabled,checked:t[e],onChange:t=>{e===`enabled`?u(t.target.checked):p({[e]:t.target.checked})}})]},e))}),r?(0,C.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,role:`status`,children:r}):null,(0,C.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:e.limitation})]})]})}async function T(){if(typeof navigator>`u`||!navigator.mediaDevices?.getUserMedia)return!1;try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});for(let t of e.getTracks())t.stop();return!0}catch{return!1}}function E(e,t,n){return e.outcome===`opened-settings`?n.openedSettings:e.status===`granted`&&t?e.outcome===`already-granted`?n.alreadyGranted:n.granted:t?e.status===`denied`?n.denied:n.prompted:n.rendererDenied}function D(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:t.denied}function O(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:e.status===`denied`?t.denied:t.prompted}function k(e,t){return e.outcome===`opened-settings`?t.openedSettings:e.status===`granted`?e.outcome===`already-granted`?t.alreadyGranted:t.granted:e.status===`denied`?t.denied:t.prompted}var A=new Set([`microphone`,`accessibility`,`notifications`,`screen`]);function j(e,t,n){return t===`granted`?!1:e===`accessibility`&&(n===`darwin`||n===`win32`||n===`linux`)||e===`screen`&&(n===`darwin`||n===`win32`)||A.has(e)?t===`unknown`:!1}function M(e,t,n){return e===`accessibility`?!1:e===`screen`&&n===`linux`?!0:A.has(e)?t===`denied`:!0}var N=[{key:`fullDisk`,pane:`fullDisk`,platforms:[`darwin`]},{key:`screen`,pane:`screen`},{key:`microphone`,pane:`microphone`},{key:`accessibility`,pane:`accessibility`},{key:`automation`,pane:`automation`},{key:`notifications`,pane:`notifications`},{key:`location`,pane:`location`}];function P(e){return e===`linux`?N:N.filter(t=>!t.platforms||t.platforms.includes(e))}function F(e,t){let n=i(e).systemSettings.status;return t===`granted`?{label:n.granted,className:`text-emerald-600 dark:text-emerald-400`}:t===`denied`?{label:n.denied,className:`text-amber-600 dark:text-amber-400`}:{label:n.unknown,className:`text-fg-muted`}}function I(e,t,n){let r=i(e).systemSettings.permUnknown?.[t];return r?n===`darwin`&&r.darwin?r.darwin:n===`win32`&&r.win32?r.win32:n===`linux`&&r.linux?r.linux:null:null}var L={behavior:null,perms:null,loadError:null,permFeedback:null,permBusy:!1,refreshing:!1};function R(){let e=o(e=>e.language),t=i(e),n=t.systemSettings,[c,d]=(0,x.useReducer)(p,L),{behavior:f,perms:h,loadError:g,permFeedback:A,permBusy:N,refreshing:R}=c,z=typeof window<`u`?window.electronAPI?.system:void 0,B=(0,x.useCallback)(async e=>{if(z){d({type:`patch`,patch:{loadError:null}});try{d({type:`patch`,patch:{behavior:await z.getBehavior(),perms:await z.getPermissions({probe:e?.showRefreshFeedback}),...e?.showRefreshFeedback?{permFeedback:n.refreshDone}:{}}})}catch(t){d({type:`patch`,patch:{loadError:t instanceof Error?t.message:String(t),...e?.showRefreshFeedback?{permFeedback:null}:{}}})}}},[z,n.refreshDone]),V=(0,x.useCallback)(async()=>{if(!(R||N)){d({type:`patch`,patch:{refreshing:!0}});try{await B({showRefreshFeedback:!0})}finally{d({type:`patch`,patch:{refreshing:!1}})}}},[B,N,R]);if((0,x.useEffect)(()=>{let e=new Set([n.refreshDone,n.openSettingsDone,n.openSettingsFailed,n.desktopNotify.testShown]);if(!A||!e.has(A))return;let t=window.setTimeout(()=>{d({type:`patch`,patch:{permFeedback:null}})},3e3);return()=>window.clearTimeout(t)},[A,n.openSettingsDone,n.openSettingsFailed,n.refreshDone,n.desktopNotify.testShown]),(0,x.useEffect)(()=>{m()&&z&&B()},[z,B]),!m()||!z)return(0,C.jsx)(w,{});let H=async e=>{try{let{behavior:t}=await z.setBehavior(e);d({type:`patch`,patch:{behavior:t}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},U=async e=>{if(!e){await H({notifyEnabled:!1});return}d({type:`patch`,patch:{permBusy:!0,permFeedback:null}});try{let e=await S(n.desktopNotify.testTitle,n.desktopNotify.testBody);if(e===`unsupported`){d({type:`patch`,patch:{permFeedback:n.notificationsFeedback.unsupported}});return}if(e===`denied`){d({type:`patch`,patch:{permFeedback:n.desktopNotify.denied}});return}if(e==="default"){d({type:`patch`,patch:{permFeedback:n.notificationsFeedback.default}});return}await H({notifyEnabled:!0}),d({type:`patch`,patch:{perms:await z.getPermissions()}}),d({type:`patch`,patch:{permFeedback:n.desktopNotify.testShown}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{d({type:`patch`,patch:{permBusy:!1}})}},W=async e=>{d({type:`patch`,patch:{permFeedback:null}}),d({type:`patch`,patch:{loadError:null}});try{(await z.openPrivacy(e)).ok?d({type:`patch`,patch:{permFeedback:n.openSettingsDone}}):d({type:`patch`,patch:{permFeedback:n.openSettingsFailed}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}},G=async()=>{d({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),d({type:`patch`,patch:{loadError:null}});try{let e=await z.requestMicrophone(),t=e.outcome===`opened-settings`||e.status===`denied`?!1:await T();d({type:`patch`,patch:{perms:await z.getPermissions()}}),d({type:`patch`,patch:{permFeedback:E(e,t,n.permFeedback)}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{d({type:`patch`,patch:{permBusy:!1}})}},K=async()=>{if(z.requestAccessibility){d({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),d({type:`patch`,patch:{loadError:null}});try{let e=await z.requestAccessibility();d({type:`patch`,patch:{perms:await z.getPermissions()}}),d({type:`patch`,patch:{permFeedback:D(e,n.accessibilityFeedback)}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{d({type:`patch`,patch:{permBusy:!1}})}}},q=async()=>{if(z.requestNotifications){d({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),d({type:`patch`,patch:{loadError:null}});try{let e=await z.requestNotifications();d({type:`patch`,patch:{perms:await z.getPermissions()}}),d({type:`patch`,patch:{permFeedback:O(e,n.notificationsFeedback)}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{d({type:`patch`,patch:{permBusy:!1}})}}},J=async()=>{if(z.requestScreen){d({type:`patch`,patch:{permBusy:!0,permFeedback:null}}),d({type:`patch`,patch:{loadError:null}});try{let e=await z.requestScreen();d({type:`patch`,patch:{perms:await z.getPermissions()}}),d({type:`patch`,patch:{permFeedback:k(e,n.screenFeedback)}})}catch(e){d({type:`patch`,patch:{loadError:e instanceof Error?e.message:String(e)}})}finally{d({type:`patch`,patch:{permBusy:!1}})}}},Y=f?f.platform===`win32`?n.permissionsHintWin:f.platform===`linux`?n.permissionsHintLinux:f.platform===`darwin`?n.permissionsHintDarwin:n.permissionsHint:n.permissionsHint;return(0,C.jsxs)(v,{gap:`gap-6`,children:[(0,C.jsx)(_,{title:n.title}),g?(0,C.jsx)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:g}):null,A?(0,C.jsx)(`p`,{className:a(`text-sm`,A===n.refreshDone||A===n.openSettingsDone||A===n.permFeedback.granted||A===n.permFeedback.alreadyGranted||A===n.accessibilityFeedback.granted||A===n.accessibilityFeedback.alreadyGranted||A===n.notificationsFeedback.granted||A===n.notificationsFeedback.alreadyGranted||A===n.screenFeedback.granted||A===n.screenFeedback.alreadyGranted||A===n.desktopNotify.testShown?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`),role:`status`,"aria-live":`polite`,children:A}):null,(0,C.jsxs)(b,{children:[(0,C.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,C.jsx)(l,{className:`size-4 text-accent`,strokeWidth:1.75}),n.behaviorGroup]}),(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(0,C.jsxs)(`label`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.endpointToolsSettings.deviceAccess.background}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.endpointToolsSettings.deviceAccess.sleep})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f?.backgroundSupported,checked:!!f?.runInBackground,onChange:e=>void H({runInBackground:e.target.checked})})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.toggles.openAtLogin}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.openAtLoginDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f,checked:!!f?.openAtLogin,onChange:e=>{H({openAtLogin:e.target.checked})}})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.toggles.keepAwake}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.keepAwakeDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f,checked:!!f?.keepAwakePreferred,onChange:e=>{H({keepAwakePreferred:e.target.checked})}})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.toggles.notifyDesktop}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.notifyDesktopDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f||N,checked:!!f?.notifyEnabled,onChange:e=>{U(e.target.checked)}})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.toggles.notifySound}),(0,C.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.toggles.notifySoundDesc})]}),(0,C.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:!f,checked:!!f?.notifySoundEnabled,onChange:e=>{H({notifySoundEnabled:e.target.checked})}})]})]})]}),f&&h?(0,C.jsxs)(`section`,{className:y(),children:[(0,C.jsxs)(`div`,{className:`mb-4 flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.permissionsTitle}),(0,C.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:Y}),f.platform===`darwin`&&!f.packaged?(0,C.jsx)(`p`,{className:`mt-1 text-xs text-amber-600 dark:text-amber-400`,children:n.permissionsHintDevDarwin}):null]}),(0,C.jsxs)(`button`,{type:`button`,disabled:R||N,"aria-busy":R,className:a(`mt-2 inline-flex max-w-full items-center justify-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-3 py-1.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover disabled:opacity-50 sm:mt-0`,s.press),onClick:()=>void V(),children:[(0,C.jsx)(u,{className:a(`size-3.5`,R&&`animate-spin`),strokeWidth:1.75,"aria-hidden":!0}),R?n.refreshing:n.refresh]})]}),(0,C.jsx)(`ul`,{className:`space-y-3`,children:P(f.platform).map(({key:t,pane:i})=>{let o=F(e,h[t]),c=n.perm[t],l=h[t]===`unknown`?I(e,t,f.platform):null;return c?(0,C.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-xl bg-surface-panel/70 p-3 shadow-surface sm:flex-row sm:items-center sm:justify-between`,children:[(0,C.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,C.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:c.title}),(0,C.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:c.desc}),(0,C.jsx)(`p`,{className:`mt-1 text-xs font-medium ${o.className}`,children:o.label}),l?(0,C.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:l}):null]}),(0,C.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[t===`notifications`&&j(t,h[t],f.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:a(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,s.press),onClick:()=>void q(),children:n.requestAccess}):null,t===`microphone`&&j(t,h[t],f.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:a(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,s.press),onClick:()=>void G(),children:n.requestAccess}):null,t===`accessibility`&&j(t,h[t],f.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:a(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,s.press),onClick:()=>void K(),children:n.requestAccess}):null,t===`screen`&&j(t,h[t],f.platform)?(0,C.jsx)(`button`,{type:`button`,disabled:N,className:a(`inline-flex items-center gap-1 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,s.press),onClick:()=>void J(),children:n.requestAccess}):null,M(t,h[t],f.platform)?(0,C.jsxs)(`button`,{type:`button`,className:a(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,s.press),onClick:()=>void W(i),children:[n.openSettings,(0,C.jsx)(r,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})]}):null]})]},t):null})})]}):null]})}export{R as SystemSettingsPanel};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,g as a,m as o,t as s}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as c}from"./circle-check-C23XjkUj.js";import{t as l}from"./ellipsis-0k4rZLoy.js";import{t as u}from"./external-link-DjqjBmc3.js";import{F as d,N as f,V as p,z as m}from"./markdown-view-CthsQiiO.js";import{t as h}from"./folder-open-CyzJ19I9.js";import{t as g}from"./x-B_N4OPjy.js";import{t as _}from"./cn-0WouolD0.js";import{a as v,c as ee,n as te,r as ne}from"./locale-store-D5h-Ha6-.js";import{i as y,n as b,o as re,r as ie,s as ae,t as x}from"./dist-BGTk37IG.js";import{i as S}from"./vendor-swr-BIWyz7Rc.js";import{$c as oe,Ad as C,Af as se,Bu as w,Ca as T,Eu as E,Go as D,Kc as O,Ni as k,No as A,Pd as j,Qa as ce,Qs as le,Rc as M,Xc as ue,Za as de,Zc as fe,ar as pe,bo as me,cl as he,ds as N,er as ge,fl as _e,fs as ve,gl as ye,hf as be,il as xe,ir as Se,l as Ce,la as we,ml as Te,n as Ee,nf as De,nr as Oe,qc as ke,rf as Ae,rr as je,so as Me,tr as Ne,ua as Pe,ul as Fe,va as P,yu as Ie}from"./index-DdJ_djQt.js";import{t as F}from"./date-picker-cGUcobcp.js";import{n as Le,t as I}from"./task-expandable-content-BoGtWYbk.js";import{t as Re}from"./page-context-capture-button-DkFhXsZj.js";import{t as ze}from"./dependency-picker-BvEoPDqz.js";var L=n(),R=r();function Be(e){let t=(0,L.c)(33),{changes:n,language:r}=e,i=r===`zh`,a;t[0]===i?a=t[1]:(a=i?{backlog:`待办池`,ready:`就绪`,active:`进行中`,review:`待验收`,closed:`已关闭`}:{backlog:`Backlog`,ready:`Ready`,active:`Active`,review:`Review`,closed:`Closed`},t[0]=i,t[1]=a);let o=a,s;t[2]===i?s=t[3]:(s=i?{board:`看板`,mobile:`移动端`,api:`手动操作`,runtime:`自动流转`,undo:`撤销`}:{board:`Board`,mobile:`Mobile`,api:`Manual update`,runtime:`Automatic`,undo:`Undo`},t[2]=i,t[3]=s);let c=s,l;t[4]===i?l=t[5]:(l=i?{done:`完成`,cancelled:`取消`,duplicate:`重复`,wont_do:`不做`}:{done:`Done`,cancelled:`Cancelled`,duplicate:`Duplicate`,wont_do:`Won’t do`},t[4]=i,t[5]=l);let u=l,d;t[6]===i?d=t[7]:(d=i?{user:`用户`,agent:`Agent`,system:`系统`,integration:`外部服务`}:{user:`User`,agent:`Agent`,system:`System`,integration:`Integration`},t[6]=i,t[7]=d);let f=d,p=i?`变更记录`:`Change log`,m;t[8]!==n.length||t[9]!==p?(m=(0,R.jsxs)(`summary`,{className:`cursor-pointer text-sm font-semibold text-fg`,children:[p,` (`,n.length,`)`]}),t[8]=n.length,t[9]=p,t[10]=m):m=t[10];let h;if(t[11]!==f||t[12]!==n||t[13]!==r||t[14]!==o||t[15]!==u||t[16]!==c){let e;t[18]!==f||t[19]!==r||t[20]!==o||t[21]!==u||t[22]!==c?(e=e=>(0,R.jsxs)(`li`,{className:`text-sm text-fg`,children:[(0,R.jsxs)(`div`,{children:[o[e.fromPhase],e.fromResolution?` · ${u[e.fromResolution]}`:``,` → `,o[e.toPhase],e.toResolution?` · ${u[e.toResolution]}`:``]}),(0,R.jsxs)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:[f[e.actor.kind],e.actor.id?` (${e.actor.id})`:``,` · `,c[e.source],` · `,(0,R.jsx)(`time`,{dateTime:new Date(e.createdAt).toISOString(),children:k(e.createdAt,r)})]})]},e.id),t[18]=f,t[19]=r,t[20]=o,t[21]=u,t[22]=c,t[23]=e):e=t[23],h=[...n].reverse().map(e),t[11]=f,t[12]=n,t[13]=r,t[14]=o,t[15]=u,t[16]=c,t[17]=h}else h=t[17];let g;t[24]===h?g=t[25]:(g=(0,R.jsx)(`ol`,{className:`mt-3 max-h-80 space-y-3 overflow-y-auto`,children:h}),t[24]=h,t[25]=g);let _;t[26]!==n.length||t[27]!==i?(_=n.length?null:(0,R.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:i?`暂无阶段变更记录`:`No phase changes yet`}),t[26]=n.length,t[27]=i,t[28]=_):_=t[28];let v;return t[29]!==m||t[30]!==g||t[31]!==_?(v=(0,R.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[m,g,_]}),t[29]=m,t[30]=g,t[31]=_,t[32]=v):v=t[32],v}var z=e(t(),1);function Ve({wait:e,detail:t,zh:n,onUpdated:r}){let[i,a]=(0,z.useState)(``),[o,s]=(0,z.useState)(!1),[c,l]=(0,z.useState)(``),[u,d]=(0,z.useState)(!1),f=(0,z.useRef)(null),p=e.kind===`approval`,m=Array.isArray(e.condition.choices)?e.condition.choices.filter(e=>typeof e==`string`):[];async function h(a){if(!p&&!i.trim()||p&&!a||o)return;let c=JSON.stringify([t.task.version,i.trim(),a]);f.current?.signature!==c&&(f.current={signature:c,key:crypto.randomUUID()}),s(!0),l(``);try{let o=await fe(t.task.id,{type:`resolve_wait`,waitId:e.id,resolution:p?{kind:`task_approval`,decision:a}:{kind:`user_answer`,answer:i.trim()}},t.task.version,f.current.key);d(!0),r(o),le({tone:`success`,title:p?n?`决定已保存`:`Decision saved`:n?`补充信息已保存`:`Answer saved`,message:o.waits.length?n?`仍有其他等待条件,任务尚未恢复执行。`:`Other waiting conditions remain.`:n?`等待已解除,请在任务状态中查看后续执行进展。`:`The wait is resolved. Follow progress in the task status.`,source:n?`任务`:`Task`})}catch{l(n?`提交未确认,内容已保留。可重试;若问题已变化,请刷新。`:`Submission not confirmed. Your answer is saved here; retry or refresh if the question changed.`)}finally{s(!1)}}return(0,R.jsxs)(`form`,{className:`mt-3 space-y-3 rounded-lg border border-edge p-3`,onSubmit:e=>{e.preventDefault(),h()},children:[p?(0,R.jsxs)(`div`,{className:`text-sm text-fg`,children:[(0,R.jsx)(`p`,{children:e.reason}),(0,R.jsxs)(`p`,{className:`mt-2`,children:[n?`授权范围:`:`Permission: `,String(e.condition.capability)]}),(0,R.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,R.jsx)(O,{type:`button`,variant:`primary`,disabled:o||u,onClick:()=>void h(`approve`),children:n?`批准`:`Approve`}),(0,R.jsx)(O,{type:`button`,disabled:o||u,onClick:()=>void h(`deny`),children:n?`拒绝并暂停`:`Deny and pause`})]})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`label`,{className:`block text-sm text-fg`,children:[typeof e.condition.question==`string`?e.condition.question:e.reason,(0,R.jsx)(`textarea`,{className:`mt-2 w-full rounded-lg border border-edge bg-surface-panel p-3`,rows:3,maxLength:12e3,value:i,disabled:o||u,onChange:e=>a(e.target.value)})]}),m.length>0&&(0,R.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:m.map(e=>(0,R.jsx)(O,{type:`button`,disabled:o||u,variant:`secondary`,"aria-pressed":i===e,onClick:()=>a(e),children:e},e))}),(0,R.jsx)(O,{type:`submit`,variant:`primary`,disabled:o||u||!i.trim(),children:o?n?`正在提交`:`Submitting`:n?`提交补充信息`:`Submit answer`})]}),(0,R.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n?`保存到任务上下文;其他等待条件满足后继续执行。`:`Saved to task context. Work continues once all waiting conditions are met.`}),c&&(0,R.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:c})]})}function He(e){let t=(0,L.c)(17),{children:n,contentKey:r,language:i,className:o}=e,s=(0,z.useId)(),c=z.Children.toArray(n),[l,u]=a(),d;t[0]!==r||t[1]!==l?(d=l.getAll(`taskExpanded`).includes(r),t[0]=r,t[1]=l,t[2]=d):d=t[2];let f=d,p=f?c:c.slice(0,3),m;t[3]!==s||t[4]!==p?(m=(0,R.jsx)(`ul`,{id:s,className:`space-y-1.5`,children:p}),t[3]=s,t[4]=p,t[5]=m):m=t[5];let h;t[6]!==r||t[7]!==f||t[8]!==s||t[9]!==c.length||t[10]!==i||t[11]!==u?(h=c.length>3?(0,R.jsx)(`button`,{type:`button`,"aria-expanded":f,"aria-controls":s,className:`mt-2 min-h-9 rounded-sm text-xs font-medium text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,onClick:()=>u(e=>{let t=new URLSearchParams(e),n=t.getAll(`taskExpanded`).filter(e=>e!==r);return t.delete(`taskExpanded`),n.forEach(e=>t.append(`taskExpanded`,e)),f||t.append(`taskExpanded`,r),t},{preventScrollReset:!0}),children:i===`zh`?f?`收起`:`查看全部(${c.length})`:f?`Show less`:`Show all (${c.length})`}):null,t[6]=r,t[7]=f,t[8]=s,t[9]=c.length,t[10]=i,t[11]=u,t[12]=h):h=t[12];let g;return t[13]!==o||t[14]!==m||t[15]!==h?(g=(0,R.jsxs)(`div`,{className:o,children:[m,h]}),t[13]=o,t[14]=m,t[15]=h,t[16]=g):g=t[16],g}function Ue(e,t){let n;try{n=new URL(e)}catch{return}return t.find(e=>[e.shareUrl,e.lanUrl].some(e=>{if(!e)return!1;try{let t=new URL(e);return t.origin===n.origin&&t.pathname.replace(/\/$/,``)===n.pathname.replace(/\/$/,``)}catch{return!1}}))}function B({uri:e,zh:t}){let[n,r]=(0,z.useState)(),[i,a]=(0,z.useState)(!1),[o,c]=(0,z.useState)(!1),[l,u]=(0,z.useState)(``),[d,f]=(0,z.useState)(``);async function p(){a(!0),u(``);try{let n=Ue(e,(await T()).payload.shares);r(n),c(!0),n?n.kind!==`file`&&n.kind!==`directory`?u(t?`这是文档快照,请从原笔记或对话的分享面板重新发布。`:`This is a document snapshot. Republish it from the original note or conversation.`):n.revoked?u(t?`分享已被撤销,不能自动恢复。请从原任务重新生成并分享。`:`This share was revoked. Generate and share a new artifact from the task.`):n.maxViews!==null&&n.downloadCount>=n.maxViews?u(t?`已达到访问次数上限,请在分享设置中调整后重试。`:`The access limit was reached. Adjust it in share settings.`):n.expired||(f(n.shareUrl),u(t?`链接仍在有效期内;若打不开,请检查网关连接。`:`The link has not expired. If it cannot open, check gateway connectivity.`)):u(t?`未找到本机管理的分享记录。外部链接或已清理的记录无法在这里续期,请从原任务重新生成产物。`:`No locally managed share matches this link. Regenerate the artifact from its task.`)}catch{u(t?`检查失败,请重试。`:`Check failed. Please retry.`)}finally{a(!1)}}async function m(){if(!(!n||i)){a(!0),u(``);try{let e=await P(n.id,864e5);f(e.payload.shareUrl),r({...n,expired:!1,expiresAt:e.payload.expiresAt}),u(t?`已续期 24 小时,访问范围与次数限制保持不变。`:`Renewed for 24 hours. Access scope and view limits are unchanged.`)}catch(e){u(`${t?`恢复失败:`:`Recovery failed: `}${e instanceof Error?e.message:String(e)}`)}finally{a(!1)}}}return(0,R.jsxs)(`details`,{className:`mt-2 text-xs text-fg-muted`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t?`链接打不开?`:`Trouble opening the link?`}),(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(O,{type:`button`,variant:`ghost`,disabled:i,onClick:()=>void p(),children:t?`检查链接状态`:`Check link`}),o&&n?.expired&&(n.kind===`file`||n.kind===`directory`)&&!n.revoked&&(n.maxViews===null||n.downloadCount<n.maxViews)&&(0,R.jsx)(O,{type:`button`,disabled:i,onClick:()=>void m(),children:t?`恢复链接 · 续期 24 小时`:`Restore link for 24 hours`}),l&&(0,R.jsx)(`p`,{role:`status`,className:`break-words leading-5`,children:l}),d&&(0,R.jsx)(`a`,{className:`block py-2 text-accent`,href:d,target:`_blank`,rel:`noopener noreferrer`,children:t?`打开产物`:`Open artifact`}),o&&(0,R.jsx)(s,{className:`block py-2 text-accent`,to:`/settings/shares`,children:t?`管理分享记录`:`Manage shares`})]})]})}function We(e){let t=(0,L.c)(14),{evidence:n,projectId:r,conversationId:i,language:a}=e,o=we(Ge);if(!n.length)return null;let s=a===`zh`?`交付物与验证依据`:`Deliverables and evidence`,c;if(t[0]!==i||t[1]!==n||t[2]!==a||t[3]!==r||t[4]!==o){let e;t[6]!==i||t[7]!==a||t[8]!==r||t[9]!==o?(e=(e,t)=>{let n=e.uri?.trim(),s=n&&/^https?:\/\//i.test(n),c=n&&!s&&e.kind===`artifact`&&!/^[a-z][a-z0-9+.-]*:/i.test(n)&&!n.startsWith(`//`),l=e.title||(a===`zh`?`查看产物`:`Open artifact`);return(0,R.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge-subtle p-3`,children:[(0,R.jsx)(I,{content:l,contentKey:`${i??r}:evidence-title:${t}:${e.title}`,language:a,previewHeight:60,children:s?(0,R.jsxs)(`a`,{className:`inline-flex min-h-11 items-center gap-2 text-sm font-medium text-accent hover:underline [overflow-wrap:anywhere]`,href:n,target:`_blank`,rel:`noopener noreferrer`,children:[(0,R.jsx)(u,{className:`size-4 shrink-0`}),(0,R.jsx)(`span`,{className:`min-w-0 break-words`,children:l})]}):c&&(r||i)?(0,R.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-11 items-center gap-2 text-sm font-medium text-accent hover:underline [overflow-wrap:anywhere]`,onClick:()=>o(n,null,r,i),children:[(0,R.jsx)(j,{className:`size-4 shrink-0`}),l]}):(0,R.jsx)(`p`,{className:`break-words [overflow-wrap:anywhere] text-sm font-medium text-fg`,children:l})}),s&&e.kind===`artifact`&&(0,R.jsx)(B,{uri:n,zh:a===`zh`},n),e.summary?(0,R.jsx)(I,{content:e.summary,contentKey:`${i??r}:evidence:${t}:${e.title}`,language:a,markdown:!1,previewHeight:80,className:`mt-1 text-xs leading-5 text-fg-muted`}):null,(0,R.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:e.provenance===`judge`?e.strength===`verified`?a===`zh`?`模型审阅通过`:`Model reviewed`:a===`zh`?`模型未确认,待核验`:`Not confirmed by review`:e.strength===`verified`?a===`zh`?`已验证`:`Verified`:a===`zh`?`已记录,待验证`:`Observed, not verified`})]},`${e.title}-${t}`)},t[6]=i,t[7]=a,t[8]=r,t[9]=o,t[10]=e):e=t[10],c=n.map(e),t[0]=i,t[1]=n,t[2]=a,t[3]=r,t[4]=o,t[5]=c}else c=t[5];let l;return t[11]!==s||t[12]!==c?(l=(0,R.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,"aria-label":s,children:c}),t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function Ge(e){return e.setPath}function Ke({taskId:e}){let t=ee(e=>e.conversationId),n=te(e=>e.language),[r,i]=(0,z.useState)(``),[a,o]=(0,z.useState)(null),[s,c]=(0,z.useState)(!1),[l,u]=(0,z.useState)(!1),[d,f]=(0,z.useState)([]),[p,m]=(0,z.useState)(null),h=ne(`/api/tasks/${encodeURIComponent(e)}/collaboration`),{data:g,error:_,mutate:y}=S([`task-collaboration`,e,t],()=>v(`${h}?recent=1`),{revalidateOnFocus:!0}),b=[...new Map([...d,...g?.items??[]].map(e=>[e.id,e])).values()].sort((e,t)=>e.sequence-t.sequence),re=async()=>{let e=b[0];if(!(!e||l)){u(!0);try{let t=await v(`${h}?recent=1&beforeSequence=${e.sequence}`);f(e=>[...t.items,...e])}catch(e){m(e instanceof Error?e.message:String(e))}finally{u(!1)}}};(0,z.useEffect)(()=>{let t=t=>{let n=t.detail;(!n?.taskId||n.taskId===e)&&y()};return window.addEventListener(`task-collaboration-entry-added`,t),window.addEventListener(`gateway-realtime-connected`,t),()=>{window.removeEventListener(`task-collaboration-entry-added`,t),window.removeEventListener(`gateway-realtime-connected`,t)}},[y,e]);let ie=async()=>{if(!(!r.trim()||s)){c(!0),m(null);try{await v(h,{method:`POST`,headers:{"idempotency-key":crypto.randomUUID()},body:JSON.stringify({kind:a?`answer`:`instruction`,body:r.trim(),...a?{causationId:a}:{}})}),i(``),o(null),await y()}catch(e){m(e instanceof Error?e.message:String(e))}finally{c(!1)}}};return(0,R.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n===`zh`?`任务留言`:`Task updates`}),(0,R.jsxs)(`div`,{className:`mt-3 max-h-64 space-y-2 overflow-y-auto`,children:[!g&&!_?(0,R.jsxs)(`div`,{"aria-busy":`true`,className:`space-y-2`,children:[(0,R.jsx)(M,{className:`h-14 w-full`}),(0,R.jsx)(M,{className:`h-14 w-4/5`})]}):null,_?(0,R.jsx)(`p`,{role:`status`,className:`text-xs text-fg-muted`,children:n===`zh`?`暂时无法读取留言`:`Updates unavailable`}):null,b[0]&&b[0].sequence>1?(0,R.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>void re(),className:`text-xs text-accent hover:underline disabled:opacity-50`,children:n===`zh`?`查看更早留言`:`Earlier updates`}):null,b.map(t=>(0,R.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 text-sm`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-subtle`,children:[(0,R.jsx)(`span`,{children:t.authorKind===`worker_agent`?n===`zh`?`执行 Agent`:`Worker`:t.authorKind===`main_agent`?n===`zh`?`主 Agent`:`Main Agent`:t.authorKind===`system`?n===`zh`?`系统`:`System`:n===`zh`?`用户`:`You`}),(0,R.jsxs)(`span`,{children:[`· `,t.kind]}),t.deliveryStatus?(0,R.jsxs)(`span`,{children:[`· `,t.deliveryStatus]}):null]}),(0,R.jsx)(`div`,{className:`mt-1 min-w-0 text-fg`,"data-task-collaboration-body":!0,children:(0,R.jsx)(I,{content:t.body,contentKey:`${e}:update:${t.id}`,language:n,breaks:!0,previewHeight:120})}),t.kind===`question`&&t.authorKind===`worker_agent`?(0,R.jsx)(`button`,{type:`button`,className:`mt-2 text-xs text-accent hover:underline`,onClick:()=>o(t.id),children:n===`zh`?`回复问题`:`Reply`}):null]},t.id)),g&&!b.length?(0,R.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n===`zh`?`暂无进展留言`:`No updates yet`}):null]}),a?(0,R.jsxs)(`p`,{className:`mt-3 text-xs text-accent`,children:[n===`zh`?`正在回复执行 Agent 的问题`:`Replying to the worker`,(0,R.jsx)(`button`,{type:`button`,className:`ml-2 underline`,onClick:()=>o(null),children:n===`zh`?`取消`:`Cancel`})]}):null,(0,R.jsx)(`textarea`,{value:r,onChange:e=>i(e.target.value),rows:2,"aria-label":n===`zh`?`任务留言`:`Task message`,placeholder:n===`zh`?`给执行 Agent 留言`:`Message the worker`,className:`mt-3 w-full resize-y rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`}),p?(0,R.jsx)(`p`,{role:`alert`,className:`mt-1 text-xs text-danger`,children:p}):null,(0,R.jsx)(`button`,{type:`button`,disabled:!r.trim()||s,onClick:()=>void ie(),className:`mt-2 rounded-lg bg-accent px-3 py-2 text-xs font-medium text-white disabled:opacity-50`,children:s?n===`zh`?`发送中`:`Sending`:n===`zh`?`发送`:`Send`})]})}function qe(e,t,n,r){return!!(e&&t!==e.version&&n!==e.value&&r!==n)}function Je(e,t){let n={...e.task};t.title!==void 0&&(n.title=t.title),t.priority!==void 0&&(n.priority=t.priority);for(let e of[`body`,`projectId`,`milestoneId`,`parentTaskId`,`dueAt`,`ownerId`]){let r=t[e];r!==void 0&&(r===null?delete n[e]:Object.assign(n,{[e]:r}))}return n.version+=1,n.updatedAt=Date.now(),{...e,task:n}}function Ye(e,t){return(t===`zh`?{backlog:`待规划`,ready:`就绪`,active:`进行中`,review:`待验收`,closed:`已关闭`}:{backlog:`Backlog`,ready:`Ready`,active:`Active`,review:`Review`,closed:`Closed`})[e]}function Xe(){let e=(0,L.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,R.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[(0,R.jsx)(M,{className:`h-32 rounded-2xl`}),(0,R.jsx)(M,{className:`h-52 rounded-2xl`}),(0,R.jsx)(M,{className:`h-40 rounded-2xl`})]}),e[0]=t):t=e[0],t}function Ze(e){if(e===void 0)return``;let t=new Date(e);return new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,10)}function Qe(e){return e?new Date(`${e}T23:59:59.999`).getTime():null}var $e=[`backlog`,`ready`,`active`,`review`,`closed`],et=[`low`,`normal`,`high`,`critical`],tt=(0,z.memo)(function(e){let t=(0,L.c)(20),{value:n,disabled:r,canMove:i,canApprove:a,canReopen:o,language:s,label:c,onChange:l}=e,u;t[0]!==a||t[1]!==i||t[2]!==o||t[3]!==n?(u=e=>e!==n&&!i&&!(e===`closed`?a:n===`closed`&&o),t[0]=a,t[1]=i,t[2]=o,t[3]=n,t[4]=u):u=t[4];let d=u,f;t[5]===c?f=t[6]:(f=(0,R.jsx)(`span`,{children:c}),t[5]=c,t[6]=f);let p;t[7]===l?p=t[8]:(p=e=>l(e.target.value),t[7]=l,t[8]=p);let m;t[9]!==s||t[10]!==d?(m=$e.map(e=>(0,R.jsx)(ve,{value:e,disabled:d(e),children:Ye(e,s)},e)),t[9]=s,t[10]=d,t[11]=m):m=t[11];let h;t[12]!==r||t[13]!==p||t[14]!==m||t[15]!==n?(h=(0,R.jsx)(N,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:p,children:m}),t[12]=r,t[13]=p,t[14]=m,t[15]=n,t[16]=h):h=t[16];let g;return t[17]!==f||t[18]!==h?(g=(0,R.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[f,h]}),t[17]=f,t[18]=h,t[19]=g):g=t[19],g}),nt=(0,z.memo)(function(e){let t=(0,L.c)(14),{value:n,disabled:r,label:i,labels:a,onChange:o}=e,s;t[0]===i?s=t[1]:(s=(0,R.jsx)(`span`,{children:i}),t[0]=i,t[1]=s);let c;t[2]===o?c=t[3]:(c=e=>o(e.target.value),t[2]=o,t[3]=c);let l;t[4]===a?l=t[5]:(l=et.map(e=>(0,R.jsx)(ve,{value:e,children:a[e]},e)),t[4]=a,t[5]=l);let u;t[6]!==r||t[7]!==c||t[8]!==l||t[9]!==n?(u=(0,R.jsx)(N,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:c,children:l}),t[6]=r,t[7]=c,t[8]=l,t[9]=n,t[10]=u):u=t[10];let d;return t[11]!==s||t[12]!==u?(d=(0,R.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[s,u]}),t[11]=s,t[12]=u,t[13]=d):d=t[13],d}),rt=(0,z.memo)(function(e){let t=(0,L.c)(10),{value:n,disabled:r,label:i,onChange:a}=e,o;t[0]===i?o=t[1]:(o=(0,R.jsx)(`span`,{children:i}),t[0]=i,t[1]=o);let s;t[2]!==r||t[3]!==i||t[4]!==a||t[5]!==n?(s=(0,R.jsx)(F,{disabled:r,value:n,onChange:a,ariaLabel:i}),t[2]=r,t[3]=i,t[4]=a,t[5]=n,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,R.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}),it=(0,z.memo)(function(e){let t=(0,L.c)(17),{value:n,disabled:r,label:i,unassignedLabel:a,agents:o,onChange:s}=e,c;t[0]===i?c=t[1]:(c=(0,R.jsx)(`span`,{children:i}),t[0]=i,t[1]=c);let l;t[2]===s?l=t[3]:(l=e=>s(e.target.value),t[2]=s,t[3]=l);let u;t[4]===a?u=t[5]:(u=(0,R.jsx)(ve,{value:``,disabled:!0,children:a}),t[4]=a,t[5]=u);let d;t[6]===o?d=t[7]:(d=o.map(bt),t[6]=o,t[7]=d);let f;t[8]!==r||t[9]!==l||t[10]!==u||t[11]!==d||t[12]!==n?(f=(0,R.jsxs)(N,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:l,children:[u,d]}),t[8]=r,t[9]=l,t[10]=u,t[11]=d,t[12]=n,t[13]=f):f=t[13];let p;return t[14]!==c||t[15]!==f?(p=(0,R.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[c,f]}),t[14]=c,t[15]=f,t[16]=p):p=t[16],p}),at=(0,z.memo)(function(e){let t=(0,L.c)(9),{candidates:n,selected:r,disabled:i,labels:a,getTaskHref:o,onChange:s}=e,c;t[0]===r?c=t[1]:(c=r.map(xt),t[0]=r,t[1]=c);let l;return t[2]!==n||t[3]!==i||t[4]!==o||t[5]!==a||t[6]!==s||t[7]!==c?(l=(0,R.jsx)(ze,{borderless:!0,candidates:n,selectedIds:c,disabled:i,getTaskHref:o,onChange:s,labels:a}),t[2]=n,t[3]=i,t[4]=o,t[5]=a,t[6]=s,t[7]=c,t[8]=l):l=t[8],l},(e,t)=>e.disabled===t.disabled&&e.labels===t.labels&&e.getTaskHref===t.getTaskHref&&e.onChange===t.onChange&&e.candidates.length===t.candidates.length&&e.candidates.every((e,n)=>e.id===t.candidates[n]?.id&&e.title===t.candidates[n]?.title)&&e.selected.length===t.selected.length&&e.selected.every((e,n)=>e.id===t.selected[n]?.id&&e.title===t.selected[n]?.title)),ot=`xopc.taskDetail.chatPanelPercent`,st=42;function ct(e,t){let n=Math.max(30,352/Math.max(t,1)*100),r=Math.min(60,(t-480)/Math.max(t,1)*100);return r<n?st:Math.min(r,Math.max(n,e))}function lt(){try{let e=Number(window.localStorage.getItem(ot));return Number.isFinite(e)&&e>=30&&e<=60?e:st}catch{return st}}function ut(e){return e.task.phase===`closed`?e.task.resolution===`done`?`completed`:`ended`:e.waits.some(e=>e.kind===`paused`)?`paused`:e.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`)?`needsUser`:e.operationalState===`idle`?e.task.phase===`backlog`?`captured`:e.task.phase===`ready`?`ready`:e.task.phase===`review`?`review`:`ready`:e.operationalState}function dt(e){return e===`failed`?`bg-danger/10 text-danger`:e===`needsUser`||e===`blocked`?`bg-warning/10 text-warning`:e===`completed`?`bg-success-soft text-success`:e===`running`||e===`verifying`||e===`review`?`bg-accent-soft text-accent-fg`:`bg-surface-hover text-fg-muted`}function ft(e){let t=(0,L.c)(13),{items:n,empty:r,contentKey:i}=e,a=te(mt);if(n.length===0){let e;return t[0]===r?e=t[1]:(e=(0,R.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:r}),t[0]=r,t[1]=e),e}let o;t[2]===n?o=t[3]:(o=n.join(`
|
|
2
|
+
`),t[2]=n,t[3]=o);let s;t[4]===n?s=t[5]:(s=n.map(pt),t[4]=n,t[5]=s);let c;t[6]===s?c=t[7]:(c=(0,R.jsx)(`ul`,{className:`space-y-2`,children:s}),t[6]=s,t[7]=c);let l;return t[8]!==i||t[9]!==a||t[10]!==o||t[11]!==c?(l=(0,R.jsx)(I,{content:o,contentKey:i,language:a,previewHeight:144,children:c}),t[8]=i,t[9]=a,t[10]=o,t[11]=c,t[12]=l):l=t[12],l}function pt(e){return(0,R.jsxs)(`li`,{className:`flex gap-2 text-sm leading-6 text-fg`,children:[(0,R.jsx)(De,{className:`mt-1 size-4 shrink-0 text-fg-subtle`}),(0,R.jsx)(`span`,{className:`min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:e})]},e)}function mt(e){return e.language}function ht({taskId:e,presentation:t,backgroundPath:n,onDeleted:r}){let[o]=a(),g=i(),v=te(e=>e.language),ne=ee(e=>e.conversationId),y=(0,z.useMemo)(()=>ye(v),[v]),b=D(e=>e.setPageHeader),re=D(e=>e.clearPageHeader),ie=ce(e=>e.panes),ae=Pe(e=>e.openForSession),{data:x,error:T,mutate:j,lastChange:le,conversationLoading:M,conversationError:N}=ke(e),{data:ve}=S(e?`task-detail-automations`:null,()=>Ce.list()),[we,P]=(0,z.useState)(null),[F,ze]=(0,z.useState)(()=>new Set),[L,Ue]=(0,z.useState)([]),[B,Ge]=(0,z.useState)(null),[Ye,$e]=(0,z.useState)([]),[et,pt]=(0,z.useState)(!1),[mt,ht]=(0,z.useState)(``),[gt,V]=(0,z.useState)(!1),[_t,vt]=(0,z.useState)(``),[H,yt]=(0,z.useState)(lt),[bt,xt]=(0,z.useState)(!1),St=(0,z.useRef)(null),Ct=(0,z.useRef)(!1),wt=(0,z.useRef)(!1),Tt=(0,z.useRef)(``),Et=(0,z.useRef)(null),Dt=(0,z.useRef)(null),Ot=(0,z.useRef)(null),U=(0,z.useRef)(x),[kt,W]=(0,z.useState)(null),[At,jt]=(0,z.useState)(null),[Mt,Nt]=(0,z.useState)(!1),Pt=(0,z.useMemo)(()=>({link:y.linkDependencies,linked:y.linkedDependencies,searchPlaceholder:y.dependencySearchPlaceholder,noMatches:y.noDependencyMatches,noCandidates:y.noDependencyCandidates,remove:y.removeDependency}),[y.dependencySearchPlaceholder,y.linkDependencies,y.linkedDependencies,y.noDependencyCandidates,y.noDependencyMatches,y.removeDependency]),Ft=x?.dependencies.map(e=>`${e.id}:${e.title}`).join(`\0`)??``,It=(0,z.useMemo)(()=>m(o.get(`returnTo`),`/`,[`/projects`,`/chat`,`/notes`,`/tasks`]),[o]),Lt=(0,z.useCallback)(e=>t===`modal`&&n?d(n,e):p(`/tasks/${encodeURIComponent(e)}`,It),[n,t,It]);U.current=x;let G=(0,z.useCallback)((e,t)=>{ze(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]);(0,z.useEffect)(()=>{P(null),W(null),pt(!1),Et.current=null,V(!1),jt(null),Nt(!1)},[e]),(0,z.useEffect)(()=>{let e=!0;return Me().then(t=>{e&&$e(t.items)}).catch(()=>void 0),()=>{e=!1}},[ne]),(0,z.useEffect)(()=>{if(!le||le.source===`user`)return;jt(le);let e=window.setTimeout(()=>jt(null),3500);return()=>window.clearTimeout(e)},[le]),(0,z.useEffect)(()=>{let t=x?.task.projectId,n=x?.dependencies??[];if(!t){Ot.current=null,Ge(null),Ue(n);return}Ot.current!==t&&(Ot.current=t,Ge(null));let r=!0;return me(t).then(t=>{if(!r)return;Ge(t.project.name);let i=new Map;for(let r of[...t.tasks,...n])r.id!==e&&i.set(r.id,{id:r.id,title:r.title});Ue([...i.values()])}).catch(()=>{r&&Ue(n)}),()=>{r=!1}},[Ft,x?.task.projectId,e]);let K=(0,z.useCallback)(async(t,n=`command`)=>{let r=U.current;if(r){G(n,!0),P(null);try{await j(await fe(e,t,r.task.version),{revalidate:!1})}catch{P(y.actionFailed)}finally{G(n,!1)}}},[y.actionFailed,j,G,e]),q=(0,z.useCallback)(async(t,n)=>{let r=U.current;if(!r)return!1;n&&G(n,!0),P(null);try{return await j(_e(e,t,r.task.version),{optimisticData:Je(r,t),populateCache:!0,revalidate:!1,rollbackOnError:!0}),!0}catch{return P(y.actionFailed),!1}finally{n&&G(n,!1)}},[y.actionFailed,j,G,e]),Rt=()=>{x&&(Et.current={value:x.task.title,version:x.task.version},W(null),ht(x.task.title),pt(!0))},zt=()=>{Ct.current=!0,ht(U.current?.task.title??``),Et.current=null,W(null),pt(!1),queueMicrotask(()=>{Ct.current=!1})},Bt=async(e=!1)=>{if(Ct.current){Ct.current=!1;return}let t=U.current;if(!t||F.has(`title`))return;let n=mt.trim();if(!n){zt();return}let r=Et.current;if(!e&&qe(r,t.task.version,t.task.title,n)){W(`title`);return}if(n===t.task.title){zt();return}await q({title:n},`title`)&&(Et.current=null,W(null),pt(!1))},Vt=async()=>{if(!x)return;if(wt.current){wt.current=!1;return}let e=_t.trim(),t=Dt.current;if(qe(t,x.task.version,x.task.body??``,e)){W(`description`);return}if(_t===Tt.current||e===(x.task.body??``).trim()){V(!1);return}await q({body:e||null})&&(W(null),V(!1))},Ht=(0,z.useCallback)(async e=>{let t=U.current;!t||e===t.task.phase||await K({type:`move`,phase:e},`phase`)},[K]),Ut=(0,z.useCallback)(e=>{q({priority:e},`priority`)},[q]),Wt=(0,z.useCallback)(e=>{q({dueAt:Qe(e)},`dueAt`)},[q]),Gt=(0,z.useCallback)(e=>{yt(e);try{window.localStorage.setItem(ot,String(e))}catch{}},[]),Kt=(0,z.useCallback)(e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`&&e.key!==`Home`)return;e.preventDefault();let t=St.current?.clientWidth??0;Gt(ct(e.key===`Home`?st:H+(e.key===`ArrowLeft`?2:-2),t))},[H,Gt]),qt=(0,z.useCallback)(e=>{if(!window.matchMedia(`(min-width: 1024px)`).matches)return;let t=St.current;if(!t)return;e.preventDefault();let n=e.currentTarget,r=e.pointerId;n.setPointerCapture(r),xt(!0);let i=H,a=0,o=()=>{a=0,t.style.setProperty(`--task-chat-panel-width`,`${i}%`)},s=e=>{let n=t.getBoundingClientRect();i=ct((n.right-e.clientX)/n.width*100,n.width),a===0&&(a=window.requestAnimationFrame(o))},c=()=>{a!==0&&(window.cancelAnimationFrame(a),o());try{n.releasePointerCapture(r)}catch{}xt(!1),Gt(i),window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c)};window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,c)},[H,Gt]),Jt=(0,z.useCallback)(async t=>{let n=U.current;if(n){G(`dependencies`,!0),P(null);try{await j(await Te(e,t,n.task.version),{revalidate:!1})}catch{P(y.dependencyUpdateFailed)}finally{G(`dependencies`,!1)}}},[y.dependencyUpdateFailed,j,G,e]),Yt=(0,z.useCallback)(async t=>{let n=U.current;if(!(!n||!t||t===n.conversation.currentExecutorAgentId)){G(`delegateAgentId`,!0),P(null);try{await j(await xe(e,t,n.task.version),{revalidate:!1})}catch{P(y.actionFailed)}finally{G(`delegateAgentId`,!1)}}},[y.actionFailed,j,G,e]),Xt=(0,z.useCallback)(async()=>{G(`delete`,!0),P(null);try{await oe(e),r?r():g(It,{replace:!0})}catch(e){P(e instanceof Error?e.message:y.actionFailed)}finally{G(`delete`,!1)}},[y.actionFailed,g,r,It,G,e]),Zt=(0,z.useCallback)(async(t,n)=>{let r=U.current;if(r){G(`acceptance`,!0),P(null);try{await j(await he(e,t,n,r.task.version,r.task.latestContractVersion),{revalidate:!1})}catch{P(y.actionFailed),await j()}finally{G(`acceptance`,!1)}}},[y.actionFailed,j,G,e]);if((0,z.useLayoutEffect)(()=>{if(t!==`modal`)return b({startExtra:(0,R.jsx)(s,{to:It,className:`flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":y.backToWork,children:(0,R.jsx)(se,{className:`size-4`})}),main:x?(0,R.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:B?`${B} / ${y.taskLabel}`:y.taskLabel}):null,end:null}),re},[re,y.backToWork,y.taskLabel,x,t,B,It,b]),T&&!x)return(0,R.jsx)(`div`,{className:t===`modal`?`p-5 text-sm text-danger`:`mx-auto max-w-3xl p-6 text-sm text-danger`,children:y.taskNotFound});if(!x)return(0,R.jsx)(`div`,{className:t===`modal`?`p-5`:`mx-auto max-w-4xl p-4 sm:p-6`,children:(0,R.jsx)(Xe,{})});let Qt=x.waits[0],J=Le(x),$t=J.length>0&&J.every(e=>e.status===`passed`),en=x.waits.find(e=>e.kind===`paused`),Y=x.receipts[0],tn=ut(x),nn=y.detailStatuses[tn],rn=x.task.body?.trim()||x.task.contract?.objective.trim(),an=x.allowedCommands.includes(`mark_ready`),on=x.allowedCommands.includes(`start`),sn=x.allowedCommands.includes(`add_wait`),cn=!Qt&&$t&&x.task.phase===`review`&&x.allowedCommands.includes(`close`),ln=x.allowedCommands.includes(`reopen`),X=x.conversation.activeConversationId,un=x.conversation.currentExecutorAgentId??x.task.delegateAgentId??x.task.ownerId,dn=Ye.find(e=>e.id===un),fn=!!(X&&ie[X]?.open),pn=x.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`),mn=J.filter(e=>e.status===`passed`).length,hn=x.context.filter(e=>e.role===`deliverable`),gn=new Set(x.runs.filter(e=>e.contractVersion===x.task.latestContractVersion).map(e=>e.id)),_n=[...new Map(x.receipts.filter(e=>gn.has(e.runId)).flatMap(e=>e.evidence.filter(e=>e.kind===`artifact`)).map(e=>[e.uri??e.title,e])).values()],vn=x.context.filter(e=>e.role!==`deliverable`),yn=x.runs.filter(e=>e.executorKind===`workflow`&&!e.parentRunId),bn=[...new Set(yn.map(e=>e.executorRef.workflowId).filter(e=>typeof e==`string`))],xn=ve?.automations.filter(t=>t.action.kind===`task_command`&&t.action.taskId===e)??[],Z=x.sessions.filter((e,t,n)=>n.findIndex(t=>t.conversationId===e.conversationId)===t),Sn=x.task.contract?.expectedOutputs??[],Cn=x.task.contract?.constraints??[],wn=x.task.contract?.approvalRequired??[],Tn=x.task.contract?.assumptions??[],En=x.task.contract?.risks??[],Dn=Cn.length>0||wn.length>0||Tn.length>0||En.length>0,Q=(...e)=>!!At?.changedFields.some(t=>e.includes(t)),On=x.allowedCommands.includes(`move`),$=F.has(`command`),kn=F.has(`delete`),An=x.runs.find(e=>!e.parentRunId&&[`queued`,`running`,`waiting`,`verifying`].includes(e.status)),jn=An!==void 0,Mn=`/automations?action=create&taskId=${encodeURIComponent(x.task.id)}${x.task.projectId?`&projectId=${encodeURIComponent(x.task.projectId)}`:``}`,Nn=(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[an?(0,R.jsxs)(O,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`primary`,disabled:$,onClick:()=>void K({type:`mark_ready`}),children:[(0,R.jsx)(Ie,{className:`size-4`}),y.scheduleTask]}):null,en&&x.allowedCommands.includes(`resolve_wait`)?(0,R.jsxs)(O,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`primary`,disabled:$,onClick:()=>void K({type:`resolve_wait`,waitId:en.id}),children:[(0,R.jsx)(Ie,{className:`size-4`}),y.resumeTask]}):null,!Qt&&on&&un?(0,R.jsxs)(O,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`primary`,disabled:$,onClick:()=>void K({type:`start`,executor:{kind:`agent`,agentId:un}}),children:[(0,R.jsx)(Ie,{className:`size-4`}),y.runTask]}):null,cn?(0,R.jsxs)(O,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`primary`,disabled:$,onClick:()=>void K({type:`close`,resolution:`done`}),children:[(0,R.jsx)(c,{className:`size-4`}),y.approveTask]}):null,ln?(0,R.jsxs)(O,{className:`min-h-9 px-3 py-1.5 text-xs`,variant:`primary`,disabled:$,onClick:()=>void K({type:`reopen`,phase:`ready`}),children:[(0,R.jsx)(Ie,{className:`size-4`}),y.reopenTask]}):null,!en&&sn?(0,R.jsxs)(O,{variant:`ghost`,className:`min-h-9 px-3 py-1.5 text-xs`,disabled:$,onClick:()=>void K({type:`add_wait`,wait:{kind:`paused`,reason:`Paused by user`,condition:{}}}),children:[(0,R.jsx)(E,{className:`size-4`}),y.pauseTask]}):null,x.task.phase===`closed`?null:(0,R.jsx)(O,{asChild:!0,variant:`ghost`,className:`min-h-9 px-3 py-1.5 text-xs`,children:(0,R.jsxs)(s,{to:Mn,children:[(0,R.jsx)(be,{className:`size-4`}),y.scheduleRecurringTask]})}),(0,R.jsxs)(je,{children:[(0,R.jsx)(pe,{asChild:!0,children:(0,R.jsx)(O,{type:`button`,variant:`ghost`,className:`size-9 p-0`,disabled:$||kn,"aria-label":y.moreActions,children:(0,R.jsx)(l,{className:`size-4`,"aria-hidden":!0})})}),(0,R.jsx)(Oe,{children:(0,R.jsxs)(ge,{align:`end`,sideOffset:6,className:`z-[100] min-w-44 rounded-lg border border-edge bg-surface-overlay p-1 shadow-popover`,children:[An?(0,R.jsx)(Ne,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>{G(`command`,!0),P(null),j(ue(e,An.id,An.version),{revalidate:!1}).catch(()=>P(y.actionFailed)).finally(()=>G(`command`,!1))},children:y.cancelActiveRun}):null,An?(0,R.jsx)(Se,{className:`my-1 h-px bg-edge`}):null,x.task.phase===`closed`?null:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Ne,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>void K({type:`close`,resolution:`cancelled`}),children:y.cancelTask}),(0,R.jsx)(Se,{className:`my-1 h-px bg-edge`})]}),(0,R.jsx)(Ne,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>{if(jn){P(y.deleteActiveTaskBlocked);return}Nt(!0)},children:y.deleteTask})]})})]})]});return(0,R.jsxs)(`div`,{ref:St,className:`flex h-full min-h-0 flex-col overflow-hidden ${bt?`lg:cursor-col-resize lg:select-none`:``}`,style:{"--task-chat-panel-width":`${H}%`},children:[(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto lg:flex-row lg:overflow-hidden`,children:[(0,R.jsxs)(`div`,{className:`task-detail-scroll flex min-w-0 shrink-0 flex-col lg:min-h-0 lg:flex-1 lg:shrink lg:overflow-y-auto lg:overscroll-contain`,children:[(0,R.jsxs)(`header`,{className:_(`shrink-0 border-b border-edge-subtle bg-surface-panel px-5 py-4 sm:px-6`,Q(`title`)&&`task-detail-live-update`),children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-x-6 gap-y-3`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[B?(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,R.jsx)(C,{className:`size-3.5`,"aria-hidden":!0}),B]}):null,B?(0,R.jsx)(`span`,{"aria-hidden":`true`,children:`/`}):null,(0,R.jsx)(`span`,{children:y.taskLabel}),At?(0,R.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,role:`status`,children:At.source===`agent`?v===`zh`?`Agent 刚刚更新`:`Updated by Agent`:v===`zh`?`执行结果已同步`:`Execution result synced`}):null]}),et?(0,R.jsx)(`textarea`,{autoFocus:!0,"data-task-inline-editor":!0,"aria-label":v===`zh`?`任务标题`:`Task title`,rows:2,value:mt,onFocus:e=>{Et.current?.value===mt&&(e.currentTarget.setSelectionRange(0,0),e.currentTarget.scrollTop=0)},onChange:e=>ht(e.target.value),onBlur:()=>void Bt(),onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),zt()):e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.currentTarget.blur()))},className:`mt-2 block max-h-56 min-h-14 w-full max-w-3xl resize-none overflow-y-auto bg-transparent p-0 text-xl font-semibold leading-7 text-fg outline-none [field-sizing:content]`}):(0,R.jsx)(I,{content:x.task.title,contentKey:`${e}:title`,language:v,previewHeight:56,className:`mt-2 max-w-3xl`,children:(0,R.jsx)(`h1`,{className:`break-words text-xl font-semibold leading-7 text-fg`,children:(0,R.jsx)(`button`,{type:`button`,className:`max-w-full whitespace-pre-wrap break-words [overflow-wrap:anywhere] rounded-sm text-left outline-none hover:bg-surface-hover/60 focus-visible:ring-2 focus-visible:ring-accent/40`,title:x.task.title,onClick:Rt,children:x.task.title})})}),kt===`title`?(0,R.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,R.jsx)(`span`,{children:v===`zh`?`Agent 在你编辑期间更新了标题。`:`The Agent updated the title while you were editing.`}),(0,R.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:zt,children:v===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,R.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,disabled:F.has(`title`),onClick:()=>void Bt(!0),children:v===`zh`?`保留我的修改`:`Keep my changes`})]}):null]}),(0,R.jsx)(`span`,{className:_(`shrink-0 rounded-full px-2.5 py-1 text-xs font-medium`,dt(tn)),children:nn})]}),(0,R.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-fg-muted`,children:[(0,R.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[un?(0,R.jsx)(A,{agentId:un,avatar:dn?.avatar,size:20,className:`shrink-0`}):null,(0,R.jsxs)(`span`,{className:`min-w-0 break-words [overflow-wrap:anywhere]`,children:[y.executorLabel,` · `,dn?.name??un??y.unassigned]})]}),(0,R.jsx)(`span`,{className:`text-fg-subtle`,children:y.updatedAt.replace(`{{date}}`,k(x.task.updatedAt,v))})]}),(0,R.jsx)(`div`,{className:`mt-4 border-t border-edge-subtle pt-3`,children:Nn}),we?(0,R.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:we}):null]}),(0,R.jsxs)(`section`,{className:`min-w-0 p-5 sm:p-6`,children:[(0,R.jsxs)(`section`,{className:`mb-4 overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel shadow-surface`,children:[(0,R.jsxs)(`div`,{className:`border-b border-edge-subtle p-5`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:v===`zh`?`目标与验收`:`Goal and acceptance`}),J.length>0?(0,R.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs text-fg-muted`,children:y.criteriaProgress.replace(`{{verified}}`,String(mn)).replace(`{{total}}`,String(J.length))}):null]}),(0,R.jsx)(I,{content:x.task.contract?.objective||x.task.title,contentKey:`${e}:goal`,language:v,markdown:!1,previewHeight:72,className:`mt-3 text-sm leading-6 text-fg`})]}),(0,R.jsxs)(`div`,{className:`p-5`,children:[(0,R.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:y.successDefinition}),J.length>0?(0,R.jsx)(`ul`,{className:`mt-3 space-y-3`,children:J.map((t,n)=>(0,R.jsxs)(`li`,{className:`flex items-start gap-2.5 text-sm leading-5 text-fg`,children:[(0,R.jsx)(t.status===`passed`?c:t.status===`failed`?Ae:De,{className:_(`mt-0.5 size-4 shrink-0`,t.status===`passed`?`text-success`:t.status===`failed`?`text-danger`:`text-fg-subtle`),"aria-hidden":!0}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(I,{content:t.text,contentKey:`${e}:criterion:${n}`,language:v,markdown:!1,previewHeight:60}),t.evidence.length>0?(0,R.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-x-2 text-xs leading-5 text-fg-muted`,children:[(0,R.jsx)(`span`,{children:v===`zh`?`依据:`:`Evidence:`}),t.evidence.map(e=>e.uri&&/^https?:\/\//.test(e.uri)?(0,R.jsx)(`a`,{className:`text-accent hover:underline`,href:e.uri,target:`_blank`,rel:`noreferrer`,children:e.title},e.title):(0,R.jsx)(`span`,{children:e.title},e.title))]}):null,t.review?(0,R.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[v===`zh`?`人工判定`:`Reviewed by user`,` · `,k(t.review.reviewedAt,v)]}):null,t.method===`model_reviewed`?(0,R.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:v===`zh`?`模型审阅:${t.verificationStatus===`passed`?`通过`:t.verificationStatus===`failed`?`未通过`:`未核验`}`:`Model review: ${t.verificationStatus===`passed`?`passed`:t.verificationStatus===`failed`?`failed`:`unverified`}`}):null,t.note?(0,R.jsx)(I,{content:t.note,contentKey:`${e}:criterion-note:${n}`,language:v,markdown:!1,previewHeight:60,className:`mt-1 text-xs text-fg-muted`}):null]}),x.task.phase!==`closed`&&x.task.contract?.acceptancePolicy!==`verified_auto`?(0,R.jsxs)(je,{children:[(0,R.jsx)(pe,{asChild:!0,children:(0,R.jsx)(O,{type:`button`,variant:`ghost`,className:`h-7 shrink-0 px-2 text-xs`,disabled:F.has(`acceptance`),children:v===`zh`?`判定`:`Review`})}),(0,R.jsx)(Oe,{children:(0,R.jsxs)(ge,{align:`end`,sideOffset:4,className:`z-[100] min-w-32 rounded-lg border border-edge bg-surface-overlay p-1 shadow-popover`,children:[(0,R.jsx)(Ne,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>void Zt(n,`passed`),children:v===`zh`?`确认通过`:`Mark passed`}),(0,R.jsx)(Ne,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>void Zt(n,`failed`),children:v===`zh`?`标记未通过`:`Mark failed`})]})})]}):null]},`${n}-${t.text}`))}):(0,R.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:y.noDefinition})]})]}),x.attention.length>0?(0,R.jsxs)(`section`,{className:_(`mb-4 rounded-xl border border-warning/20 bg-warning/10 p-4`,Q(`attention`)&&`task-detail-live-update`),children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:pn?y.needsAttention:y.waitingStatus}),(0,R.jsx)(`ul`,{className:`mt-2 space-y-1.5 text-sm leading-6 text-fg-muted`,children:x.attention.map((t,n)=>(0,R.jsxs)(`li`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,R.jsx)(I,{content:t.summary,contentKey:`${e}:attention:${t.kind}:${n}`,language:v,markdown:!1,previewHeight:72,className:`min-w-0 flex-1`}),t.kind===`input_required`||t.kind===`approval_required`?(0,R.jsx)(s,{className:`inline-flex min-h-11 items-center rounded-lg bg-surface-panel px-3 text-sm font-medium text-accent`,to:f(e),children:v===`zh`?t.kind===`approval_required`?`查看并决定`:`补充信息`:t.kind===`approval_required`?`Review decision`:`Provide information`}):null]},`${t.kind}-${n}`))})]}):null,x.allowedCommands.includes(`resolve_wait`)&&!en&&x.waits.filter(e=>(e.kind===`user_input`||e.kind===`approval`&&typeof e.condition.capability==`string`)&&e.condition.type!==`connection`).map(e=>(0,R.jsx)(Ve,{wait:e,detail:x,zh:v===`zh`,onUpdated:e=>{j(e,{revalidate:!1})}},e.id)),(0,R.jsx)(`div`,{className:`mb-4`,children:(0,R.jsx)(Be,{changes:x.phaseChanges,language:v})}),(0,R.jsx)(`div`,{className:`mb-4`,children:(0,R.jsx)(Ke,{taskId:e},e)}),hn.length>0||_n.length>0||Sn.length>0?(0,R.jsxs)(`section`,{className:`mb-4 rounded-xl border border-edge-subtle bg-surface-panel p-5 shadow-surface`,children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:v===`zh`?`交付物`:`Deliverables`}),hn.length>0||_n.length>0?(0,R.jsxs)(`ul`,{className:`mt-3 space-y-2`,children:[hn.map(t=>(0,R.jsxs)(`li`,{className:`rounded-lg bg-surface-hover p-3 text-sm`,children:[(0,R.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:y.contextKindLabels[t.targetKind]}),t.targetKind===`url`&&/^https?:\/\//.test(t.targetId)?(0,R.jsx)(I,{content:t.title??t.targetId,contentKey:`${e}:deliverable:${t.id}`,language:v,previewHeight:60,className:`mt-1`,children:(0,R.jsx)(`a`,{className:`block break-all text-accent hover:underline`,href:t.targetId,target:`_blank`,rel:`noreferrer`,children:t.title??t.targetId})}):(0,R.jsx)(I,{content:t.title??t.targetId,contentKey:`${e}:deliverable:${t.id}`,language:v,markdown:!1,previewHeight:60,className:`mt-1 text-fg`})]},t.id)),_n.map(t=>(0,R.jsxs)(`li`,{className:`rounded-lg bg-surface-hover p-3 text-sm`,children:[(0,R.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:v===`zh`?`执行产物`:`Run artifact`}),t.uri&&/^https?:\/\//.test(t.uri)?(0,R.jsx)(I,{content:t.title,contentKey:`${e}:artifact:${t.uri??t.title}`,language:v,previewHeight:60,className:`mt-1`,children:(0,R.jsx)(`a`,{className:`block break-all text-accent hover:underline`,href:t.uri,target:`_blank`,rel:`noreferrer`,children:t.title})}):(0,R.jsx)(I,{content:t.title,contentKey:`${e}:artifact:${t.uri??t.title}`,language:v,markdown:!1,previewHeight:60,className:`mt-1 text-fg`})]},t.uri??t.title))]}):(0,R.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:v===`zh`?`尚未关联交付物`:`No deliverables linked yet`}),Sn.length>0?(0,R.jsxs)(`div`,{className:`mt-4 border-t border-edge-subtle pt-3`,children:[(0,R.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:y.expectedOutputs}),(0,R.jsx)(`div`,{className:`mt-2`,children:(0,R.jsx)(ft,{contentKey:`${e}:expectedOutputs`,items:Sn,empty:y.noDefinition})})]}):null]}):null,(0,R.jsxs)(`section`,{className:`mb-4 rounded-xl border border-edge-subtle bg-surface-panel p-5 shadow-surface`,children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:v===`zh`?`关联内容`:`Related work`}),Z.length>0||x.runs.length>0||xn.length>0||x.dependencies.length>0||x.dependents.length>0?(0,R.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[Z.length>0?(0,R.jsxs)(`div`,{className:`rounded-lg bg-surface-hover p-3`,children:[(0,R.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:v===`zh`?`对话 · ${Z.length}`:`Conversations · ${Z.length}`}),(0,R.jsx)(He,{contentKey:`${e}:sessions`,language:v,className:`mt-2`,children:Z.map(t=>(0,R.jsx)(`li`,{children:(0,R.jsx)(s,{className:`block break-words [overflow-wrap:anywhere] text-sm text-accent hover:underline`,to:t.conversationId===X?f(e):`/chat/${encodeURIComponent(t.conversationId)}`,children:t.conversationId===X?v===`zh`?`当前执行对话`:`Current execution chat`:t.role===`discussion`?v===`zh`?`关联讨论`:`Linked discussion`:v===`zh`?`历史执行对话`:`Earlier execution chat`})},t.id))})]}):null,x.runs.length>0?(0,R.jsxs)(`div`,{className:`rounded-lg bg-surface-hover p-3`,children:[(0,R.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:v===`zh`?`执行 · ${x.runs.length}`:`Runs · ${x.runs.length}`}),(0,R.jsxs)(`p`,{className:`mt-2 text-sm text-fg`,children:[v===`zh`?`最近执行:`:`Latest run: `,Y?y.receiptStatuses[Y.status]:nn]}),yn.length>0?(0,R.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:v===`zh`?`含 ${yn.length} 次工作流执行`:`${yn.length} workflow runs`}):null,bn.map(e=>(0,R.jsxs)(s,{className:`mt-1 block break-words [overflow-wrap:anywhere] text-xs text-accent hover:underline`,to:`/workflows/${encodeURIComponent(e)}`,children:[v===`zh`?`工作流:`:`Workflow: `,e]},e))]}):null,xn.length>0?(0,R.jsxs)(`div`,{className:`rounded-lg bg-surface-hover p-3`,children:[(0,R.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:v===`zh`?`自动化 · ${xn.length}`:`Automations · ${xn.length}`}),(0,R.jsx)(He,{contentKey:`${e}:automations`,language:v,className:`mt-2`,children:xn.map(e=>(0,R.jsx)(`li`,{children:(0,R.jsx)(s,{className:`block break-words [overflow-wrap:anywhere] text-sm text-accent hover:underline`,to:`/automations?automation=${encodeURIComponent(e.id)}`,children:e.name})},e.id))})]}):null,x.dependencies.length>0||x.dependents.length>0?(0,R.jsxs)(`div`,{className:`rounded-lg bg-surface-hover p-3`,children:[(0,R.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:y.taskRelations}),(0,R.jsx)(`p`,{className:`mt-2 text-sm text-fg`,children:v===`zh`?`${x.dependencies.length} 个前置任务 · ${x.dependents.length} 个后续任务`:`${x.dependencies.length} prerequisites · ${x.dependents.length} dependents`})]}):null]}):(0,R.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:v===`zh`?`还没有关联内容`:`No related work yet`}),(0,R.jsx)(`div`,{className:`mt-4 border-t border-edge-subtle pt-3`,children:(0,R.jsx)(Re,{resource:{kind:`task`,id:x.task.id,revision:String(x.task.version)},disabled:et||gt||F.size>0})})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,R.jsxs)(`main`,{className:`min-w-0 overflow-hidden rounded-xl bg-surface-panel shadow-surface divide-y divide-edge-subtle`,children:[(0,R.jsxs)(`section`,{className:_(`p-5`,Q(`body`)&&`task-detail-live-update`),children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:y.taskDescription}),gt?(0,R.jsx)(`textarea`,{autoFocus:!0,"data-task-inline-editor":!0,rows:6,value:_t,onChange:e=>vt(e.target.value),onBlur:()=>void Vt(),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),wt.current=!0,vt(x.task.body??x.task.contract?.objective??``),V(!1),queueMicrotask(()=>{wt.current=!1}))},className:`mt-3 w-full resize-y rounded-lg bg-surface-hover px-3 py-2 text-sm leading-6 text-fg outline-none ring-2 ring-accent/20 focus:ring-accent/50`}):(0,R.jsxs)(`div`,{className:`mt-2`,children:[rn&&rn!==x.task.title?(0,R.jsx)(I,{content:rn,contentKey:`${e}:description`,language:v}):(0,R.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:y.noTaskDescription}),(0,R.jsx)(`button`,{type:`button`,className:`mt-2 rounded-md px-2 py-1 text-xs text-accent hover:bg-surface-hover focus-visible:bg-surface-hover`,onClick:()=>{let e=x.task.body??x.task.contract?.objective??``;Tt.current=e,Dt.current={value:x.task.body??``,version:x.task.version},W(null),vt(e),V(!0)},children:v===`zh`?`编辑说明`:`Edit description`})]}),kt===`description`?(0,R.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,R.jsx)(`span`,{children:v===`zh`?`Agent 在你编辑期间更新了描述。`:`The Agent updated the description while you were editing.`}),(0,R.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{vt(x.task.body??``),W(null),V(!1)},children:v===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,R.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void q({body:_t.trim()||null}).then(e=>{e&&(W(null),V(!1))}),children:v===`zh`?`保留我的修改`:`Keep my changes`})]}):null]}),Dn?(0,R.jsxs)(`section`,{className:_(`p-5`,Q(`contract`)&&`task-detail-live-update`),children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:y.taskDefinition}),(0,R.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:v===`zh`?`执行边界及补充背景`:`Execution boundaries and supporting context`}),Cn.length>0?(0,R.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:y.constraints}),(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(ft,{contentKey:`${e}:constraints`,items:Cn,empty:y.noDefinition})})]}):null,wn.length>0?(0,R.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:y.approvalRequired}),(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(ft,{contentKey:`${e}:approvalRequired`,items:wn,empty:y.noDefinition})})]}):null,Tn.length>0?(0,R.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:y.contextAssumptions}),(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(ft,{contentKey:`${e}:assumptions`,items:Tn,empty:y.noDefinition})})]}):null,En.length>0?(0,R.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:y.contextRisks}),(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(ft,{contentKey:`${e}:risks`,items:En,empty:y.noDefinition})})]}):null]}):null,Y?(0,R.jsxs)(`section`,{className:_(`p-5`,Q(`runs`,`receipts`)&&`task-detail-live-update`),children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:y.latestResult}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:v===`zh`?Y.completionVerdict===`achieved`?`本次执行报告目标已达成,请结合下方验证依据验收。`:`这是阶段性结果,尚不能代表任务全部完成。`:Y.completionVerdict===`achieved`?`The run reports the goal achieved. Review the evidence below.`:`This is a partial result; the task is not yet fully complete.`})]}),(0,R.jsxs)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs text-fg-muted`,children:[y.receiptStatuses[Y.status],` · `,y.verificationStatuses[Y.verification.status]]})]}),(0,R.jsx)(I,{content:Y.summary,contentKey:`${e}:result:${Y.runId}`,language:v,className:`mt-3`}),Y.remainingWork.length>0?(0,R.jsxs)(`div`,{className:`mt-4`,children:[(0,R.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:y.remainingWork}),(0,R.jsx)(`div`,{className:`mt-2`,children:(0,R.jsx)(ft,{contentKey:`${e}:remaining:${Y.runId}`,items:Y.remainingWork,empty:y.noRemainingWork})})]}):null,Y.nextAction?(0,R.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3`,children:[(0,R.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:y.nextAction}),(0,R.jsx)(I,{content:Y.nextAction,contentKey:`${e}:next:${Y.runId}`,language:v,markdown:!1,previewHeight:72,className:`mt-1 text-sm text-fg`})]}):null,(0,R.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(O,{className:`border-0 bg-surface-hover px-2 py-1 text-xs shadow-none`,variant:`secondary`,onClick:()=>void Fe(Y.runId,`helpful`),children:y.doneWell}),(0,R.jsx)(O,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void Fe(Y.runId,`not_helpful`),children:y.needsFix})]}),(0,R.jsx)(We,{evidence:Y.evidence,projectId:x.task.projectId,conversationId:X??void 0,language:v}),x.receipts.length>1?(0,R.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-4`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:y.executionHistory.replace(`{{count}}`,String(x.receipts.length-1))}),(0,R.jsx)(`div`,{className:`mt-3 space-y-3`,children:x.receipts.slice(1).map(t=>(0,R.jsx)(`article`,{className:`rounded-lg bg-surface-hover p-3`,children:(0,R.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,R.jsx)(I,{content:t.summary,contentKey:`${e}:result:${t.runId}`,language:v,className:`min-w-0 flex-1`}),(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:y.receiptStatuses[t.status]})]})},t.runId))})]}):null]}):null,vn.length>0?(0,R.jsxs)(`section`,{className:_(`p-5`,Q(`context`)&&`task-detail-live-update`),children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:y.contextUsed}),(0,R.jsx)(`ul`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:vn.map(e=>(0,R.jsxs)(`li`,{className:`min-w-0 rounded-lg bg-surface-hover p-2.5`,children:[(0,R.jsxs)(`span`,{className:`text-[11px] text-fg-subtle`,children:[y.contextRoleLabels[e.role],` · `,y.contextKindLabels[e.targetKind]]}),e.targetKind===`url`&&/^https?:\/\//.test(e.targetId)?(0,R.jsx)(`a`,{className:`mt-1 block break-all text-sm text-accent hover:underline`,href:e.targetId,target:`_blank`,rel:`noreferrer`,children:e.title??e.targetId}):(0,R.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:e.title??e.targetId})]},e.id))})]}):null]}),(0,R.jsxs)(`aside`,{className:`min-w-0 overflow-hidden rounded-xl bg-surface-panel shadow-surface divide-y divide-edge-subtle`,children:[(0,R.jsxs)(`section`,{className:_(`p-5`,Q(`phase`,`resolution`,`priority`,`dueAt`,`delegateAgentId`)&&`task-detail-live-update`),children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:y.taskProperties}),(0,R.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,R.jsx)(tt,{value:x.task.phase,disabled:F.has(`phase`),canMove:On,canApprove:cn,canReopen:ln,language:v,label:y.taskPhase,onChange:Ht}),(0,R.jsx)(nt,{value:x.task.priority,disabled:F.has(`priority`),label:y.priority,labels:y.priorityLabels,onChange:Ut}),(0,R.jsx)(rt,{value:Ze(x.task.dueAt),disabled:F.has(`dueAt`),label:y.dueDate,onChange:Wt}),(0,R.jsx)(it,{value:x.conversation.currentExecutorAgentId??``,disabled:F.has(`delegateAgentId`),label:y.executorLabel,unassignedLabel:y.unassigned,agents:Ye,onChange:Yt})]})]}),(0,R.jsxs)(`section`,{className:_(`p-5`,Q(`dependencies`)&&`task-detail-live-update`),children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:y.taskRelations}),(0,R.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:y.dependencies}),(0,R.jsx)(at,{candidates:L,selected:x.dependencies,disabled:F.has(`dependencies`),labels:Pt,getTaskHref:Lt,onChange:Jt})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:y.dependents}),x.dependents.length>0?(0,R.jsx)(`div`,{className:`space-y-1.5`,children:x.dependents.map(t=>(0,R.jsx)(I,{content:t.title,contentKey:`${e}:dependent:${t.id}`,language:v,previewHeight:72,className:`rounded-lg bg-surface-hover p-2.5`,children:(0,R.jsx)(s,{to:Lt(t.id),className:`block break-words [overflow-wrap:anywhere] text-sm text-fg-muted transition-colors hover:text-fg`,children:t.title})},t.id))}):(0,R.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:y.noDependents})]})]})]})]})]})]})]}),(0,R.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":v===`zh`?`调整任务信息和 Agent 对话的宽度`:`Resize task details and Agent chat`,"aria-valuemin":30,"aria-valuemax":60,"aria-valuenow":Math.round(H),tabIndex:0,onPointerDown:qt,onKeyDown:Kt,onDoubleClick:()=>Gt(st),className:`group hidden w-2 shrink-0 cursor-col-resize touch-none items-stretch justify-center bg-surface-panel outline-none transition-colors hover:bg-surface-hover focus-visible:bg-surface-hover lg:flex ${bt?`bg-surface-hover`:``}`,children:(0,R.jsx)(`div`,{className:`w-px bg-edge-strong/70 transition-colors group-hover:bg-accent group-focus-visible:bg-accent`})}),(0,R.jsxs)(`aside`,{className:`flex min-h-[34rem] min-w-0 shrink-0 flex-col border-t border-edge-subtle bg-surface-panel lg:min-h-0 lg:w-[var(--task-chat-panel-width)] lg:border-t-0`,children:[(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge-subtle px-4 py-3`,children:[(0,R.jsx)(`h2`,{className:`text-sm font-medium text-fg-muted`,children:v===`zh`?`执行对话`:`Execution chat`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[Z.length>1?(0,R.jsxs)(je,{children:[(0,R.jsx)(pe,{asChild:!0,children:(0,R.jsx)(O,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,children:v===`zh`?`${Z.length} 段对话`:`${Z.length} conversations`})}),(0,R.jsx)(Oe,{children:(0,R.jsx)(ge,{align:`end`,sideOffset:6,className:`z-[100] min-w-52 rounded-lg border border-edge bg-surface-overlay p-1 shadow-popover`,children:Z.map(t=>(0,R.jsx)(Ne,{asChild:!0,children:(0,R.jsx)(s,{className:`block rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,to:t.conversationId===X?f(e):`/chat/${encodeURIComponent(t.conversationId)}`,children:t.conversationId===X?v===`zh`?`当前执行对话`:`Current execution chat`:t.role===`discussion`?v===`zh`?`关联讨论`:`Linked discussion`:v===`zh`?`历史执行对话`:`Earlier execution chat`})},t.id))})})]}):null,X?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(O,{type:`button`,variant:`ghost`,className:_(`size-8 p-0`,fn&&`bg-surface-hover text-fg`),"aria-label":v===`zh`?`项目文件`:`Project files`,"aria-pressed":fn,onClick:()=>{ce.getState().openFiles(X),ae(X)},children:(0,R.jsx)(h,{className:`size-4`,"aria-hidden":!0})}),(0,R.jsx)(O,{asChild:!0,variant:`ghost`,className:`size-8 p-0`,children:(0,R.jsx)(s,{to:f(e),"aria-label":v===`zh`?`全屏打开对话`:`Open chat full screen`,children:(0,R.jsx)(u,{className:`size-4`,"aria-hidden":!0})})})]}):null]})]}),X?(0,R.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,R.jsx)(Ee,{embedded:!0,conversationId:X,taskId:e})}):M?(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,R.jsxs)(`div`,{className:`max-w-xs`,children:[(0,R.jsx)(w,{className:`mx-auto size-8 animate-pulse text-fg-subtle`}),(0,R.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:v===`zh`?`正在创建任务会话`:`Creating task conversation`})]})}):N?(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,R.jsxs)(`div`,{className:`max-w-xs`,children:[(0,R.jsx)(w,{className:`mx-auto size-8 text-danger`}),(0,R.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:v===`zh`?`任务会话创建失败`:`Could not create task conversation`}),(0,R.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:N instanceof Error?N.message:String(N)})]})}):(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,R.jsxs)(`div`,{className:`max-w-xs`,children:[(0,R.jsx)(w,{className:`mx-auto size-8 text-fg-subtle`}),(0,R.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:v===`zh`?`等待任务会话`:`Waiting for a task conversation`}),(0,R.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:v===`zh`?`安排或开始任务后,Agent 的执行过程和持续对话会显示在这里。`:`Schedule or start the task to see the agent run and continue the conversation here.`})]})})]})]}),(0,R.jsx)(de,{open:Mt,title:y.deleteTaskTitle,description:y.deleteTaskDescription.replace(`{{title}}`,x.task.title),confirmLabel:y.confirmDeleteTask,cancelLabel:y.keepTask,destructive:!0,onConfirm:()=>{Nt(!1),Xt()},onCancel:()=>Nt(!1)})]})}function gt(){let e=(0,L.c)(2),{taskId:t}=o(),n=t===void 0?``:t,r;return e[0]===n?r=e[1]:(r=(0,R.jsx)(ht,{taskId:n,presentation:`page`}),e[0]=n,e[1]=r),r}function V(e){let t=(0,L.c)(41),{taskId:n,backgroundPath:r,workspacePanelWidth:i,onClose:a}=e,o=i===void 0?0:i,s=te(yt),c=we(H),l=o>0,u;t[0]!==a||t[1]!==c?(u=e=>{e||(c(null),a())},t[0]=a,t[1]=c,t[2]=u):u=t[2];let d=s===`zh`?`关闭任务详情`:`Close task details`,f;t[3]!==a||t[4]!==c?(f=()=>{c(null),a()},t[3]=a,t[4]=c,t[5]=f):f=t[5];let p;t[6]!==d||t[7]!==f?(p=(0,R.jsx)(`button`,{type:`button`,tabIndex:-1,"data-task-modal-backdrop":!0,className:`fixed inset-0 z-[80] bg-black/45`,"aria-label":d,onClick:f}),t[6]=d,t[7]=f,t[8]=p):p=t[8];let m=l?`true`:`false`,h=`${o/2}px`,_=`${o}px`,v;t[9]!==h||t[10]!==_?(v={"--task-detail-workspace-offset":h,"--task-detail-workspace-width":_},t[9]=h,t[10]=_,t[11]=v):v=t[11];let ee=v,ne=s===`zh`?`任务详情`:`Task details`,S;t[12]===ne?S=t[13]:(S=(0,R.jsx)(ae,{className:`font-medium text-fg`,children:ne}),t[12]=ne,t[13]=S);let oe=s===`zh`?`查看并操作任务详情`:`View and manage task details`,C;t[14]===oe?C=t[15]:(C=(0,R.jsx)(y,{className:`sr-only`,children:oe}),t[14]=oe,t[15]=C);let se=s===`zh`?`关闭任务详情`:`Close task details`,w;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,R.jsx)(g,{className:`size-4`,"aria-hidden":!0}),t[16]=w):w=t[16];let T;t[17]===se?T=t[18]:(T=(0,R.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:(0,R.jsx)(b,{className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":se,children:w})}),t[17]=se,t[18]=T);let E;t[19]!==S||t[20]!==C||t[21]!==T?(E=(0,R.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 bg-surface-panel px-5 py-3.5`,children:[S,C,T]}),t[19]=S,t[20]=C,t[21]=T,t[22]=E):E=t[22];let D;t[23]!==a||t[24]!==c?(D=()=>{c(null),a()},t[23]=a,t[24]=c,t[25]=D):D=t[25];let O;t[26]!==r||t[27]!==D||t[28]!==n?(O=(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,R.jsx)(ht,{taskId:n,presentation:`modal`,backgroundPath:r,onDeleted:D})}),t[26]=r,t[27]=D,t[28]=n,t[29]=O):O=t[29];let k;t[30]!==ee||t[31]!==E||t[32]!==O||t[33]!==m?(k=(0,R.jsxs)(ie,{className:`xopc-dialog-content task-detail-modal-content fixed top-1/2 z-[90] flex h-[min(54rem,calc(100dvh-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay focus:outline-none`,"data-workspace-panel-open":m,style:ee,onEscapeKeyDown:vt,onInteractOutside:_t,children:[E,O]}),t[30]=ee,t[31]=E,t[32]=O,t[33]=m,t[34]=k):k=t[34];let A;t[35]!==k||t[36]!==p?(A=(0,R.jsxs)(re,{children:[p,k]}),t[35]=k,t[36]=p,t[37]=A):A=t[37];let j;return t[38]!==u||t[39]!==A?(j=(0,R.jsx)(x,{modal:!1,open:!0,onOpenChange:u,children:A}),t[38]=u,t[39]=A,t[40]=j):j=t[40],j}function _t(e){let t=e.detail.originalEvent.target;t instanceof Element&&t.closest(`#app-workspace-panel, [data-task-modal-backdrop]`)&&e.preventDefault()}function vt(e){let t=e.target;t instanceof HTMLElement&&t.closest(`[data-task-inline-editor]`)&&e.preventDefault()}function H(e){return e.setPath}function yt(e){return e.language}function bt(e){return(0,R.jsx)(ve,{value:e.id,children:e.name||e.id},e.id)}function xt(e){return e.id}export{V as TaskDetailModal,gt as TaskDetailPage};
|
|
@@ -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{g as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./markdown-view-CthsQiiO.js";import{t as o}from"./cn-0WouolD0.js";import{d as s}from"./tasks-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{g as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./markdown-view-CthsQiiO.js";import{t as o}from"./cn-0WouolD0.js";import{d as s}from"./tasks-B4bZpO6O.js";function c(e){let t=e.task.contract?.acceptanceCriteria??[],n=new Map(e.runs.map(e=>[e.id,e])),r=e.receipts.filter(t=>n.get(t.runId)?.contractVersion===e.task.latestContractVersion).sort((e,t)=>t.finalizedAt-e.finalizedAt);return t.map((t,n)=>{let i=e.criterionReviews.find(r=>r.criterionIndex===n&&r.contractVersion===e.task.latestContractVersion&&r.criterionText===t),a={text:t,status:`unverified`,evidence:[]};for(let e of r){let n=e.verification.checks.find(e=>e.criterion===t);if(!n)continue;let r=e.evidence.filter(e=>n.evidenceTitles.includes(e.title)),i=n.status===`passed`&&s(e).has(t)?`passed`:n.status===`failed`?`failed`:`unverified`;a={text:t,status:i,evidence:r,runId:e.runId,verificationStatus:i,method:n.method,note:n.note};break}return i&&e.task.contract?.acceptancePolicy!==`verified_auto`?{...a,status:i.status,review:i}:e.task.contract?.acceptancePolicy===`manual`?{...a,status:`unverified`}:a})}var l=n(),u=e(t(),1),d=r();function f(e){let t=(0,l.c)(36),{content:n,contentKey:r,language:s,markdown:c,breaks:f,previewHeight:p,className:m,children:h}=e,g=c===void 0?!0:c,_=f===void 0?!1:f,v=p===void 0?240:p,y=(0,u.useId)(),b=(0,u.useRef)(null),[x,S]=(0,u.useState)(!1),[C,w]=i(),T;t[0]!==r||t[1]!==C?(T=C.getAll(`taskExpanded`).includes(r),t[0]=r,t[1]=C,t[2]=T):T=t[2];let E=T,D;t[3]===v?D=t[4]:(D=()=>{let e=b.current;if(!e)return;let t=()=>S(e.scrollHeight>v);if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},t[3]=v,t[4]=D);let O;t[5]!==n||t[6]!==v?(O=[n,v],t[5]=n,t[6]=v,t[7]=O):O=t[7],(0,u.useLayoutEffect)(D,O);let k=x&&!E,A;t[8]===m?A=t[9]:(A=o(`min-w-0`,m),t[8]=m,t[9]=A);let j;t[10]!==k||t[11]!==v?(j=k?{maxHeight:v,overflow:`hidden`,maskImage:`linear-gradient(to bottom, black calc(100% - ${Math.min(24,v/3)}px), transparent)`}:void 0,t[10]=k,t[11]=v,t[12]=j):j=t[12];let M;t[13]!==_||t[14]!==h||t[15]!==n||t[16]!==g?(M=h??(g?(0,d.jsx)(a,{content:n,compact:!0,breaks:_,className:`text-sm leading-6 text-fg`}):(0,d.jsx)(`p`,{className:`whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:n})),t[13]=_,t[14]=h,t[15]=n,t[16]=g,t[17]=M):M=t[17];let N;t[18]!==k||t[19]!==M?(N=(0,d.jsx)(`div`,{ref:b,inert:k,children:M}),t[18]=k,t[19]=M,t[20]=N):N=t[20];let P;t[21]!==y||t[22]!==N||t[23]!==j?(P=(0,d.jsx)(`div`,{id:y,style:j,children:N}),t[21]=y,t[22]=N,t[23]=j,t[24]=P):P=t[24];let F;t[25]!==r||t[26]!==E||t[27]!==y||t[28]!==s||t[29]!==x||t[30]!==w?(F=x?(0,d.jsx)(`button`,{type:`button`,"aria-expanded":E,"aria-controls":y,className:`mt-2 min-h-9 rounded-sm text-xs font-medium text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,onClick:()=>w(e=>{let t=new URLSearchParams(e),n=t.getAll(`taskExpanded`).filter(e=>e!==r);t.delete(`taskExpanded`);for(let e of n)t.append(`taskExpanded`,e);return E||t.append(`taskExpanded`,r),t},{preventScrollReset:!0}),children:s===`zh`?E?`收起`:`查看更多`:E?`Show less`:`Show more`}):null,t[25]=r,t[26]=E,t[27]=y,t[28]=s,t[29]=x,t[30]=w,t[31]=F):F=t[31];let I;return t[32]!==P||t[33]!==F||t[34]!==A?(I=(0,d.jsxs)(`div`,{className:A,children:[P,F]}),t[32]=P,t[33]=F,t[34]=A,t[35]=I):I=t[35],I}export{c as n,f as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,d as t,g as n,i as r,l as i,p as a,r as o,s,t as c,u as l}from"./schemas-CObaziC7.js";import{n as u}from"./specialists-4bkS5rZ4.js";var d=c([`backlog`,`ready`,`active`,`review`,`closed`]),f=c([`done`,`cancelled`,`duplicate`,`wont_do`]),p=c([`allocating`,`idle`,`queued`,`running`,`waiting`,`verifying`,`blocked`,`failed`,`cancelled`]),m=c([`dependency`,`user_input`,`approval`,`external_event`,`scheduled_time`,`retry_backoff`,`paused`]),h=c([`active`,`resolved`,`cancelled`]),g=l({id:a(),taskId:a(),taskRunId:a().optional(),kind:m,status:h,reason:a(),condition:t(a(),n()),resumeAt:i().int().nonnegative().optional(),resolvedBy:t(a(),n()).optional(),resolution:n().optional(),createdAt:i().int().nonnegative(),resolvedAt:i().int().nonnegative().optional()}),_=l({kind:c([`allocation_blocked`,`allocation_failed`,`input_required`,`approval_required`,`dependency_blocked`,`run_failed`,`verification_failed`,`overdue`,`stale`]),summary:a(),sourceId:a().optional()}),v=c([`agent`,`workflow`,`human`,`external`]),y=c([`queued`,`running`,`waiting`,`verifying`,`succeeded`,`failed`,`cancelled`]),b=new Set([`succeeded`,`failed`,`cancelled`]),x=l({id:a(),taskId:a(),rootRunId:a(),parentRunId:a().optional(),attempt:i().int().positive(),status:y,executorKind:v,executorRef:t(a(),n()),trigger:t(a(),n()),correlationId:a(),causationId:a().optional(),idempotencyKey:a(),contractVersion:i().int().positive(),contextSnapshotId:a().optional(),policySnapshot:t(a(),n()).optional(),conversationId:a().optional(),queuedAt:i().int().nonnegative(),scheduledAt:i().int().nonnegative().optional(),startedAt:i().int().nonnegative().optional(),heartbeatAt:i().int().nonnegative().optional(),completedAt:i().int().nonnegative().optional(),timeoutAt:i().int().nonnegative().optional(),leaseOwner:a().optional(),leaseExpiresAt:i().int().nonnegative().optional(),retryPolicy:t(a(),n()),retryOfRunId:a().optional(),terminalCode:a().optional(),terminalMessage:a().optional(),version:i().int().positive()}).superRefine((e,t)=>{!e.parentRunId&&e.rootRunId!==e.id&&t.addIssue({code:`custom`,path:[`rootRunId`],message:`A root run must reference itself`}),(e.startedAt!==void 0||[`running`,`verifying`,`succeeded`].includes(e.status))&&(!e.contextSnapshotId||!e.policySnapshot)&&t.addIssue({code:`custom`,path:[`contextSnapshotId`],message:`A dispatched run requires context and policy snapshots`}),b.has(e.status)!==!!e.completedAt&&t.addIssue({code:`custom`,path:[`completedAt`],message:`Only terminal runs have a completion timestamp`})}),S=l({id:a(),runId:a(),sequence:i().int().positive(),type:a(),payload:t(a(),n()),actor:t(a(),n()),occurredAt:i().int().nonnegative()}),C=l({id:a(),taskId:a(),status:c([`pending`,`selecting`,`assigned`,`blocked`,`failed`,`cancelled`]),selectedAgentId:a().optional(),selectionReason:a().optional(),reasonCode:a().optional(),attempts:i(),updatedAt:i()}),w=c([`low`,`normal`,`high`,`critical`]),T=c([`title`,`body`,`phase`,`resolution`,`priority`,`dueAt`,`projectId`,`milestoneId`,`parentTaskId`,`ownerId`,`delegateAgentId`,`boardRank`,`contract`,`dependencies`,`context`,`runs`,`receipts`,`acceptance`,`feedback`,`attention`,`conversation`]),E=l({taskId:a().min(1),projectId:a().min(1).optional(),version:i().int().positive(),changedFields:o(T).min(1),source:c([`user`,`agent`,`runtime`]),actorId:a().min(1).optional(),occurredAt:i().int().nonnegative()}),D=l({taskId:a().min(1),projectId:a().min(1).optional(),deletedAt:i().int().nonnegative()}),O=c([`verified_auto`,`verified_then_review`,`manual`]),k=l({kind:c([`user`,`agent`,`system`,`integration`]),id:a().optional()}),A=l({taskId:a(),version:i().int().positive(),objective:a(),expectedOutputs:o(a()),acceptanceCriteria:o(a()),constraints:o(a()),approvalRequired:o(a()),assumptions:o(a()),risks:o(a()),acceptancePolicy:O,outputDestinations:o(t(a(),n())),createdBy:k,createdAt:i().int().nonnegative()}),j=l({id:a(),title:a(),body:a().optional(),phase:d,resolution:f.optional(),priority:w,dueAt:i().int().nonnegative().optional(),projectId:a().optional(),milestoneId:a().optional(),parentTaskId:a().optional(),ownerId:a().optional(),delegateAgentId:a().optional(),source:a(),locale:c([`en`,`zh`]).optional(),latestContractVersion:i().int().positive(),boardRank:i().finite().default(0),version:i().int().positive(),contract:A.optional(),createdAt:i().int().nonnegative(),updatedAt:i().int().nonnegative(),closedAt:i().int().nonnegative().optional()}).superRefine((e,t)=>{e.phase===`closed`!=!!e.resolution&&t.addIssue({code:`custom`,path:[`resolution`],message:`Closed tasks require a resolution and open tasks cannot have one`})}),M=c([`input`,`reference`,`constraint`,`deliverable`,`evidence`]),N=l({id:a(),taskId:a(),targetKind:c([`document`,`file`,`url`,`session`,`memory`,`task`,`artifact`,`source`]),targetId:a(),role:M,title:a().optional(),pinned:r(),retrievalPolicy:t(a(),n()),metadata:t(a(),n()),createdBy:k,createdAt:i().int().nonnegative(),updatedAt:i().int().nonnegative()}),P=l({id:a(),taskId:a(),capability:a(),scope:t(a(),n()),grantedBy:k,grantedAt:i().int().nonnegative(),expiresAt:i().int().nonnegative().optional(),revokedAt:i().int().nonnegative().optional()}),F=l({id:a(),title:a(),phase:d,resolution:f.optional(),allocation:C.optional(),operationalState:p}),I=l({kind:c([`artifact`,`test`,`state`,`source`]),title:a(),summary:a(),uri:a().optional(),verifies:o(a()).optional(),provenance:c([`tool`,`external`,`user`,`judge`]),strength:c([`observed`,`verified`]),observedAt:i().int().nonnegative()}),L=l({recommendation:a(),reasons:o(a()),rejectedAlternatives:o(l({option:a(),reason:a()})),uncertainty:a().optional(),confidence:i().min(0).max(1)}),R=l({runId:a(),status:c([`succeeded`,`failed`,`cancelled`]),summary:a(),changes:o(I),evidence:o(I),verification:l({status:c([`passed`,`failed`,`unverified`]),checks:o(l({criterion:a(),status:c([`passed`,`failed`,`unverified`]),evidenceTitles:o(a()),note:a().optional(),method:c([`tool_verified`,`model_reviewed`,`unverified`]).optional()}))}),remainingWork:o(a()),nextAction:a().optional(),needsUser:r(),completionVerdict:c([`achieved`,`partial`,`not_achieved`]).optional(),failure:l({code:a(),phase:a(),recoveryAction:a()}).optional(),judgment:L.optional(),contextTraceId:a().optional(),finalizedAt:i().int().nonnegative()}),z=l({contractVersion:i().int().positive(),criterionIndex:i().int().nonnegative(),criterionText:a(),status:c([`passed`,`failed`]),note:a().optional(),reviewedBy:k,reviewedAt:i().int().nonnegative()});l({expectedVersion:i().int().positive(),contractVersion:i().int().positive(),status:c([`passed`,`failed`]),note:a().trim().max(2e3).optional()}).strict();var B=e(`kind`,[l({kind:s(`agent`),agentId:a().min(1)}),l({kind:s(`workflow`),workflowId:a().min(1),workflowVersion:a().min(1).optional(),input:n().optional()}),l({kind:s(`human`),actorId:a().min(1)}),l({kind:s(`external`),provider:a().min(1),config:n()})]),V=A.omit({taskId:!0,version:!0,createdBy:!0,createdAt:!0}),H=N.omit({id:!0,taskId:!0,createdBy:!0,createdAt:!0,updatedAt:!0});l({idempotencyKey:a().trim().min(1).max(200),title:a().trim().min(1).max(500),body:a().trim().max(5e4).optional(),projectId:a().trim().min(1).optional(),milestoneId:a().trim().min(1).optional(),parentTaskId:a().trim().min(1).optional(),priority:w.default(`normal`),dueAt:i().int().nonnegative().optional(),ownerId:a().trim().min(1).optional(),delegateAgentId:a().trim().min(1).optional(),originConversationId:a().trim().min(1).optional(),locale:c([`en`,`zh`]).optional(),contract:V,dependencies:o(a().trim().min(1)).default([]),context:o(H).default([]),authorityGrants:o(l({capability:a().min(1),scope:t(a(),n()).default({}),expiresAt:i().int().nonnegative().optional()})).default([]),activation:e(`mode`,[l({mode:s(`allocate`),requirements:u}).strict(),l({mode:s(`capture`),phase:c([`backlog`,`ready`]).default(`backlog`)}),l({mode:s(`start`),executor:B.optional(),scheduleAt:i().int().nonnegative().optional()})])}).strict(),l({expectedVersion:i().int().positive(),title:a().trim().min(1).max(500).optional(),body:a().trim().max(5e4).nullable().optional(),projectId:a().trim().min(1).nullable().optional(),milestoneId:a().trim().min(1).nullable().optional(),parentTaskId:a().trim().min(1).nullable().optional(),priority:w.optional(),dueAt:i().int().nonnegative().nullable().optional(),ownerId:a().trim().min(1).nullable().optional()}).strict();var U=l({kind:c([`dependency`,`user_input`,`approval`,`external_event`,`scheduled_time`,`retry_backoff`,`paused`]),reason:a().min(1),condition:t(a(),n()).default({}),resumeAt:i().int().nonnegative().optional()}),W=e(`type`,[l({type:s(`retry_allocation`)}),l({type:s(`move`),phase:c([`backlog`,`ready`,`active`,`review`])}),l({type:s(`mark_ready`)}),l({type:s(`start`),executor:B,scheduleAt:i().int().nonnegative().optional()}),l({type:s(`request_review`)}),l({type:s(`close`),resolution:f}),l({type:s(`reopen`),phase:c([`backlog`,`ready`,`active`,`review`])}),l({type:s(`add_wait`),wait:U}),l({type:s(`resolve_wait`),waitId:a(),resolution:n().optional()}),l({type:s(`revise_contract`),contract:V})]);l({idempotencyKey:a().trim().min(1).max(200),expectedVersion:i().int().positive(),command:W}).strict(),l({dependsOnTaskIds:o(a().trim().min(1)),expectedVersion:i().int().positive()}).strict(),l({expectedVersion:i().int().positive(),beforeTaskId:a().trim().min(1).nullable().optional()}).strict();var G=l({ok:s(!0),items:o(l({task:j,allocation:C.optional(),operationalState:p,attention:o(_)}))}),K=l({ok:s(!0),task:j,allocation:C.optional(),operationalState:p,run:x.optional()}),q=l({taskId:a(),activeConversationId:a().optional(),currentExecutorAgentId:a().optional(),assignmentEpoch:i().int().nonnegative(),status:c([`idle`,`active`]),updatedAt:i().int().nonnegative()}),J=l({id:a(),taskId:a(),conversationId:a(),role:c([`primary`,`discussion`,`execution`]),agentId:a().optional(),runId:a().optional(),assignmentEpoch:i().int().nonnegative(),status:c([`active`,`completed`,`superseded`,`failed`]),startedAt:i().int().nonnegative(),endedAt:i().int().nonnegative().optional(),createdAt:i().int().nonnegative()});l({toAgentId:a().trim().min(1),expectedVersion:i().int().positive(),idempotencyKey:a().trim().min(1).max(200)}).strict(),l({ok:s(!0),task:j,conversation:q,fromAgentId:a().optional(),toAgentId:a(),activeConversationId:a(),assignmentEpoch:i().int().positive()});var Y=l({ok:s(!0),task:j,allocation:C.optional(),operationalState:p,attention:o(_),waits:o(g),runs:o(x),receipts:o(R),criterionReviews:o(z),context:o(N),conversation:q,sessions:o(J),authorityGrants:o(P),dependencies:o(F),dependents:o(F),allowedCommands:o(a())});l({ok:s(!0),items:o(R)});function X(e){let t=new Set(e?.evidence.filter(e=>e.strength===`verified`).map(e=>e.title));return new Set(e?.verification.checks.filter(e=>e.status===`passed`&&e.evidenceTitles.some(e=>t.has(e))).map(e=>e.criterion))}export{f as _,F as a,G as c,X as d,S as f,d as g,p as h,D as i,w as l,_ as m,W as n,Y as o,x as p,K as r,B as s,E as t,R as u,g as v};
|
|
1
|
+
import{a as e,d as t,g as n,i as r,l as i,p as a,r as o,s,t as c,u as l}from"./schemas-CObaziC7.js";import{n as u}from"./specialists-4bkS5rZ4.js";var d=c([`backlog`,`ready`,`active`,`review`,`closed`]),f=c([`done`,`cancelled`,`duplicate`,`wont_do`]),p=c([`allocating`,`idle`,`queued`,`running`,`waiting`,`verifying`,`blocked`,`failed`,`cancelled`]),m=c([`dependency`,`user_input`,`approval`,`external_event`,`scheduled_time`,`retry_backoff`,`paused`]),h=c([`active`,`resolved`,`cancelled`]),g=l({id:a(),taskId:a(),taskRunId:a().optional(),kind:m,status:h,reason:a(),condition:t(a(),n()),resumeAt:i().int().nonnegative().optional(),resolvedBy:t(a(),n()).optional(),resolution:n().optional(),createdAt:i().int().nonnegative(),resolvedAt:i().int().nonnegative().optional()}),_=l({kind:c([`allocation_blocked`,`allocation_failed`,`input_required`,`approval_required`,`dependency_blocked`,`run_failed`,`verification_failed`,`overdue`,`stale`]),summary:a(),sourceId:a().optional()}),v=c([`agent`,`workflow`,`human`,`external`]),y=c([`queued`,`running`,`waiting`,`verifying`,`succeeded`,`failed`,`cancelled`]),b=new Set([`succeeded`,`failed`,`cancelled`]),x=l({id:a(),taskId:a(),rootRunId:a(),parentRunId:a().optional(),attempt:i().int().positive(),status:y,executorKind:v,executorRef:t(a(),n()),trigger:t(a(),n()),correlationId:a(),causationId:a().optional(),idempotencyKey:a(),contractVersion:i().int().positive(),contextSnapshotId:a().optional(),policySnapshot:t(a(),n()).optional(),conversationId:a().optional(),queuedAt:i().int().nonnegative(),scheduledAt:i().int().nonnegative().optional(),startedAt:i().int().nonnegative().optional(),heartbeatAt:i().int().nonnegative().optional(),completedAt:i().int().nonnegative().optional(),timeoutAt:i().int().nonnegative().optional(),leaseOwner:a().optional(),leaseExpiresAt:i().int().nonnegative().optional(),retryPolicy:t(a(),n()),retryOfRunId:a().optional(),terminalCode:a().optional(),terminalMessage:a().optional(),version:i().int().positive()}).superRefine((e,t)=>{!e.parentRunId&&e.rootRunId!==e.id&&t.addIssue({code:`custom`,path:[`rootRunId`],message:`A root run must reference itself`}),(e.startedAt!==void 0||[`running`,`verifying`,`succeeded`].includes(e.status))&&(!e.contextSnapshotId||!e.policySnapshot)&&t.addIssue({code:`custom`,path:[`contextSnapshotId`],message:`A dispatched run requires context and policy snapshots`}),b.has(e.status)!==!!e.completedAt&&t.addIssue({code:`custom`,path:[`completedAt`],message:`Only terminal runs have a completion timestamp`})}),S=l({id:a(),runId:a(),sequence:i().int().positive(),type:a(),payload:t(a(),n()),actor:t(a(),n()),occurredAt:i().int().nonnegative()}),C=l({id:a(),taskId:a(),status:c([`pending`,`selecting`,`assigned`,`blocked`,`failed`,`cancelled`]),selectedAgentId:a().optional(),selectionReason:a().optional(),reasonCode:a().optional(),attempts:i(),updatedAt:i()}),w=c([`low`,`normal`,`high`,`critical`]),T=c([`title`,`body`,`phase`,`resolution`,`priority`,`dueAt`,`projectId`,`milestoneId`,`parentTaskId`,`ownerId`,`delegateAgentId`,`boardRank`,`contract`,`dependencies`,`context`,`runs`,`receipts`,`acceptance`,`feedback`,`attention`,`conversation`]),E=l({taskId:a().min(1),projectId:a().min(1).optional(),version:i().int().positive(),changedFields:o(T).min(1),source:c([`user`,`agent`,`runtime`]),actorId:a().min(1).optional(),occurredAt:i().int().nonnegative()}),D=l({taskId:a().min(1),projectId:a().min(1).optional(),deletedAt:i().int().nonnegative()}),O=c([`verified_auto`,`verified_then_review`,`manual`]),k=l({kind:c([`user`,`agent`,`system`,`integration`]),id:a().optional()}),A=l({taskId:a(),version:i().int().positive(),objective:a(),expectedOutputs:o(a()),acceptanceCriteria:o(a()),constraints:o(a()),approvalRequired:o(a()),assumptions:o(a()),risks:o(a()),acceptancePolicy:O,outputDestinations:o(t(a(),n())),createdBy:k,createdAt:i().int().nonnegative()}),j=l({id:a(),title:a(),body:a().optional(),phase:d,resolution:f.optional(),priority:w,dueAt:i().int().nonnegative().optional(),projectId:a().optional(),milestoneId:a().optional(),parentTaskId:a().optional(),ownerId:a().optional(),delegateAgentId:a().optional(),source:a(),locale:c([`en`,`zh`]).optional(),latestContractVersion:i().int().positive(),boardRank:i().finite().default(0),version:i().int().positive(),contract:A.optional(),createdAt:i().int().nonnegative(),updatedAt:i().int().nonnegative(),closedAt:i().int().nonnegative().optional()}).superRefine((e,t)=>{e.phase===`closed`!=!!e.resolution&&t.addIssue({code:`custom`,path:[`resolution`],message:`Closed tasks require a resolution and open tasks cannot have one`})}),M=c([`input`,`reference`,`constraint`,`deliverable`,`evidence`]),N=l({id:a(),taskId:a(),targetKind:c([`document`,`file`,`url`,`session`,`memory`,`task`,`artifact`,`source`]),targetId:a(),role:M,title:a().optional(),pinned:r(),retrievalPolicy:t(a(),n()),metadata:t(a(),n()),createdBy:k,createdAt:i().int().nonnegative(),updatedAt:i().int().nonnegative()}),P=l({id:a(),taskId:a(),capability:a(),scope:t(a(),n()),grantedBy:k,grantedAt:i().int().nonnegative(),expiresAt:i().int().nonnegative().optional(),revokedAt:i().int().nonnegative().optional()}),F=l({id:a(),title:a(),phase:d,resolution:f.optional(),allocation:C.optional(),operationalState:p}),I=l({kind:c([`artifact`,`test`,`state`,`source`]),title:a(),summary:a(),uri:a().optional(),verifies:o(a()).optional(),provenance:c([`tool`,`external`,`user`,`judge`]),strength:c([`observed`,`verified`]),observedAt:i().int().nonnegative()}),L=l({recommendation:a(),reasons:o(a()),rejectedAlternatives:o(l({option:a(),reason:a()})),uncertainty:a().optional(),confidence:i().min(0).max(1)}),R=l({runId:a(),status:c([`succeeded`,`failed`,`cancelled`]),summary:a(),changes:o(I),evidence:o(I),verification:l({status:c([`passed`,`failed`,`unverified`]),checks:o(l({criterion:a(),status:c([`passed`,`failed`,`unverified`]),evidenceTitles:o(a()),note:a().optional(),method:c([`tool_verified`,`model_reviewed`,`unverified`]).optional()}))}),remainingWork:o(a()),nextAction:a().optional(),needsUser:r(),completionVerdict:c([`achieved`,`partial`,`not_achieved`]).optional(),failure:l({code:a(),phase:a(),recoveryAction:a()}).optional(),judgment:L.optional(),contextTraceId:a().optional(),finalizedAt:i().int().nonnegative()}),z=l({contractVersion:i().int().positive(),criterionIndex:i().int().nonnegative(),criterionText:a(),status:c([`passed`,`failed`]),note:a().optional(),reviewedBy:k,reviewedAt:i().int().nonnegative()});l({expectedVersion:i().int().positive(),contractVersion:i().int().positive(),status:c([`passed`,`failed`]),note:a().trim().max(2e3).optional()}).strict();var B=e(`kind`,[l({kind:s(`agent`),agentId:a().min(1)}),l({kind:s(`workflow`),workflowId:a().min(1),workflowVersion:a().min(1).optional(),input:n().optional()}),l({kind:s(`human`),actorId:a().min(1)}),l({kind:s(`external`),provider:a().min(1),config:n()})]),V=A.omit({taskId:!0,version:!0,createdBy:!0,createdAt:!0}),H=N.omit({id:!0,taskId:!0,createdBy:!0,createdAt:!0,updatedAt:!0});l({idempotencyKey:a().trim().min(1).max(200),title:a().trim().min(1).max(500),body:a().trim().max(5e4).optional(),projectId:a().trim().min(1).optional(),milestoneId:a().trim().min(1).optional(),parentTaskId:a().trim().min(1).optional(),priority:w.default(`normal`),dueAt:i().int().nonnegative().optional(),ownerId:a().trim().min(1).optional(),delegateAgentId:a().trim().min(1).optional(),originConversationId:a().trim().min(1).optional(),locale:c([`en`,`zh`]).optional(),contract:V,dependencies:o(a().trim().min(1)).default([]),context:o(H).default([]),authorityGrants:o(l({capability:a().min(1),scope:t(a(),n()).default({}),expiresAt:i().int().nonnegative().optional()})).default([]),activation:e(`mode`,[l({mode:s(`allocate`),requirements:u}).strict(),l({mode:s(`capture`),phase:c([`backlog`,`ready`]).default(`backlog`)}),l({mode:s(`start`),executor:B.optional(),scheduleAt:i().int().nonnegative().optional()})])}).strict(),l({expectedVersion:i().int().positive(),title:a().trim().min(1).max(500).optional(),body:a().trim().max(5e4).nullable().optional(),projectId:a().trim().min(1).nullable().optional(),milestoneId:a().trim().min(1).nullable().optional(),parentTaskId:a().trim().min(1).nullable().optional(),priority:w.optional(),dueAt:i().int().nonnegative().nullable().optional(),ownerId:a().trim().min(1).nullable().optional()}).strict();var U=l({kind:c([`dependency`,`user_input`,`approval`,`external_event`,`scheduled_time`,`retry_backoff`,`paused`]),reason:a().min(1),condition:t(a(),n()).default({}),resumeAt:i().int().nonnegative().optional()}),W=e(`type`,[l({type:s(`retry_allocation`)}),l({type:s(`move`),phase:d,resolution:f.optional()}),l({type:s(`mark_ready`)}),l({type:s(`start`),executor:B,scheduleAt:i().int().nonnegative().optional()}),l({type:s(`request_review`)}),l({type:s(`close`),resolution:f}),l({type:s(`reopen`),phase:c([`backlog`,`ready`,`active`,`review`])}),l({type:s(`add_wait`),wait:U}),l({type:s(`resolve_wait`),waitId:a(),resolution:n().optional()}),l({type:s(`revise_contract`),contract:V})]),G=c([`board`,`mobile`,`api`,`runtime`,`undo`]),K=l({id:a(),taskId:a(),fromPhase:d,toPhase:d,fromResolution:f.optional(),toResolution:f.optional(),actor:k,source:G,operationId:a().optional(),runId:a().optional(),taskVersion:i().int().positive(),createdAt:i()});l({source:G.optional(),idempotencyKey:a().trim().min(1).max(200),expectedVersion:i().int().positive(),command:W}).strict(),l({dependsOnTaskIds:o(a().trim().min(1)),expectedVersion:i().int().positive()}).strict(),l({expectedVersion:i().int().positive(),beforeTaskId:a().trim().min(1).nullable().optional()}).strict();var q=l({ok:s(!0),items:o(l({task:j,allocation:C.optional(),operationalState:p,attention:o(_)}))}),J=l({ok:s(!0),task:j,allocation:C.optional(),operationalState:p,run:x.optional()}),Y=l({taskId:a(),activeConversationId:a().optional(),currentExecutorAgentId:a().optional(),assignmentEpoch:i().int().nonnegative(),status:c([`idle`,`active`]),updatedAt:i().int().nonnegative()}),X=l({id:a(),taskId:a(),conversationId:a(),role:c([`primary`,`discussion`,`execution`]),agentId:a().optional(),runId:a().optional(),assignmentEpoch:i().int().nonnegative(),status:c([`active`,`completed`,`superseded`,`failed`]),startedAt:i().int().nonnegative(),endedAt:i().int().nonnegative().optional(),createdAt:i().int().nonnegative()});l({toAgentId:a().trim().min(1),expectedVersion:i().int().positive(),idempotencyKey:a().trim().min(1).max(200)}).strict(),l({ok:s(!0),task:j,conversation:Y,fromAgentId:a().optional(),toAgentId:a(),activeConversationId:a(),assignmentEpoch:i().int().positive()});var Z=l({phaseChanges:o(K).default([]),ok:s(!0),task:j,allocation:C.optional(),operationalState:p,attention:o(_),waits:o(g),runs:o(x),receipts:o(R),criterionReviews:o(z),context:o(N),conversation:Y,sessions:o(X),authorityGrants:o(P),dependencies:o(F),dependents:o(F),allowedCommands:o(a())});l({ok:s(!0),items:o(R)});function Q(e){let t=new Set(e?.evidence.filter(e=>e.strength===`verified`).map(e=>e.title));return new Set(e?.verification.checks.filter(e=>e.status===`passed`&&e.evidenceTitles.some(e=>t.has(e))).map(e=>e.criterion))}export{f as _,F as a,q as c,Q as d,S as f,d as g,p as h,D as i,w as l,_ as m,W as n,Z as o,x as p,J as r,B as s,E as t,R as u,g as v};
|
|
@@ -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{a as i,n as ee,r as a}from"./locale-store-D5h-Ha6-.js";import{a as te,i as ne,n as o,o as re,r as ie,s as ae,t as oe}from"./dist-BGTk37IG.js";import{i as s}from"./vendor-swr-BIWyz7Rc.js";import{Ao as se,Kc as c,Ns as ce,Rc as l,us as u}from"./index-DmURUvvA.js";import{t as d}from"./number-input-DDeqHK-G.js";import{n as le,r as ue}from"./settings-page-layout-Dx5S-Msc.js";import{n as f,t as p}from"./use-autosave-BnMIUc_5.js";var m=e(t(),1),h=n(),g=e=>a(`/api/observability/${e}`);async function _(e,t=`GET`,n){return i(g(e),{method:t,...n===void 0?{}:{body:JSON.stringify(n)}})}var v=r(),y=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,b=`space-y-4 rounded-xl border border-edge bg-surface-panel p-4`,x=(e=0)=>`${(e/1048576).toFixed(1)} MiB`;function S(){let e=(0,h.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,v.jsxs)(`div`,{"aria-busy":`true`,className:`space-y-4`,children:[(0,v.jsx)(l,{className:`h-48 rounded-xl`}),(0,v.jsx)(l,{className:`h-64 rounded-xl`})]}),e[0]=t):t=e[0],t}function de(e,t){let n=0,r=e,i=new Set;for(;r.parentSpanId&&n<12&&!i.has(r.spanId);){i.add(r.spanId);let e=t.find(e=>e.spanId===r.parentSpanId);if(!e)break;r=e,n++}return n}function fe(e){let t=[],n=new Set;function r(i){n.has(i.spanId)||(n.add(i.spanId),t.push(i),e.filter(e=>e.parentSpanId===i.spanId).forEach(r))}return e.filter(t=>!t.parentSpanId||!e.some(e=>e.spanId===t.parentSpanId)).forEach(r),e.forEach(r),t}function pe(){let e=ee(e=>e.language)===`zh`,t=(t,n)=>e?n:t,n=s(g(`tracing/settings`),()=>_(`tracing/settings`)),r=s(g(`tracing/status`),()=>_(`tracing/status`),{refreshInterval:1e4}),[i,a]=(0,m.useState)(),[h,pe]=(0,m.useState)(),C=i??h??n.data?.config,[w,T]=(0,m.useState)(``),[E,D]=(0,m.useState)(``),[me,O]=(0,m.useState)(0),[k,he]=(0,m.useState)(!1),[ge,A]=(0,m.useState)(``),[_e,ve]=(0,m.useState)(!1),[j,ye]=(0,m.useState)(``),[M,be]=(0,m.useState)(`7`),[N,xe]=(0,m.useState)({conversationId:``,runId:``,agentId:``}),[P,F]=(0,m.useState)(`records`),[I,Se]=(0,m.useState)(`10`),[Ce,L]=(0,m.useState)([``]),[R,z]=(0,m.useState)(0),[we,Te]=(0,m.useState)(()=>Date.now()+1),B=Ce[R],[V,H]=(0,m.useState)();function U(){L([``]),z(0),Te(Date.now()+1)}let[Ee,W]=(0,m.useState)(!1),G=new URLSearchParams({limit:I,from:String(we-Number(M)*864e5),to:String(we)});j&&G.set(`status`,j),B&&G.set(`cursor`,B);for(let[e,t]of Object.entries(N))t&&G.set(e,t);let De=`traces?${G}`,K=s(g(De),()=>_(De),{refreshInterval:B?0:1e4}),q=s(V?g(`traces/${V}`):null,()=>_(`traces/${V}`));function J(e){if(!C)return;let t=structuredClone(C);e(t),a(t)}async function Y(e,i=t(`Saved`,`已保存`)){he(!0),A(``),ve(!1);try{await e(),A(i),await Promise.all([n.mutate(),r.mutate(),K.mutate()])}catch(e){ve(!0),A(e instanceof Error?e.message:t(`Request failed`,`操作失败`))}finally{he(!1)}}let X=p({value:C??null,dirty:!!(i&&JSON.stringify(i)!==JSON.stringify(h??n.data?.config)),validate:e=>{if([[`retentionDays`,1,90],[`maxStoreMiB`,16,4096],[`maxTraces`,10,1e5],[`maxSpans`,100,1e6],[`maxTraceKiB`,16,4096],[`maxWriteMiBPerMinute`,1,100]].some(([t,n,r])=>!Number.isInteger(e.local[t])||e.local[t]<n||e.local[t]>r))return t(`Enter valid storage limits before continuing.`,`请填写有效的存储限额。`);try{let t=new URL(e.langfuse.baseUrl);if(![`http:`,`https:`].includes(t.protocol)||e.langfuse.baseUrl.length>2048)throw Error()}catch{return t(`Enter a valid HTTP(S) Base URL.`,`请填写有效的 HTTP(S) Base URL。`)}return null},onSave:async e=>{pe((await _(`tracing/settings`,`PATCH`,e)).config),a(t=>t&&JSON.stringify(t)===JSON.stringify(e)?void 0:t),await r.mutate().catch(()=>{})}}),Z=(0,m.useMemo)(()=>({publicKey:w.trim(),secretKey:E.trim()}),[w,E]),Q=p({value:Z,dirty:!!(Z.publicKey||Z.secretKey),delayMs:1e3,validate:e=>e.publicKey.length>512||e.secretKey.length>512?t(`Credentials must be at most 512 characters.`,`凭证长度不能超过 512 个字符。`):null,onSave:async e=>{await _(`tracing/langfuse/credentials`,`PUT`,{...e.publicKey?{publicKey:e.publicKey}:{},...e.secretKey?{secretKey:e.secretKey}:{}}),T(t=>t.trim()===e.publicKey?``:t),D(t=>t.trim()===e.secretKey?``:t),O(e=>e+1),await Promise.allSettled([n.mutate(),r.mutate()])}}),$=[X.status,Q.status].some(e=>e===`dirty`||e===`saving`);async function Oe(){V&&await Y(async()=>{let e=await _(`traces/${V}/export`),t=URL.createObjectURL(new Blob([JSON.stringify(e,null,2)],{type:`application/json`})),n=document.createElement(`a`);n.href=t,n.download=`trace-${V}.json`,n.click(),URL.revokeObjectURL(t)},t(`Exported`,`已导出`))}return(0,v.jsxs)(ue,{className:`space-y-6`,children:[(0,v.jsx)(le,{title:t(`Runtime tracing`,`运行追踪`),subtitle:t(`Local diagnostics with bounded retention. Enable Langfuse to also export new traces.`,`默认保留有界本地记录;启用 Langfuse 后同时导出新采集的追踪。`),actions:P===`settings`?(0,v.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,v.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t(`Changes save automatically`,`修改后自动保存`)}),(0,v.jsx)(f,{status:X.status,error:X.error})]}):(0,v.jsx)(c,{disabled:K.isValidating,onClick:U,children:t(`Refresh records`,`刷新记录`)})}),ge&&(0,v.jsx)(`p`,{role:_e?`alert`:`status`,className:`text-sm text-fg-muted`,children:ge}),n.error&&(0,v.jsx)(`p`,{role:`alert`,children:String(n.error.message)}),(0,v.jsxs)(se,{as:`nav`,"aria-label":t(`Tracing sections`,`追踪页面分区`),className:`flex gap-2 border-b border-edge pb-3`,children:[(0,v.jsx)(c,{"aria-pressed":P===`records`,variant:`ghost`,onClick:()=>F(`records`),children:t(`Execution records`,`执行记录`)}),(0,v.jsx)(c,{"aria-pressed":P===`settings`,variant:`ghost`,onClick:()=>F(`settings`),children:t(`Capture settings`,`采集设置`)})]}),P===`settings`&&(C?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`section`,{className:b,onBlurCapture:X.onBlurCapture,children:[(0,v.jsx)(`h2`,{className:`font-medium`,children:t(`Local recording`,`本地记录`)}),X.error&&(0,v.jsx)(c,{variant:`ghost`,onClick:X.retry,children:t(`Retry autosave`,`重试自动保存`)}),(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:C.enabled,onChange:e=>J(t=>{t.enabled=e.target.checked})}),t(`Record traces`,`记录运行追踪`)]}),(0,v.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Retention (days)`,`保留天数`),(0,v.jsx)(d,{className:y,type:`number`,min:1,max:90,value:C.local.retentionDays,onChange:e=>J(t=>{t.local.retentionDays=Number(e.target.value)})})]}),(0,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Storage budget (MiB)`,`存储上限(MiB)`),(0,v.jsx)(d,{className:y,type:`number`,min:16,max:4096,value:C.local.maxStoreMiB,onChange:e=>J(t=>{t.local.maxStoreMiB=Number(e.target.value)})})]}),(0,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Capture`,`采集内容`),(0,v.jsx)(u,{placeholder:t(`Choose`,`请选择`),allowEmpty:!1,value:C.capture,onChange:e=>J(t=>{t.capture=e}),options:[{value:`metadata`,label:t(`Metadata only`,`仅元数据`)},{value:`redacted`,label:t(`Redacted previews`,`脱敏摘要`)},{value:`detailed`,label:t(`Detailed · 30 minutes`,`详细记录 · 30 分钟`)}]})]})]}),(0,v.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t(`Previews may contain personal content. Secrets and media are filtered; large values are truncated.`,`摘要可能包含个人内容。过滤凭证和媒体,超长内容会截断。`)}),C.detailedUntil&&(0,v.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[t(`Detailed capture expires: `,`详细采集截止:`),new Date(C.detailedUntil).toLocaleString()]}),(0,v.jsxs)(`details`,{children:[(0,v.jsx)(`summary`,{className:`cursor-pointer text-sm`,children:t(`Advanced limits`,`高级限制`)}),(0,v.jsx)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[[`maxTraces`,t(`Trace count`,`Trace 条数`)],[`maxSpans`,t(`Span count`,`Span 条数`)],[`maxTraceKiB`,t(`Per trace (KiB)`,`单 Trace 上限(KiB)`)],[`maxWriteMiBPerMinute`,t(`Write budget (MiB/minute)`,`写入额度(MiB/分钟)`)]].map(([e,t])=>(0,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t,(0,v.jsx)(d,{type:`number`,min:1,className:y,value:C.local[e],onChange:t=>J(n=>{n.local[e]=Number(t.target.value)})})]},e))})]}),r.data?(0,v.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[t(`Disk / payload`,`磁盘 / 数据`),`:`,x(r.data.local.physicalBytes),` / `,x(r.data.local.bytes),` · `,r.data.local.traces??0,` traces · `,r.data.local.spans??0,` spans · `,t(`Dropped`,`丢弃`),` `,Number(r.data.local.dropped??0)+Number(r.data.local.queueDropped??0),(r.data.local.paused||r.data.local.unavailable)&&` · ${t(`Recording paused`,`存储暂停`)}`]}):(0,v.jsx)(l,{className:`h-10`}),(r.error||r.data?.local.lastError)&&(0,v.jsx)(`p`,{role:`alert`,className:`text-sm`,children:r.data?.local.lastError||String(r.error.message)}),(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(c,{disabled:k||$,onClick:()=>void Y(async()=>{await _(`traces/prune`,`POST`)}),children:t(`Clean expired`,`清理过期记录`)}),(0,v.jsx)(c,{disabled:k,onClick:()=>W(!0),children:t(`Clear local traces`,`清空本地追踪`)})]})]}),(0,v.jsxs)(`section`,{className:b,children:[(0,v.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,v.jsx)(`h2`,{className:`font-medium`,children:`Langfuse`}),(0,v.jsx)(f,{status:Q.status,error:Q.error})]}),Q.error&&(0,v.jsx)(c,{variant:`ghost`,onClick:Q.retry,children:t(`Retry autosave`,`重试自动保存`)}),(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:C.langfuse.enabled,onBlur:X.onBlurCapture,onChange:e=>J(t=>{t.langfuse.enabled=e.target.checked})}),t(`Also export new traces to Langfuse`,`同时导出新采集的追踪到 Langfuse`)]}),(0,v.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,v.jsxs)(`label`,{className:`space-y-1 text-sm sm:col-span-2`,children:[`Base URL`,(0,v.jsx)(`input`,{className:y,type:`url`,value:C.langfuse.baseUrl,onBlur:X.onBlurCapture,onChange:e=>J(t=>{t.langfuse.baseUrl=e.target.value})})]}),[`publicKey`,`secretKey`].map(e=>{let r=e===`publicKey`?`Public Key`:`Secret Key`,i=e===`publicKey`?w:E,ee=n.data?.credentials[e===`publicKey`?`publicKeyConfigured`:`secretKeyConfigured`];return(0,v.jsxs)(`div`,{className:`space-y-1 text-sm`,onBlurCapture:Q.onBlurCapture,children:[(0,v.jsx)(`label`,{htmlFor:`langfuse-${e}`,children:r}),(0,v.jsx)(ce,{id:`langfuse-${e}`,value:i||(ee?`••••••••••••`:``),allowUnrevealedCopy:!0,onChange:t=>(e===`publicKey`?T:D)(t.replace(/^•+/,``)),placeholder:e===`publicKey`?`pk-lf-…`:`sk-lf-…`,labels:{show:t(`Show ${r}`,`查看 ${r}`),hide:t(`Hide ${r}`,`隐藏 ${r}`),copy:t(`Copy ${r}`,`复制 ${r}`),copied:t(`Copied`,`已复制`)},reveal:()=>_(`tracing/langfuse/credentials/${e}/reveal`,`POST`).then(e=>e.key),loadFailedLabel:t(`Unable to load the configured key.`,`无法读取已配置的 Key。`),notInConfigFile:t(`No configured key is available.`,`暂无已配置的 Key。`)},me)]},e)})]}),(0,v.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[t(`Credential sources`,`凭证来源`),`:`,n.data?.credentials.publicKeySource,` / `,n.data?.credentials.secretKeySource,` · URL: `,n.data?.credentials.baseUrlSource]}),r.data&&(0,v.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[r.data.langfuse.state,` · `,t(`Pending`,`待发送`),` `,r.data.langfuse.pending,` · `,t(`Dropped`,`丢弃`),` `,r.data.langfuse.dropped,r.data.langfuse.lastSuccess?` · ${new Date(r.data.langfuse.lastSuccess).toLocaleString()}`:``]}),r.data?.langfuse.lastError&&(0,v.jsx)(`p`,{role:`alert`,className:`text-sm`,children:r.data.langfuse.lastError}),(0,v.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t(`Changes save automatically. Historical traces are not uploaded. Offline exports may be dropped.`,`修改后自动保存。不会上传历史记录;断网或队列满时可能丢弃远端导出。`)}),(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(c,{disabled:k||$,onClick:()=>void Y(async()=>{if(!(await _(`tracing/langfuse/test`,`POST`)).ok)throw Error(t(`Connection test failed. Check saved configuration and credentials.`,`连接测试失败,请检查已保存的配置和凭证。`))},t(`Diagnostic trace accepted by the ingestion endpoint`,`采集端已接受诊断追踪`)),children:t(`Test connection`,`测试连接`)}),(0,v.jsx)(c,{disabled:k||$,onClick:()=>void Y(async()=>{await _(`tracing/langfuse/credentials`,`DELETE`),T(``),D(``),O(e=>e+1)}),children:t(`Remove saved credentials`,`移除已保存凭证`)})]})]})]}):(0,v.jsx)(S,{})),P===`records`&&(0,v.jsxs)(`section`,{className:b,children:[(0,v.jsx)(`h2`,{className:`font-medium`,children:t(`Recent runs`,`最近执行`)}),(0,v.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Status`,`执行状态`),(0,v.jsx)(u,{placeholder:t(`All statuses`,`全部状态`),allowEmpty:!1,value:j,onChange:e=>{ye(e),U()},options:[{value:``,label:t(`All statuses`,`全部状态`)},...[`running`,`success`,`error`,`cancelled`,`suspended`,`interrupted`].map(e=>({value:e,label:t(e,{running:`运行中`,success:`成功`,error:`失败`,cancelled:`已取消`,suspended:`已暂停`,interrupted:`已中断`}[e])}))]})]}),(0,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Time range`,`时间范围`),(0,v.jsx)(u,{placeholder:t(`Choose`,`请选择`),value:M,allowEmpty:!1,onChange:e=>{be(e),U()},options:[`1`,`7`,`30`,`90`].map(e=>({value:e,label:`${e} ${t(`days`,`天`)}`}))})]}),(0,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Page size`,`每页条数`),(0,v.jsx)(u,{placeholder:t(`Choose`,`请选择`),value:I,allowEmpty:!1,onChange:e=>{Se(e),U()},options:[`10`,`20`].map(e=>({value:e,label:`${e} ${t(`records`,`条`)}`}))})]})]}),(0,v.jsxs)(`details`,{children:[(0,v.jsxs)(`summary`,{className:`cursor-pointer text-sm text-fg-muted`,children:[t(`Advanced filters`,`高级筛选`),Object.values(N).some(Boolean)?` · ${t(`Active`,`已启用`)}`:``]}),(0,v.jsx)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-3`,children:[`conversationId`,`runId`,`agentId`].map(e=>(0,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[{conversationId:t(`Conversation ID`,`会话 ID`),runId:t(`Run ID`,`执行 ID`),agentId:t(`Agent ID`,`Agent ID`)}[e],(0,v.jsx)(`input`,{"aria-label":e,placeholder:t(`Exact ID`,`输入完整 ID`),className:y,value:N[e],onChange:t=>{xe({...N,[e]:t.target.value}),U()}})]},e))})]}),(0,v.jsxs)(`div`,{role:`region`,"aria-label":t(`Execution results`,`执行结果`),"aria-busy":K.isValidating,className:`h-[24rem] min-h-0 overflow-y-auto overscroll-contain rounded-lg border border-edge sm:h-[28rem]`,children:[K.error&&(0,v.jsx)(`p`,{role:`alert`,className:`p-4 text-sm`,children:K.error.message}),!K.data&&!K.error?(0,v.jsx)(`div`,{className:`space-y-3 p-3`,children:[0,1,2,3,4].map(e=>(0,v.jsx)(l,{className:`h-16`},e))}):(0,v.jsxs)(`div`,{className:`divide-y divide-edge`,children:[K.data?.traces.length===0&&(0,v.jsx)(`p`,{className:`flex h-48 items-center justify-center px-4 text-sm text-fg-muted`,children:t(`No traces in this range`,`此时间范围内暂无记录`)}),K.data?.traces.map(n=>(0,v.jsxs)(`button`,{onClick:()=>H(n.traceId),className:`flex w-full flex-col gap-2 px-3 py-3 text-left text-sm hover:bg-surface-hover sm:flex-row sm:items-center sm:justify-between`,children:[(0,v.jsxs)(`div`,{className:`min-w-0`,children:[(0,v.jsxs)(`p`,{className:`truncate font-medium`,children:[n.name,n.attributes[`xopc.agentId`]?` · ${n.attributes[`xopc.agentId`]}`:``]}),(0,v.jsxs)(`p`,{className:`truncate text-xs text-fg-muted`,children:[new Date(n.startedAt).toLocaleString(e?`zh-CN`:`en-US`),` · `,n.traceId]}),n.stats&&(0,v.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[n.stats.generations,` `,t(`model calls`,`次模型调用`),` · `,n.stats.tokens,` tokens · $`,n.stats.knownCostUsd.toFixed(4),n.stats.unknownCostCalls>0?` · ${t(`partial cost`,`部分成本未知`)}`:``]})]}),(0,v.jsxs)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:[t(n.status,{running:`运行中`,success:`成功`,error:`失败`,cancelled:`已取消`,suspended:`已暂停`,interrupted:`已中断`}[n.status]??n.status),` · `,n.endedAt?`${Math.round(n.endedAt-n.startedAt)} ms`:`—`,n.partialReason?` · ${t(`Partial`,`部分记录`)}`:``]})]},n.traceId))]})]}),(0,v.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,v.jsx)(`p`,{"aria-live":`polite`,className:`text-xs text-fg-muted`,children:t(`Page ${R+1} · ${K.data?.traces.length??0} records`,`第 ${R+1} 页 · ${K.data?.traces.length??0} 条`)}),(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(c,{disabled:R===0||K.isValidating,onClick:()=>z(e=>Math.max(0,e-1)),children:t(`Previous page`,`上一页`)}),(0,v.jsx)(c,{disabled:!K.data?.nextCursor||K.isValidating,onClick:()=>{let e=K.data?.nextCursor;e&&(L(t=>[...t.slice(0,R+1),e]),z(e=>e+1))},children:t(`Next page`,`下一页`)})]})]})]}),(0,v.jsx)(oe,{open:!!V,onOpenChange:e=>{e||H(void 0)},children:(0,v.jsxs)(re,{children:[(0,v.jsx)(te,{className:`fixed inset-0 z-[90] bg-black/40`}),(0,v.jsxs)(ie,{className:`fixed left-1/2 top-1/2 z-[91] flex h-[min(44rem,calc(100vh-2rem))] w-[min(64rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay p-4`,children:[(0,v.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3`,children:[(0,v.jsx)(ae,{className:`font-medium`,children:t(`Trace details`,`追踪详情`)}),(0,v.jsx)(o,{asChild:!0,children:(0,v.jsx)(c,{children:t(`Close`,`关闭`)})})]}),(0,v.jsx)(ne,{className:`shrink-0 truncate text-xs text-fg-muted`,children:V}),(0,v.jsx)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto py-4`,children:q.error?(0,v.jsx)(`p`,{role:`alert`,children:q.error.message}):q.data?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`p`,{className:`text-sm`,children:[q.data.trace.status,` `,q.data.trace.partialReason&&` · ${q.data.trace.partialReason}`]}),fe(q.data.spans).map(e=>(0,v.jsxs)(`details`,{style:{marginLeft:de(e,q.data.spans)*12},className:`rounded-lg border border-edge p-3 text-sm`,children:[(0,v.jsxs)(`summary`,{className:`cursor-pointer`,children:[e.name,` · `,e.status,` · `,e.endedAt?`${Math.round(e.endedAt-e.startedAt)} ms`:`—`]}),(0,v.jsx)(`pre`,{className:`mt-3 whitespace-pre-wrap break-all text-xs text-fg-muted`,children:JSON.stringify(e.attributes,null,2)})]},e.spanId))]}):(0,v.jsx)(S,{})}),(0,v.jsx)(`div`,{className:`shrink-0 border-t border-edge pt-3`,children:(0,v.jsx)(c,{disabled:!q.data||k,onClick:()=>void Oe(),children:t(`Export JSON`,`导出 JSON`)})})]})]})}),(0,v.jsx)(oe,{open:Ee,onOpenChange:W,children:(0,v.jsxs)(re,{children:[(0,v.jsx)(te,{className:`fixed inset-0 z-[90] bg-black/40`}),(0,v.jsxs)(ie,{className:`fixed left-1/2 top-1/2 z-[91] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 space-y-4 rounded-xl border border-edge bg-surface-overlay p-5`,children:[(0,v.jsx)(ae,{children:t(`Clear local traces?`,`清空本地追踪?`)}),(0,v.jsx)(ne,{className:`text-sm text-fg-muted`,children:t(`Removes retained local traces. Conversations, usage records and Langfuse data remain available.`,`删除已保留的本地追踪。会话、用量记录及 Langfuse 数据仍保留。`)}),(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(c,{disabled:k||$,onClick:()=>void Y(async()=>{await _(`traces`,`DELETE`),W(!1),H(void 0)}),children:t(`Clear`,`清空`)}),(0,v.jsx)(o,{asChild:!0,children:(0,v.jsx)(c,{children:t(`Cancel`,`取消`)})})]})]})]})})]})}export{pe as TracingSettingsPage};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{a as i,n as ee,r as a}from"./locale-store-D5h-Ha6-.js";import{a as te,i as ne,n as o,o as re,r as ie,s as ae,t as oe}from"./dist-BGTk37IG.js";import{i as s}from"./vendor-swr-BIWyz7Rc.js";import{Ao as se,Kc as c,Ns as ce,Rc as l,us as u}from"./index-DdJ_djQt.js";import{t as d}from"./number-input-DDeqHK-G.js";import{n as le,r as ue}from"./settings-page-layout-Dx5S-Msc.js";import{n as f,t as p}from"./use-autosave-0dTfTmCk.js";var m=e(t(),1),h=n(),g=e=>a(`/api/observability/${e}`);async function _(e,t=`GET`,n){return i(g(e),{method:t,...n===void 0?{}:{body:JSON.stringify(n)}})}var v=r(),y=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,b=`space-y-4 rounded-xl border border-edge bg-surface-panel p-4`,x=(e=0)=>`${(e/1048576).toFixed(1)} MiB`;function S(){let e=(0,h.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,v.jsxs)(`div`,{"aria-busy":`true`,className:`space-y-4`,children:[(0,v.jsx)(l,{className:`h-48 rounded-xl`}),(0,v.jsx)(l,{className:`h-64 rounded-xl`})]}),e[0]=t):t=e[0],t}function de(e,t){let n=0,r=e,i=new Set;for(;r.parentSpanId&&n<12&&!i.has(r.spanId);){i.add(r.spanId);let e=t.find(e=>e.spanId===r.parentSpanId);if(!e)break;r=e,n++}return n}function fe(e){let t=[],n=new Set;function r(i){n.has(i.spanId)||(n.add(i.spanId),t.push(i),e.filter(e=>e.parentSpanId===i.spanId).forEach(r))}return e.filter(t=>!t.parentSpanId||!e.some(e=>e.spanId===t.parentSpanId)).forEach(r),e.forEach(r),t}function pe(){let e=ee(e=>e.language)===`zh`,t=(t,n)=>e?n:t,n=s(g(`tracing/settings`),()=>_(`tracing/settings`)),r=s(g(`tracing/status`),()=>_(`tracing/status`),{refreshInterval:1e4}),[i,a]=(0,m.useState)(),[h,pe]=(0,m.useState)(),C=i??h??n.data?.config,[w,T]=(0,m.useState)(``),[E,D]=(0,m.useState)(``),[me,O]=(0,m.useState)(0),[k,he]=(0,m.useState)(!1),[ge,A]=(0,m.useState)(``),[_e,ve]=(0,m.useState)(!1),[j,ye]=(0,m.useState)(``),[M,be]=(0,m.useState)(`7`),[N,xe]=(0,m.useState)({conversationId:``,runId:``,agentId:``}),[P,F]=(0,m.useState)(`records`),[I,Se]=(0,m.useState)(`10`),[Ce,L]=(0,m.useState)([``]),[R,z]=(0,m.useState)(0),[we,Te]=(0,m.useState)(()=>Date.now()+1),B=Ce[R],[V,H]=(0,m.useState)();function U(){L([``]),z(0),Te(Date.now()+1)}let[Ee,W]=(0,m.useState)(!1),G=new URLSearchParams({limit:I,from:String(we-Number(M)*864e5),to:String(we)});j&&G.set(`status`,j),B&&G.set(`cursor`,B);for(let[e,t]of Object.entries(N))t&&G.set(e,t);let De=`traces?${G}`,K=s(g(De),()=>_(De),{refreshInterval:B?0:1e4}),q=s(V?g(`traces/${V}`):null,()=>_(`traces/${V}`));function J(e){if(!C)return;let t=structuredClone(C);e(t),a(t)}async function Y(e,i=t(`Saved`,`已保存`)){he(!0),A(``),ve(!1);try{await e(),A(i),await Promise.all([n.mutate(),r.mutate(),K.mutate()])}catch(e){ve(!0),A(e instanceof Error?e.message:t(`Request failed`,`操作失败`))}finally{he(!1)}}let X=p({value:C??null,dirty:!!(i&&JSON.stringify(i)!==JSON.stringify(h??n.data?.config)),validate:e=>{if([[`retentionDays`,1,90],[`maxStoreMiB`,16,4096],[`maxTraces`,10,1e5],[`maxSpans`,100,1e6],[`maxTraceKiB`,16,4096],[`maxWriteMiBPerMinute`,1,100]].some(([t,n,r])=>!Number.isInteger(e.local[t])||e.local[t]<n||e.local[t]>r))return t(`Enter valid storage limits before continuing.`,`请填写有效的存储限额。`);try{let t=new URL(e.langfuse.baseUrl);if(![`http:`,`https:`].includes(t.protocol)||e.langfuse.baseUrl.length>2048)throw Error()}catch{return t(`Enter a valid HTTP(S) Base URL.`,`请填写有效的 HTTP(S) Base URL。`)}return null},onSave:async e=>{pe((await _(`tracing/settings`,`PATCH`,e)).config),a(t=>t&&JSON.stringify(t)===JSON.stringify(e)?void 0:t),await r.mutate().catch(()=>{})}}),Z=(0,m.useMemo)(()=>({publicKey:w.trim(),secretKey:E.trim()}),[w,E]),Q=p({value:Z,dirty:!!(Z.publicKey||Z.secretKey),delayMs:1e3,validate:e=>e.publicKey.length>512||e.secretKey.length>512?t(`Credentials must be at most 512 characters.`,`凭证长度不能超过 512 个字符。`):null,onSave:async e=>{await _(`tracing/langfuse/credentials`,`PUT`,{...e.publicKey?{publicKey:e.publicKey}:{},...e.secretKey?{secretKey:e.secretKey}:{}}),T(t=>t.trim()===e.publicKey?``:t),D(t=>t.trim()===e.secretKey?``:t),O(e=>e+1),await Promise.allSettled([n.mutate(),r.mutate()])}}),$=[X.status,Q.status].some(e=>e===`dirty`||e===`saving`);async function Oe(){V&&await Y(async()=>{let e=await _(`traces/${V}/export`),t=URL.createObjectURL(new Blob([JSON.stringify(e,null,2)],{type:`application/json`})),n=document.createElement(`a`);n.href=t,n.download=`trace-${V}.json`,n.click(),URL.revokeObjectURL(t)},t(`Exported`,`已导出`))}return(0,v.jsxs)(ue,{className:`space-y-6`,children:[(0,v.jsx)(le,{title:t(`Runtime tracing`,`运行追踪`),subtitle:t(`Local diagnostics with bounded retention. Enable Langfuse to also export new traces.`,`默认保留有界本地记录;启用 Langfuse 后同时导出新采集的追踪。`),actions:P===`settings`?(0,v.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,v.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t(`Changes save automatically`,`修改后自动保存`)}),(0,v.jsx)(f,{status:X.status,error:X.error})]}):(0,v.jsx)(c,{disabled:K.isValidating,onClick:U,children:t(`Refresh records`,`刷新记录`)})}),ge&&(0,v.jsx)(`p`,{role:_e?`alert`:`status`,className:`text-sm text-fg-muted`,children:ge}),n.error&&(0,v.jsx)(`p`,{role:`alert`,children:String(n.error.message)}),(0,v.jsxs)(se,{as:`nav`,"aria-label":t(`Tracing sections`,`追踪页面分区`),className:`flex gap-2 border-b border-edge pb-3`,children:[(0,v.jsx)(c,{"aria-pressed":P===`records`,variant:`ghost`,onClick:()=>F(`records`),children:t(`Execution records`,`执行记录`)}),(0,v.jsx)(c,{"aria-pressed":P===`settings`,variant:`ghost`,onClick:()=>F(`settings`),children:t(`Capture settings`,`采集设置`)})]}),P===`settings`&&(C?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`section`,{className:b,onBlurCapture:X.onBlurCapture,children:[(0,v.jsx)(`h2`,{className:`font-medium`,children:t(`Local recording`,`本地记录`)}),X.error&&(0,v.jsx)(c,{variant:`ghost`,onClick:X.retry,children:t(`Retry autosave`,`重试自动保存`)}),(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:C.enabled,onChange:e=>J(t=>{t.enabled=e.target.checked})}),t(`Record traces`,`记录运行追踪`)]}),(0,v.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Retention (days)`,`保留天数`),(0,v.jsx)(d,{className:y,type:`number`,min:1,max:90,value:C.local.retentionDays,onChange:e=>J(t=>{t.local.retentionDays=Number(e.target.value)})})]}),(0,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Storage budget (MiB)`,`存储上限(MiB)`),(0,v.jsx)(d,{className:y,type:`number`,min:16,max:4096,value:C.local.maxStoreMiB,onChange:e=>J(t=>{t.local.maxStoreMiB=Number(e.target.value)})})]}),(0,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Capture`,`采集内容`),(0,v.jsx)(u,{placeholder:t(`Choose`,`请选择`),allowEmpty:!1,value:C.capture,onChange:e=>J(t=>{t.capture=e}),options:[{value:`metadata`,label:t(`Metadata only`,`仅元数据`)},{value:`redacted`,label:t(`Redacted previews`,`脱敏摘要`)},{value:`detailed`,label:t(`Detailed · 30 minutes`,`详细记录 · 30 分钟`)}]})]})]}),(0,v.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t(`Previews may contain personal content. Secrets and media are filtered; large values are truncated.`,`摘要可能包含个人内容。过滤凭证和媒体,超长内容会截断。`)}),C.detailedUntil&&(0,v.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[t(`Detailed capture expires: `,`详细采集截止:`),new Date(C.detailedUntil).toLocaleString()]}),(0,v.jsxs)(`details`,{children:[(0,v.jsx)(`summary`,{className:`cursor-pointer text-sm`,children:t(`Advanced limits`,`高级限制`)}),(0,v.jsx)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[[`maxTraces`,t(`Trace count`,`Trace 条数`)],[`maxSpans`,t(`Span count`,`Span 条数`)],[`maxTraceKiB`,t(`Per trace (KiB)`,`单 Trace 上限(KiB)`)],[`maxWriteMiBPerMinute`,t(`Write budget (MiB/minute)`,`写入额度(MiB/分钟)`)]].map(([e,t])=>(0,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t,(0,v.jsx)(d,{type:`number`,min:1,className:y,value:C.local[e],onChange:t=>J(n=>{n.local[e]=Number(t.target.value)})})]},e))})]}),r.data?(0,v.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[t(`Disk / payload`,`磁盘 / 数据`),`:`,x(r.data.local.physicalBytes),` / `,x(r.data.local.bytes),` · `,r.data.local.traces??0,` traces · `,r.data.local.spans??0,` spans · `,t(`Dropped`,`丢弃`),` `,Number(r.data.local.dropped??0)+Number(r.data.local.queueDropped??0),(r.data.local.paused||r.data.local.unavailable)&&` · ${t(`Recording paused`,`存储暂停`)}`]}):(0,v.jsx)(l,{className:`h-10`}),(r.error||r.data?.local.lastError)&&(0,v.jsx)(`p`,{role:`alert`,className:`text-sm`,children:r.data?.local.lastError||String(r.error.message)}),(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(c,{disabled:k||$,onClick:()=>void Y(async()=>{await _(`traces/prune`,`POST`)}),children:t(`Clean expired`,`清理过期记录`)}),(0,v.jsx)(c,{disabled:k,onClick:()=>W(!0),children:t(`Clear local traces`,`清空本地追踪`)})]})]}),(0,v.jsxs)(`section`,{className:b,children:[(0,v.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,v.jsx)(`h2`,{className:`font-medium`,children:`Langfuse`}),(0,v.jsx)(f,{status:Q.status,error:Q.error})]}),Q.error&&(0,v.jsx)(c,{variant:`ghost`,onClick:Q.retry,children:t(`Retry autosave`,`重试自动保存`)}),(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:C.langfuse.enabled,onBlur:X.onBlurCapture,onChange:e=>J(t=>{t.langfuse.enabled=e.target.checked})}),t(`Also export new traces to Langfuse`,`同时导出新采集的追踪到 Langfuse`)]}),(0,v.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,v.jsxs)(`label`,{className:`space-y-1 text-sm sm:col-span-2`,children:[`Base URL`,(0,v.jsx)(`input`,{className:y,type:`url`,value:C.langfuse.baseUrl,onBlur:X.onBlurCapture,onChange:e=>J(t=>{t.langfuse.baseUrl=e.target.value})})]}),[`publicKey`,`secretKey`].map(e=>{let r=e===`publicKey`?`Public Key`:`Secret Key`,i=e===`publicKey`?w:E,ee=n.data?.credentials[e===`publicKey`?`publicKeyConfigured`:`secretKeyConfigured`];return(0,v.jsxs)(`div`,{className:`space-y-1 text-sm`,onBlurCapture:Q.onBlurCapture,children:[(0,v.jsx)(`label`,{htmlFor:`langfuse-${e}`,children:r}),(0,v.jsx)(ce,{id:`langfuse-${e}`,value:i||(ee?`••••••••••••`:``),allowUnrevealedCopy:!0,onChange:t=>(e===`publicKey`?T:D)(t.replace(/^•+/,``)),placeholder:e===`publicKey`?`pk-lf-…`:`sk-lf-…`,labels:{show:t(`Show ${r}`,`查看 ${r}`),hide:t(`Hide ${r}`,`隐藏 ${r}`),copy:t(`Copy ${r}`,`复制 ${r}`),copied:t(`Copied`,`已复制`)},reveal:()=>_(`tracing/langfuse/credentials/${e}/reveal`,`POST`).then(e=>e.key),loadFailedLabel:t(`Unable to load the configured key.`,`无法读取已配置的 Key。`),notInConfigFile:t(`No configured key is available.`,`暂无已配置的 Key。`)},me)]},e)})]}),(0,v.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[t(`Credential sources`,`凭证来源`),`:`,n.data?.credentials.publicKeySource,` / `,n.data?.credentials.secretKeySource,` · URL: `,n.data?.credentials.baseUrlSource]}),r.data&&(0,v.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[r.data.langfuse.state,` · `,t(`Pending`,`待发送`),` `,r.data.langfuse.pending,` · `,t(`Dropped`,`丢弃`),` `,r.data.langfuse.dropped,r.data.langfuse.lastSuccess?` · ${new Date(r.data.langfuse.lastSuccess).toLocaleString()}`:``]}),r.data?.langfuse.lastError&&(0,v.jsx)(`p`,{role:`alert`,className:`text-sm`,children:r.data.langfuse.lastError}),(0,v.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t(`Changes save automatically. Historical traces are not uploaded. Offline exports may be dropped.`,`修改后自动保存。不会上传历史记录;断网或队列满时可能丢弃远端导出。`)}),(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(c,{disabled:k||$,onClick:()=>void Y(async()=>{if(!(await _(`tracing/langfuse/test`,`POST`)).ok)throw Error(t(`Connection test failed. Check saved configuration and credentials.`,`连接测试失败,请检查已保存的配置和凭证。`))},t(`Diagnostic trace accepted by the ingestion endpoint`,`采集端已接受诊断追踪`)),children:t(`Test connection`,`测试连接`)}),(0,v.jsx)(c,{disabled:k||$,onClick:()=>void Y(async()=>{await _(`tracing/langfuse/credentials`,`DELETE`),T(``),D(``),O(e=>e+1)}),children:t(`Remove saved credentials`,`移除已保存凭证`)})]})]})]}):(0,v.jsx)(S,{})),P===`records`&&(0,v.jsxs)(`section`,{className:b,children:[(0,v.jsx)(`h2`,{className:`font-medium`,children:t(`Recent runs`,`最近执行`)}),(0,v.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Status`,`执行状态`),(0,v.jsx)(u,{placeholder:t(`All statuses`,`全部状态`),allowEmpty:!1,value:j,onChange:e=>{ye(e),U()},options:[{value:``,label:t(`All statuses`,`全部状态`)},...[`running`,`success`,`error`,`cancelled`,`suspended`,`interrupted`].map(e=>({value:e,label:t(e,{running:`运行中`,success:`成功`,error:`失败`,cancelled:`已取消`,suspended:`已暂停`,interrupted:`已中断`}[e])}))]})]}),(0,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Time range`,`时间范围`),(0,v.jsx)(u,{placeholder:t(`Choose`,`请选择`),value:M,allowEmpty:!1,onChange:e=>{be(e),U()},options:[`1`,`7`,`30`,`90`].map(e=>({value:e,label:`${e} ${t(`days`,`天`)}`}))})]}),(0,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[t(`Page size`,`每页条数`),(0,v.jsx)(u,{placeholder:t(`Choose`,`请选择`),value:I,allowEmpty:!1,onChange:e=>{Se(e),U()},options:[`10`,`20`].map(e=>({value:e,label:`${e} ${t(`records`,`条`)}`}))})]})]}),(0,v.jsxs)(`details`,{children:[(0,v.jsxs)(`summary`,{className:`cursor-pointer text-sm text-fg-muted`,children:[t(`Advanced filters`,`高级筛选`),Object.values(N).some(Boolean)?` · ${t(`Active`,`已启用`)}`:``]}),(0,v.jsx)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-3`,children:[`conversationId`,`runId`,`agentId`].map(e=>(0,v.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[{conversationId:t(`Conversation ID`,`会话 ID`),runId:t(`Run ID`,`执行 ID`),agentId:t(`Agent ID`,`Agent ID`)}[e],(0,v.jsx)(`input`,{"aria-label":e,placeholder:t(`Exact ID`,`输入完整 ID`),className:y,value:N[e],onChange:t=>{xe({...N,[e]:t.target.value}),U()}})]},e))})]}),(0,v.jsxs)(`div`,{role:`region`,"aria-label":t(`Execution results`,`执行结果`),"aria-busy":K.isValidating,className:`h-[24rem] min-h-0 overflow-y-auto overscroll-contain rounded-lg border border-edge sm:h-[28rem]`,children:[K.error&&(0,v.jsx)(`p`,{role:`alert`,className:`p-4 text-sm`,children:K.error.message}),!K.data&&!K.error?(0,v.jsx)(`div`,{className:`space-y-3 p-3`,children:[0,1,2,3,4].map(e=>(0,v.jsx)(l,{className:`h-16`},e))}):(0,v.jsxs)(`div`,{className:`divide-y divide-edge`,children:[K.data?.traces.length===0&&(0,v.jsx)(`p`,{className:`flex h-48 items-center justify-center px-4 text-sm text-fg-muted`,children:t(`No traces in this range`,`此时间范围内暂无记录`)}),K.data?.traces.map(n=>(0,v.jsxs)(`button`,{onClick:()=>H(n.traceId),className:`flex w-full flex-col gap-2 px-3 py-3 text-left text-sm hover:bg-surface-hover sm:flex-row sm:items-center sm:justify-between`,children:[(0,v.jsxs)(`div`,{className:`min-w-0`,children:[(0,v.jsxs)(`p`,{className:`truncate font-medium`,children:[n.name,n.attributes[`xopc.agentId`]?` · ${n.attributes[`xopc.agentId`]}`:``]}),(0,v.jsxs)(`p`,{className:`truncate text-xs text-fg-muted`,children:[new Date(n.startedAt).toLocaleString(e?`zh-CN`:`en-US`),` · `,n.traceId]}),n.stats&&(0,v.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[n.stats.generations,` `,t(`model calls`,`次模型调用`),` · `,n.stats.tokens,` tokens · $`,n.stats.knownCostUsd.toFixed(4),n.stats.unknownCostCalls>0?` · ${t(`partial cost`,`部分成本未知`)}`:``]})]}),(0,v.jsxs)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:[t(n.status,{running:`运行中`,success:`成功`,error:`失败`,cancelled:`已取消`,suspended:`已暂停`,interrupted:`已中断`}[n.status]??n.status),` · `,n.endedAt?`${Math.round(n.endedAt-n.startedAt)} ms`:`—`,n.partialReason?` · ${t(`Partial`,`部分记录`)}`:``]})]},n.traceId))]})]}),(0,v.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,v.jsx)(`p`,{"aria-live":`polite`,className:`text-xs text-fg-muted`,children:t(`Page ${R+1} · ${K.data?.traces.length??0} records`,`第 ${R+1} 页 · ${K.data?.traces.length??0} 条`)}),(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(c,{disabled:R===0||K.isValidating,onClick:()=>z(e=>Math.max(0,e-1)),children:t(`Previous page`,`上一页`)}),(0,v.jsx)(c,{disabled:!K.data?.nextCursor||K.isValidating,onClick:()=>{let e=K.data?.nextCursor;e&&(L(t=>[...t.slice(0,R+1),e]),z(e=>e+1))},children:t(`Next page`,`下一页`)})]})]})]}),(0,v.jsx)(oe,{open:!!V,onOpenChange:e=>{e||H(void 0)},children:(0,v.jsxs)(re,{children:[(0,v.jsx)(te,{className:`fixed inset-0 z-[90] bg-black/40`}),(0,v.jsxs)(ie,{className:`fixed left-1/2 top-1/2 z-[91] flex h-[min(44rem,calc(100vh-2rem))] w-[min(64rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay p-4`,children:[(0,v.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3`,children:[(0,v.jsx)(ae,{className:`font-medium`,children:t(`Trace details`,`追踪详情`)}),(0,v.jsx)(o,{asChild:!0,children:(0,v.jsx)(c,{children:t(`Close`,`关闭`)})})]}),(0,v.jsx)(ne,{className:`shrink-0 truncate text-xs text-fg-muted`,children:V}),(0,v.jsx)(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto py-4`,children:q.error?(0,v.jsx)(`p`,{role:`alert`,children:q.error.message}):q.data?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`p`,{className:`text-sm`,children:[q.data.trace.status,` `,q.data.trace.partialReason&&` · ${q.data.trace.partialReason}`]}),fe(q.data.spans).map(e=>(0,v.jsxs)(`details`,{style:{marginLeft:de(e,q.data.spans)*12},className:`rounded-lg border border-edge p-3 text-sm`,children:[(0,v.jsxs)(`summary`,{className:`cursor-pointer`,children:[e.name,` · `,e.status,` · `,e.endedAt?`${Math.round(e.endedAt-e.startedAt)} ms`:`—`]}),(0,v.jsx)(`pre`,{className:`mt-3 whitespace-pre-wrap break-all text-xs text-fg-muted`,children:JSON.stringify(e.attributes,null,2)})]},e.spanId))]}):(0,v.jsx)(S,{})}),(0,v.jsx)(`div`,{className:`shrink-0 border-t border-edge pt-3`,children:(0,v.jsx)(c,{disabled:!q.data||k,onClick:()=>void Oe(),children:t(`Export JSON`,`导出 JSON`)})})]})]})}),(0,v.jsx)(oe,{open:Ee,onOpenChange:W,children:(0,v.jsxs)(re,{children:[(0,v.jsx)(te,{className:`fixed inset-0 z-[90] bg-black/40`}),(0,v.jsxs)(ie,{className:`fixed left-1/2 top-1/2 z-[91] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 space-y-4 rounded-xl border border-edge bg-surface-overlay p-5`,children:[(0,v.jsx)(ae,{children:t(`Clear local traces?`,`清空本地追踪?`)}),(0,v.jsx)(ne,{className:`text-sm text-fg-muted`,children:t(`Removes retained local traces. Conversations, usage records and Langfuse data remain available.`,`删除已保留的本地追踪。会话、用量记录及 Langfuse 数据仍保留。`)}),(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(c,{disabled:k||$,onClick:()=>void Y(async()=>{await _(`traces`,`DELETE`),W(!1),H(void 0)}),children:t(`Clear`,`清空`)}),(0,v.jsx)(o,{asChild:!0,children:(0,v.jsx)(c,{children:t(`Cancel`,`取消`)})})]})]})]})})]})}export{pe as TracingSettingsPage};
|
|
@@ -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"./external-link-DjqjBmc3.js";import{t as a}from"./messages-Bwv-AOYl.js";import{t as o}from"./cn-0WouolD0.js";import{a as s,c,i as l,n as u,r as d}from"./locale-store-D5h-Ha6-.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{n as p,r as m}from"./gateway-config-swr-BvuySoCX.js";import{Ju as ee,Kc as h,Rc as g,Rs as _,Td as te,cs as v,gu as y,ja as b}from"./index-DmURUvvA.js";import{n as ne,t as re}from"./settings-form-section-BTUFu5KS.js";var x=e(t(),1),S=n(),C=r();function w(e){let t=(0,S.c)(10),{language:n,label:r,section:a,className:s}=e,c;t[0]!==n||t[1]!==a?(c=v(n,a),t[0]=n,t[1]=a,t[2]=c):c=t[2];let l;t[3]===s?l=t[4]:(l=o(`inline-flex items-center gap-1 text-sm font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,s),t[3]=s,t[4]=l);let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,C.jsx)(i,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=u):u=t[5];let d;return t[6]!==r||t[7]!==c||t[8]!==l?(d=(0,C.jsxs)(`a`,{href:c,target:`_blank`,rel:`noreferrer`,className:l,children:[r,u]}),t[6]=r,t[7]=c,t[8]=l,t[9]=d):d=t[9],d}async function T(){let e=await l(`/api/exposure/status`);if(!e.ok)throw Error(`Failed to load exposure status (${e.status})`);return await e.json()}async function E(e=`serve`){let t=await l(`/api/exposure/tailscale/start`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`Start failed (${t.status})`)}return await t.json()}async function D(){let e=await l(`/api/exposure/tailscale/stop`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`Stop failed (${e.status})`)}return await e.json()}var O=`https://tailscale.com/download`;function k(e){let t=(0,S.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,C.jsx)(`a`,{href:O,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent hover:underline`,children:n}),t[0]=n,t[1]=r),r}function A({embedded:e=!1}){let t=u(e=>e.language),n=a(t).remoteAccess.tailscale,r=(0,x.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:a(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]),i=!!c(e=>e.conversationId),[o,s]=(0,x.useState)(!1),[l,d]=(0,x.useState)(null),{data:p,mutate:m,isLoading:_}=f(i?`exposure-status`:null,T,{refreshInterval:3e4}),v=p?.tailscale.hostname,S=p?.tailscale.active===!0,O=p?.tailscale.cliAvailable!==!1,A=v?`https://${v}/`:null,ie=(0,x.useCallback)(async()=>{s(!0),d(null);try{await E(`serve`),await m()}catch(e){d(e instanceof Error?e.message:String(e))}finally{s(!1)}},[m]),ae=(0,x.useCallback)(async()=>{s(!0),d(null);try{await D(),await m()}catch(e){d(e instanceof Error?e.message:String(e))}finally{s(!1)}},[m]);if(!i)return null;let j=(0,C.jsxs)(`div`,{className:e?`space-y-4`:`mt-4 space-y-3`,children:[e?(0,C.jsxs)(`ol`,{className:`space-y-3 text-sm text-fg-muted`,children:[(0,C.jsxs)(`li`,{className:`flex gap-2`,children:[(0,C.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`1`}),(0,C.jsxs)(`span`,{children:[n.stepInstallBefore,(0,C.jsx)(k,{label:n.stepInstallLink}),n.stepInstallAfter]})]}),(0,C.jsxs)(`li`,{className:`flex gap-2`,children:[(0,C.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`2`}),(0,C.jsx)(`span`,{children:n.stepEnable})]}),(0,C.jsxs)(`li`,{className:`flex gap-2`,children:[(0,C.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`3`}),(0,C.jsx)(`span`,{children:n.stepCopy})]})]}):null,e&&p?.tailscale.cliAvailable===!1?(0,C.jsxs)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-sm text-fg-muted`,children:[n.cliMissingIntro,` `,(0,C.jsx)(k,{label:n.cliMissingDownloadLink}),n.cliMissingSuffix]}):null,_&&!p?(0,C.jsxs)(`div`,{className:`grid gap-3`,"aria-busy":`true`,children:[(0,C.jsx)(g,{className:`h-20 rounded-lg`}),(0,C.jsx)(g,{className:`h-20 rounded-lg`})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(re,{children:[(0,C.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.statusLabel}),(0,C.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S?n.statusActive:n.statusOff}),A?(0,C.jsx)(`div`,{className:`mt-3`,children:(0,C.jsx)(b,{text:A,labels:r})}):null,l?(0,C.jsx)(`p`,{className:`mt-2 text-sm text-red-600 dark:text-red-400`,children:l}):null,(0,C.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:S?(0,C.jsxs)(h,{type:`button`,variant:`secondary`,disabled:o,onClick:()=>void ae(),children:[o?(0,C.jsx)(ee,{className:`mr-1 size-4 animate-spin`}):null,n.disableServe]}):(0,C.jsxs)(h,{type:`button`,disabled:o||!O,onClick:()=>void ie(),children:[o?(0,C.jsx)(ee,{className:`mr-1 size-4 animate-spin`}):(0,C.jsx)(y,{className:`mr-1 size-4`}),n.enableServe]})})]}),(0,C.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.hint}),(0,C.jsx)(w,{language:t,label:n.docsLink,section:`tailscale-serve`,className:`mt-2`})]})]});return e?j:(0,C.jsxs)(re,{children:[(0,C.jsx)(ne,{icon:te,title:n.title,subtitle:n.subtitle}),j]})}async function ie(e){let t=await l(d(`/api/tunnel/probe-public`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e})});if(!t.ok&&t.status!==400)throw Error(`Probe failed (${t.status})`);return await t.json()}async function ae(e){await s(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{publicUrl:e??null}})})}function j(e){let t=e.split(`.`).map(e=>Number.parseInt(e,10));if(t.length!==4||t.some(e=>!Number.isFinite(e)))return!1;let[n,r]=t;return n===10||n===127||n===169&&r===254||n===172&&r>=16&&r<=31||n===192&&r===168||n===100&&r>=64&&r<=127}function oe(){return(0,x.useMemo)(()=>{if(typeof window>`u`)return null;let{protocol:e,hostname:t,origin:n}=window.location;if(e!==`https:`&&e!==`http:`)return null;let r=t.toLowerCase();return!r||r===`localhost`||r===`127.0.0.1`||r===`::1`||r===`[::1]`||r.endsWith(`.local`)||r.endsWith(`.localhost`)||j(r)?null:n.toLowerCase().replace(/\/+$/,``)},[])}function se(){return o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,_,`dark:border-edge`)}function ce(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e.gateway;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t.publicUrl;return typeof n==`string`&&n.trim()?n.trim():null}function M(){let e=(0,S.c)(85),t=u(ue),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n.remoteAccess.reverseProxy,i=!!c(le),s=oe(),l=m(i).data?.payload?.config,d;e[2]===l?d=e[3]:(d=ce(l),e[2]=l,e[3]=d);let f=d,[g,_]=(0,x.useState)(``),v;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(v={busy:!1,result:null},e[4]=v):v=e[4];let[y,b]=(0,x.useState)(v),w;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(w={busy:!1,error:null},e[5]=w):w=e[5];let[T,E]=(0,x.useState)(w),D,O;e[6]!==f||e[7]!==s||e[8]!==g?(D=()=>{g||(f?_(f):s&&_(s))},O=[f,s,g],e[6]=f,e[7]=s,e[8]=g,e[9]=D,e[10]=O):(D=e[9],O=e[10]),(0,x.useEffect)(D,O);let k;bb0:{let t;e[11]===g?t=e[12]:(t=g.trim(),e[11]=g,e[12]=t);let n=t;if(n){k=n;break bb0}k=f??s??``}let A=k,j=!f&&!!s&&A===s,M;e[13]!==g||e[14]!==A?(M=async()=>{let e=g.trim()||A;if(e){b({busy:!0,result:null});try{b({busy:!1,result:await ie(e)})}catch(e){let t=e;b({busy:!1,result:{ok:!1,code:`NETWORK_ERROR`,message:t instanceof Error?t.message:String(t)}})}}},e[13]=g,e[14]=A,e[15]=M):M=e[15];let fe=M,N;e[16]===A?N=e[17]:(N=async()=>{let e=A.trim();if(e){E({busy:!0,error:null});try{await ae(e),await p(),E({busy:!1,error:null})}catch(e){let t=e;E({busy:!1,error:t instanceof Error?t.message:String(t)})}}},e[16]=A,e[17]=N);let pe=N,P;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(P=async()=>{E({busy:!0,error:null});try{await ae(null),await p(),_(``),b({busy:!1,result:null}),E({busy:!1,error:null})}catch(e){let t=e;E({busy:!1,error:t instanceof Error?t.message:String(t)})}},e[18]=P):P=e[18];let me=P;if(!i)return null;let F;e[19]!==r.subtitle||e[20]!==r.title?(F=(0,C.jsx)(ne,{icon:te,title:r.title,subtitle:r.subtitle}),e[19]=r.subtitle,e[20]=r.title,e[21]=F):F=e[21];let I;e[22]===r.urlLabel?I=e[23]:(I=(0,C.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`reverse-proxy-url`,children:r.urlLabel}),e[22]=r.urlLabel,e[23]=I);let L;e[24]===Symbol.for(`react.memo_cache_sentinel`)?(L=o(se(),`font-mono text-xs sm:flex-1 sm:min-w-0 sm:w-auto`),e[24]=L):L=e[24];let R;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(R=e=>{_(e.target.value),b({busy:!1,result:null})},e[25]=R):R=e[25];let z;e[26]!==g||e[27]!==r.urlPlaceholder||e[28]!==L?(z=(0,C.jsx)(`input`,{id:`reverse-proxy-url`,className:L,type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:r.urlPlaceholder,value:g,onChange:R}),e[26]=g,e[27]=r.urlPlaceholder,e[28]=L,e[29]=z):z=e[29];let B;e[30]===fe?B=e[31]:(B=()=>void fe(),e[30]=fe,e[31]=B);let V;e[32]!==g||e[33]!==y.busy?(V=y.busy||!g.trim(),e[32]=g,e[33]=y.busy,e[34]=V):V=e[34];let H;e[35]===y.busy?H=e[36]:(H=y.busy?(0,C.jsx)(ee,{className:`size-3.5 animate-spin`}):null,e[35]=y.busy,e[36]=H);let he=y.busy?r.probing:r.probeButton,U;e[37]!==B||e[38]!==V||e[39]!==H||e[40]!==he?(U=(0,C.jsxs)(h,{type:`button`,variant:`secondary`,className:`shrink-0 whitespace-nowrap`,onClick:B,disabled:V,children:[H,he]}),e[37]=B,e[38]=V,e[39]=H,e[40]=he,e[41]=U):U=e[41];let W;e[42]!==z||e[43]!==U?(W=(0,C.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch`,children:[z,U]}),e[42]=z,e[43]=U,e[44]=W):W=e[44];let G;e[45]===r.urlHint?G=e[46]:(G=(0,C.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.urlHint}),e[45]=r.urlHint,e[46]=G);let K;e[47]!==s||e[48]!==j||e[49]!==r.autoDetectedHint||e[50]!==r.autoDetectedTitle?(K=j&&s?(0,C.jsxs)(`div`,{className:`rounded-lg bg-accent-soft/60 px-3 py-2 text-xs leading-relaxed text-accent-fg`,children:[(0,C.jsx)(`div`,{className:`font-medium`,children:r.autoDetectedTitle}),(0,C.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px]`,children:s}),(0,C.jsx)(`p`,{className:`mt-1`,children:r.autoDetectedHint})]}):null,e[47]=s,e[48]=j,e[49]=r.autoDetectedHint,e[50]=r.autoDetectedTitle,e[51]=K):K=e[51];let q;e[52]!==y.result||e[53]!==r.probeStatus?(q=y.result?(0,C.jsx)(de,{result:y.result,labels:r.probeStatus}):null,e[52]=y.result,e[53]=r.probeStatus,e[54]=q):q=e[54];let J;e[55]!==f||e[56]!==A||e[57]!==pe||e[58]!==r.saveAsDefault||e[59]!==r.saving||e[60]!==T.busy?(J=A&&f!==A?(0,C.jsxs)(h,{type:`button`,onClick:()=>void pe(),disabled:T.busy,children:[T.busy?(0,C.jsx)(ee,{className:`size-3.5 animate-spin`}):null,T.busy?r.saving:r.saveAsDefault]}):null,e[55]=f,e[56]=A,e[57]=pe,e[58]=r.saveAsDefault,e[59]=r.saving,e[60]=T.busy,e[61]=J):J=e[61];let Y;e[62]!==f||e[63]!==r.clear||e[64]!==T.busy?(Y=f?(0,C.jsx)(h,{type:`button`,variant:`ghost`,onClick:()=>void me(),disabled:T.busy,children:r.clear}):null,e[62]=f,e[63]=r.clear,e[64]=T.busy,e[65]=Y):Y=e[65];let X;e[66]!==J||e[67]!==Y?(X=(0,C.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:[J,Y]}),e[66]=J,e[67]=Y,e[68]=X):X=e[68];let Z;e[69]===T.error?Z=e[70]:(Z=T.error?(0,C.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:T.error}):null,e[69]=T.error,e[70]=Z);let Q;e[71]===r.certWarning?Q=e[72]:(Q=(0,C.jsx)(`div`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-950 dark:bg-amber-950/30 dark:text-amber-100`,children:r.certWarning}),e[71]=r.certWarning,e[72]=Q);let $;e[73]!==I||e[74]!==W||e[75]!==G||e[76]!==K||e[77]!==q||e[78]!==X||e[79]!==Z||e[80]!==Q?($=(0,C.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[I,W,G,K,q,X,Z,Q]}),e[73]=I,e[74]=W,e[75]=G,e[76]=K,e[77]=q,e[78]=X,e[79]=Z,e[80]=Q,e[81]=$):$=e[81];let ge;return e[82]!==F||e[83]!==$?(ge=(0,C.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,C.jsxs)(re,{children:[F,$]})}),e[82]=F,e[83]=$,e[84]=ge):ge=e[84],ge}function le(e){return e.conversationId}function ue(e){return e.language}function de(e){let t=(0,S.c)(18),{result:n,labels:r}=e;if(n.ok){let e;t[0]===r.ok?e=t[1]:(e=(0,C.jsx)(`span`,{className:`font-medium`,children:r.ok}),t[0]=r.ok,t[1]=e);let i;t[2]===n.latencyMs?i=t[3]:(i=(0,C.jsxs)(`span`,{className:`font-mono`,children:[n.latencyMs,`ms`]}),t[2]=n.latencyMs,t[3]=i);let a;t[4]!==r.gatewayReady||t[5]!==n.gatewayReady?(a=n.gatewayReady?(0,C.jsxs)(C.Fragment,{children:[` · `,(0,C.jsx)(`span`,{children:r.gatewayReady})]}):null,t[4]=r.gatewayReady,t[5]=n.gatewayReady,t[6]=a):a=t[6];let o;return t[7]!==e||t[8]!==i||t[9]!==a?(o=(0,C.jsxs)(`div`,{className:`rounded-lg bg-emerald-50 px-3 py-2 text-xs text-emerald-900 dark:bg-emerald-950/30 dark:text-emerald-100`,children:[e,` · `,i,a]}),t[7]=e,t[8]=i,t[9]=a,t[10]=o):o=t[10],o}let i=r[`code_${n.code}`]??r.codeUnknown,a;t[11]===i?a=t[12]:(a=(0,C.jsx)(`span`,{className:`font-medium`,children:i}),t[11]=i,t[12]=a);let o;t[13]===n.message?o=t[14]:(o=n.message?(0,C.jsxs)(C.Fragment,{children:[` — `,(0,C.jsx)(`span`,{className:`font-mono break-all`,children:n.message})]}):null,t[13]=n.message,t[14]=o);let s;return t[15]!==a||t[16]!==o?(s=(0,C.jsxs)(`div`,{className:`rounded-lg bg-red-50 px-3 py-2 text-xs text-red-900 dark:bg-red-950/30 dark:text-red-100`,children:[a,o]}),t[15]=a,t[16]=o,t[17]=s):s=t[17],s}async function fe(){let e=await s(d(`/api/device-pairing/readiness`));return{ready:e.ready,routes:e.routes,protocolVersion:e.protocolVersion}}async function N(e){try{return{kind:`ready`,setup:(await s(d(`/api/device-pairing/setups`),{method:`POST`,body:JSON.stringify({targetKind:e})})).setup}}catch(e){if(e.body?.error?.code===`NO_SECURE_ROUTE`)return{kind:`needs-secure-route`};throw e}}async function pe(e){return s(d(`/api/device-pairing/setups/${encodeURIComponent(e)}`))}async function P(e){await s(d(`/api/device-pairing/setups/${encodeURIComponent(e)}`),{method:`DELETE`})}async function me(e,t){await s(d(`/api/device-pairing/requests/${encodeURIComponent(e.requestId)}/decision`),{method:`POST`,body:JSON.stringify({decision:t,expectedRevision:e.revision})})}async function F(){let e=await l(d(`/api/browser/extension/archive`));if(!e.ok)throw Error(`Browser extension download failed (${e.status})`);let t=e.headers.get(`Content-Disposition`)??``,n=/filename="([^"]+)"/.exec(t)?.[1]??`xopc-browser-extension.zip`,r=URL.createObjectURL(await e.blob());try{let e=document.createElement(`a`);e.href=r,e.download=n,e.click()}finally{URL.revokeObjectURL(r)}}var I=`https://console.xopc.ai/access/client`;function L(e){if(!e||typeof e!=`object`)return;let t=e.body;if(!t||typeof t!=`object`)return;let n=t.error;if(!n||typeof n!=`object`)return;let r=n.code;return typeof r==`string`?r:void 0}function R(e){return[`tunnel_oauth_required`,`invalid_token`,`insufficient_scope`].includes(L(e)??``)}async function z(){return s(d(`/api/tunnel/status`))}async function B(){await s(d(`/api/tunnel/consent`),{method:`POST`,body:JSON.stringify({})})}async function V(){await s(d(`/api/tunnel/registration-key`),{method:`POST`,body:JSON.stringify({})})}async function H(){return s(d(`/api/tunnel/start`),{method:`POST`,body:JSON.stringify({})})}async function he(e){return s(d(`/api/tunnel/stop`),{method:`POST`,body:JSON.stringify({release:e?.release===!0})})}async function U(){let e=(await s(d(`/api/tunnel/reveal-registration-secret`),{method:`POST`,body:JSON.stringify({})})).payload;if(!e)throw Error(`Missing reveal payload`);return{registrationSecret:e.registrationSecret??null,source:e.source===`config`?`config`:`none`}}async function W(e){await s(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({tunnel:e})})}export{M as _,B as a,w as b,he as c,P as d,N as f,pe as g,fe as h,V as i,L as l,F as m,z as n,U as o,me as p,W as r,H as s,I as t,R as u,A as v,T as y};
|
|
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"./external-link-DjqjBmc3.js";import{t as a}from"./messages-Bwv-AOYl.js";import{t as o}from"./cn-0WouolD0.js";import{a as s,c,i as l,n as u,r as d}from"./locale-store-D5h-Ha6-.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{n as p,r as m}from"./gateway-config-swr-BvuySoCX.js";import{Ju as ee,Kc as h,Rc as g,Rs as _,Td as te,cs as v,gu as y,ja as b}from"./index-DdJ_djQt.js";import{n as ne,t as re}from"./settings-form-section-CihKQYlF.js";var x=e(t(),1),S=n(),C=r();function w(e){let t=(0,S.c)(10),{language:n,label:r,section:a,className:s}=e,c;t[0]!==n||t[1]!==a?(c=v(n,a),t[0]=n,t[1]=a,t[2]=c):c=t[2];let l;t[3]===s?l=t[4]:(l=o(`inline-flex items-center gap-1 text-sm font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,s),t[3]=s,t[4]=l);let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,C.jsx)(i,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=u):u=t[5];let d;return t[6]!==r||t[7]!==c||t[8]!==l?(d=(0,C.jsxs)(`a`,{href:c,target:`_blank`,rel:`noreferrer`,className:l,children:[r,u]}),t[6]=r,t[7]=c,t[8]=l,t[9]=d):d=t[9],d}async function T(){let e=await l(`/api/exposure/status`);if(!e.ok)throw Error(`Failed to load exposure status (${e.status})`);return await e.json()}async function E(e=`serve`){let t=await l(`/api/exposure/tailscale/start`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`Start failed (${t.status})`)}return await t.json()}async function D(){let e=await l(`/api/exposure/tailscale/stop`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`Stop failed (${e.status})`)}return await e.json()}var O=`https://tailscale.com/download`;function k(e){let t=(0,S.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,C.jsx)(`a`,{href:O,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent hover:underline`,children:n}),t[0]=n,t[1]=r),r}function A({embedded:e=!1}){let t=u(e=>e.language),n=a(t).remoteAccess.tailscale,r=(0,x.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:a(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]),i=!!c(e=>e.conversationId),[o,s]=(0,x.useState)(!1),[l,d]=(0,x.useState)(null),{data:p,mutate:m,isLoading:_}=f(i?`exposure-status`:null,T,{refreshInterval:3e4}),v=p?.tailscale.hostname,S=p?.tailscale.active===!0,O=p?.tailscale.cliAvailable!==!1,A=v?`https://${v}/`:null,ie=(0,x.useCallback)(async()=>{s(!0),d(null);try{await E(`serve`),await m()}catch(e){d(e instanceof Error?e.message:String(e))}finally{s(!1)}},[m]),ae=(0,x.useCallback)(async()=>{s(!0),d(null);try{await D(),await m()}catch(e){d(e instanceof Error?e.message:String(e))}finally{s(!1)}},[m]);if(!i)return null;let j=(0,C.jsxs)(`div`,{className:e?`space-y-4`:`mt-4 space-y-3`,children:[e?(0,C.jsxs)(`ol`,{className:`space-y-3 text-sm text-fg-muted`,children:[(0,C.jsxs)(`li`,{className:`flex gap-2`,children:[(0,C.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`1`}),(0,C.jsxs)(`span`,{children:[n.stepInstallBefore,(0,C.jsx)(k,{label:n.stepInstallLink}),n.stepInstallAfter]})]}),(0,C.jsxs)(`li`,{className:`flex gap-2`,children:[(0,C.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`2`}),(0,C.jsx)(`span`,{children:n.stepEnable})]}),(0,C.jsxs)(`li`,{className:`flex gap-2`,children:[(0,C.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`3`}),(0,C.jsx)(`span`,{children:n.stepCopy})]})]}):null,e&&p?.tailscale.cliAvailable===!1?(0,C.jsxs)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-sm text-fg-muted`,children:[n.cliMissingIntro,` `,(0,C.jsx)(k,{label:n.cliMissingDownloadLink}),n.cliMissingSuffix]}):null,_&&!p?(0,C.jsxs)(`div`,{className:`grid gap-3`,"aria-busy":`true`,children:[(0,C.jsx)(g,{className:`h-20 rounded-lg`}),(0,C.jsx)(g,{className:`h-20 rounded-lg`})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(re,{children:[(0,C.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.statusLabel}),(0,C.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S?n.statusActive:n.statusOff}),A?(0,C.jsx)(`div`,{className:`mt-3`,children:(0,C.jsx)(b,{text:A,labels:r})}):null,l?(0,C.jsx)(`p`,{className:`mt-2 text-sm text-red-600 dark:text-red-400`,children:l}):null,(0,C.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:S?(0,C.jsxs)(h,{type:`button`,variant:`secondary`,disabled:o,onClick:()=>void ae(),children:[o?(0,C.jsx)(ee,{className:`mr-1 size-4 animate-spin`}):null,n.disableServe]}):(0,C.jsxs)(h,{type:`button`,disabled:o||!O,onClick:()=>void ie(),children:[o?(0,C.jsx)(ee,{className:`mr-1 size-4 animate-spin`}):(0,C.jsx)(y,{className:`mr-1 size-4`}),n.enableServe]})})]}),(0,C.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.hint}),(0,C.jsx)(w,{language:t,label:n.docsLink,section:`tailscale-serve`,className:`mt-2`})]})]});return e?j:(0,C.jsxs)(re,{children:[(0,C.jsx)(ne,{icon:te,title:n.title,subtitle:n.subtitle}),j]})}async function ie(e){let t=await l(d(`/api/tunnel/probe-public`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e})});if(!t.ok&&t.status!==400)throw Error(`Probe failed (${t.status})`);return await t.json()}async function ae(e){await s(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{publicUrl:e??null}})})}function j(e){let t=e.split(`.`).map(e=>Number.parseInt(e,10));if(t.length!==4||t.some(e=>!Number.isFinite(e)))return!1;let[n,r]=t;return n===10||n===127||n===169&&r===254||n===172&&r>=16&&r<=31||n===192&&r===168||n===100&&r>=64&&r<=127}function oe(){return(0,x.useMemo)(()=>{if(typeof window>`u`)return null;let{protocol:e,hostname:t,origin:n}=window.location;if(e!==`https:`&&e!==`http:`)return null;let r=t.toLowerCase();return!r||r===`localhost`||r===`127.0.0.1`||r===`::1`||r===`[::1]`||r.endsWith(`.local`)||r.endsWith(`.localhost`)||j(r)?null:n.toLowerCase().replace(/\/+$/,``)},[])}function se(){return o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,_,`dark:border-edge`)}function ce(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e.gateway;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t.publicUrl;return typeof n==`string`&&n.trim()?n.trim():null}function M(){let e=(0,S.c)(85),t=u(ue),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n.remoteAccess.reverseProxy,i=!!c(le),s=oe(),l=m(i).data?.payload?.config,d;e[2]===l?d=e[3]:(d=ce(l),e[2]=l,e[3]=d);let f=d,[g,_]=(0,x.useState)(``),v;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(v={busy:!1,result:null},e[4]=v):v=e[4];let[y,b]=(0,x.useState)(v),w;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(w={busy:!1,error:null},e[5]=w):w=e[5];let[T,E]=(0,x.useState)(w),D,O;e[6]!==f||e[7]!==s||e[8]!==g?(D=()=>{g||(f?_(f):s&&_(s))},O=[f,s,g],e[6]=f,e[7]=s,e[8]=g,e[9]=D,e[10]=O):(D=e[9],O=e[10]),(0,x.useEffect)(D,O);let k;bb0:{let t;e[11]===g?t=e[12]:(t=g.trim(),e[11]=g,e[12]=t);let n=t;if(n){k=n;break bb0}k=f??s??``}let A=k,j=!f&&!!s&&A===s,M;e[13]!==g||e[14]!==A?(M=async()=>{let e=g.trim()||A;if(e){b({busy:!0,result:null});try{b({busy:!1,result:await ie(e)})}catch(e){let t=e;b({busy:!1,result:{ok:!1,code:`NETWORK_ERROR`,message:t instanceof Error?t.message:String(t)}})}}},e[13]=g,e[14]=A,e[15]=M):M=e[15];let fe=M,N;e[16]===A?N=e[17]:(N=async()=>{let e=A.trim();if(e){E({busy:!0,error:null});try{await ae(e),await p(),E({busy:!1,error:null})}catch(e){let t=e;E({busy:!1,error:t instanceof Error?t.message:String(t)})}}},e[16]=A,e[17]=N);let pe=N,P;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(P=async()=>{E({busy:!0,error:null});try{await ae(null),await p(),_(``),b({busy:!1,result:null}),E({busy:!1,error:null})}catch(e){let t=e;E({busy:!1,error:t instanceof Error?t.message:String(t)})}},e[18]=P):P=e[18];let me=P;if(!i)return null;let F;e[19]!==r.subtitle||e[20]!==r.title?(F=(0,C.jsx)(ne,{icon:te,title:r.title,subtitle:r.subtitle}),e[19]=r.subtitle,e[20]=r.title,e[21]=F):F=e[21];let I;e[22]===r.urlLabel?I=e[23]:(I=(0,C.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`reverse-proxy-url`,children:r.urlLabel}),e[22]=r.urlLabel,e[23]=I);let L;e[24]===Symbol.for(`react.memo_cache_sentinel`)?(L=o(se(),`font-mono text-xs sm:flex-1 sm:min-w-0 sm:w-auto`),e[24]=L):L=e[24];let R;e[25]===Symbol.for(`react.memo_cache_sentinel`)?(R=e=>{_(e.target.value),b({busy:!1,result:null})},e[25]=R):R=e[25];let z;e[26]!==g||e[27]!==r.urlPlaceholder||e[28]!==L?(z=(0,C.jsx)(`input`,{id:`reverse-proxy-url`,className:L,type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:r.urlPlaceholder,value:g,onChange:R}),e[26]=g,e[27]=r.urlPlaceholder,e[28]=L,e[29]=z):z=e[29];let B;e[30]===fe?B=e[31]:(B=()=>void fe(),e[30]=fe,e[31]=B);let V;e[32]!==g||e[33]!==y.busy?(V=y.busy||!g.trim(),e[32]=g,e[33]=y.busy,e[34]=V):V=e[34];let H;e[35]===y.busy?H=e[36]:(H=y.busy?(0,C.jsx)(ee,{className:`size-3.5 animate-spin`}):null,e[35]=y.busy,e[36]=H);let he=y.busy?r.probing:r.probeButton,U;e[37]!==B||e[38]!==V||e[39]!==H||e[40]!==he?(U=(0,C.jsxs)(h,{type:`button`,variant:`secondary`,className:`shrink-0 whitespace-nowrap`,onClick:B,disabled:V,children:[H,he]}),e[37]=B,e[38]=V,e[39]=H,e[40]=he,e[41]=U):U=e[41];let W;e[42]!==z||e[43]!==U?(W=(0,C.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch`,children:[z,U]}),e[42]=z,e[43]=U,e[44]=W):W=e[44];let G;e[45]===r.urlHint?G=e[46]:(G=(0,C.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.urlHint}),e[45]=r.urlHint,e[46]=G);let K;e[47]!==s||e[48]!==j||e[49]!==r.autoDetectedHint||e[50]!==r.autoDetectedTitle?(K=j&&s?(0,C.jsxs)(`div`,{className:`rounded-lg bg-accent-soft/60 px-3 py-2 text-xs leading-relaxed text-accent-fg`,children:[(0,C.jsx)(`div`,{className:`font-medium`,children:r.autoDetectedTitle}),(0,C.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px]`,children:s}),(0,C.jsx)(`p`,{className:`mt-1`,children:r.autoDetectedHint})]}):null,e[47]=s,e[48]=j,e[49]=r.autoDetectedHint,e[50]=r.autoDetectedTitle,e[51]=K):K=e[51];let q;e[52]!==y.result||e[53]!==r.probeStatus?(q=y.result?(0,C.jsx)(de,{result:y.result,labels:r.probeStatus}):null,e[52]=y.result,e[53]=r.probeStatus,e[54]=q):q=e[54];let J;e[55]!==f||e[56]!==A||e[57]!==pe||e[58]!==r.saveAsDefault||e[59]!==r.saving||e[60]!==T.busy?(J=A&&f!==A?(0,C.jsxs)(h,{type:`button`,onClick:()=>void pe(),disabled:T.busy,children:[T.busy?(0,C.jsx)(ee,{className:`size-3.5 animate-spin`}):null,T.busy?r.saving:r.saveAsDefault]}):null,e[55]=f,e[56]=A,e[57]=pe,e[58]=r.saveAsDefault,e[59]=r.saving,e[60]=T.busy,e[61]=J):J=e[61];let Y;e[62]!==f||e[63]!==r.clear||e[64]!==T.busy?(Y=f?(0,C.jsx)(h,{type:`button`,variant:`ghost`,onClick:()=>void me(),disabled:T.busy,children:r.clear}):null,e[62]=f,e[63]=r.clear,e[64]=T.busy,e[65]=Y):Y=e[65];let X;e[66]!==J||e[67]!==Y?(X=(0,C.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:[J,Y]}),e[66]=J,e[67]=Y,e[68]=X):X=e[68];let Z;e[69]===T.error?Z=e[70]:(Z=T.error?(0,C.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:T.error}):null,e[69]=T.error,e[70]=Z);let Q;e[71]===r.certWarning?Q=e[72]:(Q=(0,C.jsx)(`div`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-950 dark:bg-amber-950/30 dark:text-amber-100`,children:r.certWarning}),e[71]=r.certWarning,e[72]=Q);let $;e[73]!==I||e[74]!==W||e[75]!==G||e[76]!==K||e[77]!==q||e[78]!==X||e[79]!==Z||e[80]!==Q?($=(0,C.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[I,W,G,K,q,X,Z,Q]}),e[73]=I,e[74]=W,e[75]=G,e[76]=K,e[77]=q,e[78]=X,e[79]=Z,e[80]=Q,e[81]=$):$=e[81];let ge;return e[82]!==F||e[83]!==$?(ge=(0,C.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,C.jsxs)(re,{children:[F,$]})}),e[82]=F,e[83]=$,e[84]=ge):ge=e[84],ge}function le(e){return e.conversationId}function ue(e){return e.language}function de(e){let t=(0,S.c)(18),{result:n,labels:r}=e;if(n.ok){let e;t[0]===r.ok?e=t[1]:(e=(0,C.jsx)(`span`,{className:`font-medium`,children:r.ok}),t[0]=r.ok,t[1]=e);let i;t[2]===n.latencyMs?i=t[3]:(i=(0,C.jsxs)(`span`,{className:`font-mono`,children:[n.latencyMs,`ms`]}),t[2]=n.latencyMs,t[3]=i);let a;t[4]!==r.gatewayReady||t[5]!==n.gatewayReady?(a=n.gatewayReady?(0,C.jsxs)(C.Fragment,{children:[` · `,(0,C.jsx)(`span`,{children:r.gatewayReady})]}):null,t[4]=r.gatewayReady,t[5]=n.gatewayReady,t[6]=a):a=t[6];let o;return t[7]!==e||t[8]!==i||t[9]!==a?(o=(0,C.jsxs)(`div`,{className:`rounded-lg bg-emerald-50 px-3 py-2 text-xs text-emerald-900 dark:bg-emerald-950/30 dark:text-emerald-100`,children:[e,` · `,i,a]}),t[7]=e,t[8]=i,t[9]=a,t[10]=o):o=t[10],o}let i=r[`code_${n.code}`]??r.codeUnknown,a;t[11]===i?a=t[12]:(a=(0,C.jsx)(`span`,{className:`font-medium`,children:i}),t[11]=i,t[12]=a);let o;t[13]===n.message?o=t[14]:(o=n.message?(0,C.jsxs)(C.Fragment,{children:[` — `,(0,C.jsx)(`span`,{className:`font-mono break-all`,children:n.message})]}):null,t[13]=n.message,t[14]=o);let s;return t[15]!==a||t[16]!==o?(s=(0,C.jsxs)(`div`,{className:`rounded-lg bg-red-50 px-3 py-2 text-xs text-red-900 dark:bg-red-950/30 dark:text-red-100`,children:[a,o]}),t[15]=a,t[16]=o,t[17]=s):s=t[17],s}async function fe(){let e=await s(d(`/api/device-pairing/readiness`));return{ready:e.ready,routes:e.routes,protocolVersion:e.protocolVersion}}async function N(e){try{return{kind:`ready`,setup:(await s(d(`/api/device-pairing/setups`),{method:`POST`,body:JSON.stringify({targetKind:e})})).setup}}catch(e){if(e.body?.error?.code===`NO_SECURE_ROUTE`)return{kind:`needs-secure-route`};throw e}}async function pe(e){return s(d(`/api/device-pairing/setups/${encodeURIComponent(e)}`))}async function P(e){await s(d(`/api/device-pairing/setups/${encodeURIComponent(e)}`),{method:`DELETE`})}async function me(e,t){await s(d(`/api/device-pairing/requests/${encodeURIComponent(e.requestId)}/decision`),{method:`POST`,body:JSON.stringify({decision:t,expectedRevision:e.revision})})}async function F(){let e=await l(d(`/api/browser/extension/archive`));if(!e.ok)throw Error(`Browser extension download failed (${e.status})`);let t=e.headers.get(`Content-Disposition`)??``,n=/filename="([^"]+)"/.exec(t)?.[1]??`xopc-browser-extension.zip`,r=URL.createObjectURL(await e.blob());try{let e=document.createElement(`a`);e.href=r,e.download=n,e.click()}finally{URL.revokeObjectURL(r)}}var I=`https://console.xopc.ai/access/client`;function L(e){if(!e||typeof e!=`object`)return;let t=e.body;if(!t||typeof t!=`object`)return;let n=t.error;if(!n||typeof n!=`object`)return;let r=n.code;return typeof r==`string`?r:void 0}function R(e){return[`tunnel_oauth_required`,`invalid_token`,`insufficient_scope`].includes(L(e)??``)}async function z(){return s(d(`/api/tunnel/status`))}async function B(){await s(d(`/api/tunnel/consent`),{method:`POST`,body:JSON.stringify({})})}async function V(){await s(d(`/api/tunnel/registration-key`),{method:`POST`,body:JSON.stringify({})})}async function H(){return s(d(`/api/tunnel/start`),{method:`POST`,body:JSON.stringify({})})}async function he(e){return s(d(`/api/tunnel/stop`),{method:`POST`,body:JSON.stringify({release:e?.release===!0})})}async function U(){let e=(await s(d(`/api/tunnel/reveal-registration-secret`),{method:`POST`,body:JSON.stringify({})})).payload;if(!e)throw Error(`Missing reveal payload`);return{registrationSecret:e.registrationSecret??null,source:e.source===`config`?`config`:`none`}}async function W(e){await s(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({tunnel:e})})}export{M as _,B as a,w as b,he as c,P as d,N as f,pe as g,fe as h,V as i,L as l,F as m,z as n,U as o,me as p,W as r,H as s,I as t,R as u,A as v,T as y};
|
|
@@ -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{g as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./messages-Bwv-AOYl.js";import{a as o,n as s,r as c}from"./locale-store-D5h-Ha6-.js";import{i as l}from"./vendor-swr-BIWyz7Rc.js";import{Ao as u,Dd as d,Hd as f,Kc as p,Pl as m,Rc as h,bf as g,du as _,qd as v,uf as y,us as b}from"./index-DmURUvvA.js";import{n as x,r as S}from"./settings-page-layout-Dx5S-Msc.js";import{t as ee}from"./xopc-cloud-account-card-BsW2acj1.js";var C=e(t(),1),w=n();function T(e,t=Date.now()+1){let n=t-e*24*60*60*1e3;return new URLSearchParams({from:String(n),to:String(t)}).toString()}function E(e){return o(c(`/api/usage/summary?${e}`))}function D(e,t,n=20){let r=new URLSearchParams(e);return r.set(`limit`,String(n)),t&&r.set(`cursor`,t),o(c(`/api/usage/events?${r}`))}var O=r();function k(e,t){return new Intl.NumberFormat(t===`zh`?`zh-CN`:`en-US`,{notation:`compact`,maximumFractionDigits:1}).format(e)}function A(e){return`$${Number(e).toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:6})}`}function j(e){let t=BigInt(e),n=String(t%10000n).padStart(4,`0`).replace(/0+$/,``);return`${t/10000n}${n?`.${n}`:``}`}function te(e,t){return new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}).format(e)}function M(){let e=(0,w.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,O.jsxs)(`div`,{className:`space-y-4`,"aria-busy":`true`,children:[(0,O.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[0,1,2,3].map(N)}),(0,O.jsx)(h,{className:`h-52 rounded-xl`}),(0,O.jsx)(h,{className:`h-72 rounded-xl`})]}),e[0]=t):t=e[0],t}function N(e){return(0,O.jsx)(h,{className:`h-24 rounded-xl`},e)}function P(){let e=s(e=>e.language),t=a(e).usage,[n,r]=i(),o=[`7`,`30`,`90`].includes(n.get(`days`)??``)?n.get(`days`):`7`,c=n.get(`size`)===`50`?50:20,w=n.getAll(`cursor`),N=w.at(-1),[P]=(0,C.useState)(()=>Date.now()+1),F=Number(n.get(`to`)),I=Number.isSafeInteger(F)&&F>Number(o)*864e5?F:P,L=(0,C.useMemo)(()=>T(Number(o),I),[o,I]),R=l([`usage-summary`,L],()=>E(L),{refreshInterval:15e3}),z=l([`usage-events`,L,N,c],()=>D(L,N,c),{refreshInterval:15e3}),B=!R.data&&!R.error,V=R.error,H=e=>{let t=new URLSearchParams(n);t.set(`to`,String(I)),e(t),r(t)},U=e=>H(t=>{t.set(`days`,e),t.set(`to`,String(Date.now()+1)),t.delete(`cursor`),t.delete(`groupPage`)}),W=n.get(`group`)===`model`?`model`:`scenario`,G=[...W===`model`?R.data?.byModel??[]:R.data?.byCategory??[]].sort((e,t)=>t.totals.calls-e.totals.calls||e.key.localeCompare(t.key)),K=Math.max(1,Math.ceil((G?.length??0)/6)),q=Number(n.get(`groupPage`)),J=Math.min(K,Number.isSafeInteger(q)&&q>0?q:1),Y=G?.slice((J-1)*6,J*6),X=w.length+1,Z=R.data?.totals,ne=(Z?.billing?.cloud.calls??0)>0,Q=e=>{let n=e.billing?.cloud;return n?.calls?n.chargedCreditMicro===null?t.cloudUnconfirmed:`${n.pendingCalls+n.unavailableCalls>0?`≥ `:``}${j(n.chargedCreditMicro)} Credits`:t.noCloudCalls},$=e=>{let n=e.billing?.external;return n?.calls?n.unknownCostCalls===n.calls?t.costUnknown:`${n.unknownCostCalls>0?`≥ `:`≈ `}${A(n.estimatedCostUsd)}`:t.noExternalCalls},re=e=>e.billing?.source===`local`||e.provider!==`xopc-cloud`&&e.costSource===`local`?t.localSource:e.billing?.source===`xopc_cloud`||e.provider===`xopc-cloud`?t.cloudSource:t.externalSource,ie=e=>{let n=e.billing;return n?.source===`local`?t.localNoCharge:n?.source===`xopc_cloud`?n.state===`settled`&&n.chargedCreditMicro!==null?`${j(n.chargedCreditMicro)} Credits`:n.state===`released`?t.cloudReleased:n.state===`pending`?n.reservedCreditMicro===null?t.cloudPending:t.cloudPendingReserved.replace(`{{credits}}`,j(n.reservedCreditMicro)):t.cloudUnconfirmed:e.provider===`xopc-cloud`?t.cloudUnconfirmed:e.costSource===`local`?t.localNoCharge:e.estimatedCostUsd===void 0?t.costUnknown:`≈ ${A(e.estimatedCostUsd)}`},ae=e=>(0,O.jsxs)(`span`,{className:`flex flex-col items-end gap-1 text-xs`,children:[e.billing?.cloud.calls?(0,O.jsxs)(`span`,{children:[t.cloudSource,`: `,Q(e)]}):null,e.billing?.external.calls?(0,O.jsxs)(`span`,{children:[t.externalSource,`: `,$(e)]}):null,e.billing?.localCalls?(0,O.jsx)(`span`,{children:t.localNoCharge}):null,(0,O.jsxs)(`span`,{children:[e.calls,` `,t.callUnit]})]}),oe={"usage.reason.imageGeneration":t.reasons.imageGeneration,"usage.reason.audioTranscription":t.reasons.audioTranscription,"usage.reason.audioSpeech":t.reasons.audioSpeech,"usage.reason.agentAnswer":t.reasons.agentAnswer,"usage.reason.continueAfterTool":t.reasons.continueAfterTool,"usage.reason.backgroundReview":t.reasons.backgroundReview,"usage.reason.sessionCompaction":t.reasons.sessionCompaction,"usage.reason.sessionTitle":t.reasons.sessionTitle,"usage.reason.imageUnderstanding":t.reasons.imageUnderstanding,"usage.reason.webExtract":t.reasons.webExtract,"usage.reason.sessionSearch":t.reasons.sessionSearch,"usage.reason.noteGeneration":t.reasons.noteGeneration,"usage.reason.automationDraft":t.reasons.automationDraft,"usage.reason.taskPlanning":t.reasons.taskPlanning,"usage.reason.taskJudging":t.reasons.taskJudging,"usage.reason.voiceSummary":t.reasons.voiceSummary,"usage.reason.voiceSelection":t.reasons.voiceSelection,"usage.reason.homeAdvice":t.reasons.homeAdvice,"usage.reason.workDiscovery":t.reasons.workDiscovery,"usage.reason.workInvestigation":t.reasons.workInvestigation,"usage.reason.discussionAnalysis":t.reasons.discussionAnalysis,"usage.reason.textAssist":t.reasons.textAssist,"usage.reason.userModelInterpretation":t.reasons.userModelInterpretation,"usage.reason.other":t.reasons.other};return(0,O.jsxs)(S,{children:[(0,O.jsx)(x,{title:t.title,subtitle:t.subtitle,actions:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`w-36`,children:(0,O.jsx)(b,{value:o,allowEmpty:!1,ariaLabel:t.periodLabel,placeholder:t.periodLabel,options:[{value:`7`,label:t.last7Days},{value:`30`,label:t.last30Days},{value:`90`,label:t.last90Days}],onChange:U})}),(0,O.jsx)(p,{variant:`ghost`,"aria-label":t.refresh,title:t.refresh,onClick:()=>U(o),children:(0,O.jsx)(_,{className:`size-4`,"aria-hidden":!0})})]})}),B?(0,O.jsx)(M,{}):V?(0,O.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-3 rounded-xl border border-edge bg-surface-inset p-4 text-sm text-fg-muted`,children:[(0,O.jsx)(y,{className:`mt-0.5 size-4 shrink-0 text-danger`,"aria-hidden":!0}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`p`,{className:`font-medium text-fg`,children:t.loadError}),(0,O.jsx)(`p`,{className:`mt-1`,children:String(V.message??V)})]}),(0,O.jsx)(p,{variant:`secondary`,onClick:()=>void Promise.all([R.mutate(),z.mutate()]),children:t.retry})]})]}):Z?(0,O.jsxs)(`div`,{className:`space-y-5`,children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.summaryLabel}),(0,O.jsx)(`section`,{"aria-label":t.summaryLabel,className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[{label:t.cloudCharged,value:Q(Z),icon:v},{label:t.knownCost,value:$(Z),icon:v},{label:t.calls,value:Z.calls.toLocaleString(),icon:d},{label:t.tokens,value:k(Z.totalTokens,e),icon:f}].map(e=>(0,O.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,O.jsx)(e.icon,{className:`size-4`,"aria-hidden":!0}),e.label]}),(0,O.jsx)(`div`,{className:`mt-2 text-xl font-semibold tabular-nums text-fg`,children:e.value})]},e.label))}),(Z.billing?.external.unknownCostCalls??0)>0?(0,O.jsx)(`p`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:Z.billing?.external.unknownCostCalls===Z.billing?.external.calls?t.allCostsUnknown:t.someCostsUnknown}):null,Z.billing?.cloud.calls?(0,O.jsxs)(`p`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:[t.cloudCoverage.replace(`{{pending}}`,String(Z.billing.cloud.pendingCalls)).replace(`{{unknown}}`,String(Z.billing.cloud.unavailableCalls)),Z.billing.cloud.reservedCreditMicro===null?``:` ${t.cloudReserved.replace(`{{credits}}`,j(Z.billing.cloud.reservedCreditMicro))}`]}):null,(0,O.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.distribution}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.distributionHint})]}),(0,O.jsx)(u,{className:`flex gap-1`,role:`group`,"aria-label":t.distribution,children:[`scenario`,`model`].map(e=>(0,O.jsx)(p,{variant:W===e?`secondary`:`ghost`,"aria-pressed":W===e,onClick:()=>H(t=>{t.set(`group`,e),t.delete(`groupPage`)}),children:e===`scenario`?t.byScenario:t.byModel},e))})]}),(0,O.jsx)(`div`,{className:`divide-y divide-edge-subtle px-4`,children:Y?.length?Y.map(e=>{let n=W===`scenario`?t.categories[e.key]??e.key:e.key;return(0,O.jsxs)(`div`,{className:`flex flex-col gap-3 py-3 text-sm sm:flex-row sm:items-center sm:justify-between`,children:[(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`p`,{className:`truncate font-medium text-fg`,title:n,children:n}),(0,O.jsx)(`div`,{className:`mt-2 h-1 max-w-64 overflow-hidden rounded-full bg-surface-inset`,"aria-hidden":!0,children:(0,O.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${Z.calls?e.totals.calls/Z.calls*100:0}%`}})})]}),(0,O.jsx)(`div`,{className:`shrink-0 self-end tabular-nums text-fg-muted sm:self-auto`,children:ae(e.totals)})]},e.key)}):(0,O.jsx)(`p`,{className:`py-5 text-sm text-fg-subtle`,children:t.empty})}),K>1?(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[(0,O.jsx)(`p`,{className:`text-xs text-fg-muted`,"aria-live":`polite`,children:t.groupPage.replace(`{{page}}`,String(J)).replace(`{{pages}}`,String(K)).replace(`{{count}}`,String(G?.length??0))}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(p,{disabled:J===1,"aria-label":t.previousDistribution,onClick:()=>H(e=>e.set(`groupPage`,String(J-1))),children:t.previousPage}),(0,O.jsx)(p,{disabled:J===K,"aria-label":t.nextDistribution,onClick:()=>H(e=>e.set(`groupPage`,String(J+1))),children:t.nextPage})]})]}):null]}),(0,O.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.recentCalls}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.recentCallsHint})]}),(0,O.jsx)(`div`,{className:`w-36`,children:(0,O.jsx)(b,{value:String(c),allowEmpty:!1,ariaLabel:t.pageSize,placeholder:t.pageSize,options:[20,50].map(e=>({value:String(e),label:t.rowsPerPage.replace(`{{count}}`,String(e))})),onChange:e=>H(t=>{t.set(`size`,e),t.delete(`cursor`)})})})]}),(0,O.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:z.error?(0,O.jsxs)(`div`,{role:`alert`,className:`space-y-3 p-4 text-sm text-fg-muted`,children:[(0,O.jsx)(`p`,{children:t.loadError}),(0,O.jsx)(p,{onClick:()=>void z.mutate(),children:t.retry})]}):z.data?z.data.items.length?z.data.items.map(n=>(0,O.jsxs)(`article`,{className:`grid gap-2 px-4 py-3 text-sm sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,O.jsx)(g,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,O.jsx)(`span`,{className:`truncate font-medium text-fg`,children:oe[n.reasonKey]??t.reasons.other})]}),(0,O.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-subtle`,children:[(0,O.jsxs)(`span`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:[n.provider,`/`,n.model]}),(0,O.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,O.jsx)(m,{className:`size-3`,"aria-hidden":!0}),te(n.startedAt,e)]}),(0,O.jsx)(`span`,{className:`rounded border border-edge px-1.5 py-0.5`,children:re(n)}),(0,O.jsx)(`span`,{children:n.totalTokens===void 0?t.tokensUnknown:`${k(n.totalTokens,e)} tokens`})]})]}),(0,O.jsxs)(`div`,{className:`text-left tabular-nums text-fg sm:text-right`,children:[ie(n),(0,O.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.status[n.status]??n.status})]})]},n.id)):(0,O.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-fg-subtle`,children:t.empty}):(0,O.jsx)(`div`,{"aria-busy":`true`,className:`space-y-3 p-4`,children:[0,1,2,3].map(e=>(0,O.jsx)(h,{className:`h-16`},e))})}),(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[(0,O.jsx)(`p`,{className:`text-xs text-fg-muted`,"aria-live":`polite`,children:t.eventPage.replace(`{{page}}`,String(X)).replace(`{{count}}`,String(z.data?.items.length??0))}),(0,O.jsxs)(`nav`,{className:`flex gap-2`,"aria-label":t.pagination,children:[X>1?(0,O.jsx)(p,{variant:`ghost`,onClick:()=>H(e=>e.delete(`cursor`)),children:t.firstPage}):null,(0,O.jsx)(p,{disabled:X===1,onClick:()=>H(e=>{e.delete(`cursor`),w.slice(0,-1).forEach(t=>e.append(`cursor`,t))}),children:t.previousPage}),(0,O.jsx)(p,{disabled:!z.data?.nextCursor||!!z.error,onClick:()=>H(e=>{z.data?.nextCursor&&e.append(`cursor`,z.data.nextCursor)}),children:t.nextPage})]})]})]}),(0,O.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,O.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg focus-visible:outline-accent`,children:t.billingDetails}),(0,O.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-muted`,children:t.cloudBillingHint}),(0,O.jsx)(`a`,{className:`mt-2 inline-block text-xs text-accent-fg hover:underline`,href:`https://console.xopc.ai/models/billing`,target:`_blank`,rel:`noreferrer`,children:t.cloudCreditsLabel}),ne?(0,O.jsx)(`div`,{className:`mt-4`,children:(0,O.jsx)(ee,{labels:a(e).capabilitiesSettings.xopcCloudAccount})}):null]})]}):null]})}export{P as UsageSettingsPage};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{g as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./messages-Bwv-AOYl.js";import{a as o,n as s,r as c}from"./locale-store-D5h-Ha6-.js";import{i as l}from"./vendor-swr-BIWyz7Rc.js";import{Ao as u,Dd as d,Hd as f,Kc as p,Pl as m,Rc as h,bf as g,du as _,qd as v,uf as y,us as b}from"./index-DdJ_djQt.js";import{n as x,r as S}from"./settings-page-layout-Dx5S-Msc.js";import{t as ee}from"./xopc-cloud-account-card-BARP73BX.js";var C=e(t(),1),w=n();function T(e,t=Date.now()+1){let n=t-e*24*60*60*1e3;return new URLSearchParams({from:String(n),to:String(t)}).toString()}function E(e){return o(c(`/api/usage/summary?${e}`))}function D(e,t,n=20){let r=new URLSearchParams(e);return r.set(`limit`,String(n)),t&&r.set(`cursor`,t),o(c(`/api/usage/events?${r}`))}var O=r();function k(e,t){return new Intl.NumberFormat(t===`zh`?`zh-CN`:`en-US`,{notation:`compact`,maximumFractionDigits:1}).format(e)}function A(e){return`$${Number(e).toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:6})}`}function j(e){let t=BigInt(e),n=String(t%10000n).padStart(4,`0`).replace(/0+$/,``);return`${t/10000n}${n?`.${n}`:``}`}function te(e,t){return new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}).format(e)}function M(){let e=(0,w.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,O.jsxs)(`div`,{className:`space-y-4`,"aria-busy":`true`,children:[(0,O.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[0,1,2,3].map(N)}),(0,O.jsx)(h,{className:`h-52 rounded-xl`}),(0,O.jsx)(h,{className:`h-72 rounded-xl`})]}),e[0]=t):t=e[0],t}function N(e){return(0,O.jsx)(h,{className:`h-24 rounded-xl`},e)}function P(){let e=s(e=>e.language),t=a(e).usage,[n,r]=i(),o=[`7`,`30`,`90`].includes(n.get(`days`)??``)?n.get(`days`):`7`,c=n.get(`size`)===`50`?50:20,w=n.getAll(`cursor`),N=w.at(-1),[P]=(0,C.useState)(()=>Date.now()+1),F=Number(n.get(`to`)),I=Number.isSafeInteger(F)&&F>Number(o)*864e5?F:P,L=(0,C.useMemo)(()=>T(Number(o),I),[o,I]),R=l([`usage-summary`,L],()=>E(L),{refreshInterval:15e3}),z=l([`usage-events`,L,N,c],()=>D(L,N,c),{refreshInterval:15e3}),B=!R.data&&!R.error,V=R.error,H=e=>{let t=new URLSearchParams(n);t.set(`to`,String(I)),e(t),r(t)},U=e=>H(t=>{t.set(`days`,e),t.set(`to`,String(Date.now()+1)),t.delete(`cursor`),t.delete(`groupPage`)}),W=n.get(`group`)===`model`?`model`:`scenario`,G=[...W===`model`?R.data?.byModel??[]:R.data?.byCategory??[]].sort((e,t)=>t.totals.calls-e.totals.calls||e.key.localeCompare(t.key)),K=Math.max(1,Math.ceil((G?.length??0)/6)),q=Number(n.get(`groupPage`)),J=Math.min(K,Number.isSafeInteger(q)&&q>0?q:1),Y=G?.slice((J-1)*6,J*6),X=w.length+1,Z=R.data?.totals,ne=(Z?.billing?.cloud.calls??0)>0,Q=e=>{let n=e.billing?.cloud;return n?.calls?n.chargedCreditMicro===null?t.cloudUnconfirmed:`${n.pendingCalls+n.unavailableCalls>0?`≥ `:``}${j(n.chargedCreditMicro)} Credits`:t.noCloudCalls},$=e=>{let n=e.billing?.external;return n?.calls?n.unknownCostCalls===n.calls?t.costUnknown:`${n.unknownCostCalls>0?`≥ `:`≈ `}${A(n.estimatedCostUsd)}`:t.noExternalCalls},re=e=>e.billing?.source===`local`||e.provider!==`xopc-cloud`&&e.costSource===`local`?t.localSource:e.billing?.source===`xopc_cloud`||e.provider===`xopc-cloud`?t.cloudSource:t.externalSource,ie=e=>{let n=e.billing;return n?.source===`local`?t.localNoCharge:n?.source===`xopc_cloud`?n.state===`settled`&&n.chargedCreditMicro!==null?`${j(n.chargedCreditMicro)} Credits`:n.state===`released`?t.cloudReleased:n.state===`pending`?n.reservedCreditMicro===null?t.cloudPending:t.cloudPendingReserved.replace(`{{credits}}`,j(n.reservedCreditMicro)):t.cloudUnconfirmed:e.provider===`xopc-cloud`?t.cloudUnconfirmed:e.costSource===`local`?t.localNoCharge:e.estimatedCostUsd===void 0?t.costUnknown:`≈ ${A(e.estimatedCostUsd)}`},ae=e=>(0,O.jsxs)(`span`,{className:`flex flex-col items-end gap-1 text-xs`,children:[e.billing?.cloud.calls?(0,O.jsxs)(`span`,{children:[t.cloudSource,`: `,Q(e)]}):null,e.billing?.external.calls?(0,O.jsxs)(`span`,{children:[t.externalSource,`: `,$(e)]}):null,e.billing?.localCalls?(0,O.jsx)(`span`,{children:t.localNoCharge}):null,(0,O.jsxs)(`span`,{children:[e.calls,` `,t.callUnit]})]}),oe={"usage.reason.imageGeneration":t.reasons.imageGeneration,"usage.reason.audioTranscription":t.reasons.audioTranscription,"usage.reason.audioSpeech":t.reasons.audioSpeech,"usage.reason.agentAnswer":t.reasons.agentAnswer,"usage.reason.continueAfterTool":t.reasons.continueAfterTool,"usage.reason.backgroundReview":t.reasons.backgroundReview,"usage.reason.sessionCompaction":t.reasons.sessionCompaction,"usage.reason.sessionTitle":t.reasons.sessionTitle,"usage.reason.imageUnderstanding":t.reasons.imageUnderstanding,"usage.reason.webExtract":t.reasons.webExtract,"usage.reason.sessionSearch":t.reasons.sessionSearch,"usage.reason.noteGeneration":t.reasons.noteGeneration,"usage.reason.automationDraft":t.reasons.automationDraft,"usage.reason.taskPlanning":t.reasons.taskPlanning,"usage.reason.taskJudging":t.reasons.taskJudging,"usage.reason.voiceSummary":t.reasons.voiceSummary,"usage.reason.voiceSelection":t.reasons.voiceSelection,"usage.reason.homeAdvice":t.reasons.homeAdvice,"usage.reason.workDiscovery":t.reasons.workDiscovery,"usage.reason.workInvestigation":t.reasons.workInvestigation,"usage.reason.discussionAnalysis":t.reasons.discussionAnalysis,"usage.reason.textAssist":t.reasons.textAssist,"usage.reason.userModelInterpretation":t.reasons.userModelInterpretation,"usage.reason.other":t.reasons.other};return(0,O.jsxs)(S,{children:[(0,O.jsx)(x,{title:t.title,subtitle:t.subtitle,actions:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`w-36`,children:(0,O.jsx)(b,{value:o,allowEmpty:!1,ariaLabel:t.periodLabel,placeholder:t.periodLabel,options:[{value:`7`,label:t.last7Days},{value:`30`,label:t.last30Days},{value:`90`,label:t.last90Days}],onChange:U})}),(0,O.jsx)(p,{variant:`ghost`,"aria-label":t.refresh,title:t.refresh,onClick:()=>U(o),children:(0,O.jsx)(_,{className:`size-4`,"aria-hidden":!0})})]})}),B?(0,O.jsx)(M,{}):V?(0,O.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-3 rounded-xl border border-edge bg-surface-inset p-4 text-sm text-fg-muted`,children:[(0,O.jsx)(y,{className:`mt-0.5 size-4 shrink-0 text-danger`,"aria-hidden":!0}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`p`,{className:`font-medium text-fg`,children:t.loadError}),(0,O.jsx)(`p`,{className:`mt-1`,children:String(V.message??V)})]}),(0,O.jsx)(p,{variant:`secondary`,onClick:()=>void Promise.all([R.mutate(),z.mutate()]),children:t.retry})]})]}):Z?(0,O.jsxs)(`div`,{className:`space-y-5`,children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.summaryLabel}),(0,O.jsx)(`section`,{"aria-label":t.summaryLabel,className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[{label:t.cloudCharged,value:Q(Z),icon:v},{label:t.knownCost,value:$(Z),icon:v},{label:t.calls,value:Z.calls.toLocaleString(),icon:d},{label:t.tokens,value:k(Z.totalTokens,e),icon:f}].map(e=>(0,O.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,O.jsx)(e.icon,{className:`size-4`,"aria-hidden":!0}),e.label]}),(0,O.jsx)(`div`,{className:`mt-2 text-xl font-semibold tabular-nums text-fg`,children:e.value})]},e.label))}),(Z.billing?.external.unknownCostCalls??0)>0?(0,O.jsx)(`p`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:Z.billing?.external.unknownCostCalls===Z.billing?.external.calls?t.allCostsUnknown:t.someCostsUnknown}):null,Z.billing?.cloud.calls?(0,O.jsxs)(`p`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:[t.cloudCoverage.replace(`{{pending}}`,String(Z.billing.cloud.pendingCalls)).replace(`{{unknown}}`,String(Z.billing.cloud.unavailableCalls)),Z.billing.cloud.reservedCreditMicro===null?``:` ${t.cloudReserved.replace(`{{credits}}`,j(Z.billing.cloud.reservedCreditMicro))}`]}):null,(0,O.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.distribution}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.distributionHint})]}),(0,O.jsx)(u,{className:`flex gap-1`,role:`group`,"aria-label":t.distribution,children:[`scenario`,`model`].map(e=>(0,O.jsx)(p,{variant:W===e?`secondary`:`ghost`,"aria-pressed":W===e,onClick:()=>H(t=>{t.set(`group`,e),t.delete(`groupPage`)}),children:e===`scenario`?t.byScenario:t.byModel},e))})]}),(0,O.jsx)(`div`,{className:`divide-y divide-edge-subtle px-4`,children:Y?.length?Y.map(e=>{let n=W===`scenario`?t.categories[e.key]??e.key:e.key;return(0,O.jsxs)(`div`,{className:`flex flex-col gap-3 py-3 text-sm sm:flex-row sm:items-center sm:justify-between`,children:[(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`p`,{className:`truncate font-medium text-fg`,title:n,children:n}),(0,O.jsx)(`div`,{className:`mt-2 h-1 max-w-64 overflow-hidden rounded-full bg-surface-inset`,"aria-hidden":!0,children:(0,O.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${Z.calls?e.totals.calls/Z.calls*100:0}%`}})})]}),(0,O.jsx)(`div`,{className:`shrink-0 self-end tabular-nums text-fg-muted sm:self-auto`,children:ae(e.totals)})]},e.key)}):(0,O.jsx)(`p`,{className:`py-5 text-sm text-fg-subtle`,children:t.empty})}),K>1?(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[(0,O.jsx)(`p`,{className:`text-xs text-fg-muted`,"aria-live":`polite`,children:t.groupPage.replace(`{{page}}`,String(J)).replace(`{{pages}}`,String(K)).replace(`{{count}}`,String(G?.length??0))}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(p,{disabled:J===1,"aria-label":t.previousDistribution,onClick:()=>H(e=>e.set(`groupPage`,String(J-1))),children:t.previousPage}),(0,O.jsx)(p,{disabled:J===K,"aria-label":t.nextDistribution,onClick:()=>H(e=>e.set(`groupPage`,String(J+1))),children:t.nextPage})]})]}):null]}),(0,O.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.recentCalls}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.recentCallsHint})]}),(0,O.jsx)(`div`,{className:`w-36`,children:(0,O.jsx)(b,{value:String(c),allowEmpty:!1,ariaLabel:t.pageSize,placeholder:t.pageSize,options:[20,50].map(e=>({value:String(e),label:t.rowsPerPage.replace(`{{count}}`,String(e))})),onChange:e=>H(t=>{t.set(`size`,e),t.delete(`cursor`)})})})]}),(0,O.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:z.error?(0,O.jsxs)(`div`,{role:`alert`,className:`space-y-3 p-4 text-sm text-fg-muted`,children:[(0,O.jsx)(`p`,{children:t.loadError}),(0,O.jsx)(p,{onClick:()=>void z.mutate(),children:t.retry})]}):z.data?z.data.items.length?z.data.items.map(n=>(0,O.jsxs)(`article`,{className:`grid gap-2 px-4 py-3 text-sm sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,O.jsx)(g,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,O.jsx)(`span`,{className:`truncate font-medium text-fg`,children:oe[n.reasonKey]??t.reasons.other})]}),(0,O.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-subtle`,children:[(0,O.jsxs)(`span`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:[n.provider,`/`,n.model]}),(0,O.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,O.jsx)(m,{className:`size-3`,"aria-hidden":!0}),te(n.startedAt,e)]}),(0,O.jsx)(`span`,{className:`rounded border border-edge px-1.5 py-0.5`,children:re(n)}),(0,O.jsx)(`span`,{children:n.totalTokens===void 0?t.tokensUnknown:`${k(n.totalTokens,e)} tokens`})]})]}),(0,O.jsxs)(`div`,{className:`text-left tabular-nums text-fg sm:text-right`,children:[ie(n),(0,O.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.status[n.status]??n.status})]})]},n.id)):(0,O.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-fg-subtle`,children:t.empty}):(0,O.jsx)(`div`,{"aria-busy":`true`,className:`space-y-3 p-4`,children:[0,1,2,3].map(e=>(0,O.jsx)(h,{className:`h-16`},e))})}),(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[(0,O.jsx)(`p`,{className:`text-xs text-fg-muted`,"aria-live":`polite`,children:t.eventPage.replace(`{{page}}`,String(X)).replace(`{{count}}`,String(z.data?.items.length??0))}),(0,O.jsxs)(`nav`,{className:`flex gap-2`,"aria-label":t.pagination,children:[X>1?(0,O.jsx)(p,{variant:`ghost`,onClick:()=>H(e=>e.delete(`cursor`)),children:t.firstPage}):null,(0,O.jsx)(p,{disabled:X===1,onClick:()=>H(e=>{e.delete(`cursor`),w.slice(0,-1).forEach(t=>e.append(`cursor`,t))}),children:t.previousPage}),(0,O.jsx)(p,{disabled:!z.data?.nextCursor||!!z.error,onClick:()=>H(e=>{z.data?.nextCursor&&e.append(`cursor`,z.data.nextCursor)}),children:t.nextPage})]})]})]}),(0,O.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,O.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg focus-visible:outline-accent`,children:t.billingDetails}),(0,O.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-muted`,children:t.cloudBillingHint}),(0,O.jsx)(`a`,{className:`mt-2 inline-block text-xs text-accent-fg hover:underline`,href:`https://console.xopc.ai/models/billing`,target:`_blank`,rel:`noreferrer`,children:t.cloudCreditsLabel}),ne?(0,O.jsx)(`div`,{className:`mt-4`,children:(0,O.jsx)(ee,{labels:a(e).capabilitiesSettings.xopcCloudAccount})}):null]})]}):null]})}export{P as UsageSettingsPage};
|
package/dist/gateway/static/root/assets/{use-autosave-BnMIUc_5.js → use-autosave-0dTfTmCk.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"./check-DUBLcKHA.js";import{t as a}from"./cn-0WouolD0.js";import{n as o}from"./locale-store-D5h-Ha6-.js";import{Ju as s,uf as c}from"./index-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./check-DUBLcKHA.js";import{t as a}from"./cn-0WouolD0.js";import{n as o}from"./locale-store-D5h-Ha6-.js";import{Ju as s,uf as c}from"./index-DdJ_djQt.js";var l=n(),u=r();function d(e){let t=(0,l.c)(21),{status:n,error:r,className:d}=e,p=o(f)===`zh`;if(n===`idle`)return null;let m=n===`saving`?p?`正在保存…`:`Saving…`:n===`saved`?p?`已自动保存`:`Saved automatically`:n===`error`?r||(p?`自动保存失败`:`Autosave failed`):n===`dirty`?p?`编辑中,将自动保存`:`Editing — autosave pending`:``,h=n===`error`?`text-danger`:n===`saved`?`text-success`:`text-fg-subtle`,g;t[0]!==d||t[1]!==h?(g=a(`inline-flex min-w-0 items-center gap-1.5 text-xs`,h,d),t[0]=d,t[1]=h,t[2]=g):g=t[2];let _;t[3]===n?_=t[4]:(_=n===`saving`?(0,u.jsx)(s,{className:`size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}):null,t[3]=n,t[4]=_);let v;t[5]===n?v=t[6]:(v=n===`saved`?(0,u.jsx)(i,{className:`size-3.5 shrink-0`,"aria-hidden":!0}):null,t[5]=n,t[6]=v);let y;t[7]===n?y=t[8]:(y=n===`error`?(0,u.jsx)(c,{className:`size-3.5 shrink-0`,"aria-hidden":!0}):null,t[7]=n,t[8]=y);let b;t[9]===n?b=t[10]:(b=n===`dirty`?(0,u.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current`,"aria-hidden":!0}):null,t[9]=n,t[10]=b);let x;t[11]===m?x=t[12]:(x=(0,u.jsx)(`span`,{className:`truncate`,children:m}),t[11]=m,t[12]=x);let S;return t[13]!==m||t[14]!==g||t[15]!==_||t[16]!==v||t[17]!==y||t[18]!==b||t[19]!==x?(S=(0,u.jsxs)(`span`,{className:g,role:`status`,"aria-live":`polite`,title:m,children:[_,v,y,b,x]}),t[13]=m,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b,t[19]=x,t[20]=S):S=t[20],S}function f(e){return e.language}var p=e(t(),1);function m({value:e,dirty:t,onSave:n,enabled:r=!0,delayMs:i=700,validate:a,serialize:o=JSON.stringify}){let[s,c]=(0,p.useState)(`idle`),[l,u]=(0,p.useState)(null),d=(0,p.useRef)(e),f=(0,p.useRef)(n),m=(0,p.useRef)(a),h=(0,p.useRef)(o),g=(0,p.useRef)(null),_=(0,p.useRef)(!1),v=(0,p.useRef)(null),y=(0,p.useRef)(null),b=(0,p.useRef)(null),x=(0,p.useRef)(!0);d.current=e,f.current=n,m.current=a,h.current=o;let S=(0,p.useCallback)(()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]),C=(0,p.useCallback)(async e=>{S();let t=h.current(e);b.current=t;let n=m.current?.(e)??null;if(n){u(n),c(`error`);return}if(_.current){v.current=e;return}_.current=!0,u(null),c(`saving`);try{await f.current(e),y.current=t,x.current&&c(`saved`)}catch(e){x.current&&(u(e instanceof Error?e.message:String(e)),c(`error`))}finally{_.current=!1;let e=v.current;v.current=null,e&&h.current(e)!==y.current&&C(e)}},[S]),w=(0,p.useCallback)(()=>{let e=d.current;!r||!t||e===null||C(e)},[t,r,C]),T=(0,p.useCallback)(e=>{let t=e??d.current;!r||t===null||C(t)},[r,C]);return(0,p.useEffect)(()=>{if(!r||!t||e===null){S(),!t&&s===`dirty`&&c(`idle`);return}let n=o(e);if(n!==y.current&&!(s===`error`&&n===b.current))return c(e=>e===`saving`?e:`dirty`),S(),g.current=window.setTimeout(()=>void C(e),i),S},[S,i,t,r,C,o,s,e]),(0,p.useEffect)(()=>(x.current=!0,()=>{x.current=!1,S()}),[S]),(0,p.useEffect)(()=>{if(s!==`saved`)return;let e=window.setTimeout(()=>c(`idle`),1600);return()=>window.clearTimeout(e)},[s]),{status:s,error:l,flush:w,saveNow:T,retry:w,onBlurCapture:w}}export{d as n,m as t};
|