MCPcopy Create free account
hub / github.com/tiann/hapi / authAndSetupMachineIfNeeded

Function authAndSetupMachineIfNeeded

cli/src/ui/auth.ts:5–28  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3import { updateSettings } from '@/persistence'
4
5export async function authAndSetupMachineIfNeeded(): Promise<{
6 token: string
7 machineId: string
8}> {
9 if (!configuration.cliApiToken) {
10 throw new Error('CLI_API_TOKEN is required')
11 }
12
13 const settings = await updateSettings((current) => {
14 if (!current.machineId) {
15 return {
16 ...current,
17 machineId: randomUUID()
18 }
19 }
20 return current
21 })
22
23 if (!settings.machineId) {
24 throw new Error('Failed to initialize machineId')
25 }
26
27 return { token: configuration.cliApiToken, machineId: settings.machineId }
28}
29

Callers 8

startRunnerFunction · 0.90
resume.tsFile · 0.90
claude.tsFile · 0.90
codex.tsFile · 0.90
opencode.tsFile · 0.90
gemini.tsFile · 0.90
kimi.tsFile · 0.90
cursor.tsFile · 0.90

Calls 1

updateSettingsFunction · 0.90

Tested by

no test coverage detected