openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.7 kB
JavaScript
import{l as normalizeOptionalString}from"./string-coerce-CpTFcSwY.mjs";import{r as defaultRuntime}from"./runtime-DIcLIHcp.mjs";import{r as terminalText}from"./safe-text-B_QTgn0s.mjs";import{t as ADMIN_SCOPE}from"./operator-scopes-bEvB7E5X.mjs";import"./method-scopes-Dalbwzsv.mjs";import{r as callGatewayFromCliWithTransport}from"./gateway-rpc-17pTfL8i.mjs";import{n as readUnlessAborted}from"./devices-cli-gateway-D1RnHrtd.mjs";
//!src/cli/devices-cli-join.ts
async function runDevicesJoinCodeCommand(e){const t=await readUnlessAborted(t=>callGatewayFromCliWithTransport(`device.pair.setupCode`,e,{bootstrapProfile:`node`,includeQr:false,joinUrl:true},{label:`Devices device.pair.setupCode`,defaultTimeoutMs:1e4,scopes:[ADMIN_SCOPE],sharedStateMode:`read-only`,signal:t}));if(!t)return;const n=normalizeOptionalString(t.joinUrl);if(!n)throw new Error(`Gateway did not return a device join URL.`);const r=normalizeOptionalString(t.command);const i=normalizeOptionalString(t.serviceCommand);const a=normalizeOptionalString(t.installedCommand);const o=normalizeOptionalString(t.versionNote);if(!r||!i||!a)throw new Error(`Gateway did not return device join commands. Update the Gateway and try again.`);if(e.json){defaultRuntime.writeJson({joinUrl:n,command:r,serviceCommand:i,installedCommand:a,...o?{versionNote:o}:{}});return}defaultRuntime.log(terminalText`${n}`);defaultRuntime.log(terminalText`${r}`);defaultRuntime.log(`Installs a background node service that can run agent sessions.`);defaultRuntime.log(terminalText`Command-only node: ${i}`);defaultRuntime.log(terminalText`Already have OpenClaw installed? Run: ${a}`);if(o)defaultRuntime.log(terminalText`${o}`)}export{runDevicesJoinCodeCommand};