@vapi-ai/mcp-server 0.0.11 → 0.2.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 (59) hide show
  1. package/README.md +241 -104
  2. package/dist/knowledge/docs.d.ts +96 -0
  3. package/dist/knowledge/docs.d.ts.map +1 -0
  4. package/dist/knowledge/docs.js +16 -0
  5. package/dist/knowledge/skills.d.ts +28 -0
  6. package/dist/knowledge/skills.d.ts.map +1 -0
  7. package/dist/knowledge/skills.js +131 -0
  8. package/dist/schemas/assistant-openapi.d.ts +31 -0
  9. package/dist/schemas/assistant-openapi.d.ts.map +1 -0
  10. package/dist/schemas/assistant-openapi.js +87 -0
  11. package/dist/schemas/assistant-openapi.json +2341 -0
  12. package/dist/schemas/index.d.ts +161 -1181
  13. package/dist/schemas/index.d.ts.map +1 -1
  14. package/dist/schemas/index.js +99 -172
  15. package/dist/schemas/simulation-openapi.d.ts +9 -0
  16. package/dist/schemas/simulation-openapi.d.ts.map +1 -0
  17. package/dist/schemas/simulation-openapi.js +81 -0
  18. package/dist/schemas/simulation-openapi.json +27558 -0
  19. package/dist/schemas/simulation.d.ts +54 -0
  20. package/dist/schemas/simulation.d.ts.map +1 -0
  21. package/dist/schemas/simulation.js +76 -0
  22. package/dist/tools/annotations.d.ts +5 -0
  23. package/dist/tools/annotations.d.ts.map +1 -0
  24. package/dist/tools/annotations.js +14 -0
  25. package/dist/tools/api-schema.d.ts +4 -0
  26. package/dist/tools/api-schema.d.ts.map +1 -0
  27. package/dist/tools/api-schema.js +69 -0
  28. package/dist/tools/assistant.d.ts.map +1 -1
  29. package/dist/tools/assistant.js +33 -17
  30. package/dist/tools/call.d.ts.map +1 -1
  31. package/dist/tools/call.js +20 -11
  32. package/dist/tools/docs.d.ts +3 -0
  33. package/dist/tools/docs.d.ts.map +1 -0
  34. package/dist/tools/docs.js +27 -0
  35. package/dist/tools/index.d.ts.map +1 -1
  36. package/dist/tools/index.js +8 -0
  37. package/dist/tools/input-schema.d.ts +5 -0
  38. package/dist/tools/input-schema.d.ts.map +1 -0
  39. package/dist/tools/input-schema.js +59 -0
  40. package/dist/tools/list.d.ts +34 -0
  41. package/dist/tools/list.d.ts.map +1 -0
  42. package/dist/tools/list.js +47 -0
  43. package/dist/tools/phone-number.d.ts.map +1 -1
  44. package/dist/tools/phone-number.js +17 -10
  45. package/dist/tools/simulation.d.ts +4 -0
  46. package/dist/tools/simulation.d.ts.map +1 -0
  47. package/dist/tools/simulation.js +146 -0
  48. package/dist/tools/skills.d.ts +3 -0
  49. package/dist/tools/skills.d.ts.map +1 -0
  50. package/dist/tools/skills.js +31 -0
  51. package/dist/tools/tool.d.ts.map +1 -1
  52. package/dist/tools/tool.js +31 -14
  53. package/dist/tools/validation.d.ts +24 -0
  54. package/dist/tools/validation.d.ts.map +1 -0
  55. package/dist/tools/validation.js +94 -0
  56. package/dist/transformers/index.d.ts +3 -3
  57. package/dist/transformers/index.d.ts.map +1 -1
  58. package/dist/transformers/index.js +52 -31
  59. package/package.json +9 -6
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,aAAa;;;;CAIhB,CAAC;AAEX,eAAO,MAAM,YAAY;;;CAGf,CAAC;AAEX,eAAO,MAAM,eAAe;;;CAGlB,CAAC;AAEX,eAAO,MAAM,YAAY;;;;;CAKf,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAC3B,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AACrD,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAC/E,MAAM,MAAM,kBAAkB,GAC5B,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;AACzD,MAA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BAgBhC,CAAC;AAEH,eAAO,MAAM,uBAAuB;;iBAElC,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwBrC,CAAC;AAIH,eAAO,MAAM,eAAe;;;;;;;;;;iBA4B1B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;iBAW3B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;iBAE7B,CAAC;AAIH,eAAO,MAAM,yBAAyB;;iBAEpC,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;;;;;;iBAUlC,CAAC;AAIH,eAAO,MAAM,kBAAkB;;iBAE7B,CAAC;AAqEH,eAAO,MAAM,qBAAqB;;;;;;;;;;kBAnEqB,QAAQ;oBAAU,MAAM;wBAAc,MAAM;uBAAa,MAAM;0BAAgB,MAAM;;kBAArF,QAAQ;oBAAU,MAAM;wBAAc,MAAM;uBAAa,MAAM;0BAAgB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;iBAgFxI,CAAC;AAEL,eAAO,MAAM,qBAAqB;;;;;;;;;;kBAlFqB,QAAQ;oBAAU,MAAM;wBAAc,MAAM;uBAAa,MAAM;0BAAgB,MAAM;;kBAArF,QAAQ;oBAAU,MAAM;wBAAc,MAAM;uBAAa,MAAM;0BAAgB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;iBAoF1I,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;iBAQ3B,CAAC;AAIH,eAAO,MAAM,uBAAuB;;;iBAalC,CAAC;AAEH,cAAc,iBAAiB,CAAC"}
@@ -1,4 +1,10 @@
1
1
  import { z } from 'zod';
