@openhands/agent-canvas 1.0.0-alpha.8 → 1.0.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -6
- package/build/assets/{add-backend-modal-KMmPQNZU.js → add-backend-modal-FsnpTTgO.js} +1 -1
- package/build/assets/{agent-server-conversation-service.api-DSl9G5UR.js → agent-server-conversation-service.api-BZmUqtiO.js} +1 -1
- package/build/assets/{automation-detail-g5-RZ0da.js → automation-detail-R-99FUce.js} +1 -1
- package/build/assets/{automations-list-DHoq_0MM.js → automations-list-Dfu2c-_D.js} +1 -1
- package/build/assets/backend-form-modal-DxYjqqAK.js +1 -0
- package/build/assets/browser-HrYc5Gce.js +5 -0
- package/build/assets/conversation--ldUK72N.js +19 -0
- package/build/assets/conversation-eNrhH94O.js +1 -0
- package/build/assets/conversation-panel-B49Jpqpb.js +1 -0
- package/build/assets/{conversation-service.api-C8pYCyV6.js → conversation-service.api--f8WglOC.js} +1 -1
- package/build/assets/conversation-websocket-context-BW68-J8o.js +3 -0
- package/build/assets/{entry.client-D9uR9Blz.js → entry.client-CqqXOSvd.js} +2 -2
- package/build/assets/{files-tab-B3A1NDlZ.js → files-tab-CQHdWpQt.js} +1 -1
- package/build/assets/git-control-bar-branch-button-C8u5rzjc.js +27 -0
- package/build/assets/{git-provider-icon-DYE9n7fs.js → git-provider-icon-D-a-rcLm.js} +1 -1
- package/build/assets/{home-dIzxi5Dd.js → home-DD0GroCu.js} +1 -1
- package/build/assets/{launch-hZ0ifhcV.js → launch-B2mbfOSm.js} +1 -1
- package/build/assets/llm-settings-BEyqixPI.js +1 -0
- package/build/assets/{llm-settings-CcHqGOYL.js → llm-settings-BdiaGFbg.js} +1 -1
- package/build/assets/{manage-backends-modal-rYeyGx7j.js → manage-backends-modal-s22zCdEW.js} +1 -1
- package/build/assets/{manifest-97e839da.js → manifest-9d1c34fb.js} +1 -1
- package/build/assets/{messages-T2ewVkbp.js → messages-6aOyUu3r.js} +1 -1
- package/build/assets/{path-utils-CqJboYxo.js → path-utils-BVbe598W.js} +1 -1
- package/build/assets/{planner-tab-BrntFmb1.js → planner-tab-bN6r1G-1.js} +1 -1
- package/build/assets/{recommended-automations-launcher-BI9NhG8Y.js → recommended-automations-launcher-mJhK6Atl.js} +1 -1
- package/build/assets/{root-BS1Td78t.js → root-3t9rxEpE.js} +2 -2
- package/build/assets/{root-layout-BLjAEgle.js → root-layout-BjVwHmta.js} +2 -2
- package/build/assets/{shared-conversation-a0QV8o99.js → shared-conversation-EZV0FRIf.js} +1 -1
- package/build/assets/{sidebar-mobile-menu-toggle-DTUNI1WQ.js → sidebar-mobile-menu-toggle-BnbzzpQl.js} +1 -1
- package/build/assets/{skills-settings-DOnMn9q1.js → skills-settings-CG2hu34D.js} +1 -1
- package/build/assets/{task-list-tab-Day9nhRT.js → task-list-tab-465DDju0.js} +1 -1
- package/build/assets/{terminal-ro4SNjUU.js → terminal-CcgBEVnC.js} +1 -1
- package/build/assets/{use-active-conversation-D15D9GgR.js → use-active-conversation-DS5j9R4q.js} +1 -1
- package/build/assets/{use-agent-state-DE5dlEXJ.js → use-agent-state-D2C9SeGw.js} +1 -1
- package/build/assets/{use-create-conversation-DW7AGgLA.js → use-create-conversation-BEZg__Vv.js} +1 -1
- package/build/assets/{use-event-store-CQZCcVz-.js → use-event-store-BT_gV3ut.js} +1 -1
- package/build/assets/{use-handle-plan-click-DpgEQDAV.js → use-handle-plan-click-uOpew2LO.js} +1 -1
- package/build/assets/{use-runtime-is-ready-XFbT16BD.js → use-runtime-is-ready-pGSbPddC.js} +1 -1
- package/build/assets/{use-skills-Xe0vjPMt.js → use-skills-BIvlWblA.js} +1 -1
- package/build/assets/{use-task-list-Bs90uF2N.js → use-task-list-DDeNHprj.js} +1 -1
- package/build/assets/{use-unified-vscode-url-BOsIOd-b.js → use-unified-vscode-url-wAMzv8Sn.js} +1 -1
- package/build/assets/{use-user-conversation-Mc0mQgkl.js → use-user-conversation-B_zDoSeh.js} +1 -1
- package/build/assets/{vscode-tab-C0ShhiSU.js → vscode-tab-B0vdh9gU.js} +1 -1
- package/build/index.html +4 -4
- package/dist/api/agent-server-adapter.cjs +1 -1
- package/dist/api/agent-server-adapter.cjs.map +1 -1
- package/dist/api/agent-server-adapter.js +1 -0
- package/dist/api/agent-server-adapter.js.map +1 -1
- package/dist/api/skills-service.cjs +1 -1
- package/dist/api/skills-service.cjs.map +1 -1
- package/dist/api/skills-service.d.ts +1 -1
- package/dist/api/skills-service.js +2 -2
- package/dist/api/skills-service.js.map +1 -1
- package/dist/components/features/backends/backend-form-modal.cjs +1 -1
- package/dist/components/features/backends/backend-form-modal.cjs.map +1 -1
- package/dist/components/features/backends/backend-form-modal.js +149 -142
- package/dist/components/features/backends/backend-form-modal.js.map +1 -1
- package/dist/components/features/conversation-panel/skills-modal.cjs +1 -1
- package/dist/components/features/conversation-panel/skills-modal.cjs.map +1 -1
- package/dist/components/features/conversation-panel/skills-modal.js +1 -1
- package/dist/components/features/conversation-panel/skills-modal.js.map +1 -1
- package/dist/contexts/conversation-websocket-context.cjs +3 -3
- package/dist/contexts/conversation-websocket-context.cjs.map +1 -1
- package/dist/contexts/conversation-websocket-context.js +97 -89
- package/dist/contexts/conversation-websocket-context.js.map +1 -1
- package/dist/hooks/chat/use-slash-command.cjs +1 -1
- package/dist/hooks/chat/use-slash-command.cjs.map +1 -1
- package/dist/hooks/chat/use-slash-command.js +1 -1
- package/dist/hooks/chat/use-slash-command.js.map +1 -1
- package/dist/hooks/query/use-conversation-skills.cjs +2 -0
- package/dist/hooks/query/use-conversation-skills.cjs.map +1 -0
- package/dist/hooks/query/use-conversation-skills.d.ts +7 -0
- package/dist/hooks/query/use-conversation-skills.js +8 -0
- package/dist/hooks/query/use-conversation-skills.js.map +1 -0
- package/dist/hooks/query/use-skills.cjs +1 -1
- package/dist/hooks/query/use-skills.cjs.map +1 -1
- package/dist/hooks/query/use-skills.d.ts +6 -1
- package/dist/hooks/query/use-skills.js +3 -3
- package/dist/hooks/query/use-skills.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.cjs.map +1 -1
- package/dist/package.js +3 -3
- package/dist/package.js.map +1 -1
- package/dist/routes/conversation.cjs +1 -1
- package/dist/routes/conversation.cjs.map +1 -1
- package/dist/routes/conversation.js +61 -63
- package/dist/routes/conversation.js.map +1 -1
- package/dist/stores/use-event-store.cjs +1 -1
- package/dist/stores/use-event-store.cjs.map +1 -1
- package/dist/stores/use-event-store.d.ts +22 -0
- package/dist/stores/use-event-store.js +9 -1
- package/dist/stores/use-event-store.js.map +1 -1
- package/dist/ui/context-menu.d.ts +1 -1
- package/dist/ui/help-link.d.ts +1 -1
- package/package.json +3 -3
- package/scripts/dev-safe.mjs +35 -17
- package/scripts/dev-with-automation.mjs +24 -49
- package/build/assets/backend-form-modal-K6IMCr3p.js +0 -1
- package/build/assets/browser-DKG63inJ.js +0 -5
- package/build/assets/conversation-BD5WemJI.js +0 -19
- package/build/assets/conversation-C47K62n8.js +0 -1
- package/build/assets/conversation-panel-Dn-S56Gk.js +0 -1
- package/build/assets/conversation-websocket-context-Ywrxd_9p.js +0 -3
- package/build/assets/git-control-bar-branch-button-CcIpmyfM.js +0 -27
- package/build/assets/llm-settings-2036m7Wt.js +0 -1
- /package/build/assets/{link-external-Df8J52xI.js → link-external-C9d6Fo3x.js} +0 -0
- /package/build/assets/{use-llm-profiles-D3-KXwQ0.js → use-llm-profiles-O4a9V6RC.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{I as n,L as r,M as i}from"./vendor~entry.client~root~root-layout~index-redirect~home~conversation-panel~conversation~la~cnj3raoq-DTEXlLSB.js";import{o as a,t as o}from"./declaration-D378OjpZ.js";import{t as s}from"./useTranslation-CpIcQBq6.js";import{t as c}from"./utils-D-HX7JCe.js";import{t as l}from"./modal-backdrop-DTYGVmOR.js";import{r as u,t as d}from"./modal-body-YElmM1dV.js";import{t as f}from"./brand-button-C2nEKopC.js";import{t as p}from"./modal-close-button-C_GpQt9F.js";import{t as m}from"./settings-input-DBywAnA7.js";import{t as h}from"./use-create-conversation-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{I as n,L as r,M as i}from"./vendor~entry.client~root~root-layout~index-redirect~home~conversation-panel~conversation~la~cnj3raoq-DTEXlLSB.js";import{o as a,t as o}from"./declaration-D378OjpZ.js";import{t as s}from"./useTranslation-CpIcQBq6.js";import{t as c}from"./utils-D-HX7JCe.js";import{t as l}from"./modal-backdrop-DTYGVmOR.js";import{r as u,t as d}from"./modal-body-YElmM1dV.js";import{t as f}from"./brand-button-C2nEKopC.js";import{t as p}from"./modal-close-button-C_GpQt9F.js";import{t as m}from"./settings-input-DBywAnA7.js";import{t as h}from"./use-create-conversation-BEZg__Vv.js";import{r as g}from"./typography-vVUMoNUg.js";import{n as _,t as v}from"./vendor~launch-Dg--Ssk6.js";var y=e(t(),1),b=a();function x({pluginIndex:e,paramKey:t,paramValue:n,onParameterChange:r}){let i=`plugin-${e}-param-${t}`;return typeof n==`boolean`?(0,b.jsxs)(`label`,{htmlFor:i,className:`flex w-full cursor-pointer items-center gap-2.5`,children:[(0,b.jsx)(`input`,{id:i,"data-testid":i,type:`checkbox`,checked:n,onChange:n=>r(e,t,n.target.checked),className:`h-4 w-4 shrink-0 rounded`}),(0,b.jsx)(`span`,{className:`text-sm`,children:t})]}):typeof n==`number`?(0,b.jsx)(m,{testId:i,name:`plugin-${e}-param-${t}`,type:`number`,label:t,value:String(n),className:`w-full`,onChange:n=>r(e,t,n===``?0:parseFloat(n)||0)}):(0,b.jsx)(m,{testId:i,name:`plugin-${e}-param-${t}`,type:`text`,label:t,value:String(n??``),className:`w-full`,onChange:n=>r(e,t,n)})}function S({plugin:e,originalIndex:t,isExpanded:n,onToggle:r,getPluginDisplayName:i,onParameterChange:a}){let{t:c}=s(`openhands`);return e.parameters&&Object.keys(e.parameters).length>0?(0,b.jsxs)(`div`,{className:`rounded-lg border border-[var(--oh-border)] bg-tertiary`,children:[(0,b.jsxs)(`button`,{type:`button`,onClick:r,className:`flex w-full items-center justify-between px-4 py-3 text-left hover:bg-base-tertiary rounded-t-lg cursor-pointer`,"data-testid":`plugin-section-${t}`,children:[(0,b.jsx)(g.Text,{className:`text-base font-normal`,children:i(e)}),n?(0,b.jsx)(v,{className:`h-5 w-5 text-white`}):(0,b.jsx)(_,{className:`h-5 w-5 text-white`})]}),n&&(0,b.jsxs)(`div`,{className:`border-t border-[var(--oh-border-subtle)] px-4 pb-3`,children:[e.ref&&(0,b.jsxs)(`div`,{className:`mb-2 text-sm text-white`,children:[c(o.LAUNCH$PLUGIN_REF),` `,e.ref]}),e.repo_path&&(0,b.jsxs)(`div`,{className:`mb-2 text-sm text-white`,children:[c(o.LAUNCH$PLUGIN_PATH),` `,e.repo_path]}),(0,b.jsx)(`div`,{className:`flex flex-col gap-4`,children:Object.entries(e.parameters||{}).map(([e,n])=>(0,b.jsx)(x,{pluginIndex:t,paramKey:e,paramValue:n,onParameterChange:a},e))})]})]}):null}function C({plugins:e,message:t,isLoading:n=!1,onStartConversation:r,onClose:i}){let{t:a}=s(`openhands`),[m,h]=y.useState(e),[_,v]=y.useState(()=>{let t={};return e.forEach((e,n)=>{e.parameters&&Object.keys(e.parameters).length>0&&(t[n]=!0)}),t}),[x,C]=y.useState(!1),w=m.filter(e=>e.parameters&&Object.keys(e.parameters).length>0),T=m.filter(e=>!e.parameters||Object.keys(e.parameters).length===0),E=e=>{v(t=>({...t,[e]:!t[e]}))},D=(e,t,n)=>{h(r=>{let i=[...r],a={...i[e]};return a.parameters={...a.parameters,[t]:n},i[e]=a,i})},O=e=>{let{source:t,repo_path:n}=e;if(n){let e=n.split(`/`);return e[e.length-1]}if(t.startsWith(`github:`))return t.replace(`github:`,``);if(t.includes(`/`)){let e=t.split(`/`);return e[e.length-1].replace(`.git`,``)}return t},k=e=>{let{source:t}=e;return t.startsWith(`github:`)?t.replace(`github:`,``):t.includes(`github.com/`)&&t.split(`github.com/`)[1]?.replace(`.git`,``)||t},A=()=>{let e=m.map(e=>k(e));return[...new Set(e)]},j=()=>{r(m,t)},M=m.length===1?O(m[0]):a(o.LAUNCH$MODAL_TITLE_GENERIC);return(0,b.jsx)(l,{onClose:i,children:(0,b.jsxs)(`div`,{"data-testid":`plugin-launch-modal`,className:c(`relative bg-base-secondary p-6 rounded-xl flex flex-col gap-4 border border-[var(--oh-border)] max-h-[80vh]`,u(`md`),d),children:[(0,b.jsx)(p,{onClose:i,testId:`close-button`}),(0,b.jsxs)(g.H2,{className:`pr-6 text-content-2`,children:[a(o.LAUNCH$MODAL_TITLE),` `,M]}),t&&(0,b.jsx)(`p`,{className:`text-sm text-white`,children:t}),(0,b.jsxs)(`div`,{className:`flex-1 overflow-y-auto custom-scrollbar`,children:[w.length>0&&(0,b.jsx)(`div`,{className:`space-y-3`,children:m.map((e,t)=>(0,b.jsx)(S,{plugin:e,originalIndex:t,isExpanded:!!_[t],onToggle:()=>E(t),getPluginDisplayName:O,onParameterChange:D},`plugin-${t}`))}),T.length>0&&(0,b.jsxs)(`div`,{className:c(w.length>0&&`mt-4`),children:[(0,b.jsx)(g.H3,{className:`mb-2 text-white`,children:w.length>0?a(o.LAUNCH$ADDITIONAL_PLUGINS):a(o.LAUNCH$PLUGINS)}),(0,b.jsx)(`div`,{className:`space-y-2`,children:T.map((e,t)=>(0,b.jsxs)(`div`,{className:`rounded-md bg-tertiary px-3 py-2 text-sm`,children:[(0,b.jsx)(`div`,{className:`font-medium`,children:O(e)}),(0,b.jsxs)(`div`,{className:`text-xs text-white mt-1`,children:[k(e),e.repo_path&&(0,b.jsxs)(`span`,{className:`ml-1`,children:[`/ `,e.repo_path]}),e.ref&&(0,b.jsxs)(`span`,{className:`ml-2`,children:[`@ `,e.ref]})]})]},`simple-plugin-${t}`))})]})]}),(0,b.jsxs)(`div`,{className:`pt-4 border-t border-[var(--oh-border-subtle)]`,children:[(0,b.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,b.jsx)(`input`,{id:`trust-checkbox`,"data-testid":`trust-checkbox`,type:`checkbox`,checked:x,onChange:e=>C(e.target.checked),className:`mt-1 h-4 w-4 flex-shrink-0`}),(0,b.jsx)(`label`,{htmlFor:`trust-checkbox`,className:`text-sm text-white`,children:a(o.LAUNCH$TRUST_SKILL_CHECKBOX,{sources:A().join(`, `),interpolation:{escapeValue:!1}})})]}),(0,b.jsx)(`div`,{className:`flex w-full justify-end mt-8`,children:(0,b.jsx)(f,{testId:`start-conversation-button`,type:`button`,variant:`primary`,onClick:j,isDisabled:n||!x,className:`px-4`,children:a(n?o.LAUNCH$STARTING:o.LAUNCH$START_CONVERSATION)})})]})]})})}function w(e){if(e)return e.replace(/<[^>]*>/g,``).slice(0,500)||void 0}function T(e){let t=e.get(`plugins`);if(t)try{let n=atob(t),r=JSON.parse(n);if(!Array.isArray(r))return{plugins:[],error:`invalid_format`};let i=[];for(let e of r){if(typeof e!=`object`||!e||typeof e.source!=`string`)return{plugins:[],error:`invalid_format`};i.push({source:e.source,ref:e.ref??null,repo_path:e.repo_path??null,parameters:e.parameters??null})}return i.length===0?{plugins:[],error:`no_plugins`}:{plugins:i,message:w(e.get(`message`))}}catch{return{plugins:[],error:`invalid_format`}}let n=e.get(`plugin_source`);return n?{plugins:[{source:n,ref:e.get(`plugin_ref`)??null,repo_path:e.get(`plugin_repo_path`)??null,parameters:null}],message:w(e.get(`message`))}:{plugins:[],error:`no_plugins`}}function E({errorType:e,onGoHome:t,onTryAgain:n}){let{t:r}=s(`openhands`),i={no_plugins:r(o.LAUNCH$ERROR_NO_PLUGINS),invalid_format:r(o.LAUNCH$ERROR_INVALID_FORMAT),creation_failed:r(o.LAUNCH$ERROR_CREATION_FAILED)};return(0,b.jsx)(`div`,{className:`flex h-full items-center justify-center`,"data-testid":`launch-error`,children:(0,b.jsxs)(`div`,{className:`max-w-md rounded-lg bg-[var(--oh-surface)] p-6 text-center`,children:[(0,b.jsx)(`h2`,{className:`mb-4 text-xl font-medium text-red-400`,children:r(o.LAUNCH$ERROR_TITLE)}),(0,b.jsx)(`p`,{className:`mb-6 text-[var(--oh-text-tertiary)]`,children:i[e]}),(0,b.jsxs)(`div`,{className:`flex justify-center gap-3`,children:[(0,b.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-md bg-tertiary px-4 py-2 text-sm text-[var(--oh-foreground)] hover:bg-[var(--oh-interactive-hover)]`,"data-testid":`go-home-button`,children:r(o.LAUNCH$GO_HOME)}),n&&(0,b.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-md bg-blue-600 px-4 py-2 text-sm text-white hover:bg-blue-700`,"data-testid":`try-again-button`,children:r(o.LAUNCH$TRY_AGAIN)})]})]})})}var D=r(function(){let[e]=n(),t=i(),{t:r}=s(`openhands`),a=h(),[c,l]=y.useState(null),u=y.useMemo(()=>T(e),[e]),d=async(e,n)=>{l(null);try{t(`/conversations/${(await a.mutateAsync({plugins:e,query:n})).conversation_id}`)}catch{l(r(o.LAUNCH$ERROR_CREATION_UNKNOWN))}},f=()=>{t(`/conversations`)};return u.error?(0,b.jsx)(E,{errorType:u.error,onGoHome:f}):c?(0,b.jsx)(E,{errorType:`creation_failed`,onGoHome:f,onTryAgain:()=>{l(null),window.location.reload()}}):(0,b.jsx)(`div`,{className:`h-full`,"data-testid":`launch-route`,children:(0,b.jsx)(C,{plugins:u.plugins,message:u.message,isLoading:a.isPending,onStartConversation:d,onClose:f})})});export{D as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./llm-settings-BdiaGFbg.js";export{e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{L as n}from"./vendor~entry.client~root~root-layout~index-redirect~home~conversation-panel~conversation~la~cnj3raoq-DTEXlLSB.js";import{t as r}from"./react-dom-hVBnwgwZ.js";import{t as i}from"./useMutation-B4OUESdw.js";import{o as a,t as o}from"./declaration-D378OjpZ.js";import{n as s}from"./QueryClientProvider-B7kl84Kj.js";import{t as c}from"./useTranslation-CpIcQBq6.js";import{t as l}from"./createLucideIcon-Ddu8jDOQ.js";import{i as u,n as d,r as f,t as p,u as m}from"./settings-list-classes-BOS092DR.js";import{n as h,r as g}from"./custom-toast-handlers-BOc3qeQ7.js";import{t as _}from"./utils-D-HX7JCe.js";import{n as v}from"./active-backend-context-TVbjnvmP.js";import{a as y,n as b}from"./query-keys-tAsQcc_9.js";import{t as x}from"./modal-backdrop-DTYGVmOR.js";import{r as S,t as C}from"./modal-body-YElmM1dV.js";import{r as w}from"./base-modal-CQRvRHu1.js";import{t as T}from"./brand-button-C2nEKopC.js";import{t as E}from"./loading-spinner-C04FGh14.js";import{n as D,t as O}from"./model-selector-DeMmw-Xa.js";import{t as k}from"./settings-input-DBywAnA7.js";import{t as A}from"./settings-D5am1n6X.js";import{t as j}from"./settings-service.api-FvJGK45W.js";import{r as ee}from"./use-settings-DQ7Oo1Hj.js";import{i as te,r as M,t as N}from"./ellipsis-button-ugUATsNo.js";import{t as P}from"./u-edit-KAUlufD8.js";import{n as F,t as I}from"./use-llm-profiles-D3-KXwQ0.js";import{r as ne}from"./typography-vVUMoNUg.js";import{l as L,s as re}from"./sdk-settings-schema-QBYH-ONX.js";import{t as ie}from"./use-agent-settings-schema-Bvp5UzV8.js";import{t as ae}from"./sdk-section-page-CJW0G04-.js";import{t as oe}from"./u-check-circle-DplbarS5.js";import{n as se}from"./settings-section-header-context-32x6WTyL.js";var ce=l(`text-cursor`,[[`path`,{d:`M17 22h-1a4 4 0 0 1-4-4V6a4 4 0 0 1 4-4h1`,key:`uvaxm9`}],[`path`,{d:`M7 22h1a4 4 0 0 0 4-4v-1`,key:`11xy8d`}],[`path`,{d:`M7 2h1a4 4 0 0 1 4 4v1`,key:`1uw06m`}]]),R=e(t()),z=a(),B=e=>(0,z.jsxs)(`svg`,{width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[(0,z.jsx)(`path`,{d:`M9.9509 15.588H10.8349L16.5125 9.91042L15.6285 9.0264L10.3991 14.2681L8.00867 11.8777L7.12465 12.7617L9.9509 15.588Z`,fill:`currentColor`}),(0,z.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12.8521 3.29895C14.8443 3.42346 16.712 4.41954 18.0816 5.78916C19.7002 7.53231 20.5718 9.64898 20.5718 12.1392C20.5718 14.1314 19.8247 15.999 18.5796 17.6177C17.3345 19.1118 15.5914 20.2324 13.5992 20.6059C11.607 20.9794 9.61486 20.7304 7.87171 19.7343C6.12856 18.7382 4.75895 17.2441 4.01189 15.3765C3.26482 13.5088 3.14031 11.3921 3.76286 9.52447C4.38542 7.53231 5.50601 5.91367 7.24916 4.79308C8.86779 3.67248 10.86 3.17444 12.8521 3.29895ZM13.4747 19.3608C15.0933 18.9873 16.5874 18.1157 17.708 16.7461C18.7041 15.3765 19.3267 13.7578 19.2022 12.0147C19.2022 10.0225 18.4551 8.03035 17.0855 6.66073C15.8404 5.41563 14.3463 4.66857 12.6031 4.54405C10.9845 4.41954 9.24132 4.79308 7.87171 5.78916C6.50209 6.78524 5.50601 8.15486 5.00797 9.89801C4.50993 11.5166 4.50993 13.2598 5.25699 14.8784C6.00405 16.4971 7.12465 17.7422 8.61877 18.6137C10.1129 19.4853 11.856 19.7343 13.4747 19.3608Z`,fill:`currentColor`})]});function V({testId:e,isSet:t}){return(0,z.jsx)(`span`,{"data-testid":e||(t?`set-indicator`:`unset-indicator`),children:(0,z.jsx)(B,{className:_(t?`text-success`:`text-danger`)})})}var H=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;function U(e,{isRequired:t=!1}={}){return e===``?!t:H.test(e)}function W(e){let t=e.split(`/`),n=(t[t.length-1]||e).replace(/[^A-Za-z0-9._-]/g,`-`).replace(/-+/g,`-`).replace(/^-+|-+$/g,``);return n&&!/^[A-Za-z0-9]/.test(n)&&(n=`profile-${n}`),n.length>64&&(n=n.substring(0,64).replace(/-+$/,``)),n||`default-profile`}var G=(0,R.forwardRef)(function({testId:e,ruleTestId:t,value:n,onChange:r,onKeyDown:i,placeholder:a,isDisabled:s,isOptional:l,isRequired:u=!1},d){let{t:f}=c(`openhands`),p=U(n,{isRequired:u}),m=l?`${f(o.SETTINGS$PROFILE_NAME_LABEL)} (${f(o.COMMON$OPTIONAL)})`:f(o.SETTINGS$PROFILE_NAME_LABEL),h=R.useId(),g=t??`${h}-rule`;return(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(k,{ref:d,testId:e,label:m,type:`text`,className:`w-full`,value:n,placeholder:a??f(o.SETTINGS$PROFILE_NAME_PLACEHOLDER),onChange:r,onKeyDown:i,isDisabled:s,ariaDescribedBy:g,ariaInvalid:!p}),(0,z.jsx)(`p`,{id:g,"data-testid":t,className:_(`text-xs`,p?`text-[var(--oh-muted)]`:`text-red-400`),children:f(o.SETTINGS$PROFILE_NAME_RULE)})]})});function K({isOpen:e,title:t,width:n=`md`,children:r,footer:i,onClose:a,initialFocusRef:o}){let s=(0,R.useRef)(null);return(0,R.useEffect)(()=>{if(!e)return;let t=o?.current??s.current;if(t){let e=setTimeout(()=>{t.focus()},0);return()=>clearTimeout(e)}},[e,o]),(0,R.useEffect)(()=>{if(!e||!s.current)return;let t=s.current,n=e=>{if(e.key!==`Tab`)return;let n=t.querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`),r=n[0],i=n[n.length-1];e.shiftKey&&document.activeElement===r?(e.preventDefault(),i?.focus()):!e.shiftKey&&document.activeElement===i&&(e.preventDefault(),r?.focus())};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e]),e?(0,z.jsx)(x,{onClose:a,children:(0,z.jsxs)(`div`,{ref:s,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`modal-title`,className:_(`bg-base-secondary p-6 rounded-xl flex flex-col gap-4 border border-[var(--oh-border)]`,S(n),C),children:[(0,z.jsx)(w,{id:`modal-title`,title:t,className:`text-xl font-medium text-white`}),r,(0,z.jsx)(`div`,{className:`w-full flex justify-end gap-2 mt-2`,children:i})]})}):null}function le(){let e=s();return i({mutationFn:({name:e,newName:t})=>F.renameProfile(e,t),onSuccess:async()=>{j.invalidateCache(),await e.invalidateQueries({queryKey:b.all}),await e.invalidateQueries({queryKey:y.personal()})},meta:{disableToast:!0}})}function ue({profile:e,onClose:t}){let{t:n}=c(`openhands`),[r,i]=(0,R.useState)(``),a=le(),s=(0,R.useRef)(null);if((0,R.useEffect)(()=>{i(e?.name??``)},[e?.name]),!e)return null;let l=U(r,{isRequired:!0}),u=r===e.name,d=async()=>{if(!l){h(n(o.SETTINGS$PROFILE_NAME_RULE));return}if(u){t();return}try{await a.mutateAsync({name:e.name,newName:r}),g(n(o.SETTINGS$PROFILE_RENAMED,{name:r})),t()}catch(e){h(e instanceof Error?e.message:n(o.ERROR$GENERIC))}},f=()=>{a.isPending||t()},p=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(T,{type:`button`,variant:`tertiary`,onClick:f,isDisabled:a.isPending,children:n(o.BUTTON$CANCEL)}),(0,z.jsx)(T,{testId:`rename-profile-submit`,type:`button`,variant:`primary`,onClick:d,isDisabled:a.isPending||!l,children:a.isPending?(0,z.jsx)(E,{size:`small`}):n(o.BUTTON$RENAME)})]});return(0,z.jsx)(K,{isOpen:!0,title:n(o.SETTINGS$PROFILE_RENAME_TITLE),footer:p,onClose:f,initialFocusRef:s,children:(0,z.jsx)(`div`,{"data-testid":`rename-profile-modal`,className:`flex flex-col gap-3`,children:(0,z.jsx)(G,{ref:s,testId:`rename-profile-input`,ruleTestId:`rename-profile-rule`,value:r,onChange:i,isRequired:!0,onKeyDown:e=>{e.key===`Enter`&&!a.isPending&&l&&d()}})})})}function de(){let e=s();return i({mutationFn:e=>F.deleteProfile(e),onSuccess:async()=>{j.invalidateCache(),await e.invalidateQueries({queryKey:b.all}),await e.invalidateQueries({queryKey:y.personal()})},meta:{disableToast:!0}})}function fe({profile:e,onClose:t}){let{t:n}=c(`openhands`),r=de(),i=(0,R.useRef)(null);if(!e)return null;let a=async()=>{try{await r.mutateAsync(e.name),g(n(o.SETTINGS$PROFILE_DELETED,{name:e.name})),t()}catch(e){h(e instanceof Error?e.message:n(o.ERROR$GENERIC))}},s=()=>{r.isPending||t()},l=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(T,{ref:i,type:`button`,variant:`tertiary`,onClick:s,isDisabled:r.isPending,children:n(o.BUTTON$CANCEL)}),(0,z.jsx)(T,{testId:`delete-profile-confirm`,type:`button`,variant:`danger`,onClick:a,isDisabled:r.isPending,"aria-busy":r.isPending,children:r.isPending?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(E,{size:`small`}),(0,z.jsx)(`span`,{className:`sr-only`,children:n(o.BUTTON$DELETE)})]}):n(o.BUTTON$DELETE)})]});return(0,z.jsx)(K,{isOpen:!0,title:n(o.SETTINGS$PROFILE_DELETE_TITLE),footer:l,onClose:s,initialFocusRef:i,children:(0,z.jsx)(`p`,{className:`text-sm break-all`,children:n(o.SETTINGS$PROFILE_DELETE_CONFIRMATION,{name:e.name})})})}var pe=e(r(),1);function q({index:e,icon:t,label:n,onClick:r,onKeyDown:i,menuItemsRef:a,disabled:o,testId:s}){return(0,z.jsx)(`button`,{ref:t=>{a.current[e]=t},type:`button`,onClick:r,onKeyDown:t=>i(t,e),disabled:o,className:_(`group w-full cursor-pointer rounded px-2 py-2 text-start text-nowrap text-sm font-normal`,`text-[var(--oh-foreground)] hover:bg-[var(--oh-interactive-hover)]`,`disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent`),role:`menuitem`,"data-testid":s,children:(0,z.jsx)(te,{icon:t,text:n})})}function me({onEdit:e,onRename:t,onSetActive:n,onDelete:r,isActive:i,isActivating:a,onClose:s,anchorRef:l}){let{t:u}=c(`openhands`),d=(0,R.useRef)(null),f=(0,R.useRef)([]),p=l?.current??null,[m,h]=(0,R.useState)();(0,R.useLayoutEffect)(()=>{if(!p)return;let e=()=>{let e=p.getBoundingClientRect();e&&h({position:`fixed`,zIndex:9999,top:e.bottom+8,right:window.innerWidth-e.right,width:`max-content`})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[p]),(0,R.useEffect)(()=>{f.current[0]?.focus()},[]),(0,R.useEffect)(()=>{let e=e=>{let t=e.target;d.current&&!d.current.contains(t)&&s()},t=e=>{e.key===`Escape`&&s()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[s]);let g=e=>{e(),s()},v=(0,R.useCallback)((e,t)=>{if(e.key===`Tab`){s();return}let n=f.current.filter(Boolean).length;if(e.key===`ArrowDown`){e.preventDefault();let r=(t+1)%n;f.current[r]?.focus()}else if(e.key===`ArrowUp`){e.preventDefault();let r=(t-1+n)%n;f.current[r]?.focus()}},[s]),y=i||a,b=!!p,x=(0,z.jsxs)(`div`,{ref:d,className:_(`absolute right-0 top-full z-10 mt-2 w-[160px] rounded-md border border-[var(--oh-border-subtle)] bg-tertiary px-1 py-1 shadow-lg`,b&&`!static !top-auto !bottom-auto !left-auto !right-auto !mt-0`),role:`menu`,"aria-orientation":`vertical`,"data-testid":`profile-actions-menu`,children:[(0,z.jsx)(q,{index:0,icon:(0,z.jsx)(P,{width:16,height:16}),label:u(o.SETTINGS$PROFILE_EDIT),onClick:()=>g(e),onKeyDown:v,menuItemsRef:f,testId:`profile-edit`}),(0,z.jsx)(q,{index:1,icon:(0,z.jsx)(ce,{"aria-hidden":!0,className:`size-4`,strokeWidth:2}),label:u(o.BUTTON$RENAME),onClick:()=>g(t),onKeyDown:v,menuItemsRef:f,testId:`profile-rename`}),(0,z.jsx)(q,{index:2,icon:(0,z.jsx)(oe,{width:16,height:16}),label:u(o.SETTINGS$PROFILE_SET_ACTIVE),onClick:()=>g(n),onKeyDown:v,menuItemsRef:f,disabled:y,testId:`profile-set-active`}),(0,z.jsx)(q,{index:3,icon:(0,z.jsx)(M,{width:16,height:16}),label:u(o.BUTTON$DELETE),onClick:()=>g(r),onKeyDown:v,menuItemsRef:f,testId:`profile-delete`})]});return b?typeof document>`u`||!m?null:pe.createPortal((0,z.jsx)(`div`,{style:m,children:x}),document.body):x}function he({children:e,className:t,...n}){return(0,z.jsx)(`span`,{className:_(`text-sm leading-4 text-black font-semibold tracking-tighter bg-primary p-1 rounded-full`,t),...n,children:e})}function ge({profile:e,isActive:t,onActivate:n,onEdit:r,onRename:i,onDelete:a,isActivating:s}){let{t:l}=c(`openhands`),[d,p]=(0,R.useState)(!1),m=(0,R.useRef)(null);return(0,z.jsxs)(`div`,{"data-testid":`profile-row`,className:_(u,`justify-between gap-3`),children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,z.jsx)(`span`,{className:`min-w-0 max-w-full truncate text-sm font-medium text-white`,title:e.name,children:e.name}),e.model?(0,z.jsx)(`span`,{className:`min-w-0 max-w-full truncate text-sm text-[var(--oh-muted)]`,title:e.model,children:e.model}):null,t&&(0,z.jsx)(he,{className:`shrink-0 whitespace-nowrap px-2.5 py-1 text-xs`,"data-testid":`profile-active-badge`,children:l(o.SETTINGS$PROFILE_ACTIVE)})]}),(0,z.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,z.jsx)(N,{ref:m,onClick:()=>p(e=>!e),ariaLabel:l(o.SETTINGS$PROFILE_MENU),testId:`profile-menu-trigger`,className:f}),d&&(0,z.jsx)(me,{anchorRef:m,onEdit:()=>r(e),onRename:()=>i(e),onSetActive:()=>n(e.name),onDelete:()=>a(e),isActive:t,isActivating:s,onClose:()=>p(!1)})]})]})}function _e({isLoading:e,loadError:t,profiles:n,active:r,onActivate:i,onEdit:a,onRename:s,onDelete:l,isActivating:u}){let{t:f}=c(`openhands`);return e?(0,z.jsx)(`div`,{className:`flex justify-center p-4`,children:(0,z.jsx)(E,{size:`large`})}):t?(0,z.jsx)(`p`,{className:`text-sm text-red-400`,children:f(o.SETTINGS$PROFILES_LOAD_ERROR)}):n.length===0?(0,z.jsx)(`p`,{className:`text-sm text-[var(--oh-muted)] italic`,children:f(o.SETTINGS$PROFILES_EMPTY)}):(0,z.jsx)(`div`,{className:_(p,d),children:n.map(e=>(0,z.jsx)(ge,{profile:e,isActive:e.name===r,onActivate:i,onEdit:a,onRename:s,onDelete:l,isActivating:u},e.name))})}function J(){let e=s();return i({mutationFn:e=>F.activateProfile(e),onSuccess:async()=>{j.invalidateCache(),await e.invalidateQueries({queryKey:b.all}),await e.invalidateQueries({queryKey:y.personal()})},meta:{disableToast:!0}})}function Y({onAddProfile:e,onEditProfile:t}){let{t:n}=c(`openhands`),{data:r,isLoading:i,error:a}=I(),s=J(),[l,u]=(0,R.useState)(null),[d,f]=(0,R.useState)(null),p=r?.profiles??[],m=r?.active_profile??null;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,z.jsx)(`h2`,{className:`text-base font-medium text-white`,children:n(o.SETTINGS$AVAILABLE_PROFILES)}),e?(0,z.jsx)(T,{testId:`add-llm-profile`,type:`button`,variant:`secondary`,className:`ml-auto`,onClick:e,children:n(o.SETTINGS$ADD_LLM_PROFILE)}):null]}),(0,z.jsx)(_e,{isLoading:i,loadError:a??null,profiles:p,active:m,onActivate:async e=>{try{await s.mutateAsync(e),g(n(o.SETTINGS$PROFILE_ACTIVATED,{name:e}))}catch(e){console.error(`Failed to activate profile:`,e),h(n(o.ERROR$GENERIC))}},onEdit:e=>{t?.(e)},onRename:u,onDelete:f,isActivating:s.isPending})]}),(0,z.jsx)(ue,{profile:l,onClose:()=>u(null)}),(0,z.jsx)(fe,{profile:d,onClose:()=>f(null)})]})}function X(){let e=s();return i({mutationFn:({name:e,request:t})=>F.saveProfile(e,t),onSuccess:async()=>{j.invalidateCache(),await e.invalidateQueries({queryKey:b.all}),await e.invalidateQueries({queryKey:y.personal()})},meta:{disableToast:!0}})}function ve(){let{t:e}=c(`openhands`),{setHideSectionHeader:t}=se(),n=X(),{data:r}=I(),[i,a]=(0,R.useState)(`list`),[s,l]=(0,R.useState)(``),[u,d]=(0,R.useState)(null),[f,p]=(0,R.useState)(null),[_,v]=(0,R.useState)(!1);(0,R.useEffect)(()=>(t(i!==`list`),()=>t(!1)),[i,t]);let y=(0,R.useMemo)(()=>new Set(r?.profiles.map(e=>e.name)??[]),[r]),b=(0,R.useMemo)(()=>!(!U(s,{isRequired:!0})||i===`create`&&y.has(s)||i===`edit`&&s!==u?.profile.name&&y.has(s)),[s,i,y,u?.profile.name]),x=(0,R.useCallback)(()=>{l(``),d(null),a(`create`)},[]),S=(0,R.useCallback)(async t=>{try{let e=(await F.getProfile(t.name,`encrypted`)).config??{};d({profile:t,initialValues:{"llm.model":e.model??``,"llm.api_key":e.api_key??``,"llm.base_url":e.base_url??``}}),l(t.name),a(`edit`)}catch(t){console.error(`Failed to fetch profile details:`,t),h(e(o.ERROR$GENERIC))}},[e]),C=(0,R.useCallback)(()=>{a(`list`),d(null),l(``),p(null)},[]),w=(0,R.useCallback)(e=>{if(p(e),i===`create`&&!s){let t=e.values[`llm.model`];if(typeof t==`string`&&t){let e=W(t);y.has(e)||l(e)}}},[i,s,y]),E=(0,R.useCallback)(async()=>{if(!f||!b)return;let t=f.values,a=typeof t[`llm.model`]==`string`?t[`llm.model`]:``,c=typeof t[`llm.api_key`]==`string`?t[`llm.api_key`]:``,l=typeof t[`llm.base_url`]==`string`?t[`llm.base_url`]:``;if(!a){h(e(o.SETTINGS$MODEL_REQUIRED));return}let d=s.trim(),p=u?.profile.name,m=i===`edit`&&p&&p!==d,_=r?.active_profile===p;v(!0);try{m&&await F.renameProfile(p,d);let t={model:a};c?t.api_key=c:i===`edit`&&u?.initialValues[`llm.api_key`]&&(t.api_key=u.initialValues[`llm.api_key`]),l&&(t.base_url=l),await n.mutateAsync({name:d,request:{llm:t,include_secrets:!0}}),m&&_&&await F.activateProfile(d),g(e(i===`create`?o.SETTINGS$PROFILE_CREATED:o.SETTINGS$PROFILE_UPDATED,{name:d})),C()}catch(t){console.error(`Failed to save profile:`,t),h(e(o.ERROR$GENERIC))}finally{v(!1)}},[f,b,s,i,u,r?.active_profile,n,e,C]);if(i===`list`)return(0,z.jsx)(Y,{onAddProfile:x,onEditProfile:S});let D=e(i===`edit`?o.SETTINGS$EDIT_LLM_PROFILE:o.SETTINGS$ADD_LLM_PROFILE),O=i===`edit`&&u?e(o.SETTINGS$PROFILE_LOADED,{name:u.profile.name}):e(o.SETTINGS$PROFILE_SAVE_HINT);return(0,z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:C,className:`flex items-center gap-2 self-start rounded-lg p-2 text-[var(--oh-muted)] transition-colors hover:bg-tertiary hover:text-white`,"data-testid":`back-to-profiles`,children:[(0,z.jsx)(m,{size:20,"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`text-sm leading-5`,children:e(o.BUTTON$BACK)})]}),(0,z.jsx)(ne.H2,{testId:`profile-editor-title`,children:D}),(0,z.jsx)(`p`,{"data-testid":`profile-editor-description`,className:`text-sm leading-5 text-tertiary-light`,children:O})]}),(0,z.jsx)(G,{testId:`profile-name-input`,value:s,onChange:l,isRequired:!0}),(0,z.jsx)($,{embedded:!0,hideSaveButton:!0,initialValueOverrides:i===`edit`&&u?.initialValues?u.initialValues:{"llm.model":``,"llm.api_key":``,"llm.base_url":``},onSaveControlChange:w},i===`edit`?`edit-${u?.profile.name}`:`new-profile`),(0,z.jsxs)(`div`,{className:`flex justify-start gap-3 pt-4 border-t border-[var(--oh-border)]`,children:[(0,z.jsx)(T,{testId:`cancel-profile-btn`,type:`button`,variant:`tertiary`,onClick:C,children:e(o.BUTTON$CANCEL)}),(0,z.jsx)(T,{testId:`save-profile-btn`,type:`button`,variant:`primary`,onClick:E,isDisabled:!b||_||!f,"aria-busy":_,children:e(_?o.STATUS$SAVING:o.BUTTON$SAVE)})]})]})}var ye=new Set([`llm.model`,`llm.api_key`,`llm.base_url`]),be=(e,t)=>!e||!t?null:`${e}/${t}`,xe=(e,t)=>e?.sections.flatMap(e=>e.fields).find(e=>e.key===t)?.default??null,Z={openai:new Set([`https://api.openai.com`,`https://api.openai.com/v1`]),openhands:new Set([`https://llm-proxy.app.all-hands.dev`,`https://llm-proxy.app.all-hands.dev/v1`]),litellm_proxy:new Set([`https://llm-proxy.app.all-hands.dev`,`https://llm-proxy.app.all-hands.dev/v1`])},Se=e=>{try{let t=new URL(e),n=t.pathname.replace(/\/+$/,``)||``;return`${t.origin}${n}`}catch{return e.trim().replace(/\/+$/,``)}},Ce=(e,t)=>{let n=Se(t),{provider:r}=D(e);if(r){let e=Z[r];if(e)return e.has(n)}return Object.values(Z).some(e=>e?.has(n))};function Q({testId:e}){let{t}=c(`openhands`);return(0,z.jsx)(L,{testId:e,text:t(o.SETTINGS$OPENHANDS_API_KEY_HELP_TEXT),linkText:t(o.SETTINGS$NAV_API_KEYS),href:`https://app.all-hands.dev/settings/api-keys`,suffix:` ${t(o.SETTINGS$OPENHANDS_API_KEY_HELP_SUFFIX)}`})}function $({scope:e=`personal`,onSaveSuccess:t,initialValueOverrides:n,embedded:r,hideSaveButton:i,onSaveControlChange:a}){let{t:s}=c(`openhands`),{data:l}=ee(e),{data:u}=ie(l?.agent_settings_schema),d=String(A.agent_settings?.llm?.model??``),f=R.useCallback((e,t)=>{let n=re(e,t);if(n!==`basic`)return n;let r=e.llm_model??``,i=e.llm_base_url?.trim()??``;return i.length>0&&!Ce(r,i)?`all`:`basic`},[]);return(0,z.jsx)(ae,{scope:e,sectionKeys:[`llm`],excludeKeys:ye,header:R.useCallback(({values:e,isDisabled:t,view:n,onChange:i})=>{let a=typeof e[`llm.model`]==`string`?e[`llm.model`]:``,c=typeof e[`llm.base_url`]==`string`?e[`llm.base_url`]:``,u=a.startsWith(`openhands/`),f=typeof e[`llm.api_key`]==`string`?e[`llm.api_key`]:``,p=r?f.length>0:!!l?.llm_api_key_set,m=(e,n)=>(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(k,{testId:e,label:s(o.SETTINGS_FORM$API_KEY),type:`password`,className:`w-full`,value:f,placeholder:p?`<hidden>`:``,onChange:e=>i(`llm.api_key`,e),isDisabled:t,startContent:p?(0,z.jsx)(V,{isSet:p}):void 0}),(0,z.jsx)(L,{testId:n,text:s(o.SETTINGS$DONT_KNOW_API_KEY),linkText:s(o.SETTINGS$CLICK_FOR_INSTRUCTIONS),href:`https://docs.openhands.dev/usage/local-setup#getting-an-api-key`})]});return(0,z.jsx)(`div`,{className:`flex flex-col gap-6`,children:n===`basic`?(0,z.jsxs)(`div`,{className:`flex flex-col gap-6`,"data-testid":`llm-settings-form-basic`,children:[(0,z.jsx)(O,{currentModel:a||void 0,currentBaseUrl:c||void 0,onChange:(e,t)=>{let n=be(e,t);n&&i(`llm.model`,n)},wrapperClassName:`!flex-col !gap-6`,isDisabled:t}),u?(0,z.jsx)(Q,{testId:`openhands-api-key-help`}):null,m(`llm-api-key-input`,`llm-api-key-help-anchor`)]}):(0,z.jsxs)(`div`,{className:`flex flex-col gap-6`,"data-testid":`llm-settings-form-advanced`,children:[(0,z.jsx)(k,{testId:`llm-custom-model-input`,label:s(o.SETTINGS$CUSTOM_MODEL),type:`text`,className:`w-full`,value:a,placeholder:d,onChange:e=>i(`llm.model`,e),isDisabled:t}),u?(0,z.jsx)(Q,{testId:`openhands-api-key-help-2`}):null,(0,z.jsx)(k,{testId:`base-url-input`,label:s(o.SETTINGS$BASE_URL),type:`text`,className:`w-full`,value:c,placeholder:`https://api.openai.com`,onChange:e=>i(`llm.base_url`,e),isDisabled:t}),m(`llm-api-key-input`,`llm-api-key-help-anchor-advanced`)]})})},[d,r,l?.llm_api_key_set,s]),buildPayload:R.useCallback((e,t)=>{let n=structuredClone(e),r=n.llm??{};return t.view===`basic`&&(r.base_url=xe(u,`llm.base_url`),n.llm=r),{agent_settings_diff:n}},[u]),getInitialView:f,forceShowAdvancedView:!0,allowAllView:!0,onSaveSuccess:t,initialValueOverrides:n,embedded:r,hideSaveButton:i,onSaveControlChange:a,testId:`llm-settings-screen`})}var we=n(function(){let{backend:e}=v();return e.kind===`cloud`?(0,z.jsx)($,{}):(0,z.jsx)(ve,{})});export{W as a,J as i,we as n,X as r,$ as t};
|
|
1
|
+
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{L as n}from"./vendor~entry.client~root~root-layout~index-redirect~home~conversation-panel~conversation~la~cnj3raoq-DTEXlLSB.js";import{t as r}from"./react-dom-hVBnwgwZ.js";import{t as i}from"./useMutation-B4OUESdw.js";import{o as a,t as o}from"./declaration-D378OjpZ.js";import{n as s}from"./QueryClientProvider-B7kl84Kj.js";import{t as c}from"./useTranslation-CpIcQBq6.js";import{t as l}from"./createLucideIcon-Ddu8jDOQ.js";import{i as u,n as d,r as f,t as p,u as m}from"./settings-list-classes-BOS092DR.js";import{n as h,r as g}from"./custom-toast-handlers-BOc3qeQ7.js";import{t as _}from"./utils-D-HX7JCe.js";import{n as v}from"./active-backend-context-TVbjnvmP.js";import{a as y,n as b}from"./query-keys-tAsQcc_9.js";import{t as x}from"./modal-backdrop-DTYGVmOR.js";import{r as S,t as C}from"./modal-body-YElmM1dV.js";import{r as w}from"./base-modal-CQRvRHu1.js";import{t as T}from"./brand-button-C2nEKopC.js";import{t as E}from"./loading-spinner-C04FGh14.js";import{n as D,t as O}from"./model-selector-DeMmw-Xa.js";import{t as k}from"./settings-input-DBywAnA7.js";import{t as A}from"./settings-D5am1n6X.js";import{t as j}from"./settings-service.api-FvJGK45W.js";import{r as ee}from"./use-settings-DQ7Oo1Hj.js";import{i as te,r as M,t as N}from"./ellipsis-button-ugUATsNo.js";import{t as P}from"./u-edit-KAUlufD8.js";import{n as F,t as I}from"./use-llm-profiles-O4a9V6RC.js";import{r as ne}from"./typography-vVUMoNUg.js";import{l as L,s as re}from"./sdk-settings-schema-QBYH-ONX.js";import{t as ie}from"./use-agent-settings-schema-Bvp5UzV8.js";import{t as ae}from"./sdk-section-page-CJW0G04-.js";import{t as oe}from"./u-check-circle-DplbarS5.js";import{n as se}from"./settings-section-header-context-32x6WTyL.js";var ce=l(`text-cursor`,[[`path`,{d:`M17 22h-1a4 4 0 0 1-4-4V6a4 4 0 0 1 4-4h1`,key:`uvaxm9`}],[`path`,{d:`M7 22h1a4 4 0 0 0 4-4v-1`,key:`11xy8d`}],[`path`,{d:`M7 2h1a4 4 0 0 1 4 4v1`,key:`1uw06m`}]]),R=e(t()),z=a(),B=e=>(0,z.jsxs)(`svg`,{width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[(0,z.jsx)(`path`,{d:`M9.9509 15.588H10.8349L16.5125 9.91042L15.6285 9.0264L10.3991 14.2681L8.00867 11.8777L7.12465 12.7617L9.9509 15.588Z`,fill:`currentColor`}),(0,z.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12.8521 3.29895C14.8443 3.42346 16.712 4.41954 18.0816 5.78916C19.7002 7.53231 20.5718 9.64898 20.5718 12.1392C20.5718 14.1314 19.8247 15.999 18.5796 17.6177C17.3345 19.1118 15.5914 20.2324 13.5992 20.6059C11.607 20.9794 9.61486 20.7304 7.87171 19.7343C6.12856 18.7382 4.75895 17.2441 4.01189 15.3765C3.26482 13.5088 3.14031 11.3921 3.76286 9.52447C4.38542 7.53231 5.50601 5.91367 7.24916 4.79308C8.86779 3.67248 10.86 3.17444 12.8521 3.29895ZM13.4747 19.3608C15.0933 18.9873 16.5874 18.1157 17.708 16.7461C18.7041 15.3765 19.3267 13.7578 19.2022 12.0147C19.2022 10.0225 18.4551 8.03035 17.0855 6.66073C15.8404 5.41563 14.3463 4.66857 12.6031 4.54405C10.9845 4.41954 9.24132 4.79308 7.87171 5.78916C6.50209 6.78524 5.50601 8.15486 5.00797 9.89801C4.50993 11.5166 4.50993 13.2598 5.25699 14.8784C6.00405 16.4971 7.12465 17.7422 8.61877 18.6137C10.1129 19.4853 11.856 19.7343 13.4747 19.3608Z`,fill:`currentColor`})]});function V({testId:e,isSet:t}){return(0,z.jsx)(`span`,{"data-testid":e||(t?`set-indicator`:`unset-indicator`),children:(0,z.jsx)(B,{className:_(t?`text-success`:`text-danger`)})})}var H=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;function U(e,{isRequired:t=!1}={}){return e===``?!t:H.test(e)}function W(e){let t=e.split(`/`),n=(t[t.length-1]||e).replace(/[^A-Za-z0-9._-]/g,`-`).replace(/-+/g,`-`).replace(/^-+|-+$/g,``);return n&&!/^[A-Za-z0-9]/.test(n)&&(n=`profile-${n}`),n.length>64&&(n=n.substring(0,64).replace(/-+$/,``)),n||`default-profile`}var G=(0,R.forwardRef)(function({testId:e,ruleTestId:t,value:n,onChange:r,onKeyDown:i,placeholder:a,isDisabled:s,isOptional:l,isRequired:u=!1},d){let{t:f}=c(`openhands`),p=U(n,{isRequired:u}),m=l?`${f(o.SETTINGS$PROFILE_NAME_LABEL)} (${f(o.COMMON$OPTIONAL)})`:f(o.SETTINGS$PROFILE_NAME_LABEL),h=R.useId(),g=t??`${h}-rule`;return(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(k,{ref:d,testId:e,label:m,type:`text`,className:`w-full`,value:n,placeholder:a??f(o.SETTINGS$PROFILE_NAME_PLACEHOLDER),onChange:r,onKeyDown:i,isDisabled:s,ariaDescribedBy:g,ariaInvalid:!p}),(0,z.jsx)(`p`,{id:g,"data-testid":t,className:_(`text-xs`,p?`text-[var(--oh-muted)]`:`text-red-400`),children:f(o.SETTINGS$PROFILE_NAME_RULE)})]})});function K({isOpen:e,title:t,width:n=`md`,children:r,footer:i,onClose:a,initialFocusRef:o}){let s=(0,R.useRef)(null);return(0,R.useEffect)(()=>{if(!e)return;let t=o?.current??s.current;if(t){let e=setTimeout(()=>{t.focus()},0);return()=>clearTimeout(e)}},[e,o]),(0,R.useEffect)(()=>{if(!e||!s.current)return;let t=s.current,n=e=>{if(e.key!==`Tab`)return;let n=t.querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`),r=n[0],i=n[n.length-1];e.shiftKey&&document.activeElement===r?(e.preventDefault(),i?.focus()):!e.shiftKey&&document.activeElement===i&&(e.preventDefault(),r?.focus())};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e]),e?(0,z.jsx)(x,{onClose:a,children:(0,z.jsxs)(`div`,{ref:s,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`modal-title`,className:_(`bg-base-secondary p-6 rounded-xl flex flex-col gap-4 border border-[var(--oh-border)]`,S(n),C),children:[(0,z.jsx)(w,{id:`modal-title`,title:t,className:`text-xl font-medium text-white`}),r,(0,z.jsx)(`div`,{className:`w-full flex justify-end gap-2 mt-2`,children:i})]})}):null}function le(){let e=s();return i({mutationFn:({name:e,newName:t})=>F.renameProfile(e,t),onSuccess:async()=>{j.invalidateCache(),await e.invalidateQueries({queryKey:b.all}),await e.invalidateQueries({queryKey:y.personal()})},meta:{disableToast:!0}})}function ue({profile:e,onClose:t}){let{t:n}=c(`openhands`),[r,i]=(0,R.useState)(``),a=le(),s=(0,R.useRef)(null);if((0,R.useEffect)(()=>{i(e?.name??``)},[e?.name]),!e)return null;let l=U(r,{isRequired:!0}),u=r===e.name,d=async()=>{if(!l){h(n(o.SETTINGS$PROFILE_NAME_RULE));return}if(u){t();return}try{await a.mutateAsync({name:e.name,newName:r}),g(n(o.SETTINGS$PROFILE_RENAMED,{name:r})),t()}catch(e){h(e instanceof Error?e.message:n(o.ERROR$GENERIC))}},f=()=>{a.isPending||t()},p=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(T,{type:`button`,variant:`tertiary`,onClick:f,isDisabled:a.isPending,children:n(o.BUTTON$CANCEL)}),(0,z.jsx)(T,{testId:`rename-profile-submit`,type:`button`,variant:`primary`,onClick:d,isDisabled:a.isPending||!l,children:a.isPending?(0,z.jsx)(E,{size:`small`}):n(o.BUTTON$RENAME)})]});return(0,z.jsx)(K,{isOpen:!0,title:n(o.SETTINGS$PROFILE_RENAME_TITLE),footer:p,onClose:f,initialFocusRef:s,children:(0,z.jsx)(`div`,{"data-testid":`rename-profile-modal`,className:`flex flex-col gap-3`,children:(0,z.jsx)(G,{ref:s,testId:`rename-profile-input`,ruleTestId:`rename-profile-rule`,value:r,onChange:i,isRequired:!0,onKeyDown:e=>{e.key===`Enter`&&!a.isPending&&l&&d()}})})})}function de(){let e=s();return i({mutationFn:e=>F.deleteProfile(e),onSuccess:async()=>{j.invalidateCache(),await e.invalidateQueries({queryKey:b.all}),await e.invalidateQueries({queryKey:y.personal()})},meta:{disableToast:!0}})}function fe({profile:e,onClose:t}){let{t:n}=c(`openhands`),r=de(),i=(0,R.useRef)(null);if(!e)return null;let a=async()=>{try{await r.mutateAsync(e.name),g(n(o.SETTINGS$PROFILE_DELETED,{name:e.name})),t()}catch(e){h(e instanceof Error?e.message:n(o.ERROR$GENERIC))}},s=()=>{r.isPending||t()},l=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(T,{ref:i,type:`button`,variant:`tertiary`,onClick:s,isDisabled:r.isPending,children:n(o.BUTTON$CANCEL)}),(0,z.jsx)(T,{testId:`delete-profile-confirm`,type:`button`,variant:`danger`,onClick:a,isDisabled:r.isPending,"aria-busy":r.isPending,children:r.isPending?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(E,{size:`small`}),(0,z.jsx)(`span`,{className:`sr-only`,children:n(o.BUTTON$DELETE)})]}):n(o.BUTTON$DELETE)})]});return(0,z.jsx)(K,{isOpen:!0,title:n(o.SETTINGS$PROFILE_DELETE_TITLE),footer:l,onClose:s,initialFocusRef:i,children:(0,z.jsx)(`p`,{className:`text-sm break-all`,children:n(o.SETTINGS$PROFILE_DELETE_CONFIRMATION,{name:e.name})})})}var pe=e(r(),1);function q({index:e,icon:t,label:n,onClick:r,onKeyDown:i,menuItemsRef:a,disabled:o,testId:s}){return(0,z.jsx)(`button`,{ref:t=>{a.current[e]=t},type:`button`,onClick:r,onKeyDown:t=>i(t,e),disabled:o,className:_(`group w-full cursor-pointer rounded px-2 py-2 text-start text-nowrap text-sm font-normal`,`text-[var(--oh-foreground)] hover:bg-[var(--oh-interactive-hover)]`,`disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent`),role:`menuitem`,"data-testid":s,children:(0,z.jsx)(te,{icon:t,text:n})})}function me({onEdit:e,onRename:t,onSetActive:n,onDelete:r,isActive:i,isActivating:a,onClose:s,anchorRef:l}){let{t:u}=c(`openhands`),d=(0,R.useRef)(null),f=(0,R.useRef)([]),p=l?.current??null,[m,h]=(0,R.useState)();(0,R.useLayoutEffect)(()=>{if(!p)return;let e=()=>{let e=p.getBoundingClientRect();e&&h({position:`fixed`,zIndex:9999,top:e.bottom+8,right:window.innerWidth-e.right,width:`max-content`})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[p]),(0,R.useEffect)(()=>{f.current[0]?.focus()},[]),(0,R.useEffect)(()=>{let e=e=>{let t=e.target;d.current&&!d.current.contains(t)&&s()},t=e=>{e.key===`Escape`&&s()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[s]);let g=e=>{e(),s()},v=(0,R.useCallback)((e,t)=>{if(e.key===`Tab`){s();return}let n=f.current.filter(Boolean).length;if(e.key===`ArrowDown`){e.preventDefault();let r=(t+1)%n;f.current[r]?.focus()}else if(e.key===`ArrowUp`){e.preventDefault();let r=(t-1+n)%n;f.current[r]?.focus()}},[s]),y=i||a,b=!!p,x=(0,z.jsxs)(`div`,{ref:d,className:_(`absolute right-0 top-full z-10 mt-2 w-[160px] rounded-md border border-[var(--oh-border-subtle)] bg-tertiary px-1 py-1 shadow-lg`,b&&`!static !top-auto !bottom-auto !left-auto !right-auto !mt-0`),role:`menu`,"aria-orientation":`vertical`,"data-testid":`profile-actions-menu`,children:[(0,z.jsx)(q,{index:0,icon:(0,z.jsx)(P,{width:16,height:16}),label:u(o.SETTINGS$PROFILE_EDIT),onClick:()=>g(e),onKeyDown:v,menuItemsRef:f,testId:`profile-edit`}),(0,z.jsx)(q,{index:1,icon:(0,z.jsx)(ce,{"aria-hidden":!0,className:`size-4`,strokeWidth:2}),label:u(o.BUTTON$RENAME),onClick:()=>g(t),onKeyDown:v,menuItemsRef:f,testId:`profile-rename`}),(0,z.jsx)(q,{index:2,icon:(0,z.jsx)(oe,{width:16,height:16}),label:u(o.SETTINGS$PROFILE_SET_ACTIVE),onClick:()=>g(n),onKeyDown:v,menuItemsRef:f,disabled:y,testId:`profile-set-active`}),(0,z.jsx)(q,{index:3,icon:(0,z.jsx)(M,{width:16,height:16}),label:u(o.BUTTON$DELETE),onClick:()=>g(r),onKeyDown:v,menuItemsRef:f,testId:`profile-delete`})]});return b?typeof document>`u`||!m?null:pe.createPortal((0,z.jsx)(`div`,{style:m,children:x}),document.body):x}function he({children:e,className:t,...n}){return(0,z.jsx)(`span`,{className:_(`text-sm leading-4 text-black font-semibold tracking-tighter bg-primary p-1 rounded-full`,t),...n,children:e})}function ge({profile:e,isActive:t,onActivate:n,onEdit:r,onRename:i,onDelete:a,isActivating:s}){let{t:l}=c(`openhands`),[d,p]=(0,R.useState)(!1),m=(0,R.useRef)(null);return(0,z.jsxs)(`div`,{"data-testid":`profile-row`,className:_(u,`justify-between gap-3`),children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,z.jsx)(`span`,{className:`min-w-0 max-w-full truncate text-sm font-medium text-white`,title:e.name,children:e.name}),e.model?(0,z.jsx)(`span`,{className:`min-w-0 max-w-full truncate text-sm text-[var(--oh-muted)]`,title:e.model,children:e.model}):null,t&&(0,z.jsx)(he,{className:`shrink-0 whitespace-nowrap px-2.5 py-1 text-xs`,"data-testid":`profile-active-badge`,children:l(o.SETTINGS$PROFILE_ACTIVE)})]}),(0,z.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,z.jsx)(N,{ref:m,onClick:()=>p(e=>!e),ariaLabel:l(o.SETTINGS$PROFILE_MENU),testId:`profile-menu-trigger`,className:f}),d&&(0,z.jsx)(me,{anchorRef:m,onEdit:()=>r(e),onRename:()=>i(e),onSetActive:()=>n(e.name),onDelete:()=>a(e),isActive:t,isActivating:s,onClose:()=>p(!1)})]})]})}function _e({isLoading:e,loadError:t,profiles:n,active:r,onActivate:i,onEdit:a,onRename:s,onDelete:l,isActivating:u}){let{t:f}=c(`openhands`);return e?(0,z.jsx)(`div`,{className:`flex justify-center p-4`,children:(0,z.jsx)(E,{size:`large`})}):t?(0,z.jsx)(`p`,{className:`text-sm text-red-400`,children:f(o.SETTINGS$PROFILES_LOAD_ERROR)}):n.length===0?(0,z.jsx)(`p`,{className:`text-sm text-[var(--oh-muted)] italic`,children:f(o.SETTINGS$PROFILES_EMPTY)}):(0,z.jsx)(`div`,{className:_(p,d),children:n.map(e=>(0,z.jsx)(ge,{profile:e,isActive:e.name===r,onActivate:i,onEdit:a,onRename:s,onDelete:l,isActivating:u},e.name))})}function J(){let e=s();return i({mutationFn:e=>F.activateProfile(e),onSuccess:async()=>{j.invalidateCache(),await e.invalidateQueries({queryKey:b.all}),await e.invalidateQueries({queryKey:y.personal()})},meta:{disableToast:!0}})}function Y({onAddProfile:e,onEditProfile:t}){let{t:n}=c(`openhands`),{data:r,isLoading:i,error:a}=I(),s=J(),[l,u]=(0,R.useState)(null),[d,f]=(0,R.useState)(null),p=r?.profiles??[],m=r?.active_profile??null;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,z.jsx)(`h2`,{className:`text-base font-medium text-white`,children:n(o.SETTINGS$AVAILABLE_PROFILES)}),e?(0,z.jsx)(T,{testId:`add-llm-profile`,type:`button`,variant:`secondary`,className:`ml-auto`,onClick:e,children:n(o.SETTINGS$ADD_LLM_PROFILE)}):null]}),(0,z.jsx)(_e,{isLoading:i,loadError:a??null,profiles:p,active:m,onActivate:async e=>{try{await s.mutateAsync(e),g(n(o.SETTINGS$PROFILE_ACTIVATED,{name:e}))}catch(e){console.error(`Failed to activate profile:`,e),h(n(o.ERROR$GENERIC))}},onEdit:e=>{t?.(e)},onRename:u,onDelete:f,isActivating:s.isPending})]}),(0,z.jsx)(ue,{profile:l,onClose:()=>u(null)}),(0,z.jsx)(fe,{profile:d,onClose:()=>f(null)})]})}function X(){let e=s();return i({mutationFn:({name:e,request:t})=>F.saveProfile(e,t),onSuccess:async()=>{j.invalidateCache(),await e.invalidateQueries({queryKey:b.all}),await e.invalidateQueries({queryKey:y.personal()})},meta:{disableToast:!0}})}function ve(){let{t:e}=c(`openhands`),{setHideSectionHeader:t}=se(),n=X(),{data:r}=I(),[i,a]=(0,R.useState)(`list`),[s,l]=(0,R.useState)(``),[u,d]=(0,R.useState)(null),[f,p]=(0,R.useState)(null),[_,v]=(0,R.useState)(!1);(0,R.useEffect)(()=>(t(i!==`list`),()=>t(!1)),[i,t]);let y=(0,R.useMemo)(()=>new Set(r?.profiles.map(e=>e.name)??[]),[r]),b=(0,R.useMemo)(()=>!(!U(s,{isRequired:!0})||i===`create`&&y.has(s)||i===`edit`&&s!==u?.profile.name&&y.has(s)),[s,i,y,u?.profile.name]),x=(0,R.useCallback)(()=>{l(``),d(null),a(`create`)},[]),S=(0,R.useCallback)(async t=>{try{let e=(await F.getProfile(t.name,`encrypted`)).config??{};d({profile:t,initialValues:{"llm.model":e.model??``,"llm.api_key":e.api_key??``,"llm.base_url":e.base_url??``}}),l(t.name),a(`edit`)}catch(t){console.error(`Failed to fetch profile details:`,t),h(e(o.ERROR$GENERIC))}},[e]),C=(0,R.useCallback)(()=>{a(`list`),d(null),l(``),p(null)},[]),w=(0,R.useCallback)(e=>{if(p(e),i===`create`&&!s){let t=e.values[`llm.model`];if(typeof t==`string`&&t){let e=W(t);y.has(e)||l(e)}}},[i,s,y]),E=(0,R.useCallback)(async()=>{if(!f||!b)return;let t=f.values,a=typeof t[`llm.model`]==`string`?t[`llm.model`]:``,c=typeof t[`llm.api_key`]==`string`?t[`llm.api_key`]:``,l=typeof t[`llm.base_url`]==`string`?t[`llm.base_url`]:``;if(!a){h(e(o.SETTINGS$MODEL_REQUIRED));return}let d=s.trim(),p=u?.profile.name,m=i===`edit`&&p&&p!==d,_=r?.active_profile===p;v(!0);try{m&&await F.renameProfile(p,d);let t={model:a};c?t.api_key=c:i===`edit`&&u?.initialValues[`llm.api_key`]&&(t.api_key=u.initialValues[`llm.api_key`]),l&&(t.base_url=l),await n.mutateAsync({name:d,request:{llm:t,include_secrets:!0}}),m&&_&&await F.activateProfile(d),g(e(i===`create`?o.SETTINGS$PROFILE_CREATED:o.SETTINGS$PROFILE_UPDATED,{name:d})),C()}catch(t){console.error(`Failed to save profile:`,t),h(e(o.ERROR$GENERIC))}finally{v(!1)}},[f,b,s,i,u,r?.active_profile,n,e,C]);if(i===`list`)return(0,z.jsx)(Y,{onAddProfile:x,onEditProfile:S});let D=e(i===`edit`?o.SETTINGS$EDIT_LLM_PROFILE:o.SETTINGS$ADD_LLM_PROFILE),O=i===`edit`&&u?e(o.SETTINGS$PROFILE_LOADED,{name:u.profile.name}):e(o.SETTINGS$PROFILE_SAVE_HINT);return(0,z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:C,className:`flex items-center gap-2 self-start rounded-lg p-2 text-[var(--oh-muted)] transition-colors hover:bg-tertiary hover:text-white`,"data-testid":`back-to-profiles`,children:[(0,z.jsx)(m,{size:20,"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`text-sm leading-5`,children:e(o.BUTTON$BACK)})]}),(0,z.jsx)(ne.H2,{testId:`profile-editor-title`,children:D}),(0,z.jsx)(`p`,{"data-testid":`profile-editor-description`,className:`text-sm leading-5 text-tertiary-light`,children:O})]}),(0,z.jsx)(G,{testId:`profile-name-input`,value:s,onChange:l,isRequired:!0}),(0,z.jsx)($,{embedded:!0,hideSaveButton:!0,initialValueOverrides:i===`edit`&&u?.initialValues?u.initialValues:{"llm.model":``,"llm.api_key":``,"llm.base_url":``},onSaveControlChange:w},i===`edit`?`edit-${u?.profile.name}`:`new-profile`),(0,z.jsxs)(`div`,{className:`flex justify-start gap-3 pt-4 border-t border-[var(--oh-border)]`,children:[(0,z.jsx)(T,{testId:`cancel-profile-btn`,type:`button`,variant:`tertiary`,onClick:C,children:e(o.BUTTON$CANCEL)}),(0,z.jsx)(T,{testId:`save-profile-btn`,type:`button`,variant:`primary`,onClick:E,isDisabled:!b||_||!f,"aria-busy":_,children:e(_?o.STATUS$SAVING:o.BUTTON$SAVE)})]})]})}var ye=new Set([`llm.model`,`llm.api_key`,`llm.base_url`]),be=(e,t)=>!e||!t?null:`${e}/${t}`,xe=(e,t)=>e?.sections.flatMap(e=>e.fields).find(e=>e.key===t)?.default??null,Z={openai:new Set([`https://api.openai.com`,`https://api.openai.com/v1`]),openhands:new Set([`https://llm-proxy.app.all-hands.dev`,`https://llm-proxy.app.all-hands.dev/v1`]),litellm_proxy:new Set([`https://llm-proxy.app.all-hands.dev`,`https://llm-proxy.app.all-hands.dev/v1`])},Se=e=>{try{let t=new URL(e),n=t.pathname.replace(/\/+$/,``)||``;return`${t.origin}${n}`}catch{return e.trim().replace(/\/+$/,``)}},Ce=(e,t)=>{let n=Se(t),{provider:r}=D(e);if(r){let e=Z[r];if(e)return e.has(n)}return Object.values(Z).some(e=>e?.has(n))};function Q({testId:e}){let{t}=c(`openhands`);return(0,z.jsx)(L,{testId:e,text:t(o.SETTINGS$OPENHANDS_API_KEY_HELP_TEXT),linkText:t(o.SETTINGS$NAV_API_KEYS),href:`https://app.all-hands.dev/settings/api-keys`,suffix:` ${t(o.SETTINGS$OPENHANDS_API_KEY_HELP_SUFFIX)}`})}function $({scope:e=`personal`,onSaveSuccess:t,initialValueOverrides:n,embedded:r,hideSaveButton:i,onSaveControlChange:a}){let{t:s}=c(`openhands`),{data:l}=ee(e),{data:u}=ie(l?.agent_settings_schema),d=String(A.agent_settings?.llm?.model??``),f=R.useCallback((e,t)=>{let n=re(e,t);if(n!==`basic`)return n;let r=e.llm_model??``,i=e.llm_base_url?.trim()??``;return i.length>0&&!Ce(r,i)?`all`:`basic`},[]);return(0,z.jsx)(ae,{scope:e,sectionKeys:[`llm`],excludeKeys:ye,header:R.useCallback(({values:e,isDisabled:t,view:n,onChange:i})=>{let a=typeof e[`llm.model`]==`string`?e[`llm.model`]:``,c=typeof e[`llm.base_url`]==`string`?e[`llm.base_url`]:``,u=a.startsWith(`openhands/`),f=typeof e[`llm.api_key`]==`string`?e[`llm.api_key`]:``,p=r?f.length>0:!!l?.llm_api_key_set,m=(e,n)=>(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(k,{testId:e,label:s(o.SETTINGS_FORM$API_KEY),type:`password`,className:`w-full`,value:f,placeholder:p?`<hidden>`:``,onChange:e=>i(`llm.api_key`,e),isDisabled:t,startContent:p?(0,z.jsx)(V,{isSet:p}):void 0}),(0,z.jsx)(L,{testId:n,text:s(o.SETTINGS$DONT_KNOW_API_KEY),linkText:s(o.SETTINGS$CLICK_FOR_INSTRUCTIONS),href:`https://docs.openhands.dev/usage/local-setup#getting-an-api-key`})]});return(0,z.jsx)(`div`,{className:`flex flex-col gap-6`,children:n===`basic`?(0,z.jsxs)(`div`,{className:`flex flex-col gap-6`,"data-testid":`llm-settings-form-basic`,children:[(0,z.jsx)(O,{currentModel:a||void 0,currentBaseUrl:c||void 0,onChange:(e,t)=>{let n=be(e,t);n&&i(`llm.model`,n)},wrapperClassName:`!flex-col !gap-6`,isDisabled:t}),u?(0,z.jsx)(Q,{testId:`openhands-api-key-help`}):null,m(`llm-api-key-input`,`llm-api-key-help-anchor`)]}):(0,z.jsxs)(`div`,{className:`flex flex-col gap-6`,"data-testid":`llm-settings-form-advanced`,children:[(0,z.jsx)(k,{testId:`llm-custom-model-input`,label:s(o.SETTINGS$CUSTOM_MODEL),type:`text`,className:`w-full`,value:a,placeholder:d,onChange:e=>i(`llm.model`,e),isDisabled:t}),u?(0,z.jsx)(Q,{testId:`openhands-api-key-help-2`}):null,(0,z.jsx)(k,{testId:`base-url-input`,label:s(o.SETTINGS$BASE_URL),type:`text`,className:`w-full`,value:c,placeholder:`https://api.openai.com`,onChange:e=>i(`llm.base_url`,e),isDisabled:t}),m(`llm-api-key-input`,`llm-api-key-help-anchor-advanced`)]})})},[d,r,l?.llm_api_key_set,s]),buildPayload:R.useCallback((e,t)=>{let n=structuredClone(e),r=n.llm??{};return t.view===`basic`&&(r.base_url=xe(u,`llm.base_url`),n.llm=r),{agent_settings_diff:n}},[u]),getInitialView:f,forceShowAdvancedView:!0,allowAllView:!0,onSaveSuccess:t,initialValueOverrides:n,embedded:r,hideSaveButton:i,onSaveControlChange:a,testId:`llm-settings-screen`})}var we=n(function(){let{backend:e}=v();return e.kind===`cloud`?(0,z.jsx)($,{}):(0,z.jsx)(ve,{})});export{W as a,J as i,we as n,X as r,$ as t};
|
package/build/assets/{manage-backends-modal-rYeyGx7j.js → manage-backends-modal-s22zCdEW.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,r as t}from"./rolldown-runtime-BFRubm34.js";import{t as n}from"./react-CM_dJw1Z.js";import{t as r}from"./vendor~root~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-s~kyz9p27j-CyUbhpbm.js";import{o as i,t as a}from"./declaration-D378OjpZ.js";import{t as o}from"./useTranslation-CpIcQBq6.js";import{t as s}from"./pencil-Dr0b2jL1.js";import{t as c}from"./plus-DT-M0FA1.js";import{t as l}from"./trash-2-CbVljPko.js";import{t as u}from"./utils-D-HX7JCe.js";import{t as d}from"./agent-server-client-options-DT2GP6VJ.js";import{r as f}from"./active-backend-context-TVbjnvmP.js";import{t as p}from"./server-client-C3mC8Hl3.js";import{t as m}from"./modal-backdrop-DTYGVmOR.js";import{r as h,t as g}from"./modal-body-YElmM1dV.js";import{t as _}from"./brand-button-C2nEKopC.js";import{i as v,n as y,r as b}from"./backend-form-modal-
|
|
1
|
+
import{a as e,r as t}from"./rolldown-runtime-BFRubm34.js";import{t as n}from"./react-CM_dJw1Z.js";import{t as r}from"./vendor~root~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-s~kyz9p27j-CyUbhpbm.js";import{o as i,t as a}from"./declaration-D378OjpZ.js";import{t as o}from"./useTranslation-CpIcQBq6.js";import{t as s}from"./pencil-Dr0b2jL1.js";import{t as c}from"./plus-DT-M0FA1.js";import{t as l}from"./trash-2-CbVljPko.js";import{t as u}from"./utils-D-HX7JCe.js";import{t as d}from"./agent-server-client-options-DT2GP6VJ.js";import{r as f}from"./active-backend-context-TVbjnvmP.js";import{t as p}from"./server-client-C3mC8Hl3.js";import{t as m}from"./modal-backdrop-DTYGVmOR.js";import{r as h,t as g}from"./modal-body-YElmM1dV.js";import{t as _}from"./brand-button-C2nEKopC.js";import{i as v,n as y,r as b}from"./backend-form-modal-DxYjqqAK.js";import{t as x}from"./modal-close-button-C_GpQt9F.js";import{t as S}from"./confirmation-modal-C9-La0h3.js";var C=t({ManageBackendsModal:()=>k}),w=e(n(),1),T=i(),E=`inline-flex cursor-pointer items-center justify-center rounded-md p-1 text-muted transition-colors hover:bg-interactive-hover hover:text-white`;function D({backend:e}){let{t}=o(`openhands`),{data:n}=r({queryKey:[`backend-version`,e.host,e.apiKey],queryFn:async()=>(await new p(d({host:e.host,sessionApiKey:e.apiKey||null,timeout:5e3})).getServerInfo()).version??null,retry:!1,staleTime:6e4,enabled:e.kind===`local`});return n?(0,T.jsx)(`span`,{className:`inline-flex shrink-0 items-center rounded-full border border-[var(--oh-border)] bg-[var(--oh-surface)] px-1.5 py-0.5 text-[10px] font-medium leading-none text-[var(--oh-text-dim)]`,"data-testid":`manage-backends-version-${e.name}`,children:t(a.BACKEND$VERSION_LABEL,{version:n})}):null}function O({backend:e,health:t,onEdit:n,onRemove:r}){let{t:i}=o(`openhands`);return(0,T.jsxs)(`li`,{className:`flex items-center gap-3 px-3 py-3`,"data-testid":`manage-backends-row-${e.name}`,children:[(0,T.jsx)(b,{isConnected:t?.isConnected??null}),(0,T.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,T.jsx)(`span`,{className:`truncate text-sm text-white`,children:e.name}),(0,T.jsx)(D,{backend:e})]}),(0,T.jsx)(`span`,{className:`truncate text-xs text-[var(--oh-muted)]`,children:e.host})]}),(0,T.jsx)(`span`,{className:`px-2 py-1 rounded-full text-[11px] uppercase tracking-wide text-[var(--oh-text-tertiary)] bg-[var(--oh-surface)] border border-[var(--oh-border)]`,children:e.kind===`cloud`?i(a.BACKEND$KIND_CLOUD):i(a.BACKEND$KIND_LOCAL)}),(0,T.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,T.jsx)(`button`,{type:`button`,onClick:n,"aria-label":i(a.BACKEND$EDIT),"data-testid":`manage-backends-edit-${e.name}`,className:E,children:(0,T.jsx)(s,{"aria-hidden":!0,className:`size-4`,strokeWidth:2})}),(0,T.jsx)(`button`,{type:`button`,onClick:r,"aria-label":i(a.BACKEND$REMOVE),"data-testid":`manage-backends-remove-${e.name}`,className:E,children:(0,T.jsx)(l,{"aria-hidden":!0,className:`size-4`,strokeWidth:2})})]})]})}function k({onClose:e}){let{t}=o(`openhands`),{backends:n,removeBackend:r}=f(),i=v(n,{probeDisabledOnce:!0}),[s,l]=w.useState(null),[d,p]=w.useState(null),[b,C]=w.useState(!1);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(m,{onClose:e,"aria-label":t(a.BACKEND$MANAGE_TITLE),children:(0,T.jsxs)(`div`,{"data-testid":`manage-backends-modal`,className:u(`relative flex flex-col bg-[var(--oh-surface)] border border-[var(--oh-border)] rounded-xl`,h(`lg`),g,`max-h-[70vh]`),children:[(0,T.jsx)(x,{onClose:e,testId:`close-manage-backends-modal`}),(0,T.jsx)(`div`,{className:`p-5 pr-12`,children:(0,T.jsx)(`h2`,{className:`text-lg font-semibold`,children:t(a.BACKEND$MANAGE_TITLE)})}),(0,T.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-5`,children:(0,T.jsx)(`div`,{className:`flex-1 overflow-auto rounded-md border border-[var(--oh-border)] bg-surface-raised custom-scrollbar-always`,"data-testid":`manage-backends-list`,children:n.length===0?(0,T.jsx)(`p`,{className:`px-3 py-6 text-center text-sm text-[var(--oh-text-secondary)]`,children:t(a.BACKEND$MANAGE_EMPTY)}):(0,T.jsx)(`ul`,{className:`divide-y divide-[var(--oh-border)]`,children:n.map(e=>(0,T.jsx)(O,{backend:e,health:i[e.id],onEdit:()=>p(e),onRemove:()=>l({id:e.id,name:e.name})},e.id))})})}),(0,T.jsxs)(`div`,{className:`flex justify-end gap-2 p-5`,children:[(0,T.jsx)(_,{type:`button`,variant:`secondary`,onClick:()=>C(!0),testId:`manage-backends-add`,startContent:(0,T.jsx)(c,{width:14,height:14}),children:t(a.BACKEND$ADD)}),(0,T.jsx)(_,{type:`button`,variant:`primary`,onClick:e,testId:`manage-backends-done`,children:t(a.HOME$DONE)})]})]})}),b?(0,T.jsx)(y,{mode:`add`,onClose:()=>C(!1)}):null,d?(0,T.jsx)(y,{mode:`edit`,backend:d,onClose:()=>p(null)}):null,s?(0,T.jsx)(S,{text:t(a.BACKEND$REMOVE_CONFIRMATION,{name:s.name}),onConfirm:()=>{s&&(r(s.id),l(null))},onCancel:()=>l(null)}):null]})}export{C as n,k as t};
|