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.
Files changed (124) hide show
  1. package/package.json +5 -5
  2. package/web/.vite/manifest.json +691 -691
  3. package/web/assets/{AppDialog-B18LKxGz.js → AppDialog-OZpJxSBP.js} +1 -1
  4. package/web/assets/{AppOverlays-CVsIn893.js → AppOverlays-DBsxr-pZ.js} +1 -1
  5. package/web/assets/{AssetsPage-DTUqqVRZ.js → AssetsPage-H1OABD-M.js} +1 -1
  6. package/web/assets/{AttachmentTray-CdgiJGKL.js → AttachmentTray-BB89fdpQ.js} +1 -1
  7. package/web/assets/{BoardPage-C1zvNkyM.js → BoardPage-B2GIOdjF.js} +3 -3
  8. package/web/assets/{ChannelsPage-EXfbi1Uu.js → ChannelsPage-DJOprsIR.js} +1 -1
  9. package/web/assets/{ChatAppearancePage-BpHEGASI.js → ChatAppearancePage-BqY06fK8.js} +1 -1
  10. package/web/assets/{ChatHistoryPage-C-mJV9uR.js → ChatHistoryPage-N1OwflL6.js} +1 -1
  11. package/web/assets/{ChatMessage-CBGpmO8b.js → ChatMessage-Cb3Rzxbr.js} +3 -3
  12. package/web/assets/{ChatPage-AjVB1P4r.js → ChatPage-Di2pvZ7B.js} +3 -3
  13. package/web/assets/{ConfigPage-D7YSSKLJ.js → ConfigPage-Ba8yOTn6.js} +4 -4
  14. package/web/assets/{DesktopWindowControls-D_LAKbeD.js → DesktopWindowControls-Dgr7SBc9.js} +1 -1
  15. package/web/assets/{FeaturePage-DT8W4UlT.js → FeaturePage-xE563vuG.js} +1 -1
  16. package/web/assets/{FileAttachmentPreview-B9i02UCX.js → FileAttachmentPreview-Cx6BlBm7.js} +1 -1
  17. package/web/assets/{FloatingWidgets-CmBCqisu.js → FloatingWidgets-CWGdGGgQ.js} +1 -1
  18. package/web/assets/{FocusRuntimeControls-yUa6cOxD.js → FocusRuntimeControls-CoEB10QW.js} +1 -1
  19. package/web/assets/{GitDiffViewer-LK0S-bDi.js → GitDiffViewer-DplIwM8m.js} +1 -1
  20. package/web/assets/{ManageProjectsDialog-DPdZnbwA.js → ManageProjectsDialog-U8MUgrlm.js} +1 -1
  21. package/web/assets/{MarkdownMessage-CkLJFdr9.js → MarkdownMessage-DylM7nUB.js} +1 -1
  22. package/web/assets/{McpPage-DM00Xr9x.js → McpPage-BG-pc52d.js} +1 -1
  23. package/web/assets/{MemoryEvolution-D4AAcf9c.js → MemoryEvolution-DDiqR1FL.js} +1 -1
  24. package/web/assets/{MemoryPage-CtUzZ4-U.js → MemoryPage-B7zAKyaw.js} +2 -2
  25. package/web/assets/{MobileNavigation-BqPs-o2r.js → MobileNavigation-B9TLGML2.js} +1 -1
  26. package/web/assets/{MorePage-suAYgIS5.js → MorePage-D2qm09O6.js} +1 -1
  27. package/web/assets/{NewFolderDialog-kUUU6qCp.js → NewFolderDialog-CWpNgMKR.js} +1 -1
  28. package/web/assets/{PageHeader-BkPqAK50.js → PageHeader-DsZ5ehNL.js} +1 -1
  29. package/web/assets/{PhoneDrawer-BggePi7m.js → PhoneDrawer-sIG28Onx.js} +1 -1
  30. package/web/assets/{PhoneMenuButton-BOcCSFnH.js → PhoneMenuButton-DiDPv4NZ.js} +1 -1
  31. package/web/assets/{PhoneTopBar-IjowCATK.js → PhoneTopBar-DRQ5EQmK.js} +1 -1
  32. package/web/assets/{PluginsPage-CW9s28T1.js → PluginsPage-CKUCMJjh.js} +1 -1
  33. package/web/assets/{SafeModePrompt-cyd5YWlE.js → SafeModePrompt-OycVdcvt.js} +1 -1
  34. package/web/assets/{SchedulesPage-PTc_ojAJ.js → SchedulesPage-DsHGElm6.js} +1 -1
  35. package/web/assets/{SessionBrowserPane-CAJoHlNh.js → SessionBrowserPane-DGQsDUqd.js} +2 -2
  36. package/web/assets/{SessionContextPanel-CnMlSYsk.js → SessionContextPanel-CQXBX8HL.js} +2 -2
  37. package/web/assets/{SessionHome-1L6ETCUP.js → SessionHome-_X0M5GiH.js} +1 -1
  38. package/web/assets/{SessionInspector-DTvk3cYP.js → SessionInspector-C03rShQ1.js} +1 -1
  39. package/web/assets/{SessionShell-DCZjgm4_.js → SessionShell-Dsfvs_JW.js} +1 -1
  40. package/web/assets/{SettingsSidebar-FNMhjBah.js → SettingsSidebar-Bur_oRZx.js} +1 -1
  41. package/web/assets/{ShortcutHelpDialog-pFOsy2re.js → ShortcutHelpDialog-rAbhuzNm.js} +1 -1
  42. package/web/assets/{ShortcutKeys-BfiFGtIF.js → ShortcutKeys-DFKIS7Us.js} +1 -1
  43. package/web/assets/{SidebarUpdateStatus-BdfPkA-6.js → SidebarUpdateStatus-W1H_IFTb.js} +1 -1
  44. package/web/assets/{SkillsPage-CauQvPAH.js → SkillsPage-Cyg7klwt.js} +1 -1
  45. package/web/assets/{TaskProcessesPane-Kj4R2eFS.js → TaskProcessesPane-CkC-ZQos.js} +1 -1
  46. package/web/assets/{TaskTerminalView-CVBvmwIN.js → TaskTerminalView-CU-kjS_J.js} +1 -1
  47. package/web/assets/{TerminalPanel-BlaqYk_y.js → TerminalPanel-CL7C-bZ3.js} +1 -1
  48. package/web/assets/{WebDesktopPet-B524lpZ8.js → WebDesktopPet-Cc_B2Ihr.js} +1 -1
  49. package/web/assets/{WorkflowsPage-Dr0Mb-lj.js → WorkflowsPage-DExImPqA.js} +1 -1
  50. package/web/assets/{WorkspacePicker-BC-V-qKc.js → WorkspacePicker-Cd0QCRnc.js} +1 -1
  51. package/web/assets/{api-BA-WPJCg.js → api-BbBnrW3n.js} +1 -1
  52. package/web/assets/{app-update-AoFhnKr8.js → app-update-pRA7vtj3.js} +1 -1
  53. package/web/assets/{approval-confirm-B0nXB32b.js → approval-confirm-CLY2H0YG.js} +1 -1
  54. package/web/assets/{assets-api-Dw9uxhK9.js → assets-api-A0ZKJkf3.js} +1 -1
  55. package/web/assets/{board-projects-geCUCUov.js → board-projects-DHtEAHvu.js} +1 -1
  56. package/web/assets/{bots-store-CljyYMIo.js → bots-store-Br31qCcA.js} +1 -1
  57. package/web/assets/{chat-api-DixX49bK.js → chat-api-BSs2idF4.js} +1 -1
  58. package/web/assets/{client-store-JUgMl-Fs.js → client-store-C_ajzmyH.js} +1 -1
  59. package/web/assets/{command-Dugx8Xyc.js → command-Cb876BWo.js} +1 -1
  60. package/web/assets/{config-search-B5mtRMAH.js → config-search-DQ-bCU2h.js} +1 -1
  61. package/web/assets/{desktop-hosts-CLjxzh1F.js → desktop-hosts-qz2OZ5I1.js} +1 -1
  62. package/web/assets/{dialog-BfkdQrrN.js → dialog-CW8GeCdI.js} +1 -1
  63. package/web/assets/{event-stream-C1gqpD-D.js → event-stream-BYSr6laS.js} +1 -1
  64. package/web/assets/{events-BCP3T_26.js → events-CAivTGZK.js} +1 -1
  65. package/web/assets/{folder-paths-hX8Gx2zK.js → folder-paths-CYDY1W9R.js} +1 -1
  66. package/web/assets/{hosts-BqwTes2H.js → hosts-CdsdAvJs.js} +1 -1
  67. package/web/assets/{http-BJXYcBJZ.js → http-CMHs5x9g.js} +1 -1
  68. package/web/assets/{http-response-tU9Jgwk1.js → http-response-DObpyFrX.js} +1 -1
  69. package/web/assets/{i18n-BigTf78f.js → i18n-C_TfFRc2.js} +1 -1
  70. package/web/assets/{index-Cj4werSq.js → index-DL89Jrzh.js} +2 -2
  71. package/web/assets/{machine-messages-C5HnwFMY.js → machine-messages-BZFO3mNM.js} +1 -1
  72. package/web/assets/{machines-api-Bd73Uc9W.js → machines-api-Brwmi001.js} +1 -1
  73. package/web/assets/{memory-api-CizRSxek.js → memory-api-BsElJ4mL.js} +1 -1
  74. package/web/assets/{mount-app-BiyUP9uu.js → mount-app-DdYcKl3f.js} +3 -3
  75. package/web/assets/{permission-rules-api-D26h2i5i.js → permission-rules-api-pDaT7JHN.js} +1 -1
  76. package/web/assets/{pick-system-directory-j8yF4oD7.js → pick-system-directory-C4P5z66U.js} +1 -1
  77. package/web/assets/{placements-DaEYVBYS.js → placements-DY62NlQc.js} +2 -2
  78. package/web/assets/{popover-CYgt88Di.js → popover-CPdjoO3T.js} +1 -1
  79. package/web/assets/{public-fbSrYOz9.js → public--dz5MkXs.js} +2 -2
  80. package/web/assets/{public-uWGpE-xc.js → public-B3nCWERr.js} +1 -1
  81. package/web/assets/{public-DFbbN84l.js → public-BvZGd3OL.js} +1 -1
  82. package/web/assets/{public-CbGNOymN.js → public-CAdIUTea.js} +2 -2
  83. package/web/assets/{public-components-BxT4OWVf.js → public-components-BIhHhBwc.js} +1 -1
  84. package/web/assets/public-diff-Dha1wj7p.js +1 -0
  85. package/web/assets/public-events-CtLbk6Ps.js +1 -0
  86. package/web/assets/{public-flags-DtOWkThd.js → public-flags-CBzwNp70.js} +1 -1
  87. package/web/assets/{public-folder-dialog-BdoTA7R9.js → public-folder-dialog-Dmd5Qull.js} +1 -1
  88. package/web/assets/{public-greeting-WuolFgYD.js → public-greeting-lOuYNysY.js} +1 -1
  89. package/web/assets/{public-session-BHqubfWo.js → public-session-QlZ9_Zsb.js} +1 -1
  90. package/web/assets/{public-sidebar-Dy3GnDnb.js → public-sidebar-DsfBxQWb.js} +1 -1
  91. package/web/assets/{runtime-capabilities-store-CJA8-sSC.js → runtime-capabilities-store-aG2QVT6b.js} +1 -1
  92. package/web/assets/{safe-mode-instance-BdOJv29n.js → safe-mode-instance-HzaYIZf6.js} +1 -1
  93. package/web/assets/safe-mode-sentinel-DfoN8ker.js +1 -0
  94. package/web/assets/{session-change-summary-api-CvAF7fwO.js → session-change-summary-api-Kcf7-e2G.js} +1 -1
  95. package/web/assets/{session-home-DbvyzdI5.js → session-home-DOe7Q-qI.js} +1 -1
  96. package/web/assets/{session-inspector-store-C3ZsefJH.js → session-inspector-store-BolK9Mpy.js} +1 -1
  97. package/web/assets/{session-questions-DLgJUkQv.js → session-questions-l81YErJo.js} +1 -1
  98. package/web/assets/{session-scope-CFdEpHVY.js → session-scope-BCcnPOi0.js} +1 -1
  99. package/web/assets/{session-tree-actions-CYj1yPgQ.js → session-tree-actions-DHSmxj_g.js} +1 -1
  100. package/web/assets/{session-tree-summary-BeUnCg9w.js → session-tree-summary-C0dKEzZx.js} +1 -1
  101. package/web/assets/{session-web-preview-DfdZezsZ.js → session-web-preview-DvDFSKV-.js} +1 -1
  102. package/web/assets/{shortcuts-Cth0vc77.js → shortcuts-DsFEMyT1.js} +1 -1
  103. package/web/assets/{side-chat-context-D0zsA72l.js → side-chat-context-DxeaaCWm.js} +4 -4
  104. package/web/assets/{sidebar-vQzRTtRF.js → sidebar-CmpuB-ul.js} +1 -1
  105. package/web/assets/{sidebar-store-1-20GZhs.js → sidebar-store-BxHuw5mD.js} +1 -1
  106. package/web/assets/{speech-session-BpiqMMm5.js → speech-session-BXAj3OAY.js} +1 -1
  107. package/web/assets/{startup-queries-mAINlcNF.js → startup-queries-Cc9LSolC.js} +1 -1
  108. package/web/assets/{use-i18n-DL1_y_Ge.js → use-i18n-BqDnJFL5.js} +1 -1
  109. package/web/assets/{use-open-bot-CiF65aUO.js → use-open-bot-B_UFxUmd.js} +1 -1
  110. package/web/assets/{use-studio-actions-yGeYtIj_.js → use-studio-actions-BM3RKvXH.js} +1 -1
  111. package/web/assets/{useCatalogProjects-BBTryY8n.js → useCatalogProjects-BhW44QEx.js} +1 -1
  112. package/web/assets/{useMachines-DbkhDwVU.js → useMachines-Cv7VNdjI.js} +1 -1
  113. package/web/assets/{useNewProjectPicker-CW-ndILs.js → useNewProjectPicker-DRZ4v1BJ.js} +2 -2
  114. package/web/assets/{useNow-CyOr3v9y.js → useNow-tTW4r_Vo.js} +1 -1
  115. package/web/assets/{usePhoneShell-E0zpNbPD.js → usePhoneShell-iGegDaj2.js} +1 -1
  116. package/web/assets/{useSessionListQuery-CaaqoetW.js → useSessionListQuery-mhLtsKkB.js} +1 -1
  117. package/web/assets/{useSessionRowActions-BNWcYCP1.js → useSessionRowActions-UT3R_Cfq.js} +1 -1
  118. package/web/assets/{useSidebarModel-zw1ozcJm.js → useSidebarModel-D21Q54-Q.js} +1 -1
  119. package/web/assets/{workspace-folders-Cl8xGY9c.js → workspace-folders-CIuHDEZQ.js} +1 -1
  120. package/web/assets/{workspace-order-store-BlPd8HV9.js → workspace-order-store-Cv4TWT44.js} +1 -1
  121. package/web/index.html +1 -1
  122. package/web/assets/public-diff-L3aHU7Ip.js +0 -1
  123. package/web/assets/public-events-CIldV-8b.js +0 -1
  124. package/web/assets/safe-mode-sentinel-DiBJExnu.js +0 -1
@@ -1,4 +1,4 @@
1
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{f as t,m as n,n as r,r as i,u as a}from"./vendor-router-CSN_DGvx.js";import{i as o,r as s}from"./vendor-react-DwNgTV1j.js";import{f as c,h as l,r as u}from"./routes-BYsK6aeM.js";import{t as d}from"./use-i18n-DL1_y_Ge.js";import{a as f,t as p}from"./http-response-tU9Jgwk1.js";import{n as m}from"./http-BJXYcBJZ.js";import{t as h}from"./runtime-capabilities-store-CJA8-sSC.js";import{t as g}from"./usePhoneShell-E0zpNbPD.js";import{t as _}from"./createLucideIcon-Cd-3GVxJ.js";import{t as v}from"./arrow-down-CDGua-ue.js";import{t as y}from"./arrow-up-DST6-qVQ.js";import{t as b}from"./calendar-clock-VIxTaqqy.js";import{t as x}from"./check-2vYc6QaP.js";import{t as S}from"./chevron-down-CxtxIjiP.js";import{t as C}from"./chevron-left-BAtyp3_6.js";import{t as w}from"./chevron-right-C3t2Rckj.js";import{t as T}from"./copy-DHmIFc52.js";import{t as E}from"./ellipsis-CfGKfbq6.js";import{S as D,b as O,d as ee}from"./FocusRuntimeControls-yUa6cOxD.js";import{t as te}from"./WorkspacePicker-BC-V-qKc.js";import{t as ne}from"./folder-open-FIShC5Qk.js";import{n as k}from"./ChatMessage-CBGpmO8b.js";import{t as A}from"./undo-2-ChaURM4t.js";import{t as j}from"./message-circle-D-XrK6Ft.js";import{t as re}from"./monitor-ORxecA9m.js";import{t as ie}from"./panel-right-BSUtqUd8.js";import{t as ae}from"./paperclip-BCXrwYpb.js";import{t as M}from"./pencil-U08v_vV9.js";import{t as oe}from"./pin-CU0FG0lI.js";import{t as N}from"./plus-fQbSqB1n.js";import{C as se,D as P,E as F,O as I,S as L,T as ce,_ as R,a as z,b as le,c as ue,d as de,f as fe,g as pe,h as me,i as he,k as ge,m as _e,n as ve,o as B,p as ye,s as be,t as xe,u as Se,v as Ce,w as we,x as Te,y as Ee}from"./use-open-bot-CiF65aUO.js";import{t as De}from"./sparkles-S_eeuqn9.js";import{t as Oe}from"./square-bHHVTT3G.js";import{i as ke,r as Ae,t as je}from"./AttachmentTray-CdgiJGKL.js";import{t as Me}from"./trash-2-CNrPOoPR.js";import{t as Ne}from"./users-CCtFZzwl.js";import{t as Pe}from"./x-07u4-129.js";import{a as Fe,c as Ie,i as Le,n as Re,o as ze,r as Be,s as Ve,t as He}from"./alert-dialog-DiUitBB0.js";import{c as Ue,i as V,p as We,r as Ge,t as Ke}from"./dropdown-menu-Ds0gD8S8.js";import{n as qe,r as Je,t as Ye}from"./popover-CYgt88Di.js";import{t as H}from"./switch-D_G8wFhs.js";import{t as U}from"./segmented-control-xkrEOP_d.js";import{t as W}from"./utils-C8uzG5AZ.js";import{n as G,t as K}from"./button-CCcCN8tE.js";import{n as Xe,o as Ze,r as Qe,t as $e}from"./sheet-BTaIEX4w.js";import{T as et}from"./useSessionListQuery-CaaqoetW.js";import{i as tt,r as nt}from"./room-changes-DMfb5VNn.js";import{a as rt,o as it,t as at}from"./command-Dugx8Xyc.js";import{a as ot,i as st,l as ct,o as lt,s as ut,t as dt}from"./dialog-BfkdQrrN.js";import{t as q}from"./input-CPw-zkYh.js";import{t as ft}from"./textarea-DmATpOqT.js";import{t as pt}from"./model-display-kDwvtxrW.js";import"./public-CbGNOymN.js";import{t as mt}from"./pick-system-directory-j8yF4oD7.js";import{n as ht,t as gt}from"./PageState-Cz6vFMXv.js";import{n as _t}from"./field-DoLEb0np.js";import{n as vt,t as yt}from"./assets-api-Dw9uxhK9.js";import{t as bt}from"./MarkdownMessage-CkLJFdr9.js";import{a as xt,o as St,t as J}from"./BotAvatar-SFQi6bVG.js";import{t as Y}from"./AppSelect-B15Hpk2W.js";import{D as Ct,E as wt,M as Tt,O as Et,S as Dt,T as Ot,_ as kt,a as At,b as jt,d as Mt,f as Nt,g as Pt,h as Ft,i as It,j as Lt,k as Rt,l as zt,m as Bt,n as X,o as Vt,p as Ht,r as Ut,s as Wt,t as Gt,u as Kt,v as qt,w as Jt,x as Yt,y as Xt}from"./bots-store-CljyYMIo.js";import{t as Zt}from"./public-flags-DtOWkThd.js";import{n as Qt,t as Z}from"./SettingsRow-CT0AZ7re.js";import{t as $t}from"./chip-ZhnvFlFg.js";var en=_(`at-sign`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]),tn=_(`circle-dashed`,[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]),nn=_(`corner-up-left`,[[`path`,{d:`M20 20v-7a4 4 0 0 0-4-4H4`,key:`1nkjon`}],[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}]]),rn=_(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),an=_(`list-tree`,[[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`M3 10a2 2 0 0 0 2 2h3`,key:`1npucw`}],[`path`,{d:`M3 5v12a2 2 0 0 0 2 2h3`,key:`x1gjn2`}]]),on=_(`notebook-pen`,[[`path`,{d:`M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4`,key:`re6nr2`}],[`path`,{d:`M2 6h4`,key:`aawbzj`}],[`path`,{d:`M2 10h4`,key:`l0bgd4`}],[`path`,{d:`M2 14h4`,key:`1gsvsf`}],[`path`,{d:`M2 18h4`,key:`1bu2t1`}],[`path`,{d:`M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`pqwjuv`}]]),Q=e(o(),1),$=s();function sn({bot:e,initiallyOpen:t=!1,onDeleted:n,onError:r}){let{t:i}=d(),a=X(e=>e.remove),[o,s]=(0,Q.useState)(t),[c,l]=(0,Q.useState)(!1),u=async()=>{l(!0);try{await Mt(e.id),a(e.id),s(!1),n()}catch(e){r(e instanceof Error?e.message:String(e))}finally{l(!1)}};return(0,$.jsxs)(Qt,{title:i(`bots:delete.section`),className:`mt-4`,children:[(0,$.jsx)(Z,{title:i(`bots:delete.title`),description:i(`bots:delete.hint`),control:(0,$.jsxs)(K,{type:`button`,variant:`destructive`,size:`sm`,"data-bot-delete":e.id,onClick:()=>s(!0),children:[(0,$.jsx)(Me,{"aria-hidden":`true`}),i(`bots:delete.action`)]})}),(0,$.jsx)(He,{open:o,onOpenChange:e=>!c&&s(e),children:(0,$.jsxs)(Le,{children:[(0,$.jsxs)(Ve,{children:[(0,$.jsx)(Ie,{children:i(`bots:delete.confirmTitle`,{name:e.name})}),(0,$.jsx)(Fe,{children:i(`bots:delete.confirmDescription`)})]}),(0,$.jsxs)(ze,{children:[(0,$.jsx)(Be,{disabled:c,children:i(`common:ui.cancel`)}),(0,$.jsxs)(Re,{variant:`destructive`,disabled:c,onClick:e=>{e.preventDefault(),u()},children:[c&&(0,$.jsx)(G,{className:`text-current`}),i(`bots:delete.action`)]})]})]})})]})}function cn(e,t){return!t||t.kind===`local`?e(`bots:computer.local`):t.name||e(`bots:computer.unnamed`)}function ln(e,t){return[`npx pisper executor pair --brain ${e.remote.endpoints[0]||t.brain} --fingerprint ${e.remote.fingerprint||t.fingerprint} --code ${e.code} --root ${t.root}`,`npx pisper executor`]}function un({environment:e,onRemoved:t,onError:n}){let{t:r}=d(),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(!1),c=async()=>{s(!0);try{await Jt(e.id),t()}catch(e){n(e instanceof Error?e.message:String(e)),a(!1)}finally{s(!1)}};return(0,$.jsxs)(`li`,{"data-environment":e.id,className:`flex flex-col gap-1 py-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:W(`size-2 flex-none rounded-full`,e.online?`bg-success`:`bg-content-faint`)}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-content`,children:cn(r,e)}),(0,$.jsx)(`span`,{className:`text-xs text-content-muted`,children:e.online?r(`bots:computer.online`):r(`bots:computer.offline`)}),e.kind===`node`&&(i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{size:`sm`,variant:`ghost`,disabled:o,onClick:()=>a(!1),children:r(`bots:computer.cancel`)}),(0,$.jsx)(K,{size:`sm`,variant:`destructive`,disabled:o,onClick:()=>void c(),children:r(`bots:computer.confirmRemove`)})]}):(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:()=>a(!0),children:r(`bots:computer.remove`)}))]}),e.roots.length>0&&(0,$.jsx)(`p`,{className:`truncate pl-4 font-mono text-xs text-content-muted`,children:e.roots.join(` · `)}),e.usedBy.length>0&&(0,$.jsx)(`p`,{className:`pl-4 text-xs text-content-muted`,children:r(`bots:computer.usedBy`,{names:e.usedBy.map(e=>e.name).join(`、`)})})]})}function dn({pairing:e,onDone:t}){let{t:n}=d(),r=a(),[i,o]=(0,Q.useState)(!1),s=ln(e,{brain:n(`bots:computer.brainPlaceholder`),fingerprint:`SHA256:…`,root:n(`bots:computer.rootPlaceholder`)}),c=async()=>{try{await navigator.clipboard.writeText(s.join(`
1
+ import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{f as t,m as n,n as r,r as i,u as a}from"./vendor-router-CSN_DGvx.js";import{i as o,r as s}from"./vendor-react-DwNgTV1j.js";import{f as c,h as l,r as u}from"./routes-BYsK6aeM.js";import{t as d}from"./use-i18n-BqDnJFL5.js";import{a as f,t as p}from"./http-response-DObpyFrX.js";import{n as m}from"./http-CMHs5x9g.js";import{t as h}from"./runtime-capabilities-store-aG2QVT6b.js";import{t as g}from"./usePhoneShell-iGegDaj2.js";import{t as _}from"./createLucideIcon-Cd-3GVxJ.js";import{t as v}from"./arrow-down-CDGua-ue.js";import{t as y}from"./arrow-up-DST6-qVQ.js";import{t as b}from"./calendar-clock-VIxTaqqy.js";import{t as x}from"./check-2vYc6QaP.js";import{t as S}from"./chevron-down-CxtxIjiP.js";import{t as C}from"./chevron-left-BAtyp3_6.js";import{t as w}from"./chevron-right-C3t2Rckj.js";import{t as T}from"./copy-DHmIFc52.js";import{t as E}from"./ellipsis-CfGKfbq6.js";import{S as D,b as O,d as ee}from"./FocusRuntimeControls-CoEB10QW.js";import{t as te}from"./WorkspacePicker-Cd0QCRnc.js";import{t as ne}from"./folder-open-FIShC5Qk.js";import{n as k}from"./ChatMessage-Cb3Rzxbr.js";import{t as A}from"./undo-2-ChaURM4t.js";import{t as j}from"./message-circle-D-XrK6Ft.js";import{t as re}from"./monitor-ORxecA9m.js";import{t as ie}from"./panel-right-BSUtqUd8.js";import{t as ae}from"./paperclip-BCXrwYpb.js";import{t as M}from"./pencil-U08v_vV9.js";import{t as oe}from"./pin-CU0FG0lI.js";import{t as N}from"./plus-fQbSqB1n.js";import{C as se,D as P,E as F,O as I,S as L,T as ce,_ as R,a as z,b as le,c as ue,d as de,f as fe,g as pe,h as me,i as he,k as ge,m as _e,n as ve,o as B,p as ye,s as be,t as xe,u as Se,v as Ce,w as we,x as Te,y as Ee}from"./use-open-bot-B_UFxUmd.js";import{t as De}from"./sparkles-S_eeuqn9.js";import{t as Oe}from"./square-bHHVTT3G.js";import{i as ke,r as Ae,t as je}from"./AttachmentTray-BB89fdpQ.js";import{t as Me}from"./trash-2-CNrPOoPR.js";import{t as Ne}from"./users-CCtFZzwl.js";import{t as Pe}from"./x-07u4-129.js";import{a as Fe,c as Ie,i as Le,n as Re,o as ze,r as Be,s as Ve,t as He}from"./alert-dialog-DiUitBB0.js";import{c as Ue,i as V,p as We,r as Ge,t as Ke}from"./dropdown-menu-Ds0gD8S8.js";import{n as qe,r as Je,t as Ye}from"./popover-CPdjoO3T.js";import{t as H}from"./switch-D_G8wFhs.js";import{t as U}from"./segmented-control-xkrEOP_d.js";import{t as W}from"./utils-C8uzG5AZ.js";import{n as G,t as K}from"./button-CCcCN8tE.js";import{n as Xe,o as Ze,r as Qe,t as $e}from"./sheet-BTaIEX4w.js";import{T as et}from"./useSessionListQuery-mhLtsKkB.js";import{i as tt,r as nt}from"./room-changes-DMfb5VNn.js";import{a as rt,o as it,t as at}from"./command-Cb876BWo.js";import{a as ot,i as st,l as ct,o as lt,s as ut,t as dt}from"./dialog-CW8GeCdI.js";import{t as q}from"./input-CPw-zkYh.js";import{t as ft}from"./textarea-DmATpOqT.js";import{t as pt}from"./model-display-kDwvtxrW.js";import"./public-CAdIUTea.js";import{t as mt}from"./pick-system-directory-C4P5z66U.js";import{n as ht,t as gt}from"./PageState-Cz6vFMXv.js";import{n as _t}from"./field-DoLEb0np.js";import{n as vt,t as yt}from"./assets-api-A0ZKJkf3.js";import{t as bt}from"./MarkdownMessage-DylM7nUB.js";import{a as xt,o as St,t as J}from"./BotAvatar-SFQi6bVG.js";import{t as Y}from"./AppSelect-B15Hpk2W.js";import{D as Ct,E as wt,M as Tt,O as Et,S as Dt,T as Ot,_ as kt,a as At,b as jt,d as Mt,f as Nt,g as Pt,h as Ft,i as It,j as Lt,k as Rt,l as zt,m as Bt,n as X,o as Vt,p as Ht,r as Ut,s as Wt,t as Gt,u as Kt,v as qt,w as Jt,x as Yt,y as Xt}from"./bots-store-Br31qCcA.js";import{t as Zt}from"./public-flags-CBzwNp70.js";import{n as Qt,t as Z}from"./SettingsRow-CT0AZ7re.js";import{t as $t}from"./chip-ZhnvFlFg.js";var en=_(`at-sign`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]),tn=_(`circle-dashed`,[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]),nn=_(`corner-up-left`,[[`path`,{d:`M20 20v-7a4 4 0 0 0-4-4H4`,key:`1nkjon`}],[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}]]),rn=_(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),an=_(`list-tree`,[[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`M3 10a2 2 0 0 0 2 2h3`,key:`1npucw`}],[`path`,{d:`M3 5v12a2 2 0 0 0 2 2h3`,key:`x1gjn2`}]]),on=_(`notebook-pen`,[[`path`,{d:`M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4`,key:`re6nr2`}],[`path`,{d:`M2 6h4`,key:`aawbzj`}],[`path`,{d:`M2 10h4`,key:`l0bgd4`}],[`path`,{d:`M2 14h4`,key:`1gsvsf`}],[`path`,{d:`M2 18h4`,key:`1bu2t1`}],[`path`,{d:`M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`pqwjuv`}]]),Q=e(o(),1),$=s();function sn({bot:e,initiallyOpen:t=!1,onDeleted:n,onError:r}){let{t:i}=d(),a=X(e=>e.remove),[o,s]=(0,Q.useState)(t),[c,l]=(0,Q.useState)(!1),u=async()=>{l(!0);try{await Mt(e.id),a(e.id),s(!1),n()}catch(e){r(e instanceof Error?e.message:String(e))}finally{l(!1)}};return(0,$.jsxs)(Qt,{title:i(`bots:delete.section`),className:`mt-4`,children:[(0,$.jsx)(Z,{title:i(`bots:delete.title`),description:i(`bots:delete.hint`),control:(0,$.jsxs)(K,{type:`button`,variant:`destructive`,size:`sm`,"data-bot-delete":e.id,onClick:()=>s(!0),children:[(0,$.jsx)(Me,{"aria-hidden":`true`}),i(`bots:delete.action`)]})}),(0,$.jsx)(He,{open:o,onOpenChange:e=>!c&&s(e),children:(0,$.jsxs)(Le,{children:[(0,$.jsxs)(Ve,{children:[(0,$.jsx)(Ie,{children:i(`bots:delete.confirmTitle`,{name:e.name})}),(0,$.jsx)(Fe,{children:i(`bots:delete.confirmDescription`)})]}),(0,$.jsxs)(ze,{children:[(0,$.jsx)(Be,{disabled:c,children:i(`common:ui.cancel`)}),(0,$.jsxs)(Re,{variant:`destructive`,disabled:c,onClick:e=>{e.preventDefault(),u()},children:[c&&(0,$.jsx)(G,{className:`text-current`}),i(`bots:delete.action`)]})]})]})})]})}function cn(e,t){return!t||t.kind===`local`?e(`bots:computer.local`):t.name||e(`bots:computer.unnamed`)}function ln(e,t){return[`npx pisper executor pair --brain ${e.remote.endpoints[0]||t.brain} --fingerprint ${e.remote.fingerprint||t.fingerprint} --code ${e.code} --root ${t.root}`,`npx pisper executor`]}function un({environment:e,onRemoved:t,onError:n}){let{t:r}=d(),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(!1),c=async()=>{s(!0);try{await Jt(e.id),t()}catch(e){n(e instanceof Error?e.message:String(e)),a(!1)}finally{s(!1)}};return(0,$.jsxs)(`li`,{"data-environment":e.id,className:`flex flex-col gap-1 py-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:W(`size-2 flex-none rounded-full`,e.online?`bg-success`:`bg-content-faint`)}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-content`,children:cn(r,e)}),(0,$.jsx)(`span`,{className:`text-xs text-content-muted`,children:e.online?r(`bots:computer.online`):r(`bots:computer.offline`)}),e.kind===`node`&&(i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{size:`sm`,variant:`ghost`,disabled:o,onClick:()=>a(!1),children:r(`bots:computer.cancel`)}),(0,$.jsx)(K,{size:`sm`,variant:`destructive`,disabled:o,onClick:()=>void c(),children:r(`bots:computer.confirmRemove`)})]}):(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:()=>a(!0),children:r(`bots:computer.remove`)}))]}),e.roots.length>0&&(0,$.jsx)(`p`,{className:`truncate pl-4 font-mono text-xs text-content-muted`,children:e.roots.join(` · `)}),e.usedBy.length>0&&(0,$.jsx)(`p`,{className:`pl-4 text-xs text-content-muted`,children:r(`bots:computer.usedBy`,{names:e.usedBy.map(e=>e.name).join(`、`)})})]})}function dn({pairing:e,onDone:t}){let{t:n}=d(),r=a(),[i,o]=(0,Q.useState)(!1),s=ln(e,{brain:n(`bots:computer.brainPlaceholder`),fingerprint:`SHA256:…`,root:n(`bots:computer.rootPlaceholder`)}),c=async()=>{try{await navigator.clipboard.writeText(s.join(`
2
2
  `)),o(!0)}catch{o(!1)}};return(0,$.jsxs)(`section`,{"aria-label":n(`bots:computer.addTitle`),className:`mt-2 rounded-xl border border-stroke bg-surface-subtle p-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`h4`,{className:`font-semibold text-content`,children:n(`bots:computer.addTitle`)}),(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:t,children:n(`bots:computer.done`)})]}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-content-muted`,children:[n(`bots:computer.code`),` `,(0,$.jsx)(`b`,{"data-pairing-code":!0,className:`font-mono text-content`,children:e.code}),` `,`· `,n(`bots:computer.codeHint`)]}),!e.remote.enabled&&(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 rounded-lg border border-st-attn-border bg-surface-raised px-2.5 py-2 text-xs text-content-secondary`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:n(`bots:computer.remoteOff`)}),(0,$.jsx)(K,{size:`sm`,variant:`outline`,onClick:()=>r(`/config/remote-access`),children:n(`bots:computer.openRemote`)})]}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-content-muted`,children:n(`bots:computer.runThere`)}),(0,$.jsx)(`pre`,{className:`mt-1 max-h-40 overflow-auto rounded-lg bg-surface-raised p-2.5 font-mono text-xs whitespace-pre-wrap break-all text-content-secondary`,children:s.join(`
