/ src / server / agents / process.ts
process.ts
 1  import process from 'node:process'
 2  
 3  import {
 4    isCliCommandAvailable,
 5    runCliProcess,
 6    truncateCliOutput,
 7  } from '@/server/agents/cli-runner'
 8  
 9  export { isCliCommandAvailable, runCliProcess, truncateCliOutput }
10  
11  export function getEnv(name: string): string | null {
12    const value = process.env[name]
13    if (!value) return null
14    const trimmed = value.trim()
15    return trimmed.length > 0 ? trimmed : null
16  }
17  
18  export function envBoolean(name: string, fallback: boolean): boolean {
19    const value = getEnv(name)
20    if (!value) return fallback
21    const normalized = value.toLowerCase()
22    if (['1', 'true', 'yes', 'on'].includes(normalized)) return true
23    if (['0', 'false', 'no', 'off'].includes(normalized)) return false
24    return fallback
25  }
26  
27  export function sleep(ms: number): Promise<void> {
28    return new Promise((resolve) => {
29      setTimeout(resolve, ms)
30    })
31  }