@openhands/agent-canvas 1.0.0-beta.7 → 1.0.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/README.md +2 -2
  2. package/build/assets/{acp-providers-CPdgcp13.js → acp-providers-BAX8OU5C.js} +1 -1
  3. package/build/assets/{acp-route-guard-BoVmCn0e.js → acp-route-guard-HPk6TV-L.js} +1 -1
  4. package/build/assets/{active-backend-context-Beu-LZL-.js → active-backend-context-BSPE-W72.js} +1 -1
  5. package/build/assets/{add-backend-modal-BheqYXHK.js → add-backend-modal-mXKmfMI2.js} +1 -1
  6. package/build/assets/agent-server-client-options-9agOSarV.js +1 -0
  7. package/build/assets/{agent-server-compatibility-CdI3N7dr.js → agent-server-compatibility-B7QStIcH.js} +1 -1
  8. package/build/assets/{agent-server-conversation-service.api-CORdqJZg.js → agent-server-conversation-service.api-B9TUYJon.js} +3 -3
  9. package/build/assets/{agent-settings-UFvcGjoI.js → agent-settings-g3F623RJ.js} +1 -1
  10. package/build/assets/{analytics-consent-form-modal-CVNugqzu.js → analytics-consent-form-modal-BQCNeNVt.js} +1 -1
  11. package/build/assets/{api-key-entry-screen-M6su2VSf.js → api-key-entry-screen-myuWMqzW.js} +1 -1
  12. package/build/assets/{app-settings-BlvBhBdc.js → app-settings-CCcX8ZEH.js} +1 -1
  13. package/build/assets/{automation-detail-BWrQk4Oa.js → automation-detail-BDHLHSJd.js} +1 -1
  14. package/build/assets/{automations-list-ux9KvYsU.js → automations-list-CiNtQhq_.js} +1 -1
  15. package/build/assets/{backend-form-modal-CDnEYjaU.js → backend-form-modal-D3bDMO3C.js} +1 -1
  16. package/build/assets/{backend-synced-settings-badge-BTIj-Ffq.js → backend-synced-settings-badge-BkW5evM0.js} +1 -1
  17. package/build/assets/{condenser-settings-BolbDvm5.js → condenser-settings-DCTulgLO.js} +1 -1
  18. package/build/assets/conversation-BKhikfYl.js +1 -0
  19. package/build/assets/{conversation-D0N4dw_p.js → conversation-DTn8jN8L.js} +3 -3
  20. package/build/assets/conversation-panel-DfHR42mG.js +1 -0
  21. package/build/assets/{conversation-service.api-BsJy6uuL.js → conversation-service.api-B6CkzaKD.js} +1 -1
  22. package/build/assets/{conversation-websocket-context-DvHgx_FE.js → conversation-websocket-context-DShEuLjh.js} +1 -1
  23. package/build/assets/{edit-automation-modal-BpX-t-HD.js → edit-automation-modal-DamwL0s0.js} +1 -1
  24. package/build/assets/{entry.client-Ck9rQCg-.js → entry.client-Cn71WM8q.js} +1 -1
  25. package/build/assets/{extensions-hub-CE9QOb5n.js → extensions-hub-CUEmfvGy.js} +1 -1
  26. package/build/assets/{extensions-navigation-DSLGNGbS.js → extensions-navigation-VQ-3umJ7.js} +1 -1
  27. package/build/assets/{files-tab-cL668j1I.js → files-tab-C47fQEeL.js} +1 -1
  28. package/build/assets/{git-control-bar-branch-button-DtIrOrie.js → git-control-bar-branch-button-BT0aWH-o.js} +1 -1
  29. package/build/assets/{git-provider-icon-CHdGBdU2.js → git-provider-icon-Pi-Cxpgv.js} +1 -1
  30. package/build/assets/{home-Cz2Veg56.js → home-C3k6sFvB.js} +1 -1
  31. package/build/assets/{install-server-modal-B9nXCS3u.js → install-server-modal-6fuq-TU6.js} +1 -1
  32. package/build/assets/{launch-CWz0dm4o.js → launch-DGghLfGx.js} +1 -1
  33. package/build/assets/{llm-client-CYEaUjGx.js → llm-client-BqyLKgUN.js} +1 -1
  34. package/build/assets/{llm-settings-DFkXHuvT.js → llm-settings-BKraGtOu.js} +1 -1
  35. package/build/assets/llm-settings-DRQTgOF1.js +1 -0
  36. package/build/assets/{manage-backends-modal-DpBD_vR9.js → manage-backends-modal-CRMwyU0t.js} +1 -1
  37. package/build/assets/{manage-workspaces-modal-CtRbxREx.js → manage-workspaces-modal-BYmGD1W7.js} +1 -1
  38. package/build/assets/{manifest-eed90ff5.js → manifest-99b06a11.js} +1 -1
  39. package/build/assets/{mcp-BUe7kiYM.js → mcp-CfDRAmPn.js} +1 -1
  40. package/build/assets/{messages-dqp_KYyl.js → messages-Ba1vaw6t.js} +1 -1
  41. package/build/assets/{model-selector-BvSTrkhT.js → model-selector-DcztJSxT.js} +1 -1
  42. package/build/assets/{option-service.api-DmNVxAvS.js → option-service.api-CGNANEcT.js} +1 -1
  43. package/build/assets/{organization-service.api-DbnougaQ.js → organization-service.api-BeuMC9QL.js} +1 -1
  44. package/build/assets/{path-utils-onx24uF5.js → path-utils-z12iCrQO.js} +1 -1
  45. package/build/assets/{planner-tab-CmIjLz7q.js → planner-tab-Dte6Vzza.js} +1 -1
  46. package/build/assets/{profiles-client-fEmgWkCW.js → profiles-client-BrqNmaDV.js} +1 -1
  47. package/build/assets/{providers-CbD7fiic.js → providers-eUyo6pgr.js} +1 -1
  48. package/build/assets/{proxy-BAdHH8QB.js → proxy-BqDMnUY-.js} +1 -1
  49. package/build/assets/{recommended-automations-launcher-uTyODuzB.js → recommended-automations-launcher-D5ADbXao.js} +1 -1
  50. package/build/assets/{root-DmjpFpTu.js → root-BmhaEJJ8.js} +2 -2
  51. package/build/assets/{root-layout-DejMsKhy.js → root-layout-CNggm0d8.js} +2 -2
  52. package/build/assets/{sdk-section-page-BgDlMhcq.js → sdk-section-page-CRCRY3PG.js} +1 -1
  53. package/build/assets/{secrets-service-B7CxNinp.js → secrets-service-B9AFn9OE.js} +1 -1
  54. package/build/assets/{secrets-settings-yK7CqIpm.js → secrets-settings-0UrKMS60.js} +1 -1
  55. package/build/assets/{server-client-Kh4QSwDJ.js → server-client-DYv_GHPl.js} +1 -1
  56. package/build/assets/{settings-DN5PpgRD.js → settings-6t6LGW04.js} +1 -1
  57. package/build/assets/{settings-index-DKC8IY1P.js → settings-index-CR6Ou73o.js} +1 -1
  58. package/build/assets/{settings-modal-DJ4kGzUx.js → settings-modal-T_Yk1Zfo.js} +1 -1
  59. package/build/assets/{settings-service.api-C3rxTtPj.js → settings-service.api-DwtyDeGh.js} +1 -1
  60. package/build/assets/{shared-conversation-h9YnBtCU.js → shared-conversation-BzccsVej.js} +1 -1
  61. package/build/assets/{sidebar-mobile-menu-toggle-D0-AvsnT.js → sidebar-mobile-menu-toggle-DGlRg6jG.js} +1 -1
  62. package/build/assets/{sidebar-nav-link-OhIeFyna.js → sidebar-nav-link-dgVb8Fpy.js} +1 -1
  63. package/build/assets/{skills-plugins-DNcsNF88.js → skills-plugins-DctDrZ8Y.js} +1 -1
  64. package/build/assets/{skills-settings-7liFiSY6.js → skills-settings-rvxImDj_.js} +1 -1
  65. package/build/assets/{terminal-CDhQGDua.js → terminal-KldRPIRT.js} +1 -1
  66. package/build/assets/{use-active-conversation-DHGcmjCK.js → use-active-conversation-sPgfSkql.js} +1 -1
  67. package/build/assets/{use-agent-settings-schema-CLoTOSJI.js → use-agent-settings-schema-B66kGIi_.js} +1 -1
  68. package/build/assets/{use-agent-state-PKrUPMJ3.js → use-agent-state-Dp3pD1h3.js} +1 -1
  69. package/build/assets/{use-cloud-current-user-id-Ddr75hEz.js → use-cloud-current-user-id-ClKFPjFz.js} +1 -1
  70. package/build/assets/{use-config-OIMQLQ2s.js → use-config-C9pvb0Sm.js} +1 -1
  71. package/build/assets/{use-create-conversation-Bszyp13O.js → use-create-conversation-B-lwTnfE.js} +1 -1
  72. package/build/assets/{use-get-secrets-8Jby8ele.js → use-get-secrets-oyC7PFRz.js} +1 -1
  73. package/build/assets/{use-handle-plan-click-CohJPvvW.js → use-handle-plan-click-DP6Rs-YP.js} +1 -1
  74. package/build/assets/{use-llm-profiles-C861aFAq.js → use-llm-profiles-Bh5JqZUZ.js} +1 -1
  75. package/build/assets/use-runtime-is-ready-BakOUVU-.js +1 -0
  76. package/build/assets/{use-save-settings-DkAOEfD9.js → use-save-settings-uXXkqvD7.js} +1 -1
  77. package/build/assets/{use-settings-D5hbTS9t.js → use-settings-DeO7nvpM.js} +1 -1
  78. package/build/assets/{use-settings-nav-items-BcSbo02d.js → use-settings-nav-items-BGMFn25b.js} +1 -1
  79. package/build/assets/{use-skills-D7PS0fH0.js → use-skills-DWIK3l3a.js} +1 -1
  80. package/build/assets/{use-unified-vscode-url-DEoe-NRI.js → use-unified-vscode-url-DXPtB317.js} +1 -1
  81. package/build/assets/{use-user-conversation-Cs5H1pUF.js → use-user-conversation-DJen4YIP.js} +1 -1
  82. package/build/assets/{vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~dp08i1qy-hTzSytKK.js → vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~dp08i1qy-D8soyAAx.js} +1 -1
  83. package/build/assets/{verification-settings-Dlt8pINd.js → verification-settings-C_zHuDx9.js} +1 -1
  84. package/build/assets/{vscode-tab-DgepcYtF.js → vscode-tab-DH9x7xXS.js} +1 -1
  85. package/build/index.html +4 -4
  86. package/dist/api/agent-server-config.cjs +1 -1
  87. package/dist/api/agent-server-config.cjs.map +1 -1
  88. package/dist/api/agent-server-config.d.ts +17 -0
  89. package/dist/api/agent-server-config.js +7 -1
  90. package/dist/api/agent-server-config.js.map +1 -1
  91. package/dist/package.cjs +1 -1
  92. package/dist/package.cjs.map +1 -1
  93. package/dist/package.js +1 -1
  94. package/dist/package.js.map +1 -1
  95. package/package.json +1 -1
  96. package/scripts/static-server.mjs +15 -3
  97. package/build/assets/agent-server-client-options-HEOwGVIU.js +0 -1
  98. package/build/assets/conversation-DhRJuZLG.js +0 -1
  99. package/build/assets/conversation-panel-CNqHbS_Z.js +0 -1
  100. package/build/assets/llm-settings-DhrdCXqX.js +0 -1
  101. package/build/assets/use-runtime-is-ready-Do2h_hRl.js +0 -1