3
3
  `)}),(0,$.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-content-muted`,children:n(`bots:computer.rootHint`)}),(0,$.jsxs)(K,{size:`sm`,variant:`outline`,onClick:()=>void c(),children:[(0,$.jsx)(T,{"aria-hidden":`true`}),n(i?`bots:computer.copied`:`bots:computer.copy`)]})]})]})}function fn({bot:e,environments:t,onEnvironmentsChanged:n,onError:r}){let{t:i}=d(),a=X(e=>e.upsert),[o,s]=(0,Q.useState)(e.workspace.environmentId),[c,l]=(0,Q.useState)(e.workspace.cwd),[u,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{s(e.workspace.environmentId),l(e.workspace.cwd)},[e.id,e.workspace.environmentId,e.workspace.cwd]);let y=t.find(e=>e.id===o),b=o===`local`,x=o!==e.workspace.environmentId||c.trim()!==e.workspace.cwd,S=async t=>{g(!0);try{a(await wt(e.id,{workspace:{...e.workspace,...t}})),n()}catch(e){r(e instanceof Error?e.message:String(e))}finally{g(!1)}},C=async()=>{if(!u){if(!b){m(!0);return}f(!0);try{let t=await mt(c||e.workspace.cwd,i(`bots:computer.folder`));t.status===`picked`?l(t.path):t.status===`unavailable`&&m(!0)}catch(e){r(e instanceof Error?e.message:String(e))}finally{f(!1)}}},w=async()=>{try{v(await Kt())}catch(e){r(e instanceof Error?e.message:String(e))}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-xs text-content-muted`,children:i(`bots:computer.description`)}),(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm`,children:[(0,$.jsx)(`span`,{className:`flex-none`,children:i(`bots:computer.runsOn`)}),(0,$.jsxs)(Y,{value:o,className:`w-48`,"aria-label":i(`bots:computer.runsOn`),disabled:h,onChange:t=>{s(t.target.value),l(t.target.value===e.workspace.environmentId?e.workspace.cwd:``)},children:[t.length===0&&(0,$.jsx)(`option`,{value:`local`,children:i(`bots:computer.local`)}),t.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.kind===`local`?i(`bots:computer.local`):i(`bots:computer.option`,{name:cn(i,e),state:e.online?i(`bots:computer.online`):i(`bots:computer.offline`)})},e.id))]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-content-muted`,children:i(`bots:computer.folder`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(re,{className:`size-3.5 flex-none text-content-muted`,"aria-hidden":`true`}),(0,$.jsx)(q,{value:c,className:`font-mono text-xs`,"aria-label":i(`bots:computer.folder`),placeholder:b?i(`bots:computer.folderPlaceholder`):y?.roots[0]??i(`bots:computer.folderPlaceholder`),disabled:h,onChange:e=>l(e.target.value)}),(b||y)&&(0,$.jsx)(K,{size:`sm`,variant:`outline`,disabled:h||u,onClick:()=>void C(),children:i(`bots:new.pick`)})]}),!b&&y&&(0,$.jsx)(`p`,{className:`text-xs text-content-muted`,children:i(`bots:computer.folderInRoots`,{roots:y.roots.join(`、`)})}),x&&(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(K,{size:`sm`,disabled:h||!c.trim(),onClick:()=>void S({environmentId:o,cwd:c.trim()}),children:i(`bots:computer.switch`)})})]}),(0,$.jsxs)(`section`,{"aria-label":i(`bots:computer.listTitle`),className:`border-t border-stroke pt-3`,children:[(0,$.jsx)(`h4`,{className:`text-xs font-medium text-content-muted`,children:i(`bots:computer.listTitle`)}),(0,$.jsx)(`ul`,{role:`list`,className:`m-0 list-none divide-y divide-stroke p-0`,children:t.map(e=>(0,$.jsx)(un,{environment:e,onRemoved:n,onError:r},e.id))}),_?(0,$.jsx)(dn,{pairing:_,onDone:()=>{v(null),n()}}):(0,$.jsxs)(K,{size:`sm`,variant:`outline`,className:`mt-1`,onClick:()=>void w(),children:[(0,$.jsx)(N,{"aria-hidden":`true`}),i(`bots:computer.add`)]})]}),(0,$.jsx)(te,{open:p,initialPath:c,onOpenChange:m,listFolders:(e,t)=>Dt(o,e,t),onSelect:e=>{l(e),m(!1)}})]})}function pn(e){return`ref`in e?`ref:${e.ref}`:`tier:${e.tier}`}function mn(e){return e.startsWith(`ref:`)?{ref:e.slice(4)}:{tier:Ut.find(t=>`tier:${t}`===e)??`standard`}}function hn({bot:e,saving:t,onSave:n}){let{t:r}=d(),[i,a]=(0,Q.useState)([]);(0,Q.useEffect)(()=>{let e=!0;return kt().then(t=>e&&a(t)).catch(()=>e&&a([])),()=>{e=!1}},[]);let o=i.map(e=>e.name),s=pn(e.model);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{title:r(`bots:model.model`),description:r(`bots:model.hint`),control:(0,$.jsxs)(Y,{value:s,className:`w-48`,"aria-label":r(`bots:model.model`),disabled:t,onChange:e=>n({model:mn(e.target.value)}),children:[Ut.map(e=>(0,$.jsx)(`option`,{value:`tier:${e}`,children:se(r,{tier:e})},e)),`ref`in e.model&&!i.some(e=>`ref:${e.ref}`===s)&&(0,$.jsx)(`option`,{value:s,children:e.model.ref}),i.map(e=>(0,$.jsx)(`option`,{value:`ref:${e.ref}`,children:`${pt(e.name,o)} · ${e.providerName}`},e.ref))]})}),(0,$.jsx)(Z,{title:r(`bots:model.thinking`),control:(0,$.jsxs)(Y,{value:e.thinking??``,className:`w-48`,"aria-label":r(`bots:model.thinking`),disabled:t,onChange:e=>n({thinking:Vt.find(t=>t===e.target.value)??null}),children:[(0,$.jsx)(`option`,{value:``,children:r(`bots:model.thinkingDefault`)}),Vt.map(e=>(0,$.jsx)(`option`,{value:e,children:we(r,e)},e))]})})]})}function gn({bot:e,saving:t=!1,onError:n,onCount:r,onReadGlobalChange:i}){let{t:a}=d(),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(``),[u,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let t=new AbortController;return Pt(e.id,t.signal).then(e=>s(e)).catch(e=>{t.signal.aborted||(s([]),n(e instanceof Error?e.message:String(e)))}),()=>t.abort()},[e.id,n]),(0,Q.useEffect)(()=>{o&&r?.(o.length)},[o,r]);let h=async e=>{m(!0);try{await e()}catch(e){n(e instanceof Error?e.message:String(e))}finally{m(!1)}},g=()=>h(async()=>{let t=await Wt(e.id,c);s(e=>[...(e||[]).filter(e=>e.id!==t.id),t]),l(``)}),_=()=>h(async()=>{if(!u)return;let t=await Ft(e.id,u.id,u.text);s(e=>(e||[]).map(e=>e.id===t.id?t:e)),f(null)}),v=t=>h(async()=>{await Nt(e.id,t),s(e=>(e||[]).filter(e=>e.id!==t))});return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`p`,{className:`m-0 text-xs text-content-muted`,children:a(`bots:memory.hint`,{name:e.name})}),i&&(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{children:a(`bots:memory.readGlobal`)}),(0,$.jsx)(`span`,{className:`text-xs text-content-muted`,children:a(`bots:memory.readGlobalHint`)})]}),(0,$.jsx)(H,{checked:e.readGlobalMemory,disabled:t,onCheckedChange:i})]}),o&&!o.length&&(0,$.jsx)(gt,{compact:!0,title:a(`bots:memory.empty`,{name:e.name})}),o&&o.length>0&&(0,$.jsx)(`ul`,{role:`list`,className:`m-0 flex list-none flex-col gap-1.5 p-0`,children:[...o].reverse().map(e=>u?.id===e.id?(0,$.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(q,{value:u.text,maxLength:500,"aria-label":a(`bots:memory.editLabel`),onChange:t=>f({id:e.id,text:t.target.value}),onKeyDown:e=>{e.key===`Enter`&&u.text.trim()&&_(),e.key===`Escape`&&f(null)}}),(0,$.jsx)(K,{size:`sm`,disabled:p||!u.text.trim(),onClick:()=>void _(),children:a(`bots:memory.save`)}),(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:()=>f(null),children:a(`bots:memory.cancel`)})]},e.id):(0,$.jsxs)(`li`,{"data-bot-memory":e.id,className:`group flex items-start gap-2 rounded-lg bg-surface-subtle px-2.5 py-2 text-[13px]`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-content`,children:e.text}),(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`flex-none pointer-coarse:size-11`,"aria-label":a(`bots:memory.edit`),title:a(`bots:memory.edit`),disabled:p,onClick:()=>f({id:e.id,text:e.text}),children:(0,$.jsx)(M,{"aria-hidden":`true`})}),(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`flex-none pointer-coarse:size-11`,"aria-label":a(`bots:memory.delete`),title:a(`bots:memory.delete`),disabled:p,onClick:()=>void v(e.id),children:(0,$.jsx)(Me,{"aria-hidden":`true`})})]},e.id))}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(q,{value:c,maxLength:500,"aria-label":a(`bots:memory.addLabel`),placeholder:a(`bots:memory.addPlaceholder`),onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&c.trim()&&g()}}),(0,$.jsx)(K,{size:`sm`,variant:`outline`,disabled:p||!c.trim(),onClick:()=>void g(),children:a(`bots:memory.add`)})]})]})}var _n=[`feishu`,`weixin`,`qq`,`telegram`],vn=e=>_n.includes(e);function yn(e){let t=e&&typeof e==`object`?e:null,n=t?.connections;if(!n||typeof n!=`object`||Array.isArray(n))throw p();let r=_n.flatMap(e=>{let t=n[e];if(!t||typeof t!=`object`)return[];let{enabled:r,ownerConfigured:i}=t;return r===!1?[]:[{platform:e,ownerConfigured:i===!0}]}),i=new Set(r.map(e=>e.platform));return{channels:r,groups:(Array.isArray(t.scopes)?t.scopes:[]).flatMap(e=>{let t=e&&typeof e==`object`?e:{},n=e=>typeof e==`string`?e.trim():``,r=n(t.peerId);return t.chatType!==`group`||!vn(t.platform)||!r||!i.has(t.platform)?[]:[{platform:t.platform,peerId:r,title:n(t.title)||r,lastMessage:n(t.lastMessage)}]})}}function bn(e){return m(`/api/channels`,{signal:e,parse:yn})}function xn(e,t){return e.some(e=>e.platform===t.platform&&e.chatType===t.chatType&&e.senderIds.length===0&&(e.peerIds===null||t.peerIds!==null&&t.peerIds.every(t=>e.peerIds?.includes(t))))}function Sn({bot:e,onError:t}){let{t:n}=d(),i=X(e=>e.upsert),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(`feishu`),[y,b]=(0,Q.useState)(`p2p`),[x,S]=(0,Q.useState)(``),[C,w]=(0,Q.useState)(``),[T,E]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let e=new AbortController;return g(``),bn(e.signal).then(t=>{e.signal.aborted||m(t)},t=>{e.signal.aborted||g(t instanceof Error?t.message:String(t))}),()=>e.abort()},[a]);let D=async n=>{f(!0);try{return i(await wt(e.id,{channels:n})),!0}catch(e){return t(e instanceof Error?e.message:String(e)),!1}finally{f(!1)}},O=()=>{o(!1),c(!1),S(``),w(``),E(!1)},ee=async t=>{await D([...e.channels,t])&&O()},te=()=>{let e=I(x);ee({platform:_,chatType:y,peerIds:e.length?e:null,senderIds:I(C),everyone:T})},ne=p?[...p.channels.map(e=>({key:`${e.platform}:p2p`,title:n(`bots:triggers.pickP2p`,{platform:F(n,e.platform)}),detail:e.ownerConfigured?n(`bots:triggers.ownerOnly`):n(`bots:triggers.ownerMissing`),channel:{platform:e.platform,chatType:`p2p`,peerIds:null,senderIds:[],everyone:!1},unavailable:!e.ownerConfigured})),...p.groups.map(e=>{let t=p.channels.find(t=>t.platform===e.platform);return{key:`${e.platform}:group:${e.peerId}`,title:e.title,detail:[n(`bots:triggers.pickGroup`,{platform:F(n,e.platform)}),e.lastMessage].filter(Boolean).join(` · `),channel:{platform:e.platform,chatType:`group`,peerIds:[e.peerId],senderIds:[],everyone:!1},unavailable:!t?.ownerConfigured}})]:[];return(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs text-content-muted`,children:n(`bots:triggers.chatsHint`,{name:e.name})}),e.channels.length>0&&(0,$.jsx)(`ul`,{role:`list`,className:`m-0 mb-2 flex list-none flex-col gap-1.5 p-0`,children:e.channels.map((t,r)=>(0,$.jsxs)(`li`,{"data-bot-channel":t.platform,className:`flex items-start gap-2 rounded-lg bg-surface-subtle px-2.5 py-2 text-xs`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`b`,{className:`font-medium text-content`,children:[F(n,t.platform),` ·`,` `,t.chatType===`group`?n(`bots:triggers.group`):n(`bots:triggers.p2p`)]}),(0,$.jsxs)(`span`,{className:`block truncate text-content-muted`,children:[t.peerIds?n(`bots:triggers.peers`,{ids:t.peerIds.map(e=>p?.groups.find(n=>n.platform===t.platform&&n.peerId===e)?.title||e).join(`、`)}):n(`bots:triggers.allPeers`),` · `,t.senderIds.length?n(`bots:triggers.adminsWith`,{ids:t.senderIds.join(`、`)}):n(`bots:triggers.admins`)]}),(0,$.jsxs)(`label`,{className:`mt-1.5 flex items-center gap-2 text-content-secondary`,children:[(0,$.jsx)(H,{size:`sm`,checked:t.everyone,disabled:l,onCheckedChange:t=>void D(e.channels.map((e,n)=>n===r?{...e,everyone:t}:e))}),n(`bots:triggers.everyone`)]})]}),(0,$.jsx)(K,{size:`sm`,variant:`ghost`,disabled:l,onClick:()=>void D(e.channels.filter((e,t)=>t!==r)),children:n(`bots:triggers.remove`)})]},`${t.platform}-${r}`))}),a?(0,$.jsxs)(`div`,{"data-bot-channel-picker":!0,className:`flex flex-col gap-2 rounded-lg border border-stroke p-2.5`,children:[s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`m-0 text-xs text-content-muted`,children:n(`bots:triggers.manualHint`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{value:_,className:`w-32`,"aria-label":n(`bots:triggers.platform`),onChange:e=>v(e.target.value),children:It.map(e=>(0,$.jsx)(`option`,{value:e,children:F(n,e)},e))}),(0,$.jsx)(U,{value:y,onValueChange:e=>b(e),options:[{value:`p2p`,label:n(`bots:triggers.p2p`)},{value:`group`,label:n(`bots:triggers.group`)}]})]}),(0,$.jsx)(q,{value:x,"aria-label":n(`bots:triggers.peerIds`),placeholder:n(`bots:triggers.peerIdsPlaceholder`),onChange:e=>S(e.target.value)}),(0,$.jsx)(q,{value:C,"aria-label":n(`bots:triggers.senderIds`),placeholder:n(`bots:triggers.senderIdsPlaceholder`),onChange:e=>w(e.target.value)}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-content-secondary`,children:[(0,$.jsx)(H,{size:`sm`,checked:T,onCheckedChange:E}),n(`bots:triggers.everyone`)]})]}):h?(0,$.jsx)(`p`,{role:`alert`,className:`m-0 text-xs text-destructive`,children:h}):p?ne.length===0?(0,$.jsx)(gt,{compact:!0,icon:j,title:n(`bots:triggers.noChannels`),description:n(`bots:triggers.noChannelsHint`),action:(0,$.jsx)(K,{asChild:!0,size:`sm`,variant:`outline`,children:(0,$.jsx)(r,{to:u.channels,children:n(`bots:triggers.openChannels`)})})}):(0,$.jsx)(`ul`,{role:`list`,"aria-label":n(`bots:triggers.pickTitle`),className:`m-0 flex list-none flex-col p-0`,children:ne.map(t=>{let r=xn(e.channels,t.channel),i=t.channel.chatType===`group`?Ne:j;return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,"data-bot-chat-option":t.key,className:`flex min-h-11 w-full min-w-0 items-center gap-2.5 rounded-md px-2 py-1.5 text-left outline-none hover:bg-surface-hover focus-visible:ring-3 focus-visible:ring-focus-ring disabled:cursor-not-allowed disabled:opacity-50`,disabled:l||r||t.unavailable,onClick:()=>void ee(t.channel),children:[(0,$.jsx)(i,{className:`size-4 flex-none text-content-muted`,"aria-hidden":`true`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm text-content`,children:t.title}),(0,$.jsx)(`span`,{className:`block truncate text-xs text-content-muted`,children:t.detail})]}),r?(0,$.jsx)(`span`,{className:`flex-none text-xs text-content-muted`,children:n(`bots:triggers.added`)}):(0,$.jsx)(N,{className:`size-4 flex-none text-content-muted`,"aria-hidden":`true`})]})},t.key)})}):(0,$.jsx)(`div`,{role:`status`,className:`grid min-h-16 place-items-center`,children:(0,$.jsx)(G,{className:`size-4`})}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[s?(0,$.jsx)(`span`,{}):(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:()=>c(!0),children:n(`bots:triggers.manual`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:O,children:n(`bots:triggers.cancel`)}),s&&(0,$.jsx)(K,{size:`sm`,disabled:l,onClick:te,children:n(`bots:triggers.add`)})]})]})]}):(0,$.jsx)(K,{size:`sm`,variant:`outline`,className:`self-start`,onClick:()=>o(!0),children:n(`bots:triggers.addChat`)})]})}var Cn=[1,2,3,4,5,6,0];function wn(){let e=new Date,t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`}function Tn({bot:e,initialMessage:t=``,onCancel:n,onCreated:r,onError:i}){let{t:a}=d(),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(t),[u,f]=(0,Q.useState)(t?`weekly`:`daily`),[p,m]=(0,Q.useState)(`09:00`),[h,g]=(0,Q.useState)(wn),[_,v]=(0,Q.useState)(t?5:1),y=async()=>{let t=c.trim();s(!0);try{await zt({botId:e.id,name:`${e.name}:${t.slice(0,40)}`,botMessage:t,frequency:u,time:p,date:u===`once`?h:``,dayOfWeek:_,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||`Asia/Hong_Kong`}),r()}catch(e){i(e instanceof Error?e.message:String(e))}finally{s(!1)}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-stroke p-2.5`,children:[(0,$.jsx)(q,{value:c,maxLength:12e3,"aria-label":a(`bots:triggers.scheduleMessage`),placeholder:a(`bots:triggers.scheduleMessagePlaceholder`),onChange:e=>l(e.target.value)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(Y,{value:u,className:`w-28`,"aria-label":a(`bots:triggers.frequency`),onChange:e=>f(e.target.value),children:[(0,$.jsx)(`option`,{value:`daily`,children:a(`bots:triggers.daily`)}),(0,$.jsx)(`option`,{value:`weekly`,children:a(`bots:triggers.weekly`)}),(0,$.jsx)(`option`,{value:`once`,children:a(`bots:triggers.once`)})]}),u===`weekly`&&(0,$.jsx)(Y,{value:String(_),className:`w-24`,"aria-label":a(`bots:triggers.weekday`),onChange:e=>v(Number(e.target.value)),children:Cn.map(e=>(0,$.jsx)(`option`,{value:e,children:ge(a,e)},e))}),u===`once`&&(0,$.jsx)(q,{type:`date`,value:h,className:`w-40`,"aria-label":a(`bots:triggers.date`),onChange:e=>g(e.target.value)}),(0,$.jsx)(q,{type:`time`,value:p,className:`w-28`,"aria-label":a(`bots:triggers.time`),onChange:e=>m(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:n,children:a(`bots:triggers.cancel`)}),(0,$.jsx)(K,{size:`sm`,disabled:o||!c.trim(),onClick:()=>void y(),children:a(`bots:triggers.add`)})]})]})}function En({bot:e,onError:t,onCount:n}){let{t:r}=d(),[i,a]=(0,Q.useState)([]),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1),u=(0,Q.useCallback)(async()=>{try{let t=await qt(e.id);a(t),n?.(t.length)}catch{}},[e.id,n]);(0,Q.useEffect)(()=>{u()},[u]);let f=async e=>{l(!0);try{await e(),await u()}catch(e){t(e instanceof Error?e.message:String(e))}finally{l(!1)}};return(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[i.length>0&&(0,$.jsx)(`ul`,{role:`list`,className:`m-0 mb-2 flex list-none flex-col gap-1.5 p-0`,children:i.map(e=>(0,$.jsxs)(`li`,{"data-bot-schedule":e.id,className:`flex items-center gap-2 rounded-lg bg-surface-subtle px-2.5 py-2 text-xs`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`b`,{className:`block truncate font-medium text-content`,children:e.botMessage}),(0,$.jsx)(`span`,{className:`text-content-muted`,children:P(r,e)})]}),(0,$.jsx)(H,{checked:e.enabled,disabled:c,"aria-label":r(`bots:triggers.scheduleEnabled`),onCheckedChange:t=>void f(()=>Ot(e.id,t))}),(0,$.jsx)(K,{size:`sm`,variant:`ghost`,disabled:c,onClick:()=>void f(()=>Ht(e.id)),children:r(`bots:triggers.remove`)})]},e.id))}),o?(0,$.jsx)(Tn,{bot:e,onCancel:()=>s(!1),onCreated:()=>{s(!1),u()},onError:t}):(0,$.jsx)(K,{size:`sm`,variant:`outline`,className:`self-start`,onClick:()=>s(!0),children:r(`bots:triggers.addSchedule`)})]})}function Dn({bot:e,onError:t,onCount:n}){let{t:r}=d(),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(``),[u,f]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let n=new AbortController;return jt(e.id,n.signal).then(e=>a(e)).catch(e=>{n.signal.aborted||(a([]),t(e instanceof Error?e.message:String(e)))}),()=>n.abort()},[e.id,t]),(0,Q.useEffect)(()=>{i&&n?.(i.length)},[i,n]);let p=n=>{if(o?.name===n){s(null);return}s({name:n,body:null}),Xt(e.id,n).then(e=>s(t=>t?.name===n?{name:n,body:e.body}:t)).catch(e=>{s(null),t(e instanceof Error?e.message:String(e))})},m=async n=>{f(!0);try{await Bt(e.id,n),a(e=>(e||[]).filter(e=>e.name!==n)),o?.name===n&&s(null)}catch(e){t(e instanceof Error?e.message:String(e))}finally{f(!1)}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`p`,{className:`m-0 text-xs text-content-muted`,children:r(`bots:skills.hint`,{name:e.name})}),i&&!i.length&&(0,$.jsx)(gt,{compact:!0,title:r(`bots:skills.empty`,{name:e.name})}),i&&i.length>0&&(0,$.jsx)(`ul`,{role:`list`,className:`m-0 flex list-none flex-col gap-1.5 p-0`,children:i.map(n=>{let i=o?.name===n.name;return(0,$.jsxs)(`li`,{"data-bot-skill":n.name,className:`flex flex-col gap-2 rounded-lg bg-surface-subtle px-2.5 py-2 text-[13px]`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-start gap-1.5 text-left`,"aria-expanded":i,onClick:()=>p(n.name),children:[i?(0,$.jsx)(S,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 flex-none`}):(0,$.jsx)(w,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 flex-none`}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`b`,{className:`block truncate font-medium text-content`,children:n.name}),(0,$.jsx)(`span`,{className:`block text-xs text-content-muted`,children:n.description})]})]}),(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`flex-none pointer-coarse:size-11`,"aria-label":r(`bots:skills.schedule`),title:r(`bots:skills.schedule`),disabled:u,onClick:()=>l(e=>e===n.name?``:n.name),children:(0,$.jsx)(b,{"aria-hidden":`true`})}),(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`flex-none pointer-coarse:size-11`,"aria-label":r(`bots:skills.delete`),title:r(`bots:skills.delete`),disabled:u,onClick:()=>void m(n.name),children:(0,$.jsx)(Me,{"aria-hidden":`true`})})]}),i&&(0,$.jsx)(`pre`,{className:`m-0 max-h-72 overflow-auto rounded-md bg-surface px-2.5 py-2 text-xs whitespace-pre-wrap text-content`,children:o.body??r(`bots:skills.loading`)}),c===n.name&&(0,$.jsx)(Tn,{bot:e,initialMessage:r(`bots:skills.scheduleMessage`,{name:n.name}),onCancel:()=>l(``),onCreated:()=>l(``),onError:t})]},n.name)})})]})}function On({bot:e,saving:t,onSave:n}){let{t:r}=d(),[i,a]=(0,Q.useState)(e.proactive.briefAt);return(0,Q.useEffect)(()=>a(e.proactive.briefAt),[e.id,e.proactive.briefAt]),(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{title:r(`bots:proactive.check`),description:r(`bots:proactive.checkHint`,{name:e.name}),control:(0,$.jsx)(H,{checked:e.proactive.enabled,disabled:t,"aria-label":r(`bots:proactive.check`),onCheckedChange:e=>n({enabled:e})})}),e.proactive.enabled&&(0,$.jsx)(Z,{nested:!0,title:r(`bots:proactive.every`),control:(0,$.jsx)(Y,{value:String(e.proactive.everyHours),className:`w-48`,"aria-label":r(`bots:proactive.every`),disabled:t,onChange:e=>n({everyHours:Number(e.target.value)}),children:At.map(e=>(0,$.jsx)(`option`,{value:e,children:r(`bots:proactive.everyHours`,{count:e})},e))})}),(0,$.jsx)(Z,{title:r(`bots:proactive.brief`),description:r(`bots:proactive.briefHint`),control:(0,$.jsx)(H,{checked:e.proactive.brief,disabled:t,"aria-label":r(`bots:proactive.brief`),onCheckedChange:e=>n({brief:e})})}),e.proactive.brief&&(0,$.jsx)(Z,{nested:!0,title:r(`bots:proactive.briefAt`),control:(0,$.jsx)(q,{type:`time`,value:i,className:`w-48`,"aria-label":r(`bots:proactive.briefAt`),disabled:t,onChange:e=>a(e.target.value),onBlur:()=>{/^\d{2}:\d{2}$/.test(i)&&i!==e.proactive.briefAt&&n({briefAt:i})}})})]})}var kn={name:``,kind:`task`,text:``,audience:`admins`,allowExtra:!1};function An({initial:e,saving:t,onCancel:n,onSave:r}){let{t:i}=d(),[a,o]=(0,Q.useState)(e),s=e=>o(t=>({...t,...e})),c=a.kind===`task`;return(0,$.jsxs)(`form`,{"data-bot-command-form":!0,className:`flex flex-col gap-2 rounded-lg border border-stroke p-2.5`,onSubmit:e=>{e.preventDefault(),r({...a,name:a.name.trim(),text:a.text.trim()})},children:[(0,$.jsx)(q,{value:a.name,autoFocus:!0,maxLength:24,"aria-label":i(`bots:commands.name`),placeholder:i(`bots:commands.namePlaceholder`),onChange:e=>s({name:e.target.value})}),(0,$.jsx)(U,{value:a.kind,onValueChange:e=>s({kind:e,allowExtra:e===`task`&&a.allowExtra}),options:[{value:`task`,label:i(`bots:commands.task`)},{value:`reply`,label:i(`bots:commands.reply`)}]}),(0,$.jsx)(ft,{value:a.text,rows:3,maxLength:4e3,"aria-label":i(c?`bots:commands.taskText`:`bots:commands.replyText`),placeholder:i(c?`bots:commands.taskPlaceholder`:`bots:commands.replyPlaceholder`),onChange:e=>s({text:e.target.value})}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-sm`,children:[(0,$.jsx)(`span`,{className:`text-content-secondary`,children:i(`bots:commands.audience`)}),(0,$.jsx)(U,{value:a.audience,onValueChange:e=>s({audience:e}),options:[{value:`admins`,label:i(`bots:commands.admins`)},{value:`everyone`,label:i(`bots:commands.everyone`)}]})]}),c&&(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm`,children:[(0,$.jsx)(`span`,{className:`text-content-secondary`,children:i(`bots:commands.allowExtra`)}),(0,$.jsx)(H,{checked:a.allowExtra,onCheckedChange:e=>s({allowExtra:e})})]}),c&&a.allowExtra&&a.audience===`everyone`&&(0,$.jsx)(`p`,{className:`m-0 text-xs text-content-muted`,children:i(`bots:commands.extraNote`)}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(K,{type:`button`,size:`sm`,variant:`ghost`,onClick:n,children:i(`bots:triggers.cancel`)}),(0,$.jsx)(K,{type:`submit`,size:`sm`,disabled:t||!a.name.trim()||!a.text.trim(),children:i(`bots:commands.save`)})]})]})}function jn({bot:e,onError:t}){let{t:n}=d(),r=X(e=>e.upsert),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(!1),c=async n=>{s(!0);try{return r(await wt(e.id,{commands:n})),!0}catch(e){return t(e instanceof Error?e.message:String(e)),!1}finally{s(!1)}},l=(t,n)=>{let r=[...e.commands],[i]=r.splice(t,1);r.splice(t+n,0,i),c(r)},u=e.channels.some(e=>e.everyone);return(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs text-content-muted`,children:n(`bots:commands.hint`,{name:e.name})}),e.commands.some(e=>e.audience===`everyone`)&&!u&&(0,$.jsx)(`p`,{className:`mb-2 text-xs text-content-muted`,children:n(`bots:commands.noEveryoneChat`)}),e.commands.length>0&&(0,$.jsx)(`ol`,{className:`m-0 mb-2 flex list-none flex-col gap-1.5 p-0`,children:e.commands.map((t,r)=>i===r?(0,$.jsx)(`li`,{children:(0,$.jsx)(An,{initial:t,saving:o,onCancel:()=>a(null),onSave:async t=>{await c(e.commands.map((e,n)=>n===r?t:e))&&a(null)}})},t.name):(0,$.jsxs)(`li`,{"data-bot-command":t.name,className:`flex items-start gap-2 rounded-lg bg-surface-subtle px-2.5 py-2 text-xs`,children:[(0,$.jsx)(`span`,{className:`w-4 flex-none pt-px text-right font-mono text-content-muted`,children:r+1}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`b`,{className:`block truncate font-medium text-content`,children:t.name}),(0,$.jsx)(`span`,{className:`block truncate text-content-muted`,children:[t.audience===`everyone`?n(`bots:commands.everyone`):n(`bots:commands.admins`),t.kind===`reply`?n(`bots:commands.reply`):n(`bots:commands.task`),t.allowExtra?n(`bots:commands.extraAllowed`):``,t.text].filter(Boolean).join(` · `)})]}),(0,$.jsx)(K,{size:`icon-sm`,variant:`ghost`,"aria-label":n(`bots:commands.moveUp`),disabled:o||i!==null||r===0,onClick:()=>l(r,-1),children:(0,$.jsx)(y,{})}),(0,$.jsx)(K,{size:`icon-sm`,variant:`ghost`,"aria-label":n(`bots:commands.moveDown`),disabled:o||i!==null||r===e.commands.length-1,onClick:()=>l(r,1),children:(0,$.jsx)(v,{})}),(0,$.jsx)(K,{size:`sm`,variant:`ghost`,disabled:o||i!==null,onClick:()=>a(r),children:n(`bots:commands.edit`)}),(0,$.jsx)(K,{size:`sm`,variant:`ghost`,disabled:o||i!==null,onClick:()=>void c(e.commands.filter((e,t)=>t!==r)),children:n(`bots:triggers.remove`)})]},t.name))}),i===-1?(0,$.jsx)(An,{initial:kn,saving:o,onCancel:()=>a(null),onSave:async t=>{await c([...e.commands,t])&&a(null)}}):(0,$.jsx)(K,{size:`sm`,variant:`outline`,className:`self-start`,disabled:i!==null||e.commands.length>=20,onClick:()=>a(-1),children:n(`bots:commands.add`)})]})}function Mn({id:e,title:t,summary:n,open:r,onToggle:i,children:a}){let{t:o}=d(),s=(0,Q.useId)();return(0,$.jsx)(Z,{"data-bot-setting":e,"data-state":r?`open`:`closed`,title:t,description:n,control:(0,$.jsxs)(K,{variant:`ghost`,size:`sm`,"aria-expanded":r,"aria-controls":r?s:void 0,onClick:i,children:[o(r?`bots:settings.collapse`:`bots:settings.manage`),(0,$.jsx)(w,{"aria-hidden":`true`,className:W(`transition-transform motion-reduce:transition-none`,r&&`rotate-90`)})]}),children:r&&(0,$.jsx)(`div`,{id:s,className:`mt-3`,children:a})})}function Nn({bot:e,environment:t,saving:n,onSave:r}){let{t:i}=d(),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),l=async()=>{let t=s?.trim()??``;if(!t||t===e.name){c(null);return}await r({name:t})&&c(null)},u=[Et(i,e),i(`bots:settings.computerSummary`,{computer:cn(i,t),folder:Lt(e.workspace.cwd)}),se(i,e.model)].join(` · `);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,$.jsxs)(`button`,{type:`button`,"aria-label":i(`bots:settings.changeLook`),"aria-expanded":a,title:i(`bots:settings.changeLook`),className:`relative flex-none rounded-[16px] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus`,onClick:()=>o(e=>!e),children:[(0,$.jsx)(J,{avatar:e.avatar,state:Rt(e),size:56}),(0,$.jsx)(`span`,{className:`absolute -right-1 -bottom-1 grid size-6 place-items-center rounded-full border border-stroke bg-solid text-content-muted shadow-edge`,children:(0,$.jsx)(M,{className:`size-3`,"aria-hidden":`true`})})]}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[s===null?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,$.jsx)(`h2`,{className:`m-0 truncate text-lg font-semibold text-content`,children:e.name}),(0,$.jsx)(K,{variant:`ghost`,size:`icon-xs`,"aria-label":i(`bots:settings.rename`),title:i(`bots:settings.rename`),onClick:()=>c(e.name),children:(0,$.jsx)(M,{})})]}):(0,$.jsxs)(`form`,{className:`flex items-center gap-2`,onSubmit:e=>{e.preventDefault(),l()},children:[(0,$.jsx)(q,{autoFocus:!0,value:s,maxLength:24,"aria-label":i(`bots:new.name`),disabled:n,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Escape`&&c(null)}}),(0,$.jsx)(K,{type:`submit`,size:`sm`,disabled:n||!s.trim(),children:i(`bots:details.save`)}),(0,$.jsx)(K,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>c(null),children:i(`common:ui.cancel`)})]}),(0,$.jsxs)(`p`,{className:`m-0 mt-0.5 flex min-w-0 items-center gap-1.5 text-xs text-content-muted`,children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:W(`size-1.5 flex-none rounded-full`,e.enabled?`bg-success`:`bg-content-faint`)}),(0,$.jsx)(`span`,{className:`truncate`,children:u})]})]}),(0,$.jsxs)(`label`,{className:`flex flex-none items-center gap-2 text-[13px] text-content-secondary`,title:i(`bots:details.acceptsWork`),children:[i(`bots:settings.accepting`),(0,$.jsx)(H,{checked:e.enabled,disabled:n,"aria-label":i(`bots:details.acceptsWork`),onCheckedChange:e=>void r({enabled:e})})]})]}),a&&(0,$.jsx)(L,{value:e.avatar,disabled:n,onChange:e=>void r({avatar:e})})]})}function Pn({bot:e,environments:t,openSection:n,onEnvironmentsChanged:r,onError:i}){let{t:a}=d(),o=X(e=>e.upsert),[s,c]=(0,Q.useState)(e.instructions),[l,u]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(()=>new Set(n?[n]:[])),[m,h]=(0,Q.useState)({memory:null,skills:null,schedules:null});(0,Q.useEffect)(()=>c(e.instructions),[e.id,e.instructions]),(0,Q.useEffect)(()=>{let t=new AbortController,n=(e,t)=>t.then(t=>h(n=>({...n,[e]:t.length}))).catch(()=>{});return n(`memory`,Pt(e.id,t.signal)),n(`skills`,jt(e.id,t.signal)),n(`schedules`,qt(e.id,t.signal)),()=>t.abort()},[e.id]);let g=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{n&&g.current?.querySelector(`[data-bot-setting="${CSS.escape(n)}"]`)?.scrollIntoView()},[n]);let _=async t=>{u(!0);try{return o(await wt(e.id,t)),!0}catch(e){return i(e instanceof Error?e.message:String(e)),!1}finally{u(!1)}},v=e=>p(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),y=e=>({id:e,open:f.has(e),onToggle:()=>v(e)}),b=m.memory===null?``:a(`bots:memory.count`,{count:m.memory}),x=m.skills===null?``:a(`bots:skills.count`,{count:m.skills}),S=m.schedules===null?``:m.schedules?a(`bots:settings.schedulesCount`,{count:m.schedules}):a(`bots:settings.notSet`),C=(0,Q.useMemo)(()=>{let e=e=>t=>h(n=>n[e]===t?n:{...n,[e]:t});return{memory:e(`memory`),skills:e(`skills`),schedules:e(`schedules`)}},[]),w=t.find(t=>t.id===e.workspace.environmentId),T=e.commands.filter(e=>e.audience===`everyone`).length;return(0,$.jsxs)(`div`,{ref:g,className:`flex flex-col gap-8 pb-4`,children:[(0,$.jsx)(Nn,{bot:e,environment:w,saving:l,onSave:_}),(0,$.jsxs)(`section`,{"aria-labelledby":`bot-instructions-title`,className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`h2`,{id:`bot-instructions-title`,className:`m-0 text-[15px] leading-6 font-medium text-content`,children:a(`bots:details.instructions`)}),(0,$.jsx)(ft,{value:s,rows:3,maxLength:12e3,"aria-labelledby":`bot-instructions-title`,placeholder:a(`bots:details.instructionsPlaceholder`),onChange:e=>c(e.target.value)}),s!==e.instructions&&(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(K,{size:`sm`,disabled:l,onClick:()=>void _({instructions:s}),children:a(`bots:details.save`)})})]}),(0,$.jsxs)(Qt,{title:a(`bots:settings.groupWork`),children:[(0,$.jsx)(Mn,{...y(`computer`),title:a(`bots:settings.computer`),summary:a(`bots:settings.computerSummary`,{computer:cn(a,w),folder:Lt(e.workspace.cwd)}),children:(0,$.jsx)(fn,{bot:e,environments:t,onEnvironmentsChanged:r,onError:i})}),(0,$.jsx)(hn,{bot:e,saving:l,onSave:e=>void _(e)}),(0,$.jsx)(Z,{title:a(`bots:details.permission`),description:a(`bots:details.permissionHint`),control:(0,$.jsx)(Y,{value:e.executionMode,className:`w-48`,"aria-label":a(`bots:details.permission`),disabled:l,onChange:e=>void _({executionMode:e.target.value}),children:[`approval-required`,`workspace-write`,`full-access`].map(e=>(0,$.jsx)(`option`,{value:e,children:ce(a,e)},e))})}),(0,$.jsx)(Z,{title:a(`bots:details.tools`),description:a(`bots:details.toolsHint`),control:(0,$.jsxs)(Y,{value:Tt(e.tools),className:`w-48`,"aria-label":a(`bots:details.tools`),disabled:l,onChange:e=>void _({tools:e.target.value===`read-only`?[...Ct]:null}),children:[(0,$.jsx)(`option`,{value:`all`,children:a(`bots:details.toolsAll`)}),(0,$.jsx)(`option`,{value:`read-only`,children:a(`bots:details.toolsReadOnly`)}),Tt(e.tools)===`custom`&&(0,$.jsx)(`option`,{value:`custom`,disabled:!0,children:a(`bots:details.toolsCustom`,{count:e.tools?.length??0})})]})}),(0,$.jsx)(Z,{title:a(`bots:details.parallel`),description:a(`bots:details.parallelHint`),control:(0,$.jsx)(Y,{value:String(e.maxParallelAgents),className:`w-48`,"aria-label":a(`bots:details.parallel`),disabled:l,onChange:e=>void _({maxParallelAgents:Number(e.target.value)}),children:[1,2,3,4,5,6].map(e=>(0,$.jsx)(`option`,{value:e,children:a(`bots:details.parallelCount`,{count:e})},e))})})]}),(0,$.jsxs)(Qt,{title:a(`bots:settings.groupReach`),children:[(0,$.jsx)(Mn,{...y(`chats`),title:a(`bots:settings.chats`),summary:e.channels.length?a(`bots:settings.chatsCount`,{count:e.channels.length}):a(`bots:settings.notSet`),children:(0,$.jsx)(Sn,{bot:e,onError:i})}),(0,$.jsx)(Mn,{...y(`commands`),title:a(`bots:commands.title`),summary:e.commands.length?a(`bots:commands.count`,{count:e.commands.length,open:T}):a(`bots:settings.notSet`),children:(0,$.jsx)(jn,{bot:e,onError:i})})]}),(0,$.jsxs)(Qt,{title:a(`bots:settings.groupOwn`),children:[(0,$.jsx)(On,{bot:e,saving:l,onSave:e=>void _({proactive:e})}),(0,$.jsx)(Mn,{...y(`schedules`),title:a(`bots:settings.schedules`),summary:S,children:(0,$.jsx)(En,{bot:e,onError:i,onCount:C.schedules})})]}),(0,$.jsxs)(Qt,{title:a(`bots:settings.groupMemory`),children:[(0,$.jsx)(Mn,{...y(`memory`),title:a(`bots:memory.title`),summary:b,children:(0,$.jsx)(gn,{bot:e,onError:i,onCount:C.memory})}),(0,$.jsx)(Z,{title:a(`bots:memory.readGlobal`),description:a(`bots:memory.readGlobalHint`),control:(0,$.jsx)(H,{checked:e.readGlobalMemory,disabled:l,"aria-label":a(`bots:memory.readGlobal`),onCheckedChange:e=>void _({readGlobalMemory:e})})}),(0,$.jsx)(Mn,{...y(`skills`),title:a(`bots:skills.title`),summary:x,children:(0,$.jsx)(Dn,{bot:e,onError:i,onCount:C.skills})})]})]})}var Fn={enabled:!1,endpoints:[],fingerprint:null};function In(){let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(Fn),[i,a]=(0,Q.useState)(!1),o=(0,Q.useRef)(0),s=(0,Q.useCallback)(async()=>{let e=++o.current;try{let n=await Yt();if(e!==o.current)return;t(n.environments),r(n.remote)}catch{}finally{e===o.current&&a(!0)}},[]);return(0,Q.useEffect)(()=>{s();let e=window.setInterval(()=>{document.visibilityState===`visible`&&s()},1e4);return()=>{window.clearInterval(e),o.current+=1}},[s]),{environments:e,remote:n,loaded:i,refresh:s}}var Ln=`flex h-[52px] flex-none items-center gap-2 border-b border-stroke px-3 max-[650px]:h-[calc(52px+var(--pisper-safe-area-top,0px))] max-[650px]:px-2 max-[650px]:pt-[var(--pisper-safe-area-top,0px)] [[data-custom-titlebar]_&]:pr-[144px]`;function Rn({notify:e,phoneLeading:n}){let{t:r}=d(),o=g(),s=Zt(`bots`),{botId:c=``}=t(),l=a(),u=X(e=>e.bots),f=X(e=>e.loaded),[p,m]=(0,Q.useState)(!1),h=(0,Q.useCallback)(t=>e(t,`error`),[e]),_=xe(h);Gt(s);let v=u.find(e=>e.id===c)??null,y=e=>o&&c?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-col`,children:[(0,$.jsx)(`header`,{className:Ln,children:n}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:e})]}):e;return s?f?!c&&u[0]?(0,$.jsx)(i,{to:`/bots/${encodeURIComponent(u[0].id)}`,replace:!0}):v?(0,$.jsx)(zn,{botId:v.id,phoneLeading:o?n:null,onOpenChat:()=>void _(v),onDeleted:()=>{e(r(`bots:delete.deleted`,{name:v.name})),l(`/`,{replace:!0})},onError:h},v.id):y((0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ht,{kind:`empty`,title:u.length?r(`bots:page.notFound`):r(`bots:page.emptyTitle`),description:r(`bots:page.emptyDescription`),action:(0,$.jsxs)(K,{onClick:()=>m(!0),children:[(0,$.jsx)(N,{"aria-hidden":`true`}),r(`bots:sidebar.newBot`)]})}),(0,$.jsx)(Te,{open:p,onOpenChange:m,onCreated:e=>void _(e)})]})):y((0,$.jsx)(ht,{kind:`loading`,title:r(`bots:page.loading`)})):y((0,$.jsx)(ht,{kind:`empty`,title:r(`bots:page.disabledTitle`),description:r(`bots:page.disabledDescription`),action:(0,$.jsx)(K,{onClick:()=>l(`/config/labs`),children:r(`bots:page.openLabs`)})}))}function zn({botId:e,phoneLeading:t,onOpenChat:r,onDeleted:i,onError:a}){let{t:o}=d(),s=X(t=>t.bots.find(t=>t.id===e)),c=X(e=>e.load),l=In(),[u]=n(),f=u.get(`section`)===`chats`?`chats`:void 0,p=u.get(`action`)===`delete`;return s?(0,$.jsxs)(`div`,{"data-bot-settings":s.id,className:`flex h-full min-h-0 w-full min-w-0 flex-col`,children:[(0,$.jsxs)(`header`,{"data-window-drag-region":!0,className:`flex h-[52px] flex-none items-center gap-2 border-b border-stroke px-3 max-[650px]:h-[calc(52px+var(--pisper-safe-area-top,0px))] max-[650px]:px-2 max-[650px]:pt-[var(--pisper-safe-area-top,0px)] [[data-custom-titlebar]_&]:pr-[144px]`,children:[t,(0,$.jsxs)(K,{variant:`ghost`,size:`sm`,onClick:r,children:[(0,$.jsx)(C,{"aria-hidden":`true`}),o(`bots:settingsPage.backToChat`,{name:s.name})]}),(0,$.jsx)(`h1`,{className:`sr-only`,children:o(`bots:settingsPage.title`,{name:s.name})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,$.jsxs)(`div`,{className:`mx-auto w-[min(640px,calc(100%-32px))] py-6`,children:[(0,$.jsx)(Pn,{bot:s,environments:l.environments,openSection:f,onEnvironmentsChanged:()=>{l.refresh(),c()},onError:a}),(0,$.jsx)(sn,{bot:s,initiallyOpen:p,onDeleted:i,onError:a})]})})]}):null}function Bn(e,t=new Map){if(/(^|[^\p{L}\p{N}_])@(所有人|all|everyone)(?![\p{L}\p{N}_])/iu.test(e.text))return!0;let n=e.replyTo?t.get(e.replyTo)?.author.kind===`bot`:!1;return e.recipients===`all`&&!e.mentions?.length&&!n}function Vn(e){let t=new Map(e.map(e=>[e.id,e])),n=new Map;for(let r of e){let e=r.turn;if(!e||r.author.kind!==`bot`)continue;let i=r.author.botId;for(let r of[...e.triggers,...e.alsoAnswered]){let a=t.get(r);if(!a||a.author.kind!==`user`||!Bn(a,t))continue;let o=n.get(r)||[];o.some(e=>e.botId===i)||(o.push({botId:i,state:e.state===`skipped`?`skipped`:e.state===`running`||e.state===`waiting`?`working`:`replied`}),n.set(r,o))}}let r=[];for(let i of e){if(i.recalled){r.push({kind:`recalled`,message:i});continue}if(i.author.kind===`system`){r.push({kind:`system`,message:i});continue}if(i.author.kind===`user`){r.push({kind:`user`,message:i,round:n.get(i.id)||null});continue}if(!i.turn){r.push({kind:`post`,message:i});continue}if(i.turn.state===`skipped`)continue;let e=i.turn.triggers.map(e=>t.get(e)).find(Boolean);r.push({kind:`card`,message:i,handoff:e?.author.kind===`bot`?{from:e.author.botId,hop:Math.max(2,i.chainHop)}:null})}return r}function Hn(e,t){let n=t.filter(e=>e.name).sort((e,t)=>t.name.length-e.name.length),r=[],i=``,a=0;for(;a<e.length;){if(e[a]===`@`){let t=e.slice(a+1),o=n.find(e=>{if(!t.toLowerCase().startsWith(e.name.toLowerCase()))return!1;let n=t.charAt(e.name.length);return!n||!/[\p{L}\p{N}_-]/u.test(n)}),s=/[\p{L}\p{N}_]/u.test(e.charAt(a-1))?null:/^(所有人|all|everyone)(?![\p{L}\p{N}_])/iu.exec(t);if(o||s){i&&r.push({text:i}),i=``;let t=o?o.name.length:s[0].length;r.push({text:e.slice(a,a+1+t),...o?{memberId:o.id}:{everyone:!0}}),a+=1+t;continue}}i+=e[a],a+=1}return i&&r.push({text:i}),r}function Un(e,t){let n=e.slice(0,t),r=n.lastIndexOf(`@`);if(r<0||r>0&&/[\p{L}\p{N}_]/u.test(n[r-1]))return null;let i=n.slice(r+1);return/\s/.test(i)||i.length>24?null:{start:r,query:i}}function Wn(e,t){return[...new Set(Hn(e,t).map(e=>e.memberId).filter(e=>!!e))]}function Gn(e){let t=Wn(e.text,e.members),n=Hn(e.text,e.members).some(e=>e.everyone),r=t.length>0||n||!!e.repliedBot,i=n?e.members.map(e=>e.id):r?[...t,...e.repliedBot?[e.repliedBot]:[]]:e.chosen;return{addressed:r,mentionsAll:n,targets:[...new Set(i)]}}function Kn(e){return e>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`:e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}K`:String(Math.max(0,Math.round(e)))}function qn(e,t){let n=e.owner===`user`?`@me `:e.owner?`@${t.find(t=>t.id===e.owner)?.name||``} `:``;return`${e.done?`[x] `:``}${n}${e.text}`}function Jn(e,t){let n=e.trim();if(!n)return null;let r=!1,i=/^\[(x|X| )\]\s*/.exec(n);i&&(r=i[1].toLowerCase()===`x`,n=n.slice(i[0].length));let a=``;if(n.startsWith(`@`)){let e=t.filter(e=>e.name).sort((e,t)=>t.name.length-e.name.length).find(e=>n.slice(1).startsWith(e.name));e?(a=e.id,n=n.slice(e.name.length+1).trim()):/^@me\b/i.test(n)&&(a=`user`,n=n.slice(3).trim())}return n?{text:n,owner:a,done:r}:null}function Yn(e){return e.map(e=>e.kind===`path`?{id:`path:${e.path}`,kind:`path`,name:e.name,path:e.path}:{id:e.id,kind:e.kind,name:e.name,mimeType:e.mimeType,size:e.size,downloadUrl:yt(e.id),...e.kind===`image`?{url:vt(e.id)}:{}})}function Xn(e){if(e.kind===`user`)return!0;if(e.kind!==`card`)return!1;let t=e.message.turn?.state;return t!==`running`&&t!==`waiting`}function Zn(e,t,n,r,i){if(e.altKey||e.ctrlKey||e.metaKey||r<=0)return null;let a=r-1;return e.key===`ArrowDown`?{type:`move`,index:Math.min(a,n+1)}:e.key===`ArrowUp`?{type:`move`,index:Math.max(0,n-1)}:e.key===`Home`?{type:`move`,index:0}:e.key===`End`?{type:`move`,index:a}:i?(e.key===`r`||e.key===`R`)&&Xn(t)?{type:`reply`}:e.key===`Delete`&&Xn(t)?{type:`recall`}:e.key===`Enter`&&t.kind===`card`&&t.message.turn?.sessionId?{type:`process`}:null:null}function Qn(e){return e.turn?.state===`running`||e.turn?.state===`waiting`}function $n(e){let t=[];for(let n of e){let e=n.turn;!e||n.author.kind!==`bot`||n.recalled||(e.state===`running`||e.state===`waiting`?t.push({message:n,botId:n.author.botId,waiting:e.state===`waiting`?e.waiting||`approval`:null,approval:e.state===`waiting`?e.approval:null,pending:!1}):e.pending&&t.push({message:n,botId:n.author.botId,waiting:e.pending.waiting,approval:e.pending.approval,pending:!0}))}return t}function er(e,t){if(!e||e.recalled||t.replyTo||e.author.kind!==t.author.kind||t.author.kind===`bot`&&(e.author.kind!==`bot`||e.author.botId!==t.author.botId)||t.author.kind===`system`)return!1;let n=Date.parse(t.at)-Date.parse(e.at);return Number.isFinite(n)&&n>=0&&n<=12e4}function tr(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:`${t.getFullYear()}-${t.getMonth()+1}-${t.getDate()}`}function nr(e){if(e.maintained)return null;let t=Math.max(e.brief?.upToSeq||0,e.skipUpTo||0),n=Math.max(0,e.lastSeq-t),r=e.messages.filter(e=>e.seq>t&&!e.recalled).reduce((e,t)=>e+t.text.length,0);return n>0&&r>=24e3?{count:n,chars:r}:null}var rr=`relative pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 pointer-coarse:after:-inset-y-2.5`,ir=`border-transparent bg-transparent text-content-muted shadow-none`,ar=12e3,or=`@everyone`,sr=[`所有人`,`all`,`everyone`];function cr({roomId:e,cwd:t,members:n,recipients:r,onRecipientsChange:i,replyTo:a,replyName:o,onCancelReply:s,onSend:c,placeholder:l,idleLabel:u,idleHint:f}){let{t:p}=d(),m=(0,Q.useId)(),h=(0,Q.useRef)(!1),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(0),[b,x]=(0,Q.useState)(``),[S,C]=(0,Q.useState)(-1),[w,T]=(0,Q.useState)(!1),[E,te]=(0,Q.useState)(!1),ne=(0,Q.useRef)(!1),k=(0,Q.useRef)(null),A=n.filter(e=>!e.deleted),j=D([],void 0,e),re=Ae({cwd:t,selection:j}),ie=j.attachments.length>0,M=j.preparingAttachments.length>0,oe=!!(g.trim()||ie)&&!M&&!w,se=a?.id;(0,Q.useEffect)(()=>{se&&k.current?.focus()},[se]);let P=Un(g,v),F=p(`bots:room.composer.everyone`),I=(0,Q.useMemo)(()=>{if(!P)return[];let e=P.query.toLowerCase(),t=A.filter(t=>t.name.toLowerCase().includes(e)).slice(0,8).map(e=>({id:e.id,name:e.name,member:e}));return A.length>1&&[F,...sr].some(t=>t.toLowerCase().startsWith(e))&&t.push({id:or,name:F}),t},[A,P,F]),L=!!(P&&I.length&&S!==P.start),ce=I.find(e=>e.id===b)||I[0],R=r===`all`||!u&&!A.some(e=>r.includes(e.id)),z=R?A.map(e=>e.id):r,le=A.filter(e=>z.includes(e.id)),{addressed:ue,mentionsAll:de,targets:fe}=Gn({text:g,members:A,chosen:z,repliedBot:a?.author.kind===`bot`?a.author.botId:``}),pe=new Set(A.filter(e=>e.enabled).map(e=>e.id)),me=fe.filter(e=>pe.has(e)).length,he=!u&&!ue&&R&&me>=2,ge=e=>{if(!P)return;let t=g.slice(0,P.start),n=g.slice(v),r=`${t}@${e.name} ${n}`,i=t.length+e.name.length+2;_(r),y(i),window.requestAnimationFrame(()=>{k.current?.focus(),k.current?.setSelectionRange(i,i)})},_e=()=>{let e=k.current?.selectionStart??g.length,t=g.slice(0,e),n=t&&!/\s$/.test(t)?` @`:`@`,r=`${t}${n}${g.slice(e)}`,i=e+n.length;_(r),y(i),C(-1),window.requestAnimationFrame(()=>{k.current?.focus(),k.current?.setSelectionRange(i,i)})},ve=e=>{let t=e.currentTarget;t.scrollWidth<=t.clientWidth||Math.abs(e.deltaX)>Math.abs(e.deltaY)||(t.scrollLeft+=e.deltaY)},B=(e,t)=>{let n=R?A.map(e=>e.id):r,a=t?[...new Set([...n,e])]:n.filter(t=>t!==e);i(a.length===A.length&&A.length>1||!a.length&&!u?`all`:a)},ye=async()=>{let e=g.trim();if(oe){T(!0);try{await c(e,Wn(e,A),j.attachments)&&(_(``),y(0),j.clearAttachments(),k.current&&(k.current.style.height=`auto`))}finally{T(!1)}}},be=e=>{if(!(ne.current||e.nativeEvent.isComposing)){if(L&&ce){let t=I.indexOf(ce);if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let n=e.key===`ArrowDown`?1:-1;x(I[(t+n+I.length)%I.length].id);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),ge(ce);return}if(e.key===`Escape`){e.preventDefault(),C(P.start);return}}if(e.key===`Escape`&&a){e.preventDefault(),s();return}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),ye())}},xe=e=>{O(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,te(!0))};return(0,$.jsxs)(Ye,{open:L,children:[j.attachmentError&&(0,$.jsx)(`p`,{role:`alert`,className:`m-0 mb-2 text-[13px] text-danger`,children:j.attachmentError}),(0,$.jsx)(qe,{asChild:!0,children:(0,$.jsxs)(`form`,{"data-room-composer":!0,onSubmit:e=>{e.preventDefault(),ye()},className:W(`relative flex min-w-0 flex-col rounded-[var(--composer-radius,22px)] border border-control bg-solid shadow-composer transition-[border-color,box-shadow] duration-(--d-fast) has-[textarea:focus]:border-focus has-[textarea:focus]:ring-3 has-[textarea:focus]:ring-focus-ring max-[650px]:rounded-[28px] max-[650px]:border-stroke-strong max-[650px]:shadow-none max-[650px]:has-[textarea:focus]:border-control max-[650px]:has-[textarea:focus]:ring-0 [&>.attachment-tray]:px-3 [&>.attachment-tray]:pt-3`,E&&`border-focus ring-3 ring-focus-ring`),onDragEnter:xe,onDragOver:xe,onDragLeave:e=>{let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||te(!1)},onDrop:e=>{te(!1),j.dropFiles(e)},children:[E&&(0,$.jsx)(`div`,{role:`status`,className:`pointer-events-none absolute inset-0 z-10 grid place-items-center rounded-[inherit] border border-dashed border-focus bg-panel px-4 text-center text-sm text-content`,children:p(`chat:focusSession.dropAttachment`)}),a&&(0,$.jsxs)(`div`,{className:`mx-3 mt-2.5 flex min-w-0 items-center gap-2 rounded-lg bg-surface-subtle px-2.5 py-1.5 text-[12.5px] text-content-secondary`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:p(`bots:room.replyTo`,{name:o,text:a.text.replace(/\s+/g,` `)||a.attachments.map(e=>e.name).join(`、`)||`…`})}),(0,$.jsx)(K,{variant:`ghost`,size:`icon-xs`,"aria-label":p(`bots:room.composer.cancelReply`),onClick:s,children:(0,$.jsx)(Pe,{})})]}),(0,$.jsx)(je,{attachments:j.attachments,preparing:j.preparingAttachments,onRemove:j.removeAttachment}),(0,$.jsx)(`textarea`,{ref:k,rows:1,value:g,maxLength:ar,"aria-label":p(`bots:room.composer.label`),"aria-autocomplete":`list`,"aria-expanded":L,placeholder:l,enterKeyHint:`send`,className:`max-h-[220px] min-h-11 w-full min-w-0 resize-none overflow-y-auto border-0 bg-transparent px-4 pt-3 pb-1 text-[length:calc(var(--app-message-font-size)*.9375)] leading-5 text-content [font-family:var(--font-content-family)] [outline:0] placeholder:text-content-muted max-[650px]:px-3.5 max-[650px]:text-[length:var(--app-message-font-size)]`,onChange:e=>{_(e.target.value),y(e.target.selectionStart??e.target.value.length),e.currentTarget.style.height=`auto`,e.currentTarget.style.height=`${Math.min(e.currentTarget.scrollHeight,220)}px`},onSelect:e=>y(e.currentTarget.selectionStart??0),onPaste:j.pasteFiles,onCompositionStart:()=>ne.current=!0,onCompositionEnd:()=>window.setTimeout(()=>ne.current=!1,0),onKeyDown:be}),(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1 px-2 pt-1 pb-2 max-[650px]:gap-2 max-[650px]:pb-3`,children:[re.input,(0,$.jsxs)(Ke,{children:[(0,$.jsx)(We,{asChild:!0,children:(0,$.jsx)(K,{variant:`ghost`,size:`icon-sm`,className:`rounded-full`,"aria-label":p(`bots:room.composer.add`),title:p(`bots:room.composer.add`),children:(0,$.jsx)(N,{})})}),(0,$.jsxs)(Ge,{align:`start`,side:`top`,className:`w-52`,onCloseAutoFocus:e=>{h.current&&(h.current=!1,e.preventDefault())},children:[(0,$.jsxs)(V,{onSelect:()=>void re.choose(),children:[(0,$.jsx)(ae,{"aria-hidden":`true`}),p(`chat:focusSession.addAttachment`)]}),(0,$.jsxs)(V,{onSelect:()=>{h.current=!0,_e()},children:[(0,$.jsx)(en,{"aria-hidden":`true`}),p(`bots:room.composer.mentionMember`)]})]})]}),(0,$.jsx)(K,{variant:`ghost`,size:`icon-sm`,className:`rounded-full max-[650px]:hidden`,"aria-label":p(`chat:focusSession.addAttachment`),title:p(`chat:focusSession.addAttachment`),onClick:()=>void re.choose(),children:(0,$.jsx)(ae,{})}),(0,$.jsx)(`span`,{id:m,className:`ml-1 flex-none text-[12.5px] text-content-muted`,children:p(`bots:room.composer.sendToLabel`)}),(0,$.jsxs)(`div`,{role:`group`,"aria-labelledby":m,"data-room-recipients":!0,onWheel:ve,className:`flex min-w-0 flex-1 items-center gap-1 overflow-x-auto overscroll-x-contain [scrollbar-width:none] pointer-coarse:-my-2.5 pointer-coarse:py-2.5 [&::-webkit-scrollbar]:hidden`,children:[A.map((e,t)=>{let n=z.includes(e.id),r=xt(e.avatar.color),i=n&&!R;return(0,$.jsxs)($t,{size:`sm`,"aria-pressed":n,disabled:!e.enabled,className:W(rr,!n&&ir),style:n?{background:r.fill,borderColor:i?r.line:`transparent`,boxShadow:i?`0 0 0 1px ${r.fill}, 0 0 14px -1px ${r.glow}`:`none`}:void 0,onClick:()=>B(e.id,!n),children:[i&&(0,$.jsx)(ur,{delay:t*.3}),(0,$.jsx)(`span`,{"aria-hidden":`true`,className:W(`size-1.5 rounded-full`,!n&&`opacity-40`),style:{background:St(e.avatar.color).shade,...i?{boxShadow:`0 0 6px ${r.glow}`}:{}}}),e.name,!e.enabled&&(0,$.jsxs)(`span`,{className:`font-normal text-content-muted`,children:[`· `,p(`bots:room.paused`)]})]},e.id)}),A.length>1&&(0,$.jsxs)($t,{size:`sm`,"data-room-recipients-everyone":!0,"aria-pressed":R,className:W(rr,!R&&ir),style:R?lr(A):void 0,onClick:()=>{R?u&&i([]):i(`all`)},children:[R&&(0,$.jsx)(ur,{delay:0}),p(`bots:room.composer.everyone`)]})]}),he?(0,$.jsx)(`span`,{"data-room-triage-hint":!0,className:`max-w-[40%] min-w-0 flex-none truncate px-1 text-[12px] text-content-muted max-[650px]:hidden`,children:p(`bots:room.composer.triageHint`)}):me>=3?(0,$.jsx)(`span`,{className:`flex-none px-1 text-[12px] text-content-muted max-[650px]:hidden`,children:p(`bots:room.composer.wakes`,{count:me})}):ue&&!de&&le.length>0?(0,$.jsx)(`span`,{"data-room-addressed-only":!0,className:`max-w-[40%] min-w-0 flex-none truncate px-1 text-[12px] text-content-muted max-[650px]:hidden`,children:p(`bots:room.composer.addressedOnly`)}):f&&!ue&&le.length===0?(0,$.jsx)(`span`,{className:`max-w-[40%] min-w-0 flex-none truncate px-1 text-[12px] text-content-muted max-[650px]:hidden`,children:f}):null,(0,$.jsx)(ee,{queueing:!1,submitting:w,preparing:M,hasDraft:!!(g.trim()||ie),disabled:!oe})]})]})}),(0,$.jsx)(Je,{side:`top`,align:`start`,className:`w-64 p-1`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),children:(0,$.jsx)(at,{value:ce?.id||``,shouldFilter:!1,"aria-label":p(`bots:room.composer.mentionList`),children:(0,$.jsx)(it,{children:I.map(e=>(0,$.jsxs)(rt,{value:e.id,"data-room-mention-everyone":e.member?void 0:``,onMouseEnter:()=>x(e.id),onSelect:()=>ge(e),children:[e.member?(0,$.jsx)(J,{avatar:e.member.avatar,size:18,animate:!1}):(0,$.jsx)(Ne,{"aria-hidden":`true`,className:`size-[18px] p-0.5 text-content-muted`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name})]},e.id))})})})]})}function lr(e){let t=e.map(e=>xt(e.avatar.color)),n=e=>t.map(t=>t[e]).join(`, `);return{background:`linear-gradient(90deg, ${n(`fill`)}) padding-box, linear-gradient(var(--solid), var(--solid)) padding-box, linear-gradient(90deg, ${n(`line`)}) border-box`,borderColor:`transparent`,boxShadow:`0 0 14px -1px ${t[0]?.glow||`transparent`}`}}function ur({delay:e}){return(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 overflow-hidden rounded-[inherit]`,children:(0,$.jsx)(`span`,{className:`absolute inset-y-0 left-0 w-2/5 animate-[chip-sheen_3.6s_ease-in-out_infinite] bg-linear-to-r from-transparent via-white/85 to-transparent dark:via-white/45`,style:{animationDelay:`${e}s`}})})}function dr({open:e,onOpenChange:t,brief:n,members:r,onSave:i}){let{t:a}=d(),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``),[u,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(``),h=(0,Q.useRef)(!1);return(0,Q.useEffect)(()=>{e&&!h.current&&(s((n?.decisions||[]).join(`
4
4
  `)),l((n?.todos||[]).map(e=>qn(e,r)).join(`
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/public-folder-dialog-BdoTA7R9.js","assets/rolldown-runtime-B0Z9INg1.js","assets/vendor-react-DwNgTV1j.js","assets/use-i18n-DL1_y_Ge.js","assets/i18n-BigTf78f.js","assets/vendor-router-CSN_DGvx.js","assets/index-Cj4werSq.js","assets/index-PnQKlTEM.css","assets/storage-DtvZ_lEu.js","assets/vendor-state-GkUciC5H.js","assets/server-BgNvmqwJ.js","assets/createLucideIcon-Cd-3GVxJ.js","assets/triangle-alert-CE1q54ci.js","assets/button-CCcCN8tE.js","assets/vendor-ui-DvrYggeS.js","assets/dist-41X0pdUs.js","assets/utils-C8uzG5AZ.js","assets/dialog-BfkdQrrN.js","assets/x-07u4-129.js","assets/dist-BHkR6BLP.js","assets/dist-BsRXXcSL.js","assets/es2015-DTZdOI9P.js","assets/input-CPw-zkYh.js","assets/machines-api-Bd73Uc9W.js","assets/http-response-tU9Jgwk1.js","assets/http-BJXYcBJZ.js","assets/abort-signal-f4JsiYKX.js","assets/alert-DRIrgNI4.js","assets/field-DoLEb0np.js","assets/label-CVWjEcfV.js","assets/separator-BPh_qxvc.js","assets/machine-messages-C5HnwFMY.js"])))=>i.map(i=>d[i]);
2
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{h as t,u as n}from"./vendor-router-CSN_DGvx.js";import{i as r,r as i}from"./vendor-react-DwNgTV1j.js";import{t as a}from"./use-i18n-DL1_y_Ge.js";import{t as o}from"./useQuery-DfOU-27z.js";import{a as s,i as c,o as l}from"./startup-queries-mAINlcNF.js";import{a as u}from"./http-response-tU9Jgwk1.js";import{n as d}from"./http-BJXYcBJZ.js";import{t as f}from"./runtime-capabilities-store-CJA8-sSC.js";import{t as ee}from"./chevron-down-CxtxIjiP.js";import{o as te}from"./FocusRuntimeControls-yUa6cOxD.js";import{t as p}from"./folder-open-FIShC5Qk.js";import{t as m}from"./folder-plus-OPHZsJho.js";import{t as ne}from"./folder-DPM8D8cf.js";import{n as re,t as h}from"./useMachines-DbkhDwVU.js";import{t as g}from"./plus-fQbSqB1n.js";import{t as _}from"./server-BgNvmqwJ.js";import{a as v,c as y,i as b,o as x,p as ie,r as S,s as C,t as ae}from"./dropdown-menu-Ds0gD8S8.js";import{t as w}from"./utils-C8uzG5AZ.js";import{u as T}from"./events-BCP3T_26.js";import{t as E}from"./chat-api-DixX49bK.js";import{_ as D,d as O,l as k,t as A,u as j,v as M,x as N,y as P}from"./useSessionListQuery-CaaqoetW.js";import"./useNow-CyOr3v9y.js";import{a as F,i as I,n as L,t as oe}from"./useNewProjectPicker-CW-ndILs.js";import{a as se}from"./card-presentation-zU6WKfgu.js";import"./useSidebarModel-zw1ozcJm.js";import{o as ce}from"./format-DMJQzoZ7.js";import{n as R,t as z}from"./workspace-order-store-BlPd8HV9.js";import{r as B,t as V}from"./board-projects-geCUCUov.js";var H=e(r(),1),U=class extends Error{stage;cause;sessionId;code=`board_launch_failed`;constructor(e,t,n=``){super(t instanceof Error?t.message:String(t||`launch failed`)),this.stage=e,this.cause=t,this.sessionId=n}},W=1e5,G=5e3;function K(e){if(!e||typeof e!=`object`)return!1;let t=e;return Array.isArray(t.messages)&&t.messages.length===0&&t.streaming===!1&&t.configurationBusy!==!0&&(t.queuedInputs===void 0||Array.isArray(t.queuedInputs)&&t.queuedInputs.length===0)}function q(e){return e instanceof u?`${e.kind||`error`}:${e.status??`-`}`:`error`}async function J(e){let t=`/api/sessions/${encodeURIComponent(e)}`;try{if(!K(await E.getLiveSession(e,{timeout:G})))return!1;await d(t,{method:`DELETE`,timeout:G})}catch(e){return console.warn(`[board] 派发失败后未能清理空会话(${q(e)})`),!1}return s.setQueryData(k,t=>t&&{...t,sessions:t.sessions.filter(t=>t.id!==e)}),T({deletedIds:[e]}),!0}function Y(e){s.setQueryData(k,t=>t&&!t.sessions.some(t=>t.id===e.id)?{...t,sessions:[e,...t.sessions]}:t),c(`sessions`)}function le(e){let t=e.indexOf(`/`);return t>0?{provider:e.slice(0,t),modelId:e.slice(t+1)}:null}async function ue(e,t,n){let r=le(n.model);r&&n.model!==t.model&&await E.updateModel(e,r.provider,r.modelId),n.thinkingLevel&&n.thinkingLevel!==t.thinkingLevel&&await E.setThinkingLevel(e,n.thinkingLevel),n.executionMode&&n.executionMode!==t.executionMode&&await E.updateExecutionMode(e,n.executionMode),n.runMode!==`plan`&&n.runMode!==t.runMode&&await E.updateRunMode(e,n.runMode)}async function de(e){if(!e.prompt.trim().slice(0,W))throw new U(`create`,Error(`empty prompt`));let t;try{t=await E.createSession(``,e.cwd,{projectless:e.projectless===!0,machine:e.machine??null})}catch(e){throw new U(`create`,e)}let n=t.id;try{await ue(n,t,e)}catch(e){throw await J(n),new U(`configure`,e,n)}return{session:t}}var fe=/^\/[a-z][a-z0-9:-]{0,63}$/;async function pe(e){let{sessionId:t}=e,n=e.prompt.trim().slice(0,W);if(!t||!n)throw new U(`send`,Error(`empty prompt`),t);let r=e.commandWhenEmpty?.trim()??``;if(r&&!fe.test(r))throw new U(`send`,Error(`invalid command`),t);let i;try{i=await E.getLiveSession(t)}catch(e){throw new U(`send`,e,t)}let a=i&&typeof i==`object`?i:{},o=Array.isArray(a.messages)&&a.messages.length===0&&r?`${r} ${n}`:n,l=async()=>{try{await E.queueInput(t,o,[],`followUp`)}catch(e){throw new U(`send`,e,t)}return{sessionId:t,queued:!0}};if(a.streaming===!0)return l();e.created?.id===t?Y({...e.created,firstMessage:n,messageCount:1}):s.getQueryData(k)?.sessions.some(e=>e.id===t)||c(`sessions`);let u=O(t,{streaming:!0});try{await N(t,`launch`,(e,n)=>E.openStream({sessionId:t,message:o,attachments:[],goalMode:!1,teamMode:!1},e,{signal:n}))}catch(e){if(D(t,u),e instanceof j)return l();throw P().catch(()=>void 0),new U(`send`,e,t)}return M(t,e=>!!e).catch(()=>void 0).finally(()=>D(t,u)),{sessionId:t,queued:!1}}function X(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function Z(e){return typeof e==`string`?e:``}function me(e){return(Array.isArray(X(e).providers)?X(e).providers:[]).flatMap(e=>{let t=X(e),n=Z(t.id);return!n||t.configured!==!0||t.enabled===!1?[]:(Array.isArray(t.models)?t.models:[]).flatMap(e=>{let r=X(e),i=Z(r.id);return!i||r.kind!==`chat`?[]:[{key:`${n}/${i}`,label:Z(r.name)||i,providerName:Z(t.name)||n,thinkingLevels:Array.isArray(r.thinkingLevels)?r.thinkingLevels.filter(e=>typeof e==`string`):[]}]})})}function he(){let e=o(l(`config`)),t=A(),n=z(e=>e.names),r=R(e=>e.projects),i=f(e=>e.capabilities.features),a=(0,H.useMemo)(()=>me(e.data),[e.data]),s=e.data?.provider&&e.data?.model?`${e.data.provider}/${e.data.model}`:``,c=t.data?.sessions,u=(0,H.useMemo)(()=>B(c??[],r,n),[c,n,r]),d=(0,H.useMemo)(()=>V(c??[],u),[c,u]);return{models:a,defaultModel:s,defaultThinkingLevel:Z(e.data?.thinkingLevel)||`medium`,projects:u,defaultCwd:d,goalsAvailable:i.goals!==!1,teamAvailable:i.goals!==!1&&i.multiAgent!==!1,loading:e.isPending,error:e.error??null}}var Q=i(),ge=(0,H.lazy)(()=>t(()=>import(`./public-folder-dialog-BdoTA7R9.js`).then(e=>({default:e.MachineFolderDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]))),$=`\0no-project`;function _e(e){return e===`full-access`||L.includes(e)}function ve(e){return e===`plan`||e===`goal`||e===`team`}function ye({onError:e}){let{t,language:r}=a(),i=n(),o=he(),s=h(),[c,l]=(0,H.useState)(null),u=I(),[d,T]=(0,H.useState)(!1),E=(0,H.useRef)(null),D=oe({onProjectChosen:()=>void 0,onError:e}),O=f(e=>e.capabilities.features.workspaceFolders),k=o.models.some(e=>e.key===u.model),A=k?u.model:o.defaultModel,j=o.models.find(e=>e.key===A)?.thinkingLevels??[],M=j.includes(u.thinkingLevel)?u.thinkingLevel:``,N=M||(j.includes(o.defaultThinkingLevel)?o.defaultThinkingLevel:``),P=d?`full-access`:u.executionMode||`approval-required`,L=u.runMode===`team`&&!o.teamAvailable||u.runMode===`goal`&&!o.goalsAvailable?`plan`:u.runMode,R=(0,H.useMemo)(()=>{if(!u.cwd||o.projects.some(e=>e.cwd===u.cwd))return o.projects;let e=u.cwd.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||u.cwd;return[{key:u.cwd,cwd:u.cwd,label:e},...o.projects]},[u.cwd,o.projects]),z=(0,H.useMemo)(()=>se(R),[R]),B=u.projectless,V=!!u.machineId,U=s.machines.find(e=>e.id===u.machineId),{rememberLaunch:W}=u;(0,H.useEffect)(()=>{V&&s.loaded&&!U&&W({machineId:``,machineCwd:``})},[U,V,s.loaded,W]);let G=V||B?``:u.cwd||o.defaultCwd||R[0]?.cwd||``,K=V||B?void 0:R.find(e=>e.cwd===G),q=`${U?.name??``}:${ce(u.machineCwd,r)}`,J=V?q:K?.label||t(B?`board:launch.noProject`:`board:launch.defaultProject`),Y=t(`board:launch.projectLabel`,{project:K?z.get(K.key)?`${K.label} (${z.get(K.key)})`:K.label:J});return{cwd:G,model:A,thinkingLevel:N,availableThinkingLevels:j,executionMode:P,runMode:L,onModelChange:e=>u.rememberLaunch({model:e,thinkingLevel:``}),onThinkingLevelChange:e=>u.rememberLaunch({thinkingLevel:e}),onExecutionModeChange:e=>_e(e)?(T(e===`full-access`),e!==`full-access`&&u.rememberLaunch({executionMode:e}),!0):!1,onRunModeChange:e=>ve(e)?(u.rememberLaunch({runMode:e}),!0):!1,renderProjectControl:e=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(ae,{children:[(0,Q.jsx)(ie,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:e===`header`?`relative inline-flex h-6 max-w-full min-w-0 cursor-pointer items-center gap-1 rounded-full px-2 text-xs leading-4 text-content-muted outline-none after:absolute after:-inset-x-1 after:-inset-y-2.5 after:content-[""] focus-visible:outline-2 focus-visible:outline-focus active:bg-surface-hover aria-expanded:bg-surface-hover`:w(te,`max-w-[24ch] max-[650px]:max-w-[14ch]`),title:V?`${U?.name??``}:${u.machineCwd}`:K?.cwd||void 0,"aria-label":Y,"data-new-task-project":V?`machine:${u.machineId}`:B?`none`:G||`default`,children:[V?(0,Q.jsx)(_,{size:e===`header`?12:14,className:`shrink-0`,"aria-hidden":`true`}):(0,Q.jsx)(ne,{size:e===`header`?12:14,className:`shrink-0`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:w(`min-w-0 truncate`,(K?.label||V)&&`font-mono`),children:J}),(0,Q.jsx)(ee,{size:e===`header`?12:14,className:w(`shrink-0 opacity-70`,e===`chip`&&`max-[650px]:hidden`),"aria-hidden":`true`})]})}),(0,Q.jsxs)(S,{align:e===`header`?`center`:`start`,side:e===`header`?`bottom`:`top`,className:`max-h-[min(24rem,var(--radix-dropdown-menu-content-available-height))] w-64 overflow-y-auto`,onCloseAutoFocus:e=>{let t=E.current;t&&(E.current=null,e.preventDefault(),t())},children:[(0,Q.jsxs)(x,{value:V?``:B?$:G,onValueChange:e=>u.rememberLaunch(e===$?{projectless:!0}:{cwd:e}),children:[(0,Q.jsx)(C,{value:$,children:(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:t(`board:launch.noProject`)})}),(0,Q.jsx)(y,{}),(0,Q.jsx)(v,{children:t(`board:launch.projects`)}),R.length===0&&(0,Q.jsx)(C,{value:``,children:t(`board:launch.defaultProject`)}),R.map(e=>(0,Q.jsxs)(C,{value:e.cwd,title:e.cwd,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:e.label}),z.get(e.key)&&(0,Q.jsx)(`span`,{className:`ml-auto min-w-0 truncate pl-2 font-mono text-xs text-content-muted`,children:z.get(e.key)})]},e.key))]}),(0,Q.jsx)(y,{}),(0,Q.jsxs)(b,{disabled:D.picking,"data-launch-new-project":!0,onSelect:()=>E.current=()=>void D.newProject(),children:[(0,Q.jsx)(p,{"aria-hidden":`true`}),t(`board:launch.chooseFolder`)]}),O&&(0,Q.jsxs)(b,{"data-launch-new-folder":!0,onSelect:()=>E.current=()=>D.newFolder(G||o.defaultCwd),children:[(0,Q.jsx)(m,{"aria-hidden":`true`}),t(`board:launch.newFolder`)]}),s.available&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(y,{}),(0,Q.jsx)(v,{children:t(`board:launch.machines`)}),s.machines.map(e=>(0,Q.jsxs)(b,{"data-launch-machine":e.id,onSelect:()=>E.current=()=>l(e),children:[e.kind===`ssh`?(0,Q.jsx)(_,{"aria-hidden":`true`}):(0,Q.jsx)(re,{"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:w(`ml-auto size-2 flex-none rounded-full`,e.online?`bg-success`:`bg-content-faint`)})]},e.id)),(0,Q.jsxs)(b,{"data-launch-add-machine":!0,onSelect:()=>i(`/config/remote-access`),children:[(0,Q.jsx)(g,{"aria-hidden":`true`}),t(`board:launch.addMachine`)]})]})]})]}),(0,Q.jsx)(F,{picker:D.picker,folderDialog:D.folderDialog}),c&&(0,Q.jsx)(H.Suspense,{fallback:null,children:(0,Q.jsx)(ge,{machine:c,initialCwd:c?.id===u.machineId?u.machineCwd:c?.defaultCwd??``,onOpenChange:e=>{e||l(null)},onChosen:(e,t)=>{W({machineId:e.id,machineCwd:t}),l(null)}})})]}),prepare:e=>de({prompt:e,cwd:G,projectless:B,machine:V?{id:u.machineId,cwd:u.machineCwd}:null,model:k?A:``,thinkingLevel:M,executionMode:P,runMode:L}),onSent:()=>{T(!1)}}}export{pe as n,ye as t};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/public-folder-dialog-Dmd5Qull.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/server-BgNvmqwJ.js","assets/createLucideIcon-Cd-3GVxJ.js","assets/triangle-alert-CE1q54ci.js","assets/button-CCcCN8tE.js","assets/vendor-ui-DvrYggeS.js","assets/dist-41X0pdUs.js","assets/utils-C8uzG5AZ.js","assets/dialog-CW8GeCdI.js","assets/x-07u4-129.js","assets/dist-BHkR6BLP.js","assets/dist-BsRXXcSL.js","assets/es2015-DTZdOI9P.js","assets/input-CPw-zkYh.js","assets/machines-api-Brwmi001.js","assets/http-response-DObpyFrX.js","assets/http-CMHs5x9g.js","assets/abort-signal-f4JsiYKX.js","assets/alert-DRIrgNI4.js","assets/field-DoLEb0np.js","assets/label-CVWjEcfV.js","assets/separator-BPh_qxvc.js","assets/machine-messages-BZFO3mNM.js"])))=>i.map(i=>d[i]);
2
+ import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{h as t,u as n}from"./vendor-router-CSN_DGvx.js";import{i as r,r as i}from"./vendor-react-DwNgTV1j.js";import{t as a}from"./use-i18n-BqDnJFL5.js";import{t as o}from"./useQuery-DfOU-27z.js";import{a as s,i as c,o as l}from"./startup-queries-Cc9LSolC.js";import{a as u}from"./http-response-DObpyFrX.js";import{n as d}from"./http-CMHs5x9g.js";import{t as f}from"./runtime-capabilities-store-aG2QVT6b.js";import{t as ee}from"./chevron-down-CxtxIjiP.js";import{o as te}from"./FocusRuntimeControls-CoEB10QW.js";import{t as p}from"./folder-open-FIShC5Qk.js";import{t as m}from"./folder-plus-OPHZsJho.js";import{t as ne}from"./folder-DPM8D8cf.js";import{n as re,t as h}from"./useMachines-Cv7VNdjI.js";import{t as g}from"./plus-fQbSqB1n.js";import{t as _}from"./server-BgNvmqwJ.js";import{a as v,c as y,i as b,o as x,p as ie,r as S,s as C,t as ae}from"./dropdown-menu-Ds0gD8S8.js";import{t as w}from"./utils-C8uzG5AZ.js";import{u as T}from"./events-CAivTGZK.js";import{t as E}from"./chat-api-BSs2idF4.js";import{_ as D,d as O,l as k,t as A,u as j,v as M,x as N,y as P}from"./useSessionListQuery-mhLtsKkB.js";import"./useNow-tTW4r_Vo.js";import{a as F,i as I,n as L,t as oe}from"./useNewProjectPicker-DRZ4v1BJ.js";import{a as se}from"./card-presentation-zU6WKfgu.js";import"./useSidebarModel-D21Q54-Q.js";import{o as ce}from"./format-DMJQzoZ7.js";import{n as R,t as z}from"./workspace-order-store-Cv4TWT44.js";import{r as B,t as V}from"./board-projects-DHtEAHvu.js";var H=e(r(),1),U=class extends Error{stage;cause;sessionId;code=`board_launch_failed`;constructor(e,t,n=``){super(t instanceof Error?t.message:String(t||`launch failed`)),this.stage=e,this.cause=t,this.sessionId=n}},W=1e5,G=5e3;function K(e){if(!e||typeof e!=`object`)return!1;let t=e;return Array.isArray(t.messages)&&t.messages.length===0&&t.streaming===!1&&t.configurationBusy!==!0&&(t.queuedInputs===void 0||Array.isArray(t.queuedInputs)&&t.queuedInputs.length===0)}function q(e){return e instanceof u?`${e.kind||`error`}:${e.status??`-`}`:`error`}async function J(e){let t=`/api/sessions/${encodeURIComponent(e)}`;try{if(!K(await E.getLiveSession(e,{timeout:G})))return!1;await d(t,{method:`DELETE`,timeout:G})}catch(e){return console.warn(`[board] 派发失败后未能清理空会话(${q(e)})`),!1}return s.setQueryData(k,t=>t&&{...t,sessions:t.sessions.filter(t=>t.id!==e)}),T({deletedIds:[e]}),!0}function Y(e){s.setQueryData(k,t=>t&&!t.sessions.some(t=>t.id===e.id)?{...t,sessions:[e,...t.sessions]}:t),c(`sessions`)}function le(e){let t=e.indexOf(`/`);return t>0?{provider:e.slice(0,t),modelId:e.slice(t+1)}:null}async function ue(e,t,n){let r=le(n.model);r&&n.model!==t.model&&await E.updateModel(e,r.provider,r.modelId),n.thinkingLevel&&n.thinkingLevel!==t.thinkingLevel&&await E.setThinkingLevel(e,n.thinkingLevel),n.executionMode&&n.executionMode!==t.executionMode&&await E.updateExecutionMode(e,n.executionMode),n.runMode!==`plan`&&n.runMode!==t.runMode&&await E.updateRunMode(e,n.runMode)}async function de(e){if(!e.prompt.trim().slice(0,W))throw new U(`create`,Error(`empty prompt`));let t;try{t=await E.createSession(``,e.cwd,{projectless:e.projectless===!0,machine:e.machine??null})}catch(e){throw new U(`create`,e)}let n=t.id;try{await ue(n,t,e)}catch(e){throw await J(n),new U(`configure`,e,n)}return{session:t}}var fe=/^\/[a-z][a-z0-9:-]{0,63}$/;async function pe(e){let{sessionId:t}=e,n=e.prompt.trim().slice(0,W);if(!t||!n)throw new U(`send`,Error(`empty prompt`),t);let r=e.commandWhenEmpty?.trim()??``;if(r&&!fe.test(r))throw new U(`send`,Error(`invalid command`),t);let i;try{i=await E.getLiveSession(t)}catch(e){throw new U(`send`,e,t)}let a=i&&typeof i==`object`?i:{},o=Array.isArray(a.messages)&&a.messages.length===0&&r?`${r} ${n}`:n,l=async()=>{try{await E.queueInput(t,o,[],`followUp`)}catch(e){throw new U(`send`,e,t)}return{sessionId:t,queued:!0}};if(a.streaming===!0)return l();e.created?.id===t?Y({...e.created,firstMessage:n,messageCount:1}):s.getQueryData(k)?.sessions.some(e=>e.id===t)||c(`sessions`);let u=O(t,{streaming:!0});try{await N(t,`launch`,(e,n)=>E.openStream({sessionId:t,message:o,attachments:[],goalMode:!1,teamMode:!1},e,{signal:n}))}catch(e){if(D(t,u),e instanceof j)return l();throw P().catch(()=>void 0),new U(`send`,e,t)}return M(t,e=>!!e).catch(()=>void 0).finally(()=>D(t,u)),{sessionId:t,queued:!1}}function X(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function Z(e){return typeof e==`string`?e:``}function me(e){return(Array.isArray(X(e).providers)?X(e).providers:[]).flatMap(e=>{let t=X(e),n=Z(t.id);return!n||t.configured!==!0||t.enabled===!1?[]:(Array.isArray(t.models)?t.models:[]).flatMap(e=>{let r=X(e),i=Z(r.id);return!i||r.kind!==`chat`?[]:[{key:`${n}/${i}`,label:Z(r.name)||i,providerName:Z(t.name)||n,thinkingLevels:Array.isArray(r.thinkingLevels)?r.thinkingLevels.filter(e=>typeof e==`string`):[]}]})})}function he(){let e=o(l(`config`)),t=A(),n=z(e=>e.names),r=R(e=>e.projects),i=f(e=>e.capabilities.features),a=(0,H.useMemo)(()=>me(e.data),[e.data]),s=e.data?.provider&&e.data?.model?`${e.data.provider}/${e.data.model}`:``,c=t.data?.sessions,u=(0,H.useMemo)(()=>B(c??[],r,n),[c,n,r]),d=(0,H.useMemo)(()=>V(c??[],u),[c,u]);return{models:a,defaultModel:s,defaultThinkingLevel:Z(e.data?.thinkingLevel)||`medium`,projects:u,defaultCwd:d,goalsAvailable:i.goals!==!1,teamAvailable:i.goals!==!1&&i.multiAgent!==!1,loading:e.isPending,error:e.error??null}}var Q=i(),ge=(0,H.lazy)(()=>t(()=>import(`./public-folder-dialog-Dmd5Qull.js`).then(e=>({default:e.MachineFolderDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]))),$=`\0no-project`;function _e(e){return e===`full-access`||L.includes(e)}function ve(e){return e===`plan`||e===`goal`||e===`team`}function ye({onError:e}){let{t,language:r}=a(),i=n(),o=he(),s=h(),[c,l]=(0,H.useState)(null),u=I(),[d,T]=(0,H.useState)(!1),E=(0,H.useRef)(null),D=oe({onProjectChosen:()=>void 0,onError:e}),O=f(e=>e.capabilities.features.workspaceFolders),k=o.models.some(e=>e.key===u.model),A=k?u.model:o.defaultModel,j=o.models.find(e=>e.key===A)?.thinkingLevels??[],M=j.includes(u.thinkingLevel)?u.thinkingLevel:``,N=M||(j.includes(o.defaultThinkingLevel)?o.defaultThinkingLevel:``),P=d?`full-access`:u.executionMode||`approval-required`,L=u.runMode===`team`&&!o.teamAvailable||u.runMode===`goal`&&!o.goalsAvailable?`plan`:u.runMode,R=(0,H.useMemo)(()=>{if(!u.cwd||o.projects.some(e=>e.cwd===u.cwd))return o.projects;let e=u.cwd.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||u.cwd;return[{key:u.cwd,cwd:u.cwd,label:e},...o.projects]},[u.cwd,o.projects]),z=(0,H.useMemo)(()=>se(R),[R]),B=u.projectless,V=!!u.machineId,U=s.machines.find(e=>e.id===u.machineId),{rememberLaunch:W}=u;(0,H.useEffect)(()=>{V&&s.loaded&&!U&&W({machineId:``,machineCwd:``})},[U,V,s.loaded,W]);let G=V||B?``:u.cwd||o.defaultCwd||R[0]?.cwd||``,K=V||B?void 0:R.find(e=>e.cwd===G),q=`${U?.name??``}:${ce(u.machineCwd,r)}`,J=V?q:K?.label||t(B?`board:launch.noProject`:`board:launch.defaultProject`),Y=t(`board:launch.projectLabel`,{project:K?z.get(K.key)?`${K.label} (${z.get(K.key)})`:K.label:J});return{cwd:G,model:A,thinkingLevel:N,availableThinkingLevels:j,executionMode:P,runMode:L,onModelChange:e=>u.rememberLaunch({model:e,thinkingLevel:``}),onThinkingLevelChange:e=>u.rememberLaunch({thinkingLevel:e}),onExecutionModeChange:e=>_e(e)?(T(e===`full-access`),e!==`full-access`&&u.rememberLaunch({executionMode:e}),!0):!1,onRunModeChange:e=>ve(e)?(u.rememberLaunch({runMode:e}),!0):!1,renderProjectControl:e=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(ae,{children:[(0,Q.jsx)(ie,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:e===`header`?`relative inline-flex h-6 max-w-full min-w-0 cursor-pointer items-center gap-1 rounded-full px-2 text-xs leading-4 text-content-muted outline-none after:absolute after:-inset-x-1 after:-inset-y-2.5 after:content-[""] focus-visible:outline-2 focus-visible:outline-focus active:bg-surface-hover aria-expanded:bg-surface-hover`:w(te,`max-w-[24ch] max-[650px]:max-w-[14ch]`),title:V?`${U?.name??``}:${u.machineCwd}`:K?.cwd||void 0,"aria-label":Y,"data-new-task-project":V?`machine:${u.machineId}`:B?`none`:G||`default`,children:[V?(0,Q.jsx)(_,{size:e===`header`?12:14,className:`shrink-0`,"aria-hidden":`true`}):(0,Q.jsx)(ne,{size:e===`header`?12:14,className:`shrink-0`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:w(`min-w-0 truncate`,(K?.label||V)&&`font-mono`),children:J}),(0,Q.jsx)(ee,{size:e===`header`?12:14,className:w(`shrink-0 opacity-70`,e===`chip`&&`max-[650px]:hidden`),"aria-hidden":`true`})]})}),(0,Q.jsxs)(S,{align:e===`header`?`center`:`start`,side:e===`header`?`bottom`:`top`,className:`max-h-[min(24rem,var(--radix-dropdown-menu-content-available-height))] w-64 overflow-y-auto`,onCloseAutoFocus:e=>{let t=E.current;t&&(E.current=null,e.preventDefault(),t())},children:[(0,Q.jsxs)(x,{value:V?``:B?$:G,onValueChange:e=>u.rememberLaunch(e===$?{projectless:!0}:{cwd:e}),children:[(0,Q.jsx)(C,{value:$,children:(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:t(`board:launch.noProject`)})}),(0,Q.jsx)(y,{}),(0,Q.jsx)(v,{children:t(`board:launch.projects`)}),R.length===0&&(0,Q.jsx)(C,{value:``,children:t(`board:launch.defaultProject`)}),R.map(e=>(0,Q.jsxs)(C,{value:e.cwd,title:e.cwd,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:e.label}),z.get(e.key)&&(0,Q.jsx)(`span`,{className:`ml-auto min-w-0 truncate pl-2 font-mono text-xs text-content-muted`,children:z.get(e.key)})]},e.key))]}),(0,Q.jsx)(y,{}),(0,Q.jsxs)(b,{disabled:D.picking,"data-launch-new-project":!0,onSelect:()=>E.current=()=>void D.newProject(),children:[(0,Q.jsx)(p,{"aria-hidden":`true`}),t(`board:launch.chooseFolder`)]}),O&&(0,Q.jsxs)(b,{"data-launch-new-folder":!0,onSelect:()=>E.current=()=>D.newFolder(G||o.defaultCwd),children:[(0,Q.jsx)(m,{"aria-hidden":`true`}),t(`board:launch.newFolder`)]}),s.available&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(y,{}),(0,Q.jsx)(v,{children:t(`board:launch.machines`)}),s.machines.map(e=>(0,Q.jsxs)(b,{"data-launch-machine":e.id,onSelect:()=>E.current=()=>l(e),children:[e.kind===`ssh`?(0,Q.jsx)(_,{"aria-hidden":`true`}):(0,Q.jsx)(re,{"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:w(`ml-auto size-2 flex-none rounded-full`,e.online?`bg-success`:`bg-content-faint`)})]},e.id)),(0,Q.jsxs)(b,{"data-launch-add-machine":!0,onSelect:()=>i(`/config/remote-access`),children:[(0,Q.jsx)(g,{"aria-hidden":`true`}),t(`board:launch.addMachine`)]})]})]})]}),(0,Q.jsx)(F,{picker:D.picker,folderDialog:D.folderDialog}),c&&(0,Q.jsx)(H.Suspense,{fallback:null,children:(0,Q.jsx)(ge,{machine:c,initialCwd:c?.id===u.machineId?u.machineCwd:c?.defaultCwd??``,onOpenChange:e=>{e||l(null)},onChosen:(e,t)=>{W({machineId:e.id,machineCwd:t}),l(null)}})})]}),prepare:e=>de({prompt:e,cwd:G,projectless:B,machine:V?{id:u.machineId,cwd:u.machineCwd}:null,model:k?A:``,thinkingLevel:M,executionMode:P,runMode:L}),onSent:()=>{T(!1)}}}export{pe as n,ye as t};
@@ -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"./runtime-capabilities-store-CJA8-sSC.js";import{t as a}from"./arrow-right-DqLOhpA2.js";import{t as o}from"./download-BCfIiuaL.js";import{t as s}from"./key-round-C29uZbsf.js";import{t as c}from"./search-D0mqDaf_.js";import{t as l}from"./server-BgNvmqwJ.js";import{t as u}from"./x-07u4-129.js";import{t as d}from"./utils-C8uzG5AZ.js";import{t as f}from"./button-CCcCN8tE.js";import{t as p}from"./kbd-CAufZTkl.js";import{n as m,r as h}from"./config-search-B5mtRMAH.js";import{s as g}from"./shortcuts-Cth0vc77.js";import{a as _,i as v,l as y,o as b,s as x,t as S}from"./dialog-BfkdQrrN.js";import{t as C}from"./input-CPw-zkYh.js";import{t as w}from"./BrandLogo-k3CvJjd4.js";var T=e(t(),1),E=n();function D({query:e,onQueryChange:t,onSelect:n,inputRef:a,placement:o=`toolbar`}){let{t:s,language:l}=r(),[u,f]=(0,T.useState)(!1),[_,v]=(0,T.useState)(0),y=(0,T.useRef)(null),b=i(e=>e.capabilities),x=g(`focusSearch`),S=(0,T.useMemo)(()=>h(e,l,{capabilities:b,mobileApp:!!window.__PISPER_MOBILE_APP__}),[l,e,b]);(0,T.useEffect)(()=>v(0),[e]),(0,T.useEffect)(()=>{if(!u)return;let e=e=>{y.current&&!y.current.contains(e.target)&&f(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[u]);let w=e=>{if(f(!1),t(``),e.entry.card===`interface-custom-ui`){n(e.entry.section,`widgets`);return}m(e.entry.card,e.entry.section,{targetId:e.entry.targetId,targetText:e.title,expandGroup:e.entry.expandGroup}),n(e.entry.section)},D=u&&e.trim().length>0;return(0,E.jsxs)(`div`,{ref:y,className:d(`relative`,o===`sidebar`?`w-full`:`w-[min(250px,24vw)] max-[900px]:w-[190px] max-[650px]:col-start-1 max-[650px]:row-start-1 max-[650px]:w-full max-[650px]:min-w-0`),children:[(0,E.jsx)(c,{size:15,"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-2.5 -translate-y-1/2 text-content-muted`}),(0,E.jsx)(C,{ref:a,value:e,title:s(`navigation:pageHeader.search`),"aria-label":s(`navigation:pageHeader.search`),className:d(`pl-8 text-sm`,o!==`sidebar`&&`max-[650px]:h-11 max-[650px]:text-[16px]`,o===`sidebar`&&`h-8 border-key-border bg-key pr-9 text-ellipsis shadow-key`),placeholder:s(o===`sidebar`?`config:configSearch.placeholderShort`:`config:configSearch.placeholder`),onChange:e=>{t(e.target.value),f(!0)},onFocus:()=>{e.trim()&&f(!0)},onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),t(``),f(!1)):e.key===`ArrowDown`?(e.preventDefault(),v(e=>Math.min(e+1,S.length-1))):e.key===`ArrowUp`?(e.preventDefault(),v(e=>Math.max(e-1,0))):e.key===`Enter`&&S[_]&&(e.preventDefault(),w(S[_]))}}),o===`sidebar`&&x&&!e&&(0,E.jsx)(p,{className:`absolute top-1/2 right-2 -translate-y-1/2 pointer-coarse:hidden`,children:x}),D&&(0,E.jsx)(`div`,{className:`absolute top-full left-0 z-50 mt-1.5 w-full overflow-hidden rounded-md bg-solid shadow-float`,children:S.length===0?(0,E.jsx)(`p`,{role:`status`,className:`px-3 py-3 text-xs text-content-muted`,children:s(`config:configSearch.noResults`)}):(0,E.jsx)(`ul`,{className:`max-h-[280px] overflow-auto py-1`,children:S.map((e,t)=>(0,E.jsx)(`li`,{children:(0,E.jsxs)(`button`,{type:`button`,className:d(`flex w-full flex-col gap-0.5 px-3 py-1.5 text-left pointer-coarse:min-h-11`,t===_?`bg-surface-hover`:`hover:bg-surface-subtle`),onMouseEnter:()=>v(t),onClick:()=>w(e),children:[(0,E.jsx)(`span`,{className:`text-sm text-content`,children:e.title}),(0,E.jsx)(`span`,{className:`text-xs text-content-muted`,children:e.sectionTitle})]})},e.entry.id))})})]})}function O({open:e,onDismiss:t,onOpenImport:n,onOpenSettings:i}){let{t:c}=r();return(0,E.jsx)(S,{open:e,onOpenChange:e=>!e&&t(),children:(0,E.jsxs)(v,{showCloseButton:!1,overlayClassName:`z-[220]`,className:`z-[220] gap-0 rounded-[var(--r-lg)] border border-stroke bg-solid p-0`,style:{maxWidth:`min(28rem, calc(100vw - max(1rem, env(safe-area-inset-left), env(safe-area-inset-right)) - max(1rem, env(safe-area-inset-left), env(safe-area-inset-right))))`,maxHeight:`calc(100dvh - max(1rem, env(safe-area-inset-top), env(safe-area-inset-bottom)) - max(1rem, env(safe-area-inset-top), env(safe-area-inset-bottom)))`},"aria-describedby":`model-onboarding-description`,children:[(0,E.jsxs)(`div`,{className:`relative px-5 pt-5 pb-2 max-[650px]:px-4 max-[650px]:pt-4`,children:[(0,E.jsxs)(x,{className:`gap-3 pr-9 text-left`,children:[(0,E.jsx)(`span`,{"aria-hidden":`true`,className:`w-fit rounded-[13px] shadow-raise`,children:(0,E.jsx)(w,{size:44})}),(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(`p`,{className:`text-xs font-medium text-content-muted`,children:c(`config:modelOnboarding.eyebrow`)}),(0,E.jsx)(y,{className:`text-[length:calc(var(--ui-font-size)*10/7)] leading-[1.3] font-semibold tracking-[-.015em]`,children:c(`config:modelOnboarding.title`)}),(0,E.jsx)(_,{id:`model-onboarding-description`,className:`leading-6`,children:c(`config:modelOnboarding.description`)})]})]}),(0,E.jsx)(f,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`absolute top-3 right-3 pointer-coarse:size-11`,"aria-label":c(`common:ui.closeDialog`),title:c(`common:ui.closeDialog`),onClick:t,children:(0,E.jsx)(u,{})})]}),(0,E.jsxs)(`div`,{className:`grid gap-3 px-5 pt-2 pb-4 max-[650px]:px-4`,children:[(0,E.jsx)(`ol`,{className:`m-0 list-none divide-y divide-stroke-soft border-y border-stroke-soft p-0`,children:[{Icon:l,title:c(`config:modelOnboarding.connectionTitle`),description:c(`config:modelOnboarding.connectionDescription`)},{Icon:s,title:c(`config:modelOnboarding.modelTitle`),description:c(`config:modelOnboarding.modelDescription`)}].map(({Icon:e,title:t,description:n},r)=>(0,E.jsxs)(`li`,{className:`flex items-start gap-3 py-3`,children:[(0,E.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-7 shrink-0 place-items-center rounded-full bg-surface-subtle text-xs font-medium text-content-secondary tabular-nums`,children:r+1}),(0,E.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,E.jsxs)(`strong`,{className:`flex items-center gap-1.5 text-sm font-medium text-content`,children:[(0,E.jsx)(e,{className:`size-3.5 text-content-muted`,"aria-hidden":`true`}),t]}),(0,E.jsx)(`p`,{className:`text-xs leading-5 text-content-muted`,children:n})]})]},t))}),(0,E.jsxs)(f,{type:`button`,variant:`secondary`,className:`w-full max-[650px]:h-11`,onClick:n,children:[(0,E.jsx)(o,{}),c(`config:modelOnboarding.findExisting`)]})]}),(0,E.jsxs)(b,{className:`m-0 rounded-none px-5 pt-3 max-[650px]:px-4`,style:{paddingBottom:`max(env(safe-area-inset-bottom), 1rem)`},children:[(0,E.jsx)(f,{type:`button`,variant:`ghost`,className:`max-[650px]:h-11`,onClick:t,children:c(`config:modelOnboarding.later`)}),(0,E.jsxs)(f,{type:`button`,className:`max-[650px]:h-11`,onClick:i,children:[c(`config:modelOnboarding.openSettings`),(0,E.jsx)(a,{})]})]})]})})}export{D as ConfigSearchBox,O as ModelOnboardingDialog};
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"./runtime-capabilities-store-aG2QVT6b.js";import{t as a}from"./arrow-right-DqLOhpA2.js";import{t as o}from"./download-BCfIiuaL.js";import{t as s}from"./key-round-C29uZbsf.js";import{t as c}from"./search-D0mqDaf_.js";import{t as l}from"./server-BgNvmqwJ.js";import{t as u}from"./x-07u4-129.js";import{t as d}from"./utils-C8uzG5AZ.js";import{t as f}from"./button-CCcCN8tE.js";import{t as p}from"./kbd-CAufZTkl.js";import{n as m,r as h}from"./config-search-DQ-bCU2h.js";import{s as g}from"./shortcuts-DsFEMyT1.js";import{a as _,i as v,l as y,o as b,s as x,t as S}from"./dialog-CW8GeCdI.js";import{t as C}from"./input-CPw-zkYh.js";import{t as w}from"./BrandLogo-k3CvJjd4.js";var T=e(t(),1),E=n();function D({query:e,onQueryChange:t,onSelect:n,inputRef:a,placement:o=`toolbar`}){let{t:s,language:l}=r(),[u,f]=(0,T.useState)(!1),[_,v]=(0,T.useState)(0),y=(0,T.useRef)(null),b=i(e=>e.capabilities),x=g(`focusSearch`),S=(0,T.useMemo)(()=>h(e,l,{capabilities:b,mobileApp:!!window.__PISPER_MOBILE_APP__}),[l,e,b]);(0,T.useEffect)(()=>v(0),[e]),(0,T.useEffect)(()=>{if(!u)return;let e=e=>{y.current&&!y.current.contains(e.target)&&f(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[u]);let w=e=>{if(f(!1),t(``),e.entry.card===`interface-custom-ui`){n(e.entry.section,`widgets`);return}m(e.entry.card,e.entry.section,{targetId:e.entry.targetId,targetText:e.title,expandGroup:e.entry.expandGroup}),n(e.entry.section)},D=u&&e.trim().length>0;return(0,E.jsxs)(`div`,{ref:y,className:d(`relative`,o===`sidebar`?`w-full`:`w-[min(250px,24vw)] max-[900px]:w-[190px] max-[650px]:col-start-1 max-[650px]:row-start-1 max-[650px]:w-full max-[650px]:min-w-0`),children:[(0,E.jsx)(c,{size:15,"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-2.5 -translate-y-1/2 text-content-muted`}),(0,E.jsx)(C,{ref:a,value:e,title:s(`navigation:pageHeader.search`),"aria-label":s(`navigation:pageHeader.search`),className:d(`pl-8 text-sm`,o!==`sidebar`&&`max-[650px]:h-11 max-[650px]:text-[16px]`,o===`sidebar`&&`h-8 border-key-border bg-key pr-9 text-ellipsis shadow-key`),placeholder:s(o===`sidebar`?`config:configSearch.placeholderShort`:`config:configSearch.placeholder`),onChange:e=>{t(e.target.value),f(!0)},onFocus:()=>{e.trim()&&f(!0)},onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),t(``),f(!1)):e.key===`ArrowDown`?(e.preventDefault(),v(e=>Math.min(e+1,S.length-1))):e.key===`ArrowUp`?(e.preventDefault(),v(e=>Math.max(e-1,0))):e.key===`Enter`&&S[_]&&(e.preventDefault(),w(S[_]))}}),o===`sidebar`&&x&&!e&&(0,E.jsx)(p,{className:`absolute top-1/2 right-2 -translate-y-1/2 pointer-coarse:hidden`,children:x}),D&&(0,E.jsx)(`div`,{className:`absolute top-full left-0 z-50 mt-1.5 w-full overflow-hidden rounded-md bg-solid shadow-float`,children:S.length===0?(0,E.jsx)(`p`,{role:`status`,className:`px-3 py-3 text-xs text-content-muted`,children:s(`config:configSearch.noResults`)}):(0,E.jsx)(`ul`,{className:`max-h-[280px] overflow-auto py-1`,children:S.map((e,t)=>(0,E.jsx)(`li`,{children:(0,E.jsxs)(`button`,{type:`button`,className:d(`flex w-full flex-col gap-0.5 px-3 py-1.5 text-left pointer-coarse:min-h-11`,t===_?`bg-surface-hover`:`hover:bg-surface-subtle`),onMouseEnter:()=>v(t),onClick:()=>w(e),children:[(0,E.jsx)(`span`,{className:`text-sm text-content`,children:e.title}),(0,E.jsx)(`span`,{className:`text-xs text-content-muted`,children:e.sectionTitle})]})},e.entry.id))})})]})}function O({open:e,onDismiss:t,onOpenImport:n,onOpenSettings:i}){let{t:c}=r();return(0,E.jsx)(S,{open:e,onOpenChange:e=>!e&&t(),children:(0,E.jsxs)(v,{showCloseButton:!1,overlayClassName:`z-[220]`,className:`z-[220] gap-0 rounded-[var(--r-lg)] border border-stroke bg-solid p-0`,style:{maxWidth:`min(28rem, calc(100vw - max(1rem, env(safe-area-inset-left), env(safe-area-inset-right)) - max(1rem, env(safe-area-inset-left), env(safe-area-inset-right))))`,maxHeight:`calc(100dvh - max(1rem, env(safe-area-inset-top), env(safe-area-inset-bottom)) - max(1rem, env(safe-area-inset-top), env(safe-area-inset-bottom)))`},"aria-describedby":`model-onboarding-description`,children:[(0,E.jsxs)(`div`,{className:`relative px-5 pt-5 pb-2 max-[650px]:px-4 max-[650px]:pt-4`,children:[(0,E.jsxs)(x,{className:`gap-3 pr-9 text-left`,children:[(0,E.jsx)(`span`,{"aria-hidden":`true`,className:`w-fit rounded-[13px] shadow-raise`,children:(0,E.jsx)(w,{size:44})}),(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(`p`,{className:`text-xs font-medium text-content-muted`,children:c(`config:modelOnboarding.eyebrow`)}),(0,E.jsx)(y,{className:`text-[length:calc(var(--ui-font-size)*10/7)] leading-[1.3] font-semibold tracking-[-.015em]`,children:c(`config:modelOnboarding.title`)}),(0,E.jsx)(_,{id:`model-onboarding-description`,className:`leading-6`,children:c(`config:modelOnboarding.description`)})]})]}),(0,E.jsx)(f,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`absolute top-3 right-3 pointer-coarse:size-11`,"aria-label":c(`common:ui.closeDialog`),title:c(`common:ui.closeDialog`),onClick:t,children:(0,E.jsx)(u,{})})]}),(0,E.jsxs)(`div`,{className:`grid gap-3 px-5 pt-2 pb-4 max-[650px]:px-4`,children:[(0,E.jsx)(`ol`,{className:`m-0 list-none divide-y divide-stroke-soft border-y border-stroke-soft p-0`,children:[{Icon:l,title:c(`config:modelOnboarding.connectionTitle`),description:c(`config:modelOnboarding.connectionDescription`)},{Icon:s,title:c(`config:modelOnboarding.modelTitle`),description:c(`config:modelOnboarding.modelDescription`)}].map(({Icon:e,title:t,description:n},r)=>(0,E.jsxs)(`li`,{className:`flex items-start gap-3 py-3`,children:[(0,E.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-7 shrink-0 place-items-center rounded-full bg-surface-subtle text-xs font-medium text-content-secondary tabular-nums`,children:r+1}),(0,E.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,E.jsxs)(`strong`,{className:`flex items-center gap-1.5 text-sm font-medium text-content`,children:[(0,E.jsx)(e,{className:`size-3.5 text-content-muted`,"aria-hidden":`true`}),t]}),(0,E.jsx)(`p`,{className:`text-xs leading-5 text-content-muted`,children:n})]})]},t))}),(0,E.jsxs)(f,{type:`button`,variant:`secondary`,className:`w-full max-[650px]:h-11`,onClick:n,children:[(0,E.jsx)(o,{}),c(`config:modelOnboarding.findExisting`)]})]}),(0,E.jsxs)(b,{className:`m-0 rounded-none px-5 pt-3 max-[650px]:px-4`,style:{paddingBottom:`max(env(safe-area-inset-bottom), 1rem)`},children:[(0,E.jsx)(f,{type:`button`,variant:`ghost`,className:`max-[650px]:h-11`,onClick:t,children:c(`config:modelOnboarding.later`)}),(0,E.jsxs)(f,{type:`button`,className:`max-[650px]:h-11`,onClick:i,children:[c(`config:modelOnboarding.openSettings`),(0,E.jsx)(a,{})]})]})]})})}export{D as ConfigSearchBox,O as ModelOnboardingDialog};
@@ -0,0 +1 @@
1
+ import{r as e}from"./GitDiffViewer-DplIwM8m.js";export{e as InlineGitDiff};
@@ -0,0 +1 @@
1
+ import"./events-CAivTGZK.js";
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t}from"./vendor-react-DwNgTV1j.js";import{o as n}from"./vendor-state-GkUciC5H.js";import{t as r}from"./http-response-tU9Jgwk1.js";import{n as i}from"./http-BJXYcBJZ.js";import{i as a}from"./runtime-capabilities-CxyszNkG.js";import{t as o}from"./runtime-capabilities-store-CJA8-sSC.js";import{u as s}from"./events-BCP3T_26.js";import"./public-events-CIldV-8b.js";var c=e(t(),1),l=Object.freeze([`experimental`,`preview`]),u=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,d=48;Object.freeze([{id:`bots`,stage:`experimental`,requires:[`bots`],feedbackUrl:`https://github.com/ling-kong-ran/pisper/issues`}]);function f(e){return typeof e==`string`&&e.length<=d&&u.test(e)}var p=`/api/settings/beta-features`,m=/^https:\/\/github\.com\/[^\s]{1,400}$/;function h(e){if(!e||typeof e!=`object`||Array.isArray(e))throw r();let t=e;if(!f(t.id)||!l.includes(t.stage)||typeof t.enabled!=`boolean`||typeof t.available!=`boolean`||t.unavailableReason!==null&&t.unavailableReason!==`runtime`)throw r();return{id:t.id,stage:t.stage,feedbackUrl:typeof t.feedbackUrl==`string`&&m.test(t.feedbackUrl)?t.feedbackUrl:``,enabled:t.enabled,available:t.available,unavailableReason:t.unavailableReason}}function g(e){if(!e||typeof e!=`object`||Array.isArray(e))throw r();let t=e.features;if(!Array.isArray(t))throw r();return t.map(h)}function _(e={}){return i(p,{signal:e.signal,parse:g})}function v(e,t){return i(p,{method:`PATCH`,data:{[e]:t},parse:g})}function y(e){return e instanceof Error&&e.message?e.message:String(e||``)}var b=null,x=n()((e,t)=>({features:[],status:`idle`,error:``,pending:{},rowErrors:{},load:()=>b||(e({status:t().status===`ready`?`ready`:`loading`,error:``}),b=_().then(n=>{let{pending:r}=t();e({features:n.map(e=>r[e.id]&&t().features.find(t=>t.id===e.id)||e),status:`ready`})}).catch(t=>{e({status:`error`,error:y(t)})}).finally(()=>{b=null}),b),setEnabled:async(n,r)=>{let i=t().features.find(e=>e.id===n);if(!i||t().pending[n]||!i.available)return;let{[n]:a,...o}=t().rowErrors;e({features:t().features.map(e=>e.id===n?{...e,enabled:r}:e),pending:{...t().pending,[n]:!0},rowErrors:o});try{let i=await v(n,r),{pending:a}=t();e({features:i.map(e=>e.id!==n&&a[e.id]&&t().features.find(t=>t.id===e.id)||e)}),s()}catch(a){e({features:t().features.map(e=>e.id===n?{...e,enabled:i.enabled}:e),rowErrors:{...t().rowErrors,[n]:{message:y(a),desired:r}}})}finally{let{[n]:r,...i}=t().pending;e({pending:i})}}}));function S(e){let t=o(e=>a(e.capabilities,`betaFeatures`)),n=x(e=>e.status),r=x(e=>e.load),i=x(t=>t.features.some(t=>t.id===e&&t.enabled&&t.available));return(0,c.useEffect)(()=>{t&&n===`idle`&&r()},[t,n,r]),t&&i}export{x as n,S as t};
1
+ import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t}from"./vendor-react-DwNgTV1j.js";import{o as n}from"./vendor-state-GkUciC5H.js";import{t as r}from"./http-response-DObpyFrX.js";import{n as i}from"./http-CMHs5x9g.js";import{i as a}from"./runtime-capabilities-CxyszNkG.js";import{t as o}from"./runtime-capabilities-store-aG2QVT6b.js";import{u as s}from"./events-CAivTGZK.js";import"./public-events-CtLbk6Ps.js";var c=e(t(),1),l=Object.freeze([`experimental`,`preview`]),u=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,d=48;Object.freeze([{id:`bots`,stage:`experimental`,requires:[`bots`],feedbackUrl:`https://github.com/ling-kong-ran/pisper/issues`}]);function f(e){return typeof e==`string`&&e.length<=d&&u.test(e)}var p=`/api/settings/beta-features`,m=/^https:\/\/github\.com\/[^\s]{1,400}$/;function h(e){if(!e||typeof e!=`object`||Array.isArray(e))throw r();let t=e;if(!f(t.id)||!l.includes(t.stage)||typeof t.enabled!=`boolean`||typeof t.available!=`boolean`||t.unavailableReason!==null&&t.unavailableReason!==`runtime`)throw r();return{id:t.id,stage:t.stage,feedbackUrl:typeof t.feedbackUrl==`string`&&m.test(t.feedbackUrl)?t.feedbackUrl:``,enabled:t.enabled,available:t.available,unavailableReason:t.unavailableReason}}function g(e){if(!e||typeof e!=`object`||Array.isArray(e))throw r();let t=e.features;if(!Array.isArray(t))throw r();return t.map(h)}function _(e={}){return i(p,{signal:e.signal,parse:g})}function v(e,t){return i(p,{method:`PATCH`,data:{[e]:t},parse:g})}function y(e){return e instanceof Error&&e.message?e.message:String(e||``)}var b=null,x=n()((e,t)=>({features:[],status:`idle`,error:``,pending:{},rowErrors:{},load:()=>b||(e({status:t().status===`ready`?`ready`:`loading`,error:``}),b=_().then(n=>{let{pending:r}=t();e({features:n.map(e=>r[e.id]&&t().features.find(t=>t.id===e.id)||e),status:`ready`})}).catch(t=>{e({status:`error`,error:y(t)})}).finally(()=>{b=null}),b),setEnabled:async(n,r)=>{let i=t().features.find(e=>e.id===n);if(!i||t().pending[n]||!i.available)return;let{[n]:a,...o}=t().rowErrors;e({features:t().features.map(e=>e.id===n?{...e,enabled:r}:e),pending:{...t().pending,[n]:!0},rowErrors:o});try{let i=await v(n,r),{pending:a}=t();e({features:i.map(e=>e.id!==n&&a[e.id]&&t().features.find(t=>t.id===e.id)||e)}),s()}catch(a){e({features:t().features.map(e=>e.id===n?{...e,enabled:i.enabled}:e),rowErrors:{...t().rowErrors,[n]:{message:y(a),desired:r}}})}finally{let{[n]:r,...i}=t().pending;e({pending:i})}}}));function S(e){let t=o(e=>a(e.capabilities,`betaFeatures`)),n=x(e=>e.status),r=x(e=>e.load),i=x(t=>t.features.some(t=>t.id===e&&t.enabled&&t.available));return(0,c.useEffect)(()=>{t&&n===`idle`&&r()},[t,n,r]),t&&i}export{x as n,S as t};
@@ -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"./server-BgNvmqwJ.js";import{t as a}from"./triangle-alert-CE1q54ci.js";import{n as o,t as s}from"./button-CCcCN8tE.js";import{a as c,i as l,l as u,o as d,s as f,t as p}from"./dialog-BfkdQrrN.js";import{t as m}from"./input-CPw-zkYh.js";import{c as h,o as g}from"./machines-api-Bd73Uc9W.js";import{n as _,t as v}from"./alert-DRIrgNI4.js";import{n as y,t as b}from"./field-DoLEb0np.js";import{n as x}from"./machine-messages-C5HnwFMY.js";var S=e(t(),1),C=n();function w({machine:e,initialCwd:t,onOpenChange:n,onChosen:w}){let{t:T}=r(),[E,D]=(0,S.useState)(t),[O,k]=(0,S.useState)(!1),[A,j]=(0,S.useState)(``),M=(0,S.useRef)(null);(0,S.useEffect)(()=>(e&&(D(t),j(``)),()=>{M.current?.abort(),M.current=null,k(!1)}),[e,t]);let N=async t=>{if(t.preventDefault(),!e||O)return;let n=new AbortController;M.current=n,k(!0),j(``);try{let t=await h(e.id,E.trim(),n.signal);n.signal.aborted||w(e,t)}catch(e){if(n.signal.aborted)return;j(x(T,g(e),e instanceof Error?e.message:``))}finally{n.signal.aborted||k(!1)}};return(0,C.jsx)(p,{open:!!e,onOpenChange:n,children:(0,C.jsx)(l,{className:`sm:max-w-md`,children:(0,C.jsxs)(`form`,{onSubmit:e=>void N(e),className:`grid gap-4`,children:[(0,C.jsxs)(f,{children:[(0,C.jsxs)(u,{className:`flex items-center gap-2`,children:[(0,C.jsx)(i,{className:`size-4`,"aria-hidden":`true`}),T(`board:machine.folderTitle`,{name:e?.name??``})]}),(0,C.jsx)(c,{children:T(`board:machine.folderDescription`)})]}),(0,C.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,C.jsx)(y,{htmlFor:`machine-folder`,children:T(`board:machine.folderLabel`)}),(0,C.jsx)(m,{id:`machine-folder`,value:E,autoFocus:!0,spellCheck:!1,className:`font-mono text-xs`,placeholder:e?.roots[0]||`~`,disabled:O,"data-machine-folder":!0,onChange:e=>D(e.target.value)}),(0,C.jsx)(b,{children:e?.kind===`node`?T(`board:machine.folderInRoots`,{roots:e.roots.join(`、`)}):T(`board:machine.folderHint`)})]}),A&&(0,C.jsxs)(v,{variant:`destructive`,"data-machine-folder-error":!0,children:[(0,C.jsx)(a,{"aria-hidden":`true`}),(0,C.jsx)(_,{children:A})]}),(0,C.jsxs)(d,{children:[(0,C.jsx)(s,{type:`button`,variant:`ghost`,onClick:()=>n(!1),children:T(`board:machine.cancel`)}),(0,C.jsxs)(s,{type:`submit`,disabled:O,"data-machine-folder-confirm":!0,children:[O&&(0,C.jsx)(o,{className:`size-3.5`}),T(O?`board:machine.checking`:`board:machine.confirm`)]})]})]})})})}export{w as MachineFolderDialog};
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"./server-BgNvmqwJ.js";import{t as a}from"./triangle-alert-CE1q54ci.js";import{n as o,t as s}from"./button-CCcCN8tE.js";import{a as c,i as l,l as u,o as d,s as f,t as p}from"./dialog-CW8GeCdI.js";import{t as m}from"./input-CPw-zkYh.js";import{c as h,o as g}from"./machines-api-Brwmi001.js";import{n as _,t as v}from"./alert-DRIrgNI4.js";import{n as y,t as b}from"./field-DoLEb0np.js";import{n as x}from"./machine-messages-BZFO3mNM.js";var S=e(t(),1),C=n();function w({machine:e,initialCwd:t,onOpenChange:n,onChosen:w}){let{t:T}=r(),[E,D]=(0,S.useState)(t),[O,k]=(0,S.useState)(!1),[A,j]=(0,S.useState)(``),M=(0,S.useRef)(null);(0,S.useEffect)(()=>(e&&(D(t),j(``)),()=>{M.current?.abort(),M.current=null,k(!1)}),[e,t]);let N=async t=>{if(t.preventDefault(),!e||O)return;let n=new AbortController;M.current=n,k(!0),j(``);try{let t=await h(e.id,E.trim(),n.signal);n.signal.aborted||w(e,t)}catch(e){if(n.signal.aborted)return;j(x(T,g(e),e instanceof Error?e.message:``))}finally{n.signal.aborted||k(!1)}};return(0,C.jsx)(p,{open:!!e,onOpenChange:n,children:(0,C.jsx)(l,{className:`sm:max-w-md`,children:(0,C.jsxs)(`form`,{onSubmit:e=>void N(e),className:`grid gap-4`,children:[(0,C.jsxs)(f,{children:[(0,C.jsxs)(u,{className:`flex items-center gap-2`,children:[(0,C.jsx)(i,{className:`size-4`,"aria-hidden":`true`}),T(`board:machine.folderTitle`,{name:e?.name??``})]}),(0,C.jsx)(c,{children:T(`board:machine.folderDescription`)})]}),(0,C.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,C.jsx)(y,{htmlFor:`machine-folder`,children:T(`board:machine.folderLabel`)}),(0,C.jsx)(m,{id:`machine-folder`,value:E,autoFocus:!0,spellCheck:!1,className:`font-mono text-xs`,placeholder:e?.roots[0]||`~`,disabled:O,"data-machine-folder":!0,onChange:e=>D(e.target.value)}),(0,C.jsx)(b,{children:e?.kind===`node`?T(`board:machine.folderInRoots`,{roots:e.roots.join(`、`)}):T(`board:machine.folderHint`)})]}),A&&(0,C.jsxs)(v,{variant:`destructive`,"data-machine-folder-error":!0,children:[(0,C.jsx)(a,{"aria-hidden":`true`}),(0,C.jsx)(_,{children:A})]}),(0,C.jsxs)(d,{children:[(0,C.jsx)(s,{type:`button`,variant:`ghost`,onClick:()=>n(!1),children:T(`board:machine.cancel`)}),(0,C.jsxs)(s,{type:`submit`,disabled:O,"data-machine-folder-confirm":!0,children:[O&&(0,C.jsx)(o,{className:`size-3.5`}),T(O?`board:machine.checking`:`board:machine.confirm`)]})]})]})})})}export{w as MachineFolderDialog};
@@ -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"./vendor-ui-DvrYggeS.js";import{t as a}from"./use-i18n-DL1_y_Ge.js";import{t as o}from"./createLucideIcon-Cd-3GVxJ.js";import{t as s}from"./arrow-right-DqLOhpA2.js";import{t as c}from"./check-2vYc6QaP.js";import{t as l}from"./WorkspacePicker-BC-V-qKc.js";import{t as u}from"./folder-open-FIShC5Qk.js";import{t as d}from"./message-circle-D-XrK6Ft.js";import{t as f}from"./dist-41X0pdUs.js";import"./separator-BPh_qxvc.js";import{t as p}from"./utils-C8uzG5AZ.js";import{t as m}from"./button-CCcCN8tE.js";import{u as h}from"./events-BCP3T_26.js";import{t as g}from"./input-CPw-zkYh.js";import{t as _}from"./pick-system-directory-j8yF4oD7.js";import{t as v}from"./BotAvatar-SFQi6bVG.js";import{t as y}from"./AppSelect-B15Hpk2W.js";import{A as b,E as x,a as S,j as C,k as w,n as T}from"./bots-store-CljyYMIo.js";import"./public-events-CIldV-8b.js";import{t as E}from"./public-flags-DtOWkThd.js";var D=o(`newspaper`,[[`path`,{d:`M15 18h-5`,key:`95g1m2`}],[`path`,{d:`M18 14h-8`,key:`sponae`}],[`path`,{d:`M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-4 0v-9a2 2 0 0 1 2-2h2`,key:`39pd36`}],[`rect`,{width:`8`,height:`4`,x:`10`,y:`6`,rx:`1`,key:`aywv1n`}]]),O=e(n(),1),k=r(),A=i(`group/item flex w-full flex-wrap items-center rounded-lg border text-sm transition-colors duration-100 outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 [a]:transition-colors [a]:hover:bg-muted`,{variants:{variant:{default:`border-transparent`,outline:`border-border`,muted:`border-transparent bg-muted/50`},size:{default:`gap-2.5 px-3 py-2.5`,sm:`gap-2.5 px-3 py-2.5`,xs:`gap-2 px-2.5 py-2 in-data-[slot=dropdown-menu-content]:p-0`}},defaultVariants:{variant:`default`,size:`default`}});function j({className:e,variant:t=`default`,size:n=`default`,asChild:r=!1,...i}){let a=r?f:`div`;return(0,k.jsx)(a,{"data-slot":`item`,"data-variant":t,"data-size":n,className:p(A({variant:t,size:n,className:e})),...i})}var M=i(`flex shrink-0 items-center justify-center gap-2 group-has-data-[slot=item-description]/item:translate-y-0.5 group-has-data-[slot=item-description]/item:self-start [&_svg]:pointer-events-none`,{variants:{variant:{default:`bg-transparent`,icon:`[&_svg:not([class*='size-'])]:size-4`,image:`size-10 overflow-hidden rounded-sm group-data-[size=sm]/item:size-8 group-data-[size=xs]/item:size-6 [&_img]:size-full [&_img]:object-cover`}},defaultVariants:{variant:`default`}});function N({className:e,variant:t=`default`,...n}){return(0,k.jsx)(`div`,{"data-slot":`item-media`,"data-variant":t,className:p(M({variant:t,className:e})),...n})}function P({className:e,...t}){return(0,k.jsx)(`div`,{"data-slot":`item-content`,className:p(`flex flex-1 flex-col gap-1 group-data-[size=xs]/item:gap-0 [&+[data-slot=item-content]]:flex-none`,e),...t})}function F({className:e,...t}){return(0,k.jsx)(`div`,{"data-slot":`item-title`,className:p(`line-clamp-1 flex w-fit items-center gap-2 text-sm leading-snug font-medium underline-offset-4`,e),...t})}function I({className:e,...t}){return(0,k.jsx)(`p`,{"data-slot":`item-description`,className:p(`line-clamp-2 text-left text-sm leading-normal font-normal text-muted-foreground group-data-[size=xs]/item:text-xs [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,e),...t})}function L({className:e,...t}){return(0,k.jsx)(`div`,{"data-slot":`item-actions`,className:p(`flex items-center gap-2`,e),...t})}function R({botId:e,collapsed:t=!1,fallback:n=null}){let r=E(`bots`),i=T(t=>t.bots.find(t=>t.id===e)),a=T(e=>e.loaded),o=T(e=>e.load);return(0,O.useEffect)(()=>{r&&!a&&o()},[r,o,a]),r?i?(0,k.jsx)(z,{bot:i,collapsed:t}):a?n:null:n}function z({bot:e,collapsed:n}){let{t:r}=a(),i=t(),o=T(e=>e.upsert),[s,c]=(0,O.useState)(!1),[f,E]=(0,O.useState)(e.proactive.briefAt),[A,j]=(0,O.useState)(!1),[M,N]=(0,O.useState)(!1),[P,F]=(0,O.useState)(e.proactive.everyHours),[I,L]=(0,O.useState)(!1),[R,z]=(0,O.useState)(``),V=b(e.instructions),H=e.workspace.environmentId===`local`,U=`/bots/${encodeURIComponent(e.id)}`,W=async t=>{L(!0),z(``);try{return o(await x(e.id,t)),!0}catch(e){return z(e instanceof Error?e.message:String(e)),!1}finally{L(!1)}},G=async e=>{e.preventDefault(),/^\d{2}:\d{2}$/.test(f)&&await W({proactive:{brief:!0,briefAt:f}})&&c(!1)},K=async t=>{let n=await x(e.id,{workspace:{...e.workspace,cwd:t},...V?{}:{instructions:r(`bots:greeting.watchDuty`),proactive:{enabled:!0,everyHours:P}}});o(n),e.threadSessionId&&h({id:e.threadSessionId,cwd:n.workspace.cwd}),j(!1),N(!1)},q=async()=>{if(!I){L(!0),z(``);try{let t=await _(e.workspace.cwd,r(`bots:greeting.folder`));t.status===`picked`?await K(t.path):t.status===`unavailable`&&j(!0)}catch(e){z(e instanceof Error?e.message:String(e))}finally{L(!1)}}};return(0,k.jsxs)(`section`,{"data-bot-greeting":e.id,"data-collapsed":n||void 0,"aria-label":r(`bots:greeting.hello`,{name:e.name}),className:p(`mx-auto w-full max-w-[var(--chat-content-width,1040px)]`,n?`mb-[var(--chat-message-gap,32px)]`:`[animation:transcript-reveal-enter_.22s_var(--ease-out)_both]`),children:[(0,k.jsxs)(`div`,{className:`flex items-start gap-3.5`,children:[(0,k.jsx)(v,{avatar:e.avatar,state:n?`idle`:w(e),animate:!n,size:56}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1 pt-0.5`,children:[(0,k.jsx)(`h2`,{className:`text-[15px] leading-6 font-medium text-content`,children:r(`bots:greeting.hello`,{name:e.name})}),V?(0,k.jsxs)(`p`,{className:`text-sm leading-6 [overflow-wrap:anywhere] text-content-secondary`,children:[r(`bots:greeting.duty`,{duty:V}),` `,(0,k.jsx)(`button`,{type:`button`,"data-bot-greeting-edit":!0,className:`relative whitespace-nowrap text-content-muted underline underline-offset-2 after:absolute after:-inset-3 after:hidden after:content-[''] hover:text-content focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-focus pointer-coarse:after:block`,onClick:()=>i(U),children:r(`bots:greeting.editDuty`)})]}):(0,k.jsx)(`p`,{className:`text-sm leading-6 text-content-secondary`,children:r(n?`bots:greeting.talk`:`bots:greeting.ask`)})]})]}),!n&&(0,k.jsxs)(`div`,{className:`mt-4 flex max-w-[560px] flex-col gap-2`,children:[H&&(s?(0,k.jsxs)(`form`,{"data-bot-greeting-brief":!0,className:`flex flex-col gap-3 rounded-[var(--r-md)] border border-stroke px-3 py-2.5`,onSubmit:e=>void G(e),onKeyDown:e=>{e.key===`Escape`&&c(!1)},children:[(0,k.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm font-medium text-content`,children:[r(`bots:greeting.briefWhen`),(0,k.jsx)(g,{type:`time`,value:f,autoFocus:!0,disabled:I,className:`w-32 font-normal`,onChange:e=>E(e.target.value)})]}),(0,k.jsx)(`p`,{className:`m-0 text-xs text-content-muted`,children:r(`bots:greeting.briefNote`)}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(m,{type:`submit`,disabled:I||!f,children:r(`bots:greeting.briefConfirm`)}),(0,k.jsx)(m,{type:`button`,variant:`ghost`,disabled:I,onClick:()=>c(!1),children:r(`bots:new.cancel`)})]})]}):(0,k.jsx)(B,{action:`brief`,icon:D,done:e.proactive.brief,title:e.proactive.brief?r(`bots:greeting.briefOn`,{time:e.proactive.briefAt}):r(`bots:greeting.brief`),hint:e.proactive.brief?r(`bots:greeting.briefOnHint`):r(`bots:greeting.briefHint`),disabled:I,onClick:()=>{E(e.proactive.briefAt),c(!0)}})),H&&(M?(0,k.jsxs)(`form`,{"data-bot-greeting-watch":!0,className:`flex flex-col gap-3 rounded-[var(--r-md)] border border-stroke px-3 py-2.5`,onSubmit:e=>{e.preventDefault(),q()},onKeyDown:e=>{e.key===`Escape`&&e.currentTarget.contains(e.target)&&N(!1)},children:[(0,k.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm font-medium text-content`,children:[r(`bots:greeting.watchWhen`),(0,k.jsx)(y,{value:String(P),className:`w-44 font-normal`,onChange:e=>F(Number(e.target.value)),children:S.map(e=>(0,k.jsx)(`option`,{value:e,children:r(`bots:proactive.everyHours`,{count:e})},e))})]}),(0,k.jsx)(`p`,{className:`m-0 text-xs text-content-muted`,children:r(`bots:greeting.watchNote`)}),(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,k.jsx)(m,{type:`submit`,autoFocus:!0,children:r(`bots:greeting.watchConfirm`)}),(0,k.jsx)(m,{type:`button`,variant:`ghost`,onClick:()=>N(!1),children:r(`bots:new.cancel`)})]})]}):(0,k.jsx)(B,{action:`folder`,icon:u,title:r(V?`bots:greeting.folder`:`bots:greeting.watch`),hint:V?e.proactive.enabled?r(`bots:greeting.folderWatchHint`,{folder:C(e.workspace.cwd),count:e.proactive.everyHours}):r(`bots:greeting.folderHint`,{folder:C(e.workspace.cwd)}):r(`bots:greeting.watchHint`,{count:e.proactive.everyHours}),disabled:I,onClick:()=>{if(V){q();return}F(e.proactive.everyHours),N(!0)}})),(0,k.jsx)(B,{action:`chats`,icon:d,done:e.channels.length>0,title:e.channels.length?r(`bots:greeting.chatsOn`,{count:e.channels.length}):r(`bots:greeting.chats`),hint:e.channels.length?r(`bots:greeting.chatsOnHint`):r(`bots:greeting.chatsHint`),disabled:I,onClick:()=>i(`${U}?section=chats`)}),R&&(0,k.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:R}),(0,k.jsx)(l,{open:A,initialPath:e.workspace.cwd,onOpenChange:j,onSelect:K})]})]})}function B({action:e,icon:t,title:n,hint:r,done:i=!1,disabled:a,onClick:o}){return(0,k.jsx)(j,{asChild:!0,variant:`outline`,children:(0,k.jsxs)(`button`,{type:`button`,"data-bot-greeting-action":e,disabled:a,className:`group/action w-full cursor-pointer text-left hover:bg-surface-hover disabled:cursor-default disabled:opacity-60`,onClick:o,children:[(0,k.jsx)(N,{variant:`icon`,children:(0,k.jsx)(t,{className:`text-content-secondary`,strokeWidth:1.75,"aria-hidden":`true`})}),(0,k.jsxs)(P,{children:[(0,k.jsx)(F,{children:n}),(0,k.jsx)(I,{children:r})]}),(0,k.jsx)(L,{children:(0,k.jsx)(i?c:s,{className:`size-4 text-content-faint group-hover/action:text-content-secondary`,"aria-hidden":`true`})})]})})}export{R as default};
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"./vendor-ui-DvrYggeS.js";import{t as a}from"./use-i18n-BqDnJFL5.js";import{t as o}from"./createLucideIcon-Cd-3GVxJ.js";import{t as s}from"./arrow-right-DqLOhpA2.js";import{t as c}from"./check-2vYc6QaP.js";import{t as l}from"./WorkspacePicker-Cd0QCRnc.js";import{t as u}from"./folder-open-FIShC5Qk.js";import{t as d}from"./message-circle-D-XrK6Ft.js";import{t as f}from"./dist-41X0pdUs.js";import"./separator-BPh_qxvc.js";import{t as p}from"./utils-C8uzG5AZ.js";import{t as m}from"./button-CCcCN8tE.js";import{u as h}from"./events-CAivTGZK.js";import{t as g}from"./input-CPw-zkYh.js";import{t as _}from"./pick-system-directory-C4P5z66U.js";import{t as v}from"./BotAvatar-SFQi6bVG.js";import{t as y}from"./AppSelect-B15Hpk2W.js";import{A as b,E as x,a as S,j as C,k as w,n as T}from"./bots-store-Br31qCcA.js";import"./public-events-CtLbk6Ps.js";import{t as E}from"./public-flags-CBzwNp70.js";var D=o(`newspaper`,[[`path`,{d:`M15 18h-5`,key:`95g1m2`}],[`path`,{d:`M18 14h-8`,key:`sponae`}],[`path`,{d:`M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-4 0v-9a2 2 0 0 1 2-2h2`,key:`39pd36`}],[`rect`,{width:`8`,height:`4`,x:`10`,y:`6`,rx:`1`,key:`aywv1n`}]]),O=e(n(),1),k=r(),A=i(`group/item flex w-full flex-wrap items-center rounded-lg border text-sm transition-colors duration-100 outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 [a]:transition-colors [a]:hover:bg-muted`,{variants:{variant:{default:`border-transparent`,outline:`border-border`,muted:`border-transparent bg-muted/50`},size:{default:`gap-2.5 px-3 py-2.5`,sm:`gap-2.5 px-3 py-2.5`,xs:`gap-2 px-2.5 py-2 in-data-[slot=dropdown-menu-content]:p-0`}},defaultVariants:{variant:`default`,size:`default`}});function j({className:e,variant:t=`default`,size:n=`default`,asChild:r=!1,...i}){let a=r?f:`div`;return(0,k.jsx)(a,{"data-slot":`item`,"data-variant":t,"data-size":n,className:p(A({variant:t,size:n,className:e})),...i})}var M=i(`flex shrink-0 items-center justify-center gap-2 group-has-data-[slot=item-description]/item:translate-y-0.5 group-has-data-[slot=item-description]/item:self-start [&_svg]:pointer-events-none`,{variants:{variant:{default:`bg-transparent`,icon:`[&_svg:not([class*='size-'])]:size-4`,image:`size-10 overflow-hidden rounded-sm group-data-[size=sm]/item:size-8 group-data-[size=xs]/item:size-6 [&_img]:size-full [&_img]:object-cover`}},defaultVariants:{variant:`default`}});function N({className:e,variant:t=`default`,...n}){return(0,k.jsx)(`div`,{"data-slot":`item-media`,"data-variant":t,className:p(M({variant:t,className:e})),...n})}function P({className:e,...t}){return(0,k.jsx)(`div`,{"data-slot":`item-content`,className:p(`flex flex-1 flex-col gap-1 group-data-[size=xs]/item:gap-0 [&+[data-slot=item-content]]:flex-none`,e),...t})}function F({className:e,...t}){return(0,k.jsx)(`div`,{"data-slot":`item-title`,className:p(`line-clamp-1 flex w-fit items-center gap-2 text-sm leading-snug font-medium underline-offset-4`,e),...t})}function I({className:e,...t}){return(0,k.jsx)(`p`,{"data-slot":`item-description`,className:p(`line-clamp-2 text-left text-sm leading-normal font-normal text-muted-foreground group-data-[size=xs]/item:text-xs [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,e),...t})}function L({className:e,...t}){return(0,k.jsx)(`div`,{"data-slot":`item-actions`,className:p(`flex items-center gap-2`,e),...t})}function R({botId:e,collapsed:t=!1,fallback:n=null}){let r=E(`bots`),i=T(t=>t.bots.find(t=>t.id===e)),a=T(e=>e.loaded),o=T(e=>e.load);return(0,O.useEffect)(()=>{r&&!a&&o()},[r,o,a]),r?i?(0,k.jsx)(z,{bot:i,collapsed:t}):a?n:null:n}function z({bot:e,collapsed:n}){let{t:r}=a(),i=t(),o=T(e=>e.upsert),[s,c]=(0,O.useState)(!1),[f,E]=(0,O.useState)(e.proactive.briefAt),[A,j]=(0,O.useState)(!1),[M,N]=(0,O.useState)(!1),[P,F]=(0,O.useState)(e.proactive.everyHours),[I,L]=(0,O.useState)(!1),[R,z]=(0,O.useState)(``),V=b(e.instructions),H=e.workspace.environmentId===`local`,U=`/bots/${encodeURIComponent(e.id)}`,W=async t=>{L(!0),z(``);try{return o(await x(e.id,t)),!0}catch(e){return z(e instanceof Error?e.message:String(e)),!1}finally{L(!1)}},G=async e=>{e.preventDefault(),/^\d{2}:\d{2}$/.test(f)&&await W({proactive:{brief:!0,briefAt:f}})&&c(!1)},K=async t=>{let n=await x(e.id,{workspace:{...e.workspace,cwd:t},...V?{}:{instructions:r(`bots:greeting.watchDuty`),proactive:{enabled:!0,everyHours:P}}});o(n),e.threadSessionId&&h({id:e.threadSessionId,cwd:n.workspace.cwd}),j(!1),N(!1)},q=async()=>{if(!I){L(!0),z(``);try{let t=await _(e.workspace.cwd,r(`bots:greeting.folder`));t.status===`picked`?await K(t.path):t.status===`unavailable`&&j(!0)}catch(e){z(e instanceof Error?e.message:String(e))}finally{L(!1)}}};return(0,k.jsxs)(`section`,{"data-bot-greeting":e.id,"data-collapsed":n||void 0,"aria-label":r(`bots:greeting.hello`,{name:e.name}),className:p(`mx-auto w-full max-w-[var(--chat-content-width,1040px)]`,n?`mb-[var(--chat-message-gap,32px)]`:`[animation:transcript-reveal-enter_.22s_var(--ease-out)_both]`),children:[(0,k.jsxs)(`div`,{className:`flex items-start gap-3.5`,children:[(0,k.jsx)(v,{avatar:e.avatar,state:n?`idle`:w(e),animate:!n,size:56}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1 pt-0.5`,children:[(0,k.jsx)(`h2`,{className:`text-[15px] leading-6 font-medium text-content`,children:r(`bots:greeting.hello`,{name:e.name})}),V?(0,k.jsxs)(`p`,{className:`text-sm leading-6 [overflow-wrap:anywhere] text-content-secondary`,children:[r(`bots:greeting.duty`,{duty:V}),` `,(0,k.jsx)(`button`,{type:`button`,"data-bot-greeting-edit":!0,className:`relative whitespace-nowrap text-content-muted underline underline-offset-2 after:absolute after:-inset-3 after:hidden after:content-[''] hover:text-content focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-focus pointer-coarse:after:block`,onClick:()=>i(U),children:r(`bots:greeting.editDuty`)})]}):(0,k.jsx)(`p`,{className:`text-sm leading-6 text-content-secondary`,children:r(n?`bots:greeting.talk`:`bots:greeting.ask`)})]})]}),!n&&(0,k.jsxs)(`div`,{className:`mt-4 flex max-w-[560px] flex-col gap-2`,children:[H&&(s?(0,k.jsxs)(`form`,{"data-bot-greeting-brief":!0,className:`flex flex-col gap-3 rounded-[var(--r-md)] border border-stroke px-3 py-2.5`,onSubmit:e=>void G(e),onKeyDown:e=>{e.key===`Escape`&&c(!1)},children:[(0,k.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm font-medium text-content`,children:[r(`bots:greeting.briefWhen`),(0,k.jsx)(g,{type:`time`,value:f,autoFocus:!0,disabled:I,className:`w-32 font-normal`,onChange:e=>E(e.target.value)})]}),(0,k.jsx)(`p`,{className:`m-0 text-xs text-content-muted`,children:r(`bots:greeting.briefNote`)}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(m,{type:`submit`,disabled:I||!f,children:r(`bots:greeting.briefConfirm`)}),(0,k.jsx)(m,{type:`button`,variant:`ghost`,disabled:I,onClick:()=>c(!1),children:r(`bots:new.cancel`)})]})]}):(0,k.jsx)(B,{action:`brief`,icon:D,done:e.proactive.brief,title:e.proactive.brief?r(`bots:greeting.briefOn`,{time:e.proactive.briefAt}):r(`bots:greeting.brief`),hint:e.proactive.brief?r(`bots:greeting.briefOnHint`):r(`bots:greeting.briefHint`),disabled:I,onClick:()=>{E(e.proactive.briefAt),c(!0)}})),H&&(M?(0,k.jsxs)(`form`,{"data-bot-greeting-watch":!0,className:`flex flex-col gap-3 rounded-[var(--r-md)] border border-stroke px-3 py-2.5`,onSubmit:e=>{e.preventDefault(),q()},onKeyDown:e=>{e.key===`Escape`&&e.currentTarget.contains(e.target)&&N(!1)},children:[(0,k.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm font-medium text-content`,children:[r(`bots:greeting.watchWhen`),(0,k.jsx)(y,{value:String(P),className:`w-44 font-normal`,onChange:e=>F(Number(e.target.value)),children:S.map(e=>(0,k.jsx)(`option`,{value:e,children:r(`bots:proactive.everyHours`,{count:e})},e))})]}),(0,k.jsx)(`p`,{className:`m-0 text-xs text-content-muted`,children:r(`bots:greeting.watchNote`)}),(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,k.jsx)(m,{type:`submit`,autoFocus:!0,children:r(`bots:greeting.watchConfirm`)}),(0,k.jsx)(m,{type:`button`,variant:`ghost`,onClick:()=>N(!1),children:r(`bots:new.cancel`)})]})]}):(0,k.jsx)(B,{action:`folder`,icon:u,title:r(V?`bots:greeting.folder`:`bots:greeting.watch`),hint:V?e.proactive.enabled?r(`bots:greeting.folderWatchHint`,{folder:C(e.workspace.cwd),count:e.proactive.everyHours}):r(`bots:greeting.folderHint`,{folder:C(e.workspace.cwd)}):r(`bots:greeting.watchHint`,{count:e.proactive.everyHours}),disabled:I,onClick:()=>{if(V){q();return}F(e.proactive.everyHours),N(!0)}})),(0,k.jsx)(B,{action:`chats`,icon:d,done:e.channels.length>0,title:e.channels.length?r(`bots:greeting.chatsOn`,{count:e.channels.length}):r(`bots:greeting.chats`),hint:e.channels.length?r(`bots:greeting.chatsOnHint`):r(`bots:greeting.chatsHint`),disabled:I,onClick:()=>i(`${U}?section=chats`)}),R&&(0,k.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:R}),(0,k.jsx)(l,{open:A,initialPath:e.workspace.cwd,onOpenChange:j,onSelect:K})]})]})}function B({action:e,icon:t,title:n,hint:r,done:i=!1,disabled:a,onClick:o}){return(0,k.jsx)(j,{asChild:!0,variant:`outline`,children:(0,k.jsxs)(`button`,{type:`button`,"data-bot-greeting-action":e,disabled:a,className:`group/action w-full cursor-pointer text-left hover:bg-surface-hover disabled:cursor-default disabled:opacity-60`,onClick:o,children:[(0,k.jsx)(N,{variant:`icon`,children:(0,k.jsx)(t,{className:`text-content-secondary`,strokeWidth:1.75,"aria-hidden":`true`})}),(0,k.jsxs)(P,{children:[(0,k.jsx)(F,{children:n}),(0,k.jsx)(I,{children:r})]}),(0,k.jsx)(L,{children:(0,k.jsx)(i?c:s,{className:`size-4 text-content-faint group-hover/action:text-content-secondary`,"aria-hidden":`true`})})]})})}export{R as default};
@@ -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"./settings-2-CXJjXJS9.js";import{t as o}from"./button-CCcCN8tE.js";import{t as s}from"./BotAvatar-SFQi6bVG.js";import{k as c,n as l,t as u}from"./bots-store-CljyYMIo.js";import{t as d}from"./public-flags-DtOWkThd.js";var f=e(n(),1),p=r();function m({botId:e,part:n,animate:r=!0,fallback:m=null}){let{t:h}=i(),g=d(`bots`),_=t(),v=l(t=>t.bots.find(t=>t.id===e));u(g&&n===`avatar`);let y=l(e=>e.loaded),b=l(e=>e.load);if((0,f.useEffect)(()=>{g&&!y&&n!==`avatar`&&b()},[g,b,y,n]),!g||!v)return m;if(n===`mark`)return(0,p.jsx)(s,{avatar:v.avatar,state:r?c(v):`idle`,animate:r,size:22});if(n===`name`)return v.name;if(n===`avatar`)return(0,p.jsx)(`span`,{"data-session-bot":v.id,className:`flex flex-none items-center pl-1`,children:(0,p.jsx)(s,{avatar:v.avatar,state:c(v),size:22})});let x=h(`bots:settingsPage.title`,{name:v.name});return(0,p.jsx)(o,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`flex-none text-content-muted hover:text-content pointer-coarse:size-11`,"data-session-bot-settings":v.id,"aria-label":x,title:x,onClick:()=>_(`/bots/${encodeURIComponent(v.id)}`),children:(0,p.jsx)(a,{"aria-hidden":`true`})})}export{m as default};
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"./settings-2-CXJjXJS9.js";import{t as o}from"./button-CCcCN8tE.js";import{t as s}from"./BotAvatar-SFQi6bVG.js";import{k as c,n as l,t as u}from"./bots-store-Br31qCcA.js";import{t as d}from"./public-flags-CBzwNp70.js";var f=e(n(),1),p=r();function m({botId:e,part:n,animate:r=!0,fallback:m=null}){let{t:h}=i(),g=d(`bots`),_=t(),v=l(t=>t.bots.find(t=>t.id===e));u(g&&n===`avatar`);let y=l(e=>e.loaded),b=l(e=>e.load);if((0,f.useEffect)(()=>{g&&!y&&n!==`avatar`&&b()},[g,b,y,n]),!g||!v)return m;if(n===`mark`)return(0,p.jsx)(s,{avatar:v.avatar,state:r?c(v):`idle`,animate:r,size:22});if(n===`name`)return v.name;if(n===`avatar`)return(0,p.jsx)(`span`,{"data-session-bot":v.id,className:`flex flex-none items-center pl-1`,children:(0,p.jsx)(s,{avatar:v.avatar,state:c(v),size:22})});let x=h(`bots:settingsPage.title`,{name:v.name});return(0,p.jsx)(o,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`flex-none text-content-muted hover:text-content pointer-coarse:size-11`,"data-session-bot-settings":v.id,"aria-label":x,title:x,onClick:()=>_(`/bots/${encodeURIComponent(v.id)}`),children:(0,p.jsx)(a,{"aria-hidden":`true`})})}export{m as default};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{l as t,u as n}from"./vendor-router-CSN_DGvx.js";import{i as r,r as i}from"./vendor-react-DwNgTV1j.js";import{m as a,p as o}from"./routes-BYsK6aeM.js";import{t as s}from"./use-i18n-DL1_y_Ge.js";import{t as c}from"./bot-B3TaBp_T.js";import{t as l}from"./plus-fQbSqB1n.js";import{i as u,l as d,n as f,r as p,t as m,x as h}from"./use-open-bot-CiF65aUO.js";import{t as g}from"./users-CCtFZzwl.js";import{t as _}from"./checkbox-BrEHgFV0.js";import{i as v,p as y,r as b,t as x}from"./dropdown-menu-Ds0gD8S8.js";import{t as S}from"./utils-C8uzG5AZ.js";import{t as C}from"./button-CCcCN8tE.js";import{a as w,i as T,l as E,o as D,s as O,t as k}from"./dialog-BfkdQrrN.js";import{t as A}from"./input-CPw-zkYh.js";import{t as j}from"./PageState-Cz6vFMXv.js";import{n as M}from"./field-DoLEb0np.js";import{t as N}from"./BotAvatar-SFQi6bVG.js";import{N as P,O as F,k as I,n as L,t as R}from"./bots-store-CljyYMIo.js";import{t as z}from"./public-flags-DtOWkThd.js";var B=e(r(),1),V=i(),H=8;function U({open:e,onOpenChange:t,onCreated:n}){let{t:r}=s(),i=L(e=>e.bots),a=u(e=>e.upsert),[o,c]=(0,B.useState)(``),[l,f]=(0,B.useState)(``),[p,m]=(0,B.useState)([]),[h,g]=(0,B.useState)(!1),[v,y]=(0,B.useState)(``);(0,B.useEffect)(()=>{e&&(c(``),f(``),m([]),y(``))},[e]);let b=(e,t)=>m(n=>t?[...n,e].slice(0,H):n.filter(t=>t!==e));return(0,V.jsx)(k,{open:e,onOpenChange:t,children:(0,V.jsx)(T,{className:`sm:max-w-md`,children:(0,V.jsxs)(`form`,{onSubmit:async e=>{if(e.preventDefault(),!(!o.trim()||!p.length)){g(!0),y(``);try{let e=await d({name:o.trim(),members:p,goal:l.trim()});a(e),t(!1),n(e)}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(!1)}}},className:`contents`,children:[(0,V.jsxs)(O,{children:[(0,V.jsx)(E,{children:r(`bots:room.new.title`)}),(0,V.jsx)(w,{children:r(`bots:room.new.description`)})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(M,{htmlFor:`new-room-name`,children:r(`bots:room.new.name`)}),(0,V.jsx)(A,{id:`new-room-name`,value:o,maxLength:40,autoFocus:!0,placeholder:r(`bots:room.new.namePlaceholder`),onChange:e=>c(e.target.value)})]}),(0,V.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,V.jsx)(`legend`,{className:`mb-1.5 text-sm font-medium text-content`,children:r(`bots:room.new.members`,{count:p.length,max:H})}),i.length?(0,V.jsx)(`ul`,{className:`m-0 flex max-h-56 list-none flex-col gap-0.5 overflow-y-auto p-0`,children:i.map(e=>{let t=`new-room-member-${e.id}`,n=p.includes(e.id);return(0,V.jsx)(`li`,{children:(0,V.jsxs)(`label`,{htmlFor:t,className:`flex h-9 items-center gap-2.5 rounded-[var(--r-md)] px-2 hover:bg-surface-hover pointer-coarse:h-11`,children:[(0,V.jsx)(_,{id:t,checked:n,disabled:!n&&p.length>=H,onCheckedChange:t=>b(e.id,t===!0)}),(0,V.jsx)(N,{avatar:e.avatar,size:20,animate:!1}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-content`,children:e.name}),!e.enabled&&(0,V.jsx)(`span`,{className:`text-xs text-content-muted`,children:r(`bots:room.paused`)})]})},e.id)})}):(0,V.jsx)(j,{compact:!0,title:r(`bots:room.new.noBots`)})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(M,{htmlFor:`new-room-goal`,children:r(`bots:room.new.goal`)}),(0,V.jsx)(A,{id:`new-room-goal`,value:l,maxLength:200,placeholder:r(`bots:room.new.goalPlaceholder`),onChange:e=>f(e.target.value)})]}),v&&(0,V.jsx)(`p`,{role:`alert`,className:`m-0 text-sm text-destructive`,children:v})]}),(0,V.jsxs)(D,{children:[(0,V.jsx)(C,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:r(`common:ui.cancel`)}),(0,V.jsx)(C,{type:`submit`,disabled:h||!o.trim()||!p.length,children:r(`bots:room.new.create`)})]})]})})})}function W(){let{t:e}=s(),r=z(`bots`),i=L(e=>e.bots),d=n(),_=t(),[C,w]=(0,B.useState)(!1),[T,E]=(0,B.useState)(!1),[D,O]=(0,B.useState)(!1),k=u(e=>e.rooms),A=m((0,B.useCallback)((e,t)=>d(`/bots/${encodeURIComponent(t)}`),[d]));if(R(r),p(r),!r)return null;let j=a(_.pathname),M=/^\/bots\/([^/]+)/.exec(_.pathname)?.[1]??i.find(e=>j&&e.threadSessionId===j)?.id,{shown:H,hidden:W}=P(i,{expanded:D,currentId:M});return(0,V.jsxs)(`section`,{"data-sidebar-bots":!0,"aria-label":e(`bots:sidebar.title`),className:`mb-2`,children:[(0,V.jsxs)(`div`,{className:`flex h-[26px] items-center gap-1.5 px-2.5 text-xs font-medium text-content-muted`,children:[(0,V.jsx)(`h2`,{className:`flex-1`,children:e(`bots:sidebar.title`)}),(0,V.jsxs)(x,{children:[(0,V.jsx)(y,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"data-sidebar-bots-new":!0,className:`grid size-6 place-items-center rounded-md hover:bg-surface-hover hover:text-content`,"aria-label":e(`bots:sidebar.new`),title:e(`bots:sidebar.new`),children:(0,V.jsx)(l,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,V.jsxs)(b,{align:`end`,children:[(0,V.jsxs)(v,{onSelect:()=>w(!0),children:[(0,V.jsx)(c,{"aria-hidden":`true`}),e(`bots:sidebar.newBot`)]}),(0,V.jsxs)(v,{disabled:!i.length,onSelect:()=>E(!0),children:[(0,V.jsx)(g,{"aria-hidden":`true`}),e(`bots:sidebar.newRoom`)]})]})]})]}),(0,V.jsx)(`ul`,{role:`list`,className:`m-0 list-none p-0`,children:H.map(t=>{let n=t.activity,r=F(e,t);return(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,"data-sidebar-bot":t.id,"aria-current":M===t.id?`page`:void 0,title:r,className:S(`flex h-8 w-full min-w-0 items-center gap-2.5 rounded-[var(--r-md)] px-2.5 text-left hover:bg-surface-hover pointer-coarse:h-11`,M===t.id&&`bg-surface-active hover:bg-surface-active`),onClick:()=>void A(t),children:[(0,V.jsx)(N,{avatar:t.avatar,state:I(t),size:20}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-[13.5px] text-content`,children:[t.name,(0,V.jsx)(`span`,{className:`sr-only`,children:` · ${r}`})]}),n?.working?(0,V.jsx)(`span`,{"aria-hidden":`true`,"data-sidebar-bot-working":n.working,className:`flex-none text-[11.5px] text-content-muted tabular-nums`,children:n.working}):null,n?.needsYou&&(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 flex-none rounded-full bg-st-attn`})]})},t.id)})}),(W>0||D&&i.length>3)&&(0,V.jsx)(`button`,{type:`button`,"data-sidebar-bots-more":!0,"aria-expanded":D,className:`flex h-7 w-full items-center rounded-[var(--r-md)] px-2.5 pl-9 text-left text-xs text-content-muted transition-colors duration-(--d-fast) hover:bg-surface-hover hover:text-content-secondary focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus pointer-coarse:h-11`,onClick:()=>O(!D),children:D?e(`bots:sidebar.showLess`):e(`bots:sidebar.showAll`,{count:i.length})}),k.length>0&&(0,V.jsx)(`ul`,{role:`list`,"aria-label":e(`bots:sidebar.rooms`),className:`m-0 mt-0.5 list-none p-0`,children:k.map(t=>{let n=_.pathname===o(t.id),r=t.members.map(e=>i.find(t=>t.id===e)?.avatar).filter(e=>e!==void 0);return(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,"data-sidebar-room":t.id,"aria-current":n?`page`:void 0,className:S(`flex h-8 w-full min-w-0 items-center gap-2.5 rounded-[var(--r-md)] px-2.5 text-left hover:bg-surface-hover pointer-coarse:h-11`,n&&`bg-surface-active hover:bg-surface-active`),onClick:()=>d(o(t.id)),children:[(0,V.jsx)(f,{avatars:r,variant:`tile`}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-[13.5px] text-content`,children:[t.name,t.activity.needsYou&&(0,V.jsx)(`span`,{className:`sr-only`,children:` · ${e(`bots:room.needsYou`)}`})]}),t.activity.working>0&&(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`flex-none text-[11.5px] text-content-muted tabular-nums`,children:t.activity.working}),t.activity.needsYou&&(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 flex-none rounded-full bg-st-attn`})]})},t.id)})}),(0,V.jsx)(U,{open:T,onOpenChange:E,onCreated:e=>d(o(e.id))}),(0,V.jsx)(h,{open:C,onOpenChange:w,onCreated:e=>void A(e)})]})}export{W as default};
1
+ import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{l as t,u as n}from"./vendor-router-CSN_DGvx.js";import{i as r,r as i}from"./vendor-react-DwNgTV1j.js";import{m as a,p as o}from"./routes-BYsK6aeM.js";import{t as s}from"./use-i18n-BqDnJFL5.js";import{t as c}from"./bot-B3TaBp_T.js";import{t as l}from"./plus-fQbSqB1n.js";import{i as u,l as d,n as f,r as p,t as m,x as h}from"./use-open-bot-B_UFxUmd.js";import{t as g}from"./users-CCtFZzwl.js";import{t as _}from"./checkbox-BrEHgFV0.js";import{i as v,p as y,r as b,t as x}from"./dropdown-menu-Ds0gD8S8.js";import{t as S}from"./utils-C8uzG5AZ.js";import{t as C}from"./button-CCcCN8tE.js";import{a as w,i as T,l as E,o as D,s as O,t as k}from"./dialog-CW8GeCdI.js";import{t as A}from"./input-CPw-zkYh.js";import{t as j}from"./PageState-Cz6vFMXv.js";import{n as M}from"./field-DoLEb0np.js";import{t as N}from"./BotAvatar-SFQi6bVG.js";import{N as P,O as F,k as I,n as L,t as R}from"./bots-store-Br31qCcA.js";import{t as z}from"./public-flags-CBzwNp70.js";var B=e(r(),1),V=i(),H=8;function U({open:e,onOpenChange:t,onCreated:n}){let{t:r}=s(),i=L(e=>e.bots),a=u(e=>e.upsert),[o,c]=(0,B.useState)(``),[l,f]=(0,B.useState)(``),[p,m]=(0,B.useState)([]),[h,g]=(0,B.useState)(!1),[v,y]=(0,B.useState)(``);(0,B.useEffect)(()=>{e&&(c(``),f(``),m([]),y(``))},[e]);let b=(e,t)=>m(n=>t?[...n,e].slice(0,H):n.filter(t=>t!==e));return(0,V.jsx)(k,{open:e,onOpenChange:t,children:(0,V.jsx)(T,{className:`sm:max-w-md`,children:(0,V.jsxs)(`form`,{onSubmit:async e=>{if(e.preventDefault(),!(!o.trim()||!p.length)){g(!0),y(``);try{let e=await d({name:o.trim(),members:p,goal:l.trim()});a(e),t(!1),n(e)}catch(e){y(e instanceof Error?e.message:String(e))}finally{g(!1)}}},className:`contents`,children:[(0,V.jsxs)(O,{children:[(0,V.jsx)(E,{children:r(`bots:room.new.title`)}),(0,V.jsx)(w,{children:r(`bots:room.new.description`)})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(M,{htmlFor:`new-room-name`,children:r(`bots:room.new.name`)}),(0,V.jsx)(A,{id:`new-room-name`,value:o,maxLength:40,autoFocus:!0,placeholder:r(`bots:room.new.namePlaceholder`),onChange:e=>c(e.target.value)})]}),(0,V.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,V.jsx)(`legend`,{className:`mb-1.5 text-sm font-medium text-content`,children:r(`bots:room.new.members`,{count:p.length,max:H})}),i.length?(0,V.jsx)(`ul`,{className:`m-0 flex max-h-56 list-none flex-col gap-0.5 overflow-y-auto p-0`,children:i.map(e=>{let t=`new-room-member-${e.id}`,n=p.includes(e.id);return(0,V.jsx)(`li`,{children:(0,V.jsxs)(`label`,{htmlFor:t,className:`flex h-9 items-center gap-2.5 rounded-[var(--r-md)] px-2 hover:bg-surface-hover pointer-coarse:h-11`,children:[(0,V.jsx)(_,{id:t,checked:n,disabled:!n&&p.length>=H,onCheckedChange:t=>b(e.id,t===!0)}),(0,V.jsx)(N,{avatar:e.avatar,size:20,animate:!1}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-content`,children:e.name}),!e.enabled&&(0,V.jsx)(`span`,{className:`text-xs text-content-muted`,children:r(`bots:room.paused`)})]})},e.id)})}):(0,V.jsx)(j,{compact:!0,title:r(`bots:room.new.noBots`)})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(M,{htmlFor:`new-room-goal`,children:r(`bots:room.new.goal`)}),(0,V.jsx)(A,{id:`new-room-goal`,value:l,maxLength:200,placeholder:r(`bots:room.new.goalPlaceholder`),onChange:e=>f(e.target.value)})]}),v&&(0,V.jsx)(`p`,{role:`alert`,className:`m-0 text-sm text-destructive`,children:v})]}),(0,V.jsxs)(D,{children:[(0,V.jsx)(C,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:r(`common:ui.cancel`)}),(0,V.jsx)(C,{type:`submit`,disabled:h||!o.trim()||!p.length,children:r(`bots:room.new.create`)})]})]})})})}function W(){let{t:e}=s(),r=z(`bots`),i=L(e=>e.bots),d=n(),_=t(),[C,w]=(0,B.useState)(!1),[T,E]=(0,B.useState)(!1),[D,O]=(0,B.useState)(!1),k=u(e=>e.rooms),A=m((0,B.useCallback)((e,t)=>d(`/bots/${encodeURIComponent(t)}`),[d]));if(R(r),p(r),!r)return null;let j=a(_.pathname),M=/^\/bots\/([^/]+)/.exec(_.pathname)?.[1]??i.find(e=>j&&e.threadSessionId===j)?.id,{shown:H,hidden:W}=P(i,{expanded:D,currentId:M});return(0,V.jsxs)(`section`,{"data-sidebar-bots":!0,"aria-label":e(`bots:sidebar.title`),className:`mb-2`,children:[(0,V.jsxs)(`div`,{className:`flex h-[26px] items-center gap-1.5 px-2.5 text-xs font-medium text-content-muted`,children:[(0,V.jsx)(`h2`,{className:`flex-1`,children:e(`bots:sidebar.title`)}),(0,V.jsxs)(x,{children:[(0,V.jsx)(y,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,"data-sidebar-bots-new":!0,className:`grid size-6 place-items-center rounded-md hover:bg-surface-hover hover:text-content`,"aria-label":e(`bots:sidebar.new`),title:e(`bots:sidebar.new`),children:(0,V.jsx)(l,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,V.jsxs)(b,{align:`end`,children:[(0,V.jsxs)(v,{onSelect:()=>w(!0),children:[(0,V.jsx)(c,{"aria-hidden":`true`}),e(`bots:sidebar.newBot`)]}),(0,V.jsxs)(v,{disabled:!i.length,onSelect:()=>E(!0),children:[(0,V.jsx)(g,{"aria-hidden":`true`}),e(`bots:sidebar.newRoom`)]})]})]})]}),(0,V.jsx)(`ul`,{role:`list`,className:`m-0 list-none p-0`,children:H.map(t=>{let n=t.activity,r=F(e,t);return(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,"data-sidebar-bot":t.id,"aria-current":M===t.id?`page`:void 0,title:r,className:S(`flex h-8 w-full min-w-0 items-center gap-2.5 rounded-[var(--r-md)] px-2.5 text-left hover:bg-surface-hover pointer-coarse:h-11`,M===t.id&&`bg-surface-active hover:bg-surface-active`),onClick:()=>void A(t),children:[(0,V.jsx)(N,{avatar:t.avatar,state:I(t),size:20}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-[13.5px] text-content`,children:[t.name,(0,V.jsx)(`span`,{className:`sr-only`,children:` · ${r}`})]}),n?.working?(0,V.jsx)(`span`,{"aria-hidden":`true`,"data-sidebar-bot-working":n.working,className:`flex-none text-[11.5px] text-content-muted tabular-nums`,children:n.working}):null,n?.needsYou&&(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 flex-none rounded-full bg-st-attn`})]})},t.id)})}),(W>0||D&&i.length>3)&&(0,V.jsx)(`button`,{type:`button`,"data-sidebar-bots-more":!0,"aria-expanded":D,className:`flex h-7 w-full items-center rounded-[var(--r-md)] px-2.5 pl-9 text-left text-xs text-content-muted transition-colors duration-(--d-fast) hover:bg-surface-hover hover:text-content-secondary focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus pointer-coarse:h-11`,onClick:()=>O(!D),children:D?e(`bots:sidebar.showLess`):e(`bots:sidebar.showAll`,{count:i.length})}),k.length>0&&(0,V.jsx)(`ul`,{role:`list`,"aria-label":e(`bots:sidebar.rooms`),className:`m-0 mt-0.5 list-none p-0`,children:k.map(t=>{let n=_.pathname===o(t.id),r=t.members.map(e=>i.find(t=>t.id===e)?.avatar).filter(e=>e!==void 0);return(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,"data-sidebar-room":t.id,"aria-current":n?`page`:void 0,className:S(`flex h-8 w-full min-w-0 items-center gap-2.5 rounded-[var(--r-md)] px-2.5 text-left hover:bg-surface-hover pointer-coarse:h-11`,n&&`bg-surface-active hover:bg-surface-active`),onClick:()=>d(o(t.id)),children:[(0,V.jsx)(f,{avatars:r,variant:`tile`}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-[13.5px] text-content`,children:[t.name,t.activity.needsYou&&(0,V.jsx)(`span`,{className:`sr-only`,children:` · ${e(`bots:room.needsYou`)}`})]}),t.activity.working>0&&(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`flex-none text-[11.5px] text-content-muted tabular-nums`,children:t.activity.working}),t.activity.needsYou&&(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 flex-none rounded-full bg-st-attn`})]})},t.id)})}),(0,V.jsx)(U,{open:T,onOpenChange:E,onCreated:e=>d(o(e.id))}),(0,V.jsx)(h,{open:C,onOpenChange:w,onCreated:e=>void A(e)})]})}export{W as default};
@@ -1 +1 @@
1
- import{o as e}from"./vendor-state-GkUciC5H.js";import{t}from"./api-BA-WPJCg.js";import{t as n}from"./runtime-capabilities-CxyszNkG.js";function r(e){let t={...n.features};for(let n of Object.keys(t)){let r=e.features?.[n];typeof r==`boolean`&&(t[n]=r)}let r=[`desktop`,`mobile-embedded`,`mobile-store`].includes(String(e.profile))?e.profile:`desktop`;return{version:Number(e.version)||0,profile:r,engine:`node`,degraded:e.degraded===!0,modules:{childProcess:e.modules?.childProcess!==!1,workerThreads:e.modules?.workerThreads!==!1,sqlite:e.modules?.sqlite!==!1,wasm:e.modules?.wasm!==!1},features:t,tools:Array.isArray(e.tools)?e.tools.filter(e=>typeof e==`string`):[]}}var i=null,a=e()((e,a)=>({capabilities:n,loaded:!1,load:({refresh:o=!0}={})=>i||(!o&&a().loaded?Promise.resolve():(i=(async()=>{try{e({capabilities:r(await t(`/api/runtime/capabilities`)),loaded:!0})}catch{e({capabilities:n,loaded:!0})}})().finally(()=>{i=null}),i))}));export{a as t};
1
+ import{o as e}from"./vendor-state-GkUciC5H.js";import{t}from"./api-BbBnrW3n.js";import{t as n}from"./runtime-capabilities-CxyszNkG.js";function r(e){let t={...n.features};for(let n of Object.keys(t)){let r=e.features?.[n];typeof r==`boolean`&&(t[n]=r)}let r=[`desktop`,`mobile-embedded`,`mobile-store`].includes(String(e.profile))?e.profile:`desktop`;return{version:Number(e.version)||0,profile:r,engine:`node`,degraded:e.degraded===!0,modules:{childProcess:e.modules?.childProcess!==!1,workerThreads:e.modules?.workerThreads!==!1,sqlite:e.modules?.sqlite!==!1,wasm:e.modules?.wasm!==!1},features:t,tools:Array.isArray(e.tools)?e.tools.filter(e=>typeof e==`string`):[]}}var i=null,a=e()((e,a)=>({capabilities:n,loaded:!1,load:({refresh:o=!0}={})=>i||(!o&&a().loaded?Promise.resolve():(i=(async()=>{try{e({capabilities:r(await t(`/api/runtime/capabilities`)),loaded:!0})}catch{e({capabilities:n,loaded:!0})}})().finally(()=>{i=null}),i))}));export{a as t};
@@ -1 +1 @@
1
- import{t as e}from"./index-Cj4werSq.js";import{t}from"./safe-mode-sentinel-DiBJExnu.js";var n=`safe-mode`,r=`components`,i=3e3,a=64,o=/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,95}$/;function s(e){if(!e||e.length>16384)return null;let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t.loading;if(!n||typeof n!=`object`||Array.isArray(n))return null;let{at:r,instanceIds:i}=n;return typeof r!=`string`||!Number.isFinite(Date.parse(r))||!Array.isArray(i)?null:{loading:{at:r,instanceIds:i.filter(e=>typeof e==`string`&&o.test(e)).slice(0,a)}}}function c(e){try{return new URLSearchParams(e).get(n)===r}catch{return!1}}function l(e){return typeof window>`u`?()=>{}:(window.addEventListener(`beforeunload`,e),window.addEventListener(`pagehide`,e,{capture:!0}),()=>{window.removeEventListener(`beforeunload`,e),window.removeEventListener(`pagehide`,e,{capture:!0})})}function u({storage:e,search:n,now:r=()=>Date.now(),schedule:o=(e,t)=>setTimeout(e,t),cancel:u=e=>clearTimeout(e),listenUnload:d=l}){let f=new Set,p=()=>{try{return s(e.getItem(t))}catch{return null}},m=n=>{try{n?e.setItem(t,JSON.stringify(n)):e.removeItem(t)}catch{}},h=c(n)?null:p(),g=c(n)?`safe`:h?`pending`:`normal`,_=h,v=`idle`,y=new Set,b=[],x=null,S=null,C=()=>{S?.(),S=null},w=()=>{for(let e of[...f])e()};return{mode:()=>g,staleSentinel:()=>_,beginLoad(e){g===`normal`&&v!==`done`&&(x!==null&&(u(x),x=null),v=`loading`,S??=d(()=>{v===`loading`&&m(null)}),y.add(e),!b.includes(e)&&b.length<a&&b.push(e),m({loading:{at:new Date(r()).toISOString(),instanceIds:[...b]}}))},endLoad(e){v!==`loading`||!y.delete(e)||y.size||(x=o(()=>{x=null,!y.size&&(v=`done`,C(),m(null))},i))},resolve(e){g===`pending`&&(_=null,m(null),g=e===`safe`?`safe`:`normal`,w())},subscribe(e){return f.add(e),()=>{f.delete(e)}},dispose(){x!==null&&u(x),x=null,C(),f.clear()}}}var d=null;function f(){return d??=u({storage:e,search:typeof window>`u`?``:window.location.search}),d}export{f as t};
1
+ import{t as e}from"./index-DL89Jrzh.js";import{t}from"./safe-mode-sentinel-DfoN8ker.js";var n=`safe-mode`,r=`components`,i=3e3,a=64,o=/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,95}$/;function s(e){if(!e||e.length>16384)return null;let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t.loading;if(!n||typeof n!=`object`||Array.isArray(n))return null;let{at:r,instanceIds:i}=n;return typeof r!=`string`||!Number.isFinite(Date.parse(r))||!Array.isArray(i)?null:{loading:{at:r,instanceIds:i.filter(e=>typeof e==`string`&&o.test(e)).slice(0,a)}}}function c(e){try{return new URLSearchParams(e).get(n)===r}catch{return!1}}function l(e){return typeof window>`u`?()=>{}:(window.addEventListener(`beforeunload`,e),window.addEventListener(`pagehide`,e,{capture:!0}),()=>{window.removeEventListener(`beforeunload`,e),window.removeEventListener(`pagehide`,e,{capture:!0})})}function u({storage:e,search:n,now:r=()=>Date.now(),schedule:o=(e,t)=>setTimeout(e,t),cancel:u=e=>clearTimeout(e),listenUnload:d=l}){let f=new Set,p=()=>{try{return s(e.getItem(t))}catch{return null}},m=n=>{try{n?e.setItem(t,JSON.stringify(n)):e.removeItem(t)}catch{}},h=c(n)?null:p(),g=c(n)?`safe`:h?`pending`:`normal`,_=h,v=`idle`,y=new Set,b=[],x=null,S=null,C=()=>{S?.(),S=null},w=()=>{for(let e of[...f])e()};return{mode:()=>g,staleSentinel:()=>_,beginLoad(e){g===`normal`&&v!==`done`&&(x!==null&&(u(x),x=null),v=`loading`,S??=d(()=>{v===`loading`&&m(null)}),y.add(e),!b.includes(e)&&b.length<a&&b.push(e),m({loading:{at:new Date(r()).toISOString(),instanceIds:[...b]}}))},endLoad(e){v!==`loading`||!y.delete(e)||y.size||(x=o(()=>{x=null,!y.size&&(v=`done`,C(),m(null))},i))},resolve(e){g===`pending`&&(_=null,m(null),g=e===`safe`?`safe`:`normal`,w())},subscribe(e){return f.add(e),()=>{f.delete(e)}},dispose(){x!==null&&u(x),x=null,C(),f.clear()}}}var d=null;function f(){return d??=u({storage:e,search:typeof window>`u`?``:window.location.search}),d}export{f as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./index-DL89Jrzh.js";var t=`pisper-components-safe-mode`;function n(){try{return e.getItem(t)!==null}catch{return!1}}export{n,t};
@@ -1 +1 @@
1
- import{a as e}from"./startup-queries-mAINlcNF.js";import{t}from"./api-BA-WPJCg.js";function n(e){if(!e||typeof e!=`object`)throw Error(`Invalid change summary`);let t=e;if(t.status!==`known`&&t.status!==`partial`&&t.status!==`unavailable`||!Number.isInteger(t.unknownFiles)||Number(t.unknownFiles)<0||typeof t.capped!=`boolean`||![`changedFiles`,`pendingFiles`,`added`,`removed`].every(e=>t.status===`known`?Number.isInteger(t[e])&&Number(t[e])>=0:t[e]===null))throw Error(`Invalid change summary`);return t}async function r(e){return n(await t(`/api/sessions/${encodeURIComponent(e)}/change-summary`))}function i(t){return e.invalidateQueries({queryKey:[`session-change-summary`,t]})}export{i as n,r as t};
1
+ import{a as e}from"./startup-queries-Cc9LSolC.js";import{t}from"./api-BbBnrW3n.js";function n(e){if(!e||typeof e!=`object`)throw Error(`Invalid change summary`);let t=e;if(t.status!==`known`&&t.status!==`partial`&&t.status!==`unavailable`||!Number.isInteger(t.unknownFiles)||Number(t.unknownFiles)<0||typeof t.capped!=`boolean`||![`changedFiles`,`pendingFiles`,`added`,`removed`].every(e=>t.status===`known`?Number.isInteger(t[e])&&Number(t[e])>=0:t[e]===null))throw Error(`Invalid change summary`);return t}async function r(e){return n(await t(`/api/sessions/${encodeURIComponent(e)}/change-summary`))}function i(t){return e.invalidateQueries({queryKey:[`session-change-summary`,t]})}export{i as n,r as t};
@@ -1 +1 @@
1
- import{t as e}from"./index-Cj4werSq.js";var t=`pisper-last-session`;function n(e){if(typeof e!=`string`)return``;let t=e.trim();return!t||t.length>256||t===`new`||/[\u0000-\u001f\u007f]/.test(t)?``:t}function r(){try{return n(e.getItem(t))}catch{return``}}function i(r){let i=n(r);if(i)try{e.getItem(`pisper-last-session`)!==i&&e.setItem(t,i)}catch{}}function a(n){try{e.getItem(`pisper-last-session`)===n&&e.removeItem(t)}catch{}}function o(e){if(!e||typeof e!=`object`)return null;let t=e.sessions;return Array.isArray(t)?t.flatMap(e=>{if(!e||typeof e!=`object`)return[];let{id:t,archived:n}=e;return typeof t==`string`&&t?[{id:t,archived:n===!0}]:[]}):null}function s({lastId:e,data:t,failed:n}){if(!e)return{kind:`draft`};let r=o(t);if(!r)return n?{kind:`error`}:{kind:`loading`};let i=r.find(t=>t.id===e);return i&&!i.archived?{kind:`session`,id:i.id}:{kind:`draft`}}export{i,s as n,r,a as t};
1
+ import{t as e}from"./index-DL89Jrzh.js";var t=`pisper-last-session`;function n(e){if(typeof e!=`string`)return``;let t=e.trim();return!t||t.length>256||t===`new`||/[\u0000-\u001f\u007f]/.test(t)?``:t}function r(){try{return n(e.getItem(t))}catch{return``}}function i(r){let i=n(r);if(i)try{e.getItem(`pisper-last-session`)!==i&&e.setItem(t,i)}catch{}}function a(n){try{e.getItem(`pisper-last-session`)===n&&e.removeItem(t)}catch{}}function o(e){if(!e||typeof e!=`object`)return null;let t=e.sessions;return Array.isArray(t)?t.flatMap(e=>{if(!e||typeof e!=`object`)return[];let{id:t,archived:n}=e;return typeof t==`string`&&t?[{id:t,archived:n===!0}]:[]}):null}function s({lastId:e,data:t,failed:n}){if(!e)return{kind:`draft`};let r=o(t);if(!r)return n?{kind:`error`}:{kind:`loading`};let i=r.find(t=>t.id===e);return i&&!i.archived?{kind:`session`,id:i.id}:{kind:`draft`}}export{i,s as n,r,a as t};
@@ -1 +1 @@
1
- import{t as e}from"./index-Cj4werSq.js";import{a as t,i as n,o as r}from"./vendor-state-GkUciC5H.js";var i=[`changes`,`terminal`,`running`,`files`,`preview`,`plan`,`side-chat`,`subagent`],a=3,o=720;function s(e){return typeof e!=`number`||!Number.isFinite(e)?456:Math.min(o,Math.max(360,Math.round(e)))}function c(e){return Math.round(Math.min(80,Math.max(a,e))*100)/100}function l(e,t){return typeof e==`number`&&Number.isFinite(e)?c(e):typeof t==`number`&&s(t)!==456?null:39}function u(e,t){let n=Math.max(360,Math.min(t*80/100,t-480-8));return Math.round(Math.min(n,Math.max(360,e)))}function d({widthPercent:e,width:t},n){return u(e===null?s(t):n*e/100,n)}function f(e){let t=e&&typeof e==`object`&&!Array.isArray(e)?e:{},n=i.find(e=>e===t.tab)??`changes`,r=t.pinned===!0;return{open:r&&t.open!==!1,pinned:r,tab:n===`side-chat`?`changes`:n,widthPercent:l(t.widthPercent,t.width),width:s(t.width),terminalView:t.terminalView===`processes`?`processes`:`terminal`,changesView:t.changesView===`workspace`?`workspace`:`session`,diffMode:t.diffMode===`split`?`split`:`unified`}}var p=n(()=>({getItem:t=>{try{return e.getItem(t)}catch{return null}},setItem:(t,n)=>{try{e.setItem(t,n)}catch{}},removeItem:t=>{try{e.removeItem(t)}catch{}}})),m=r()(t((e,t)=>({...f(void 0),setOpen:n=>{t().open!==n&&e({open:n})},setPinned:t=>e(t?{pinned:t,open:!0}:{pinned:t}),setTab:n=>{t().tab!==n&&e({tab:n})},setWidth:(n,r)=>{if(!(r>0))return;let i=c(n/r*100);t().widthPercent!==i&&e({widthPercent:i,width:s(n)})},resetWidth:()=>e({widthPercent:39,width:456}),setTerminalView:t=>e({terminalView:t}),setChangesView:t=>e({changesView:t}),setDiffMode:t=>e({diffMode:t})}),{name:`pisper-session-inspector`,version:1,storage:p,partialize:({open:e,pinned:t,tab:n,widthPercent:r,width:i,terminalView:a,changesView:o,diffMode:s})=>({open:e,pinned:t,tab:n,widthPercent:r,width:i,terminalView:a,changesView:o,diffMode:s}),migrate:e=>f(e),merge:(e,t)=>({...t,...f(e)})}));export{d as n,m as r,u as t};
1
+ import{t as e}from"./index-DL89Jrzh.js";import{a as t,i as n,o as r}from"./vendor-state-GkUciC5H.js";var i=[`changes`,`terminal`,`running`,`files`,`preview`,`plan`,`side-chat`,`subagent`],a=3,o=720;function s(e){return typeof e!=`number`||!Number.isFinite(e)?456:Math.min(o,Math.max(360,Math.round(e)))}function c(e){return Math.round(Math.min(80,Math.max(a,e))*100)/100}function l(e,t){return typeof e==`number`&&Number.isFinite(e)?c(e):typeof t==`number`&&s(t)!==456?null:39}function u(e,t){let n=Math.max(360,Math.min(t*80/100,t-480-8));return Math.round(Math.min(n,Math.max(360,e)))}function d({widthPercent:e,width:t},n){return u(e===null?s(t):n*e/100,n)}function f(e){let t=e&&typeof e==`object`&&!Array.isArray(e)?e:{},n=i.find(e=>e===t.tab)??`changes`,r=t.pinned===!0;return{open:r&&t.open!==!1,pinned:r,tab:n===`side-chat`?`changes`:n,widthPercent:l(t.widthPercent,t.width),width:s(t.width),terminalView:t.terminalView===`processes`?`processes`:`terminal`,changesView:t.changesView===`workspace`?`workspace`:`session`,diffMode:t.diffMode===`split`?`split`:`unified`}}var p=n(()=>({getItem:t=>{try{return e.getItem(t)}catch{return null}},setItem:(t,n)=>{try{e.setItem(t,n)}catch{}},removeItem:t=>{try{e.removeItem(t)}catch{}}})),m=r()(t((e,t)=>({...f(void 0),setOpen:n=>{t().open!==n&&e({open:n})},setPinned:t=>e(t?{pinned:t,open:!0}:{pinned:t}),setTab:n=>{t().tab!==n&&e({tab:n})},setWidth:(n,r)=>{if(!(r>0))return;let i=c(n/r*100);t().widthPercent!==i&&e({widthPercent:i,width:s(n)})},resetWidth:()=>e({widthPercent:39,width:456}),setTerminalView:t=>e({terminalView:t}),setChangesView:t=>e({changesView:t}),setDiffMode:t=>e({diffMode:t})}),{name:`pisper-session-inspector`,version:1,storage:p,partialize:({open:e,pinned:t,tab:n,widthPercent:r,width:i,terminalView:a,changesView:o,diffMode:s})=>({open:e,pinned:t,tab:n,widthPercent:r,width:i,terminalView:a,changesView:o,diffMode:s}),migrate:e=>f(e),merge:(e,t)=>({...t,...f(e)})}));export{d as n,m as r,u as t};
@@ -1 +1 @@
1
- import{t as e}from"./api-BA-WPJCg.js";import{u as t}from"./events-BCP3T_26.js";var n=class extends Error{code=`invalid_session_organization_response`};function r(e){if(!e||typeof e!=`object`)throw new n;let{id:t,pinned:r,archived:i,unread:a,needsAttention:o,attentionReason:s}=e;if(typeof t!=`string`||!t||typeof r!=`boolean`||typeof i!=`boolean`||typeof a!=`boolean`||typeof o!=`boolean`||s!==null&&s!==`approval`&&s!==`failure`)throw new n;return{id:t,pinned:r,archived:i,unread:a,needsAttention:o,attentionReason:s}}async function i(i,a){if(!i||!Object.keys(a).length)throw new n;let o=r(await e(`/api/sessions/${encodeURIComponent(i)}/organization`,{method:`PATCH`,body:JSON.stringify(a)}));if(o.id!==i)throw new n;return t(o),o}var a=new Set;function o(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e.id;return typeof t==`string`&&t&&t.length<=200?t:null}function s(e){return a.add(e),()=>{a.delete(e)}}function c(e,t,n){if(!n||!a.size)return;let r=e===`snapshot`?`*`:e===`session_workspace`?o(t):null;if(r)for(let e of[...a])try{e(r)}catch{}}var l=Object.freeze({questions:4,header:24,question:400,options:6,label:60,description:200,other:2e3}),u=/^q_[A-Za-z0-9-]{8,64}$/;function d(e,t){if(typeof e!=`string`)return``;let n=Array.from(e.trim());return n.length>t?n.slice(0,t).join(``):n.join(``)}function f(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function p(e){let t=f(e);if(!t)return null;let n=d(t.question,l.question),r=[],i=new Set;for(let e of Array.isArray(t.options)?t.options:[]){let t=f(e),n=d(t?t.label:e,l.label);if(!(!n||i.has(n))&&(i.add(n),r.push({label:n,description:d(t?.description,l.description)}),r.length>=l.options))break}return!n||r.length<2?null:{header:d(t.header,l.header),question:n,options:r,multiSelect:t.multiSelect===!0}}function m(e){let t=f(e);if(!t)return null;let n=typeof t.id==`string`?t.id:typeof t.questionId==`string`?t.questionId:``;if(!u.test(n))return null;let r=(Array.isArray(t.questions)?t.questions:[]).slice(0,l.questions).map(p);return!r.length||r.some(e=>!e)?null:{id:n,questions:r,createdAt:typeof t.createdAt==`string`?t.createdAt:``}}function h(e){if(!Array.isArray(e))return[];let t=new Set,n=[];for(let r of e){let e=m(r);!e||t.has(e.id)||(t.add(e.id),n.push(e))}return n.sort((e,t)=>e.createdAt.localeCompare(t.createdAt))}function g(e){if(!e||e.questions.length!==1)return null;let[t]=e.questions;return t.multiSelect||t.options.length>4?null:t.options.map(e=>e.label)}function _(e,t){return e.questions.every((e,n)=>{let r=t[n];return!!(r&&(r.selected.length>0||r.other?.trim()))})}export{h as a,n as c,m as i,i as l,_ as n,c as o,g as r,s,l as t};
1
+ import{t as e}from"./api-BbBnrW3n.js";import{u as t}from"./events-CAivTGZK.js";var n=class extends Error{code=`invalid_session_organization_response`};function r(e){if(!e||typeof e!=`object`)throw new n;let{id:t,pinned:r,archived:i,unread:a,needsAttention:o,attentionReason:s}=e;if(typeof t!=`string`||!t||typeof r!=`boolean`||typeof i!=`boolean`||typeof a!=`boolean`||typeof o!=`boolean`||s!==null&&s!==`approval`&&s!==`failure`)throw new n;return{id:t,pinned:r,archived:i,unread:a,needsAttention:o,attentionReason:s}}async function i(i,a){if(!i||!Object.keys(a).length)throw new n;let o=r(await e(`/api/sessions/${encodeURIComponent(i)}/organization`,{method:`PATCH`,body:JSON.stringify(a)}));if(o.id!==i)throw new n;return t(o),o}var a=new Set;function o(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e.id;return typeof t==`string`&&t&&t.length<=200?t:null}function s(e){return a.add(e),()=>{a.delete(e)}}function c(e,t,n){if(!n||!a.size)return;let r=e===`snapshot`?`*`:e===`session_workspace`?o(t):null;if(r)for(let e of[...a])try{e(r)}catch{}}var l=Object.freeze({questions:4,header:24,question:400,options:6,label:60,description:200,other:2e3}),u=/^q_[A-Za-z0-9-]{8,64}$/;function d(e,t){if(typeof e!=`string`)return``;let n=Array.from(e.trim());return n.length>t?n.slice(0,t).join(``):n.join(``)}function f(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function p(e){let t=f(e);if(!t)return null;let n=d(t.question,l.question),r=[],i=new Set;for(let e of Array.isArray(t.options)?t.options:[]){let t=f(e),n=d(t?t.label:e,l.label);if(!(!n||i.has(n))&&(i.add(n),r.push({label:n,description:d(t?.description,l.description)}),r.length>=l.options))break}return!n||r.length<2?null:{header:d(t.header,l.header),question:n,options:r,multiSelect:t.multiSelect===!0}}function m(e){let t=f(e);if(!t)return null;let n=typeof t.id==`string`?t.id:typeof t.questionId==`string`?t.questionId:``;if(!u.test(n))return null;let r=(Array.isArray(t.questions)?t.questions:[]).slice(0,l.questions).map(p);return!r.length||r.some(e=>!e)?null:{id:n,questions:r,createdAt:typeof t.createdAt==`string`?t.createdAt:``}}function h(e){if(!Array.isArray(e))return[];let t=new Set,n=[];for(let r of e){let e=m(r);!e||t.has(e.id)||(t.add(e.id),n.push(e))}return n.sort((e,t)=>e.createdAt.localeCompare(t.createdAt))}function g(e){if(!e||e.questions.length!==1)return null;let[t]=e.questions;return t.multiSelect||t.options.length>4?null:t.options.map(e=>e.label)}function _(e,t){return e.questions.every((e,n)=>{let r=t[n];return!!(r&&(r.selected.length>0||r.other?.trim()))})}export{h as a,n as c,m as i,i as l,_ as n,c as o,g as r,s,l as t};
@@ -1 +1 @@
1
- import{a as e}from"./http-response-tU9Jgwk1.js";import{n as t,r as n}from"./http-BJXYcBJZ.js";import{a as r}from"./session-board-status-D_Tz3HJm.js";var i={all:[`custom-ui`],catalog:()=>[`custom-ui`,`catalog`],instances:()=>[`custom-ui`,`instances`],describe:e=>[`custom-ui`,`describe`,e],errors:e=>[`custom-ui`,`errors`,e],versions:e=>[`custom-ui`,`versions`,e],usage:e=>[`custom-ui`,`usage`,e],trash:()=>[`custom-ui`,`trash`],staged:e=>[`custom-ui`,`staged`,e]};function a(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var o=[`overview-card`,`session-panel`,`feature-page`,`floating`],s=[`S`,`M`],c=/^[a-z0-9][a-z0-9._-]{0,63}$/,l=/^[a-f0-9]{24}$/,u=/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,79}$/,d=/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/,f=/^[a-f0-9]{16}$/,p=[`network`,`notify`,`sessions.read`,`sessions.open`,`storage`,`provider.request`];function m(e,t=4e3){return typeof e==`string`?e.slice(0,t):``}function h(e){if(typeof e!=`string`||!e||e.length>512)return!1;let t=e.split(`/`);return t.length<=3&&t.every(e=>d.test(e))}function g(e,t=200){let n={};if(!a(e))return n;for(let[r,i]of Object.entries(e).slice(0,t))typeof i==`string`&&(n[r]=i);return n}function _(e){if(!Array.isArray(e))return[];let t=[];for(let n of e.slice(0,200)){if(!a(n)||typeof n.code!=`string`||!n.code)continue;let e={path:m(n.path,512),code:m(n.code,128)};if(a(n.params)){let t={};for(let[e,r]of Object.entries(n.params))(typeof r==`string`||typeof r==`number`&&Number.isFinite(r))&&(t[e]=r);e.params=t}t.push(e)}return t}function v(e){let t={};if(!a(e))return t;for(let n of[`zh-CN`,`en-US`]){let r=e[n];a(r)&&(t[n]={...typeof r.name==`string`?{name:r.name}:{},...typeof r.description==`string`?{description:r.description}:{},strings:g(r.strings,500)})}return t}function y(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!a(n)||!o.includes(n.surface))continue;let e=n.surface;if(t.some(t=>t.surface===e))continue;let r={surface:e};if(Array.isArray(n.sizes)){let e=s.filter(e=>n.sizes.includes(e));e.length&&(r.sizes=e)}a(n.size)&&typeof n.size.w==`number`&&typeof n.size.h==`number`&&Number.isFinite(n.size.w)&&Number.isFinite(n.size.h)&&n.size.w>0&&n.size.h>0&&(r.size={w:n.size.w,h:n.size.h}),t.push(r)}return t}function b(e){let t={};if(!a(e))return t;let n=e=>m(e.reason,500);for(let r of[`notify`,`sessions.read`,`sessions.open`]){let i=e[r];a(i)&&(t[r]={reason:n(i)})}let r=e[`provider.request`];a(r)&&Array.isArray(r.paths)&&Array.isArray(r.methods)&&(t[`provider.request`]={reason:n(r),paths:r.paths.filter(e=>typeof e==`string`),methods:r.methods.filter(e=>typeof e==`string`)});let i=e.network;a(i)&&Array.isArray(i.hosts)&&(t.network={reason:n(i),hosts:i.hosts.filter(e=>typeof e==`string`).slice(0,32),...Array.isArray(i.privateOrigins)&&{privateOrigins:i.privateOrigins.filter(e=>typeof e==`string`).slice(0,32)}});let o=e.storage;return a(o)&&(t.storage={reason:n(o),quotaKb:typeof o.quotaKb==`number`&&Number.isFinite(o.quotaKb)?o.quotaKb:256}),t}function x(e,t){if(!a(t)||t.runtime!==`native`||t.id!==e||!h(t.entry))return null;let n=a(t.props)?t.props:null;if(!n||n.type!==`object`||!a(n.properties))return null;let r=Array.isArray(t.styles)?t.styles:[];return r.every(h)?{runtime:`native`,id:e,name:m(t.name,120)||e,version:m(t.version,64),description:m(t.description,500),entry:t.entry,styles:r.slice(0,8),icon:m(t.icon,48),i18n:v(t.i18n),props:{type:`object`,properties:n.properties,required:Array.isArray(n.required)?n.required.filter(e=>typeof e==`string`):[]},placements:y(t.placements),capabilities:b(t.capabilities),sdk:typeof t.sdk==`number`?t.sdk:1,minHostVersion:m(t.minHostVersion,64)}:null}function S(e){return e===`agent`||e===`template`||e===`import`?e:`local`}function C(e){return Array.isArray(e)?p.filter(t=>e.includes(t)):[]}function w(e){return!a(e)||typeof e.stageId!=`string`||!f.test(e.stageId)||typeof e.id!=`string`||!c.test(e.id)?null:{stageId:e.stageId,id:e.id,name:m(e.name,120)||e.id,version:m(e.version,64),fileName:m(e.fileName,200)||`${e.id}.zip`,bytes:typeof e.bytes==`number`&&Number.isFinite(e.bytes)?e.bytes:0,sha256:/^[a-f0-9]{64}$/.test(String(e.sha256))?String(e.sha256):``,createdAt:m(e.createdAt,64),replaces:e.replaces===`native`||e.replaces===`legacy`||e.replaces===`broken`?e.replaces:null}}function T(e){if(!a(e)||typeof e.id!=`string`||!c.test(e.id))return null;let t=e.id,n={id:t,name:m(e.name,120)||t,version:m(e.version,64),description:m(e.description,500),directory:m(e.directory,4096),updatedAt:m(e.updatedAt,64),revoked:C(e.revoked)};if(e.kind!==`native`&&e.kind!==`broken`)return{...n,kind:`legacy`,status:`unsupported`,enabled:!1,source:S(e.source),entry:``,errors:_(e.errors)};if(e.kind===`broken`)return{...n,kind:`broken`,status:`invalid`,enabled:!1,source:S(e.source),entry:``,errors:_(e.errors)};let r=_(e.errors),i={...n,kind:`native`,status:e.status===`ready`?`ready`:`invalid`,enabled:e.enabled===!0,source:S(e.source),entry:m(e.entry,512),errors:r};if(e.manifest!==void 0){let n=x(t,e.manifest);n&&(i.manifest=n)}return i.status===`ready`&&(typeof e.rev==`string`&&l.test(e.rev)&&i.manifest?i.rev=e.rev:(i.status=`invalid`,i.errors=[...r,{path:``,code:`component_response_invalid`}])),i}function E(e){if(!a(e)||typeof e.root!=`string`||!Array.isArray(e.components))throw Error(`Invalid custom UI component response`);let t=a(e.features)?e.features:null,n=[],r=new Set;for(let t of e.components){let e=T(t);!e||r.has(e.id)||(r.add(e.id),n.push(e))}let i=[];for(let t of Array.isArray(e.staged)?e.staged.slice(0,50):[]){let e=w(t);e&&!i.some(t=>t.stageId===e.stageId)&&i.push(e)}return{root:e.root,features:{import:t?.import===!0,versions:t?.versions===!0,export:t?.export===!0,trash:t?.trash===`move`?`move`:`none`,trashRestore:t?.trashRestore===!0,usage:t?.usage===!0,revoke:t?.revoke===!0},components:n,staged:i,legacyShape:!t}}function D(e){return a(e)?e.type===`all`?{type:`all`}:e.type===`project`&&typeof e.cwd==`string`&&e.cwd?{type:`project`,cwd:e.cwd}:null:null}function O(e){if(!a(e)||typeof e.instanceId!=`string`||!u.test(e.instanceId)||typeof e.componentId!=`string`||!c.test(e.componentId)||!o.includes(e.surface))return null;let t=e.surface;return{instanceId:e.instanceId,componentId:e.componentId,surface:t,size:t===`overview-card`?s.includes(e.size)?e.size:`S`:null,scope:t===`session-panel`?D(e.scope)??{type:`all`}:null,title:m(e.title,80),props:a(e.props)?e.props:{},enabled:e.enabled!==!1,order:typeof e.order==`number`&&Number.isFinite(e.order)?e.order:0,createdAt:m(e.createdAt,64),updatedAt:m(e.updatedAt,64)}}function k(e){if(!a(e)||typeof e.revision!=`number`||!Number.isSafeInteger(e.revision)||!Array.isArray(e.instances))throw Error(`Invalid custom UI instances response`);let t=[],n=new Set;for(let r of e.instances){let e=O(r);!e||n.has(e.instanceId)||(n.add(e.instanceId),t.push(e))}return t.sort((e,t)=>e.order-t.order),{revision:e.revision,instances:t}}function A(e){let t=a(e)?O(e.instance):null;if(!t||!a(e)||typeof e.revision!=`number`)throw Error(`Invalid custom UI instance response`);return{revision:e.revision,instance:t}}function j(e){if(!a(e)||!Array.isArray(e.entries))throw Error(`Invalid custom UI errors response`);let t=[];for(let n of e.entries.slice(-200))!a(n)||typeof n.message!=`string`||t.push({at:m(n.at,64),kind:m(n.kind,32),level:m(n.level,16),message:m(n.message,500),...typeof n.stack==`string`?{stack:m(n.stack,4e3)}:{},...typeof n.instanceId==`string`?{instanceId:m(n.instanceId,80)}:{},...typeof n.surface==`string`?{surface:m(n.surface,32)}:{}});let n=a(e.network)?e.network:{},r={};if(a(n.hosts))for(let[e,t]of Object.entries(n.hosts).slice(0,64))typeof t==`number`&&Number.isFinite(t)&&(r[e]=t);return{entries:t,dropped:typeof e.dropped==`number`&&Number.isFinite(e.dropped)?e.dropped:0,network:{count:typeof n.count==`number`&&Number.isFinite(n.count)?n.count:0,lastAt:typeof n.lastAt==`string`?n.lastAt:null,hosts:r}}}function M(e){return typeof e==`number`&&Number.isFinite(e)&&e>=0?e:0}function N(e){if(!a(e)||e.status!==`ok`)return{status:`unsupported`};let t=a(e.summary)?e.summary:{},n=[`danger`,`warn`,`info`];return{status:`ok`,hosts:(Array.isArray(e.hosts)?e.hosts.slice(0,50):[]).flatMap(e=>a(e)&&typeof e.host==`string`?[{host:m(e.host,253),declared:e.declared===!0,file:m(e.file,512),line:M(e.line)}]:[]),findings:(Array.isArray(e.findings)?e.findings.slice(0,200):[]).flatMap(e=>a(e)&&typeof e.rule==`string`&&n.includes(e.severity)?[{rule:m(e.rule,32),severity:e.severity,file:m(e.file,512),line:M(e.line),excerpt:m(e.excerpt,200)}]:[]),summary:{danger:M(t.danger),warn:M(t.warn),info:M(t.info),undeclaredHosts:M(t.undeclaredHosts)},truncated:e.truncated===!0}}function P(e){return Array.isArray(e)?e.filter(e=>a(e)&&typeof e.path==`string`&&typeof e.size==`number`&&typeof e.type==`string`).slice(0,256).map(e=>({path:e.path,size:e.size,type:e.type})):[]}function F(e){let t=a(e)?T(e.component):null;if(!t||!a(e)||!Array.isArray(e.files))throw Error(`Invalid custom UI describe response`);return{component:t,files:P(e.files),errors:_(e.errors),scan:N(e.scan)}}function I(e){if(!a(e)||typeof e.status!=`number`||typeof e.body!=`string`||e.bodyEncoding!==`utf8`&&e.bodyEncoding!==`base64`)throw Error(`Invalid custom UI fetch response`);return{status:e.status,statusText:m(e.statusText,200),headers:g(e.headers,64),body:e.body,bodyEncoding:e.bodyEncoding,url:m(e.url,2048),redirected:e.redirected===!0}}function L(t){if(!(t instanceof e)||!t.data)return null;let n=t.data.code??t.data.error;return typeof n==`string`&&/^[a-z0-9_]{1,64}$/.test(n)?n:null}function R(t){return!(t instanceof e)||!t.data?[]:_(t.data.errors)}var z=e=>`/api/custom-ui/components/${encodeURIComponent(e)}`;function B(e,t,n){if(!c.test(e)||!l.test(t)||!h(n))throw Error(`Invalid component module path`);return`${z(e)}/r/${t}/${n.split(`/`).map(e=>encodeURIComponent(e)).join(`/`)}`}function V(e,t,r,i){return n(B(e,t,r),{signal:i})}function H(e){return t(`/api/custom-ui/components`,{signal:e,parse:E})}function U(e,n){return t(`${z(e)}/describe`,{signal:n,parse:F})}function ee(e){return t(`/api/custom-ui/components`,{method:`POST`,body:e,parse:e=>{let t=a(e)?T(e.component):null;if(!t)throw Error(`Invalid custom UI component response`);return t}})}function W(e,n){return t(z(e),{method:`PATCH`,body:{enabled:n},parse:e=>{let t=a(e)?T(e.component):null;if(!t)throw Error(`Invalid custom UI component response`);return t}})}function G(e){return t(z(e),{method:`DELETE`,parse:e=>({trashedAs:a(e)?m(e.trashedAs,256):``})})}function K(e){return t(`/api/custom-ui/instances`,{signal:e,parse:k})}function q(e){return t(`/api/custom-ui/instances`,{method:`POST`,body:e,parse:A})}function J(e,n){return t(`/api/custom-ui/instances/${encodeURIComponent(e)}`,{method:`PATCH`,body:n,parse:A})}function Y(e){return t(`/api/custom-ui/instances/${encodeURIComponent(e)}`,{method:`DELETE`,parse:e=>({revision:a(e)&&typeof e.revision==`number`?e.revision:0})})}function X(e,n){return t(`${z(e)}/errors`,{signal:n,parse:j})}function Z(e,n){return t(`${z(e)}/errors`,{method:`POST`,body:n,keepalive:!0,parse:()=>void 0})}function Q(e,n){return t(`${z(e)}/usage`,{method:`POST`,body:{entries:n},keepalive:!0,parse:()=>void 0})}function $(e,n,r){return t(`${z(e)}/storage/${encodeURIComponent(n)}`,{signal:r,parse:e=>{if(!a(e)||!Object.hasOwn(e,`value`))throw Error(`Invalid custom UI storage response`);return{value:e.value}}})}function te(e,n,r){return t(`${z(e)}/storage/${encodeURIComponent(n)}`,{method:`PUT`,body:{value:r},parse:()=>void 0})}function ne(e,n){return t(`${z(e)}/storage/${encodeURIComponent(n)}`,{method:`DELETE`,parse:()=>void 0})}async function re(e,n,r,i){return await t(`/api/custom-ui/provider-session`,{method:`PUT`,body:{sessionId:n},signal:i,timeout:15e3,parse:()=>void 0}),t(`${z(e)}/provider-request`,{method:`POST`,body:{sessionId:n,request:r},signal:i,timeout:15e3,parse:I})}function ie(e,n,r){return t(`${z(e)}/fetch`,{method:`POST`,body:n,signal:r,timeout:15e3,parse:I})}var ae=/^[A-Za-z0-9._:-]{1,128}$/,oe=/^\/skill:[a-z0-9][a-z0-9-]{0,63}$/;function se(e){if(!a(e)||typeof e.sessionId!=`string`||!ae.test(e.sessionId))throw Error(`Invalid custom UI session response`);let t=typeof e.command==`string`&&oe.test(e.command)?e.command:``,n=a(e.session)&&e.session.id===e.sessionId?e.session:null;return{sessionId:e.sessionId,created:e.created===!0,command:t,session:n}}function ce(e){return t(`${z(e)}/session`,{method:`POST`,body:{},parse:se})}function le(e=!0){return{queryKey:i.catalog(),queryFn:({signal:e})=>H(e),enabled:e,staleTime:3e4,retry:!1,refetchOnWindowFocus:!1}}function ue(e=!0){return{queryKey:i.instances(),queryFn:({signal:e})=>K(e),enabled:e,staleTime:3e4,retry:!1,refetchOnWindowFocus:!1}}function de(e,t){if(!e||e.type===`all`)return!0;let n=r(t);return n!==``&&r(e.cwd)===n}export{J as A,x as C,Q as D,Z as E,ce as O,_ as S,V as T,H as _,ie as a,T as b,re as c,te as d,ee as f,U as g,Y as h,L as i,i as j,W as k,$ as l,G as m,le as n,R as o,q as p,ue as r,B as s,de as t,ne as u,X as v,w,N as x,P as y};
1
+ import{a as e}from"./http-response-DObpyFrX.js";import{n as t,r as n}from"./http-CMHs5x9g.js";import{a as r}from"./session-board-status-D_Tz3HJm.js";var i={all:[`custom-ui`],catalog:()=>[`custom-ui`,`catalog`],instances:()=>[`custom-ui`,`instances`],describe:e=>[`custom-ui`,`describe`,e],errors:e=>[`custom-ui`,`errors`,e],versions:e=>[`custom-ui`,`versions`,e],usage:e=>[`custom-ui`,`usage`,e],trash:()=>[`custom-ui`,`trash`],staged:e=>[`custom-ui`,`staged`,e]};function a(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var o=[`overview-card`,`session-panel`,`feature-page`,`floating`],s=[`S`,`M`],c=/^[a-z0-9][a-z0-9._-]{0,63}$/,l=/^[a-f0-9]{24}$/,u=/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,79}$/,d=/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/,f=/^[a-f0-9]{16}$/,p=[`network`,`notify`,`sessions.read`,`sessions.open`,`storage`,`provider.request`];function m(e,t=4e3){return typeof e==`string`?e.slice(0,t):``}function h(e){if(typeof e!=`string`||!e||e.length>512)return!1;let t=e.split(`/`);return t.length<=3&&t.every(e=>d.test(e))}function g(e,t=200){let n={};if(!a(e))return n;for(let[r,i]of Object.entries(e).slice(0,t))typeof i==`string`&&(n[r]=i);return n}function _(e){if(!Array.isArray(e))return[];let t=[];for(let n of e.slice(0,200)){if(!a(n)||typeof n.code!=`string`||!n.code)continue;let e={path:m(n.path,512),code:m(n.code,128)};if(a(n.params)){let t={};for(let[e,r]of Object.entries(n.params))(typeof r==`string`||typeof r==`number`&&Number.isFinite(r))&&(t[e]=r);e.params=t}t.push(e)}return t}function v(e){let t={};if(!a(e))return t;for(let n of[`zh-CN`,`en-US`]){let r=e[n];a(r)&&(t[n]={...typeof r.name==`string`?{name:r.name}:{},...typeof r.description==`string`?{description:r.description}:{},strings:g(r.strings,500)})}return t}function y(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!a(n)||!o.includes(n.surface))continue;let e=n.surface;if(t.some(t=>t.surface===e))continue;let r={surface:e};if(Array.isArray(n.sizes)){let e=s.filter(e=>n.sizes.includes(e));e.length&&(r.sizes=e)}a(n.size)&&typeof n.size.w==`number`&&typeof n.size.h==`number`&&Number.isFinite(n.size.w)&&Number.isFinite(n.size.h)&&n.size.w>0&&n.size.h>0&&(r.size={w:n.size.w,h:n.size.h}),t.push(r)}return t}function b(e){let t={};if(!a(e))return t;let n=e=>m(e.reason,500);for(let r of[`notify`,`sessions.read`,`sessions.open`]){let i=e[r];a(i)&&(t[r]={reason:n(i)})}let r=e[`provider.request`];a(r)&&Array.isArray(r.paths)&&Array.isArray(r.methods)&&(t[`provider.request`]={reason:n(r),paths:r.paths.filter(e=>typeof e==`string`),methods:r.methods.filter(e=>typeof e==`string`)});let i=e.network;a(i)&&Array.isArray(i.hosts)&&(t.network={reason:n(i),hosts:i.hosts.filter(e=>typeof e==`string`).slice(0,32),...Array.isArray(i.privateOrigins)&&{privateOrigins:i.privateOrigins.filter(e=>typeof e==`string`).slice(0,32)}});let o=e.storage;return a(o)&&(t.storage={reason:n(o),quotaKb:typeof o.quotaKb==`number`&&Number.isFinite(o.quotaKb)?o.quotaKb:256}),t}function x(e,t){if(!a(t)||t.runtime!==`native`||t.id!==e||!h(t.entry))return null;let n=a(t.props)?t.props:null;if(!n||n.type!==`object`||!a(n.properties))return null;let r=Array.isArray(t.styles)?t.styles:[];return r.every(h)?{runtime:`native`,id:e,name:m(t.name,120)||e,version:m(t.version,64),description:m(t.description,500),entry:t.entry,styles:r.slice(0,8),icon:m(t.icon,48),i18n:v(t.i18n),props:{type:`object`,properties:n.properties,required:Array.isArray(n.required)?n.required.filter(e=>typeof e==`string`):[]},placements:y(t.placements),capabilities:b(t.capabilities),sdk:typeof t.sdk==`number`?t.sdk:1,minHostVersion:m(t.minHostVersion,64)}:null}function S(e){return e===`agent`||e===`template`||e===`import`?e:`local`}function C(e){return Array.isArray(e)?p.filter(t=>e.includes(t)):[]}function w(e){return!a(e)||typeof e.stageId!=`string`||!f.test(e.stageId)||typeof e.id!=`string`||!c.test(e.id)?null:{stageId:e.stageId,id:e.id,name:m(e.name,120)||e.id,version:m(e.version,64),fileName:m(e.fileName,200)||`${e.id}.zip`,bytes:typeof e.bytes==`number`&&Number.isFinite(e.bytes)?e.bytes:0,sha256:/^[a-f0-9]{64}$/.test(String(e.sha256))?String(e.sha256):``,createdAt:m(e.createdAt,64),replaces:e.replaces===`native`||e.replaces===`legacy`||e.replaces===`broken`?e.replaces:null}}function T(e){if(!a(e)||typeof e.id!=`string`||!c.test(e.id))return null;let t=e.id,n={id:t,name:m(e.name,120)||t,version:m(e.version,64),description:m(e.description,500),directory:m(e.directory,4096),updatedAt:m(e.updatedAt,64),revoked:C(e.revoked)};if(e.kind!==`native`&&e.kind!==`broken`)return{...n,kind:`legacy`,status:`unsupported`,enabled:!1,source:S(e.source),entry:``,errors:_(e.errors)};if(e.kind===`broken`)return{...n,kind:`broken`,status:`invalid`,enabled:!1,source:S(e.source),entry:``,errors:_(e.errors)};let r=_(e.errors),i={...n,kind:`native`,status:e.status===`ready`?`ready`:`invalid`,enabled:e.enabled===!0,source:S(e.source),entry:m(e.entry,512),errors:r};if(e.manifest!==void 0){let n=x(t,e.manifest);n&&(i.manifest=n)}return i.status===`ready`&&(typeof e.rev==`string`&&l.test(e.rev)&&i.manifest?i.rev=e.rev:(i.status=`invalid`,i.errors=[...r,{path:``,code:`component_response_invalid`}])),i}function E(e){if(!a(e)||typeof e.root!=`string`||!Array.isArray(e.components))throw Error(`Invalid custom UI component response`);let t=a(e.features)?e.features:null,n=[],r=new Set;for(let t of e.components){let e=T(t);!e||r.has(e.id)||(r.add(e.id),n.push(e))}let i=[];for(let t of Array.isArray(e.staged)?e.staged.slice(0,50):[]){let e=w(t);e&&!i.some(t=>t.stageId===e.stageId)&&i.push(e)}return{root:e.root,features:{import:t?.import===!0,versions:t?.versions===!0,export:t?.export===!0,trash:t?.trash===`move`?`move`:`none`,trashRestore:t?.trashRestore===!0,usage:t?.usage===!0,revoke:t?.revoke===!0},components:n,staged:i,legacyShape:!t}}function D(e){return a(e)?e.type===`all`?{type:`all`}:e.type===`project`&&typeof e.cwd==`string`&&e.cwd?{type:`project`,cwd:e.cwd}:null:null}function O(e){if(!a(e)||typeof e.instanceId!=`string`||!u.test(e.instanceId)||typeof e.componentId!=`string`||!c.test(e.componentId)||!o.includes(e.surface))return null;let t=e.surface;return{instanceId:e.instanceId,componentId:e.componentId,surface:t,size:t===`overview-card`?s.includes(e.size)?e.size:`S`:null,scope:t===`session-panel`?D(e.scope)??{type:`all`}:null,title:m(e.title,80),props:a(e.props)?e.props:{},enabled:e.enabled!==!1,order:typeof e.order==`number`&&Number.isFinite(e.order)?e.order:0,createdAt:m(e.createdAt,64),updatedAt:m(e.updatedAt,64)}}function k(e){if(!a(e)||typeof e.revision!=`number`||!Number.isSafeInteger(e.revision)||!Array.isArray(e.instances))throw Error(`Invalid custom UI instances response`);let t=[],n=new Set;for(let r of e.instances){let e=O(r);!e||n.has(e.instanceId)||(n.add(e.instanceId),t.push(e))}return t.sort((e,t)=>e.order-t.order),{revision:e.revision,instances:t}}function A(e){let t=a(e)?O(e.instance):null;if(!t||!a(e)||typeof e.revision!=`number`)throw Error(`Invalid custom UI instance response`);return{revision:e.revision,instance:t}}function j(e){if(!a(e)||!Array.isArray(e.entries))throw Error(`Invalid custom UI errors response`);let t=[];for(let n of e.entries.slice(-200))!a(n)||typeof n.message!=`string`||t.push({at:m(n.at,64),kind:m(n.kind,32),level:m(n.level,16),message:m(n.message,500),...typeof n.stack==`string`?{stack:m(n.stack,4e3)}:{},...typeof n.instanceId==`string`?{instanceId:m(n.instanceId,80)}:{},...typeof n.surface==`string`?{surface:m(n.surface,32)}:{}});let n=a(e.network)?e.network:{},r={};if(a(n.hosts))for(let[e,t]of Object.entries(n.hosts).slice(0,64))typeof t==`number`&&Number.isFinite(t)&&(r[e]=t);return{entries:t,dropped:typeof e.dropped==`number`&&Number.isFinite(e.dropped)?e.dropped:0,network:{count:typeof n.count==`number`&&Number.isFinite(n.count)?n.count:0,lastAt:typeof n.lastAt==`string`?n.lastAt:null,hosts:r}}}function M(e){return typeof e==`number`&&Number.isFinite(e)&&e>=0?e:0}function N(e){if(!a(e)||e.status!==`ok`)return{status:`unsupported`};let t=a(e.summary)?e.summary:{},n=[`danger`,`warn`,`info`];return{status:`ok`,hosts:(Array.isArray(e.hosts)?e.hosts.slice(0,50):[]).flatMap(e=>a(e)&&typeof e.host==`string`?[{host:m(e.host,253),declared:e.declared===!0,file:m(e.file,512),line:M(e.line)}]:[]),findings:(Array.isArray(e.findings)?e.findings.slice(0,200):[]).flatMap(e=>a(e)&&typeof e.rule==`string`&&n.includes(e.severity)?[{rule:m(e.rule,32),severity:e.severity,file:m(e.file,512),line:M(e.line),excerpt:m(e.excerpt,200)}]:[]),summary:{danger:M(t.danger),warn:M(t.warn),info:M(t.info),undeclaredHosts:M(t.undeclaredHosts)},truncated:e.truncated===!0}}function P(e){return Array.isArray(e)?e.filter(e=>a(e)&&typeof e.path==`string`&&typeof e.size==`number`&&typeof e.type==`string`).slice(0,256).map(e=>({path:e.path,size:e.size,type:e.type})):[]}function F(e){let t=a(e)?T(e.component):null;if(!t||!a(e)||!Array.isArray(e.files))throw Error(`Invalid custom UI describe response`);return{component:t,files:P(e.files),errors:_(e.errors),scan:N(e.scan)}}function I(e){if(!a(e)||typeof e.status!=`number`||typeof e.body!=`string`||e.bodyEncoding!==`utf8`&&e.bodyEncoding!==`base64`)throw Error(`Invalid custom UI fetch response`);return{status:e.status,statusText:m(e.statusText,200),headers:g(e.headers,64),body:e.body,bodyEncoding:e.bodyEncoding,url:m(e.url,2048),redirected:e.redirected===!0}}function L(t){if(!(t instanceof e)||!t.data)return null;let n=t.data.code??t.data.error;return typeof n==`string`&&/^[a-z0-9_]{1,64}$/.test(n)?n:null}function R(t){return!(t instanceof e)||!t.data?[]:_(t.data.errors)}var z=e=>`/api/custom-ui/components/${encodeURIComponent(e)}`;function B(e,t,n){if(!c.test(e)||!l.test(t)||!h(n))throw Error(`Invalid component module path`);return`${z(e)}/r/${t}/${n.split(`/`).map(e=>encodeURIComponent(e)).join(`/`)}`}function V(e,t,r,i){return n(B(e,t,r),{signal:i})}function H(e){return t(`/api/custom-ui/components`,{signal:e,parse:E})}function U(e,n){return t(`${z(e)}/describe`,{signal:n,parse:F})}function ee(e){return t(`/api/custom-ui/components`,{method:`POST`,body:e,parse:e=>{let t=a(e)?T(e.component):null;if(!t)throw Error(`Invalid custom UI component response`);return t}})}function W(e,n){return t(z(e),{method:`PATCH`,body:{enabled:n},parse:e=>{let t=a(e)?T(e.component):null;if(!t)throw Error(`Invalid custom UI component response`);return t}})}function G(e){return t(z(e),{method:`DELETE`,parse:e=>({trashedAs:a(e)?m(e.trashedAs,256):``})})}function K(e){return t(`/api/custom-ui/instances`,{signal:e,parse:k})}function q(e){return t(`/api/custom-ui/instances`,{method:`POST`,body:e,parse:A})}function J(e,n){return t(`/api/custom-ui/instances/${encodeURIComponent(e)}`,{method:`PATCH`,body:n,parse:A})}function Y(e){return t(`/api/custom-ui/instances/${encodeURIComponent(e)}`,{method:`DELETE`,parse:e=>({revision:a(e)&&typeof e.revision==`number`?e.revision:0})})}function X(e,n){return t(`${z(e)}/errors`,{signal:n,parse:j})}function Z(e,n){return t(`${z(e)}/errors`,{method:`POST`,body:n,keepalive:!0,parse:()=>void 0})}function Q(e,n){return t(`${z(e)}/usage`,{method:`POST`,body:{entries:n},keepalive:!0,parse:()=>void 0})}function $(e,n,r){return t(`${z(e)}/storage/${encodeURIComponent(n)}`,{signal:r,parse:e=>{if(!a(e)||!Object.hasOwn(e,`value`))throw Error(`Invalid custom UI storage response`);return{value:e.value}}})}function te(e,n,r){return t(`${z(e)}/storage/${encodeURIComponent(n)}`,{method:`PUT`,body:{value:r},parse:()=>void 0})}function ne(e,n){return t(`${z(e)}/storage/${encodeURIComponent(n)}`,{method:`DELETE`,parse:()=>void 0})}async function re(e,n,r,i){return await t(`/api/custom-ui/provider-session`,{method:`PUT`,body:{sessionId:n},signal:i,timeout:15e3,parse:()=>void 0}),t(`${z(e)}/provider-request`,{method:`POST`,body:{sessionId:n,request:r},signal:i,timeout:15e3,parse:I})}function ie(e,n,r){return t(`${z(e)}/fetch`,{method:`POST`,body:n,signal:r,timeout:15e3,parse:I})}var ae=/^[A-Za-z0-9._:-]{1,128}$/,oe=/^\/skill:[a-z0-9][a-z0-9-]{0,63}$/;function se(e){if(!a(e)||typeof e.sessionId!=`string`||!ae.test(e.sessionId))throw Error(`Invalid custom UI session response`);let t=typeof e.command==`string`&&oe.test(e.command)?e.command:``,n=a(e.session)&&e.session.id===e.sessionId?e.session:null;return{sessionId:e.sessionId,created:e.created===!0,command:t,session:n}}function ce(e){return t(`${z(e)}/session`,{method:`POST`,body:{},parse:se})}function le(e=!0){return{queryKey:i.catalog(),queryFn:({signal:e})=>H(e),enabled:e,staleTime:3e4,retry:!1,refetchOnWindowFocus:!1}}function ue(e=!0){return{queryKey:i.instances(),queryFn:({signal:e})=>K(e),enabled:e,staleTime:3e4,retry:!1,refetchOnWindowFocus:!1}}function de(e,t){if(!e||e.type===`all`)return!0;let n=r(t);return n!==``&&r(e.cwd)===n}export{J as A,x as C,Q as D,Z as E,ce as O,_ as S,V as T,H as _,ie as a,T as b,re as c,te as d,ee as f,U as g,Y as h,L as i,i as j,W as k,$ as l,G as m,le as n,R as o,q as p,ue as r,B as s,de as t,ne as u,X as v,w,N as x,P as y};