2
+ import { CreateAssistantNameSchema, UpdateAssistantNameSchema, VoiceInputSchema, TranscriberInputSchema, LLMInputSchema, apiField, apiObjectField, requiredToolConfigurations, functionRequiresName } from './assistant-openapi.js';
3
+ export const EmptyInputSchema = z.object({});
4
+ export const ListInputSchema = z.strictObject({
5
+ // Keep discovery compact while validating the full ISO timestamp at runtime.
6
+ before: z.string().meta({ format: 'date-time' }).pipe(z.iso.datetime({ offset: true })).optional().describe('Use pagination.nextBefore to continue.'),
7
+ });
2
8
  // ===== Model Provider and Models =====
3
9
  export const ModelProvider = {
4
10
  OpenAI: 'openai',
@@ -19,58 +25,22 @@ export const GoogleModels = {
19
25
  Gemini2Flash: 'gemini-2.0-flash',
20
26
  Gemini2Pro: 'gemini-2.0-pro',
21
27
  };
22
- const OpenAILLMSchema = z.object({
23
- provider: z.literal(ModelProvider.OpenAI),
24
- model: z.enum([OpenAIModels.GPT4o, OpenAIModels.GPT4oMini]),
25
- });
26
- const AnthropicLLMSchema = z.object({
27
- provider: z.literal(ModelProvider.Anthropic),
28
- model: z.enum([
29
- AnthropicModels.Claude3Sonnet,
30
- AnthropicModels.Claude3Haiku,
31
- ]),
32
- });
33
- const GoogleLLMSchema = z.object({
34
- provider: z.literal(ModelProvider.GoogleAI),
35
- model: z.enum([
36
- GoogleModels.GeminiPro,
37
- GoogleModels.GeminiFlash,
38
- GoogleModels.Gemini2Flash,
39
- GoogleModels.Gemini2Pro,
40
- ]),
41
- });
42
- const GenericLLMSchema = z.object({
43
- provider: z.string(),
44
- model: z.string(),
45
- });
46
28
  const LLMSchema = z.union([
47
- OpenAILLMSchema,
48
- AnthropicLLMSchema,
49
- GoogleLLMSchema,
50
- GenericLLMSchema,
29
+ LLMInputSchema,
30
+ z.string().transform((value, ctx) => {
31
+ try {
32
+ return JSON.parse(value);
33
+ }
34
+ catch {
35
+ ctx.addIssue({ code: 'custom', message: 'Invalid JSON. Provide an LLM object or a valid JSON object string.' });
36
+ return z.NEVER;
37
+ }
38
+ }).pipe(LLMInputSchema),
51
39
  ]);
52
40
  export const DEFAULT_LLM = {
53
41
  provider: ModelProvider.OpenAI,
54
42
  model: OpenAIModels.GPT4o,
55
43
  };
56
- const VoiceProviderSchema = z.enum([
57
- 'vapi',
58
- '11labs',
59
- 'azure',
60
- 'cartesia',
61
- 'custom-voice',
62
- 'deepgram',
63
- '11labs',
64
- 'hume',
65
- 'lmnt',
66
- 'neuphonic',
67
- 'openai',
68
- 'playht',
69
- 'rime-ai',
70
- 'smallest-ai',
71
- 'tavus',
72
- 'sesame',
73
- ]);
74
44
  export const DEFAULT_VOICE = {
75
45
  provider: '11labs',
76
46
  voiceId: 'sarah',
@@ -94,58 +64,31 @@ export const BaseResponseSchema = z.object({
94
64
  });
95
65
  // ===== Assistant Schemas =====
96
66
  export const CreateAssistantInputSchema = z.object({
97
- name: z.string().describe('Name of the assistant'),
98
- instructions: z
99
- .string()
67
+ name: CreateAssistantNameSchema.describe('Name of the assistant'),
68
+ instructions: apiField('instructions', { nullable: false })
100
69
  .optional()
101
70
  .default('You are a helpful assistant.')
102
71
  .describe('Instructions for the assistant'),
103
- llm: z
104
- .union([
105
- LLMSchema,
106
- z.string().transform((str) => {
107
- try {
108
- return JSON.parse(str);
109
- }
110
- catch (e) {
111
- throw new Error(`Invalid LLM JSON string: ${str}`);
112
- }
113
- }),
114
- ])
72
+ llm: LLMSchema
115
73
  .default(DEFAULT_LLM)
116
74
  .describe('LLM configuration'),
117
- toolIds: z
118
- .array(z.string())
75
+ toolIds: apiField('toolIds')
119
76
  .optional()
120
77
  .describe('IDs of tools to use with this assistant'),
121
- transcriber: z
122
- .object({
123
- provider: z.string().describe('Provider to use for transcription'),
124
- model: z.string().describe('Transcription model to use'),
125
- })
78
+ transcriber: TranscriberInputSchema
126
79
  .default(DEFAULT_TRANSCRIBER)
127
80
  .describe('Transcription configuration'),
128
- voice: z
129
- .object({
130
- provider: VoiceProviderSchema.describe('Provider to use for voice'),
131
- voiceId: z.string().describe('Voice ID to use'),
132
- model: z.string().optional().describe('Voice model to use'),
133
- })
81
+ voice: VoiceInputSchema
134
82
  .default(DEFAULT_VOICE)
135
83
  .describe('Voice configuration'),
136
- firstMessage: z
137
- .string()
84
+ firstMessage: apiField('firstMessage')
138
85
  .optional()
139
86
  .default('Hello, how can I help you today?')
140
87
  .describe('First message to say to the user'),
141
- firstMessageMode: z
142
- .enum([
143
- 'assistant-speaks-first',
144
- 'assistant-waits-for-user',
145
- 'assistant-speaks-first-with-model-generated-message',
146
- ])
147
- .default('assistant-speaks-first')
88
+ firstMessageMode: apiField('firstMessageMode')
148
89
  .optional()
90
+ // Keep the advertised default without applying it to omitted input (Zod 3 behavior).
91
+ .meta({ default: 'assistant-speaks-first' })
149
92
  .describe('This determines who speaks first, either assistant or user'),
150
93
  });
151
94
  export const AssistantOutputSchema = BaseResponseSchema.extend({
@@ -161,90 +104,58 @@ export const AssistantOutputSchema = BaseResponseSchema.extend({
161
104
  }),
162
105
  transcriber: z.object({
163
106
  provider: z.string(),
164
- model: z.string(),
107
+ model: z.string().optional(),
165
108
  }),
166
109
  toolIds: z.array(z.string()).optional(),
167
110
  });
168
111
  export const GetAssistantInputSchema = z.object({
169
- assistantId: z.string().describe('ID of the assistant to get'),
112
+ assistantId: apiField('assistantId').describe('ID of the assistant to get'),
170
113
  });
171
114
  export const UpdateAssistantInputSchema = z.object({
172
- assistantId: z.string().describe('ID of the assistant to update'),
173
- name: z.string().optional().describe('New name for the assistant'),
174
- instructions: z
175
- .string()
115
+ assistantId: apiField('assistantId').describe('ID of the assistant to update'),
116
+ name: UpdateAssistantNameSchema.optional().describe('New name for the assistant'),
117
+ instructions: apiField('instructions', { nullable: false })
176
118
  .optional()
177
119
  .describe('New instructions for the assistant'),
178
- llm: z
179
- .union([
180
- LLMSchema,
181
- z.string().transform((str) => {
182
- try {
183
- return JSON.parse(str);
184
- }
185
- catch (e) {
186
- throw new Error(`Invalid LLM JSON string: ${str}`);
187
- }
188
- }),
189
- ])
120
+ llm: LLMSchema
190
121
  .optional()
191
122
  .describe('New LLM configuration'),
192
- toolIds: z
193
- .array(z.string())
123
+ toolIds: apiField('toolIds')
194
124
  .optional()
195
125
  .describe('New IDs of tools to use with this assistant'),
196
- transcriber: z
197
- .object({
198
- provider: z.string().describe('Provider to use for transcription'),
199
- model: z.string().describe('Transcription model to use'),
200
- })
126
+ transcriber: TranscriberInputSchema
201
127
  .optional()
202
128
  .describe('New transcription configuration'),
203
- voice: z
204
- .object({
205
- provider: VoiceProviderSchema.describe('Provider to use for voice'),
206
- voiceId: z.string().describe('Voice ID to use'),
207
- model: z.string().optional().describe('Voice model to use'),
208
- })
129
+ voice: VoiceInputSchema
209
130
  .optional()
210
131
  .describe('New voice configuration'),
211
- firstMessage: z
212
- .string()
132
+ firstMessage: apiField('firstMessage')
213
133
  .optional()
214
134
  .describe('First message to say to the user'),
215
- firstMessageMode: z
216
- .enum([
217
- 'assistant-speaks-first',
218
- 'assistant-waits-for-user',
219
- 'assistant-speaks-first-with-model-generated-message',
220
- ])
135
+ firstMessageMode: apiField('firstMessageMode')
221
136
  .optional()
222
137
  .describe('This determines who speaks first, either assistant or user'),
223
138
  });
224
139
  // ===== Call Schemas =====
225
140
  export const CallInputSchema = z.object({
226
- assistantId: z
227
- .string()
141
+ assistantId: apiField('callAssistantId')
228
142
  .optional()
229
143
  .describe('ID of the assistant to use for the call'),
230
- phoneNumberId: z
231
- .string()
144
+ phoneNumberId: apiField('callPhoneNumberId')
232
145
  .optional()
233
146
  .describe('ID of the phone number to use for the call'),
234
147
  customer: z
235
148
  .object({
236
- number: z.string().describe('Customer phone number'),
149
+ number: apiField('customerNumber').describe('Customer phone number'),
237
150
  })
238
151
  .optional()
239
152
  .describe('Customer information'),
240
- scheduledAt: z
241
- .string()
153
+ scheduledAt: apiField('scheduledAt')
242
154
  .optional()
243
155
  .describe('ISO datetime string for when the call should be scheduled (e.g. "2025-03-25T22:39:27.771Z")'),
244
156
  assistantOverrides: z
245
157
  .object({
246
- variableValues: z
247
- .record(z.string(), z.any())
158
+ variableValues: apiField('variableValues')
248
159
  .optional()
249
160
  .describe('Key-value pairs for dynamic variables to use in the assistant\'s prompts (e.g. {"name": "Joe", "age": "24"})'),
250
161
  })
@@ -264,11 +175,11 @@ export const CallOutputSchema = BaseResponseSchema.extend({
264
175
  scheduledAt: z.string().optional(),
265
176
  });
266
177
  export const GetCallInputSchema = z.object({
267
- callId: z.string().describe('ID of the call to get'),
178
+ callId: apiField('callId').describe('ID of the call to get'),
268
179
  });
269
180
  // ===== Phone Number Schemas =====
270
181
  export const GetPhoneNumberInputSchema = z.object({
271
- phoneNumberId: z.string().describe('ID of the phone number to get'),
182
+ phoneNumberId: apiField('phoneNumberId').describe('ID of the phone number to get'),
272
183
  });
273
184
  export const PhoneNumberOutputSchema = BaseResponseSchema.extend({
274
185
  name: z.string().optional(),
@@ -283,43 +194,30 @@ export const PhoneNumberOutputSchema = BaseResponseSchema.extend({
283
194
  });
284
195
  // ===== Tool Schemas =====
285
196
  export const GetToolInputSchema = z.object({
286
- toolId: z.string().describe('ID of the tool to get'),
287
- });
288
- const TransferCallDestinationSchema = z.object({
289
- type: z.literal('number'),
290
- number: z.string().describe('Phone number to transfer to (e.g., "+16054440129"). It can be any phone number in E.164 format.'),
291
- extension: z.string().optional().describe('Extension number if applicable'),
292
- callerId: z.string().optional().describe('Caller ID to use for the transfer'),
293
- description: z.string().optional().describe('Description of the transfer destination'),
294
- });
295
- // Generic custom tool schemas
296
- const JsonSchemaProperty = z.object({
297
- type: z.string(),
298
- description: z.string().optional(),
299
- enum: z.array(z.string()).optional(),
300
- items: z.any().optional(),
301
- properties: z.record(z.any()).optional(),
302
- required: z.array(z.string()).optional(),
303
- });
304
- const JsonSchema = z.object({
305
- type: z.literal('object'),
306
- properties: z.record(JsonSchemaProperty),
307
- required: z.array(z.string()).optional(),
197
+ toolId: apiField('toolId').describe('ID of the tool to get'),
308
198
  });
199
+ const TransferCallDestinationSchema = apiField('transferDestination', { additionalProperties: true })
200
+ .describe('Transfer destination. Other TransferDestinationNumber fields, such as transferPlan and message, are sent as given (see get_api_schema).');
201
+ const FunctionParametersSchema = apiObjectField('functionParameters');
202
+ const ApiBodySchema = apiObjectField('apiBody');
203
+ // URLs and string-valued headers are retained MCP transport constraints where
204
+ // the published DTO describes only a string/object. They are not copied API rules.
205
+ const HeaderMapSchema = apiField('serverHeaders').pipe(z.record(z.string(), z.string()))
206
+ .meta({ type: 'object', additionalProperties: { type: 'string' } });
309
207
  const ServerSchema = z.object({
310
- url: z.string().url().describe('Server URL where the function will be called'),
311
- headers: z.record(z.string()).optional().describe('Headers to send with the request'),
208
+ url: apiField('serverUrl').pipe(z.string().url()).meta({ format: 'uri' }).describe('Server URL where the function will be called'),
209
+ headers: HeaderMapSchema.optional().describe('Headers to send with the request'),
312
210
  });
313
211
  const BackoffPlanSchema = z.object({
314
- type: z.enum(['fixed', 'exponential']).default('fixed'),
315
- maxRetries: z.number().default(3).describe('Maximum number of retries'),
316
- baseDelaySeconds: z.number().default(1).describe('Base delay between retries in seconds'),
212
+ type: apiField('backoffType').default('fixed'),
213
+ maxRetries: apiField('backoffMaxRetries').default(3).describe('Maximum number of retries'),
214
+ baseDelaySeconds: apiField('backoffDelay').default(1).describe('Base delay between retries in seconds'),
317
215
  });
318
216
  // Base tool configuration schema (reusable for both create and update)
319
217
  const BaseToolConfigSchema = z.object({
320
218
  // Common fields for all tools
321
- name: z.string().optional().describe('Name of the function/tool'),
322
- description: z.string().optional().describe('Description of what the function/tool does'),
219
+ name: apiField('functionName').optional().describe('Name of the function/tool'),
220
+ description: apiField('functionDescription').optional().describe('Description of what the function/tool does'),
323
221
  // SMS tool configuration
324
222
  sms: z.object({
325
223
  metadata: z.object({
@@ -332,25 +230,42 @@ const BaseToolConfigSchema = z.object({
332
230
  }).optional().describe('Transfer call tool configuration - to transfer calls to destinations'),
333
231
  // Function tool configuration (custom functions with parameters)
334
232
  function: z.object({
335
- parameters: JsonSchema.describe('JSON schema for function parameters'),
233
+ parameters: FunctionParametersSchema.describe('JSON schema for function parameters'),
336
234
  server: ServerSchema.describe('Server configuration with URL where the function will be called'),
337
235
  }).optional().describe('Custom function tool configuration - for custom server-side functions'),
338
236
  // API Request tool configuration
339
237
  apiRequest: z.object({
340
- url: z.string().url().describe('URL to make the API request to'),
341
- method: z.enum(['GET', 'POST']).default('POST').describe('HTTP method for the API request'),
342
- headers: z.record(z.string()).optional().describe('Headers to send with the request (key-value pairs)'),
343
- body: JsonSchema.optional().describe('Body schema for the API request in JSON Schema format'),
238
+ url: apiField('apiUrl').pipe(z.string().url()).meta({ format: 'uri' }).describe('URL to make the API request to'),
239
+ method: apiField('apiMethod').default('POST').describe('HTTP method for the API request'),
240
+ headers: HeaderMapSchema.optional().describe('Headers to send with the request (key-value pairs)'),
241
+ body: ApiBodySchema.optional().describe('Body schema for the API request in JSON Schema format'),
344
242
  backoffPlan: BackoffPlanSchema.optional().describe('Retry configuration for failed API requests'),
345
- timeoutSeconds: z.number().default(20).describe('Request timeout in seconds'),
243
+ timeoutSeconds: apiField('apiTimeout').default(20).describe('Request timeout in seconds'),
346
244
  }).optional().describe('API Request tool configuration - for HTTP API integration'),
245
+ // Documented fields the options above don't cover
246
+ additionalFields: z
247
+ .record(z.string(), z.any())
248
+ .optional()
249
+ .describe('Other top-level fields from the Vapi API for this tool type, such as messages or rejectionPlan, sent as given. ' +
250
+ 'Look them up with get_api_schema, e.g. CreateTransferCallToolDTO. ' +
251
+ 'On update_tool, each field given here replaces that whole field.'),
347
252
  });
348
253
  export const CreateToolInputSchema = BaseToolConfigSchema.extend({
349
- type: z.enum(['sms', 'transferCall', 'function', 'apiRequest'])
254
+ type: apiField('toolType')
350
255
  .describe('Type of the tool to create'),
351
- });
256
+ }).superRefine((input, ctx) => {
257
+ if (requiredToolConfigurations.includes(input.type) && !input[input.type]) {
258
+ ctx.addIssue({ code: 'custom', path: [input.type], message: 'This configuration is required for the selected tool type.' });
259
+ }
260
+ if (functionRequiresName && input.type === 'function' && (input.function || input.description) && !input.name) {
261
+ ctx.addIssue({ code: 'custom', path: ['name'], message: 'A function name is required when providing a function definition.' });
262
+ }
263
+ }).meta({ allOf: [
264
+ ...requiredToolConfigurations.map(type => ({ if: { properties: { type: { const: type } }, required: ['type'] }, then: { required: [type] } })),
265
+ ...(functionRequiresName ? [{ if: { properties: { type: { const: 'function' } }, required: ['type'], anyOf: [{ required: ['function'] }, { required: ['description'], properties: { description: { minLength: 1 } } }] }, then: { required: ['name'] } }] : []),
266
+ ] });
352
267
  export const UpdateToolInputSchema = BaseToolConfigSchema.extend({
353
- toolId: z.string().describe('ID of the tool to update'),
268
+ toolId: apiField('toolId').describe('ID of the tool to update'),
354
269
  });
355
270
  export const ToolOutputSchema = BaseResponseSchema.extend({
356
271
  type: z
@@ -358,6 +273,18 @@ export const ToolOutputSchema = BaseResponseSchema.extend({
358
273
  .describe('Type of the tool (dtmf, function, mcp, query, etc.)'),
359
274
  name: z.string().describe('Name of the tool'),
360
275
  description: z.string().describe('Description of the tool'),
361
- parameters: z.record(z.any()).describe('Parameters of the tool'),
276
+ parameters: z.record(z.string(), z.any()).describe('Parameters of the tool'),
362
277
  server: ServerSchema.describe('Server of the tool'),
363
278
  });
279
+ // ===== API Schema Lookup =====
280
+ export const GetApiSchemaInputSchema = z.object({
281
+ name: z
282
+ .string()
283
+ .optional()
284
+ .describe('Exact schema name to return, e.g. "CreateTransferCallToolDTO" or "TransferPlan"'),
285
+ search: z
286
+ .string()
287
+ .optional()
288
+ .describe('Case-insensitive text to find schema names, e.g. "transfer". Used when name is not given.'),
289
+ });
290
+ export * from './simulation.js';
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ type JsonSchema = z.core.JSONSchema.JSONSchema;
3
+ export declare function simulationContract(name: string): JsonSchema;
4
+ export declare function simulationValidator(name: string): z.ZodType;
5
+ export declare function simulationParameter<T>(name: string): z.ZodType<T>;
6
+ export declare function simulationField<T>(dto: string, field: string): z.ZodType<T>;
7
+ export declare function validateSimulationBody(dto: string, input: Record<string, unknown>, ctx: z.RefinementCtx): void;
8
+ export {};
9
+ //# sourceMappingURL=simulation-openapi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simulation-openapi.d.ts","sourceRoot":"","sources":["../../src/schemas/simulation-openapi.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,KAAK,UAAU,GAAG,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC;AAQ/C,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAK3D;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,CAO3D;AAkCD,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAEjE;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAS3E;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,aAAa,QAQvG"}
@@ -0,0 +1,81 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { z } from 'zod';
3
+ import { inputContract } from './assistant-openapi.js';
4
+ const snapshot = JSON.parse(readFileSync(new URL('./simulation-openapi.json', import.meta.url), 'utf8'));
5
+ export function simulationContract(name) {
6
+ const schema = snapshot.schemas[name] ?? snapshot.parameters[name] ?? snapshot.definitions[name];
7
+ if (!schema)
8
+ throw new Error(`Unknown simulation contract: ${name}`);
9
+ return JSON.parse(JSON.stringify(inputContract({ ...schema, definitions: snapshot.definitions }), (key, value) => key === '$ref' && typeof value === 'string' ? value.replace('#/components/schemas/', '#/definitions/') : value));
10
+ }
11
+ const validators = new Map();
12
+ export function simulationValidator(name) {
13
+ let validator = validators.get(name);
14
+ if (!validator) {
15
+ validator = z.fromJSONSchema(simulationContract(name), { defaultTarget: 'openapi-3.0' });
16
+ validators.set(name, validator);
17
+ }
18
+ return validator;
19
+ }
20
+ // Full assistant/structured-output DTOs expand to hundreds of MB if converted
21
+ // back to inline tool JSON. Advertise compact object envelopes for these fields,
22
+ // while validating their complete published contracts at the same boundary.
23
+ function compact(schema) {
24
+ if (typeof schema === 'boolean')
25
+ return schema;
26
+ if (schema.$ref) {
27
+ const name = schema.$ref.split('/').at(-1);
28
+ return compact(inputContract(snapshot.definitions[name]));
29
+ }
30
+ const result = { ...schema };
31
+ delete result.definitions;
32
+ for (const key of ['allOf', 'oneOf', 'anyOf']) {
33
+ if (result[key])
34
+ result[key] = result[key].map(compact);
35
+ }
36
+ if (result.items && !Array.isArray(result.items))
37
+ result.items = compact(result.items);
38
+ if (result.properties)
39
+ result.properties = Object.fromEntries(Object.entries(result.properties).map(([key, value]) => [key,
40
+ ['assistant', 'structuredOutput', 'targetOverrides'].includes(key)
41
+ ? { type: 'object', additionalProperties: true, description: `Full ${key} configuration, validated against the bundled Vapi OpenAPI schema. See https://api.vapi.ai/api-json.` }
42
+ : compact(value),
43
+ ]));
44
+ return result;
45
+ }
46
+ function advertised(validator, contract) {
47
+ return z.any().superRefine((value, ctx) => {
48
+ const result = validator.safeParse(value);
49
+ if (!result.success)
50
+ for (const issue of result.error.issues)
51
+ ctx.addIssue({ ...issue });
52
+ // Preserve the submitted payload: imported defaults are annotations and
53
+ // unknown documented extension fields must not disappear during parsing.
54
+ }).meta(compact(contract));
55
+ }
56
+ export function simulationParameter(name) {
57
+ return advertised(simulationValidator(name), simulationContract(name));
58
+ }
59
+ export function simulationField(dto, field) {
60
+ const validator = simulationValidator(dto);
61
+ if (!(validator instanceof z.ZodObject))
62
+ throw new Error(`${dto} must be an object schema`);
63
+ const contract = simulationContract(dto).properties?.[field];
64
+ if (!contract || !validator.shape[field])
65
+ throw new Error(`Missing simulation field: ${dto}.${field}`);
66
+ const result = advertised(validator.shape[field], field === 'assistant'
67
+ ? { type: 'object', additionalProperties: true, description: 'Full tester assistant configuration, validated against the bundled Vapi OpenAPI schema. See https://api.vapi.ai/api-json (TransientAssistantDTO).' }
68
+ : contract);
69
+ return simulationContract(dto).required?.includes(field) ? result : result.optional();
70
+ }
71
+ export function validateSimulationBody(dto, input, ctx) {
72
+ const { additionalFields, ...fields } = input;
73
+ const extra = additionalFields;
74
+ const result = simulationValidator(dto).safeParse({ ...fields, ...extra });
75
+ if (!result.success)
76
+ for (const issue of result.error.issues)
77
+ ctx.addIssue({
78
+ ...issue,
79
+ path: extra && Object.hasOwn(extra, issue.path[0]) ? ['additionalFields', ...issue.path] : issue.path,
80
+ });
81
+ }