openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 10.4 kB
JavaScript
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{Dt as t,Ot as n,Tt as r,jt as i,sa as a,va as o,ya as s}from"./control-ui-connection-Bfj9beF_.js";import{Ia as ee,Ik as te,La as ne,OE as re,Ra as ie,Rc as ae,TE as c,Vc as oe,Vk as se,aj as l,bv as u,c as d,dj as f,ej as p,gj as ce,hj as m,mj as le,pj as h,rg as ue,rj as de,tg as fe,tj as pe}from"./control-ui-boot-shared-DFTSUQQ0.js";import{B as g,Ct as me,F as _,J as he,P as ge,Rt as _e,U as ve,d as v,gt as ye,j as y,u as be,x as b}from"./solid-runtime-C416s-HC.js";import{X as xe,Y as x}from"./deferred-ui-support-D-VedBtc.js";import{h as S}from"./route-controls-runtime-Bx6nx3QW.js";import{n as Se,y as C}from"./settings-ui-Ck6BJLhD.js";import{n as Ce,t as w}from"./gateway-page-BGbclR08.js";import{_ as we,c as Te,f as Ee,i as T,n as De,o as Oe,r as ke,s as Ae,t as je,v as Me,y as Ne}from"./page-operations-CZNhzkUJ.js";import{a as Pe,o as E}from"./route-chrome-7YRVJwhf.js";import{n as D,t as O}from"./en-devices-aBltI3cs.js";import{a as Fe,c as k,d as Ie,f as A,i as j,l as Le,m as Re,n as M,o as N,p as P,r as ze,s as Be,t as Ve,u as F}from"./view-DG57BOOe.js";function I(e){let i=pe(),[a,ne]=g([],{ownedWrite:!0}),[ae,c]=g(null,{ownedWrite:!0}),[se,l]=g([],{ownedWrite:!0}),d=Re([]);function f(e){let t=Re(e),n=t!==d;return d=t,ne(e),n}let p=!1,m=ke(),h=(e=!1)=>tt(`devices`,e),[fe,ve]=g(null),[be,b]=g(null),x=!1,C=!1,w=!0,T=null,E=null,D=`gateway`,O=null,k=!1,A,j=ce(()=>m,e=>e()),M=j.publish,N=oe(i.runtimeConfig),P=Ie({canManagePairing:()=>z.connected&&x,gatewayConnected:()=>z.connected,gatewayClient:()=>z.client,gatewayUrl:()=>i.gateway.connection.gatewayUrl,runPageTask:K,runInventoryTask:e=>U.run(()=>K(e)).presented,rotateDevice:e=>U.run(()=>K(t=>we(t,e))).result,setDevicesError:e=>{m.devicesError=e,M()}}),F=S(()=>{},{task:async(e,{signal:t})=>z.connected&&w&&z.gateway?z.client?.request(`system-presence`,{},{signal:t}):void 0,onComplete:e=>{e!==void 0&&f(e)},onError:e=>{ue(e)&&f([])}}),I=S(()=>{},{task:async(e,{signal:t})=>z.gateway&&q()&&z.client?ie(z.gateway,t).then(e=>e.value):void 0,onComplete:e=>{e!==void 0&&(c(e),R.stop(),R.start())},onError:e=>{ue(e)&&(c(null),p=!0,R.stop())}}),L=S(()=>{},{task:async(e,{signal:t})=>z.gateway&&J()?z.client?.request(`environments.list`,{},{signal:t}):void 0,onComplete:e=>{e!==void 0&&l(e.environments)},onError:()=>l([])}),R=xe(6e4,Y),We=xe(3e4,()=>{X(!0),x&&h(!0)}),z=Ce({getGateway:()=>me(()=>i.gateway),onIdentityChange:e=>{T=null,E=null,Ze(e.snapshot)},invalidateRequests:Ye,onSnapshot:Je,ensureInitialData:$e}),B=Fe({state:j.read,config:()=>N.read().state,hasConfig:()=>at(V().state)!==null,gateway:z,target:()=>`${D}:${O??``}`}),Ge=_(()=>j.read().execApprovalsSnapshot),V=_(()=>N.read()),H=Be({scope:()=>({state:j.read(),gateway:z.gateway,epoch:z.epoch,target:D===`node`?O:null}),canSave:()=>C&&z.connected,canEdit:()=>C,runtimeConfig:()=>i.runtimeConfig,isCurrent:e=>e.state===m&&e.gateway===i.gateway&&e.epoch===z.readEpoch(),read:e=>e===`bindings`?V:Ge,run:e=>e===`bindings`?i.runtimeConfig.save():K(e=>Me(e,rt())),publish:()=>M()}),{scope:Ke,read:qe}=ze({scope:()=>({gateway:i.gateway,state:j.read(),epoch:z.epoch}),nodesRead:fe,devicesRead:be}),U=Le({scope:Ke,isCurrent:e=>e.gateway===i.gateway&&e.state===m&&e.epoch===z.epoch,read:qe,publish:()=>M()});ye(()=>{i.runtimeConfig.ensureLoaded().catch(()=>void 0),W();let e=N.subscribe(W),t=i.router.subscribe(()=>{U.retire(),m.devicesDeciding=[],M();let e=i.router.getState();(e.pendingMatches[0]??e.matches[0])?.routeId!==`devices`&&H.retire()});return()=>{H.retire(),U.retire(),t(),e(),A?.(),P.cancel(),F.cancel(),I.cancel(),L.cancel(),x=!1,C=!1}});function W(){te(i.runtimeConfig.state)&&(T=z.gateway,E=z.client)}function Je(e){let t=e.snapshot;if(m.client=t.client,m.connected=t.phase===`connected`,m.requestGeneration=z.epoch,e.becameConnected&&(p=!1),G(t),W(),e.initial||e.sourceChanged){A?.();let e=i.gateway;A=e.subscribeEvents(t=>{if(z.gateway!==e||i.gateway!==e)return;let n=t.event===`presence`?u(t.payload):null;n&&w&&(F.cancel(),f(n)&&(x&&h(!0),X(!0))),(t.event===`device.pair.changed`||t.event===`device.pair.requested`||t.event===`device.pair.resolved`)&&x&&h(!0),(t.event===`node.pair.requested`||t.event===`node.pair.resolved`||t.event===`node.runnerInventory.changed`||t.event===`node.hostStats`)&&X(!0)})}if(e.identityChanged&&Z(),t.phase===`connected`&&!q()&&(I.cancel(),c(null)),t.phase===`connected`&&!J()&&(L.cancel(),l([])),k&&t.phase===`connected`&&t.client&&(e.identityChanged||e.connectionChanged)){let e=u(t.hello?.snapshot);e&&w&&f(e),F.run(),X(!0),x&&h(!0)}(e.initial||e.identityChanged||e.connectionChanged)&&(Y(),J()&&L.run()),et(),M()}function Ye(){m.devicesDeciding=[],H.retire(),U.retire(),m.requestGeneration=z.epoch,m.nodesLoading=!1,m.nodesQueuedRefresh=`none`,m.devicesLoading=!1,m.devicesQueuedRefresh=`none`,m.execApprovalsLoading=!1,m.execApprovalsSaving=!1,F.cancel(),I.cancel(),L.cancel()}function G(e){if(e.phase!==`connected`)return;let i=e.hello?.auth??null,a=n(i),o=r(i),s=!i||t(i);(w&&!a||C&&!o||x&&!s)&&(z.invalidate(),Ye()),w=a,C=o,x=s,w||(m.nodes=[],Z()),x||(m.devicesList=null,m.devicesError=null,P.cancel()),C||(m.execApprovalsSnapshot=null,m.execApprovalsForm=null,m.execApprovalsDirty=!1,m.execApprovalsSelectedAgent=null)}function Xe(e){if(!e)return;k=!0;let t=i.gateway.snapshot;if(!z.isRouteDataCurrent(e)){Ze(t),G(t),Z(),w&&f(u(t.hello?.snapshot)??[]),F.run();return}H.retire(),m={...e.devices,client:t.client,connected:t.phase===`connected`,requestGeneration:z.epoch},G(t);let n=u(t.hello?.snapshot);n&&w&&f(n),F.run()}function Ze(e){H.retire(),U.retire(),P.cancel(),m.requestGeneration+=1;let t=ke({client:e.client,connected:e.phase===`connected`});t.requestGeneration=z.epoch,m=t,F.cancel(),I.cancel(),L.cancel(),R.stop(),p=!1,w=!1,C=!1,x=!1,D=`gateway`,O=null}async function K(e){let t=m;try{let n=e(t);return m===t&&M(),await n}finally{m===t&&M()}}function Qe(e){C&&K(e)}function $e(){let e=m;if(!e.connected||!e.client||!k)return;w&&!e.nodes.length&&!e.nodesLoading&&X(),x&&!e.devicesList&&!e.devicesLoading&&h();let t=i.runtimeConfig.state;!t.configSnapshot&&!t.configLoading&&i.runtimeConfig.refresh(),C&&!e.execApprovalsSnapshot&&!e.execApprovalsLoading&&it()}function et(){q()?R.start():R.stop(),z.connected&&z.client&&w?We.start():We.stop()}function q(){let e=z.snapshot;return z.connected&&!p&&ee(e)}function J(){let e=z.snapshot;return z.connected&&!!(e&&re(e))}function Y(){q()&&!I.pending&&I.run()}function tt(e,t){let n=i.gateway,r=m,a=z.epoch,o=e===`nodes`?r.nodesLoading:r.devicesLoading,s=K(n=>e===`nodes`?Te(n,{quiet:t}):Oe(n,{quiet:t}));return o||(e===`nodes`?ve:b)({gateway:n,state:r,epoch:a,result:s}),s}function X(e=!1){w&&(Y(),J()&&!L.pending&&L.run(),tt(`nodes`,e))}function Z(){f([]),c(null),l([])}async function nt(e,t){let n=m;n.execApprovalsDirty&&!await P.confirmExecApprovalsDiscard()?M():m===n&&(H.retire(),D=e,O=t,n.execApprovalsSnapshot=null,n.execApprovalsForm=null,n.execApprovalsDirty=!1,n.execApprovalsSelectedAgent=null,M())}function rt(){return D===`node`&&O?{kind:`node`,nodeId:O}:{kind:`gateway`}}function it(){if(!C||m.execApprovalsLoading)return;let e=m,t=K(e=>Ae(e,rt()));B.observeApprovals(e,t)}function at(e){return w?te(e)??(T===z.gateway&&E===z.client?e.configForm:null):null}function ot(){let e=j.read(),t=V().state,n=z.snapshot??i.gateway.snapshot;return{configRead:B.config,execApprovalsRead:B.approvals,loading:e.nodesLoading,inventoryRead:qe,inventoryScope:Ke(),onReloadInventory:()=>{X(),x&&h()},connected:z.connected,nodes:e.nodes,presence:a(),gatewayVersion:n.hello?.server?.version?.trim()||null,basePath:i.basePath,gatewaySystemInfo:ae(),desktopEnvironments:se(),lastError:e.lastError,devicesLoading:e.devicesLoading,devicesError:e.devicesError,devicesList:e.devicesList,devicesDeciding:e.devicesDeciding,canPairDevice:C,canManagePairing:x,canAdmin:C,configForm:at(t),configLoading:t.configLoading,configSaving:t.configSaving,configDirty:t.configFormDirty,configFormMode:t.configFormMode,execApprovalsLoading:e.execApprovalsLoading,execApprovalsSaving:e.execApprovalsSaving,execApprovalsDirty:e.execApprovalsDirty,execApprovalsSnapshot:Ge(),execApprovalsForm:e.execApprovalsForm,execApprovalsSelectedAgent:e.execApprovalsSelectedAgent,execApprovalsTarget:D,execApprovalsTargetNodeId:O,onDevicePairSetupOpen:()=>{C&&z.connected&&i.overlays.openDevicePairSetup()},onDeviceApprove:e=>{x&&K(t=>je(t,e))},onDeviceReject:e=>void P.confirmPairingReject(`device`,e),onNodeApprove:e=>{x&&K(t=>De(t,e))},onNodeReject:e=>void P.confirmPairingReject(`node`,e),onInventoryRemove:e=>void P.confirmInventoryRemoval({kind:`entry`,entry:e}),onInventoryCleanup:e=>{e.length>0&&P.confirmInventoryRemoval({kind:`stale`,entries:e})},onDeviceRotate:(e,t,n)=>void P.reportRotationOutcome(e,t,n),onDeviceRevoke:(e,t)=>void P.confirmTokenRevoke(e,t),onDeviceRename:e=>void P.editAlias(e),onLoadConfig:()=>void i.runtimeConfig.discardDraft({reloadOnly:!0}),onLoadExecApprovals:it,onBindDefault:e=>H.bindNode(e),onBindAgent:(e,t)=>H.bindNode(t,e),onSaveBindings:()=>void H.save(`bindings`),onExecApprovalsTargetChange:(e,t)=>void nt(e,t),onExecApprovalsSelectAgent:t=>{e.execApprovalsSelectedAgent=t,M()},onExecApprovalsPatch:(e,t)=>Qe(n=>Ne(n,e,t)),onExecApprovalsRemove:e=>Qe(t=>Ee(t,e)),onSaveExecApprovals:()=>void H.save(`approvals`)}}let Q=_(ot);ge(_(()=>e.routeData),e=>{Xe(e),e&&z.connected&&z.isRouteDataCurrent(e)&&i.runtimeConfig.refresh({background:!0}).catch(()=>void 0),$e(),M()});var $=Ue(),st=$.firstChild,ct=st.nextSibling;return $._$owner=_e(),v($,y(de,{traits:{toolbarHeader:!0},get children(){var e=He(),t=e.firstChild.firstChild,n=t.nextSibling,r=n.firstChild,i=r.nextSibling;return v(t,()=>s(`devices`,le)),v(n,()=>o(`devices`,le),r),v(n,y(Se,{url:`https://docs.openclaw.ai/nodes`}),i),e}}),st),v($,y(Pe,{get children(){return y(Ve,he(Q,{get inventorySaving(){return U.saving()},get configSaving(){return H.configSaving()||Q().configSaving},get execApprovalsSaving(){return H.approvalsSaving()||Q().execApprovalsSaving}}))}}),ct),$}var He,Ue;function L(){return(L=e((()=>{be(),ve(),d(),a(),i(),c(),l(),C(),E(),O(),se(),fe(),P(),T(),p(),ae(),w(),f(),m(),x(),ne(),A(),F(),k(),N(),j(),M(),He=b(`<section class=content-header><div><h1 class=page-title></h1><div class=page-subtitle> <!>`),Ue=b(`<openclaw-devices-page><!><!>`,1),h(D)})))()}export{L as n,I as t};