This folder contains Node.js scripts that run outside the browser — validation and setup tools. These are CLI tools you run with npm run <script>.
| Script | Command | What it does |
|---|---|---|
validate-config.ts |
npm run validate |
Validates config/*.json files against Zod schemas |
check-env.ts |
npm run check-env |
Validates required environment variables are set before dev server starts |
init.ts |
npm run init |
Copies a reference PAL into your Tavus account and writes its persona_id into config/presets.config.json |
Setup is manual. Copy .env.example to .env and fill in TAVUS_API_KEY. Set persona_id / replica_id in config/presets.config.json — the single source of truth. Then run npm run dev.
PALs are managed on Tavus directly. The PAL (system prompt, objectives, guardrails, layers) is created and edited via the Tavus dashboard or the Tavus API — the deployed PAL is the source of truth. Point
presets[0].persona_idat it. There is no local PAL-deployment script.
Validates config/*.json files against Zod schemas.
- Reads each config file (
presets.config.json,branding.config.json) - Strips
_prefixed keys - Parses against the Zod schema defined in
src/lib/config/schema.ts - Reports success or failure with error details
- Exits with code 1 on failure (blocks
npm run devfrom starting)
Schema validation (per-file):
- Missing required fields (e.g.,
persona_idfield missing from preset) - Wrong types (string where number expected, etc.)
- Empty arrays where at least one entry is required
- Structural mismatches (e.g., a feature chip missing the
descfield)
This validator does not cross-validate objective_name values against config entries, because the medical intake app fetches objectives dynamically from the Tavus API at runtime. There is no static objective-to-label mapping in config that could go stale. The dynamic fetch means no manual sync is required.
- You've added new fields to a config file — update the Zod schema in
src/lib/config/schema.tsand the TypeScript types insrc/types/ - You want to add cross-file checks (e.g., verify that
persona_idin presets.config.json is non-empty before allowingnpm run dev)
Validates that required environment variables are set before the dev server starts. Runs automatically as part of npm run dev.
| Variable | Required | Notes |
|---|---|---|
TAVUS_API_KEY |
Yes | Must be set — copy .env.example to .env and paste in your key from maker.tavus.io/dev/api-keys |
persona_idandreplica_idare not env vars — they live inconfig/presets.config.json(presets[0]), the single source of truth.check-envdoes not check them; pick an existing PAL at maker.tavus.io/dev/pals and paste its ID in.
All Tavus API calls go to production (https://tavusapi.com) — the base URL is hardcoded in api/_lib/handlers/tavus.ts, not an env var.
- You've added new required environment variables (e.g., a HIPAA-compliant logging endpoint)
- You want to add a connectivity check (e.g., ping the Tavus API on startup)
Copies a reference PAL into your Tavus account and writes the new persona_id into config/presets.config.json (under presets[0]). Run it once after setting TAVUS_API_KEY in .env, unless the preset already points at a custom PAL.
config/*.json—validate-config.tsvalidates these. Both must be valid fornpm run devto start.src/lib/config/schema.ts— Zod schemas shared between the validation script and the runtime config loaderconfig/presets.config.json— holdspresets[0].persona_id/replica_id, pointing at a PAL in your Tavus account
- Create the script in
scripts/ - Add an entry to
package.jsonunderscripts:"your-script": "tsx scripts/your-script.ts"
- The script can import from
src/(like Zod schemas) — thetsxrunner handles TypeScript
- Tavus API calls: Use
x-api-keyheader, not Bearer token. Base URL ishttps://tavusapi.com. - Stripping comments: Scripts that read config JSON use the
stripCommentshelper to remove_prefixed keys before parsing.