pisper 0.6.36 → 0.6.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -6
- package/web/.vite/manifest.json +696 -696
- package/web/assets/{AppDialog-C79lPTAo.js → AppDialog-Cw7rc4XR.js} +1 -1
- package/web/assets/{AppOverlays-CcLTlcPI.js → AppOverlays-Di-fHhSB.js} +1 -1
- package/web/assets/{AssetsPage-DItvQcTv.js → AssetsPage-DIe85h--.js} +1 -1
- package/web/assets/{AttachmentTray-DT4tuA-0.js → AttachmentTray-BLSQp6M3.js} +1 -1
- package/web/assets/{BoardPage-BS2Mn5BB.js → BoardPage-DpaN03Lf.js} +3 -3
- package/web/assets/BotAvatar-SFQi6bVG.js +1 -0
- package/web/assets/{ChannelsPage-HLl1Exdg.js → ChannelsPage-D_GuiQzA.js} +1 -1
- package/web/assets/{ChatAppearancePage-COu9kuXs.js → ChatAppearancePage-CFZBJho6.js} +1 -1
- package/web/assets/{ChatHistoryPage-DW7tD7eq.js → ChatHistoryPage-Dk3KMztM.js} +1 -1
- package/web/assets/{ChatMessage-BA6Yf2bc.js → ChatMessage-pqXPc_eb.js} +3 -3
- package/web/assets/{ChatPage-Cz50Wq-F.js → ChatPage-oQQshWkr.js} +3 -3
- package/web/assets/{ConfigPage-BBU5Rrn1.js → ConfigPage-CWuA29xP.js} +2 -2
- package/web/assets/{DesktopWindowControls-BJa4zqE2.js → DesktopWindowControls-DUcVtVCs.js} +1 -1
- package/web/assets/{FeaturePage-D2NZ4cLC.js → FeaturePage-DLnP1aDp.js} +1 -1
- package/web/assets/{FileAttachmentPreview-CFAdIi3l.js → FileAttachmentPreview-RKOc2WdF.js} +1 -1
- package/web/assets/{FloatingWidgets-BzwWhwvZ.js → FloatingWidgets-Bith-ECr.js} +1 -1
- package/web/assets/{FocusRuntimeControls-eXxgJIFt.js → FocusRuntimeControls-1e47Xb4z.js} +1 -1
- package/web/assets/{GitDiffViewer-DDd2yMvx.js → GitDiffViewer-CwMYo1oB.js} +1 -1
- package/web/assets/{ManageProjectsDialog-Sf4KX5NQ.js → ManageProjectsDialog-Docy1GpF.js} +1 -1
- package/web/assets/{MarkdownMessage-CggW-dCt.js → MarkdownMessage-Brsfnbe4.js} +1 -1
- package/web/assets/{McpPage-CSaBHKz7.js → McpPage-DiwEaVc_.js} +1 -1
- package/web/assets/{MemoryEvolution-DV0LMrEd.js → MemoryEvolution-uvjfuUUj.js} +1 -1
- package/web/assets/{MemoryPage-G0tvVhJb.js → MemoryPage-BAi5hlI3.js} +2 -2
- package/web/assets/{MobileNavigation-B1XfXR2s.js → MobileNavigation-vcszVJOp.js} +1 -1
- package/web/assets/{MorePage-DGYxdHLm.js → MorePage-BVlc8OoO.js} +1 -1
- package/web/assets/{NewFolderDialog-CzgCnqfC.js → NewFolderDialog-DW2eVsTT.js} +1 -1
- package/web/assets/{PageHeader-CQ4qg6wC.js → PageHeader-ZD7qkymY.js} +1 -1
- package/web/assets/{PhoneDrawer-CjUjF454.js → PhoneDrawer-Bj5UN8ml.js} +1 -1
- package/web/assets/{PhoneMenuButton-DbsLKxdG.js → PhoneMenuButton-B6s1QtNQ.js} +1 -1
- package/web/assets/{PhoneTopBar-DMMlJYcd.js → PhoneTopBar-DA373mh5.js} +1 -1
- package/web/assets/{PluginsPage-BnNOlT_w.js → PluginsPage-B3hsUZ_Q.js} +1 -1
- package/web/assets/{SafeModePrompt-DpzPKu3D.js → SafeModePrompt-BLbALi0G.js} +1 -1
- package/web/assets/{SchedulesPage-Ds4Q6aNP.js → SchedulesPage-YQ6aVxUS.js} +1 -1
- package/web/assets/{SessionBrowserPane-C0P_zk8r.js → SessionBrowserPane-KHWJ-cT-.js} +2 -2
- package/web/assets/{SessionContextPanel-CHOeF4Yg.js → SessionContextPanel-BQCxpXfH.js} +2 -2
- package/web/assets/{SessionHome-BVB1DziO.js → SessionHome-KgMFcRJ4.js} +1 -1
- package/web/assets/{SessionInspector-CI0yM7hn.js → SessionInspector-BwFBCtmV.js} +1 -1
- package/web/assets/{SessionShell-kd6S4sjr.js → SessionShell-wr7-_Sjt.js} +1 -1
- package/web/assets/{SettingsSidebar-Tef3Nnew.js → SettingsSidebar-DXwdmUIk.js} +1 -1
- package/web/assets/{ShortcutHelpDialog-C8XduaKQ.js → ShortcutHelpDialog-89JopRc_.js} +1 -1
- package/web/assets/{ShortcutKeys-CHOVA_5P.js → ShortcutKeys-6jUwKZTe.js} +1 -1
- package/web/assets/{SidebarUpdateStatus-BNFx2j6q.js → SidebarUpdateStatus-CG5oRTvE.js} +1 -1
- package/web/assets/{SkillsPage-TBWU04ie.js → SkillsPage-CHUoIXMG.js} +1 -1
- package/web/assets/{TaskProcessesPane-BHe6CquN.js → TaskProcessesPane-BsR96Uy0.js} +1 -1
- package/web/assets/{TaskTerminalView-ByuB7q2B.js → TaskTerminalView-BqhXX5DQ.js} +1 -1
- package/web/assets/{TerminalPanel-FXsJQMsq.js → TerminalPanel-CPYlb-Yf.js} +1 -1
- package/web/assets/{WebDesktopPet-Bw-jipEg.js → WebDesktopPet-Czdppa-t.js} +1 -1
- package/web/assets/{WorkflowsPage-COT3iS5m.js → WorkflowsPage-CUCLMWKi.js} +1 -1
- package/web/assets/{WorkspacePicker-DjW-sAP5.js → WorkspacePicker-CtkwBoo-.js} +1 -1
- package/web/assets/{api-BET28sp7.js → api-O9Wq9r_X.js} +1 -1
- package/web/assets/{app-update-7n8nXaPd.js → app-update-B-qeHgdo.js} +1 -1
- package/web/assets/{approval-confirm-SBeU3s_9.js → approval-confirm-BE2pBBhd.js} +1 -1
- package/web/assets/{assets-api-DOGSXB2A.js → assets-api-ZX3ew8NP.js} +1 -1
- package/web/assets/{board-projects-31Kch8Or.js → board-projects-7fgew4qK.js} +1 -1
- package/web/assets/{bots-store-CgzHr2dN.js → bots-store-BakkfdxA.js} +1 -1
- package/web/assets/{chat-api-DwR_1yAu.js → chat-api-DRk1HYBW.js} +1 -1
- package/web/assets/{client-store-Bv5fkPKC.js → client-store-C9d-4zaw.js} +1 -1
- package/web/assets/{command-DQJks9Cg.js → command-C1iIZLBg.js} +1 -1
- package/web/assets/{config-search-1R0m2Dxn.js → config-search-BwTOSp7w.js} +1 -1
- package/web/assets/{desktop-hosts-DMZi66Qp.js → desktop-hosts-BQpofR4x.js} +1 -1
- package/web/assets/{dialog-C6pJ93kY.js → dialog-BokgY2lK.js} +1 -1
- package/web/assets/{event-stream-DujJnWl2.js → event-stream-w-KcgLqy.js} +1 -1
- package/web/assets/{events-BrkEbuk_.js → events-DkkGxATR.js} +1 -1
- package/web/assets/{folder-paths-C8UCsQpi.js → folder-paths-nGHHc6li.js} +1 -1
- package/web/assets/{hosts-DCtZi0Vu.js → hosts-DKIfcYBZ.js} +1 -1
- package/web/assets/{http-Da7z8Zhw.js → http-9v-LnE5x.js} +1 -1
- package/web/assets/{http-response-DHqWBecB.js → http-response-DkUhGWkC.js} +1 -1
- package/web/assets/{i18n-CYOV8NO5.js → i18n-DwWLj5fa.js} +1 -1
- package/web/assets/index-DOsrWaMc.css +2 -0
- package/web/assets/{index-B446sLQy.js → index-DOv7xFwV.js} +2 -2
- package/web/assets/{machine-messages-P6rRT5_Y.js → machine-messages-B5ms0mPd.js} +1 -1
- package/web/assets/{machines-api-Cww34Att.js → machines-api-O06vkXBt.js} +1 -1
- package/web/assets/{memory-api-Bl58uVxS.js → memory-api-Bb1TcNUv.js} +1 -1
- package/web/assets/{mount-app-Dz4ohBAB.js → mount-app-MpOpK-lX.js} +3 -3
- package/web/assets/{permission-rules-api-DKvt9Ijn.js → permission-rules-api-CrWUDTm4.js} +1 -1
- package/web/assets/{pick-system-directory-BRdpqAVu.js → pick-system-directory-DM8TTiur.js} +1 -1
- package/web/assets/{placements-DueXe1Zp.js → placements-Crw6KKZv.js} +2 -2
- package/web/assets/{popover-Bz5EGqVg.js → popover-BL8OTqgj.js} +1 -1
- package/web/assets/{public-WgIAq7m6.js → public-B3SnUlET.js} +1 -1
- package/web/assets/{public-bzVRS_Ps.js → public-B3_chwnY.js} +2 -2
- package/web/assets/public-BreU1CGn.js +9 -0
- package/web/assets/{public-C_3jqJ-h.js → public-CuiN0QDk.js} +2 -2
- package/web/assets/{public-components-CNnORHGF.js → public-components-9_uBKNP6.js} +1 -1
- package/web/assets/public-diff-BDIjPUsI.js +1 -0
- package/web/assets/public-events-BzPfNLlE.js +1 -0
- package/web/assets/{public-flags-ItOVvu41.js → public-flags-DTUvSTHx.js} +1 -1
- package/web/assets/{public-folder-dialog-CooqqcGn.js → public-folder-dialog-CUSNnRpf.js} +1 -1
- package/web/assets/{public-greeting-C9UC30cx.js → public-greeting-CafD21gA.js} +1 -1
- package/web/assets/{public-session-Cb2rGpEN.js → public-session-_pn-KOSb.js} +1 -1
- package/web/assets/{public-sidebar-DT8uieIs.js → public-sidebar-BJv_YzQa.js} +1 -1
- package/web/assets/{runtime-capabilities-store-1qxTCxHV.js → runtime-capabilities-store-C9rMp9Rl.js} +1 -1
- package/web/assets/{safe-mode-instance-DlkQOfml.js → safe-mode-instance-rlw24j9k.js} +1 -1
- package/web/assets/safe-mode-sentinel-D_nToF0q.js +1 -0
- package/web/assets/{session-change-summary-api-5OOAmNzo.js → session-change-summary-api-56l8yH9F.js} +1 -1
- package/web/assets/{session-home-fCQ4eKhT.js → session-home-D124ua9H.js} +1 -1
- package/web/assets/{session-inspector-store-Dk8BXrxC.js → session-inspector-store-DEkETXO9.js} +1 -1
- package/web/assets/{session-questions-COno7uhe.js → session-questions-T27yIHtt.js} +1 -1
- package/web/assets/{session-scope-B13jJaQq.js → session-scope-zQ_17RIF.js} +1 -1
- package/web/assets/{session-tree-actions-CS9J4Eer.js → session-tree-actions-ChzgJEea.js} +1 -1
- package/web/assets/{session-tree-summary-_F4a4OX7.js → session-tree-summary-BKDd_JYM.js} +1 -1
- package/web/assets/{session-web-preview-NBd9P7Kp.js → session-web-preview-BVkOy4vs.js} +1 -1
- package/web/assets/{shortcuts-CctXrljf.js → shortcuts-Bv8JhC38.js} +1 -1
- package/web/assets/{side-chat-context-oyi3ytlS.js → side-chat-context-D5EIphVm.js} +4 -4
- package/web/assets/{sidebar-B1PDwCql.js → sidebar-SxdQe8CQ.js} +1 -1
- package/web/assets/{sidebar-store-D3ZnQB3e.js → sidebar-store-DyY6rJW1.js} +1 -1
- package/web/assets/{speech-session-BwcPoFaK.js → speech-session-BKR1toDn.js} +1 -1
- package/web/assets/{startup-queries-CNUOrW7A.js → startup-queries-BlzaybQG.js} +1 -1
- package/web/assets/{use-i18n-CbqEZb3r.js → use-i18n-DIPRXE6G.js} +1 -1
- package/web/assets/{use-open-bot-Dv66YK0n.js → use-open-bot-B_ehsO-d.js} +1 -1
- package/web/assets/{use-studio-actions-GplOMwz9.js → use-studio-actions-oQQ3gp-a.js} +1 -1
- package/web/assets/{useCatalogProjects-CtZwq4VJ.js → useCatalogProjects-5i9tmSU1.js} +1 -1
- package/web/assets/{useMachines-DHK5FVXC.js → useMachines-Cxl0lZtt.js} +1 -1
- package/web/assets/{useNewProjectPicker-Dum2z5eb.js → useNewProjectPicker-Be_hs0bk.js} +2 -2
- package/web/assets/{useNow-Cm86munt.js → useNow-DDBbGE9C.js} +1 -1
- package/web/assets/{usePhoneShell-BDH8-EY7.js → usePhoneShell-BiMVOvVC.js} +1 -1
- package/web/assets/{useSessionListQuery-D8hWYbAp.js → useSessionListQuery-whsrfhx8.js} +1 -1
- package/web/assets/{useSessionRowActions-D3-sAs-h.js → useSessionRowActions-44XcAIma.js} +1 -1
- package/web/assets/{useSidebarModel-CR0sLO4j.js → useSidebarModel-DXUg2oqd.js} +1 -1
- package/web/assets/{workspace-folders-DWoX16M_.js → workspace-folders-CnuvMXgu.js} +1 -1
- package/web/assets/{workspace-order-store-CI03povy.js → workspace-order-store-1MaQWfWN.js} +1 -1
- package/web/index.html +2 -2
- package/web/assets/BotAvatar-DfRTuJjC.js +0 -1
- package/web/assets/index-Fb-GT4ka.css +0 -2
- package/web/assets/public-CL4QGDNW.js +0 -9
- package/web/assets/public-diff-BiBx9iwa.js +0 -1
- package/web/assets/public-events-CUnBp7HK.js +0 -1
- package/web/assets/safe-mode-sentinel-MZiIHVDW.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{S as r}from"./events-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./vendor-react-DwNgTV1j.js";import{S as r}from"./events-DkkGxATR.js";import"./public-events-BzPfNLlE.js";import{t as i}from"./terminal-context-aIsIJPn8.js";var a=e(t(),1),o=2097152,s=524288;function c(){let e=new TextDecoder,t=`text`;return n=>{let r=``;for(let i of e.decode(n,{stream:!0})){let e=i.codePointAt(0);t===`text`?e===27?t=`escape`:e===155?t=`csi`:e===157?t=`osc`:(e===9||e===10||e===13||e>=32&&e!==127)&&(r+=i):t===`escape`?t=i===`[`?`csi`:i===`]`?`osc`:`()*+`.includes(i)?`charset`:`text`:t===`csi`?e>=64&&e<=126&&(t=`text`):t===`charset`?t=`text`:t===`osc`?e===7?t=`text`:e===27&&(t=`osc-escape`):t===`osc-escape`&&(t=i===`\\`?`text`:e===27?`osc-escape`:`osc`)}return r}}function l(e){let t=new Map,n=new Map,r=new Set,i=new Map,a=new Map,l=new Set,u=new Set,d=new Map,f=!1,p,m=e=>(d.has(e)||d.set(e,[...t.values()].filter(t=>e===void 0||t.sessionId===e)),d.get(e)),h=()=>{for(let[e,n]of d){let r=[...t.values()].filter(t=>e===void 0||t.sessionId===e);(r.length!==n.length||r.some((e,t)=>e!==n[t]))&&d.set(e,r)}for(let e of l)e()},g=(e,n)=>{let r=t.get(e);r&&(t.set(e,{...r,...n}),h())},_=(e,i)=>{if(!(f||i.terminalId!==e||!r.has(e))){if(i.type===`output`){if(!Array.isArray(i.data)||i.data.some(e=>!Number.isInteger(e)||e<0||e>255))return;let r=n.get(e),a=Uint8Array.from(i.data.slice(-2097152));r.chunks.push({sequence:++r.sequence,data:a}),r.bytes+=a.length;let c=t.get(e).truncated||i.data.length>o;for(;r.bytes>o&&r.chunks.length>1;)r.bytes-=r.chunks.shift().data.length,c=!0;r.text+=r.decoder(a),r.text.length>s&&(r.text=r.text.slice(-524288).replace(/^[\uDC00-\uDFFF]/,``),c=!0),g(e,{output:r.text,truncated:c})}else i.type===`exit`?(r.delete(e),g(e,{status:`exited`,exitCode:i.code,error:``})):i.type===`error`&&g(e,{status:`error`,error:i.message});for(let e of u)e(i)}},v=async(a,o,s)=>{if(f)throw Error(`Terminal registry disposed`);let l=`terminal-${crypto.randomUUID()}`;t.set(l,{id:l,sessionId:a,cwd:o,profileId:s,orphaned:!1,status:`starting`,exitCode:null,error:``,output:``,truncated:!1}),n.set(l,{chunks:[],bytes:0,sequence:0,decoder:c(),text:``}),r.add(l),h();let u=(async()=>{try{let n=await e.terminalCreate({terminalId:l,profileId:s,cwd:o,cols:100,rows:24},e=>_(l,e));if(n.terminalId!==l)throw Error(`Terminal creation returned a different identity`);return g(l,{cwd:n.cwd,profileId:n.profileId,...!f&&t.get(l)?.status===`starting`?{status:`running`}:{}}),l}catch(e){throw g(l,{status:`error`,error:e instanceof Error?e.message:String(e)}),e}finally{i.delete(l)}})();return i.set(l,u),u},y=t=>{let n=a.get(t);if(n)return n;if(!r.has(t))return Promise.resolve();g(t,{status:`stopping`,error:``});let o=(async()=>{try{let n=i.get(t);if(n&&await n.catch(()=>void 0),!r.has(t))return;await e.terminalClose(t),r.delete(t),g(t,{status:`exited`,exitCode:null,error:``})}catch(e){throw g(t,{status:`error`,error:e instanceof Error?e.message:String(e)}),e}finally{a.delete(t)}})();return a.set(t,o),o};return{create:v,stop:y,snapshot:m,subscribe(e){return l.add(e),()=>{l.delete(e)}},subscribeEvents(e){return u.add(e),()=>{u.delete(e)}},outputChunks(e){return n.get(e)?.chunks||[]},async write(t,n){if(f||!r.has(t))throw Error(`Terminal is not running`);await e.terminalWrite(t,n)},async resize(t,n,i){f||!r.has(t)||!Number.isInteger(n)||!Number.isInteger(i)||n<1||i<1||await e.terminalResize(t,n,i)},orphan(e){let n=new Set(e);for(let e of t.values())n.has(e.sessionId)&&!e.orphaned&&t.set(e.id,{...e,orphaned:!0});h()},dispose(){return p||(f=!0,p=(async()=>{let e=await Promise.allSettled([...r].map(y));l.clear(),u.clear();let t=e.find(e=>e.status===`rejected`);if(t?.status===`rejected`)throw t.reason})(),p)}}}var u=n();function d({bridge:e,children:t}){let[n,o]=(0,a.useState)(null);return(0,a.useEffect)(()=>{if(!e?.terminalCreate||!e.terminalWrite||!e.terminalResize||!e.terminalClose||!e.terminalProfiles){o(null);return}let t=l({terminalCreate:e.terminalCreate,terminalWrite:e.terminalWrite,terminalResize:e.terminalResize,terminalClose:e.terminalClose}),n=new Map,i,a=e.terminalProfiles;o({registry:t,profiles:()=>i||=a().catch(e=>{throw i=void 0,e}),renderer:(e,t)=>(n.has(e)||n.set(e,t()),n.get(e))});let s=r(window,({deletedIds:e})=>t.orphan(e)),c=()=>{for(let e of n.values())e.dispose();n.clear(),t.dispose().catch(()=>{})};return window.addEventListener(`pagehide`,c),()=>{s(),window.removeEventListener(`pagehide`,c),c()}},[e]),(0,u.jsx)(i.Provider,{value:n,children:t})}export{d as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/public-folder-dialog-
|
|
2
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{h as t,u as n}from"./vendor-router-CSN_DGvx.js";import{i as r,r as i}from"./vendor-react-DwNgTV1j.js";import{t as a}from"./use-i18n-CbqEZb3r.js";import{t as o}from"./useQuery-DfOU-27z.js";import{a as s,i as c,o as l}from"./startup-queries-CNUOrW7A.js";import{a as u}from"./http-response-DHqWBecB.js";import{n as d}from"./http-Da7z8Zhw.js";import{t as f}from"./runtime-capabilities-store-1qxTCxHV.js";import{t as ee}from"./chevron-down-CxtxIjiP.js";import{o as te}from"./FocusRuntimeControls-eXxgJIFt.js";import{t as p}from"./folder-open-FIShC5Qk.js";import{t as m}from"./folder-plus-OPHZsJho.js";import{t as ne}from"./folder-DPM8D8cf.js";import{n as re,t as h}from"./useMachines-DHK5FVXC.js";import{t as g}from"./plus-fQbSqB1n.js";import{t as _}from"./server-BgNvmqwJ.js";import{a as v,c as y,i as b,o as x,p as ie,r as S,s as C,t as ae}from"./dropdown-menu-Ds0gD8S8.js";import{t as w}from"./utils-C8uzG5AZ.js";import{u as T}from"./events-BrkEbuk_.js";import{t as E}from"./chat-api-DwR_1yAu.js";import{_ as D,d as O,l as k,t as A,u as j,v as M,x as N,y as P}from"./useSessionListQuery-D8hWYbAp.js";import"./useNow-Cm86munt.js";import{a as F,i as I,n as L,t as oe}from"./useNewProjectPicker-Dum2z5eb.js";import{a as se}from"./card-presentation-zU6WKfgu.js";import"./useSidebarModel-CR0sLO4j.js";import{o as ce}from"./format-DMJQzoZ7.js";import{n as R,t as z}from"./workspace-order-store-CI03povy.js";import{r as B,t as V}from"./board-projects-31Kch8Or.js";var H=e(r(),1),U=class extends Error{stage;cause;sessionId;code=`board_launch_failed`;constructor(e,t,n=``){super(t instanceof Error?t.message:String(t||`launch failed`)),this.stage=e,this.cause=t,this.sessionId=n}},W=1e5,G=5e3;function K(e){if(!e||typeof e!=`object`)return!1;let t=e;return Array.isArray(t.messages)&&t.messages.length===0&&t.streaming===!1&&t.configurationBusy!==!0&&(t.queuedInputs===void 0||Array.isArray(t.queuedInputs)&&t.queuedInputs.length===0)}function q(e){return e instanceof u?`${e.kind||`error`}:${e.status??`-`}`:`error`}async function J(e){let t=`/api/sessions/${encodeURIComponent(e)}`;try{if(!K(await E.getLiveSession(e,{timeout:G})))return!1;await d(t,{method:`DELETE`,timeout:G})}catch(e){return console.warn(`[board] 派发失败后未能清理空会话(${q(e)})`),!1}return s.setQueryData(k,t=>t&&{...t,sessions:t.sessions.filter(t=>t.id!==e)}),T({deletedIds:[e]}),!0}function Y(e){s.setQueryData(k,t=>t&&!t.sessions.some(t=>t.id===e.id)?{...t,sessions:[e,...t.sessions]}:t),c(`sessions`)}function le(e){let t=e.indexOf(`/`);return t>0?{provider:e.slice(0,t),modelId:e.slice(t+1)}:null}async function ue(e,t,n){let r=le(n.model);r&&n.model!==t.model&&await E.updateModel(e,r.provider,r.modelId),n.thinkingLevel&&n.thinkingLevel!==t.thinkingLevel&&await E.setThinkingLevel(e,n.thinkingLevel),n.executionMode&&n.executionMode!==t.executionMode&&await E.updateExecutionMode(e,n.executionMode),n.runMode!==`plan`&&n.runMode!==t.runMode&&await E.updateRunMode(e,n.runMode)}async function de(e){if(!e.prompt.trim().slice(0,W))throw new U(`create`,Error(`empty prompt`));let t;try{t=await E.createSession(``,e.cwd,{projectless:e.projectless===!0,machine:e.machine??null})}catch(e){throw new U(`create`,e)}let n=t.id;try{await ue(n,t,e)}catch(e){throw await J(n),new U(`configure`,e,n)}return{session:t}}var fe=/^\/[a-z][a-z0-9:-]{0,63}$/;async function pe(e){let{sessionId:t}=e,n=e.prompt.trim().slice(0,W);if(!t||!n)throw new U(`send`,Error(`empty prompt`),t);let r=e.commandWhenEmpty?.trim()??``;if(r&&!fe.test(r))throw new U(`send`,Error(`invalid command`),t);let i;try{i=await E.getLiveSession(t)}catch(e){throw new U(`send`,e,t)}let a=i&&typeof i==`object`?i:{},o=Array.isArray(a.messages)&&a.messages.length===0&&r?`${r} ${n}`:n,l=async()=>{try{await E.queueInput(t,o,[],`followUp`)}catch(e){throw new U(`send`,e,t)}return{sessionId:t,queued:!0}};if(a.streaming===!0)return l();e.created?.id===t?Y({...e.created,firstMessage:n,messageCount:1}):s.getQueryData(k)?.sessions.some(e=>e.id===t)||c(`sessions`);let u=O(t,{streaming:!0});try{await N(t,`launch`,(e,n)=>E.openStream({sessionId:t,message:o,attachments:[],goalMode:!1,teamMode:!1},e,{signal:n}))}catch(e){if(D(t,u),e instanceof j)return l();throw P().catch(()=>void 0),new U(`send`,e,t)}return M(t,e=>!!e).catch(()=>void 0).finally(()=>D(t,u)),{sessionId:t,queued:!1}}function X(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function Z(e){return typeof e==`string`?e:``}function me(e){return(Array.isArray(X(e).providers)?X(e).providers:[]).flatMap(e=>{let t=X(e),n=Z(t.id);return!n||t.configured!==!0||t.enabled===!1?[]:(Array.isArray(t.models)?t.models:[]).flatMap(e=>{let r=X(e),i=Z(r.id);return!i||r.kind!==`chat`?[]:[{key:`${n}/${i}`,label:Z(r.name)||i,providerName:Z(t.name)||n,thinkingLevels:Array.isArray(r.thinkingLevels)?r.thinkingLevels.filter(e=>typeof e==`string`):[]}]})})}function he(){let e=o(l(`config`)),t=A(),n=z(e=>e.names),r=R(e=>e.projects),i=f(e=>e.capabilities.features),a=(0,H.useMemo)(()=>me(e.data),[e.data]),s=e.data?.provider&&e.data?.model?`${e.data.provider}/${e.data.model}`:``,c=t.data?.sessions,u=(0,H.useMemo)(()=>B(c??[],r,n),[c,n,r]),d=(0,H.useMemo)(()=>V(c??[],u),[c,u]);return{models:a,defaultModel:s,defaultThinkingLevel:Z(e.data?.thinkingLevel)||`medium`,projects:u,defaultCwd:d,goalsAvailable:i.goals!==!1,teamAvailable:i.goals!==!1&&i.multiAgent!==!1,loading:e.isPending,error:e.error??null}}var Q=i(),ge=(0,H.lazy)(()=>t(()=>import(`./public-folder-dialog-CooqqcGn.js`).then(e=>({default:e.MachineFolderDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]))),$=`\0no-project`;function _e(e){return e===`full-access`||L.includes(e)}function ve(e){return e===`plan`||e===`goal`||e===`team`}function ye({onError:e}){let{t,language:r}=a(),i=n(),o=he(),s=h(),[c,l]=(0,H.useState)(null),u=I(),[d,T]=(0,H.useState)(!1),E=(0,H.useRef)(null),D=oe({onProjectChosen:()=>void 0,onError:e}),O=f(e=>e.capabilities.features.workspaceFolders),k=o.models.some(e=>e.key===u.model),A=k?u.model:o.defaultModel,j=o.models.find(e=>e.key===A)?.thinkingLevels??[],M=j.includes(u.thinkingLevel)?u.thinkingLevel:``,N=M||(j.includes(o.defaultThinkingLevel)?o.defaultThinkingLevel:``),P=d?`full-access`:u.executionMode||`approval-required`,L=u.runMode===`team`&&!o.teamAvailable||u.runMode===`goal`&&!o.goalsAvailable?`plan`:u.runMode,R=(0,H.useMemo)(()=>{if(!u.cwd||o.projects.some(e=>e.cwd===u.cwd))return o.projects;let e=u.cwd.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||u.cwd;return[{key:u.cwd,cwd:u.cwd,label:e},...o.projects]},[u.cwd,o.projects]),z=(0,H.useMemo)(()=>se(R),[R]),B=u.projectless,V=!!u.machineId,U=s.machines.find(e=>e.id===u.machineId),{rememberLaunch:W}=u;(0,H.useEffect)(()=>{V&&s.loaded&&!U&&W({machineId:``,machineCwd:``})},[U,V,s.loaded,W]);let G=V||B?``:u.cwd||o.defaultCwd||R[0]?.cwd||``,K=V||B?void 0:R.find(e=>e.cwd===G),q=`${U?.name??``}:${ce(u.machineCwd,r)}`,J=V?q:K?.label||t(B?`board:launch.noProject`:`board:launch.defaultProject`),Y=t(`board:launch.projectLabel`,{project:K?z.get(K.key)?`${K.label} (${z.get(K.key)})`:K.label:J});return{cwd:G,model:A,thinkingLevel:N,availableThinkingLevels:j,executionMode:P,runMode:L,onModelChange:e=>u.rememberLaunch({model:e,thinkingLevel:``}),onThinkingLevelChange:e=>u.rememberLaunch({thinkingLevel:e}),onExecutionModeChange:e=>_e(e)?(T(e===`full-access`),e!==`full-access`&&u.rememberLaunch({executionMode:e}),!0):!1,onRunModeChange:e=>ve(e)?(u.rememberLaunch({runMode:e}),!0):!1,renderProjectControl:e=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(ae,{children:[(0,Q.jsx)(ie,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:e===`header`?`relative inline-flex h-6 max-w-full min-w-0 cursor-pointer items-center gap-1 rounded-full px-2 text-xs leading-4 text-content-muted outline-none after:absolute after:-inset-x-1 after:-inset-y-2.5 after:content-[""] focus-visible:outline-2 focus-visible:outline-focus active:bg-surface-hover aria-expanded:bg-surface-hover`:w(te,`max-w-[24ch] max-[650px]:max-w-[14ch]`),title:V?`${U?.name??``}:${u.machineCwd}`:K?.cwd||void 0,"aria-label":Y,"data-new-task-project":V?`machine:${u.machineId}`:B?`none`:G||`default`,children:[V?(0,Q.jsx)(_,{size:e===`header`?12:14,className:`shrink-0`,"aria-hidden":`true`}):(0,Q.jsx)(ne,{size:e===`header`?12:14,className:`shrink-0`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:w(`min-w-0 truncate`,(K?.label||V)&&`font-mono`),children:J}),(0,Q.jsx)(ee,{size:e===`header`?12:14,className:w(`shrink-0 opacity-70`,e===`chip`&&`max-[650px]:hidden`),"aria-hidden":`true`})]})}),(0,Q.jsxs)(S,{align:e===`header`?`center`:`start`,side:e===`header`?`bottom`:`top`,className:`max-h-[min(24rem,var(--radix-dropdown-menu-content-available-height))] w-64 overflow-y-auto`,onCloseAutoFocus:e=>{let t=E.current;t&&(E.current=null,e.preventDefault(),t())},children:[(0,Q.jsxs)(x,{value:V?``:B?$:G,onValueChange:e=>u.rememberLaunch(e===$?{projectless:!0}:{cwd:e}),children:[(0,Q.jsx)(C,{value:$,children:(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:t(`board:launch.noProject`)})}),(0,Q.jsx)(y,{}),(0,Q.jsx)(v,{children:t(`board:launch.projects`)}),R.length===0&&(0,Q.jsx)(C,{value:``,children:t(`board:launch.defaultProject`)}),R.map(e=>(0,Q.jsxs)(C,{value:e.cwd,title:e.cwd,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:e.label}),z.get(e.key)&&(0,Q.jsx)(`span`,{className:`ml-auto min-w-0 truncate pl-2 font-mono text-xs text-content-muted`,children:z.get(e.key)})]},e.key))]}),(0,Q.jsx)(y,{}),(0,Q.jsxs)(b,{disabled:D.picking,"data-launch-new-project":!0,onSelect:()=>E.current=()=>void D.newProject(),children:[(0,Q.jsx)(p,{"aria-hidden":`true`}),t(`board:launch.chooseFolder`)]}),O&&(0,Q.jsxs)(b,{"data-launch-new-folder":!0,onSelect:()=>E.current=()=>D.newFolder(G||o.defaultCwd),children:[(0,Q.jsx)(m,{"aria-hidden":`true`}),t(`board:launch.newFolder`)]}),s.available&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(y,{}),(0,Q.jsx)(v,{children:t(`board:launch.machines`)}),s.machines.map(e=>(0,Q.jsxs)(b,{"data-launch-machine":e.id,onSelect:()=>E.current=()=>l(e),children:[e.kind===`ssh`?(0,Q.jsx)(_,{"aria-hidden":`true`}):(0,Q.jsx)(re,{"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:w(`ml-auto size-2 flex-none rounded-full`,e.online?`bg-success`:`bg-content-faint`)})]},e.id)),(0,Q.jsxs)(b,{"data-launch-add-machine":!0,onSelect:()=>i(`/config/remote-access`),children:[(0,Q.jsx)(g,{"aria-hidden":`true`}),t(`board:launch.addMachine`)]})]})]})]}),(0,Q.jsx)(F,{picker:D.picker,folderDialog:D.folderDialog}),c&&(0,Q.jsx)(H.Suspense,{fallback:null,children:(0,Q.jsx)(ge,{machine:c,initialCwd:c?.id===u.machineId?u.machineCwd:c?.defaultCwd??``,onOpenChange:e=>{e||l(null)},onChosen:(e,t)=>{W({machineId:e.id,machineCwd:t}),l(null)}})})]}),prepare:e=>de({prompt:e,cwd:G,projectless:B,machine:V?{id:u.machineId,cwd:u.machineCwd}:null,model:k?A:``,thinkingLevel:M,executionMode:P,runMode:L}),onSent:()=>{T(!1)}}}export{pe as n,ye as t};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/public-folder-dialog-CUSNnRpf.js","assets/rolldown-runtime-B0Z9INg1.js","assets/vendor-react-DwNgTV1j.js","assets/use-i18n-DIPRXE6G.js","assets/i18n-DwWLj5fa.js","assets/vendor-router-CSN_DGvx.js","assets/index-DOv7xFwV.js","assets/index-DOsrWaMc.css","assets/storage-DtvZ_lEu.js","assets/vendor-state-GkUciC5H.js","assets/server-BgNvmqwJ.js","assets/createLucideIcon-Cd-3GVxJ.js","assets/triangle-alert-CE1q54ci.js","assets/button-CCcCN8tE.js","assets/vendor-ui-DvrYggeS.js","assets/dist-41X0pdUs.js","assets/utils-C8uzG5AZ.js","assets/dialog-BokgY2lK.js","assets/x-07u4-129.js","assets/dist-BHkR6BLP.js","assets/dist-BsRXXcSL.js","assets/es2015-DTZdOI9P.js","assets/input-CPw-zkYh.js","assets/machines-api-O06vkXBt.js","assets/http-response-DkUhGWkC.js","assets/http-9v-LnE5x.js","assets/abort-signal-f4JsiYKX.js","assets/alert-DRIrgNI4.js","assets/field-DoLEb0np.js","assets/label-CVWjEcfV.js","assets/separator-BPh_qxvc.js","assets/machine-messages-B5ms0mPd.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{h as t,u as n}from"./vendor-router-CSN_DGvx.js";import{i as r,r as i}from"./vendor-react-DwNgTV1j.js";import{t as a}from"./use-i18n-DIPRXE6G.js";import{t as o}from"./useQuery-DfOU-27z.js";import{a as s,i as c,o as l}from"./startup-queries-BlzaybQG.js";import{a as u}from"./http-response-DkUhGWkC.js";import{n as d}from"./http-9v-LnE5x.js";import{t as f}from"./runtime-capabilities-store-C9rMp9Rl.js";import{t as ee}from"./chevron-down-CxtxIjiP.js";import{o as te}from"./FocusRuntimeControls-1e47Xb4z.js";import{t as p}from"./folder-open-FIShC5Qk.js";import{t as m}from"./folder-plus-OPHZsJho.js";import{t as ne}from"./folder-DPM8D8cf.js";import{n as re,t as h}from"./useMachines-Cxl0lZtt.js";import{t as g}from"./plus-fQbSqB1n.js";import{t as _}from"./server-BgNvmqwJ.js";import{a as v,c as y,i as b,o as x,p as ie,r as S,s as C,t as ae}from"./dropdown-menu-Ds0gD8S8.js";import{t as w}from"./utils-C8uzG5AZ.js";import{u as T}from"./events-DkkGxATR.js";import{t as E}from"./chat-api-DRk1HYBW.js";import{_ as D,d as O,l as k,t as A,u as j,v as M,x as N,y as P}from"./useSessionListQuery-whsrfhx8.js";import"./useNow-DDBbGE9C.js";import{a as F,i as I,n as L,t as oe}from"./useNewProjectPicker-Be_hs0bk.js";import{a as se}from"./card-presentation-zU6WKfgu.js";import"./useSidebarModel-DXUg2oqd.js";import{o as ce}from"./format-DMJQzoZ7.js";import{n as R,t as z}from"./workspace-order-store-1MaQWfWN.js";import{r as B,t as V}from"./board-projects-7fgew4qK.js";var H=e(r(),1),U=class extends Error{stage;cause;sessionId;code=`board_launch_failed`;constructor(e,t,n=``){super(t instanceof Error?t.message:String(t||`launch failed`)),this.stage=e,this.cause=t,this.sessionId=n}},W=1e5,G=5e3;function K(e){if(!e||typeof e!=`object`)return!1;let t=e;return Array.isArray(t.messages)&&t.messages.length===0&&t.streaming===!1&&t.configurationBusy!==!0&&(t.queuedInputs===void 0||Array.isArray(t.queuedInputs)&&t.queuedInputs.length===0)}function q(e){return e instanceof u?`${e.kind||`error`}:${e.status??`-`}`:`error`}async function J(e){let t=`/api/sessions/${encodeURIComponent(e)}`;try{if(!K(await E.getLiveSession(e,{timeout:G})))return!1;await d(t,{method:`DELETE`,timeout:G})}catch(e){return console.warn(`[board] 派发失败后未能清理空会话(${q(e)})`),!1}return s.setQueryData(k,t=>t&&{...t,sessions:t.sessions.filter(t=>t.id!==e)}),T({deletedIds:[e]}),!0}function Y(e){s.setQueryData(k,t=>t&&!t.sessions.some(t=>t.id===e.id)?{...t,sessions:[e,...t.sessions]}:t),c(`sessions`)}function le(e){let t=e.indexOf(`/`);return t>0?{provider:e.slice(0,t),modelId:e.slice(t+1)}:null}async function ue(e,t,n){let r=le(n.model);r&&n.model!==t.model&&await E.updateModel(e,r.provider,r.modelId),n.thinkingLevel&&n.thinkingLevel!==t.thinkingLevel&&await E.setThinkingLevel(e,n.thinkingLevel),n.executionMode&&n.executionMode!==t.executionMode&&await E.updateExecutionMode(e,n.executionMode),n.runMode!==`plan`&&n.runMode!==t.runMode&&await E.updateRunMode(e,n.runMode)}async function de(e){if(!e.prompt.trim().slice(0,W))throw new U(`create`,Error(`empty prompt`));let t;try{t=await E.createSession(``,e.cwd,{projectless:e.projectless===!0,machine:e.machine??null})}catch(e){throw new U(`create`,e)}let n=t.id;try{await ue(n,t,e)}catch(e){throw await J(n),new U(`configure`,e,n)}return{session:t}}var fe=/^\/[a-z][a-z0-9:-]{0,63}$/;async function pe(e){let{sessionId:t}=e,n=e.prompt.trim().slice(0,W);if(!t||!n)throw new U(`send`,Error(`empty prompt`),t);let r=e.commandWhenEmpty?.trim()??``;if(r&&!fe.test(r))throw new U(`send`,Error(`invalid command`),t);let i;try{i=await E.getLiveSession(t)}catch(e){throw new U(`send`,e,t)}let a=i&&typeof i==`object`?i:{},o=Array.isArray(a.messages)&&a.messages.length===0&&r?`${r} ${n}`:n,l=async()=>{try{await E.queueInput(t,o,[],`followUp`)}catch(e){throw new U(`send`,e,t)}return{sessionId:t,queued:!0}};if(a.streaming===!0)return l();e.created?.id===t?Y({...e.created,firstMessage:n,messageCount:1}):s.getQueryData(k)?.sessions.some(e=>e.id===t)||c(`sessions`);let u=O(t,{streaming:!0});try{await N(t,`launch`,(e,n)=>E.openStream({sessionId:t,message:o,attachments:[],goalMode:!1,teamMode:!1},e,{signal:n}))}catch(e){if(D(t,u),e instanceof j)return l();throw P().catch(()=>void 0),new U(`send`,e,t)}return M(t,e=>!!e).catch(()=>void 0).finally(()=>D(t,u)),{sessionId:t,queued:!1}}function X(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function Z(e){return typeof e==`string`?e:``}function me(e){return(Array.isArray(X(e).providers)?X(e).providers:[]).flatMap(e=>{let t=X(e),n=Z(t.id);return!n||t.configured!==!0||t.enabled===!1?[]:(Array.isArray(t.models)?t.models:[]).flatMap(e=>{let r=X(e),i=Z(r.id);return!i||r.kind!==`chat`?[]:[{key:`${n}/${i}`,label:Z(r.name)||i,providerName:Z(t.name)||n,thinkingLevels:Array.isArray(r.thinkingLevels)?r.thinkingLevels.filter(e=>typeof e==`string`):[]}]})})}function he(){let e=o(l(`config`)),t=A(),n=z(e=>e.names),r=R(e=>e.projects),i=f(e=>e.capabilities.features),a=(0,H.useMemo)(()=>me(e.data),[e.data]),s=e.data?.provider&&e.data?.model?`${e.data.provider}/${e.data.model}`:``,c=t.data?.sessions,u=(0,H.useMemo)(()=>B(c??[],r,n),[c,n,r]),d=(0,H.useMemo)(()=>V(c??[],u),[c,u]);return{models:a,defaultModel:s,defaultThinkingLevel:Z(e.data?.thinkingLevel)||`medium`,projects:u,defaultCwd:d,goalsAvailable:i.goals!==!1,teamAvailable:i.goals!==!1&&i.multiAgent!==!1,loading:e.isPending,error:e.error??null}}var Q=i(),ge=(0,H.lazy)(()=>t(()=>import(`./public-folder-dialog-CUSNnRpf.js`).then(e=>({default:e.MachineFolderDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]))),$=`\0no-project`;function _e(e){return e===`full-access`||L.includes(e)}function ve(e){return e===`plan`||e===`goal`||e===`team`}function ye({onError:e}){let{t,language:r}=a(),i=n(),o=he(),s=h(),[c,l]=(0,H.useState)(null),u=I(),[d,T]=(0,H.useState)(!1),E=(0,H.useRef)(null),D=oe({onProjectChosen:()=>void 0,onError:e}),O=f(e=>e.capabilities.features.workspaceFolders),k=o.models.some(e=>e.key===u.model),A=k?u.model:o.defaultModel,j=o.models.find(e=>e.key===A)?.thinkingLevels??[],M=j.includes(u.thinkingLevel)?u.thinkingLevel:``,N=M||(j.includes(o.defaultThinkingLevel)?o.defaultThinkingLevel:``),P=d?`full-access`:u.executionMode||`approval-required`,L=u.runMode===`team`&&!o.teamAvailable||u.runMode===`goal`&&!o.goalsAvailable?`plan`:u.runMode,R=(0,H.useMemo)(()=>{if(!u.cwd||o.projects.some(e=>e.cwd===u.cwd))return o.projects;let e=u.cwd.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||u.cwd;return[{key:u.cwd,cwd:u.cwd,label:e},...o.projects]},[u.cwd,o.projects]),z=(0,H.useMemo)(()=>se(R),[R]),B=u.projectless,V=!!u.machineId,U=s.machines.find(e=>e.id===u.machineId),{rememberLaunch:W}=u;(0,H.useEffect)(()=>{V&&s.loaded&&!U&&W({machineId:``,machineCwd:``})},[U,V,s.loaded,W]);let G=V||B?``:u.cwd||o.defaultCwd||R[0]?.cwd||``,K=V||B?void 0:R.find(e=>e.cwd===G),q=`${U?.name??``}:${ce(u.machineCwd,r)}`,J=V?q:K?.label||t(B?`board:launch.noProject`:`board:launch.defaultProject`),Y=t(`board:launch.projectLabel`,{project:K?z.get(K.key)?`${K.label} (${z.get(K.key)})`:K.label:J});return{cwd:G,model:A,thinkingLevel:N,availableThinkingLevels:j,executionMode:P,runMode:L,onModelChange:e=>u.rememberLaunch({model:e,thinkingLevel:``}),onThinkingLevelChange:e=>u.rememberLaunch({thinkingLevel:e}),onExecutionModeChange:e=>_e(e)?(T(e===`full-access`),e!==`full-access`&&u.rememberLaunch({executionMode:e}),!0):!1,onRunModeChange:e=>ve(e)?(u.rememberLaunch({runMode:e}),!0):!1,renderProjectControl:e=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(ae,{children:[(0,Q.jsx)(ie,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:e===`header`?`relative inline-flex h-6 max-w-full min-w-0 cursor-pointer items-center gap-1 rounded-full px-2 text-xs leading-4 text-content-muted outline-none after:absolute after:-inset-x-1 after:-inset-y-2.5 after:content-[""] focus-visible:outline-2 focus-visible:outline-focus active:bg-surface-hover aria-expanded:bg-surface-hover`:w(te,`max-w-[24ch] max-[650px]:max-w-[14ch]`),title:V?`${U?.name??``}:${u.machineCwd}`:K?.cwd||void 0,"aria-label":Y,"data-new-task-project":V?`machine:${u.machineId}`:B?`none`:G||`default`,children:[V?(0,Q.jsx)(_,{size:e===`header`?12:14,className:`shrink-0`,"aria-hidden":`true`}):(0,Q.jsx)(ne,{size:e===`header`?12:14,className:`shrink-0`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:w(`min-w-0 truncate`,(K?.label||V)&&`font-mono`),children:J}),(0,Q.jsx)(ee,{size:e===`header`?12:14,className:w(`shrink-0 opacity-70`,e===`chip`&&`max-[650px]:hidden`),"aria-hidden":`true`})]})}),(0,Q.jsxs)(S,{align:e===`header`?`center`:`start`,side:e===`header`?`bottom`:`top`,className:`max-h-[min(24rem,var(--radix-dropdown-menu-content-available-height))] w-64 overflow-y-auto`,onCloseAutoFocus:e=>{let t=E.current;t&&(E.current=null,e.preventDefault(),t())},children:[(0,Q.jsxs)(x,{value:V?``:B?$:G,onValueChange:e=>u.rememberLaunch(e===$?{projectless:!0}:{cwd:e}),children:[(0,Q.jsx)(C,{value:$,children:(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:t(`board:launch.noProject`)})}),(0,Q.jsx)(y,{}),(0,Q.jsx)(v,{children:t(`board:launch.projects`)}),R.length===0&&(0,Q.jsx)(C,{value:``,children:t(`board:launch.defaultProject`)}),R.map(e=>(0,Q.jsxs)(C,{value:e.cwd,title:e.cwd,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:e.label}),z.get(e.key)&&(0,Q.jsx)(`span`,{className:`ml-auto min-w-0 truncate pl-2 font-mono text-xs text-content-muted`,children:z.get(e.key)})]},e.key))]}),(0,Q.jsx)(y,{}),(0,Q.jsxs)(b,{disabled:D.picking,"data-launch-new-project":!0,onSelect:()=>E.current=()=>void D.newProject(),children:[(0,Q.jsx)(p,{"aria-hidden":`true`}),t(`board:launch.chooseFolder`)]}),O&&(0,Q.jsxs)(b,{"data-launch-new-folder":!0,onSelect:()=>E.current=()=>D.newFolder(G||o.defaultCwd),children:[(0,Q.jsx)(m,{"aria-hidden":`true`}),t(`board:launch.newFolder`)]}),s.available&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(y,{}),(0,Q.jsx)(v,{children:t(`board:launch.machines`)}),s.machines.map(e=>(0,Q.jsxs)(b,{"data-launch-machine":e.id,onSelect:()=>E.current=()=>l(e),children:[e.kind===`ssh`?(0,Q.jsx)(_,{"aria-hidden":`true`}):(0,Q.jsx)(re,{"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:w(`ml-auto size-2 flex-none rounded-full`,e.online?`bg-success`:`bg-content-faint`)})]},e.id)),(0,Q.jsxs)(b,{"data-launch-add-machine":!0,onSelect:()=>i(`/config/remote-access`),children:[(0,Q.jsx)(g,{"aria-hidden":`true`}),t(`board:launch.addMachine`)]})]})]})]}),(0,Q.jsx)(F,{picker:D.picker,folderDialog:D.folderDialog}),c&&(0,Q.jsx)(H.Suspense,{fallback:null,children:(0,Q.jsx)(ge,{machine:c,initialCwd:c?.id===u.machineId?u.machineCwd:c?.defaultCwd??``,onOpenChange:e=>{e||l(null)},onChosen:(e,t)=>{W({machineId:e.id,machineCwd:t}),l(null)}})})]}),prepare:e=>de({prompt:e,cwd:G,projectless:B,machine:V?{id:u.machineId,cwd:u.machineCwd}:null,model:k?A:``,thinkingLevel:M,executionMode:P,runMode:L}),onSent:()=>{T(!1)}}}export{pe as n,ye as t};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{f as t,m as n,n as r,r as i,u as a}from"./vendor-router-CSN_DGvx.js";import{i as o,r as s}from"./vendor-react-DwNgTV1j.js";import{f as c,h as l,r as u}from"./routes-BYsK6aeM.js";import{t as d}from"./use-i18n-DIPRXE6G.js";import{a as f,t as p}from"./http-response-DkUhGWkC.js";import{n as m}from"./http-9v-LnE5x.js";import{t as h}from"./runtime-capabilities-store-C9rMp9Rl.js";import{t as g}from"./usePhoneShell-BiMVOvVC.js";import{t as _}from"./createLucideIcon-Cd-3GVxJ.js";import{t as v}from"./arrow-down-CDGua-ue.js";import{t as y}from"./arrow-up-DST6-qVQ.js";import{t as b}from"./calendar-clock-VIxTaqqy.js";import{t as x}from"./check-2vYc6QaP.js";import{t as S}from"./chevron-down-CxtxIjiP.js";import{t as C}from"./chevron-left-BAtyp3_6.js";import{t as w}from"./chevron-right-C3t2Rckj.js";import{t as T}from"./copy-DHmIFc52.js";import{t as E}from"./ellipsis-CfGKfbq6.js";import{S as D,b as O,d as ee}from"./FocusRuntimeControls-1e47Xb4z.js";import{t as te}from"./WorkspacePicker-CtkwBoo-.js";import{t as k}from"./folder-open-FIShC5Qk.js";import{n as A}from"./ChatMessage-pqXPc_eb.js";import{t as j}from"./undo-2-ChaURM4t.js";import{t as M}from"./message-circle-D-XrK6Ft.js";import{t as ne}from"./monitor-ORxecA9m.js";import{t as re}from"./panel-right-BSUtqUd8.js";import{t as ie}from"./paperclip-BCXrwYpb.js";import{t as N}from"./pencil-U08v_vV9.js";import{t as ae}from"./pin-CU0FG0lI.js";import{t as oe}from"./plus-fQbSqB1n.js";import{C as se,D as P,E as F,O as I,S as ce,T as L,_ as R,a as le,b as ue,c as de,d as fe,f as z,g as pe,h as me,i as he,m as ge,n as _e,o as ve,p as ye,s as be,t as xe,u as Se,v as Ce,w as we,x as Te,y as Ee}from"./use-open-bot-B_ehsO-d.js";import{t as De}from"./sparkles-S_eeuqn9.js";import{t as Oe}from"./square-bHHVTT3G.js";import{i as ke,r as Ae,t as je}from"./AttachmentTray-BLSQp6M3.js";import{t as Me}from"./trash-2-CNrPOoPR.js";import{t as Ne}from"./users-CCtFZzwl.js";import{t as Pe}from"./x-07u4-129.js";import{a as Fe,c as Ie,i as Le,n as Re,o as ze,r as Be,s as Ve,t as He}from"./alert-dialog-DiUitBB0.js";import{c as Ue,i as B,p as We,r as Ge,t as Ke}from"./dropdown-menu-Ds0gD8S8.js";import{n as qe,r as Je,t as Ye}from"./popover-BL8OTqgj.js";import{t as V}from"./switch-D_G8wFhs.js";import{t as H}from"./segmented-control-xkrEOP_d.js";import{t as U}from"./utils-C8uzG5AZ.js";import{n as W,t as G}from"./button-CCcCN8tE.js";import{n as Xe,o as Ze,r as Qe,t as $e}from"./sheet-BTaIEX4w.js";import{T as et}from"./useSessionListQuery-whsrfhx8.js";import{i as tt,r as nt}from"./room-changes-DMfb5VNn.js";import{a as rt,o as it,t as at}from"./command-C1iIZLBg.js";import{a as ot,i as st,l as ct,o as lt,s as ut,t as dt}from"./dialog-BokgY2lK.js";import{t as K}from"./input-CPw-zkYh.js";import{t as ft}from"./textarea-DmATpOqT.js";import{t as pt}from"./model-display-kDwvtxrW.js";import"./public-B3_chwnY.js";import{t as mt}from"./pick-system-directory-DM8TTiur.js";import{n as q,t as ht}from"./PageState-Cz6vFMXv.js";import{n as gt}from"./field-DoLEb0np.js";import{n as _t,t as vt}from"./assets-api-ZX3ew8NP.js";import{t as yt}from"./MarkdownMessage-Brsfnbe4.js";import{a as bt,o as xt,t as J}from"./BotAvatar-SFQi6bVG.js";import{t as Y}from"./AppSelect-DQYKUW5E.js";import{D as St,E as Ct,M as wt,O as Tt,S as Et,T as Dt,_ as Ot,a as kt,b as At,d as jt,f as Mt,g as Nt,h as Pt,i as Ft,j as It,k as Lt,l as Rt,m as zt,n as X,o as Bt,p as Vt,r as Ht,s as Ut,t as Wt,u as Gt,v as Kt,w as qt,x as Jt,y as Yt}from"./bots-store-BakkfdxA.js";import{t as Xt}from"./public-flags-DTUvSTHx.js";import{n as Zt,t as Z}from"./SettingsRow-CT0AZ7re.js";import{t as Qt}from"./chip-ZhnvFlFg.js";var $t=_(`at-sign`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]),en=_(`circle-dashed`,[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]),tn=_(`corner-up-left`,[[`path`,{d:`M20 20v-7a4 4 0 0 0-4-4H4`,key:`1nkjon`}],[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}]]),nn=_(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),rn=_(`list-tree`,[[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`M3 10a2 2 0 0 0 2 2h3`,key:`1npucw`}],[`path`,{d:`M3 5v12a2 2 0 0 0 2 2h3`,key:`x1gjn2`}]]),an=_(`notebook-pen`,[[`path`,{d:`M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4`,key:`re6nr2`}],[`path`,{d:`M2 6h4`,key:`aawbzj`}],[`path`,{d:`M2 10h4`,key:`l0bgd4`}],[`path`,{d:`M2 14h4`,key:`1gsvsf`}],[`path`,{d:`M2 18h4`,key:`1bu2t1`}],[`path`,{d:`M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`pqwjuv`}]]),Q=e(o(),1),$=s();function on({bot:e,initiallyOpen:t=!1,onDeleted:n,onError:r}){let{t:i}=d(),a=X(e=>e.remove),[o,s]=(0,Q.useState)(t),[c,l]=(0,Q.useState)(!1),u=async()=>{l(!0);try{await jt(e.id),a(e.id),s(!1),n()}catch(e){r(e instanceof Error?e.message:String(e))}finally{l(!1)}};return(0,$.jsxs)(Zt,{title:i(`bots:delete.section`),className:`mt-4`,children:[(0,$.jsx)(Z,{title:i(`bots:delete.title`),description:i(`bots:delete.hint`),control:(0,$.jsxs)(G,{type:`button`,variant:`destructive`,size:`sm`,"data-bot-delete":e.id,onClick:()=>s(!0),children:[(0,$.jsx)(Me,{"aria-hidden":`true`}),i(`bots:delete.action`)]})}),(0,$.jsx)(He,{open:o,onOpenChange:e=>!c&&s(e),children:(0,$.jsxs)(Le,{children:[(0,$.jsxs)(Ve,{children:[(0,$.jsx)(Ie,{children:i(`bots:delete.confirmTitle`,{name:e.name})}),(0,$.jsx)(Fe,{children:i(`bots:delete.confirmDescription`)})]}),(0,$.jsxs)(ze,{children:[(0,$.jsx)(Be,{disabled:c,children:i(`common:ui.cancel`)}),(0,$.jsxs)(Re,{variant:`destructive`,disabled:c,onClick:e=>{e.preventDefault(),u()},children:[c&&(0,$.jsx)(W,{className:`text-current`}),i(`bots:delete.action`)]})]})]})})]})}function sn(e,t){return!t||t.kind===`local`?e(`bots:computer.local`):t.name||e(`bots:computer.unnamed`)}function cn(e,t){return[`npx pisper executor pair --brain ${e.remote.endpoints[0]||t.brain} --fingerprint ${e.remote.fingerprint||t.fingerprint} --code ${e.code} --root ${t.root}`,`npx pisper executor`]}function ln({environment:e,onRemoved:t,onError:n}){let{t:r}=d(),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(!1),c=async()=>{s(!0);try{await qt(e.id),t()}catch(e){n(e instanceof Error?e.message:String(e)),a(!1)}finally{s(!1)}};return(0,$.jsxs)(`li`,{"data-environment":e.id,className:`flex flex-col gap-1 py-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:U(`size-2 flex-none rounded-full`,e.online?`bg-success`:`bg-content-faint`)}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-content`,children:sn(r,e)}),(0,$.jsx)(`span`,{className:`text-xs text-content-muted`,children:e.online?r(`bots:computer.online`):r(`bots:computer.offline`)}),e.kind===`node`&&(i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(G,{size:`sm`,variant:`ghost`,disabled:o,onClick:()=>a(!1),children:r(`bots:computer.cancel`)}),(0,$.jsx)(G,{size:`sm`,variant:`destructive`,disabled:o,onClick:()=>void c(),children:r(`bots:computer.confirmRemove`)})]}):(0,$.jsx)(G,{size:`sm`,variant:`ghost`,onClick:()=>a(!0),children:r(`bots:computer.remove`)}))]}),e.roots.length>0&&(0,$.jsx)(`p`,{className:`truncate pl-4 font-mono text-xs text-content-muted`,children:e.roots.join(` · `)}),e.usedBy.length>0&&(0,$.jsx)(`p`,{className:`pl-4 text-xs text-content-muted`,children:r(`bots:computer.usedBy`,{names:e.usedBy.map(e=>e.name).join(`、`)})})]})}function un({pairing:e,onDone:t}){let{t:n}=d(),r=a(),[i,o]=(0,Q.useState)(!1),s=cn(e,{brain:n(`bots:computer.brainPlaceholder`),fingerprint:`SHA256:…`,root:n(`bots:computer.rootPlaceholder`)}),c=async()=>{try{await navigator.clipboard.writeText(s.join(`
|
|
2
|
+
`)),o(!0)}catch{o(!1)}};return(0,$.jsxs)(`section`,{"aria-label":n(`bots:computer.addTitle`),className:`mt-2 rounded-xl border border-stroke bg-surface-subtle p-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`h4`,{className:`font-semibold text-content`,children:n(`bots:computer.addTitle`)}),(0,$.jsx)(G,{size:`sm`,variant:`ghost`,onClick:t,children:n(`bots:computer.done`)})]}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-content-muted`,children:[n(`bots:computer.code`),` `,(0,$.jsx)(`b`,{"data-pairing-code":!0,className:`font-mono text-content`,children:e.code}),` `,`· `,n(`bots:computer.codeHint`)]}),!e.remote.enabled&&(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 rounded-lg border border-st-attn-border bg-surface-raised px-2.5 py-2 text-xs text-content-secondary`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:n(`bots:computer.remoteOff`)}),(0,$.jsx)(G,{size:`sm`,variant:`outline`,onClick:()=>r(`/config/remote-access`),children:n(`bots:computer.openRemote`)})]}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-content-muted`,children:n(`bots:computer.runThere`)}),(0,$.jsx)(`pre`,{className:`mt-1 max-h-40 overflow-auto rounded-lg bg-surface-raised p-2.5 font-mono text-xs whitespace-pre-wrap break-all text-content-secondary`,children:s.join(`
|
|
3
|
+
`)}),(0,$.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-content-muted`,children:n(`bots:computer.rootHint`)}),(0,$.jsxs)(G,{size:`sm`,variant:`outline`,onClick:()=>void c(),children:[(0,$.jsx)(T,{"aria-hidden":`true`}),n(i?`bots:computer.copied`:`bots:computer.copy`)]})]})]})}function dn({bot:e,environments:t,onEnvironmentsChanged:n,onError:r}){let{t:i}=d(),a=X(e=>e.upsert),[o,s]=(0,Q.useState)(e.workspace.environmentId),[c,l]=(0,Q.useState)(e.workspace.cwd),[u,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{s(e.workspace.environmentId),l(e.workspace.cwd)},[e.id,e.workspace.environmentId,e.workspace.cwd]);let y=t.find(e=>e.id===o),b=o===`local`,x=o!==e.workspace.environmentId||c.trim()!==e.workspace.cwd,S=async t=>{g(!0);try{a(await Ct(e.id,{workspace:{...e.workspace,...t}})),n()}catch(e){r(e instanceof Error?e.message:String(e))}finally{g(!1)}},C=async()=>{if(!u){if(!b){m(!0);return}f(!0);try{let t=await mt(c||e.workspace.cwd,i(`bots:computer.folder`));t.status===`picked`?l(t.path):t.status===`unavailable`&&m(!0)}catch(e){r(e instanceof Error?e.message:String(e))}finally{f(!1)}}},w=async()=>{try{v(await Gt())}catch(e){r(e instanceof Error?e.message:String(e))}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-xs text-content-muted`,children:i(`bots:computer.description`)}),(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm`,children:[(0,$.jsx)(`span`,{className:`flex-none`,children:i(`bots:computer.runsOn`)}),(0,$.jsxs)(Y,{value:o,className:`w-48`,"aria-label":i(`bots:computer.runsOn`),disabled:h,onChange:t=>{s(t.target.value),l(t.target.value===e.workspace.environmentId?e.workspace.cwd:``)},children:[t.length===0&&(0,$.jsx)(`option`,{value:`local`,children:i(`bots:computer.local`)}),t.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.kind===`local`?i(`bots:computer.local`):i(`bots:computer.option`,{name:sn(i,e),state:e.online?i(`bots:computer.online`):i(`bots:computer.offline`)})},e.id))]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-content-muted`,children:i(`bots:computer.folder`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(ne,{className:`size-3.5 flex-none text-content-muted`,"aria-hidden":`true`}),(0,$.jsx)(K,{value:c,className:`font-mono text-xs`,"aria-label":i(`bots:computer.folder`),placeholder:b?i(`bots:computer.folderPlaceholder`):y?.roots[0]??i(`bots:computer.folderPlaceholder`),disabled:h,onChange:e=>l(e.target.value)}),(b||y)&&(0,$.jsx)(G,{size:`sm`,variant:`outline`,disabled:h||u,onClick:()=>void C(),children:i(`bots:new.pick`)})]}),!b&&y&&(0,$.jsx)(`p`,{className:`text-xs text-content-muted`,children:i(`bots:computer.folderInRoots`,{roots:y.roots.join(`、`)})}),x&&(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(G,{size:`sm`,disabled:h||!c.trim(),onClick:()=>void S({environmentId:o,cwd:c.trim()}),children:i(`bots:computer.switch`)})})]}),(0,$.jsxs)(`section`,{"aria-label":i(`bots:computer.listTitle`),className:`border-t border-stroke pt-3`,children:[(0,$.jsx)(`h4`,{className:`text-xs font-medium text-content-muted`,children:i(`bots:computer.listTitle`)}),(0,$.jsx)(`ul`,{role:`list`,className:`m-0 list-none divide-y divide-stroke p-0`,children:t.map(e=>(0,$.jsx)(ln,{environment:e,onRemoved:n,onError:r},e.id))}),_?(0,$.jsx)(un,{pairing:_,onDone:()=>{v(null),n()}}):(0,$.jsxs)(G,{size:`sm`,variant:`outline`,className:`mt-1`,onClick:()=>void w(),children:[(0,$.jsx)(oe,{"aria-hidden":`true`}),i(`bots:computer.add`)]})]}),(0,$.jsx)(te,{open:p,initialPath:c,onOpenChange:m,listFolders:(e,t)=>Et(o,e,t),onSelect:e=>{l(e),m(!1)}})]})}function fn(e){return`ref`in e?`ref:${e.ref}`:`tier:${e.tier}`}function pn(e){return e.startsWith(`ref:`)?{ref:e.slice(4)}:{tier:Ht.find(t=>`tier:${t}`===e)??`standard`}}function mn({bot:e,saving:t,onSave:n}){let{t:r}=d(),[i,a]=(0,Q.useState)([]);(0,Q.useEffect)(()=>{let e=!0;return Ot().then(t=>e&&a(t)).catch(()=>e&&a([])),()=>{e=!1}},[]);let o=i.map(e=>e.name),s=fn(e.model);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{title:r(`bots:model.model`),description:r(`bots:model.hint`),control:(0,$.jsxs)(Y,{value:s,className:`w-48`,"aria-label":r(`bots:model.model`),disabled:t,onChange:e=>n({model:pn(e.target.value)}),children:[Ht.map(e=>(0,$.jsx)(`option`,{value:`tier:${e}`,children:ce(r,{tier:e})},e)),`ref`in e.model&&!i.some(e=>`ref:${e.ref}`===s)&&(0,$.jsx)(`option`,{value:s,children:e.model.ref}),i.map(e=>(0,$.jsx)(`option`,{value:`ref:${e.ref}`,children:`${pt(e.name,o)} · ${e.providerName}`},e.ref))]})}),(0,$.jsx)(Z,{title:r(`bots:model.thinking`),control:(0,$.jsxs)(Y,{value:e.thinking??``,className:`w-48`,"aria-label":r(`bots:model.thinking`),disabled:t,onChange:e=>n({thinking:Bt.find(t=>t===e.target.value)??null}),children:[(0,$.jsx)(`option`,{value:``,children:r(`bots:model.thinkingDefault`)}),Bt.map(e=>(0,$.jsx)(`option`,{value:e,children:se(r,e)},e))]})})]})}function hn({bot:e,saving:t=!1,onError:n,onCount:r,onReadGlobalChange:i}){let{t:a}=d(),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(``),[u,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let t=new AbortController;return Nt(e.id,t.signal).then(e=>s(e)).catch(e=>{t.signal.aborted||(s([]),n(e instanceof Error?e.message:String(e)))}),()=>t.abort()},[e.id,n]),(0,Q.useEffect)(()=>{o&&r?.(o.length)},[o,r]);let h=async e=>{m(!0);try{await e()}catch(e){n(e instanceof Error?e.message:String(e))}finally{m(!1)}},g=()=>h(async()=>{let t=await Ut(e.id,c);s(e=>[...(e||[]).filter(e=>e.id!==t.id),t]),l(``)}),_=()=>h(async()=>{if(!u)return;let t=await Pt(e.id,u.id,u.text);s(e=>(e||[]).map(e=>e.id===t.id?t:e)),f(null)}),v=t=>h(async()=>{await Mt(e.id,t),s(e=>(e||[]).filter(e=>e.id!==t))});return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`p`,{className:`m-0 text-xs text-content-muted`,children:a(`bots:memory.hint`,{name:e.name})}),i&&(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{children:a(`bots:memory.readGlobal`)}),(0,$.jsx)(`span`,{className:`text-xs text-content-muted`,children:a(`bots:memory.readGlobalHint`)})]}),(0,$.jsx)(V,{checked:e.readGlobalMemory,disabled:t,onCheckedChange:i})]}),o&&!o.length&&(0,$.jsx)(ht,{compact:!0,title:a(`bots:memory.empty`,{name:e.name})}),o&&o.length>0&&(0,$.jsx)(`ul`,{role:`list`,className:`m-0 flex list-none flex-col gap-1.5 p-0`,children:[...o].reverse().map(e=>u?.id===e.id?(0,$.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(K,{value:u.text,maxLength:500,"aria-label":a(`bots:memory.editLabel`),onChange:t=>f({id:e.id,text:t.target.value}),onKeyDown:e=>{e.key===`Enter`&&u.text.trim()&&_(),e.key===`Escape`&&f(null)}}),(0,$.jsx)(G,{size:`sm`,disabled:p||!u.text.trim(),onClick:()=>void _(),children:a(`bots:memory.save`)}),(0,$.jsx)(G,{size:`sm`,variant:`ghost`,onClick:()=>f(null),children:a(`bots:memory.cancel`)})]},e.id):(0,$.jsxs)(`li`,{"data-bot-memory":e.id,className:`group flex items-start gap-2 rounded-lg bg-surface-subtle px-2.5 py-2 text-[13px]`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-content`,children:e.text}),(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`flex-none pointer-coarse:size-11`,"aria-label":a(`bots:memory.edit`),title:a(`bots:memory.edit`),disabled:p,onClick:()=>f({id:e.id,text:e.text}),children:(0,$.jsx)(N,{"aria-hidden":`true`})}),(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`flex-none pointer-coarse:size-11`,"aria-label":a(`bots:memory.delete`),title:a(`bots:memory.delete`),disabled:p,onClick:()=>void v(e.id),children:(0,$.jsx)(Me,{"aria-hidden":`true`})})]},e.id))}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(K,{value:c,maxLength:500,"aria-label":a(`bots:memory.addLabel`),placeholder:a(`bots:memory.addPlaceholder`),onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&c.trim()&&g()}}),(0,$.jsx)(G,{size:`sm`,variant:`outline`,disabled:p||!c.trim(),onClick:()=>void g(),children:a(`bots:memory.add`)})]})]})}var gn=[`feishu`,`weixin`,`qq`,`telegram`],_n=e=>gn.includes(e);function vn(e){let t=e&&typeof e==`object`?e:null,n=t?.connections;if(!n||typeof n!=`object`||Array.isArray(n))throw p();let r=gn.flatMap(e=>{let t=n[e];if(!t||typeof t!=`object`)return[];let{enabled:r,ownerConfigured:i}=t;return r===!1?[]:[{platform:e,ownerConfigured:i===!0}]}),i=new Set(r.map(e=>e.platform));return{channels:r,groups:(Array.isArray(t.scopes)?t.scopes:[]).flatMap(e=>{let t=e&&typeof e==`object`?e:{},n=e=>typeof e==`string`?e.trim():``,r=n(t.peerId);return t.chatType!==`group`||!_n(t.platform)||!r||!i.has(t.platform)?[]:[{platform:t.platform,peerId:r,title:n(t.title)||r,lastMessage:n(t.lastMessage)}]})}}function yn(e){return m(`/api/channels`,{signal:e,parse:vn})}function bn(e,t){return e.some(e=>e.platform===t.platform&&e.chatType===t.chatType&&e.senderIds.length===0&&(e.peerIds===null||t.peerIds!==null&&t.peerIds.every(t=>e.peerIds?.includes(t))))}function xn({bot:e,onError:t}){let{t:n}=d(),i=X(e=>e.upsert),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(`feishu`),[y,b]=(0,Q.useState)(`p2p`),[x,S]=(0,Q.useState)(``),[C,w]=(0,Q.useState)(``),[T,E]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let e=new AbortController;return g(``),yn(e.signal).then(t=>{e.signal.aborted||m(t)},t=>{e.signal.aborted||g(t instanceof Error?t.message:String(t))}),()=>e.abort()},[a]);let D=async n=>{f(!0);try{return i(await Ct(e.id,{channels:n})),!0}catch(e){return t(e instanceof Error?e.message:String(e)),!1}finally{f(!1)}},O=()=>{o(!1),c(!1),S(``),w(``),E(!1)},ee=async t=>{await D([...e.channels,t])&&O()},te=()=>{let e=P(x);ee({platform:_,chatType:y,peerIds:e.length?e:null,senderIds:P(C),everyone:T})},k=p?[...p.channels.map(e=>({key:`${e.platform}:p2p`,title:n(`bots:triggers.pickP2p`,{platform:L(n,e.platform)}),detail:e.ownerConfigured?n(`bots:triggers.ownerOnly`):n(`bots:triggers.ownerMissing`),channel:{platform:e.platform,chatType:`p2p`,peerIds:null,senderIds:[],everyone:!1},unavailable:!e.ownerConfigured})),...p.groups.map(e=>{let t=p.channels.find(t=>t.platform===e.platform);return{key:`${e.platform}:group:${e.peerId}`,title:e.title,detail:[n(`bots:triggers.pickGroup`,{platform:L(n,e.platform)}),e.lastMessage].filter(Boolean).join(` · `),channel:{platform:e.platform,chatType:`group`,peerIds:[e.peerId],senderIds:[],everyone:!1},unavailable:!t?.ownerConfigured}})]:[];return(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs text-content-muted`,children:n(`bots:triggers.chatsHint`,{name:e.name})}),e.channels.length>0&&(0,$.jsx)(`ul`,{role:`list`,className:`m-0 mb-2 flex list-none flex-col gap-1.5 p-0`,children:e.channels.map((t,r)=>(0,$.jsxs)(`li`,{"data-bot-channel":t.platform,className:`flex items-start gap-2 rounded-lg bg-surface-subtle px-2.5 py-2 text-xs`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`b`,{className:`font-medium text-content`,children:[L(n,t.platform),` ·`,` `,t.chatType===`group`?n(`bots:triggers.group`):n(`bots:triggers.p2p`)]}),(0,$.jsxs)(`span`,{className:`block truncate text-content-muted`,children:[t.peerIds?n(`bots:triggers.peers`,{ids:t.peerIds.map(e=>p?.groups.find(n=>n.platform===t.platform&&n.peerId===e)?.title||e).join(`、`)}):n(`bots:triggers.allPeers`),` · `,t.senderIds.length?n(`bots:triggers.adminsWith`,{ids:t.senderIds.join(`、`)}):n(`bots:triggers.admins`)]}),(0,$.jsxs)(`label`,{className:`mt-1.5 flex items-center gap-2 text-content-secondary`,children:[(0,$.jsx)(V,{size:`sm`,checked:t.everyone,disabled:l,onCheckedChange:t=>void D(e.channels.map((e,n)=>n===r?{...e,everyone:t}:e))}),n(`bots:triggers.everyone`)]})]}),(0,$.jsx)(G,{size:`sm`,variant:`ghost`,disabled:l,onClick:()=>void D(e.channels.filter((e,t)=>t!==r)),children:n(`bots:triggers.remove`)})]},`${t.platform}-${r}`))}),a?(0,$.jsxs)(`div`,{"data-bot-channel-picker":!0,className:`flex flex-col gap-2 rounded-lg border border-stroke p-2.5`,children:[s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`m-0 text-xs text-content-muted`,children:n(`bots:triggers.manualHint`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{value:_,className:`w-32`,"aria-label":n(`bots:triggers.platform`),onChange:e=>v(e.target.value),children:Ft.map(e=>(0,$.jsx)(`option`,{value:e,children:L(n,e)},e))}),(0,$.jsx)(H,{value:y,onValueChange:e=>b(e),options:[{value:`p2p`,label:n(`bots:triggers.p2p`)},{value:`group`,label:n(`bots:triggers.group`)}]})]}),(0,$.jsx)(K,{value:x,"aria-label":n(`bots:triggers.peerIds`),placeholder:n(`bots:triggers.peerIdsPlaceholder`),onChange:e=>S(e.target.value)}),(0,$.jsx)(K,{value:C,"aria-label":n(`bots:triggers.senderIds`),placeholder:n(`bots:triggers.senderIdsPlaceholder`),onChange:e=>w(e.target.value)}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-content-secondary`,children:[(0,$.jsx)(V,{size:`sm`,checked:T,onCheckedChange:E}),n(`bots:triggers.everyone`)]})]}):h?(0,$.jsx)(`p`,{role:`alert`,className:`m-0 text-xs text-destructive`,children:h}):p?k.length===0?(0,$.jsx)(ht,{compact:!0,icon:M,title:n(`bots:triggers.noChannels`),description:n(`bots:triggers.noChannelsHint`),action:(0,$.jsx)(G,{asChild:!0,size:`sm`,variant:`outline`,children:(0,$.jsx)(r,{to:u.channels,children:n(`bots:triggers.openChannels`)})})}):(0,$.jsx)(`ul`,{role:`list`,"aria-label":n(`bots:triggers.pickTitle`),className:`m-0 flex list-none flex-col p-0`,children:k.map(t=>{let r=bn(e.channels,t.channel),i=t.channel.chatType===`group`?Ne:M;return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,"data-bot-chat-option":t.key,className:`flex min-h-11 w-full min-w-0 items-center gap-2.5 rounded-md px-2 py-1.5 text-left outline-none hover:bg-surface-hover focus-visible:ring-3 focus-visible:ring-focus-ring disabled:cursor-not-allowed disabled:opacity-50`,disabled:l||r||t.unavailable,onClick:()=>void ee(t.channel),children:[(0,$.jsx)(i,{className:`size-4 flex-none text-content-muted`,"aria-hidden":`true`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm text-content`,children:t.title}),(0,$.jsx)(`span`,{className:`block truncate text-xs text-content-muted`,children:t.detail})]}),r?(0,$.jsx)(`span`,{className:`flex-none text-xs text-content-muted`,children:n(`bots:triggers.added`)}):(0,$.jsx)(oe,{className:`size-4 flex-none text-content-muted`,"aria-hidden":`true`})]})},t.key)})}):(0,$.jsx)(`div`,{role:`status`,className:`grid min-h-16 place-items-center`,children:(0,$.jsx)(W,{className:`size-4`})}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[s?(0,$.jsx)(`span`,{}):(0,$.jsx)(G,{size:`sm`,variant:`ghost`,onClick:()=>c(!0),children:n(`bots:triggers.manual`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(G,{size:`sm`,variant:`ghost`,onClick:O,children:n(`bots:triggers.cancel`)}),s&&(0,$.jsx)(G,{size:`sm`,disabled:l,onClick:te,children:n(`bots:triggers.add`)})]})]})]}):(0,$.jsx)(G,{size:`sm`,variant:`outline`,className:`self-start`,onClick:()=>o(!0),children:n(`bots:triggers.addChat`)})]})}var Sn=[1,2,3,4,5,6,0];function Cn(){let e=new Date,t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`}function wn({bot:e,initialMessage:t=``,onCancel:n,onCreated:r,onError:i}){let{t:a}=d(),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(t),[u,f]=(0,Q.useState)(t?`weekly`:`daily`),[p,m]=(0,Q.useState)(`09:00`),[h,g]=(0,Q.useState)(Cn),[_,v]=(0,Q.useState)(t?5:1),y=async()=>{let t=c.trim();s(!0);try{await Rt({botId:e.id,name:`${e.name}:${t.slice(0,40)}`,botMessage:t,frequency:u,time:p,date:u===`once`?h:``,dayOfWeek:_,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||`Asia/Hong_Kong`}),r()}catch(e){i(e instanceof Error?e.message:String(e))}finally{s(!1)}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-stroke p-2.5`,children:[(0,$.jsx)(K,{value:c,maxLength:12e3,"aria-label":a(`bots:triggers.scheduleMessage`),placeholder:a(`bots:triggers.scheduleMessagePlaceholder`),onChange:e=>l(e.target.value)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(Y,{value:u,className:`w-28`,"aria-label":a(`bots:triggers.frequency`),onChange:e=>f(e.target.value),children:[(0,$.jsx)(`option`,{value:`daily`,children:a(`bots:triggers.daily`)}),(0,$.jsx)(`option`,{value:`weekly`,children:a(`bots:triggers.weekly`)}),(0,$.jsx)(`option`,{value:`once`,children:a(`bots:triggers.once`)})]}),u===`weekly`&&(0,$.jsx)(Y,{value:String(_),className:`w-24`,"aria-label":a(`bots:triggers.weekday`),onChange:e=>v(Number(e.target.value)),children:Sn.map(e=>(0,$.jsx)(`option`,{value:e,children:I(a,e)},e))}),u===`once`&&(0,$.jsx)(K,{type:`date`,value:h,className:`w-40`,"aria-label":a(`bots:triggers.date`),onChange:e=>g(e.target.value)}),(0,$.jsx)(K,{type:`time`,value:p,className:`w-28`,"aria-label":a(`bots:triggers.time`),onChange:e=>m(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(G,{size:`sm`,variant:`ghost`,onClick:n,children:a(`bots:triggers.cancel`)}),(0,$.jsx)(G,{size:`sm`,disabled:o||!c.trim(),onClick:()=>void y(),children:a(`bots:triggers.add`)})]})]})}function Tn({bot:e,onError:t,onCount:n}){let{t:r}=d(),[i,a]=(0,Q.useState)([]),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1),u=(0,Q.useCallback)(async()=>{try{let t=await Kt(e.id);a(t),n?.(t.length)}catch{}},[e.id,n]);(0,Q.useEffect)(()=>{u()},[u]);let f=async e=>{l(!0);try{await e(),await u()}catch(e){t(e instanceof Error?e.message:String(e))}finally{l(!1)}};return(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[i.length>0&&(0,$.jsx)(`ul`,{role:`list`,className:`m-0 mb-2 flex list-none flex-col gap-1.5 p-0`,children:i.map(e=>(0,$.jsxs)(`li`,{"data-bot-schedule":e.id,className:`flex items-center gap-2 rounded-lg bg-surface-subtle px-2.5 py-2 text-xs`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`b`,{className:`block truncate font-medium text-content`,children:e.botMessage}),(0,$.jsx)(`span`,{className:`text-content-muted`,children:F(r,e)})]}),(0,$.jsx)(V,{checked:e.enabled,disabled:c,"aria-label":r(`bots:triggers.scheduleEnabled`),onCheckedChange:t=>void f(()=>Dt(e.id,t))}),(0,$.jsx)(G,{size:`sm`,variant:`ghost`,disabled:c,onClick:()=>void f(()=>Vt(e.id)),children:r(`bots:triggers.remove`)})]},e.id))}),o?(0,$.jsx)(wn,{bot:e,onCancel:()=>s(!1),onCreated:()=>{s(!1),u()},onError:t}):(0,$.jsx)(G,{size:`sm`,variant:`outline`,className:`self-start`,onClick:()=>s(!0),children:r(`bots:triggers.addSchedule`)})]})}function En({bot:e,onError:t,onCount:n}){let{t:r}=d(),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(``),[u,f]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let n=new AbortController;return At(e.id,n.signal).then(e=>a(e)).catch(e=>{n.signal.aborted||(a([]),t(e instanceof Error?e.message:String(e)))}),()=>n.abort()},[e.id,t]),(0,Q.useEffect)(()=>{i&&n?.(i.length)},[i,n]);let p=n=>{if(o?.name===n){s(null);return}s({name:n,body:null}),Yt(e.id,n).then(e=>s(t=>t?.name===n?{name:n,body:e.body}:t)).catch(e=>{s(null),t(e instanceof Error?e.message:String(e))})},m=async n=>{f(!0);try{await zt(e.id,n),a(e=>(e||[]).filter(e=>e.name!==n)),o?.name===n&&s(null)}catch(e){t(e instanceof Error?e.message:String(e))}finally{f(!1)}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`p`,{className:`m-0 text-xs text-content-muted`,children:r(`bots:skills.hint`,{name:e.name})}),i&&!i.length&&(0,$.jsx)(ht,{compact:!0,title:r(`bots:skills.empty`,{name:e.name})}),i&&i.length>0&&(0,$.jsx)(`ul`,{role:`list`,className:`m-0 flex list-none flex-col gap-1.5 p-0`,children:i.map(n=>{let i=o?.name===n.name;return(0,$.jsxs)(`li`,{"data-bot-skill":n.name,className:`flex flex-col gap-2 rounded-lg bg-surface-subtle px-2.5 py-2 text-[13px]`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-start gap-1.5 text-left`,"aria-expanded":i,onClick:()=>p(n.name),children:[i?(0,$.jsx)(S,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 flex-none`}):(0,$.jsx)(w,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 flex-none`}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`b`,{className:`block truncate font-medium text-content`,children:n.name}),(0,$.jsx)(`span`,{className:`block text-xs text-content-muted`,children:n.description})]})]}),(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`flex-none pointer-coarse:size-11`,"aria-label":r(`bots:skills.schedule`),title:r(`bots:skills.schedule`),disabled:u,onClick:()=>l(e=>e===n.name?``:n.name),children:(0,$.jsx)(b,{"aria-hidden":`true`})}),(0,$.jsx)(G,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`flex-none pointer-coarse:size-11`,"aria-label":r(`bots:skills.delete`),title:r(`bots:skills.delete`),disabled:u,onClick:()=>void m(n.name),children:(0,$.jsx)(Me,{"aria-hidden":`true`})})]}),i&&(0,$.jsx)(`pre`,{className:`m-0 max-h-72 overflow-auto rounded-md bg-surface px-2.5 py-2 text-xs whitespace-pre-wrap text-content`,children:o.body??r(`bots:skills.loading`)}),c===n.name&&(0,$.jsx)(wn,{bot:e,initialMessage:r(`bots:skills.scheduleMessage`,{name:n.name}),onCancel:()=>l(``),onCreated:()=>l(``),onError:t})]},n.name)})})]})}function Dn({bot:e,saving:t,onSave:n}){let{t:r}=d(),[i,a]=(0,Q.useState)(e.proactive.briefAt);return(0,Q.useEffect)(()=>a(e.proactive.briefAt),[e.id,e.proactive.briefAt]),(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{title:r(`bots:proactive.check`),description:r(`bots:proactive.checkHint`,{name:e.name}),control:(0,$.jsx)(V,{checked:e.proactive.enabled,disabled:t,"aria-label":r(`bots:proactive.check`),onCheckedChange:e=>n({enabled:e})})}),e.proactive.enabled&&(0,$.jsx)(Z,{nested:!0,title:r(`bots:proactive.every`),control:(0,$.jsx)(Y,{value:String(e.proactive.everyHours),className:`w-48`,"aria-label":r(`bots:proactive.every`),disabled:t,onChange:e=>n({everyHours:Number(e.target.value)}),children:kt.map(e=>(0,$.jsx)(`option`,{value:e,children:r(`bots:proactive.everyHours`,{count:e})},e))})}),(0,$.jsx)(Z,{title:r(`bots:proactive.brief`),description:r(`bots:proactive.briefHint`),control:(0,$.jsx)(V,{checked:e.proactive.brief,disabled:t,"aria-label":r(`bots:proactive.brief`),onCheckedChange:e=>n({brief:e})})}),e.proactive.brief&&(0,$.jsx)(Z,{nested:!0,title:r(`bots:proactive.briefAt`),control:(0,$.jsx)(K,{type:`time`,value:i,className:`w-48`,"aria-label":r(`bots:proactive.briefAt`),disabled:t,onChange:e=>a(e.target.value),onBlur:()=>{/^\d{2}:\d{2}$/.test(i)&&i!==e.proactive.briefAt&&n({briefAt:i})}})})]})}var On={name:``,kind:`task`,text:``,audience:`admins`,allowExtra:!1};function kn({initial:e,saving:t,onCancel:n,onSave:r}){let{t:i}=d(),[a,o]=(0,Q.useState)(e),s=e=>o(t=>({...t,...e})),c=a.kind===`task`;return(0,$.jsxs)(`form`,{"data-bot-command-form":!0,className:`flex flex-col gap-2 rounded-lg border border-stroke p-2.5`,onSubmit:e=>{e.preventDefault(),r({...a,name:a.name.trim(),text:a.text.trim()})},children:[(0,$.jsx)(K,{value:a.name,autoFocus:!0,maxLength:24,"aria-label":i(`bots:commands.name`),placeholder:i(`bots:commands.namePlaceholder`),onChange:e=>s({name:e.target.value})}),(0,$.jsx)(H,{value:a.kind,onValueChange:e=>s({kind:e,allowExtra:e===`task`&&a.allowExtra}),options:[{value:`task`,label:i(`bots:commands.task`)},{value:`reply`,label:i(`bots:commands.reply`)}]}),(0,$.jsx)(ft,{value:a.text,rows:3,maxLength:4e3,"aria-label":i(c?`bots:commands.taskText`:`bots:commands.replyText`),placeholder:i(c?`bots:commands.taskPlaceholder`:`bots:commands.replyPlaceholder`),onChange:e=>s({text:e.target.value})}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-sm`,children:[(0,$.jsx)(`span`,{className:`text-content-secondary`,children:i(`bots:commands.audience`)}),(0,$.jsx)(H,{value:a.audience,onValueChange:e=>s({audience:e}),options:[{value:`admins`,label:i(`bots:commands.admins`)},{value:`everyone`,label:i(`bots:commands.everyone`)}]})]}),c&&(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm`,children:[(0,$.jsx)(`span`,{className:`text-content-secondary`,children:i(`bots:commands.allowExtra`)}),(0,$.jsx)(V,{checked:a.allowExtra,onCheckedChange:e=>s({allowExtra:e})})]}),c&&a.allowExtra&&a.audience===`everyone`&&(0,$.jsx)(`p`,{className:`m-0 text-xs text-content-muted`,children:i(`bots:commands.extraNote`)}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(G,{type:`button`,size:`sm`,variant:`ghost`,onClick:n,children:i(`bots:triggers.cancel`)}),(0,$.jsx)(G,{type:`submit`,size:`sm`,disabled:t||!a.name.trim()||!a.text.trim(),children:i(`bots:commands.save`)})]})]})}function An({bot:e,onError:t}){let{t:n}=d(),r=X(e=>e.upsert),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(!1),c=async n=>{s(!0);try{return r(await Ct(e.id,{commands:n})),!0}catch(e){return t(e instanceof Error?e.message:String(e)),!1}finally{s(!1)}},l=(t,n)=>{let r=[...e.commands],[i]=r.splice(t,1);r.splice(t+n,0,i),c(r)},u=e.channels.some(e=>e.everyone);return(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs text-content-muted`,children:n(`bots:commands.hint`,{name:e.name})}),e.commands.some(e=>e.audience===`everyone`)&&!u&&(0,$.jsx)(`p`,{className:`mb-2 text-xs text-content-muted`,children:n(`bots:commands.noEveryoneChat`)}),e.commands.length>0&&(0,$.jsx)(`ol`,{className:`m-0 mb-2 flex list-none flex-col gap-1.5 p-0`,children:e.commands.map((t,r)=>i===r?(0,$.jsx)(`li`,{children:(0,$.jsx)(kn,{initial:t,saving:o,onCancel:()=>a(null),onSave:async t=>{await c(e.commands.map((e,n)=>n===r?t:e))&&a(null)}})},t.name):(0,$.jsxs)(`li`,{"data-bot-command":t.name,className:`flex items-start gap-2 rounded-lg bg-surface-subtle px-2.5 py-2 text-xs`,children:[(0,$.jsx)(`span`,{className:`w-4 flex-none pt-px text-right font-mono text-content-muted`,children:r+1}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`b`,{className:`block truncate font-medium text-content`,children:t.name}),(0,$.jsx)(`span`,{className:`block truncate text-content-muted`,children:[t.audience===`everyone`?n(`bots:commands.everyone`):n(`bots:commands.admins`),t.kind===`reply`?n(`bots:commands.reply`):n(`bots:commands.task`),t.allowExtra?n(`bots:commands.extraAllowed`):``,t.text].filter(Boolean).join(` · `)})]}),(0,$.jsx)(G,{size:`icon-sm`,variant:`ghost`,"aria-label":n(`bots:commands.moveUp`),disabled:o||i!==null||r===0,onClick:()=>l(r,-1),children:(0,$.jsx)(y,{})}),(0,$.jsx)(G,{size:`icon-sm`,variant:`ghost`,"aria-label":n(`bots:commands.moveDown`),disabled:o||i!==null||r===e.commands.length-1,onClick:()=>l(r,1),children:(0,$.jsx)(v,{})}),(0,$.jsx)(G,{size:`sm`,variant:`ghost`,disabled:o||i!==null,onClick:()=>a(r),children:n(`bots:commands.edit`)}),(0,$.jsx)(G,{size:`sm`,variant:`ghost`,disabled:o||i!==null,onClick:()=>void c(e.commands.filter((e,t)=>t!==r)),children:n(`bots:triggers.remove`)})]},t.name))}),i===-1?(0,$.jsx)(kn,{initial:On,saving:o,onCancel:()=>a(null),onSave:async t=>{await c([...e.commands,t])&&a(null)}}):(0,$.jsx)(G,{size:`sm`,variant:`outline`,className:`self-start`,disabled:i!==null||e.commands.length>=20,onClick:()=>a(-1),children:n(`bots:commands.add`)})]})}function jn({id:e,title:t,summary:n,open:r,onToggle:i,children:a}){let{t:o}=d(),s=(0,Q.useId)();return(0,$.jsx)(Z,{"data-bot-setting":e,"data-state":r?`open`:`closed`,title:t,description:n,control:(0,$.jsxs)(G,{variant:`ghost`,size:`sm`,"aria-expanded":r,"aria-controls":r?s:void 0,onClick:i,children:[o(r?`bots:settings.collapse`:`bots:settings.manage`),(0,$.jsx)(w,{"aria-hidden":`true`,className:U(`transition-transform motion-reduce:transition-none`,r&&`rotate-90`)})]}),children:r&&(0,$.jsx)(`div`,{id:s,className:`mt-3`,children:a})})}function Mn({bot:e,environment:t,saving:n,onSave:r}){let{t:i}=d(),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),l=async()=>{let t=s?.trim()??``;if(!t||t===e.name){c(null);return}await r({name:t})&&c(null)},u=[Tt(i,e),i(`bots:settings.computerSummary`,{computer:sn(i,t),folder:It(e.workspace.cwd)}),ce(i,e.model)].join(` · `);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,$.jsxs)(`button`,{type:`button`,"aria-label":i(`bots:settings.changeLook`),"aria-expanded":a,title:i(`bots:settings.changeLook`),className:`relative flex-none rounded-[16px] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus`,onClick:()=>o(e=>!e),children:[(0,$.jsx)(J,{avatar:e.avatar,state:Lt(e),size:56}),(0,$.jsx)(`span`,{className:`absolute -right-1 -bottom-1 grid size-6 place-items-center rounded-full border border-stroke bg-solid text-content-muted shadow-edge`,children:(0,$.jsx)(N,{className:`size-3`,"aria-hidden":`true`})})]}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[s===null?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,$.jsx)(`h2`,{className:`m-0 truncate text-lg font-semibold text-content`,children:e.name}),(0,$.jsx)(G,{variant:`ghost`,size:`icon-xs`,"aria-label":i(`bots:settings.rename`),title:i(`bots:settings.rename`),onClick:()=>c(e.name),children:(0,$.jsx)(N,{})})]}):(0,$.jsxs)(`form`,{className:`flex items-center gap-2`,onSubmit:e=>{e.preventDefault(),l()},children:[(0,$.jsx)(K,{autoFocus:!0,value:s,maxLength:24,"aria-label":i(`bots:new.name`),disabled:n,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Escape`&&c(null)}}),(0,$.jsx)(G,{type:`submit`,size:`sm`,disabled:n||!s.trim(),children:i(`bots:details.save`)}),(0,$.jsx)(G,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>c(null),children:i(`common:ui.cancel`)})]}),(0,$.jsxs)(`p`,{className:`m-0 mt-0.5 flex min-w-0 items-center gap-1.5 text-xs text-content-muted`,children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:U(`size-1.5 flex-none rounded-full`,e.enabled?`bg-success`:`bg-content-faint`)}),(0,$.jsx)(`span`,{className:`truncate`,children:u})]})]}),(0,$.jsxs)(`label`,{className:`flex flex-none items-center gap-2 text-[13px] text-content-secondary`,title:i(`bots:details.acceptsWork`),children:[i(`bots:settings.accepting`),(0,$.jsx)(V,{checked:e.enabled,disabled:n,"aria-label":i(`bots:details.acceptsWork`),onCheckedChange:e=>void r({enabled:e})})]})]}),a&&(0,$.jsx)(Te,{value:e.avatar,disabled:n,onChange:e=>void r({avatar:e})})]})}function Nn({bot:e,environments:t,openSection:n,onEnvironmentsChanged:r,onError:i}){let{t:a}=d(),o=X(e=>e.upsert),[s,c]=(0,Q.useState)(e.instructions),[l,u]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(()=>new Set(n?[n]:[])),[m,h]=(0,Q.useState)({memory:null,skills:null,schedules:null});(0,Q.useEffect)(()=>c(e.instructions),[e.id,e.instructions]),(0,Q.useEffect)(()=>{let t=new AbortController,n=(e,t)=>t.then(t=>h(n=>({...n,[e]:t.length}))).catch(()=>{});return n(`memory`,Nt(e.id,t.signal)),n(`skills`,At(e.id,t.signal)),n(`schedules`,Kt(e.id,t.signal)),()=>t.abort()},[e.id]);let g=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{n&&g.current?.querySelector(`[data-bot-setting="${CSS.escape(n)}"]`)?.scrollIntoView()},[n]);let _=async t=>{u(!0);try{return o(await Ct(e.id,t)),!0}catch(e){return i(e instanceof Error?e.message:String(e)),!1}finally{u(!1)}},v=e=>p(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),y=e=>({id:e,open:f.has(e),onToggle:()=>v(e)}),b=m.memory===null?``:a(`bots:memory.count`,{count:m.memory}),x=m.skills===null?``:a(`bots:skills.count`,{count:m.skills}),S=m.schedules===null?``:m.schedules?a(`bots:settings.schedulesCount`,{count:m.schedules}):a(`bots:settings.notSet`),C=(0,Q.useMemo)(()=>{let e=e=>t=>h(n=>n[e]===t?n:{...n,[e]:t});return{memory:e(`memory`),skills:e(`skills`),schedules:e(`schedules`)}},[]),w=t.find(t=>t.id===e.workspace.environmentId),T=e.commands.filter(e=>e.audience===`everyone`).length;return(0,$.jsxs)(`div`,{ref:g,className:`flex flex-col gap-8 pb-4`,children:[(0,$.jsx)(Mn,{bot:e,environment:w,saving:l,onSave:_}),(0,$.jsxs)(`section`,{"aria-labelledby":`bot-instructions-title`,className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`h2`,{id:`bot-instructions-title`,className:`m-0 text-[15px] leading-6 font-medium text-content`,children:a(`bots:details.instructions`)}),(0,$.jsx)(ft,{value:s,rows:3,maxLength:12e3,"aria-labelledby":`bot-instructions-title`,placeholder:a(`bots:details.instructionsPlaceholder`),onChange:e=>c(e.target.value)}),s!==e.instructions&&(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(G,{size:`sm`,disabled:l,onClick:()=>void _({instructions:s}),children:a(`bots:details.save`)})})]}),(0,$.jsxs)(Zt,{title:a(`bots:settings.groupWork`),children:[(0,$.jsx)(jn,{...y(`computer`),title:a(`bots:settings.computer`),summary:a(`bots:settings.computerSummary`,{computer:sn(a,w),folder:It(e.workspace.cwd)}),children:(0,$.jsx)(dn,{bot:e,environments:t,onEnvironmentsChanged:r,onError:i})}),(0,$.jsx)(mn,{bot:e,saving:l,onSave:e=>void _(e)}),(0,$.jsx)(Z,{title:a(`bots:details.permission`),description:a(`bots:details.permissionHint`),control:(0,$.jsx)(Y,{value:e.executionMode,className:`w-48`,"aria-label":a(`bots:details.permission`),disabled:l,onChange:e=>void _({executionMode:e.target.value}),children:[`approval-required`,`workspace-write`,`full-access`].map(e=>(0,$.jsx)(`option`,{value:e,children:we(a,e)},e))})}),(0,$.jsx)(Z,{title:a(`bots:details.tools`),description:a(`bots:details.toolsHint`),control:(0,$.jsxs)(Y,{value:wt(e.tools),className:`w-48`,"aria-label":a(`bots:details.tools`),disabled:l,onChange:e=>void _({tools:e.target.value===`read-only`?[...St]:null}),children:[(0,$.jsx)(`option`,{value:`all`,children:a(`bots:details.toolsAll`)}),(0,$.jsx)(`option`,{value:`read-only`,children:a(`bots:details.toolsReadOnly`)}),wt(e.tools)===`custom`&&(0,$.jsx)(`option`,{value:`custom`,disabled:!0,children:a(`bots:details.toolsCustom`,{count:e.tools?.length??0})})]})}),(0,$.jsx)(Z,{title:a(`bots:details.parallel`),description:a(`bots:details.parallelHint`),control:(0,$.jsx)(Y,{value:String(e.maxParallelAgents),className:`w-48`,"aria-label":a(`bots:details.parallel`),disabled:l,onChange:e=>void _({maxParallelAgents:Number(e.target.value)}),children:[1,2,3,4,5,6].map(e=>(0,$.jsx)(`option`,{value:e,children:a(`bots:details.parallelCount`,{count:e})},e))})})]}),(0,$.jsxs)(Zt,{title:a(`bots:settings.groupReach`),children:[(0,$.jsx)(jn,{...y(`chats`),title:a(`bots:settings.chats`),summary:e.channels.length?a(`bots:settings.chatsCount`,{count:e.channels.length}):a(`bots:settings.notSet`),children:(0,$.jsx)(xn,{bot:e,onError:i})}),(0,$.jsx)(jn,{...y(`commands`),title:a(`bots:commands.title`),summary:e.commands.length?a(`bots:commands.count`,{count:e.commands.length,open:T}):a(`bots:settings.notSet`),children:(0,$.jsx)(An,{bot:e,onError:i})})]}),(0,$.jsxs)(Zt,{title:a(`bots:settings.groupOwn`),children:[(0,$.jsx)(Dn,{bot:e,saving:l,onSave:e=>void _({proactive:e})}),(0,$.jsx)(jn,{...y(`schedules`),title:a(`bots:settings.schedules`),summary:S,children:(0,$.jsx)(Tn,{bot:e,onError:i,onCount:C.schedules})})]}),(0,$.jsxs)(Zt,{title:a(`bots:settings.groupMemory`),children:[(0,$.jsx)(jn,{...y(`memory`),title:a(`bots:memory.title`),summary:b,children:(0,$.jsx)(hn,{bot:e,onError:i,onCount:C.memory})}),(0,$.jsx)(Z,{title:a(`bots:memory.readGlobal`),description:a(`bots:memory.readGlobalHint`),control:(0,$.jsx)(V,{checked:e.readGlobalMemory,disabled:l,"aria-label":a(`bots:memory.readGlobal`),onCheckedChange:e=>void _({readGlobalMemory:e})})}),(0,$.jsx)(jn,{...y(`skills`),title:a(`bots:skills.title`),summary:x,children:(0,$.jsx)(En,{bot:e,onError:i,onCount:C.skills})})]})]})}var Pn={enabled:!1,endpoints:[],fingerprint:null};function Fn(){let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(Pn),[i,a]=(0,Q.useState)(!1),o=(0,Q.useRef)(0),s=(0,Q.useCallback)(async()=>{let e=++o.current;try{let n=await Jt();if(e!==o.current)return;t(n.environments),r(n.remote)}catch{}finally{e===o.current&&a(!0)}},[]);return(0,Q.useEffect)(()=>{s();let e=window.setInterval(()=>{document.visibilityState===`visible`&&s()},1e4);return()=>{window.clearInterval(e),o.current+=1}},[s]),{environments:e,remote:n,loaded:i,refresh:s}}var In=`flex h-[52px] flex-none items-center gap-2 border-b border-stroke px-3 max-[650px]:h-[calc(52px+var(--pisper-safe-area-top,0px))] max-[650px]:px-2 max-[650px]:pt-[var(--pisper-safe-area-top,0px)] [[data-custom-titlebar]_&]:pr-[144px]`;function Ln({notify:e,phoneLeading:n}){let{t:r}=d(),o=g(),s=Xt(`bots`),{botId:c=``}=t(),l=a(),u=X(e=>e.bots),f=X(e=>e.loaded),[p,m]=(0,Q.useState)(!1),h=(0,Q.useCallback)(t=>e(t,`error`),[e]),_=xe(h);Wt(s);let v=u.find(e=>e.id===c)??null,y=e=>o&&c?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-col`,children:[(0,$.jsx)(`header`,{className:In,children:n}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:e})]}):e;return s?f?!c&&u[0]?(0,$.jsx)(i,{to:`/bots/${encodeURIComponent(u[0].id)}`,replace:!0}):v?(0,$.jsx)(Rn,{botId:v.id,phoneLeading:o?n:null,onOpenChat:()=>void _(v),onDeleted:()=>{e(r(`bots:delete.deleted`,{name:v.name})),l(`/`,{replace:!0})},onError:h},v.id):y((0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{kind:`empty`,title:u.length?r(`bots:page.notFound`):r(`bots:page.emptyTitle`),description:r(`bots:page.emptyDescription`),action:(0,$.jsxs)(G,{onClick:()=>m(!0),children:[(0,$.jsx)(oe,{"aria-hidden":`true`}),r(`bots:sidebar.newBot`)]})}),(0,$.jsx)(ue,{open:p,onOpenChange:m,onCreated:e=>void _(e)})]})):y((0,$.jsx)(q,{kind:`loading`,title:r(`bots:page.loading`)})):y((0,$.jsx)(q,{kind:`empty`,title:r(`bots:page.disabledTitle`),description:r(`bots:page.disabledDescription`),action:(0,$.jsx)(G,{onClick:()=>l(`/config/labs`),children:r(`bots:page.openLabs`)})}))}function Rn({botId:e,phoneLeading:t,onOpenChat:r,onDeleted:i,onError:a}){let{t:o}=d(),s=X(t=>t.bots.find(t=>t.id===e)),c=X(e=>e.load),l=Fn(),[u]=n(),f=u.get(`section`)===`chats`?`chats`:void 0,p=u.get(`action`)===`delete`;return s?(0,$.jsxs)(`div`,{"data-bot-settings":s.id,className:`flex h-full min-h-0 w-full min-w-0 flex-col`,children:[(0,$.jsxs)(`header`,{"data-window-drag-region":!0,className:`flex h-[52px] flex-none items-center gap-2 border-b border-stroke px-3 max-[650px]:h-[calc(52px+var(--pisper-safe-area-top,0px))] max-[650px]:px-2 max-[650px]:pt-[var(--pisper-safe-area-top,0px)] [[data-custom-titlebar]_&]:pr-[144px]`,children:[t,(0,$.jsxs)(G,{variant:`ghost`,size:`sm`,onClick:r,children:[(0,$.jsx)(C,{"aria-hidden":`true`}),o(`bots:settingsPage.backToChat`,{name:s.name})]}),(0,$.jsx)(`h1`,{className:`sr-only`,children:o(`bots:settingsPage.title`,{name:s.name})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,$.jsxs)(`div`,{className:`mx-auto w-[min(640px,calc(100%-32px))] py-6`,children:[(0,$.jsx)(Nn,{bot:s,environments:l.environments,openSection:f,onEnvironmentsChanged:()=>{l.refresh(),c()},onError:a}),(0,$.jsx)(on,{bot:s,initiallyOpen:p,onDeleted:i,onError:a})]})})]}):null}function zn(e,t=new Map){if(/(^|[^\p{L}\p{N}_])@(所有人|all|everyone)(?![\p{L}\p{N}_])/iu.test(e.text))return!0;let n=e.replyTo?t.get(e.replyTo)?.author.kind===`bot`:!1;return e.recipients===`all`&&!e.mentions?.length&&!n}function Bn(e){let t=new Map(e.map(e=>[e.id,e])),n=new Map;for(let r of e){let e=r.turn;if(!e||r.author.kind!==`bot`)continue;let i=r.author.botId;for(let r of[...e.triggers,...e.alsoAnswered]){let a=t.get(r);if(!a||a.author.kind!==`user`||!zn(a,t))continue;let o=n.get(r)||[];o.some(e=>e.botId===i)||(o.push({botId:i,state:e.state===`skipped`?`skipped`:e.state===`running`||e.state===`waiting`?`working`:`replied`}),n.set(r,o))}}let r=[];for(let i of e){if(i.recalled){r.push({kind:`recalled`,message:i});continue}if(i.author.kind===`system`){r.push({kind:`system`,message:i});continue}if(i.author.kind===`user`){r.push({kind:`user`,message:i,round:n.get(i.id)||null});continue}if(!i.turn){r.push({kind:`post`,message:i});continue}if(i.turn.state===`skipped`)continue;let e=i.turn.triggers.map(e=>t.get(e)).find(Boolean);r.push({kind:`card`,message:i,handoff:e?.author.kind===`bot`?{from:e.author.botId,hop:Math.max(2,i.chainHop)}:null})}return r}function Vn(e,t){let n=t.filter(e=>e.name).sort((e,t)=>t.name.length-e.name.length),r=[],i=``,a=0;for(;a<e.length;){if(e[a]===`@`){let t=e.slice(a+1),o=n.find(e=>{if(!t.toLowerCase().startsWith(e.name.toLowerCase()))return!1;let n=t.charAt(e.name.length);return!n||!/[\p{L}\p{N}_-]/u.test(n)}),s=/[\p{L}\p{N}_]/u.test(e.charAt(a-1))?null:/^(所有人|all|everyone)(?![\p{L}\p{N}_])/iu.exec(t);if(o||s){i&&r.push({text:i}),i=``;let t=o?o.name.length:s[0].length;r.push({text:e.slice(a,a+1+t),...o?{memberId:o.id}:{everyone:!0}}),a+=1+t;continue}}i+=e[a],a+=1}return i&&r.push({text:i}),r}function Hn(e,t){let n=e.slice(0,t),r=n.lastIndexOf(`@`);if(r<0||r>0&&/[\p{L}\p{N}_]/u.test(n[r-1]))return null;let i=n.slice(r+1);return/\s/.test(i)||i.length>24?null:{start:r,query:i}}function Un(e,t){return[...new Set(Vn(e,t).map(e=>e.memberId).filter(e=>!!e))]}function Wn(e){let t=Un(e.text,e.members),n=Vn(e.text,e.members).some(e=>e.everyone),r=t.length>0||n||!!e.repliedBot,i=n?e.members.map(e=>e.id):r?[...t,...e.repliedBot?[e.repliedBot]:[]]:e.chosen;return{addressed:r,mentionsAll:n,targets:[...new Set(i)]}}function Gn(e){return e>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`:e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}K`:String(Math.max(0,Math.round(e)))}function Kn(e,t){let n=e.owner===`user`?`@me `:e.owner?`@${t.find(t=>t.id===e.owner)?.name||``} `:``;return`${e.done?`[x] `:``}${n}${e.text}`}function qn(e,t){let n=e.trim();if(!n)return null;let r=!1,i=/^\[(x|X| )\]\s*/.exec(n);i&&(r=i[1].toLowerCase()===`x`,n=n.slice(i[0].length));let a=``;if(n.startsWith(`@`)){let e=t.filter(e=>e.name).sort((e,t)=>t.name.length-e.name.length).find(e=>n.slice(1).startsWith(e.name));e?(a=e.id,n=n.slice(e.name.length+1).trim()):/^@me\b/i.test(n)&&(a=`user`,n=n.slice(3).trim())}return n?{text:n,owner:a,done:r}:null}function Jn(e){return e.map(e=>e.kind===`path`?{id:`path:${e.path}`,kind:`path`,name:e.name,path:e.path}:{id:e.id,kind:e.kind,name:e.name,mimeType:e.mimeType,size:e.size,downloadUrl:vt(e.id),...e.kind===`image`?{url:_t(e.id)}:{}})}function Yn(e){if(e.kind===`user`)return!0;if(e.kind!==`card`)return!1;let t=e.message.turn?.state;return t!==`running`&&t!==`waiting`}function Xn(e,t,n,r,i){if(e.altKey||e.ctrlKey||e.metaKey||r<=0)return null;let a=r-1;return e.key===`ArrowDown`?{type:`move`,index:Math.min(a,n+1)}:e.key===`ArrowUp`?{type:`move`,index:Math.max(0,n-1)}:e.key===`Home`?{type:`move`,index:0}:e.key===`End`?{type:`move`,index:a}:i?(e.key===`r`||e.key===`R`)&&Yn(t)?{type:`reply`}:e.key===`Delete`&&Yn(t)?{type:`recall`}:e.key===`Enter`&&t.kind===`card`&&t.message.turn?.sessionId?{type:`process`}:null:null}function Zn(e){return e.turn?.state===`running`||e.turn?.state===`waiting`}function Qn(e){let t=[];for(let n of e){let e=n.turn;!e||n.author.kind!==`bot`||n.recalled||(e.state===`running`||e.state===`waiting`?t.push({message:n,botId:n.author.botId,waiting:e.state===`waiting`?e.waiting||`approval`:null,approval:e.state===`waiting`?e.approval:null,pending:!1}):e.pending&&t.push({message:n,botId:n.author.botId,waiting:e.pending.waiting,approval:e.pending.approval,pending:!0}))}return t}function $n(e,t){if(!e||e.recalled||t.replyTo||e.author.kind!==t.author.kind||t.author.kind===`bot`&&(e.author.kind!==`bot`||e.author.botId!==t.author.botId)||t.author.kind===`system`)return!1;let n=Date.parse(t.at)-Date.parse(e.at);return Number.isFinite(n)&&n>=0&&n<=12e4}function er(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:`${t.getFullYear()}-${t.getMonth()+1}-${t.getDate()}`}function tr(e){if(e.maintained)return null;let t=Math.max(e.brief?.upToSeq||0,e.skipUpTo||0),n=Math.max(0,e.lastSeq-t),r=e.messages.filter(e=>e.seq>t&&!e.recalled).reduce((e,t)=>e+t.text.length,0);return n>0&&r>=24e3?{count:n,chars:r}:null}var nr=`relative pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 pointer-coarse:after:-inset-y-2.5`,rr=`border-transparent bg-transparent text-content-muted shadow-none`,ir=12e3,ar=`@everyone`,or=[`所有人`,`all`,`everyone`];function sr({roomId:e,cwd:t,members:n,recipients:r,onRecipientsChange:i,replyTo:a,replyName:o,onCancelReply:s,onSend:c,placeholder:l,idleLabel:u,idleHint:f}){let{t:p}=d(),m=(0,Q.useId)(),h=(0,Q.useRef)(!1),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(0),[b,x]=(0,Q.useState)(``),[S,C]=(0,Q.useState)(-1),[w,T]=(0,Q.useState)(!1),[E,te]=(0,Q.useState)(!1),k=(0,Q.useRef)(!1),A=(0,Q.useRef)(null),j=n.filter(e=>!e.deleted),M=D([],void 0,e),ne=Ae({cwd:t,selection:M}),re=M.attachments.length>0,N=M.preparingAttachments.length>0,ae=!!(g.trim()||re)&&!N&&!w,se=a?.id;(0,Q.useEffect)(()=>{se&&A.current?.focus()},[se]);let P=Hn(g,v),F=p(`bots:room.composer.everyone`),I=(0,Q.useMemo)(()=>{if(!P)return[];let e=P.query.toLowerCase(),t=j.filter(t=>t.name.toLowerCase().includes(e)).slice(0,8).map(e=>({id:e.id,name:e.name,member:e}));return j.length>1&&[F,...or].some(t=>t.toLowerCase().startsWith(e))&&t.push({id:ar,name:F}),t},[j,P,F]),ce=!!(P&&I.length&&S!==P.start),L=I.find(e=>e.id===b)||I[0],R=r===`all`||!u&&!j.some(e=>r.includes(e.id)),le=R?j.map(e=>e.id):r,ue=j.filter(e=>le.includes(e.id)),{addressed:de,mentionsAll:fe,targets:z}=Wn({text:g,members:j,chosen:le,repliedBot:a?.author.kind===`bot`?a.author.botId:``}),pe=new Set(j.filter(e=>e.enabled).map(e=>e.id)),me=z.filter(e=>pe.has(e)).length,he=!u&&!de&&R&&me>=2,ge=e=>{if(!P)return;let t=g.slice(0,P.start),n=g.slice(v),r=`${t}@${e.name} ${n}`,i=t.length+e.name.length+2;_(r),y(i),window.requestAnimationFrame(()=>{A.current?.focus(),A.current?.setSelectionRange(i,i)})},_e=()=>{let e=A.current?.selectionStart??g.length,t=g.slice(0,e),n=t&&!/\s$/.test(t)?` @`:`@`,r=`${t}${n}${g.slice(e)}`,i=e+n.length;_(r),y(i),C(-1),window.requestAnimationFrame(()=>{A.current?.focus(),A.current?.setSelectionRange(i,i)})},ve=e=>{let t=e.currentTarget;t.scrollWidth<=t.clientWidth||Math.abs(e.deltaX)>Math.abs(e.deltaY)||(t.scrollLeft+=e.deltaY)},ye=(e,t)=>{let n=R?j.map(e=>e.id):r,a=t?[...new Set([...n,e])]:n.filter(t=>t!==e);i(a.length===j.length&&j.length>1||!a.length&&!u?`all`:a)},be=async()=>{let e=g.trim();if(ae){T(!0);try{await c(e,Un(e,j),M.attachments)&&(_(``),y(0),M.clearAttachments(),A.current&&(A.current.style.height=`auto`))}finally{T(!1)}}},xe=e=>{if(!(k.current||e.nativeEvent.isComposing)){if(ce&&L){let t=I.indexOf(L);if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let n=e.key===`ArrowDown`?1:-1;x(I[(t+n+I.length)%I.length].id);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),ge(L);return}if(e.key===`Escape`){e.preventDefault(),C(P.start);return}}if(e.key===`Escape`&&a){e.preventDefault(),s();return}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),be())}},Se=e=>{O(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,te(!0))};return(0,$.jsxs)(Ye,{open:ce,children:[M.attachmentError&&(0,$.jsx)(`p`,{role:`alert`,className:`m-0 mb-2 text-[13px] text-danger`,children:M.attachmentError}),(0,$.jsx)(qe,{asChild:!0,children:(0,$.jsxs)(`form`,{"data-room-composer":!0,onSubmit:e=>{e.preventDefault(),be()},className:U(`relative flex min-w-0 flex-col rounded-[var(--composer-radius,22px)] border border-control bg-solid shadow-composer transition-[border-color,box-shadow] duration-(--d-fast) has-[textarea:focus]:border-focus has-[textarea:focus]:ring-3 has-[textarea:focus]:ring-focus-ring max-[650px]:rounded-[28px] max-[650px]:border-stroke-strong max-[650px]:shadow-none max-[650px]:has-[textarea:focus]:border-control max-[650px]:has-[textarea:focus]:ring-0 [&>.attachment-tray]:px-3 [&>.attachment-tray]:pt-3`,E&&`border-focus ring-3 ring-focus-ring`),onDragEnter:Se,onDragOver:Se,onDragLeave:e=>{let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||te(!1)},onDrop:e=>{te(!1),M.dropFiles(e)},children:[E&&(0,$.jsx)(`div`,{role:`status`,className:`pointer-events-none absolute inset-0 z-10 grid place-items-center rounded-[inherit] border border-dashed border-focus bg-panel px-4 text-center text-sm text-content`,children:p(`chat:focusSession.dropAttachment`)}),a&&(0,$.jsxs)(`div`,{className:`mx-3 mt-2.5 flex min-w-0 items-center gap-2 rounded-lg bg-surface-subtle px-2.5 py-1.5 text-[12.5px] text-content-secondary`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:p(`bots:room.replyTo`,{name:o,text:a.text.replace(/\s+/g,` `)||a.attachments.map(e=>e.name).join(`、`)||`…`})}),(0,$.jsx)(G,{variant:`ghost`,size:`icon-xs`,"aria-label":p(`bots:room.composer.cancelReply`),onClick:s,children:(0,$.jsx)(Pe,{})})]}),(0,$.jsx)(je,{attachments:M.attachments,preparing:M.preparingAttachments,onRemove:M.removeAttachment}),(0,$.jsx)(`textarea`,{ref:A,rows:1,value:g,maxLength:ir,"aria-label":p(`bots:room.composer.label`),"aria-autocomplete":`list`,"aria-expanded":ce,placeholder:l,enterKeyHint:`send`,className:`max-h-[220px] min-h-11 w-full min-w-0 resize-none overflow-y-auto border-0 bg-transparent px-4 pt-3 pb-1 text-[length:calc(var(--app-message-font-size)*.9375)] leading-5 text-content [font-family:var(--font-content-family)] [outline:0] placeholder:text-content-muted max-[650px]:px-3.5 max-[650px]:text-[length:var(--app-message-font-size)]`,onChange:e=>{_(e.target.value),y(e.target.selectionStart??e.target.value.length),e.currentTarget.style.height=`auto`,e.currentTarget.style.height=`${Math.min(e.currentTarget.scrollHeight,220)}px`},onSelect:e=>y(e.currentTarget.selectionStart??0),onPaste:M.pasteFiles,onCompositionStart:()=>k.current=!0,onCompositionEnd:()=>window.setTimeout(()=>k.current=!1,0),onKeyDown:xe}),(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1 px-2 pt-1 pb-2 max-[650px]:gap-2 max-[650px]:pb-3`,children:[ne.input,(0,$.jsxs)(Ke,{children:[(0,$.jsx)(We,{asChild:!0,children:(0,$.jsx)(G,{variant:`ghost`,size:`icon-sm`,className:`rounded-full`,"aria-label":p(`bots:room.composer.add`),title:p(`bots:room.composer.add`),children:(0,$.jsx)(oe,{})})}),(0,$.jsxs)(Ge,{align:`start`,side:`top`,className:`w-52`,onCloseAutoFocus:e=>{h.current&&(h.current=!1,e.preventDefault())},children:[(0,$.jsxs)(B,{onSelect:()=>void ne.choose(),children:[(0,$.jsx)(ie,{"aria-hidden":`true`}),p(`chat:focusSession.addAttachment`)]}),(0,$.jsxs)(B,{onSelect:()=>{h.current=!0,_e()},children:[(0,$.jsx)($t,{"aria-hidden":`true`}),p(`bots:room.composer.mentionMember`)]})]})]}),(0,$.jsx)(G,{variant:`ghost`,size:`icon-sm`,className:`rounded-full max-[650px]:hidden`,"aria-label":p(`chat:focusSession.addAttachment`),title:p(`chat:focusSession.addAttachment`),onClick:()=>void ne.choose(),children:(0,$.jsx)(ie,{})}),(0,$.jsx)(`span`,{id:m,className:`ml-1 flex-none text-[12.5px] text-content-muted`,children:p(`bots:room.composer.sendToLabel`)}),(0,$.jsxs)(`div`,{role:`group`,"aria-labelledby":m,"data-room-recipients":!0,onWheel:ve,className:`flex min-w-0 flex-1 items-center gap-1 overflow-x-auto overscroll-x-contain [scrollbar-width:none] pointer-coarse:-my-2.5 pointer-coarse:py-2.5 [&::-webkit-scrollbar]:hidden`,children:[j.map((e,t)=>{let n=le.includes(e.id),r=bt(e.avatar.color),i=n&&!R;return(0,$.jsxs)(Qt,{size:`sm`,"aria-pressed":n,disabled:!e.enabled,className:U(nr,!n&&rr),style:n?{background:r.fill,borderColor:i?r.line:`transparent`,boxShadow:i?`0 0 0 1px ${r.fill}, 0 0 14px -1px ${r.glow}`:`none`}:void 0,onClick:()=>ye(e.id,!n),children:[i&&(0,$.jsx)(lr,{delay:t*.3}),(0,$.jsx)(`span`,{"aria-hidden":`true`,className:U(`size-1.5 rounded-full`,!n&&`opacity-40`),style:{background:xt(e.avatar.color).shade,...i?{boxShadow:`0 0 6px ${r.glow}`}:{}}}),e.name,!e.enabled&&(0,$.jsxs)(`span`,{className:`font-normal text-content-muted`,children:[`· `,p(`bots:room.paused`)]})]},e.id)}),j.length>1&&(0,$.jsxs)(Qt,{size:`sm`,"data-room-recipients-everyone":!0,"aria-pressed":R,className:U(nr,!R&&rr),style:R?cr(j):void 0,onClick:()=>{R?u&&i([]):i(`all`)},children:[R&&(0,$.jsx)(lr,{delay:0}),p(`bots:room.composer.everyone`)]})]}),he?(0,$.jsx)(`span`,{"data-room-triage-hint":!0,className:`max-w-[40%] min-w-0 flex-none truncate px-1 text-[12px] text-content-muted max-[650px]:hidden`,children:p(`bots:room.composer.triageHint`)}):me>=3?(0,$.jsx)(`span`,{className:`flex-none px-1 text-[12px] text-content-muted max-[650px]:hidden`,children:p(`bots:room.composer.wakes`,{count:me})}):de&&!fe&&ue.length>0?(0,$.jsx)(`span`,{"data-room-addressed-only":!0,className:`max-w-[40%] min-w-0 flex-none truncate px-1 text-[12px] text-content-muted max-[650px]:hidden`,children:p(`bots:room.composer.addressedOnly`)}):f&&!de&&ue.length===0?(0,$.jsx)(`span`,{className:`max-w-[40%] min-w-0 flex-none truncate px-1 text-[12px] text-content-muted max-[650px]:hidden`,children:f}):null,(0,$.jsx)(ee,{queueing:!1,submitting:w,preparing:N,hasDraft:!!(g.trim()||re),disabled:!ae})]})]})}),(0,$.jsx)(Je,{side:`top`,align:`start`,className:`w-64 p-1`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),children:(0,$.jsx)(at,{value:L?.id||``,shouldFilter:!1,"aria-label":p(`bots:room.composer.mentionList`),children:(0,$.jsx)(it,{children:I.map(e=>(0,$.jsxs)(rt,{value:e.id,"data-room-mention-everyone":e.member?void 0:``,onMouseEnter:()=>x(e.id),onSelect:()=>ge(e),children:[e.member?(0,$.jsx)(J,{avatar:e.member.avatar,size:18,animate:!1}):(0,$.jsx)(Ne,{"aria-hidden":`true`,className:`size-[18px] p-0.5 text-content-muted`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name})]},e.id))})})})]})}function cr(e){let t=e.map(e=>bt(e.avatar.color)),n=e=>t.map(t=>t[e]).join(`, `);return{background:`linear-gradient(90deg, ${n(`fill`)}) padding-box, linear-gradient(var(--solid), var(--solid)) padding-box, linear-gradient(90deg, ${n(`line`)}) border-box`,borderColor:`transparent`,boxShadow:`0 0 14px -1px ${t[0]?.glow||`transparent`}`}}function lr({delay:e}){return(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 overflow-hidden rounded-[inherit]`,children:(0,$.jsx)(`span`,{className:`absolute inset-y-0 left-0 w-2/5 animate-[chip-sheen_3.6s_ease-in-out_infinite] bg-linear-to-r from-transparent via-white/85 to-transparent dark:via-white/45`,style:{animationDelay:`${e}s`}})})}function ur({open:e,onOpenChange:t,brief:n,members:r,onSave:i}){let{t:a}=d(),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``),[u,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(``),h=(0,Q.useRef)(!1);return(0,Q.useEffect)(()=>{e&&!h.current&&(s((n?.decisions||[]).join(`
|
|
4
|
+
`)),l((n?.todos||[]).map(e=>Kn(e,r)).join(`
|
|
5
|
+
`)),m(``)),h.current=e},[e,n,r]),(0,$.jsx)(dt,{open:e,onOpenChange:t,children:(0,$.jsx)(st,{className:`sm:max-w-lg`,children:(0,$.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),f(!0),m(``);try{await i({decisions:o.split(`
|
|
6
|
+
`).map(e=>e.trim()).filter(Boolean),todos:c.split(`
|
|
7
|
+
`).map(e=>qn(e,r)).filter(e=>!!e)}),t(!1)}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(!1)}},className:`contents`,children:[(0,$.jsxs)(ut,{children:[(0,$.jsx)(ct,{children:a(`bots:room.brief.editTitle`)}),(0,$.jsx)(ot,{children:a(`bots:room.brief.editDescription`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(gt,{htmlFor:`room-brief-decisions`,children:a(`bots:room.brief.decisionsLabel`)}),(0,$.jsx)(ft,{id:`room-brief-decisions`,rows:4,value:o,onChange:e=>s(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(gt,{htmlFor:`room-brief-todos`,children:a(`bots:room.brief.todosLabel`)}),(0,$.jsx)(ft,{id:`room-brief-todos`,rows:5,value:c,onChange:e=>l(e.target.value)})]}),p&&(0,$.jsx)(`p`,{role:`alert`,className:`m-0 text-sm text-destructive`,children:p})]}),(0,$.jsxs)(lt,{children:[(0,$.jsx)(G,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:a(`common:ui.cancel`)}),(0,$.jsx)(G,{type:`submit`,disabled:u,children:a(`bots:room.brief.save`)})]})]})})})}var dr=8;function fr({member:e}){let{t}=d(),{status:n}=e;return e.deleted?(0,$.jsx)($.Fragment,{children:t(`bots:room.removedBot`)}):e.enabled?n.waiting===`approval`?(0,$.jsx)($.Fragment,{children:t(`bots:room.member.approval`)}):n.waiting===`question`?(0,$.jsx)($.Fragment,{children:t(`bots:room.member.question`)}):n.state===`running`?n.current?(0,$.jsx)($.Fragment,{children:t(`bots:room.member.runningStep`,{step:n.current})}):(0,$.jsx)($.Fragment,{children:t(`bots:room.member.running`)}):e.unread>0?(0,$.jsx)($.Fragment,{children:t(`bots:room.member.unread`,{count:e.unread})}):(0,$.jsx)($.Fragment,{children:t(`bots:room.member.idle`)}):(0,$.jsx)($.Fragment,{children:t(`bots:room.member.paused`)})}function pr({detail:e,briefing:t,onTidy:n,onEditBrief:r}){let{t:i}=d(),{brief:a,members:o,room:s}=e,c=new Map(o.map(e=>[e.id,e])),l=s.briefBotId?c.get(s.briefBotId):null,u=Math.max(0,e.lastSeq-(a?.upToSeq||0)),f=l?(0,$.jsxs)(G,{variant:`ghost`,size:`xs`,disabled:t||!u,onClick:()=>n(),children:[t?(0,$.jsx)(W,{className:`size-3`}):(0,$.jsx)(De,{"aria-hidden":`true`}),i(t?`bots:room.brief.tidying`:`bots:room.brief.tidy`)]}):(0,$.jsxs)(Ke,{children:[(0,$.jsx)(We,{asChild:!0,children:(0,$.jsxs)(G,{variant:`ghost`,size:`xs`,disabled:t||!u,children:[t?(0,$.jsx)(W,{className:`size-3`}):(0,$.jsx)(De,{"aria-hidden":`true`}),i(t?`bots:room.brief.tidying`:`bots:room.brief.tidy`)]})}),(0,$.jsx)(Ge,{align:`end`,children:o.filter(e=>!e.deleted&&e.enabled).map(e=>(0,$.jsxs)(B,{onSelect:()=>n(e.id),children:[(0,$.jsx)(J,{avatar:e.avatar,size:16,animate:!1}),e.name]},e.id))})]});return(0,$.jsxs)(`section`,{"aria-labelledby":`room-brief-title`,className:`rounded-xl border border-stroke-soft bg-solid p-3 shadow-edge`,children:[(0,$.jsxs)(`header`,{className:`mb-2 flex items-center gap-1.5 text-[12.5px] font-semibold text-content`,children:[(0,$.jsx)(ae,{className:`size-3.5 text-content-muted`,"aria-hidden":`true`}),(0,$.jsx)(`h2`,{id:`room-brief-title`,className:`m-0 text-[12.5px] font-semibold`,children:i(`bots:room.brief`)}),(0,$.jsx)(`span`,{className:`flex-1`}),a?.by&&(0,$.jsx)(`span`,{className:`flex min-w-0 items-center gap-1 truncate text-[11.5px] font-normal text-content-muted`,children:a.by===`user`?i(`bots:room.brief.byYou`):(0,$.jsxs)($.Fragment,{children:[c.get(a.by)&&(0,$.jsx)(J,{avatar:c.get(a.by).avatar,size:12,animate:!1}),i(`bots:room.brief.by`,{name:c.get(a.by)?.name||i(`bots:room.removedBot`)})]})}),(0,$.jsx)(G,{variant:`ghost`,size:`icon-xs`,"aria-label":i(`bots:room.brief.edit`),title:i(`bots:room.brief.edit`),onClick:r,children:(0,$.jsx)(N,{})})]}),s.goal&&(0,$.jsxs)(`p`,{className:`m-0 mb-2 flex min-w-0 items-start gap-1.5 text-[12.5px] text-content-secondary`,children:[(0,$.jsx)(ke,{className:`mt-0.5 size-3.5 flex-none text-content-muted`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`min-w-0`,children:s.goal})]}),a&&(a.decisions.length||a.todos.length)?(0,$.jsxs)($.Fragment,{children:[a.decisions.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{className:`m-0 pt-1 pb-1 text-[11.5px] font-medium text-content-muted`,children:i(`bots:room.brief.decided`)}),(0,$.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0 text-[12.5px] text-content-secondary`,children:a.decisions.map((e,t)=>(0,$.jsxs)(`li`,{children:[`· `,e]},t))})]}),a.todos.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{className:`m-0 pt-3 pb-1 text-[11.5px] font-medium text-content-muted`,children:i(`bots:room.brief.todo`)}),(0,$.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1.5 p-0 text-[12.5px]`,children:a.todos.map((e,t)=>{let n=e.owner&&e.owner!==`user`?c.get(e.owner):null;return(0,$.jsxs)(`li`,{className:`flex items-center gap-2`,children:[e.done?(0,$.jsx)(x,{className:`size-3.5 flex-none text-content-muted`,"aria-label":i(`bots:room.brief.done`)}):(0,$.jsx)(en,{className:`size-3.5 flex-none text-content-muted`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:U(`min-w-0 flex-1 truncate`,e.done?`text-content-muted line-through`:`text-content`),children:e.text}),n?(0,$.jsx)(`span`,{title:n.name,children:(0,$.jsx)(J,{avatar:n.avatar,size:14,animate:!1})}):e.owner===`user`?(0,$.jsx)(`span`,{className:`text-[11px] text-content-muted`,children:i(`bots:room.you`)}):null]},t)})})]})]}):(0,$.jsx)(ht,{compact:!0,title:i(`bots:room.brief.empty`),description:l?i(`bots:room.brief.emptyWithBot`,{name:l.name}):i(`bots:room.brief.emptyHint`)}),(0,$.jsxs)(`footer`,{className:`mt-3 flex items-center gap-2 border-t border-stroke-soft pt-2 text-[11.5px] text-content-muted`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:a?.upToSeq?u?i(`bots:room.brief.coverage`,{seq:a.upToSeq,count:u}):i(`bots:room.brief.upToDate`):l?i(`bots:room.brief.by`,{name:l.name}):i(`bots:room.brief.noMaintainer`)}),f]})]})}function mr({detail:e,bots:t,hostAvailable:n,onOpenMember:r,onSave:i,onAnswerModeChange:a,onDelete:o,onError:s}){let{t:c}=d(),{members:l,room:u}=e,[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(!1),S=l.filter(e=>!e.deleted),C=t.filter(e=>!u.members.includes(e.id)),w=e=>e===`host`?S.some(e=>e.id===u.hostBotId)?u.hostBotId:S[0]?.id||``:u.hostBotId,T=async e=>{p(!0);try{return await i(e)}finally{p(!1)}},D=e=>void T({members:e,briefBotId:e.includes(u.briefBotId)?u.briefBotId:``,...n?{answerMode:u.answerMode,hostBotId:e.includes(u.hostBotId)?u.hostBotId:u.answerMode===`host`&&e[0]||``}:{}}),O=(e,t)=>async n=>{n.preventDefault();let r=t?.trim()??``;e===`name`&&!r||(r===u[e]||await T({[e]:r}))&&(e===`name`?h:_)(null)},ee=async()=>{if(!v){y(!0);try{let e=await mt(u.cwd,c(`bots:room.settings.folder`));e.status===`picked`?T({cwd:e.path}):e.status===`unavailable`&&x(!0)}catch(e){s(e)}finally{y(!1)}}},A=u.cwd.split(/[\\/]/).filter(Boolean).at(-1)||u.cwd;return(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`section`,{"aria-labelledby":`room-info-title`,className:`px-2`,children:[m===null?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,$.jsx)(`h2`,{id:`room-info-title`,className:`m-0 min-w-0 flex-1 truncate text-[15px] font-semibold text-content`,children:u.name}),(0,$.jsx)(G,{variant:`ghost`,size:`icon-xs`,"aria-label":c(`bots:room.info.rename`),title:c(`bots:room.info.rename`),onClick:()=>h(u.name),children:(0,$.jsx)(N,{})})]}):(0,$.jsxs)(`form`,{className:`flex items-center gap-1.5`,onSubmit:O(`name`,m),children:[(0,$.jsx)(K,{autoFocus:!0,value:m,maxLength:40,"aria-label":c(`bots:room.new.name`),disabled:f,onChange:e=>h(e.target.value),onKeyDown:e=>e.key===`Escape`&&h(null)}),(0,$.jsx)(G,{type:`submit`,size:`sm`,disabled:f||!m.trim(),children:c(`bots:room.settings.save`)})]}),g===null?(0,$.jsx)(`button`,{type:`button`,className:`mt-0.5 flex w-full min-w-0 items-start gap-1.5 rounded-[var(--r-sm)] text-left text-[12.5px] text-content-muted hover:text-content focus-visible:outline-2 focus-visible:outline-focus`,onClick:()=>_(u.goal),children:u.goal?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ke,{className:`mt-0.5 size-3.5 flex-none`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`min-w-0`,children:u.goal})]}):c(`bots:room.info.addGoal`)}):(0,$.jsxs)(`form`,{className:`mt-1.5 flex items-center gap-1.5`,onSubmit:O(`goal`,g),children:[(0,$.jsx)(K,{autoFocus:!0,value:g,maxLength:200,"aria-label":c(`bots:room.new.goal`),placeholder:c(`bots:room.new.goalPlaceholder`),disabled:f,onChange:e=>_(e.target.value),onKeyDown:e=>e.key===`Escape`&&_(null)}),(0,$.jsx)(G,{type:`submit`,size:`sm`,disabled:f,children:c(`bots:room.settings.save`)})]})]}),(0,$.jsx)(hr,{title:c(`bots:room.members.title`,{count:u.members.length,max:dr}),action:(0,$.jsxs)(Ke,{children:[(0,$.jsx)(We,{asChild:!0,children:(0,$.jsxs)(G,{variant:`ghost`,size:`xs`,disabled:f||!C.length||u.members.length>=dr,children:[(0,$.jsx)(oe,{"aria-hidden":`true`}),c(`bots:room.info.add`)]})}),(0,$.jsx)(Ge,{align:`end`,children:C.map(e=>(0,$.jsxs)(B,{onSelect:()=>D([...u.members,e.id]),children:[(0,$.jsx)(J,{avatar:e.avatar,size:16,animate:!1}),e.name]},e.id))})]}),children:(0,$.jsx)(`ul`,{className:`m-0 list-none p-0`,children:l.map(e=>{let t=!!e.status.waiting;return(0,$.jsxs)(`li`,{className:`flex items-center gap-0.5`,children:[(0,$.jsxs)(`button`,{type:`button`,disabled:!e.sessionId,title:e.sessionId?c(`bots:room.member.open`):void 0,onClick:()=>r(e),className:`flex min-w-0 flex-1 items-start gap-2.5 rounded-[var(--r-md)] px-2 py-1.5 text-left enabled:hover:bg-surface-hover focus-visible:outline-2 focus-visible:outline-focus`,children:[(0,$.jsx)(J,{avatar:e.avatar,size:22,animate:e.status.state!==`idle`,state:t?`need`:e.status.state===`running`?`running`:`idle`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-[13px] text-content`,children:e.name||c(`bots:room.removedBot`)}),(0,$.jsx)(`span`,{className:U(`block truncate text-[11.5px]`,t?`font-medium text-st-attn`:`text-content-muted`),children:(0,$.jsx)(fr,{member:e})})]})]}),(0,$.jsxs)(Ke,{children:[(0,$.jsx)(We,{asChild:!0,children:(0,$.jsx)(G,{variant:`ghost`,size:`icon-xs`,className:`flex-none text-content-muted`,"aria-label":c(`bots:room.info.memberMenu`,{name:e.name||c(`bots:room.removedBot`)}),children:(0,$.jsx)(E,{})})}),(0,$.jsxs)(Ge,{align:`end`,children:[(0,$.jsx)(B,{disabled:!e.sessionId,onSelect:()=>r(e),children:c(`bots:room.member.open`)}),(0,$.jsx)(Ue,{}),(0,$.jsx)(B,{variant:`destructive`,disabled:f||u.members.length<=1,onSelect:()=>D(u.members.filter(t=>t!==e.id)),children:c(`bots:room.info.removeMember`)})]})]})]},e.id)})})}),n&&(0,$.jsx)(hr,{title:c(`bots:room.settings.answerMode`),titleId:`room-answer-title`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 px-2`,children:[(0,$.jsx)(H,{size:`sm`,"aria-labelledby":`room-answer-title`,value:u.answerMode,onValueChange:e=>a(e,w(e)),options:[{value:`mention`,label:c(`bots:room.settings.answerMention`)},{value:`host`,label:c(`bots:room.settings.answerHost`)}]}),u.answerMode===`host`&&(0,$.jsx)(Y,{"aria-label":c(`bots:room.settings.host`),value:w(`host`),onChange:e=>a(`host`,e.target.value),children:S.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,$.jsx)(`p`,{className:`m-0 text-xs text-content-muted`,children:u.answerMode===`host`?c(`bots:room.settings.answerHostHint`):c(`bots:room.settings.answerMentionHint`)})]})}),(0,$.jsxs)(hr,{title:c(`bots:room.info.folder`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2`,children:[(0,$.jsx)(k,{className:`size-3.5 flex-none text-content-muted`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:U(`min-w-0 flex-1 truncate text-[12.5px]`,u.cwd?`font-mono text-content-secondary`:`text-content-muted`),title:u.cwd||void 0,children:u.cwd?A:c(`bots:room.info.folderNone`)}),u.cwd&&(0,$.jsx)(G,{variant:`ghost`,size:`icon-xs`,"aria-label":c(`bots:room.info.folderClear`),title:c(`bots:room.info.folderClear`),disabled:f,onClick:()=>void T({cwd:``}),children:(0,$.jsx)(Pe,{})}),(0,$.jsx)(G,{variant:`ghost`,size:`xs`,disabled:f||v,onClick:()=>void ee(),children:c(`bots:room.info.folderChange`)})]}),(0,$.jsx)(`p`,{className:`m-0 mt-1 px-2 text-xs text-content-muted`,children:c(`bots:room.settings.folderHint`)})]}),(0,$.jsx)(hr,{title:c(`bots:room.settings.briefBot`),titleId:`room-brief-bot-title`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 px-2`,children:[(0,$.jsxs)(Y,{"aria-labelledby":`room-brief-bot-title`,value:u.briefBotId,disabled:f,onChange:e=>void T({briefBotId:e.target.value}),children:[(0,$.jsx)(`option`,{value:``,children:c(`bots:room.settings.briefBotNone`)}),S.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,$.jsx)(`p`,{className:`m-0 text-xs text-content-muted`,children:c(`bots:room.settings.briefBotHint`)})]})}),(0,$.jsx)(`div`,{className:`border-t border-stroke-soft px-2 pt-3`,children:(0,$.jsxs)(G,{variant:`ghost`,size:`xs`,className:`text-destructive`,onClick:o,children:[(0,$.jsx)(Me,{"aria-hidden":`true`}),c(`bots:room.delete`)]})}),(0,$.jsx)(te,{open:b,initialPath:u.cwd,onOpenChange:x,onSelect:e=>{x(!1),T({cwd:e})}})]})}function hr({title:e,titleId:t,action:n,children:r}){return(0,$.jsxs)(`section`,{"aria-labelledby":t,children:[(0,$.jsxs)(`div`,{className:`mb-1 flex h-7 items-center gap-1.5 px-2`,children:[(0,$.jsx)(`h3`,{id:t,className:`m-0 min-w-0 flex-1 text-[12.5px] font-semibold text-content`,children:e}),n]}),r]})}function gr({entries:e,members:t,modeLabel:n,onOpenProcess:r,onApprove:i,onStop:a}){let{t:o}=d();return(0,$.jsx)(`div`,{"aria-live":`polite`,className:`mb-1.5 flex flex-col gap-0.5 empty:hidden`,children:e.map(e=>{let s=t.get(e.botId),c=e.message.turn,l=!!e.waiting,u=n(e.botId),d=e.approval?(e.approval.argsPreview.split(`
|
|
8
|
+
`).find(e=>e.trim())||``).trim()||e.approval.toolName:``,f=e.waiting?e.waiting===`approval`?d?o(`bots:room.status.wantsToRun`,{what:d}):``:c.current||o(`bots:room.card.questionHint`):c.current||(c.steps.at(-1)?`${c.steps.at(-1).name} ${c.steps.at(-1).summary}`.trim():o(`bots:room.card.reading`)),p=e.waiting?e.waiting===`question`?o(`bots:room.card.waitingQuestion`):o(`bots:room.card.waitingApproval`):o(`bots:room.status.working`),m=()=>c.sessionId&&r(c.sessionId),h=e.waiting===`approval`?e.approval:null;return(0,$.jsxs)(`div`,{"data-room-status":e.waiting||`running`,className:U(`flex min-w-0 items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-[13px]`,l&&`bg-st-attn-soft max-[650px]:flex-wrap`),children:[s&&(0,$.jsx)(J,{avatar:s.avatar,state:l?`need`:`running`,size:22}),(0,$.jsx)(`span`,{className:`flex-none font-medium text-content`,children:s?.name||o(`bots:room.removedBot`)}),(0,$.jsx)(`span`,{className:U(`flex-none`,l?`font-medium text-st-attn`:`text-content-muted`),children:p}),u&&(0,$.jsxs)(`span`,{className:`flex-none text-content-muted max-[650px]:hidden`,children:[`· `,u]}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[12px] text-content-secondary`,title:e.pending?o(`bots:room.card.pendingApproval`):void 0,children:f}),l?(0,$.jsxs)(`span`,{className:`flex flex-none items-center gap-2.5 max-[650px]:basis-full max-[650px]:justify-end`,children:[h&&h.severity!==`critical`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(G,{size:`sm`,variant:`outline`,onClick:()=>i(e.message,h.id,!0),children:o(`bots:room.card.approve`)}),(0,$.jsx)(G,{size:`sm`,variant:`outline`,onClick:()=>i(e.message,h.id,!1),children:o(`bots:room.card.deny`)})]}),(0,$.jsx)(G,{size:`sm`,variant:`outline`,disabled:!c.sessionId,title:h?.severity===`critical`?o(`bots:room.card.critical`):o(`bots:room.card.processHint`),onClick:m,children:o(`bots:room.status.view`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(G,{variant:`ghost`,size:`icon-sm`,"aria-label":o(`bots:room.card.stop`),title:o(`bots:room.card.stop`),onClick:()=>a(e.message),children:(0,$.jsx)(Oe,{})}),c.sessionId&&(0,$.jsx)(G,{variant:`ghost`,size:`icon-sm`,"aria-label":o(`bots:room.viewProcess`),title:o(`bots:room.viewProcess`),onClick:m,children:(0,$.jsx)(rn,{})})]})]},e.message.id)})})}function _r({count:e,chars:t,members:n,phone:r,onPick:i,onWrite:a,onLater:o,onSkip:s,onOpen:c}){let{t:l}=d();return r?(0,$.jsxs)(`button`,{type:`button`,onClick:c,className:`mb-2 flex w-full items-center gap-2 rounded-xl border border-stroke-soft bg-surface-subtle px-3 py-2.5 text-left text-[13px] text-content-secondary focus-visible:outline-2 focus-visible:outline-focus`,children:[(0,$.jsx)(an,{className:`size-4 flex-none text-content-muted`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:l(`bots:room.briefPrompt.short`,{count:e})}),(0,$.jsx)(`span`,{className:`flex-none font-medium text-content`,children:l(`bots:room.briefPrompt.shortAction`)})]}):(0,$.jsxs)(`div`,{role:`region`,"aria-label":l(`bots:room.briefPrompt.ask`),className:`mb-2 rounded-xl border border-stroke-soft bg-surface-subtle px-3 py-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(an,{className:`mt-0.5 size-4 flex-none text-content-muted`,"aria-hidden":`true`}),(0,$.jsxs)(`p`,{className:`m-0 flex-1 text-[13px] text-content-secondary`,children:[l(`bots:room.briefPrompt.text`,{count:e,thousands:Math.round(t/1e3)}),(0,$.jsx)(`span`,{className:`font-medium text-content`,children:l(`bots:room.briefPrompt.ask`)})]}),(0,$.jsx)(G,{variant:`ghost`,size:`icon-xs`,"aria-label":l(`bots:room.briefPrompt.close`),onClick:o,children:(0,$.jsx)(Pe,{})})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5 pl-6`,children:[(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:n.filter(e=>!e.deleted&&e.enabled).map(e=>(0,$.jsxs)(Qt,{size:`sm`,onClick:()=>i(e.id),children:[(0,$.jsx)(J,{avatar:e.avatar,size:14,animate:!1}),e.name]},e.id))}),(0,$.jsx)(G,{variant:`ghost`,size:`xs`,onClick:a,children:l(`bots:room.briefPrompt.write`)}),(0,$.jsx)(G,{variant:`ghost`,size:`xs`,onClick:o,children:l(`bots:room.briefPrompt.later`)}),(0,$.jsx)(G,{variant:`ghost`,size:`xs`,onClick:s,children:l(`bots:room.briefPrompt.skip`)})]})]})}var vr=8,yr=600;function br(e){let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function xr(e,t){let n=new Date(e);if(Number.isNaN(n.getTime()))return``;let r=new Date,i=new Date(r.getFullYear(),r.getMonth(),r.getDate()-1),a=er(e);return a===er(r.toISOString())?t(`bots:room.day.today`):a===er(i.toISOString())?t(`bots:room.day.yesterday`):n.toLocaleDateString([],{month:`long`,day:`numeric`,...n.getFullYear()===r.getFullYear()?{}:{year:`numeric`}})}function Sr({text:e,members:t}){let n=[...t.values()];return(0,$.jsx)($.Fragment,{children:Vn(e,n).map((e,n)=>{let r=e.memberId?t.get(e.memberId):null;if(!r&&!e.everyone)return(0,$.jsx)(`span`,{children:e.text},n);let i=r?xt(r.avatar.color):null;return(0,$.jsx)(`span`,{className:U(`rounded-[4px] px-0.5 font-medium`,!i&&`bg-surface-active`),style:i?{color:i.shade,background:i.tile}:void 0,children:e.text},n)})})}function Cr({label:e}){return(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-7 flex-none place-items-center rounded-full bg-content text-[12px] font-semibold text-panel`,children:Array.from(e)[0]||``})}function wr({message:e,members:t,onJump:n}){let{t:r}=d(),i=e.author.kind===`bot`?t.get(e.author.botId)?.name||r(`bots:room.removedBot`):r(`bots:room.you`),a=e.recalled?r(`bots:room.recalledShort`):e.text.replace(/\s+/g,` `)||e.attachments.map(e=>e.name).join(`、`);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),className:`mb-1 flex max-w-full min-w-0 items-center gap-1.5 rounded-sm border-l-2 border-stroke-strong py-0.5 pl-2 text-left text-[12.5px] text-content-muted hover:text-content-secondary focus-visible:outline-2 focus-visible:outline-focus`,children:[(0,$.jsx)(tn,{className:`size-3 flex-none`,"aria-hidden":`true`}),(0,$.jsxs)(`span`,{className:`truncate`,children:[r(`bots:room.quote.prefix`),(0,$.jsx)(`span`,{className:`font-medium text-content-secondary`,children:i}),r(`bots:room.quote.separator`),a]})]})}function Tr({children:e,className:t}){return(0,$.jsx)(`p`,{className:U(`m-0 my-2 text-center text-[12px] text-content-muted`,t),children:e})}function Er(e,t,n){return n(`bots:room.round.line`,{parts:e.map(e=>e.state===`skipped`?n(`bots:room.round.skippedBy`,{name:t(e.botId)}):e.state===`working`?n(`bots:room.round.workingBy`,{name:t(e.botId)}):n(`bots:room.round.repliedBy`,{name:t(e.botId)})).join(` · `)})}function Dr(e,t,n){if(e.type===`triaged`){let r=e.note;if(!e.bots.length)return r?n(`bots:room.system.triagedNobody`,{reason:r}):n(`bots:room.system.triagedNobodyPlain`);let i=e.bots.map(t).join(`、`);return r?n(`bots:room.system.triaged`,{names:i,reason:r}):n(`bots:room.system.triagedPlain`,{names:i})}let r=t(e.botId);if(e.type===`route_failed`)return e.reason===`host_paused`?n(`bots:room.system.routeHostPaused`,{host:r}):n(`bots:room.system.routeFailed`,{host:r});if(e.type!==`routed`)return``;let i=e.note;if(!e.bots.length)return i?n(`bots:room.system.routedNobody`,{host:r,reason:i}):n(`bots:room.system.routedNobodyPlain`,{host:r});let a=e.bots.map(t).join(`、`);return i?n(`bots:room.system.routed`,{host:r,names:a,reason:i}):n(`bots:room.system.routedPlain`,{host:r,names:a})}function Or({icon:e,children:t,...n}){return(0,$.jsxs)(G,{variant:`ghost`,size:`xs`,className:`text-content-muted hover:text-content`,...n,children:[e,t]})}function kr({items:e,messages:t,members:n,modelLabel:r,actions:i}){let{t:a}=d(),o=new Map(t.map(e=>[e.id,e])),s=e=>n.get(e)?.name||a(`bots:room.removedBot`),c=a(`bots:room.you`),l=(0,Q.useRef)(null),u=(0,Q.useId)(),[f,p]=(0,Q.useState)(new Set),m=e=>{let t=e.event;return t?.type===`paused`?a(`bots:room.system.paused`,{name:s(t.botId)}):t?.type===`chain_stopped`?a(`bots:room.system.chainStopped`,{from:s(t.from),to:s(t.to),reason:t.reason===`hops`?a(`bots:room.system.reason.hops`):t.reason===`rate`?a(`bots:room.system.reason.rate`):a(`bots:room.system.reason.total`)}):t?.type===`wake_failed`?t.reason===`attachment`?a(`bots:room.system.wakeFailedAttachment`,{name:s(t.botId)}):t.reason===`model`?a(`bots:room.system.wakeFailedModel`,{name:s(t.botId)}):a(`bots:room.system.wakeFailed`,{name:s(t.botId)}):t?Dr(t,s,a):``},h=e.filter(e=>!(e.kind===`card`&&Zn(e.message))&&(e.kind!==`system`||m(e.message))),[g,_]=(0,Q.useState)(``),v=h.some(e=>e.message.id===g)?g:h.at(-1)?.message.id||``,y=e=>{let t=h[e]?.message.id,n=t?l.current?.querySelector(`[data-room-message="${CSS.escape(t)}"]`):null;n instanceof HTMLElement&&(n.focus({preventScroll:!0}),n.scrollIntoView({block:`nearest`}))},b=e=>{let t=e.target;if(!(t instanceof HTMLElement))return;let n=t.closest(`[data-room-message]`);if(!(n instanceof HTMLElement)||!l.current?.contains(n)||t.closest(`input, textarea, select, [contenteditable="true"]`))return;let r=t===n||!t.closest(`button, a, [role="button"]`),a=h.findIndex(e=>e.message.id===n.dataset.roomMessage);if(a<0)return;let o=Xn(e,h[a],a,h.length,r);if(!o)return;e.preventDefault();let{message:s}=h[a];o.type===`move`?y(o.index):o.type===`reply`?i.onReply(s):o.type===`recall`?i.onRecall(s):s.turn?.sessionId&&i.onOpenProcess(s.turn.sessionId)},x=(e,t,n,r,i=``)=>{let o=h[t-1]?.message,s=er(e.at),c=s&&(!o||er(o.at)!==s);return(0,$.jsxs)(`article`,{"data-room-message":e.id,tabIndex:e.id===v?0:-1,"aria-label":n,"aria-posinset":t+1,"aria-setsize":h.length,onFocus:()=>_(e.id),className:U(`group/msg rounded-lg outline-none focus-visible:ring-2 focus-visible:ring-focus-ring focus-visible:ring-offset-2 focus-visible:ring-offset-panel`,i),children:[c&&(0,$.jsxs)(`div`,{"aria-hidden":`true`,className:`my-3 flex items-center gap-3 text-[12px] text-content-muted`,children:[(0,$.jsx)(`span`,{className:`h-px flex-1 bg-stroke-soft`}),xr(e.at,a),(0,$.jsx)(`span`,{className:`h-px flex-1 bg-stroke-soft`})]}),r]},e.id)},C=({avatar:e,author:t,meta:n,at:r,right:i,merged:a,children:o})=>(0,$.jsxs)(`div`,{className:U(`-mx-3 flex gap-3 rounded-lg px-3 transition-colors group-hover/msg:bg-surface-subtle`,a?`py-1`:`py-2.5`),children:[(0,$.jsx)(`div`,{className:`w-7 flex-none pt-0.5`,children:!a&&e}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[!a&&(0,$.jsxs)(`header`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-[13.5px] font-semibold text-content`,children:t}),n,(0,$.jsx)(`time`,{dateTime:r,className:`text-[12px] text-content-muted tabular-nums`,children:br(r)}),(0,$.jsx)(`span`,{className:`flex-1`}),i]}),(0,$.jsx)(`div`,{className:`mt-0.5 text-[length:calc(var(--app-message-font-size)*.9375)] leading-[1.65] break-words text-content [font-family:var(--font-content-family)]`,children:o})]})]}),w=(e,t)=>(0,$.jsxs)(`div`,{className:`mt-1 -ml-2 flex flex-wrap items-center gap-0.5`,children:[e,t&&(0,$.jsx)(`span`,{className:`hidden items-center gap-0.5 group-focus-within/msg:flex group-hover/msg:flex`,children:t})]}),T=e=>p(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),E=e=>{let t=e.text.length>yr||e.text.split(`
|
|
9
|
+
`).length>vr,n=f.has(e.id);return{long:t,open:n,body:(0,$.jsxs)(`div`,{className:U(`relative`,t&&!n&&`max-h-[9.9em] overflow-hidden`),children:[(0,$.jsx)(yt,{children:e.text}),t&&!n&&(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 h-12 bg-gradient-to-t from-[var(--main-surface-bg,var(--panel))] to-transparent group-hover/msg:from-surface-subtle`})]})}},D=e=>{let t=r(e),i=n.get(e);if(!t||!i)return null;let a=xt(i.avatar.color);return(0,$.jsx)(`span`,{className:`max-w-40 flex-none truncate rounded-[4px] px-1.5 py-px text-[11px] font-medium`,style:{color:a.shade,background:a.tile},children:t})};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{id:u,className:`sr-only`,children:a(`bots:room.timeline.hint`)}),(0,$.jsx)(`div`,{ref:l,role:`feed`,"aria-label":a(`bots:room.timeline.label`),"aria-describedby":u,className:`flex flex-col`,onKeyDown:b,children:h.map((e,t)=>{let{message:r}=e,l=r.replyTo?o.get(r.replyTo):null,u=br(r.at),d=h[t-1],f=!!d&&(d.kind===`user`||d.kind===`post`)&&(e.kind===`user`||e.kind===`post`)&&$n(d.message,r);if(e.kind===`system`){let e=m(r);return e?x(r,t,e,(0,$.jsx)(Tr,{children:e})):null}if(e.kind===`recalled`){let e=r.recalled?.seenBy.map(s)||[],n=r.author.kind===`user`?a(`bots:room.recalledMine`):a(`bots:room.recalledBot`,{name:r.author.kind===`bot`?s(r.author.botId):``});return x(r,t,n,(0,$.jsxs)(Tr,{className:`my-3`,children:[n,e.length>0&&` · ${a(`bots:room.seenBy`,{names:e.join(`、`)})}`]}))}if(e.kind===`user`)return x(r,t,[a(`bots:room.a11y.message`,{name:c,time:u}),r.attachments.length?a(`bots:room.a11y.attachments`,{count:r.attachments.length}):``].filter(Boolean).join(` · `),(0,$.jsxs)($.Fragment,{children:[C({avatar:(0,$.jsx)(Cr,{label:c}),author:c,at:r.at,merged:f,children:(0,$.jsxs)($.Fragment,{children:[l&&(0,$.jsx)(wr,{message:l,members:n,onJump:i.onJump}),r.text&&(0,$.jsx)(`div`,{className:`whitespace-pre-wrap`,children:(0,$.jsx)(Sr,{text:r.text,members:n})}),r.attachments.length>0&&(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(A,{attachments:Jn(r.attachments),compact:!0})}),w(null,(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Or,{icon:(0,$.jsx)(tn,{}),"aria-keyshortcuts":`R`,onClick:()=>i.onReply(r),children:a(`bots:room.reply`)}),(0,$.jsx)(Or,{icon:(0,$.jsx)(j,{}),"aria-keyshortcuts":`Delete`,onClick:()=>i.onRecall(r),children:a(`bots:room.recall`)})]}))]})}),e.round&&(0,$.jsx)(Tr,{children:Er(e.round,s,a)})]}));if(e.kind===`post`){let e=r.author.kind===`bot`?r.author.botId:``,o=n.get(e),{long:c,open:d,body:p}=E(r);return x(r,t,a(`bots:room.a11y.message`,{name:s(e),time:u}),C({avatar:o&&(0,$.jsx)(J,{avatar:o.avatar,size:28,animate:!1}),author:s(e),meta:D(e),at:r.at,merged:f,children:(0,$.jsxs)($.Fragment,{children:[l&&(0,$.jsx)(wr,{message:l,members:n,onJump:i.onJump}),p,c&&w((0,$.jsx)(Or,{icon:(0,$.jsx)(S,{className:U(d&&`rotate-180`)}),"aria-expanded":d,onClick:()=>T(r.id),children:a(d?`bots:room.card.collapse`:`bots:room.card.expand`)}),null)]})}))}let p=r.author.kind===`bot`?r.author.botId:``,g=n.get(p),_=r.turn,v=e.handoff?(0,$.jsx)(Tr,{children:a(`bots:room.handoff.line`,{from:s(e.handoff.from),to:s(p),hop:e.handoff.hop})}):null;if(_.state===`error`||_.state===`stopped`){let e=_.state===`error`?_.error?a(`bots:room.turn.errorLine`,{name:s(p),error:_.error}):a(`bots:room.turn.errorLinePlain`,{name:s(p)}):a(`bots:room.turn.stoppedLine`,{name:s(p)});return x(r,t,e,(0,$.jsxs)($.Fragment,{children:[v,(0,$.jsx)(Tr,{children:e})]}))}let y=(_.alsoAnswered||[]).map(e=>o.get(e)).filter(e=>!!e),{long:b,open:O,body:ee}=E(r);return x(r,t,a(`bots:room.a11y.message`,{name:s(p),time:u}),(0,$.jsxs)($.Fragment,{children:[v,C({avatar:g&&(0,$.jsx)(J,{avatar:g.avatar,size:28,animate:!1}),author:s(p),meta:D(p),at:r.at,right:(0,$.jsx)(`span`,{className:`flex-none rounded-full border border-stroke-soft px-1.5 py-px text-[11px] text-content-muted`,children:a(`bots:room.turnEnded`)}),merged:!1,children:(0,$.jsxs)($.Fragment,{children:[l&&(0,$.jsx)(wr,{message:l,members:n,onJump:i.onJump}),y.length>0&&(0,$.jsxs)(`p`,{className:`m-0 mb-1 text-[12px] text-content-muted`,children:[a(`bots:room.alsoAnsweredPrefix`),y.map((e,t)=>(0,$.jsxs)(`span`,{children:[t>0&&`、`,(0,$.jsxs)(`button`,{type:`button`,className:`underline decoration-stroke-strong underline-offset-2 hover:text-content-secondary focus-visible:outline-2 focus-visible:outline-focus`,onClick:()=>i.onJump(e.id),children:[`#`,e.seq]})]},e.id))]}),r.text?ee:(0,$.jsx)(`p`,{className:`m-0 text-[13px] text-content-muted`,children:a(`bots:room.card.emptyReply`)}),w((0,$.jsxs)($.Fragment,{children:[b&&(0,$.jsx)(Or,{icon:(0,$.jsx)(S,{className:U(O&&`rotate-180`)}),"aria-expanded":O,onClick:()=>T(r.id),children:a(O?`bots:room.card.collapse`:`bots:room.card.expand`)}),_.sessionId&&(0,$.jsx)(Or,{icon:(0,$.jsx)(rn,{}),title:a(`bots:room.card.processHint`),onClick:()=>i.onOpenProcess(_.sessionId),children:a(`bots:room.viewProcess`)}),(0,$.jsx)(Or,{icon:(0,$.jsx)(tn,{}),"aria-keyshortcuts":`R`,onClick:()=>i.onReply(r),children:a(`bots:room.reply`)})]}),(0,$.jsx)(Or,{icon:(0,$.jsx)(nn,{}),"aria-keyshortcuts":`Delete`,onClick:()=>i.onRecall(r),children:a(`bots:room.hide`)}))]})})]}))})})]})}function Ar(e,t,n){if(!t.length)return e;let r=new Map(e.map(e=>[e.id,e])),i=!1;for(let e of t){if(n.has(e.id)&&!e.recalled)continue;let t=r.get(e.id);t&&JSON.stringify(t)===JSON.stringify(e)||(r.set(e.id,e),i=!0)}return i?[...r.values()].sort((e,t)=>e.seq-t.seq):e}function jr(e,t){return!!e&&JSON.stringify(e)===JSON.stringify(t)}function Mr(e){return e.turn?.state===`running`||e.turn?.state===`waiting`}function Nr(e){let[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)([]),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!0),[l,u]=(0,Q.useState)(``),[d,p]=(0,Q.useState)(!1),m=(0,Q.useRef)(0),g=(0,Q.useRef)(0),_=(0,Q.useRef)(null),v=(0,Q.useRef)(!1),y=(0,Q.useRef)(!1),b=(0,Q.useRef)({timer:0,detail:!1}),x=(0,Q.useRef)(0),S=(0,Q.useRef)(new Set),C=(0,Q.useRef)([]),w=(0,Q.useRef)(0);C.current=r;let T=(t?.activity.working??0)>0||r.some(Mr),E=h(e=>e.capabilities.features[`rooms.events`]===!0);(0,Q.useEffect)(()=>E?et():void 0,[E]);let D=(0,Q.useCallback)(async({detail:t=!0}={})=>{let r=g.current,a=!1;if(_.current)return v.current=!0,t&&(y.current=!0),_.current;x.current=Date.now(),_.current=Promise.all([t?z(e):null,ye(e,{after:m.current,watch:C.current.filter(Mr).map(e=>e.id)})]).then(([e,t])=>{if(r!==g.current)return;e&&n(t=>jr(t,e)?t:e),i(e=>Ar(e,t.messages,S.current)),a=t.hasMore&&t.messages.length>0;let o=a?Math.max(...t.messages.map(e=>e.seq)):t.lastSeq;m.current=Math.max(m.current,o),u(``)}).catch(e=>{r===g.current&&(e instanceof f&&e.status===404&&p(!0),u(e instanceof Error?e.message:String(e)))}).finally(()=>{_.current=null}),await _.current;let o=a||v.current,s=y.current;v.current=!1,y.current=!1,o&&r===g.current&&await D({detail:s})},[e]);return(0,Q.useEffect)(()=>{g.current+=1;let t=g.current,r=new AbortController;return n(null),i([]),o(!1),c(!0),u(``),p(!1),m.current=0,S.current=new Set,Promise.all([z(e,r.signal),ye(e,{},r.signal)]).then(([e,r])=>{t===g.current&&(n(e),i(r.messages),o(r.hasMore),m.current=r.lastSeq)}).catch(e=>{t===g.current&&!r.signal.aborted&&u(e instanceof Error?e.message:String(e))}).finally(()=>{t===g.current&&c(!1)}),()=>{r.abort(),window.clearTimeout(w.current)}},[e]),(0,Q.useEffect)(()=>{if(s||d)return;let t=()=>document.visibilityState===`visible`,n=()=>{t()&&D()},r=window.setInterval(()=>{if(!t())return;let e=de({push:E,alive:nt(),busy:T});Date.now()-x.current>=e&&D()},le);document.addEventListener(`visibilitychange`,n);let i=b.current,a=E?tt(n=>{!ve(n,e)||!t()||(be(n)&&(i.detail=!0),!i.timer&&(i.timer=window.setTimeout(()=>{i.timer=0;let e=i.detail;i.detail=!1,D({detail:e})},350)))}):()=>{};return()=>{window.clearInterval(r),document.removeEventListener(`visibilitychange`,n),a(),window.clearTimeout(i.timer),i.timer=0}},[T,d,s,D,E,e]),{detail:t,messages:r,hasMore:a,loading:s,error:l,gone:d,busy:T,poll:D,pollSoon:(0,Q.useCallback)(()=>{D(),window.clearTimeout(w.current),w.current=window.setTimeout(()=>void D(),700)},[D]),loadOlder:(0,Q.useCallback)(async()=>{let t=C.current[0];if(!t)return;let n=g.current,r=await ye(e,{before:t.seq});n===g.current&&(i(e=>Ar(e,r.messages,S.current)),o(r.hasMore))},[e]),replace:(0,Q.useCallback)(e=>{e.recalled&&S.current.add(e.id),i(t=>Ar(t,[e],S.current))},[])}}function Pr(e){let n=String(t().roomId||``);return(0,$.jsx)(Fr,{roomId:n,...e},n)}function Fr({roomId:e,notify:t,phoneLeading:n}){let{t:r}=d(),i=a(),o=Xt(`bots`),s=g();Wt(o);let u=X(e=>e.bots),f=he(e=>e.upsert),p=he(e=>e.remove),m=h(e=>e.capabilities.features[`rooms.host`]===!0),_=Nr(e),{detail:v,messages:y}=_,[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(`brief`),[ee,te]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(0),[j,M]=(0,Q.useState)(!1),[ne,ie]=(0,Q.useState)(!1),[N,ae]=(0,Q.useState)(!1),[oe,se]=(0,Q.useState)(null),P=(0,Q.useRef)(new Set),F=(0,Q.useRef)(null),I=(0,Q.useRef)(null),L=(0,Q.useMemo)(()=>{let e=new Map((v?.members||[]).map(e=>[e.id,e]));for(let t of u)e.has(t.id)||e.set(t.id,{id:t.id,name:t.name,avatar:t.avatar,enabled:t.enabled,deleted:!1,sessionId:``,readSeq:0,unread:0,status:{state:`idle`,waiting:null,current:``}});return e},[v?.members,u]),le=(0,Q.useMemo)(()=>Bn(y),[y]),ue=(0,Q.useMemo)(()=>Qn(y),[y]),de=(0,Q.useMemo)(()=>new Map(u.map(e=>[e.id,e])),[u]),z=(0,Q.useCallback)(e=>t(e instanceof Error?e.message:String(e),`error`),[t]),ve=y.at(-1)?.id,ye=(0,Q.useRef)(!0),be=(0,Q.useCallback)(e=>{F.current=e,e&&ye.current&&(e.scrollTop=e.scrollHeight)},[ve,_.loading]),xe=v?.room.name||``;(0,Q.useEffect)(()=>{_.gone&&(p(e),t(r(`bots:room.gone`,{name:xe}),`error`),i(c(`bots`),{replace:!0}))},[xe,_.gone,i,t,p,e,r]);let Te=(e,t)=>{P.current.has(e)||(P.current.add(e),t().then(()=>_.poll()).catch(z).finally(()=>P.current.delete(e)))},De=e=>e.kind===`bot`?L.get(e.botId)?.name||r(`bots:room.removedBot`):r(`bots:room.you`),Oe={onReply:e=>x(e),onRecall:e=>{I.current={node:document.activeElement instanceof HTMLElement?document.activeElement:null,id:e.id},C(e)},onOpenProcess:e=>i(l(e)),onJump:e=>{let t=F.current?.querySelector(`[data-room-message="${CSS.escape(e)}"]`);t instanceof HTMLElement&&(t.focus({preventScroll:!0}),t.scrollIntoView({block:`center`,behavior:`smooth`}),t.classList.add(`ring-2`,`ring-focus-ring`),window.setTimeout(()=>t.classList.remove(`ring-2`,`ring-focus-ring`),1200))}},ke=async(t,n,r)=>{if(!v)return!1;try{let i=await ge(e,{text:t,...r.length?{attachments:r}:{},mentions:n,recipients:oe??v.room.recipients,...b?{replyTo:b.id}:{}});return _.replace(i.message),x(null),ye.current=!0,_.pollSoon(),!0}catch(e){return z(e),!1}},Ae=t=>{v&&(se(t),Ee(e,{recipients:t}).then(f).catch(e=>{se(null),z(e)}))},je=async()=>{let n=S;if(C(null),n)try{let i=await me(e,n.id);_.replace({...n,text:``,attachments:[],mentions:[],recalled:{seenBy:i.seenBy}}),i.briefMayContain&&t(r(`bots:room.recall.briefNote`)),i.attachmentsKept>0&&t(r(`bots:room.recall.attachmentsKept`,{count:i.attachmentsKept}))}catch(e){z(e)}},Me=async t=>{ae(!0);try{await pe(e,t),await _.poll()}catch(e){z(e)}finally{ae(!1)}},Pe=(t,n,r)=>Te(`approval:${n}`,()=>R(e,t.id,n,r)),qe=(t,n)=>{Ee(e,{answerMode:t,hostBotId:n}).then(e=>(se(null),f(e),_.poll())).catch(z)},Je=e=>{O(e),T(t=>t===e?null:e)},Ye=async t=>{try{return f(await Ee(e,t)),await _.poll(),!0}catch(e){return z(e),!1}},V=async()=>{ie(!1);try{await Se(e),p(e),t(r(`bots:room.deleted`,{name:v?.room.name||``})),i(c(`bots`))}catch(e){z(e)}};if(!o)return(0,$.jsx)(q,{kind:`empty`,title:r(`bots:room.labsOff`),description:r(`bots:room.labsOffHint`)});if(_.loading)return(0,$.jsx)(q,{kind:`loading`,title:r(`bots:room.loading`)});if(!v)return(0,$.jsx)(q,{kind:`error`,title:r(`bots:room.loadFailed`),description:_.error,action:(0,$.jsx)(G,{variant:`outline`,onClick:()=>i(c(`bots`)),children:r(`bots:room.backToBots`)})});let{room:H}=v,W=v.members.filter(e=>!e.deleted),et=m&&H.answerMode===`host`?L.get(H.hostBotId)?.name||r(`bots:room.removedBot`):``,tt=w===`members`?(0,$.jsx)(mr,{detail:v,bots:u,hostAvailable:m,onOpenMember:e=>e.sessionId&&i(l(e.sessionId)),onSave:Ye,onAnswerModeChange:qe,onDelete:()=>ie(!0),onError:z}):(0,$.jsx)(pr,{detail:v,briefing:N||v.briefing,onTidy:e=>void Me(e),onEditBrief:()=>M(!0)}),nt=r(w===`members`?`bots:room.header.info`:`bots:room.brief`),rt=ee||N||v.briefing?null:tr({messages:y,brief:v.brief,lastSeq:v.lastSeq,maintained:!!H.briefBotId,skipUpTo:k}),it=H.cwd.split(/[\\/]/).filter(Boolean).at(-1)||``,at=e=>{let t=de.get(e);return t?ce(r,t.model):``},ot=e=>{let t=de.get(e);return t?we(r,t.executionMode):``},st=S&&!S.turn?v.members.filter(e=>e.readSeq>=S.seq).map(e=>e.name):S?v.members.filter(e=>e.readSeq>=S.seq&&(S.author.kind!==`bot`||S.author.botId!==e.id)).map(e=>e.name):[];return(0,$.jsxs)(`div`,{"data-room-page":H.id,className:`flex h-full min-h-0 bg-[var(--main-surface-bg,var(--panel))]`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,$.jsxs)(`header`,{className:U(`flex h-[52px] flex-none items-center gap-2 px-4 max-[650px]:h-[calc(52px+var(--pisper-safe-area-top,0px))] max-[650px]:px-2 max-[650px]:pt-[var(--pisper-safe-area-top,0px)]`,!(w&&!s)&&`[[data-custom-titlebar]_&]:pr-[144px]`),children:[s&&n,(0,$.jsx)(_e,{avatars:W.map(e=>e.avatar)}),(0,$.jsx)(`h1`,{className:`m-0 min-w-0 truncate text-[15px] font-semibold text-content`,children:H.name}),(0,$.jsx)(`span`,{className:`flex-none text-[13px] text-content-muted max-[650px]:hidden`,children:it?r(`bots:room.header.summaryWithFolder`,{count:W.length,folder:it}):r(`bots:room.header.summary`,{count:W.length})}),(0,$.jsx)(`span`,{className:`flex-1`}),v.totalTokens>0&&(0,$.jsx)(`span`,{className:`flex-none text-[12px] text-content-muted tabular-nums max-[650px]:hidden`,children:r(`bots:room.usage`,{tokens:Gn(v.totalTokens)})}),!s&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(G,{variant:`ghost`,size:`sm`,"aria-pressed":w===`brief`,onClick:()=>Je(`brief`),children:[(0,$.jsx)(an,{}),r(`bots:room.brief`)]}),(0,$.jsxs)(G,{variant:`ghost`,size:`sm`,"aria-pressed":w===`members`,onClick:()=>Je(`members`),children:[(0,$.jsx)(Ne,{}),r(`bots:room.header.info`)]})]}),(0,$.jsxs)(Ke,{children:[(0,$.jsx)(We,{asChild:!0,children:(0,$.jsx)(G,{variant:`ghost`,size:`icon-sm`,"aria-label":r(`bots:room.more`),children:(0,$.jsx)(E,{})})}),(0,$.jsxs)(Ge,{align:`end`,children:[s&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(B,{onSelect:()=>T(`brief`),children:[(0,$.jsx)(an,{"aria-hidden":`true`}),r(`bots:room.brief`)]}),(0,$.jsxs)(B,{onSelect:()=>T(`members`),children:[(0,$.jsx)(Ne,{"aria-hidden":`true`}),r(`bots:room.header.info`)]}),(0,$.jsx)(Ue,{})]}),(0,$.jsx)(B,{onSelect:()=>M(!0),children:r(`bots:room.brief.edit`)}),(0,$.jsx)(Ue,{}),(0,$.jsx)(B,{variant:`destructive`,onSelect:()=>ie(!0),children:r(`bots:room.delete`)})]})]}),!s&&(0,$.jsx)(G,{variant:`ghost`,size:`icon-sm`,"aria-label":r(`bots:room.toggleRail`),"aria-pressed":!!w,onClick:()=>T(w?null:D),children:(0,$.jsx)(re,{})})]}),(0,$.jsx)(`div`,{ref:be,"data-room-timeline":!0,className:`min-h-0 flex-1 overflow-y-auto`,onScroll:e=>{let t=e.currentTarget;ye.current=t.scrollHeight-t.scrollTop-t.clientHeight<80},children:(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-[768px] px-6 pt-2 pb-4 max-[650px]:px-4`,children:[_.hasMore&&(0,$.jsx)(`div`,{className:`flex justify-center`,children:(0,$.jsx)(G,{variant:`ghost`,size:`sm`,onClick:()=>void _.loadOlder().catch(z),children:r(`bots:room.loadOlder`)})}),le.length?(0,$.jsx)(kr,{items:le,messages:y,members:L,modelLabel:at,actions:Oe}):(0,$.jsx)(q,{kind:`empty`,title:r(`bots:room.empty.title`),description:r(`bots:room.empty.description`)})]})}),(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-[816px] flex-none px-6 pb-4 max-[650px]:px-3 max-[650px]:pb-[calc(12px+var(--pisper-safe-area-bottom,0px))]`,children:[_.error&&(0,$.jsx)(`p`,{role:`status`,className:`m-0 mb-2 text-center text-[12px] text-content-muted`,children:r(`bots:room.reconnecting`)}),(0,$.jsx)(gr,{entries:ue,members:L,modeLabel:ot,onOpenProcess:e=>i(l(e)),onApprove:Pe,onStop:t=>Te(`stop:${t.id}`,()=>Ce(e,t.id))}),rt&&(0,$.jsx)(_r,{count:rt.count,chars:rt.chars,members:W,phone:s,onPick:e=>void Me(e),onWrite:()=>M(!0),onLater:()=>te(!0),onSkip:()=>A(v.lastSeq),onOpen:()=>T(`brief`)}),(0,$.jsx)(sr,{roomId:H.id,cwd:H.cwd||void 0,members:W,recipients:oe??H.recipients,onRecipientsChange:Ae,replyTo:b,replyName:b?De(b.author):``,onCancelReply:()=>x(null),onSend:ke,placeholder:et?r(s?`bots:room.composer.placeholderHostPhone`:`bots:room.composer.placeholderHost`,{name:et}):r(s?`bots:room.composer.placeholderPhone`:`bots:room.composer.placeholder`),idleLabel:et?r(`bots:room.composer.toHost`):void 0,idleHint:et?r(`bots:room.composer.hostHint`,{name:et}):void 0})]})]}),!s&&w&&(0,$.jsx)(`aside`,{"aria-label":nt,className:`w-[288px] flex-none overflow-y-auto border-l border-stroke-soft px-3 py-3 [[data-custom-titlebar]_&]:pt-[52px]`,children:tt}),s&&(0,$.jsx)($e,{open:!!w,onOpenChange:e=>!e&&T(null),children:(0,$.jsxs)(Xe,{side:`bottom`,className:`max-h-[85dvh] overflow-y-auto px-4 pt-12 pb-[calc(16px+var(--pisper-safe-area-bottom,0px))]`,children:[(0,$.jsx)(Ze,{className:`sr-only`,children:nt}),(0,$.jsx)(Qe,{className:`sr-only`,children:H.name}),tt]})}),(0,$.jsx)(ur,{open:j,onOpenChange:M,brief:v.brief,members:W,onSave:async t=>{await fe(e,t),await _.poll()}}),(0,$.jsx)(He,{open:!!S,onOpenChange:e=>!e&&C(null),children:(0,$.jsxs)(Le,{onCloseAutoFocus:e=>{let t=I.current;I.current=null;let n=t?.node?.isConnected?t.node:t?F.current?.querySelector(`[data-room-message="${CSS.escape(t.id)}"]`):null;n instanceof HTMLElement&&(e.preventDefault(),n.focus({preventScroll:!0}))},children:[(0,$.jsxs)(Ve,{children:[(0,$.jsx)(Ie,{children:S?.author.kind===`bot`?r(`bots:room.recallConfirm.hideTitle`):r(`bots:room.recallConfirm.title`)}),(0,$.jsxs)(Fe,{children:[r(`bots:room.recallConfirm.description`),st.length>0&&(0,$.jsxs)($.Fragment,{children:[` `,r(`bots:room.recallConfirm.seen`,{names:st.join(`、`)})]}),st.length>0&&!!S?.attachments.length&&(0,$.jsxs)($.Fragment,{children:[` `,r(`bots:room.recallConfirm.attachments`)]})]})]}),(0,$.jsxs)(ze,{children:[(0,$.jsx)(Be,{children:r(`common:ui.cancel`)}),(0,$.jsx)(Re,{onClick:()=>void je(),children:S?.author.kind===`bot`?r(`bots:room.hide`):r(`bots:room.recall`)})]})]})}),(0,$.jsx)(He,{open:ne,onOpenChange:ie,children:(0,$.jsxs)(Le,{children:[(0,$.jsxs)(Ve,{children:[(0,$.jsx)(Ie,{children:r(`bots:room.deleteConfirm.title`,{name:H.name})}),(0,$.jsx)(Fe,{children:r(`bots:room.deleteConfirm.description`)})]}),(0,$.jsxs)(ze,{children:[(0,$.jsx)(Be,{children:r(`common:ui.cancel`)}),(0,$.jsx)(Re,{variant:`destructive`,onClick:()=>void V(),children:r(`bots:room.delete`)})]})]})})]})}export{Ln as BotsPage,Pr as RoomPage};
|