Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

feat(os): sign a Harness OS computer in to GitHub from the phone (#1804)

Bubu-Dudu-52hzebd1b7966d88
diff --git a/cli/src/services/osDevice.spec.ts b/cli/src/services/osDevice.spec.ts
index 9065e12fa..67991cc06 100644
--- a/cli/src/services/osDevice.spec.ts
+++ b/cli/src/services/osDevice.spec.ts
@@ -3,7 +3,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
import { encryptDownFrame, encryptRpcResult } from '../lib/e2ee/applicationFrames.js'
import { fakeCore } from '../testing/fakeCore.js'
import {
- activeSsid, CMDLINE, execBounded, joinRequest, LIVE_UPDATE, MAX_OUTPUT, nmcliFields, OS_DEVICE_REQUESTS, SETUP, SETUP_RESULT, spawnDetached,
+ activeSsid, CMDLINE, deviceCodeOf, execBounded, GH, githubDeviceSignIn, githubLoginOf, joinRequest, LIVE_UPDATE, MAX_OUTPUT, nmcliFields, OS_DEVICE_REQUESTS, SETUP, SETUP_RESULT, spawnDetached,
startOsDevice, UPDATE_BUSY_MS, updateOf, wifiNetworks, type OsDeviceDeps,
} from './osDevice.js'
@@ -77,7 +77,7 @@ describe('the Harness OS computer, managed from the phone', () => {
cli: { running: '0.9.1', available: true, next: null },
},
},
- wifi: { ssid: 'Home: 5G' }, hotspot: 'Harness-BD19', encrypted: true, features: ['sign_out', 'password', 'ssh'],
+ wifi: { ssid: 'Home: 5G' }, hotspot: 'Harness-BD19', encrypted: true, features: ['sign_out', 'password', 'ssh', 'github'],
})
expect(exec).toHaveBeenCalledWith('/usr/bin/python3', [LIVE_UPDATE, 'status'], { timeout: 15_000 })
expect(exec).toHaveBeenCalledWith('/usr/bin/python3', [SETUP, 'name'], { timeout: 10_000 })
@@ -88,8 +88,8 @@ describe('the Harness OS computer, managed from the phone', () => {
it('still answers on Harness OS when its update tool or nmcli fails', async () => {
const failing = (reason: unknown) => service({ exec: vi.fn(async () => { throw reason }) }).ask({ action: 'status' })
- expect(await failing(new Error('Command failed: python3\nTraceback ...'))).toEqual({ harnessOs: true, update: { available: false, error: 'Command failed: python3' }, wifi: { ssid: null }, hotspot: null, encrypted: true, features: ['sign_out', 'password', 'ssh'] })
- expect(await failing('killed')).toEqual({ harnessOs: true, update: { available: false, error: 'killed' }, wifi: { ssid: null }, hotspot: null, encrypted: true, features: ['sign_out', 'password', 'ssh'] })
+ expect(await failing(new Error('Command failed: python3\nTraceback ...'))).toEqual({ harnessOs: true, update: { available: false, error: 'Command failed: python3' }, wifi: { ssid: null }, hotspot: null, encrypted: true, features: ['sign_out', 'password', 'ssh', 'github'] })
+ expect(await failing('killed')).toEqual({ harnessOs: true, update: { available: false, error: 'killed' }, wifi: { ssid: null }, hotspot: null, encrypted: true, features: ['sign_out', 'password', 'ssh', 'github'] })
const notJson = service({ exec: vi.fn(async () => 'not json') })
expect(await notJson.ask({ action: 'status' })).toMatchObject({ update: { available: false, error: expect.stringContaining('JSON') } })
const notObject = service({ exec: vi.fn(async () => '[1]') })
@@ -252,6 +252,135 @@ describe('the Harness OS computer, managed from the phone', () => {
])
})
+ describe('GitHub, for the agents to clone, push and open pull requests with', () => {
+ const SIGNED_IN = JSON.stringify({ hosts: { 'github.com': [{ state: 'success', active: true, host: 'github.com', login: 'octo' }] } })
+ const SIGNED_OUT = JSON.stringify({ hosts: {} })
+
+ /** A `gh auth login` that shows [code] and ends when the test says. */
+ function signIn(code = { code: 'AB12-CD34', url: 'https://github.com/login/device' }) {
+ let end!: (error?: Error) => void
+ const done = new Promise<void>((resolve, reject) => { end = (error) => error ? reject(error) : resolve() })
+ done.catch(() => {})
+ const run = { code: Promise.resolve(code), done, stop: vi.fn() }
+ return { run, end }
+ }
+
+ function github(over: OsDeviceDeps = {}) {
+ let account = SIGNED_OUT
+ const exec = vi.fn(async (_file: string, args: readonly string[]) => {
+ if (args[1] === 'logout') account = SIGNED_OUT
+ return args[1] === 'status' ? account : ''
+ })
+ const login = signIn()
+ const githubSignIn = vi.fn(() => login.run)
+ const { ask } = service({ exec, githubSignIn, ...over })
+ return { ask, exec, githubSignIn, login, signInAs: (name: string) => { account = SIGNED_IN.replace('octo', name) } }
+ }
+
+ it('says which account it uses, or none', async () => {
+ const { ask, signInAs } = github()
+ expect(await ask({ action: 'github' })).toEqual({ login: null })
+ signInAs('octo')
+ expect(await ask({ action: 'github', state: 'status' })).toEqual({ login: 'octo' })
+ })
+
+ it('reads an account whose token stopped working, or one not active, as signed out', () => {
+ expect(githubLoginOf(SIGNED_IN)).toBe('octo')
+ expect(githubLoginOf(SIGNED_IN.replace('success', 'error'))).toBeNull()
+ expect(githubLoginOf(SIGNED_IN.replace('"active":true', '"active":false'))).toBeNull()
+ expect(githubLoginOf('{}')).toBeNull()
+ })
+
+ it('signs in with a code to enter on another device, then sets git up to use the account', async () => {
+ vi.spyOn(console, 'log').mockImplementation(() => {})
+ const { ask, exec, githubSignIn, login, signInAs } = github()
+ const waiting = { login: null, signingIn: { code: 'AB12-CD34', url: 'https://github.com/login/device' } }
+ expect(await ask({ action: 'github', state: 'sign_in' })).toEqual(waiting)
+ // Asked again, the same code: one sign-in at a time.
+ expect(await ask({ action: 'github', state: 'sign_in' })).toEqual(waiting)
+ expect(await ask({ action: 'github' })).toEqual(waiting)
+ expect(githubSignIn).toHaveBeenCalledTimes(1)
+ signInAs('octo')
+ login.end()
+ await vi.waitFor(() => expect(exec).toHaveBeenCalledWith(GH, ['auth', 'setup-git', '--hostname', 'github.com'], { timeout: 15_000 }))
+ expect(await ask({ action: 'github' })).toEqual({ login: 'octo' })
+ })
+
+ it('starts one sign-in for two asks at once, while its code is on its way', async () => {
+ vi.spyOn(console, 'log').mockImplementation(() => {})
+ let show!: (code: { code: string; url: string }) => void
+ const run = { code: new Promise<{ code: string; url: string }>((resolve) => { show = resolve }), done: new Promise<void>(() => {}), stop: vi.fn() }
+ const githubSignIn = vi.fn(() => run)
+ const { ask } = github({ githubSignIn })
+ const first = ask({ action: 'github', state: 'sign_in' })
+ const second = ask({ action: 'github', state: 'sign_in' })
+ show({ code: 'AB12-CD34', url: 'https://github.com/login/device' })
+ const waiting = { login: null, signingIn: { code: 'AB12-CD34', url: 'https://github.com/login/device' } }
+ expect(await first).toEqual(waiting)
+ expect(await second).toEqual(waiting)
+ expect(githubSignIn).toHaveBeenCalledTimes(1)
+ })
+
+ it('sets git up once the code was entered', async () => {
+ vi.spyOn(console, 'log').mockImplementation(() => {})
+ const { ask, exec, login, signInAs } = github()
+ await ask({ action: 'github', state: 'sign_in' })
+ signInAs('octo')
+ login.end()
+ await vi.waitFor(() => expect(exec).toHaveBeenCalledWith(GH, ['auth', 'setup-git', '--hostname', 'github.com'], { timeout: 15_000 }))
+ expect(await ask({ action: 'github' })).toEqual({ login: 'octo' })
+ })
+
+ it('says why a sign-in ended without signing in, until the next one', async () => {
+ vi.spyOn(console, 'log').mockImplementation(() => {})
+ const { ask, login } = github()
+ await ask({ action: 'github', state: 'sign_in' })
+ login.end(new Error('error: access denied'))
+ await vi.waitFor(async () => expect(await ask({ action: 'github' })).toEqual({ login: null, signInError: 'error: access denied' }))
+ })
+
+ it('gives up on a sign-in that shows no code', async () => {
+ vi.useFakeTimers()
+ vi.spyOn(console, 'error').mockImplementation(() => {})
+ const stop = vi.fn()
+ const { ask } = github({ githubSignIn: () => ({ code: new Promise(() => {}), done: new Promise(() => {}), stop }) })
+ const answer = ask({ action: 'github', state: 'sign_in' })
+ await vi.advanceTimersByTimeAsync(15_000)
+ expect(await answer).toEqual({ error: 'FAILED', message: 'gh auth login did not show a code' })
+ expect(stop).toHaveBeenCalled()
+ vi.useRealTimers()
+ })
+
+ it('signs out of the account it uses, and stops a sign-in waiting', async () => {
+ vi.spyOn(console, 'log').mockImplementation(() => {})
+ const { ask, exec, login, signInAs } = github()
+ await ask({ action: 'github', state: 'sign_in' })
+ expect(await ask({ action: 'github', state: 'sign_out' })).toEqual({ login: null })
+ expect(login.run.stop).toHaveBeenCalled()
+ signInAs('octo')
+ expect(await ask({ action: 'github', state: 'sign_out' })).toEqual({ login: null })
+ expect(exec).toHaveBeenCalledWith(GH, ['auth', 'logout', '--hostname', 'github.com', '--user', 'octo'], { timeout: 15_000 })
+ })
+
+ it('says so on a computer without the GitHub CLI', async () => {
+ const { ask, githubSignIn } = github({ exists: (path) => path !== GH })
+ const missing = { error: 'GH_MISSING', message: 'The GitHub CLI is not on this computer yet: update it first.' }
+ expect(await ask({ action: 'github' })).toEqual(missing)
+ expect(await ask({ action: 'github', state: 'sign_in' })).toEqual(missing)
+ expect(githubSignIn).not.toHaveBeenCalled()
+ })
+
+ it('finds the code and the page in what gh prints', () => {
+ expect(deviceCodeOf('! First copy your one-time code: B4B9-2B70\nOpen this URL to continue in your web browser: https://github.com/login/device\n'))
+ .toEqual({ code: 'B4B9-2B70', url: 'https://github.com/login/device' })
+ expect(deviceCodeOf('! First copy your one-time code: B4B9-2B70\n')).toEqual({ code: 'B4B9-2B70', url: 'https://github.com/login/device' })
+ // Where gh found a clipboard (a Harness OS screen), it says it another way (gh 2.102, seen on one).
+ expect(deviceCodeOf('! One-time code (8856-2E47) copied to clipboard\nOpen this URL to continue in your web browser: https://github.com/login/device\n'))
+ .toEqual({ code: '8856-2E47', url: 'https://github.com/login/device' })
+ expect(deviceCodeOf('Press Enter to open github.com')).toBeNull()
+ })
+ })
+
it('runs on the real filesystem and environment by default', async () => {
vi.stubEnv('HARNESS_OS', '')
const requests = startOsDevice(fakeCore())
@@ -302,4 +431,40 @@ describe('the defaults that run commands', () => {
expect(child.spawn).toHaveBeenLastCalledWith('/usr/bin/harness', ['update'], { detached: true, stdio: ['ignore', 'ignore', 'ignore'] })
expect(bare.unref).toHaveBeenCalled()
})
+
+ function ghProcess() {
+ const proc = Object.assign(new EventEmitter(), { stdout: new EventEmitter(), stderr: new EventEmitter(), kill: vi.fn() })
+ child.spawn.mockReturnValueOnce(proc)
+ return proc
+ }
+
+ it('runs gh\'s device sign-in with no browser and no questions, the code read as it prints', async () => {
+ vi.stubEnv('WAYLAND_DISPLAY', 'wayland-0')
+ vi.stubEnv('DISPLAY', ':0')
+ const proc = ghProcess()
+ const run = githubDeviceSignIn()
+ const { env } = child.spawn.mock.calls[0][2] as { env: Record<string, string | undefined> }
+ expect(env).not.toHaveProperty('WAYLAND_DISPLAY')
+ expect(env).not.toHaveProperty('DISPLAY')
+ vi.unstubAllEnvs()
+ expect(child.spawn).toHaveBeenCalledWith(GH, ['auth', 'login', '--hostname', 'github.com', '--git-protocol', 'https', '--web', '--skip-ssh-key'],
+ expect.objectContaining({ stdio: ['ignore', 'pipe', 'pipe'], env: expect.objectContaining({ BROWSER: 'true', GH_PROMPT_DISABLED: '1' }) }))
+ proc.stderr.emit('data', Buffer.from('! First copy your one-time code: '))
+ proc.stderr.emit('data', Buffer.from('B4B9-2B70\nOpen this URL to continue in your web browser: https://github.com/login/device\n'))
+ await expect(run.code).resolves.toEqual({ code: 'B4B9-2B70', url: 'https://github.com/login/device' })
+ proc.emit('close', 0)
+ await expect(run.done).resolves.toBeUndefined()
+ })
+
+ it('ends a device sign-in that failed with gh\'s last line, and stops one on request', async () => {
+ const failed = ghProcess()
+ const run = githubDeviceSignIn()
+ failed.stderr.emit('data', Buffer.from('error connecting to github.com\n'))
+ failed.emit('close', 1)
+ await expect(run.code).rejects.toThrow('error connecting to github.com')
+ await expect(run.done).rejects.toThrow('error connecting to github.com')
+ const stopped = ghProcess()
+ githubDeviceSignIn().stop()
+ expect(stopped.kill).toHaveBeenCalledWith('SIGKILL')
+ })
})
diff --git a/cli/src/services/osDevice.ts b/cli/src/services/osDevice.ts
index ae06e3617..a0ad96be3 100644
--- a/cli/src/services/osDevice.ts
+++ b/cli/src/services/osDevice.ts
@@ -1,6 +1,7 @@
/**
* A Harness OS computer, managed from the owner's phone (`os_device`): whether this computer runs Harness OS,
- * whether an update is ready and starting it, the Wi-Fi networks it sees, and moving it to another one.
+ * whether an update is ready and starting it, the Wi-Fi networks it sees, and moving it to another one, and
+ * the GitHub account its agents use (`github`: a device code entered on the phone, no screen needed here).
*
* Owner only. Everything it runs is bounded in time and output, and what must outlive this daemon runs
* detached in a process group of its own: the update restarts the daemon, and joining another Wi-Fi drops the
@@ -35,7 +36,12 @@ export const NMCLI_TIMEOUT_MS = 10_000
export const SCAN_TIMEOUT_MS = 20_000
/** The disk's key slots are slow to change on purpose (a passphrase is hashed for seconds), twice. */
export const PASSWORD_TIMEOUT_MS = 90_000
-const ACTIONS = ['update', 'wifi_scan', 'wifi_join', 'wifi_result', 'sign_out', 'password', 'ssh']
+/** The GitHub CLI, in the image and a dependency of the harness-os package (os/tools/build-package.py). */
+export const GH = '/usr/bin/gh'
+export const GH_TIMEOUT_MS = 15_000
+/** How long a GitHub sign-in waits for its code to be entered: GitHub's device codes last 15 minutes. */
+export const GITHUB_SIGN_IN_MS = 15 * 60_000
+const ACTIONS = ['update', 'wifi_scan', 'wifi_join', 'wifi_result', 'sign_out', 'password', 'ssh', 'github']
/** The most output a command run here may print before it is stopped. */
export const MAX_OUTPUT = 1024 * 1024
@@ -51,9 +57,70 @@ export interface OsDeviceDeps {
exec?: (file: string, args: readonly string[], options: ExecOptions) => Promise<string>
/** Start [file] detached from this daemon (its own process group, no output), [input] written to its stdin. */
spawnDetached?: (file: string, args: readonly string[], input?: string) => void
+ /** Start `gh auth login`'s device flow (a code to enter at github.com/login/device). */
+ githubSignIn?: () => GithubSignIn
now?: () => number
}
+/** A `gh auth login` under way: the code it shows, and it ending once the code was entered (or refused). */
+export interface GithubSignIn {
+ code: Promise<{ code: string; url: string }>
+ done: Promise<void>
+ stop: () => void
+}
+
+/** The code and the page in `gh auth login --web`'s output: "First copy your one-time code: AB12-CD34", or
+ * "One-time code (AB12-CD34) copied to clipboard" where it found a clipboard. */
+export function deviceCodeOf(output: string): { code: string; url: string } | null {
+ const code = /one-time code\W*([A-Z0-9]{4}-[A-Z0-9]{4})/i.exec(output)?.[1]
+ if (!code) return null
+ return { code, url: /https:\/\/\S+\/login\/device/.exec(output)?.[0] ?? 'https://github.com/login/device' }
+}
+
+/** The account `gh` uses on github.com, from `gh auth status --json hosts`; null when signed out or its
+ * token no longer works. */
+export function githubLoginOf(out: string): string | null {
+ const parsed: unknown = JSON.parse(out)
+ const hosts = record(parsed) && record(parsed.hosts) ? parsed.hosts : {}
+ const accounts = Array.isArray(hosts['github.com']) ? hosts['github.com'] : []
+ const active = accounts.find((a: unknown) => record(a) && a.active === true)
+ return record(active) && active.state === 'success' && typeof active.login === 'string' ? active.login : null
+}
+
+/** `gh auth login`'s device flow, bounded by GITHUB_SIGN_IN_MS. BROWSER=true: the page opens on the phone,
+ * not on this computer's screen; its stdin closed, it asks nothing and prints the code. Without the
+ * screen's display either: the code is the phone's to copy, not this computer's clipboard. */
+export function githubDeviceSignIn(): GithubSignIn {
+ const { WAYLAND_DISPLAY: _wayland, DISPLAY: _x11, ...env } = process.env
+ const child = spawn(GH, ['auth', 'login', '--hostname', 'github.com', '--git-protocol', 'https', '--web', '--skip-ssh-key'],
+ { stdio: ['ignore', 'pipe', 'pipe'], env: { ...env, BROWSER: 'true', GH_PROMPT_DISABLED: '1' } })
+ let output = ''
+ let shown: (value: { code: string; url: string }) => void
+ let failed: (error: Error) => void
+ const code = new Promise<{ code: string; url: string }>((resolve, reject) => { shown = resolve; failed = reject })
+ const read = (chunk: Buffer): void => {
+ if (output.length < MAX_OUTPUT) output += chunk.toString('utf8')
+ const found = deviceCodeOf(output)
+ if (found) shown(found)
+ }
+ child.stdout!.on('data', read)
+ child.stderr!.on('data', read)
+ const timer = setTimeout(() => child.kill('SIGKILL'), GITHUB_SIGN_IN_MS)
+ const done = new Promise<void>((resolve, reject) => {
+ child.on('error', (error) => { clearTimeout(timer); failed(error); reject(error) })
+ child.on('close', (status) => {
+ clearTimeout(timer)
+ const error = new Error(output.trim().split('\n').pop()?.slice(0, 200) || `gh auth login exited ${status}`)
+ failed(error)
+ if (status === 0) resolve(); else reject(error)
+ })
+ })
+ // Each read on its own: a code never shown, or a sign-in nobody waits on, is not an unhandled rejection.
+ code.catch(() => {})
+ done.catch(() => {})
+ return { code, done, stop: () => { clearTimeout(timer); child.kill('SIGKILL') } }
+}
+
/** Run a command, bounded in time and output (core/AGENTS.md rule 4). */
export function execBounded(file: string, args: readonly string[], options: ExecOptions): Promise<string> {
return new Promise((resolve, reject) => {
@@ -162,8 +229,14 @@ export function startOsDevice(_core: CoreApi, deps: OsDeviceDeps = {}): ServiceR
const read = deps.readFile ?? ((path: string) => readFile(path, 'utf8'))
const exec = deps.exec ?? execBounded
const detached = deps.spawnDetached ?? spawnDetached
+ const startSignIn = deps.githubSignIn ?? githubDeviceSignIn
const now = deps.now ?? Date.now
let updateStartedAt: number | null = null
+ /** The GitHub sign-in waiting for its code, and why the last one ended without signing in. */
+ let signingIn: { run: GithubSignIn; code: string; url: string } | null = null
+ let signInError: string | null = null
+ /** A sign-in started and not yet showing its code. */
+ let starting: Promise<void> | null = null
const harnessOs = (): boolean => env.HARNESS_OS === '1' || exists(LIVE_UPDATE)
@@ -185,7 +258,7 @@ export function startOsDevice(_core: CoreApi, deps: OsDeviceDeps = {}): ServiceR
])
// Encrypted, it waits for its password at every start (installer.py: rd.luks.name=).
// features: what this daemon does for a phone beyond the update and the Wi-Fi.
- return { harnessOs: true, update, wifi: { ssid }, hotspot, encrypted: /(^|\s)rd\.luks\.name=/.test(cmdline), features: ['sign_out', 'password', 'ssh'] }
+ return { harnessOs: true, update, wifi: { ssid }, hotspot, encrypted: /(^|\s)rd\.luks\.name=/.test(cmdline), features: ['sign_out', 'password', 'ssh', 'github'] }
}
const update = (payload: Payload): Payload => {
@@ -247,6 +320,64 @@ export function startOsDevice(_core: CoreApi, deps: OsDeviceDeps = {}): ServiceR
return parsed
}
+ /** The GitHub account this computer's `gh` (and git, through it) uses, for the agents to clone, push and
+ * open pull requests with. `{ login }`, with the code to enter while a sign-in waits for it. */
+ const githubStatus = async (): Promise<Payload> => {
+ if (!exists(GH)) return { error: 'GH_MISSING', message: 'The GitHub CLI is not on this computer yet: update it first.' }
+ const login = githubLoginOf(await exec(GH, ['auth', 'status', '--json', 'hosts'], { timeout: GH_TIMEOUT_MS }))
+ return {
+ login,
+ ...(signingIn && !login ? { signingIn: { code: signingIn.code, url: signingIn.url } } : {}),
+ ...(signInError && !login && !signingIn ? { signInError } : {}),
+ }
+ }
+
+ /** A device sign-in started, and answered with its code once `gh` shows it; the one already waiting
+ * answered again. Signed in, git is set up to use the account (`gh auth setup-git`). */
+ const githubSignIn = async (): Promise<Payload> => {
+ if (!exists(GH)) return githubStatus()
+ // A second ask while the first waits for its code (a phone asking again): the same sign-in, not another.
+ if (!signingIn) {
+ starting ??= startGithubSignIn().finally(() => { starting = null })
+ await starting
+ }
+ return githubStatus()
+ }
+
+ /** `gh auth login` started and kept once it shows its code; failed when it shows none in GH_TIMEOUT_MS. */
+ const startGithubSignIn = async (): Promise<void> => {
+ const run = startSignIn()
+ signInError = null
+ let timer: ReturnType<typeof setTimeout> | undefined
+ const shown = await Promise.race([run.code, new Promise<null>((resolve) => { timer = setTimeout(() => resolve(null), GH_TIMEOUT_MS) })])
+ .finally(() => clearTimeout(timer))
+ if (!shown) {
+ run.stop()
+ throw new Error('gh auth login did not show a code')
+ }
+ console.log('[os-device] github sign-in started')
+ signingIn = { run, ...shown }
+ run.done.then(async () => {
+ await exec(GH, ['auth', 'setup-git', '--hostname', 'github.com'], { timeout: GH_TIMEOUT_MS })
+ .catch((error: unknown) => console.error('[os-device] gh auth setup-git failed:', short(error)))
+ console.log('[os-device] github signed in')
+ }, (error: unknown) => {
+ if (signingIn?.run === run) signInError = short(error)
+ }).finally(() => { if (signingIn?.run === run) signingIn = null })
+ }
+
+ /** Signed out of GitHub here: the account's token taken off this computer, a sign-in waiting stopped. */
+ const githubSignOut = async (): Promise<Payload> => {
+ if (signingIn) { signingIn.run.stop(); signingIn = null }
+ signInError = null
+ const status = await githubStatus()
+ if (typeof status.login === 'string') {
+ console.log('[os-device] github sign-out')
+ await exec(GH, ['auth', 'logout', '--hostname', 'github.com', '--user', status.login], { timeout: GH_TIMEOUT_MS })
+ }
+ return githubStatus()
+ }
+
return {
os_device: async (payload, asker) => {
if (!asker.owner) return { error: 'OWNER_REQUIRED' }
@@ -261,6 +392,11 @@ export function startOsDevice(_core: CoreApi, deps: OsDeviceDeps = {}): ServiceR
if (action === 'sign_out') return signOut()
if (action === 'password') return await password(payload)
if (action === 'ssh') return await ssh(payload)
+ if (action === 'github') {
+ if (payload.state === 'sign_in') return await githubSignIn()
+ if (payload.state === 'sign_out') return await githubSignOut()
+ return await githubStatus()
+ }
return await result()
} catch (error) {
// Never the payload: it may hold a Wi-Fi password.