- Move all application env vars to repository-root .env (with .env.example as the committed template) and drop the per-app .env.example files. - Add @code/env subpaths (agent, convex) and consume validated exports everywhere instead of reading process.env directly. - Wire every dev/build/start script to load ../../.env via bun --env-file and point vite.config.ts envDir at the repo root.
18 lines
587 B
TypeScript
18 lines
587 B
TypeScript
import { z } from "zod";
|
|
|
|
const agentEnvSchema = z.object({
|
|
AGENT_MODEL_API: z.literal("openai-completions"),
|
|
AGENT_MODEL_API_KEY: z.string().min(1),
|
|
AGENT_MODEL_BASE_URL: z.url(),
|
|
AGENT_MODEL_CONTEXT_WINDOW: z.coerce.number().int().positive(),
|
|
AGENT_MODEL_MAX_TOKENS: z.coerce.number().int().positive(),
|
|
AGENT_MODEL_NAME: z.string().min(1),
|
|
AGENT_MODEL_PROVIDER: z.string().min(1),
|
|
});
|
|
|
|
export type AgentEnv = z.infer<typeof agentEnvSchema>;
|
|
|
|
export const parseAgentEnv = (
|
|
runtimeEnv: Record<string, string | undefined>
|
|
): AgentEnv => agentEnvSchema.parse(runtimeEnv);
|