pisper 0.6.25 → 0.6.26

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 (113) hide show
  1. package/package.json +6 -6
  2. package/web/.vite/manifest.json +573 -573
  3. package/web/assets/{AppDialog-CuxO26Km.js → AppDialog-B9y7rq_4.js} +1 -1
  4. package/web/assets/{AppOverlays-Bt5SL3PY.js → AppOverlays-CzdCHrpC.js} +1 -1
  5. package/web/assets/{AssetsPage-BE6AzOGC.js → AssetsPage-MzCklx_a.js} +1 -1
  6. package/web/assets/{BoardPage-DX0fJ_ap.js → BoardPage-CjQXbluj.js} +3 -3
  7. package/web/assets/{ChannelsPage-CyT7oDYZ.js → ChannelsPage-C6HqgnP7.js} +1 -1
  8. package/web/assets/{ChatAppearancePage-B6Dzj2Bj.js → ChatAppearancePage-BRlvWkJX.js} +1 -1
  9. package/web/assets/{ChatHistoryPage-Cq20l93c.js → ChatHistoryPage-D3jSE4oY.js} +1 -1
  10. package/web/assets/{ChatPage-DgiS-Qj_.js → ChatPage-BfG3KbJi.js} +3 -3
  11. package/web/assets/{ConfigPage-CgrWdzb5.js → ConfigPage-CshLFv2D.js} +1 -1
  12. package/web/assets/{DesktopWindowControls-D8axeuEx.js → DesktopWindowControls-BZu-eiS1.js} +1 -1
  13. package/web/assets/{FeaturePage-BB1TeMlr.js → FeaturePage-DD_32h19.js} +1 -1
  14. package/web/assets/{FileAttachmentPreview-DPjT_iYk.js → FileAttachmentPreview-DDX_cRzm.js} +1 -1
  15. package/web/assets/{FloatingWidgets-FI1S4hdn.js → FloatingWidgets-Dc4Lhl5d.js} +1 -1
  16. package/web/assets/{FocusRuntimeControls-CvAx-KDV.js → FocusRuntimeControls-CkYJXBrP.js} +1 -1
  17. package/web/assets/{GitDiffViewer-DwFfeFOA.js → GitDiffViewer-DeVUAwce.js} +1 -1
  18. package/web/assets/{ManageProjectsDialog-BSLNf6qD.js → ManageProjectsDialog-DPzESWUB.js} +1 -1
  19. package/web/assets/{MarkdownMessage-NK7Ixb4Y.js → MarkdownMessage-BfSy1Cg4.js} +1 -1
  20. package/web/assets/{McpPage-Cn-yDgC5.js → McpPage-CcJDe2nE.js} +1 -1
  21. package/web/assets/MemoryEvolution-Cwdreg5P.js +1 -0
  22. package/web/assets/{MemoryPage-ZwoG_oj6.js → MemoryPage-BkALQ2WN.js} +2 -2
  23. package/web/assets/{MobileNavigation-DK5a0kZU.js → MobileNavigation-C1mjjmqO.js} +1 -1
  24. package/web/assets/{MorePage-BL8nDnTQ.js → MorePage-C7kCRfpo.js} +1 -1
  25. package/web/assets/{NewFolderDialog-COkq83LW.js → NewFolderDialog-sqiEXqxJ.js} +1 -1
  26. package/web/assets/{PageHeader-BBTCMqXc.js → PageHeader-DDaW4Sdv.js} +1 -1
  27. package/web/assets/{PhoneDrawer-BcPKJWl-.js → PhoneDrawer-Be7C0xLf.js} +1 -1
  28. package/web/assets/{PhoneMenuButton-D6vdTZdF.js → PhoneMenuButton-1dPMDaRV.js} +1 -1
  29. package/web/assets/{PhoneTopBar-MqNeI69v.js → PhoneTopBar-BLXoPO6P.js} +1 -1
  30. package/web/assets/{PluginsPage-Bp71HpKD.js → PluginsPage-Bjp82DPO.js} +1 -1
  31. package/web/assets/{SafeModePrompt-CpvvU5wL.js → SafeModePrompt-D_OCmR6G.js} +1 -1
  32. package/web/assets/{SchedulesPage-Drs10rEV.js → SchedulesPage-DCOhjQ8W.js} +1 -1
  33. package/web/assets/{SessionBrowserPane-DjtB4MCI.js → SessionBrowserPane-Cvmqo12R.js} +2 -2
  34. package/web/assets/{SessionContextPanel-ETfnp4pT.js → SessionContextPanel-B9KtrMwl.js} +2 -2
  35. package/web/assets/{SessionHome-CHBw3ZvP.js → SessionHome-DMAZBF3M.js} +1 -1
  36. package/web/assets/{SessionInspector-DVaRflQy.js → SessionInspector-DfinUUs5.js} +1 -1
  37. package/web/assets/{SessionShell-CwfQAX7i.js → SessionShell-BxYZQh_O.js} +1 -1
  38. package/web/assets/{SettingsSidebar-FgC-tlY2.js → SettingsSidebar-DWXc-Z4_.js} +1 -1
  39. package/web/assets/{ShortcutHelpDialog-DKbIkUnk.js → ShortcutHelpDialog-QBYqmifG.js} +1 -1
  40. package/web/assets/{ShortcutKeys-BuHXNKVW.js → ShortcutKeys-B6hllpKE.js} +1 -1
  41. package/web/assets/{SidebarUpdateStatus-LKwNKESF.js → SidebarUpdateStatus-C-ebi4wI.js} +1 -1
  42. package/web/assets/{SkillsPage-BbnerW44.js → SkillsPage-CcNononn.js} +1 -1
  43. package/web/assets/{TaskProcessesPane-B2fyZEK9.js → TaskProcessesPane-D442bSux.js} +1 -1
  44. package/web/assets/{TaskTerminalView-CKApgF75.js → TaskTerminalView-B4fD3kVF.js} +1 -1
  45. package/web/assets/{TerminalPanel-D03WycYm.js → TerminalPanel-64E97AR4.js} +1 -1
  46. package/web/assets/{WebDesktopPet-K2dbcbnQ.js → WebDesktopPet-DUpnoJ1_.js} +1 -1
  47. package/web/assets/{WorkflowsPage-CmzftCtz.js → WorkflowsPage-Cj0mQmb3.js} +1 -1
  48. package/web/assets/{WorkspacePicker-DbdbTOV2.js → WorkspacePicker-_dbgAw5b.js} +1 -1
  49. package/web/assets/{api-BW_X0FMZ.js → api-_MWfl2VL.js} +1 -1
  50. package/web/assets/{app-update-DYFXTosD.js → app-update-CJSjwHEp.js} +1 -1
  51. package/web/assets/{approval-confirm-DQ5N_lJB.js → approval-confirm-D9j-l9WE.js} +1 -1
  52. package/web/assets/{board-projects-CrejrMrn.js → board-projects-BI5ssHIa.js} +1 -1
  53. package/web/assets/{bots-store-CNXTx3UY.js → bots-store-D8M80DQa.js} +1 -1
  54. package/web/assets/{chat-api-Bo6nhq40.js → chat-api-9V8j4rSS.js} +1 -1
  55. package/web/assets/{client-store-DzgOPMlh.js → client-store-xZC2AfqC.js} +1 -1
  56. package/web/assets/{config-search-BiQmWst4.js → config-search-VE6brXfx.js} +1 -1
  57. package/web/assets/{dialog-DFZX_Dek.js → dialog-BgFAhLng.js} +1 -1
  58. package/web/assets/{events-PfANjkHx.js → events-C96FsPEU.js} +1 -1
  59. package/web/assets/{focus-session-composer-bits-C_LOpJH_.js → focus-session-composer-bits-DJHZmmrf.js} +1 -1
  60. package/web/assets/{folder-paths-aRRH_MYq.js → folder-paths-BguW7FsR.js} +1 -1
  61. package/web/assets/{hosts-lvoPwC3T.js → hosts-D2X7ud3S.js} +1 -1
  62. package/web/assets/i18n-zKD1z9i9.js +1 -0
  63. package/web/assets/{index-D_zLThH_.js → index-CwdjZZLG.js} +2 -2
  64. package/web/assets/{memory-api-DkPje--t.js → memory-api-DilYLnpG.js} +1 -1
  65. package/web/assets/{mount-app-7pFSwVLO.js → mount-app-Dc-WeJ9N.js} +3 -3
  66. package/web/assets/{permission-rules-api-CAJsSBA5.js → permission-rules-api-CW4GK6hJ.js} +1 -1
  67. package/web/assets/{pick-system-directory-yk6L7wR2.js → pick-system-directory-UTgPstWX.js} +1 -1
  68. package/web/assets/{placements-CMrgmg3t.js → placements-Cw2TcTmd.js} +2 -2
  69. package/web/assets/{popover--q2hs_pT.js → popover-Cw7QFeII.js} +1 -1
  70. package/web/assets/{public-DkqrpWXx.js → public-4OSY9BE4.js} +2 -2
  71. package/web/assets/{public-DWbrDr0p.js → public-DaL-1TT_.js} +1 -1
  72. package/web/assets/{public-62LVX7HU.js → public-DdhGlwHC.js} +1 -1
  73. package/web/assets/{public-components-DHMvCgH2.js → public-components-C0KUBrxH.js} +1 -1
  74. package/web/assets/public-diff-ooK8-fn0.js +1 -0
  75. package/web/assets/public-events-ntCr-b1Y.js +1 -0
  76. package/web/assets/{public-flags-D9LdpQwJ.js → public-flags-D6y-DU98.js} +1 -1
  77. package/web/assets/{public-greeting-DEKYruJJ.js → public-greeting-JGqTdWhf.js} +1 -1
  78. package/web/assets/{public-session-B9UHA6rN.js → public-session-fPM64rB7.js} +1 -1
  79. package/web/assets/{public-sidebar-Lne86i_K.js → public-sidebar-CvLw1vam.js} +1 -1
  80. package/web/assets/{runtime-capabilities-store-BNM5Ug-5.js → runtime-capabilities-store-CWJvmV83.js} +1 -1
  81. package/web/assets/{safe-mode-instance-DnTP7EUr.js → safe-mode-instance-Dz4-ObZg.js} +1 -1
  82. package/web/assets/safe-mode-sentinel-Bg8pbnu-.js +1 -0
  83. package/web/assets/{session-change-summary-api-DMTwGz7o.js → session-change-summary-api-C3QE98fZ.js} +1 -1
  84. package/web/assets/{session-home-DUpZt2dn.js → session-home-CLGrhgld.js} +1 -1
  85. package/web/assets/{session-organization-api-BGyp66Uv.js → session-organization-api-B2UGOx0B.js} +1 -1
  86. package/web/assets/{session-scope-DZITSvZr.js → session-scope-okdygSiV.js} +1 -1
  87. package/web/assets/{session-tree-actions-CRWyFqAD.js → session-tree-actions-9m9DHqIx.js} +1 -1
  88. package/web/assets/{session-tree-summary-HTmAo_9V.js → session-tree-summary-u-RSxXXY.js} +1 -1
  89. package/web/assets/{shortcuts-D72gQCwH.js → shortcuts-CVPFuAiJ.js} +1 -1
  90. package/web/assets/{side-chat-context-D1hZOT7g.js → side-chat-context-By5GbAvl.js} +4 -4
  91. package/web/assets/{sidebar-sj8X80Y9.js → sidebar-BWHi3RGN.js} +1 -1
  92. package/web/assets/{sidebar-store-CXZ7QrOr.js → sidebar-store-CLA6EfOm.js} +1 -1
  93. package/web/assets/{speech-session-D2GQEOAL.js → speech-session-CFUz5f6J.js} +1 -1
  94. package/web/assets/{startup-queries-CuEXV1Zu.js → startup-queries-Xa-I9BT7.js} +1 -1
  95. package/web/assets/{use-i18n-_vdxObu5.js → use-i18n-CIheiCov.js} +1 -1
  96. package/web/assets/{use-open-bot-BTxzOAbZ.js → use-open-bot-zjJ_Tnfv.js} +1 -1
  97. package/web/assets/{use-studio-actions-CbMHRZpd.js → use-studio-actions-BiRUtcRX.js} +1 -1
  98. package/web/assets/{useCatalogProjects-BEkCpADy.js → useCatalogProjects-CbyrRuIn.js} +1 -1
  99. package/web/assets/{useNewProjectPicker-CUtLjwYE.js → useNewProjectPicker-6iK1xIT3.js} +2 -2
  100. package/web/assets/{useNow-eQeBCqQk.js → useNow-CE8ZJGxH.js} +1 -1
  101. package/web/assets/{usePhoneShell-DZHZWXnN.js → usePhoneShell-sWQz-gv8.js} +1 -1
  102. package/web/assets/{useSessionListQuery-BoUzmjZC.js → useSessionListQuery-K7Hh_V_2.js} +1 -1
  103. package/web/assets/{useSessionRowActions-DCqDrGZY.js → useSessionRowActions-Geuo0bzR.js} +1 -1
  104. package/web/assets/{useSidebarModel-CZAfH4Fa.js → useSidebarModel-BuyZjTgh.js} +1 -1
  105. package/web/assets/{web-preview-XrRFo42l.js → web-preview-0hEXH_IN.js} +1 -1
  106. package/web/assets/{web-preview-events-Ba6duwGi.js → web-preview-events-B5w8DSl2.js} +1 -1
  107. package/web/assets/{workspace-order-store-Ao4OZ13V.js → workspace-order-store-GwJH1aiS.js} +1 -1
  108. package/web/index.html +1 -1
  109. package/web/assets/MemoryEvolution-B8IeSLcd.js +0 -1
  110. package/web/assets/i18n-EVP8yIdy.js +0 -1
  111. package/web/assets/public-diff-WjbTu91T.js +0 -1
  112. package/web/assets/public-events-CTdTIu5Q.js +0 -1
  113. package/web/assets/safe-mode-sentinel-DOhqH4gj.js +0 -1
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{t as r}from"./use-i18n-_vdxObu5.js";import{t as i}from"./useQuery-DdcpUQhO.js";import{a,i as o,o as s}from"./startup-queries-CuEXV1Zu.js";import{a as c,u as l}from"./api-BW_X0FMZ.js";import{t as u}from"./runtime-capabilities-store-BNM5Ug-5.js";import{t as d}from"./chevron-down-CxtxIjiP.js";import{t as f}from"./focus-session-composer-bits-C_LOpJH_.js";import{t as p}from"./folder-open-FIShC5Qk.js";import{i as m,n as h,t as g}from"./workspace-order-store-Ao4OZ13V.js";import{i as ee,n as _,r as v,s as y,t as b}from"./useNewProjectPicker-CUtLjwYE.js";import{a as x,c as S,i as C,o as te,p as w,r as T,s as E,t as D}from"./dropdown-menu-Ds0gD8S8.js";import{t as O}from"./utils-C8uzG5AZ.js";import{u as k}from"./events-PfANjkHx.js";import{t as A}from"./chat-api-Bo6nhq40.js";import{_ as j,d as M,l as N,t as P,u as F,v as I,x as L,y as R}from"./useSessionListQuery-BoUzmjZC.js";import"./useNow-eQeBCqQk.js";import{a as z}from"./card-presentation-1oph2b8P.js";import"./useSidebarModel-CZAfH4Fa.js";import{r as B,t as V}from"./board-projects-CrejrMrn.js";var H=e(t(),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 l?`${e.kind||`error`}:${e.status??`-`}`:`error`}async function J(e){let t=`/api/sessions/${encodeURIComponent(e)}`;try{if(!K(await A.getLiveSession(e,{timeout:G})))return!1;await c(t,{method:`DELETE`,timeout:G})}catch(e){return console.warn(`[board] 派发失败后未能清理空会话(${q(e)})`),!1}return a.setQueryData(N,t=>t&&{...t,sessions:t.sessions.filter(t=>t.id!==e)}),k({deletedIds:[e]}),!0}function Y(e){a.setQueryData(N,t=>t&&!t.sessions.some(t=>t.id===e.id)?{...t,sessions:[e,...t.sessions]}:t),o(`sessions`)}function ne(e){let t=e.indexOf(`/`);return t>0?{provider:e.slice(0,t),modelId:e.slice(t+1)}:null}async function re(e,t,n){let r=ne(n.model);r&&n.model!==t.model&&await A.updateModel(e,r.provider,r.modelId),n.thinkingLevel&&n.thinkingLevel!==t.thinkingLevel&&await A.setThinkingLevel(e,n.thinkingLevel),n.executionMode&&n.executionMode!==t.executionMode&&await A.updateExecutionMode(e,n.executionMode),n.runMode!==`plan`&&n.runMode!==t.runMode&&await A.updateRunMode(e,n.runMode)}async function ie(e){if(!e.prompt.trim().slice(0,W))throw new U(`create`,Error(`empty prompt`));let t;try{t=await A.createSession(``,e.cwd,{projectless:e.projectless===!0})}catch(e){throw new U(`create`,e)}let n=t.id;try{await re(n,t,e)}catch(e){throw await J(n),new U(`configure`,e,n)}return{session:t}}var ae=/^\/[a-z][a-z0-9:-]{0,63}$/;async function oe(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&&!ae.test(r))throw new U(`send`,Error(`invalid command`),t);let i;try{i=await A.getLiveSession(t)}catch(e){throw new U(`send`,e,t)}let s=i&&typeof i==`object`?i:{},c=Array.isArray(s.messages)&&s.messages.length===0&&r?`${r} ${n}`:n,l=async()=>{try{await A.queueInput(t,c,[],`followUp`)}catch(e){throw new U(`send`,e,t)}return{sessionId:t,queued:!0}};if(s.streaming===!0)return l();e.created?.id===t?Y({...e.created,firstMessage:n,messageCount:1}):a.getQueryData(N)?.sessions.some(e=>e.id===t)||o(`sessions`);let u=M(t,{streaming:!0});try{await L(t,`launch`,(e,n)=>A.openStream({sessionId:t,message:c,attachments:[],goalMode:!1,teamMode:!1},e,{signal:n}))}catch(e){if(j(t,u),e instanceof F)return l();throw R().catch(()=>void 0),new U(`send`,e,t)}return I(t,e=>!!e).catch(()=>void 0).finally(()=>j(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 se(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 ce(){let e=i(s(`config`)),t=P(),n=g(e=>e.names),r=h(e=>e.projects),a=u(e=>e.capabilities.features),o=(0,H.useMemo)(()=>se(e.data),[e.data]),c=e.data?.provider&&e.data?.model?`${e.data.provider}/${e.data.model}`:``,l=t.data?.sessions,d=(0,H.useMemo)(()=>B(l??[],r,n),[l,n,r]),f=(0,H.useMemo)(()=>V(l??[],d),[l,d]);return{models:o,defaultModel:c,defaultThinkingLevel:Z(e.data?.thinkingLevel)||`medium`,projects:d,defaultCwd:f,goalsAvailable:a.goals!==!1,teamAvailable:a.goals!==!1&&a.multiAgent!==!1,loading:e.isPending,error:e.error??null}}var Q=n(),$=`\0no-project`;function le(e){return e===`full-access`||_.includes(e)}function ue(e){return e===`plan`||e===`goal`||e===`team`}function de({onError:e}){let{t}=r(),n=ce(),i=v(),[a,o]=(0,H.useState)(!1),s=(0,H.useRef)(null),c=b({onProjectChosen:()=>void 0,onError:e}),l=u(e=>e.capabilities.features.workspaceFolders),h=n.models.some(e=>e.key===i.model),g=h?i.model:n.defaultModel,_=n.models.find(e=>e.key===g)?.thinkingLevels??[],k=_.includes(i.thinkingLevel)?i.thinkingLevel:``,A=k||(_.includes(n.defaultThinkingLevel)?n.defaultThinkingLevel:``),j=a?`full-access`:i.executionMode||`approval-required`,M=i.runMode===`team`&&!n.teamAvailable||i.runMode===`goal`&&!n.goalsAvailable?`plan`:i.runMode,N=(0,H.useMemo)(()=>{if(!i.cwd||n.projects.some(e=>e.cwd===i.cwd))return n.projects;let e=i.cwd.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||i.cwd;return[{key:i.cwd,cwd:i.cwd,label:e},...n.projects]},[i.cwd,n.projects]),P=(0,H.useMemo)(()=>z(N),[N]),F=i.projectless,I=F?``:i.cwd||n.defaultCwd||N[0]?.cwd||``,L=F?void 0:N.find(e=>e.cwd===I),R=L?.label||t(F?`board:launch.noProject`:`board:launch.defaultProject`),B=t(`board:launch.projectLabel`,{project:L?P.get(L.key)?`${L.label} (${P.get(L.key)})`:L.label:R});return{cwd:I,model:g,thinkingLevel:A,availableThinkingLevels:_,executionMode:j,runMode:M,onModelChange:e=>i.rememberLaunch({model:e,thinkingLevel:``}),onThinkingLevelChange:e=>i.rememberLaunch({thinkingLevel:e}),onExecutionModeChange:e=>le(e)?(o(e===`full-access`),e!==`full-access`&&i.rememberLaunch({executionMode:e}),!0):!1,onRunModeChange:e=>ue(e)?(i.rememberLaunch({runMode:e}),!0):!1,renderProjectControl:e=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(D,{children:[(0,Q.jsx)(w,{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`:O(f,`max-w-[24ch] max-[650px]:max-w-[14ch]`),title:L?.cwd||void 0,"aria-label":B,"data-new-task-project":F?`none`:I||`default`,children:[(0,Q.jsx)(y,{size:e===`header`?12:14,className:`shrink-0`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:O(`min-w-0 truncate`,L?.label&&`font-mono`),children:R}),(0,Q.jsx)(d,{size:e===`header`?12:14,className:O(`shrink-0 opacity-70`,e===`chip`&&`max-[650px]:hidden`),"aria-hidden":`true`})]})}),(0,Q.jsxs)(T,{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=s.current;t&&(s.current=null,e.preventDefault(),t())},children:[(0,Q.jsxs)(te,{value:F?$:I,onValueChange:e=>i.rememberLaunch(e===$?{projectless:!0}:{cwd:e}),children:[(0,Q.jsx)(E,{value:$,children:(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:t(`board:launch.noProject`)})}),(0,Q.jsx)(S,{}),(0,Q.jsx)(x,{children:t(`board:launch.projects`)}),N.length===0&&(0,Q.jsx)(E,{value:``,children:t(`board:launch.defaultProject`)}),N.map(e=>(0,Q.jsxs)(E,{value:e.cwd,title:e.cwd,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:e.label}),P.get(e.key)&&(0,Q.jsx)(`span`,{className:`ml-auto min-w-0 truncate pl-2 font-mono text-xs text-content-muted`,children:P.get(e.key)})]},e.key))]}),(0,Q.jsx)(S,{}),(0,Q.jsxs)(C,{disabled:c.picking,"data-launch-new-project":!0,onSelect:()=>s.current=()=>void c.newProject(),children:[(0,Q.jsx)(p,{"aria-hidden":`true`}),t(`board:launch.chooseFolder`)]}),l&&(0,Q.jsxs)(C,{"data-launch-new-folder":!0,onSelect:()=>s.current=()=>c.newFolder(I||n.defaultCwd),children:[(0,Q.jsx)(m,{"aria-hidden":`true`}),t(`board:launch.newFolder`)]})]})]}),(0,Q.jsx)(ee,{picker:c.picker,folderDialog:c.folderDialog})]}),prepare:e=>ie({prompt:e,cwd:I,projectless:F,model:h?g:``,thinkingLevel:k,executionMode:j,runMode:M}),onSent:()=>{o(!1)}}}export{oe as n,de as t};
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-CIheiCov.js";import{t as i}from"./useQuery-DdcpUQhO.js";import{a,i as o,o as s}from"./startup-queries-Xa-I9BT7.js";import{a as c,u as l}from"./api-_MWfl2VL.js";import{t as u}from"./runtime-capabilities-store-CWJvmV83.js";import{t as d}from"./chevron-down-CxtxIjiP.js";import{t as f}from"./focus-session-composer-bits-DJHZmmrf.js";import{t as p}from"./folder-open-FIShC5Qk.js";import{i as m,n as h,t as g}from"./workspace-order-store-GwJH1aiS.js";import{i as ee,n as _,r as v,s as y,t as b}from"./useNewProjectPicker-6iK1xIT3.js";import{a as x,c as S,i as C,o as te,p as w,r as T,s as E,t as D}from"./dropdown-menu-Ds0gD8S8.js";import{t as O}from"./utils-C8uzG5AZ.js";import{u as k}from"./events-C96FsPEU.js";import{t as A}from"./chat-api-9V8j4rSS.js";import{_ as j,d as M,l as N,t as P,u as F,v as I,x as L,y as R}from"./useSessionListQuery-K7Hh_V_2.js";import"./useNow-CE8ZJGxH.js";import{a as z}from"./card-presentation-1oph2b8P.js";import"./useSidebarModel-BuyZjTgh.js";import{r as B,t as V}from"./board-projects-BI5ssHIa.js";var H=e(t(),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 l?`${e.kind||`error`}:${e.status??`-`}`:`error`}async function J(e){let t=`/api/sessions/${encodeURIComponent(e)}`;try{if(!K(await A.getLiveSession(e,{timeout:G})))return!1;await c(t,{method:`DELETE`,timeout:G})}catch(e){return console.warn(`[board] 派发失败后未能清理空会话(${q(e)})`),!1}return a.setQueryData(N,t=>t&&{...t,sessions:t.sessions.filter(t=>t.id!==e)}),k({deletedIds:[e]}),!0}function Y(e){a.setQueryData(N,t=>t&&!t.sessions.some(t=>t.id===e.id)?{...t,sessions:[e,...t.sessions]}:t),o(`sessions`)}function ne(e){let t=e.indexOf(`/`);return t>0?{provider:e.slice(0,t),modelId:e.slice(t+1)}:null}async function re(e,t,n){let r=ne(n.model);r&&n.model!==t.model&&await A.updateModel(e,r.provider,r.modelId),n.thinkingLevel&&n.thinkingLevel!==t.thinkingLevel&&await A.setThinkingLevel(e,n.thinkingLevel),n.executionMode&&n.executionMode!==t.executionMode&&await A.updateExecutionMode(e,n.executionMode),n.runMode!==`plan`&&n.runMode!==t.runMode&&await A.updateRunMode(e,n.runMode)}async function ie(e){if(!e.prompt.trim().slice(0,W))throw new U(`create`,Error(`empty prompt`));let t;try{t=await A.createSession(``,e.cwd,{projectless:e.projectless===!0})}catch(e){throw new U(`create`,e)}let n=t.id;try{await re(n,t,e)}catch(e){throw await J(n),new U(`configure`,e,n)}return{session:t}}var ae=/^\/[a-z][a-z0-9:-]{0,63}$/;async function oe(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&&!ae.test(r))throw new U(`send`,Error(`invalid command`),t);let i;try{i=await A.getLiveSession(t)}catch(e){throw new U(`send`,e,t)}let s=i&&typeof i==`object`?i:{},c=Array.isArray(s.messages)&&s.messages.length===0&&r?`${r} ${n}`:n,l=async()=>{try{await A.queueInput(t,c,[],`followUp`)}catch(e){throw new U(`send`,e,t)}return{sessionId:t,queued:!0}};if(s.streaming===!0)return l();e.created?.id===t?Y({...e.created,firstMessage:n,messageCount:1}):a.getQueryData(N)?.sessions.some(e=>e.id===t)||o(`sessions`);let u=M(t,{streaming:!0});try{await L(t,`launch`,(e,n)=>A.openStream({sessionId:t,message:c,attachments:[],goalMode:!1,teamMode:!1},e,{signal:n}))}catch(e){if(j(t,u),e instanceof F)return l();throw R().catch(()=>void 0),new U(`send`,e,t)}return I(t,e=>!!e).catch(()=>void 0).finally(()=>j(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 se(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 ce(){let e=i(s(`config`)),t=P(),n=g(e=>e.names),r=h(e=>e.projects),a=u(e=>e.capabilities.features),o=(0,H.useMemo)(()=>se(e.data),[e.data]),c=e.data?.provider&&e.data?.model?`${e.data.provider}/${e.data.model}`:``,l=t.data?.sessions,d=(0,H.useMemo)(()=>B(l??[],r,n),[l,n,r]),f=(0,H.useMemo)(()=>V(l??[],d),[l,d]);return{models:o,defaultModel:c,defaultThinkingLevel:Z(e.data?.thinkingLevel)||`medium`,projects:d,defaultCwd:f,goalsAvailable:a.goals!==!1,teamAvailable:a.goals!==!1&&a.multiAgent!==!1,loading:e.isPending,error:e.error??null}}var Q=n(),$=`\0no-project`;function le(e){return e===`full-access`||_.includes(e)}function ue(e){return e===`plan`||e===`goal`||e===`team`}function de({onError:e}){let{t}=r(),n=ce(),i=v(),[a,o]=(0,H.useState)(!1),s=(0,H.useRef)(null),c=b({onProjectChosen:()=>void 0,onError:e}),l=u(e=>e.capabilities.features.workspaceFolders),h=n.models.some(e=>e.key===i.model),g=h?i.model:n.defaultModel,_=n.models.find(e=>e.key===g)?.thinkingLevels??[],k=_.includes(i.thinkingLevel)?i.thinkingLevel:``,A=k||(_.includes(n.defaultThinkingLevel)?n.defaultThinkingLevel:``),j=a?`full-access`:i.executionMode||`approval-required`,M=i.runMode===`team`&&!n.teamAvailable||i.runMode===`goal`&&!n.goalsAvailable?`plan`:i.runMode,N=(0,H.useMemo)(()=>{if(!i.cwd||n.projects.some(e=>e.cwd===i.cwd))return n.projects;let e=i.cwd.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||i.cwd;return[{key:i.cwd,cwd:i.cwd,label:e},...n.projects]},[i.cwd,n.projects]),P=(0,H.useMemo)(()=>z(N),[N]),F=i.projectless,I=F?``:i.cwd||n.defaultCwd||N[0]?.cwd||``,L=F?void 0:N.find(e=>e.cwd===I),R=L?.label||t(F?`board:launch.noProject`:`board:launch.defaultProject`),B=t(`board:launch.projectLabel`,{project:L?P.get(L.key)?`${L.label} (${P.get(L.key)})`:L.label:R});return{cwd:I,model:g,thinkingLevel:A,availableThinkingLevels:_,executionMode:j,runMode:M,onModelChange:e=>i.rememberLaunch({model:e,thinkingLevel:``}),onThinkingLevelChange:e=>i.rememberLaunch({thinkingLevel:e}),onExecutionModeChange:e=>le(e)?(o(e===`full-access`),e!==`full-access`&&i.rememberLaunch({executionMode:e}),!0):!1,onRunModeChange:e=>ue(e)?(i.rememberLaunch({runMode:e}),!0):!1,renderProjectControl:e=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(D,{children:[(0,Q.jsx)(w,{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`:O(f,`max-w-[24ch] max-[650px]:max-w-[14ch]`),title:L?.cwd||void 0,"aria-label":B,"data-new-task-project":F?`none`:I||`default`,children:[(0,Q.jsx)(y,{size:e===`header`?12:14,className:`shrink-0`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:O(`min-w-0 truncate`,L?.label&&`font-mono`),children:R}),(0,Q.jsx)(d,{size:e===`header`?12:14,className:O(`shrink-0 opacity-70`,e===`chip`&&`max-[650px]:hidden`),"aria-hidden":`true`})]})}),(0,Q.jsxs)(T,{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=s.current;t&&(s.current=null,e.preventDefault(),t())},children:[(0,Q.jsxs)(te,{value:F?$:I,onValueChange:e=>i.rememberLaunch(e===$?{projectless:!0}:{cwd:e}),children:[(0,Q.jsx)(E,{value:$,children:(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:t(`board:launch.noProject`)})}),(0,Q.jsx)(S,{}),(0,Q.jsx)(x,{children:t(`board:launch.projects`)}),N.length===0&&(0,Q.jsx)(E,{value:``,children:t(`board:launch.defaultProject`)}),N.map(e=>(0,Q.jsxs)(E,{value:e.cwd,title:e.cwd,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:e.label}),P.get(e.key)&&(0,Q.jsx)(`span`,{className:`ml-auto min-w-0 truncate pl-2 font-mono text-xs text-content-muted`,children:P.get(e.key)})]},e.key))]}),(0,Q.jsx)(S,{}),(0,Q.jsxs)(C,{disabled:c.picking,"data-launch-new-project":!0,onSelect:()=>s.current=()=>void c.newProject(),children:[(0,Q.jsx)(p,{"aria-hidden":`true`}),t(`board:launch.chooseFolder`)]}),l&&(0,Q.jsxs)(C,{"data-launch-new-folder":!0,onSelect:()=>s.current=()=>c.newFolder(I||n.defaultCwd),children:[(0,Q.jsx)(m,{"aria-hidden":`true`}),t(`board:launch.newFolder`)]})]})]}),(0,Q.jsx)(ee,{picker:c.picker,folderDialog:c.folderDialog})]}),prepare:e=>ie({prompt:e,cwd:I,projectless:F,model:h?g:``,thinkingLevel:k,executionMode:j,runMode:M}),onSent:()=>{o(!1)}}}export{oe as n,de 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-_vdxObu5.js";import{t as i}from"./runtime-capabilities-store-BNM5Ug-5.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-BiQmWst4.js";import{s as g}from"./shortcuts-D72gQCwH.js";import{a as _,i as v,l as y,o as b,s as x,t as S}from"./dialog-DFZX_Dek.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-CIheiCov.js";import{t as i}from"./runtime-capabilities-store-CWJvmV83.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-VE6brXfx.js";import{s as g}from"./shortcuts-CVPFuAiJ.js";import{a as _,i as v,l as y,o as b,s as x,t as S}from"./dialog-BgFAhLng.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-DeVUAwce.js";export{e as InlineGitDiff};
@@ -0,0 +1 @@
1
+ import"./events-C96FsPEU.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{a as r,l as i}from"./api-BW_X0FMZ.js";import{i as a}from"./runtime-capabilities-CHYOF_hE.js";import{t as o}from"./runtime-capabilities-store-BNM5Ug-5.js";import{u as s}from"./events-PfANjkHx.js";import"./public-events-CTdTIu5Q.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 i();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 i();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 i();let t=e.features;if(!Array.isArray(t))throw i();return t.map(h)}function _(e={}){return r(p,{signal:e.signal,parse:g})}function v(e,t){return r(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{a as r,l as i}from"./api-_MWfl2VL.js";import{i as a}from"./runtime-capabilities-CHYOF_hE.js";import{t as o}from"./runtime-capabilities-store-CWJvmV83.js";import{u as s}from"./events-C96FsPEU.js";import"./public-events-ntCr-b1Y.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 i();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 i();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 i();let t=e.features;if(!Array.isArray(t))throw i();return t.map(h)}function _(e={}){return r(p,{signal:e.signal,parse:g})}function v(e,t){return r(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{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-_vdxObu5.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-DbdbTOV2.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-PfANjkHx.js";import{t as g}from"./input-CPw-zkYh.js";import{t as _}from"./BotAvatar-CNL-APwP.js";import{t as v}from"./AppSelect-DQYKUW5E.js";import{D as y,O as b,a as x,k as S,n as C,w}from"./bots-store-CNXTx3UY.js";import"./public-events-CTdTIu5Q.js";import{t as T}from"./public-flags-D9LdpQwJ.js";var E=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`}]]),D=e(n(),1),O=r(),k=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 A({className:e,variant:t=`default`,size:n=`default`,asChild:r=!1,...i}){let a=r?f:`div`;return(0,O.jsx)(a,{"data-slot":`item`,"data-variant":t,"data-size":n,className:p(k({variant:t,size:n,className:e})),...i})}var j=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 M({className:e,variant:t=`default`,...n}){return(0,O.jsx)(`div`,{"data-slot":`item-media`,"data-variant":t,className:p(j({variant:t,className:e})),...n})}function N({className:e,...t}){return(0,O.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 P({className:e,...t}){return(0,O.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 F({className:e,...t}){return(0,O.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 I({className:e,...t}){return(0,O.jsx)(`div`,{"data-slot":`item-actions`,className:p(`flex items-center gap-2`,e),...t})}function L({botId:e,collapsed:t=!1,fallback:n=null}){let r=T(`bots`),i=C(t=>t.bots.find(t=>t.id===e)),a=C(e=>e.loaded),o=C(e=>e.load);return(0,D.useEffect)(()=>{r&&!a&&o()},[r,o,a]),r?i?(0,O.jsx)(R,{bot:i,collapsed:t}):a?n:null:n}function R({bot:e,collapsed:n}){let{t:r}=a(),i=t(),o=C(e=>e.upsert),[s,c]=(0,D.useState)(!1),[f,T]=(0,D.useState)(e.proactive.briefAt),[k,A]=(0,D.useState)(!1),[j,M]=(0,D.useState)(!1),[N,P]=(0,D.useState)(e.proactive.everyHours),[F,I]=(0,D.useState)(!1),[L,R]=(0,D.useState)(``),B=b(e.instructions),V=e.workspace.environmentId===`local`,H=`/bots/${encodeURIComponent(e.id)}`,U=async t=>{I(!0),R(``);try{return o(await w(e.id,t)),!0}catch(e){return R(e instanceof Error?e.message:String(e)),!1}finally{I(!1)}},W=async e=>{e.preventDefault(),/^\d{2}:\d{2}$/.test(f)&&await U({proactive:{brief:!0,briefAt:f}})&&c(!1)};return(0,O.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,O.jsxs)(`div`,{className:`flex items-start gap-3.5`,children:[(0,O.jsx)(_,{avatar:e.avatar,state:n?`idle`:y(e),animate:!n,size:56}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1 pt-0.5`,children:[(0,O.jsx)(`h2`,{className:`text-[15px] leading-6 font-medium text-content`,children:r(`bots:greeting.hello`,{name:e.name})}),B?(0,O.jsxs)(`p`,{className:`text-sm leading-6 [overflow-wrap:anywhere] text-content-secondary`,children:[r(`bots:greeting.duty`,{duty:B}),` `,(0,O.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(H),children:r(`bots:greeting.editDuty`)})]}):(0,O.jsx)(`p`,{className:`text-sm leading-6 text-content-secondary`,children:r(n?`bots:greeting.talk`:`bots:greeting.ask`)})]})]}),!n&&(0,O.jsxs)(`div`,{className:`mt-4 flex max-w-[560px] flex-col gap-2`,children:[V&&(s?(0,O.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 W(e),onKeyDown:e=>{e.key===`Escape`&&c(!1)},children:[(0,O.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm font-medium text-content`,children:[r(`bots:greeting.briefWhen`),(0,O.jsx)(g,{type:`time`,value:f,autoFocus:!0,disabled:F,className:`w-32 font-normal`,onChange:e=>T(e.target.value)})]}),(0,O.jsx)(`p`,{className:`m-0 text-xs text-content-muted`,children:r(`bots:greeting.briefNote`)}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(m,{type:`submit`,disabled:F||!f,children:r(`bots:greeting.briefConfirm`)}),(0,O.jsx)(m,{type:`button`,variant:`ghost`,disabled:F,onClick:()=>c(!1),children:r(`bots:new.cancel`)})]})]}):(0,O.jsx)(z,{action:`brief`,icon:E,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:F,onClick:()=>{T(e.proactive.briefAt),c(!0)}})),V&&(j?(0,O.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(),A(!0)},onKeyDown:e=>{e.key===`Escape`&&e.currentTarget.contains(e.target)&&M(!1)},children:[(0,O.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm font-medium text-content`,children:[r(`bots:greeting.watchWhen`),(0,O.jsx)(v,{value:String(N),className:`w-44 font-normal`,onChange:e=>P(Number(e.target.value)),children:x.map(e=>(0,O.jsx)(`option`,{value:e,children:r(`bots:proactive.everyHours`,{count:e})},e))})]}),(0,O.jsx)(`p`,{className:`m-0 text-xs text-content-muted`,children:r(`bots:greeting.watchNote`)}),(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,O.jsx)(m,{type:`submit`,autoFocus:!0,children:r(`bots:greeting.watchConfirm`)}),(0,O.jsx)(m,{type:`button`,variant:`ghost`,onClick:()=>M(!1),children:r(`bots:new.cancel`)})]})]}):(0,O.jsx)(z,{action:`folder`,icon:u,title:r(B?`bots:greeting.folder`:`bots:greeting.watch`),hint:B?e.proactive.enabled?r(`bots:greeting.folderWatchHint`,{folder:S(e.workspace.cwd),count:e.proactive.everyHours}):r(`bots:greeting.folderHint`,{folder:S(e.workspace.cwd)}):r(`bots:greeting.watchHint`,{count:e.proactive.everyHours}),disabled:F,onClick:()=>{if(B){A(!0);return}P(e.proactive.everyHours),M(!0)}})),(0,O.jsx)(z,{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:F,onClick:()=>i(`${H}?section=chats`)}),L&&(0,O.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:L}),(0,O.jsx)(l,{open:k,initialPath:e.workspace.cwd,onOpenChange:A,onSelect:async t=>{let n=await w(e.id,{workspace:{...e.workspace,cwd:t},...B?{}:{instructions:r(`bots:greeting.watchDuty`),proactive:{enabled:!0,everyHours:N}}});o(n),e.threadSessionId&&h({id:e.threadSessionId,cwd:n.workspace.cwd}),A(!1),M(!1)}})]})]})}function z({action:e,icon:t,title:n,hint:r,done:i=!1,disabled:a,onClick:o}){return(0,O.jsx)(A,{asChild:!0,variant:`outline`,children:(0,O.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,O.jsx)(M,{variant:`icon`,children:(0,O.jsx)(t,{className:`text-content-secondary`,strokeWidth:1.75,"aria-hidden":`true`})}),(0,O.jsxs)(N,{children:[(0,O.jsx)(P,{children:n}),(0,O.jsx)(F,{children:r})]}),(0,O.jsx)(I,{children:(0,O.jsx)(i?c:s,{className:`size-4 text-content-faint group-hover/action:text-content-secondary`,"aria-hidden":`true`})})]})})}export{L 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-CIheiCov.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-_dbgAw5b.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-C96FsPEU.js";import{t as g}from"./input-CPw-zkYh.js";import{t as _}from"./BotAvatar-CNL-APwP.js";import{t as v}from"./AppSelect-DQYKUW5E.js";import{D as y,O as b,a as x,k as S,n as C,w}from"./bots-store-D8M80DQa.js";import"./public-events-ntCr-b1Y.js";import{t as T}from"./public-flags-D6y-DU98.js";var E=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`}]]),D=e(n(),1),O=r(),k=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 A({className:e,variant:t=`default`,size:n=`default`,asChild:r=!1,...i}){let a=r?f:`div`;return(0,O.jsx)(a,{"data-slot":`item`,"data-variant":t,"data-size":n,className:p(k({variant:t,size:n,className:e})),...i})}var j=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 M({className:e,variant:t=`default`,...n}){return(0,O.jsx)(`div`,{"data-slot":`item-media`,"data-variant":t,className:p(j({variant:t,className:e})),...n})}function N({className:e,...t}){return(0,O.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 P({className:e,...t}){return(0,O.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 F({className:e,...t}){return(0,O.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 I({className:e,...t}){return(0,O.jsx)(`div`,{"data-slot":`item-actions`,className:p(`flex items-center gap-2`,e),...t})}function L({botId:e,collapsed:t=!1,fallback:n=null}){let r=T(`bots`),i=C(t=>t.bots.find(t=>t.id===e)),a=C(e=>e.loaded),o=C(e=>e.load);return(0,D.useEffect)(()=>{r&&!a&&o()},[r,o,a]),r?i?(0,O.jsx)(R,{bot:i,collapsed:t}):a?n:null:n}function R({bot:e,collapsed:n}){let{t:r}=a(),i=t(),o=C(e=>e.upsert),[s,c]=(0,D.useState)(!1),[f,T]=(0,D.useState)(e.proactive.briefAt),[k,A]=(0,D.useState)(!1),[j,M]=(0,D.useState)(!1),[N,P]=(0,D.useState)(e.proactive.everyHours),[F,I]=(0,D.useState)(!1),[L,R]=(0,D.useState)(``),B=b(e.instructions),V=e.workspace.environmentId===`local`,H=`/bots/${encodeURIComponent(e.id)}`,U=async t=>{I(!0),R(``);try{return o(await w(e.id,t)),!0}catch(e){return R(e instanceof Error?e.message:String(e)),!1}finally{I(!1)}},W=async e=>{e.preventDefault(),/^\d{2}:\d{2}$/.test(f)&&await U({proactive:{brief:!0,briefAt:f}})&&c(!1)};return(0,O.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,O.jsxs)(`div`,{className:`flex items-start gap-3.5`,children:[(0,O.jsx)(_,{avatar:e.avatar,state:n?`idle`:y(e),animate:!n,size:56}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1 pt-0.5`,children:[(0,O.jsx)(`h2`,{className:`text-[15px] leading-6 font-medium text-content`,children:r(`bots:greeting.hello`,{name:e.name})}),B?(0,O.jsxs)(`p`,{className:`text-sm leading-6 [overflow-wrap:anywhere] text-content-secondary`,children:[r(`bots:greeting.duty`,{duty:B}),` `,(0,O.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(H),children:r(`bots:greeting.editDuty`)})]}):(0,O.jsx)(`p`,{className:`text-sm leading-6 text-content-secondary`,children:r(n?`bots:greeting.talk`:`bots:greeting.ask`)})]})]}),!n&&(0,O.jsxs)(`div`,{className:`mt-4 flex max-w-[560px] flex-col gap-2`,children:[V&&(s?(0,O.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 W(e),onKeyDown:e=>{e.key===`Escape`&&c(!1)},children:[(0,O.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm font-medium text-content`,children:[r(`bots:greeting.briefWhen`),(0,O.jsx)(g,{type:`time`,value:f,autoFocus:!0,disabled:F,className:`w-32 font-normal`,onChange:e=>T(e.target.value)})]}),(0,O.jsx)(`p`,{className:`m-0 text-xs text-content-muted`,children:r(`bots:greeting.briefNote`)}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(m,{type:`submit`,disabled:F||!f,children:r(`bots:greeting.briefConfirm`)}),(0,O.jsx)(m,{type:`button`,variant:`ghost`,disabled:F,onClick:()=>c(!1),children:r(`bots:new.cancel`)})]})]}):(0,O.jsx)(z,{action:`brief`,icon:E,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:F,onClick:()=>{T(e.proactive.briefAt),c(!0)}})),V&&(j?(0,O.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(),A(!0)},onKeyDown:e=>{e.key===`Escape`&&e.currentTarget.contains(e.target)&&M(!1)},children:[(0,O.jsxs)(`label`,{className:`flex flex-col gap-2 text-sm font-medium text-content`,children:[r(`bots:greeting.watchWhen`),(0,O.jsx)(v,{value:String(N),className:`w-44 font-normal`,onChange:e=>P(Number(e.target.value)),children:x.map(e=>(0,O.jsx)(`option`,{value:e,children:r(`bots:proactive.everyHours`,{count:e})},e))})]}),(0,O.jsx)(`p`,{className:`m-0 text-xs text-content-muted`,children:r(`bots:greeting.watchNote`)}),(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,O.jsx)(m,{type:`submit`,autoFocus:!0,children:r(`bots:greeting.watchConfirm`)}),(0,O.jsx)(m,{type:`button`,variant:`ghost`,onClick:()=>M(!1),children:r(`bots:new.cancel`)})]})]}):(0,O.jsx)(z,{action:`folder`,icon:u,title:r(B?`bots:greeting.folder`:`bots:greeting.watch`),hint:B?e.proactive.enabled?r(`bots:greeting.folderWatchHint`,{folder:S(e.workspace.cwd),count:e.proactive.everyHours}):r(`bots:greeting.folderHint`,{folder:S(e.workspace.cwd)}):r(`bots:greeting.watchHint`,{count:e.proactive.everyHours}),disabled:F,onClick:()=>{if(B){A(!0);return}P(e.proactive.everyHours),M(!0)}})),(0,O.jsx)(z,{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:F,onClick:()=>i(`${H}?section=chats`)}),L&&(0,O.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:L}),(0,O.jsx)(l,{open:k,initialPath:e.workspace.cwd,onOpenChange:A,onSelect:async t=>{let n=await w(e.id,{workspace:{...e.workspace,cwd:t},...B?{}:{instructions:r(`bots:greeting.watchDuty`),proactive:{enabled:!0,everyHours:N}}});o(n),e.threadSessionId&&h({id:e.threadSessionId,cwd:n.workspace.cwd}),A(!1),M(!1)}})]})]})}function z({action:e,icon:t,title:n,hint:r,done:i=!1,disabled:a,onClick:o}){return(0,O.jsx)(A,{asChild:!0,variant:`outline`,children:(0,O.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,O.jsx)(M,{variant:`icon`,children:(0,O.jsx)(t,{className:`text-content-secondary`,strokeWidth:1.75,"aria-hidden":`true`})}),(0,O.jsxs)(N,{children:[(0,O.jsx)(P,{children:n}),(0,O.jsx)(F,{children:r})]}),(0,O.jsx)(I,{children:(0,O.jsx)(i?c:s,{className:`size-4 text-content-faint group-hover/action:text-content-secondary`,"aria-hidden":`true`})})]})})}export{L 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-_vdxObu5.js";import{t as a}from"./settings-2-CXJjXJS9.js";import{t as o}from"./button-CCcCN8tE.js";import{t as s}from"./BotAvatar-CNL-APwP.js";import{D as c,n as l,t as u}from"./bots-store-CNXTx3UY.js";import{t as d}from"./public-flags-D9LdpQwJ.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-CIheiCov.js";import{t as a}from"./settings-2-CXJjXJS9.js";import{t as o}from"./button-CCcCN8tE.js";import{t as s}from"./BotAvatar-CNL-APwP.js";import{D as c,n as l,t as u}from"./bots-store-D8M80DQa.js";import{t as d}from"./public-flags-D6y-DU98.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{d as a}from"./routes-DIeaqWVc.js";import{t as o}from"./use-i18n-_vdxObu5.js";import{t as s}from"./plus-fQbSqB1n.js";import{n as c,t as l}from"./use-open-bot-BTxzOAbZ.js";import{t as u}from"./utils-C8uzG5AZ.js";import{t as d}from"./BotAvatar-CNL-APwP.js";import{D as f,E as p,j as m,n as h,t as g}from"./bots-store-CNXTx3UY.js";import{t as _}from"./public-flags-D9LdpQwJ.js";var v=e(r(),1),y=i();function b(){let{t:e}=o(),r=_(`bots`),i=h(e=>e.bots),b=n(),x=t(),[S,C]=(0,v.useState)(!1),[w,T]=(0,v.useState)(!1),E=l((0,v.useCallback)((e,t)=>b(`/bots/${encodeURIComponent(t)}`),[b]));if(g(r),!r)return null;let D=a(x.pathname),O=/^\/bots\/([^/]+)/.exec(x.pathname)?.[1]??i.find(e=>D&&e.threadSessionId===D)?.id,{shown:k,hidden:A}=m(i,{expanded:w,currentId:O});return(0,y.jsxs)(`section`,{"data-sidebar-bots":!0,"aria-label":e(`bots:sidebar.title`),className:`mb-2`,children:[(0,y.jsxs)(`div`,{className:`flex h-[26px] items-center gap-1.5 px-2.5 text-xs font-medium text-content-muted`,children:[(0,y.jsx)(`h2`,{className:`flex-1`,children:e(`bots:sidebar.title`)}),(0,y.jsx)(`button`,{type:`button`,className:`grid size-6 place-items-center rounded-md hover:bg-surface-hover hover:text-content`,"aria-label":e(`bots:sidebar.newBot`),title:e(`bots:sidebar.newBot`),onClick:()=>C(!0),children:(0,y.jsx)(s,{className:`size-3.5`,"aria-hidden":`true`})})]}),(0,y.jsx)(`ul`,{role:`list`,className:`m-0 list-none p-0`,children:k.map(t=>{let n=t.activity,r=p(e,t);return(0,y.jsx)(`li`,{children:(0,y.jsxs)(`button`,{type:`button`,"data-sidebar-bot":t.id,"aria-current":O===t.id?`page`:void 0,title:r,className:u(`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`,O===t.id&&`bg-surface-active hover:bg-surface-active`),onClick:()=>void E(t),children:[(0,y.jsx)(d,{avatar:t.avatar,state:f(t),size:20}),(0,y.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-[13.5px] text-content`,children:[t.name,(0,y.jsx)(`span`,{className:`sr-only`,children:` · ${r}`})]}),n?.working?(0,y.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,y.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 flex-none rounded-full bg-st-attn`})]})},t.id)})}),(A>0||w&&i.length>3)&&(0,y.jsx)(`button`,{type:`button`,"data-sidebar-bots-more":!0,"aria-expanded":w,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:()=>T(!w),children:w?e(`bots:sidebar.showLess`):e(`bots:sidebar.showAll`,{count:i.length})}),(0,y.jsx)(c,{open:S,onOpenChange:C,onCreated:e=>void E(e)})]})}export{b 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{d as a}from"./routes-DIeaqWVc.js";import{t as o}from"./use-i18n-CIheiCov.js";import{t as s}from"./plus-fQbSqB1n.js";import{n as c,t as l}from"./use-open-bot-zjJ_Tnfv.js";import{t as u}from"./utils-C8uzG5AZ.js";import{t as d}from"./BotAvatar-CNL-APwP.js";import{D as f,E as p,j as m,n as h,t as g}from"./bots-store-D8M80DQa.js";import{t as _}from"./public-flags-D6y-DU98.js";var v=e(r(),1),y=i();function b(){let{t:e}=o(),r=_(`bots`),i=h(e=>e.bots),b=n(),x=t(),[S,C]=(0,v.useState)(!1),[w,T]=(0,v.useState)(!1),E=l((0,v.useCallback)((e,t)=>b(`/bots/${encodeURIComponent(t)}`),[b]));if(g(r),!r)return null;let D=a(x.pathname),O=/^\/bots\/([^/]+)/.exec(x.pathname)?.[1]??i.find(e=>D&&e.threadSessionId===D)?.id,{shown:k,hidden:A}=m(i,{expanded:w,currentId:O});return(0,y.jsxs)(`section`,{"data-sidebar-bots":!0,"aria-label":e(`bots:sidebar.title`),className:`mb-2`,children:[(0,y.jsxs)(`div`,{className:`flex h-[26px] items-center gap-1.5 px-2.5 text-xs font-medium text-content-muted`,children:[(0,y.jsx)(`h2`,{className:`flex-1`,children:e(`bots:sidebar.title`)}),(0,y.jsx)(`button`,{type:`button`,className:`grid size-6 place-items-center rounded-md hover:bg-surface-hover hover:text-content`,"aria-label":e(`bots:sidebar.newBot`),title:e(`bots:sidebar.newBot`),onClick:()=>C(!0),children:(0,y.jsx)(s,{className:`size-3.5`,"aria-hidden":`true`})})]}),(0,y.jsx)(`ul`,{role:`list`,className:`m-0 list-none p-0`,children:k.map(t=>{let n=t.activity,r=p(e,t);return(0,y.jsx)(`li`,{children:(0,y.jsxs)(`button`,{type:`button`,"data-sidebar-bot":t.id,"aria-current":O===t.id?`page`:void 0,title:r,className:u(`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`,O===t.id&&`bg-surface-active hover:bg-surface-active`),onClick:()=>void E(t),children:[(0,y.jsx)(d,{avatar:t.avatar,state:f(t),size:20}),(0,y.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-[13.5px] text-content`,children:[t.name,(0,y.jsx)(`span`,{className:`sr-only`,children:` · ${r}`})]}),n?.working?(0,y.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,y.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 flex-none rounded-full bg-st-attn`})]})},t.id)})}),(A>0||w&&i.length>3)&&(0,y.jsx)(`button`,{type:`button`,"data-sidebar-bots-more":!0,"aria-expanded":w,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:()=>T(!w),children:w?e(`bots:sidebar.showLess`):e(`bots:sidebar.showAll`,{count:i.length})}),(0,y.jsx)(c,{open:S,onOpenChange:C,onCreated:e=>void E(e)})]})}export{b as default};
@@ -1 +1 @@
1
- import{o as e}from"./vendor-state-GkUciC5H.js";import{t}from"./api-BW_X0FMZ.js";import{t as n}from"./runtime-capabilities-CHYOF_hE.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-_MWfl2VL.js";import{t as n}from"./runtime-capabilities-CHYOF_hE.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-D_zLThH_.js";import{t}from"./safe-mode-sentinel-DOhqH4gj.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-CwdjZZLG.js";import{t}from"./safe-mode-sentinel-Bg8pbnu-.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-CwdjZZLG.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-CuEXV1Zu.js";import{t}from"./api-BW_X0FMZ.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-Xa-I9BT7.js";import{t}from"./api-_MWfl2VL.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-D_zLThH_.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-CwdjZZLG.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"./api-BW_X0FMZ.js";import{u as t}from"./events-PfANjkHx.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}export{i as n,n as t};
1
+ import{t as e}from"./api-_MWfl2VL.js";import{u as t}from"./events-C96FsPEU.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}export{i as n,n as t};
@@ -1 +1 @@
1
- import{a as e,o as t,u as n}from"./api-BW_X0FMZ.js";import{o as r}from"./session-board-status-D2lpFPiI.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(e){if(!(e instanceof n)||!e.data)return null;let t=e.data.code??e.data.error;return typeof t==`string`&&/^[a-z0-9_]{1,64}$/.test(t)?t:null}function R(e){return!(e instanceof n)||!e.data?[]:_(e.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,n,r,i){return t(B(e,n,r),{signal:i})}function H(t){return e(`/api/custom-ui/components`,{signal:t,parse:E})}function U(t,n){return e(`${z(t)}/describe`,{signal:n,parse:F})}function ee(t){return e(`/api/custom-ui/components`,{method:`POST`,body:t,parse:e=>{let t=a(e)?T(e.component):null;if(!t)throw Error(`Invalid custom UI component response`);return t}})}function W(t,n){return e(z(t),{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(t){return e(z(t),{method:`DELETE`,parse:e=>({trashedAs:a(e)?m(e.trashedAs,256):``})})}function K(t){return e(`/api/custom-ui/instances`,{signal:t,parse:k})}function q(t){return e(`/api/custom-ui/instances`,{method:`POST`,body:t,parse:A})}function J(t,n){return e(`/api/custom-ui/instances/${encodeURIComponent(t)}`,{method:`PATCH`,body:n,parse:A})}function Y(t){return e(`/api/custom-ui/instances/${encodeURIComponent(t)}`,{method:`DELETE`,parse:e=>({revision:a(e)&&typeof e.revision==`number`?e.revision:0})})}function X(t,n){return e(`${z(t)}/errors`,{signal:n,parse:j})}function Z(t,n){return e(`${z(t)}/errors`,{method:`POST`,body:n,keepalive:!0,parse:()=>void 0})}function Q(t,n){return e(`${z(t)}/usage`,{method:`POST`,body:{entries:n},keepalive:!0,parse:()=>void 0})}function $(t,n,r){return e(`${z(t)}/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(t,n,r){return e(`${z(t)}/storage/${encodeURIComponent(n)}`,{method:`PUT`,body:{value:r},parse:()=>void 0})}function ne(t,n){return e(`${z(t)}/storage/${encodeURIComponent(n)}`,{method:`DELETE`,parse:()=>void 0})}async function re(t,n,r,i){return await e(`/api/custom-ui/provider-session`,{method:`PUT`,body:{sessionId:n},signal:i,timeout:15e3,parse:()=>void 0}),e(`${z(t)}/provider-request`,{method:`POST`,body:{sessionId:n,request:r},signal:i,timeout:15e3,parse:I})}function ie(t,n,r){return e(`${z(t)}/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(t){return e(`${z(t)}/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,o as t,u as n}from"./api-_MWfl2VL.js";import{o as r}from"./session-board-status-D2lpFPiI.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(e){if(!(e instanceof n)||!e.data)return null;let t=e.data.code??e.data.error;return typeof t==`string`&&/^[a-z0-9_]{1,64}$/.test(t)?t:null}function R(e){return!(e instanceof n)||!e.data?[]:_(e.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,n,r,i){return t(B(e,n,r),{signal:i})}function H(t){return e(`/api/custom-ui/components`,{signal:t,parse:E})}function U(t,n){return e(`${z(t)}/describe`,{signal:n,parse:F})}function ee(t){return e(`/api/custom-ui/components`,{method:`POST`,body:t,parse:e=>{let t=a(e)?T(e.component):null;if(!t)throw Error(`Invalid custom UI component response`);return t}})}function W(t,n){return e(z(t),{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(t){return e(z(t),{method:`DELETE`,parse:e=>({trashedAs:a(e)?m(e.trashedAs,256):``})})}function K(t){return e(`/api/custom-ui/instances`,{signal:t,parse:k})}function q(t){return e(`/api/custom-ui/instances`,{method:`POST`,body:t,parse:A})}function J(t,n){return e(`/api/custom-ui/instances/${encodeURIComponent(t)}`,{method:`PATCH`,body:n,parse:A})}function Y(t){return e(`/api/custom-ui/instances/${encodeURIComponent(t)}`,{method:`DELETE`,parse:e=>({revision:a(e)&&typeof e.revision==`number`?e.revision:0})})}function X(t,n){return e(`${z(t)}/errors`,{signal:n,parse:j})}function Z(t,n){return e(`${z(t)}/errors`,{method:`POST`,body:n,keepalive:!0,parse:()=>void 0})}function Q(t,n){return e(`${z(t)}/usage`,{method:`POST`,body:{entries:n},keepalive:!0,parse:()=>void 0})}function $(t,n,r){return e(`${z(t)}/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(t,n,r){return e(`${z(t)}/storage/${encodeURIComponent(n)}`,{method:`PUT`,body:{value:r},parse:()=>void 0})}function ne(t,n){return e(`${z(t)}/storage/${encodeURIComponent(n)}`,{method:`DELETE`,parse:()=>void 0})}async function re(t,n,r,i){return await e(`/api/custom-ui/provider-session`,{method:`PUT`,body:{sessionId:n},signal:i,timeout:15e3,parse:()=>void 0}),e(`${z(t)}/provider-request`,{method:`POST`,body:{sessionId:n,request:r},signal:i,timeout:15e3,parse:I})}function ie(t,n,r){return e(`${z(t)}/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(t){return e(`${z(t)}/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,2 +1,2 @@
1
- import{l as e}from"./events-PfANjkHx.js";import{t}from"./chat-api-Bo6nhq40.js";import{n,o as r,t as i}from"./session-tree-summary-HTmAo_9V.js";function a(e){if(typeof e!=`string`)return``;let t=e.trim();return t&&t.length<=200?t:``}async function o(n,a,{notify:o,t:s}){try{let r=await t.navigateSessionTree(n,a,!1);return i(n,r),e(n),o(s(`chat:sessionTree.undone`)),!0}catch(e){return o(r(e),`error`),!1}}function s(e,t,n,r){let i=a(t?.restoreEntryId);r.notify(n,`success`,i?{action:{label:r.t(`chat:sessionTree.undo`),onAction:()=>void o(e,i,r)}}:void 0)}function c(e){return{title:e(`chat:sessionTree.otherBranchTitle`),message:e(`chat:sessionTree.otherBranchMessage`),confirmLabel:e(`chat:sessionTree.switchBranch`),tone:`primary`}}async function l({sessionId:e,entryId:r,confirm:i,open:a,notify:o,t:l}){if(!await i(c(l)))return!1;let u=await t.navigateSessionTreeTarget(e,r);return!u.cancelled&&(n(e),a(e,r),s(e,u,l(`chat:sessionTree.switchedBranch`),{notify:o,t:l}),!0)}var u=8;function d(e,t){let n=e.files.filter(e=>e.action!==`unavailable`),r=e.files.filter(e=>e.action===`unavailable`),i=[];if(n.length){i.push(t(`chat:fileRewind.summary`,{count:n.length,restore:n.filter(e=>e.action===`restore`).length,remove:n.filter(e=>e.action===`delete`).length}));for(let e of n.slice(0,u))i.push(e.action===`delete`?t(`chat:fileRewind.deleteItem`,{path:e.path}):t(`chat:fileRewind.restoreItem`,{path:e.path}));n.length>u&&i.push(t(`chat:fileRewind.more`,{count:n.length-u}))}else i.push(t(`chat:fileRewind.nothing`));return r.length&&i.push(t(`chat:fileRewind.unavailable`,{count:r.length,paths:r.slice(0,u).map(e=>e.path).join(`, `)})),e.incomplete&&i.push(t(`chat:fileRewind.incomplete`)),i.push(t(`chat:fileRewind.scope`)),{title:t(`chat:fileRewind.title`),message:i.join(`
1
+ import{l as e}from"./events-C96FsPEU.js";import{t}from"./chat-api-9V8j4rSS.js";import{n,o as r,t as i}from"./session-tree-summary-u-RSxXXY.js";function a(e){if(typeof e!=`string`)return``;let t=e.trim();return t&&t.length<=200?t:``}async function o(n,a,{notify:o,t:s}){try{let r=await t.navigateSessionTree(n,a,!1);return i(n,r),e(n),o(s(`chat:sessionTree.undone`)),!0}catch(e){return o(r(e),`error`),!1}}function s(e,t,n,r){let i=a(t?.restoreEntryId);r.notify(n,`success`,i?{action:{label:r.t(`chat:sessionTree.undo`),onAction:()=>void o(e,i,r)}}:void 0)}function c(e){return{title:e(`chat:sessionTree.otherBranchTitle`),message:e(`chat:sessionTree.otherBranchMessage`),confirmLabel:e(`chat:sessionTree.switchBranch`),tone:`primary`}}async function l({sessionId:e,entryId:r,confirm:i,open:a,notify:o,t:l}){if(!await i(c(l)))return!1;let u=await t.navigateSessionTreeTarget(e,r);return!u.cancelled&&(n(e),a(e,r),s(e,u,l(`chat:sessionTree.switchedBranch`),{notify:o,t:l}),!0)}var u=8;function d(e,t){let n=e.files.filter(e=>e.action!==`unavailable`),r=e.files.filter(e=>e.action===`unavailable`),i=[];if(n.length){i.push(t(`chat:fileRewind.summary`,{count:n.length,restore:n.filter(e=>e.action===`restore`).length,remove:n.filter(e=>e.action===`delete`).length}));for(let e of n.slice(0,u))i.push(e.action===`delete`?t(`chat:fileRewind.deleteItem`,{path:e.path}):t(`chat:fileRewind.restoreItem`,{path:e.path}));n.length>u&&i.push(t(`chat:fileRewind.more`,{count:n.length-u}))}else i.push(t(`chat:fileRewind.nothing`));return r.length&&i.push(t(`chat:fileRewind.unavailable`,{count:r.length,paths:r.slice(0,u).map(e=>e.path).join(`, `)})),e.incomplete&&i.push(t(`chat:fileRewind.incomplete`)),i.push(t(`chat:fileRewind.scope`)),{title:t(`chat:fileRewind.title`),message:i.join(`
2
2
  `),confirmLabel:n.length?t(`chat:fileRewind.confirm`):t(`chat:fileRewind.confirmChatOnly`),tone:n.length?`danger`:`primary`}}function f(e,t){let n=e.restored.length+e.deleted.length,r=n?t(`chat:fileRewind.done`,{count:n}):t(`chat:fileRewind.doneChatOnly`);return e.unavailable.length?`${r} ${t(`chat:fileRewind.doneUnavailable`,{count:e.unavailable.length})}`:r}export{d as fileRewindConfirmOptions,f as fileRewindNotice,s as notifyTreeNavigation,l as switchToTurnOnOtherBranch};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t}from"./vendor-react-DwNgTV1j.js";import{t as n}from"./useQuery-DdcpUQhO.js";import{a as r}from"./startup-queries-CuEXV1Zu.js";import{t as i}from"./chat-api-Bo6nhq40.js";function a(e){return e instanceof Error?e.message:String(e)}function o(e){return/(?:当前会话已经结束运行|session .*?(?:ended|finished|no longer running))/i.test(a(e))}var s=e(t(),1),c=Object.freeze({});function l(e){return[`session-tree-summary`,e]}function u(e){let t=e&&typeof e==`object`?e:{},n=Number(t.branchCount),r={};for(let e of Array.isArray(t.nodes)?t.nodes:[]){if(!e||typeof e.id!=`string`||typeof e.label!=`string`)continue;let t=e.label.trim();t&&(r[e.id]=t.slice(0,80))}return{branchCount:Number.isFinite(n)&&n>0?Math.floor(n):0,labels:Object.keys(r).length?r:c}}async function d(e){return u(await i.getSessionTree(e))}function f(e,t){if(!e)return;let n=t;n&&Array.isArray(n.nodes)?r.setQueryData(l(e),u(n)):m(e)}function p(e){return r.fetchQuery({queryKey:l(e),queryFn:()=>d(e),staleTime:1/0})}function m(e){return r.invalidateQueries({queryKey:l(e)})}function h(e,{enabled:t,streaming:i,revision:a=0}){let o=t&&!i&&!!e,c=n({queryKey:l(e),queryFn:()=>d(e),enabled:o,staleTime:1/0},r),u=(0,s.useRef)({sessionId:e,streaming:i,revision:a});return(0,s.useEffect)(()=>{let t=u.current;u.current={sessionId:e,streaming:i,revision:a},!(!o||t.sessionId!==e)&&(t.streaming!==i||t.revision!==a)&&m(e)},[o,a,e,i]),c.data??null}function g(e,t){let i=n({queryKey:l(e),queryFn:()=>d(e),enabled:!1,staleTime:1/0,select:e=>t&&e.labels[t]||``},r);return t&&i.data||``}export{g as a,h as i,m as n,a as o,p as r,o as s,f as t};
1
+ import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t}from"./vendor-react-DwNgTV1j.js";import{t as n}from"./useQuery-DdcpUQhO.js";import{a as r}from"./startup-queries-Xa-I9BT7.js";import{t as i}from"./chat-api-9V8j4rSS.js";function a(e){return e instanceof Error?e.message:String(e)}function o(e){return/(?:当前会话已经结束运行|session .*?(?:ended|finished|no longer running))/i.test(a(e))}var s=e(t(),1),c=Object.freeze({});function l(e){return[`session-tree-summary`,e]}function u(e){let t=e&&typeof e==`object`?e:{},n=Number(t.branchCount),r={};for(let e of Array.isArray(t.nodes)?t.nodes:[]){if(!e||typeof e.id!=`string`||typeof e.label!=`string`)continue;let t=e.label.trim();t&&(r[e.id]=t.slice(0,80))}return{branchCount:Number.isFinite(n)&&n>0?Math.floor(n):0,labels:Object.keys(r).length?r:c}}async function d(e){return u(await i.getSessionTree(e))}function f(e,t){if(!e)return;let n=t;n&&Array.isArray(n.nodes)?r.setQueryData(l(e),u(n)):m(e)}function p(e){return r.fetchQuery({queryKey:l(e),queryFn:()=>d(e),staleTime:1/0})}function m(e){return r.invalidateQueries({queryKey:l(e)})}function h(e,{enabled:t,streaming:i,revision:a=0}){let o=t&&!i&&!!e,c=n({queryKey:l(e),queryFn:()=>d(e),enabled:o,staleTime:1/0},r),u=(0,s.useRef)({sessionId:e,streaming:i,revision:a});return(0,s.useEffect)(()=>{let t=u.current;u.current={sessionId:e,streaming:i,revision:a},!(!o||t.sessionId!==e)&&(t.streaming!==i||t.revision!==a)&&m(e)},[o,a,e,i]),c.data??null}function g(e,t){let i=n({queryKey:l(e),queryFn:()=>d(e),enabled:!1,staleTime:1/0,select:e=>t&&e.labels[t]||``},r);return t&&i.data||``}export{g as a,h as i,m as n,a as o,p as r,o as s,f as t};
@@ -1 +1 @@
1
- import{t as e}from"./index-D_zLThH_.js";import{o as t}from"./vendor-state-GkUciC5H.js";import{t as n}from"./storage-DtvZ_lEu.js";var r=Object.freeze([`commandPalette`,`primaryAction`,`focusSearch`,`toggleSidebar`,`toggleTerminal`,`openSettings`,`focusComposer`,`sendMessage`,`voiceInput`,`openBoard`,`openComponents`,`openMore`,`jumpToAttention`,`agentPanel`,`toggleInspector`,`previousAgent`,`nextAgent`,`steerMessage`,`shortcutHelp`,`openSession`,`sessionTree`,`sideChat`,`cycleFocusRegion`]),i=Object.freeze({commandPalette:`Mod+KeyK`,primaryAction:`Mod+KeyN`,focusSearch:`Slash`,toggleSidebar:`Mod+KeyB`,toggleTerminal:`Mod+Backquote`,openSettings:`Mod+Comma`,focusComposer:`Mod+Shift+KeyL`,sendMessage:`Enter`,voiceInput:`F8`,openBoard:`Mod+Digit1`,openComponents:null,openMore:`Mod+Digit2`,jumpToAttention:`Alt+KeyA`,agentPanel:`Mod+KeyJ`,toggleInspector:`Mod+KeyI`,previousAgent:`Alt+ArrowUp`,nextAgent:`Alt+ArrowDown`,steerMessage:`Alt+Enter`,shortcutHelp:`Mod+Slash`,openSession:null,sessionTree:`Mod+Shift+KeyB`,sideChat:null,cycleFocusRegion:`F6`}),a=[`Mod`,`Ctrl`,`Meta`,`Alt`,`Shift`],o=new Set([`Space`,`Backquote`,`Minus`,`Equal`,`BracketLeft`,`BracketRight`,`Backslash`,`Semicolon`,`Quote`,`Comma`,`Period`,`Slash`,`IntlBackslash`,`IntlRo`,`IntlYen`,`NumpadAdd`,`NumpadSubtract`,`NumpadMultiply`,`NumpadDivide`,`NumpadDecimal`]),s=new Set([`KeyA`,`KeyC`,`KeyF`,`KeyL`,`KeyO`,`KeyP`,`KeyQ`,`KeyR`,`KeyS`,`KeyT`,`KeyV`,`KeyW`,`KeyX`,`KeyY`,`KeyZ`]),c=new Map([[` `,`Space`],[`Spacebar`,`Space`],["`",`Backquote`],[`~`,`Backquote`],[`-`,`Minus`],[`_`,`Minus`],[`=`,`Equal`],[`+`,`Equal`],[`[`,`BracketLeft`],[`{`,`BracketLeft`],[`]`,`BracketRight`],[`}`,`BracketRight`],[`\\`,`Backslash`],[`|`,`Backslash`],[`;`,`Semicolon`],[`:`,`Semicolon`],[`'`,`Quote`],[`"`,`Quote`],[`,`,`Comma`],[`<`,`Comma`],[`.`,`Period`],[`>`,`Period`],[`/`,`Slash`],[`?`,`Slash`],...[...`)!@#$%^&*(`].map((e,t)=>[e,`Digit${t}`])]),l=class extends Error{constructor(e,t=`invalid`,n=null,r=null){super(e),this.name=`ShortcutValidationError`,this.code=t,this.action=n,this.conflictingAction=r}};function u(e){if(typeof e!=`string`||!e)return null;let t=e.split(`+`),n=t.pop();if(!/^(Key[A-Z]|Digit[0-9]|Numpad[0-9]|F([1-9]|1[0-2])|Enter|Arrow(Up|Down))$/.test(n)&&!o.has(n))return null;let r=-1;for(let e of t){let t=a.indexOf(e);if(t<=r)return null;r=t}return t.filter(e=>[`Mod`,`Ctrl`,`Meta`].includes(e)).length>1?null:{code:n,primary:t.find(e=>[`Mod`,`Ctrl`,`Meta`].includes(e))||null,alt:t.includes(`Alt`),shift:t.includes(`Shift`)}}function d(e,t=null){let{code:n,primary:r,alt:i,shift:a}=e;return n.startsWith(`Arrow`)?i&&!r&&!a:n===`Enter`&&a&&!r&&!i||i&&(n===`F4`||n===`Space`)||r&&n===`F4`||(r===`Mod`||r===`Meta`)&&n===`Space`&&!a||r&&s.has(n)&&!(n===`KeyL`&&a)?!1:/^F\d+$/.test(n)||r||i?!0:a?!1:n===`Enter`&&(!t||t===`sendMessage`)||n===`Slash`&&(!t||t===`focusSearch`)}function f(e,t){return{ctrl:e.primary===`Ctrl`||e.primary===`Mod`&&!t,meta:e.primary===`Meta`||e.primary===`Mod`&&t,alt:e.alt,shift:e.shift}}function p(e,t,n){let r=f(e,n),i=f(t,n);return e.code===t.code&&r.ctrl===i.ctrl&&r.meta===i.meta&&r.alt===i.alt&&r.shift===i.shift}function m(e,t,n){let i=u(n);if(!i)return null;for(let n of r){if(n===t)continue;let r=u(e?.[n]);if(r&&(p(i,r,!1)||p(i,r,!0)))return n}return null}function h(e){if(!e||typeof e!=`object`||Array.isArray(e)||![Object.prototype,null].includes(Object.getPrototypeOf(e))||Reflect.ownKeys(e).length!==r.length||!r.every(t=>Object.hasOwn(e,t)))throw new l(`Expected a complete shortcut map with only known actions`);let t={};for(let n of r){let r=e[n];if(r!==null){let e=u(r);if(!e||!d(e,n))throw new l(`Invalid or reserved shortcut for ${n}`,`invalid`,n)}t[n]=r}for(let e of r){let n=m(t,e,t[e]);if(n)throw new l(`Shortcut conflict between ${e} and ${n}`,`conflict`,e,n)}return t}var g=Object.freeze({openBoard:`Mod+Digit1`,openComponents:`Mod+Digit2`,openMore:`Mod+Digit3`}),_=Object.freeze({openSession:`Mod+Digit1`,openBoard:`Mod+Digit2`,openComponents:`Mod+Digit3`,openMore:`Mod+Digit4`}),v=Object.freeze([`openMore`,`openComponents`,`openBoard`,`openSession`]),y=Object.freeze({openSession:null,openBoard:`Mod+Digit1`,openComponents:null,openMore:`Mod+Digit2`});function b(e){for(let[t,n]of Object.entries(g))if(e[t]!==n)return;for(let t of v){let n=_[t];m(e,t,n)||(e[t]=n)}}function x(e){for(let[t,n]of Object.entries(_))if(e[t]!==n)return;Object.assign(e,y)}function S(e){if(!e||typeof e!=`object`||Array.isArray(e)||![Object.prototype,null].includes(Object.getPrototypeOf(e)))return e;let t=r.filter(t=>Object.hasOwn(e,t));if(t.length===r.length&&Reflect.ownKeys(e).length===t.length)return e;let n={};for(let r of t)n[r]=e[r];Object.hasOwn(n,`sessionTree`)||(Object.hasOwn(n,`openSession`)||b(n),x(n));for(let e of r){if(Object.hasOwn(n,e))continue;let t=i[e];n[e]=m(n,e,t)?null:t}return n}function C(e){try{let t=h(S(e));return t.voiceInput===`Mod+Shift+Space`&&!m(t,`voiceInput`,`F8`)&&(t.voiceInput=`F8`),t}catch{return{...i}}}function w(e){if(e.code)return e.code;let t=e.key;return typeof t==`string`?/^[a-z]$/i.test(t)?`Key${t.toUpperCase()}`:/^[0-9]$/.test(t)?`Digit${t}`:/^(Enter|Arrow(Up|Down)|F([1-9]|1[0-2]))$/.test(t)?t:c.get(t)||null:null}function T(e){return!e||e.defaultPrevented||e.repeat||e.isComposing||e.keyCode===229||[`Dead`,`Process`,`Unidentified`,`AltGraph`].includes(e.key)||e.getModifierState?.(`AltGraph`)}function E(e,t=!1){if(T(e)||e.ctrlKey&&e.metaKey)return null;let n=w(e);if(!n)return null;let r=[];(t?e.metaKey:e.ctrlKey)?r.push(`Mod`):e.ctrlKey?r.push(`Ctrl`):e.metaKey&&r.push(`Meta`),e.altKey&&r.push(`Alt`),e.shiftKey&&r.push(`Shift`),r.push(n);let i=r.join(`+`),a=u(i);return a&&d(a)?i:null}function D(e,t,n=!1){if(T(e))return!1;let r=u(t);if(!r||!d(r)||w(e)!==r.code)return!1;let i=f(r,n);return!!e.ctrlKey===i.ctrl&&!!e.metaKey===i.meta&&!!e.altKey===i.alt&&!!e.shiftKey===i.shift}function O(e,t=!1){let n=u(e);if(!n)return``;let r=[];n.primary&&r.push(n.primary===`Mod`?t?`Cmd`:`Ctrl`:n.primary===`Meta`?`Cmd`:`Ctrl`),n.alt&&r.push(`Alt`),n.shift&&r.push(`Shift`);let i={Backquote:"`",Minus:`-`,Equal:`=`,BracketLeft:`[`,BracketRight:`]`,Backslash:`\\`,Semicolon:`;`,Quote:`'`,Comma:`,`,Period:`.`,Slash:`/`,IntlBackslash:`\\`,IntlRo:`\\`,IntlYen:`Yen`,NumpadAdd:`Num +`,NumpadSubtract:`Num -`,NumpadMultiply:`Num *`,NumpadDivide:`Num /`,NumpadDecimal:`Num .`,ArrowUp:`↑`,ArrowDown:`↓`},a=n.code;return r.push(i[a]||a.replace(/^Key|^Digit/,``).replace(/^Numpad/,`Num `)),r.join(` + `)}var k=Object.freeze([`boardNext`,`boardPrevious`,`boardApprove`,`boardDeny`,`boardRetry`,`boardTriage`,`boardToggleGrouping`]),A=Object.freeze({boardNext:`KeyJ`,boardPrevious:`KeyK`,boardApprove:`KeyA`,boardDeny:`KeyD`,boardRetry:`KeyR`,boardTriage:`KeyT`,boardToggleGrouping:`KeyG`}),j=/^Key[A-Z]$/;function M(e,t,n){return typeof n!=`string`||!j.test(n)?null:k.find(r=>r!==t&&e?.[r]===n)||null}function N(e){if(!e||typeof e!=`object`||Array.isArray(e)||![Object.prototype,null].includes(Object.getPrototypeOf(e))||Reflect.ownKeys(e).length!==k.length||!k.every(t=>Object.hasOwn(e,t)))throw new l(`Expected a complete board shortcut map`);let t={};for(let n of k){let r=e[n];if(r!==null&&(typeof r!=`string`||!j.test(r)))throw new l(`Invalid board shortcut for ${n}`,`invalid`,n);t[n]=r}for(let e of k){let n=M(t,e,t[e]);if(n)throw new l(`Board shortcut conflict between ${e} and ${n}`,`conflict`,e,n)}return t}function P(e){try{let t=e&&typeof e==`object`&&!Array.isArray(e)?e:Object.create(null),n={};for(let e of k)Object.hasOwn(t,e)&&(n[e]=t[e]);for(let e of k){if(Object.hasOwn(n,e))continue;let t=A[e];n[e]=M(n,e,t)?null:t}return N(n)}catch{return{...A}}}function F(e){return!!(e?.ctrlKey||e?.metaKey||e?.altKey||e?.shiftKey)}function I(e){if(T(e)||F(e))return null;let t=w(e);return t&&j.test(t)?t:null}function L(e,t){return typeof t!=`string`||!j.test(t)?!1:I(e)===t}function R(){try{return C(JSON.parse(e.getItem(n.shortcuts)||`null`))}catch{return{...i}}}function z(){try{return P(JSON.parse(e.getItem(n.boardShortcuts)||`null`))}catch{return{...A}}}var B=t((t,r)=>{let a=r=>{e.setItem(n.shortcuts,JSON.stringify(r)),t({bindings:r})},o=r=>{e.setItem(n.boardShortcuts,JSON.stringify(r)),t({boardBindings:r})};return{bindings:R(),boardBindings:z(),setBinding:(e,t)=>a(h({...r().bindings,[e]:t})),setBoardBinding:(e,t)=>o(N({...r().boardBindings,[e]:t})),resetBindings:()=>{a({...i}),o({...A})}}});typeof window<`u`&&window.addEventListener(`storage`,e=>{(e.key===n.shortcuts||e.key===null)&&B.setState({bindings:R()}),(e.key===n.boardShortcuts||e.key===null)&&B.setState({boardBindings:z()})});var V=/Mac|iPhone|iPad/.test(globalThis.navigator?.platform||``);function H(e,t=V){return O(e,t)}function U(e,t,n=V){return D(e,t,n)}function W(e,t=V){return E(e,t)}function G(e){return H(B(t=>t.bindings[e]))}function K(e){return e instanceof HTMLElement&&!!e.closest(`input, textarea, select, [contenteditable]:not([contenteditable="false"]), [role="textbox"]`)}function q(e,t=V){return t&&e.altKey&&!e.ctrlKey&&!e.metaKey&&K(e.target)}function J(e){return e.defaultPrevented||e.isComposing||e.keyCode===229||e.repeat||document.visibilityState===`hidden`||!!document.querySelector(`[role="dialog"], [role="alertdialog"], dialog[open]`)||e.target instanceof HTMLElement&&!!e.target.closest(`[data-shortcut-recorder], .terminal-panel, [role="menu"], [role="listbox"]`)}export{h as _,J as a,B as c,i as d,r as f,L as g,m as h,q as i,k as l,M as m,K as n,W as o,I as p,U as r,G as s,H as t,A as u};
1
+ import{t as e}from"./index-CwdjZZLG.js";import{o as t}from"./vendor-state-GkUciC5H.js";import{t as n}from"./storage-DtvZ_lEu.js";var r=Object.freeze([`commandPalette`,`primaryAction`,`focusSearch`,`toggleSidebar`,`toggleTerminal`,`openSettings`,`focusComposer`,`sendMessage`,`voiceInput`,`openBoard`,`openComponents`,`openMore`,`jumpToAttention`,`agentPanel`,`toggleInspector`,`previousAgent`,`nextAgent`,`steerMessage`,`shortcutHelp`,`openSession`,`sessionTree`,`sideChat`,`cycleFocusRegion`]),i=Object.freeze({commandPalette:`Mod+KeyK`,primaryAction:`Mod+KeyN`,focusSearch:`Slash`,toggleSidebar:`Mod+KeyB`,toggleTerminal:`Mod+Backquote`,openSettings:`Mod+Comma`,focusComposer:`Mod+Shift+KeyL`,sendMessage:`Enter`,voiceInput:`F8`,openBoard:`Mod+Digit1`,openComponents:null,openMore:`Mod+Digit2`,jumpToAttention:`Alt+KeyA`,agentPanel:`Mod+KeyJ`,toggleInspector:`Mod+KeyI`,previousAgent:`Alt+ArrowUp`,nextAgent:`Alt+ArrowDown`,steerMessage:`Alt+Enter`,shortcutHelp:`Mod+Slash`,openSession:null,sessionTree:`Mod+Shift+KeyB`,sideChat:null,cycleFocusRegion:`F6`}),a=[`Mod`,`Ctrl`,`Meta`,`Alt`,`Shift`],o=new Set([`Space`,`Backquote`,`Minus`,`Equal`,`BracketLeft`,`BracketRight`,`Backslash`,`Semicolon`,`Quote`,`Comma`,`Period`,`Slash`,`IntlBackslash`,`IntlRo`,`IntlYen`,`NumpadAdd`,`NumpadSubtract`,`NumpadMultiply`,`NumpadDivide`,`NumpadDecimal`]),s=new Set([`KeyA`,`KeyC`,`KeyF`,`KeyL`,`KeyO`,`KeyP`,`KeyQ`,`KeyR`,`KeyS`,`KeyT`,`KeyV`,`KeyW`,`KeyX`,`KeyY`,`KeyZ`]),c=new Map([[` `,`Space`],[`Spacebar`,`Space`],["`",`Backquote`],[`~`,`Backquote`],[`-`,`Minus`],[`_`,`Minus`],[`=`,`Equal`],[`+`,`Equal`],[`[`,`BracketLeft`],[`{`,`BracketLeft`],[`]`,`BracketRight`],[`}`,`BracketRight`],[`\\`,`Backslash`],[`|`,`Backslash`],[`;`,`Semicolon`],[`:`,`Semicolon`],[`'`,`Quote`],[`"`,`Quote`],[`,`,`Comma`],[`<`,`Comma`],[`.`,`Period`],[`>`,`Period`],[`/`,`Slash`],[`?`,`Slash`],...[...`)!@#$%^&*(`].map((e,t)=>[e,`Digit${t}`])]),l=class extends Error{constructor(e,t=`invalid`,n=null,r=null){super(e),this.name=`ShortcutValidationError`,this.code=t,this.action=n,this.conflictingAction=r}};function u(e){if(typeof e!=`string`||!e)return null;let t=e.split(`+`),n=t.pop();if(!/^(Key[A-Z]|Digit[0-9]|Numpad[0-9]|F([1-9]|1[0-2])|Enter|Arrow(Up|Down))$/.test(n)&&!o.has(n))return null;let r=-1;for(let e of t){let t=a.indexOf(e);if(t<=r)return null;r=t}return t.filter(e=>[`Mod`,`Ctrl`,`Meta`].includes(e)).length>1?null:{code:n,primary:t.find(e=>[`Mod`,`Ctrl`,`Meta`].includes(e))||null,alt:t.includes(`Alt`),shift:t.includes(`Shift`)}}function d(e,t=null){let{code:n,primary:r,alt:i,shift:a}=e;return n.startsWith(`Arrow`)?i&&!r&&!a:n===`Enter`&&a&&!r&&!i||i&&(n===`F4`||n===`Space`)||r&&n===`F4`||(r===`Mod`||r===`Meta`)&&n===`Space`&&!a||r&&s.has(n)&&!(n===`KeyL`&&a)?!1:/^F\d+$/.test(n)||r||i?!0:a?!1:n===`Enter`&&(!t||t===`sendMessage`)||n===`Slash`&&(!t||t===`focusSearch`)}function f(e,t){return{ctrl:e.primary===`Ctrl`||e.primary===`Mod`&&!t,meta:e.primary===`Meta`||e.primary===`Mod`&&t,alt:e.alt,shift:e.shift}}function p(e,t,n){let r=f(e,n),i=f(t,n);return e.code===t.code&&r.ctrl===i.ctrl&&r.meta===i.meta&&r.alt===i.alt&&r.shift===i.shift}function m(e,t,n){let i=u(n);if(!i)return null;for(let n of r){if(n===t)continue;let r=u(e?.[n]);if(r&&(p(i,r,!1)||p(i,r,!0)))return n}return null}function h(e){if(!e||typeof e!=`object`||Array.isArray(e)||![Object.prototype,null].includes(Object.getPrototypeOf(e))||Reflect.ownKeys(e).length!==r.length||!r.every(t=>Object.hasOwn(e,t)))throw new l(`Expected a complete shortcut map with only known actions`);let t={};for(let n of r){let r=e[n];if(r!==null){let e=u(r);if(!e||!d(e,n))throw new l(`Invalid or reserved shortcut for ${n}`,`invalid`,n)}t[n]=r}for(let e of r){let n=m(t,e,t[e]);if(n)throw new l(`Shortcut conflict between ${e} and ${n}`,`conflict`,e,n)}return t}var g=Object.freeze({openBoard:`Mod+Digit1`,openComponents:`Mod+Digit2`,openMore:`Mod+Digit3`}),_=Object.freeze({openSession:`Mod+Digit1`,openBoard:`Mod+Digit2`,openComponents:`Mod+Digit3`,openMore:`Mod+Digit4`}),v=Object.freeze([`openMore`,`openComponents`,`openBoard`,`openSession`]),y=Object.freeze({openSession:null,openBoard:`Mod+Digit1`,openComponents:null,openMore:`Mod+Digit2`});function b(e){for(let[t,n]of Object.entries(g))if(e[t]!==n)return;for(let t of v){let n=_[t];m(e,t,n)||(e[t]=n)}}function x(e){for(let[t,n]of Object.entries(_))if(e[t]!==n)return;Object.assign(e,y)}function S(e){if(!e||typeof e!=`object`||Array.isArray(e)||![Object.prototype,null].includes(Object.getPrototypeOf(e)))return e;let t=r.filter(t=>Object.hasOwn(e,t));if(t.length===r.length&&Reflect.ownKeys(e).length===t.length)return e;let n={};for(let r of t)n[r]=e[r];Object.hasOwn(n,`sessionTree`)||(Object.hasOwn(n,`openSession`)||b(n),x(n));for(let e of r){if(Object.hasOwn(n,e))continue;let t=i[e];n[e]=m(n,e,t)?null:t}return n}function C(e){try{let t=h(S(e));return t.voiceInput===`Mod+Shift+Space`&&!m(t,`voiceInput`,`F8`)&&(t.voiceInput=`F8`),t}catch{return{...i}}}function w(e){if(e.code)return e.code;let t=e.key;return typeof t==`string`?/^[a-z]$/i.test(t)?`Key${t.toUpperCase()}`:/^[0-9]$/.test(t)?`Digit${t}`:/^(Enter|Arrow(Up|Down)|F([1-9]|1[0-2]))$/.test(t)?t:c.get(t)||null:null}function T(e){return!e||e.defaultPrevented||e.repeat||e.isComposing||e.keyCode===229||[`Dead`,`Process`,`Unidentified`,`AltGraph`].includes(e.key)||e.getModifierState?.(`AltGraph`)}function E(e,t=!1){if(T(e)||e.ctrlKey&&e.metaKey)return null;let n=w(e);if(!n)return null;let r=[];(t?e.metaKey:e.ctrlKey)?r.push(`Mod`):e.ctrlKey?r.push(`Ctrl`):e.metaKey&&r.push(`Meta`),e.altKey&&r.push(`Alt`),e.shiftKey&&r.push(`Shift`),r.push(n);let i=r.join(`+`),a=u(i);return a&&d(a)?i:null}function D(e,t,n=!1){if(T(e))return!1;let r=u(t);if(!r||!d(r)||w(e)!==r.code)return!1;let i=f(r,n);return!!e.ctrlKey===i.ctrl&&!!e.metaKey===i.meta&&!!e.altKey===i.alt&&!!e.shiftKey===i.shift}function O(e,t=!1){let n=u(e);if(!n)return``;let r=[];n.primary&&r.push(n.primary===`Mod`?t?`Cmd`:`Ctrl`:n.primary===`Meta`?`Cmd`:`Ctrl`),n.alt&&r.push(`Alt`),n.shift&&r.push(`Shift`);let i={Backquote:"`",Minus:`-`,Equal:`=`,BracketLeft:`[`,BracketRight:`]`,Backslash:`\\`,Semicolon:`;`,Quote:`'`,Comma:`,`,Period:`.`,Slash:`/`,IntlBackslash:`\\`,IntlRo:`\\`,IntlYen:`Yen`,NumpadAdd:`Num +`,NumpadSubtract:`Num -`,NumpadMultiply:`Num *`,NumpadDivide:`Num /`,NumpadDecimal:`Num .`,ArrowUp:`↑`,ArrowDown:`↓`},a=n.code;return r.push(i[a]||a.replace(/^Key|^Digit/,``).replace(/^Numpad/,`Num `)),r.join(` + `)}var k=Object.freeze([`boardNext`,`boardPrevious`,`boardApprove`,`boardDeny`,`boardRetry`,`boardTriage`,`boardToggleGrouping`]),A=Object.freeze({boardNext:`KeyJ`,boardPrevious:`KeyK`,boardApprove:`KeyA`,boardDeny:`KeyD`,boardRetry:`KeyR`,boardTriage:`KeyT`,boardToggleGrouping:`KeyG`}),j=/^Key[A-Z]$/;function M(e,t,n){return typeof n!=`string`||!j.test(n)?null:k.find(r=>r!==t&&e?.[r]===n)||null}function N(e){if(!e||typeof e!=`object`||Array.isArray(e)||![Object.prototype,null].includes(Object.getPrototypeOf(e))||Reflect.ownKeys(e).length!==k.length||!k.every(t=>Object.hasOwn(e,t)))throw new l(`Expected a complete board shortcut map`);let t={};for(let n of k){let r=e[n];if(r!==null&&(typeof r!=`string`||!j.test(r)))throw new l(`Invalid board shortcut for ${n}`,`invalid`,n);t[n]=r}for(let e of k){let n=M(t,e,t[e]);if(n)throw new l(`Board shortcut conflict between ${e} and ${n}`,`conflict`,e,n)}return t}function P(e){try{let t=e&&typeof e==`object`&&!Array.isArray(e)?e:Object.create(null),n={};for(let e of k)Object.hasOwn(t,e)&&(n[e]=t[e]);for(let e of k){if(Object.hasOwn(n,e))continue;let t=A[e];n[e]=M(n,e,t)?null:t}return N(n)}catch{return{...A}}}function F(e){return!!(e?.ctrlKey||e?.metaKey||e?.altKey||e?.shiftKey)}function I(e){if(T(e)||F(e))return null;let t=w(e);return t&&j.test(t)?t:null}function L(e,t){return typeof t!=`string`||!j.test(t)?!1:I(e)===t}function R(){try{return C(JSON.parse(e.getItem(n.shortcuts)||`null`))}catch{return{...i}}}function z(){try{return P(JSON.parse(e.getItem(n.boardShortcuts)||`null`))}catch{return{...A}}}var B=t((t,r)=>{let a=r=>{e.setItem(n.shortcuts,JSON.stringify(r)),t({bindings:r})},o=r=>{e.setItem(n.boardShortcuts,JSON.stringify(r)),t({boardBindings:r})};return{bindings:R(),boardBindings:z(),setBinding:(e,t)=>a(h({...r().bindings,[e]:t})),setBoardBinding:(e,t)=>o(N({...r().boardBindings,[e]:t})),resetBindings:()=>{a({...i}),o({...A})}}});typeof window<`u`&&window.addEventListener(`storage`,e=>{(e.key===n.shortcuts||e.key===null)&&B.setState({bindings:R()}),(e.key===n.boardShortcuts||e.key===null)&&B.setState({boardBindings:z()})});var V=/Mac|iPhone|iPad/.test(globalThis.navigator?.platform||``);function H(e,t=V){return O(e,t)}function U(e,t,n=V){return D(e,t,n)}function W(e,t=V){return E(e,t)}function G(e){return H(B(t=>t.bindings[e]))}function K(e){return e instanceof HTMLElement&&!!e.closest(`input, textarea, select, [contenteditable]:not([contenteditable="false"]), [role="textbox"]`)}function q(e,t=V){return t&&e.altKey&&!e.ctrlKey&&!e.metaKey&&K(e.target)}function J(e){return e.defaultPrevented||e.isComposing||e.keyCode===229||e.repeat||document.visibilityState===`hidden`||!!document.querySelector(`[role="dialog"], [role="alertdialog"], dialog[open]`)||e.target instanceof HTMLElement&&!!e.target.closest(`[data-shortcut-recorder], .terminal-panel, [role="menu"], [role="listbox"]`)}export{h as _,J as a,B as c,i as d,r as f,L as g,m as h,q as i,k as l,M as m,K as n,W as o,I as p,U as r,G as s,H as t,A as u};