pisper 0.6.39 → 0.6.40
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/package.json +5 -5
- package/web/.vite/manifest.json +691 -691
- package/web/assets/{AppDialog-B18LKxGz.js → AppDialog-OZpJxSBP.js} +1 -1
- package/web/assets/{AppOverlays-CVsIn893.js → AppOverlays-DBsxr-pZ.js} +1 -1
- package/web/assets/{AssetsPage-DTUqqVRZ.js → AssetsPage-H1OABD-M.js} +1 -1
- package/web/assets/{AttachmentTray-CdgiJGKL.js → AttachmentTray-BB89fdpQ.js} +1 -1
- package/web/assets/{BoardPage-C1zvNkyM.js → BoardPage-B2GIOdjF.js} +3 -3
- package/web/assets/{ChannelsPage-EXfbi1Uu.js → ChannelsPage-DJOprsIR.js} +1 -1
- package/web/assets/{ChatAppearancePage-BpHEGASI.js → ChatAppearancePage-BqY06fK8.js} +1 -1
- package/web/assets/{ChatHistoryPage-C-mJV9uR.js → ChatHistoryPage-N1OwflL6.js} +1 -1
- package/web/assets/{ChatMessage-CBGpmO8b.js → ChatMessage-Cb3Rzxbr.js} +3 -3
- package/web/assets/{ChatPage-AjVB1P4r.js → ChatPage-Di2pvZ7B.js} +3 -3
- package/web/assets/{ConfigPage-D7YSSKLJ.js → ConfigPage-Ba8yOTn6.js} +4 -4
- package/web/assets/{DesktopWindowControls-D_LAKbeD.js → DesktopWindowControls-Dgr7SBc9.js} +1 -1
- package/web/assets/{FeaturePage-DT8W4UlT.js → FeaturePage-xE563vuG.js} +1 -1
- package/web/assets/{FileAttachmentPreview-B9i02UCX.js → FileAttachmentPreview-Cx6BlBm7.js} +1 -1
- package/web/assets/{FloatingWidgets-CmBCqisu.js → FloatingWidgets-CWGdGGgQ.js} +1 -1
- package/web/assets/{FocusRuntimeControls-yUa6cOxD.js → FocusRuntimeControls-CoEB10QW.js} +1 -1
- package/web/assets/{GitDiffViewer-LK0S-bDi.js → GitDiffViewer-DplIwM8m.js} +1 -1
- package/web/assets/{ManageProjectsDialog-DPdZnbwA.js → ManageProjectsDialog-U8MUgrlm.js} +1 -1
- package/web/assets/{MarkdownMessage-CkLJFdr9.js → MarkdownMessage-DylM7nUB.js} +1 -1
- package/web/assets/{McpPage-DM00Xr9x.js → McpPage-BG-pc52d.js} +1 -1
- package/web/assets/{MemoryEvolution-D4AAcf9c.js → MemoryEvolution-DDiqR1FL.js} +1 -1
- package/web/assets/{MemoryPage-CtUzZ4-U.js → MemoryPage-B7zAKyaw.js} +2 -2
- package/web/assets/{MobileNavigation-BqPs-o2r.js → MobileNavigation-B9TLGML2.js} +1 -1
- package/web/assets/{MorePage-suAYgIS5.js → MorePage-D2qm09O6.js} +1 -1
- package/web/assets/{NewFolderDialog-kUUU6qCp.js → NewFolderDialog-CWpNgMKR.js} +1 -1
- package/web/assets/{PageHeader-BkPqAK50.js → PageHeader-DsZ5ehNL.js} +1 -1
- package/web/assets/{PhoneDrawer-BggePi7m.js → PhoneDrawer-sIG28Onx.js} +1 -1
- package/web/assets/{PhoneMenuButton-BOcCSFnH.js → PhoneMenuButton-DiDPv4NZ.js} +1 -1
- package/web/assets/{PhoneTopBar-IjowCATK.js → PhoneTopBar-DRQ5EQmK.js} +1 -1
- package/web/assets/{PluginsPage-CW9s28T1.js → PluginsPage-CKUCMJjh.js} +1 -1
- package/web/assets/{SafeModePrompt-cyd5YWlE.js → SafeModePrompt-OycVdcvt.js} +1 -1
- package/web/assets/{SchedulesPage-PTc_ojAJ.js → SchedulesPage-DsHGElm6.js} +1 -1
- package/web/assets/{SessionBrowserPane-CAJoHlNh.js → SessionBrowserPane-DGQsDUqd.js} +2 -2
- package/web/assets/{SessionContextPanel-CnMlSYsk.js → SessionContextPanel-CQXBX8HL.js} +2 -2
- package/web/assets/{SessionHome-1L6ETCUP.js → SessionHome-_X0M5GiH.js} +1 -1
- package/web/assets/{SessionInspector-DTvk3cYP.js → SessionInspector-C03rShQ1.js} +1 -1
- package/web/assets/{SessionShell-DCZjgm4_.js → SessionShell-Dsfvs_JW.js} +1 -1
- package/web/assets/{SettingsSidebar-FNMhjBah.js → SettingsSidebar-Bur_oRZx.js} +1 -1
- package/web/assets/{ShortcutHelpDialog-pFOsy2re.js → ShortcutHelpDialog-rAbhuzNm.js} +1 -1
- package/web/assets/{ShortcutKeys-BfiFGtIF.js → ShortcutKeys-DFKIS7Us.js} +1 -1
- package/web/assets/{SidebarUpdateStatus-BdfPkA-6.js → SidebarUpdateStatus-W1H_IFTb.js} +1 -1
- package/web/assets/{SkillsPage-CauQvPAH.js → SkillsPage-Cyg7klwt.js} +1 -1
- package/web/assets/{TaskProcessesPane-Kj4R2eFS.js → TaskProcessesPane-CkC-ZQos.js} +1 -1
- package/web/assets/{TaskTerminalView-CVBvmwIN.js → TaskTerminalView-CU-kjS_J.js} +1 -1
- package/web/assets/{TerminalPanel-BlaqYk_y.js → TerminalPanel-CL7C-bZ3.js} +1 -1
- package/web/assets/{WebDesktopPet-B524lpZ8.js → WebDesktopPet-Cc_B2Ihr.js} +1 -1
- package/web/assets/{WorkflowsPage-Dr0Mb-lj.js → WorkflowsPage-DExImPqA.js} +1 -1
- package/web/assets/{WorkspacePicker-BC-V-qKc.js → WorkspacePicker-Cd0QCRnc.js} +1 -1
- package/web/assets/{api-BA-WPJCg.js → api-BbBnrW3n.js} +1 -1
- package/web/assets/{app-update-AoFhnKr8.js → app-update-pRA7vtj3.js} +1 -1
- package/web/assets/{approval-confirm-B0nXB32b.js → approval-confirm-CLY2H0YG.js} +1 -1
- package/web/assets/{assets-api-Dw9uxhK9.js → assets-api-A0ZKJkf3.js} +1 -1
- package/web/assets/{board-projects-geCUCUov.js → board-projects-DHtEAHvu.js} +1 -1
- package/web/assets/{bots-store-CljyYMIo.js → bots-store-Br31qCcA.js} +1 -1
- package/web/assets/{chat-api-DixX49bK.js → chat-api-BSs2idF4.js} +1 -1
- package/web/assets/{client-store-JUgMl-Fs.js → client-store-C_ajzmyH.js} +1 -1
- package/web/assets/{command-Dugx8Xyc.js → command-Cb876BWo.js} +1 -1
- package/web/assets/{config-search-B5mtRMAH.js → config-search-DQ-bCU2h.js} +1 -1
- package/web/assets/{desktop-hosts-CLjxzh1F.js → desktop-hosts-qz2OZ5I1.js} +1 -1
- package/web/assets/{dialog-BfkdQrrN.js → dialog-CW8GeCdI.js} +1 -1
- package/web/assets/{event-stream-C1gqpD-D.js → event-stream-BYSr6laS.js} +1 -1
- package/web/assets/{events-BCP3T_26.js → events-CAivTGZK.js} +1 -1
- package/web/assets/{folder-paths-hX8Gx2zK.js → folder-paths-CYDY1W9R.js} +1 -1
- package/web/assets/{hosts-BqwTes2H.js → hosts-CdsdAvJs.js} +1 -1
- package/web/assets/{http-BJXYcBJZ.js → http-CMHs5x9g.js} +1 -1
- package/web/assets/{http-response-tU9Jgwk1.js → http-response-DObpyFrX.js} +1 -1
- package/web/assets/{i18n-BigTf78f.js → i18n-C_TfFRc2.js} +1 -1
- package/web/assets/{index-Cj4werSq.js → index-DL89Jrzh.js} +2 -2
- package/web/assets/{machine-messages-C5HnwFMY.js → machine-messages-BZFO3mNM.js} +1 -1
- package/web/assets/{machines-api-Bd73Uc9W.js → machines-api-Brwmi001.js} +1 -1
- package/web/assets/{memory-api-CizRSxek.js → memory-api-BsElJ4mL.js} +1 -1
- package/web/assets/{mount-app-BiyUP9uu.js → mount-app-DdYcKl3f.js} +3 -3
- package/web/assets/{permission-rules-api-D26h2i5i.js → permission-rules-api-pDaT7JHN.js} +1 -1
- package/web/assets/{pick-system-directory-j8yF4oD7.js → pick-system-directory-C4P5z66U.js} +1 -1
- package/web/assets/{placements-DaEYVBYS.js → placements-DY62NlQc.js} +2 -2
- package/web/assets/{popover-CYgt88Di.js → popover-CPdjoO3T.js} +1 -1
- package/web/assets/{public-fbSrYOz9.js → public--dz5MkXs.js} +2 -2
- package/web/assets/{public-uWGpE-xc.js → public-B3nCWERr.js} +1 -1
- package/web/assets/{public-DFbbN84l.js → public-BvZGd3OL.js} +1 -1
- package/web/assets/{public-CbGNOymN.js → public-CAdIUTea.js} +2 -2
- package/web/assets/{public-components-BxT4OWVf.js → public-components-BIhHhBwc.js} +1 -1
- package/web/assets/public-diff-Dha1wj7p.js +1 -0
- package/web/assets/public-events-CtLbk6Ps.js +1 -0
- package/web/assets/{public-flags-DtOWkThd.js → public-flags-CBzwNp70.js} +1 -1
- package/web/assets/{public-folder-dialog-BdoTA7R9.js → public-folder-dialog-Dmd5Qull.js} +1 -1
- package/web/assets/{public-greeting-WuolFgYD.js → public-greeting-lOuYNysY.js} +1 -1
- package/web/assets/{public-session-BHqubfWo.js → public-session-QlZ9_Zsb.js} +1 -1
- package/web/assets/{public-sidebar-Dy3GnDnb.js → public-sidebar-DsfBxQWb.js} +1 -1
- package/web/assets/{runtime-capabilities-store-CJA8-sSC.js → runtime-capabilities-store-aG2QVT6b.js} +1 -1
- package/web/assets/{safe-mode-instance-BdOJv29n.js → safe-mode-instance-HzaYIZf6.js} +1 -1
- package/web/assets/safe-mode-sentinel-DfoN8ker.js +1 -0
- package/web/assets/{session-change-summary-api-CvAF7fwO.js → session-change-summary-api-Kcf7-e2G.js} +1 -1
- package/web/assets/{session-home-DbvyzdI5.js → session-home-DOe7Q-qI.js} +1 -1
- package/web/assets/{session-inspector-store-C3ZsefJH.js → session-inspector-store-BolK9Mpy.js} +1 -1
- package/web/assets/{session-questions-DLgJUkQv.js → session-questions-l81YErJo.js} +1 -1
- package/web/assets/{session-scope-CFdEpHVY.js → session-scope-BCcnPOi0.js} +1 -1
- package/web/assets/{session-tree-actions-CYj1yPgQ.js → session-tree-actions-DHSmxj_g.js} +1 -1
- package/web/assets/{session-tree-summary-BeUnCg9w.js → session-tree-summary-C0dKEzZx.js} +1 -1
- package/web/assets/{session-web-preview-DfdZezsZ.js → session-web-preview-DvDFSKV-.js} +1 -1
- package/web/assets/{shortcuts-Cth0vc77.js → shortcuts-DsFEMyT1.js} +1 -1
- package/web/assets/{side-chat-context-D0zsA72l.js → side-chat-context-DxeaaCWm.js} +4 -4
- package/web/assets/{sidebar-vQzRTtRF.js → sidebar-CmpuB-ul.js} +1 -1
- package/web/assets/{sidebar-store-1-20GZhs.js → sidebar-store-BxHuw5mD.js} +1 -1
- package/web/assets/{speech-session-BpiqMMm5.js → speech-session-BXAj3OAY.js} +1 -1
- package/web/assets/{startup-queries-mAINlcNF.js → startup-queries-Cc9LSolC.js} +1 -1
- package/web/assets/{use-i18n-DL1_y_Ge.js → use-i18n-BqDnJFL5.js} +1 -1
- package/web/assets/{use-open-bot-CiF65aUO.js → use-open-bot-B_UFxUmd.js} +1 -1
- package/web/assets/{use-studio-actions-yGeYtIj_.js → use-studio-actions-BM3RKvXH.js} +1 -1
- package/web/assets/{useCatalogProjects-BBTryY8n.js → useCatalogProjects-BhW44QEx.js} +1 -1
- package/web/assets/{useMachines-DbkhDwVU.js → useMachines-Cv7VNdjI.js} +1 -1
- package/web/assets/{useNewProjectPicker-CW-ndILs.js → useNewProjectPicker-DRZ4v1BJ.js} +2 -2
- package/web/assets/{useNow-CyOr3v9y.js → useNow-tTW4r_Vo.js} +1 -1
- package/web/assets/{usePhoneShell-E0zpNbPD.js → usePhoneShell-iGegDaj2.js} +1 -1
- package/web/assets/{useSessionListQuery-CaaqoetW.js → useSessionListQuery-mhLtsKkB.js} +1 -1
- package/web/assets/{useSessionRowActions-BNWcYCP1.js → useSessionRowActions-UT3R_Cfq.js} +1 -1
- package/web/assets/{useSidebarModel-zw1ozcJm.js → useSidebarModel-D21Q54-Q.js} +1 -1
- package/web/assets/{workspace-folders-Cl8xGY9c.js → workspace-folders-CIuHDEZQ.js} +1 -1
- package/web/assets/{workspace-order-store-BlPd8HV9.js → workspace-order-store-Cv4TWT44.js} +1 -1
- package/web/index.html +1 -1
- package/web/assets/public-diff-L3aHU7Ip.js +0 -1
- package/web/assets/public-events-CIldV-8b.js +0 -1
- package/web/assets/safe-mode-sentinel-DiBJExnu.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{t as r}from"./use-i18n-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{t as r}from"./use-i18n-BqDnJFL5.js";import{a as i}from"./http-response-DObpyFrX.js";import{t as a}from"./folder-open-FIShC5Qk.js";import{t as o}from"./folder-plus-OPHZsJho.js";import{t as s}from"./triangle-alert-CE1q54ci.js";import{n as c,t as l}from"./button-CCcCN8tE.js";import{a as u,i as d,l as f,o as p,s as m,t as h}from"./dialog-CW8GeCdI.js";import{t as g}from"./input-CPw-zkYh.js";import{i as _,n as v,r as y,t as b}from"./input-group-h8z63MzW.js";import{t as x}from"./pick-system-directory-C4P5z66U.js";import{r as S,t as C}from"./folder-paths-CYDY1W9R.js";import{n as w,t as T}from"./alert-DRIrgNI4.js";import{n as E,t as D}from"./field-DoLEb0np.js";var O=e(t(),1),k=n();function A(e,t){switch(e){case`folder_name_required`:return t(`board:folder.error.nameRequired`);case`folder_name_invalid`:return t(`board:folder.error.nameInvalid`);case`folder_parent_missing`:case`folder_parent_invalid`:return t(`board:folder.error.parentMissing`);case`folder_exists_as_file`:return t(`board:folder.error.existsAsFile`);case`folder_permission_denied`:return t(`board:folder.error.permission`);default:return``}}function j({open:e,initialParent:t,onOpenChange:n,onCreated:j,onCloseAutoFocus:M}){let{t:N}=r(),[P,F]=(0,O.useState)(t),[I,L]=(0,O.useState)(``),[R,z]=(0,O.useState)(!1),[B,V]=(0,O.useState)(!1),[H,U]=(0,O.useState)(!1),[W,G]=(0,O.useState)(``),K=(0,O.useRef)(0),q=(0,O.useRef)(!1),J=(0,O.useRef)(null),Y=R||B;(0,O.useEffect)(()=>{K.current+=1,q.current=!1,e&&(F(t),L(``),z(!1),V(!1),U(!1),G(``))},[t,e]);let X=async()=>{if(q.current)return;q.current=!0;let e=K.current;V(!0),G(``);try{let t=await x(P.trim(),N(`board:folder.browseTitle`));if(e!==K.current)return;t.status===`picked`?F(t.path):t.status===`unavailable`&&(U(!0),J.current?.focus())}catch(t){e===K.current&&G(t instanceof Error?t.message:String(t))}finally{e===K.current&&(q.current=!1,V(!1))}},Z=async e=>{if(e.preventDefault(),q.current||!I.trim())return;q.current=!0;let t=K.current;z(!0),G(``);try{let e=await S(P.trim(),I.trim());if(t!==K.current)return;j(e.path),n(!1)}catch(e){if(t!==K.current)return;let n=A(e instanceof i?e.data?.code:void 0,N);G(n||(e instanceof Error&&e.message?N(`board:folder.error.failedWithReason`,{reason:e.message}):N(`board:folder.error.failed`)))}finally{t===K.current&&(q.current=!1,z(!1))}},Q=I.trim()?C(P,I.trim()):``;return(0,k.jsx)(h,{open:e,onOpenChange:e=>!q.current&&n(e),children:(0,k.jsxs)(d,{showCloseButton:!Y,"aria-describedby":`board-new-folder`,onCloseAutoFocus:M,"data-new-folder-dialog":!0,children:[(0,k.jsxs)(m,{children:[(0,k.jsx)(f,{children:N(`board:folder.title`)}),(0,k.jsx)(u,{id:`board-new-folder`,children:N(`board:folder.description`)})]}),(0,k.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:e=>void Z(e),children:[(0,k.jsxs)(E,{variant:`control`,children:[N(`board:folder.parent`),(0,k.jsxs)(b,{className:`max-[650px]:h-11`,children:[(0,k.jsx)(_,{ref:J,className:`font-mono text-xs`,value:P,disabled:Y,placeholder:N(`board:folder.parentPlaceholder`),"data-new-folder-parent":!0,onChange:e=>F(e.target.value)}),(0,k.jsx)(v,{align:`inline-end`,children:(0,k.jsxs)(y,{size:`xs`,disabled:Y,"data-new-folder-browse":!0,onClick:()=>void X(),children:[B?(0,k.jsx)(c,{className:`text-current`}):(0,k.jsx)(a,{}),N(`board:folder.browse`)]})})]})]}),H&&(0,k.jsx)(D,{className:`-mt-2`,children:N(`board:folder.browseUnavailable`)}),(0,k.jsxs)(E,{variant:`control`,children:[N(`board:folder.name`),(0,k.jsx)(g,{autoFocus:!0,className:`max-[650px]:h-11`,value:I,disabled:Y,placeholder:N(`board:folder.namePlaceholder`),autoComplete:`off`,spellCheck:!1,"data-new-folder-name":!0,onChange:e=>{L(e.target.value),W&&G(``)}})]}),Q&&(0,k.jsx)(`p`,{className:`-mt-2 truncate font-mono text-xs text-content-muted`,title:Q,children:N(`board:folder.preview`,{path:Q})}),W&&(0,k.jsxs)(T,{variant:`destructive`,children:[(0,k.jsx)(s,{}),(0,k.jsx)(w,{className:`min-w-0 break-words`,children:W})]}),(0,k.jsxs)(p,{children:[(0,k.jsx)(l,{type:`button`,variant:`secondary`,size:`dialogAction`,disabled:Y,onClick:()=>n(!1),children:N(`common:ui.cancel`)}),(0,k.jsxs)(l,{type:`submit`,size:`dialogAction`,disabled:Y||!I.trim(),children:[R?(0,k.jsx)(c,{className:`text-current`}):(0,k.jsx)(o,{}),N(R?`board:folder.creating`:`board:folder.create`)]})]})]})]})})}export{j as NewFolderDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./vendor-react-DwNgTV1j.js";import{t}from"./use-i18n-
|
|
1
|
+
import{r as e}from"./vendor-react-DwNgTV1j.js";import{t}from"./use-i18n-BqDnJFL5.js";import{t as n}from"./chevron-left-BAtyp3_6.js";import{t as r}from"./square-terminal-BVG6cUT1.js";import{r as i}from"./more-pages-D_PnxLN0.js";import{t as a}from"./utils-C8uzG5AZ.js";import{t as o}from"./button-CCcCN8tE.js";import{s}from"./shortcuts-DsFEMyT1.js";var c=e();function l({meta:e,page:l,desktopPlatform:u,terminalOpen:d,onToggleTerminal:f,onBackToMore:p,phoneShell:m=!1}){let{t:h}=t(),g=s(`toggleTerminal`),_=!!u,v=i.has(l)||p?h(`navigation:sidebar.features`):``;return(0,c.jsx)(`header`,{"data-focus-region":`header`,"data-window-drag-region":!0,className:a(`@container/page-header relative z-[2] flex flex-none flex-col`,_&&`[-webkit-app-region:drag]`),children:(0,c.jsxs)(`div`,{className:a(`flex min-h-12 items-center gap-2 border-b border-stroke-soft py-1.5 pr-2.5 in-data-[density=compact]:min-h-11 max-[650px]:min-h-0 max-[650px]:flex-wrap max-[650px]:gap-x-2 max-[650px]:gap-y-0 max-[650px]:border-b-0 max-[650px]:px-4 max-[650px]:pt-0 max-[650px]:pb-3`,`pl-[calc(16px+var(--workbench-leading-inset,0px))] max-[650px]:pl-4`,`[[data-custom-titlebar]_&]:pr-[144px]`),children:[(0,c.jsxs)(`div`,{className:a(`mr-auto flex min-w-0 items-center gap-1.5 text-[13px]`,`max-[650px]:h-14 max-[650px]:basis-full max-[650px]:gap-2`,m&&(v&&p?`max-[650px]:h-11`:`max-[650px]:h-0`)),children:[v&&p?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)(`button`,{type:`button`,"data-back-to-more":!0,className:`-ml-1.5 flex h-7 shrink-0 items-center gap-0.5 rounded-sm pr-1.5 pl-1 text-content-muted transition-colors duration-(--d-fast) hover:bg-surface-hover hover:text-content focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus max-[650px]:-ml-3 max-[650px]:h-11 max-[650px]:min-w-11 max-[650px]:pr-2 max-[650px]:text-sm max-[650px]:text-content-secondary`,"aria-label":h(`navigation:shell.backToFeaturesLabel`),onClick:p,children:[(0,c.jsx)(n,{className:`size-4 max-[650px]:size-5`,"aria-hidden":`true`}),(0,c.jsx)(`span`,{children:v})]}),(0,c.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 text-content-faint max-[650px]:hidden`,children:`/`})]}):v&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(`span`,{className:`shrink-0 text-content-muted max-[900px]:hidden`,children:v}),(0,c.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 text-content-faint max-[900px]:hidden`,children:`/`})]}),(0,c.jsx)(`h1`,{className:a(`max-w-full min-w-[4em] truncate text-[13px] leading-5 font-medium text-content max-[650px]:min-w-0 max-[650px]:text-2xl max-[650px]:leading-8 max-[650px]:font-[650] max-[650px]:tracking-[-.015em]`,m&&`sr-only`),children:e[0]}),e[1]&&!m&&(0,c.jsx)(`p`,{className:`ml-1.5 min-w-0 truncate text-xs text-content-muted max-[900px]:hidden max-[650px]:ml-0 max-[650px]:block max-[650px]:flex-1 max-[650px]:basis-0`,children:e[1]})]}),_&&(0,c.jsx)(`div`,{className:`flex min-w-0 items-center justify-end gap-1.5 [-webkit-app-region:no-drag]`,children:(0,c.jsx)(o,{variant:`ghost`,size:`icon`,className:a(`text-content-muted max-[650px]:hidden`,d&&`bg-surface-hover text-accent-fg`),title:g?`${h(`navigation:pageHeader.toggleTerminal`)} (${g})`:h(`navigation:pageHeader.toggleTerminal`),"aria-label":h(`navigation:pageHeader.toggleTerminal`),"aria-pressed":d,onClick:f,children:(0,c.jsx)(r,{size:16})})})]})})}export{l as PageHeader};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./vendor-react-DwNgTV1j.js";import{t}from"./use-i18n-
|
|
1
|
+
import{r as e}from"./vendor-react-DwNgTV1j.js";import{t}from"./use-i18n-BqDnJFL5.js";import{n,t as r}from"./list-T5PqlpS2.js";import{t as i}from"./search-D0mqDaf_.js";import{t as a}from"./settings-QX0oWnVK.js";import{t as o}from"./square-pen-hYbjKh6A.js";import{t as s}from"./utils-C8uzG5AZ.js";import{n as c,o as l,r as u,t as d}from"./sheet-BTaIEX4w.js";import{t as f}from"./sidebar-store-BxHuw5mD.js";var p=e(),m=`flex h-11 w-full min-w-0 items-center gap-3 rounded-[var(--r-md)] px-2.5 text-base text-content transition-colors duration-(--d-fast) focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus active:bg-surface-hover`;function h({active:e,onSearch:h,onNewTask:g,onOpenBoard:_,onOpenFeatures:v,onOpenSettings:y,content:b,boardCount:x,update:S}){let{t:C}=t(),w=f(e=>e.drawerOpen),T=f(e=>e.setDrawerOpen),E=e=>()=>{T(!1),e()},D=(t,n,r,i,a)=>(0,p.jsxs)(`button`,{type:`button`,"data-drawer-entry":t,"aria-current":e===t?`page`:void 0,className:s(m,e===t&&`bg-surface-active`),onClick:E(i),children:[(0,p.jsx)(n,{className:`size-[18px] flex-none text-content-secondary`,strokeWidth:1.75,"aria-hidden":`true`}),(0,p.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:r}),a]});return(0,p.jsx)(d,{open:w,onOpenChange:T,children:(0,p.jsxs)(c,{side:`left`,showCloseButton:!1,"data-phone-drawer":!0,onCloseAutoFocus:e=>{let t=document.querySelector(`[data-phone-menu]`);t&&(e.preventDefault(),t.focus())},"aria-describedby":void 0,className:`w-[min(320px,85vw)] gap-0 border-stroke-soft bg-sidebar p-0 pt-[var(--pisper-safe-area-top)] pb-[var(--pisper-safe-area-bottom)] pl-[var(--pisper-safe-area-left)] data-[side=left]:w-[min(320px,85vw)] data-[side=left]:max-w-none`,children:[(0,p.jsx)(l,{className:`sr-only`,children:C(`navigation:phone.drawer`)}),(0,p.jsx)(u,{className:`sr-only`,children:C(`navigation:phone.drawerHint`)}),(0,p.jsxs)(`div`,{className:`flex flex-none items-center gap-2 px-3 pt-3 pb-2`,children:[(0,p.jsxs)(`button`,{type:`button`,"data-drawer-search":!0,className:`flex h-11 min-w-0 flex-1 items-center gap-2 rounded-[10px] bg-surface-muted px-3 text-left text-base text-content-muted focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus`,onClick:E(h),children:[(0,p.jsx)(i,{className:`size-[18px] flex-none`,strokeWidth:1.75,"aria-hidden":`true`}),(0,p.jsx)(`span`,{className:`truncate`,children:C(`navigation:sidebar.search`)})]}),(0,p.jsx)(`button`,{type:`button`,"data-drawer-new-task":!0,"aria-label":C(`navigation:shell.newTask`),className:`grid size-11 flex-none place-items-center rounded-[var(--r-md)] text-content-secondary focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus active:bg-surface-hover`,onClick:E(g),children:(0,p.jsx)(o,{className:`size-5`,strokeWidth:1.75,"aria-hidden":`true`})})]}),(0,p.jsxs)(`nav`,{"aria-label":C(`navigation:shell.primaryNavigation`),className:`flex-none px-2 pb-2`,children:[D(`board`,r,C(`navigation:sidebar.allAgents`),_,x?(0,p.jsx)(`span`,{className:`flex-none text-sm text-content-muted tabular-nums`,children:x}):void 0),D(`features`,n,C(`navigation:sidebar.features`),v)]}),(0,p.jsx)(`div`,{"data-drawer-sessions":!0,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-2 pt-1`,children:b}),(0,p.jsxs)(`div`,{className:`flex flex-none items-center gap-1 border-t border-stroke-soft px-2 py-2`,children:[(0,p.jsx)(`div`,{className:`min-w-0 flex-1`,children:D(`settings`,a,C(`navigation:navigation.settings`),y)}),S]})]})})}export{h as PhoneDrawer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./vendor-react-DwNgTV1j.js";import{t}from"./use-i18n-
|
|
1
|
+
import{r as e}from"./vendor-react-DwNgTV1j.js";import{t}from"./use-i18n-BqDnJFL5.js";import{t as n}from"./createLucideIcon-Cd-3GVxJ.js";import{t as r}from"./utils-C8uzG5AZ.js";import{t as i}from"./sidebar-store-BxHuw5mD.js";import{t as a}from"./useSidebarModel-D21Q54-Q.js";import"./public-CAdIUTea.js";var o=n(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),s=e();function c({className:e}){let{t:n}=t(),{model:c}=a(),l=i(e=>e.drawerOpen),u=i(e=>e.setDrawerOpen),d=c.counts.attention;return(0,s.jsxs)(`button`,{type:`button`,"data-phone-menu":!0,"aria-haspopup":`dialog`,"aria-expanded":l,"aria-label":d>0?n(`navigation:phone.menuAttention`,{count:d}):n(`navigation:phone.menu`),className:r(`flex h-11 min-w-11 flex-none items-center justify-center gap-1.5 rounded-full bg-surface-muted px-2.5 text-content transition-colors duration-(--d-fast) focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus active:bg-surface-hover dark:bg-surface-active`,e),onClick:()=>u(!0),children:[(0,s.jsx)(o,{className:`size-5`,strokeWidth:1.75,"aria-hidden":`true`}),d>0&&(0,s.jsxs)(`span`,{"aria-hidden":`true`,"data-phone-attention":d,className:`flex h-5 items-center gap-1 rounded-full bg-warning-soft px-1.5 text-xs leading-none font-semibold text-warning-strong tabular-nums ring-1 ring-st-attn-border ring-inset`,children:[(0,s.jsx)(`span`,{className:`size-1.5 rounded-full bg-st-attn-fill`}),d>99?`99+`:d]})]})}export{c as PhoneMenuButton};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./vendor-react-DwNgTV1j.js";import{t}from"./use-i18n-
|
|
1
|
+
import{r as e}from"./vendor-react-DwNgTV1j.js";import{t}from"./use-i18n-BqDnJFL5.js";import{t as n}from"./search-D0mqDaf_.js";import{t as r}from"./square-pen-hYbjKh6A.js";import{PhoneMenuButton as i}from"./PhoneMenuButton-DiDPv4NZ.js";var a=e(),o=`grid size-11 flex-none place-items-center rounded-full bg-surface-muted text-content focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus active:bg-surface-hover dark:bg-surface-active`;function s({title:e,onNewTask:s,onSearch:c}){let{t:l}=t();return(0,a.jsxs)(`header`,{"data-phone-topbar":!0,"data-focus-region":`header`,className:`relative grid h-14 flex-none grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center bg-panel px-3`,children:[(0,a.jsx)(`div`,{className:`flex min-w-0 items-center`,children:(0,a.jsx)(i,{})}),(0,a.jsx)(`p`,{"data-phone-title":!0,"aria-hidden":`true`,className:`max-w-[min(56vw,240px)] truncate text-center text-base leading-6 font-semibold text-content`,children:e}),(0,a.jsxs)(`div`,{className:`flex min-w-0 items-center justify-end gap-2`,children:[c&&(0,a.jsx)(`button`,{type:`button`,"data-phone-search":!0,"aria-label":l(`navigation:sidebar.search`),className:o,onClick:c,children:(0,a.jsx)(n,{className:`size-5`,strokeWidth:1.75,"aria-hidden":`true`})}),(0,a.jsx)(`button`,{type:`button`,"data-phone-new-task":!0,"aria-label":l(`navigation:shell.newTask`),className:o,onClick:s,children:(0,a.jsx)(r,{className:`size-5`,strokeWidth:1.75,"aria-hidden":`true`})})]})]})}export{s as PhoneTopBar};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{t as r}from"./use-i18n-DL1_y_Ge.js";import{t as i}from"./api-BA-WPJCg.js";import{i as a}from"./runtime-capabilities-CxyszNkG.js";import{t as o}from"./runtime-capabilities-store-CJA8-sSC.js";import{t as s}from"./createLucideIcon-Cd-3GVxJ.js";import{t as c}from"./circle-check-iEdCm3Pw.js";import{t as l}from"./earth-Ddy13fHh.js";import{t as u}from"./external-link-CEQqPcqc.js";import{t as d}from"./eye-uWAPXNzJ.js";import{t as f}from"./file-code-corner-BnE1ljT0.js";import{t as p}from"./folder-open-FIShC5Qk.js";import{t as m}from"./image-BY_c3FYU.js";import{t as h}from"./package-BOmkLaKS.js";import{t as g}from"./plug-BsIeHRwC.js";import{t as _}from"./save-CHBB52P8.js";import{t as v}from"./search-D0mqDaf_.js";import{t as y}from"./server-BgNvmqwJ.js";import{t as b}from"./shield-alert-oZqX6MNu.js";import{t as ee}from"./trash-2-CNrPOoPR.js";import{t as x}from"./triangle-alert-CE1q54ci.js";import{t as S}from"./more-pages-D_PnxLN0.js";import{a as C,c as w,i as te,n as ne,o as re,r as ie,s as ae,t as oe}from"./alert-dialog-DiUitBB0.js";import{t as se}from"./utils-C8uzG5AZ.js";import{n as ce,t as T}from"./button-CCcCN8tE.js";import{s as le}from"./shortcuts-Cth0vc77.js";import{a as E,i as ue,l as D,o as O,s as de,t as k}from"./dialog-BfkdQrrN.js";import{t as A}from"./input-CPw-zkYh.js";import{t as j}from"./pick-system-directory-j8yF4oD7.js";import{n as fe,t as pe}from"./PageState-Cz6vFMXv.js";import{a as me,i as M,n as N,o as P,r as he,s as ge,t as F}from"./FeaturePage-DT8W4UlT.js";import{t as I}from"./AppSelect-B15Hpk2W.js";import{c as _e,i as ve,s as ye}from"./app-primitives-BskZ4ZJj.js";import{a as L,i as be,n as xe,o as Se,r as Ce,s as we,t as Te}from"./tool-labels-D-3gybP7.js";var R=s(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),z=s(`package-plus`,[[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`path`,{d:`M16 17h6`,key:`1ook5g`}],[`path`,{d:`M19 14v6`,key:`1ckrd5`}],[`path`,{d:`M21 10.535V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.729l7 4a2 2 0 0 0 2 .001l1.675-.955`,key:`28k6lz`}],[`path`,{d:`M3.29 7 12 12l8.71-5`,key:`19ckod`}],[`path`,{d:`m7.5 4.27 8.997 5.148`,key:`9yrvtv`}]]),B=e(t(),1),V=n();function H(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Ee({open:e,onOpenChange:t,onInstalled:n}){let{t:a}=r(),[o,s]=(0,B.useState)(``),[l,u]=(0,B.useState)(null),[d,f]=(0,B.useState)(!1),[m,h]=(0,B.useState)(``);return(0,B.useEffect)(()=>{e||(s(``),u(null),f(!1),h(``))},[e]),(0,V.jsx)(k,{open:e,onOpenChange:e=>!d&&t(e),children:(0,V.jsxs)(ue,{className:`z-[220] sm:max-w-xl`,overlayClassName:`z-[220]`,children:[(0,V.jsxs)(de,{children:[(0,V.jsxs)(D,{className:`flex items-center gap-2`,children:[(0,V.jsx)(z,{className:`size-4 text-content-secondary`}),a(`plugins:pluginsPage.installLocalPlugin`)]}),(0,V.jsx)(E,{children:a(`plugins:pluginsPage.installLocalPluginDescription`)})]}),(0,V.jsxs)(`div`,{className:`grid gap-3`,children:[(0,V.jsxs)(`label`,{className:`grid gap-1.5 text-xs font-medium text-content-secondary`,children:[a(`plugins:pluginsPage.pluginDirectory`),(0,V.jsxs)(`span`,{className:`flex min-w-0 gap-2`,children:[(0,V.jsx)(A,{className:`min-w-0 flex-1 font-mono text-xs max-[650px]:h-11`,value:o,disabled:d,placeholder:a(`plugins:pluginsPage.pluginDirectoryPlaceholder`),onChange:e=>{s(e.target.value),u(null)}}),(0,V.jsx)(T,{type:`button`,variant:`secondary`,size:`icon`,className:`size-[34px] shrink-0 max-[650px]:size-11`,title:a(`plugins:pluginsPage.chooseDirectory`),"aria-label":a(`plugins:pluginsPage.chooseDirectory`),onClick:async()=>{h(``);try{let e=await j(o,a(`plugins:pluginsPage.chooseDirectory`));e.status===`picked`?(s(e.path),u(null)):e.status===`unavailable`&&h(a(`common:workspacePicker.systemPickerUnavailable`))}catch(e){h(e instanceof Error?e.message:String(e))}},children:(0,V.jsx)(p,{})})]})]}),l&&(0,V.jsxs)(`div`,{className:`grid gap-3 overflow-hidden rounded-md border border-stroke bg-surface-subtle p-3`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,V.jsx)(`span`,{className:`grid size-8 shrink-0 place-items-center rounded-sm bg-success-soft text-success`,children:(0,V.jsx)(c,{className:`size-4`})}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`strong`,{className:`block truncate text-sm font-medium text-content`,children:l.plugin.name}),(0,V.jsxs)(`small`,{className:`block truncate font-mono text-xs text-content-muted tabular-nums`,children:[l.plugin.id,` · v`,l.plugin.version,` · `,l.fileCount,` `,a(`plugins:pluginsPage.files`),` · `,H(l.byteCount)]})]})]}),(0,V.jsx)(`div`,{className:`grid gap-1.5`,children:l.plugin.capabilities.map(e=>(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-t border-stroke-soft pt-2 text-xs`,children:[(0,V.jsxs)(`span`,{className:`min-w-0`,children:[(0,V.jsx)(`strong`,{className:`block font-medium text-content`,children:e.label}),(0,V.jsx)(`small`,{className:`text-xs text-content-muted`,children:e.description})]}),(0,V.jsx)(`code`,{className:`shrink-0 font-mono text-xs text-content-secondary`,children:e.name})]},e.name))}),(0,V.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm bg-warning-soft p-2.5 text-xs leading-5 text-warning-strong`,children:[(0,V.jsx)(x,{className:`mt-0.5 shrink-0`,size:15}),(0,V.jsx)(`span`,{children:a(`plugins:pluginsPage.localPluginSecurityWarning`)})]})]}),m&&(0,V.jsxs)(ve,{className:`m-0`,children:[(0,V.jsx)(x,{size:14}),(0,V.jsx)(`span`,{children:m})]})]}),(0,V.jsxs)(O,{children:[(0,V.jsx)(T,{type:`button`,variant:`secondary`,size:`dialogAction`,disabled:d,onClick:()=>t(!1),children:a(`common:ui.cancel`)}),(0,V.jsxs)(T,{type:`button`,size:`dialogAction`,disabled:d||!l&&!o.trim(),onClick:l?async()=>{if(!(!l||d)){f(!0),h(``);try{await i(`/api/plugins/install`,{method:`POST`,body:JSON.stringify({inspectionId:l.inspectionId})}),await n(),t(!1)}catch(e){h(e instanceof Error?e.message:String(e))}finally{f(!1)}}}:async()=>{if(!(!o.trim()||d)){f(!0),h(``);try{u(await i(`/api/plugins/inspect`,{method:`POST`,body:JSON.stringify({path:o.trim()})}))}catch(e){u(null),h(e instanceof Error?e.message:String(e))}finally{f(!1)}}},children:[d?(0,V.jsx)(ce,{className:`text-current`}):l?(0,V.jsx)(z,{}):(0,V.jsx)(c,{}),a(d?`plugins:pluginsPage.processing`:l?`plugins:pluginsPage.installPlugin`:`plugins:pluginsPage.inspectPlugin`)]})]})]})})}var U=[`tool`,`prompt`,`skill`];function W(e){let t=Array.isArray(e.resourceTypes)?e.resourceTypes.filter(e=>U.includes(e)):[];return t.length?t:[`tool`]}function G(e,t){return{tool:t(`plugins:pluginsPage.extensionType.tool`),prompt:t(`plugins:pluginsPage.extensionType.prompt`),skill:t(`plugins:pluginsPage.extensionType.skill`)}[e]}var De=[`all`,`builtin`,`local`],Oe={read:d,ls:p,grep:v,find:v,edit:f,write:f,bash:y,web_search:l,browser_automation:l,computer_use:R,generate_visual:m};function K(e,t){return t(e===`builtin`?`plugins:pluginsPage.builtIn`:e===`local`?`plugins:pluginsPage.local`:`plugins:pluginsPage.all`)}function ke(e){return e.flatMap(e=>e.managedExternally?[]:e.capabilities.filter(e=>e.enabled).map(e=>e.name))}function Ae(e){return e.filter(e=>!e.managedExternally||e.source===`pi`).flatMap(e=>e.capabilities.map(t=>({...t,pluginId:e.id,pluginName:e.name,pluginDescription:e.description,pluginVersion:e.version,pluginSource:e.source,pluginBuiltIn:e.builtIn,pluginPermissions:e.permissions||[],pluginSystemAccess:!!e.systemAccess})))}function je(e){return Object.fromEntries(e.filter(e=>e.source===`pi`&&e.name!==`Computer Use`&&!!e.packageSource).map(e=>[e.packageSource,e.enabled!==!1]))}function Me(e,t){return[...e].sort().join(`\0`)===[...t].sort().join(`\0`)}function Ne(e,t){return L({id:e.name,name:e.label},t)}function q(e,t){return e.pluginSource===`pi`?e.pluginName:Ce(e.pluginName,t)}function Pe({value:e,testing:t,onChange:n,onTest:i}){let{t:a}=r();return(0,V.jsxs)(`div`,{className:`plugin-tool-config grid gap-2.5 border-t border-stroke pt-3 [&_label]:grid [&_label]:gap-1.5 [&_label]:text-xs [&_label]:font-medium [&_label]:text-content-secondary`,children:[(0,V.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,V.jsxs)(`label`,{children:[a(`plugins:pluginsPage.defaultLanguage`),(0,V.jsxs)(I,{value:e.language,onChange:t=>n({...e,language:t.target.value}),children:[(0,V.jsx)(`option`,{value:`auto`,children:a(`plugins:pluginsPage.auto`)}),(0,V.jsx)(`option`,{value:`zh-CN`,children:a(`plugins:pluginsPage.simplifiedChinese`)}),(0,V.jsx)(`option`,{value:`en-US`,children:a(`plugins:pluginsPage.english`)})]})]}),(0,V.jsxs)(`label`,{children:[a(`plugins:pluginsPage.safeSearch`),(0,V.jsxs)(I,{value:e.safeSearch,onChange:t=>n({...e,safeSearch:Number(t.target.value)}),children:[(0,V.jsx)(`option`,{value:0,children:a(`plugins:pluginsPage.off`)}),(0,V.jsx)(`option`,{value:1,children:a(`plugins:pluginsPage.moderate`)}),(0,V.jsx)(`option`,{value:2,children:a(`plugins:pluginsPage.strict`)})]})]}),(0,V.jsxs)(`label`,{children:[a(`plugins:pluginsPage.resultCount`),(0,V.jsx)(A,{type:`number`,min:`1`,max:`12`,className:`tabular-nums`,value:e.maxResults,onChange:t=>n({...e,maxResults:Number(t.target.value)})})]})]}),(0,V.jsxs)(T,{type:`button`,variant:`secondary`,className:`justify-self-end max-[650px]:h-11`,loading:t,disabled:t,onClick:i,children:[(0,V.jsx)(l,{}),a(t?`plugins:pluginsPage.testing`:`plugins:pluginsPage.testConnection`)]})]})}function Fe({query:e,notify:t,requestText:n,requestConfirm:a}){let{t:o}=r(),[s,c]=(0,B.useState)(``),[l,d]=(0,B.useState)(null),[f,p]=(0,B.useState)([]),[m,g]=(0,B.useState)(!1),[_,y]=(0,B.useState)(``),[b,x]=(0,B.useState)(``),S=(0,B.useCallback)(async(e=``)=>{g(!0),x(``);try{let[t,n]=await Promise.all([i(`/api/extensions/market?name=${encodeURIComponent(e)}`),i(`/api/extensions`)]);d(t),p(n.packages||[])}catch(e){x(e instanceof Error?e.message:String(e))}finally{g(!1)}},[]);(0,B.useEffect)(()=>{S(``)},[S]);let C=(l?.packages||[]).filter(t=>`${t.name} ${t.description}`.toLowerCase().includes(e.trim().toLowerCase())),w=async e=>{if(await a?.({title:o(`plugins:pluginsPage.installExtension`),message:o(`plugins:pluginsPage.extensionSecurityWarning`,{name:e}),confirmLabel:o(`plugins:pluginsPage.installExtension`),tone:`danger`})!==!1){y(e);try{let n=/^(?:[.~\\/]|[A-Za-z]:[\\/])/.test(e)||/^(?:npm:|https?:\/\/|git\+)/i.test(e)?e:`npm:${e}`,r=await i(`/api/extensions/install`,{method:`POST`,body:JSON.stringify({source:n})});p(r.packages||[]),t(o(`plugins:pluginsPage.extensionInstalled`),`success`)}catch(e){t(e instanceof Error?e.message:String(e),`error`)}finally{y(``)}}},te=async()=>{let e=await n?.({title:o(`plugins:pluginsPage.installExtension`),message:o(`plugins:pluginsPage.extensionSourceHelp`),inputLabel:o(`plugins:pluginsPage.extensionSource`),placeholder:`npm:@scope/package or https://github.com/…`,maxLength:2e3});e?.trim()&&await w(e.trim())},ne=async e=>{if(await a?.({title:o(`plugins:pluginsPage.uninstallExtension`),message:o(`plugins:pluginsPage.uninstallExtensionDescription`,{name:e.name}),confirmLabel:o(`plugins:pluginsPage.uninstallExtension`),tone:`danger`})!==!1){y(e.source);try{await i(`/api/extensions`,{method:`DELETE`,body:JSON.stringify({source:e.source,scope:e.scope})}),await S(s),t(o(`plugins:pluginsPage.extensionUninstalled`),`success`)}catch(e){t(e instanceof Error?e.message:String(e),`error`)}finally{y(``)}}},re=U.map(e=>({type:e,items:f.filter(t=>W(t).includes(e))})).filter(e=>e.items.length>0);return(0,V.jsxs)(V.Fragment,{children:[re.map(e=>(0,V.jsx)(P,{className:`plugin-installed-extensions`,title:`${o(`plugins:pluginsPage.installedExtensions`)} · ${G(e.type,o)}`,count:e.items.length,children:(0,V.jsx)(N,{children:e.items.map(t=>(0,V.jsx)(M,{icon:(0,V.jsx)(h,{}),name:(0,V.jsx)(`span`,{className:`font-mono`,children:t.name}),nameMeta:`v${t.version}`,description:(0,V.jsx)(`span`,{className:`font-mono text-xs`,children:t.source}),actions:(0,V.jsxs)(T,{type:`button`,variant:`ghost`,size:`sm`,className:`text-content-muted hover:bg-danger-soft hover:text-danger`,loading:_===t.source,disabled:!!_,onClick:()=>void ne(t),children:[(0,V.jsx)(ee,{}),o(`plugins:pluginsPage.uninstallExtension`)]})},`${e.type}:${t.scope}:${t.source}`))})},e.type)),(0,V.jsxs)(P,{className:`plugin-market`,title:o(`plugins:pluginsPage.extensionMarket`),actions:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(T,{asChild:!0,variant:`ghost`,size:`sm`,children:(0,V.jsxs)(`a`,{href:`https://pi.dev/packages`,target:`_blank`,rel:`noreferrer`,children:[(0,V.jsx)(u,{}),o(`plugins:pluginsPage.openPackageCatalog`)]})}),(0,V.jsxs)(T,{type:`button`,variant:`secondary`,size:`sm`,onClick:te,disabled:!!_,children:[(0,V.jsx)(z,{}),o(`plugins:pluginsPage.installExtension`)]})]}),children:[(0,V.jsxs)(`form`,{className:`mb-3 flex min-w-0 gap-2`,onSubmit:e=>{e.preventDefault(),S(s)},children:[(0,V.jsx)(A,{className:`min-w-0 flex-1 max-[650px]:h-11`,value:s,onChange:e=>c(e.target.value),placeholder:o(`plugins:pluginsPage.searchPackageCatalog`),"aria-label":o(`plugins:pluginsPage.searchPackageCatalog`)}),(0,V.jsxs)(T,{type:`submit`,variant:`secondary`,className:`h-[34px] max-[650px]:h-11`,loading:m,disabled:m,children:[(0,V.jsx)(v,{}),o(`plugins:pluginsPage.search`)]})]}),b&&(0,V.jsx)(F,{className:`mt-0 mb-3`,children:b}),C.length>0&&(0,V.jsx)(N,{children:C.slice(0,12).map(e=>{let t=f.some(t=>t.name===e.name||t.source===`npm:${e.name}`);return(0,V.jsx)(M,{icon:(0,V.jsx)(h,{}),name:(0,V.jsx)(`span`,{className:`font-mono`,children:e.name}),description:e.description,status:e.published,actions:(0,V.jsx)(T,{type:`button`,variant:`secondary`,size:`sm`,loading:_===e.name,disabled:t||!!_,onClick:()=>void w(e.name),children:o(t?`plugins:pluginsPage.installed`:`plugins:pluginsPage.installExtension`)})},e.name)})})]})]})}function J({notify:e,onBack:t,requestText:n,requestConfirm:s}){let{t:c}=r(),l=le(`focusSearch`),u=o(e=>e.capabilities),d=a(u,`plugins`),f=d?De:De.slice(0,2),[p,m]=(0,B.useState)(``),[h,v]=(0,B.useState)(null),[y,E]=(0,B.useState)([]),[ue,D]=(0,B.useState)(``),[O,de]=(0,B.useState)(`all`),[k,A]=(0,B.useState)({provider:`bing`,language:`auto`,safeSearch:1,maxResults:8}),[j,F]=(0,B.useState)(!1),[I,L]=(0,B.useState)(!1),[Ce,R]=(0,B.useState)(!1),[H,U]=(0,B.useState)(null),[W,G]=(0,B.useState)(!1),[J,Y]=(0,B.useState)(``),[Ie,Le]=(0,B.useState)(!1),X=(0,B.useCallback)(e=>{v(e),E(e.plugins),A(e.webSearch)},[]),Z=(0,B.useCallback)(async()=>{Y(``);try{X(await i(`/api/plugins`))}catch(e){Y(e instanceof Error?e.message:String(e))}},[X]);(0,B.useEffect)(()=>{Z()},[Z]);let Re=(0,B.useMemo)(()=>Ae(y),[y]),ze=(0,B.useMemo)(()=>ke(y),[y]),Q=h?!Me(ze,h.enabledTools)||JSON.stringify(je(y))!==JSON.stringify(h.piExtensions)||JSON.stringify(k)!==JSON.stringify(h.webSearch):!1,Be=(0,B.useCallback)(async()=>{if(!j){if(!h||!Q){h&&e(c(`plugins:pluginsPage.noPluginPolicyChanges`));return}F(!0),Y(``);try{let t=await i(`/api/plugins`,{method:`PUT`,body:JSON.stringify({enabledTools:ze,webSearch:k,piExtensions:je(y)})});X(t),e(c(`plugins:pluginsPage.pluginPolicySavedAgentRuntimeUpdated`))}catch(e){Y(e instanceof Error?e.message:String(e))}finally{F(!1)}}},[X,h,Q,y,ze,e,j,c,k]),Ve=async()=>{L(!0),Y(``);try{let t=await i(`/api/plugins/web-search/test`,{method:`POST`,body:JSON.stringify(k)});e(c(`plugins:pluginsPage.bingSearchIsAvailableAndReturnedCountResults`,{count:t.count}))}catch(t){let n=t instanceof Error?t.message:String(t);Y(n),e(n,`error`)}finally{L(!1)}},He=(e,t,n)=>{E(r=>r.map(r=>{if(r.id!==e)return r;let i=r.source===`pi`&&r.managedExternally;return{...r,enabled:n||r.capabilities.some(e=>e.enabled),capabilities:r.capabilities.map(e=>i||e.name===t?{...e,enabled:n}:e)}}))},Ue=()=>!Q||(Y(c(`plugins:pluginsPage.saveBeforePluginChanges`)),!1),We=async()=>{if(!(!H||W)){G(!0),Y(``);try{X(await i(`/api/plugins/${encodeURIComponent(H.pluginId)}`,{method:`DELETE`})),e(c(`plugins:pluginsPage.pluginUninstalled`,{name:H.pluginName})),D(``),U(null)}catch(e){Y(e instanceof Error?e.message:String(e))}finally{G(!1)}}},Ge=c(`navigation:navigation.plugins`),Ke=p.trim().toLowerCase(),$=Re.filter(e=>O!==`all`&&e.pluginSource!==O?!1:[Ne(e,c),e.name,e.description,q(e,c),e.pluginId].join(` `).toLowerCase().includes(Ke));return(0,V.jsxs)(he,{title:Ge,description:c(`plugins:pluginsPage.lede`),back:t&&{label:c(`navigation:sidebar.features`),ariaLabel:c(`navigation:shell.backToFeaturesLabel`),onBack:t},toolbar:(0,V.jsx)(ge,{search:(0,V.jsx)(me,{id:S,value:p,onValueChange:m,placeholder:c(`navigation:pageHeader.searchPage`,{page:Ge}),shortcut:l,clearLabel:c(`navigation:more.clearSearch`)}),actions:(0,V.jsxs)(V.Fragment,{children:[d&&(0,V.jsxs)(T,{type:`button`,variant:`secondary`,className:`h-9`,disabled:!h,onClick:()=>Ue()&&R(!0),children:[(0,V.jsx)(z,{}),c(`plugins:pluginsPage.installPlugin`)]}),(0,V.jsxs)(T,{type:`button`,className:`h-9`,"data-plugins-save":!0,loading:j,disabled:!h||j,onClick:()=>void Be(),children:[(0,V.jsx)(_,{}),c(`plugins:pluginsPage.savePolicy`)]})]}),filters:(0,V.jsx)(_e,{options:f.map(e=>K(e,c)),value:K(O,c),onChange:e=>de(f.find(t=>K(t,c)===e)||`all`)})}),children:[h?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(P,{className:`plugin-catalog`,title:c(`plugins:pluginsPage.toolCatalog`),count:$.length,meta:(0,V.jsxs)(`span`,{className:`plugin-catalog-summary`,children:[Re.filter(e=>e.enabled).length,`/`,Re.length,` `,c(`plugins:pluginsPage.enabled2`)]}),actions:Q&&(0,V.jsxs)(`span`,{"data-plugins-unsaved":!0,className:`flex items-center gap-1.5 text-xs font-medium text-content-secondary`,children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full bg-content-secondary`}),c(`plugins:pluginsPage.unsaved`)]}),children:$.length?(0,V.jsx)(N,{className:`plugin-tool-grid`,children:$.map(e=>{let t=Oe[e.name]||g,n=Ne(e,c);return(0,V.jsx)(M,{className:`plugin-tool-card`,"data-plugin-tool":e.name,icon:(0,V.jsx)(t,{}),name:(0,V.jsx)(`span`,{title:n,children:n}),nameMeta:e.name,description:`${q(e,c)} · ${Se(e.risk,c)}`,status:e.pluginBuiltIn?void 0:c(`plugins:pluginsPage.local`),actions:(0,V.jsx)(ye,{value:e.enabled,onChange:t=>He(e.pluginId,e.name,t),ariaLabel:n}),expanded:ue===e.name,onExpandedChange:t=>D(t?e.name:``),toggleLabel:c(`plugins:pluginsPage.toggleToolDetails`,{name:n}),detail:(0,V.jsxs)(`div`,{className:`plugin-tool-details grid gap-3`,children:[(0,V.jsx)(`p`,{className:`text-sm leading-relaxed text-content-soft`,children:be({id:e.name,description:e.description},c)}),(0,V.jsxs)(`dl`,{className:`grid grid-cols-[88px_minmax(0,1fr)] gap-x-3 gap-y-1.5 text-xs [&_dd]:min-w-0 [&_dd]:[overflow-wrap:anywhere] [&_dd]:text-content-soft [&_dt]:text-content-muted [&>div]:contents`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{children:c(`plugins:pluginsPage.source`)}),(0,V.jsxs)(`dd`,{className:`tabular-nums`,children:[q(e,c),!e.pluginBuiltIn&&` · v${e.pluginVersion}`]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{children:c(`plugins:pluginsPage.riskLevel`)}),(0,V.jsx)(`dd`,{className:se((Te(e.risk)||xe(e.risk))&&`font-medium text-content!`),children:Se(e.risk,c)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{children:c(`plugins:pluginsPage.pathScope`)}),(0,V.jsx)(`dd`,{children:we({id:e.name,scope:e.scope},c)})]}),!e.pluginBuiltIn&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{children:c(`plugins:pluginsPage.executionMode`)}),(0,V.jsx)(`dd`,{children:c(`plugins:pluginsPage.confirmUnlessFullAccess`)})]})]}),!e.pluginBuiltIn&&(0,V.jsxs)(`div`,{className:`plugin-tool-warning flex items-start gap-2 rounded-sm bg-surface-subtle p-2.5 text-xs leading-normal text-content-secondary`,children:[(0,V.jsx)(b,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{children:c(`plugins:pluginsPage.localPluginSecurityWarning`)})]}),e.name===`web_search`&&(0,V.jsx)(Pe,{value:k,testing:I,onChange:A,onTest:Ve}),!e.pluginBuiltIn&&(0,V.jsxs)(T,{type:`button`,variant:`ghost`,className:`justify-self-end text-danger hover:bg-danger-soft hover:text-danger max-[650px]:h-11`,onClick:()=>Ue()&&U(e),children:[(0,V.jsx)(ee,{}),c(`plugins:pluginsPage.uninstallPlugin`)]})]})},e.name)})}):(0,V.jsx)(pe,{compact:!0,title:c(`plugins:pluginsPage.noMatchingTools`)})}),(0,V.jsx)(Fe,{query:p,notify:e,requestText:n,requestConfirm:s})]}):J?(0,V.jsx)(fe,{kind:`error`,title:c(`plugins:pluginsPage.loadFailed`),description:J,action:(0,V.jsx)(T,{variant:`secondary`,className:`max-[650px]:h-11`,loading:Ie,disabled:Ie,onClick:()=>{Le(!0),Z().finally(()=>Le(!1))},children:c(`common:pageTemplate.retry`)})}):(0,V.jsx)(fe,{kind:`loading`,title:c(`plugins:pluginsPage.loadingToolPlugins`)}),d&&(0,V.jsx)(Ee,{open:Ce,onOpenChange:R,onInstalled:Z}),(0,V.jsx)(oe,{open:!!H,onOpenChange:e=>!e&&!W&&U(null),children:(0,V.jsxs)(te,{className:`z-[220]`,children:[(0,V.jsxs)(ae,{children:[(0,V.jsx)(w,{children:c(`plugins:pluginsPage.uninstallPlugin`)}),(0,V.jsx)(C,{children:c(`plugins:pluginsPage.uninstallPluginDescription`,{name:H?.pluginName||``})})]}),(0,V.jsxs)(re,{children:[(0,V.jsx)(ie,{disabled:W,children:c(`common:ui.cancel`)}),(0,V.jsxs)(ne,{variant:`destructive`,disabled:W,onClick:We,children:[W&&(0,V.jsx)(ce,{className:`text-current`}),c(`plugins:pluginsPage.uninstallPlugin`)]})]})]})}),J&&h&&(0,V.jsxs)(ve,{className:`fixed right-6 bottom-6 z-[21] max-w-[360px] border border-danger-border shadow-float`,children:[(0,V.jsx)(x,{size:13}),J]})]})}export{J as PluginsPage};
|
|
1
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{t as r}from"./use-i18n-BqDnJFL5.js";import{t as i}from"./api-BbBnrW3n.js";import{i as a}from"./runtime-capabilities-CxyszNkG.js";import{t as o}from"./runtime-capabilities-store-aG2QVT6b.js";import{t as s}from"./createLucideIcon-Cd-3GVxJ.js";import{t as c}from"./circle-check-iEdCm3Pw.js";import{t as l}from"./earth-Ddy13fHh.js";import{t as u}from"./external-link-CEQqPcqc.js";import{t as d}from"./eye-uWAPXNzJ.js";import{t as f}from"./file-code-corner-BnE1ljT0.js";import{t as p}from"./folder-open-FIShC5Qk.js";import{t as m}from"./image-BY_c3FYU.js";import{t as h}from"./package-BOmkLaKS.js";import{t as g}from"./plug-BsIeHRwC.js";import{t as _}from"./save-CHBB52P8.js";import{t as v}from"./search-D0mqDaf_.js";import{t as y}from"./server-BgNvmqwJ.js";import{t as b}from"./shield-alert-oZqX6MNu.js";import{t as ee}from"./trash-2-CNrPOoPR.js";import{t as x}from"./triangle-alert-CE1q54ci.js";import{t as S}from"./more-pages-D_PnxLN0.js";import{a as C,c as w,i as te,n as ne,o as re,r as ie,s as ae,t as oe}from"./alert-dialog-DiUitBB0.js";import{t as se}from"./utils-C8uzG5AZ.js";import{n as ce,t as T}from"./button-CCcCN8tE.js";import{s as le}from"./shortcuts-DsFEMyT1.js";import{a as E,i as ue,l as D,o as O,s as de,t as k}from"./dialog-CW8GeCdI.js";import{t as A}from"./input-CPw-zkYh.js";import{t as j}from"./pick-system-directory-C4P5z66U.js";import{n as fe,t as pe}from"./PageState-Cz6vFMXv.js";import{a as me,i as M,n as N,o as P,r as he,s as ge,t as F}from"./FeaturePage-xE563vuG.js";import{t as I}from"./AppSelect-B15Hpk2W.js";import{c as _e,i as ve,s as ye}from"./app-primitives-BskZ4ZJj.js";import{a as L,i as be,n as xe,o as Se,r as Ce,s as we,t as Te}from"./tool-labels-D-3gybP7.js";var R=s(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),z=s(`package-plus`,[[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`path`,{d:`M16 17h6`,key:`1ook5g`}],[`path`,{d:`M19 14v6`,key:`1ckrd5`}],[`path`,{d:`M21 10.535V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.729l7 4a2 2 0 0 0 2 .001l1.675-.955`,key:`28k6lz`}],[`path`,{d:`M3.29 7 12 12l8.71-5`,key:`19ckod`}],[`path`,{d:`m7.5 4.27 8.997 5.148`,key:`9yrvtv`}]]),B=e(t(),1),V=n();function H(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Ee({open:e,onOpenChange:t,onInstalled:n}){let{t:a}=r(),[o,s]=(0,B.useState)(``),[l,u]=(0,B.useState)(null),[d,f]=(0,B.useState)(!1),[m,h]=(0,B.useState)(``);return(0,B.useEffect)(()=>{e||(s(``),u(null),f(!1),h(``))},[e]),(0,V.jsx)(k,{open:e,onOpenChange:e=>!d&&t(e),children:(0,V.jsxs)(ue,{className:`z-[220] sm:max-w-xl`,overlayClassName:`z-[220]`,children:[(0,V.jsxs)(de,{children:[(0,V.jsxs)(D,{className:`flex items-center gap-2`,children:[(0,V.jsx)(z,{className:`size-4 text-content-secondary`}),a(`plugins:pluginsPage.installLocalPlugin`)]}),(0,V.jsx)(E,{children:a(`plugins:pluginsPage.installLocalPluginDescription`)})]}),(0,V.jsxs)(`div`,{className:`grid gap-3`,children:[(0,V.jsxs)(`label`,{className:`grid gap-1.5 text-xs font-medium text-content-secondary`,children:[a(`plugins:pluginsPage.pluginDirectory`),(0,V.jsxs)(`span`,{className:`flex min-w-0 gap-2`,children:[(0,V.jsx)(A,{className:`min-w-0 flex-1 font-mono text-xs max-[650px]:h-11`,value:o,disabled:d,placeholder:a(`plugins:pluginsPage.pluginDirectoryPlaceholder`),onChange:e=>{s(e.target.value),u(null)}}),(0,V.jsx)(T,{type:`button`,variant:`secondary`,size:`icon`,className:`size-[34px] shrink-0 max-[650px]:size-11`,title:a(`plugins:pluginsPage.chooseDirectory`),"aria-label":a(`plugins:pluginsPage.chooseDirectory`),onClick:async()=>{h(``);try{let e=await j(o,a(`plugins:pluginsPage.chooseDirectory`));e.status===`picked`?(s(e.path),u(null)):e.status===`unavailable`&&h(a(`common:workspacePicker.systemPickerUnavailable`))}catch(e){h(e instanceof Error?e.message:String(e))}},children:(0,V.jsx)(p,{})})]})]}),l&&(0,V.jsxs)(`div`,{className:`grid gap-3 overflow-hidden rounded-md border border-stroke bg-surface-subtle p-3`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,V.jsx)(`span`,{className:`grid size-8 shrink-0 place-items-center rounded-sm bg-success-soft text-success`,children:(0,V.jsx)(c,{className:`size-4`})}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`strong`,{className:`block truncate text-sm font-medium text-content`,children:l.plugin.name}),(0,V.jsxs)(`small`,{className:`block truncate font-mono text-xs text-content-muted tabular-nums`,children:[l.plugin.id,` · v`,l.plugin.version,` · `,l.fileCount,` `,a(`plugins:pluginsPage.files`),` · `,H(l.byteCount)]})]})]}),(0,V.jsx)(`div`,{className:`grid gap-1.5`,children:l.plugin.capabilities.map(e=>(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-t border-stroke-soft pt-2 text-xs`,children:[(0,V.jsxs)(`span`,{className:`min-w-0`,children:[(0,V.jsx)(`strong`,{className:`block font-medium text-content`,children:e.label}),(0,V.jsx)(`small`,{className:`text-xs text-content-muted`,children:e.description})]}),(0,V.jsx)(`code`,{className:`shrink-0 font-mono text-xs text-content-secondary`,children:e.name})]},e.name))}),(0,V.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm bg-warning-soft p-2.5 text-xs leading-5 text-warning-strong`,children:[(0,V.jsx)(x,{className:`mt-0.5 shrink-0`,size:15}),(0,V.jsx)(`span`,{children:a(`plugins:pluginsPage.localPluginSecurityWarning`)})]})]}),m&&(0,V.jsxs)(ve,{className:`m-0`,children:[(0,V.jsx)(x,{size:14}),(0,V.jsx)(`span`,{children:m})]})]}),(0,V.jsxs)(O,{children:[(0,V.jsx)(T,{type:`button`,variant:`secondary`,size:`dialogAction`,disabled:d,onClick:()=>t(!1),children:a(`common:ui.cancel`)}),(0,V.jsxs)(T,{type:`button`,size:`dialogAction`,disabled:d||!l&&!o.trim(),onClick:l?async()=>{if(!(!l||d)){f(!0),h(``);try{await i(`/api/plugins/install`,{method:`POST`,body:JSON.stringify({inspectionId:l.inspectionId})}),await n(),t(!1)}catch(e){h(e instanceof Error?e.message:String(e))}finally{f(!1)}}}:async()=>{if(!(!o.trim()||d)){f(!0),h(``);try{u(await i(`/api/plugins/inspect`,{method:`POST`,body:JSON.stringify({path:o.trim()})}))}catch(e){u(null),h(e instanceof Error?e.message:String(e))}finally{f(!1)}}},children:[d?(0,V.jsx)(ce,{className:`text-current`}):l?(0,V.jsx)(z,{}):(0,V.jsx)(c,{}),a(d?`plugins:pluginsPage.processing`:l?`plugins:pluginsPage.installPlugin`:`plugins:pluginsPage.inspectPlugin`)]})]})]})})}var U=[`tool`,`prompt`,`skill`];function W(e){let t=Array.isArray(e.resourceTypes)?e.resourceTypes.filter(e=>U.includes(e)):[];return t.length?t:[`tool`]}function G(e,t){return{tool:t(`plugins:pluginsPage.extensionType.tool`),prompt:t(`plugins:pluginsPage.extensionType.prompt`),skill:t(`plugins:pluginsPage.extensionType.skill`)}[e]}var De=[`all`,`builtin`,`local`],Oe={read:d,ls:p,grep:v,find:v,edit:f,write:f,bash:y,web_search:l,browser_automation:l,computer_use:R,generate_visual:m};function K(e,t){return t(e===`builtin`?`plugins:pluginsPage.builtIn`:e===`local`?`plugins:pluginsPage.local`:`plugins:pluginsPage.all`)}function ke(e){return e.flatMap(e=>e.managedExternally?[]:e.capabilities.filter(e=>e.enabled).map(e=>e.name))}function Ae(e){return e.filter(e=>!e.managedExternally||e.source===`pi`).flatMap(e=>e.capabilities.map(t=>({...t,pluginId:e.id,pluginName:e.name,pluginDescription:e.description,pluginVersion:e.version,pluginSource:e.source,pluginBuiltIn:e.builtIn,pluginPermissions:e.permissions||[],pluginSystemAccess:!!e.systemAccess})))}function je(e){return Object.fromEntries(e.filter(e=>e.source===`pi`&&e.name!==`Computer Use`&&!!e.packageSource).map(e=>[e.packageSource,e.enabled!==!1]))}function Me(e,t){return[...e].sort().join(`\0`)===[...t].sort().join(`\0`)}function Ne(e,t){return L({id:e.name,name:e.label},t)}function q(e,t){return e.pluginSource===`pi`?e.pluginName:Ce(e.pluginName,t)}function Pe({value:e,testing:t,onChange:n,onTest:i}){let{t:a}=r();return(0,V.jsxs)(`div`,{className:`plugin-tool-config grid gap-2.5 border-t border-stroke pt-3 [&_label]:grid [&_label]:gap-1.5 [&_label]:text-xs [&_label]:font-medium [&_label]:text-content-secondary`,children:[(0,V.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,V.jsxs)(`label`,{children:[a(`plugins:pluginsPage.defaultLanguage`),(0,V.jsxs)(I,{value:e.language,onChange:t=>n({...e,language:t.target.value}),children:[(0,V.jsx)(`option`,{value:`auto`,children:a(`plugins:pluginsPage.auto`)}),(0,V.jsx)(`option`,{value:`zh-CN`,children:a(`plugins:pluginsPage.simplifiedChinese`)}),(0,V.jsx)(`option`,{value:`en-US`,children:a(`plugins:pluginsPage.english`)})]})]}),(0,V.jsxs)(`label`,{children:[a(`plugins:pluginsPage.safeSearch`),(0,V.jsxs)(I,{value:e.safeSearch,onChange:t=>n({...e,safeSearch:Number(t.target.value)}),children:[(0,V.jsx)(`option`,{value:0,children:a(`plugins:pluginsPage.off`)}),(0,V.jsx)(`option`,{value:1,children:a(`plugins:pluginsPage.moderate`)}),(0,V.jsx)(`option`,{value:2,children:a(`plugins:pluginsPage.strict`)})]})]}),(0,V.jsxs)(`label`,{children:[a(`plugins:pluginsPage.resultCount`),(0,V.jsx)(A,{type:`number`,min:`1`,max:`12`,className:`tabular-nums`,value:e.maxResults,onChange:t=>n({...e,maxResults:Number(t.target.value)})})]})]}),(0,V.jsxs)(T,{type:`button`,variant:`secondary`,className:`justify-self-end max-[650px]:h-11`,loading:t,disabled:t,onClick:i,children:[(0,V.jsx)(l,{}),a(t?`plugins:pluginsPage.testing`:`plugins:pluginsPage.testConnection`)]})]})}function Fe({query:e,notify:t,requestText:n,requestConfirm:a}){let{t:o}=r(),[s,c]=(0,B.useState)(``),[l,d]=(0,B.useState)(null),[f,p]=(0,B.useState)([]),[m,g]=(0,B.useState)(!1),[_,y]=(0,B.useState)(``),[b,x]=(0,B.useState)(``),S=(0,B.useCallback)(async(e=``)=>{g(!0),x(``);try{let[t,n]=await Promise.all([i(`/api/extensions/market?name=${encodeURIComponent(e)}`),i(`/api/extensions`)]);d(t),p(n.packages||[])}catch(e){x(e instanceof Error?e.message:String(e))}finally{g(!1)}},[]);(0,B.useEffect)(()=>{S(``)},[S]);let C=(l?.packages||[]).filter(t=>`${t.name} ${t.description}`.toLowerCase().includes(e.trim().toLowerCase())),w=async e=>{if(await a?.({title:o(`plugins:pluginsPage.installExtension`),message:o(`plugins:pluginsPage.extensionSecurityWarning`,{name:e}),confirmLabel:o(`plugins:pluginsPage.installExtension`),tone:`danger`})!==!1){y(e);try{let n=/^(?:[.~\\/]|[A-Za-z]:[\\/])/.test(e)||/^(?:npm:|https?:\/\/|git\+)/i.test(e)?e:`npm:${e}`,r=await i(`/api/extensions/install`,{method:`POST`,body:JSON.stringify({source:n})});p(r.packages||[]),t(o(`plugins:pluginsPage.extensionInstalled`),`success`)}catch(e){t(e instanceof Error?e.message:String(e),`error`)}finally{y(``)}}},te=async()=>{let e=await n?.({title:o(`plugins:pluginsPage.installExtension`),message:o(`plugins:pluginsPage.extensionSourceHelp`),inputLabel:o(`plugins:pluginsPage.extensionSource`),placeholder:`npm:@scope/package or https://github.com/…`,maxLength:2e3});e?.trim()&&await w(e.trim())},ne=async e=>{if(await a?.({title:o(`plugins:pluginsPage.uninstallExtension`),message:o(`plugins:pluginsPage.uninstallExtensionDescription`,{name:e.name}),confirmLabel:o(`plugins:pluginsPage.uninstallExtension`),tone:`danger`})!==!1){y(e.source);try{await i(`/api/extensions`,{method:`DELETE`,body:JSON.stringify({source:e.source,scope:e.scope})}),await S(s),t(o(`plugins:pluginsPage.extensionUninstalled`),`success`)}catch(e){t(e instanceof Error?e.message:String(e),`error`)}finally{y(``)}}},re=U.map(e=>({type:e,items:f.filter(t=>W(t).includes(e))})).filter(e=>e.items.length>0);return(0,V.jsxs)(V.Fragment,{children:[re.map(e=>(0,V.jsx)(P,{className:`plugin-installed-extensions`,title:`${o(`plugins:pluginsPage.installedExtensions`)} · ${G(e.type,o)}`,count:e.items.length,children:(0,V.jsx)(N,{children:e.items.map(t=>(0,V.jsx)(M,{icon:(0,V.jsx)(h,{}),name:(0,V.jsx)(`span`,{className:`font-mono`,children:t.name}),nameMeta:`v${t.version}`,description:(0,V.jsx)(`span`,{className:`font-mono text-xs`,children:t.source}),actions:(0,V.jsxs)(T,{type:`button`,variant:`ghost`,size:`sm`,className:`text-content-muted hover:bg-danger-soft hover:text-danger`,loading:_===t.source,disabled:!!_,onClick:()=>void ne(t),children:[(0,V.jsx)(ee,{}),o(`plugins:pluginsPage.uninstallExtension`)]})},`${e.type}:${t.scope}:${t.source}`))})},e.type)),(0,V.jsxs)(P,{className:`plugin-market`,title:o(`plugins:pluginsPage.extensionMarket`),actions:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(T,{asChild:!0,variant:`ghost`,size:`sm`,children:(0,V.jsxs)(`a`,{href:`https://pi.dev/packages`,target:`_blank`,rel:`noreferrer`,children:[(0,V.jsx)(u,{}),o(`plugins:pluginsPage.openPackageCatalog`)]})}),(0,V.jsxs)(T,{type:`button`,variant:`secondary`,size:`sm`,onClick:te,disabled:!!_,children:[(0,V.jsx)(z,{}),o(`plugins:pluginsPage.installExtension`)]})]}),children:[(0,V.jsxs)(`form`,{className:`mb-3 flex min-w-0 gap-2`,onSubmit:e=>{e.preventDefault(),S(s)},children:[(0,V.jsx)(A,{className:`min-w-0 flex-1 max-[650px]:h-11`,value:s,onChange:e=>c(e.target.value),placeholder:o(`plugins:pluginsPage.searchPackageCatalog`),"aria-label":o(`plugins:pluginsPage.searchPackageCatalog`)}),(0,V.jsxs)(T,{type:`submit`,variant:`secondary`,className:`h-[34px] max-[650px]:h-11`,loading:m,disabled:m,children:[(0,V.jsx)(v,{}),o(`plugins:pluginsPage.search`)]})]}),b&&(0,V.jsx)(F,{className:`mt-0 mb-3`,children:b}),C.length>0&&(0,V.jsx)(N,{children:C.slice(0,12).map(e=>{let t=f.some(t=>t.name===e.name||t.source===`npm:${e.name}`);return(0,V.jsx)(M,{icon:(0,V.jsx)(h,{}),name:(0,V.jsx)(`span`,{className:`font-mono`,children:e.name}),description:e.description,status:e.published,actions:(0,V.jsx)(T,{type:`button`,variant:`secondary`,size:`sm`,loading:_===e.name,disabled:t||!!_,onClick:()=>void w(e.name),children:o(t?`plugins:pluginsPage.installed`:`plugins:pluginsPage.installExtension`)})},e.name)})})]})]})}function J({notify:e,onBack:t,requestText:n,requestConfirm:s}){let{t:c}=r(),l=le(`focusSearch`),u=o(e=>e.capabilities),d=a(u,`plugins`),f=d?De:De.slice(0,2),[p,m]=(0,B.useState)(``),[h,v]=(0,B.useState)(null),[y,E]=(0,B.useState)([]),[ue,D]=(0,B.useState)(``),[O,de]=(0,B.useState)(`all`),[k,A]=(0,B.useState)({provider:`bing`,language:`auto`,safeSearch:1,maxResults:8}),[j,F]=(0,B.useState)(!1),[I,L]=(0,B.useState)(!1),[Ce,R]=(0,B.useState)(!1),[H,U]=(0,B.useState)(null),[W,G]=(0,B.useState)(!1),[J,Y]=(0,B.useState)(``),[Ie,Le]=(0,B.useState)(!1),X=(0,B.useCallback)(e=>{v(e),E(e.plugins),A(e.webSearch)},[]),Z=(0,B.useCallback)(async()=>{Y(``);try{X(await i(`/api/plugins`))}catch(e){Y(e instanceof Error?e.message:String(e))}},[X]);(0,B.useEffect)(()=>{Z()},[Z]);let Re=(0,B.useMemo)(()=>Ae(y),[y]),ze=(0,B.useMemo)(()=>ke(y),[y]),Q=h?!Me(ze,h.enabledTools)||JSON.stringify(je(y))!==JSON.stringify(h.piExtensions)||JSON.stringify(k)!==JSON.stringify(h.webSearch):!1,Be=(0,B.useCallback)(async()=>{if(!j){if(!h||!Q){h&&e(c(`plugins:pluginsPage.noPluginPolicyChanges`));return}F(!0),Y(``);try{let t=await i(`/api/plugins`,{method:`PUT`,body:JSON.stringify({enabledTools:ze,webSearch:k,piExtensions:je(y)})});X(t),e(c(`plugins:pluginsPage.pluginPolicySavedAgentRuntimeUpdated`))}catch(e){Y(e instanceof Error?e.message:String(e))}finally{F(!1)}}},[X,h,Q,y,ze,e,j,c,k]),Ve=async()=>{L(!0),Y(``);try{let t=await i(`/api/plugins/web-search/test`,{method:`POST`,body:JSON.stringify(k)});e(c(`plugins:pluginsPage.bingSearchIsAvailableAndReturnedCountResults`,{count:t.count}))}catch(t){let n=t instanceof Error?t.message:String(t);Y(n),e(n,`error`)}finally{L(!1)}},He=(e,t,n)=>{E(r=>r.map(r=>{if(r.id!==e)return r;let i=r.source===`pi`&&r.managedExternally;return{...r,enabled:n||r.capabilities.some(e=>e.enabled),capabilities:r.capabilities.map(e=>i||e.name===t?{...e,enabled:n}:e)}}))},Ue=()=>!Q||(Y(c(`plugins:pluginsPage.saveBeforePluginChanges`)),!1),We=async()=>{if(!(!H||W)){G(!0),Y(``);try{X(await i(`/api/plugins/${encodeURIComponent(H.pluginId)}`,{method:`DELETE`})),e(c(`plugins:pluginsPage.pluginUninstalled`,{name:H.pluginName})),D(``),U(null)}catch(e){Y(e instanceof Error?e.message:String(e))}finally{G(!1)}}},Ge=c(`navigation:navigation.plugins`),Ke=p.trim().toLowerCase(),$=Re.filter(e=>O!==`all`&&e.pluginSource!==O?!1:[Ne(e,c),e.name,e.description,q(e,c),e.pluginId].join(` `).toLowerCase().includes(Ke));return(0,V.jsxs)(he,{title:Ge,description:c(`plugins:pluginsPage.lede`),back:t&&{label:c(`navigation:sidebar.features`),ariaLabel:c(`navigation:shell.backToFeaturesLabel`),onBack:t},toolbar:(0,V.jsx)(ge,{search:(0,V.jsx)(me,{id:S,value:p,onValueChange:m,placeholder:c(`navigation:pageHeader.searchPage`,{page:Ge}),shortcut:l,clearLabel:c(`navigation:more.clearSearch`)}),actions:(0,V.jsxs)(V.Fragment,{children:[d&&(0,V.jsxs)(T,{type:`button`,variant:`secondary`,className:`h-9`,disabled:!h,onClick:()=>Ue()&&R(!0),children:[(0,V.jsx)(z,{}),c(`plugins:pluginsPage.installPlugin`)]}),(0,V.jsxs)(T,{type:`button`,className:`h-9`,"data-plugins-save":!0,loading:j,disabled:!h||j,onClick:()=>void Be(),children:[(0,V.jsx)(_,{}),c(`plugins:pluginsPage.savePolicy`)]})]}),filters:(0,V.jsx)(_e,{options:f.map(e=>K(e,c)),value:K(O,c),onChange:e=>de(f.find(t=>K(t,c)===e)||`all`)})}),children:[h?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(P,{className:`plugin-catalog`,title:c(`plugins:pluginsPage.toolCatalog`),count:$.length,meta:(0,V.jsxs)(`span`,{className:`plugin-catalog-summary`,children:[Re.filter(e=>e.enabled).length,`/`,Re.length,` `,c(`plugins:pluginsPage.enabled2`)]}),actions:Q&&(0,V.jsxs)(`span`,{"data-plugins-unsaved":!0,className:`flex items-center gap-1.5 text-xs font-medium text-content-secondary`,children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full bg-content-secondary`}),c(`plugins:pluginsPage.unsaved`)]}),children:$.length?(0,V.jsx)(N,{className:`plugin-tool-grid`,children:$.map(e=>{let t=Oe[e.name]||g,n=Ne(e,c);return(0,V.jsx)(M,{className:`plugin-tool-card`,"data-plugin-tool":e.name,icon:(0,V.jsx)(t,{}),name:(0,V.jsx)(`span`,{title:n,children:n}),nameMeta:e.name,description:`${q(e,c)} · ${Se(e.risk,c)}`,status:e.pluginBuiltIn?void 0:c(`plugins:pluginsPage.local`),actions:(0,V.jsx)(ye,{value:e.enabled,onChange:t=>He(e.pluginId,e.name,t),ariaLabel:n}),expanded:ue===e.name,onExpandedChange:t=>D(t?e.name:``),toggleLabel:c(`plugins:pluginsPage.toggleToolDetails`,{name:n}),detail:(0,V.jsxs)(`div`,{className:`plugin-tool-details grid gap-3`,children:[(0,V.jsx)(`p`,{className:`text-sm leading-relaxed text-content-soft`,children:be({id:e.name,description:e.description},c)}),(0,V.jsxs)(`dl`,{className:`grid grid-cols-[88px_minmax(0,1fr)] gap-x-3 gap-y-1.5 text-xs [&_dd]:min-w-0 [&_dd]:[overflow-wrap:anywhere] [&_dd]:text-content-soft [&_dt]:text-content-muted [&>div]:contents`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{children:c(`plugins:pluginsPage.source`)}),(0,V.jsxs)(`dd`,{className:`tabular-nums`,children:[q(e,c),!e.pluginBuiltIn&&` · v${e.pluginVersion}`]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{children:c(`plugins:pluginsPage.riskLevel`)}),(0,V.jsx)(`dd`,{className:se((Te(e.risk)||xe(e.risk))&&`font-medium text-content!`),children:Se(e.risk,c)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{children:c(`plugins:pluginsPage.pathScope`)}),(0,V.jsx)(`dd`,{children:we({id:e.name,scope:e.scope},c)})]}),!e.pluginBuiltIn&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{children:c(`plugins:pluginsPage.executionMode`)}),(0,V.jsx)(`dd`,{children:c(`plugins:pluginsPage.confirmUnlessFullAccess`)})]})]}),!e.pluginBuiltIn&&(0,V.jsxs)(`div`,{className:`plugin-tool-warning flex items-start gap-2 rounded-sm bg-surface-subtle p-2.5 text-xs leading-normal text-content-secondary`,children:[(0,V.jsx)(b,{className:`mt-px size-3.5 shrink-0`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{children:c(`plugins:pluginsPage.localPluginSecurityWarning`)})]}),e.name===`web_search`&&(0,V.jsx)(Pe,{value:k,testing:I,onChange:A,onTest:Ve}),!e.pluginBuiltIn&&(0,V.jsxs)(T,{type:`button`,variant:`ghost`,className:`justify-self-end text-danger hover:bg-danger-soft hover:text-danger max-[650px]:h-11`,onClick:()=>Ue()&&U(e),children:[(0,V.jsx)(ee,{}),c(`plugins:pluginsPage.uninstallPlugin`)]})]})},e.name)})}):(0,V.jsx)(pe,{compact:!0,title:c(`plugins:pluginsPage.noMatchingTools`)})}),(0,V.jsx)(Fe,{query:p,notify:e,requestText:n,requestConfirm:s})]}):J?(0,V.jsx)(fe,{kind:`error`,title:c(`plugins:pluginsPage.loadFailed`),description:J,action:(0,V.jsx)(T,{variant:`secondary`,className:`max-[650px]:h-11`,loading:Ie,disabled:Ie,onClick:()=>{Le(!0),Z().finally(()=>Le(!1))},children:c(`common:pageTemplate.retry`)})}):(0,V.jsx)(fe,{kind:`loading`,title:c(`plugins:pluginsPage.loadingToolPlugins`)}),d&&(0,V.jsx)(Ee,{open:Ce,onOpenChange:R,onInstalled:Z}),(0,V.jsx)(oe,{open:!!H,onOpenChange:e=>!e&&!W&&U(null),children:(0,V.jsxs)(te,{className:`z-[220]`,children:[(0,V.jsxs)(ae,{children:[(0,V.jsx)(w,{children:c(`plugins:pluginsPage.uninstallPlugin`)}),(0,V.jsx)(C,{children:c(`plugins:pluginsPage.uninstallPluginDescription`,{name:H?.pluginName||``})})]}),(0,V.jsxs)(re,{children:[(0,V.jsx)(ie,{disabled:W,children:c(`common:ui.cancel`)}),(0,V.jsxs)(ne,{variant:`destructive`,disabled:W,onClick:We,children:[W&&(0,V.jsx)(ce,{className:`text-current`}),c(`plugins:pluginsPage.uninstallPlugin`)]})]})]})}),J&&h&&(0,V.jsxs)(ve,{className:`fixed right-6 bottom-6 z-[21] max-w-[360px] border border-danger-border shadow-float`,children:[(0,V.jsx)(x,{size:13}),J]})]})}export{J as PluginsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{t as r}from"./use-i18n-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{t as r}from"./use-i18n-BqDnJFL5.js";import{t as i}from"./button-CCcCN8tE.js";import{a,i as o,l as s,o as c,s as l,t as u}from"./dialog-CW8GeCdI.js";import{t as d}from"./safe-mode-instance-HzaYIZf6.js";var f=e(t(),1),p=n();function m({notify:e,disableAll:t}){let{t:n}=r(),m=d(),h=(0,f.useSyncExternalStore)(m.subscribe,m.mode,m.mode),[g,_]=(0,f.useState)(!1);if(h!==`pending`)return null;let v=async()=>{_(!0);try{await t()||e(n(`custom-ui:safeMode.disableFailed`)),m.resolve(`normal`)}catch{e(n(`custom-ui:safeMode.disableFailed`))}finally{_(!1)}};return(0,p.jsx)(u,{open:!0,onOpenChange:e=>{!e&&!g&&m.resolve(`safe`)},children:(0,p.jsxs)(o,{"data-components-safe-mode-prompt":!0,children:[(0,p.jsxs)(l,{children:[(0,p.jsx)(s,{children:n(`custom-ui:safeMode.promptTitle`)}),(0,p.jsx)(a,{children:n(`custom-ui:safeMode.promptHint`)})]}),(0,p.jsxs)(c,{children:[(0,p.jsx)(i,{variant:`outline`,disabled:g,onClick:()=>void v(),children:n(`custom-ui:safeMode.disableAll`)}),(0,p.jsx)(i,{variant:`outline`,disabled:g,onClick:()=>m.resolve(`normal`),children:n(`custom-ui:safeMode.loadNormally`)}),(0,p.jsx)(i,{disabled:g,onClick:()=>m.resolve(`safe`),children:n(`custom-ui:safeMode.keepSafe`)})]})]})})}export{m as SafeModePrompt};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{u as t}from"./vendor-router-CSN_DGvx.js";import{i as n,r}from"./vendor-react-DwNgTV1j.js";import{t as i}from"./use-i18n-DL1_y_Ge.js";import{t as a}from"./api-BA-WPJCg.js";import{t as o}from"./bell-BjONAtgH.js";import{t as s}from"./bot-B3TaBp_T.js";import{t as c}from"./calendar-clock-VIxTaqqy.js";import{t as l}from"./circle-check-iEdCm3Pw.js";import{t as u}from"./WorkspacePicker-BC-V-qKc.js";import{t as d}from"./folder-open-FIShC5Qk.js";import{t as f}from"./message-circle-D-XrK6Ft.js";import{t as p}from"./play-DNDjDNGn.js";import{t as m}from"./plus-fQbSqB1n.js";import{t as h}from"./send-Cj-W03w_.js";import{t as g}from"./trash-2-CNrPOoPR.js";import{t as _}from"./triangle-alert-CE1q54ci.js";import{t as v}from"./more-pages-D_PnxLN0.js";import{t as y}from"./switch-D_G8wFhs.js";import{t as b}from"./utils-C8uzG5AZ.js";import{n as x,t as S}from"./button-CCcCN8tE.js";import{s as C}from"./shortcuts-Cth0vc77.js";import{a as w}from"./format-DMJQzoZ7.js";import{t as T}from"./StatusGlyph-1KgitlUg.js";import{a as E,i as D,l as O,s as ee,t as k}from"./dialog-BfkdQrrN.js";import{t as A}from"./input-CPw-zkYh.js";import{t as j}from"./textarea-DmATpOqT.js";import{t as M}from"./pick-system-directory-j8yF4oD7.js";import{n as N,t as P}from"./PageState-Cz6vFMXv.js";import{a as te,i as ne,n as re,o as ie,r as ae,s as oe,t as se}from"./FeaturePage-DT8W4UlT.js";import{n as F}from"./field-DoLEb0np.js";import{t as I}from"./AppSelect-B15Hpk2W.js";import{i as L,s as R}from"./app-primitives-BskZ4ZJj.js";var z=e(n(),1),B=r(),V={browser:{name:`通知`,Icon:o},feishu:{name:`飞书`,Icon:s},weixin:{name:`微信`,Icon:f},qq:{name:`QQ`,Icon:f},telegram:{name:`Telegram`,Icon:h}},H={once:`一次`,interval:`每隔一段时间`,daily:`每天`,weekly:`每周`,monthly:`每月`},U={minutes:`分钟`,hours:`小时`,days:`天`},W=[...new Set([`Asia/Hong_Kong`,`UTC`,...typeof Intl.supportedValuesOf==`function`?Intl.supportedValuesOf(`timeZone`):[]])],G=[`full-access`],K=`mt-4 border-t border-stroke-soft pt-1`,q=`form-grid grid gap-x-3 sm:grid-cols-3`,J=`schedule-interval-input grid grid-cols-[minmax(0,1fr)_minmax(84px,auto)] gap-1.5`,Y=`inline-grid h-8 grid-cols-2 rounded-md border border-stroke bg-chrome p-[3px] max-[650px]:h-auto max-[650px]:w-full pointer-coarse:h-auto`,ce=`inline-flex min-w-0 items-center justify-center rounded-sm border border-transparent px-3 text-sm text-content-secondary transition-colors duration-(--d-fast) hover:text-content aria-pressed:border-key-border aria-pressed:bg-key aria-pressed:font-medium aria-pressed:text-content aria-pressed:shadow-key max-[650px]:h-11 pointer-coarse:h-11`;function le({status:e}){return(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`mt-px grid size-[18px] flex-none place-items-center`,children:(0,B.jsx)(T,{status:e===`running`?`run`:e===`completed`?`done`:`failed`,className:`size-3.5`})})}function ue(e){return e(`schedules:schedulesPage.fullAccessHelp`)}function de(e,t){return t(e===`once`?`schedules:schedulesPage.once`:e===`daily`?`schedules:schedulesPage.daily`:e===`weekly`?`schedules:schedulesPage.weekly`:e===`monthly`?`schedules:schedulesPage.monthly`:`schedules:schedulesPage.atIntervals`)}function fe(e,t){return t(e===`hours`?`schedules:schedulesPage.hours`:e===`days`?`schedules:schedulesPage.days`:`schedules:schedulesPage.minutes`)}function pe(e,t){return t(e===`feishu`?`schedules:schedulesPage.feishu`:e===`weixin`?`schedules:schedulesPage.weChat`:e===`qq`?`schedules:schedulesPage.qq`:e===`telegram`?`schedules:schedulesPage.telegram`:`schedules:schedulesPage.browserNotification`)}function X({value:e,onChange:t}){let{t:n}=i();return(0,B.jsxs)(F,{variant:`control`,children:[n(`schedules:schedulesPage.executionMode`),(0,B.jsx)(I,{value:e,onChange:e=>t(e.target.value),children:G.map(e=>(0,B.jsx)(`option`,{value:e,children:n(`schedules:schedulesPage.fullAccess`)},e))}),(0,B.jsx)(`small`,{children:ue(n)})]})}function Z(e){return Object.fromEntries((e?.inputs||[]).map(e=>[e.name,e.defaultValue??``]))}function Q(e,t,n,r,i){if(e===`prompt`)return!!t.trim();let a=i.find(e=>e.id===n);return a?a.inputs.every(e=>{let t=Object.hasOwn(r,e.name)?r[e.name]:e.defaultValue;return!e.required||t!=null&&t!==``}):!1}function $({targetType:e,prompt:t,workflowId:n,workflowInputs:r,workflows:a,onChange:o}){let{t:s}=i(),c=a.find(e=>e.id===n);return(0,B.jsxs)(`div`,{className:`grid`,children:[(0,B.jsxs)(F,{variant:`control`,children:[s(`schedules:schedulesPage.executionTarget`),(0,B.jsxs)(I,{value:e,onChange:e=>{let t=e.target.value,i=a[0];o(t===`workflow`?{targetType:t,workflowId:n||i?.id||``,workflowInputs:n?r:Z(i)}:{targetType:t})},children:[(0,B.jsx)(`option`,{value:`prompt`,children:`Prompt`}),(0,B.jsx)(`option`,{value:`workflow`,children:s(`schedules:schedulesPage.workflow`)})]})]}),e===`prompt`?(0,B.jsxs)(F,{variant:`control`,children:[`Prompt`,(0,B.jsx)(j,{value:t,onChange:e=>o({prompt:e.target.value}),placeholder:s(`schedules:schedulesPage.describeTheWorkTheAgentShouldCompleteEachTime`)})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(F,{variant:`control`,children:[s(`schedules:schedulesPage.workflow`),(0,B.jsxs)(I,{value:n,onChange:e=>{let t=a.find(t=>t.id===e.target.value);o({workflowId:e.target.value,workflowInputs:Z(t)})},children:[(0,B.jsx)(`option`,{value:``,children:s(`schedules:schedulesPage.selectPublishedWorkflow`)}),a.map(e=>(0,B.jsxs)(`option`,{value:e.id,children:[e.name,` · v`,e.revision]},e.id))]}),(0,B.jsx)(`small`,{children:c?.description||(a.length?s(`schedules:schedulesPage.workflowUsesItsOwnRuntimeSettings`):s(`schedules:schedulesPage.noPublishedWorkflows`))})]}),c?.inputs.length?(0,B.jsxs)(`div`,{className:`grid`,children:[(0,B.jsxs)(`div`,{className:`schedule-workflow-inputs-heading mt-3 flex items-baseline justify-between gap-3 max-[650px]:flex-col max-[650px]:items-start max-[650px]:gap-0.5 [&_small]:text-xs [&_small]:text-content-muted [&_strong]:text-xs [&_strong]:font-medium [&_strong]:text-content-secondary`,children:[(0,B.jsx)(`strong`,{children:s(`schedules:schedulesPage.workflowInputs`)}),(0,B.jsx)(`small`,{children:s(`schedules:schedulesPage.workflowInputsHelp`)})]}),(0,B.jsx)(`div`,{className:`schedule-workflow-inputs grid gap-x-3 sm:grid-cols-2 [&_input[type=checkbox]]:size-4 [&_input[type=checkbox]]:justify-self-end [&_input[type=checkbox]]:accent-star`,children:c.inputs.map(e=>(0,B.jsxs)(F,{variant:`control`,className:e.type===`boolean`?`grid grid-cols-[minmax(0,1fr)_auto] items-center`:void 0,children:[e.label,e.required?` *`:``,e.type===`boolean`?(0,B.jsx)(y,{checked:!!r[e.name],onCheckedChange:t=>o({workflowInputs:{...r,[e.name]:t}})}):(0,B.jsx)(A,{type:e.type===`number`?`number`:`text`,required:e.required,value:String(r[e.name]??``),onChange:t=>o({workflowInputs:{...r,[e.name]:t.target.value}})}),e.description&&(0,B.jsx)(`small`,{children:e.description})]},e.id))})]}):null]})]})}function me({value:e,onChange:t}){let{t:n}=i(),[r,a]=(0,z.useState)(``),[o,s]=(0,z.useState)(!1),c=async()=>{a(``);try{let r=await M(e,n(`common:workspacePicker.selectWorkspaceForSchedule`));r.status===`picked`?t(r.path):r.status===`unavailable`&&s(!0)}catch(e){a(e instanceof Error?e.message:String(e))}};return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(F,{variant:`control`,children:[n(`schedules:schedulesPage.workingDirectory`),(0,B.jsxs)(`span`,{className:`schedule-workspace-input grid grid-cols-[minmax(0,1fr)_auto] gap-1.5 [&_input]:min-w-0 [&_input]:font-mono`,children:[(0,B.jsx)(A,{value:e,onChange:e=>t(e.target.value),placeholder:n(`schedules:schedulesPage.enterTheProjectSAbsolutePath`)}),(0,B.jsxs)(S,{type:`button`,variant:`secondary`,className:`h-auto min-h-8`,onClick:()=>void c(),children:[(0,B.jsx)(d,{}),n(`schedules:schedulesPage.browseDirectories`)]})]}),(0,B.jsx)(`small`,{children:n(`schedules:schedulesPage.theScheduledAgentWillRunInThisDirectory`)})]}),r&&(0,B.jsxs)(L,{children:[(0,B.jsx)(_,{size:13}),r]}),(0,B.jsx)(u,{open:o,initialPath:e,description:n(`common:workspacePicker.selectWorkspaceForSchedule`),onOpenChange:s,onSelect:e=>t(e)})]})}function he(e){return{id:e.id,name:e.name,targetType:e.targetType||`prompt`,prompt:e.prompt,workflowId:e.workflowId||``,workflowInputs:e.workflowInputs||{},enabled:e.enabled,frequency:e.frequency,intervalValue:e.intervalValue||1,intervalUnit:e.intervalUnit||`hours`,time:e.time,date:e.date||``,timezone:e.timezone,dayOfWeek:e.dayOfWeek,dayOfMonth:e.dayOfMonth,cwd:e.cwd,executionMode:e.executionMode||`full-access`,model:e.model,notifications:e.notifications||[],notifyOn:e.notifyOn||`always`}}function ge(e,t=`zh-CN`){return!e.enabled||!e.nextRunAt?t===`en-US`?`Paused`:`已暂停`:new Intl.DateTimeFormat(t,{timeZone:e.timezone,dateStyle:`medium`,timeStyle:`short`}).format(new Date(e.nextRunAt))}function _e({notify:e,onBack:n,openNotificationSettings:r,requestConfirm:o}){let{t:s,language:l}=i(),u=t(),d=C(`focusSearch`),[f,p]=(0,z.useState)({tasks:[],runs:[],notificationTargets:{browser:{enabled:!1},feishu:{enabled:!1},weixin:{enabled:!1},qq:{enabled:!1},telegram:{enabled:!1}},workflows:[],defaultCwd:``}),[h,g]=(0,z.useState)(``),[_,y]=(0,z.useState)({}),[b,x]=(0,z.useState)(!0),[w,E]=(0,z.useState)(!1),[D,O]=(0,z.useState)(``),[ee,k]=(0,z.useState)(!1),[A,j]=(0,z.useState)(``),[M,F]=(0,z.useState)(!1),[I,L]=(0,z.useState)(``),R=(0,z.useCallback)(async()=>{try{let e=await a(`/api/schedules`);p(e),E(!0),O(``),g(t=>e.tasks.some(e=>e.id===t)?t:``),y(t=>{let n=Object.entries(t).filter(([t])=>e.tasks.some(e=>e.id===t));return n.length===Object.keys(t).length?t:Object.fromEntries(n)})}catch(e){O(e instanceof Error?e.message:String(e))}finally{x(!1)}},[]);(0,z.useEffect)(()=>{R()},[R]),(0,z.useEffect)(()=>{let e=window.setInterval(R,f.tasks.some(e=>e.lastStatus===`running`)?2e3:1e4);return()=>window.clearInterval(e)},[f.tasks,R]);let V=f.tasks.find(e=>e.id===h),H=f.workflows||[],U=V?_[V.id]??he(V):null,W=(0,z.useMemo)(()=>f.runs.filter(e=>e.taskId===h).sort((e,t)=>new Date(t.startedAt).getTime()-new Date(e.startedAt).getTime()).slice(0,20),[f.runs,h]),G=e=>H.find(t=>t.id===e.workflowId)?.name||s(`schedules:schedulesPage.workflowUnavailable`),K=I.trim().toLocaleLowerCase(),q=K?f.tasks.filter(e=>`${e.name} ${e.targetType===`workflow`?G(e):e.targetType===`bot`?e.botMessage||``:e.prompt}`.toLocaleLowerCase().includes(K)):f.tasks,J=f.tasks.filter(e=>e.enabled).length,Y=e=>{if(!V)return;let t=he(V);y(n=>({...n,[t.id]:{...n[t.id]??t,...e}}))},ce=e=>{U&&Y({notifications:U.notifications.includes(e)?U.notifications.filter(t=>t!==e):[...U.notifications,e]})},le=async()=>{if(!(!V||!U)){k(!0),j(``);try{let t=await a(`/api/schedules/${encodeURIComponent(V.id)}`,{method:`PATCH`,body:JSON.stringify(U)});p(t.state),y(e=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t.task.id))),e(s(`schedules:schedulesPage.scheduledTaskSaved`))}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(!1)}}},ue=async()=>{if(V){k(!0),j(``);try{await a(`/api/schedules/${encodeURIComponent(V.id)}/run`,{method:`POST`,body:`{}`}),await R(),e(s(`schedules:schedulesPage.scheduledTaskStarted`))}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(!1)}}},pe=async()=>{if(V&&await o({title:s(`schedules:schedulesPage.deleteScheduledTask`),message:s(`schedules:schedulesPage.deleteScheduledTaskNameAndItsRunHistory`,{name:V.name}),confirmLabel:s(`schedules:schedulesPage.delete`)}))try{await a(`/api/schedules/${encodeURIComponent(V.id)}`,{method:`DELETE`}),await R(),e(s(`schedules:schedulesPage.scheduledTaskDeleted`))}catch(e){j(e instanceof Error?e.message:String(e))}},X=t=>{p(t.state),g(t.task.id),e(s(`schedules:schedulesPage.scheduledTaskCreated`))},Z=e=>(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-col items-end gap-0.5 max-[650px]:flex-row max-[650px]:items-center max-[650px]:gap-2`,children:[e.lastStatus===`running`?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,B.jsx)(T,{status:`run`,className:`size-3.5`}),s(`schedules:schedulesPage.running`)]}):(0,B.jsx)(`span`,{className:`whitespace-nowrap`,children:e.enabled?s(`schedules:schedulesPage.nextRunTime`,{time:ge(e,l)}):e.lastStatus===`missed`?s(`schedules:schedulesPage.missed`):e.frequency===`once`&&e.lastRunAt?s(`schedules:schedulesPage.onceDone`):s(`schedules:schedulesPage.pause`)}),e.lastStatus===`failed`&&(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,B.jsx)(T,{status:`failed`,className:`size-3.5`}),s(`schedules:schedulesPage.lastRunFailed`)]})]}),Q=s(`navigation:navigation.schedules`);return(0,B.jsxs)(ae,{title:Q,description:s(`schedules:schedulesPage.lede`),back:n&&{label:s(`navigation:sidebar.features`),ariaLabel:s(`navigation:shell.backToFeaturesLabel`),onBack:n},toolbar:(0,B.jsx)(oe,{search:(0,B.jsx)(te,{id:v,value:I,onValueChange:L,placeholder:s(`navigation:pageHeader.searchPage`,{page:Q}),shortcut:d,clearLabel:s(`navigation:more.clearSearch`)}),actions:(0,B.jsxs)(S,{type:`button`,className:`h-9`,disabled:!w,onClick:()=>F(!0),children:[(0,B.jsx)(m,{}),s(`schedules:schedulesPage.newTask`)]})}),children:[b?(0,B.jsx)(N,{kind:`loading`,title:s(`schedules:schedulesPage.loadingScheduledTasks`)}):D&&!w?(0,B.jsx)(N,{kind:`error`,title:s(`schedules:schedulesPage.loadFailed`),description:D,action:(0,B.jsx)(S,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>{x(!0),R()},children:s(`common:pageTemplate.retry`)})}):(0,B.jsxs)(B.Fragment,{children:[(A||D)&&(0,B.jsx)(se,{children:A||D}),(0,B.jsx)(ie,{title:s(`schedules:schedulesPage.tasks`),count:f.tasks.length,meta:f.tasks.length?s(`schedules:schedulesPage.enabledCount`,{count:J}):void 0,children:q.length?(0,B.jsx)(re,{children:q.map(e=>{let t=h===e.id;return(0,B.jsx)(ne,{"data-schedule-task":e.id,className:`schedule-list-item`,icon:(0,B.jsx)(c,{}),name:e.name,description:e.targetType===`workflow`?(0,B.jsx)(`span`,{className:`font-mono`,children:G(e)}):e.targetType===`bot`?s(`schedules:schedulesPage.botTarget`,{message:e.botMessage||``}):e.prompt,meta:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{children:de(e.frequency,s)}),(0,B.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,B.jsx)(`span`,{className:`tabular-nums`,children:e.frequency===`interval`?`${e.intervalValue} ${fe(e.intervalUnit,s)}`:e.frequency===`once`?`${e.date} ${e.time}`:e.time}),(0,B.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,B.jsx)(`span`,{className:`truncate`,children:e.timezone}),e.createdBy?.kind===`agent`&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,B.jsx)(`span`,{"data-schedule-created-by":`agent`,children:s(`schedules:schedulesPage.createdByAgent`)})]})]}),status:Z(e),expanded:t,onExpandedChange:t=>g(t?e.id:``),toggleLabel:s(`schedules:schedulesPage.toggleTaskDetails`,{name:e.name}),detail:t&&e.targetType===`bot`?(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm text-content-secondary`,children:[(0,B.jsx)(`span`,{className:`min-w-0 flex-1`,children:s(`schedules:schedulesPage.botManagedThere`)}),(0,B.jsx)(S,{size:`sm`,variant:`outline`,onClick:()=>u(`/bots/${encodeURIComponent(e.botId||``)}`),children:s(`schedules:schedulesPage.openBot`)})]}):t&&U&&V?(0,B.jsx)(ve,{task:V,draft:U,runs:W,saving:ee,workflows:H,notificationTargets:f.notificationTargets,language:l,onUpdate:Y,onToggleNotification:ce,onRun:ue,onRemove:pe,onSave:le,onEditTemplates:r}):null},e.id)})}):(0,B.jsx)(P,{title:f.tasks.length?s(`schedules:schedulesPage.noMatchingTasks`):s(`schedules:schedulesPage.theTimelineIsStillUnlit`),description:f.tasks.length?void 0:s(`schedules:schedulesPage.createATaskAndLetItSetOutAutomaticallyAtTheAppointedTime`)})})]}),M&&(0,B.jsx)(ye,{notificationTargets:f.notificationTargets,workflows:H,defaultCwd:f.defaultCwd,onClose:()=>F(!1),onCreated:e=>{F(!1),X(e)}})]})}function ve({task:e,draft:t,runs:n,saving:r,workflows:a,notificationTargets:o,language:s,onUpdate:c,onToggleNotification:u,onRun:d,onRemove:f,onSave:m,onEditTemplates:h}){let{t:_}=i(),v=e.lastStatus===`running`;return(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,B.jsxs)(`label`,{className:`mr-auto inline-flex min-h-8 items-center gap-2.5 text-sm text-content max-[650px]:min-h-11`,children:[(0,B.jsx)(R,{value:t.enabled,onChange:e=>c({enabled:e}),ariaLabel:_(`schedules:schedulesPage.enableTaskName`,{name:t.name})}),t.enabled?_(`schedules:schedulesPage.enabled`):_(`schedules:schedulesPage.pause`)]}),(0,B.jsxs)(S,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,disabled:r||v,onClick:d,children:[v?(0,B.jsx)(x,{}):(0,B.jsx)(p,{}),_(v?`schedules:schedulesPage.running`:`schedules:schedulesPage.runNow`)]}),(0,B.jsx)(S,{variant:`ghost`,size:`icon-sm`,className:`hover:bg-danger-soft hover:text-danger max-[650px]:size-11`,title:_(`schedules:schedulesPage.deleteTask`),"aria-label":_(`schedules:schedulesPage.deleteTask`),onClick:f,children:(0,B.jsx)(g,{})})]}),(0,B.jsx)($,{targetType:t.targetType,prompt:t.prompt,workflowId:t.workflowId,workflowInputs:t.workflowInputs,workflows:a,onChange:c}),t.targetType===`prompt`&&(0,B.jsx)(me,{value:t.cwd,onChange:e=>c({cwd:e})}),(0,B.jsx)(`div`,{className:K,children:(0,B.jsxs)(`div`,{className:q,children:[(0,B.jsxs)(F,{variant:`control`,children:[_(`schedules:schedulesPage.frequency`),(0,B.jsx)(I,{value:t.frequency,onChange:e=>c({frequency:e.target.value}),children:Object.keys(H).map(e=>(0,B.jsx)(`option`,{value:e,children:de(e,_)},e))})]}),t.frequency===`interval`?(0,B.jsxs)(F,{variant:`control`,children:[_(`schedules:schedulesPage.runInterval`),(0,B.jsxs)(`span`,{className:J,children:[(0,B.jsx)(A,{type:`number`,min:`1`,value:t.intervalValue,onChange:e=>c({intervalValue:Number(e.target.value)})}),(0,B.jsx)(I,{value:t.intervalUnit,onChange:e=>c({intervalUnit:e.target.value}),children:Object.keys(U).map(e=>(0,B.jsx)(`option`,{value:e,children:fe(e,_)},e))})]})]}):(0,B.jsxs)(B.Fragment,{children:[t.frequency===`once`&&(0,B.jsxs)(F,{variant:`control`,children:[_(`schedules:schedulesPage.date`),(0,B.jsx)(A,{type:`date`,className:`tabular-nums`,value:t.date,onChange:e=>c({date:e.target.value})})]}),(0,B.jsxs)(F,{variant:`control`,children:[_(`schedules:schedulesPage.time`),(0,B.jsx)(A,{type:`time`,className:`tabular-nums`,value:t.time,onChange:e=>c({time:e.target.value})})]})]}),(0,B.jsxs)(F,{variant:`control`,children:[_(`schedules:schedulesPage.timeZone`),(0,B.jsx)(I,{value:t.timezone,onChange:e=>c({timezone:e.target.value}),children:W.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))})]}),t.targetType===`prompt`&&(0,B.jsx)(X,{value:t.executionMode,onChange:e=>c({executionMode:e})})]})}),(0,B.jsxs)(`div`,{className:b(`schedule-notification-section pt-3`,K),children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsx)(`strong`,{className:`text-sm font-medium`,children:_(`schedules:schedulesPage.notificationChannels`)}),(0,B.jsx)(`button`,{type:`button`,className:`text-button text-xs font-medium text-content-secondary underline underline-offset-2 hover:text-content max-[650px]:min-h-11`,onClick:h,children:_(`schedules:schedulesPage.editTemplates`)})]}),(0,B.jsx)(`p`,{className:`mt-0.5 text-xs text-content-muted`,children:_(`schedules:schedulesPage.notificationChannelsHelp`)}),(0,B.jsx)(`div`,{className:`schedule-notification-targets mt-2.5 grid grid-cols-[repeat(auto-fill,minmax(132px,1fr))] gap-2`,children:Object.entries(V).map(([e,n])=>{let r=n.Icon,i=t.notifications.includes(e);return(0,B.jsxs)(`button`,{type:`button`,"aria-pressed":i,className:b(`grid min-h-[52px] grid-cols-[16px_minmax(0,1fr)_16px] items-center gap-2 rounded-md border px-2.5 py-2 text-left transition-colors duration-(--d-fast)`,i?`selected border-star-border bg-star-soft text-star-strong`:`border-stroke bg-panel text-content hover:bg-surface-subtle`),onClick:()=>u(e),children:[(0,B.jsx)(r,{className:`size-4`}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,B.jsx)(`strong`,{className:`truncate text-sm font-medium`,children:pe(e,_)}),(0,B.jsx)(`small`,{className:`truncate text-xs text-content-muted`,children:o[e].enabled?_(`schedules:schedulesPage.configured`):_(`schedules:schedulesPage.notConfigured`)})]}),(0,B.jsx)(l,{className:b(`size-4`,i?`text-star-strong`:`text-content-faint`)})]},e)})}),(0,B.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[(0,B.jsx)(`span`,{id:`schedule-notify-on-${e.id}`,className:`text-xs text-content-muted`,children:_(`schedules:schedulesPage.notifyWhen`)}),(0,B.jsx)(`div`,{role:`group`,"aria-labelledby":`schedule-notify-on-${e.id}`,className:b(`schedule-notification-chip`,Y),children:[`always`,`failure`].map(e=>(0,B.jsx)(`button`,{type:`button`,"aria-pressed":t.notifyOn===e,className:ce,onClick:()=>c({notifyOn:e}),children:_(e===`failure`?`schedules:schedulesPage.failuresOnly`:`schedules:schedulesPage.completionAndFailure`)},e))})]})]}),(0,B.jsxs)(`div`,{className:`form-footer mt-4 flex items-center justify-between gap-2.5 border-t border-stroke-soft pt-3 max-[650px]:flex-wrap`,children:[(0,B.jsx)(`span`,{className:`text-xs text-content-muted tabular-nums`,children:e.lastRunAt?_(`schedules:schedulesPage.lastRunTime`,{time:w(e.lastRunAt,s)}):_(`schedules:schedulesPage.nextRunTime`,{time:ge(e,s)})}),(0,B.jsxs)(S,{className:`max-[650px]:h-11 max-[650px]:w-full`,disabled:r||!Q(t.targetType,t.prompt,t.workflowId,t.workflowInputs,a),onClick:m,children:[r?(0,B.jsx)(x,{className:`text-current`}):null,_(r?`schedules:schedulesPage.saving`:`schedules:schedulesPage.saveTask`)]})]})]}),(0,B.jsxs)(`section`,{"aria-labelledby":`schedule-runs-${e.id}`,className:`min-w-0`,children:[(0,B.jsxs)(`h3`,{id:`schedule-runs-${e.id}`,className:`mb-1.5 text-[13px] font-medium text-content-muted tabular-nums`,children:[_(`schedules:schedulesPage.recentRuns`),` · `,n.length]}),n.length?(0,B.jsx)(`ul`,{className:`divide-y divide-stroke-soft overflow-hidden rounded-[var(--r-md)] border border-stroke`,children:n.map(e=>(0,B.jsxs)(`li`,{className:`schedule-run-row grid min-h-11 grid-cols-[18px_minmax(0,1fr)_auto] items-start gap-2.5 px-3 py-2.5 ${e.status}`,children:[(0,B.jsx)(le,{status:e.status}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,B.jsx)(`strong`,{className:`line-clamp-2 text-sm leading-5 font-medium text-content`,children:e.status===`running`?_(`schedules:schedulesPage.running2`):e.status===`completed`?e.summary||_(`schedules:schedulesPage.taskCompleted`):e.status===`interrupted`?_(`schedules:schedulesPage.taskInterrupted`):e.error||_(`schedules:schedulesPage.taskFailed`)}),(0,B.jsxs)(`small`,{className:`text-xs text-content-muted tabular-nums`,children:[w(e.startedAt,s),` ·`,` `,e.trigger===`manual`?_(`schedules:schedulesPage.manualRun`):_(`schedules:schedulesPage.scheduledTrigger`),e.durationMs?` · ${_(`schedules:schedulesPage.countSec`,{count:Math.round(e.durationMs/1e3)})}`:``]})]}),(0,B.jsx)(`em`,{className:`font-mono text-xs leading-5 text-content-secondary not-italic tabular-nums`,children:new Intl.DateTimeFormat(s,{hour:`2-digit`,minute:`2-digit`}).format(new Date(e.startedAt))})]},e.id))}):(0,B.jsx)(P,{compact:!0,title:_(`schedules:schedulesPage.noRunHistory`)})]})]})}function ye({notificationTargets:e,workflows:t,defaultCwd:n,onClose:r,onCreated:o}){let{t:s}=i(),[c,l]=(0,z.useState)(``),[u,d]=(0,z.useState)(`prompt`),[f,p]=(0,z.useState)(``),[h,g]=(0,z.useState)(``),[v,y]=(0,z.useState)({}),[b,C]=(0,z.useState)(n||``),[w,T]=(0,z.useState)(`full-access`),[j,M]=(0,z.useState)(!1),[N,P]=(0,z.useState)(``);return(0,B.jsx)(k,{open:!0,onOpenChange:e=>!e&&r(),children:(0,B.jsx)(D,{size:`compact`,children:(0,B.jsxs)(`form`,{className:`grid min-w-0`,onSubmit:async t=>{t.preventDefault(),M(!0),P(``);try{let t=Object.entries(e).filter(([,e])=>e.enabled).map(([e])=>e);o(await a(`/api/schedules`,{method:`POST`,body:JSON.stringify({name:c,targetType:u,prompt:f,workflowId:h,workflowInputs:v,cwd:b,enabled:!0,frequency:`daily`,time:`09:00`,timezone:`Asia/Hong_Kong`,executionMode:w,notifications:t,notifyOn:`always`})}))}catch(e){P(e instanceof Error?e.message:String(e))}finally{M(!1)}},children:[(0,B.jsxs)(ee,{children:[(0,B.jsx)(O,{children:s(`schedules:schedulesPage.newScheduledTask`)}),(0,B.jsx)(E,{children:s(`schedules:schedulesPage.youCanContinueSettingTheRunTimeAndNotificationChannelsAfterCreation`)})]}),(0,B.jsxs)(F,{variant:`control`,children:[s(`schedules:schedulesPage.taskName`),(0,B.jsx)(A,{value:c,onChange:e=>l(e.target.value),placeholder:s(`schedules:schedulesPage.forExampleDailyCodeReview`)})]}),(0,B.jsx)($,{targetType:u,prompt:f,workflowId:h,workflowInputs:v,workflows:t,onChange:e=>{e.targetType&&d(e.targetType),e.prompt!==void 0&&p(e.prompt),e.workflowId!==void 0&&g(e.workflowId),e.workflowInputs!==void 0&&y(e.workflowInputs)}}),u===`prompt`&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(me,{value:b,onChange:C}),(0,B.jsx)(X,{value:w,onChange:T})]}),N&&(0,B.jsxs)(L,{children:[(0,B.jsx)(_,{size:13}),N]}),(0,B.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2 max-[650px]:[&>button]:h-11 max-[650px]:[&>button]:flex-1`,children:[(0,B.jsx)(S,{type:`button`,variant:`secondary`,onClick:r,children:s(`schedules:schedulesPage.cancel`)}),(0,B.jsxs)(S,{type:`submit`,disabled:j||!c.trim()||!Q(u,f,h,v,t),children:[j?(0,B.jsx)(x,{className:`text-current`}):(0,B.jsx)(m,{}),s(j?`schedules:schedulesPage.creating`:`schedules:schedulesPage.createTask`)]})]})]})})})}export{_e as SchedulesPage};
|
|
1
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{u as t}from"./vendor-router-CSN_DGvx.js";import{i as n,r}from"./vendor-react-DwNgTV1j.js";import{t as i}from"./use-i18n-BqDnJFL5.js";import{t as a}from"./api-BbBnrW3n.js";import{t as o}from"./bell-BjONAtgH.js";import{t as s}from"./bot-B3TaBp_T.js";import{t as c}from"./calendar-clock-VIxTaqqy.js";import{t as l}from"./circle-check-iEdCm3Pw.js";import{t as u}from"./WorkspacePicker-Cd0QCRnc.js";import{t as d}from"./folder-open-FIShC5Qk.js";import{t as f}from"./message-circle-D-XrK6Ft.js";import{t as p}from"./play-DNDjDNGn.js";import{t as m}from"./plus-fQbSqB1n.js";import{t as h}from"./send-Cj-W03w_.js";import{t as g}from"./trash-2-CNrPOoPR.js";import{t as _}from"./triangle-alert-CE1q54ci.js";import{t as v}from"./more-pages-D_PnxLN0.js";import{t as y}from"./switch-D_G8wFhs.js";import{t as b}from"./utils-C8uzG5AZ.js";import{n as x,t as S}from"./button-CCcCN8tE.js";import{s as C}from"./shortcuts-DsFEMyT1.js";import{a as w}from"./format-DMJQzoZ7.js";import{t as T}from"./StatusGlyph-1KgitlUg.js";import{a as E,i as D,l as O,s as ee,t as k}from"./dialog-CW8GeCdI.js";import{t as A}from"./input-CPw-zkYh.js";import{t as j}from"./textarea-DmATpOqT.js";import{t as M}from"./pick-system-directory-C4P5z66U.js";import{n as N,t as P}from"./PageState-Cz6vFMXv.js";import{a as te,i as ne,n as re,o as ie,r as ae,s as oe,t as se}from"./FeaturePage-xE563vuG.js";import{n as F}from"./field-DoLEb0np.js";import{t as I}from"./AppSelect-B15Hpk2W.js";import{i as L,s as R}from"./app-primitives-BskZ4ZJj.js";var z=e(n(),1),B=r(),V={browser:{name:`通知`,Icon:o},feishu:{name:`飞书`,Icon:s},weixin:{name:`微信`,Icon:f},qq:{name:`QQ`,Icon:f},telegram:{name:`Telegram`,Icon:h}},H={once:`一次`,interval:`每隔一段时间`,daily:`每天`,weekly:`每周`,monthly:`每月`},U={minutes:`分钟`,hours:`小时`,days:`天`},W=[...new Set([`Asia/Hong_Kong`,`UTC`,...typeof Intl.supportedValuesOf==`function`?Intl.supportedValuesOf(`timeZone`):[]])],G=[`full-access`],K=`mt-4 border-t border-stroke-soft pt-1`,q=`form-grid grid gap-x-3 sm:grid-cols-3`,J=`schedule-interval-input grid grid-cols-[minmax(0,1fr)_minmax(84px,auto)] gap-1.5`,Y=`inline-grid h-8 grid-cols-2 rounded-md border border-stroke bg-chrome p-[3px] max-[650px]:h-auto max-[650px]:w-full pointer-coarse:h-auto`,ce=`inline-flex min-w-0 items-center justify-center rounded-sm border border-transparent px-3 text-sm text-content-secondary transition-colors duration-(--d-fast) hover:text-content aria-pressed:border-key-border aria-pressed:bg-key aria-pressed:font-medium aria-pressed:text-content aria-pressed:shadow-key max-[650px]:h-11 pointer-coarse:h-11`;function le({status:e}){return(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`mt-px grid size-[18px] flex-none place-items-center`,children:(0,B.jsx)(T,{status:e===`running`?`run`:e===`completed`?`done`:`failed`,className:`size-3.5`})})}function ue(e){return e(`schedules:schedulesPage.fullAccessHelp`)}function de(e,t){return t(e===`once`?`schedules:schedulesPage.once`:e===`daily`?`schedules:schedulesPage.daily`:e===`weekly`?`schedules:schedulesPage.weekly`:e===`monthly`?`schedules:schedulesPage.monthly`:`schedules:schedulesPage.atIntervals`)}function fe(e,t){return t(e===`hours`?`schedules:schedulesPage.hours`:e===`days`?`schedules:schedulesPage.days`:`schedules:schedulesPage.minutes`)}function pe(e,t){return t(e===`feishu`?`schedules:schedulesPage.feishu`:e===`weixin`?`schedules:schedulesPage.weChat`:e===`qq`?`schedules:schedulesPage.qq`:e===`telegram`?`schedules:schedulesPage.telegram`:`schedules:schedulesPage.browserNotification`)}function X({value:e,onChange:t}){let{t:n}=i();return(0,B.jsxs)(F,{variant:`control`,children:[n(`schedules:schedulesPage.executionMode`),(0,B.jsx)(I,{value:e,onChange:e=>t(e.target.value),children:G.map(e=>(0,B.jsx)(`option`,{value:e,children:n(`schedules:schedulesPage.fullAccess`)},e))}),(0,B.jsx)(`small`,{children:ue(n)})]})}function Z(e){return Object.fromEntries((e?.inputs||[]).map(e=>[e.name,e.defaultValue??``]))}function Q(e,t,n,r,i){if(e===`prompt`)return!!t.trim();let a=i.find(e=>e.id===n);return a?a.inputs.every(e=>{let t=Object.hasOwn(r,e.name)?r[e.name]:e.defaultValue;return!e.required||t!=null&&t!==``}):!1}function $({targetType:e,prompt:t,workflowId:n,workflowInputs:r,workflows:a,onChange:o}){let{t:s}=i(),c=a.find(e=>e.id===n);return(0,B.jsxs)(`div`,{className:`grid`,children:[(0,B.jsxs)(F,{variant:`control`,children:[s(`schedules:schedulesPage.executionTarget`),(0,B.jsxs)(I,{value:e,onChange:e=>{let t=e.target.value,i=a[0];o(t===`workflow`?{targetType:t,workflowId:n||i?.id||``,workflowInputs:n?r:Z(i)}:{targetType:t})},children:[(0,B.jsx)(`option`,{value:`prompt`,children:`Prompt`}),(0,B.jsx)(`option`,{value:`workflow`,children:s(`schedules:schedulesPage.workflow`)})]})]}),e===`prompt`?(0,B.jsxs)(F,{variant:`control`,children:[`Prompt`,(0,B.jsx)(j,{value:t,onChange:e=>o({prompt:e.target.value}),placeholder:s(`schedules:schedulesPage.describeTheWorkTheAgentShouldCompleteEachTime`)})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(F,{variant:`control`,children:[s(`schedules:schedulesPage.workflow`),(0,B.jsxs)(I,{value:n,onChange:e=>{let t=a.find(t=>t.id===e.target.value);o({workflowId:e.target.value,workflowInputs:Z(t)})},children:[(0,B.jsx)(`option`,{value:``,children:s(`schedules:schedulesPage.selectPublishedWorkflow`)}),a.map(e=>(0,B.jsxs)(`option`,{value:e.id,children:[e.name,` · v`,e.revision]},e.id))]}),(0,B.jsx)(`small`,{children:c?.description||(a.length?s(`schedules:schedulesPage.workflowUsesItsOwnRuntimeSettings`):s(`schedules:schedulesPage.noPublishedWorkflows`))})]}),c?.inputs.length?(0,B.jsxs)(`div`,{className:`grid`,children:[(0,B.jsxs)(`div`,{className:`schedule-workflow-inputs-heading mt-3 flex items-baseline justify-between gap-3 max-[650px]:flex-col max-[650px]:items-start max-[650px]:gap-0.5 [&_small]:text-xs [&_small]:text-content-muted [&_strong]:text-xs [&_strong]:font-medium [&_strong]:text-content-secondary`,children:[(0,B.jsx)(`strong`,{children:s(`schedules:schedulesPage.workflowInputs`)}),(0,B.jsx)(`small`,{children:s(`schedules:schedulesPage.workflowInputsHelp`)})]}),(0,B.jsx)(`div`,{className:`schedule-workflow-inputs grid gap-x-3 sm:grid-cols-2 [&_input[type=checkbox]]:size-4 [&_input[type=checkbox]]:justify-self-end [&_input[type=checkbox]]:accent-star`,children:c.inputs.map(e=>(0,B.jsxs)(F,{variant:`control`,className:e.type===`boolean`?`grid grid-cols-[minmax(0,1fr)_auto] items-center`:void 0,children:[e.label,e.required?` *`:``,e.type===`boolean`?(0,B.jsx)(y,{checked:!!r[e.name],onCheckedChange:t=>o({workflowInputs:{...r,[e.name]:t}})}):(0,B.jsx)(A,{type:e.type===`number`?`number`:`text`,required:e.required,value:String(r[e.name]??``),onChange:t=>o({workflowInputs:{...r,[e.name]:t.target.value}})}),e.description&&(0,B.jsx)(`small`,{children:e.description})]},e.id))})]}):null]})]})}function me({value:e,onChange:t}){let{t:n}=i(),[r,a]=(0,z.useState)(``),[o,s]=(0,z.useState)(!1),c=async()=>{a(``);try{let r=await M(e,n(`common:workspacePicker.selectWorkspaceForSchedule`));r.status===`picked`?t(r.path):r.status===`unavailable`&&s(!0)}catch(e){a(e instanceof Error?e.message:String(e))}};return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(F,{variant:`control`,children:[n(`schedules:schedulesPage.workingDirectory`),(0,B.jsxs)(`span`,{className:`schedule-workspace-input grid grid-cols-[minmax(0,1fr)_auto] gap-1.5 [&_input]:min-w-0 [&_input]:font-mono`,children:[(0,B.jsx)(A,{value:e,onChange:e=>t(e.target.value),placeholder:n(`schedules:schedulesPage.enterTheProjectSAbsolutePath`)}),(0,B.jsxs)(S,{type:`button`,variant:`secondary`,className:`h-auto min-h-8`,onClick:()=>void c(),children:[(0,B.jsx)(d,{}),n(`schedules:schedulesPage.browseDirectories`)]})]}),(0,B.jsx)(`small`,{children:n(`schedules:schedulesPage.theScheduledAgentWillRunInThisDirectory`)})]}),r&&(0,B.jsxs)(L,{children:[(0,B.jsx)(_,{size:13}),r]}),(0,B.jsx)(u,{open:o,initialPath:e,description:n(`common:workspacePicker.selectWorkspaceForSchedule`),onOpenChange:s,onSelect:e=>t(e)})]})}function he(e){return{id:e.id,name:e.name,targetType:e.targetType||`prompt`,prompt:e.prompt,workflowId:e.workflowId||``,workflowInputs:e.workflowInputs||{},enabled:e.enabled,frequency:e.frequency,intervalValue:e.intervalValue||1,intervalUnit:e.intervalUnit||`hours`,time:e.time,date:e.date||``,timezone:e.timezone,dayOfWeek:e.dayOfWeek,dayOfMonth:e.dayOfMonth,cwd:e.cwd,executionMode:e.executionMode||`full-access`,model:e.model,notifications:e.notifications||[],notifyOn:e.notifyOn||`always`}}function ge(e,t=`zh-CN`){return!e.enabled||!e.nextRunAt?t===`en-US`?`Paused`:`已暂停`:new Intl.DateTimeFormat(t,{timeZone:e.timezone,dateStyle:`medium`,timeStyle:`short`}).format(new Date(e.nextRunAt))}function _e({notify:e,onBack:n,openNotificationSettings:r,requestConfirm:o}){let{t:s,language:l}=i(),u=t(),d=C(`focusSearch`),[f,p]=(0,z.useState)({tasks:[],runs:[],notificationTargets:{browser:{enabled:!1},feishu:{enabled:!1},weixin:{enabled:!1},qq:{enabled:!1},telegram:{enabled:!1}},workflows:[],defaultCwd:``}),[h,g]=(0,z.useState)(``),[_,y]=(0,z.useState)({}),[b,x]=(0,z.useState)(!0),[w,E]=(0,z.useState)(!1),[D,O]=(0,z.useState)(``),[ee,k]=(0,z.useState)(!1),[A,j]=(0,z.useState)(``),[M,F]=(0,z.useState)(!1),[I,L]=(0,z.useState)(``),R=(0,z.useCallback)(async()=>{try{let e=await a(`/api/schedules`);p(e),E(!0),O(``),g(t=>e.tasks.some(e=>e.id===t)?t:``),y(t=>{let n=Object.entries(t).filter(([t])=>e.tasks.some(e=>e.id===t));return n.length===Object.keys(t).length?t:Object.fromEntries(n)})}catch(e){O(e instanceof Error?e.message:String(e))}finally{x(!1)}},[]);(0,z.useEffect)(()=>{R()},[R]),(0,z.useEffect)(()=>{let e=window.setInterval(R,f.tasks.some(e=>e.lastStatus===`running`)?2e3:1e4);return()=>window.clearInterval(e)},[f.tasks,R]);let V=f.tasks.find(e=>e.id===h),H=f.workflows||[],U=V?_[V.id]??he(V):null,W=(0,z.useMemo)(()=>f.runs.filter(e=>e.taskId===h).sort((e,t)=>new Date(t.startedAt).getTime()-new Date(e.startedAt).getTime()).slice(0,20),[f.runs,h]),G=e=>H.find(t=>t.id===e.workflowId)?.name||s(`schedules:schedulesPage.workflowUnavailable`),K=I.trim().toLocaleLowerCase(),q=K?f.tasks.filter(e=>`${e.name} ${e.targetType===`workflow`?G(e):e.targetType===`bot`?e.botMessage||``:e.prompt}`.toLocaleLowerCase().includes(K)):f.tasks,J=f.tasks.filter(e=>e.enabled).length,Y=e=>{if(!V)return;let t=he(V);y(n=>({...n,[t.id]:{...n[t.id]??t,...e}}))},ce=e=>{U&&Y({notifications:U.notifications.includes(e)?U.notifications.filter(t=>t!==e):[...U.notifications,e]})},le=async()=>{if(!(!V||!U)){k(!0),j(``);try{let t=await a(`/api/schedules/${encodeURIComponent(V.id)}`,{method:`PATCH`,body:JSON.stringify(U)});p(t.state),y(e=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t.task.id))),e(s(`schedules:schedulesPage.scheduledTaskSaved`))}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(!1)}}},ue=async()=>{if(V){k(!0),j(``);try{await a(`/api/schedules/${encodeURIComponent(V.id)}/run`,{method:`POST`,body:`{}`}),await R(),e(s(`schedules:schedulesPage.scheduledTaskStarted`))}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(!1)}}},pe=async()=>{if(V&&await o({title:s(`schedules:schedulesPage.deleteScheduledTask`),message:s(`schedules:schedulesPage.deleteScheduledTaskNameAndItsRunHistory`,{name:V.name}),confirmLabel:s(`schedules:schedulesPage.delete`)}))try{await a(`/api/schedules/${encodeURIComponent(V.id)}`,{method:`DELETE`}),await R(),e(s(`schedules:schedulesPage.scheduledTaskDeleted`))}catch(e){j(e instanceof Error?e.message:String(e))}},X=t=>{p(t.state),g(t.task.id),e(s(`schedules:schedulesPage.scheduledTaskCreated`))},Z=e=>(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-col items-end gap-0.5 max-[650px]:flex-row max-[650px]:items-center max-[650px]:gap-2`,children:[e.lastStatus===`running`?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,B.jsx)(T,{status:`run`,className:`size-3.5`}),s(`schedules:schedulesPage.running`)]}):(0,B.jsx)(`span`,{className:`whitespace-nowrap`,children:e.enabled?s(`schedules:schedulesPage.nextRunTime`,{time:ge(e,l)}):e.lastStatus===`missed`?s(`schedules:schedulesPage.missed`):e.frequency===`once`&&e.lastRunAt?s(`schedules:schedulesPage.onceDone`):s(`schedules:schedulesPage.pause`)}),e.lastStatus===`failed`&&(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-content-secondary`,children:[(0,B.jsx)(T,{status:`failed`,className:`size-3.5`}),s(`schedules:schedulesPage.lastRunFailed`)]})]}),Q=s(`navigation:navigation.schedules`);return(0,B.jsxs)(ae,{title:Q,description:s(`schedules:schedulesPage.lede`),back:n&&{label:s(`navigation:sidebar.features`),ariaLabel:s(`navigation:shell.backToFeaturesLabel`),onBack:n},toolbar:(0,B.jsx)(oe,{search:(0,B.jsx)(te,{id:v,value:I,onValueChange:L,placeholder:s(`navigation:pageHeader.searchPage`,{page:Q}),shortcut:d,clearLabel:s(`navigation:more.clearSearch`)}),actions:(0,B.jsxs)(S,{type:`button`,className:`h-9`,disabled:!w,onClick:()=>F(!0),children:[(0,B.jsx)(m,{}),s(`schedules:schedulesPage.newTask`)]})}),children:[b?(0,B.jsx)(N,{kind:`loading`,title:s(`schedules:schedulesPage.loadingScheduledTasks`)}):D&&!w?(0,B.jsx)(N,{kind:`error`,title:s(`schedules:schedulesPage.loadFailed`),description:D,action:(0,B.jsx)(S,{variant:`secondary`,className:`max-[650px]:h-11`,onClick:()=>{x(!0),R()},children:s(`common:pageTemplate.retry`)})}):(0,B.jsxs)(B.Fragment,{children:[(A||D)&&(0,B.jsx)(se,{children:A||D}),(0,B.jsx)(ie,{title:s(`schedules:schedulesPage.tasks`),count:f.tasks.length,meta:f.tasks.length?s(`schedules:schedulesPage.enabledCount`,{count:J}):void 0,children:q.length?(0,B.jsx)(re,{children:q.map(e=>{let t=h===e.id;return(0,B.jsx)(ne,{"data-schedule-task":e.id,className:`schedule-list-item`,icon:(0,B.jsx)(c,{}),name:e.name,description:e.targetType===`workflow`?(0,B.jsx)(`span`,{className:`font-mono`,children:G(e)}):e.targetType===`bot`?s(`schedules:schedulesPage.botTarget`,{message:e.botMessage||``}):e.prompt,meta:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{children:de(e.frequency,s)}),(0,B.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,B.jsx)(`span`,{className:`tabular-nums`,children:e.frequency===`interval`?`${e.intervalValue} ${fe(e.intervalUnit,s)}`:e.frequency===`once`?`${e.date} ${e.time}`:e.time}),(0,B.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,B.jsx)(`span`,{className:`truncate`,children:e.timezone}),e.createdBy?.kind===`agent`&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,B.jsx)(`span`,{"data-schedule-created-by":`agent`,children:s(`schedules:schedulesPage.createdByAgent`)})]})]}),status:Z(e),expanded:t,onExpandedChange:t=>g(t?e.id:``),toggleLabel:s(`schedules:schedulesPage.toggleTaskDetails`,{name:e.name}),detail:t&&e.targetType===`bot`?(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm text-content-secondary`,children:[(0,B.jsx)(`span`,{className:`min-w-0 flex-1`,children:s(`schedules:schedulesPage.botManagedThere`)}),(0,B.jsx)(S,{size:`sm`,variant:`outline`,onClick:()=>u(`/bots/${encodeURIComponent(e.botId||``)}`),children:s(`schedules:schedulesPage.openBot`)})]}):t&&U&&V?(0,B.jsx)(ve,{task:V,draft:U,runs:W,saving:ee,workflows:H,notificationTargets:f.notificationTargets,language:l,onUpdate:Y,onToggleNotification:ce,onRun:ue,onRemove:pe,onSave:le,onEditTemplates:r}):null},e.id)})}):(0,B.jsx)(P,{title:f.tasks.length?s(`schedules:schedulesPage.noMatchingTasks`):s(`schedules:schedulesPage.theTimelineIsStillUnlit`),description:f.tasks.length?void 0:s(`schedules:schedulesPage.createATaskAndLetItSetOutAutomaticallyAtTheAppointedTime`)})})]}),M&&(0,B.jsx)(ye,{notificationTargets:f.notificationTargets,workflows:H,defaultCwd:f.defaultCwd,onClose:()=>F(!1),onCreated:e=>{F(!1),X(e)}})]})}function ve({task:e,draft:t,runs:n,saving:r,workflows:a,notificationTargets:o,language:s,onUpdate:c,onToggleNotification:u,onRun:d,onRemove:f,onSave:m,onEditTemplates:h}){let{t:_}=i(),v=e.lastStatus===`running`;return(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,B.jsxs)(`label`,{className:`mr-auto inline-flex min-h-8 items-center gap-2.5 text-sm text-content max-[650px]:min-h-11`,children:[(0,B.jsx)(R,{value:t.enabled,onChange:e=>c({enabled:e}),ariaLabel:_(`schedules:schedulesPage.enableTaskName`,{name:t.name})}),t.enabled?_(`schedules:schedulesPage.enabled`):_(`schedules:schedulesPage.pause`)]}),(0,B.jsxs)(S,{variant:`secondary`,size:`sm`,className:`max-[650px]:h-11`,disabled:r||v,onClick:d,children:[v?(0,B.jsx)(x,{}):(0,B.jsx)(p,{}),_(v?`schedules:schedulesPage.running`:`schedules:schedulesPage.runNow`)]}),(0,B.jsx)(S,{variant:`ghost`,size:`icon-sm`,className:`hover:bg-danger-soft hover:text-danger max-[650px]:size-11`,title:_(`schedules:schedulesPage.deleteTask`),"aria-label":_(`schedules:schedulesPage.deleteTask`),onClick:f,children:(0,B.jsx)(g,{})})]}),(0,B.jsx)($,{targetType:t.targetType,prompt:t.prompt,workflowId:t.workflowId,workflowInputs:t.workflowInputs,workflows:a,onChange:c}),t.targetType===`prompt`&&(0,B.jsx)(me,{value:t.cwd,onChange:e=>c({cwd:e})}),(0,B.jsx)(`div`,{className:K,children:(0,B.jsxs)(`div`,{className:q,children:[(0,B.jsxs)(F,{variant:`control`,children:[_(`schedules:schedulesPage.frequency`),(0,B.jsx)(I,{value:t.frequency,onChange:e=>c({frequency:e.target.value}),children:Object.keys(H).map(e=>(0,B.jsx)(`option`,{value:e,children:de(e,_)},e))})]}),t.frequency===`interval`?(0,B.jsxs)(F,{variant:`control`,children:[_(`schedules:schedulesPage.runInterval`),(0,B.jsxs)(`span`,{className:J,children:[(0,B.jsx)(A,{type:`number`,min:`1`,value:t.intervalValue,onChange:e=>c({intervalValue:Number(e.target.value)})}),(0,B.jsx)(I,{value:t.intervalUnit,onChange:e=>c({intervalUnit:e.target.value}),children:Object.keys(U).map(e=>(0,B.jsx)(`option`,{value:e,children:fe(e,_)},e))})]})]}):(0,B.jsxs)(B.Fragment,{children:[t.frequency===`once`&&(0,B.jsxs)(F,{variant:`control`,children:[_(`schedules:schedulesPage.date`),(0,B.jsx)(A,{type:`date`,className:`tabular-nums`,value:t.date,onChange:e=>c({date:e.target.value})})]}),(0,B.jsxs)(F,{variant:`control`,children:[_(`schedules:schedulesPage.time`),(0,B.jsx)(A,{type:`time`,className:`tabular-nums`,value:t.time,onChange:e=>c({time:e.target.value})})]})]}),(0,B.jsxs)(F,{variant:`control`,children:[_(`schedules:schedulesPage.timeZone`),(0,B.jsx)(I,{value:t.timezone,onChange:e=>c({timezone:e.target.value}),children:W.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))})]}),t.targetType===`prompt`&&(0,B.jsx)(X,{value:t.executionMode,onChange:e=>c({executionMode:e})})]})}),(0,B.jsxs)(`div`,{className:b(`schedule-notification-section pt-3`,K),children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsx)(`strong`,{className:`text-sm font-medium`,children:_(`schedules:schedulesPage.notificationChannels`)}),(0,B.jsx)(`button`,{type:`button`,className:`text-button text-xs font-medium text-content-secondary underline underline-offset-2 hover:text-content max-[650px]:min-h-11`,onClick:h,children:_(`schedules:schedulesPage.editTemplates`)})]}),(0,B.jsx)(`p`,{className:`mt-0.5 text-xs text-content-muted`,children:_(`schedules:schedulesPage.notificationChannelsHelp`)}),(0,B.jsx)(`div`,{className:`schedule-notification-targets mt-2.5 grid grid-cols-[repeat(auto-fill,minmax(132px,1fr))] gap-2`,children:Object.entries(V).map(([e,n])=>{let r=n.Icon,i=t.notifications.includes(e);return(0,B.jsxs)(`button`,{type:`button`,"aria-pressed":i,className:b(`grid min-h-[52px] grid-cols-[16px_minmax(0,1fr)_16px] items-center gap-2 rounded-md border px-2.5 py-2 text-left transition-colors duration-(--d-fast)`,i?`selected border-star-border bg-star-soft text-star-strong`:`border-stroke bg-panel text-content hover:bg-surface-subtle`),onClick:()=>u(e),children:[(0,B.jsx)(r,{className:`size-4`}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,B.jsx)(`strong`,{className:`truncate text-sm font-medium`,children:pe(e,_)}),(0,B.jsx)(`small`,{className:`truncate text-xs text-content-muted`,children:o[e].enabled?_(`schedules:schedulesPage.configured`):_(`schedules:schedulesPage.notConfigured`)})]}),(0,B.jsx)(l,{className:b(`size-4`,i?`text-star-strong`:`text-content-faint`)})]},e)})}),(0,B.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[(0,B.jsx)(`span`,{id:`schedule-notify-on-${e.id}`,className:`text-xs text-content-muted`,children:_(`schedules:schedulesPage.notifyWhen`)}),(0,B.jsx)(`div`,{role:`group`,"aria-labelledby":`schedule-notify-on-${e.id}`,className:b(`schedule-notification-chip`,Y),children:[`always`,`failure`].map(e=>(0,B.jsx)(`button`,{type:`button`,"aria-pressed":t.notifyOn===e,className:ce,onClick:()=>c({notifyOn:e}),children:_(e===`failure`?`schedules:schedulesPage.failuresOnly`:`schedules:schedulesPage.completionAndFailure`)},e))})]})]}),(0,B.jsxs)(`div`,{className:`form-footer mt-4 flex items-center justify-between gap-2.5 border-t border-stroke-soft pt-3 max-[650px]:flex-wrap`,children:[(0,B.jsx)(`span`,{className:`text-xs text-content-muted tabular-nums`,children:e.lastRunAt?_(`schedules:schedulesPage.lastRunTime`,{time:w(e.lastRunAt,s)}):_(`schedules:schedulesPage.nextRunTime`,{time:ge(e,s)})}),(0,B.jsxs)(S,{className:`max-[650px]:h-11 max-[650px]:w-full`,disabled:r||!Q(t.targetType,t.prompt,t.workflowId,t.workflowInputs,a),onClick:m,children:[r?(0,B.jsx)(x,{className:`text-current`}):null,_(r?`schedules:schedulesPage.saving`:`schedules:schedulesPage.saveTask`)]})]})]}),(0,B.jsxs)(`section`,{"aria-labelledby":`schedule-runs-${e.id}`,className:`min-w-0`,children:[(0,B.jsxs)(`h3`,{id:`schedule-runs-${e.id}`,className:`mb-1.5 text-[13px] font-medium text-content-muted tabular-nums`,children:[_(`schedules:schedulesPage.recentRuns`),` · `,n.length]}),n.length?(0,B.jsx)(`ul`,{className:`divide-y divide-stroke-soft overflow-hidden rounded-[var(--r-md)] border border-stroke`,children:n.map(e=>(0,B.jsxs)(`li`,{className:`schedule-run-row grid min-h-11 grid-cols-[18px_minmax(0,1fr)_auto] items-start gap-2.5 px-3 py-2.5 ${e.status}`,children:[(0,B.jsx)(le,{status:e.status}),(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,B.jsx)(`strong`,{className:`line-clamp-2 text-sm leading-5 font-medium text-content`,children:e.status===`running`?_(`schedules:schedulesPage.running2`):e.status===`completed`?e.summary||_(`schedules:schedulesPage.taskCompleted`):e.status===`interrupted`?_(`schedules:schedulesPage.taskInterrupted`):e.error||_(`schedules:schedulesPage.taskFailed`)}),(0,B.jsxs)(`small`,{className:`text-xs text-content-muted tabular-nums`,children:[w(e.startedAt,s),` ·`,` `,e.trigger===`manual`?_(`schedules:schedulesPage.manualRun`):_(`schedules:schedulesPage.scheduledTrigger`),e.durationMs?` · ${_(`schedules:schedulesPage.countSec`,{count:Math.round(e.durationMs/1e3)})}`:``]})]}),(0,B.jsx)(`em`,{className:`font-mono text-xs leading-5 text-content-secondary not-italic tabular-nums`,children:new Intl.DateTimeFormat(s,{hour:`2-digit`,minute:`2-digit`}).format(new Date(e.startedAt))})]},e.id))}):(0,B.jsx)(P,{compact:!0,title:_(`schedules:schedulesPage.noRunHistory`)})]})]})}function ye({notificationTargets:e,workflows:t,defaultCwd:n,onClose:r,onCreated:o}){let{t:s}=i(),[c,l]=(0,z.useState)(``),[u,d]=(0,z.useState)(`prompt`),[f,p]=(0,z.useState)(``),[h,g]=(0,z.useState)(``),[v,y]=(0,z.useState)({}),[b,C]=(0,z.useState)(n||``),[w,T]=(0,z.useState)(`full-access`),[j,M]=(0,z.useState)(!1),[N,P]=(0,z.useState)(``);return(0,B.jsx)(k,{open:!0,onOpenChange:e=>!e&&r(),children:(0,B.jsx)(D,{size:`compact`,children:(0,B.jsxs)(`form`,{className:`grid min-w-0`,onSubmit:async t=>{t.preventDefault(),M(!0),P(``);try{let t=Object.entries(e).filter(([,e])=>e.enabled).map(([e])=>e);o(await a(`/api/schedules`,{method:`POST`,body:JSON.stringify({name:c,targetType:u,prompt:f,workflowId:h,workflowInputs:v,cwd:b,enabled:!0,frequency:`daily`,time:`09:00`,timezone:`Asia/Hong_Kong`,executionMode:w,notifications:t,notifyOn:`always`})}))}catch(e){P(e instanceof Error?e.message:String(e))}finally{M(!1)}},children:[(0,B.jsxs)(ee,{children:[(0,B.jsx)(O,{children:s(`schedules:schedulesPage.newScheduledTask`)}),(0,B.jsx)(E,{children:s(`schedules:schedulesPage.youCanContinueSettingTheRunTimeAndNotificationChannelsAfterCreation`)})]}),(0,B.jsxs)(F,{variant:`control`,children:[s(`schedules:schedulesPage.taskName`),(0,B.jsx)(A,{value:c,onChange:e=>l(e.target.value),placeholder:s(`schedules:schedulesPage.forExampleDailyCodeReview`)})]}),(0,B.jsx)($,{targetType:u,prompt:f,workflowId:h,workflowInputs:v,workflows:t,onChange:e=>{e.targetType&&d(e.targetType),e.prompt!==void 0&&p(e.prompt),e.workflowId!==void 0&&g(e.workflowId),e.workflowInputs!==void 0&&y(e.workflowInputs)}}),u===`prompt`&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(me,{value:b,onChange:C}),(0,B.jsx)(X,{value:w,onChange:T})]}),N&&(0,B.jsxs)(L,{children:[(0,B.jsx)(_,{size:13}),N]}),(0,B.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2 max-[650px]:[&>button]:h-11 max-[650px]:[&>button]:flex-1`,children:[(0,B.jsx)(S,{type:`button`,variant:`secondary`,onClick:r,children:s(`schedules:schedulesPage.cancel`)}),(0,B.jsxs)(S,{type:`submit`,disabled:j||!c.trim()||!Q(u,f,h,v,t),children:[j?(0,B.jsx)(x,{className:`text-current`}):(0,B.jsx)(m,{}),s(j?`schedules:schedulesPage.creating`:`schedules:schedulesPage.createTask`)]})]})]})})})}export{_e as SchedulesPage};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitDiffViewer-
|
|
2
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{h as t}from"./vendor-router-CSN_DGvx.js";import{i as n,r}from"./vendor-react-DwNgTV1j.js";import{t as i}from"./use-i18n-DL1_y_Ge.js";import{o as a}from"./vendor-state-GkUciC5H.js";import{t as o}from"./useQuery-DfOU-27z.js";import{t as s}from"./createLucideIcon-Cd-3GVxJ.js";import{t as c}from"./arrow-left-B8oVrQ2S.js";import{t as l}from"./arrow-right-DqLOhpA2.js";import{t as u}from"./arrow-up-DST6-qVQ.js";import{t as d}from"./check-2vYc6QaP.js";import{t as f}from"./chevron-down-CxtxIjiP.js";import{t as p}from"./chevron-right-C3t2Rckj.js";import{t as m}from"./download-BCfIiuaL.js";import{t as h}from"./earth-Ddy13fHh.js";import{t as g}from"./external-link-CEQqPcqc.js";import{a as _}from"./GitDiffViewer-LK0S-bDi.js";import{t as v}from"./file-Bllajneu.js";import{a as y,c as b,i as ee,o as x,r as S,s as C,y as w}from"./side-chat-context-D0zsA72l.js";import{t as T}from"./git-branch-N7LGjtzt.js";import{y as E}from"./ChatMessage-CBGpmO8b.js";import{t as D}from"./image-BY_c3FYU.js";import{t as O}from"./link-2-mgasYn21.js";import{t as k}from"./loader-circle-BOwQzHB-.js";import{t as te}from"./message-square-SKjZyY3v.js";import{t as A}from"./pause-CYWpPg1R.js";import{t as j}from"./refresh-cw-TbWxTY4K.js";import{t as M}from"./rotate-ccw-clock-CO6Bw-sF.js";import{t as ne}from"./square-bHHVTT3G.js";import{t as N}from"./trash-2-CNrPOoPR.js";import{t as re}from"./triangle-alert-CE1q54ci.js";import"./collapsible-B-fc7n0u.js";import{a as ie,c as ae,i as oe,n as se,o as ce,r as le,s as ue,t as de}from"./alert-dialog-DiUitBB0.js";import{a as fe,r as pe,t as me}from"./popover-CYgt88Di.js";import"./tooltip-D4MFbqcG.js";import{t as P}from"./utils-C8uzG5AZ.js";import{n as F,t as I}from"./button-CCcCN8tE.js";import{c as he,r as ge}from"./shortcuts-Cth0vc77.js";import{t as L}from"./chat-api-DixX49bK.js";import{a as _e,i as ve,n as ye,o as be,r as xe,t as Se}from"./command-Dugx8Xyc.js";import{t as R}from"./input-CPw-zkYh.js";import{n as Ce}from"./session-change-summary-api-CvAF7fwO.js";import{n as we,t as z}from"./PageState-Cz6vFMXv.js";import{n as Te,t as Ee}from"./alert-DRIrgNI4.js";import{t as De}from"./AppSelect-B15Hpk2W.js";import{o as B}from"./session-tree-summary-BeUnCg9w.js";import{a as V,i as H,o as Oe,s as ke,t as Ae}from"./session-web-preview-DfdZezsZ.js";import{i as je,n as Me,r as U,t as Ne}from"./web-preview-C7DdG9JP.js";import{n as Pe}from"./useNativeBrowser-C0j3zafh.js";var Fe=s(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Ie=s(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),W=s(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),Le=s(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),G=e(n(),1),K=r(),Re={completed:`completed`,in_progress:`running`,paused:`pending`,blocked:`blocked`,pending:`pending`};function ze(e){let t=new Map(e.map(e=>[String(e.id||``),e])),n=e=>e?.status===`completed`;return e.map(e=>{let r=String(e.id||``),i=(Array.isArray(e.dependsOn)?e.dependsOn:[]).map(e=>t.get(String(e))).filter(e=>!!e&&!n(e)),a=e.status!==`completed`&&(e.status===`blocked`||i.length>0);return{...e,id:r,blocked:a,blockedBy:i}})}function Be({status:e,t}){let n=t(e===`completed`?`chat:planBoard.completed`:e===`in_progress`?`chat:planBoard.inProgress`:e===`paused`?`chat:planBoard.paused`:e===`blocked`?`chat:planBoard.blocked`:`chat:planBoard.pending`);return(0,K.jsxs)(`span`,{className:`plan-board-status grid size-[18px] flex-none place-items-center rounded-xs text-content-muted [&.completed]:bg-success-soft [&.completed]:text-success [&.running]:text-accent-fg [&.blocked]:bg-danger-soft [&.blocked]:text-danger ${Re[String(e)]||`pending`}`,title:n,children:[e===`completed`?(0,K.jsx)(d,{size:12,strokeWidth:2.25}):e===`in_progress`?(0,K.jsx)(F,{className:`size-3.5`}):e===`paused`?(0,K.jsx)(A,{size:11,strokeWidth:2}):e===`blocked`?(0,K.jsx)(W,{size:11,strokeWidth:2}):(0,K.jsx)(Fe,{size:11,strokeWidth:2}),(0,K.jsx)(`span`,{className:`sr-only`,children:n})]})}function Ve({item:e,current:t,running:n,t:r}){return(0,K.jsxs)(`li`,{className:`plan-board-row flex min-w-0 flex-col gap-[2px] rounded-sm px-[6px] py-[6px] aria-[current=step]:bg-surface-subtle ${e.blocked?`blocked`:``}`,"aria-current":t?`step`:void 0,"data-pisper-plan-current":t?`true`:void 0,"data-pisper-plan-id":e.id,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-[10px]`,children:[(0,K.jsx)(Be,{status:e.blocked?`blocked`:e.status===`in_progress`&&!n?`paused`:e.status,t:r}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] ${e.status===`completed`?`text-content-muted`:`text-foreground`}`,title:e.title,children:e.title}),e.assignee?(0,K.jsxs)(`span`,{className:`inline-flex max-w-[40%] flex-none items-center gap-[4px] truncate rounded-xs border border-stroke px-[6px] font-mono text-[12px] leading-[18px] text-content-secondary`,title:r(`chat:planBoard.assignedTo`,{name:e.assignee}),children:[(0,K.jsx)(w,{size:11,className:`flex-none`}),e.assignee]}):e.status!==`completed`&&(0,K.jsx)(`span`,{className:`flex-none text-[12px] text-content-muted`,children:r(`chat:planBoard.unassigned`)})]}),e.blockedBy.length>0&&(0,K.jsxs)(`div`,{className:`inline-flex min-w-0 items-center gap-[5px] pl-[28px] text-[12px] text-content-muted`,children:[(0,K.jsx)(W,{size:11,className:`flex-none`}),(0,K.jsx)(`span`,{className:`truncate`,children:r(`chat:planBoard.waitingFor`,{tasks:e.blockedBy.map(e=>e.title||e.id).join(` · `)})})]})]})}function He({plan:e,running:t,header:n,collapsible:r=!1}){let{t:a}=i(),o=(0,G.useRef)(null),[s,c]=(0,G.useState)(!0),l=e?.items||[],u=ze(l),d=u.filter(e=>e.status===`completed`).length,p=u.filter(e=>e.status===`in_progress`&&!e.blocked).length,m=u.filter(e=>e.blocked).length,h=u.find(e=>e.status===`in_progress`&&!e.blocked)?.id??u.find(e=>e.blocked)?.id??u.find(e=>e.status===`pending`)?.id??u.at(-1)?.id;if((0,G.useLayoutEffect)(()=>{if(r&&!s)return;let e=o.current,t=e?.querySelector(`[data-pisper-plan-current="true"]`);if(!e||!t)return;let n=e.getBoundingClientRect(),i=t.getBoundingClientRect();i.top<n.top?e.scrollTop-=n.top-i.top:i.bottom>n.bottom&&(e.scrollTop+=i.bottom-n.bottom)},[r,h,s,u.length]),!l.length)return null;let g=u.find(e=>e.id===h),_=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ie,{className:`flex-none text-content-muted`,size:15}),(0,K.jsx)(`strong`,{className:`tabular-nums`,children:a(`chat:planBoard.progress`,{completed:d,total:l.length})}),g?(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-content-secondary`,title:g.title,children:g.title}):null,(0,K.jsxs)(`span`,{className:`plan-board-counts inline-flex flex-none items-center gap-[8px] text-content-muted tabular-nums @max-[470px]:hidden`,children:[p>0&&(0,K.jsx)(`span`,{children:a(t?`chat:planBoard.countInProgress`:`chat:planBoard.countPaused`,{count:p})}),m>0&&(0,K.jsx)(`span`,{className:`blocked text-danger`,children:a(`chat:planBoard.countBlocked`,{count:m})})]}),n,r?(0,K.jsx)(f,{className:`plan-board-chevron flex-none text-content-muted transition-transform duration-(--d-fast) ease-precise [.plan-board-collapsible[open]_&]:rotate-180`,size:15}):null]}),v=(0,K.jsx)(`ul`,{ref:o,className:`plan-board-list [.plan-board-collapsible_>_&]:border-t [.plan-board-collapsible_>_&]:border-stroke-soft [.plan-board-collapsible_>_&]:p-[6px_8px_8px] m-0 flex list-none flex-col gap-[1px] pt-[6px]${u.length>4?` is-scrollable [.session-plan-popover_.plan-board-list&]:[block-size:min(250px,38dvh)] [.plan-board-list&]:[block-size:min(220px,34dvh)] [.plan-board-list&]:overflow-y-auto [.plan-board-list&]:[overscroll-behavior:contain] [.plan-board-list&]:pr-[4px] [.plan-board-list&]:[scrollbar-gutter:stable] [.plan-board-list&:focus-visible]:outline-2 [.plan-board-list&:focus-visible]:outline-focus [.plan-board-list&:focus-visible]:outline-offset-2`:``}`,tabIndex:u.length>4?0:void 0,children:u.map(e=>(0,K.jsx)(Ve,{running:t,item:e,current:e.id===h,t:a},e.id))});return r?(0,K.jsxs)(`details`,{className:`plan-board plan-board-collapsible m-[0_auto] flex w-[min(900px,100%)] flex-col overflow-hidden rounded-md border border-stroke bg-panel !p-0 [.session-plan-popover_&]:w-full [.session-plan-popover_&]:border-0 [.session-plan-popover_&]:bg-transparent`,open:s,onToggle:e=>c(e.currentTarget.open),children:[(0,K.jsx)(`summary`,{className:`plan-board-summary flex min-w-0 items-center gap-[8px] border-b border-stroke-soft pb-[8px] text-[13px] text-content-secondary [&_strong]:flex-none [&_strong]:font-medium [&_strong]:text-foreground [.plan-board-collapsible_>_&]:min-h-[34px] [.plan-board-collapsible_>_&]:cursor-pointer [.plan-board-collapsible_>_&]:list-none [.plan-board-collapsible_>_&]:border-0 [.plan-board-collapsible_>_&]:p-[6px_12px] max-[650px]:[.plan-board-collapsible_>_&]:min-h-11 [.plan-board-collapsible_>_&::-webkit-details-marker]:hidden [.plan-board-collapsible_>_&:hover]:bg-surface-subtle [.plan-board-collapsible_>_&:focus-visible]:outline-2 [.plan-board-collapsible_>_&:focus-visible]:-outline-offset-2 [.plan-board-collapsible_>_&:focus-visible]:outline-focus`,"aria-label":a(`chat:planBoard.toggleAriaLabel`),children:_}),v]}):(0,K.jsxs)(`section`,{className:`plan-board m-[0_auto] flex w-[min(900px,100%)] flex-col rounded-md border border-stroke bg-panel p-[10px_12px] [.session-plan-popover_&]:w-full [.session-plan-popover_&]:border-0 [.session-plan-popover_&]:bg-transparent [.session-plan-popover_&]:p-0`,"aria-label":a(`chat:planBoard.ariaLabel`),children:[(0,K.jsx)(`div`,{className:`plan-board-summary flex min-w-0 items-center gap-[8px] border-b border-stroke-soft pb-[8px] text-[13px] text-content-secondary [&_strong]:flex-none [&_strong]:font-medium [&_strong]:text-foreground [.plan-board-collapsible_>_&]:min-h-[34px] [.plan-board-collapsible_>_&]:cursor-pointer [.plan-board-collapsible_>_&]:list-none [.plan-board-collapsible_>_&]:border-0 [.plan-board-collapsible_>_&]:p-[6px_12px] max-[650px]:[.plan-board-collapsible_>_&]:min-h-11 [.plan-board-collapsible_>_&::-webkit-details-marker]:hidden [.plan-board-collapsible_>_&:hover]:bg-surface-subtle [.plan-board-collapsible_>_&:focus-visible]:outline-2 [.plan-board-collapsible_>_&:focus-visible]:-outline-offset-2 [.plan-board-collapsible_>_&:focus-visible]:outline-focus`,children:_}),v]})}var Ue=(0,G.memo)(He),We=(0,G.lazy)(()=>t(()=>import(`./GitDiffViewer-LK0S-bDi.js`).then(e=>e.n).then(e=>({default:e.InlineGitDiff})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17])));function q({sessionId:e,path:t,scope:n,revision:r=0,position:a,onReading:s,mode:c,fill:l=!1}){let{t:u}=i(),d=o({queryKey:[`task-file-diff`,e,n,t,r],queryFn:({signal:r})=>n===`project`?L.getFileDiff(e,t,{signal:r}):L.getSessionFileChangeDiff(e,t,{signal:r})});return d.isPending?(0,K.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 px-3 py-2.5 text-xs text-content-muted`,children:[(0,K.jsx)(F,{className:`size-3.5`}),u(`chat:focusSession.gitLoading`)]}):d.isError?(0,K.jsxs)(`div`,{className:`px-3 py-2.5`,children:[(0,K.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:d.error.message}),(0,K.jsx)(I,{variant:`ghost`,size:`sm`,onClick:()=>void d.refetch(),children:u(`chat:chatMessage.filePreviewRetry`)})]}):(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(We,{position:a,onReading:s,diff:d.data.diff,truncated:d.data.diffTruncated,mode:c,fill:l})})}function Ge({sessionId:e,cwd:t,streaming:n,view:r,onViewChange:a}){let{t:s}=i(),c=o({queryKey:[`task-project-changes`,e,t,n],queryFn:({signal:t})=>L.getVcsChanges(e,{signal:t})}),l=_(r.reading?.list,e=>a({reading:{...r.reading,list:e}})),u=(0,G.useMemo)(()=>C(c.data?.diff||``,c.data?.files.map(e=>e.path)||[],c.data?.diffTruncated),[c.data]),d=r.expandedFiles.filter(e=>c.data&&!c.data.files.some(t=>t.path===e)),f=c.error?.message||c.data?.error,m=c.data?.files||[];return(0,K.jsxs)(`section`,{"aria-label":s(`chat:workbench.projectChanges`),className:`flex min-h-0 flex-1 flex-col`,children:[(0,K.jsxs)(`header`,{className:`flex min-h-10 min-w-0 shrink-0 items-center gap-2 border-b border-stroke-soft pr-1.5 pl-3`,children:[(0,K.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-xs font-medium tracking-[.02em] text-content-muted`,children:s(`chat:workbench.projectChanges`)}),c.data?.isRepo&&!f&&(0,K.jsxs)(`span`,{className:`shrink-0 font-mono text-xs tabular-nums`,children:[(0,K.jsxs)(`span`,{className:`text-success`,children:[`+`,u.added]}),` `,(0,K.jsxs)(`span`,{className:`text-danger`,children:[`−`,u.removed]})]}),(0,K.jsx)(I,{variant:`ghost`,size:`icon`,className:`max-[650px]:size-11`,"aria-label":s(`chat:focusSession.gitRefresh`),disabled:c.isFetching,onClick:()=>void c.refetch(),children:(0,K.jsx)(j,{size:15,className:c.isFetching?`animate-spin`:void 0})})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 border-b border-stroke-soft px-3 py-2.5`,children:[(0,K.jsx)(`p`,{className:`text-xs leading-relaxed text-content-muted`,children:s(`chat:workbench.projectScope`)}),(0,K.jsxs)(`p`,{className:`flex min-w-0 items-center gap-1.5 text-xs`,title:t,children:[c.data?.branch&&(0,K.jsxs)(`span`,{className:`inline-flex h-5.5 max-w-[45%] shrink-0 items-center gap-1 rounded-xs border border-stroke px-1.5 font-mono text-content-secondary`,children:[(0,K.jsx)(T,{size:12,className:`shrink-0`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`truncate`,children:c.data.branch})]}),(0,K.jsx)(`span`,{className:`min-w-0 truncate font-mono text-content-muted`,children:t})]}),(0,K.jsxs)(`div`,{className:`flex gap-1`,children:[(0,K.jsx)(I,{variant:`ghost`,size:`sm`,disabled:!m.length||!!f,onClick:()=>a({expandedFiles:m.map(e=>e.path)}),children:s(`chat:workbench.expandAll`)}),(0,K.jsx)(I,{variant:`ghost`,size:`sm`,onClick:()=>a({expandedFiles:[]}),children:s(`chat:workbench.collapseAll`)})]})]}),!c.isFetching&&!f&&d.map(e=>(0,K.jsx)(`p`,{role:`status`,className:`break-all px-3 pt-2 text-xs text-content-muted`,children:s(`chat:workbench.fileNoLongerChanged`,{path:e})},e)),c.isPending?(0,K.jsx)(we,{kind:`loading`,title:s(`chat:focusSession.gitLoading`)}):f?(0,K.jsx)(`p`,{role:`alert`,className:`p-3 text-sm text-danger`,children:f}):c.data?.isRepo?m.length?(0,K.jsx)(`div`,{ref:l.ref,className:`min-h-0 flex-1 overflow-y-auto`,children:m.map(t=>{let n=r.expandedFiles.includes(t.path);return(0,K.jsxs)(`article`,{className:`border-b border-stroke-soft`,children:[(0,K.jsxs)(`button`,{"aria-expanded":n,title:t.path,className:`flex min-h-9 w-full min-w-0 items-center gap-2 pr-3 pl-2 text-left text-sm hover:bg-surface-subtle focus-visible:-outline-offset-2 max-[650px]:min-h-11 pointer-coarse:min-h-11 ${n?`bg-surface-subtle`:``}`,onClick:()=>a({expandedFiles:n?r.expandedFiles.filter(e=>e!==t.path):[...r.expandedFiles,t.path]}),children:[(0,K.jsx)(p,{size:14,className:`shrink-0 text-content-muted transition-transform duration-(--d-fast) ${n?`rotate-90`:``}`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:t.path}),(0,K.jsx)(`span`,{className:`min-w-4 shrink-0 text-center font-mono text-xs font-medium text-content-secondary`,children:t.status}),Object.hasOwn(u.files,t.path)&&(0,K.jsxs)(`span`,{className:`shrink-0 font-mono text-xs tabular-nums`,children:[(0,K.jsxs)(`span`,{className:`text-success`,children:[`+`,u.files[t.path].added]}),` `,(0,K.jsxs)(`span`,{className:`text-danger`,children:[`−`,u.files[t.path].removed]})]})]}),n&&(0,K.jsx)(`p`,{className:`break-all px-3 py-1.5 font-mono text-xs text-content-muted`,children:t.path}),n&&(0,K.jsx)(q,{sessionId:e,path:t.path,scope:`project`,position:r.reading?.[t.path],onReading:e=>a({reading:{...r.reading,[t.path]:e}}),revision:c.dataUpdatedAt})]},t.path)})}):(0,K.jsx)(z,{compact:!0,title:s(`chat:focusSession.fileChangesEmpty`)}):(0,K.jsx)(z,{compact:!0,title:s(`chat:workbench.notRepository`)})]})}function J(e){return e instanceof Error?e.message:String(e)}function Ke({sessionId:e,streaming:t,requestConfirm:n}){let{t:r}=i(),[a,o]=(0,G.useState)(0),[s,c]=(0,G.useState)(0),[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(!0),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(``),[_,v]=(0,G.useState)(``),[y,b]=(0,G.useState)(null),[ee,x]=(0,G.useState)(null),[S,C]=(0,G.useState)(null),w=(0,G.useRef)(!1),T=(0,G.useRef)(0),E=(0,G.useRef)(0),D=(0,G.useRef)(!0),O=(0,G.useRef)(!1),k=(0,G.useRef)(t);return(0,G.useLayoutEffect)(()=>{k.current=t},[t]),(0,G.useLayoutEffect)(()=>(w.current=!0,()=>{w.current=!1,T.current+=1,E.current+=1}),[]),(0,G.useEffect)(()=>{let t=++T.current;return E.current+=1,x(null),C(null),D.current=!0,f(!0),m(``),L.getSessionFileChanges(e).then(e=>{w.current&&t===T.current&&(u(e),c(e=>e+1))},e=>{w.current&&t===T.current&&m(J(e))}).finally(()=>{w.current&&t===T.current&&(D.current=!1,f(!1))}),()=>{T.current+=1}},[a,e,t]),{changes:l,loading:d,error:p,actionError:h,notice:_,running:y,diff:ee,setDiff:x,diffLoading:S,snapshotRevision:s,writesDisabled:d||t||!!y||!!p||!l,pendingCount:l?.summary.pending||0,reversibleCount:l?.files.filter(e=>e.canRevert&&!e.reverted).length||0,displayedError:h||p,viewDiff:async t=>{if(O.current||D.current)return;let n=++E.current;C(t),g(``);try{let i=await L.getSessionFileChangeDiff(e,t);if(!w.current||n!==E.current)return;if(!i.diff?.trim()){g(r(`chat:focusSession.fileChangesNoSnapshot`));return}x({diff:i.diff,truncated:!!i.diffTruncated})}catch(e){w.current&&n===E.current&&g(J(e))}finally{w.current&&n===E.current&&C(null)}},runAction:async t=>{if(!w.current||O.current||D.current||k.current||!l||p||!l.files.filter(e=>t.kind===`approve`?e.pending&&!e.approved&&!e.reverted:e.canRevert&&!e.reverted).some(e=>t.path===void 0||e.path===t.path))return;O.current=!0,b(t),g(``),v(``);let i=++T.current;E.current+=1,x(null),C(null);let a=!1;try{if(t.kind===`revert`&&!await n({title:t.path?r(`chat:focusSession.fileChangesRevertFile`):r(`chat:focusSession.fileChangesRevertAll`),message:t.path?r(`chat:focusSession.fileChangesRevertFileDescription`,{path:t.path}):r(`chat:focusSession.fileChangesRevertAllDescription`),confirmLabel:r(`chat:focusSession.fileChangesConfirmRevert`),tone:`danger`})||!w.current||k.current||D.current||i!==T.current)return;a=!0;let o=t.kind===`approve`?await L.approveSessionFileChanges(e,t.path):await L.revertSessionFileChanges(e,t.path);if(Ce(e),!w.current||i!==T.current)return;u(o),t.kind===`approve`?v(t.path?r(`chat:focusSession.fileChangesApproved`):r(`chat:focusSession.fileChangesApproveDone`)):o.reverted?t.path===void 0&&o.files.some(e=>e.pending)?v(r(`chat:focusSession.fileChangesRevertPartial`,{count:o.reverted})):v(r(`chat:focusSession.fileChangesRevertDone`)):v(r(`chat:focusSession.fileChangesRevertUnavailable`))}catch(e){w.current&&i===T.current&&g(J(e))}finally{O.current=!1,w.current&&(b(null),a&&(D.current=!0,f(!0),o(e=>e+1)))}},refresh:()=>{D.current=!0,f(!0),g(``),o(e=>e+1)}}}var qe=(0,G.lazy)(()=>t(()=>import(`./TaskTerminalView-CVBvmwIN.js`).then(e=>({default:e.TaskTerminalView})),__vite__mapDeps([18,1,2,3,4,5,6,7,8,9,19,10,20,14,13,15,12,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37]))),Je=(0,G.lazy)(()=>t(()=>import(`./TaskProcessesPane-Kj4R2eFS.js`).then(e=>({default:e.TaskProcessesPane})),__vite__mapDeps([38,1,2,3,4,5,6,7,8,9,39,10,19,20,40,25,15,29,34,12,13,14,21,22,23,24,26,27,28,30,31,32,33,35,36]))),Ye=(0,G.lazy)(()=>t(()=>import(`./FileAttachmentPreview-B9i02UCX.js`).then(e=>e.n).then(e=>({default:e.FileAttachmentPreview})),__vite__mapDeps([41,1,2,3,4,5,6,7,8,9,42,43,44,45,46,47,10,48,49,11,50,13,29,15,31,51,12,14,52,53,54,32,55,56,57,58,59,25,60,61])));function Xe({sources:e,view:t,onViewChange:n}){let{t:r}=i(),a=_(t.reading?.list,e=>n({reading:{...t.reading,list:e}})),o=(0,G.useContext)(b),[s,c]=(0,G.useState)(``),l=(0,G.useRef)(null),u=e.find(e=>e.id===s),d=e.filter(e=>(!t.filter||e.kind===t.filter)&&e.name.toLocaleLowerCase().includes(t.query.toLocaleLowerCase()));return(0,K.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,"aria-label":r(`chat:workbench.sources`),children:[(0,K.jsxs)(`header`,{className:`flex min-h-10 min-w-0 shrink-0 items-center gap-2 border-b border-stroke-soft pr-1.5 pl-3`,children:[(0,K.jsxs)(`h2`,{className:`min-w-0 flex-1 truncate text-xs font-medium tracking-[.02em] text-content-muted`,children:[r(`chat:workbench.sources`),(0,K.jsx)(`span`,{className:`ml-1.5 tabular-nums`,children:e.length})]}),(0,K.jsx)(`span`,{className:`shrink-0 text-xs text-content-muted`,children:r(`chat:workbench.addSource`)}),(0,K.jsx)(`div`,{ref:o?.setSourceActionHost,className:`grid min-h-7 min-w-7 place-items-center`})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 border-b border-stroke-soft px-3 py-2.5`,children:[(0,K.jsx)(`p`,{className:`text-xs leading-relaxed text-content-muted`,children:r(`chat:workbench.sourcesScope`)}),(0,K.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,K.jsx)(R,{className:`min-w-0 flex-1`,"aria-label":r(`chat:workbench.searchSources`),placeholder:r(`chat:workbench.searchSources`),value:t.query,onChange:e=>n({query:e.target.value})}),(0,K.jsxs)(De,{"aria-label":r(`chat:workbench.sourceType`),className:`w-auto max-w-[45%] shrink-0`,value:t.filter,onChange:e=>n({filter:e.target.value}),children:[(0,K.jsx)(`option`,{value:``,children:r(`chat:workbench.allTypes`)}),(0,K.jsx)(`option`,{value:`image`,children:r(`chat:workbench.images`)}),(0,K.jsx)(`option`,{value:`text`,children:r(`chat:workbench.text`)}),(0,K.jsx)(`option`,{value:`file`,children:r(`chat:workbench.files`)})]})]})]}),(0,K.jsxs)(`div`,{ref:a.ref,className:`min-h-0 flex-1 overflow-y-auto`,children:[!d.length&&(0,K.jsx)(z,{compact:!0,title:e.length?r(`chat:workbench.noMatches`):r(`chat:workbench.noSources`)}),d.map(e=>{let i=t.selectedSourceId===e.id,a=e.kind===`image`?D:e.method===`path`?O:v;return(0,K.jsxs)(`article`,{className:`border-b border-stroke-soft`,children:[(0,K.jsxs)(`button`,{className:`flex min-h-9 w-full min-w-0 items-center gap-2 px-2 text-left hover:bg-surface-subtle focus-visible:-outline-offset-2 max-[650px]:min-h-11 pointer-coarse:min-h-11 ${i?`bg-surface-subtle`:``}`,"aria-expanded":i,onClick:()=>n({selectedSourceId:i?``:e.id}),children:[(0,K.jsx)(p,{size:14,className:`shrink-0 text-content-muted transition-transform duration-(--d-fast) ${i?`rotate-90`:``}`}),(0,K.jsx)(a,{className:`size-3.5 shrink-0 text-content-muted`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:e.name||r(`chat:chatMessage.fileAttachment`)})]}),i&&(0,K.jsxs)(`div`,{className:`space-y-1.5 border-t border-stroke-soft bg-code py-2.5 pr-3 pl-8 text-xs text-content-muted`,children:[(0,K.jsx)(`p`,{className:`break-all font-mono text-content-secondary`,children:e.attachment.path||e.attachment.id||r(`chat:workbench.unavailable`)}),(0,K.jsx)(`p`,{className:`font-mono`,children:e.attachment.mimeType||`application/octet-stream`}),(0,K.jsx)(`p`,{children:e.method===`asset`?r(`chat:workbench.registeredAsset`):e.method===`path`?r(`chat:workbench.pathReference`):r(`chat:workbench.invalidReference`)}),(0,K.jsx)(I,{variant:`secondary`,size:`sm`,className:`mt-1`,disabled:!e.available,onClick:t=>{l.current=t.currentTarget,c(e.id)},children:r(`chat:chatMessage.fileActionPreview`)})]})]},e.id)})]}),u&&(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(Ye,{attachment:u.attachment,onClose:()=>c(``),onRestoreFocus:()=>l.current?.focus(),onDownload:()=>{typeof u.attachment.downloadUrl==`string`&&window.open(u.attachment.downloadUrl,`_blank`,`noopener,noreferrer`)}})})]})}var Ze=`https://www.bing.com/search?q=`;function Qe(e){let t=e.split(`.`);return t.length===4&&t.every(e=>/^\d{1,3}$/.test(e)&&Number(e)<=255)}function $e(e){let t=e.split(/[/?#]/,1)[0]??``;if(!t||t.includes(`@`))return null;if(t.startsWith(`[`))return/^\[[\da-f:.]+\](?::\d{1,5})?$/i.test(t)?t:null;let n=/^([^:]+)(?::(\d{1,5}))?$/.exec(t);return n?n[1]:null}function et(e){if(/\s/.test(e))return null;let t=$e(e);if(!t)return null;let n=t.toLowerCase();if(n.startsWith(`[`)||n===`localhost`||n.endsWith(`.localhost`)||Qe(n))return`local`;let r=n.split(`.`);if(r.length<2||r.some(e=>!/^[\p{L}\p{N}-]+$/u.test(e)))return null;let i=r[r.length-1];return/^(?:\p{L}{2,}|xn--[a-z\d-]+)$/u.test(i)?`public`:null}function tt(e){return`${Ze}${encodeURIComponent(e)}`}function Y(e,t){let n=e.trim();if(!n)return null;if(/^https?:/i.test(n)||n.startsWith(`//`)){let e=U(n,t);return e?{kind:`url`,url:e}:null}let r=et(n);if(r===`local`){let e=je(`http://${n}`,t)?.href;if(e)return{kind:`url`,url:e}}else if(r===`public`){let e=U(n,t);if(e)return{kind:`url`,url:e}}return{kind:`search`,url:tt(n)}}function nt({parentId:e,active:t}){let{t:n}=i(),{entry:r,runtime:a,load:o,setDraft:s}=S(e),c=r.session?.id??``,l=(0,G.useMemo)(()=>e=>a.subscribeSessionState(c,e),[a,c]),d=(0,G.useMemo)(()=>()=>a.getSessionState(c),[a,c]),f=(0,G.useSyncExternalStore)(l,d),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(``),b=(0,G.useRef)(!1),C=(0,G.useRef)(!1),w=(0,G.useRef)(r.draft);w.current=r.draft;let T=(0,G.useRef)(null),D=he(e=>e.bindings),O=ee(f,r.session);(0,G.useEffect)(()=>{t&&o(e)},[t,o,e]);let k=async t=>{t.preventDefault();let n=w.current.trim();if(!(!n||b.current||O||r.expired)){b.current=!0,m(!0),v(``);try{let t=await o(e,!r.session);if(!t?.session)return;let i=t.session.id;if(a.getSessionState(i).streaming)return;w.current.trim()===n&&s(e,``),m(!1),await a.send(i,n),await o(e)}catch(e){v(B(e))}finally{b.current=!1,m(!1)}}},A=(0,G.useCallback)(async()=>{if(!(!c||a.getSessionState(c).streaming)){v(``);try{await a.retry(c),await o(e)}catch(e){v(B(e))}}},[o,e,a,c]),j=async()=>{if(!(!c||h)){g(!0);try{v(``),await a.abort(c)}catch(e){v(B(e))}finally{g(!1)}}},M=(0,K.jsxs)(`div`,{className:`grid h-full min-h-36 place-content-center justify-items-center gap-2 px-3 text-center text-xs text-content-muted`,children:[(0,K.jsx)(`span`,{className:`mb-1 grid size-8 place-items-center rounded-md bg-key text-content-secondary shadow-key ring-1 ring-key-border`,children:(0,K.jsx)(te,{className:`size-4`,"aria-hidden":`true`})}),(0,K.jsx)(`p`,{className:`max-w-64 leading-relaxed`,children:r.expired?n(`chat:sideChat.expired`):n(`chat:sideChat.empty`)}),r.expired&&(0,K.jsxs)(I,{variant:`secondary`,size:`sm`,className:`mt-1`,disabled:r.loading,onClick:async()=>{(await o(e,!0))?.session&&T.current?.focus()},children:[r.loading&&(0,K.jsx)(F,{className:`size-3.5 text-current`}),n(`chat:sideChat.restart`)]})]}),N=_||r.error||f.error;return(0,K.jsxs)(`section`,{"data-side-chat-parent":e,"aria-label":n(`chat:sideChat.title`),className:`flex h-full min-h-0 min-w-0 flex-1 flex-col [container-type:inline-size]`,children:[(0,K.jsx)(`p`,{className:`shrink-0 border-b border-stroke-soft px-3 py-2 text-xs leading-relaxed text-content-muted`,children:n(`chat:sideChat.retention`)}),c?(0,K.jsx)(x,{sessionId:c,messages:f.messages,transcriptLoadState:f.loaded?`ready`:f.error?`error`:`loading`,emptyState:M,messageStart:f.messageStart,hasOlder:f.hasOlder,loadingOlder:f.loadingOlder,olderError:f.olderError,activityFeed:f.activityFeed,tools:f.tools,thinkingText:f.thinkingText,currentActivity:f.currentActivity,compaction:f.compaction,streaming:O,runStartedAt:f.runStartedAt,lastActivityAt:f.lastActivityAt,runFinishedAt:f.runFinishedAt,runStopped:f.runStopped,runNotice:f.runNotice,error:f.error,cwd:r.session?.cwd,onLoadOlder:()=>a.loadOlderMessages(c),onRetryLastTurn:A}):(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:M}),(0,K.jsxs)(`form`,{className:`flex shrink-0 flex-col gap-2 border-t border-stroke-soft p-3`,onSubmit:k,children:[N&&(0,K.jsx)(E,{error:N,onRetry:r.error||!f.loaded?async()=>{await o(e)}:A}),(0,K.jsx)(y,{approvals:f.approvals,onResolve:async(e,t)=>{try{await a.approve(c,e,t)}catch{}}}),(0,K.jsxs)(`div`,{className:`flex min-w-0 items-end gap-2 rounded-[var(--composer-radius,22px)] border border-control bg-panel py-2 pr-2 pl-3 shadow-composer transition-[border-color,box-shadow] duration-(--d-fast) focus-within:border-focus focus-within:ring-3 focus-within:ring-focus-ring`,children:[(0,K.jsx)(`textarea`,{ref:T,rows:2,value:r.draft,"aria-label":n(`chat:sideChat.message`),placeholder:n(`chat:sideChat.placeholder`),className:`max-h-40 min-h-14 min-w-0 flex-1 resize-y border-0 bg-transparent px-1 py-1 text-sm leading-relaxed text-content caret-focus outline-none placeholder:text-content-muted`,onChange:t=>s(e,t.target.value),onCompositionStart:()=>{C.current=!0},onCompositionEnd:()=>{C.current=!1},onKeyDown:e=>{!C.current&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229&&ge(e.nativeEvent,D.sendMessage)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}),(0,K.jsx)(I,{type:O?`button`:`submit`,size:`icon`,className:`size-8 shrink-0 rounded-full max-[650px]:size-11 pointer-coarse:size-11`,"aria-label":n(O?`chat:sideChat.stop`:`chat:sideChat.send`),disabled:O?h:p||r.loading||r.expired||!r.draft.trim(),onClick:O?()=>void j():void 0,children:p||h?(0,K.jsx)(F,{className:`size-4 text-current`}):O?(0,K.jsx)(ne,{size:13,fill:`currentColor`}):(0,K.jsx)(u,{size:17})})]})]})]})}var rt=(0,G.createContext)(null),it=()=>{let e=(0,G.useContext)(rt);if(!e)throw Error(`WebPreview components must be used within a WebPreview`);return e},at=({className:e,children:t,defaultUrl:n=``,onUrlChange:r,...i})=>{let[a,o]=(0,G.useState)(n),[s,c]=(0,G.useState)(!1),l=(0,G.useCallback)(e=>{o(e),r?.(e)},[r]),u=(0,G.useMemo)(()=>({consoleOpen:s,setConsoleOpen:c,setUrl:l,url:a}),[s,l,a]);return(0,K.jsx)(rt.Provider,{value:u,children:(0,K.jsx)(`div`,{className:P(`flex size-full min-h-0 flex-col rounded-lg border bg-card`,e),...i,children:t})})},ot=({className:e,loading:t,src:n,...r})=>{let{url:i}=it();return(0,K.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden bg-background`,children:[(0,K.jsx)(`iframe`,{className:P(`block size-full border-0 bg-background`,e),loading:`lazy`,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups allow-presentation`,src:(n??i)||void 0,title:`Preview`,...r}),t]})},X=1e6;function st(e,t,n,r,i){let a=V(t,i);if(!a)return e;let o=e.find(e=>e.url===a);return[{url:a,title:H(n)||o?.title||``,lastVisitedAt:Math.max(r,o?.lastVisitedAt??0),visits:Math.min(X,(o?.visits??0)+1)},...e.filter(e=>e.url!==a)].slice(0,500)}function ct(e,t,n,r){let i=V(t,r),a=H(n);if(!i||!a)return e;let o=e.findIndex(e=>e.url===i);return o<0||e[o].title===a?e:e.map((e,t)=>t===o?{...e,title:a}:e)}function lt(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=V(t.url);if(!n)return null;let r=typeof t.lastVisitedAt==`number`&&Number.isSafeInteger(t.lastVisitedAt)?Math.max(0,t.lastVisitedAt):0,i=typeof t.visits==`number`&&Number.isSafeInteger(t.visits)?Math.min(X,Math.max(1,t.visits)):1;return{url:n,title:H(t.title),lastVisitedAt:r,visits:i}}function ut(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!t||typeof t!=`object`||Array.isArray(t))return[];let n=t;if(n.version!==1||!Array.isArray(n.entries))return[];let r=new Map;for(let e of n.entries.slice(0,1e3)){let t=lt(e);if(!t)continue;let n=r.get(t.url);n?r.set(t.url,{url:t.url,title:(n.lastVisitedAt>=t.lastVisitedAt?n:t).title,lastVisitedAt:Math.max(n.lastVisitedAt,t.lastVisitedAt),visits:Math.min(X,n.visits+t.visits)}):r.set(t.url,t)}return[...r.values()].sort((e,t)=>t.lastVisitedAt-e.lastVisitedAt).slice(0,500)}function dt(e){let t=e.slice(0,500);if(!t.length)return null;let n=new TextEncoder,r=JSON.stringify({version:1,entries:t});for(;n.encode(r).byteLength>327680&&t.length;)t.splice(-Math.max(1,Math.ceil(t.length/10))),r=JSON.stringify({version:1,entries:t});return t.length?r:null}function ft(e,t){let n=new Date(t);n.setHours(0,0,0,0);let r=n.getTime(),i=new Date(n);i.setDate(i.getDate()-1);let a=new Date(n);a.setDate(a.getDate()-6);let o={today:[],yesterday:[],week:[],earlier:[]};for(let t of e)o[t.lastVisitedAt>=r?`today`:t.lastVisitedAt>=i.getTime()?`yesterday`:t.lastVisitedAt>=a.getTime()?`week`:`earlier`].push(t);return[`today`,`yesterday`,`week`,`earlier`].filter(e=>o[e].length).map(e=>({key:e,entries:o[e]}))}function pt(e){try{return new URL(e).host}catch{return e.slice(0,200)}}var mt=`pisper-browser-history`,ht=1e3,gt=()=>typeof window>`u`?void 0:window.location.origin,_t=ke(mt),Z=Oe(mt,ht);Z.noteStored(_t);var Q=()=>Z.schedule(()=>dt($.getState().entries)),$=a(e=>({entries:ut(_t),visit:(t,n=``)=>{let r=!1;e(e=>{let i=st(e.entries,t,n,Date.now(),gt());return r=i!==e.entries,r?{entries:i}:e}),r&&Q()},title:(t,n)=>{let r=!1;e(e=>{let i=ct(e.entries,t,n,gt());return r=i!==e.entries,r?{entries:i}:e}),r&&Q()},clear:()=>{e({entries:[]}),Q(),Z.flush()}}));function vt({onOpen:e}){let{t}=i(),n=$(e=>e.entries),[r,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(!1),c=(0,G.useRef)(null),l=t(`common:webPreview.history`),u={today:t(`common:webPreview.historyToday`),yesterday:t(`common:webPreview.historyYesterday`),week:t(`common:webPreview.historyWeek`),earlier:t(`common:webPreview.historyEarlier`)},d=r?ft(n,Date.now()):[];return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(me,{open:r,onOpenChange:a,children:[(0,K.jsx)(fe,{asChild:!0,children:(0,K.jsx)(I,{ref:c,type:`button`,variant:`ghost`,size:`icon`,"aria-label":l,title:l,children:(0,K.jsx)(M,{size:14})})}),(0,K.jsx)(pe,{align:`end`,className:`w-80 gap-0 p-0`,children:n.length?(0,K.jsxs)(Se,{className:`bg-transparent`,children:[(0,K.jsx)(ve,{placeholder:t(`common:webPreview.historySearch`)}),(0,K.jsxs)(be,{className:`max-h-80`,children:[(0,K.jsx)(ye,{className:`py-0`,children:(0,K.jsx)(z,{compact:!0,title:t(`common:webPreview.historyNoMatch`)})}),d.map(t=>(0,K.jsx)(xe,{heading:u[t.key],children:t.entries.map(t=>{let n=pt(t.url);return(0,K.jsx)(_e,{value:t.url,keywords:t.title?[t.title]:void 0,title:t.url,onSelect:()=>{a(!1),e(t.url)},children:(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,K.jsx)(`span`,{className:`truncate`,children:t.title||n}),(0,K.jsx)(`span`,{className:`truncate text-xs text-content-muted`,children:n})]})},t.url)})},t.key))]}),(0,K.jsx)(`div`,{className:`border-t border-stroke-soft p-1`,children:(0,K.jsxs)(I,{type:`button`,variant:`ghost`,size:`sm`,className:`w-full justify-start text-danger`,onClick:()=>{a(!1),s(!0)},children:[(0,K.jsx)(N,{size:14}),t(`common:webPreview.clearHistory`)]})})]}):(0,K.jsx)(z,{compact:!0,icon:M,title:t(`common:webPreview.historyEmpty`)})})]}),(0,K.jsx)(de,{open:o,onOpenChange:s,children:(0,K.jsxs)(oe,{onCloseAutoFocus:e=>{e.preventDefault(),c.current?.focus()},children:[(0,K.jsxs)(ue,{children:[(0,K.jsx)(ae,{children:t(`common:webPreview.clearHistoryTitle`)}),(0,K.jsx)(ie,{children:t(`common:webPreview.clearHistoryDescription`)})]}),(0,K.jsxs)(ce,{children:[(0,K.jsx)(le,{children:t(`common:ui.cancel`)}),(0,K.jsx)(se,{variant:`destructive`,onClick:()=>$.getState().clear(),children:t(`common:webPreview.clearHistoryConfirm`)})]})]})})]})}function yt(e){let t=window.pisperDesktop;return!t||!/Windows|Macintosh/.test(navigator.userAgent)?null:t.browser?e?`failed`:null:`outdated`}function bt({sessionId:e,page:t,onChange:n,onClosed:r}){let{t:a}=i(),{draft:o,url:s}=t,[u,d]=(0,G.useState)(!1),f=(0,G.useRef)(``),p=e=>{!e||e===f.current||(f.current=e,$.getState().visit(e))},_=Pe({enabled:!!window.pisperDesktop?.browser,url:s,popupId:t.resourceId,keepAlive:t.agent,onNavigated:e=>{p(e),e!==s&&n(o===s?{url:e,draft:e}:{url:e})},onTitle:e=>{f.current&&$.getState().title(f.current,e),n({title:e})},onNewWindow:(t,n)=>Ae(e,t,n),onClosed:r}),v=yt(_.unavailable);return(0,G.useEffect)(()=>{_.active||!s||f.current===s||(f.current=s,$.getState().visit(s))},[_.active,s]),(0,K.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col gap-2 p-3`,"aria-label":a(`common:webPreview.title`),children:[(0,K.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault();let t=Y(o,window.location.href);d(!t),t&&n(t.kind===`search`?{url:t.url,draft:t.url}:{url:t.url})},children:[_.active&&(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center`,children:[(0,K.jsx)(I,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":a(`common:webPreview.back`),title:a(`common:webPreview.back`),onClick:()=>_.act(`back`),children:(0,K.jsx)(c,{size:14})}),(0,K.jsx)(I,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":a(`common:webPreview.forward`),title:a(`common:webPreview.forward`),onClick:()=>_.act(`forward`),children:(0,K.jsx)(l,{size:14})}),(0,K.jsx)(I,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":a(`common:webPreview.reload`),title:a(`common:webPreview.reload`),"aria-busy":_.loading,onClick:()=>_.act(`reload`),children:_.loading?(0,K.jsx)(k,{size:14,className:`animate-spin`}):(0,K.jsx)(Le,{size:14})})]}),(0,K.jsx)(R,{"aria-label":a(`common:webPreview.url`),className:`flex-1 font-mono`,value:o,onChange:e=>n({draft:e.target.value}),placeholder:a(`common:webPreview.urlPlaceholder`),maxLength:2048}),(0,K.jsx)(I,{type:`submit`,variant:`secondary`,children:a(`chat:sessionContext.openUrl`)}),(0,K.jsx)(vt,{onOpen:e=>n({url:e,draft:e})})]}),u&&(0,K.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:a(`chat:sessionContext.invalidUrl`)}),_.active?(0,K.jsx)(`div`,{ref:_.slotRef,role:`group`,"aria-label":a(`common:webPreview.title`),"aria-busy":_.loading,"data-native-browser-slot":!0,className:`min-h-0 flex-1 overflow-hidden rounded-md border border-stroke bg-background`}):s?(0,K.jsx)(at,{className:`min-h-0 flex-1 overflow-hidden rounded-md border-stroke`,defaultUrl:s,children:(0,K.jsx)(ot,{src:s,title:a(`common:webPreview.title`),...Me(s)?{sandbox:Ne}:{}})},s):(0,K.jsx)(z,{icon:h,className:`min-h-0 flex-1`,title:a(`chat:sessionContext.browserEmpty`)}),s&&(0,K.jsxs)(I,{type:`button`,variant:`ghost`,size:`sm`,className:`self-start`,onClick:()=>window.open(s,`_blank`,`noopener,noreferrer`),children:[(0,K.jsx)(g,{size:14}),a(`common:webPreview.openExternal`)]}),!_.active&&v&&s&&(0,K.jsxs)(Ee,{"data-native-browser-fallback":v,children:[(0,K.jsx)(re,{}),(0,K.jsxs)(Te,{className:`flex flex-col items-start gap-2`,children:[a(v===`outdated`?`common:webPreview.shellOutdated`:`common:webPreview.nativeFailed`),v===`outdated`&&(0,K.jsxs)(I,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>void window.pisperDesktop?.openReleases(),children:[(0,K.jsx)(m,{size:14}),a(`common:webPreview.downloadDesktop`)]})]})]}),!_.active&&!(v&&s)&&(0,K.jsx)(`p`,{className:`text-xs text-content-muted`,children:a(`common:webPreview.embedNotice`)})]})}export{Je as a,Ge as c,Xe as i,q as l,nt as n,qe as o,Y as r,Ke as s,bt as t,Ue as u};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitDiffViewer-DplIwM8m.js","assets/rolldown-runtime-B0Z9INg1.js","assets/vendor-react-DwNgTV1j.js","assets/use-i18n-BqDnJFL5.js","assets/i18n-C_TfFRc2.js","assets/vendor-router-CSN_DGvx.js","assets/index-DL89Jrzh.js","assets/index-PnQKlTEM.css","assets/storage-DtvZ_lEu.js","assets/vendor-state-GkUciC5H.js","assets/createLucideIcon-Cd-3GVxJ.js","assets/x-07u4-129.js","assets/utils-C8uzG5AZ.js","assets/vendor-ui-DvrYggeS.js","assets/button-CCcCN8tE.js","assets/dist-41X0pdUs.js","assets/events-CAivTGZK.js","assets/esm-DCV8yILT.js","assets/TaskTerminalView-CU-kjS_J.js","assets/square-terminal-BVG6cUT1.js","assets/square-bHHVTT3G.js","assets/PageState-Cz6vFMXv.js","assets/AppSelect-B15Hpk2W.js","assets/use-mobile-C2tPBAza.js","assets/select-DyBoNnz-.js","assets/check-2vYc6QaP.js","assets/chevron-down-CxtxIjiP.js","assets/chevron-up-D_ZcXjqr.js","assets/chevrons-up-down-C2sEPdAh.js","assets/dist-BsRXXcSL.js","assets/dist-BiRPwy4W.js","assets/dist-DzGQ7sLi.js","assets/es2015-DTZdOI9P.js","assets/dist-BRjj4UeB.js","assets/dist-OB2r6Xsr.js","assets/dist-BS3ekNDj.js","assets/terminal-context-aIsIJPn8.js","assets/TaskTerminalView-BrP-ENHg.css","assets/TaskProcessesPane-CkC-ZQos.js","assets/chevron-right-C3t2Rckj.js","assets/checkbox-BrEHgFV0.js","assets/FileAttachmentPreview-Cx6BlBm7.js","assets/api-BbBnrW3n.js","assets/abort-signal-f4JsiYKX.js","assets/http-response-DObpyFrX.js","assets/event-stream-BYSr6laS.js","assets/http-CMHs5x9g.js","assets/download-BCfIiuaL.js","assets/file-Bllajneu.js","assets/refresh-cw-TbWxTY4K.js","assets/tabs-DsgBuvJv.js","assets/dist-BaBySQmo.js","assets/format-DMJQzoZ7.js","assets/dialog-CW8GeCdI.js","assets/dist-BHkR6BLP.js","assets/MarkdownMessage-DylM7nUB.js","assets/vendor-markdown-plugins-CT5L3KA9.js","assets/vendor-shiki-runtime-DM7fm4Bl.js","assets/vendor-markdown-plugins-DEcVZfaU.css","assets/vendor-markdown-CT6Z4fh8.js","assets/copy-DHmIFc52.js","assets/route-context-DvWDul4T.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{h as t}from"./vendor-router-CSN_DGvx.js";import{i as n,r}from"./vendor-react-DwNgTV1j.js";import{t as i}from"./use-i18n-BqDnJFL5.js";import{o as a}from"./vendor-state-GkUciC5H.js";import{t as o}from"./useQuery-DfOU-27z.js";import{t as s}from"./createLucideIcon-Cd-3GVxJ.js";import{t as c}from"./arrow-left-B8oVrQ2S.js";import{t as l}from"./arrow-right-DqLOhpA2.js";import{t as u}from"./arrow-up-DST6-qVQ.js";import{t as d}from"./check-2vYc6QaP.js";import{t as f}from"./chevron-down-CxtxIjiP.js";import{t as p}from"./chevron-right-C3t2Rckj.js";import{t as m}from"./download-BCfIiuaL.js";import{t as h}from"./earth-Ddy13fHh.js";import{t as g}from"./external-link-CEQqPcqc.js";import{a as _}from"./GitDiffViewer-DplIwM8m.js";import{t as v}from"./file-Bllajneu.js";import{a as y,c as b,i as ee,o as x,r as S,s as C,y as w}from"./side-chat-context-DxeaaCWm.js";import{t as T}from"./git-branch-N7LGjtzt.js";import{y as E}from"./ChatMessage-Cb3Rzxbr.js";import{t as D}from"./image-BY_c3FYU.js";import{t as O}from"./link-2-mgasYn21.js";import{t as k}from"./loader-circle-BOwQzHB-.js";import{t as te}from"./message-square-SKjZyY3v.js";import{t as A}from"./pause-CYWpPg1R.js";import{t as j}from"./refresh-cw-TbWxTY4K.js";import{t as M}from"./rotate-ccw-clock-CO6Bw-sF.js";import{t as ne}from"./square-bHHVTT3G.js";import{t as N}from"./trash-2-CNrPOoPR.js";import{t as re}from"./triangle-alert-CE1q54ci.js";import"./collapsible-B-fc7n0u.js";import{a as ie,c as ae,i as oe,n as se,o as ce,r as le,s as ue,t as de}from"./alert-dialog-DiUitBB0.js";import{a as fe,r as pe,t as me}from"./popover-CPdjoO3T.js";import"./tooltip-D4MFbqcG.js";import{t as P}from"./utils-C8uzG5AZ.js";import{n as F,t as I}from"./button-CCcCN8tE.js";import{c as he,r as ge}from"./shortcuts-DsFEMyT1.js";import{t as L}from"./chat-api-BSs2idF4.js";import{a as _e,i as ve,n as ye,o as be,r as xe,t as Se}from"./command-Cb876BWo.js";import{t as R}from"./input-CPw-zkYh.js";import{n as Ce}from"./session-change-summary-api-Kcf7-e2G.js";import{n as we,t as z}from"./PageState-Cz6vFMXv.js";import{n as Te,t as Ee}from"./alert-DRIrgNI4.js";import{t as De}from"./AppSelect-B15Hpk2W.js";import{o as B}from"./session-tree-summary-C0dKEzZx.js";import{a as V,i as H,o as Oe,s as ke,t as Ae}from"./session-web-preview-DvDFSKV-.js";import{i as je,n as Me,r as U,t as Ne}from"./web-preview-C7DdG9JP.js";import{n as Pe}from"./useNativeBrowser-C0j3zafh.js";var Fe=s(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Ie=s(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),W=s(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),Le=s(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),G=e(n(),1),K=r(),Re={completed:`completed`,in_progress:`running`,paused:`pending`,blocked:`blocked`,pending:`pending`};function ze(e){let t=new Map(e.map(e=>[String(e.id||``),e])),n=e=>e?.status===`completed`;return e.map(e=>{let r=String(e.id||``),i=(Array.isArray(e.dependsOn)?e.dependsOn:[]).map(e=>t.get(String(e))).filter(e=>!!e&&!n(e)),a=e.status!==`completed`&&(e.status===`blocked`||i.length>0);return{...e,id:r,blocked:a,blockedBy:i}})}function Be({status:e,t}){let n=t(e===`completed`?`chat:planBoard.completed`:e===`in_progress`?`chat:planBoard.inProgress`:e===`paused`?`chat:planBoard.paused`:e===`blocked`?`chat:planBoard.blocked`:`chat:planBoard.pending`);return(0,K.jsxs)(`span`,{className:`plan-board-status grid size-[18px] flex-none place-items-center rounded-xs text-content-muted [&.completed]:bg-success-soft [&.completed]:text-success [&.running]:text-accent-fg [&.blocked]:bg-danger-soft [&.blocked]:text-danger ${Re[String(e)]||`pending`}`,title:n,children:[e===`completed`?(0,K.jsx)(d,{size:12,strokeWidth:2.25}):e===`in_progress`?(0,K.jsx)(F,{className:`size-3.5`}):e===`paused`?(0,K.jsx)(A,{size:11,strokeWidth:2}):e===`blocked`?(0,K.jsx)(W,{size:11,strokeWidth:2}):(0,K.jsx)(Fe,{size:11,strokeWidth:2}),(0,K.jsx)(`span`,{className:`sr-only`,children:n})]})}function Ve({item:e,current:t,running:n,t:r}){return(0,K.jsxs)(`li`,{className:`plan-board-row flex min-w-0 flex-col gap-[2px] rounded-sm px-[6px] py-[6px] aria-[current=step]:bg-surface-subtle ${e.blocked?`blocked`:``}`,"aria-current":t?`step`:void 0,"data-pisper-plan-current":t?`true`:void 0,"data-pisper-plan-id":e.id,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-[10px]`,children:[(0,K.jsx)(Be,{status:e.blocked?`blocked`:e.status===`in_progress`&&!n?`paused`:e.status,t:r}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] ${e.status===`completed`?`text-content-muted`:`text-foreground`}`,title:e.title,children:e.title}),e.assignee?(0,K.jsxs)(`span`,{className:`inline-flex max-w-[40%] flex-none items-center gap-[4px] truncate rounded-xs border border-stroke px-[6px] font-mono text-[12px] leading-[18px] text-content-secondary`,title:r(`chat:planBoard.assignedTo`,{name:e.assignee}),children:[(0,K.jsx)(w,{size:11,className:`flex-none`}),e.assignee]}):e.status!==`completed`&&(0,K.jsx)(`span`,{className:`flex-none text-[12px] text-content-muted`,children:r(`chat:planBoard.unassigned`)})]}),e.blockedBy.length>0&&(0,K.jsxs)(`div`,{className:`inline-flex min-w-0 items-center gap-[5px] pl-[28px] text-[12px] text-content-muted`,children:[(0,K.jsx)(W,{size:11,className:`flex-none`}),(0,K.jsx)(`span`,{className:`truncate`,children:r(`chat:planBoard.waitingFor`,{tasks:e.blockedBy.map(e=>e.title||e.id).join(` · `)})})]})]})}function He({plan:e,running:t,header:n,collapsible:r=!1}){let{t:a}=i(),o=(0,G.useRef)(null),[s,c]=(0,G.useState)(!0),l=e?.items||[],u=ze(l),d=u.filter(e=>e.status===`completed`).length,p=u.filter(e=>e.status===`in_progress`&&!e.blocked).length,m=u.filter(e=>e.blocked).length,h=u.find(e=>e.status===`in_progress`&&!e.blocked)?.id??u.find(e=>e.blocked)?.id??u.find(e=>e.status===`pending`)?.id??u.at(-1)?.id;if((0,G.useLayoutEffect)(()=>{if(r&&!s)return;let e=o.current,t=e?.querySelector(`[data-pisper-plan-current="true"]`);if(!e||!t)return;let n=e.getBoundingClientRect(),i=t.getBoundingClientRect();i.top<n.top?e.scrollTop-=n.top-i.top:i.bottom>n.bottom&&(e.scrollTop+=i.bottom-n.bottom)},[r,h,s,u.length]),!l.length)return null;let g=u.find(e=>e.id===h),_=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ie,{className:`flex-none text-content-muted`,size:15}),(0,K.jsx)(`strong`,{className:`tabular-nums`,children:a(`chat:planBoard.progress`,{completed:d,total:l.length})}),g?(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-content-secondary`,title:g.title,children:g.title}):null,(0,K.jsxs)(`span`,{className:`plan-board-counts inline-flex flex-none items-center gap-[8px] text-content-muted tabular-nums @max-[470px]:hidden`,children:[p>0&&(0,K.jsx)(`span`,{children:a(t?`chat:planBoard.countInProgress`:`chat:planBoard.countPaused`,{count:p})}),m>0&&(0,K.jsx)(`span`,{className:`blocked text-danger`,children:a(`chat:planBoard.countBlocked`,{count:m})})]}),n,r?(0,K.jsx)(f,{className:`plan-board-chevron flex-none text-content-muted transition-transform duration-(--d-fast) ease-precise [.plan-board-collapsible[open]_&]:rotate-180`,size:15}):null]}),v=(0,K.jsx)(`ul`,{ref:o,className:`plan-board-list [.plan-board-collapsible_>_&]:border-t [.plan-board-collapsible_>_&]:border-stroke-soft [.plan-board-collapsible_>_&]:p-[6px_8px_8px] m-0 flex list-none flex-col gap-[1px] pt-[6px]${u.length>4?` is-scrollable [.session-plan-popover_.plan-board-list&]:[block-size:min(250px,38dvh)] [.plan-board-list&]:[block-size:min(220px,34dvh)] [.plan-board-list&]:overflow-y-auto [.plan-board-list&]:[overscroll-behavior:contain] [.plan-board-list&]:pr-[4px] [.plan-board-list&]:[scrollbar-gutter:stable] [.plan-board-list&:focus-visible]:outline-2 [.plan-board-list&:focus-visible]:outline-focus [.plan-board-list&:focus-visible]:outline-offset-2`:``}`,tabIndex:u.length>4?0:void 0,children:u.map(e=>(0,K.jsx)(Ve,{running:t,item:e,current:e.id===h,t:a},e.id))});return r?(0,K.jsxs)(`details`,{className:`plan-board plan-board-collapsible m-[0_auto] flex w-[min(900px,100%)] flex-col overflow-hidden rounded-md border border-stroke bg-panel !p-0 [.session-plan-popover_&]:w-full [.session-plan-popover_&]:border-0 [.session-plan-popover_&]:bg-transparent`,open:s,onToggle:e=>c(e.currentTarget.open),children:[(0,K.jsx)(`summary`,{className:`plan-board-summary flex min-w-0 items-center gap-[8px] border-b border-stroke-soft pb-[8px] text-[13px] text-content-secondary [&_strong]:flex-none [&_strong]:font-medium [&_strong]:text-foreground [.plan-board-collapsible_>_&]:min-h-[34px] [.plan-board-collapsible_>_&]:cursor-pointer [.plan-board-collapsible_>_&]:list-none [.plan-board-collapsible_>_&]:border-0 [.plan-board-collapsible_>_&]:p-[6px_12px] max-[650px]:[.plan-board-collapsible_>_&]:min-h-11 [.plan-board-collapsible_>_&::-webkit-details-marker]:hidden [.plan-board-collapsible_>_&:hover]:bg-surface-subtle [.plan-board-collapsible_>_&:focus-visible]:outline-2 [.plan-board-collapsible_>_&:focus-visible]:-outline-offset-2 [.plan-board-collapsible_>_&:focus-visible]:outline-focus`,"aria-label":a(`chat:planBoard.toggleAriaLabel`),children:_}),v]}):(0,K.jsxs)(`section`,{className:`plan-board m-[0_auto] flex w-[min(900px,100%)] flex-col rounded-md border border-stroke bg-panel p-[10px_12px] [.session-plan-popover_&]:w-full [.session-plan-popover_&]:border-0 [.session-plan-popover_&]:bg-transparent [.session-plan-popover_&]:p-0`,"aria-label":a(`chat:planBoard.ariaLabel`),children:[(0,K.jsx)(`div`,{className:`plan-board-summary flex min-w-0 items-center gap-[8px] border-b border-stroke-soft pb-[8px] text-[13px] text-content-secondary [&_strong]:flex-none [&_strong]:font-medium [&_strong]:text-foreground [.plan-board-collapsible_>_&]:min-h-[34px] [.plan-board-collapsible_>_&]:cursor-pointer [.plan-board-collapsible_>_&]:list-none [.plan-board-collapsible_>_&]:border-0 [.plan-board-collapsible_>_&]:p-[6px_12px] max-[650px]:[.plan-board-collapsible_>_&]:min-h-11 [.plan-board-collapsible_>_&::-webkit-details-marker]:hidden [.plan-board-collapsible_>_&:hover]:bg-surface-subtle [.plan-board-collapsible_>_&:focus-visible]:outline-2 [.plan-board-collapsible_>_&:focus-visible]:-outline-offset-2 [.plan-board-collapsible_>_&:focus-visible]:outline-focus`,children:_}),v]})}var Ue=(0,G.memo)(He),We=(0,G.lazy)(()=>t(()=>import(`./GitDiffViewer-DplIwM8m.js`).then(e=>e.n).then(e=>({default:e.InlineGitDiff})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17])));function q({sessionId:e,path:t,scope:n,revision:r=0,position:a,onReading:s,mode:c,fill:l=!1}){let{t:u}=i(),d=o({queryKey:[`task-file-diff`,e,n,t,r],queryFn:({signal:r})=>n===`project`?L.getFileDiff(e,t,{signal:r}):L.getSessionFileChangeDiff(e,t,{signal:r})});return d.isPending?(0,K.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 px-3 py-2.5 text-xs text-content-muted`,children:[(0,K.jsx)(F,{className:`size-3.5`}),u(`chat:focusSession.gitLoading`)]}):d.isError?(0,K.jsxs)(`div`,{className:`px-3 py-2.5`,children:[(0,K.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:d.error.message}),(0,K.jsx)(I,{variant:`ghost`,size:`sm`,onClick:()=>void d.refetch(),children:u(`chat:chatMessage.filePreviewRetry`)})]}):(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(We,{position:a,onReading:s,diff:d.data.diff,truncated:d.data.diffTruncated,mode:c,fill:l})})}function Ge({sessionId:e,cwd:t,streaming:n,view:r,onViewChange:a}){let{t:s}=i(),c=o({queryKey:[`task-project-changes`,e,t,n],queryFn:({signal:t})=>L.getVcsChanges(e,{signal:t})}),l=_(r.reading?.list,e=>a({reading:{...r.reading,list:e}})),u=(0,G.useMemo)(()=>C(c.data?.diff||``,c.data?.files.map(e=>e.path)||[],c.data?.diffTruncated),[c.data]),d=r.expandedFiles.filter(e=>c.data&&!c.data.files.some(t=>t.path===e)),f=c.error?.message||c.data?.error,m=c.data?.files||[];return(0,K.jsxs)(`section`,{"aria-label":s(`chat:workbench.projectChanges`),className:`flex min-h-0 flex-1 flex-col`,children:[(0,K.jsxs)(`header`,{className:`flex min-h-10 min-w-0 shrink-0 items-center gap-2 border-b border-stroke-soft pr-1.5 pl-3`,children:[(0,K.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-xs font-medium tracking-[.02em] text-content-muted`,children:s(`chat:workbench.projectChanges`)}),c.data?.isRepo&&!f&&(0,K.jsxs)(`span`,{className:`shrink-0 font-mono text-xs tabular-nums`,children:[(0,K.jsxs)(`span`,{className:`text-success`,children:[`+`,u.added]}),` `,(0,K.jsxs)(`span`,{className:`text-danger`,children:[`−`,u.removed]})]}),(0,K.jsx)(I,{variant:`ghost`,size:`icon`,className:`max-[650px]:size-11`,"aria-label":s(`chat:focusSession.gitRefresh`),disabled:c.isFetching,onClick:()=>void c.refetch(),children:(0,K.jsx)(j,{size:15,className:c.isFetching?`animate-spin`:void 0})})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 border-b border-stroke-soft px-3 py-2.5`,children:[(0,K.jsx)(`p`,{className:`text-xs leading-relaxed text-content-muted`,children:s(`chat:workbench.projectScope`)}),(0,K.jsxs)(`p`,{className:`flex min-w-0 items-center gap-1.5 text-xs`,title:t,children:[c.data?.branch&&(0,K.jsxs)(`span`,{className:`inline-flex h-5.5 max-w-[45%] shrink-0 items-center gap-1 rounded-xs border border-stroke px-1.5 font-mono text-content-secondary`,children:[(0,K.jsx)(T,{size:12,className:`shrink-0`,"aria-hidden":`true`}),(0,K.jsx)(`span`,{className:`truncate`,children:c.data.branch})]}),(0,K.jsx)(`span`,{className:`min-w-0 truncate font-mono text-content-muted`,children:t})]}),(0,K.jsxs)(`div`,{className:`flex gap-1`,children:[(0,K.jsx)(I,{variant:`ghost`,size:`sm`,disabled:!m.length||!!f,onClick:()=>a({expandedFiles:m.map(e=>e.path)}),children:s(`chat:workbench.expandAll`)}),(0,K.jsx)(I,{variant:`ghost`,size:`sm`,onClick:()=>a({expandedFiles:[]}),children:s(`chat:workbench.collapseAll`)})]})]}),!c.isFetching&&!f&&d.map(e=>(0,K.jsx)(`p`,{role:`status`,className:`break-all px-3 pt-2 text-xs text-content-muted`,children:s(`chat:workbench.fileNoLongerChanged`,{path:e})},e)),c.isPending?(0,K.jsx)(we,{kind:`loading`,title:s(`chat:focusSession.gitLoading`)}):f?(0,K.jsx)(`p`,{role:`alert`,className:`p-3 text-sm text-danger`,children:f}):c.data?.isRepo?m.length?(0,K.jsx)(`div`,{ref:l.ref,className:`min-h-0 flex-1 overflow-y-auto`,children:m.map(t=>{let n=r.expandedFiles.includes(t.path);return(0,K.jsxs)(`article`,{className:`border-b border-stroke-soft`,children:[(0,K.jsxs)(`button`,{"aria-expanded":n,title:t.path,className:`flex min-h-9 w-full min-w-0 items-center gap-2 pr-3 pl-2 text-left text-sm hover:bg-surface-subtle focus-visible:-outline-offset-2 max-[650px]:min-h-11 pointer-coarse:min-h-11 ${n?`bg-surface-subtle`:``}`,onClick:()=>a({expandedFiles:n?r.expandedFiles.filter(e=>e!==t.path):[...r.expandedFiles,t.path]}),children:[(0,K.jsx)(p,{size:14,className:`shrink-0 text-content-muted transition-transform duration-(--d-fast) ${n?`rotate-90`:``}`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:t.path}),(0,K.jsx)(`span`,{className:`min-w-4 shrink-0 text-center font-mono text-xs font-medium text-content-secondary`,children:t.status}),Object.hasOwn(u.files,t.path)&&(0,K.jsxs)(`span`,{className:`shrink-0 font-mono text-xs tabular-nums`,children:[(0,K.jsxs)(`span`,{className:`text-success`,children:[`+`,u.files[t.path].added]}),` `,(0,K.jsxs)(`span`,{className:`text-danger`,children:[`−`,u.files[t.path].removed]})]})]}),n&&(0,K.jsx)(`p`,{className:`break-all px-3 py-1.5 font-mono text-xs text-content-muted`,children:t.path}),n&&(0,K.jsx)(q,{sessionId:e,path:t.path,scope:`project`,position:r.reading?.[t.path],onReading:e=>a({reading:{...r.reading,[t.path]:e}}),revision:c.dataUpdatedAt})]},t.path)})}):(0,K.jsx)(z,{compact:!0,title:s(`chat:focusSession.fileChangesEmpty`)}):(0,K.jsx)(z,{compact:!0,title:s(`chat:workbench.notRepository`)})]})}function J(e){return e instanceof Error?e.message:String(e)}function Ke({sessionId:e,streaming:t,requestConfirm:n}){let{t:r}=i(),[a,o]=(0,G.useState)(0),[s,c]=(0,G.useState)(0),[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(!0),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(``),[_,v]=(0,G.useState)(``),[y,b]=(0,G.useState)(null),[ee,x]=(0,G.useState)(null),[S,C]=(0,G.useState)(null),w=(0,G.useRef)(!1),T=(0,G.useRef)(0),E=(0,G.useRef)(0),D=(0,G.useRef)(!0),O=(0,G.useRef)(!1),k=(0,G.useRef)(t);return(0,G.useLayoutEffect)(()=>{k.current=t},[t]),(0,G.useLayoutEffect)(()=>(w.current=!0,()=>{w.current=!1,T.current+=1,E.current+=1}),[]),(0,G.useEffect)(()=>{let t=++T.current;return E.current+=1,x(null),C(null),D.current=!0,f(!0),m(``),L.getSessionFileChanges(e).then(e=>{w.current&&t===T.current&&(u(e),c(e=>e+1))},e=>{w.current&&t===T.current&&m(J(e))}).finally(()=>{w.current&&t===T.current&&(D.current=!1,f(!1))}),()=>{T.current+=1}},[a,e,t]),{changes:l,loading:d,error:p,actionError:h,notice:_,running:y,diff:ee,setDiff:x,diffLoading:S,snapshotRevision:s,writesDisabled:d||t||!!y||!!p||!l,pendingCount:l?.summary.pending||0,reversibleCount:l?.files.filter(e=>e.canRevert&&!e.reverted).length||0,displayedError:h||p,viewDiff:async t=>{if(O.current||D.current)return;let n=++E.current;C(t),g(``);try{let i=await L.getSessionFileChangeDiff(e,t);if(!w.current||n!==E.current)return;if(!i.diff?.trim()){g(r(`chat:focusSession.fileChangesNoSnapshot`));return}x({diff:i.diff,truncated:!!i.diffTruncated})}catch(e){w.current&&n===E.current&&g(J(e))}finally{w.current&&n===E.current&&C(null)}},runAction:async t=>{if(!w.current||O.current||D.current||k.current||!l||p||!l.files.filter(e=>t.kind===`approve`?e.pending&&!e.approved&&!e.reverted:e.canRevert&&!e.reverted).some(e=>t.path===void 0||e.path===t.path))return;O.current=!0,b(t),g(``),v(``);let i=++T.current;E.current+=1,x(null),C(null);let a=!1;try{if(t.kind===`revert`&&!await n({title:t.path?r(`chat:focusSession.fileChangesRevertFile`):r(`chat:focusSession.fileChangesRevertAll`),message:t.path?r(`chat:focusSession.fileChangesRevertFileDescription`,{path:t.path}):r(`chat:focusSession.fileChangesRevertAllDescription`),confirmLabel:r(`chat:focusSession.fileChangesConfirmRevert`),tone:`danger`})||!w.current||k.current||D.current||i!==T.current)return;a=!0;let o=t.kind===`approve`?await L.approveSessionFileChanges(e,t.path):await L.revertSessionFileChanges(e,t.path);if(Ce(e),!w.current||i!==T.current)return;u(o),t.kind===`approve`?v(t.path?r(`chat:focusSession.fileChangesApproved`):r(`chat:focusSession.fileChangesApproveDone`)):o.reverted?t.path===void 0&&o.files.some(e=>e.pending)?v(r(`chat:focusSession.fileChangesRevertPartial`,{count:o.reverted})):v(r(`chat:focusSession.fileChangesRevertDone`)):v(r(`chat:focusSession.fileChangesRevertUnavailable`))}catch(e){w.current&&i===T.current&&g(J(e))}finally{O.current=!1,w.current&&(b(null),a&&(D.current=!0,f(!0),o(e=>e+1)))}},refresh:()=>{D.current=!0,f(!0),g(``),o(e=>e+1)}}}var qe=(0,G.lazy)(()=>t(()=>import(`./TaskTerminalView-CU-kjS_J.js`).then(e=>({default:e.TaskTerminalView})),__vite__mapDeps([18,1,2,3,4,5,6,7,8,9,19,10,20,14,13,15,12,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37]))),Je=(0,G.lazy)(()=>t(()=>import(`./TaskProcessesPane-CkC-ZQos.js`).then(e=>({default:e.TaskProcessesPane})),__vite__mapDeps([38,1,2,3,4,5,6,7,8,9,39,10,19,20,40,25,15,29,34,12,13,14,21,22,23,24,26,27,28,30,31,32,33,35,36]))),Ye=(0,G.lazy)(()=>t(()=>import(`./FileAttachmentPreview-Cx6BlBm7.js`).then(e=>e.n).then(e=>({default:e.FileAttachmentPreview})),__vite__mapDeps([41,1,2,3,4,5,6,7,8,9,42,43,44,45,46,47,10,48,49,11,50,13,29,15,31,51,12,14,52,53,54,32,55,56,57,58,59,25,60,61])));function Xe({sources:e,view:t,onViewChange:n}){let{t:r}=i(),a=_(t.reading?.list,e=>n({reading:{...t.reading,list:e}})),o=(0,G.useContext)(b),[s,c]=(0,G.useState)(``),l=(0,G.useRef)(null),u=e.find(e=>e.id===s),d=e.filter(e=>(!t.filter||e.kind===t.filter)&&e.name.toLocaleLowerCase().includes(t.query.toLocaleLowerCase()));return(0,K.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,"aria-label":r(`chat:workbench.sources`),children:[(0,K.jsxs)(`header`,{className:`flex min-h-10 min-w-0 shrink-0 items-center gap-2 border-b border-stroke-soft pr-1.5 pl-3`,children:[(0,K.jsxs)(`h2`,{className:`min-w-0 flex-1 truncate text-xs font-medium tracking-[.02em] text-content-muted`,children:[r(`chat:workbench.sources`),(0,K.jsx)(`span`,{className:`ml-1.5 tabular-nums`,children:e.length})]}),(0,K.jsx)(`span`,{className:`shrink-0 text-xs text-content-muted`,children:r(`chat:workbench.addSource`)}),(0,K.jsx)(`div`,{ref:o?.setSourceActionHost,className:`grid min-h-7 min-w-7 place-items-center`})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 border-b border-stroke-soft px-3 py-2.5`,children:[(0,K.jsx)(`p`,{className:`text-xs leading-relaxed text-content-muted`,children:r(`chat:workbench.sourcesScope`)}),(0,K.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,K.jsx)(R,{className:`min-w-0 flex-1`,"aria-label":r(`chat:workbench.searchSources`),placeholder:r(`chat:workbench.searchSources`),value:t.query,onChange:e=>n({query:e.target.value})}),(0,K.jsxs)(De,{"aria-label":r(`chat:workbench.sourceType`),className:`w-auto max-w-[45%] shrink-0`,value:t.filter,onChange:e=>n({filter:e.target.value}),children:[(0,K.jsx)(`option`,{value:``,children:r(`chat:workbench.allTypes`)}),(0,K.jsx)(`option`,{value:`image`,children:r(`chat:workbench.images`)}),(0,K.jsx)(`option`,{value:`text`,children:r(`chat:workbench.text`)}),(0,K.jsx)(`option`,{value:`file`,children:r(`chat:workbench.files`)})]})]})]}),(0,K.jsxs)(`div`,{ref:a.ref,className:`min-h-0 flex-1 overflow-y-auto`,children:[!d.length&&(0,K.jsx)(z,{compact:!0,title:e.length?r(`chat:workbench.noMatches`):r(`chat:workbench.noSources`)}),d.map(e=>{let i=t.selectedSourceId===e.id,a=e.kind===`image`?D:e.method===`path`?O:v;return(0,K.jsxs)(`article`,{className:`border-b border-stroke-soft`,children:[(0,K.jsxs)(`button`,{className:`flex min-h-9 w-full min-w-0 items-center gap-2 px-2 text-left hover:bg-surface-subtle focus-visible:-outline-offset-2 max-[650px]:min-h-11 pointer-coarse:min-h-11 ${i?`bg-surface-subtle`:``}`,"aria-expanded":i,onClick:()=>n({selectedSourceId:i?``:e.id}),children:[(0,K.jsx)(p,{size:14,className:`shrink-0 text-content-muted transition-transform duration-(--d-fast) ${i?`rotate-90`:``}`}),(0,K.jsx)(a,{className:`size-3.5 shrink-0 text-content-muted`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:e.name||r(`chat:chatMessage.fileAttachment`)})]}),i&&(0,K.jsxs)(`div`,{className:`space-y-1.5 border-t border-stroke-soft bg-code py-2.5 pr-3 pl-8 text-xs text-content-muted`,children:[(0,K.jsx)(`p`,{className:`break-all font-mono text-content-secondary`,children:e.attachment.path||e.attachment.id||r(`chat:workbench.unavailable`)}),(0,K.jsx)(`p`,{className:`font-mono`,children:e.attachment.mimeType||`application/octet-stream`}),(0,K.jsx)(`p`,{children:e.method===`asset`?r(`chat:workbench.registeredAsset`):e.method===`path`?r(`chat:workbench.pathReference`):r(`chat:workbench.invalidReference`)}),(0,K.jsx)(I,{variant:`secondary`,size:`sm`,className:`mt-1`,disabled:!e.available,onClick:t=>{l.current=t.currentTarget,c(e.id)},children:r(`chat:chatMessage.fileActionPreview`)})]})]},e.id)})]}),u&&(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(Ye,{attachment:u.attachment,onClose:()=>c(``),onRestoreFocus:()=>l.current?.focus(),onDownload:()=>{typeof u.attachment.downloadUrl==`string`&&window.open(u.attachment.downloadUrl,`_blank`,`noopener,noreferrer`)}})})]})}var Ze=`https://www.bing.com/search?q=`;function Qe(e){let t=e.split(`.`);return t.length===4&&t.every(e=>/^\d{1,3}$/.test(e)&&Number(e)<=255)}function $e(e){let t=e.split(/[/?#]/,1)[0]??``;if(!t||t.includes(`@`))return null;if(t.startsWith(`[`))return/^\[[\da-f:.]+\](?::\d{1,5})?$/i.test(t)?t:null;let n=/^([^:]+)(?::(\d{1,5}))?$/.exec(t);return n?n[1]:null}function et(e){if(/\s/.test(e))return null;let t=$e(e);if(!t)return null;let n=t.toLowerCase();if(n.startsWith(`[`)||n===`localhost`||n.endsWith(`.localhost`)||Qe(n))return`local`;let r=n.split(`.`);if(r.length<2||r.some(e=>!/^[\p{L}\p{N}-]+$/u.test(e)))return null;let i=r[r.length-1];return/^(?:\p{L}{2,}|xn--[a-z\d-]+)$/u.test(i)?`public`:null}function tt(e){return`${Ze}${encodeURIComponent(e)}`}function Y(e,t){let n=e.trim();if(!n)return null;if(/^https?:/i.test(n)||n.startsWith(`//`)){let e=U(n,t);return e?{kind:`url`,url:e}:null}let r=et(n);if(r===`local`){let e=je(`http://${n}`,t)?.href;if(e)return{kind:`url`,url:e}}else if(r===`public`){let e=U(n,t);if(e)return{kind:`url`,url:e}}return{kind:`search`,url:tt(n)}}function nt({parentId:e,active:t}){let{t:n}=i(),{entry:r,runtime:a,load:o,setDraft:s}=S(e),c=r.session?.id??``,l=(0,G.useMemo)(()=>e=>a.subscribeSessionState(c,e),[a,c]),d=(0,G.useMemo)(()=>()=>a.getSessionState(c),[a,c]),f=(0,G.useSyncExternalStore)(l,d),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(``),b=(0,G.useRef)(!1),C=(0,G.useRef)(!1),w=(0,G.useRef)(r.draft);w.current=r.draft;let T=(0,G.useRef)(null),D=he(e=>e.bindings),O=ee(f,r.session);(0,G.useEffect)(()=>{t&&o(e)},[t,o,e]);let k=async t=>{t.preventDefault();let n=w.current.trim();if(!(!n||b.current||O||r.expired)){b.current=!0,m(!0),v(``);try{let t=await o(e,!r.session);if(!t?.session)return;let i=t.session.id;if(a.getSessionState(i).streaming)return;w.current.trim()===n&&s(e,``),m(!1),await a.send(i,n),await o(e)}catch(e){v(B(e))}finally{b.current=!1,m(!1)}}},A=(0,G.useCallback)(async()=>{if(!(!c||a.getSessionState(c).streaming)){v(``);try{await a.retry(c),await o(e)}catch(e){v(B(e))}}},[o,e,a,c]),j=async()=>{if(!(!c||h)){g(!0);try{v(``),await a.abort(c)}catch(e){v(B(e))}finally{g(!1)}}},M=(0,K.jsxs)(`div`,{className:`grid h-full min-h-36 place-content-center justify-items-center gap-2 px-3 text-center text-xs text-content-muted`,children:[(0,K.jsx)(`span`,{className:`mb-1 grid size-8 place-items-center rounded-md bg-key text-content-secondary shadow-key ring-1 ring-key-border`,children:(0,K.jsx)(te,{className:`size-4`,"aria-hidden":`true`})}),(0,K.jsx)(`p`,{className:`max-w-64 leading-relaxed`,children:r.expired?n(`chat:sideChat.expired`):n(`chat:sideChat.empty`)}),r.expired&&(0,K.jsxs)(I,{variant:`secondary`,size:`sm`,className:`mt-1`,disabled:r.loading,onClick:async()=>{(await o(e,!0))?.session&&T.current?.focus()},children:[r.loading&&(0,K.jsx)(F,{className:`size-3.5 text-current`}),n(`chat:sideChat.restart`)]})]}),N=_||r.error||f.error;return(0,K.jsxs)(`section`,{"data-side-chat-parent":e,"aria-label":n(`chat:sideChat.title`),className:`flex h-full min-h-0 min-w-0 flex-1 flex-col [container-type:inline-size]`,children:[(0,K.jsx)(`p`,{className:`shrink-0 border-b border-stroke-soft px-3 py-2 text-xs leading-relaxed text-content-muted`,children:n(`chat:sideChat.retention`)}),c?(0,K.jsx)(x,{sessionId:c,messages:f.messages,transcriptLoadState:f.loaded?`ready`:f.error?`error`:`loading`,emptyState:M,messageStart:f.messageStart,hasOlder:f.hasOlder,loadingOlder:f.loadingOlder,olderError:f.olderError,activityFeed:f.activityFeed,tools:f.tools,thinkingText:f.thinkingText,currentActivity:f.currentActivity,compaction:f.compaction,streaming:O,runStartedAt:f.runStartedAt,lastActivityAt:f.lastActivityAt,runFinishedAt:f.runFinishedAt,runStopped:f.runStopped,runNotice:f.runNotice,error:f.error,cwd:r.session?.cwd,onLoadOlder:()=>a.loadOlderMessages(c),onRetryLastTurn:A}):(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:M}),(0,K.jsxs)(`form`,{className:`flex shrink-0 flex-col gap-2 border-t border-stroke-soft p-3`,onSubmit:k,children:[N&&(0,K.jsx)(E,{error:N,onRetry:r.error||!f.loaded?async()=>{await o(e)}:A}),(0,K.jsx)(y,{approvals:f.approvals,onResolve:async(e,t)=>{try{await a.approve(c,e,t)}catch{}}}),(0,K.jsxs)(`div`,{className:`flex min-w-0 items-end gap-2 rounded-[var(--composer-radius,22px)] border border-control bg-panel py-2 pr-2 pl-3 shadow-composer transition-[border-color,box-shadow] duration-(--d-fast) focus-within:border-focus focus-within:ring-3 focus-within:ring-focus-ring`,children:[(0,K.jsx)(`textarea`,{ref:T,rows:2,value:r.draft,"aria-label":n(`chat:sideChat.message`),placeholder:n(`chat:sideChat.placeholder`),className:`max-h-40 min-h-14 min-w-0 flex-1 resize-y border-0 bg-transparent px-1 py-1 text-sm leading-relaxed text-content caret-focus outline-none placeholder:text-content-muted`,onChange:t=>s(e,t.target.value),onCompositionStart:()=>{C.current=!0},onCompositionEnd:()=>{C.current=!1},onKeyDown:e=>{!C.current&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229&&ge(e.nativeEvent,D.sendMessage)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}),(0,K.jsx)(I,{type:O?`button`:`submit`,size:`icon`,className:`size-8 shrink-0 rounded-full max-[650px]:size-11 pointer-coarse:size-11`,"aria-label":n(O?`chat:sideChat.stop`:`chat:sideChat.send`),disabled:O?h:p||r.loading||r.expired||!r.draft.trim(),onClick:O?()=>void j():void 0,children:p||h?(0,K.jsx)(F,{className:`size-4 text-current`}):O?(0,K.jsx)(ne,{size:13,fill:`currentColor`}):(0,K.jsx)(u,{size:17})})]})]})]})}var rt=(0,G.createContext)(null),it=()=>{let e=(0,G.useContext)(rt);if(!e)throw Error(`WebPreview components must be used within a WebPreview`);return e},at=({className:e,children:t,defaultUrl:n=``,onUrlChange:r,...i})=>{let[a,o]=(0,G.useState)(n),[s,c]=(0,G.useState)(!1),l=(0,G.useCallback)(e=>{o(e),r?.(e)},[r]),u=(0,G.useMemo)(()=>({consoleOpen:s,setConsoleOpen:c,setUrl:l,url:a}),[s,l,a]);return(0,K.jsx)(rt.Provider,{value:u,children:(0,K.jsx)(`div`,{className:P(`flex size-full min-h-0 flex-col rounded-lg border bg-card`,e),...i,children:t})})},ot=({className:e,loading:t,src:n,...r})=>{let{url:i}=it();return(0,K.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden bg-background`,children:[(0,K.jsx)(`iframe`,{className:P(`block size-full border-0 bg-background`,e),loading:`lazy`,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups allow-presentation`,src:(n??i)||void 0,title:`Preview`,...r}),t]})},X=1e6;function st(e,t,n,r,i){let a=V(t,i);if(!a)return e;let o=e.find(e=>e.url===a);return[{url:a,title:H(n)||o?.title||``,lastVisitedAt:Math.max(r,o?.lastVisitedAt??0),visits:Math.min(X,(o?.visits??0)+1)},...e.filter(e=>e.url!==a)].slice(0,500)}function ct(e,t,n,r){let i=V(t,r),a=H(n);if(!i||!a)return e;let o=e.findIndex(e=>e.url===i);return o<0||e[o].title===a?e:e.map((e,t)=>t===o?{...e,title:a}:e)}function lt(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=V(t.url);if(!n)return null;let r=typeof t.lastVisitedAt==`number`&&Number.isSafeInteger(t.lastVisitedAt)?Math.max(0,t.lastVisitedAt):0,i=typeof t.visits==`number`&&Number.isSafeInteger(t.visits)?Math.min(X,Math.max(1,t.visits)):1;return{url:n,title:H(t.title),lastVisitedAt:r,visits:i}}function ut(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!t||typeof t!=`object`||Array.isArray(t))return[];let n=t;if(n.version!==1||!Array.isArray(n.entries))return[];let r=new Map;for(let e of n.entries.slice(0,1e3)){let t=lt(e);if(!t)continue;let n=r.get(t.url);n?r.set(t.url,{url:t.url,title:(n.lastVisitedAt>=t.lastVisitedAt?n:t).title,lastVisitedAt:Math.max(n.lastVisitedAt,t.lastVisitedAt),visits:Math.min(X,n.visits+t.visits)}):r.set(t.url,t)}return[...r.values()].sort((e,t)=>t.lastVisitedAt-e.lastVisitedAt).slice(0,500)}function dt(e){let t=e.slice(0,500);if(!t.length)return null;let n=new TextEncoder,r=JSON.stringify({version:1,entries:t});for(;n.encode(r).byteLength>327680&&t.length;)t.splice(-Math.max(1,Math.ceil(t.length/10))),r=JSON.stringify({version:1,entries:t});return t.length?r:null}function ft(e,t){let n=new Date(t);n.setHours(0,0,0,0);let r=n.getTime(),i=new Date(n);i.setDate(i.getDate()-1);let a=new Date(n);a.setDate(a.getDate()-6);let o={today:[],yesterday:[],week:[],earlier:[]};for(let t of e)o[t.lastVisitedAt>=r?`today`:t.lastVisitedAt>=i.getTime()?`yesterday`:t.lastVisitedAt>=a.getTime()?`week`:`earlier`].push(t);return[`today`,`yesterday`,`week`,`earlier`].filter(e=>o[e].length).map(e=>({key:e,entries:o[e]}))}function pt(e){try{return new URL(e).host}catch{return e.slice(0,200)}}var mt=`pisper-browser-history`,ht=1e3,gt=()=>typeof window>`u`?void 0:window.location.origin,_t=ke(mt),Z=Oe(mt,ht);Z.noteStored(_t);var Q=()=>Z.schedule(()=>dt($.getState().entries)),$=a(e=>({entries:ut(_t),visit:(t,n=``)=>{let r=!1;e(e=>{let i=st(e.entries,t,n,Date.now(),gt());return r=i!==e.entries,r?{entries:i}:e}),r&&Q()},title:(t,n)=>{let r=!1;e(e=>{let i=ct(e.entries,t,n,gt());return r=i!==e.entries,r?{entries:i}:e}),r&&Q()},clear:()=>{e({entries:[]}),Q(),Z.flush()}}));function vt({onOpen:e}){let{t}=i(),n=$(e=>e.entries),[r,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(!1),c=(0,G.useRef)(null),l=t(`common:webPreview.history`),u={today:t(`common:webPreview.historyToday`),yesterday:t(`common:webPreview.historyYesterday`),week:t(`common:webPreview.historyWeek`),earlier:t(`common:webPreview.historyEarlier`)},d=r?ft(n,Date.now()):[];return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(me,{open:r,onOpenChange:a,children:[(0,K.jsx)(fe,{asChild:!0,children:(0,K.jsx)(I,{ref:c,type:`button`,variant:`ghost`,size:`icon`,"aria-label":l,title:l,children:(0,K.jsx)(M,{size:14})})}),(0,K.jsx)(pe,{align:`end`,className:`w-80 gap-0 p-0`,children:n.length?(0,K.jsxs)(Se,{className:`bg-transparent`,children:[(0,K.jsx)(ve,{placeholder:t(`common:webPreview.historySearch`)}),(0,K.jsxs)(be,{className:`max-h-80`,children:[(0,K.jsx)(ye,{className:`py-0`,children:(0,K.jsx)(z,{compact:!0,title:t(`common:webPreview.historyNoMatch`)})}),d.map(t=>(0,K.jsx)(xe,{heading:u[t.key],children:t.entries.map(t=>{let n=pt(t.url);return(0,K.jsx)(_e,{value:t.url,keywords:t.title?[t.title]:void 0,title:t.url,onSelect:()=>{a(!1),e(t.url)},children:(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,K.jsx)(`span`,{className:`truncate`,children:t.title||n}),(0,K.jsx)(`span`,{className:`truncate text-xs text-content-muted`,children:n})]})},t.url)})},t.key))]}),(0,K.jsx)(`div`,{className:`border-t border-stroke-soft p-1`,children:(0,K.jsxs)(I,{type:`button`,variant:`ghost`,size:`sm`,className:`w-full justify-start text-danger`,onClick:()=>{a(!1),s(!0)},children:[(0,K.jsx)(N,{size:14}),t(`common:webPreview.clearHistory`)]})})]}):(0,K.jsx)(z,{compact:!0,icon:M,title:t(`common:webPreview.historyEmpty`)})})]}),(0,K.jsx)(de,{open:o,onOpenChange:s,children:(0,K.jsxs)(oe,{onCloseAutoFocus:e=>{e.preventDefault(),c.current?.focus()},children:[(0,K.jsxs)(ue,{children:[(0,K.jsx)(ae,{children:t(`common:webPreview.clearHistoryTitle`)}),(0,K.jsx)(ie,{children:t(`common:webPreview.clearHistoryDescription`)})]}),(0,K.jsxs)(ce,{children:[(0,K.jsx)(le,{children:t(`common:ui.cancel`)}),(0,K.jsx)(se,{variant:`destructive`,onClick:()=>$.getState().clear(),children:t(`common:webPreview.clearHistoryConfirm`)})]})]})})]})}function yt(e){let t=window.pisperDesktop;return!t||!/Windows|Macintosh/.test(navigator.userAgent)?null:t.browser?e?`failed`:null:`outdated`}function bt({sessionId:e,page:t,onChange:n,onClosed:r}){let{t:a}=i(),{draft:o,url:s}=t,[u,d]=(0,G.useState)(!1),f=(0,G.useRef)(``),p=e=>{!e||e===f.current||(f.current=e,$.getState().visit(e))},_=Pe({enabled:!!window.pisperDesktop?.browser,url:s,popupId:t.resourceId,keepAlive:t.agent,onNavigated:e=>{p(e),e!==s&&n(o===s?{url:e,draft:e}:{url:e})},onTitle:e=>{f.current&&$.getState().title(f.current,e),n({title:e})},onNewWindow:(t,n)=>Ae(e,t,n),onClosed:r}),v=yt(_.unavailable);return(0,G.useEffect)(()=>{_.active||!s||f.current===s||(f.current=s,$.getState().visit(s))},[_.active,s]),(0,K.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col gap-2 p-3`,"aria-label":a(`common:webPreview.title`),children:[(0,K.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault();let t=Y(o,window.location.href);d(!t),t&&n(t.kind===`search`?{url:t.url,draft:t.url}:{url:t.url})},children:[_.active&&(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center`,children:[(0,K.jsx)(I,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":a(`common:webPreview.back`),title:a(`common:webPreview.back`),onClick:()=>_.act(`back`),children:(0,K.jsx)(c,{size:14})}),(0,K.jsx)(I,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":a(`common:webPreview.forward`),title:a(`common:webPreview.forward`),onClick:()=>_.act(`forward`),children:(0,K.jsx)(l,{size:14})}),(0,K.jsx)(I,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":a(`common:webPreview.reload`),title:a(`common:webPreview.reload`),"aria-busy":_.loading,onClick:()=>_.act(`reload`),children:_.loading?(0,K.jsx)(k,{size:14,className:`animate-spin`}):(0,K.jsx)(Le,{size:14})})]}),(0,K.jsx)(R,{"aria-label":a(`common:webPreview.url`),className:`flex-1 font-mono`,value:o,onChange:e=>n({draft:e.target.value}),placeholder:a(`common:webPreview.urlPlaceholder`),maxLength:2048}),(0,K.jsx)(I,{type:`submit`,variant:`secondary`,children:a(`chat:sessionContext.openUrl`)}),(0,K.jsx)(vt,{onOpen:e=>n({url:e,draft:e})})]}),u&&(0,K.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:a(`chat:sessionContext.invalidUrl`)}),_.active?(0,K.jsx)(`div`,{ref:_.slotRef,role:`group`,"aria-label":a(`common:webPreview.title`),"aria-busy":_.loading,"data-native-browser-slot":!0,className:`min-h-0 flex-1 overflow-hidden rounded-md border border-stroke bg-background`}):s?(0,K.jsx)(at,{className:`min-h-0 flex-1 overflow-hidden rounded-md border-stroke`,defaultUrl:s,children:(0,K.jsx)(ot,{src:s,title:a(`common:webPreview.title`),...Me(s)?{sandbox:Ne}:{}})},s):(0,K.jsx)(z,{icon:h,className:`min-h-0 flex-1`,title:a(`chat:sessionContext.browserEmpty`)}),s&&(0,K.jsxs)(I,{type:`button`,variant:`ghost`,size:`sm`,className:`self-start`,onClick:()=>window.open(s,`_blank`,`noopener,noreferrer`),children:[(0,K.jsx)(g,{size:14}),a(`common:webPreview.openExternal`)]}),!_.active&&v&&s&&(0,K.jsxs)(Ee,{"data-native-browser-fallback":v,children:[(0,K.jsx)(re,{}),(0,K.jsxs)(Te,{className:`flex flex-col items-start gap-2`,children:[a(v===`outdated`?`common:webPreview.shellOutdated`:`common:webPreview.nativeFailed`),v===`outdated`&&(0,K.jsxs)(I,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>void window.pisperDesktop?.openReleases(),children:[(0,K.jsx)(m,{size:14}),a(`common:webPreview.downloadDesktop`)]})]})]}),!_.active&&!(v&&s)&&(0,K.jsx)(`p`,{className:`text-xs text-content-muted`,children:a(`common:webPreview.embedNotice`)})]})}export{Je as a,Ge as c,Xe as i,q as l,nt as n,qe as o,Y as r,Ke as s,bt as t,Ue as u};
|