openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
2 lines • 6.29 kB
JavaScript
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./session-placement-move-dialog-Dt1_ORad.js","./lit-runtime-IOnANfcZ.js","./gateway-runtime-C77LeWZN.js","./session-snapshot-database-BBKeXATO.js","./control-ui-boot-shared-gZIpWrfw.js","./control-ui-boot-shared-CkXlyZBY.js","./control-ui-boot-shared-SQHdJTzb.js","./control-ui-boot-shared-VLPz5vN2.js","./plugin-contracts-runtime-ByiEPbv_.js","./control-ui-boot-shared-Q8KG_noF.js","./config-runtime-BecGLziM.js","./markdown-runtime-ORQpioyT.js","./control-ui-boot-shared-dOnP4mAA.js","./control-ui-boot-shared-styles-BXPMRytW.js","./sidebar-update-runtime-DQZboSgD.js","./chat-transcript-styles-BN-TorbW.js","./control-ui-boot-new-styles-cChqenO3.js","./control-ui-core-DI-Q_yCI.css","./control-ui-boot-shared-styles-DUf4zEvn.css","./control-ui-boot-shared-DIWJGbGi.css","./sidebar-update-runtime-Bpn2ByHA.css","./chat-transcript-styles-B0IJwY9P.css","./control-ui-boot-new-styles-BS7lzENV.css","./control-ui-boot-new-D-SpiTTi.css"])))=>i.map(i=>d[i]);
import{n as e}from"./rolldown-runtime-8BhlS34s.js";import{Hr as t,Pu as n,Vr as r,kl as i,zl as a,zu as o}from"./control-ui-core-CBJ5efDh.js";import{wr as s,yr as c}from"./control-ui-core-DtLivg_r.js";import{ga as l,ha as u}from"./control-ui-boot-shared-UG5ko-VG.js";import{ma as d,pa as f}from"./ui-CmSP4d14.js";import{Jn as p,Yn as m,na as h,ta as g}from"./control-ui-boot-shared-XreXSF7h.js";import{f as _,h as v,p as y}from"./control-ui-boot-chat-BD9CwLj7.js";import{X as b,Y as x,ct as S,lt as C,rt as w,st as T}from"./control-ui-boot-new-CkyIHJ_L.js";import{n as E,t as D}from"./cloud-worker-stop.runtime-B791S2pQ.js";async function O(e){let{showSessionPlacementTargetDialog:n}=await f(async()=>{let{showSessionPlacementTargetDialog:e}=await import(`./session-placement-move-dialog-Dt1_ORad.js`);return{showSessionPlacementTargetDialog:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]),import.meta.url),r=e.row.agentRuntime,i=t(e.gatewaySnapshot,{method:e.mode===`restart`?`sessions.reclaim`:`sessions.move`,requiredScope:`operator.write`}),a=t(e.gatewaySnapshot,{method:e.mode===`move`?`sessions.move`:`sessions.dispatch`,requiredScope:`operator.write`});return n({mode:e.mode,sessionLabel:e.row.label||e.row.key,activeRun:e.row.hasActiveRun===!0,gatewayDisabledReason:i.allowed?void 0:i.reason,deviceDisabledReason:a.allowed?r&&!r.devicePlacement?o(`newSession.deviceRuntimeUnsupported`):void 0:a.reason,profileDisabledReason:e=>a.allowed?r?.cloudPlacementSupported===!1?o(`newSession.cloudRuntimeUnsupported`,{runtime:r.id}):r?.cloudPlacementExecutionMode&&!S(e,r.cloudPlacementExecutionMode)?o(`newSession.cloudProfileRuntimeUnsupported`,{runtime:r.id}):void 0:a.reason,loadCatalog:async()=>{let t=await T(e.client,r?.id);return{profiles:c(e.gatewaySnapshot.hello?.auth??null)?t.profiles:[],devices:b(t.environments,r?.devicePlacement)}}})}async function k(e){let n=e.client,r=e.row.placement,i=e.mode===`move`&&r?.state===`active`?r:void 0,s=r?.state===`failed`&&r.recoveryAction===`restart`?r:void 0,c=y(e.row);if(!n||e.pendingKey===e.row.key||(e.mode===`move`?!i||e.row.placementMove!==void 0&&e.row.placementMove.error===void 0:e.row.archived===!0||!s&&!c))return;let l=t(e.gatewaySnapshot,{method:e.mode===`move`?`sessions.move`:`sessions.dispatch`,requiredScope:`operator.write`}),u=t(e.gatewaySnapshot,{method:`sessions.reclaim`,requiredScope:`operator.write`});if(!l.allowed&&(e.mode===`move`||!s||!u.allowed)){e.publishError(l.reason);return}let d=i?.runner?.kind===`device`&&i.runner.status===`offline`,f;if(f=d?await h({message:o(`sessionsView.continueOnGatewayConfirm`,{session:e.row.label||e.row.key}),confirmLabel:o(`sessionsView.continueOnGatewayAction`),danger:!0})?{kind:`gateway`}:null:await O({client:n,gatewaySnapshot:e.gatewaySnapshot,mode:e.mode===`move`?`move`:c?`dispatch`:`restart`,row:e.row}),!f)return;if(!e.isCurrent()){e.publishError(o(`sessionsView.actionUnavailable`));return}if(e.mode===`recover`){let t=e.currentRow(),n=t?.placement,r=n?.state===`failed`&&n.recoveryAction===`restart`&&n.generation===s?.generation;if(!t||t.key!==e.row.key||t.sessionId!==e.row.sessionId||t.repositoryWorkspaceId!==e.row.repositoryWorkspaceId||t.archived===!0||(c?!y(t):!r)){e.publishError(o(`sessionsView.actionUnavailable`));return}}let p=a(e.row.key)?.agentId,m={key:e.row.key,...p?{agentId:p}:{}};e.onPendingChange(e.row.key);try{if(i)await n.request(`sessions.move`,{...m,expected:{generation:i.generation,environmentId:i.environmentId,ownerEpoch:i.activeOwnerEpoch},target:f,...d?{abandonSource:!0}:{}});else if(f.kind===`gateway`){if(!s){e.publishError(o(`sessionsView.actionUnavailable`));return}await n.request(`sessions.reclaim`,{...m,recoverToGateway:{expectedGeneration:s.generation}},{timeoutMs:null})}else await n.request(`sessions.dispatch`,{...m,...f.kind===`profile`?{profileId:f.profileId,...f.os?{os:f.os}:{},...f.machineClass?{machineClass:f.machineClass}:{}}:{deviceId:f.deviceId}});if(e.isCurrent()){let t=await e.reconcileMutation(p);t.status===`failed`&&e.isCurrent()&&e.publishError(t.error)}}catch(t){e.isCurrent()&&(await e.reconcileMutation(p).catch(()=>void 0),e.isCurrent()&&e.publishError(t))}finally{e.onPendingChange(null),e.requestUpdate()}}async function A(e){let n=e.client,r=m(e.row.placement),i=e.reclaimingKey===e.row.key,s=e.row.placement,c=s?.state===`active`&&s.runner?.kind===`device`&&s.runner.status===`offline`;if(!n||i||c||r?.blocksActiveRun&&e.row.hasActiveRun===!0||!r)return;let l=t(e.gatewaySnapshot,r);if(!l.allowed){e.publishError(l.reason);return}let u=v(e.row,e.placementStartup.get(e.row.key));if(!await h({message:u.confirmMessage,confirmLabel:u.confirmLabel,danger:!0}))return;if(!e.isCurrent()){e.publishError(o(`sessionsView.actionUnavailable`));return}let d=a(e.row.key)?.agentId;e.onReclaimingChange(e.row.key);try{if(await E(n,{key:e.row.key,...d?{agentId:d}:{}},e.placementStartup),e.isCurrent()){let t=await e.reconcileMutation(d);t.status===`failed`&&e.isCurrent()&&e.publishError(t.error)}}catch(t){e.isCurrent()&&e.publishError(t)}finally{e.onReclaimingChange(null),e.requestUpdate()}}function j(){return(j=e((()=>{s(),D(),p(),g(),n(),u(),r(),i(),w(),x(),C(),_(),d(),l()})))()}j();export{k as changeChatPanePlacement,A as reclaimChatPanePlacement};