Introduce backend app for WebSocket terminal sessions and sandbox orchestration.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7b1df2607e
commit
91049379f7
22 files changed
+808
-11
No files matched your search
@@ -0,0 +1,28 @@
|
||||
export type BackendConfig = {
|
||||
host: string;
|
||||
port: number;
|
||||
spawnerSocket: string;
|
||||
/** Exact origins allowed to open terminal sessions. Empty allows every origin. */
|
||||
allowedOrigins: string[];
|
||||
sessionSeconds: number;
|
||||
outputRate: number;
|
||||
};
|
||||
|
||||
function integer(env: NodeJS.ProcessEnv, name: string, fallback: number): number
|
||||
{
|
||||
const value = Number(env[name] ?? fallback);
|
||||
if (!Number.isInteger(value) || value < 1) throw new Error(`${name} must be a positive integer`);
|
||||
return value;
|
||||
}
|
||||
|
||||
export function loadConfig(env: NodeJS.ProcessEnv): BackendConfig
|
||||
{
|
||||
return {
|
||||
host: env.HOST ?? '0.0.0.0',
|
||||
port: integer(env, 'PORT', 8080),
|
||||
spawnerSocket: env.SPAWNER_SOCKET ?? '/run/spawner/spawner.sock',
|
||||
allowedOrigins: (env.ALLOWED_ORIGINS ?? '').split(',').map((origin) => origin.trim()).filter(Boolean),
|
||||
sessionSeconds: integer(env, 'SESSION_SECONDS', 20 * 60),
|
||||
outputRate: integer(env, 'OUTPUT_BYTES_PER_SECOND', 1024 * 1024),
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user