create-micdrop 0.0.0-stage → 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.
- package/README.md +61 -2
- package/dist/index.js +1315 -0
- package/package.json +53 -4
- package/templates/expo/App.tsx +123 -0
- package/templates/expo/README.md +65 -0
- package/templates/expo/_env.example +6 -0
- package/templates/expo/_gitignore +7 -0
- package/templates/expo/app.json +34 -0
- package/templates/expo/babel.config.js +6 -0
- package/templates/expo/index.ts +4 -0
- package/templates/expo/package.json +39 -0
- package/templates/expo/server/index.ts +36 -0
- package/templates/expo/server/tsconfig.json +14 -0
- package/templates/expo/src/serverUrl.ts +20 -0
- package/templates/expo/tsconfig.json +8 -0
- package/templates/nextjs/README.md +40 -0
- package/templates/nextjs/_env.example +9 -0
- package/templates/nextjs/_gitignore +7 -0
- package/templates/nextjs/app/CallLoader.tsx +10 -0
- package/templates/nextjs/app/VoiceCall.tsx +71 -0
- package/templates/nextjs/app/globals.css +45 -0
- package/templates/nextjs/app/layout.tsx +16 -0
- package/templates/nextjs/app/page.tsx +10 -0
- package/templates/nextjs/next.config.ts +5 -0
- package/templates/nextjs/package.json +34 -0
- package/templates/nextjs/server/index.ts +35 -0
- package/templates/nextjs/tsconfig.json +25 -0
- package/templates/nextjs/tsconfig.server.json +14 -0
- package/templates/node/README.md +48 -0
- package/templates/node/_env.example +6 -0
- package/templates/node/_gitignore +4 -0
- package/templates/node/package.json +21 -0
- package/templates/node/src/server.ts +34 -0
- package/templates/node/tsconfig.json +14 -0
- package/templates/phone/README.md +86 -0
- package/templates/phone/_env.example +31 -0
- package/templates/phone/_gitignore +5 -0
- package/templates/phone/package.json +25 -0
- package/templates/phone/src/recording.ts +65 -0
- package/templates/phone/src/server.ts +212 -0
- package/templates/phone/src/webhooks.ts +88 -0
- package/templates/phone/telephony/plivo/env.example +6 -0
- package/templates/phone/telephony/plivo/setup.md +7 -0
- package/templates/phone/telephony/plivo/telephony.ts +111 -0
- package/templates/phone/telephony/telnyx/env.example +8 -0
- package/templates/phone/telephony/telnyx/setup.md +9 -0
- package/templates/phone/telephony/telnyx/telephony.ts +107 -0
- package/templates/phone/telephony/twilio/env.example +6 -0
- package/templates/phone/telephony/twilio/setup.md +7 -0
- package/templates/phone/telephony/twilio/telephony.ts +98 -0
- package/templates/phone/telephony/vonage/env.example +7 -0
- package/templates/phone/telephony/vonage/setup.md +15 -0
- package/templates/phone/telephony/vonage/telephony.ts +105 -0
- package/templates/phone/tsconfig.json +14 -0
- package/templates/vite-react/README.md +39 -0
- package/templates/vite-react/_env.example +2 -0
- package/templates/vite-react/_gitignore +4 -0
- package/templates/vite-react/index.html +12 -0
- package/templates/vite-react/package.json +36 -0
- package/templates/vite-react/src/client/App.tsx +75 -0
- package/templates/vite-react/src/client/main.tsx +10 -0
- package/templates/vite-react/src/client/styles.css +45 -0
- package/templates/vite-react/src/server/index.ts +42 -0
- package/templates/vite-react/tsconfig.json +16 -0
- package/templates/vite-react/tsconfig.server.json +14 -0
- package/templates/vite-react/vite.config.ts +23 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1315 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import * as p from "@clack/prompts";
|
|
5
|
+
import { existsSync as existsSync2, readdirSync } from "fs";
|
|
6
|
+
import path2 from "path";
|
|
7
|
+
import { parseArgs, styleText } from "util";
|
|
8
|
+
|
|
9
|
+
// src/generate.ts
|
|
10
|
+
import { existsSync } from "fs";
|
|
11
|
+
import { copyFile, mkdir, readdir, readFile, writeFile } from "fs/promises";
|
|
12
|
+
import path from "path";
|
|
13
|
+
import { fileURLToPath } from "url";
|
|
14
|
+
|
|
15
|
+
// src/packageManager.ts
|
|
16
|
+
import { spawn } from "child_process";
|
|
17
|
+
var PACKAGE_MANAGERS = ["npm", "pnpm", "yarn", "bun"];
|
|
18
|
+
function detectPackageManager(userAgent = process.env.npm_config_user_agent) {
|
|
19
|
+
const name = userAgent?.split("/")[0];
|
|
20
|
+
return PACKAGE_MANAGERS.includes(name) ? name : "npm";
|
|
21
|
+
}
|
|
22
|
+
function runCommand(pm, script) {
|
|
23
|
+
return pm === "npm" ? `npm run ${script}` : `${pm} ${script}`;
|
|
24
|
+
}
|
|
25
|
+
function install(pm, cwd) {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
const child = spawn(pm, ["install"], {
|
|
28
|
+
cwd,
|
|
29
|
+
stdio: "inherit",
|
|
30
|
+
// npm and pnpm are .cmd scripts on Windows
|
|
31
|
+
shell: process.platform === "win32"
|
|
32
|
+
});
|
|
33
|
+
child.on("error", reject);
|
|
34
|
+
child.on(
|
|
35
|
+
"close",
|
|
36
|
+
(code) => code === 0 ? resolve() : reject(new Error(`${pm} install exited with code ${code}`))
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// src/providers.ts
|
|
42
|
+
var OPENAI_KEY = {
|
|
43
|
+
name: "OPENAI_API_KEY",
|
|
44
|
+
comment: "https://platform.openai.com/api-keys",
|
|
45
|
+
required: true
|
|
46
|
+
};
|
|
47
|
+
var GEMINI_KEY = {
|
|
48
|
+
name: "GEMINI_API_KEY",
|
|
49
|
+
comment: "https://aistudio.google.com/apikey",
|
|
50
|
+
required: true
|
|
51
|
+
};
|
|
52
|
+
var MISTRAL_KEY = {
|
|
53
|
+
name: "MISTRAL_API_KEY",
|
|
54
|
+
comment: "https://console.mistral.ai/api-keys",
|
|
55
|
+
required: true
|
|
56
|
+
};
|
|
57
|
+
var DEEPGRAM_KEY = {
|
|
58
|
+
name: "DEEPGRAM_API_KEY",
|
|
59
|
+
comment: "https://console.deepgram.com",
|
|
60
|
+
required: true
|
|
61
|
+
};
|
|
62
|
+
var XAI_KEY = {
|
|
63
|
+
name: "XAI_API_KEY",
|
|
64
|
+
comment: "https://console.x.ai",
|
|
65
|
+
required: true
|
|
66
|
+
};
|
|
67
|
+
var GRADIUM_KEY = {
|
|
68
|
+
name: "GRADIUM_API_KEY",
|
|
69
|
+
comment: "https://gradium.ai",
|
|
70
|
+
required: true
|
|
71
|
+
};
|
|
72
|
+
var PROVIDERS = [
|
|
73
|
+
// Speech to text
|
|
74
|
+
{
|
|
75
|
+
id: "openai",
|
|
76
|
+
kind: "stt",
|
|
77
|
+
label: "OpenAI",
|
|
78
|
+
dependencies: { "@micdrop/openai": "*" },
|
|
79
|
+
imports: { "@micdrop/openai": ["OpenaiSTT"] },
|
|
80
|
+
env: [OPENAI_KEY],
|
|
81
|
+
code: `new OpenaiSTT({ apiKey: env('OPENAI_API_KEY'), language: 'en' })`,
|
|
82
|
+
docs: "https://micdrop.dev/docs/speech-to-text/openai"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: "gladia",
|
|
86
|
+
kind: "stt",
|
|
87
|
+
label: "Gladia",
|
|
88
|
+
dependencies: { "@micdrop/gladia": "*" },
|
|
89
|
+
imports: { "@micdrop/gladia": ["GladiaSTT"] },
|
|
90
|
+
env: [
|
|
91
|
+
{
|
|
92
|
+
name: "GLADIA_API_KEY",
|
|
93
|
+
comment: "https://app.gladia.io/apikeys",
|
|
94
|
+
required: true
|
|
95
|
+
}
|
|
96
|
+
],
|
|
97
|
+
code: `new GladiaSTT({ apiKey: env('GLADIA_API_KEY') })`,
|
|
98
|
+
docs: "https://micdrop.dev/docs/speech-to-text/gladia"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: "mistral",
|
|
102
|
+
kind: "stt",
|
|
103
|
+
label: "Mistral",
|
|
104
|
+
hint: "Voxtral",
|
|
105
|
+
dependencies: { "@micdrop/mistral": "*" },
|
|
106
|
+
imports: { "@micdrop/mistral": ["MistralSTT"] },
|
|
107
|
+
env: [MISTRAL_KEY],
|
|
108
|
+
code: `new MistralSTT({ apiKey: env('MISTRAL_API_KEY') })`,
|
|
109
|
+
docs: "https://micdrop.dev/docs/speech-to-text/mistral"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
id: "gemini",
|
|
113
|
+
kind: "stt",
|
|
114
|
+
label: "Gemini",
|
|
115
|
+
dependencies: { "@micdrop/gemini": "*" },
|
|
116
|
+
imports: { "@micdrop/gemini": ["GeminiSTT"] },
|
|
117
|
+
env: [GEMINI_KEY],
|
|
118
|
+
code: `new GeminiSTT({ apiKey: env('GEMINI_API_KEY'), language: 'en' })`,
|
|
119
|
+
docs: "https://micdrop.dev/docs/speech-to-text/gemini"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
id: "deepgram",
|
|
123
|
+
kind: "stt",
|
|
124
|
+
label: "Deepgram",
|
|
125
|
+
hint: "Nova-3",
|
|
126
|
+
dependencies: { "@micdrop/deepgram": "*" },
|
|
127
|
+
imports: { "@micdrop/deepgram": ["DeepgramSTT"] },
|
|
128
|
+
env: [DEEPGRAM_KEY],
|
|
129
|
+
code: `new DeepgramSTT({
|
|
130
|
+
apiKey: env('DEEPGRAM_API_KEY'),
|
|
131
|
+
model: 'nova-3',
|
|
132
|
+
language: 'en',
|
|
133
|
+
})`,
|
|
134
|
+
docs: "https://micdrop.dev/docs/speech-to-text/deepgram"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
id: "deepgram-flux",
|
|
138
|
+
kind: "stt",
|
|
139
|
+
label: "Deepgram Flux",
|
|
140
|
+
hint: "conversational model",
|
|
141
|
+
dependencies: { "@micdrop/deepgram": "*" },
|
|
142
|
+
imports: { "@micdrop/deepgram": ["DeepgramFluxSTT"] },
|
|
143
|
+
env: [DEEPGRAM_KEY],
|
|
144
|
+
code: `new DeepgramFluxSTT({
|
|
145
|
+
apiKey: env('DEEPGRAM_API_KEY'),
|
|
146
|
+
// English, or flux-general-multi for nine more languages
|
|
147
|
+
model: 'flux-general-en',
|
|
148
|
+
})`,
|
|
149
|
+
docs: "https://micdrop.dev/docs/speech-to-text/deepgram"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
id: "assemblyai",
|
|
153
|
+
kind: "stt",
|
|
154
|
+
label: "AssemblyAI",
|
|
155
|
+
hint: "Universal-Streaming",
|
|
156
|
+
dependencies: { "@micdrop/assemblyai": "*" },
|
|
157
|
+
imports: { "@micdrop/assemblyai": ["AssemblyAISTT"] },
|
|
158
|
+
env: [
|
|
159
|
+
{
|
|
160
|
+
name: "ASSEMBLYAI_API_KEY",
|
|
161
|
+
comment: "https://www.assemblyai.com/dashboard",
|
|
162
|
+
required: true
|
|
163
|
+
}
|
|
164
|
+
],
|
|
165
|
+
code: `new AssemblyAISTT({ apiKey: env('ASSEMBLYAI_API_KEY') })`,
|
|
166
|
+
docs: "https://micdrop.dev/docs/speech-to-text/assemblyai"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
id: "speechmatics",
|
|
170
|
+
kind: "stt",
|
|
171
|
+
label: "Speechmatics",
|
|
172
|
+
dependencies: { "@micdrop/speechmatics": "*" },
|
|
173
|
+
imports: { "@micdrop/speechmatics": ["SpeechmaticsSTT"] },
|
|
174
|
+
env: [
|
|
175
|
+
{
|
|
176
|
+
name: "SPEECHMATICS_API_KEY",
|
|
177
|
+
comment: "https://portal.speechmatics.com",
|
|
178
|
+
required: true
|
|
179
|
+
}
|
|
180
|
+
],
|
|
181
|
+
code: `new SpeechmaticsSTT({
|
|
182
|
+
apiKey: env('SPEECHMATICS_API_KEY'),
|
|
183
|
+
language: 'en',
|
|
184
|
+
region: 'eu',
|
|
185
|
+
})`,
|
|
186
|
+
docs: "https://micdrop.dev/docs/speech-to-text/speechmatics"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
id: "grok",
|
|
190
|
+
kind: "stt",
|
|
191
|
+
label: "Grok",
|
|
192
|
+
hint: "xAI",
|
|
193
|
+
dependencies: { "@micdrop/grok": "*", "@micdrop/openai": "*" },
|
|
194
|
+
imports: { "@micdrop/grok": ["GrokSTT"] },
|
|
195
|
+
env: [XAI_KEY],
|
|
196
|
+
code: `new GrokSTT({ apiKey: env('XAI_API_KEY'), language: 'en' })`,
|
|
197
|
+
docs: "https://micdrop.dev/docs/speech-to-text/grok"
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
id: "whisper",
|
|
201
|
+
kind: "stt",
|
|
202
|
+
label: "Whisper",
|
|
203
|
+
hint: "local, no key",
|
|
204
|
+
local: true,
|
|
205
|
+
dependencies: { "@micdrop/whisper": "*" },
|
|
206
|
+
imports: { "@micdrop/whisper": ["WhisperSTT"] },
|
|
207
|
+
env: [],
|
|
208
|
+
code: `new WhisperSTT({ model: 'base', language: 'en' })`,
|
|
209
|
+
docs: "https://micdrop.dev/docs/speech-to-text/whisper"
|
|
210
|
+
},
|
|
211
|
+
// Agents
|
|
212
|
+
{
|
|
213
|
+
id: "openai",
|
|
214
|
+
kind: "agent",
|
|
215
|
+
label: "OpenAI",
|
|
216
|
+
dependencies: { "@micdrop/openai": "*" },
|
|
217
|
+
imports: { "@micdrop/openai": ["OpenaiAgent"] },
|
|
218
|
+
env: [OPENAI_KEY],
|
|
219
|
+
code: `new OpenaiAgent({
|
|
220
|
+
apiKey: env('OPENAI_API_KEY'),
|
|
221
|
+
model: 'gpt-5.2',
|
|
222
|
+
// Answers sooner without reasoning first
|
|
223
|
+
settings: { reasoning: { effort: 'none' } },
|
|
224
|
+
systemPrompt,
|
|
225
|
+
tools,
|
|
226
|
+
})`,
|
|
227
|
+
docs: "https://micdrop.dev/docs/agents/openai"
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
id: "mistral",
|
|
231
|
+
kind: "agent",
|
|
232
|
+
label: "Mistral",
|
|
233
|
+
dependencies: { "@micdrop/mistral": "*" },
|
|
234
|
+
imports: { "@micdrop/mistral": ["MistralAgent"] },
|
|
235
|
+
env: [MISTRAL_KEY],
|
|
236
|
+
code: `new MistralAgent({
|
|
237
|
+
apiKey: env('MISTRAL_API_KEY'),
|
|
238
|
+
model: 'mistral-medium-latest',
|
|
239
|
+
// Answers sooner without reasoning first
|
|
240
|
+
settings: { reasoningEffort: 'none' },
|
|
241
|
+
systemPrompt,
|
|
242
|
+
tools,
|
|
243
|
+
})`,
|
|
244
|
+
docs: "https://micdrop.dev/docs/agents/mistral"
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
id: "gemini",
|
|
248
|
+
kind: "agent",
|
|
249
|
+
label: "Gemini",
|
|
250
|
+
dependencies: { "@micdrop/gemini": "*" },
|
|
251
|
+
imports: { "@micdrop/gemini": ["GeminiAgent"] },
|
|
252
|
+
env: [GEMINI_KEY],
|
|
253
|
+
code: `new GeminiAgent({
|
|
254
|
+
apiKey: env('GEMINI_API_KEY'),
|
|
255
|
+
// Answers in about a second, without reasoning first
|
|
256
|
+
model: 'gemini-3.5-flash-lite',
|
|
257
|
+
systemPrompt,
|
|
258
|
+
tools,
|
|
259
|
+
})`,
|
|
260
|
+
docs: "https://micdrop.dev/docs/agents/gemini"
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
id: "mastra",
|
|
264
|
+
kind: "agent",
|
|
265
|
+
label: "Mastra",
|
|
266
|
+
hint: "agent framework, on OpenAI",
|
|
267
|
+
dependencies: { "@micdrop/mastra": "*", "@mastra/core": "^1.86.0" },
|
|
268
|
+
imports: {
|
|
269
|
+
"@mastra/core/agent": ["Agent"],
|
|
270
|
+
"@micdrop/mastra": ["MastraAgent"]
|
|
271
|
+
},
|
|
272
|
+
env: [OPENAI_KEY],
|
|
273
|
+
setup: `// Give it the tools, workflows and memory of your Mastra project
|
|
274
|
+
// https://mastra.ai/docs/agents/overview
|
|
275
|
+
const assistant = new Agent({
|
|
276
|
+
id: 'assistant',
|
|
277
|
+
name: 'Assistant',
|
|
278
|
+
instructions: 'Answer in short spoken sentences.',
|
|
279
|
+
// Reads OPENAI_API_KEY
|
|
280
|
+
model: 'openai/gpt-5.2',
|
|
281
|
+
})`,
|
|
282
|
+
code: `new MastraAgent({
|
|
283
|
+
agent: assistant,
|
|
284
|
+
// Answers sooner without reasoning first
|
|
285
|
+
streamOptions: {
|
|
286
|
+
providerOptions: { openai: { reasoningEffort: 'none' } },
|
|
287
|
+
},
|
|
288
|
+
systemPrompt,
|
|
289
|
+
tools,
|
|
290
|
+
})`,
|
|
291
|
+
docs: "https://micdrop.dev/docs/agents/mastra"
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
id: "openai-agents",
|
|
295
|
+
kind: "agent",
|
|
296
|
+
label: "OpenAI Agents SDK",
|
|
297
|
+
hint: "handoffs and guardrails",
|
|
298
|
+
dependencies: {
|
|
299
|
+
"@micdrop/openai-agents": "*",
|
|
300
|
+
"@openai/agents": "^0.22.0"
|
|
301
|
+
},
|
|
302
|
+
imports: {
|
|
303
|
+
"@micdrop/openai-agents": ["OpenaiAgentsAgent"],
|
|
304
|
+
"@openai/agents": ["Agent"]
|
|
305
|
+
},
|
|
306
|
+
env: [OPENAI_KEY],
|
|
307
|
+
setup: `// Give it the tools, handoffs and guardrails of the Agents SDK
|
|
308
|
+
// https://openai.github.io/openai-agents-js/
|
|
309
|
+
const assistant = new Agent({
|
|
310
|
+
name: 'Assistant',
|
|
311
|
+
instructions: 'Answer in short spoken sentences.',
|
|
312
|
+
// Reads OPENAI_API_KEY
|
|
313
|
+
model: 'gpt-5.2',
|
|
314
|
+
// Answers sooner without reasoning first
|
|
315
|
+
modelSettings: { reasoning: { effort: 'none' } },
|
|
316
|
+
})`,
|
|
317
|
+
code: `new OpenaiAgentsAgent({ agent: assistant, systemPrompt, tools })`,
|
|
318
|
+
docs: "https://micdrop.dev/docs/agents/openai-agents"
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
id: "ollama",
|
|
322
|
+
kind: "agent",
|
|
323
|
+
label: "Ollama",
|
|
324
|
+
hint: "local, no key",
|
|
325
|
+
local: true,
|
|
326
|
+
dependencies: { "@micdrop/ai-sdk": "*", "@ai-sdk/openai": "^4.0.122" },
|
|
327
|
+
imports: {
|
|
328
|
+
"@ai-sdk/openai": ["createOpenAI"],
|
|
329
|
+
"@micdrop/ai-sdk": ["AiSdkAgent"]
|
|
330
|
+
},
|
|
331
|
+
env: [
|
|
332
|
+
{
|
|
333
|
+
name: "OLLAMA_URL",
|
|
334
|
+
comment: "Ollama serves the OpenAI protocol on /v1",
|
|
335
|
+
example: "http://localhost:11434/v1"
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
name: "OLLAMA_MODEL",
|
|
339
|
+
comment: "Pulled beforehand with `ollama pull`. The instruct tag answers without reasoning first.",
|
|
340
|
+
example: "qwen3:4b-instruct"
|
|
341
|
+
}
|
|
342
|
+
],
|
|
343
|
+
setup: `const ollama = createOpenAI({
|
|
344
|
+
baseURL: process.env.OLLAMA_URL || 'http://localhost:11434/v1',
|
|
345
|
+
apiKey: 'ollama', // Unused, the SDK refuses to start without one
|
|
346
|
+
})`,
|
|
347
|
+
code: `new AiSdkAgent({
|
|
348
|
+
// .chat() rather than the provider itself: a local server answers on the
|
|
349
|
+
// chat completions route, not on the Responses API
|
|
350
|
+
model: ollama.chat(process.env.OLLAMA_MODEL || 'qwen3:4b-instruct'),
|
|
351
|
+
providerOptions: { openai: { reasoningEffort: 'none' } },
|
|
352
|
+
systemPrompt,
|
|
353
|
+
tools,
|
|
354
|
+
})`,
|
|
355
|
+
docs: "https://micdrop.dev/docs/local-models/agent"
|
|
356
|
+
},
|
|
357
|
+
// Text to speech
|
|
358
|
+
{
|
|
359
|
+
id: "openai",
|
|
360
|
+
kind: "tts",
|
|
361
|
+
label: "OpenAI",
|
|
362
|
+
dependencies: { "@micdrop/openai": "*" },
|
|
363
|
+
imports: { "@micdrop/openai": ["OpenaiTTS"] },
|
|
364
|
+
env: [OPENAI_KEY],
|
|
365
|
+
code: `new OpenaiTTS({ apiKey: env('OPENAI_API_KEY'), voice: 'alloy' })`,
|
|
366
|
+
docs: "https://micdrop.dev/docs/text-to-speech/openai"
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
id: "elevenlabs",
|
|
370
|
+
kind: "tts",
|
|
371
|
+
label: "ElevenLabs",
|
|
372
|
+
dependencies: { "@micdrop/elevenlabs": "*" },
|
|
373
|
+
imports: { "@micdrop/elevenlabs": ["ElevenLabsTTS"] },
|
|
374
|
+
env: [
|
|
375
|
+
{
|
|
376
|
+
name: "ELEVENLABS_API_KEY",
|
|
377
|
+
comment: "https://elevenlabs.io/app/settings/api-keys",
|
|
378
|
+
required: true
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
name: "ELEVENLABS_VOICE_ID",
|
|
382
|
+
comment: "Any voice of your library, Rachel by default",
|
|
383
|
+
example: "21m00Tcm4TlvDq8ikWAM"
|
|
384
|
+
}
|
|
385
|
+
],
|
|
386
|
+
code: `new ElevenLabsTTS({
|
|
387
|
+
apiKey: env('ELEVENLABS_API_KEY'),
|
|
388
|
+
voiceId: process.env.ELEVENLABS_VOICE_ID || '21m00Tcm4TlvDq8ikWAM',
|
|
389
|
+
})`,
|
|
390
|
+
docs: "https://micdrop.dev/docs/text-to-speech/elevenlabs"
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
id: "cartesia",
|
|
394
|
+
kind: "tts",
|
|
395
|
+
label: "Cartesia",
|
|
396
|
+
dependencies: { "@micdrop/cartesia": "*" },
|
|
397
|
+
imports: { "@micdrop/cartesia": ["CartesiaTTS"] },
|
|
398
|
+
env: [
|
|
399
|
+
{
|
|
400
|
+
name: "CARTESIA_API_KEY",
|
|
401
|
+
comment: "https://play.cartesia.ai/keys",
|
|
402
|
+
required: true
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
name: "CARTESIA_VOICE_ID",
|
|
406
|
+
comment: "Any voice of the Cartesia library",
|
|
407
|
+
example: "a0e99841-438c-4a64-b679-ae501e7d6091"
|
|
408
|
+
}
|
|
409
|
+
],
|
|
410
|
+
code: `new CartesiaTTS({
|
|
411
|
+
apiKey: env('CARTESIA_API_KEY'),
|
|
412
|
+
modelId: 'sonic-3.6',
|
|
413
|
+
voiceId:
|
|
414
|
+
process.env.CARTESIA_VOICE_ID || 'a0e99841-438c-4a64-b679-ae501e7d6091',
|
|
415
|
+
})`,
|
|
416
|
+
docs: "https://micdrop.dev/docs/text-to-speech/cartesia"
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
id: "mistral",
|
|
420
|
+
kind: "tts",
|
|
421
|
+
label: "Mistral",
|
|
422
|
+
hint: "Voxtral",
|
|
423
|
+
dependencies: { "@micdrop/mistral": "*" },
|
|
424
|
+
imports: { "@micdrop/mistral": ["MistralTTS"] },
|
|
425
|
+
env: [MISTRAL_KEY],
|
|
426
|
+
code: `new MistralTTS({
|
|
427
|
+
apiKey: env('MISTRAL_API_KEY'),
|
|
428
|
+
voiceId: 'voice_3150',
|
|
429
|
+
})`,
|
|
430
|
+
docs: "https://micdrop.dev/docs/text-to-speech/mistral"
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
id: "gemini",
|
|
434
|
+
kind: "tts",
|
|
435
|
+
label: "Gemini",
|
|
436
|
+
dependencies: { "@micdrop/gemini": "*" },
|
|
437
|
+
imports: { "@micdrop/gemini": ["GeminiTTS"] },
|
|
438
|
+
env: [GEMINI_KEY],
|
|
439
|
+
code: `new GeminiTTS({ apiKey: env('GEMINI_API_KEY'), voice: 'Kore' })`,
|
|
440
|
+
docs: "https://micdrop.dev/docs/text-to-speech/gemini"
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
id: "deepgram",
|
|
444
|
+
kind: "tts",
|
|
445
|
+
label: "Deepgram",
|
|
446
|
+
hint: "Aura-2",
|
|
447
|
+
dependencies: { "@micdrop/deepgram": "*" },
|
|
448
|
+
imports: { "@micdrop/deepgram": ["DeepgramTTS"] },
|
|
449
|
+
env: [DEEPGRAM_KEY],
|
|
450
|
+
code: `new DeepgramTTS({
|
|
451
|
+
apiKey: env('DEEPGRAM_API_KEY'),
|
|
452
|
+
voice: 'aura-2-thalia-en',
|
|
453
|
+
})`,
|
|
454
|
+
docs: "https://micdrop.dev/docs/text-to-speech/deepgram"
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
id: "inworld",
|
|
458
|
+
kind: "tts",
|
|
459
|
+
label: "Inworld",
|
|
460
|
+
dependencies: { "@micdrop/inworld": "*" },
|
|
461
|
+
imports: { "@micdrop/inworld": ["InworldTTS"] },
|
|
462
|
+
env: [
|
|
463
|
+
{
|
|
464
|
+
name: "INWORLD_API_KEY",
|
|
465
|
+
comment: "The base64 key of the Inworld portal, https://platform.inworld.ai",
|
|
466
|
+
required: true
|
|
467
|
+
}
|
|
468
|
+
],
|
|
469
|
+
code: `new InworldTTS({
|
|
470
|
+
apiKey: env('INWORLD_API_KEY'),
|
|
471
|
+
voiceId: 'Dennis',
|
|
472
|
+
modelId: 'inworld-tts-2',
|
|
473
|
+
})`,
|
|
474
|
+
docs: "https://micdrop.dev/docs/text-to-speech/inworld"
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
id: "gradium",
|
|
478
|
+
kind: "tts",
|
|
479
|
+
label: "Gradium",
|
|
480
|
+
dependencies: { "@micdrop/gradium": "*" },
|
|
481
|
+
imports: { "@micdrop/gradium": ["GradiumTTS"] },
|
|
482
|
+
env: [
|
|
483
|
+
GRADIUM_KEY,
|
|
484
|
+
{
|
|
485
|
+
name: "GRADIUM_VOICE_ID",
|
|
486
|
+
comment: "Any voice of your Gradium account or catalog",
|
|
487
|
+
example: "Bla6SbVMczYnOhfK"
|
|
488
|
+
}
|
|
489
|
+
],
|
|
490
|
+
code: `new GradiumTTS({
|
|
491
|
+
apiKey: env('GRADIUM_API_KEY'),
|
|
492
|
+
voiceId: process.env.GRADIUM_VOICE_ID || 'Bla6SbVMczYnOhfK',
|
|
493
|
+
region: 'eu',
|
|
494
|
+
})`,
|
|
495
|
+
docs: "https://micdrop.dev/docs/text-to-speech/gradium"
|
|
496
|
+
},
|
|
497
|
+
{
|
|
498
|
+
id: "grok",
|
|
499
|
+
kind: "tts",
|
|
500
|
+
label: "Grok",
|
|
501
|
+
hint: "xAI",
|
|
502
|
+
dependencies: { "@micdrop/grok": "*", "@micdrop/openai": "*" },
|
|
503
|
+
imports: { "@micdrop/grok": ["GrokTTS"] },
|
|
504
|
+
env: [XAI_KEY],
|
|
505
|
+
code: `new GrokTTS({
|
|
506
|
+
apiKey: env('XAI_API_KEY'),
|
|
507
|
+
voice: 'eve',
|
|
508
|
+
language: 'en',
|
|
509
|
+
})`,
|
|
510
|
+
docs: "https://micdrop.dev/docs/text-to-speech/grok"
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
id: "kokoro",
|
|
514
|
+
kind: "tts",
|
|
515
|
+
label: "Kokoro",
|
|
516
|
+
hint: "local, no key, English",
|
|
517
|
+
local: true,
|
|
518
|
+
dependencies: { "@micdrop/kokoro": "*" },
|
|
519
|
+
imports: { "@micdrop/kokoro": ["KokoroTTS"] },
|
|
520
|
+
env: [],
|
|
521
|
+
code: `new KokoroTTS({ voice: 'af_heart' })`,
|
|
522
|
+
docs: "https://micdrop.dev/docs/text-to-speech/kokoro"
|
|
523
|
+
},
|
|
524
|
+
// Speech to speech
|
|
525
|
+
{
|
|
526
|
+
id: "openai",
|
|
527
|
+
kind: "realtime",
|
|
528
|
+
label: "OpenAI Realtime",
|
|
529
|
+
dependencies: { "@micdrop/openai": "*" },
|
|
530
|
+
imports: { "@micdrop/openai": ["OpenaiRealtime"] },
|
|
531
|
+
env: [OPENAI_KEY],
|
|
532
|
+
code: `new OpenaiRealtime({
|
|
533
|
+
apiKey: env('OPENAI_API_KEY'),
|
|
534
|
+
model: 'gpt-realtime-2.1',
|
|
535
|
+
// Reasons as little as possible, so it answers sooner
|
|
536
|
+
reasoningEffort: 'minimal',
|
|
537
|
+
language: 'en',
|
|
538
|
+
systemPrompt,
|
|
539
|
+
tools,
|
|
540
|
+
})`,
|
|
541
|
+
docs: "https://micdrop.dev/docs/realtime/openai-realtime"
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
id: "gemini",
|
|
545
|
+
kind: "realtime",
|
|
546
|
+
label: "Gemini Live",
|
|
547
|
+
dependencies: { "@micdrop/gemini": "*" },
|
|
548
|
+
imports: { "@micdrop/gemini": ["GeminiLive"] },
|
|
549
|
+
env: [GEMINI_KEY],
|
|
550
|
+
code: `new GeminiLive({
|
|
551
|
+
apiKey: env('GEMINI_API_KEY'),
|
|
552
|
+
model: 'gemini-3.8-live',
|
|
553
|
+
systemPrompt,
|
|
554
|
+
tools,
|
|
555
|
+
})`,
|
|
556
|
+
docs: "https://micdrop.dev/docs/realtime/gemini-live"
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
id: "grok",
|
|
560
|
+
kind: "realtime",
|
|
561
|
+
label: "Grok Voice",
|
|
562
|
+
hint: "xAI",
|
|
563
|
+
dependencies: { "@micdrop/grok": "*", "@micdrop/openai": "*" },
|
|
564
|
+
imports: { "@micdrop/grok": ["GrokVoice"] },
|
|
565
|
+
env: [XAI_KEY],
|
|
566
|
+
code: `new GrokVoice({
|
|
567
|
+
apiKey: env('XAI_API_KEY'),
|
|
568
|
+
voice: 'eve',
|
|
569
|
+
// Answers sooner without reasoning first
|
|
570
|
+
reasoningEffort: 'none',
|
|
571
|
+
language: 'en',
|
|
572
|
+
systemPrompt,
|
|
573
|
+
tools,
|
|
574
|
+
})`,
|
|
575
|
+
docs: "https://micdrop.dev/docs/realtime/grok-voice"
|
|
576
|
+
}
|
|
577
|
+
];
|
|
578
|
+
function providersOf(kind) {
|
|
579
|
+
return PROVIDERS.filter((provider) => provider.kind === kind);
|
|
580
|
+
}
|
|
581
|
+
function findProvider(kind, id) {
|
|
582
|
+
const provider = PROVIDERS.find((p2) => p2.kind === kind && p2.id === id);
|
|
583
|
+
if (!provider) {
|
|
584
|
+
const ids2 = providersOf(kind).map((p2) => p2.id).join(", ");
|
|
585
|
+
throw new Error(`Unknown ${KIND_LABELS[kind]} "${id}", pick one of: ${ids2}`);
|
|
586
|
+
}
|
|
587
|
+
return provider;
|
|
588
|
+
}
|
|
589
|
+
var KIND_LABELS = {
|
|
590
|
+
stt: "speech to text",
|
|
591
|
+
agent: "agent",
|
|
592
|
+
tts: "text to speech",
|
|
593
|
+
realtime: "realtime model"
|
|
594
|
+
};
|
|
595
|
+
var PRESETS = {
|
|
596
|
+
openai: {
|
|
597
|
+
label: "OpenAI",
|
|
598
|
+
hint: "speech to text, GPT and voice, one key",
|
|
599
|
+
mode: "cascade",
|
|
600
|
+
stt: "openai",
|
|
601
|
+
agent: "openai",
|
|
602
|
+
tts: "openai"
|
|
603
|
+
},
|
|
604
|
+
"openai-realtime": {
|
|
605
|
+
label: "OpenAI Realtime",
|
|
606
|
+
hint: "one speech to speech model, one key",
|
|
607
|
+
mode: "realtime",
|
|
608
|
+
realtime: "openai"
|
|
609
|
+
},
|
|
610
|
+
"gemini-live": {
|
|
611
|
+
label: "Gemini Live",
|
|
612
|
+
hint: "one speech to speech model, one key",
|
|
613
|
+
mode: "realtime",
|
|
614
|
+
realtime: "gemini"
|
|
615
|
+
},
|
|
616
|
+
"grok-voice": {
|
|
617
|
+
label: "Grok Voice",
|
|
618
|
+
hint: "one speech to speech model by xAI, one key",
|
|
619
|
+
mode: "realtime",
|
|
620
|
+
realtime: "grok"
|
|
621
|
+
},
|
|
622
|
+
mistral: {
|
|
623
|
+
label: "Mistral",
|
|
624
|
+
hint: "Voxtral and Mistral Medium, one key",
|
|
625
|
+
mode: "cascade",
|
|
626
|
+
stt: "mistral",
|
|
627
|
+
agent: "mistral",
|
|
628
|
+
tts: "mistral"
|
|
629
|
+
},
|
|
630
|
+
europe: {
|
|
631
|
+
label: "European providers",
|
|
632
|
+
hint: "Speechmatics, Mistral and Gradium, on their EU endpoints",
|
|
633
|
+
mode: "cascade",
|
|
634
|
+
stt: "speechmatics",
|
|
635
|
+
agent: "mistral",
|
|
636
|
+
tts: "gradium"
|
|
637
|
+
},
|
|
638
|
+
local: {
|
|
639
|
+
label: "Local models",
|
|
640
|
+
hint: "Whisper, Ollama and Kokoro, no key, nothing leaves the machine",
|
|
641
|
+
mode: "cascade",
|
|
642
|
+
stt: "whisper",
|
|
643
|
+
agent: "ollama",
|
|
644
|
+
tts: "kokoro"
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
function resolveProviders(choice) {
|
|
648
|
+
if (choice.mode === "realtime") {
|
|
649
|
+
return [findProvider("realtime", choice.realtime)];
|
|
650
|
+
}
|
|
651
|
+
return [
|
|
652
|
+
findProvider("stt", choice.stt),
|
|
653
|
+
findProvider("agent", choice.agent),
|
|
654
|
+
findProvider("tts", choice.tts)
|
|
655
|
+
];
|
|
656
|
+
}
|
|
657
|
+
function renderAiFile(choice) {
|
|
658
|
+
const providers = resolveProviders(choice);
|
|
659
|
+
const imports = /* @__PURE__ */ new Map();
|
|
660
|
+
for (const provider of providers) {
|
|
661
|
+
for (const [module, names] of Object.entries(provider.imports)) {
|
|
662
|
+
const set = imports.get(module) ?? /* @__PURE__ */ new Set();
|
|
663
|
+
names.forEach((name) => set.add(name));
|
|
664
|
+
imports.set(module, set);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
imports.set("@micdrop/server", /* @__PURE__ */ new Set(["Tool"]));
|
|
668
|
+
const importLines = [...imports.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([module, names]) => {
|
|
669
|
+
const list = [...names].sort().join(", ");
|
|
670
|
+
return module === "@micdrop/server" ? `import type { ${list} } from '${module}'` : `import { ${list} } from '${module}'`;
|
|
671
|
+
});
|
|
672
|
+
const usesEnv = providers.some((p2) => p2.code.includes("env("));
|
|
673
|
+
const setups = [...new Set(providers.map((p2) => p2.setup).filter(Boolean))];
|
|
674
|
+
const code = providers.map((p2) => p2.code.replace(/\n/g, "\n "));
|
|
675
|
+
const body = choice.mode === "realtime" ? ` return {
|
|
676
|
+
// Hears the user and answers with its own voice
|
|
677
|
+
// ${providers[0].docs}
|
|
678
|
+
realtime: ${code[0]},
|
|
679
|
+
}` : ` return {
|
|
680
|
+
// The ears, speech to text
|
|
681
|
+
// ${providers[0].docs}
|
|
682
|
+
stt: ${code[0]},
|
|
683
|
+
|
|
684
|
+
// The brain, an LLM that writes the answers
|
|
685
|
+
// ${providers[1].docs}
|
|
686
|
+
agent: ${code[1]},
|
|
687
|
+
|
|
688
|
+
// The mouth, text to speech
|
|
689
|
+
// ${providers[2].docs}
|
|
690
|
+
tts: ${code[2]},
|
|
691
|
+
}`;
|
|
692
|
+
const envHelper = usesEnv ? `
|
|
693
|
+
/** Reads a variable of .env, and stops the server when it is missing */
|
|
694
|
+
function env(name: string): string {
|
|
695
|
+
const value = process.env[name]
|
|
696
|
+
if (!value) throw new Error(\`\${name} is missing, set it in .env\`)
|
|
697
|
+
return value
|
|
698
|
+
}
|
|
699
|
+
` : "";
|
|
700
|
+
const requiredKeys = [
|
|
701
|
+
...new Set(
|
|
702
|
+
providers.flatMap(
|
|
703
|
+
(p2) => p2.env.filter((e) => e.required).map((e) => e.name)
|
|
704
|
+
)
|
|
705
|
+
)
|
|
706
|
+
];
|
|
707
|
+
const check = requiredKeys.length ? `
|
|
708
|
+
// Checked when the server starts rather than during the first call
|
|
709
|
+
${requiredKeys.map((key) => `env('${key}')`).join("\n")}
|
|
710
|
+
` : "";
|
|
711
|
+
return `// The AI providers of a call, picked when the project was created.
|
|
712
|
+
// Swap any of them for another one: https://micdrop.dev/docs/providers
|
|
713
|
+
|
|
714
|
+
${importLines.join("\n")}
|
|
715
|
+
${setups.length ? `
|
|
716
|
+
${setups.join("\n\n")}
|
|
717
|
+
` : ""}
|
|
718
|
+
export interface AiOptions {
|
|
719
|
+
/** What the assistant is and how it speaks */
|
|
720
|
+
systemPrompt: string
|
|
721
|
+
/** Functions the assistant can call during the call */
|
|
722
|
+
tools?: Tool[]
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
/** Builds the AI of one call, to spread into the MicdropServer options */
|
|
726
|
+
export function createAi({ systemPrompt, tools }: AiOptions) {
|
|
727
|
+
${body}
|
|
728
|
+
}
|
|
729
|
+
${envHelper}${check}`;
|
|
730
|
+
}
|
|
731
|
+
function renderEnvVars(choice) {
|
|
732
|
+
const seen = /* @__PURE__ */ new Set();
|
|
733
|
+
const blocks = [];
|
|
734
|
+
for (const provider of resolveProviders(choice)) {
|
|
735
|
+
for (const variable of provider.env) {
|
|
736
|
+
if (seen.has(variable.name)) continue;
|
|
737
|
+
seen.add(variable.name);
|
|
738
|
+
blocks.push(
|
|
739
|
+
`# ${variable.comment}
|
|
740
|
+
${variable.name}=${variable.example ?? ""}`
|
|
741
|
+
);
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
return blocks.join("\n\n");
|
|
745
|
+
}
|
|
746
|
+
function providerDependencies(choice) {
|
|
747
|
+
return Object.assign(
|
|
748
|
+
{},
|
|
749
|
+
...resolveProviders(choice).map((provider) => provider.dependencies)
|
|
750
|
+
);
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
// src/templates.ts
|
|
754
|
+
var TEMPLATES = [
|
|
755
|
+
{
|
|
756
|
+
id: "nextjs",
|
|
757
|
+
label: "Next.js",
|
|
758
|
+
hint: "Next.js app and a Node WebSocket server",
|
|
759
|
+
aiFile: "server/ai.ts",
|
|
760
|
+
envDir: ".",
|
|
761
|
+
dependencyField: "dependencies",
|
|
762
|
+
serverTsconfig: "tsconfig.server.json",
|
|
763
|
+
nextStep: "Open http://localhost:3000 and start a call"
|
|
764
|
+
},
|
|
765
|
+
{
|
|
766
|
+
id: "vite-react",
|
|
767
|
+
label: "Vite + React",
|
|
768
|
+
hint: "React app built with Vite, Fastify server",
|
|
769
|
+
aiFile: "src/server/ai.ts",
|
|
770
|
+
envDir: ".",
|
|
771
|
+
dependencyField: "dependencies",
|
|
772
|
+
serverTsconfig: "tsconfig.server.json",
|
|
773
|
+
nextStep: "Open http://localhost:5173 and start a call"
|
|
774
|
+
},
|
|
775
|
+
{
|
|
776
|
+
id: "expo",
|
|
777
|
+
label: "Expo",
|
|
778
|
+
hint: "iOS and Android app with React Native, Node server",
|
|
779
|
+
aiFile: "server/ai.ts",
|
|
780
|
+
envDir: "server",
|
|
781
|
+
dependencyField: "devDependencies",
|
|
782
|
+
serverTsconfig: "server/tsconfig.json",
|
|
783
|
+
nextStep: "Run the app on a simulator or a phone, as the README explains"
|
|
784
|
+
},
|
|
785
|
+
{
|
|
786
|
+
id: "phone",
|
|
787
|
+
label: "Phone agent",
|
|
788
|
+
hint: "Answers a phone number: Twilio, Telnyx, Vonage or Plivo",
|
|
789
|
+
aiFile: "src/ai.ts",
|
|
790
|
+
envDir: ".",
|
|
791
|
+
dependencyField: "dependencies",
|
|
792
|
+
telephony: true,
|
|
793
|
+
serverTsconfig: "tsconfig.json",
|
|
794
|
+
nextStep: "Expose the server with a tunnel and point your number to it"
|
|
795
|
+
},
|
|
796
|
+
{
|
|
797
|
+
id: "node",
|
|
798
|
+
label: "Node server",
|
|
799
|
+
hint: "A WebSocket server alone, for any client",
|
|
800
|
+
aiFile: "src/ai.ts",
|
|
801
|
+
envDir: ".",
|
|
802
|
+
dependencyField: "dependencies",
|
|
803
|
+
serverTsconfig: "tsconfig.json",
|
|
804
|
+
nextStep: "Connect a Micdrop client to ws://localhost:3001"
|
|
805
|
+
}
|
|
806
|
+
];
|
|
807
|
+
var TELEPHONY_PROVIDERS = [
|
|
808
|
+
{ id: "twilio", label: "Twilio", hint: "also SignalWire" },
|
|
809
|
+
{ id: "telnyx", label: "Telnyx", hint: "Call Control" },
|
|
810
|
+
{ id: "vonage", label: "Vonage", hint: "Voice API" },
|
|
811
|
+
{ id: "plivo", label: "Plivo", hint: "Voice API" }
|
|
812
|
+
];
|
|
813
|
+
function findTemplate(id) {
|
|
814
|
+
const template = TEMPLATES.find((t) => t.id === id);
|
|
815
|
+
if (!template) {
|
|
816
|
+
const ids2 = TEMPLATES.map((t) => t.id).join(", ");
|
|
817
|
+
throw new Error(`Unknown template "${id}", pick one of: ${ids2}`);
|
|
818
|
+
}
|
|
819
|
+
return template;
|
|
820
|
+
}
|
|
821
|
+
function findTelephony(id) {
|
|
822
|
+
const provider = TELEPHONY_PROVIDERS.find((t) => t.id === id);
|
|
823
|
+
if (!provider) {
|
|
824
|
+
const ids2 = TELEPHONY_PROVIDERS.map((t) => t.id).join(", ");
|
|
825
|
+
throw new Error(`Unknown telephony provider "${id}", pick one of: ${ids2}`);
|
|
826
|
+
}
|
|
827
|
+
return provider;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
// ../ai-sdk/package.json
|
|
831
|
+
var version = "2.3.0";
|
|
832
|
+
|
|
833
|
+
// ../assemblyai/package.json
|
|
834
|
+
var version2 = "1.0.0";
|
|
835
|
+
|
|
836
|
+
// ../cartesia/package.json
|
|
837
|
+
var version3 = "1.5.0";
|
|
838
|
+
|
|
839
|
+
// ../client/package.json
|
|
840
|
+
var version4 = "3.9.0";
|
|
841
|
+
|
|
842
|
+
// ../core/package.json
|
|
843
|
+
var version5 = "0.1.0";
|
|
844
|
+
|
|
845
|
+
// ../deepgram/package.json
|
|
846
|
+
var version6 = "1.0.0";
|
|
847
|
+
|
|
848
|
+
// ../elevenlabs/package.json
|
|
849
|
+
var version7 = "1.5.0";
|
|
850
|
+
|
|
851
|
+
// ../gemini/package.json
|
|
852
|
+
var version8 = "1.4.0";
|
|
853
|
+
|
|
854
|
+
// ../gladia/package.json
|
|
855
|
+
var version9 = "1.4.0";
|
|
856
|
+
|
|
857
|
+
// ../gradium/package.json
|
|
858
|
+
var version10 = "1.4.0";
|
|
859
|
+
|
|
860
|
+
// ../grok/package.json
|
|
861
|
+
var version11 = "1.0.0";
|
|
862
|
+
|
|
863
|
+
// ../inworld/package.json
|
|
864
|
+
var version12 = "1.0.0";
|
|
865
|
+
|
|
866
|
+
// ../kokoro/package.json
|
|
867
|
+
var version13 = "1.3.0";
|
|
868
|
+
|
|
869
|
+
// ../mastra/package.json
|
|
870
|
+
var version14 = "0.1.0";
|
|
871
|
+
|
|
872
|
+
// ../mistral/package.json
|
|
873
|
+
var version15 = "1.5.0";
|
|
874
|
+
|
|
875
|
+
// ../openai/package.json
|
|
876
|
+
var version16 = "1.10.0";
|
|
877
|
+
|
|
878
|
+
// ../openai-agents/package.json
|
|
879
|
+
var version17 = "0.1.0";
|
|
880
|
+
|
|
881
|
+
// ../react/package.json
|
|
882
|
+
var version18 = "2.2.0";
|
|
883
|
+
|
|
884
|
+
// ../react-native/package.json
|
|
885
|
+
var version19 = "0.3.0";
|
|
886
|
+
|
|
887
|
+
// ../server/package.json
|
|
888
|
+
var version20 = "2.15.0";
|
|
889
|
+
|
|
890
|
+
// ../silero/package.json
|
|
891
|
+
var version21 = "0.1.0";
|
|
892
|
+
|
|
893
|
+
// ../speechmatics/package.json
|
|
894
|
+
var version22 = "1.0.0";
|
|
895
|
+
|
|
896
|
+
// ../telephony/package.json
|
|
897
|
+
var version23 = "0.2.0";
|
|
898
|
+
|
|
899
|
+
// ../web/package.json
|
|
900
|
+
var version24 = "1.6.0";
|
|
901
|
+
|
|
902
|
+
// ../whisper/package.json
|
|
903
|
+
var version25 = "1.2.0";
|
|
904
|
+
|
|
905
|
+
// src/versions.ts
|
|
906
|
+
var MICDROP_VERSIONS = {
|
|
907
|
+
"@micdrop/ai-sdk": version,
|
|
908
|
+
"@micdrop/assemblyai": version2,
|
|
909
|
+
"@micdrop/cartesia": version3,
|
|
910
|
+
"@micdrop/client": version4,
|
|
911
|
+
"@micdrop/core": version5,
|
|
912
|
+
"@micdrop/deepgram": version6,
|
|
913
|
+
"@micdrop/elevenlabs": version7,
|
|
914
|
+
"@micdrop/gemini": version8,
|
|
915
|
+
"@micdrop/gladia": version9,
|
|
916
|
+
"@micdrop/gradium": version10,
|
|
917
|
+
"@micdrop/grok": version11,
|
|
918
|
+
"@micdrop/inworld": version12,
|
|
919
|
+
"@micdrop/kokoro": version13,
|
|
920
|
+
"@micdrop/mastra": version14,
|
|
921
|
+
"@micdrop/mistral": version15,
|
|
922
|
+
"@micdrop/openai": version16,
|
|
923
|
+
"@micdrop/openai-agents": version17,
|
|
924
|
+
"@micdrop/react": version18,
|
|
925
|
+
"@micdrop/react-native": version19,
|
|
926
|
+
"@micdrop/server": version20,
|
|
927
|
+
"@micdrop/silero": version21,
|
|
928
|
+
"@micdrop/speechmatics": version22,
|
|
929
|
+
"@micdrop/telephony": version23,
|
|
930
|
+
"@micdrop/web": version24,
|
|
931
|
+
"@micdrop/whisper": version25
|
|
932
|
+
};
|
|
933
|
+
function micdropRange(name) {
|
|
934
|
+
const version27 = MICDROP_VERSIONS[name];
|
|
935
|
+
if (!version27) throw new Error(`No known version for ${name}`);
|
|
936
|
+
return `^${version27}`;
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
// src/generate.ts
|
|
940
|
+
function templatesDir() {
|
|
941
|
+
return path.resolve(
|
|
942
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
943
|
+
"..",
|
|
944
|
+
"templates"
|
|
945
|
+
);
|
|
946
|
+
}
|
|
947
|
+
var RENAMED = {
|
|
948
|
+
_gitignore: ".gitignore"
|
|
949
|
+
};
|
|
950
|
+
var SKIPPED = /* @__PURE__ */ new Set(["telephony", "_env.example"]);
|
|
951
|
+
var TEXT_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
952
|
+
".ts",
|
|
953
|
+
".tsx",
|
|
954
|
+
".js",
|
|
955
|
+
".mjs",
|
|
956
|
+
".json",
|
|
957
|
+
".md",
|
|
958
|
+
".html",
|
|
959
|
+
".css",
|
|
960
|
+
".example",
|
|
961
|
+
""
|
|
962
|
+
]);
|
|
963
|
+
async function generate(options) {
|
|
964
|
+
const template = findTemplate(options.template);
|
|
965
|
+
if (template.telephony && !options.telephony) {
|
|
966
|
+
throw new Error(`The ${template.id} template needs a telephony provider`);
|
|
967
|
+
}
|
|
968
|
+
const sourceDir = path.join(templatesDir(), template.id);
|
|
969
|
+
const { targetDir } = options;
|
|
970
|
+
if (existsSync(targetDir) && (await readdir(targetDir)).length > 0) {
|
|
971
|
+
throw new Error(`${targetDir} is not empty`);
|
|
972
|
+
}
|
|
973
|
+
await mkdir(targetDir, { recursive: true });
|
|
974
|
+
const tokens = buildTokens(options, template);
|
|
975
|
+
await copyDir(sourceDir, targetDir, tokens, true);
|
|
976
|
+
let telephonyEnv = "";
|
|
977
|
+
if (template.telephony && options.telephony) {
|
|
978
|
+
const variantDir = path.join(sourceDir, "telephony", options.telephony);
|
|
979
|
+
if (!existsSync(variantDir)) {
|
|
980
|
+
throw new Error(`No telephony variant ${options.telephony}`);
|
|
981
|
+
}
|
|
982
|
+
await writeFile(
|
|
983
|
+
path.join(targetDir, "src/telephony.ts"),
|
|
984
|
+
await readFile(path.join(variantDir, "telephony.ts"), "utf8")
|
|
985
|
+
);
|
|
986
|
+
telephonyEnv = (await readFile(path.join(variantDir, "env.example"), "utf8")).trim();
|
|
987
|
+
const setup = (await readFile(path.join(variantDir, "setup.md"), "utf8")).trim();
|
|
988
|
+
const readmePath = path.join(targetDir, "README.md");
|
|
989
|
+
const readme = await readFile(readmePath, "utf8");
|
|
990
|
+
await writeFile(readmePath, readme.replace("{{telephonySetup}}", setup));
|
|
991
|
+
}
|
|
992
|
+
await mkdir(path.dirname(path.join(targetDir, template.aiFile)), {
|
|
993
|
+
recursive: true
|
|
994
|
+
});
|
|
995
|
+
await writeFile(
|
|
996
|
+
path.join(targetDir, template.aiFile),
|
|
997
|
+
renderAiFile(options.ai)
|
|
998
|
+
);
|
|
999
|
+
const baseEnvPath = path.join(sourceDir, "_env.example");
|
|
1000
|
+
const baseEnv = existsSync(baseEnvPath) ? (await readFile(baseEnvPath, "utf8")).trim() : "";
|
|
1001
|
+
const env = [baseEnv, telephonyEnv, renderEnvVars(options.ai)].filter(Boolean).join("\n\n") + "\n";
|
|
1002
|
+
await mkdir(path.join(targetDir, template.envDir), { recursive: true });
|
|
1003
|
+
await writeFile(path.join(targetDir, template.envDir, ".env.example"), env);
|
|
1004
|
+
await writeFile(path.join(targetDir, template.envDir, ".env"), env);
|
|
1005
|
+
await writePackageJson(options, template);
|
|
1006
|
+
return template;
|
|
1007
|
+
}
|
|
1008
|
+
function buildTokens(options, template) {
|
|
1009
|
+
const pm = options.packageManager;
|
|
1010
|
+
const providers = resolveProviders(options.ai).map((provider) => `- [${provider.label}](${provider.docs})`).join("\n");
|
|
1011
|
+
return {
|
|
1012
|
+
name: options.name,
|
|
1013
|
+
// For the iOS bundle identifier and the Android package
|
|
1014
|
+
bundleName: options.name.replace(/[^a-z0-9]/g, "") || "micdropapp",
|
|
1015
|
+
install: pm === "yarn" ? "yarn" : `${pm} install`,
|
|
1016
|
+
"run:dev": runCommand(pm, "dev"),
|
|
1017
|
+
"run:build": runCommand(pm, "build"),
|
|
1018
|
+
"run:start": runCommand(pm, "start"),
|
|
1019
|
+
"run:ios": runCommand(pm, "ios"),
|
|
1020
|
+
"run:android": runCommand(pm, "android"),
|
|
1021
|
+
"run:typecheck": runCommand(pm, "typecheck"),
|
|
1022
|
+
providers,
|
|
1023
|
+
envDir: template.envDir === "." ? "" : `${template.envDir}/`
|
|
1024
|
+
};
|
|
1025
|
+
}
|
|
1026
|
+
async function copyDir(from, to, tokens, isRoot) {
|
|
1027
|
+
await mkdir(to, { recursive: true });
|
|
1028
|
+
for (const entry of await readdir(from, { withFileTypes: true })) {
|
|
1029
|
+
if (isRoot && SKIPPED.has(entry.name)) continue;
|
|
1030
|
+
if (entry.name === "node_modules") continue;
|
|
1031
|
+
const source = path.join(from, entry.name);
|
|
1032
|
+
const target = path.join(to, RENAMED[entry.name] ?? entry.name);
|
|
1033
|
+
if (entry.isDirectory()) {
|
|
1034
|
+
await copyDir(source, target, tokens, false);
|
|
1035
|
+
} else if (TEXT_EXTENSIONS.has(path.extname(entry.name))) {
|
|
1036
|
+
const content = await readFile(source, "utf8");
|
|
1037
|
+
await writeFile(target, replaceTokens(content, tokens));
|
|
1038
|
+
} else {
|
|
1039
|
+
await copyFile(source, target);
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
function replaceTokens(content, tokens) {
|
|
1044
|
+
return content.replace(
|
|
1045
|
+
/\{\{\s*([a-zA-Z:]+)\s*\}\}/g,
|
|
1046
|
+
(match, key) => key in tokens ? tokens[key] : match
|
|
1047
|
+
);
|
|
1048
|
+
}
|
|
1049
|
+
async function writePackageJson(options, template) {
|
|
1050
|
+
const file = path.join(options.targetDir, "package.json");
|
|
1051
|
+
const pkg = JSON.parse(await readFile(file, "utf8"));
|
|
1052
|
+
pkg.name = options.name;
|
|
1053
|
+
const field = template.dependencyField;
|
|
1054
|
+
pkg[field] = { ...pkg[field], ...providerDependencies(options.ai) };
|
|
1055
|
+
const version27 = options.micdropVersion ?? micdropRange;
|
|
1056
|
+
for (const key of ["dependencies", "devDependencies"]) {
|
|
1057
|
+
if (!pkg[key]) continue;
|
|
1058
|
+
const sorted = {};
|
|
1059
|
+
for (const name of Object.keys(pkg[key]).sort()) {
|
|
1060
|
+
sorted[name] = name.startsWith("@micdrop/") ? version27(name) : pkg[key][name];
|
|
1061
|
+
}
|
|
1062
|
+
pkg[key] = sorted;
|
|
1063
|
+
}
|
|
1064
|
+
await writeFile(file, JSON.stringify(pkg, null, 2) + "\n");
|
|
1065
|
+
}
|
|
1066
|
+
function toPackageName(dir) {
|
|
1067
|
+
return path.basename(path.resolve(dir)).trim().toLowerCase().replace(/\s+/g, "-").replace(/^[._]/, "").replace(/[^a-z0-9-~]+/g, "-").replace(/^-+|-+$/g, "") || "micdrop-app";
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
// package.json
|
|
1071
|
+
var version26 = "0.1.0";
|
|
1072
|
+
|
|
1073
|
+
// src/index.ts
|
|
1074
|
+
var HELP = `Usage: npm create micdrop@latest [directory] [options]
|
|
1075
|
+
|
|
1076
|
+
Creates a voice AI app with Micdrop. Asks for whatever the options leave out.
|
|
1077
|
+
|
|
1078
|
+
Options:
|
|
1079
|
+
-t, --template <id> ${TEMPLATES.map((t) => t.id).join(", ")}
|
|
1080
|
+
--ai <preset> ${Object.keys(PRESETS).join(", ")}
|
|
1081
|
+
--stt <id> Speech to text: ${ids("stt")}
|
|
1082
|
+
--agent <id> Agent: ${ids("agent")}
|
|
1083
|
+
--tts <id> Text to speech: ${ids("tts")}
|
|
1084
|
+
--realtime <id> Speech to speech model: ${ids("realtime")}
|
|
1085
|
+
--telephony <id> Phone template: ${TELEPHONY_PROVIDERS.map((t) => t.id).join(", ")}
|
|
1086
|
+
--pm <name> ${PACKAGE_MANAGERS.join(", ")}, the one running this by default
|
|
1087
|
+
--install Installs the dependencies
|
|
1088
|
+
--no-install Leaves the install to you
|
|
1089
|
+
-y, --yes Takes the defaults instead of asking
|
|
1090
|
+
-h, --help Shows this help
|
|
1091
|
+
-v, --version Shows the version
|
|
1092
|
+
|
|
1093
|
+
Examples:
|
|
1094
|
+
npm create micdrop@latest my-agent
|
|
1095
|
+
npm create micdrop@latest my-agent -- --template phone --telephony twilio --ai openai
|
|
1096
|
+
pnpm create micdrop my-app --template nextjs --stt gladia --agent mistral --tts elevenlabs
|
|
1097
|
+
`;
|
|
1098
|
+
function ids(kind) {
|
|
1099
|
+
return providersOf(kind).map((provider) => provider.id).join(", ");
|
|
1100
|
+
}
|
|
1101
|
+
async function main() {
|
|
1102
|
+
const { values, positionals } = parseArgs({
|
|
1103
|
+
allowPositionals: true,
|
|
1104
|
+
options: {
|
|
1105
|
+
template: { type: "string", short: "t" },
|
|
1106
|
+
ai: { type: "string" },
|
|
1107
|
+
stt: { type: "string" },
|
|
1108
|
+
agent: { type: "string" },
|
|
1109
|
+
tts: { type: "string" },
|
|
1110
|
+
realtime: { type: "string" },
|
|
1111
|
+
telephony: { type: "string" },
|
|
1112
|
+
pm: { type: "string" },
|
|
1113
|
+
install: { type: "boolean" },
|
|
1114
|
+
"no-install": { type: "boolean" },
|
|
1115
|
+
yes: { type: "boolean", short: "y" },
|
|
1116
|
+
help: { type: "boolean", short: "h" },
|
|
1117
|
+
version: { type: "boolean", short: "v" }
|
|
1118
|
+
}
|
|
1119
|
+
});
|
|
1120
|
+
if (values.help) {
|
|
1121
|
+
console.log(HELP);
|
|
1122
|
+
return;
|
|
1123
|
+
}
|
|
1124
|
+
if (values.version) {
|
|
1125
|
+
console.log(version26);
|
|
1126
|
+
return;
|
|
1127
|
+
}
|
|
1128
|
+
if (values.template) findTemplate(values.template);
|
|
1129
|
+
if (values.telephony) findTelephony(values.telephony);
|
|
1130
|
+
if (values.ai && !PRESETS[values.ai]) {
|
|
1131
|
+
throw new Error(
|
|
1132
|
+
`Unknown preset "${values.ai}", pick one of: ${Object.keys(PRESETS).join(", ")}`
|
|
1133
|
+
);
|
|
1134
|
+
}
|
|
1135
|
+
if (values.realtime && (values.stt || values.agent || values.tts)) {
|
|
1136
|
+
throw new Error(
|
|
1137
|
+
"--realtime replaces --stt, --agent and --tts, give one or the others"
|
|
1138
|
+
);
|
|
1139
|
+
}
|
|
1140
|
+
if (values.stt) findProvider("stt", values.stt);
|
|
1141
|
+
if (values.agent) findProvider("agent", values.agent);
|
|
1142
|
+
if (values.tts) findProvider("tts", values.tts);
|
|
1143
|
+
if (values.realtime) findProvider("realtime", values.realtime);
|
|
1144
|
+
if (values.pm && !PACKAGE_MANAGERS.includes(values.pm)) {
|
|
1145
|
+
throw new Error(`Unknown package manager "${values.pm}"`);
|
|
1146
|
+
}
|
|
1147
|
+
const yes = Boolean(values.yes) || !process.stdin.isTTY;
|
|
1148
|
+
p.intro(styleText(["bgMagenta", "white"], " \u{1F590}\uFE0F\u{1F3A4} create-micdrop "));
|
|
1149
|
+
let dir = positionals[0];
|
|
1150
|
+
if (!dir) {
|
|
1151
|
+
dir = yes ? "micdrop-app" : ask(
|
|
1152
|
+
await p.text({
|
|
1153
|
+
message: "Where should the project go?",
|
|
1154
|
+
placeholder: "micdrop-app",
|
|
1155
|
+
defaultValue: "micdrop-app",
|
|
1156
|
+
validate: (value) => value && isNotEmpty(value) ? `${value} already holds files` : void 0
|
|
1157
|
+
})
|
|
1158
|
+
);
|
|
1159
|
+
}
|
|
1160
|
+
const targetDir = path2.resolve(dir);
|
|
1161
|
+
if (isNotEmpty(targetDir)) {
|
|
1162
|
+
throw new Error(`${dir} already holds files, pick another folder`);
|
|
1163
|
+
}
|
|
1164
|
+
const templateId = values.template ?? (yes ? "nextjs" : ask(
|
|
1165
|
+
await p.select({
|
|
1166
|
+
message: "Which template?",
|
|
1167
|
+
options: TEMPLATES.map((t) => ({
|
|
1168
|
+
value: t.id,
|
|
1169
|
+
label: t.label,
|
|
1170
|
+
hint: t.hint
|
|
1171
|
+
}))
|
|
1172
|
+
})
|
|
1173
|
+
));
|
|
1174
|
+
const template = findTemplate(templateId);
|
|
1175
|
+
let telephony = values.telephony;
|
|
1176
|
+
if (template.telephony && !telephony) {
|
|
1177
|
+
telephony = yes ? "twilio" : ask(
|
|
1178
|
+
await p.select({
|
|
1179
|
+
message: "Which telephony provider carries the calls?",
|
|
1180
|
+
options: TELEPHONY_PROVIDERS.map((t) => ({
|
|
1181
|
+
value: t.id,
|
|
1182
|
+
label: t.label,
|
|
1183
|
+
hint: t.hint
|
|
1184
|
+
}))
|
|
1185
|
+
})
|
|
1186
|
+
);
|
|
1187
|
+
}
|
|
1188
|
+
const ai = await chooseAi(values, yes);
|
|
1189
|
+
const pm = values.pm ?? detectPackageManager();
|
|
1190
|
+
const shouldInstall = values["no-install"] ? false : values.install ? true : yes ? false : ask(
|
|
1191
|
+
await p.confirm({
|
|
1192
|
+
message: `Install the dependencies with ${pm}?`,
|
|
1193
|
+
initialValue: true
|
|
1194
|
+
})
|
|
1195
|
+
);
|
|
1196
|
+
const spinner2 = p.spinner();
|
|
1197
|
+
spinner2.start("Writing the project");
|
|
1198
|
+
await generate({
|
|
1199
|
+
targetDir,
|
|
1200
|
+
name: toPackageName(targetDir),
|
|
1201
|
+
template: template.id,
|
|
1202
|
+
ai,
|
|
1203
|
+
telephony,
|
|
1204
|
+
packageManager: pm
|
|
1205
|
+
});
|
|
1206
|
+
spinner2.stop(
|
|
1207
|
+
`Project written in ${path2.relative(process.cwd(), targetDir) || "."}`
|
|
1208
|
+
);
|
|
1209
|
+
if (shouldInstall) {
|
|
1210
|
+
p.log.step(`Installing the dependencies with ${pm}`);
|
|
1211
|
+
await install(pm, targetDir);
|
|
1212
|
+
}
|
|
1213
|
+
const relative = path2.relative(process.cwd(), targetDir);
|
|
1214
|
+
const envFile = path2.join(
|
|
1215
|
+
relative,
|
|
1216
|
+
template.envDir === "." ? "" : template.envDir,
|
|
1217
|
+
".env"
|
|
1218
|
+
);
|
|
1219
|
+
const steps = [
|
|
1220
|
+
relative && `cd ${relative}`,
|
|
1221
|
+
!shouldInstall && (pm === "yarn" ? "yarn" : `${pm} install`),
|
|
1222
|
+
`Fill ${envFile}`,
|
|
1223
|
+
template.id === "expo" ? `${runCommand(pm, "ios")} # or ${runCommand(pm, "android")}` : runCommand(pm, "dev")
|
|
1224
|
+
].filter(Boolean);
|
|
1225
|
+
p.note(steps.join("\n"), "Next steps");
|
|
1226
|
+
p.outro(`${template.nextStep}. Docs: https://micdrop.dev/docs`);
|
|
1227
|
+
}
|
|
1228
|
+
async function chooseAi(values, yes) {
|
|
1229
|
+
const preset = values.ai;
|
|
1230
|
+
if (values.realtime) {
|
|
1231
|
+
return { mode: "realtime", realtime: values.realtime };
|
|
1232
|
+
}
|
|
1233
|
+
const given = values.stt || values.agent || values.tts;
|
|
1234
|
+
if (preset && !given) return PRESETS[preset];
|
|
1235
|
+
const presetChoice = preset ? PRESETS[preset] : void 0;
|
|
1236
|
+
const base = presetChoice?.mode === "cascade" ? presetChoice : { stt: "openai", agent: "openai", tts: "openai" };
|
|
1237
|
+
if (given || yes) {
|
|
1238
|
+
return {
|
|
1239
|
+
mode: "cascade",
|
|
1240
|
+
stt: values.stt ?? base.stt,
|
|
1241
|
+
agent: values.agent ?? base.agent,
|
|
1242
|
+
tts: values.tts ?? base.tts
|
|
1243
|
+
};
|
|
1244
|
+
}
|
|
1245
|
+
const picked = ask(
|
|
1246
|
+
await p.select({
|
|
1247
|
+
message: "Which AI runs the call?",
|
|
1248
|
+
options: [
|
|
1249
|
+
...Object.entries(PRESETS).map(([value, preset2]) => ({
|
|
1250
|
+
value,
|
|
1251
|
+
label: preset2.label,
|
|
1252
|
+
hint: preset2.hint
|
|
1253
|
+
})),
|
|
1254
|
+
{
|
|
1255
|
+
value: "custom",
|
|
1256
|
+
label: "Pick each provider",
|
|
1257
|
+
hint: "speech to text, LLM and text to speech, or a realtime model"
|
|
1258
|
+
}
|
|
1259
|
+
]
|
|
1260
|
+
})
|
|
1261
|
+
);
|
|
1262
|
+
if (picked !== "custom") return PRESETS[picked];
|
|
1263
|
+
const mode = ask(
|
|
1264
|
+
await p.select({
|
|
1265
|
+
message: "How does the call run?",
|
|
1266
|
+
options: [
|
|
1267
|
+
{
|
|
1268
|
+
value: "cascade",
|
|
1269
|
+
label: "Cascade",
|
|
1270
|
+
hint: "speech to text, then an LLM, then text to speech"
|
|
1271
|
+
},
|
|
1272
|
+
{
|
|
1273
|
+
value: "realtime",
|
|
1274
|
+
label: "Realtime",
|
|
1275
|
+
hint: "one speech to speech model"
|
|
1276
|
+
}
|
|
1277
|
+
]
|
|
1278
|
+
})
|
|
1279
|
+
);
|
|
1280
|
+
if (mode === "realtime") {
|
|
1281
|
+
return { mode, realtime: await pickProvider("realtime") };
|
|
1282
|
+
}
|
|
1283
|
+
return {
|
|
1284
|
+
mode,
|
|
1285
|
+
stt: await pickProvider("stt"),
|
|
1286
|
+
agent: await pickProvider("agent"),
|
|
1287
|
+
tts: await pickProvider("tts")
|
|
1288
|
+
};
|
|
1289
|
+
}
|
|
1290
|
+
async function pickProvider(kind) {
|
|
1291
|
+
return ask(
|
|
1292
|
+
await p.select({
|
|
1293
|
+
message: `Which ${KIND_LABELS[kind]}?`,
|
|
1294
|
+
options: providersOf(kind).map((provider) => ({
|
|
1295
|
+
value: provider.id,
|
|
1296
|
+
label: provider.label,
|
|
1297
|
+
hint: provider.hint
|
|
1298
|
+
}))
|
|
1299
|
+
})
|
|
1300
|
+
);
|
|
1301
|
+
}
|
|
1302
|
+
function ask(answer) {
|
|
1303
|
+
if (p.isCancel(answer)) {
|
|
1304
|
+
p.cancel("Cancelled, nothing was written");
|
|
1305
|
+
process.exit(0);
|
|
1306
|
+
}
|
|
1307
|
+
return answer;
|
|
1308
|
+
}
|
|
1309
|
+
function isNotEmpty(dir) {
|
|
1310
|
+
return existsSync2(dir) && readdirSync(dir).length > 0;
|
|
1311
|
+
}
|
|
1312
|
+
main().catch((error) => {
|
|
1313
|
+
p.cancel(error instanceof Error ? error.message : String(error));
|
|
1314
|
+
process.exit(1);
|
|
1315
|
+
});
|