@pinecall/skills 0.1.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.
Files changed (68) hide show
  1. package/README.md +65 -0
  2. package/build.mjs +204 -0
  3. package/package.json +29 -0
  4. package/skills/pinecall-concepts/SKILL.md +41 -0
  5. package/skills/pinecall-concepts/references/concepts/agents-and-channels.md +155 -0
  6. package/skills/pinecall-concepts/references/concepts/deployment-topologies.md +120 -0
  7. package/skills/pinecall-concepts/references/concepts/hot-reload.md +119 -0
  8. package/skills/pinecall-concepts/references/concepts/philosophy.md +100 -0
  9. package/skills/pinecall-concepts/references/concepts/server-vs-client-llm.md +119 -0
  10. package/skills/pinecall-examples/SKILL.md +59 -0
  11. package/skills/pinecall-examples/references/examples/browser-widget.md +206 -0
  12. package/skills/pinecall-examples/references/examples/chat-bot.md +184 -0
  13. package/skills/pinecall-examples/references/examples/headless-agent.md +121 -0
  14. package/skills/pinecall-examples/references/examples/index.md +183 -0
  15. package/skills/pinecall-examples/references/examples/multi-channel-bot.md +173 -0
  16. package/skills/pinecall-examples/references/examples/outbound-dispatch.md +109 -0
  17. package/skills/pinecall-examples/references/examples/turn-detection.md +150 -0
  18. package/skills/pinecall-guides/SKILL.md +68 -0
  19. package/skills/pinecall-guides/references/guides/call-ringing.md +149 -0
  20. package/skills/pinecall-guides/references/guides/conversation-history.md +377 -0
  21. package/skills/pinecall-guides/references/guides/dev-mode.md +130 -0
  22. package/skills/pinecall-guides/references/guides/events.md +677 -0
  23. package/skills/pinecall-guides/references/guides/human-takeover.md +184 -0
  24. package/skills/pinecall-guides/references/guides/inbound-voice.md +201 -0
  25. package/skills/pinecall-guides/references/guides/knowledge-bases.md +166 -0
  26. package/skills/pinecall-guides/references/guides/live-listening.md +199 -0
  27. package/skills/pinecall-guides/references/guides/multi-tenant.md +158 -0
  28. package/skills/pinecall-guides/references/guides/outbound-calls.md +279 -0
  29. package/skills/pinecall-guides/references/guides/sse-streaming.md +207 -0
  30. package/skills/pinecall-guides/references/guides/testing-agents.md +272 -0
  31. package/skills/pinecall-guides/references/guides/tools-and-functions.md +254 -0
  32. package/skills/pinecall-guides/references/guides/webrtc-browser.md +200 -0
  33. package/skills/pinecall-guides/references/guides/whatsapp.md +370 -0
  34. package/skills/pinecall-guides/references/guides/ws-streaming.md +235 -0
  35. package/skills/pinecall-quickstart/SKILL.md +54 -0
  36. package/skills/pinecall-quickstart/references/index.md +123 -0
  37. package/skills/pinecall-quickstart/references/quickstart.md +185 -0
  38. package/skills/pinecall-reference/SKILL.md +43 -0
  39. package/skills/pinecall-reference/references/reference/cli.md +578 -0
  40. package/skills/pinecall-reference/references/reference/events.md +366 -0
  41. package/skills/pinecall-reference/references/reference/llm-providers.md +263 -0
  42. package/skills/pinecall-reference/references/reference/rest-api.md +122 -0
  43. package/skills/pinecall-reference/references/reference/session-limits.md +119 -0
  44. package/skills/pinecall-reference/references/reference/stt-providers.md +174 -0
  45. package/skills/pinecall-reference/references/reference/tts-providers.md +149 -0
  46. package/skills/pinecall-sdk-api/SKILL.md +56 -0
  47. package/skills/pinecall-sdk-api/references/api/agent.md +328 -0
  48. package/skills/pinecall-sdk-api/references/api/call.md +324 -0
  49. package/skills/pinecall-sdk-api/references/api/pinecall.md +186 -0
  50. package/skills/pinecall-sdk-api/references/api/reply-stream.md +148 -0
  51. package/skills/pinecall-security/SKILL.md +37 -0
  52. package/skills/pinecall-security/references/security.md +138 -0
  53. package/skills/pinecall-web-chat/SKILL.md +38 -0
  54. package/skills/pinecall-web-chat/references/web/chat/chat-session.md +178 -0
  55. package/skills/pinecall-web-chat/references/web/chat/overview.md +98 -0
  56. package/skills/pinecall-web-components/SKILL.md +37 -0
  57. package/skills/pinecall-web-components/references/web/components/overview.md +128 -0
  58. package/skills/pinecall-web-voice/SKILL.md +40 -0
  59. package/skills/pinecall-web-voice/references/web/core/datachannel-protocol.md +149 -0
  60. package/skills/pinecall-web-voice/references/web/core/overview.md +70 -0
  61. package/skills/pinecall-web-voice/references/web/core/state-and-phases.md +153 -0
  62. package/skills/pinecall-web-voice/references/web/core/voice-session.md +279 -0
  63. package/skills/pinecall-web-widget/SKILL.md +41 -0
  64. package/skills/pinecall-web-widget/references/web/widget/overview.md +67 -0
  65. package/skills/pinecall-web-widget/references/web/widget/props.md +291 -0
  66. package/skills/pinecall-web-widget/references/web/widget/theming.md +131 -0
  67. package/skills/pinecall-web-widget/references/web/widget/tools-api.md +381 -0
  68. package/skills/pinecall-web-widget/references/web/widget/use-voice-session-hook.md +130 -0
