agent-device
Version:
Open source device layer for AI coding agents: a CLI, MCP server, and typed Node.js API to control mobile, web, TV, and desktop apps on devices and simulators, locally or in the cloud.
2 lines • 1.35 kB
JavaScript
import{v as e}from"./sdk-contracts.js";import{h as t}from"./daemon-resolution.js";import{a as n,n as r,t as i}from"./auth-session.js";import{n as a}from"./shared.js";const o=async({positionals:o,flags:c,host:l})=>{let u=o[0]??`status`,d=t(c.stateDir,{cwd:l.cwd,env:l.env}).baseDir;if(u===`status`){let e=n({stateDir:d});return await a(c,e,()=>s(e)),!0}if(u===`login`){let e=await i({stateDir:d,flags:c,commandLabel:`agent-device auth login`,env:l.env}),t={authenticated:!0,source:`cli-session`,sessionId:e.session.id,cloudBaseUrl:e.session.cloudBaseUrl,workspaceId:e.session.workspaceId,accountId:e.session.accountId,expiresAt:e.session.expiresAt,agentTokenExpiresAt:e.expiresAt};return await a(c,t,()=>`Authenticated with cloud CLI session.`),!0}if(u===`logout`){let e=r({stateDir:d});return await a(c,{authenticated:!1,removed:e},()=>e?`Removed stored cloud CLI session.`:`No stored cloud CLI session.`),!0}throw new e(`INVALID_ARGS`,`auth accepts only: status, login, logout`)};function s(e){return e.authenticated?[`Authenticated with cloud CLI session.`,`cloud=${e.cloudBaseUrl}`,`session=${e.sessionId}`,e.workspaceId?`workspace=${e.workspaceId}`:null,e.accountId?`account=${e.accountId}`:null,e.expiresAt?`expiresAt=${e.expiresAt}`:null,e.expired?`status=expired`:null].filter(e=>!!e).join(`
`):`Not authenticated.`}export{o as authCommand};