callwright 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.dockerignore ADDED
@@ -0,0 +1,16 @@
1
+ node_modules
2
+ .git
3
+ .env
4
+ *.log
5
+ temp
6
+
7
+ # Mutable state — created at runtime on the volume, NOT baked into the image
8
+ # (config.json/agents.json may contain personal data). scenario-profiles.json
9
+ # IS kept (shipped as the seed for the volume).
10
+ config.json
11
+ agents.json
12
+ .retell-ids.json
13
+
14
+ webhook/node_modules
15
+ job.*.json
16
+ grounding.*.json
package/.env.example ADDED
@@ -0,0 +1,21 @@
1
+ # callwright MCP server — environment
2
+ # Copy to .env (local) or set these in your host's env settings (do NOT commit secrets).
3
+
4
+ # Required: your Retell secret key (lives server-side, never sent to clients).
5
+ RETELL_API_KEY=key_xxxxxxxxxxxxxxxxxxxxxxxx
6
+
7
+ # Required for remote/hosted: the single bearer token your MCP clients must send.
8
+ # Generate a long random string. Clients send: Authorization: Bearer <this>
9
+ MCP_AUTH_TOKEN=replace-with-a-long-random-secret
10
+
11
+ # Optional: port (default 8787). Most hosts set PORT automatically.
12
+ PORT=8787
13
+
14
+ # Optional: override the from-number / voice (else from config.json / agents.json).
15
+ # RETELL_FROM_NUMBER=+15551234567
16
+ # RETELL_VOICE_ID=11labs-Adrian
17
+
18
+ # Optional (only if you also deploy the email webhook in ./webhook):
19
+ # RESEND_API_KEY=re_xxx
20
+ # EMAIL_FROM=calls@yourdomain.com
21
+ # EMAIL_TO=you@example.com
package/Dockerfile ADDED
@@ -0,0 +1,18 @@
1
+ FROM node:20-alpine
2
+ WORKDIR /app
3
+
4
+ # Install deps first (better layer caching).
5
+ COPY package.json package-lock.json* ./
6
+ RUN npm ci --omit=dev
7
+
8
+ # App source (static code, prompts, schema, seed scenario-profiles.json).
9
+ COPY . .
10
+
11
+ # Mutable state lives on a persistent volume (see fly.toml / docker run -v).
12
+ # server.js seeds scenario-profiles.json onto CALLWRIGHT_DATA_DIR on first boot.
13
+ ENV PORT=8787 \
14
+ CALLWRIGHT_DATA_DIR=/data
15
+
16
+ EXPOSE 8787
17
+
18
+ CMD ["node", "server.js"]
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Phil Topness
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,239 @@
1
+ # Callwright
2
+
3
+ A voice agent that places phone calls — reservations, appointments, confirmations, general inquiries — **on your behalf**, shaped by an LLM's direction + grounding. It discloses it's an AI, negotiates within bounds you set, never fabricates, and reports the outcome.
4
+
5
+ Built on [Retell](https://retellai.com). Exposed as an **MCP server** so any MCP-capable assistant (Claude, ChatGPT, Cursor, Copilot) can place calls for you — combining callwright (the *actuator*) with your other MCPs (WorkIQ, Gmail, calendar — the *sensors*) for context.
6
+
7
+ ## Just ask
8
+
9
+ You don't fill out forms — you ask your assistant in plain language, and it gathers the context (from your calendar, email, or the chat), shapes the call, reads it back to you, and dials on your OK:
10
+
11
+ > *"Find the repair appointment in my calendar and call the contractor to confirm it's still on for Thursday."*
12
+
13
+ > *"Call Sakura Sushi and book a table for 4 this Friday at 7 — anytime between 6:30 and 8 is fine."*
14
+
15
+ > *"Ring my dentist and move my cleaning to sometime next week; my member ID is in my profile."*
16
+
17
+ > *"電話して、東京の美容院に明日の午後カットの予約を取って."* — *(places the call in Japanese)*
18
+
19
+ > *"Call this hotel in Kyoto and ask their hire-car rate to the airport — just gathering info, don't book."*
20
+
21
+ The assistant pulls only the minimal details each call needs, confirms the plan with you first, then places it fire-and-forget and fetches the outcome when you ask.
22
+
23
+ ## How it works
24
+
25
+ ```
26
+ You (chat) --> Host LLM --gathers context from other MCPs--> shapes a place_call
27
+ |
28
+ v
29
+ callwright MCP --validate + profile + compose + guard--> Retell --> phone
30
+ | |
31
+ +-- get_call_outcome / learn_from_call <-- outcome --+
32
+ ```
33
+
34
+ - **Generic agent, not per-scenario.** One agent prompt = fixed guardrails (disclose AI, never pay, never fabricate, PII-minimize) + injected per-call direction. Handles any scenario and language.
35
+ - **Multilingual, extensible at runtime.** Ships speaking English and Japanese; `add_language` stands up a brand-new call language (translated prompt + a native voice + its own agent) entirely from chat — no redeploy. All language phrasing is data (`lang-phrases.json`), not code.
36
+ - **Purpose-first disclosure.** Opens with the goal ("I'm an AI assistant. I'm calling to confirm..."), not a name. Your name surfaces only when a business needs it.
37
+ - **Data minimization, filled lazily.** PII lives in `principal.facts` (shared *only if asked*); each call carries only the minimal relevant subset, and the read-back lists exactly which data types go out. When a call uses a durable fact you haven't saved, it offers to remember it — so the profile fills from use, not an upfront interview.
38
+ - **Learns from every call.** When a call defers on a missing detail, the profile is enriched so next time it's collected up front — manually (`learn_from_call`) or **automatically** via a signature-verified Retell webhook. A genuinely new scenario is *staged* and *proposed* (never silently created), with guards against over-specific splintering.
39
+ - **Bounded retry.** An unanswered/busy call is re-dialed — **exactly once by default**, never more without an explicit request (anti-spam).
40
+
41
+ ## Tools
42
+
43
+ **Setup & profiles**
44
+ | Tool | Purpose |
45
+ |---|---|
46
+ | `get_setup_status` | What's configured / missing |
47
+ | `configure` | Save your name, callback, standing facts (+ optional provisioning) |
48
+ | `list_scenarios` | Known scenario profiles (+ pending candidates) |
49
+
50
+ **Calling**
51
+ | Tool | Purpose |
52
+ |---|---|
53
+ | `place_call` | **Dry-run by default** (returns read-back); `confirm:true` to dial. Supports `lang` and `overrides.retry` |
54
+ | `get_call_outcome` | Outcome + analysis + transcript by `call_id` |
55
+ | `list_recent_calls` | Recent calls |
56
+ | `list_retries` | Recent automatic no-answer re-dials |
57
+
58
+ **Languages**
59
+ | Tool | Purpose |
60
+ |---|---|
61
+ | `list_voices` | Browse Retell voices (for adding a language) |
62
+ | `list_languages` | Languages this server can call in |
63
+ | `add_language` | Add a new call language at runtime (translate → agent) |
64
+ | `verify_language` | Quality-gate a new language (review card + optional live test call) |
65
+ | `update_language` / `remove_language` | Change / remove an added language |
66
+
67
+ **Learning**
68
+ | Tool | Purpose |
69
+ |---|---|
70
+ | `learn_from_call` | Enrich a profile, or stage a new-scenario candidate |
71
+ | `list_candidates` | Staged scenario candidates (pending new profiles) |
72
+ | `create_profile` | Create a new scenario profile (propose-and-confirm, guarded) |
73
+ | `add_scenario_alias` | Merge a call type into an existing profile |
74
+ | `reject_candidate` | Drop a noise/one-off candidate |
75
+
76
+ `place_call` is fire-and-forget and **gated**: the first call returns a read-back (including the PII footprint); you dial only after confirming with `confirm:true`.
77
+
78
+ ---
79
+
80
+ ## Retell setup (prerequisites)
81
+
82
+ Callwright dials through [Retell](https://retellai.com), so you need a Retell account with **outbound calling enabled** before anything works. In the [Retell dashboard](https://dashboard.retellai.com):
83
+
84
+ 1. **Create an account** and **add a payment method** (Stripe). Calls and phone numbers are pay-as-you-go; there's no Callwright fee on top.
85
+ 2. **Complete KYC verification.** This is **required** to unlock **outbound calling** and **phone-number purchases** — without it, calls are blocked. (It's a one-time identity/business check; approval is usually quick.)
86
+ 3. **Buy a phone number.** This becomes your caller ID (the `from` number). A US local number is cheapest; Callwright auto-selects it during `configure run_provisioning`.
87
+ 4. **Create an API key** (Settings → API Keys). This is your `RETELL_API_KEY` — it stays server-side and must never go in a browser or chat.
88
+
89
+ **Optional, recommended:**
90
+ - **Verified phone number / branded calling** (dashboard → Telephony) — registers your number so carriers are less likely to tag it *"Spam Likely"*, which meaningfully improves pickup rates on outbound calls.
91
+
92
+ **Not required (and currently dormant here):**
93
+ - **A2P 10DLC registration** — only needed to *send SMS*, via a multi-step business-profile → brand → campaign approval with a recurring cost. Callwright's SMS notifications are built but shelved, so you can skip this entirely for placing calls.
94
+
95
+ > Costs are per-minute and destination-driven (roughly ~$0.015/min US, higher internationally) plus the monthly number rental.
96
+
97
+ ---
98
+
99
+ ## Run locally
100
+
101
+ ```bash
102
+ npm install
103
+ node init.js # one-time setup wizard (number, agent, your identity)
104
+ export RETELL_API_KEY=key_xxx # [Environment]::SetEnvironmentVariable on Windows
105
+ node server.js # MCP server on :8787
106
+ ```
107
+
108
+ Check setup anytime: `node init.js status`.
109
+ Place a call from the CLI (bypassing MCP): `node dispatch.js <job.json> --go`.
110
+
111
+ ---
112
+
113
+ ## Deploy hosted (single-user)
114
+
115
+ Goal: a remote MCP URL **only you** can use. Works in both web clients (claude.ai, chatgpt.com) and local clients.
116
+
117
+ ### 1. Pick a host with a **persistent disk**
118
+ `config.json` and `scenario-profiles.json` are written at runtime (by `configure` and `learn_from_call`), so avoid ephemeral/serverless filesystems. Good fits: **Fly.io** (volume), **Railway** (volume), **Render** (disk). A small always-on instance is fine — call volume is tiny.
119
+
120
+ ### 2. Set environment variables (host dashboard)
121
+ ```
122
+ RETELL_API_KEY = key_xxx # your Retell secret - stays server-side
123
+ MCP_AUTH_TOKEN = <long random> # the bearer token only you hold
124
+ PORT = 8787 # or whatever the host injects
125
+ CALLWRIGHT_DATA_DIR = /data # persistent volume for runtime state
126
+ CALLWRIGHT_PUBLIC_URL = https://your-host.example.com # optional: enables the auto-learn webhook (Retell posts call_analyzed back here)
127
+ ```
128
+ See `.env.example`. **Never** put the Retell key in a browser or chat.
129
+
130
+ ### 3. Deploy
131
+ Docker is provided:
132
+ ```bash
133
+ docker build -t callwright .
134
+ docker run -p 8787:8787 --env-file .env callwright
135
+ ```
136
+ Or point the host at this repo (it auto-detects the Dockerfile). Mount a volume at the app dir so `config.json` / `scenario-profiles.json` persist across restarts.
137
+
138
+ ### 4. First-run setup over MCP (no webpage needed)
139
+ Do setup **in chat**:
140
+ 1. Connect the server (below).
141
+ 2. Ask the assistant to call `configure` with `run_provisioning: true` and your name + callback number. That verifies the key, selects your Retell number, creates the generic agent, and saves your profile.
142
+ 3. `get_setup_status` should now report `ready: true`.
143
+
144
+ (Or run `node init.js` once on the host shell if you prefer.)
145
+
146
+ ---
147
+
148
+ ## Connect a client
149
+
150
+ Replace the URL with your deployed host and the token with your `MCP_AUTH_TOKEN`. The server accepts the token **two ways**: an `Authorization: Bearer` header (Desktop/Code/Cursor) **or** a `?key=` URL query param (web clients whose connector form has no header field).
151
+
152
+ ### Claude.ai (web)
153
+
154
+ The web connector form only takes a URL, so put the token in the URL:
155
+
156
+ 1. **Settings → Connectors → Add custom connector** (or **Browse connectors → Add custom**).
157
+ 2. **Name:** `Callwright`
158
+ 3. **URL:** paste your host + `/mcp` + your token as `?key=`:
159
+ ```
160
+ https://your-host.example.com/mcp?key=<MCP_AUTH_TOKEN>
161
+ ```
162
+ 4. Save, then enable it in a chat (the 🔌/tools menu). Ask *"what callwright tools do you have?"* to confirm it connected.
163
+
164
+ > Because the token is in the URL, treat that connector URL like a password — anyone with it can place calls billed to your Retell account. Rotate by changing `MCP_AUTH_TOKEN` and updating the connector.
165
+
166
+ ### Claude Desktop / Cursor
167
+
168
+ ```json
169
+ {
170
+ "mcpServers": {
171
+ "callwright": {
172
+ "url": "https://your-host.example.com/mcp",
173
+ "headers": { "Authorization": "Bearer <MCP_AUTH_TOKEN>" }
174
+ }
175
+ }
176
+ }
177
+ ```
178
+
179
+ ### Claude Code
180
+
181
+ ```bash
182
+ claude mcp add --transport http callwright https://your-host.example.com/mcp \
183
+ --header "Authorization: Bearer <MCP_AUTH_TOKEN>"
184
+ ```
185
+
186
+ ### ChatGPT (Developer mode / connectors)
187
+
188
+ Add a custom MCP connector with the same URL — header or `?key=` both work.
189
+
190
+ > Keep **"confirm before running tools"** on. `place_call` is already dry-run-by-default, but tool-confirmation is a good second gate for an actuator that spends money and reaches real people.
191
+
192
+ ---
193
+
194
+ ## Security notes
195
+
196
+ - **Single bearer token = your lock.** Anyone with the token can place calls billed to your Retell account. Treat it like a password; rotate by changing `MCP_AUTH_TOKEN`.
197
+ - **Least-privilege Retell key.** Use a scoped key if you don't need full admin.
198
+ - **PII.** Standing facts are stored in `config.json` on your host. Calls send only the minimal subset, shared only if the business asks; the read-back shows the footprint every time.
199
+ - If `MCP_AUTH_TOKEN` is unset, the server accepts **loopback only** (local dev).
200
+
201
+ ## Key files
202
+
203
+ | File | Purpose |
204
+ |---|---|
205
+ | `server.js` | MCP server (Streamable HTTP, bearer auth) + the auto-learn / retry webhook |
206
+ | `dispatch-core.js` | Validate → profile → compose vars → dispatch (shared core) |
207
+ | `dispatch.js` | CLI over dispatch-core |
208
+ | `setup-core.js` | Provisioning + config + status + lazy-save helpers (shared by init & MCP) |
209
+ | `lang-core.js` | Runtime language management (add/verify/update/remove, voices) |
210
+ | `lang-phrases.json` | Per-language composed phrasing (data, not code) |
211
+ | `learn-core.js` | Profile enrichment + new-scenario candidate staging (anti-splintering) |
212
+ | `retry-core.js` | No-answer retry policy + bounded re-dial decisions |
213
+ | `init.js` | Terminal setup wizard (`node init.js` / `node init.js status`) |
214
+ | `update-prompt.js` | Push a prompt + tools + etiquette + webhook to an existing agent |
215
+ | `place_call.schema.json` | The job contract the LLM fills |
216
+ | `generic-prompt.md` / `.ja.md` | Generic agent prompts (guardrails + `{{variables}}`) |
217
+ | `scenario-profiles.json` | Learning profiles (recommended details per scenario) |
218
+ | `learn.js` / `get-call.js` | CLIs: enrich a profile / fetch a call outcome |
219
+ | `paths.js` | Resolves mutable state paths (honors `CALLWRIGHT_DATA_DIR`) |
220
+ | `docs/` | Design specs (add-language, profile-learning) |
221
+ | `webhook/` | Optional serverless Retell→Resend email notifier (independent of the MCP) |
222
+
223
+ > Per-user runtime files — `config.json`, `agents.json`, `.retell-ids.json`, `job.*.json`,
224
+ > `grounding.*.json` — are git-ignored. They're created at runtime (by `init`/`configure`) or
225
+ > are personal call data; never commit them. Start from `config.example.json` and `examples/`.
226
+
227
+ ## A note on disclosure & legality
228
+
229
+ The agent **always discloses that it's an AI** at the start of every call — this is a hard,
230
+ non-removable behavior. AI-call disclosure is legally required in some jurisdictions (e.g.
231
+ California's B.O.T. Act) and is good practice everywhere. The agent also never fabricates
232
+ information and shares personal data only when a business asks for it. For commercial or
233
+ at-scale use, confirm requirements with counsel in your jurisdiction.
234
+
235
+ ## Optional: proactive email on every call
236
+
237
+ See [`webhook/`](./webhook) — a serverless Retell→Resend notifier that emails you each outcome.
238
+ It is **independent of the MCP** (which retrieves outcomes on demand via `get_call_outcome`) and
239
+ is **not deployed or wired by default**.
@@ -0,0 +1,18 @@
1
+ {
2
+ "retell": {
3
+ "from_number": "+15555550100"
4
+ },
5
+ "agents": {
6
+ "default": "agent_xxxxxxxxxxxxxxxxxxxxxxxxxx",
7
+ "by_lang": {
8
+ "ja": "agent_yyyyyyyyyyyyyyyyyyyyyyyyyy"
9
+ }
10
+ },
11
+ "principal": {
12
+ "name": "Your Name",
13
+ "callback_number": "+15555550123",
14
+ "facts": {
15
+ "service_address": "123 Example St, Your City, ST 00000"
16
+ }
17
+ }
18
+ }