@@ -0,0 +1,123 @@
1
+ ---
2
+ title: "Pinecall SDK"
3
+ description: "Build real-time voice & messaging AI agents in TypeScript."
4
+ ---
5
+
6
+ # Pinecall SDK
7
+
8
+ **Build real-time voice & messaging AI agents in TypeScript.** One package, one WebSocket connection, all your channels.
9
+
10
+ ```bash
11
+ npm install @pinecall/sdk
12
+ ```
13
+
14
+ Pinecall is **code-first** voice AI: the agent runs inside your app, uses your database, calls your internal APIs, and handles tool calls as local functions. There are no webhooks to expose, no platform dashboard to configure, no JSON tool schemas to maintain separately from your code.
15
+
16
+ ```typescript
17
+ import { Pinecall, tool } from "@pinecall/sdk";
18
+ import { z } from "zod";
19
+
20
+ const pc = new Pinecall();
21
+
22
+ const agent = pc.agent("mara", {
23
+ prompt: "You are Mara, a friendly booking assistant.",
24
+ llm: "openai/gpt-5-chat-latest",
25
+ voice: "elevenlabs/sarah",
26
+ stt: "deepgram/flux",
27
+ phoneNumber: "+13186330963",
28
+ greeting: "Hello! How can I help you today?",
29
+ tools: [
30
+ tool({
31
+ name: "findSlots",
32
+ description: "Find available appointment slots for a date",
33
+ schema: z.object({ date: z.string(), service: z.string() }),
34
+ execute: async ({ date, service }) => calendar.getSlots(date, service),
35
+ }),
36
+ ],
37
+ });
38
+ ```
39
+
40
+ That snippet is a production-ready agent. The SDK auto-connects on construction, registers the agent, and starts accepting calls — phone, WebRTC, and chat. No `await pc.connect()` needed. Run it with `pinecall run agent/index.js` for a polished terminal UI.
41
+
42
+ ## What you can build
43
+
44
+ - **Voice agents** — phone (Twilio), SIP, WebRTC widgets in the browser
45
+ - **Messaging agents** — WhatsApp Cloud API, chat widgets
46
+ - **Multi-channel agents** — the same agent handling phone, WhatsApp, and browser calls simultaneously
47
+ - **Outbound campaigns** — programmatic outbound calls with TTS greetings
48
+ - **Embedded copilots** — voice inside your web app via the React widget
49
+
50
+ ## How the SDK is organized
51
+
52
+ The library has three core concepts. If you understand these, you understand the whole SDK:
53
+
54
+ - **`Pinecall`** — the WebSocket client. Manages the connection, multiplexes between agents.
55
+ - **`Agent`** — a configured personality (prompt, voice, LLM). Owns channels and emits events.
56
+ - **`Call`** — a single live session. Created automatically when someone connects. You speak to it, configure it, end it.
57
+
58
+ ![Agent tree — one connection, many agents](/assets/diagrams/agent-tree.png)
59
+
60
+ A single `Pinecall` instance can host many agents. A single agent can serve many channels. Every channel emits the same events on the agent — your code doesn't care whether the call came from a phone, a browser, or WhatsApp.
61
+
62
+ ## Advanced usage
63
+
64
+ ### Dynamic greetings
65
+
66
+ The `greeting` config accepts a string, but also a callback that receives the `Call` object — useful for personalized greetings:
67
+
68
+ ```typescript
69
+ const agent = pc.agent("mara", {
70
+ // ...
71
+ greeting: async (call) => {
72
+ const user = await db.findByPhone(call.from);
73
+ return `Hello ${user.name}! Ready to book?`;
74
+ },
75
+ });
76
+ ```
77
+
78
+ The `greeting` config is a shorthand. Under the hood it calls `call.say()` when the call connects, which sends text directly to TTS without going through the LLM. You can also use `call.say()` manually in the `call.started` event:
79
+
80
+ ```typescript
81
+ agent.on("call.started", async (call) => {
82
+ const user = await db.findByPhone(call.from);
83
+ call.say(`Hello ${user.name}!`, { addToHistory: false });
84
+ });
85
+ ```
86
+
87
+ `addToHistory: false` tells the server to speak the text but not include it in the LLM conversation history — useful for ephemeral messages like "Please hold" or "One moment."
88
+
89
+ ### Multiple phone numbers
90
+
91
+ Use `phoneNumbers` (plural) to attach several numbers with per-number overrides — ideal for A/B testing, multi-language support, or regional routing:
92
+
93
+ ```typescript
94
+ const agent = pc.agent("mara", {
95
+ prompt: "You are Mara, a friendly assistant.",
96
+ llm: "openai/gpt-5-chat-latest",
97
+ phoneNumbers: [
98
+ { number: "+14155551234", language: "en", stt: "deepgram/flux", voice: "elevenlabs/sarah" },
99
+ { number: "+966501234567", language: "ar", stt: "deepgram/nova-3", voice: "elevenlabs/ahmad" },
100
+ "+13186330963", // inherits agent defaults
101
+ ],
102
+ });
103
+ ```
104
+
105
+ Each number can override `language`, `stt`, `voice`, and `ringing`. The agent prompt, LLM, and tools stay the same — only the voice interface changes per number.
106
+
107
+ ## Where to go next
108
+
109
+ | If you want to... | Read this |
110
+ |---|---|
111
+ | Get a call working in 5 minutes | [Quickstart](/quickstart) |
112
+ | Understand the moving parts | [Concepts → Agents and Channels](/concepts/agents-and-channels) |
113
+ | Build a phone agent | [Guides → Inbound Voice](/guides/inbound-voice) |
114
+ | Build a WhatsApp bot | [Guides → WhatsApp](/guides/whatsapp) |
115
+ | Embed voice in your web app | [Guides → WebRTC in the browser](/guides/webrtc-browser) |
116
+ | Look up a method | [API Reference](/api/pinecall) |
117
+ | Tune STT, TTS, or the LLM | [Reference → Providers](/reference/stt-providers) |
118
+
119
+ ## Philosophy
120
+
121
+ Pinecall SDK is designed around one idea: **any existing app can add a voice agent without changing its architecture.**
122
+
123
+ Traditional voice AI platforms make you adapt your app to them. Pinecall adapts to your app — your code stays where it is, your tools are local functions, your data never leaves your process. The voice server handles the hard real-time parts (audio transport, STT, TTS, VAD, turn detection); your code handles everything else (business logic, prompts, history, state).
@@ -0,0 +1,185 @@
1
+ ---
2
+ title: "Quickstart"
3
+ description: "From zero to a working voice agent in under 5 minutes."
4
+ ---
5
+
6
+ # Quickstart
7
+
8
+ Get a Pinecall voice agent answering calls in under 5 minutes.
9
+
10
+ ## 1. Install
11
+
12
+ ```bash
13
+ npm install @pinecall/sdk
14
+ ```
15
+
16
+ > Node.js ≥ 18. The only runtime dependency is `ws`.
17
+
18
+ ## 2. Get an API key
19
+
20
+ Sign up at [pinecall.io](https://pinecall.io), grab your API key from the dashboard, and export it:
21
+
22
+ ```bash
23
+ export PINECALL_API_KEY=pk_...
24
+ ```
25
+
26
+ ## 3. Create your agent
27
+
28
+ Create `agent/index.js`:
29
+
30
+ ```typescript
31
+ import { Pinecall } from "@pinecall/sdk";
32
+
33
+ const pc = new Pinecall();
34
+
35
+ export const agent = pc.agent("mara", {
36
+ prompt: "You are Mara, a friendly voice assistant. Be concise.",
37
+ llm: "openai/gpt-5-chat-latest",
38
+ voice: "elevenlabs/sarah",
39
+ stt: "deepgram/flux",
40
+ language: "en",
41
+ greeting: "Hello! How can I help?",
42
+ });
43
+ ```
44
+
45
+ ## 4. Run it
46
+
47
+ ```bash
48
+ pinecall run agent/index.js
49
+ ```
50
+
51
+ You should see:
52
+
53
+ ```
54
+ ⚡ booting mara · gpt-5-chat-latest · elevenlabs/sarah
55
+ ☎ listening (no phone — webrtc/chat only)
56
+ ```
57
+
58
+ That's a running voice agent. It's connected to Pinecall's voice server, it has a personality, and it's waiting for someone to call.
59
+
60
+ ## 5. Talk to it
61
+
62
+ The fastest way to test your agent — chat from the terminal:
63
+
64
+ ```bash
65
+ pinecall chat mara
66
+ ```
67
+
68
+ ```
69
+ ⚡ Connected to mara
70
+
71
+ you › What can you help me with?
72
+ mara › I can help with all sorts of things! What do you need?
73
+ ```
74
+
75
+ This uses the same LLM, prompt, and tools as a voice call — just over text.
76
+
77
+ ### From the browser
78
+
79
+ For voice, connect from the browser using the [`@pinecall/web`](https://github.com/pinecall/web):
80
+
81
+ ```bash
82
+ npm install @pinecall/web
83
+ ```
84
+
85
+ ```tsx
86
+ import { VoiceWidget } from "@pinecall/web";
87
+
88
+ export default function App() {
89
+ return (
90
+ <VoiceWidget
91
+ agent="mara"
92
+ tokenProvider={async () => {
93
+ const res = await fetch("/api/token");
94
+ return res.json();
95
+ }}
96
+ />
97
+ );
98
+ }
99
+ ```
100
+
101
+ You'll need a tiny backend endpoint to mint the token:
102
+
103
+ ```typescript
104
+ app.get("/api/token", async (req, res) => {
105
+ const token = await mara.createToken("webrtc");
106
+ res.json(token);
107
+ });
108
+ ```
109
+
110
+ Click the widget, talk to Mara. She'll respond.
111
+
112
+ ## What just happened
113
+
114
+ You created an agent (`mara`), gave her a personality, and connected a browser to her via WebRTC. The server handles STT (you speak → text), runs the LLM (text → response), and handles TTS (response → voice). WebRTC works automatically via tokens — no channel declaration needed.
115
+
116
+ You didn't write a single line of WebSocket code, audio handling, or VAD logic. The SDK and the Pinecall server handle all of that.
117
+
118
+ ## Add a phone number
119
+
120
+ Want Mara to answer phone calls too? Add `phoneNumber`:
121
+
122
+ ```typescript
123
+ const mara = pc.agent("mara", {
124
+ // ...same as before
125
+ phoneNumber: "+13186330963",
126
+ });
127
+ ```
128
+
129
+ Now the same agent serves browser **and** phone calls. The events are identical — your code doesn't need to know which transport the call came in over.
130
+
131
+ ### Multiple numbers with per-number config
132
+
133
+ Use `phoneNumbers` (plural) to attach multiple numbers with per-number overrides — ideal for A/B testing, multi-language support, or regional routing:
134
+
135
+ ```typescript
136
+ const mara = pc.agent("mara", {
137
+ prompt: "You are Mara, a friendly voice assistant.",
138
+ llm: "openai/gpt-5-chat-latest",
139
+ phoneNumbers: [
140
+ // US number: English, fast native turns
141
+ { number: "+14155551234", language: "en", stt: "deepgram/flux", voice: "elevenlabs/sarah" },
142
+ // Saudi number: Arabic, requires Nova (Flux doesn't support Arabic)
143
+ { number: "+966501234567", language: "ar", stt: "deepgram/nova-3", voice: "elevenlabs/ahmad" },
144
+ // Simple — just a number, inherits agent defaults
145
+ "+13186330963",
146
+ ],
147
+ });
148
+ ```
149
+
150
+ Each number can override `language`, `stt`, `voice`, and `ringing`. The agent prompt, LLM, and tools stay the same — only the voice interface changes per number. This lets you test different STT providers, voices, or languages on the same agent without deploying separate instances.
151
+
152
+ ## Add a tool
153
+
154
+ Tools are local functions with Zod schemas — auto-executed by the SDK:
155
+
156
+ ```typescript
157
+ import { Pinecall, tool } from "@pinecall/sdk";
158
+ import { z } from "zod";
159
+
160
+ const lookupOrder = tool({
161
+ name: "lookupOrder",
162
+ description: "Look up an order by ID",
163
+ schema: z.object({ orderId: z.string() }),
164
+ execute: async ({ orderId }) => await db.orders.findOne(orderId),
165
+ });
166
+
167
+ const mara = pc.agent("mara", {
168
+ prompt: "You are Mara. Look up orders when asked.",
169
+ llm: "openai/gpt-5-chat-latest",
170
+ voice: "elevenlabs/sarah",
171
+ stt: "deepgram/flux",
172
+ language: "en",
173
+ greeting: "Hello! How can I help?",
174
+ tools: [lookupOrder],
175
+ });
176
+ ```
177
+
178
+ No webhook URL to expose. No manual event handler. Just a function that runs in your process.
179
+
180
+ ## Where to go next
181
+
182
+ - **Build a real phone agent** → [Guides → Inbound Voice](/guides/inbound-voice)
183
+ - **Build a WhatsApp bot** → [Guides → WhatsApp](/guides/whatsapp)
184
+ - **Understand the architecture** → [Concepts → Agents and Channels](/concepts/agents-and-channels)
185
+ - **Look up every method** → [API Reference](/api/pinecall)
@@ -0,0 +1,43 @@
1
+ ---
2
+ name: pinecall-reference
3
+ description: >-
4
+ Reference tables — CLI commands, STT/TTS/LLM providers, events, session limits, REST API. Use when the user is building, configuring, or debugging with @pinecall/sdk. Keywords: cli, commands, stt providers, tts providers, llm providers, events, session limits, rest api, reference.
5
+ license: MIT
6
+ ---
7
+
8
+ # Reference
9
+
10
+ Reference tables — CLI commands, STT/TTS/LLM providers, events, session limits, REST API.
11
+
12
+ This skill bundles the official Pinecall documentation for **Reference**. The
13
+ table below indexes every page; open the `references/…` file for the full text
14
+ (loaded on demand). Source of truth: <https://docs.pinecall.io>.
15
+
16
+ | Page | What it covers | Open |
17
+ |------|----------------|------|
18
+ | **CLI** | Inspect agents, chat, test with specs, browse voices, and manage billing from the terminal. | [`references/reference/cli.md`](references/reference/cli.md) · [docs](https://docs.pinecall.io/reference/cli) |
19
+ | **Events** | Every event the SDK emits, with payload shapes and timing. | [`references/reference/events.md`](references/reference/events.md) · [docs](https://docs.pinecall.io/reference/events) |
20
+ | **STT Providers** | Speech-to-text providers, models, and tuning parameters. | [`references/reference/stt-providers.md`](references/reference/stt-providers.md) · [docs](https://docs.pinecall.io/reference/stt-providers) |
21
+ | **TTS Providers** | Text-to-speech providers, voices, and tuning parameters. | [`references/reference/tts-providers.md`](references/reference/tts-providers.md) · [docs](https://docs.pinecall.io/reference/tts-providers) |
22
+ | **LLM Providers** | Server-side LLM providers and configuration. | [`references/reference/llm-providers.md`](references/reference/llm-providers.md) · [docs](https://docs.pinecall.io/reference/llm-providers) |
23
+ | **Session Limits** | Safety limits to prevent runaway sessions. | [`references/reference/session-limits.md`](references/reference/session-limits.md) · [docs](https://docs.pinecall.io/reference/session-limits) |
24
+ | **REST API** | Static helpers for the Pinecall management API. No WebSocket needed. | [`references/reference/rest-api.md`](references/reference/rest-api.md) · [docs](https://docs.pinecall.io/reference/rest-api) |
25
+
26
+
27
+ ## House rules — always apply
28
+
29
+ - **Example defaults** (use these exact strings unless the user asks otherwise):
30
+ `stt: "deepgram/flux"`, `llm: "openai/gpt-5-chat-latest"`, `voice: "elevenlabs/sarah"`.
31
+ **NEVER use `deepgram/nova-2`** — it is not supported. Use `deepgram/nova-3`
32
+ only for languages Flux doesn't support (e.g. Arabic).
33
+ - **Turn detection & VAD are auto-derived from the STT provider — never set
34
+ `turnDetection` or `vad` manually.** Flux → native turns + native VAD;
35
+ every other STT → `smart_turn` + `silero`.
36
+ - **Greeting**: inbound → `greeting` field in `pc.agent()`; outbound → `greeting`
37
+ field in `agent.dial()`. It is sugar for `call.say()` in `call.started`.
38
+ - **Auth**: `new Pinecall()` reads `PINECALL_API_KEY` from env and auto-connects.
39
+ - Full documentation: <https://docs.pinecall.io>
40
+
41
+ ---
42
+ *Generated from `sdk/docs/` by `@pinecall/skills` — do not edit by hand; edit the
43
+ docs and re-run `node build.mjs`.*