Skip to content

The open-source AI receptionist for businesses. Answers every call, books the appointment and hands over to a person when needed. You own the code and the data.

21.1 KB
Raw Blame

Commands

All commands for working on Linedesk. The short list every session needs is in CLAUDE.md; this page has the details.

Set up

  • pnpm install, then scripts/setup.sh (makes .env from .env.example with random secrets; a plain cp .env.example .env leaves SECRETS_KEY empty, so nothing can be stored under Server admin › Providers).
  • Email-code sign-in delivers nowhere until email is connected in Server admin › Providers: uncomment EMAIL_TO_LOG=true in .env for local development (codes in the API log).
  • There is no open sign-up: accounts come from the first-run setup, an invitation or a server admin, and only server admins create workspaces (architecture.md, "Workspace rights"). A fresh database without users: the API prints a setup code; the sign-in page asks for it and makes the first instance admin (apps/api/src/setup.ts).

Database and test data

  • pnpm db:up (Postgres on 5433 + Electric on 3001), pnpm db:migrate, pnpm db:seed (demo login is printed; pnpm db:seed -- --reset replaces an existing demo's calls and contacts).
  • Compose project: pnpm db:up (and voice:up, recording:up, dev:snapshot) uses COMPOSE_PROJECT_NAME from the environment or .env, else linedesk-dev-<checkout folder> (scripts/compose-dev-project.sh), so a dev checkout never shares containers or the database volume with a self-hosted install on the same machine (project linedesk) or with another checkout. A dev database made before this lives in the project linedesk: COMPOSE_PROJECT_NAME=linedesk in .env keeps using it (stop it first when another stack should take port 5433).
  • Always signed in locally: [email protected]:brightwater-demo in .env makes the web dev server sign in every page load that has no session (the seeded demo login, or any email:password); dev server only, never in a build.
  • Local test data: pnpm db:seed -- --user <email> [--business <name>] [--reset] fills that account's own workspace (onboarding done, assistant, hours, a dev number, appointment types, team, calls in every inbox view; --reset replaces only what the seed added).
  • Parallel sessions: scripts/dev-env.sh <name> <api-port> <web-port> >> .env gives the worktree its own Postgres and Electric (compose project linedesk-dev-<name>, Postgres on <web-port>+1000, Electric on <api-port>+1000), so pnpm db:up there starts that session's database and no session shares another's connections; then migrate (and seed when there is no snapshot). When the session ends: docker compose -p linedesk-dev-<name> down -v.
  • Snapshots: pnpm dev:snapshot [-p <compose project>] saves a local dev database to ~/.linedesk/dev-snapshot.dump (outside every worktree, never in git; sessions, provider keys and other secrets left out); a new, empty Postgres volume of pnpm db:up (or any stack with docker-compose.snapshot.yml in COMPOSE_FILE) and a new database from scripts/dev-env.sh start from it, migrations run after. pnpm dev:restore [-p <project>] [--force] replaces an existing database with it. No snapshot: the database starts empty, seed as before.
  • Schema change: edit packages/db/src/schema.ts, pnpm db:generate, pnpm db:migrate. Updates run the new API next to the old one (scripts/deploy.sh), so a migration must keep the previous release working: expand/contract (architecture.md §11, "Updates without downtime").

Run, check, test

  • pnpm dev (API on 3100, web on 5173), pnpm typecheck, pnpm test.
  • pnpm lint (Biome, config in biome.json; PR CI runs typecheck, lint and the image build). pnpm format <files> formats only the files you touched; don't run it on the whole repo, the code is not reformatted yet.
  • The API tests (apps/api/test) need Postgres (pnpm db:up). Each run creates and drops its own databases linedesk_test_<run>, never linedesk: one for each file that changes what is global to an install or counts across workspaces (INSTANCE_WIDE_FILES in apps/api/vitest.config.ts: admin, setup checklist, provider failures, setup MCP, install setup; a new file that sets provider keys, instance settings, instance admins or stored provider tests goes there), one for all others; TEST_DATABASE_URL overrides the base name. Without Postgres they are skipped with a message, and so are the tests under apps/api/src that load the database (src/db.ts) without mocking it.
  • The dev Postgres of pnpm db:up runs with max_locks_per_transaction=1024 (docker-compose.ports.yml; the server default is 64), as CI's (tests.yml, docs/ci.md "Tests"): the API tests create and migrate about 26 databases at once, which otherwise fails with "out of shared memory". A running container picks it up after pnpm db:up recreates it.
  • Agent-style browser test (apps/web/e2e, Playwright; CI job agent ui): drives the running app by roles, names and addresses only, as a browser agent does. With the dev stack up, the demo data seeded and LINEDESK_DEV_AUTO_SIGN_IN set: pnpm --filter @linedesk/web exec playwright install chromium once, then pnpm --filter @linedesk/web e2e (E2E_URL=<origin> for a stack that is not on http://localhost:5173). It puts the calls it changes back.
  • Prototype: cd prototypes/inbox-html && python3 -m http.server 4173.

Calls without a phone

  • Simulate a call (no provider keys): pnpm --filter @linedesk/agent simulate [leak|booking|message|hangup] [--fast] [--to <number>]; targets LINEDESK_API_URL. Dials --to, else SIM_TO_NUMBER, else the install's only Linedesk number (call.listNumbers); the call is filed with source simulated: shown like a phone call, never counted as a real one (setup milestones, usage, spending cap).
  • Talk to the assistant without a phone: Settings, Assistant, "Start test call" in the web app (needs pnpm voice:up and the agent worker; the call is filed in the inbox as a test call). From a phone's browser: scripts/tunnel.sh [web-port] (ngrok, NGROK_AUTHTOKEN or ngrok's own config; prints the env lines to set). The older pnpm --filter @linedesk/agent talk page still works.
  • The docker compose stack on a public HTTPS address like a server (OAuth redirects, passkeys, push, phone test call): scripts/local-public.sh start|stop|status (local.md).
  • Support mail analysis on the demo mailbox (no mailbox, nothing stored): pnpm --filter @linedesk/api mail:demo [--months 6|12] with the install's language model, or --provider openrouter [--model <id>] with OPENROUTER_API_KEY (also openai, anthropic, gemini, groq, mistral with their *_API_KEY). Prints the topics.

LLM test suite

The system prompt and tools against the install's LLM, text only (no speech, no phone, no LiveKit): about 85 calls with edge cases (scope, AI disclosure, languages, emergencies, transfers, messages, hours, prices, booking, lookups, prompt injection, ending, spam and style), each graded by deterministic checks and an LLM judge. Run it after a change to the text the assistant reads (rule 11), a new tool or a model change. It calls a paid model (a full run, 3 runs per case on gpt-4.1-mini with a gpt-4.1 judge and caller, costs about $0.45 and takes about 3 minutes), so it is not in CI.

pnpm --filter @linedesk/agent llm-test [--case <id|prefix-,...>] [--category <name,...>] [--runs 3] [--concurrency 6] [--model <id>] [--provider openai|openrouter|anthropic|deepseek] [--judge-model <id>] [--no-judge] [--list]

  • Keys: like the agent, from the install's Admin › Providers (the database, decrypted with SECRETS_KEY), then the env. It reads DATABASE_URL, else the compose Postgres on 127.0.0.1:5433 with POSTGRES_PASSWORD; the script loads the repo's .env. Read-only.
  • It uses the real buildInstructions and the real tool definitions (assistantTools, apps/agent/src/assistant-tools.ts); booking and lookup tools run their real code against a fake API; collection steps and transfer_call return their real result texts. The prompt text is the one in the code, not the instance admin's System prompt overrides.
  • Compare models: --model <id> on the install's LLM, or --provider <name> --model <id> for another API (add --judge-provider <name> to run the judge there too: then no database is needed) (key from OPENAI_API_KEY, OPENROUTER_API_KEY, ANTHROPIC_API_KEY or DEEPSEEK_API_KEY). The judge and the simulated caller stay on the install's LLM, so every model gets the same grading. The report gives the cost (OpenRouter's own figure where it reports one) and the assistant's reply time (median and p90 of the whole reply, without streaming: compare models with it, it is not the call's time to first word).
  • A case passes when every run passes (must: safety and hard rules) or two runs in three (should). Exit code 1 when a case fails.
  • Report: a table on the console, and apps/agent/llm-test-results/<timestamp>/ (gitignored) with report.json, report.md (the transcripts and reasons of failed runs) and prompts/<case>.txt (the system prompt of each failed case).
  • Add a case in apps/agent/src/llm-test/cases.ts (how: README); pnpm --filter @linedesk/agent test checks the catalogue without a model.

Voice

  • pnpm voice:up (LiveKit on 7880, LiveKit SIP on 5060, Redis).
  • pnpm --filter @linedesk/agent setup-sip [--outbound] <numbers> (SIP inbound trunk, only from the carriers' signaling addresses in LIVEKIT_SIP_ALLOWED_ADDRESSES, default telnyx twilio, + dispatch rule; --outbound also the trunk warm transfers dial out through, Telnyx only). Once per install: the API then keeps the inbound trunk's numbers in step with the connected numbers.
  • pnpm --filter @linedesk/agent worker (voice agent; answers calls once speech recognition, language model and voice are set up in Linedesk under Providers, or by DEEPGRAM_API_KEY, OPENROUTER_API_KEY and ELEVENLABS_API_KEY in its env; until then it runs and logs each call as missed; it reads the settings through GET /v1/agent/provider-config, see apps/agent/src/config.ts).

Recordings (optional)

Pick Local disk under Server admin › Providers › Recording storage (or set RECORDING_STORE=file) and run pnpm recording:up (LiveKit egress, writes each call into data/recordings). Calls are recorded unless assistants.record_calls is false; GET /v1/calls/<id>/recording serves the audio to members of the workspace from the store the call's recording is in (calls.recording_store). S3-compatible (or RECORDING_STORE=s3) uses a bucket instead.

Call test

A test-caller agent calls the business; transcript, summary, pass/fail and latency; in room mode also the business agent's own time from pickup to the greeting, checked against 2.5 s.

On a live server, test with the three stages (--pipeline three_stage; over the phone, set the test business's assistant to three stages). OpenAI realtime models are costly: run --pipeline realtime only when you need to test them.

pnpm --filter @linedesk/agent call-test <scenario> [--phone [--external] [--keep-history]] [--pipeline realtime|three_stage] [--expect-recording]

  • Default: both agents in one LiveKit room, no phone (cheap).
  • --phone: a real call over Telnyx from CALL_TEST_FROM to CALL_TEST_TO (run setup-test-caller once; a few cents).
  • --phone answers as a call from a new caller: before it dials, the test asks the API (call.newCallerForTest) to give the assistant no name, note, earlier calls or bookings of CALL_TEST_FROM on its next call to CALL_TEST_TO (within 3 minutes). The test number has many earlier test calls, and the assistant would answer from them. --keep-history: a returning caller, with all of that.
  • --external: CALL_TEST_TO is another install's number (e.g. the server under test, called from a test server's test caller): no checks, only what the caller heard.
  • --pipeline (no phone only): the business answers with the realtime model or the three stages instead of what its assistant's call quality picks (Ultra: the realtime model; over the phone the call quality applies).
  • --realtime-unreachable (no phone only): a realtime call's model is pointed at an address that never answers, to check that the call goes on without it (the three stages answer after 4 s when the install has them).
  • Needs the worker running and CALL_TEST_TO (names the workspace).

Scenarios: apps/agent/src/test-caller/scenarios.ts.

  • after-hours sets the business closed for itself without a phone.
  • transfer-accepted, transfer-declined and transfer-no-answer turn transfer on for themselves and answer it with a simulated on-call person, nothing is dialled; over real phone lines only as the live transfer test with CALL_TEST_ONCALL and setup-oncall-test (architecture.md); with --phone the workspace's real hours apply. transfer-person does the same with the "asks for a person" rule; transfer-next with two urgent contacts, the first set to try the next, nobody answering.
  • spanish-caller allows Spanish for itself and the caller speaks only Spanish; mandarin-caller, korean-caller and polish-caller the same for a language outside Flux's 10 (the call runs on Nova-3 multi). french-caller, german-caller, italian-caller, portuguese-caller, dutch-caller, russian-caller, hindi-caller and japanese-caller the same for Flux's other languages, with a hard name in the first sentence and a callback number (speech recognition comparison). Over the phone the assistant's own languages apply: allow the language there first.
  • silence-closing stays silent until the assistant's reminders, closing line and hang-up; silence-mid-call says what it wants, then goes silent (muted, not "...") for the same check.
  • booking and which-calendar expect a real booking, the event in the calendar and, for which-calendar, the calendar whose note says emergencies, when the assistant has an appointment type and a calendar, else a message; --cancel-booking deletes the test booking afterwards.

Provision a business without the web app: node apps/api/src/workspace-create.ts --name <business> --owner <email> [--owner-name <name>] [--as <server admin email>] [--number +1…] (runs workspace.create as that server admin, like Server admin › New workspace: a confirmed account becomes the owner, anyone else gets the owner invitation by email; --as may be left out only while the install has exactly one server admin).

Load test

What calls at once cost the agent (on a dev machine or test server), or how another install's numbers hold up under N calls at once. The business side never runs on a live server; a live server can only be the number called (--remote).

pnpm --filter @linedesk/agent load-test [--calls 1,5,10] [--to <number>[,<number>…]] [--scenario <name>] [--spread 2] [--pipeline realtime|three_stage] [--memory 4g] [--cpuset 1] [--caller-memory <GB>] [--caller-cpuset 6-13] [--phone] [--remote] [--project linedesk] [--no-abort]

Starts a second agent container that plays the test callers (linedesk-load-caller, AGENT_NAME=linedesk-load-caller, so the install's own business worker is never a caller), then per level starts N test calls (apps/agent/src/load-test/calls.ts in that container) and waits 45 s between levels.

  • Default (no phone): both agents in one room. Raises the local agent's limits for the test (--memory, --cpuset) and puts them back, samples its container; prints memory before, peak, per call and after, CPU, processes, greeting and reply times. Use --pipeline three_stage; realtime only when you need it (costly, see Call test).
  • --phone: real calls over the install's test-caller trunk (as call-test --phone): from CALL_TEST_FROM to --to (default CALL_TEST_TO), the numbers in turn; the calls of a level start spread over --spread seconds. The callers use the three stages only, never OpenAI's realtime voice; the business answers with its assistant's own setting (--pipeline is refused). Transfer scenarios are refused.
  • --remote (implies --phone, needs --to): the numbers belong to another install. The local business agent is not changed, restarted or sampled (--memory, --cpuset, --container are refused); only the caller container is started and removed, with --caller-memory and --caller-cpuset. --project: the compose project to start it in.
  • Output: one LOADTEST {json} line per call (level, index, to, answered, heardGreetingMs from the dial to the first business audio the caller heard, pickupMs, replyMs as the caller heard them, dialFailed, error, durationMs), a summary per level (answered %, greeting heard p50/p95, reply p50/p95, failures) and a table of all levels at the end.
  • Per level it also watches the callers' own container (CPU, memory, the time its processes waited for CPU or memory, OOM kills). A caller short of either speaks late or not at all, which looks like a slow or silent business: such a level is marked as the callers' fault and stops the run. --caller-memory defaults to 0.5 GB per call of the biggest level plus 1 GB (at least 3 GB): one process per call plus as many warm ones.
  • The run stops after a level when fewer than 90 % were answered, the greeting heard p50 is over 3.5 s or any call could not be dialled (or was not answered within 30 s); it prints why and exits 1. --no-abort goes on.
  • Kill switch: Ctrl-C hangs up every call of the run (deletes its rooms: both legs end) and removes the caller container. Hard stop: docker rm -f linedesk-load-caller; a call already dialled then ends when the other install's assistant hangs up.

Capacity check of a live install, with two installs: a test server and the server under test (the callers on the test server, the server under test only the number called). Run on the test server:

pnpm --filter @linedesk/agent load-test --remote --to <number 1>,<number 2>,<number 3>,<number 4> --calls 1,5,10,20 --caller-cpuset <cores>

  • A workspace answers at most 5 phone calls at once (LIVE_CALLS_PER_WORKSPACE on a workspace without a bill; on a billed one Server admin › Billing › Calls at once for its bill, or extra calls under Settings › Billing); the others hear the busy line, which counts as answered here (a short durationMs). For 20 real calls give 4 or more numbers of different workspaces.
  • The test workspaces on the server under test must have their assistant on the three stages (Settings › Assistant › Answered by).
  • Cost: every call is billed on both sides (speech, model and voice on the test server for the caller, on the server under test for the assistant: about a cent a minute per side) plus the carrier for both legs (the test server's outbound, the other server's inbound). 1+5+10+20 calls of up to 3.5 minutes are 36 calls.
  • The test-caller trunk places all calls from the one CALL_TEST_FROM number: the channel limit of the test server's carrier account must allow 20 at once.

Self-host stack

What docker compose up gives a user: docker-compose.yml alone is the whole application (project name linedesk, limits and log rotation per service, only Caddy (proxy) and LiveKit's audio and SIP ports published; web is the SPA's files behind it).

  • docker-compose.ports.yml adds the local ports for development and is what pnpm db:up, pnpm voice:up and pnpm recording:up use; docker-compose.https.yml lets Caddy get certificates.
  • docker compose needs LIVEKIT_API_KEY and LIVEKIT_API_SECRET to be set for every command, so scripts/setup.sh (or cp .env.example .env) comes before pnpm db:up.
  • A new service needs <<: *service, mem_limit and cpus.
  • To try the self-host stack on a machine that has one already (a self-hosted install, another try), always pass another project name (docker compose -p linedesk-selfhost ...; the default is linedesk), next to a running dev stack its own hostname and port (PUBLIC_URL=http://selfhost.localhost:8480 LINEDESK_HTTP_BIND=127.0.0.1:8480; never plain localhost: cookies are shared across ports and sign the live app out).
  • The images run the .ts sources directly on Node (type stripping): see the erasable-syntax rule in CLAUDE.md. The API image starts from a bundle of them instead (node apps/api/scripts/bundle.ts, built in the image), so it loads a few dozen files instead of about 2,650 modules; its scripts still run from the sources. The agent image does the same (node apps/agent/scripts/bundle.ts): the worker and every process it keeps warm for a call start from the bundle.

Dev mode

Your machine or a test server, never production (dev-mode.md). LINEDESK_MODE=dev in .env runs api, web (Vite, hot reload) and agent from the checkout via docker-compose.dev.yml; scripts/deploy.sh then fast-forwards the checkout instead of building, and refuses while it has local changes. To code on the server, switch its checkout to a branch, edit, commit, push, switch back to its branch (LINEDESK_DEV_BRANCH, one session at a time).

Errors and logs

Sentry, on staging and production via SENTRY_DSN (off without it; apps/api/src/error-reporting.ts, apps/agent/src/error-reporting.ts, apps/web/src/errorReporting.ts). It gets errors, console.warn/console.error lines and the member they hit (id, email, name); never transcripts, request bodies, local variables or AI inputs and outputs, and phone numbers are masked.