@@ -1,3 +1,3 @@
1
- import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{t as n}from"./vendor~root~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-s~f2l2lr17-DYXOLEck.js";import{i as r,l as i,n as a}from"./path-utils-onx24uF5.js";import{t as o}from"./useMutation-GSSKKebK.js";import{o as s}from"./declaration-CR6HMp29.js";import{n as ee}from"./QueryClientProvider-Cnr-Yl3j.js";import{t as c}from"./createLucideIcon-Ddu8jDOQ.js";import{a as l,d as u,n as d,o as f,r as p}from"./agent-server-client-options-HEOwGVIU.js";import{n as m}from"./vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~skills-set~jfc6hidu-DJS-rJdI.js";import{i as h}from"./vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~dp08i1qy-hTzSytKK.js";import{o as g,t as _}from"./agent-server-conversation-service.api-CORdqJZg.js";import{t as v}from"./proxy-BAdHH8QB.js";import{t as y}from"./react-Dy05vyj5.js";import{n as b}from"./middleware-CfatjPYZ.js";import{a as te}from"./conversation-local-storage-YmOVXxxW.js";import{t as x}from"./conversation-store-CC-isCnP.js";import{t as S}from"./v4-khGvL7i2.js";import{t as C}from"./use-user-conversation-Cs5H1pUF.js";import{t as ne}from"./conversation-state-store-D-w0uurj.js";import{C as w,_ as T,a as E,b as re,c as ie,d as ae,f as oe,g as se,h as ce,i as le,l as ue,m as de,o as fe,p as pe,r as D,s as me,t as O,u as he,v as k,x as ge,y as _e}from"./use-event-store-BomO7ywK.js";import{t as ve}from"./command-store-CE1weJy8.js";import{t as A}from"./browser-store-DAsixKdU.js";import{t as j}from"./files-tab-store-m0ARqX_E.js";var M=c(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),N=e(t(),1),ye=(e,t)=>{let[n,r]=N.useState(!1),[i,a]=N.useState(null),[o,s]=N.useState([]),[ee,c]=N.useState(null),[l,u]=N.useState(!1),d=N.useRef(null),f=N.useRef(0),p=N.useRef(null),m=N.useRef(!0),h=N.useRef(new WeakSet),g=N.useRef(t);N.useEffect(()=>{g.current=t},[t]);let _=N.useCallback(()=>{let t=e;if(g.current?.queryParams){let n=Object.entries(g.current.queryParams).reduce((e,[t,n])=>(e[t]=String(n),e),{});t=`${e}?${new URLSearchParams(n).toString()}`}let n=new WebSocket(t);d.current=n,h.current.add(n),n.onopen=e=>{r(!0),c(null),u(!1),f.current=0,g.current?.onOpen?.(e)},n.onmessage=e=>{a(e.data),s(t=>[...t,e.data]),g.current?.onMessage?.(e)},n.onclose=e=>{let t=h.current.has(n);r(!1),e.code!==1e3&&(c(Error(`WebSocket closed with code ${e.code}: ${e.reason||`Connection closed unexpectedly`}`)),t&&g.current?.onError?.(e)),g.current?.onClose?.(e);let i=g.current?.reconnect?.enabled??!1,a=g.current?.reconnect?.maxAttempts??1/0;i&&t&&m.current&&f.current<a?(u(!0),f.current+=1,p.current=setTimeout(()=>{_()},3e3)):u(!1)},n.onerror=e=>{r(!1),g.current?.onError?.(e)}},[e]);N.useEffect(()=>(m.current=!0,f.current=0,e&&e.trim()!==``&&_(),()=>{if(m.current=!1,p.current&&=(clearTimeout(p.current),null),d.current){let{readyState:e}=d.current;h.current.delete(d.current),(e===WebSocket.CONNECTING||e===WebSocket.OPEN)&&d.current.close(),d.current=null}}),[e,_]);let v=N.useCallback(e=>{d.current?.readyState===WebSocket.OPEN&&d.current.send(e)},[]),y=N.useCallback(()=>{m.current=!1,u(!1),p.current&&=(clearTimeout(p.current),null),d.current&&(h.current.delete(d.current),d.current.close())},[]),b=N.useCallback(()=>{if(m.current=!0,f.current=0,u(!0),c(null),p.current&&=(clearTimeout(p.current),null),d.current){let e=d.current;h.current.delete(e),d.current=null,(e.readyState===WebSocket.CONNECTING||e.readyState===WebSocket.OPEN)&&e.close()}_()},[_]);return{isConnected:n,lastMessage:i,messages:o,error:ee,socket:d.current,sendMessage:v,isReconnecting:l,attemptCount:f.current,disconnect:y,reconnect:b}},P=`Unable to connect to server`,F={errorMessage:null,errorType:null},be=y(e=>({...F,setErrorMessage:(t,n=`conversation`)=>e(()=>({errorMessage:t,errorType:n})),removeErrorMessage:()=>e(()=>({errorMessage:null,errorType:null})),clearConnectionError:()=>e(e=>e.errorType===`connection`?{errorMessage:null,errorType:null}:e)})),I=15e4,L={pendingMessages:[]},R=()=>`pending-${Date.now()}-${Math.random().toString(36).slice(2,10)}`,xe=y((e,t)=>({...L,enqueuePendingMessage:n=>{let r=R(),i={id:r,conversationId:n.conversationId,text:n.text,content:n.content??n.text,status:`sending`,imageUrls:n.imageUrls??[],fileUrls:n.fileUrls??[],timestamp:n.timestamp??new Date().toISOString()};return e(e=>({pendingMessages:[...e.pendingMessages,i]})),setTimeout(()=>{t().pendingMessages.find(e=>e.id===r)?.status===`sending`&&t().markPendingMessageError(r,`Send timed out`)},I),r},markPendingMessageError:(t,n)=>e(e=>({pendingMessages:e.pendingMessages.map(e=>e.id===t?{...e,status:`error`,errorMessage:n}:e)})),markPendingMessageSending:t=>e(e=>({pendingMessages:e.pendingMessages.map(e=>e.id===t?{...e,status:`sending`,errorMessage:void 0}:e)})),removePendingMessage:t=>e(e=>({pendingMessages:e.pendingMessages.filter(e=>e.id!==t)})),consumeMatchingPendingMessage:(t,n)=>{let r=null;return e(e=>{let i=e.pendingMessages.map((e,t)=>({m:e,i:t})).filter(({m:e})=>e.status===`sending`&&e.conversationId===t);if(i.length===0)return e;let a=i.find(({m:e})=>e.content===n)??i[0];return r=a.m,{pendingMessages:[...e.pendingMessages.slice(0,a.i),...e.pendingMessages.slice(a.i+1)]}}),r},clearPendingMessages:()=>e(()=>({...L})),reassignPendingMessages:(t,n)=>e(e=>({pendingMessages:e.pendingMessages.map(e=>e.conversationId===t?{...e,conversationId:n}:e)}))})),z=new Set([`files`,`browser`,`vscode`,`terminal`,`planner`,`tasklist`]);function B(e){let t=x.getState();t.setSelectedTab(e),t.isRightPanelShown||(t.setHasRightPanelToggled(!0),t.setIsRightPanelShown(!0))}function V(e){return z.has(e)}function Se(e){switch(e.command){case`navigate_to_file`:case`show_preview`:B(`files`),e.path&&j.getState().setSelectedPath(e.path);return;case`open_tab`:e.tab&&V(e.tab)?B(e.tab):e.tab&&console.warn(`[canvas_ui] Ignoring open_tab with unknown tab: ${e.tab}`);return}}var H=(e,t,n)=>({entriesByConversation:{...e.entriesByConversation,[t]:[...e.entriesByConversation[t]??[],n]}}),U=y()(b(e=>({entriesByConversation:{},activeProfileByConversation:{},show:(t,n,r)=>e(e=>H(e,t,{id:S(),anchorEventId:n,profiles:r})),recordSwitch:(t,n,r)=>e(e=>({...H(e,t,{id:S(),anchorEventId:n,profiles:[],switchedTo:r}),activeProfileByConversation:{...e.activeProfileByConversation,[t]:r}})),clearActiveProfile:t=>e(e=>{if(!(t in e.activeProfileByConversation))return e;let n={...e.activeProfileByConversation};return delete n[t],{activeProfileByConversation:n}}),clear:t=>e(e=>{let n={...e.entriesByConversation};delete n[t];let r={...e.activeProfileByConversation};return delete r[t],{entriesByConversation:n,activeProfileByConversation:r}}),clearAll:()=>e({entriesByConversation:{},activeProfileByConversation:{}})}),{name:`ModelStore`})),Ce=(e,t,n)=>{let{action:r}=e;if((r.kind===`StrReplaceEditorAction`||r.kind===`FileEditorAction`||r.kind===`ExecuteBashAction`)&&n.invalidateQueries({queryKey:[`file_changes`,t]},{cancelRefetch:!1}),(r.kind===`StrReplaceEditorAction`||r.kind===`FileEditorAction`)&&r.path){let e=a(r.path);n.invalidateQueries({queryKey:[`file_diff`,t,e]})}e.tool_name===`SwitchLLMTool`&&(n.invalidateQueries({queryKey:[`user`,`conversation`,t]}),U.getState().clearActiveProfile(t))},W=class{static async respondToConfirmation(e,t,n,r){let i=u().backend;return i.kind===`cloud`?v({backend:i,method:`POST`,hostOverride:l(t),path:`/api/conversations/${e}/events/respond_to_confirmation`,body:n,authMode:`session-api-key`,sessionApiKey:r}):new g(d({conversationUrl:t,sessionApiKey:r})).respondToConfirmation(e,n)}static async getEventCount(e,t,n){let r=u().backend;return r.kind===`cloud`?v({backend:r,method:`GET`,hostOverride:l(t),path:`/api/conversations/${e}/events/count`,authMode:`session-api-key`,sessionApiKey:n}):new g(d({conversationUrl:t,sessionApiKey:n})).getEventCount(e)}static async searchEvents(e,t,n,r={}){let i=u().backend,a=r.limit??100;if(i.kind===`cloud`){let t=Math.min(a,100),n=!!(r.sortOrder||r.pageId||r.timestampGte||r.timestampLt),o=new URLSearchParams;o.set(`limit`,String(t)),r.sortOrder&&o.set(`sort_order`,r.sortOrder),r.pageId&&o.set(`page_id`,r.pageId),r.timestampGte&&o.set(`timestamp__gte`,r.timestampGte),r.timestampLt&&o.set(`timestamp__lt`,r.timestampLt);let s=t=>v({backend:i,method:`GET`,path:`/api/v1/conversation/${e}/events/search?${t.toString()}`});try{let e=await s(o);return{items:e?.items??[],next_page_id:e?.next_page_id??null}}catch(e){if(!n)throw e;return console.warn(`[EventService] Cloud backend doesn't support pagination filters. Falling back to initial load only. Server needs OpenHands/OpenHands#14399.`),{items:[],next_page_id:null}}}let o=await new h(p({conversationUrl:t,sessionApiKey:n}),e).search({limit:a,...r.pageId?{page_id:r.pageId}:{},...r.sortOrder?{sort_order:r.sortOrder}:{},...r.timestampGte?{timestamp__gte:r.timestampGte}:{},...r.timestampLt?{timestamp__lt:r.timestampLt}:{}});return{items:o?.items??[],next_page_id:o?.next_page_id??null}}};function G({message:e,source:t,metadata:n={},posthog:r}){if(!r)return;let i=Error(e);r.captureException(i,{error_source:t||`unknown`,...n})}var we=()=>o({mutationKey:[`read-conversation-file`],mutationFn:async({conversationId:e,filePath:t})=>_.readConversationFile(e,t)}),Te=y(e=>({cost:null,max_budget_per_task:null,usage:null,setMetrics:t=>e(t)})),Ee=e=>{let{data:t}=C(e??null);return n({queryKey:[`conversation-history`,e,t?.conversation_url??null,t?.session_api_key??null],enabled:!!e&&!!t,queryFn:async()=>{if(!e)return{events:[],hasMore:!1,nextPageId:null};let n=await W.searchEvents(e,t?.conversation_url??null,t?.session_api_key??null,{limit:50,sortOrder:`TIMESTAMP_DESC`});if(!Array.isArray(n.items))throw Error(`Invalid conversation history response: expected page.items to be an array.`);return{events:[...n.items].reverse(),hasMore:!!n.next_page_id||n.items.length>=50,nextPageId:n.next_page_id??null}},staleTime:1/0,gcTime:1800*1e3})},K=e=>{if(ae(e))return!1;if(le(e)){let t=e.action.kind;return!(!t||t===`ExecuteBashAction`&&e.source===`user`||t===`PlanningFileEditorAction`||t===`SwitchLLMAction`)}return k(e)?!(e.observation.kind===`SwitchLLMObservation`&&!e.observation.is_error):!!(T(e)||E(e)||se(e)||D(e))},De=e=>e.some(e=>e.source===`user`),q=()=>{let{uiEvents:e}=O.getState();for(let t=e.length-1;t>=0;--t){let n=e[t];if(K(n))return String(n.id)}return null};function Oe(e,t,n=q()){U.getState().recordSwitch(e,n,t)}var ke=s(),Ae=(0,N.createContext)(void 0);function je(e){return e.llm_message.content.filter(e=>e.type===`text`).map(e=>e.text).join(``)}function J({children:e,conversationId:t,conversationUrl:n,sessionApiKey:a,subConversations:o,subConversationIds:s}){let[c,l]=(0,N.useState)(`CONNECTING`),[u,p]=(0,N.useState)(`CONNECTING`),h=N.useRef(!1),_=N.useRef(!1),v=m(),y=ee(),b=O(e=>e.addEvent),S=O(e=>e.addEvents),C=O(e=>e.clearEventsForConversation),{setErrorMessage:T,removeErrorMessage:se,clearConnectionError:D}=be(),k=xe(e=>e.consumeMatchingPendingMessage),{setExecutionStatus:j}=ne(),{appendInput:M,appendOutput:F}=ve(),I=A(e=>e.reset),[L,R]=(0,N.useState)(!0),[z,B]=(0,N.useState)(null),{setPlanContent:V}=x(),{mutate:H}=we(),U=(0,N.useRef)(0),K=(0,N.useRef)(null),De=e=>e?.toUpperCase().endsWith(`PLAN.MD`)??!1,q=(0,N.useCallback)(()=>{D()},[D]),J=(0,N.useCallback)(e=>{if(e.value.usage_to_metrics?.agent){let t=e.value.usage_to_metrics.agent,n={cost:t.accumulated_cost,max_budget_per_task:t.max_budget_per_task??null,usage:t.accumulated_token_usage?{prompt_tokens:t.accumulated_token_usage.prompt_tokens,completion_tokens:t.accumulated_token_usage.completion_tokens,cache_read_tokens:t.accumulated_token_usage.cache_read_tokens,cache_write_tokens:t.accumulated_token_usage.cache_write_tokens,context_window:t.accumulated_token_usage.context_window,per_turn_token:t.accumulated_token_usage.per_turn_token}:null};Te.getState().setMetrics(n)}},[]),{data:Y,isPending:X,isError:Me}=Ee(t),Ne=!!t&&X;(0,N.useLayoutEffect)(()=>{let e=t??null;O.getState().loadedConversationId!==e&&(C(e),I())},[t,C,I]),(0,N.useLayoutEffect)(()=>{if(!(!Y||Y.events.length===0)&&(S(Y.events),t))for(let e of Y.events)w(e)&&k(t,je(e))},[Y,S,t,k]);let Pe=(0,N.useMemo)(()=>{if(X)return null;let e=Y?.events??[],t=e[e.length-1];return!t||!(`timestamp`in t)||!t.timestamp?null:t.timestamp},[Y,X]),Fe=(0,N.useMemo)(()=>!t||!n||X&&!Me?null:f(t,n),[t,n,X,Me]),Z=(0,N.useMemo)(()=>{if(!o?.length)return null;let e=o[0];return!e?.id||!e.conversation_url?null:f(e.id,e.conversation_url)},[o]),Ie=(0,N.useMemo)(()=>Z?c===`CONNECTING`||u===`CONNECTING`?`CONNECTING`:c===`OPEN`&&u===`OPEN`?`OPEN`:c===`CLOSED`&&u===`CLOSED`?`CLOSED`:c===`CLOSING`||u===`CLOSING`?`CLOSING`:`CLOSED`:c,[c,u,Z]);(0,N.useEffect)(()=>{z!==null&&U.current>=z&&L&&R(!1)},[z,L,U]),(0,N.useEffect)(()=>{if(!L&&K.current){let{path:e,conversationId:t}=K.current;H({conversationId:t,filePath:e},{onSuccess:e=>{V(e)},onError:e=>{console.warn(`Failed to read conversation file:`,e)}}),K.current=null}},[L,H,V]),(0,N.useEffect)(()=>{h.current=!1,R(!!s?.length),B(null),U.current=0,K.current=null},[s]),(0,N.useEffect)(()=>{h.current=!1,_.current=!1,K.current=null},[t]);let Le=(0,N.useMemo)(()=>Ne||L,[Ne,L]),Re=(0,N.useCallback)(e=>{try{let n=JSON.parse(e.data);if(fe(n)){let e=!O.getState().eventIds.has(n.id)&&ge(n)?n:null;if(b(n),oe(n)){let e=n;G({message:e.detail,source:`conversation`,metadata:{eventId:e.id,errorCode:e.code},posthog:v}),T(e.detail)}else q();if(E(n)&&G({message:n.error,source:`agent`,metadata:{eventId:n.id,toolName:n.tool_name,toolCallId:n.tool_call_id},posthog:v}),w(n)&&t&&(k(t,je(n)),te(t,{draftMessage:null})),le(n)&&Ce(n,t||`test-conversation-id`,y),ae(n)&&(ce(n)&&j(n.value.execution_status),me(n)&&j(n.value),re(n)&&J(n)),pe(n)&&M(n.action.command),de(n)&&F(n.observation.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
1
+ import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{t as n}from"./vendor~root~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-s~f2l2lr17-DYXOLEck.js";import{i as r,l as i,n as a}from"./path-utils-z12iCrQO.js";import{t as o}from"./useMutation-GSSKKebK.js";import{o as s}from"./declaration-CR6HMp29.js";import{n as ee}from"./QueryClientProvider-Cnr-Yl3j.js";import{t as c}from"./createLucideIcon-Ddu8jDOQ.js";import{a as l,d as u,n as d,o as f,r as p}from"./agent-server-client-options-9agOSarV.js";import{n as m}from"./vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~skills-set~jfc6hidu-DJS-rJdI.js";import{i as h}from"./vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~dp08i1qy-D8soyAAx.js";import{o as g,t as _}from"./agent-server-conversation-service.api-B9TUYJon.js";import{t as v}from"./proxy-BqDMnUY-.js";import{t as y}from"./react-Dy05vyj5.js";import{n as b}from"./middleware-CfatjPYZ.js";import{a as te}from"./conversation-local-storage-YmOVXxxW.js";import{t as x}from"./conversation-store-CC-isCnP.js";import{t as S}from"./v4-khGvL7i2.js";import{t as C}from"./use-user-conversation-DJen4YIP.js";import{t as ne}from"./conversation-state-store-D-w0uurj.js";import{C as w,_ as T,a as E,b as re,c as ie,d as ae,f as oe,g as se,h as ce,i as le,l as ue,m as de,o as fe,p as pe,r as D,s as me,t as O,u as he,v as k,x as ge,y as _e}from"./use-event-store-BomO7ywK.js";import{t as ve}from"./command-store-CE1weJy8.js";import{t as A}from"./browser-store-DAsixKdU.js";import{t as j}from"./files-tab-store-m0ARqX_E.js";var M=c(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),N=e(t(),1),ye=(e,t)=>{let[n,r]=N.useState(!1),[i,a]=N.useState(null),[o,s]=N.useState([]),[ee,c]=N.useState(null),[l,u]=N.useState(!1),d=N.useRef(null),f=N.useRef(0),p=N.useRef(null),m=N.useRef(!0),h=N.useRef(new WeakSet),g=N.useRef(t);N.useEffect(()=>{g.current=t},[t]);let _=N.useCallback(()=>{let t=e;if(g.current?.queryParams){let n=Object.entries(g.current.queryParams).reduce((e,[t,n])=>(e[t]=String(n),e),{});t=`${e}?${new URLSearchParams(n).toString()}`}let n=new WebSocket(t);d.current=n,h.current.add(n),n.onopen=e=>{r(!0),c(null),u(!1),f.current=0,g.current?.onOpen?.(e)},n.onmessage=e=>{a(e.data),s(t=>[...t,e.data]),g.current?.onMessage?.(e)},n.onclose=e=>{let t=h.current.has(n);r(!1),e.code!==1e3&&(c(Error(`WebSocket closed with code ${e.code}: ${e.reason||`Connection closed unexpectedly`}`)),t&&g.current?.onError?.(e)),g.current?.onClose?.(e);let i=g.current?.reconnect?.enabled??!1,a=g.current?.reconnect?.maxAttempts??1/0;i&&t&&m.current&&f.current<a?(u(!0),f.current+=1,p.current=setTimeout(()=>{_()},3e3)):u(!1)},n.onerror=e=>{r(!1),g.current?.onError?.(e)}},[e]);N.useEffect(()=>(m.current=!0,f.current=0,e&&e.trim()!==``&&_(),()=>{if(m.current=!1,p.current&&=(clearTimeout(p.current),null),d.current){let{readyState:e}=d.current;h.current.delete(d.current),(e===WebSocket.CONNECTING||e===WebSocket.OPEN)&&d.current.close(),d.current=null}}),[e,_]);let v=N.useCallback(e=>{d.current?.readyState===WebSocket.OPEN&&d.current.send(e)},[]),y=N.useCallback(()=>{m.current=!1,u(!1),p.current&&=(clearTimeout(p.current),null),d.current&&(h.current.delete(d.current),d.current.close())},[]),b=N.useCallback(()=>{if(m.current=!0,f.current=0,u(!0),c(null),p.current&&=(clearTimeout(p.current),null),d.current){let e=d.current;h.current.delete(e),d.current=null,(e.readyState===WebSocket.CONNECTING||e.readyState===WebSocket.OPEN)&&e.close()}_()},[_]);return{isConnected:n,lastMessage:i,messages:o,error:ee,socket:d.current,sendMessage:v,isReconnecting:l,attemptCount:f.current,disconnect:y,reconnect:b}},P=`Unable to connect to server`,F={errorMessage:null,errorType:null},be=y(e=>({...F,setErrorMessage:(t,n=`conversation`)=>e(()=>({errorMessage:t,errorType:n})),removeErrorMessage:()=>e(()=>({errorMessage:null,errorType:null})),clearConnectionError:()=>e(e=>e.errorType===`connection`?{errorMessage:null,errorType:null}:e)})),I=15e4,L={pendingMessages:[]},R=()=>`pending-${Date.now()}-${Math.random().toString(36).slice(2,10)}`,xe=y((e,t)=>({...L,enqueuePendingMessage:n=>{let r=R(),i={id:r,conversationId:n.conversationId,text:n.text,content:n.content??n.text,status:`sending`,imageUrls:n.imageUrls??[],fileUrls:n.fileUrls??[],timestamp:n.timestamp??new Date().toISOString()};return e(e=>({pendingMessages:[...e.pendingMessages,i]})),setTimeout(()=>{t().pendingMessages.find(e=>e.id===r)?.status===`sending`&&t().markPendingMessageError(r,`Send timed out`)},I),r},markPendingMessageError:(t,n)=>e(e=>({pendingMessages:e.pendingMessages.map(e=>e.id===t?{...e,status:`error`,errorMessage:n}:e)})),markPendingMessageSending:t=>e(e=>({pendingMessages:e.pendingMessages.map(e=>e.id===t?{...e,status:`sending`,errorMessage:void 0}:e)})),removePendingMessage:t=>e(e=>({pendingMessages:e.pendingMessages.filter(e=>e.id!==t)})),consumeMatchingPendingMessage:(t,n)=>{let r=null;return e(e=>{let i=e.pendingMessages.map((e,t)=>({m:e,i:t})).filter(({m:e})=>e.status===`sending`&&e.conversationId===t);if(i.length===0)return e;let a=i.find(({m:e})=>e.content===n)??i[0];return r=a.m,{pendingMessages:[...e.pendingMessages.slice(0,a.i),...e.pendingMessages.slice(a.i+1)]}}),r},clearPendingMessages:()=>e(()=>({...L})),reassignPendingMessages:(t,n)=>e(e=>({pendingMessages:e.pendingMessages.map(e=>e.conversationId===t?{...e,conversationId:n}:e)}))})),z=new Set([`files`,`browser`,`vscode`,`terminal`,`planner`,`tasklist`]);function B(e){let t=x.getState();t.setSelectedTab(e),t.isRightPanelShown||(t.setHasRightPanelToggled(!0),t.setIsRightPanelShown(!0))}function V(e){return z.has(e)}function Se(e){switch(e.command){case`navigate_to_file`:case`show_preview`:B(`files`),e.path&&j.getState().setSelectedPath(e.path);return;case`open_tab`:e.tab&&V(e.tab)?B(e.tab):e.tab&&console.warn(`[canvas_ui] Ignoring open_tab with unknown tab: ${e.tab}`);return}}var H=(e,t,n)=>({entriesByConversation:{...e.entriesByConversation,[t]:[...e.entriesByConversation[t]??[],n]}}),U=y()(b(e=>({entriesByConversation:{},activeProfileByConversation:{},show:(t,n,r)=>e(e=>H(e,t,{id:S(),anchorEventId:n,profiles:r})),recordSwitch:(t,n,r)=>e(e=>({...H(e,t,{id:S(),anchorEventId:n,profiles:[],switchedTo:r}),activeProfileByConversation:{...e.activeProfileByConversation,[t]:r}})),clearActiveProfile:t=>e(e=>{if(!(t in e.activeProfileByConversation))return e;let n={...e.activeProfileByConversation};return delete n[t],{activeProfileByConversation:n}}),clear:t=>e(e=>{let n={...e.entriesByConversation};delete n[t];let r={...e.activeProfileByConversation};return delete r[t],{entriesByConversation:n,activeProfileByConversation:r}}),clearAll:()=>e({entriesByConversation:{},activeProfileByConversation:{}})}),{name:`ModelStore`})),Ce=(e,t,n)=>{let{action:r}=e;if((r.kind===`StrReplaceEditorAction`||r.kind===`FileEditorAction`||r.kind===`ExecuteBashAction`)&&n.invalidateQueries({queryKey:[`file_changes`,t]},{cancelRefetch:!1}),(r.kind===`StrReplaceEditorAction`||r.kind===`FileEditorAction`)&&r.path){let e=a(r.path);n.invalidateQueries({queryKey:[`file_diff`,t,e]})}e.tool_name===`SwitchLLMTool`&&(n.invalidateQueries({queryKey:[`user`,`conversation`,t]}),U.getState().clearActiveProfile(t))},W=class{static async respondToConfirmation(e,t,n,r){let i=u().backend;return i.kind===`cloud`?v({backend:i,method:`POST`,hostOverride:l(t),path:`/api/conversations/${e}/events/respond_to_confirmation`,body:n,authMode:`session-api-key`,sessionApiKey:r}):new g(d({conversationUrl:t,sessionApiKey:r})).respondToConfirmation(e,n)}static async getEventCount(e,t,n){let r=u().backend;return r.kind===`cloud`?v({backend:r,method:`GET`,hostOverride:l(t),path:`/api/conversations/${e}/events/count`,authMode:`session-api-key`,sessionApiKey:n}):new g(d({conversationUrl:t,sessionApiKey:n})).getEventCount(e)}static async searchEvents(e,t,n,r={}){let i=u().backend,a=r.limit??100;if(i.kind===`cloud`){let t=Math.min(a,100),n=!!(r.sortOrder||r.pageId||r.timestampGte||r.timestampLt),o=new URLSearchParams;o.set(`limit`,String(t)),r.sortOrder&&o.set(`sort_order`,r.sortOrder),r.pageId&&o.set(`page_id`,r.pageId),r.timestampGte&&o.set(`timestamp__gte`,r.timestampGte),r.timestampLt&&o.set(`timestamp__lt`,r.timestampLt);let s=t=>v({backend:i,method:`GET`,path:`/api/v1/conversation/${e}/events/search?${t.toString()}`});try{let e=await s(o);return{items:e?.items??[],next_page_id:e?.next_page_id??null}}catch(e){if(!n)throw e;return console.warn(`[EventService] Cloud backend doesn't support pagination filters. Falling back to initial load only. Server needs OpenHands/OpenHands#14399.`),{items:[],next_page_id:null}}}let o=await new h(p({conversationUrl:t,sessionApiKey:n}),e).search({limit:a,...r.pageId?{page_id:r.pageId}:{},...r.sortOrder?{sort_order:r.sortOrder}:{},...r.timestampGte?{timestamp__gte:r.timestampGte}:{},...r.timestampLt?{timestamp__lt:r.timestampLt}:{}});return{items:o?.items??[],next_page_id:o?.next_page_id??null}}};function G({message:e,source:t,metadata:n={},posthog:r}){if(!r)return;let i=Error(e);r.captureException(i,{error_source:t||`unknown`,...n})}var we=()=>o({mutationKey:[`read-conversation-file`],mutationFn:async({conversationId:e,filePath:t})=>_.readConversationFile(e,t)}),Te=y(e=>({cost:null,max_budget_per_task:null,usage:null,setMetrics:t=>e(t)})),Ee=e=>{let{data:t}=C(e??null);return n({queryKey:[`conversation-history`,e,t?.conversation_url??null,t?.session_api_key??null],enabled:!!e&&!!t,queryFn:async()=>{if(!e)return{events:[],hasMore:!1,nextPageId:null};let n=await W.searchEvents(e,t?.conversation_url??null,t?.session_api_key??null,{limit:50,sortOrder:`TIMESTAMP_DESC`});if(!Array.isArray(n.items))throw Error(`Invalid conversation history response: expected page.items to be an array.`);return{events:[...n.items].reverse(),hasMore:!!n.next_page_id||n.items.length>=50,nextPageId:n.next_page_id??null}},staleTime:1/0,gcTime:1800*1e3})},K=e=>{if(ae(e))return!1;if(le(e)){let t=e.action.kind;return!(!t||t===`ExecuteBashAction`&&e.source===`user`||t===`PlanningFileEditorAction`||t===`SwitchLLMAction`)}return k(e)?!(e.observation.kind===`SwitchLLMObservation`&&!e.observation.is_error):!!(T(e)||E(e)||se(e)||D(e))},De=e=>e.some(e=>e.source===`user`),q=()=>{let{uiEvents:e}=O.getState();for(let t=e.length-1;t>=0;--t){let n=e[t];if(K(n))return String(n.id)}return null};function Oe(e,t,n=q()){U.getState().recordSwitch(e,n,t)}var ke=s(),Ae=(0,N.createContext)(void 0);function je(e){return e.llm_message.content.filter(e=>e.type===`text`).map(e=>e.text).join(``)}function J({children:e,conversationId:t,conversationUrl:n,sessionApiKey:a,subConversations:o,subConversationIds:s}){let[c,l]=(0,N.useState)(`CONNECTING`),[u,p]=(0,N.useState)(`CONNECTING`),h=N.useRef(!1),_=N.useRef(!1),v=m(),y=ee(),b=O(e=>e.addEvent),S=O(e=>e.addEvents),C=O(e=>e.clearEventsForConversation),{setErrorMessage:T,removeErrorMessage:se,clearConnectionError:D}=be(),k=xe(e=>e.consumeMatchingPendingMessage),{setExecutionStatus:j}=ne(),{appendInput:M,appendOutput:F}=ve(),I=A(e=>e.reset),[L,R]=(0,N.useState)(!0),[z,B]=(0,N.useState)(null),{setPlanContent:V}=x(),{mutate:H}=we(),U=(0,N.useRef)(0),K=(0,N.useRef)(null),De=e=>e?.toUpperCase().endsWith(`PLAN.MD`)??!1,q=(0,N.useCallback)(()=>{D()},[D]),J=(0,N.useCallback)(e=>{if(e.value.usage_to_metrics?.agent){let t=e.value.usage_to_metrics.agent,n={cost:t.accumulated_cost,max_budget_per_task:t.max_budget_per_task??null,usage:t.accumulated_token_usage?{prompt_tokens:t.accumulated_token_usage.prompt_tokens,completion_tokens:t.accumulated_token_usage.completion_tokens,cache_read_tokens:t.accumulated_token_usage.cache_read_tokens,cache_write_tokens:t.accumulated_token_usage.cache_write_tokens,context_window:t.accumulated_token_usage.context_window,per_turn_token:t.accumulated_token_usage.per_turn_token}:null};Te.getState().setMetrics(n)}},[]),{data:Y,isPending:X,isError:Me}=Ee(t),Ne=!!t&&X;(0,N.useLayoutEffect)(()=>{let e=t??null;O.getState().loadedConversationId!==e&&(C(e),I())},[t,C,I]),(0,N.useLayoutEffect)(()=>{if(!(!Y||Y.events.length===0)&&(S(Y.events),t))for(let e of Y.events)w(e)&&k(t,je(e))},[Y,S,t,k]);let Pe=(0,N.useMemo)(()=>{if(X)return null;let e=Y?.events??[],t=e[e.length-1];return!t||!(`timestamp`in t)||!t.timestamp?null:t.timestamp},[Y,X]),Fe=(0,N.useMemo)(()=>!t||!n||X&&!Me?null:f(t,n),[t,n,X,Me]),Z=(0,N.useMemo)(()=>{if(!o?.length)return null;let e=o[0];return!e?.id||!e.conversation_url?null:f(e.id,e.conversation_url)},[o]),Ie=(0,N.useMemo)(()=>Z?c===`CONNECTING`||u===`CONNECTING`?`CONNECTING`:c===`OPEN`&&u===`OPEN`?`OPEN`:c===`CLOSED`&&u===`CLOSED`?`CLOSED`:c===`CLOSING`||u===`CLOSING`?`CLOSING`:`CLOSED`:c,[c,u,Z]);(0,N.useEffect)(()=>{z!==null&&U.current>=z&&L&&R(!1)},[z,L,U]),(0,N.useEffect)(()=>{if(!L&&K.current){let{path:e,conversationId:t}=K.current;H({conversationId:t,filePath:e},{onSuccess:e=>{V(e)},onError:e=>{console.warn(`Failed to read conversation file:`,e)}}),K.current=null}},[L,H,V]),(0,N.useEffect)(()=>{h.current=!1,R(!!s?.length),B(null),U.current=0,K.current=null},[s]),(0,N.useEffect)(()=>{h.current=!1,_.current=!1,K.current=null},[t]);let Le=(0,N.useMemo)(()=>Ne||L,[Ne,L]),Re=(0,N.useCallback)(e=>{try{let n=JSON.parse(e.data);if(fe(n)){let e=!O.getState().eventIds.has(n.id)&&ge(n)?n:null;if(b(n),oe(n)){let e=n;G({message:e.detail,source:`conversation`,metadata:{eventId:e.id,errorCode:e.code},posthog:v}),T(e.detail)}else q();if(E(n)&&G({message:n.error,source:`agent`,metadata:{eventId:n.id,toolName:n.tool_name,toolCallId:n.tool_call_id},posthog:v}),w(n)&&t&&(k(t,je(n)),te(t,{draftMessage:null})),le(n)&&Ce(n,t||`test-conversation-id`,y),ae(n)&&(ce(n)&&j(n.value.execution_status),me(n)&&j(n.value),re(n)&&J(n)),pe(n)&&M(n.action.command),de(n)&&F(n.observation.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
2
2
  `)),ue(n)){let{screenshot_data:e}=n.observation;if(e){let t=e.startsWith(`data:`)?e:`data:image/png;base64,${e}`;A.getState().setScreenshotSrc(t)}}ie(n)&&A.getState().setUrl(n.action.url),t&&e&&!e.observation.is_error&&(Oe(t,e.observation.profile_name),e.observation.active_model&&i(y,t,e.observation.active_model),r(y,t)),he(n)&&Se(n.action)}}catch(e){console.warn(`Failed to parse WebSocket message as JSON:`,e)}},[b,T,k,y,t,j,M,F,J,q,v]),ze=(0,N.useCallback)(e=>{try{let n=JSON.parse(e.data);if(L&&(U.current+=1,z!==null&&U.current>=z&&R(!1)),fe(n)){if(b({...n,isFromPlanningAgent:!0}),oe(n)){let e=n;G({message:e.detail,source:`planning_conversation`,metadata:{eventId:e.id,errorCode:e.code},posthog:v}),T(e.detail)}else q();if(E(n)&&G({message:n.error,source:`planning_agent`,metadata:{eventId:n.id,toolName:n.tool_name,toolCallId:n.tool_call_id},posthog:v}),w(n)&&t&&(k(t,je(n)),te(t,{draftMessage:null})),le(n)&&Ce(n,o?.[0]?.id||`test-conversation-id`,y),ae(n)&&(ce(n)&&j(n.value.execution_status),me(n)&&j(n.value),re(n)&&J(n)),pe(n)&&M(n.action.command),de(n)&&F(n.observation.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
3
3
  `)),_e(n)){let{path:e}=n.observation;if(De(e)){let t=o?.[0]?.id;t&&e&&(L?K.current={path:e,conversationId:t}:H({conversationId:t,filePath:e},{onSuccess:e=>{V(e)},onError:e=>{console.warn(`Failed to read conversation file:`,e)}}))}}}}catch(e){console.warn(`Failed to parse WebSocket message as JSON:`,e)}},[b,L,z,T,k,y,o,t,j,M,F,H,V,J,q,v]),Be=(0,N.useMemo)(()=>{let e=Pe?{resend_mode:`since`,after_timestamp:Pe}:{resend_mode:`all`};return a&&(e.session_api_key=a),{queryParams:e,reconnect:{enabled:!0},onOpen:()=>{l(`OPEN`),h.current=!0,D()},onClose:()=>{l(`CLOSED`)},onError:()=>{l(`CLOSED`),h.current&&T(P,`connection`)},onMessage:Re}},[Re,T,D,a,Pe]),Ve=(0,N.useMemo)(()=>{let e={resend_all:!0};a&&(e.session_api_key=a);let t=o?.[0];return{queryParams:e,reconnect:{enabled:!0},onOpen:async()=>{if(p(`OPEN`),_.current=!0,D(),t?.id&&t.conversation_url)try{let e=await W.getEventCount(t.id,t.conversation_url,t.session_api_key);B(e),e===0&&R(!1)}catch{R(!1)}},onClose:()=>{p(`CLOSED`)},onError:()=>{p(`CLOSED`),_.current&&T(P,`connection`)},onMessage:ze}},[ze,T,D,a,o]),{socket:Q,reconnect:He}=ye(Fe||``,Be),{socket:$,reconnect:Ue}=ye(Z||``,Ve),We=(0,N.useCallback)(()=>{if(se(),x.getState().conversationMode===`plan`&&Z){Ue();return}He()},[Z,He,Ue,se]),Ge=(0,N.useCallback)(async e=>{let n=x.getState().conversationMode===`plan`?$:Q;if(n?.readyState!==WebSocket.OPEN){if(!t){let e=Error(`No conversation ID available`);throw T(e.message),e}try{return await new g(d()).sendEvent(t,{role:`user`,content:e.content},{run:!0}),{queued:!0}}catch(e){throw T(e instanceof Error?e.message:`Failed to queue message for delivery`),e}}try{return n.send(JSON.stringify({...e,run:!0})),{queued:!1}}catch(e){throw T(e instanceof Error?e.message:`Failed to send message`),e}},[Q,$,T,t]);(0,N.useEffect)(()=>{Q&&Fe&&(()=>{switch(Q.readyState){case WebSocket.CONNECTING:l(`CONNECTING`);break;case WebSocket.OPEN:l(`OPEN`);break;case WebSocket.CLOSING:l(`CLOSING`);break;case WebSocket.CLOSED:l(`CLOSED`);break;default:l(`CLOSED`);break}})()},[Q,Fe]),(0,N.useEffect)(()=>{$&&Z&&(()=>{switch($.readyState){case WebSocket.CONNECTING:p(`CONNECTING`);break;case WebSocket.OPEN:p(`OPEN`);break;case WebSocket.CLOSING:p(`CLOSING`);break;case WebSocket.CLOSED:p(`CLOSED`);break;default:p(`CLOSED`);break}})()},[$,Z]);let Ke=(0,N.useMemo)(()=>({connectionState:Ie,sendMessage:Ge,isLoadingHistory:Le,reconnect:We}),[Ie,Ge,Le,We]);return(0,ke.jsx)(Ae.Provider,{value:Ke,children:e})}var Y=()=>(0,N.useContext)(Ae)||null;export{De as a,Te as c,xe as d,be as f,q as i,W as l,M as m,Y as n,K as o,P as p,Oe as r,Ee as s,J as t,U as u};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{t as n}from"./react-dom-hVBnwgwZ.js";import{t as r}from"./vendor~root~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-s~f2l2lr17-DYXOLEck.js";import{t as i}from"./useMutation-GSSKKebK.js";import{o as a,t as o}from"./declaration-CR6HMp29.js";import{n as s}from"./QueryClientProvider-Cnr-Yl3j.js";import{t as c}from"./useTranslation-B6voJV4y.js";import{n as l,r as u}from"./custom-toast-handlers-ufGJ6_Rc.js";import{t as d}from"./utils-DCVfKFRt.js";import{d as f,p,t as m}from"./agent-server-client-options-HEOwGVIU.js";import{n as h}from"./active-backend-context-Beu-LZL-.js";import{r as g}from"./modal-classes-6YqcqA6y.js";import{c as ee,d as te,t as _}from"./brand-button-DJ_S16rO.js";import{r as v,u as y}from"./dropdown-classes-BsVmxlNG.js";import{n as ne,r as re}from"./vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~ninslayh-CLlsvdNP.js";import{t as b}from"./proxy-BAdHH8QB.js";import{t as x}from"./settings-input-CehsXnb3.js";import{n as S,t as ie}from"./context-menu-list-item-7tAcm2c3.js";import{t as C}from"./settings-dropdown-input-BtoovFre.js";import{t as w}from"./x-mark-BrkSPIiT.js";import{t as T}from"./automation-XDPAjiZi.js";var E=`/api/automation`,D=re.create();D.interceptors.request.use(e=>{let t=p();if(!t)throw new m;e.baseURL||=t.host;let n=t.apiKey?.trim();return n&&e.headers.set(`X-Session-API-Key`,n),e});function O(e,t){let n=new URLSearchParams;return n.set(`limit`,String(e)),n.set(`offset`,String(t)),n.toString()}var k=class e{static async listAutomations(e={}){let{limit:t=50,offset:n=0}=e,r=f().backend;if(r.kind===`cloud`)return b({backend:r,method:`GET`,path:`${E}/v1?${O(t,n)}`});let{data:i}=await D.get(`${E}/v1`,{params:{limit:t,offset:n}});return i}static async getAutomations(t=50,n=0){return e.listAutomations({limit:t,offset:n})}static async getAutomation(e){let t=f().backend,n=`${E}/v1/${encodeURIComponent(e)}`;if(t.kind===`cloud`)return b({backend:t,method:`GET`,path:n});let{data:r}=await D.get(n);return r}static async updateAutomation(e,t){let n=f().backend,r=`${E}/v1/${encodeURIComponent(e)}`;if(n.kind===`cloud`)return b({backend:n,method:`PATCH`,path:r,body:t});let{data:i}=await D.patch(r,t);return i}static async deleteAutomation(e){let t=f().backend,n=`${E}/v1/${encodeURIComponent(e)}`;if(t.kind===`cloud`){await b({backend:t,method:`DELETE`,path:n});return}await D.delete(n)}static async dispatchAutomation(e){let t=f().backend,n=`${E}/v1/${encodeURIComponent(e)}/dispatch`;if(t.kind===`cloud`)return b({backend:t,method:`POST`,path:n});let{data:r}=await D.post(n);return r}static async listAutomationRuns(e,t={}){let{limit:n=50,offset:r=0}=t,i=f().backend,a=`${E}/v1/${encodeURIComponent(e)}/runs`;if(i.kind===`cloud`)return b({backend:i,method:`GET`,path:`${a}?${O(n,r)}`});let{data:o}=await D.get(a,{params:{limit:n,offset:r}});return o}static async getAutomationRuns(t,n=50,r=0){return e.listAutomationRuns(t,{limit:n,offset:r})}static async toggleAutomation(t,n){return e.updateAutomation(t,{enabled:n})}static async downloadTarball(e,t){let n=f().backend,r=`${E}/v1/${encodeURIComponent(e)}/tarball`,i;if(n.kind===`cloud`)i=await b({backend:n,method:`GET`,path:r,responseType:`blob`});else{let{data:e}=await D.get(r,{responseType:`blob`});i=e}let a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=`${t}.tar`,o.click(),URL.revokeObjectURL(a)}static async checkHealth(){let e=f().backend,t=`${E}/health`;try{if(e.kind===`cloud`)return await b({backend:e,method:`GET`,path:t});let{data:n}=await D.get(t,{timeout:5e3});return n}catch{return{status:`error`}}}},A=e(t()),ae=e(n(),1),j=a(),M=[`automation-detail`],N=[`automation-runs`];function oe(e){let{id:t,enabled:n=!0}=e,i=h();return r({queryKey:[...M,t,i.backend.id,i.orgId],queryFn:()=>k.getAutomation(t),staleTime:300*1e3,enabled:!!t&&n})}function P(e){let{id:t,limit:n=20,offset:i=0,enabled:a=!0}=e,o=h();return r({queryKey:[...N,t,{limit:n,offset:i},o.backend.id,o.orgId],queryFn:()=>k.getAutomationRuns(t,n,i),staleTime:60*1e3,enabled:!!t&&a,refetchInterval:e=>{let t=e.state.data;return t&&t.runs.some(e=>e.status===T.PENDING||e.status===T.RUNNING)?3e3:!1}})}var F=[`automations`];function I(e={}){let{limit:t=50,offset:n=0,enabled:i=!0}=e,a=h();return r({queryKey:[...F,{limit:t,offset:n},a.backend.id,a.orgId],queryFn:()=>k.getAutomations(t,n),staleTime:0,enabled:i})}function L(){let e=s();return i({mutationFn:({id:e,enabled:t})=>k.toggleAutomation(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:F}),e.invalidateQueries({queryKey:M})}})}function R(){let e=s();return i({mutationFn:({id:e,body:t})=>k.updateAutomation(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:F}),e.invalidateQueries({queryKey:M})}})}function z(){let e=s();return i({mutationFn:e=>k.deleteAutomation(e),onSuccess:()=>{e.invalidateQueries({queryKey:F})}})}function B(){let e=s();return i({mutationFn:e=>k.dispatchAutomation(e),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:F}),e.invalidateQueries({queryKey:M}),e.invalidateQueries({queryKey:[...N,n]})}})}var V=[`automation-health`];function H(){let e=h();return r({queryKey:[...V,e.backend.id,e.orgId],queryFn:()=>k.checkHealth(),staleTime:30*1e3,retry:!1})}var U=e=>(0,j.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`currentColor`,viewBox:`0 0 20 20`,...e,children:(0,j.jsx)(`path`,{d:`M10 6a2 2 0 110-4 2 2 0 010 4zm0 6a2 2 0 110-4 2 2 0 010 4zm0 6a2 2 0 110-4 2 2 0 010 4z`})}),W=d(`inline-flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent text-muted hover:bg-interactive-hover hover:text-white focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent disabled:hover:text-muted`,v),G=d(`inline-flex h-8 shrink-0 cursor-pointer items-center gap-1.5 rounded-md border-0 bg-transparent px-2 text-xs text-muted hover:bg-interactive-hover hover:text-white focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent disabled:hover:text-muted`,v);function K({icon:e,label:t}){return(0,j.jsxs)(`span`,{className:`flex min-w-0 w-full items-center gap-2`,children:[(0,j.jsx)(`span`,{className:d(`[&_svg]:size-4`,y),"aria-hidden":!0,children:e}),(0,j.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t})]})}function q({items:e}){let{t}=c(`openhands`),[n,r]=(0,A.useState)(!1),[i,a]=(0,A.useState)(),s=(0,A.useRef)(null),l=(0,A.useRef)(null);(0,A.useLayoutEffect)(()=>{if(!n||!s.current)return;let e=()=>{let e=s.current?.getBoundingClientRect();e&&a({position:`fixed`,zIndex:9999,top:e.bottom+4,right:window.innerWidth-e.right})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[n]),(0,A.useEffect)(()=>{if(!n)return;let e=e=>{let t=e.target;s.current?.contains(t)||l.current?.contains(t)||r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]);let u=n&&i?(0,j.jsx)(S,{ref:l,theme:`popover`,className:`min-w-[10rem]`,children:e.map(e=>(0,j.jsx)(`li`,{children:(0,j.jsx)(ie,{onClick:t=>{t.stopPropagation(),e.onClick(),r(!1)},isDisabled:e.disabled,className:`group`,children:(0,j.jsx)(K,{icon:e.icon,label:e.label})})},e.label))}):null;return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`button`,{ref:s,type:`button`,onClick:e=>{e.stopPropagation(),r(e=>!e)},className:W,"aria-label":t(o.AUTOMATIONS$ACTIONS_MENU),"aria-expanded":n,"aria-haspopup":`menu`,children:(0,j.jsx)(U,{className:`size-4`})}),n&&i&&typeof document<`u`?ae.createPortal((0,j.jsx)(`div`,{style:i,children:u}),document.body):null]})}function se(e){return!0}var ce=e=>(0,j.jsxs)(`svg`,{width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[(0,j.jsx)(`g`,{clipPath:`url(#clip0_8467_30872)`,children:(0,j.jsx)(`path`,{d:`M6.26693 21.4874L6.25583 21.4951L6.24514 21.5033C5.95991 21.7227 5.5 21.5308 5.5 21.0996V2.89961C5.5 2.4684 5.95991 2.2765 6.24514 2.49592L6.25634 2.50452L6.26799 2.51249L19.518 11.5625L19.518 11.5625L19.5226 11.5656C19.8258 11.7677 19.8258 12.1815 19.5226 12.3836L19.5226 12.3835L19.5169 12.3874L6.26693 21.4874Z`,fill:`currentColor`,stroke:`currentColor`})}),(0,j.jsx)(`defs`,{children:(0,j.jsx)(`clipPath`,{id:`clip0_8467_30872`,children:(0,j.jsx)(`rect`,{width:24,height:24,fill:`white`})})})]}),le=e=>(0,j.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,...e,children:(0,j.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z`})}),ue=e=>(0,j.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,...e,children:(0,j.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.455 2.456L21.75 6l-1.036.259a3.375 3.375 0 00-2.455 2.456z`})}),de=/^(\d+)$/;function J(e,t,n){let r=e.match(de);if(!r)return null;let i=Number(r[1]);return Number.isNaN(i)||i<t||i>n?null:i}function fe(e){let t=(e??``).trim();if(!t)return{kind:`custom`,raw:``};let n=t.split(/\s+/);if(n.length!==5)return{kind:`custom`,raw:t};let[r,i,a,o,s]=n,c=J(r,0,59),l=J(i,0,23);if(c===null||l===null)return{kind:`custom`,raw:t};if(a!==`*`||o!==`*`)return{kind:`custom`,raw:t,hour:l,minute:c};if(s===`*`||s===`0-6`)return{kind:`daily`,hour:l,minute:c};if(s===`1-5`)return{kind:`weekdays`,hour:l,minute:c};let u=J(s,0,6);return u===null?{kind:`custom`,raw:t,hour:l,minute:c}:{kind:`weekly`,hour:l,minute:c,weekday:u}}function pe(e){let{kind:t,hour:n,minute:r,weekday:i}=e;switch(t){case`daily`:return`${r} ${n} * * *`;case`weekdays`:return`${r} ${n} * * 1-5`;case`weekly`:return`${r} ${n} * * ${i??1}`;default:return t}}function Y(e,t){return`${String(e).padStart(2,`0`)}:${String(t).padStart(2,`0`)}`}function X(e){let t=e.match(/^(\d{1,2}):(\d{2})$/);if(!t)return null;let n=Number(t[1]),r=Number(t[2]);return Number.isNaN(n)||Number.isNaN(r)||n<0||n>23||r<0||r>59?null:{hour:n,minute:r}}function Z(e){return e?Array.isArray(e)?e.join(`, `):e:`—`}var me=e=>(0,j.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,...e,children:(0,j.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M5.636 5.636a9 9 0 1012.728 0M12 3v9`})}),he=e=>(0,j.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,...e,children:(0,j.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16`})}),Q=e=>(0,j.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:1.5,...e,children:(0,j.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z`})});function ge({onRetry:e}){let{t}=c(`openhands`);return(0,j.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20`,children:[(0,j.jsx)(Q,{className:`size-12 text-danger`}),(0,j.jsx)(`p`,{className:`mt-4 text-sm text-muted`,children:t(o.AUTOMATIONS$ERROR_TITLE)}),(0,j.jsx)(`button`,{type:`button`,onClick:e,className:`mt-4 rounded-lg border border-[var(--oh-border)] px-4 py-2 text-sm text-white hover:bg-surface-raised`,children:t(o.AUTOMATIONS$ERROR_RETRY)})]})}function $({onRetry:e}){let{t}=c(`openhands`);return(0,j.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20 px-4`,children:[(0,j.jsx)(Q,{className:`size-12 text-[var(--oh-warning)]`}),(0,j.jsx)(`h2`,{className:`mt-4 text-lg font-medium text-content`,children:t(o.AUTOMATIONS$BACKEND_UNAVAILABLE_TITLE)}),(0,j.jsx)(`p`,{className:`mt-2 text-sm text-muted text-center max-w-md`,children:t(o.AUTOMATIONS$BACKEND_UNAVAILABLE_MESSAGE)}),(0,j.jsx)(_,{type:`button`,variant:`secondary`,className:`mt-6`,onClick:e,children:t(o.AUTOMATIONS$BACKEND_UNAVAILABLE_RETRY)})]})}function _e({automationName:e,isOpen:t,onConfirm:n,onCancel:r}){let{t:i}=c(`openhands`);return t?(0,j.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,j.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:r,onKeyDown:e=>{e.key===`Escape`&&r()},role:`presentation`}),(0,j.jsxs)(`div`,{className:`relative w-full max-w-sm rounded-xl border border-[var(--oh-border)] bg-[var(--oh-surface)] p-6`,children:[(0,j.jsx)(`button`,{type:`button`,onClick:r,className:`absolute right-4 top-4 text-muted hover:text-foreground`,"aria-label":`Close`,children:(0,j.jsx)(w,{className:`size-5`})}),(0,j.jsx)(`h2`,{className:g,children:i(o.AUTOMATIONS$DELETE_CONFIRM_TITLE)}),(0,j.jsx)(`p`,{className:`mt-2 text-sm text-muted`,children:i(o.AUTOMATIONS$DELETE_CONFIRM_MESSAGE,{name:e})}),(0,j.jsxs)(`div`,{className:`mt-6 flex justify-end gap-3`,children:[(0,j.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-lg border border-[var(--oh-border)] px-4 py-2 text-sm text-white hover:bg-surface-raised`,children:i(o.AUTOMATIONS$CANCEL)}),(0,j.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-lg bg-danger px-4 py-2 text-sm text-white hover:bg-danger/80`,children:i(o.AUTOMATIONS$DELETE)})]})]})]}):null}var ve=[o.AUTOMATIONS$WEEKDAY_SUN,o.AUTOMATIONS$WEEKDAY_MON,o.AUTOMATIONS$WEEKDAY_TUE,o.AUTOMATIONS$WEEKDAY_WED,o.AUTOMATIONS$WEEKDAY_THU,o.AUTOMATIONS$WEEKDAY_FRI,o.AUTOMATIONS$WEEKDAY_SAT];function ye(e){if(e.trigger.type===`event`)return{name:e.name,prompt:e.prompt??``,frequency:`custom`,weekday:1,timeOfDay:``,isCustomSchedule:!0,rawSchedule:``};let t=fe(e.trigger.schedule);return t.kind===`custom`?{name:e.name,prompt:e.prompt??``,frequency:`custom`,weekday:1,timeOfDay:t.hour!==void 0&&t.minute!==void 0?Y(t.hour,t.minute):``,isCustomSchedule:!0,rawSchedule:t.raw}:{name:e.name,prompt:e.prompt??``,frequency:t.kind,weekday:t.kind===`weekly`?t.weekday??1:1,timeOfDay:Y(t.hour,t.minute),isCustomSchedule:!1,rawSchedule:e.trigger.schedule??``}}function be({automation:e,isOpen:t,onClose:n}){let{t:r}=c(`openhands`),i=R(),a=(0,A.useMemo)(()=>ye(e),[e]),[s,f]=(0,A.useState)(a),[p,m]=(0,A.useState)(null);if((0,A.useEffect)(()=>{t&&(f(a),m(null))},[t,a]),!t)return null;let h=[{key:`daily`,label:r(o.AUTOMATIONS$FREQUENCY_DAILY)},{key:`weekdays`,label:r(o.AUTOMATIONS$FREQUENCY_WEEKDAYS)},{key:`weekly`,label:r(o.AUTOMATIONS$FREQUENCY_WEEKLY)},...s.isCustomSchedule?[{key:`custom`,label:r(o.AUTOMATIONS$FREQUENCY_CUSTOM)}]:[]],v=ve.map((e,t)=>({key:String(t),label:r(e)})),y=!s.isCustomSchedule||X(s.timeOfDay)!==null||s.timeOfDay===``;return(0,j.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,j.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:n,onKeyDown:e=>{e.key===`Escape`&&n()},role:`presentation`}),(0,j.jsxs)(`div`,{className:`relative w-full max-w-md rounded-xl border border-[var(--oh-border)] bg-[var(--oh-surface)] p-6`,children:[(0,j.jsx)(`button`,{type:`button`,onClick:n,className:`absolute right-4 top-4 text-muted hover:text-foreground`,"aria-label":r(o.AUTOMATIONS$CANCEL),children:(0,j.jsx)(w,{className:`size-5`})}),(0,j.jsx)(`h2`,{className:g,children:r(o.AUTOMATIONS$EDIT_TITLE)}),(0,j.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let a=s.name.trim();if(!a){m(r(o.AUTOMATIONS$NAME_REQUIRED));return}m(null);let c={};a!==e.name&&(c.name=a);let d=s.prompt.trim();if(d!==(e.prompt??``).trim()&&(c.prompt=d.length===0?null:d),!s.isCustomSchedule&&s.frequency!==`custom`){let t=X(s.timeOfDay);if(t){let n=pe({kind:s.frequency,hour:t.hour,minute:t.minute,weekday:s.frequency===`weekly`?s.weekday:void 0});n!==e.trigger.schedule&&(c.trigger={...e.trigger,schedule:n})}}if(Object.keys(c).length===0){n();return}i.mutate({id:e.id,body:c},{onSuccess:()=>{u(r(o.AUTOMATIONS$EDIT_SUCCESS)),n()},onError:e=>{l(ne(e)?e.response?.data?.message||e.message||r(o.AUTOMATIONS$EDIT_ERROR):e.message||r(o.AUTOMATIONS$EDIT_ERROR))}})},className:`mt-4 flex flex-col gap-4`,"aria-label":r(o.AUTOMATIONS$EDIT_TITLE),children:[(0,j.jsx)(x,{testId:`edit-automation-name`,name:`name`,type:`text`,label:r(o.AUTOMATIONS$NAME),value:s.name,onChange:e=>f(t=>({...t,name:e})),error:p??void 0,showRequiredTag:!0}),(0,j.jsxs)(`label`,{className:`flex flex-col gap-2.5 w-full min-w-0`,children:[(0,j.jsx)(`span`,{className:`text-sm`,children:r(o.AUTOMATIONS$PROMPT)}),(0,j.jsx)(`textarea`,{"data-testid":`edit-automation-prompt`,name:`prompt`,value:s.prompt,onChange:e=>f(t=>({...t,prompt:e.target.value})),rows:4,className:d(ee,`placeholder:italic`)}),(0,j.jsx)(`span`,{className:`text-xs text-muted`,children:r(o.AUTOMATIONS$EDIT_PROMPT_HINT)})]}),e.trigger.type===`event`?(0,j.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg bg-[var(--oh-surface-raised)] p-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:r(o.AUTOMATIONS$DETAIL$TRIGGER)}),(0,j.jsx)(`span`,{className:`text-sm text-content`,children:r(o.AUTOMATIONS$DETAIL$TRIGGER_EVENT)})]}),e.trigger.source&&(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:r(o.AUTOMATIONS$DETAIL$EVENT_SOURCE)}),(0,j.jsx)(`span`,{className:`text-sm text-content`,children:e.trigger.source})]}),e.trigger.on&&(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:r(o.AUTOMATIONS$DETAIL$EVENT_TYPE)}),(0,j.jsx)(`code`,{className:`text-xs font-mono text-content`,children:Z(e.trigger.on)})]}),e.trigger.filter&&(0,j.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,j.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:r(o.AUTOMATIONS$DETAIL$EVENT_FILTER)}),(0,j.jsx)(`code`,{className:`text-xs font-mono text-content break-all`,children:e.trigger.filter})]})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(C,{testId:`edit-automation-frequency`,name:`frequency`,label:r(o.AUTOMATIONS$FREQUENCY),items:h,selectedKey:s.frequency,isDisabled:s.isCustomSchedule,onSelectionChange:e=>{!e||s.isCustomSchedule||f(t=>({...t,frequency:e}))}}),s.frequency===`weekly`&&!s.isCustomSchedule&&(0,j.jsx)(C,{testId:`edit-automation-weekday`,name:`weekday`,label:r(o.AUTOMATIONS$WEEKDAY),items:v,selectedKey:String(s.weekday),onSelectionChange:e=>{e!==null&&f(t=>({...t,weekday:Number(e)}))}}),(0,j.jsxs)(`label`,{className:`flex flex-col gap-2.5 w-full min-w-0`,children:[(0,j.jsx)(`span`,{className:`text-sm`,children:r(o.AUTOMATIONS$TIME_OF_DAY)}),(0,j.jsx)(`input`,{"data-testid":`edit-automation-time`,name:`timeOfDay`,type:`time`,value:s.timeOfDay,onChange:e=>f(t=>({...t,timeOfDay:e.target.value})),disabled:s.isCustomSchedule&&!y,className:d(te,`disabled:bg-[var(--oh-surface-raised)]`)}),e.timezone&&(0,j.jsxs)(`span`,{className:`text-xs text-muted`,children:[r(o.AUTOMATIONS$TIMEZONE),`: `,e.timezone]})]}),s.isCustomSchedule&&(0,j.jsxs)(`p`,{className:`text-xs text-muted`,"data-testid":`custom-schedule-hint`,children:[r(o.AUTOMATIONS$CUSTOM_SCHEDULE_HINT),s.rawSchedule&&(0,j.jsxs)(j.Fragment,{children:[` `,(0,j.jsx)(`code`,{className:`text-xs text-content`,children:s.rawSchedule})]})]})]}),(0,j.jsxs)(`div`,{className:`mt-2 flex justify-end gap-3`,children:[(0,j.jsx)(_,{testId:`edit-automation-cancel`,type:`button`,variant:`secondary`,onClick:n,isDisabled:i.isPending,children:r(o.AUTOMATIONS$CANCEL)}),(0,j.jsx)(_,{testId:`edit-automation-save`,type:`submit`,variant:`primary`,isDisabled:i.isPending,"aria-busy":i.isPending,children:i.isPending?r(o.AUTOMATIONS$SAVING):r(o.AUTOMATIONS$SAVE)})]})]})]})]})}export{k as C,P as S,I as _,Q as a,L as b,Z as c,ce as d,se as f,H as g,G as h,ge as i,ue as l,W as m,_e as n,he as o,q as p,$ as r,me as s,be as t,le as u,z as v,oe as x,B as y};
1
+ import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{t as n}from"./react-dom-hVBnwgwZ.js";import{t as r}from"./vendor~root~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-s~f2l2lr17-DYXOLEck.js";import{t as i}from"./useMutation-GSSKKebK.js";import{o as a,t as o}from"./declaration-CR6HMp29.js";import{n as s}from"./QueryClientProvider-Cnr-Yl3j.js";import{t as c}from"./useTranslation-B6voJV4y.js";import{n as l,r as u}from"./custom-toast-handlers-ufGJ6_Rc.js";import{t as d}from"./utils-DCVfKFRt.js";import{d as f,p,t as m}from"./agent-server-client-options-9agOSarV.js";import{n as h}from"./active-backend-context-BSPE-W72.js";import{r as g}from"./modal-classes-6YqcqA6y.js";import{c as ee,d as te,t as _}from"./brand-button-DJ_S16rO.js";import{r as v,u as y}from"./dropdown-classes-BsVmxlNG.js";import{n as ne,r as re}from"./vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~ninslayh-CLlsvdNP.js";import{t as b}from"./proxy-BqDMnUY-.js";import{t as x}from"./settings-input-CehsXnb3.js";import{n as S,t as ie}from"./context-menu-list-item-7tAcm2c3.js";import{t as C}from"./settings-dropdown-input-BtoovFre.js";import{t as w}from"./x-mark-BrkSPIiT.js";import{t as T}from"./automation-XDPAjiZi.js";var E=`/api/automation`,D=re.create();D.interceptors.request.use(e=>{let t=p();if(!t)throw new m;e.baseURL||=t.host;let n=t.apiKey?.trim();return n&&e.headers.set(`X-Session-API-Key`,n),e});function O(e,t){let n=new URLSearchParams;return n.set(`limit`,String(e)),n.set(`offset`,String(t)),n.toString()}var k=class e{static async listAutomations(e={}){let{limit:t=50,offset:n=0}=e,r=f().backend;if(r.kind===`cloud`)return b({backend:r,method:`GET`,path:`${E}/v1?${O(t,n)}`});let{data:i}=await D.get(`${E}/v1`,{params:{limit:t,offset:n}});return i}static async getAutomations(t=50,n=0){return e.listAutomations({limit:t,offset:n})}static async getAutomation(e){let t=f().backend,n=`${E}/v1/${encodeURIComponent(e)}`;if(t.kind===`cloud`)return b({backend:t,method:`GET`,path:n});let{data:r}=await D.get(n);return r}static async updateAutomation(e,t){let n=f().backend,r=`${E}/v1/${encodeURIComponent(e)}`;if(n.kind===`cloud`)return b({backend:n,method:`PATCH`,path:r,body:t});let{data:i}=await D.patch(r,t);return i}static async deleteAutomation(e){let t=f().backend,n=`${E}/v1/${encodeURIComponent(e)}`;if(t.kind===`cloud`){await b({backend:t,method:`DELETE`,path:n});return}await D.delete(n)}static async dispatchAutomation(e){let t=f().backend,n=`${E}/v1/${encodeURIComponent(e)}/dispatch`;if(t.kind===`cloud`)return b({backend:t,method:`POST`,path:n});let{data:r}=await D.post(n);return r}static async listAutomationRuns(e,t={}){let{limit:n=50,offset:r=0}=t,i=f().backend,a=`${E}/v1/${encodeURIComponent(e)}/runs`;if(i.kind===`cloud`)return b({backend:i,method:`GET`,path:`${a}?${O(n,r)}`});let{data:o}=await D.get(a,{params:{limit:n,offset:r}});return o}static async getAutomationRuns(t,n=50,r=0){return e.listAutomationRuns(t,{limit:n,offset:r})}static async toggleAutomation(t,n){return e.updateAutomation(t,{enabled:n})}static async downloadTarball(e,t){let n=f().backend,r=`${E}/v1/${encodeURIComponent(e)}/tarball`,i;if(n.kind===`cloud`)i=await b({backend:n,method:`GET`,path:r,responseType:`blob`});else{let{data:e}=await D.get(r,{responseType:`blob`});i=e}let a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=`${t}.tar`,o.click(),URL.revokeObjectURL(a)}static async checkHealth(){let e=f().backend,t=`${E}/health`;try{if(e.kind===`cloud`)return await b({backend:e,method:`GET`,path:t});let{data:n}=await D.get(t,{timeout:5e3});return n}catch{return{status:`error`}}}},A=e(t()),ae=e(n(),1),j=a(),M=[`automation-detail`],N=[`automation-runs`];function oe(e){let{id:t,enabled:n=!0}=e,i=h();return r({queryKey:[...M,t,i.backend.id,i.orgId],queryFn:()=>k.getAutomation(t),staleTime:300*1e3,enabled:!!t&&n})}function P(e){let{id:t,limit:n=20,offset:i=0,enabled:a=!0}=e,o=h();return r({queryKey:[...N,t,{limit:n,offset:i},o.backend.id,o.orgId],queryFn:()=>k.getAutomationRuns(t,n,i),staleTime:60*1e3,enabled:!!t&&a,refetchInterval:e=>{let t=e.state.data;return t&&t.runs.some(e=>e.status===T.PENDING||e.status===T.RUNNING)?3e3:!1}})}var F=[`automations`];function I(e={}){let{limit:t=50,offset:n=0,enabled:i=!0}=e,a=h();return r({queryKey:[...F,{limit:t,offset:n},a.backend.id,a.orgId],queryFn:()=>k.getAutomations(t,n),staleTime:0,enabled:i})}function L(){let e=s();return i({mutationFn:({id:e,enabled:t})=>k.toggleAutomation(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:F}),e.invalidateQueries({queryKey:M})}})}function R(){let e=s();return i({mutationFn:({id:e,body:t})=>k.updateAutomation(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:F}),e.invalidateQueries({queryKey:M})}})}function z(){let e=s();return i({mutationFn:e=>k.deleteAutomation(e),onSuccess:()=>{e.invalidateQueries({queryKey:F})}})}function B(){let e=s();return i({mutationFn:e=>k.dispatchAutomation(e),onSuccess:(t,n)=>{e.invalidateQueries({queryKey:F}),e.invalidateQueries({queryKey:M}),e.invalidateQueries({queryKey:[...N,n]})}})}var V=[`automation-health`];function H(){let e=h();return r({queryKey:[...V,e.backend.id,e.orgId],queryFn:()=>k.checkHealth(),staleTime:30*1e3,retry:!1})}var U=e=>(0,j.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`currentColor`,viewBox:`0 0 20 20`,...e,children:(0,j.jsx)(`path`,{d:`M10 6a2 2 0 110-4 2 2 0 010 4zm0 6a2 2 0 110-4 2 2 0 010 4zm0 6a2 2 0 110-4 2 2 0 010 4z`})}),W=d(`inline-flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent text-muted hover:bg-interactive-hover hover:text-white focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent disabled:hover:text-muted`,v),G=d(`inline-flex h-8 shrink-0 cursor-pointer items-center gap-1.5 rounded-md border-0 bg-transparent px-2 text-xs text-muted hover:bg-interactive-hover hover:text-white focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent disabled:hover:text-muted`,v);function K({icon:e,label:t}){return(0,j.jsxs)(`span`,{className:`flex min-w-0 w-full items-center gap-2`,children:[(0,j.jsx)(`span`,{className:d(`[&_svg]:size-4`,y),"aria-hidden":!0,children:e}),(0,j.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t})]})}function q({items:e}){let{t}=c(`openhands`),[n,r]=(0,A.useState)(!1),[i,a]=(0,A.useState)(),s=(0,A.useRef)(null),l=(0,A.useRef)(null);(0,A.useLayoutEffect)(()=>{if(!n||!s.current)return;let e=()=>{let e=s.current?.getBoundingClientRect();e&&a({position:`fixed`,zIndex:9999,top:e.bottom+4,right:window.innerWidth-e.right})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[n]),(0,A.useEffect)(()=>{if(!n)return;let e=e=>{let t=e.target;s.current?.contains(t)||l.current?.contains(t)||r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]);let u=n&&i?(0,j.jsx)(S,{ref:l,theme:`popover`,className:`min-w-[10rem]`,children:e.map(e=>(0,j.jsx)(`li`,{children:(0,j.jsx)(ie,{onClick:t=>{t.stopPropagation(),e.onClick(),r(!1)},isDisabled:e.disabled,className:`group`,children:(0,j.jsx)(K,{icon:e.icon,label:e.label})})},e.label))}):null;return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`button`,{ref:s,type:`button`,onClick:e=>{e.stopPropagation(),r(e=>!e)},className:W,"aria-label":t(o.AUTOMATIONS$ACTIONS_MENU),"aria-expanded":n,"aria-haspopup":`menu`,children:(0,j.jsx)(U,{className:`size-4`})}),n&&i&&typeof document<`u`?ae.createPortal((0,j.jsx)(`div`,{style:i,children:u}),document.body):null]})}function se(e){return!0}var ce=e=>(0,j.jsxs)(`svg`,{width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[(0,j.jsx)(`g`,{clipPath:`url(#clip0_8467_30872)`,children:(0,j.jsx)(`path`,{d:`M6.26693 21.4874L6.25583 21.4951L6.24514 21.5033C5.95991 21.7227 5.5 21.5308 5.5 21.0996V2.89961C5.5 2.4684 5.95991 2.2765 6.24514 2.49592L6.25634 2.50452L6.26799 2.51249L19.518 11.5625L19.518 11.5625L19.5226 11.5656C19.8258 11.7677 19.8258 12.1815 19.5226 12.3836L19.5226 12.3835L19.5169 12.3874L6.26693 21.4874Z`,fill:`currentColor`,stroke:`currentColor`})}),(0,j.jsx)(`defs`,{children:(0,j.jsx)(`clipPath`,{id:`clip0_8467_30872`,children:(0,j.jsx)(`rect`,{width:24,height:24,fill:`white`})})})]}),le=e=>(0,j.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,...e,children:(0,j.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z`})}),ue=e=>(0,j.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,...e,children:(0,j.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.455 2.456L21.75 6l-1.036.259a3.375 3.375 0 00-2.455 2.456z`})}),de=/^(\d+)$/;function J(e,t,n){let r=e.match(de);if(!r)return null;let i=Number(r[1]);return Number.isNaN(i)||i<t||i>n?null:i}function fe(e){let t=(e??``).trim();if(!t)return{kind:`custom`,raw:``};let n=t.split(/\s+/);if(n.length!==5)return{kind:`custom`,raw:t};let[r,i,a,o,s]=n,c=J(r,0,59),l=J(i,0,23);if(c===null||l===null)return{kind:`custom`,raw:t};if(a!==`*`||o!==`*`)return{kind:`custom`,raw:t,hour:l,minute:c};if(s===`*`||s===`0-6`)return{kind:`daily`,hour:l,minute:c};if(s===`1-5`)return{kind:`weekdays`,hour:l,minute:c};let u=J(s,0,6);return u===null?{kind:`custom`,raw:t,hour:l,minute:c}:{kind:`weekly`,hour:l,minute:c,weekday:u}}function pe(e){let{kind:t,hour:n,minute:r,weekday:i}=e;switch(t){case`daily`:return`${r} ${n} * * *`;case`weekdays`:return`${r} ${n} * * 1-5`;case`weekly`:return`${r} ${n} * * ${i??1}`;default:return t}}function Y(e,t){return`${String(e).padStart(2,`0`)}:${String(t).padStart(2,`0`)}`}function X(e){let t=e.match(/^(\d{1,2}):(\d{2})$/);if(!t)return null;let n=Number(t[1]),r=Number(t[2]);return Number.isNaN(n)||Number.isNaN(r)||n<0||n>23||r<0||r>59?null:{hour:n,minute:r}}function Z(e){return e?Array.isArray(e)?e.join(`, `):e:`—`}var me=e=>(0,j.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,...e,children:(0,j.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M5.636 5.636a9 9 0 1012.728 0M12 3v9`})}),he=e=>(0,j.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,...e,children:(0,j.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16`})}),Q=e=>(0,j.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:1.5,...e,children:(0,j.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z`})});function ge({onRetry:e}){let{t}=c(`openhands`);return(0,j.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20`,children:[(0,j.jsx)(Q,{className:`size-12 text-danger`}),(0,j.jsx)(`p`,{className:`mt-4 text-sm text-muted`,children:t(o.AUTOMATIONS$ERROR_TITLE)}),(0,j.jsx)(`button`,{type:`button`,onClick:e,className:`mt-4 rounded-lg border border-[var(--oh-border)] px-4 py-2 text-sm text-white hover:bg-surface-raised`,children:t(o.AUTOMATIONS$ERROR_RETRY)})]})}function $({onRetry:e}){let{t}=c(`openhands`);return(0,j.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20 px-4`,children:[(0,j.jsx)(Q,{className:`size-12 text-[var(--oh-warning)]`}),(0,j.jsx)(`h2`,{className:`mt-4 text-lg font-medium text-content`,children:t(o.AUTOMATIONS$BACKEND_UNAVAILABLE_TITLE)}),(0,j.jsx)(`p`,{className:`mt-2 text-sm text-muted text-center max-w-md`,children:t(o.AUTOMATIONS$BACKEND_UNAVAILABLE_MESSAGE)}),(0,j.jsx)(_,{type:`button`,variant:`secondary`,className:`mt-6`,onClick:e,children:t(o.AUTOMATIONS$BACKEND_UNAVAILABLE_RETRY)})]})}function _e({automationName:e,isOpen:t,onConfirm:n,onCancel:r}){let{t:i}=c(`openhands`);return t?(0,j.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,j.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:r,onKeyDown:e=>{e.key===`Escape`&&r()},role:`presentation`}),(0,j.jsxs)(`div`,{className:`relative w-full max-w-sm rounded-xl border border-[var(--oh-border)] bg-[var(--oh-surface)] p-6`,children:[(0,j.jsx)(`button`,{type:`button`,onClick:r,className:`absolute right-4 top-4 text-muted hover:text-foreground`,"aria-label":`Close`,children:(0,j.jsx)(w,{className:`size-5`})}),(0,j.jsx)(`h2`,{className:g,children:i(o.AUTOMATIONS$DELETE_CONFIRM_TITLE)}),(0,j.jsx)(`p`,{className:`mt-2 text-sm text-muted`,children:i(o.AUTOMATIONS$DELETE_CONFIRM_MESSAGE,{name:e})}),(0,j.jsxs)(`div`,{className:`mt-6 flex justify-end gap-3`,children:[(0,j.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-lg border border-[var(--oh-border)] px-4 py-2 text-sm text-white hover:bg-surface-raised`,children:i(o.AUTOMATIONS$CANCEL)}),(0,j.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-lg bg-danger px-4 py-2 text-sm text-white hover:bg-danger/80`,children:i(o.AUTOMATIONS$DELETE)})]})]})]}):null}var ve=[o.AUTOMATIONS$WEEKDAY_SUN,o.AUTOMATIONS$WEEKDAY_MON,o.AUTOMATIONS$WEEKDAY_TUE,o.AUTOMATIONS$WEEKDAY_WED,o.AUTOMATIONS$WEEKDAY_THU,o.AUTOMATIONS$WEEKDAY_FRI,o.AUTOMATIONS$WEEKDAY_SAT];function ye(e){if(e.trigger.type===`event`)return{name:e.name,prompt:e.prompt??``,frequency:`custom`,weekday:1,timeOfDay:``,isCustomSchedule:!0,rawSchedule:``};let t=fe(e.trigger.schedule);return t.kind===`custom`?{name:e.name,prompt:e.prompt??``,frequency:`custom`,weekday:1,timeOfDay:t.hour!==void 0&&t.minute!==void 0?Y(t.hour,t.minute):``,isCustomSchedule:!0,rawSchedule:t.raw}:{name:e.name,prompt:e.prompt??``,frequency:t.kind,weekday:t.kind===`weekly`?t.weekday??1:1,timeOfDay:Y(t.hour,t.minute),isCustomSchedule:!1,rawSchedule:e.trigger.schedule??``}}function be({automation:e,isOpen:t,onClose:n}){let{t:r}=c(`openhands`),i=R(),a=(0,A.useMemo)(()=>ye(e),[e]),[s,f]=(0,A.useState)(a),[p,m]=(0,A.useState)(null);if((0,A.useEffect)(()=>{t&&(f(a),m(null))},[t,a]),!t)return null;let h=[{key:`daily`,label:r(o.AUTOMATIONS$FREQUENCY_DAILY)},{key:`weekdays`,label:r(o.AUTOMATIONS$FREQUENCY_WEEKDAYS)},{key:`weekly`,label:r(o.AUTOMATIONS$FREQUENCY_WEEKLY)},...s.isCustomSchedule?[{key:`custom`,label:r(o.AUTOMATIONS$FREQUENCY_CUSTOM)}]:[]],v=ve.map((e,t)=>({key:String(t),label:r(e)})),y=!s.isCustomSchedule||X(s.timeOfDay)!==null||s.timeOfDay===``;return(0,j.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,j.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:n,onKeyDown:e=>{e.key===`Escape`&&n()},role:`presentation`}),(0,j.jsxs)(`div`,{className:`relative w-full max-w-md rounded-xl border border-[var(--oh-border)] bg-[var(--oh-surface)] p-6`,children:[(0,j.jsx)(`button`,{type:`button`,onClick:n,className:`absolute right-4 top-4 text-muted hover:text-foreground`,"aria-label":r(o.AUTOMATIONS$CANCEL),children:(0,j.jsx)(w,{className:`size-5`})}),(0,j.jsx)(`h2`,{className:g,children:r(o.AUTOMATIONS$EDIT_TITLE)}),(0,j.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let a=s.name.trim();if(!a){m(r(o.AUTOMATIONS$NAME_REQUIRED));return}m(null);let c={};a!==e.name&&(c.name=a);let d=s.prompt.trim();if(d!==(e.prompt??``).trim()&&(c.prompt=d.length===0?null:d),!s.isCustomSchedule&&s.frequency!==`custom`){let t=X(s.timeOfDay);if(t){let n=pe({kind:s.frequency,hour:t.hour,minute:t.minute,weekday:s.frequency===`weekly`?s.weekday:void 0});n!==e.trigger.schedule&&(c.trigger={...e.trigger,schedule:n})}}if(Object.keys(c).length===0){n();return}i.mutate({id:e.id,body:c},{onSuccess:()=>{u(r(o.AUTOMATIONS$EDIT_SUCCESS)),n()},onError:e=>{l(ne(e)?e.response?.data?.message||e.message||r(o.AUTOMATIONS$EDIT_ERROR):e.message||r(o.AUTOMATIONS$EDIT_ERROR))}})},className:`mt-4 flex flex-col gap-4`,"aria-label":r(o.AUTOMATIONS$EDIT_TITLE),children:[(0,j.jsx)(x,{testId:`edit-automation-name`,name:`name`,type:`text`,label:r(o.AUTOMATIONS$NAME),value:s.name,onChange:e=>f(t=>({...t,name:e})),error:p??void 0,showRequiredTag:!0}),(0,j.jsxs)(`label`,{className:`flex flex-col gap-2.5 w-full min-w-0`,children:[(0,j.jsx)(`span`,{className:`text-sm`,children:r(o.AUTOMATIONS$PROMPT)}),(0,j.jsx)(`textarea`,{"data-testid":`edit-automation-prompt`,name:`prompt`,value:s.prompt,onChange:e=>f(t=>({...t,prompt:e.target.value})),rows:4,className:d(ee,`placeholder:italic`)}),(0,j.jsx)(`span`,{className:`text-xs text-muted`,children:r(o.AUTOMATIONS$EDIT_PROMPT_HINT)})]}),e.trigger.type===`event`?(0,j.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg bg-[var(--oh-surface-raised)] p-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:r(o.AUTOMATIONS$DETAIL$TRIGGER)}),(0,j.jsx)(`span`,{className:`text-sm text-content`,children:r(o.AUTOMATIONS$DETAIL$TRIGGER_EVENT)})]}),e.trigger.source&&(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:r(o.AUTOMATIONS$DETAIL$EVENT_SOURCE)}),(0,j.jsx)(`span`,{className:`text-sm text-content`,children:e.trigger.source})]}),e.trigger.on&&(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:r(o.AUTOMATIONS$DETAIL$EVENT_TYPE)}),(0,j.jsx)(`code`,{className:`text-xs font-mono text-content`,children:Z(e.trigger.on)})]}),e.trigger.filter&&(0,j.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,j.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:r(o.AUTOMATIONS$DETAIL$EVENT_FILTER)}),(0,j.jsx)(`code`,{className:`text-xs font-mono text-content break-all`,children:e.trigger.filter})]})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(C,{testId:`edit-automation-frequency`,name:`frequency`,label:r(o.AUTOMATIONS$FREQUENCY),items:h,selectedKey:s.frequency,isDisabled:s.isCustomSchedule,onSelectionChange:e=>{!e||s.isCustomSchedule||f(t=>({...t,frequency:e}))}}),s.frequency===`weekly`&&!s.isCustomSchedule&&(0,j.jsx)(C,{testId:`edit-automation-weekday`,name:`weekday`,label:r(o.AUTOMATIONS$WEEKDAY),items:v,selectedKey:String(s.weekday),onSelectionChange:e=>{e!==null&&f(t=>({...t,weekday:Number(e)}))}}),(0,j.jsxs)(`label`,{className:`flex flex-col gap-2.5 w-full min-w-0`,children:[(0,j.jsx)(`span`,{className:`text-sm`,children:r(o.AUTOMATIONS$TIME_OF_DAY)}),(0,j.jsx)(`input`,{"data-testid":`edit-automation-time`,name:`timeOfDay`,type:`time`,value:s.timeOfDay,onChange:e=>f(t=>({...t,timeOfDay:e.target.value})),disabled:s.isCustomSchedule&&!y,className:d(te,`disabled:bg-[var(--oh-surface-raised)]`)}),e.timezone&&(0,j.jsxs)(`span`,{className:`text-xs text-muted`,children:[r(o.AUTOMATIONS$TIMEZONE),`: `,e.timezone]})]}),s.isCustomSchedule&&(0,j.jsxs)(`p`,{className:`text-xs text-muted`,"data-testid":`custom-schedule-hint`,children:[r(o.AUTOMATIONS$CUSTOM_SCHEDULE_HINT),s.rawSchedule&&(0,j.jsxs)(j.Fragment,{children:[` `,(0,j.jsx)(`code`,{className:`text-xs text-content`,children:s.rawSchedule})]})]})]}),(0,j.jsxs)(`div`,{className:`mt-2 flex justify-end gap-3`,children:[(0,j.jsx)(_,{testId:`edit-automation-cancel`,type:`button`,variant:`secondary`,onClick:n,isDisabled:i.isPending,children:r(o.AUTOMATIONS$CANCEL)}),(0,j.jsx)(_,{testId:`edit-automation-save`,type:`submit`,variant:`primary`,isDisabled:i.isPending,"aria-busy":i.isPending,children:i.isPending?r(o.AUTOMATIONS$SAVING):r(o.AUTOMATIONS$SAVE)})]})]})]})]})}export{k as C,P as S,I as _,Q as a,L as b,Z as c,ce as d,se as f,H as g,G as h,ge as i,ue as l,W as m,_e as n,he as o,q as p,$ as r,me as s,be as t,le as u,z as v,oe as x,B as y};
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browser-CGM-k-sH.js","assets/vendor~browser-BrOJLj3y.js","assets/vendor~browser-DisFGEp9.js","assets/settings-DGY6n4J2.js","assets/common-DqjLSBOt.js","assets/automation-XDPAjiZi.js","assets/query-client-config-CRnGSujB.js","assets/rolldown-runtime-BFRubm34.js","assets/vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~extensions~g56ukk6u-DsSvIDZQ.js","assets/mutation-D0OogFCz.js","assets/custom-toast-handlers-ufGJ6_Rc.js","assets/createLucideIcon-Ddu8jDOQ.js","assets/react-CM_dJw1Z.js","assets/declaration-CR6HMp29.js","assets/utils-DCVfKFRt.js","assets/vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~extensions~hkqzh1hb-BZ0HXuHD.js","assets/i18n-DET2iOyh.js","assets/vendor~entry.client~root~root-layout~home~conversation-panel~conversation~skills-settings~m~o9nrx3fm-D44TR8hL.js","assets/health-store-B5f0S2FY.js","assets/retrieve-axios-error-message-BY-yIkIq.js"])))=>i.map(i=>d[i]);
2
- import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{t as n}from"./preload-helper-CT1Z6Pdu.js";import{n as r}from"./vendor~entry.client-Du9GpFmX.js";import{t as i}from"./vendor~entry.client-CySJvEhK.js";import{o as a}from"./declaration-CR6HMp29.js";import{n as o,t as s}from"./providers-CbD7fiic.js";import{s as c}from"./i18n-DET2iOyh.js";var l=e(t(),1),u=i();function d({mockApi:e=void 0,hasWindow:t=typeof window<`u`}={}){return t&&e===`true`}var f=a();async function p(){if(await c(),d()){let{worker:e}=await n(async()=>{let{worker:e}=await import(`./browser-CGM-k-sH.js`);return{worker:e}},__vite__mapDeps([0,1,2,3,4,5]));await e.start({onUnhandledRequest:`bypass`});let{queryClient:t}=await n(async()=>{let{queryClient:e}=await import(`./query-client-config-CRnGSujB.js`).then(e=>e.i);return{queryClient:e}},__vite__mapDeps([6,7,8,9,10,11,12,13,14,15,4,16,17,18,19]));window.__TEST_INVALIDATE_QUERIES__=e=>void t.invalidateQueries(e?{queryKey:e}:void 0)}}p().then(()=>(0,l.startTransition)(()=>{(0,u.hydrateRoot)(document,(0,f.jsx)(l.StrictMode,{children:(0,f.jsx)(s,{analytics:o,withStyleRoot:!1,children:(0,f.jsx)(r,{})})}))}));
2
+ import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{t as n}from"./preload-helper-CT1Z6Pdu.js";import{n as r}from"./vendor~entry.client-Du9GpFmX.js";import{t as i}from"./vendor~entry.client-CySJvEhK.js";import{o as a}from"./declaration-CR6HMp29.js";import{n as o,t as s}from"./providers-eUyo6pgr.js";import{s as c}from"./i18n-DET2iOyh.js";var l=e(t(),1),u=i();function d({mockApi:e=void 0,hasWindow:t=typeof window<`u`}={}){return t&&e===`true`}var f=a();async function p(){if(await c(),d()){let{worker:e}=await n(async()=>{let{worker:e}=await import(`./browser-CGM-k-sH.js`);return{worker:e}},__vite__mapDeps([0,1,2,3,4,5]));await e.start({onUnhandledRequest:`bypass`});let{queryClient:t}=await n(async()=>{let{queryClient:e}=await import(`./query-client-config-CRnGSujB.js`).then(e=>e.i);return{queryClient:e}},__vite__mapDeps([6,7,8,9,10,11,12,13,14,15,4,16,17,18,19]));window.__TEST_INVALIDATE_QUERIES__=e=>void t.invalidateQueries(e?{queryKey:e}:void 0)}}p().then(()=>(0,l.startTransition)(()=>{(0,u.hydrateRoot)(document,(0,f.jsx)(l.StrictMode,{children:(0,f.jsx)(s,{analytics:o,withStyleRoot:!1,children:(0,f.jsx)(r,{})})}))}));
@@ -1 +1 @@
1
- import{L as e,s as t}from"./vendor~entry.client~root~root-layout~index-redirect~home~conversation-panel~conversation~la~cnj3raoq-DTEXlLSB.js";import{o as n,t as r}from"./declaration-CR6HMp29.js";import{t as i}from"./useTranslation-B6voJV4y.js";import{t as a}from"./sidebar-nav-link-OhIeFyna.js";import{r as o}from"./typography-BDgnT7Yp.js";import{t as s}from"./use-breakpoint-DF_RiQ6s.js";import{t as c}from"./backend-synced-settings-badge-BTIj-Ffq.js";import{t as l}from"./extensions-navigation-DSLGNGbS.js";var u=n();function d(){let{t:e}=i(`openhands`);return(0,u.jsxs)(`div`,{"data-testid":`extensions-mobile-hub`,className:`flex flex-col gap-4 px-4 py-2 md:hidden`,children:[(0,u.jsx)(o.H2,{children:e(r.NAV$CUSTOMIZE)}),(0,u.jsx)(`nav`,{className:`flex flex-col gap-0.5`,children:l.map(e=>(0,u.jsx)(a,{to:e.to,label:e.label,end:e.end,testId:`sidebar-extensions-${e.to}`,icon:e.icon,disabled:e.comingSoon},e.to))}),(0,u.jsx)(`div`,{className:`pt-1`,children:(0,u.jsx)(c,{})})]})}var f=e(function(){return s(768)?(0,u.jsx)(d,{}):(0,u.jsx)(t,{to:`/skills`,replace:!0})});export{f as default};
1
+ import{L as e,s as t}from"./vendor~entry.client~root~root-layout~index-redirect~home~conversation-panel~conversation~la~cnj3raoq-DTEXlLSB.js";import{o as n,t as r}from"./declaration-CR6HMp29.js";import{t as i}from"./useTranslation-B6voJV4y.js";import{t as a}from"./sidebar-nav-link-dgVb8Fpy.js";import{r as o}from"./typography-BDgnT7Yp.js";import{t as s}from"./use-breakpoint-DF_RiQ6s.js";import{t as c}from"./backend-synced-settings-badge-BkW5evM0.js";import{t as l}from"./extensions-navigation-VQ-3umJ7.js";var u=n();function d(){let{t:e}=i(`openhands`);return(0,u.jsxs)(`div`,{"data-testid":`extensions-mobile-hub`,className:`flex flex-col gap-4 px-4 py-2 md:hidden`,children:[(0,u.jsx)(o.H2,{children:e(r.NAV$CUSTOMIZE)}),(0,u.jsx)(`nav`,{className:`flex flex-col gap-0.5`,children:l.map(e=>(0,u.jsx)(a,{to:e.to,label:e.label,end:e.end,testId:`sidebar-extensions-${e.to}`,icon:e.icon,disabled:e.comingSoon},e.to))}),(0,u.jsx)(`div`,{className:`pt-1`,children:(0,u.jsx)(c,{})})]})}var f=e(function(){return s(768)?(0,u.jsx)(d,{}):(0,u.jsx)(t,{to:`/skills`,replace:!0})});export{f as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime-BFRubm34.js";import{t as e}from"./react-CM_dJw1Z.js";import{o as t,t as n}from"./declaration-CR6HMp29.js";import{t as r}from"./useTranslation-B6voJV4y.js";import{t as i}from"./utils-DCVfKFRt.js";import{t as a}from"./navigation-link-U4vY9i_C.js";import{c as o,m as s}from"./use-cloud-current-user-id-Ddr75hEz.js";import{t as c}from"./styled-tooltip-hdfMXPQC.js";import{n as l}from"./acp-providers-CPdgcp13.js";import{r as u}from"./use-settings-D5hbTS9t.js";import{t as d}from"./skills-0GRKX5Xj.js";import{t as f}from"./sidebar-store-DnQAJAE5.js";import{t as p}from"./use-breakpoint-DF_RiQ6s.js";import{t as m}from"./backend-synced-settings-badge-BTIj-Ffq.js";e();var h=t(),g=[{to:`/skills`,label:`Skills`,icon:(0,h.jsx)(d,{width:16,height:16,"aria-hidden":`true`}),end:!0},{to:`/mcp`,label:`MCP Servers`,icon:(0,h.jsx)(e=>(0,h.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,...e,children:(0,h.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M2.25 3H21.75L22.5 3.75V13.5H21V9H3V19.5H13.5V21H2.25L1.5 20.25V3.75L2.25 3ZM3 7.5H21V4.5H3V7.5ZM10.5 18V16.359C10.2451 16.2664 10.0074 16.132 9.7965 15.9615L8.379 16.77L7.629 15.48L9.0345 14.6595C8.98649 14.3881 8.98649 14.1104 9.0345 13.839L7.629 13.02L8.379 11.73L9.7965 12.54C10.023 12.36 10.2585 12.2265 10.5 12.141V10.5H12V12.141C12.2568 12.2293 12.4953 12.3641 12.7035 12.5385L14.121 11.73L14.871 13.02L13.4655 13.8405C13.5133 14.1114 13.5133 14.3886 13.4655 14.6595L14.871 15.48L14.121 16.77L12.7035 15.96C12.4903 16.1274 12.2531 16.2619 12 16.359V18H10.5ZM10.125 14.25C10.125 14.562 10.2345 14.8275 10.4535 15.0465C10.5568 15.1528 10.6807 15.2367 10.8177 15.2932C10.9547 15.3497 11.1018 15.3776 11.25 15.375C11.3982 15.3776 11.5453 15.3497 11.6823 15.2932C11.8193 15.2367 11.9432 15.1528 12.0465 15.0465C12.1528 14.9432 12.2367 14.8193 12.2932 14.6823C12.3497 14.5453 12.3776 14.3982 12.375 14.25C12.3776 14.1018 12.3497 13.9547 12.2932 13.8177C12.2367 13.6807 12.1528 13.5568 12.0465 13.4535C11.9432 13.3472 11.8193 13.2633 11.6823 13.2068C11.5453 13.1503 11.3982 13.1224 11.25 13.125C11.1018 13.1224 10.9547 13.1503 10.8177 13.2068C10.6807 13.2633 10.5568 13.3472 10.4535 13.4535C10.3472 13.5568 10.2633 13.6807 10.2068 13.8177C10.1503 13.9547 10.1224 14.1018 10.125 14.25ZM18.126 22.5V20.859C17.8711 20.7663 17.6334 20.632 17.4225 20.4615L16.005 21.27L15.255 19.98L16.662 19.1595C16.614 18.8881 16.614 18.6104 16.662 18.339L15.255 17.52L16.005 16.23L17.4225 17.04C17.649 16.86 17.8845 16.7265 18.1275 16.641V15H19.6275V16.641C19.8837 16.7297 20.1216 16.8644 20.3295 17.0385L21.747 16.23L22.497 17.52L21.0915 18.3405C21.1396 18.6114 21.1396 18.8886 21.0915 19.1595L22.497 19.98L21.747 21.27L20.3295 20.46C20.1163 20.6275 19.8791 20.762 19.626 20.859V22.5H18.126ZM17.751 18.75C17.751 19.062 17.8605 19.3275 18.0795 19.5465C18.1828 19.6528 18.3067 19.7367 18.4437 19.7932C18.5807 19.8497 18.7278 19.8776 18.876 19.875C19.0242 19.8776 19.1713 19.8497 19.3083 19.7932C19.4453 19.7367 19.5692 19.6528 19.6725 19.5465C19.779 19.4434 19.8633 19.3195 19.9201 19.1825C19.9768 19.0455 20.0049 18.8983 20.0025 18.75C20.0049 18.6017 19.9768 18.4545 19.9201 18.3175C19.8633 18.1805 19.779 18.0566 19.6725 17.9535C19.5694 17.8474 19.4457 17.7636 19.309 17.7071C19.1722 17.6506 19.0254 17.6226 18.8775 17.625C18.7291 17.6222 18.5817 17.65 18.4444 17.7065C18.3072 17.763 18.183 17.847 18.0795 17.9535C17.9732 18.0568 17.8893 18.1807 17.8328 18.3177C17.7763 18.4547 17.7484 18.6018 17.751 18.75Z`,fill:`currentColor`})}),{width:16,height:16}),end:!0,disabledByAcp:!0},{to:`/plugins`,label:`Plugins`,icon:(0,h.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,width:16,height:16,"aria-hidden":`true`,children:[(0,h.jsx)(`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`}),(0,h.jsx)(`path`,{d:`m3.3 7 8.7 5 8.7-5`}),(0,h.jsx)(`path`,{d:`M12 22V12`})]}),end:!0,comingSoon:!0}];function _(){let{t:e}=r(`openhands`),{data:t}=u(),d=f(e=>e.collapsed),_=p(1023),v=p(767),y=!d&&_&&!v,b=t?.agent_settings?.agent_kind===`acp`,x=typeof t?.agent_settings?.acp_server==`string`?t.agent_settings.acp_server:void 0,S=b?l.find(({key:e})=>e===x)?.display_name??`ACP Agent`:void 0;return y?null:(0,h.jsxs)(`aside`,{"data-testid":`extensions-navbar-desktop`,className:`hidden md:flex md:w-[260px] md:shrink-0 md:flex-col md:gap-2 md:sticky md:top-8 md:self-start`,children:[(0,h.jsx)(`span`,{className:`px-2 text-sm font-normal text-white`,children:e(n.NAV$CUSTOMIZE)}),(0,h.jsx)(`div`,{className:`flex flex-col gap-0.5 pt-0.5`,children:g.map(t=>{let r=!!(b&&t.disabledByAcp),l=(0,h.jsx)(`span`,{className:`shrink-0 flex items-center justify-center`,children:t.icon}),u=(0,h.jsx)(`span`,{className:`truncate`,children:t.label}),d=t.comingSoon&&(0,h.jsx)(`span`,{className:`ml-auto shrink-0 rounded-full border border-white/20 bg-white/5 px-1.5 py-0.5 text-[10px] font-medium text-[var(--oh-text-dim)]`,children:e(n.NAV$COMING_SOON)});return r?(0,h.jsx)(c,{content:e(n.SETTINGS$AGENT_DISABLED_TOOLTIP,{agentName:S}),placement:`right`,children:(0,h.jsxs)(`span`,{"aria-disabled":`true`,"data-testid":`sidebar-extensions-${t.to}`,className:i(s(),`truncate text-[var(--oh-muted)] opacity-50 cursor-not-allowed`),children:[l,u,d]})},t.to):(0,h.jsxs)(a,{to:t.to,end:t.end,"data-testid":`sidebar-extensions-${t.to}`,className:({isActive:e})=>i(s(),`truncate`,e?o.active:o.idle),children:[l,u,d]},t.to)})}),(0,h.jsx)(`div`,{className:`px-2 pt-3`,children:(0,h.jsx)(m,{})})]})}export{_ as n,g as t};
1
+ import"./rolldown-runtime-BFRubm34.js";import{t as e}from"./react-CM_dJw1Z.js";import{o as t,t as n}from"./declaration-CR6HMp29.js";import{t as r}from"./useTranslation-B6voJV4y.js";import{t as i}from"./utils-DCVfKFRt.js";import{t as a}from"./navigation-link-U4vY9i_C.js";import{c as o,m as s}from"./use-cloud-current-user-id-ClKFPjFz.js";import{t as c}from"./styled-tooltip-hdfMXPQC.js";import{n as l}from"./acp-providers-BAX8OU5C.js";import{r as u}from"./use-settings-DeO7nvpM.js";import{t as d}from"./skills-0GRKX5Xj.js";import{t as f}from"./sidebar-store-DnQAJAE5.js";import{t as p}from"./use-breakpoint-DF_RiQ6s.js";import{t as m}from"./backend-synced-settings-badge-BkW5evM0.js";e();var h=t(),g=[{to:`/skills`,label:`Skills`,icon:(0,h.jsx)(d,{width:16,height:16,"aria-hidden":`true`}),end:!0},{to:`/mcp`,label:`MCP Servers`,icon:(0,h.jsx)(e=>(0,h.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,...e,children:(0,h.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M2.25 3H21.75L22.5 3.75V13.5H21V9H3V19.5H13.5V21H2.25L1.5 20.25V3.75L2.25 3ZM3 7.5H21V4.5H3V7.5ZM10.5 18V16.359C10.2451 16.2664 10.0074 16.132 9.7965 15.9615L8.379 16.77L7.629 15.48L9.0345 14.6595C8.98649 14.3881 8.98649 14.1104 9.0345 13.839L7.629 13.02L8.379 11.73L9.7965 12.54C10.023 12.36 10.2585 12.2265 10.5 12.141V10.5H12V12.141C12.2568 12.2293 12.4953 12.3641 12.7035 12.5385L14.121 11.73L14.871 13.02L13.4655 13.8405C13.5133 14.1114 13.5133 14.3886 13.4655 14.6595L14.871 15.48L14.121 16.77L12.7035 15.96C12.4903 16.1274 12.2531 16.2619 12 16.359V18H10.5ZM10.125 14.25C10.125 14.562 10.2345 14.8275 10.4535 15.0465C10.5568 15.1528 10.6807 15.2367 10.8177 15.2932C10.9547 15.3497 11.1018 15.3776 11.25 15.375C11.3982 15.3776 11.5453 15.3497 11.6823 15.2932C11.8193 15.2367 11.9432 15.1528 12.0465 15.0465C12.1528 14.9432 12.2367 14.8193 12.2932 14.6823C12.3497 14.5453 12.3776 14.3982 12.375 14.25C12.3776 14.1018 12.3497 13.9547 12.2932 13.8177C12.2367 13.6807 12.1528 13.5568 12.0465 13.4535C11.9432 13.3472 11.8193 13.2633 11.6823 13.2068C11.5453 13.1503 11.3982 13.1224 11.25 13.125C11.1018 13.1224 10.9547 13.1503 10.8177 13.2068C10.6807 13.2633 10.5568 13.3472 10.4535 13.4535C10.3472 13.5568 10.2633 13.6807 10.2068 13.8177C10.1503 13.9547 10.1224 14.1018 10.125 14.25ZM18.126 22.5V20.859C17.8711 20.7663 17.6334 20.632 17.4225 20.4615L16.005 21.27L15.255 19.98L16.662 19.1595C16.614 18.8881 16.614 18.6104 16.662 18.339L15.255 17.52L16.005 16.23L17.4225 17.04C17.649 16.86 17.8845 16.7265 18.1275 16.641V15H19.6275V16.641C19.8837 16.7297 20.1216 16.8644 20.3295 17.0385L21.747 16.23L22.497 17.52L21.0915 18.3405C21.1396 18.6114 21.1396 18.8886 21.0915 19.1595L22.497 19.98L21.747 21.27L20.3295 20.46C20.1163 20.6275 19.8791 20.762 19.626 20.859V22.5H18.126ZM17.751 18.75C17.751 19.062 17.8605 19.3275 18.0795 19.5465C18.1828 19.6528 18.3067 19.7367 18.4437 19.7932C18.5807 19.8497 18.7278 19.8776 18.876 19.875C19.0242 19.8776 19.1713 19.8497 19.3083 19.7932C19.4453 19.7367 19.5692 19.6528 19.6725 19.5465C19.779 19.4434 19.8633 19.3195 19.9201 19.1825C19.9768 19.0455 20.0049 18.8983 20.0025 18.75C20.0049 18.6017 19.9768 18.4545 19.9201 18.3175C19.8633 18.1805 19.779 18.0566 19.6725 17.9535C19.5694 17.8474 19.4457 17.7636 19.309 17.7071C19.1722 17.6506 19.0254 17.6226 18.8775 17.625C18.7291 17.6222 18.5817 17.65 18.4444 17.7065C18.3072 17.763 18.183 17.847 18.0795 17.9535C17.9732 18.0568 17.8893 18.1807 17.8328 18.3177C17.7763 18.4547 17.7484 18.6018 17.751 18.75Z`,fill:`currentColor`})}),{width:16,height:16}),end:!0,disabledByAcp:!0},{to:`/plugins`,label:`Plugins`,icon:(0,h.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,width:16,height:16,"aria-hidden":`true`,children:[(0,h.jsx)(`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`}),(0,h.jsx)(`path`,{d:`m3.3 7 8.7 5 8.7-5`}),(0,h.jsx)(`path`,{d:`M12 22V12`})]}),end:!0,comingSoon:!0}];function _(){let{t:e}=r(`openhands`),{data:t}=u(),d=f(e=>e.collapsed),_=p(1023),v=p(767),y=!d&&_&&!v,b=t?.agent_settings?.agent_kind===`acp`,x=typeof t?.agent_settings?.acp_server==`string`?t.agent_settings.acp_server:void 0,S=b?l.find(({key:e})=>e===x)?.display_name??`ACP Agent`:void 0;return y?null:(0,h.jsxs)(`aside`,{"data-testid":`extensions-navbar-desktop`,className:`hidden md:flex md:w-[260px] md:shrink-0 md:flex-col md:gap-2 md:sticky md:top-8 md:self-start`,children:[(0,h.jsx)(`span`,{className:`px-2 text-sm font-normal text-white`,children:e(n.NAV$CUSTOMIZE)}),(0,h.jsx)(`div`,{className:`flex flex-col gap-0.5 pt-0.5`,children:g.map(t=>{let r=!!(b&&t.disabledByAcp),l=(0,h.jsx)(`span`,{className:`shrink-0 flex items-center justify-center`,children:t.icon}),u=(0,h.jsx)(`span`,{className:`truncate`,children:t.label}),d=t.comingSoon&&(0,h.jsx)(`span`,{className:`ml-auto shrink-0 rounded-full border border-white/20 bg-white/5 px-1.5 py-0.5 text-[10px] font-medium text-[var(--oh-text-dim)]`,children:e(n.NAV$COMING_SOON)});return r?(0,h.jsx)(c,{content:e(n.SETTINGS$AGENT_DISABLED_TOOLTIP,{agentName:S}),placement:`right`,children:(0,h.jsxs)(`span`,{"aria-disabled":`true`,"data-testid":`sidebar-extensions-${t.to}`,className:i(s(),`truncate text-[var(--oh-muted)] opacity-50 cursor-not-allowed`),children:[l,u,d]})},t.to):(0,h.jsxs)(a,{to:t.to,end:t.end,"data-testid":`sidebar-extensions-${t.to}`,className:({isActive:e})=>i(s(),`truncate`,e?o.active:o.idle),children:[l,u,d]},t.to)})}),(0,h.jsx)(`div`,{className:`px-2 pt-3`,children:(0,h.jsx)(m,{})})]})}export{_ as n,g as t};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{t as n}from"./vendor~root~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-s~f2l2lr17-DYXOLEck.js";import{o as r,t as i}from"./declaration-CR6HMp29.js";import{n as a}from"./QueryClientProvider-Cnr-Yl3j.js";import{t as o}from"./useTranslation-B6voJV4y.js";import{t as s}from"./retrieve-axios-error-message-BY-yIkIq.js";import{C as c,t as l}from"./utils-DCVfKFRt.js";import{S as u,a as d,d as f,n as p}from"./agent-server-client-options-HEOwGVIU.js";import{n as m}from"./active-backend-context-Beu-LZL-.js";import{r as h,u as g}from"./vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~dp08i1qy-hTzSytKK.js";import{a as _}from"./agent-server-conversation-service.api-CORdqJZg.js";import{t as v}from"./proxy-BAdHH8QB.js";import{t as y}from"./react-Dy05vyj5.js";import{s as b}from"./conversation-local-storage-YmOVXxxW.js";import{a as x}from"./vendor~root-layout~home~conversation-panel~conversation~shared-conversation~alert-banner~pl~rqjteh0a-d2oallMa.js";import{t as S}from"./folder-D1T2W1cj.js";import{t as C}from"./chevron-left-small-_uvG7RVM.js";import{t as w}from"./git-status-mapper-DnL9OC8_.js";import{n as T,r as E,t as D}from"./use-active-conversation-DHGcmjCK.js";import{t as O}from"./file-BTY6Gyy9.js";import{t as k}from"./use-agent-state-PKrUPMJ3.js";import{t as A}from"./use-event-store-BomO7ywK.js";import{t as j}from"./files-tab-store-m0ARqX_E.js";import{r as ee}from"./typography-BDgnT7Yp.js";import{ot as te,st as ne}from"./vendor~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-E4d6IEfI.js";import{t as re}from"./markdown-renderer-B3IAVfv4.js";import{t as ie}from"./link-external-DGxVm4Ps.js";import{t as M}from"./use-runtime-is-ready-Do2h_hRl.js";import{t as ae}from"./conversation-tab-empty-state-CStQLPVW.js";import{a as oe,c as se,i as ce,n as le,o as ue,r as de,s as fe,t as pe}from"./vendor~files-tab-BtkpAiMX.js";var N=e(t(),1),P=class{static async executeCommand(e,t,n,r,i=30){let a=f().backend;if(a.kind===`cloud`&&e){let o=await v({backend:a,method:`POST`,hostOverride:d(e),path:`/api/bash/execute_bash_command`,body:{command:n,...r?{cwd:r}:{},timeout:Math.floor(i)},authMode:`session-api-key`,sessionApiKey:t,timeoutSeconds:i+10});return{exit_code:o.exit_code??-1,stdout:o.stdout??``,stderr:o.stderr??``}}let o=await new h(p({conversationUrl:e,sessionApiKey:t})).executeCommand(n,r,i);return{exit_code:o.exit_code,stdout:o.stdout,stderr:o.stderr}}static async downloadFile(e,t,n){let r=f().backend;return r.kind===`cloud`&&e?(await v({backend:r,method:`GET`,hostOverride:d(e),path:`/api/file/download?path=${encodeURIComponent(n)}`,authMode:`session-api-key`,sessionApiKey:t,responseType:`blob`})).arrayBuffer():new g(p({conversationUrl:e,sessionApiKey:t})).downloadFile(n)}},F=2e3,me=[`.git`,`node_modules`,`.venv`,`venv`,`__pycache__`,`dist`,`build`,`.next`,`.cache`,`.pytest_cache`,`.mypy_cache`,`.turbo`,`.parcel-cache`,`target`];function he(){return`find . \\( ${me.map(e=>`-name '${e}' -prune`).join(` -o `)} \\) -o -type f -print 2>/dev/null | sort | head -n ${F}`}function ge(e){return e.startsWith(`./`)?e.slice(2):e}function _e(){let{data:e}=D(),t=M(),r=e?.id,i=e?.conversation_url,a=e?.session_api_key,o=e?.workspace?.working_dir?.trim();return n({queryKey:[`workspace-files`,r,i,a,o],queryFn:async()=>{let e=await P.executeCommand(i,a,he(),o,30);if(e.exit_code!==0)throw Error(e.stderr?.trim()||`Failed to list workspace files`);let t=e.stdout.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).map(ge);return Array.from(new Set(t)).slice(0,F)},enabled:t&&!!r&&!!o,retry:!1,staleTime:1e3*30,gcTime:1e3*60*5,meta:{disableToast:!0}})}function ve(){let{data:e}=D(),t=M(),r=e?.id,i=e?.conversation_url,a=e?.session_api_key,o=f().backend.kind===`local`,s=n({queryKey:[`workspace-session`,r,i,a],queryFn:async()=>({baseUrl:await new h(p({conversationUrl:i,sessionApiKey:a})).startWorkspaceSession(r)}),enabled:t&&!!r&&o,staleTime:1/0,gcTime:1/0,retry:!1});return{data:s.data??null,isLoading:s.isLoading,isError:s.isError,error:s.error??null}}function ye(e,t){let n=(t??``).replace(/^\/+/,``);return n?`${e}${n.split(`/`).map(e=>encodeURIComponent(e)).join(`/`)}`:e}var I=y(e=>({count:0,bump:()=>e(e=>({count:e.count+1}))}));function L(e,t){return e===null?null:`${e}${e.includes(`?`)?`&`:`?`}v=${t}`}var be=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`ico`,`svg`,`avif`]),xe=new Set([`pdf`]);function R(e){let t=e.lastIndexOf(`.`);return t===-1?``:e.slice(t+1).toLowerCase()}function Se(e){switch(R(e)){case`html`:case`htm`:return`text/html`;case`css`:return`text/css`;case`js`:case`mjs`:case`cjs`:return`text/javascript`;case`json`:return`application/json`;case`md`:case`markdown`:return`text/markdown`;case`svg`:return`image/svg+xml`;case`png`:return`image/png`;case`jpg`:case`jpeg`:return`image/jpeg`;case`gif`:return`image/gif`;case`webp`:return`image/webp`;case`bmp`:return`image/bmp`;case`ico`:return`image/x-icon`;case`avif`:return`image/avif`;case`pdf`:return`application/pdf`;default:return`text/plain`}}function Ce(e){let t=R(e);return be.has(t)?`image`:xe.has(t)?`pdf`:`text`}function z(e){let t=new Uint8Array(e,0,Math.min(e.byteLength,8e3));for(let e=0;e<t.length;e+=1)if(t[e]===0)return!0;return!1}function B(e){let t=new Uint8Array(e),n=32768,r=``;for(let e=0;e<t.length;e+=n)r+=String.fromCharCode.apply(null,t.subarray(e,e+n));return btoa(r)}function V(e){let{data:t}=D(),r=M(),{data:i}=ve(),a=I(e=>e.count),o=t?.id,s=t?.conversation_url,c=t?.session_api_key,l=i?.baseUrl,u=f().backend.kind===`cloud`;return n({queryKey:[`workspace-file-content`,o,s,c,u?`cloud`:l,e,a],queryFn:async()=>{if(!e)throw Error(`No path`);let t=Ce(e),n=Se(e);if(u){let r=await P.downloadFile(s,c,e);return t===`text`?z(r)?{path:e,kind:`binary`,text:null,staticUrl:`data:application/octet-stream;base64,${B(r)}`,mimeType:`application/octet-stream`}:{path:e,kind:`text`,text:new TextDecoder(`utf-8`,{fatal:!1}).decode(r),staticUrl:`data:${n};charset=utf-8;base64,${B(r)}`,mimeType:n}:{path:e,kind:t,text:null,staticUrl:`data:${n};base64,${B(r)}`,mimeType:n}}if(!l)throw Error(`No workspace session`);let r=ye(l,e);if(t!==`text`)return{path:e,kind:t,text:null,staticUrl:r,mimeType:n};let i=await fetch(r,{credentials:`include`});if(!i.ok)throw Error(`Failed to read ${e}: ${i.status}`);let a=await i.arrayBuffer();return z(a)?{path:e,kind:`binary`,text:null,staticUrl:r,mimeType:`application/octet-stream`}:{path:e,kind:`text`,text:new TextDecoder(`utf-8`,{fatal:!1}).decode(a),staticUrl:r,mimeType:n}},enabled:r&&!!o&&!!e&&(u||!!l),retry:!1,staleTime:1e3*5,gcTime:1e3*60,meta:{disableToast:!0}})}function we(){let{data:e,isLoading:t}=D(),n=e?.id?_(e.id):null;return{hasAttachedSource:!!e?.selected_repository||!!n?.selected_workspace,isLoading:t}}function Te(e){let{data:t}=D(),r=M(),{backend:i}=m(),a=i.kind===`local`,o=t?.id,s=t?.conversation_url,c=t?.session_api_key,l=t?.workspace?.working_dir?.trim(),u=(e?.enabled??!0)&&a&&r&&!!o&&!!l,d=n({queryKey:[`has-git-commits`,o,s,c,l],queryFn:async()=>(await P.executeCommand(s,c,`git rev-parse --verify HEAD`,l,10)).exit_code===0,enabled:u,retry:!1,staleTime:6e4,gcTime:5*6e4,meta:{disableToast:!0}});return{hasCommits:d.data??null,isLoading:d.isLoading}}var Ee=new Set([`FileEditorObservation`,`StrReplaceEditorObservation`,`PlanningFileEditorObservation`]),De=new Set([`view`]);function Oe(e){let t=e.observation;return!(!t||typeof t.kind!=`string`||!Ee.has(t.kind)||t.command&&De.has(t.command))}function ke(){let e=a(),t=A(e=>e.events),n=I(e=>e.bump),r=(0,N.useRef)(new Set),i=(0,N.useRef)(new WeakSet);(0,N.useEffect)(()=>{let a=[];for(let e of t){let t=`id`in e?e.id:void 0;(t===void 0?i.current.has(e):r.current.has(t))||(t===void 0?i.current.add(e):r.current.add(t),Oe(e)&&a.push(e))}a.length!==0&&(e.invalidateQueries({queryKey:[`workspace-files`]}),e.invalidateQueries({queryKey:[`workspace-file-content`]}),e.invalidateQueries({queryKey:[`file_changes`]}),n())},[t,e,n])}function H(e){return e.startsWith(`/`)?e:`/${e}`}var U=class{static async getGitChanges(e,t,n){let r=f().backend;if(r.kind===`cloud`&&e){let i=new URLSearchParams;i.set(`path`,H(n));let a=await v({backend:r,method:`GET`,hostOverride:d(e),path:`/api/git/changes?${i.toString()}`,authMode:`session-api-key`,sessionApiKey:t});if(!Array.isArray(a))throw Error(`Invalid response from runtime - runtime may be unavailable`);return a.map(e=>({status:w(String(e.status)),path:e.path}))}let i=await new h(p({conversationUrl:e,sessionApiKey:t})).gitChanges(n,{ref:`HEAD`});if(!Array.isArray(i))throw Error(`Invalid response from runtime - runtime may be unavailable`);return i.map(e=>({status:w(String(e.status)),path:e.path}))}static async getGitChangeDiff(e,t,n){let r=f().backend;if(r.kind===`cloud`&&e){let i=new URLSearchParams;i.set(`path`,H(n));let a=await v({backend:r,method:`GET`,hostOverride:d(e),path:`/api/git/diff?${i.toString()}`,authMode:`session-api-key`,sessionApiKey:t});return{modified:a?.modified??``,original:a?.original??``,...a?.diff?{diff:a.diff}:{}}}let i=await new h(p({conversationUrl:e,sessionApiKey:t})).gitDiff(n,{ref:`HEAD`});return{modified:i.modified??``,original:i.original??``,...i.diff?{diff:i.diff}:{}}}};function W(e,t){let n=t?.trim();if(n)return n;if(!e)return u;let r=e.split(`/`);return`${u}/${r[r.length-1]}`}var G=()=>{let{conversationId:e}=T(),{data:t}=D(),[r,i]=N.useState([]),a=N.useRef(null),o=M(),s=t?.conversation_url,c=t?.session_api_key,l=t?.selected_repository,u=t?.workspace?.working_dir?.trim(),d=N.useMemo(()=>W(l,u),[l,u]),f=n({queryKey:[`file_changes`,e,s,c,d],queryFn:async()=>{if(!e)throw Error(`No conversation ID`);return U.getGitChanges(s,c,d)},retry:!1,staleTime:1e3*60*5,gcTime:1e3*60*15,refetchOnMount:`always`,enabled:o&&!!e,meta:{disableToast:!0}});return N.useEffect(()=>{if(!f.isFetching&&f.isSuccess&&f.data){let e=f.data;if(e!==a.current)if(a.current=e,Array.isArray(e)){let t=new Set(e.map(e=>e.path)),n=new Set(r.map(e=>e.path)),a=e.filter(e=>!n.has(e.path)),o=r.filter(e=>t.has(e.path));i([...a,...o])}else i([e])}},[f.isFetching,f.isSuccess,f.data]),{data:r,isLoading:f.isLoading,isFetching:f.isFetching,isSuccess:f.isSuccess,isError:f.isError,error:f.error,refetch:f.refetch}},Ae=[`index.html`,`index.htm`,`readme.md`,`readme`,`main.html`,`app.html`,`index.js`,`index.ts`,`index.tsx`,`index.jsx`,`main.py`,`app.py`,`main.go`,`main.rs`,`main.java`,`main.c`,`main.cpp`,`package.json`,`pyproject.toml`,`cargo.toml`,`go.mod`,`pom.xml`,`dockerfile`,`makefile`],je=[`license`,`license.md`,`license.txt`,`changelog.md`,`agents.md`,`tsconfig.json`,`.env.sample`,`.env.example`];function Me(e){let t=e.lastIndexOf(`/`);return(t===-1?e:e.slice(t+1)).toLowerCase()}function K(e){return e.split(`/`).filter(Boolean).length-1}function q(e){let t=Me(e),n=Ae.indexOf(t);if(n!==-1)return n;let r=je.indexOf(t);return r===-1?1e4:1e3+r}function J(e){return[...e].sort((e,t)=>{let n=K(e)-K(t);if(n!==0)return n;let r=q(e)-q(t);return r===0?e.localeCompare(t):r})}var Y=r(),Ne=e=>(0,Y.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,...e,children:(0,Y.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M10.8615 8.16992L14.2799 12.158L10.8615 16.1461L9.72266 15.1699L12.3043 12.158L9.72266 9.14611L10.8615 8.16992Z`,fill:`currentColor`})});function Pe({paths:e,selectedPath:t,onSelectFile:n,isTreeVisible:r,onToggleTree:a}){let{t:s}=o(`openhands`),c=(0,N.useMemo)(()=>J(e),[e]);return(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-[var(--oh-border)] px-2 py-1.5 min-h-[34px]`,"data-testid":`file-quick-row`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:a,"data-testid":`file-quick-row-tree-toggle`,"aria-pressed":r,"aria-label":s(r?i.FILES$HIDE_FILE_TREE:i.FILES$SHOW_FILE_TREE),title:s(r?i.FILES$HIDE_FILE_TREE:i.FILES$SHOW_FILE_TREE),className:l(`shrink-0 inline-flex items-center justify-center w-6 h-6 rounded-md cursor-pointer`,`text-[var(--oh-text-tertiary)] hover:bg-tertiary`,r&&`bg-[var(--oh-surface-raised)]`),children:r?(0,Y.jsx)(C,{className:`w-3 h-3`}):(0,Y.jsx)(Ne,{className:`w-3 h-3`})}),c.length>0&&(0,Y.jsx)(`div`,{className:`flex flex-nowrap items-center gap-1.5 overflow-hidden flex-1 min-w-0`,children:c.map(e=>{let r=t===e;return(0,Y.jsx)(`button`,{type:`button`,onClick:()=>n(e),title:e,"data-testid":`file-quick-row-item-${e}`,className:l(`inline-flex items-center px-2 py-0.5 text-xs whitespace-nowrap rounded-md cursor-pointer`,r?`bg-[var(--oh-interactive-hover)] text-white`:`bg-[var(--oh-surface-raised)] text-[var(--oh-text-tertiary)] hover:bg-tertiary`),children:e},e)})})]})}function X(e){e.children.sort((e,t)=>e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1);for(let t of e.children)t.isDirectory&&X(t)}function Fe(e,t,n,r,i){let a=t.get(e);a||(a=new Map,t.set(e,a));let o=a.get(n);if(o)return!i&&!o.isDirectory&&(o.isDirectory=!0),o;let s={name:n,path:r,isDirectory:!i,children:[]};return e.children.push(s),a.set(n,s),s}function Ie(e){let t={name:``,path:``,isDirectory:!0,children:[]},n=new Map;for(let r of e){let e=r.split(`/`).filter(Boolean);if(e.length>0){let r=t,i=``;for(let t=0;t<e.length;t+=1){let a=e[t];i=i?`${i}/${a}`:a;let o=t===e.length-1;r=Fe(r,n,a,i,o)}}}return X(t),t}function Le({node:e,depth:t,selectedPath:n,onSelectFile:r}){let[i,a]=(0,N.useState)(!1),o=8+t*12;if(e.isDirectory)return(0,Y.jsxs)(`li`,{children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),"aria-expanded":i,"data-testid":`file-tree-dir-${e.path}`,className:l(`flex w-full items-center gap-1.5 py-1 pr-2 text-left text-sm text-white`,`hover:bg-tertiary cursor-pointer`),style:{paddingLeft:`${o}px`},children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:l(`inline-block w-3 text-[10px] text-[var(--oh-muted)] transition-transform`,i?`rotate-90`:`rotate-0`),children:`▶`}),(0,Y.jsx)(S,{className:`w-3.5 h-3.5 shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.name})]}),i&&e.children.length>0&&(0,Y.jsx)(`ul`,{children:e.children.map(e=>(0,Y.jsx)(Le,{node:e,depth:t+1,selectedPath:n,onSelectFile:r},e.path))})]});let s=n===e.path;return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>r(e.path),"data-testid":`file-tree-file-${e.path}`,className:l(`flex w-full items-center gap-1.5 py-1 pr-2 text-left text-sm`,`hover:bg-tertiary cursor-pointer`,s?`bg-[var(--oh-interactive-hover)] text-white`:`text-[var(--oh-text-tertiary)]`),style:{paddingLeft:`${o+16}px`},children:[(0,Y.jsx)(O,{className:`w-3.5 h-3.5 shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.name})]})})}function Re({paths:e,selectedPath:t,onSelectFile:n}){let{t:r}=o(`openhands`),a=(0,N.useMemo)(()=>Ie(e),[e]);return a.children.length===0?(0,Y.jsx)(`div`,{className:`px-3 py-4 text-sm text-[var(--oh-muted)]`,children:r(i.FILES$NO_FILES)}):(0,Y.jsx)(`ul`,{className:`py-1 custom-scrollbar-always`,"data-testid":`file-tree-view`,children:a.children.map(e=>(0,Y.jsx)(Le,{node:e,depth:0,selectedPath:t,onSelectFile:n},e.path))})}var ze={js:`javascript`,jsx:`jsx`,mjs:`javascript`,cjs:`javascript`,ts:`typescript`,tsx:`tsx`,py:`python`,pyi:`python`,pyw:`python`,html:`markup`,htm:`markup`,svg:`markup`,xml:`markup`,css:`css`,scss:`scss`,sass:`sass`,less:`less`,json:`json`,json5:`json5`,yaml:`yaml`,yml:`yaml`,toml:`toml`,ini:`ini`,cfg:`ini`,properties:`properties`,conf:`ini`,env:`bash`,md:`markdown`,markdown:`markdown`,mdx:`markdown`,sh:`bash`,bash:`bash`,zsh:`bash`,fish:`bash`,bat:`batch`,cmd:`batch`,ps1:`powershell`,ps:`powershell`,c:`c`,h:`c`,cpp:`cpp`,cc:`cpp`,cxx:`cpp`,hpp:`cpp`,hh:`cpp`,cs:`csharp`,java:`java`,kt:`kotlin`,kts:`kotlin`,scala:`scala`,rs:`rust`,go:`go`,rb:`ruby`,php:`php`,swift:`swift`,m:`objectivec`,mm:`objectivec`,hs:`haskell`,ex:`elixir`,exs:`elixir`,erl:`erlang`,fs:`fsharp`,fsx:`fsharp`,ml:`ocaml`,mli:`ocaml`,clj:`clojure`,cljs:`clojure`,cljc:`clojure`,lua:`lua`,pl:`perl`,pm:`perl`,r:`r`,jl:`julia`,dart:`dart`,groovy:`groovy`,gradle:`groovy`,tf:`hcl`,hcl:`hcl`,dockerfile:`docker`,sql:`sql`,graphql:`graphql`,gql:`graphql`,proto:`protobuf`,diff:`diff`,patch:`diff`,nix:`nix`,sol:`solidity`},Be={dockerfile:`docker`,makefile:`makefile`,gnumakefile:`makefile`,".bashrc":`bash`,".zshrc":`bash`,".profile":`bash`,".env":`bash`,".gitignore":`bash`,".dockerignore":`bash`};function Ve(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`)),n=e.slice(t+1),r=n.lastIndexOf(`.`);return r<=0?``:n.slice(r+1).toLowerCase()}function He(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return e.slice(t+1).toLowerCase()}function Ue(e,t){let n=Be[He(e)];if(n)return n;let r=Ve(e);if(r&&ze[r])return ze[r];if(t){if(t===`text/html`)return`markup`;if(t===`text/css`)return`css`;if(t===`application/json`)return`json`;if(t===`text/markdown`)return`markdown`;if(t===`application/javascript`||t===`text/javascript`)return`javascript`;if(t===`application/x-yaml`||t===`text/yaml`)return`yaml`}return null}function We({path:e,text:t,mimeType:n}){let r=Ue(e,n);return r?(0,Y.jsx)(`div`,{"data-testid":`file-content-viewer-highlighted`,"data-language":r,className:`h-full w-full overflow-auto bg-[var(--oh-surface)] custom-scrollbar-always`,children:(0,Y.jsx)(te,{language:r,style:ne,showLineNumbers:!0,wrapLongLines:!1,customStyle:{margin:0,padding:`1rem`,background:`transparent`,fontSize:`0.75rem`,lineHeight:`1.25rem`,minHeight:`100%`},codeTagProps:{style:{background:`transparent`,fontFamily:`inherit`}},lineNumberStyle:{color:`var(--oh-border)`,minWidth:`2.5em`,paddingRight:`1em`,userSelect:`none`},children:t})}):(0,Y.jsx)(`pre`,{"data-testid":`file-content-viewer-plain`,className:`h-full w-full overflow-auto whitespace-pre-wrap break-words bg-[var(--oh-surface)] p-4 text-xs leading-5 text-white custom-scrollbar-always`,children:t})}var Ge=new Set([`html`,`htm`,`svg`]),Ke=new Set([`md`,`markdown`,`mdx`]),qe={pptx:`PowerPoint`,ppt:`PowerPoint`,docx:`Word`,doc:`Word`,xlsx:`Excel`,xls:`Excel`};function Z(e){let t=e.lastIndexOf(`.`);return t===-1?``:e.slice(t+1).toLowerCase()}function Q({path:e}){let{t}=o(`openhands`),n=qe[Z(e)];return(0,Y.jsx)(`div`,{className:`flex h-full w-full items-center justify-center text-sm text-[var(--oh-muted)]`,"data-testid":n?`file-content-viewer-unsupported-document`:`file-content-viewer-binary-fallback`,children:n?t(i.FILES$UNSUPPORTED_DOCUMENT,{type:n}):t(i.FILES$BINARY_FALLBACK)})}function Je({path:e,viewMode:t}){let{t:n}=o(`openhands`),r=V(e),a=I(e=>e.count);if(r.isLoading)return(0,Y.jsx)(`div`,{className:`flex h-full w-full items-center justify-center text-sm text-[var(--oh-muted)]`,children:n(i.FILES$LOADING_FILES)});if(r.isError||!r.data)return(0,Y.jsx)(`div`,{className:`flex h-full w-full items-center justify-center text-sm text-[var(--oh-muted)]`,"data-testid":`file-content-viewer-error`,children:r.error?.message??n(i.FILES$LOAD_ERROR)});let{kind:s,text:c,staticUrl:l,mimeType:u}=r.data,d=L(l,a);return t===`plain`?s===`text`&&c!==null?(0,Y.jsx)(We,{path:e,text:c,mimeType:u??void 0}):(0,Y.jsx)(Q,{path:e}):s===`image`?(0,Y.jsx)(`div`,{className:`flex h-full w-full items-center justify-center bg-[var(--oh-surface)] p-4`,"data-testid":`file-content-viewer-image`,children:(0,Y.jsx)(`img`,{src:d,alt:e,className:`max-h-full max-w-full object-contain`})}):s===`pdf`?(0,Y.jsx)(`iframe`,{title:e,src:d,sandbox:`allow-same-origin`,"data-testid":`file-content-viewer-iframe`,className:`h-full w-full bg-white`}):s===`binary`?(0,Y.jsx)(Q,{path:e}):u===`text/html`||Ge.has(Z(e))?(0,Y.jsx)(`iframe`,{title:e,src:d,sandbox:`allow-same-origin`,"data-testid":`file-content-viewer-iframe`,className:`h-full w-full bg-white`}):s===`text`&&Ke.has(Z(e))?(0,Y.jsx)(`div`,{"data-testid":`file-content-viewer-markdown`,className:`h-full w-full overflow-auto bg-[var(--oh-surface)] text-white custom-scrollbar-always`,children:(0,Y.jsx)(`div`,{className:`prose prose-sm prose-invert max-w-none p-6 [--tw-prose-body:#fff] [--tw-prose-bold:#fff] [--tw-prose-headings:#fff] [--tw-prose-lead:#fff] [--tw-prose-counters:#fff] [--tw-prose-quotes:#fff] [--tw-prose-quote-borders:var(--oh-border-subtle)] [--tw-prose-bullets:var(--oh-muted)] [--tw-prose-hr:var(--oh-border-subtle)] [--tw-prose-captions:var(--oh-muted)] [--tw-prose-kbd:#fff]`,children:(0,Y.jsx)(re,{content:c??``,includeStandard:!0,includeHeadings:!0})})}):s===`text`&&c!==null?(0,Y.jsx)(We,{path:e,text:c,mimeType:u??void 0}):(0,Y.jsx)(Q,{path:e})}function Ye({value:e,options:t,onChange:n,ariaLabel:r,testId:i}){return(0,Y.jsx)(`div`,{role:`radiogroup`,"aria-label":r,"data-testid":i,className:`inline-flex items-center rounded-md bg-[var(--oh-surface-raised)] p-0.5 text-xs`,children:t.map(t=>{let r=t.value===e;return(0,Y.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":r,"data-testid":i?`${i}-option-${t.value}`:void 0,onClick:()=>n(t.value),className:l(`px-2 py-0.5 rounded cursor-pointer transition-colors`,r?`bg-[var(--oh-interactive-hover)] text-white`:`text-[var(--oh-muted)] hover:text-white`),children:t.label},t.value)})})}var Xe=e=>(0,Y.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 13 15`,fill:`none`,...e,children:(0,Y.jsx)(`path`,{d:`M6.59467 0.21967C6.88756 -0.0732233 7.36244 -0.0732233 7.65533 0.21967L9.90533 2.46967C10.1982 2.76256 10.1982 3.23744 9.90533 3.53033L7.65533 5.78033C7.36244 6.07322 6.88756 6.07322 6.59467 5.78033C6.30178 5.48744 6.30178 5.01256 6.59467 4.71967L7.56434 3.75H6.375C3.71421 3.75 1.5 5.96421 1.5 8.625C1.5 11.2858 3.71421 13.5 6.375 13.5C9.03579 13.5 11.25 11.2858 11.25 8.625C11.25 8.21079 11.5858 7.875 12 7.875C12.4142 7.875 12.75 8.21079 12.75 8.625C12.75 12.1142 9.86421 15 6.375 15C2.88579 15 0 12.1142 0 8.625C0 5.13579 2.88579 2.25 6.375 2.25H7.56434L6.59467 1.28033C6.30178 0.987437 6.30178 0.512563 6.59467 0.21967Z`,fill:`currentColor`})}),Ze=e=>{switch(e.split(`.`).pop()?.toLowerCase()){case`js`:case`jsx`:return`javascript`;case`ts`:case`tsx`:return`typescript`;case`py`:return`python`;case`html`:return`html`;case`css`:return`css`;case`json`:return`json`;case`md`:return`markdown`;case`yml`:case`yaml`:return`yaml`;case`sh`:case`bash`:return`bash`;case`dockerfile`:return`dockerfile`;case`rs`:return`rust`;case`go`:return`go`;case`java`:return`java`;case`cpp`:case`cc`:case`cxx`:return`cpp`;case`c`:return`c`;case`rb`:return`ruby`;case`php`:return`php`;case`sql`:return`sql`;default:return`text`}},Qe=e=>(0,Y.jsx)(`svg`,{width:13,height:8,viewBox:`0 0 13 8`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,Y.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M0.259766 6.17427L6.26425 0.715628L12.2688 6.17427L11.2597 7.28418L6.26425 2.74282L1.26878 7.28418L0.259766 6.17427Z`,fill:`currentColor`})}),$e=e=>{let{conversationId:t}=T(),{data:r}=D(),i=r?.conversation_url,a=r?.session_api_key,o=r?.selected_repository,s=r?.workspace?.working_dir?.trim(),c=N.useMemo(()=>`${W(o,s)}/${e.filePath}`,[o,e.filePath,s]),l=e.type===`D`;return n({queryKey:[`file_diff`,t,i,a,c],queryFn:async()=>{if(!t)throw Error(`No conversation ID`);return U.getGitChangeDiff(i,a,c)},enabled:e.enabled&&!l,staleTime:1e3*60*5,gcTime:1e3*60*15})};function et({className:e}){return(0,Y.jsx)(`div`,{className:`flex items-center justify-center`,children:(0,Y.jsx)(`div`,{className:l(`animate-spin rounded-full border-4 border-[var(--oh-border)] border-t-white`,e),role:`status`,"aria-label":`Loading`})})}function tt({height:e,children:t}){return(0,Y.jsx)(`div`,{"data-testid":`editor-container`,className:`w-full border-b border-[var(--oh-border)] overflow-hidden h-[var(--editor-height)]`,style:{"--editor-height":`${e}px`},children:t})}var nt=[{mode:`old`,icon:ue},{mode:`diff`,icon:oe},{mode:`new`,icon:pe}],rt={renderValidationDecorations:`off`,readOnly:!0,scrollBeyondLastLine:!1,minimap:{enabled:!1},automaticLayout:!0,scrollbar:{alwaysConsumeMouseWheel:!1}},it={A:ce,D:de,M:le,R:`Renamed`,U:`Untracked`},at=e=>{e.editor.defineTheme(`custom-diff-theme`,{base:`vs-dark`,inherit:!0,rules:[{token:`comment`,foreground:`6a9955`},{token:`keyword`,foreground:`569cd6`},{token:`string`,foreground:`ce9178`},{token:`number`,foreground:`b5cea8`}],colors:{"diffEditor.insertedTextBackground":`#014b01AA`,"diffEditor.removedTextBackground":`#750000AA`,"diffEditor.insertedLineBackground":`#003f00AA`,"diffEditor.removedLineBackground":`#5a0000AA`,"diffEditor.border":`var(--oh-border-subtle)`,"editorUnnecessaryCode.border":`#00000000`,"editorUnnecessaryCode.opacity":`rgba(0, 0, 0, 0.467)`}})};function ot({path:e,type:t}){let{t:n}=o(`openhands`),[r,a]=N.useState(!0),[s,c]=N.useState(400),[u,d]=N.useState(`diff`),f=N.useRef(null),p=N.useRef(null),m=t===`A`||t===`U`,h=t===`D`,g=N.useMemo(()=>{if(t===`R`){let t=e.split(/\s+/).slice(1);return t[t.length-1]}return e},[e,t]),{data:_,isLoading:v,isSuccess:y,isRefetching:b}=$e({filePath:g,type:t,enabled:!r}),x=N.useCallback(()=>{if(!f.current)return;let e=f.current.getOriginalEditor(),t=f.current.getModifiedEditor();e&&t&&c(Math.max(e.getContentHeight(),t.getContentHeight())+20)},[]),S=N.useCallback(()=>{p.current&&c(p.current.getContentHeight()+20)},[]),C=e=>{f.current=e,x(),e.getOriginalEditor().onDidContentSizeChange(x),e.getModifiedEditor().onDidContentSizeChange(x)},w=e=>{p.current=e,S(),e.onDidContentSizeChange(S)},T=(t===`U`?it.A:it[t])||`?`,E=typeof T==`string`?(0,Y.jsx)(ee.Text,{children:T}):N.createElement(T,{className:`w-5 h-5`}),D=v||b,O=Ze(g),k=O===`markdown`,A=u===`old`?_?.original??``:_?.modified??``;return(0,Y.jsxs)(`div`,{"data-testid":`file-diff-viewer-outer`,className:`w-full flex flex-col`,children:[(0,Y.jsx)(`div`,{className:`flex justify-between items-center px-3 py-2.5 border-b border-[var(--oh-border)] hover:cursor-pointer`,onClick:()=>a(e=>!e),children:(0,Y.jsxs)(`span`,{className:`text-sm w-full text-content flex items-center gap-2`,children:[D?(0,Y.jsx)(et,{className:`w-4 h-4`}):E,(0,Y.jsx)(`strong`,{className:`w-full truncate font-medium`,children:g}),!r&&!h&&(0,Y.jsx)(`span`,{className:`flex items-center gap-0.5 shrink-0`,onClick:e=>e.stopPropagation(),children:nt.map(({mode:e,icon:t})=>(0,Y.jsx)(`button`,{"data-testid":`view-mode-${e}`,type:`button`,"aria-pressed":u===e,onClick:()=>d(e),className:l(`p-1 rounded transition-colors cursor-pointer`,u===e?`bg-[var(--oh-interactive-hover)] text-white`:`text-[var(--oh-muted)] hover:bg-[var(--oh-interactive-hover)] hover:text-white`),children:(0,Y.jsx)(t,{className:`w-4 h-4`})},e))}),(0,Y.jsx)(`button`,{"data-testid":`collapse`,type:`button`,children:(0,Y.jsx)(Qe,{className:l(`w-4 h-4 transition-transform`,r&&`transform rotate-180`)})})]})}),!r&&h&&(0,Y.jsx)(`div`,{"data-testid":`file-deleted-message`,className:`w-full border-b border-[var(--oh-border)] p-4 bg-base text-[var(--oh-text-dim)] text-sm`,children:n(i.DIFF_VIEWER$FILE_DELETED)}),!r&&!h&&y&&(u===`diff`?(0,Y.jsx)(tt,{height:s,children:(0,Y.jsx)(se,{"data-testid":`file-diff-viewer`,className:`w-full h-full`,language:O,original:m?``:_?.original??``,modified:h?``:_?.modified??``,theme:`custom-diff-theme`,onMount:C,beforeMount:at,options:{...rt,renderSideBySide:!m&&!h,hideUnchangedRegions:{enabled:!0}}})}):k?(0,Y.jsx)(`div`,{className:`w-full border-b border-[var(--oh-border)] overflow-auto p-4 bg-base prose prose-invert max-w-none`,"data-testid":`markdown-preview`,children:(0,Y.jsx)(re,{content:A,includeStandard:!0,includeHeadings:!0})}):(0,Y.jsx)(tt,{height:s,children:(0,Y.jsx)(fe,{"data-testid":`file-single-viewer`,className:`w-full h-full`,language:O,value:A,theme:`custom-diff-theme`,beforeMount:at,onMount:w,options:rt})}))]})}function st(){let{t:e}=o(`openhands`);return(0,Y.jsx)(ae,{icon:(0,Y.jsx)(x,{}),children:e(i.DIFF_VIEWER$NO_CHANGES)})}var ct=[{key:i.TIPS$CUSTOMIZE_MICROAGENT,link:`https://docs.all-hands.dev/usage/prompting/microagents-repo`},{key:i.TIPS$SETUP_SCRIPT,link:`https://docs.all-hands.dev/usage/prompting/repository#setup-script`},{key:i.TIPS$VSCODE_INSTANCE},{key:i.TIPS$SAVE_WORK},{key:i.TIPS$SPECIFY_FILES,link:`https://docs.all-hands.dev/usage/prompting/prompting-best-practices`},{key:i.TIPS$HEADLESS_MODE,link:`https://docs.all-hands.dev/usage/how-to/headless-mode`},{key:i.TIPS$CLI_MODE,link:`https://docs.all-hands.dev/usage/how-to/cli-mode`},{key:i.TIPS$GITHUB_HOOK,link:`https://docs.all-hands.dev/usage/cloud/github-installation#working-on-github-issues-and-pull-requests-using-openhands`},{key:i.TIPS$BLOG_SIGNUP,link:`https://www.all-hands.dev/blog`},{key:i.TIPS$API_USAGE,link:`https://docs.all-hands.dev/api-reference/health-check`}];function lt(){return ct[Math.floor(Math.random()*ct.length)]}function ut(){let{t:e}=o(`openhands`),[t,n]=N.useState(lt());return N.useEffect(()=>{n(lt())},[]),(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`h4`,{className:`font-bold`,children:[e(i.TIPS$PROTIP),`:`]}),(0,Y.jsxs)(`p`,{children:[e(t.key),t.link&&(0,Y.jsxs)(Y.Fragment,{children:[` `,(0,Y.jsx)(`a`,{href:t.link,target:`_blank`,rel:`noopener noreferrer`,className:`underline`,children:e(i.TIPS$LEARN_MORE)})]})]})]})}var $=/not a git repository/i;function dt({children:e}){return(0,Y.jsx)(`div`,{className:`w-full h-full flex flex-col items-center text-center justify-center text-2xl text-tertiary-light`,children:e})}function ft(){let{t:e}=o(`openhands`),{data:t,isSuccess:n,isError:r,error:a,isLoading:l}=G(),[u,d]=N.useState(null),{curAgentState:f}=k(),p=!c.includes(f),m=a&&$.test(s(a));return N.useEffect(()=>{if(!p)d([i.DIFF_VIEWER$WAITING_FOR_RUNTIME]);else if(a){let e=s(a);$.test(e)?d([i.DIFF_VIEWER$NOT_A_GIT_REPO,i.DIFF_VIEWER$ASK_OH]):d([e])}else d(l?[i.DIFF_VIEWER$LOADING]:null)},[p,m,l,a,d]),(0,Y.jsx)(`main`,{className:`h-full w-full flex flex-col items-stretch`,children:!n||!t.length?(0,Y.jsxs)(`div`,{className:`flex flex-col h-full w-full`,children:[(0,Y.jsxs)(`div`,{className:`flex-1 flex items-center justify-center`,children:[u&&(0,Y.jsx)(dt,{children:u.map(t=>(0,Y.jsx)(`span`,{children:e(t)},t))}),!u&&n&&t.length===0&&(0,Y.jsx)(st,{})]}),!r&&n&&t.length===0&&(0,Y.jsx)(`div`,{className:`w-full text-m bg-tertiary p-4 text-left`,children:(0,Y.jsx)(ut,{})})]}):(0,Y.jsx)(`div`,{className:`h-full overflow-y-auto flex flex-col items-stretch custom-scrollbar-always`,children:t.slice(0,100).map(e=>(0,Y.jsx)(ot,{path:e.path,type:e.status},e.path))})})}function pt(){let{t:e}=o(`openhands`);ke();let{hasAttachedSource:t,isLoading:n}=we(),{hasCommits:r}=Te({enabled:t}),{conversationId:s}=E(),{state:c,setFilesTabDiffView:l,setFilesTabContentViewMode:u}=b(s??``),d=(t||n)&&r!==!1,f=c.filesTabDiffView??d,p=c.filesTabContentViewMode,[m,h]=(0,N.useState)(!1),g=_e(),_=(0,N.useMemo)(()=>g.data??[],[g.data]),v=j(e=>e.selectedPath),y=j(e=>e.setSelectedPath),x=V(v),S=I(e=>e.count),C=L(x.data?.staticUrl??null,S);(0,N.useEffect)(()=>{if(v||_.length===0)return;let[e]=J(_);e&&y(e)},[_,v]);let w=a(),{refetch:T,isFetching:D}=G();return(0,Y.jsxs)(`main`,{className:`h-full w-full flex flex-col items-stretch`,"data-testid":`files-tab`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1.5 border-b border-[var(--oh-border)]`,children:[(0,Y.jsx)(Ye,{ariaLabel:e(i.FILES$DIFF_VIEW),testId:`files-tab-diff-toggle`,value:f?`on`:`off`,options:[{value:`on`,label:e(i.FILES$DIFF_VIEW)},{value:`off`,label:e(i.COMMON$FILES)}],onChange:e=>l(e===`on`)}),!f&&(0,Y.jsx)(Ye,{ariaLabel:e(i.FILES$RICH),testId:`files-tab-content-mode-toggle`,value:p,options:[{value:`rich`,label:e(i.FILES$RICH)},{value:`plain`,label:e(i.FILES$PLAIN)}],onChange:u}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[!f&&C&&(0,Y.jsx)(`a`,{href:C,target:`_blank`,rel:`noopener noreferrer`,"aria-label":e(i.FILES$OPEN_IN_NEW_WINDOW),title:e(i.FILES$OPEN_IN_NEW_WINDOW),"data-testid":`files-tab-open-in-new-window`,className:`flex items-center justify-center w-[26px] py-1 rounded-[7px] hover:bg-[var(--oh-interactive-hover)] cursor-pointer text-white`,children:(0,Y.jsx)(ie,{width:14,height:14})}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{T(),w.invalidateQueries({queryKey:[`workspace-files`]}),w.invalidateQueries({queryKey:[`workspace-file-content`]})},disabled:D,"aria-label":e(i.FILES$REFRESH),title:e(i.FILES$REFRESH),"data-testid":`files-tab-refresh`,className:`flex items-center justify-center w-[26px] py-1 rounded-[7px] hover:enabled:bg-[var(--oh-interactive-hover)] cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed`,children:(0,Y.jsx)(Xe,{width:12.75,height:15,color:`#ffffff`,className:D?`animate-spin`:``})})]})]}),f?(0,Y.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,Y.jsx)(ft,{})}):(0,Y.jsx)(`div`,{className:`flex flex-1 flex-col min-h-0`,children:g.isLoading?(0,Y.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-[var(--oh-muted)]`,children:e(i.FILES$LOADING_FILES)}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Pe,{paths:_,selectedPath:v,onSelectFile:y,isTreeVisible:m,onToggleTree:()=>h(e=>!e)}),(0,Y.jsxs)(`div`,{className:`flex flex-1 min-h-0`,children:[m&&(0,Y.jsx)(`aside`,{className:`w-56 shrink-0 border-r border-[var(--oh-border)] overflow-y-auto custom-scrollbar-always`,"data-testid":`files-tab-tree`,children:(0,Y.jsx)(Re,{paths:_,selectedPath:v,onSelectFile:y})}),(0,Y.jsx)(`section`,{className:`flex-1 min-w-0 min-h-0`,"data-testid":`files-tab-content`,children:v?(0,Y.jsx)(Je,{path:v,viewMode:p}):(0,Y.jsx)(`div`,{className:`flex h-full w-full items-center justify-center text-sm text-[var(--oh-muted)]`,children:e(i.FILES$NO_FILE_SELECTED)})})]})]})})]})}export{pt as default};
1
+ import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{t as n}from"./vendor~root~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-s~f2l2lr17-DYXOLEck.js";import{o as r,t as i}from"./declaration-CR6HMp29.js";import{n as a}from"./QueryClientProvider-Cnr-Yl3j.js";import{t as o}from"./useTranslation-B6voJV4y.js";import{t as s}from"./retrieve-axios-error-message-BY-yIkIq.js";import{C as c,t as l}from"./utils-DCVfKFRt.js";import{S as u,a as d,d as f,n as p}from"./agent-server-client-options-9agOSarV.js";import{n as m}from"./active-backend-context-BSPE-W72.js";import{r as h,u as g}from"./vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~dp08i1qy-D8soyAAx.js";import{a as _}from"./agent-server-conversation-service.api-B9TUYJon.js";import{t as v}from"./proxy-BqDMnUY-.js";import{t as y}from"./react-Dy05vyj5.js";import{s as b}from"./conversation-local-storage-YmOVXxxW.js";import{a as x}from"./vendor~root-layout~home~conversation-panel~conversation~shared-conversation~alert-banner~pl~rqjteh0a-d2oallMa.js";import{t as S}from"./folder-D1T2W1cj.js";import{t as C}from"./chevron-left-small-_uvG7RVM.js";import{t as w}from"./git-status-mapper-DnL9OC8_.js";import{n as T,r as E,t as D}from"./use-active-conversation-sPgfSkql.js";import{t as O}from"./file-BTY6Gyy9.js";import{t as k}from"./use-agent-state-Dp3pD1h3.js";import{t as A}from"./use-event-store-BomO7ywK.js";import{t as j}from"./files-tab-store-m0ARqX_E.js";import{r as ee}from"./typography-BDgnT7Yp.js";import{ot as te,st as ne}from"./vendor~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-E4d6IEfI.js";import{t as re}from"./markdown-renderer-B3IAVfv4.js";import{t as ie}from"./link-external-DGxVm4Ps.js";import{t as M}from"./use-runtime-is-ready-BakOUVU-.js";import{t as ae}from"./conversation-tab-empty-state-CStQLPVW.js";import{a as oe,c as se,i as ce,n as le,o as ue,r as de,s as fe,t as pe}from"./vendor~files-tab-BtkpAiMX.js";var N=e(t(),1),P=class{static async executeCommand(e,t,n,r,i=30){let a=f().backend;if(a.kind===`cloud`&&e){let o=await v({backend:a,method:`POST`,hostOverride:d(e),path:`/api/bash/execute_bash_command`,body:{command:n,...r?{cwd:r}:{},timeout:Math.floor(i)},authMode:`session-api-key`,sessionApiKey:t,timeoutSeconds:i+10});return{exit_code:o.exit_code??-1,stdout:o.stdout??``,stderr:o.stderr??``}}let o=await new h(p({conversationUrl:e,sessionApiKey:t})).executeCommand(n,r,i);return{exit_code:o.exit_code,stdout:o.stdout,stderr:o.stderr}}static async downloadFile(e,t,n){let r=f().backend;return r.kind===`cloud`&&e?(await v({backend:r,method:`GET`,hostOverride:d(e),path:`/api/file/download?path=${encodeURIComponent(n)}`,authMode:`session-api-key`,sessionApiKey:t,responseType:`blob`})).arrayBuffer():new g(p({conversationUrl:e,sessionApiKey:t})).downloadFile(n)}},F=2e3,me=[`.git`,`node_modules`,`.venv`,`venv`,`__pycache__`,`dist`,`build`,`.next`,`.cache`,`.pytest_cache`,`.mypy_cache`,`.turbo`,`.parcel-cache`,`target`];function he(){return`find . \\( ${me.map(e=>`-name '${e}' -prune`).join(` -o `)} \\) -o -type f -print 2>/dev/null | sort | head -n ${F}`}function ge(e){return e.startsWith(`./`)?e.slice(2):e}function _e(){let{data:e}=D(),t=M(),r=e?.id,i=e?.conversation_url,a=e?.session_api_key,o=e?.workspace?.working_dir?.trim();return n({queryKey:[`workspace-files`,r,i,a,o],queryFn:async()=>{let e=await P.executeCommand(i,a,he(),o,30);if(e.exit_code!==0)throw Error(e.stderr?.trim()||`Failed to list workspace files`);let t=e.stdout.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).map(ge);return Array.from(new Set(t)).slice(0,F)},enabled:t&&!!r&&!!o,retry:!1,staleTime:1e3*30,gcTime:1e3*60*5,meta:{disableToast:!0}})}function ve(){let{data:e}=D(),t=M(),r=e?.id,i=e?.conversation_url,a=e?.session_api_key,o=f().backend.kind===`local`,s=n({queryKey:[`workspace-session`,r,i,a],queryFn:async()=>({baseUrl:await new h(p({conversationUrl:i,sessionApiKey:a})).startWorkspaceSession(r)}),enabled:t&&!!r&&o,staleTime:1/0,gcTime:1/0,retry:!1});return{data:s.data??null,isLoading:s.isLoading,isError:s.isError,error:s.error??null}}function ye(e,t){let n=(t??``).replace(/^\/+/,``);return n?`${e}${n.split(`/`).map(e=>encodeURIComponent(e)).join(`/`)}`:e}var I=y(e=>({count:0,bump:()=>e(e=>({count:e.count+1}))}));function L(e,t){return e===null?null:`${e}${e.includes(`?`)?`&`:`?`}v=${t}`}var be=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`ico`,`svg`,`avif`]),xe=new Set([`pdf`]);function R(e){let t=e.lastIndexOf(`.`);return t===-1?``:e.slice(t+1).toLowerCase()}function Se(e){switch(R(e)){case`html`:case`htm`:return`text/html`;case`css`:return`text/css`;case`js`:case`mjs`:case`cjs`:return`text/javascript`;case`json`:return`application/json`;case`md`:case`markdown`:return`text/markdown`;case`svg`:return`image/svg+xml`;case`png`:return`image/png`;case`jpg`:case`jpeg`:return`image/jpeg`;case`gif`:return`image/gif`;case`webp`:return`image/webp`;case`bmp`:return`image/bmp`;case`ico`:return`image/x-icon`;case`avif`:return`image/avif`;case`pdf`:return`application/pdf`;default:return`text/plain`}}function Ce(e){let t=R(e);return be.has(t)?`image`:xe.has(t)?`pdf`:`text`}function z(e){let t=new Uint8Array(e,0,Math.min(e.byteLength,8e3));for(let e=0;e<t.length;e+=1)if(t[e]===0)return!0;return!1}function B(e){let t=new Uint8Array(e),n=32768,r=``;for(let e=0;e<t.length;e+=n)r+=String.fromCharCode.apply(null,t.subarray(e,e+n));return btoa(r)}function V(e){let{data:t}=D(),r=M(),{data:i}=ve(),a=I(e=>e.count),o=t?.id,s=t?.conversation_url,c=t?.session_api_key,l=i?.baseUrl,u=f().backend.kind===`cloud`;return n({queryKey:[`workspace-file-content`,o,s,c,u?`cloud`:l,e,a],queryFn:async()=>{if(!e)throw Error(`No path`);let t=Ce(e),n=Se(e);if(u){let r=await P.downloadFile(s,c,e);return t===`text`?z(r)?{path:e,kind:`binary`,text:null,staticUrl:`data:application/octet-stream;base64,${B(r)}`,mimeType:`application/octet-stream`}:{path:e,kind:`text`,text:new TextDecoder(`utf-8`,{fatal:!1}).decode(r),staticUrl:`data:${n};charset=utf-8;base64,${B(r)}`,mimeType:n}:{path:e,kind:t,text:null,staticUrl:`data:${n};base64,${B(r)}`,mimeType:n}}if(!l)throw Error(`No workspace session`);let r=ye(l,e);if(t!==`text`)return{path:e,kind:t,text:null,staticUrl:r,mimeType:n};let i=await fetch(r,{credentials:`include`});if(!i.ok)throw Error(`Failed to read ${e}: ${i.status}`);let a=await i.arrayBuffer();return z(a)?{path:e,kind:`binary`,text:null,staticUrl:r,mimeType:`application/octet-stream`}:{path:e,kind:`text`,text:new TextDecoder(`utf-8`,{fatal:!1}).decode(a),staticUrl:r,mimeType:n}},enabled:r&&!!o&&!!e&&(u||!!l),retry:!1,staleTime:1e3*5,gcTime:1e3*60,meta:{disableToast:!0}})}function we(){let{data:e,isLoading:t}=D(),n=e?.id?_(e.id):null;return{hasAttachedSource:!!e?.selected_repository||!!n?.selected_workspace,isLoading:t}}function Te(e){let{data:t}=D(),r=M(),{backend:i}=m(),a=i.kind===`local`,o=t?.id,s=t?.conversation_url,c=t?.session_api_key,l=t?.workspace?.working_dir?.trim(),u=(e?.enabled??!0)&&a&&r&&!!o&&!!l,d=n({queryKey:[`has-git-commits`,o,s,c,l],queryFn:async()=>(await P.executeCommand(s,c,`git rev-parse --verify HEAD`,l,10)).exit_code===0,enabled:u,retry:!1,staleTime:6e4,gcTime:5*6e4,meta:{disableToast:!0}});return{hasCommits:d.data??null,isLoading:d.isLoading}}var Ee=new Set([`FileEditorObservation`,`StrReplaceEditorObservation`,`PlanningFileEditorObservation`]),De=new Set([`view`]);function Oe(e){let t=e.observation;return!(!t||typeof t.kind!=`string`||!Ee.has(t.kind)||t.command&&De.has(t.command))}function ke(){let e=a(),t=A(e=>e.events),n=I(e=>e.bump),r=(0,N.useRef)(new Set),i=(0,N.useRef)(new WeakSet);(0,N.useEffect)(()=>{let a=[];for(let e of t){let t=`id`in e?e.id:void 0;(t===void 0?i.current.has(e):r.current.has(t))||(t===void 0?i.current.add(e):r.current.add(t),Oe(e)&&a.push(e))}a.length!==0&&(e.invalidateQueries({queryKey:[`workspace-files`]}),e.invalidateQueries({queryKey:[`workspace-file-content`]}),e.invalidateQueries({queryKey:[`file_changes`]}),n())},[t,e,n])}function H(e){return e.startsWith(`/`)?e:`/${e}`}var U=class{static async getGitChanges(e,t,n){let r=f().backend;if(r.kind===`cloud`&&e){let i=new URLSearchParams;i.set(`path`,H(n));let a=await v({backend:r,method:`GET`,hostOverride:d(e),path:`/api/git/changes?${i.toString()}`,authMode:`session-api-key`,sessionApiKey:t});if(!Array.isArray(a))throw Error(`Invalid response from runtime - runtime may be unavailable`);return a.map(e=>({status:w(String(e.status)),path:e.path}))}let i=await new h(p({conversationUrl:e,sessionApiKey:t})).gitChanges(n,{ref:`HEAD`});if(!Array.isArray(i))throw Error(`Invalid response from runtime - runtime may be unavailable`);return i.map(e=>({status:w(String(e.status)),path:e.path}))}static async getGitChangeDiff(e,t,n){let r=f().backend;if(r.kind===`cloud`&&e){let i=new URLSearchParams;i.set(`path`,H(n));let a=await v({backend:r,method:`GET`,hostOverride:d(e),path:`/api/git/diff?${i.toString()}`,authMode:`session-api-key`,sessionApiKey:t});return{modified:a?.modified??``,original:a?.original??``,...a?.diff?{diff:a.diff}:{}}}let i=await new h(p({conversationUrl:e,sessionApiKey:t})).gitDiff(n,{ref:`HEAD`});return{modified:i.modified??``,original:i.original??``,...i.diff?{diff:i.diff}:{}}}};function W(e,t){let n=t?.trim();if(n)return n;if(!e)return u;let r=e.split(`/`);return`${u}/${r[r.length-1]}`}var G=()=>{let{conversationId:e}=T(),{data:t}=D(),[r,i]=N.useState([]),a=N.useRef(null),o=M(),s=t?.conversation_url,c=t?.session_api_key,l=t?.selected_repository,u=t?.workspace?.working_dir?.trim(),d=N.useMemo(()=>W(l,u),[l,u]),f=n({queryKey:[`file_changes`,e,s,c,d],queryFn:async()=>{if(!e)throw Error(`No conversation ID`);return U.getGitChanges(s,c,d)},retry:!1,staleTime:1e3*60*5,gcTime:1e3*60*15,refetchOnMount:`always`,enabled:o&&!!e,meta:{disableToast:!0}});return N.useEffect(()=>{if(!f.isFetching&&f.isSuccess&&f.data){let e=f.data;if(e!==a.current)if(a.current=e,Array.isArray(e)){let t=new Set(e.map(e=>e.path)),n=new Set(r.map(e=>e.path)),a=e.filter(e=>!n.has(e.path)),o=r.filter(e=>t.has(e.path));i([...a,...o])}else i([e])}},[f.isFetching,f.isSuccess,f.data]),{data:r,isLoading:f.isLoading,isFetching:f.isFetching,isSuccess:f.isSuccess,isError:f.isError,error:f.error,refetch:f.refetch}},Ae=[`index.html`,`index.htm`,`readme.md`,`readme`,`main.html`,`app.html`,`index.js`,`index.ts`,`index.tsx`,`index.jsx`,`main.py`,`app.py`,`main.go`,`main.rs`,`main.java`,`main.c`,`main.cpp`,`package.json`,`pyproject.toml`,`cargo.toml`,`go.mod`,`pom.xml`,`dockerfile`,`makefile`],je=[`license`,`license.md`,`license.txt`,`changelog.md`,`agents.md`,`tsconfig.json`,`.env.sample`,`.env.example`];function Me(e){let t=e.lastIndexOf(`/`);return(t===-1?e:e.slice(t+1)).toLowerCase()}function K(e){return e.split(`/`).filter(Boolean).length-1}function q(e){let t=Me(e),n=Ae.indexOf(t);if(n!==-1)return n;let r=je.indexOf(t);return r===-1?1e4:1e3+r}function J(e){return[...e].sort((e,t)=>{let n=K(e)-K(t);if(n!==0)return n;let r=q(e)-q(t);return r===0?e.localeCompare(t):r})}var Y=r(),Ne=e=>(0,Y.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,...e,children:(0,Y.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M10.8615 8.16992L14.2799 12.158L10.8615 16.1461L9.72266 15.1699L12.3043 12.158L9.72266 9.14611L10.8615 8.16992Z`,fill:`currentColor`})});function Pe({paths:e,selectedPath:t,onSelectFile:n,isTreeVisible:r,onToggleTree:a}){let{t:s}=o(`openhands`),c=(0,N.useMemo)(()=>J(e),[e]);return(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-[var(--oh-border)] px-2 py-1.5 min-h-[34px]`,"data-testid":`file-quick-row`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:a,"data-testid":`file-quick-row-tree-toggle`,"aria-pressed":r,"aria-label":s(r?i.FILES$HIDE_FILE_TREE:i.FILES$SHOW_FILE_TREE),title:s(r?i.FILES$HIDE_FILE_TREE:i.FILES$SHOW_FILE_TREE),className:l(`shrink-0 inline-flex items-center justify-center w-6 h-6 rounded-md cursor-pointer`,`text-[var(--oh-text-tertiary)] hover:bg-tertiary`,r&&`bg-[var(--oh-surface-raised)]`),children:r?(0,Y.jsx)(C,{className:`w-3 h-3`}):(0,Y.jsx)(Ne,{className:`w-3 h-3`})}),c.length>0&&(0,Y.jsx)(`div`,{className:`flex flex-nowrap items-center gap-1.5 overflow-hidden flex-1 min-w-0`,children:c.map(e=>{let r=t===e;return(0,Y.jsx)(`button`,{type:`button`,onClick:()=>n(e),title:e,"data-testid":`file-quick-row-item-${e}`,className:l(`inline-flex items-center px-2 py-0.5 text-xs whitespace-nowrap rounded-md cursor-pointer`,r?`bg-[var(--oh-interactive-hover)] text-white`:`bg-[var(--oh-surface-raised)] text-[var(--oh-text-tertiary)] hover:bg-tertiary`),children:e},e)})})]})}function X(e){e.children.sort((e,t)=>e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1);for(let t of e.children)t.isDirectory&&X(t)}function Fe(e,t,n,r,i){let a=t.get(e);a||(a=new Map,t.set(e,a));let o=a.get(n);if(o)return!i&&!o.isDirectory&&(o.isDirectory=!0),o;let s={name:n,path:r,isDirectory:!i,children:[]};return e.children.push(s),a.set(n,s),s}function Ie(e){let t={name:``,path:``,isDirectory:!0,children:[]},n=new Map;for(let r of e){let e=r.split(`/`).filter(Boolean);if(e.length>0){let r=t,i=``;for(let t=0;t<e.length;t+=1){let a=e[t];i=i?`${i}/${a}`:a;let o=t===e.length-1;r=Fe(r,n,a,i,o)}}}return X(t),t}function Le({node:e,depth:t,selectedPath:n,onSelectFile:r}){let[i,a]=(0,N.useState)(!1),o=8+t*12;if(e.isDirectory)return(0,Y.jsxs)(`li`,{children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),"aria-expanded":i,"data-testid":`file-tree-dir-${e.path}`,className:l(`flex w-full items-center gap-1.5 py-1 pr-2 text-left text-sm text-white`,`hover:bg-tertiary cursor-pointer`),style:{paddingLeft:`${o}px`},children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:l(`inline-block w-3 text-[10px] text-[var(--oh-muted)] transition-transform`,i?`rotate-90`:`rotate-0`),children:`▶`}),(0,Y.jsx)(S,{className:`w-3.5 h-3.5 shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.name})]}),i&&e.children.length>0&&(0,Y.jsx)(`ul`,{children:e.children.map(e=>(0,Y.jsx)(Le,{node:e,depth:t+1,selectedPath:n,onSelectFile:r},e.path))})]});let s=n===e.path;return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>r(e.path),"data-testid":`file-tree-file-${e.path}`,className:l(`flex w-full items-center gap-1.5 py-1 pr-2 text-left text-sm`,`hover:bg-tertiary cursor-pointer`,s?`bg-[var(--oh-interactive-hover)] text-white`:`text-[var(--oh-text-tertiary)]`),style:{paddingLeft:`${o+16}px`},children:[(0,Y.jsx)(O,{className:`w-3.5 h-3.5 shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.name})]})})}function Re({paths:e,selectedPath:t,onSelectFile:n}){let{t:r}=o(`openhands`),a=(0,N.useMemo)(()=>Ie(e),[e]);return a.children.length===0?(0,Y.jsx)(`div`,{className:`px-3 py-4 text-sm text-[var(--oh-muted)]`,children:r(i.FILES$NO_FILES)}):(0,Y.jsx)(`ul`,{className:`py-1 custom-scrollbar-always`,"data-testid":`file-tree-view`,children:a.children.map(e=>(0,Y.jsx)(Le,{node:e,depth:0,selectedPath:t,onSelectFile:n},e.path))})}var ze={js:`javascript`,jsx:`jsx`,mjs:`javascript`,cjs:`javascript`,ts:`typescript`,tsx:`tsx`,py:`python`,pyi:`python`,pyw:`python`,html:`markup`,htm:`markup`,svg:`markup`,xml:`markup`,css:`css`,scss:`scss`,sass:`sass`,less:`less`,json:`json`,json5:`json5`,yaml:`yaml`,yml:`yaml`,toml:`toml`,ini:`ini`,cfg:`ini`,properties:`properties`,conf:`ini`,env:`bash`,md:`markdown`,markdown:`markdown`,mdx:`markdown`,sh:`bash`,bash:`bash`,zsh:`bash`,fish:`bash`,bat:`batch`,cmd:`batch`,ps1:`powershell`,ps:`powershell`,c:`c`,h:`c`,cpp:`cpp`,cc:`cpp`,cxx:`cpp`,hpp:`cpp`,hh:`cpp`,cs:`csharp`,java:`java`,kt:`kotlin`,kts:`kotlin`,scala:`scala`,rs:`rust`,go:`go`,rb:`ruby`,php:`php`,swift:`swift`,m:`objectivec`,mm:`objectivec`,hs:`haskell`,ex:`elixir`,exs:`elixir`,erl:`erlang`,fs:`fsharp`,fsx:`fsharp`,ml:`ocaml`,mli:`ocaml`,clj:`clojure`,cljs:`clojure`,cljc:`clojure`,lua:`lua`,pl:`perl`,pm:`perl`,r:`r`,jl:`julia`,dart:`dart`,groovy:`groovy`,gradle:`groovy`,tf:`hcl`,hcl:`hcl`,dockerfile:`docker`,sql:`sql`,graphql:`graphql`,gql:`graphql`,proto:`protobuf`,diff:`diff`,patch:`diff`,nix:`nix`,sol:`solidity`},Be={dockerfile:`docker`,makefile:`makefile`,gnumakefile:`makefile`,".bashrc":`bash`,".zshrc":`bash`,".profile":`bash`,".env":`bash`,".gitignore":`bash`,".dockerignore":`bash`};function Ve(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`)),n=e.slice(t+1),r=n.lastIndexOf(`.`);return r<=0?``:n.slice(r+1).toLowerCase()}function He(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return e.slice(t+1).toLowerCase()}function Ue(e,t){let n=Be[He(e)];if(n)return n;let r=Ve(e);if(r&&ze[r])return ze[r];if(t){if(t===`text/html`)return`markup`;if(t===`text/css`)return`css`;if(t===`application/json`)return`json`;if(t===`text/markdown`)return`markdown`;if(t===`application/javascript`||t===`text/javascript`)return`javascript`;if(t===`application/x-yaml`||t===`text/yaml`)return`yaml`}return null}function We({path:e,text:t,mimeType:n}){let r=Ue(e,n);return r?(0,Y.jsx)(`div`,{"data-testid":`file-content-viewer-highlighted`,"data-language":r,className:`h-full w-full overflow-auto bg-[var(--oh-surface)] custom-scrollbar-always`,children:(0,Y.jsx)(te,{language:r,style:ne,showLineNumbers:!0,wrapLongLines:!1,customStyle:{margin:0,padding:`1rem`,background:`transparent`,fontSize:`0.75rem`,lineHeight:`1.25rem`,minHeight:`100%`},codeTagProps:{style:{background:`transparent`,fontFamily:`inherit`}},lineNumberStyle:{color:`var(--oh-border)`,minWidth:`2.5em`,paddingRight:`1em`,userSelect:`none`},children:t})}):(0,Y.jsx)(`pre`,{"data-testid":`file-content-viewer-plain`,className:`h-full w-full overflow-auto whitespace-pre-wrap break-words bg-[var(--oh-surface)] p-4 text-xs leading-5 text-white custom-scrollbar-always`,children:t})}var Ge=new Set([`html`,`htm`,`svg`]),Ke=new Set([`md`,`markdown`,`mdx`]),qe={pptx:`PowerPoint`,ppt:`PowerPoint`,docx:`Word`,doc:`Word`,xlsx:`Excel`,xls:`Excel`};function Z(e){let t=e.lastIndexOf(`.`);return t===-1?``:e.slice(t+1).toLowerCase()}function Q({path:e}){let{t}=o(`openhands`),n=qe[Z(e)];return(0,Y.jsx)(`div`,{className:`flex h-full w-full items-center justify-center text-sm text-[var(--oh-muted)]`,"data-testid":n?`file-content-viewer-unsupported-document`:`file-content-viewer-binary-fallback`,children:n?t(i.FILES$UNSUPPORTED_DOCUMENT,{type:n}):t(i.FILES$BINARY_FALLBACK)})}function Je({path:e,viewMode:t}){let{t:n}=o(`openhands`),r=V(e),a=I(e=>e.count);if(r.isLoading)return(0,Y.jsx)(`div`,{className:`flex h-full w-full items-center justify-center text-sm text-[var(--oh-muted)]`,children:n(i.FILES$LOADING_FILES)});if(r.isError||!r.data)return(0,Y.jsx)(`div`,{className:`flex h-full w-full items-center justify-center text-sm text-[var(--oh-muted)]`,"data-testid":`file-content-viewer-error`,children:r.error?.message??n(i.FILES$LOAD_ERROR)});let{kind:s,text:c,staticUrl:l,mimeType:u}=r.data,d=L(l,a);return t===`plain`?s===`text`&&c!==null?(0,Y.jsx)(We,{path:e,text:c,mimeType:u??void 0}):(0,Y.jsx)(Q,{path:e}):s===`image`?(0,Y.jsx)(`div`,{className:`flex h-full w-full items-center justify-center bg-[var(--oh-surface)] p-4`,"data-testid":`file-content-viewer-image`,children:(0,Y.jsx)(`img`,{src:d,alt:e,className:`max-h-full max-w-full object-contain`})}):s===`pdf`?(0,Y.jsx)(`iframe`,{title:e,src:d,sandbox:`allow-same-origin`,"data-testid":`file-content-viewer-iframe`,className:`h-full w-full bg-white`}):s===`binary`?(0,Y.jsx)(Q,{path:e}):u===`text/html`||Ge.has(Z(e))?(0,Y.jsx)(`iframe`,{title:e,src:d,sandbox:`allow-same-origin`,"data-testid":`file-content-viewer-iframe`,className:`h-full w-full bg-white`}):s===`text`&&Ke.has(Z(e))?(0,Y.jsx)(`div`,{"data-testid":`file-content-viewer-markdown`,className:`h-full w-full overflow-auto bg-[var(--oh-surface)] text-white custom-scrollbar-always`,children:(0,Y.jsx)(`div`,{className:`prose prose-sm prose-invert max-w-none p-6 [--tw-prose-body:#fff] [--tw-prose-bold:#fff] [--tw-prose-headings:#fff] [--tw-prose-lead:#fff] [--tw-prose-counters:#fff] [--tw-prose-quotes:#fff] [--tw-prose-quote-borders:var(--oh-border-subtle)] [--tw-prose-bullets:var(--oh-muted)] [--tw-prose-hr:var(--oh-border-subtle)] [--tw-prose-captions:var(--oh-muted)] [--tw-prose-kbd:#fff]`,children:(0,Y.jsx)(re,{content:c??``,includeStandard:!0,includeHeadings:!0})})}):s===`text`&&c!==null?(0,Y.jsx)(We,{path:e,text:c,mimeType:u??void 0}):(0,Y.jsx)(Q,{path:e})}function Ye({value:e,options:t,onChange:n,ariaLabel:r,testId:i}){return(0,Y.jsx)(`div`,{role:`radiogroup`,"aria-label":r,"data-testid":i,className:`inline-flex items-center rounded-md bg-[var(--oh-surface-raised)] p-0.5 text-xs`,children:t.map(t=>{let r=t.value===e;return(0,Y.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":r,"data-testid":i?`${i}-option-${t.value}`:void 0,onClick:()=>n(t.value),className:l(`px-2 py-0.5 rounded cursor-pointer transition-colors`,r?`bg-[var(--oh-interactive-hover)] text-white`:`text-[var(--oh-muted)] hover:text-white`),children:t.label},t.value)})})}var Xe=e=>(0,Y.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 13 15`,fill:`none`,...e,children:(0,Y.jsx)(`path`,{d:`M6.59467 0.21967C6.88756 -0.0732233 7.36244 -0.0732233 7.65533 0.21967L9.90533 2.46967C10.1982 2.76256 10.1982 3.23744 9.90533 3.53033L7.65533 5.78033C7.36244 6.07322 6.88756 6.07322 6.59467 5.78033C6.30178 5.48744 6.30178 5.01256 6.59467 4.71967L7.56434 3.75H6.375C3.71421 3.75 1.5 5.96421 1.5 8.625C1.5 11.2858 3.71421 13.5 6.375 13.5C9.03579 13.5 11.25 11.2858 11.25 8.625C11.25 8.21079 11.5858 7.875 12 7.875C12.4142 7.875 12.75 8.21079 12.75 8.625C12.75 12.1142 9.86421 15 6.375 15C2.88579 15 0 12.1142 0 8.625C0 5.13579 2.88579 2.25 6.375 2.25H7.56434L6.59467 1.28033C6.30178 0.987437 6.30178 0.512563 6.59467 0.21967Z`,fill:`currentColor`})}),Ze=e=>{switch(e.split(`.`).pop()?.toLowerCase()){case`js`:case`jsx`:return`javascript`;case`ts`:case`tsx`:return`typescript`;case`py`:return`python`;case`html`:return`html`;case`css`:return`css`;case`json`:return`json`;case`md`:return`markdown`;case`yml`:case`yaml`:return`yaml`;case`sh`:case`bash`:return`bash`;case`dockerfile`:return`dockerfile`;case`rs`:return`rust`;case`go`:return`go`;case`java`:return`java`;case`cpp`:case`cc`:case`cxx`:return`cpp`;case`c`:return`c`;case`rb`:return`ruby`;case`php`:return`php`;case`sql`:return`sql`;default:return`text`}},Qe=e=>(0,Y.jsx)(`svg`,{width:13,height:8,viewBox:`0 0 13 8`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,Y.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M0.259766 6.17427L6.26425 0.715628L12.2688 6.17427L11.2597 7.28418L6.26425 2.74282L1.26878 7.28418L0.259766 6.17427Z`,fill:`currentColor`})}),$e=e=>{let{conversationId:t}=T(),{data:r}=D(),i=r?.conversation_url,a=r?.session_api_key,o=r?.selected_repository,s=r?.workspace?.working_dir?.trim(),c=N.useMemo(()=>`${W(o,s)}/${e.filePath}`,[o,e.filePath,s]),l=e.type===`D`;return n({queryKey:[`file_diff`,t,i,a,c],queryFn:async()=>{if(!t)throw Error(`No conversation ID`);return U.getGitChangeDiff(i,a,c)},enabled:e.enabled&&!l,staleTime:1e3*60*5,gcTime:1e3*60*15})};function et({className:e}){return(0,Y.jsx)(`div`,{className:`flex items-center justify-center`,children:(0,Y.jsx)(`div`,{className:l(`animate-spin rounded-full border-4 border-[var(--oh-border)] border-t-white`,e),role:`status`,"aria-label":`Loading`})})}function tt({height:e,children:t}){return(0,Y.jsx)(`div`,{"data-testid":`editor-container`,className:`w-full border-b border-[var(--oh-border)] overflow-hidden h-[var(--editor-height)]`,style:{"--editor-height":`${e}px`},children:t})}var nt=[{mode:`old`,icon:ue},{mode:`diff`,icon:oe},{mode:`new`,icon:pe}],rt={renderValidationDecorations:`off`,readOnly:!0,scrollBeyondLastLine:!1,minimap:{enabled:!1},automaticLayout:!0,scrollbar:{alwaysConsumeMouseWheel:!1}},it={A:ce,D:de,M:le,R:`Renamed`,U:`Untracked`},at=e=>{e.editor.defineTheme(`custom-diff-theme`,{base:`vs-dark`,inherit:!0,rules:[{token:`comment`,foreground:`6a9955`},{token:`keyword`,foreground:`569cd6`},{token:`string`,foreground:`ce9178`},{token:`number`,foreground:`b5cea8`}],colors:{"diffEditor.insertedTextBackground":`#014b01AA`,"diffEditor.removedTextBackground":`#750000AA`,"diffEditor.insertedLineBackground":`#003f00AA`,"diffEditor.removedLineBackground":`#5a0000AA`,"diffEditor.border":`var(--oh-border-subtle)`,"editorUnnecessaryCode.border":`#00000000`,"editorUnnecessaryCode.opacity":`rgba(0, 0, 0, 0.467)`}})};function ot({path:e,type:t}){let{t:n}=o(`openhands`),[r,a]=N.useState(!0),[s,c]=N.useState(400),[u,d]=N.useState(`diff`),f=N.useRef(null),p=N.useRef(null),m=t===`A`||t===`U`,h=t===`D`,g=N.useMemo(()=>{if(t===`R`){let t=e.split(/\s+/).slice(1);return t[t.length-1]}return e},[e,t]),{data:_,isLoading:v,isSuccess:y,isRefetching:b}=$e({filePath:g,type:t,enabled:!r}),x=N.useCallback(()=>{if(!f.current)return;let e=f.current.getOriginalEditor(),t=f.current.getModifiedEditor();e&&t&&c(Math.max(e.getContentHeight(),t.getContentHeight())+20)},[]),S=N.useCallback(()=>{p.current&&c(p.current.getContentHeight()+20)},[]),C=e=>{f.current=e,x(),e.getOriginalEditor().onDidContentSizeChange(x),e.getModifiedEditor().onDidContentSizeChange(x)},w=e=>{p.current=e,S(),e.onDidContentSizeChange(S)},T=(t===`U`?it.A:it[t])||`?`,E=typeof T==`string`?(0,Y.jsx)(ee.Text,{children:T}):N.createElement(T,{className:`w-5 h-5`}),D=v||b,O=Ze(g),k=O===`markdown`,A=u===`old`?_?.original??``:_?.modified??``;return(0,Y.jsxs)(`div`,{"data-testid":`file-diff-viewer-outer`,className:`w-full flex flex-col`,children:[(0,Y.jsx)(`div`,{className:`flex justify-between items-center px-3 py-2.5 border-b border-[var(--oh-border)] hover:cursor-pointer`,onClick:()=>a(e=>!e),children:(0,Y.jsxs)(`span`,{className:`text-sm w-full text-content flex items-center gap-2`,children:[D?(0,Y.jsx)(et,{className:`w-4 h-4`}):E,(0,Y.jsx)(`strong`,{className:`w-full truncate font-medium`,children:g}),!r&&!h&&(0,Y.jsx)(`span`,{className:`flex items-center gap-0.5 shrink-0`,onClick:e=>e.stopPropagation(),children:nt.map(({mode:e,icon:t})=>(0,Y.jsx)(`button`,{"data-testid":`view-mode-${e}`,type:`button`,"aria-pressed":u===e,onClick:()=>d(e),className:l(`p-1 rounded transition-colors cursor-pointer`,u===e?`bg-[var(--oh-interactive-hover)] text-white`:`text-[var(--oh-muted)] hover:bg-[var(--oh-interactive-hover)] hover:text-white`),children:(0,Y.jsx)(t,{className:`w-4 h-4`})},e))}),(0,Y.jsx)(`button`,{"data-testid":`collapse`,type:`button`,children:(0,Y.jsx)(Qe,{className:l(`w-4 h-4 transition-transform`,r&&`transform rotate-180`)})})]})}),!r&&h&&(0,Y.jsx)(`div`,{"data-testid":`file-deleted-message`,className:`w-full border-b border-[var(--oh-border)] p-4 bg-base text-[var(--oh-text-dim)] text-sm`,children:n(i.DIFF_VIEWER$FILE_DELETED)}),!r&&!h&&y&&(u===`diff`?(0,Y.jsx)(tt,{height:s,children:(0,Y.jsx)(se,{"data-testid":`file-diff-viewer`,className:`w-full h-full`,language:O,original:m?``:_?.original??``,modified:h?``:_?.modified??``,theme:`custom-diff-theme`,onMount:C,beforeMount:at,options:{...rt,renderSideBySide:!m&&!h,hideUnchangedRegions:{enabled:!0}}})}):k?(0,Y.jsx)(`div`,{className:`w-full border-b border-[var(--oh-border)] overflow-auto p-4 bg-base prose prose-invert max-w-none`,"data-testid":`markdown-preview`,children:(0,Y.jsx)(re,{content:A,includeStandard:!0,includeHeadings:!0})}):(0,Y.jsx)(tt,{height:s,children:(0,Y.jsx)(fe,{"data-testid":`file-single-viewer`,className:`w-full h-full`,language:O,value:A,theme:`custom-diff-theme`,beforeMount:at,onMount:w,options:rt})}))]})}function st(){let{t:e}=o(`openhands`);return(0,Y.jsx)(ae,{icon:(0,Y.jsx)(x,{}),children:e(i.DIFF_VIEWER$NO_CHANGES)})}var ct=[{key:i.TIPS$CUSTOMIZE_MICROAGENT,link:`https://docs.all-hands.dev/usage/prompting/microagents-repo`},{key:i.TIPS$SETUP_SCRIPT,link:`https://docs.all-hands.dev/usage/prompting/repository#setup-script`},{key:i.TIPS$VSCODE_INSTANCE},{key:i.TIPS$SAVE_WORK},{key:i.TIPS$SPECIFY_FILES,link:`https://docs.all-hands.dev/usage/prompting/prompting-best-practices`},{key:i.TIPS$HEADLESS_MODE,link:`https://docs.all-hands.dev/usage/how-to/headless-mode`},{key:i.TIPS$CLI_MODE,link:`https://docs.all-hands.dev/usage/how-to/cli-mode`},{key:i.TIPS$GITHUB_HOOK,link:`https://docs.all-hands.dev/usage/cloud/github-installation#working-on-github-issues-and-pull-requests-using-openhands`},{key:i.TIPS$BLOG_SIGNUP,link:`https://www.all-hands.dev/blog`},{key:i.TIPS$API_USAGE,link:`https://docs.all-hands.dev/api-reference/health-check`}];function lt(){return ct[Math.floor(Math.random()*ct.length)]}function ut(){let{t:e}=o(`openhands`),[t,n]=N.useState(lt());return N.useEffect(()=>{n(lt())},[]),(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`h4`,{className:`font-bold`,children:[e(i.TIPS$PROTIP),`:`]}),(0,Y.jsxs)(`p`,{children:[e(t.key),t.link&&(0,Y.jsxs)(Y.Fragment,{children:[` `,(0,Y.jsx)(`a`,{href:t.link,target:`_blank`,rel:`noopener noreferrer`,className:`underline`,children:e(i.TIPS$LEARN_MORE)})]})]})]})}var $=/not a git repository/i;function dt({children:e}){return(0,Y.jsx)(`div`,{className:`w-full h-full flex flex-col items-center text-center justify-center text-2xl text-tertiary-light`,children:e})}function ft(){let{t:e}=o(`openhands`),{data:t,isSuccess:n,isError:r,error:a,isLoading:l}=G(),[u,d]=N.useState(null),{curAgentState:f}=k(),p=!c.includes(f),m=a&&$.test(s(a));return N.useEffect(()=>{if(!p)d([i.DIFF_VIEWER$WAITING_FOR_RUNTIME]);else if(a){let e=s(a);$.test(e)?d([i.DIFF_VIEWER$NOT_A_GIT_REPO,i.DIFF_VIEWER$ASK_OH]):d([e])}else d(l?[i.DIFF_VIEWER$LOADING]:null)},[p,m,l,a,d]),(0,Y.jsx)(`main`,{className:`h-full w-full flex flex-col items-stretch`,children:!n||!t.length?(0,Y.jsxs)(`div`,{className:`flex flex-col h-full w-full`,children:[(0,Y.jsxs)(`div`,{className:`flex-1 flex items-center justify-center`,children:[u&&(0,Y.jsx)(dt,{children:u.map(t=>(0,Y.jsx)(`span`,{children:e(t)},t))}),!u&&n&&t.length===0&&(0,Y.jsx)(st,{})]}),!r&&n&&t.length===0&&(0,Y.jsx)(`div`,{className:`w-full text-m bg-tertiary p-4 text-left`,children:(0,Y.jsx)(ut,{})})]}):(0,Y.jsx)(`div`,{className:`h-full overflow-y-auto flex flex-col items-stretch custom-scrollbar-always`,children:t.slice(0,100).map(e=>(0,Y.jsx)(ot,{path:e.path,type:e.status},e.path))})})}function pt(){let{t:e}=o(`openhands`);ke();let{hasAttachedSource:t,isLoading:n}=we(),{hasCommits:r}=Te({enabled:t}),{conversationId:s}=E(),{state:c,setFilesTabDiffView:l,setFilesTabContentViewMode:u}=b(s??``),d=(t||n)&&r!==!1,f=c.filesTabDiffView??d,p=c.filesTabContentViewMode,[m,h]=(0,N.useState)(!1),g=_e(),_=(0,N.useMemo)(()=>g.data??[],[g.data]),v=j(e=>e.selectedPath),y=j(e=>e.setSelectedPath),x=V(v),S=I(e=>e.count),C=L(x.data?.staticUrl??null,S);(0,N.useEffect)(()=>{if(v||_.length===0)return;let[e]=J(_);e&&y(e)},[_,v]);let w=a(),{refetch:T,isFetching:D}=G();return(0,Y.jsxs)(`main`,{className:`h-full w-full flex flex-col items-stretch`,"data-testid":`files-tab`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1.5 border-b border-[var(--oh-border)]`,children:[(0,Y.jsx)(Ye,{ariaLabel:e(i.FILES$DIFF_VIEW),testId:`files-tab-diff-toggle`,value:f?`on`:`off`,options:[{value:`on`,label:e(i.FILES$DIFF_VIEW)},{value:`off`,label:e(i.COMMON$FILES)}],onChange:e=>l(e===`on`)}),!f&&(0,Y.jsx)(Ye,{ariaLabel:e(i.FILES$RICH),testId:`files-tab-content-mode-toggle`,value:p,options:[{value:`rich`,label:e(i.FILES$RICH)},{value:`plain`,label:e(i.FILES$PLAIN)}],onChange:u}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[!f&&C&&(0,Y.jsx)(`a`,{href:C,target:`_blank`,rel:`noopener noreferrer`,"aria-label":e(i.FILES$OPEN_IN_NEW_WINDOW),title:e(i.FILES$OPEN_IN_NEW_WINDOW),"data-testid":`files-tab-open-in-new-window`,className:`flex items-center justify-center w-[26px] py-1 rounded-[7px] hover:bg-[var(--oh-interactive-hover)] cursor-pointer text-white`,children:(0,Y.jsx)(ie,{width:14,height:14})}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{T(),w.invalidateQueries({queryKey:[`workspace-files`]}),w.invalidateQueries({queryKey:[`workspace-file-content`]})},disabled:D,"aria-label":e(i.FILES$REFRESH),title:e(i.FILES$REFRESH),"data-testid":`files-tab-refresh`,className:`flex items-center justify-center w-[26px] py-1 rounded-[7px] hover:enabled:bg-[var(--oh-interactive-hover)] cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed`,children:(0,Y.jsx)(Xe,{width:12.75,height:15,color:`#ffffff`,className:D?`animate-spin`:``})})]})]}),f?(0,Y.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,Y.jsx)(ft,{})}):(0,Y.jsx)(`div`,{className:`flex flex-1 flex-col min-h-0`,children:g.isLoading?(0,Y.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-[var(--oh-muted)]`,children:e(i.FILES$LOADING_FILES)}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Pe,{paths:_,selectedPath:v,onSelectFile:y,isTreeVisible:m,onToggleTree:()=>h(e=>!e)}),(0,Y.jsxs)(`div`,{className:`flex flex-1 min-h-0`,children:[m&&(0,Y.jsx)(`aside`,{className:`w-56 shrink-0 border-r border-[var(--oh-border)] overflow-y-auto custom-scrollbar-always`,"data-testid":`files-tab-tree`,children:(0,Y.jsx)(Re,{paths:_,selectedPath:v,onSelectFile:y})}),(0,Y.jsx)(`section`,{className:`flex-1 min-w-0 min-h-0`,"data-testid":`files-tab-content`,children:v?(0,Y.jsx)(Je,{path:v,viewMode:p}):(0,Y.jsx)(`div`,{className:`flex h-full w-full items-center justify-center text-sm text-[var(--oh-muted)]`,children:e(i.FILES$NO_FILE_SELECTED)})})]})]})})]})}export{pt as default};