Files
deepseek-harness/apps/desktop/src/duration-env.ts
T
lsdsjy 4f26143bf2 Merge pull request #5393 from deepseek-harness/feat/desktop-login-shell-env
feat(desktop): 启动时读取用户登录 shell 环境
2026-09-29 15:59:28 +08:00

17 lines
703 B
TypeScript

/** Millisecond settings read from the Desktop process environment. */
/**
* Read a duration that `setTimeout` accepts without clamping.
* @param env - Desktop process environment.
* @param name - Variable to read; the validation error names it.
* @param fallback - Value used when the variable is unset.
* @returns Integer milliseconds from 1000 through 2147483647.
*/
export function resolveDurationMs(env: NodeJS.ProcessEnv, name: string, fallback: number): number {
const value = Number(env[name] ?? fallback)
if (!Number.isSafeInteger(value) || value < 1_000 || value > 2_147_483_647) {
throw new Error(`${name} must be an integer from 1000 through 2147483647`)
}
return value
}