@perplexity-ai/mcp-server 0.2.2 → 0.13.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 (131) hide show
  1. package/LICENSE +201 -21
  2. package/README.md +169 -73
  3. package/compat.d.mts +58 -0
  4. package/compat.d.mts.map +1 -0
  5. package/compat.d.ts +58 -0
  6. package/compat.d.ts.map +1 -0
  7. package/compat.js +387 -0
  8. package/compat.js.map +1 -0
  9. package/compat.mjs +378 -0
  10. package/compat.mjs.map +1 -0
  11. package/dynamic-tools.d.mts +12 -0
  12. package/dynamic-tools.d.mts.map +1 -0
  13. package/dynamic-tools.d.ts +12 -0
  14. package/dynamic-tools.d.ts.map +1 -0
  15. package/dynamic-tools.js +135 -0
  16. package/dynamic-tools.js.map +1 -0
  17. package/dynamic-tools.mjs +132 -0
  18. package/dynamic-tools.mjs.map +1 -0
  19. package/filtering.d.mts +2 -0
  20. package/filtering.d.mts.map +1 -0
  21. package/filtering.d.ts +2 -0
  22. package/filtering.d.ts.map +1 -0
  23. package/filtering.js +20 -0
  24. package/filtering.js.map +1 -0
  25. package/filtering.mjs +13 -0
  26. package/filtering.mjs.map +1 -0
  27. package/headers.d.mts +4 -0
  28. package/headers.d.mts.map +1 -0
  29. package/headers.d.ts +4 -0
  30. package/headers.d.ts.map +1 -0
  31. package/headers.js +22 -0
  32. package/headers.js.map +1 -0
  33. package/headers.mjs +18 -0
  34. package/headers.mjs.map +1 -0
  35. package/http.d.mts +9 -0
  36. package/http.d.mts.map +1 -0
  37. package/http.d.ts +9 -0
  38. package/http.d.ts.map +1 -0
  39. package/http.js +108 -0
  40. package/http.js.map +1 -0
  41. package/http.mjs +100 -0
  42. package/http.mjs.map +1 -0
  43. package/index.d.mts +3 -0
  44. package/index.d.mts.map +1 -0
  45. package/index.d.ts +3 -0
  46. package/index.d.ts.map +1 -0
  47. package/index.js +91 -0
  48. package/index.js.map +1 -0
  49. package/index.mjs +89 -0
  50. package/index.mjs.map +1 -0
  51. package/options.d.mts +18 -0
  52. package/options.d.mts.map +1 -0
  53. package/options.d.ts +18 -0
  54. package/options.d.ts.map +1 -0
  55. package/options.js +415 -0
  56. package/options.js.map +1 -0
  57. package/options.mjs +408 -0
  58. package/options.mjs.map +1 -0
  59. package/package.json +156 -37
  60. package/server.d.mts +35 -0
  61. package/server.d.mts.map +1 -0
  62. package/server.d.ts +35 -0
  63. package/server.d.ts.map +1 -0
  64. package/server.js +166 -0
  65. package/server.js.map +1 -0
  66. package/server.mjs +152 -0
  67. package/server.mjs.map +1 -0
  68. package/src/compat.ts +483 -0
  69. package/src/dynamic-tools.ts +159 -0
  70. package/src/filtering.ts +14 -0
  71. package/src/headers.ts +23 -0
  72. package/src/http.ts +127 -0
  73. package/src/index.ts +108 -0
  74. package/src/options.ts +453 -0
  75. package/src/server.ts +201 -0
  76. package/src/stdio.ts +13 -0
  77. package/src/tools/chat/completions/create-chat-completions.ts +1360 -0
  78. package/src/tools/index.ts +73 -0
  79. package/src/tools/search/create-search.ts +89 -0
  80. package/src/tools/types.ts +103 -0
  81. package/src/tools.ts +1 -0
  82. package/src/tsconfig.json +11 -0
  83. package/stdio.d.mts +3 -0
  84. package/stdio.d.mts.map +1 -0
  85. package/stdio.d.ts +3 -0
  86. package/stdio.d.ts.map +1 -0
  87. package/stdio.js +14 -0
  88. package/stdio.js.map +1 -0
  89. package/stdio.mjs +10 -0
  90. package/stdio.mjs.map +1 -0
  91. package/tools/chat/completions/create-chat-completions.d.mts +45 -0
  92. package/tools/chat/completions/create-chat-completions.d.mts.map +1 -0
  93. package/tools/chat/completions/create-chat-completions.d.ts +45 -0
  94. package/tools/chat/completions/create-chat-completions.d.ts.map +1 -0
  95. package/tools/chat/completions/create-chat-completions.js +1357 -0
  96. package/tools/chat/completions/create-chat-completions.js.map +1 -0
  97. package/tools/chat/completions/create-chat-completions.mjs +1353 -0
  98. package/tools/chat/completions/create-chat-completions.mjs.map +1 -0
  99. package/tools/index.d.mts +10 -0
  100. package/tools/index.d.mts.map +1 -0
  101. package/tools/index.d.ts +10 -0
  102. package/tools/index.d.ts.map +1 -0
  103. package/tools/index.js +57 -0
  104. package/tools/index.js.map +1 -0
  105. package/tools/index.mjs +50 -0
  106. package/tools/index.mjs.map +1 -0
  107. package/tools/search/create-search.d.mts +45 -0
  108. package/tools/search/create-search.d.mts.map +1 -0
  109. package/tools/search/create-search.d.ts +45 -0
  110. package/tools/search/create-search.d.ts.map +1 -0
  111. package/tools/search/create-search.js +86 -0
  112. package/tools/search/create-search.js.map +1 -0
  113. package/tools/search/create-search.mjs +82 -0
  114. package/tools/search/create-search.mjs.map +1 -0
  115. package/tools/types.d.mts +51 -0
  116. package/tools/types.d.mts.map +1 -0
  117. package/tools/types.d.ts +51 -0
  118. package/tools/types.d.ts.map +1 -0
  119. package/tools/types.js +46 -0
  120. package/tools/types.js.map +1 -0
  121. package/tools/types.mjs +42 -0
  122. package/tools/types.mjs.map +1 -0
  123. package/tools.d.mts +2 -0
  124. package/tools.d.mts.map +1 -0
  125. package/tools.d.ts +2 -0
  126. package/tools.d.ts.map +1 -0
  127. package/tools.js +18 -0
  128. package/tools.js.map +1 -0
  129. package/tools.mjs +2 -0
  130. package/tools.mjs.map +1 -0
  131. package/dist/index.js +0 -446
@@ -0,0 +1,1360 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { Metadata, asTextContentResult } from '@perplexity-ai/mcp-server/tools/types';
4
+
5
+ import { Tool } from '@modelcontextprotocol/sdk/types.js';
6
+ import Perplexity from '@perplexity-ai/perplexity_ai';
7
+
8
+ export const metadata: Metadata = {
9
+ resource: 'chat.completions',
10
+ operation: 'write',
11
+ tags: [],
12
+ httpMethod: 'post',
13
+ httpPath: '/chat/completions',
14
+ operationId: 'chat_completions_chat_completions_post',
15
+ };
16
+
17
+ export const tool: Tool = {
18
+ name: 'create_chat_completions',
19
+ description: 'Generate a chat completion response for the given conversation.',
20
+ inputSchema: {
21
+ type: 'object',
22
+ anyOf: [
23
+ {
24
+ type: 'object',
25
+ properties: {
26
+ messages: {
27
+ type: 'array',
28
+ title: 'Messages',
29
+ items: {
30
+ $ref: '#/$defs/chat_message_input',
31
+ },
32
+ },
33
+ model: {
34
+ type: 'string',
35
+ title: 'Model',
36
+ },
37
+ _debug_pro_search: {
38
+ type: 'boolean',
39
+ title: 'Debug Pro Search',
40
+ },
41
+ _inputs: {
42
+ type: 'array',
43
+ title: 'Inputs',
44
+ items: {
45
+ type: 'integer',
46
+ },
47
+ },
48
+ _is_browser_agent: {
49
+ type: 'boolean',
50
+ title: 'Is Browser Agent',
51
+ },
52
+ _prompt_token_length: {
53
+ type: 'integer',
54
+ title: 'Prompt Token Length',
55
+ },
56
+ best_of: {
57
+ type: 'integer',
58
+ title: 'Best Of',
59
+ },
60
+ country: {
61
+ type: 'string',
62
+ title: 'Country',
63
+ },
64
+ cum_logprobs: {
65
+ type: 'boolean',
66
+ title: 'Cum Logprobs',
67
+ },
68
+ debug_params: {
69
+ type: 'object',
70
+ title: 'DebugParams',
71
+ properties: {
72
+ summarizer_model_override: {
73
+ type: 'string',
74
+ title: 'Summarizer Model Override',
75
+ },
76
+ summarizer_prompt_override: {
77
+ type: 'string',
78
+ title: 'Summarizer Prompt Override',
79
+ },
80
+ },
81
+ },
82
+ disable_search: {
83
+ type: 'boolean',
84
+ title: 'Disable Search',
85
+ },
86
+ diverse_first_token: {
87
+ type: 'boolean',
88
+ title: 'Diverse First Token',
89
+ },
90
+ enable_search_classifier: {
91
+ type: 'boolean',
92
+ title: 'Enable Search Classifier',
93
+ },
94
+ file_workspace_id: {
95
+ type: 'string',
96
+ title: 'File Workspace Id',
97
+ },
98
+ frequency_penalty: {
99
+ type: 'number',
100
+ title: 'Frequency Penalty',
101
+ },
102
+ has_image_url: {
103
+ type: 'boolean',
104
+ title: 'Has Image Url',
105
+ },
106
+ image_domain_filter: {
107
+ type: 'array',
108
+ title: 'Image Domain Filter',
109
+ items: {
110
+ type: 'string',
111
+ },
112
+ },
113
+ image_format_filter: {
114
+ type: 'array',
115
+ title: 'Image Format Filter',
116
+ items: {
117
+ type: 'string',
118
+ },
119
+ },
120
+ language_preference: {
121
+ type: 'string',
122
+ title: 'Language Preference',
123
+ },
124
+ last_updated_after_filter: {
125
+ type: 'string',
126
+ title: 'Last Updated After Filter',
127
+ },
128
+ last_updated_before_filter: {
129
+ type: 'string',
130
+ title: 'Last Updated Before Filter',
131
+ },
132
+ latitude: {
133
+ type: 'number',
134
+ title: 'Latitude',
135
+ },
136
+ logprobs: {
137
+ type: 'boolean',
138
+ title: 'Logprobs',
139
+ },
140
+ longitude: {
141
+ type: 'number',
142
+ title: 'Longitude',
143
+ },
144
+ max_tokens: {
145
+ type: 'integer',
146
+ title: 'Max Tokens',
147
+ },
148
+ n: {
149
+ type: 'integer',
150
+ title: 'N',
151
+ },
152
+ num_images: {
153
+ type: 'integer',
154
+ title: 'Num Images',
155
+ },
156
+ num_search_results: {
157
+ type: 'integer',
158
+ title: 'Num Search Results',
159
+ },
160
+ parallel_tool_calls: {
161
+ type: 'boolean',
162
+ title: 'Parallel Tool Calls',
163
+ },
164
+ presence_penalty: {
165
+ type: 'number',
166
+ title: 'Presence Penalty',
167
+ },
168
+ ranking_model: {
169
+ type: 'string',
170
+ title: 'Ranking Model',
171
+ },
172
+ reasoning_effort: {
173
+ type: 'string',
174
+ title: 'Reasoning Effort',
175
+ enum: ['minimal', 'low', 'medium', 'high'],
176
+ },
177
+ response_format: {
178
+ anyOf: [
179
+ {
180
+ type: 'object',
181
+ title: 'ResponseFormatText',
182
+ properties: {
183
+ type: {
184
+ type: 'string',
185
+ title: 'Type',
186
+ enum: ['text'],
187
+ },
188
+ },
189
+ required: ['type'],
190
+ },
191
+ {
192
+ type: 'object',
193
+ title: 'ResponseFormatJSONSchema',
194
+ properties: {
195
+ json_schema: {
196
+ type: 'object',
197
+ title: 'JSONSchema',
198
+ properties: {
199
+ schema: {
200
+ type: 'object',
201
+ title: 'Schema',
202
+ additionalProperties: true,
203
+ },
204
+ description: {
205
+ type: 'string',
206
+ title: 'Description',
207
+ },
208
+ name: {
209
+ type: 'string',
210
+ title: 'Name',
211
+ },
212
+ strict: {
213
+ type: 'boolean',
214
+ title: 'Strict',
215
+ },
216
+ },
217
+ required: ['schema'],
218
+ },
219
+ type: {
220
+ type: 'string',
221
+ title: 'Type',
222
+ enum: ['json_schema'],
223
+ },
224
+ },
225
+ required: ['json_schema', 'type'],
226
+ },
227
+ {
228
+ type: 'object',
229
+ title: 'ResponseFormatRegex',
230
+ properties: {
231
+ regex: {
232
+ type: 'object',
233
+ title: 'RegexSchema',
234
+ properties: {
235
+ regex: {
236
+ type: 'string',
237
+ title: 'Regex',
238
+ },
239
+ description: {
240
+ type: 'string',
241
+ title: 'Description',
242
+ },
243
+ name: {
244
+ type: 'string',
245
+ title: 'Name',
246
+ },
247
+ strict: {
248
+ type: 'boolean',
249
+ title: 'Strict',
250
+ },
251
+ },
252
+ required: ['regex'],
253
+ },
254
+ type: {
255
+ type: 'string',
256
+ title: 'Type',
257
+ enum: ['regex'],
258
+ },
259
+ },
260
+ required: ['regex', 'type'],
261
+ },
262
+ ],
263
+ title: 'Response Format',
264
+ },
265
+ response_metadata: {
266
+ type: 'object',
267
+ title: 'Response Metadata',
268
+ additionalProperties: true,
269
+ },
270
+ return_images: {
271
+ type: 'boolean',
272
+ title: 'Return Images',
273
+ },
274
+ return_related_questions: {
275
+ type: 'boolean',
276
+ title: 'Return Related Questions',
277
+ },
278
+ safe_search: {
279
+ type: 'boolean',
280
+ title: 'Safe Search',
281
+ },
282
+ search_after_date_filter: {
283
+ type: 'string',
284
+ title: 'Search After Date Filter',
285
+ },
286
+ search_before_date_filter: {
287
+ type: 'string',
288
+ title: 'Search Before Date Filter',
289
+ },
290
+ search_domain_filter: {
291
+ type: 'array',
292
+ title: 'Search Domain Filter',
293
+ items: {
294
+ type: 'string',
295
+ },
296
+ },
297
+ search_internal_properties: {
298
+ type: 'object',
299
+ title: 'Search Internal Properties',
300
+ additionalProperties: true,
301
+ },
302
+ search_mode: {
303
+ type: 'string',
304
+ title: 'Search Mode',
305
+ enum: ['web', 'academic', 'sec'],
306
+ },
307
+ search_recency_filter: {
308
+ type: 'string',
309
+ title: 'Search Recency Filter',
310
+ enum: ['hour', 'day', 'week', 'month', 'year'],
311
+ },
312
+ search_tenant: {
313
+ type: 'string',
314
+ title: 'Search Tenant',
315
+ },
316
+ stop: {
317
+ anyOf: [
318
+ {
319
+ type: 'string',
320
+ },
321
+ {
322
+ type: 'array',
323
+ items: {
324
+ type: 'string',
325
+ },
326
+ },
327
+ ],
328
+ title: 'Stop',
329
+ },
330
+ stream: {
331
+ type: 'string',
332
+ title: 'Stream',
333
+ enum: [false],
334
+ },
335
+ stream_mode: {
336
+ type: 'string',
337
+ title: 'Stream Mode',
338
+ enum: ['full', 'concise'],
339
+ },
340
+ temperature: {
341
+ type: 'number',
342
+ title: 'Temperature',
343
+ },
344
+ thread_id: {
345
+ type: 'string',
346
+ title: 'Thread Id',
347
+ },
348
+ tool_choice: {
349
+ type: 'string',
350
+ title: 'Tool Choice',
351
+ enum: ['none', 'auto', 'required'],
352
+ },
353
+ tools: {
354
+ type: 'array',
355
+ title: 'Tools',
356
+ items: {
357
+ type: 'object',
358
+ title: 'ToolSpec',
359
+ properties: {
360
+ function: {
361
+ type: 'object',
362
+ title: 'FunctionSpec',
363
+ properties: {
364
+ description: {
365
+ type: 'string',
366
+ title: 'Description',
367
+ },
368
+ name: {
369
+ type: 'string',
370
+ title: 'Name',
371
+ },
372
+ parameters: {
373
+ type: 'object',
374
+ title: 'ParameterSpec',
375
+ properties: {
376
+ properties: {
377
+ type: 'object',
378
+ title: 'Properties',
379
+ additionalProperties: true,
380
+ },
381
+ type: {
382
+ type: 'string',
383
+ title: 'Type',
384
+ },
385
+ additional_properties: {
386
+ type: 'boolean',
387
+ title: 'Additional Properties',
388
+ },
389
+ required: {
390
+ type: 'array',
391
+ title: 'Required',
392
+ items: {
393
+ type: 'string',
394
+ },
395
+ },
396
+ },
397
+ required: ['properties', 'type'],
398
+ },
399
+ strict: {
400
+ type: 'boolean',
401
+ title: 'Strict',
402
+ },
403
+ },
404
+ required: ['description', 'name', 'parameters'],
405
+ },
406
+ type: {
407
+ type: 'string',
408
+ title: 'Type',
409
+ enum: ['function'],
410
+ },
411
+ },
412
+ required: ['function', 'type'],
413
+ },
414
+ },
415
+ top_k: {
416
+ type: 'integer',
417
+ title: 'Top K',
418
+ },
419
+ top_logprobs: {
420
+ type: 'integer',
421
+ title: 'Top Logprobs',
422
+ },
423
+ top_p: {
424
+ type: 'number',
425
+ title: 'Top P',
426
+ },
427
+ updated_after_timestamp: {
428
+ type: 'integer',
429
+ title: 'Updated After Timestamp',
430
+ },
431
+ updated_before_timestamp: {
432
+ type: 'integer',
433
+ title: 'Updated Before Timestamp',
434
+ },
435
+ use_threads: {
436
+ type: 'boolean',
437
+ title: 'Use Threads',
438
+ },
439
+ web_search_options: {
440
+ type: 'object',
441
+ title: 'WebSearchOptions',
442
+ properties: {
443
+ image_results_enhanced_relevance: {
444
+ type: 'boolean',
445
+ title: 'Image Results Enhanced Relevance',
446
+ },
447
+ search_context_size: {
448
+ type: 'string',
449
+ title: 'Search Context Size',
450
+ enum: ['low', 'medium', 'high'],
451
+ },
452
+ search_type: {
453
+ type: 'string',
454
+ title: 'Search Type',
455
+ enum: ['fast', 'pro', 'auto'],
456
+ },
457
+ user_location: {
458
+ type: 'object',
459
+ title: 'UserLocation',
460
+ properties: {
461
+ city: {
462
+ type: 'string',
463
+ title: 'City',
464
+ },
465
+ country: {
466
+ type: 'string',
467
+ title: 'Country',
468
+ },
469
+ latitude: {
470
+ type: 'number',
471
+ title: 'Latitude',
472
+ },
473
+ longitude: {
474
+ type: 'number',
475
+ title: 'Longitude',
476
+ },
477
+ region: {
478
+ type: 'string',
479
+ title: 'Region',
480
+ },
481
+ },
482
+ },
483
+ },
484
+ },
485
+ },
486
+ required: ['messages', 'model'],
487
+ },
488
+ {
489
+ type: 'object',
490
+ properties: {
491
+ messages: {
492
+ type: 'array',
493
+ title: 'Messages',
494
+ items: {
495
+ $ref: '#/$defs/chat_message_input',
496
+ },
497
+ },
498
+ model: {
499
+ type: 'string',
500
+ title: 'Model',
501
+ },
502
+ stream: {
503
+ type: 'string',
504
+ title: 'Stream',
505
+ enum: [true],
506
+ },
507
+ _debug_pro_search: {
508
+ type: 'boolean',
509
+ title: 'Debug Pro Search',
510
+ },
511
+ _inputs: {
512
+ type: 'array',
513
+ title: 'Inputs',
514
+ items: {
515
+ type: 'integer',
516
+ },
517
+ },
518
+ _is_browser_agent: {
519
+ type: 'boolean',
520
+ title: 'Is Browser Agent',
521
+ },
522
+ _prompt_token_length: {
523
+ type: 'integer',
524
+ title: 'Prompt Token Length',
525
+ },
526
+ best_of: {
527
+ type: 'integer',
528
+ title: 'Best Of',
529
+ },
530
+ country: {
531
+ type: 'string',
532
+ title: 'Country',
533
+ },
534
+ cum_logprobs: {
535
+ type: 'boolean',
536
+ title: 'Cum Logprobs',
537
+ },
538
+ debug_params: {
539
+ type: 'object',
540
+ title: 'DebugParams',
541
+ properties: {
542
+ summarizer_model_override: {
543
+ type: 'string',
544
+ title: 'Summarizer Model Override',
545
+ },
546
+ summarizer_prompt_override: {
547
+ type: 'string',
548
+ title: 'Summarizer Prompt Override',
549
+ },
550
+ },
551
+ },
552
+ disable_search: {
553
+ type: 'boolean',
554
+ title: 'Disable Search',
555
+ },
556
+ diverse_first_token: {
557
+ type: 'boolean',
558
+ title: 'Diverse First Token',
559
+ },
560
+ enable_search_classifier: {
561
+ type: 'boolean',
562
+ title: 'Enable Search Classifier',
563
+ },
564
+ file_workspace_id: {
565
+ type: 'string',
566
+ title: 'File Workspace Id',
567
+ },
568
+ frequency_penalty: {
569
+ type: 'number',
570
+ title: 'Frequency Penalty',
571
+ },
572
+ has_image_url: {
573
+ type: 'boolean',
574
+ title: 'Has Image Url',
575
+ },
576
+ image_domain_filter: {
577
+ type: 'array',
578
+ title: 'Image Domain Filter',
579
+ items: {
580
+ type: 'string',
581
+ },
582
+ },
583
+ image_format_filter: {
584
+ type: 'array',
585
+ title: 'Image Format Filter',
586
+ items: {
587
+ type: 'string',
588
+ },
589
+ },
590
+ language_preference: {
591
+ type: 'string',
592
+ title: 'Language Preference',
593
+ },
594
+ last_updated_after_filter: {
595
+ type: 'string',
596
+ title: 'Last Updated After Filter',
597
+ },
598
+ last_updated_before_filter: {
599
+ type: 'string',
600
+ title: 'Last Updated Before Filter',
601
+ },
602
+ latitude: {
603
+ type: 'number',
604
+ title: 'Latitude',
605
+ },
606
+ logprobs: {
607
+ type: 'boolean',
608
+ title: 'Logprobs',
609
+ },
610
+ longitude: {
611
+ type: 'number',
612
+ title: 'Longitude',
613
+ },
614
+ max_tokens: {
615
+ type: 'integer',
616
+ title: 'Max Tokens',
617
+ },
618
+ n: {
619
+ type: 'integer',
620
+ title: 'N',
621
+ },
622
+ num_images: {
623
+ type: 'integer',
624
+ title: 'Num Images',
625
+ },
626
+ num_search_results: {
627
+ type: 'integer',
628
+ title: 'Num Search Results',
629
+ },
630
+ parallel_tool_calls: {
631
+ type: 'boolean',
632
+ title: 'Parallel Tool Calls',
633
+ },
634
+ presence_penalty: {
635
+ type: 'number',
636
+ title: 'Presence Penalty',
637
+ },
638
+ ranking_model: {
639
+ type: 'string',
640
+ title: 'Ranking Model',
641
+ },
642
+ reasoning_effort: {
643
+ type: 'string',
644
+ title: 'Reasoning Effort',
645
+ enum: ['minimal', 'low', 'medium', 'high'],
646
+ },
647
+ response_format: {
648
+ anyOf: [
649
+ {
650
+ type: 'object',
651
+ title: 'ResponseFormatText',
652
+ properties: {
653
+ type: {
654
+ type: 'string',
655
+ title: 'Type',
656
+ enum: ['text'],
657
+ },
658
+ },
659
+ required: ['type'],
660
+ },
661
+ {
662
+ type: 'object',
663
+ title: 'ResponseFormatJSONSchema',
664
+ properties: {
665
+ json_schema: {
666
+ type: 'object',
667
+ title: 'JSONSchema',
668
+ properties: {
669
+ schema: {
670
+ type: 'object',
671
+ title: 'Schema',
672
+ additionalProperties: true,
673
+ },
674
+ description: {
675
+ type: 'string',
676
+ title: 'Description',
677
+ },
678
+ name: {
679
+ type: 'string',
680
+ title: 'Name',
681
+ },
682
+ strict: {
683
+ type: 'boolean',
684
+ title: 'Strict',
685
+ },
686
+ },
687
+ required: ['schema'],
688
+ },
689
+ type: {
690
+ type: 'string',
691
+ title: 'Type',
692
+ enum: ['json_schema'],
693
+ },
694
+ },
695
+ required: ['json_schema', 'type'],
696
+ },
697
+ {
698
+ type: 'object',
699
+ title: 'ResponseFormatRegex',
700
+ properties: {
701
+ regex: {
702
+ type: 'object',
703
+ title: 'RegexSchema',
704
+ properties: {
705
+ regex: {
706
+ type: 'string',
707
+ title: 'Regex',
708
+ },
709
+ description: {
710
+ type: 'string',
711
+ title: 'Description',
712
+ },
713
+ name: {
714
+ type: 'string',
715
+ title: 'Name',
716
+ },
717
+ strict: {
718
+ type: 'boolean',
719
+ title: 'Strict',
720
+ },
721
+ },
722
+ required: ['regex'],
723
+ },
724
+ type: {
725
+ type: 'string',
726
+ title: 'Type',
727
+ enum: ['regex'],
728
+ },
729
+ },
730
+ required: ['regex', 'type'],
731
+ },
732
+ ],
733
+ title: 'Response Format',
734
+ },
735
+ response_metadata: {
736
+ type: 'object',
737
+ title: 'Response Metadata',
738
+ additionalProperties: true,
739
+ },
740
+ return_images: {
741
+ type: 'boolean',
742
+ title: 'Return Images',
743
+ },
744
+ return_related_questions: {
745
+ type: 'boolean',
746
+ title: 'Return Related Questions',
747
+ },
748
+ safe_search: {
749
+ type: 'boolean',
750
+ title: 'Safe Search',
751
+ },
752
+ search_after_date_filter: {
753
+ type: 'string',
754
+ title: 'Search After Date Filter',
755
+ },
756
+ search_before_date_filter: {
757
+ type: 'string',
758
+ title: 'Search Before Date Filter',
759
+ },
760
+ search_domain_filter: {
761
+ type: 'array',
762
+ title: 'Search Domain Filter',
763
+ items: {
764
+ type: 'string',
765
+ },
766
+ },
767
+ search_internal_properties: {
768
+ type: 'object',
769
+ title: 'Search Internal Properties',
770
+ additionalProperties: true,
771
+ },
772
+ search_mode: {
773
+ type: 'string',
774
+ title: 'Search Mode',
775
+ enum: ['web', 'academic', 'sec'],
776
+ },
777
+ search_recency_filter: {
778
+ type: 'string',
779
+ title: 'Search Recency Filter',
780
+ enum: ['hour', 'day', 'week', 'month', 'year'],
781
+ },
782
+ search_tenant: {
783
+ type: 'string',
784
+ title: 'Search Tenant',
785
+ },
786
+ stop: {
787
+ anyOf: [
788
+ {
789
+ type: 'string',
790
+ },
791
+ {
792
+ type: 'array',
793
+ items: {
794
+ type: 'string',
795
+ },
796
+ },
797
+ ],
798
+ title: 'Stop',
799
+ },
800
+ stream_mode: {
801
+ type: 'string',
802
+ title: 'Stream Mode',
803
+ enum: ['full', 'concise'],
804
+ },
805
+ temperature: {
806
+ type: 'number',
807
+ title: 'Temperature',
808
+ },
809
+ thread_id: {
810
+ type: 'string',
811
+ title: 'Thread Id',
812
+ },
813
+ tool_choice: {
814
+ type: 'string',
815
+ title: 'Tool Choice',
816
+ enum: ['none', 'auto', 'required'],
817
+ },
818
+ tools: {
819
+ type: 'array',
820
+ title: 'Tools',
821
+ items: {
822
+ type: 'object',
823
+ title: 'ToolSpec',
824
+ properties: {
825
+ function: {
826
+ type: 'object',
827
+ title: 'FunctionSpec',
828
+ properties: {
829
+ description: {
830
+ type: 'string',
831
+ title: 'Description',
832
+ },
833
+ name: {
834
+ type: 'string',
835
+ title: 'Name',
836
+ },
837
+ parameters: {
838
+ type: 'object',
839
+ title: 'ParameterSpec',
840
+ properties: {
841
+ properties: {
842
+ type: 'object',
843
+ title: 'Properties',
844
+ additionalProperties: true,
845
+ },
846
+ type: {
847
+ type: 'string',
848
+ title: 'Type',
849
+ },
850
+ additional_properties: {
851
+ type: 'boolean',
852
+ title: 'Additional Properties',
853
+ },
854
+ required: {
855
+ type: 'array',
856
+ title: 'Required',
857
+ items: {
858
+ type: 'string',
859
+ },
860
+ },
861
+ },
862
+ required: ['properties', 'type'],
863
+ },
864
+ strict: {
865
+ type: 'boolean',
866
+ title: 'Strict',
867
+ },
868
+ },
869
+ required: ['description', 'name', 'parameters'],
870
+ },
871
+ type: {
872
+ type: 'string',
873
+ title: 'Type',
874
+ enum: ['function'],
875
+ },
876
+ },
877
+ required: ['function', 'type'],
878
+ },
879
+ },
880
+ top_k: {
881
+ type: 'integer',
882
+ title: 'Top K',
883
+ },
884
+ top_logprobs: {
885
+ type: 'integer',
886
+ title: 'Top Logprobs',
887
+ },
888
+ top_p: {
889
+ type: 'number',
890
+ title: 'Top P',
891
+ },
892
+ updated_after_timestamp: {
893
+ type: 'integer',
894
+ title: 'Updated After Timestamp',
895
+ },
896
+ updated_before_timestamp: {
897
+ type: 'integer',
898
+ title: 'Updated Before Timestamp',
899
+ },
900
+ use_threads: {
901
+ type: 'boolean',
902
+ title: 'Use Threads',
903
+ },
904
+ web_search_options: {
905
+ type: 'object',
906
+ title: 'WebSearchOptions',
907
+ properties: {
908
+ image_results_enhanced_relevance: {
909
+ type: 'boolean',
910
+ title: 'Image Results Enhanced Relevance',
911
+ },
912
+ search_context_size: {
913
+ type: 'string',
914
+ title: 'Search Context Size',
915
+ enum: ['low', 'medium', 'high'],
916
+ },
917
+ search_type: {
918
+ type: 'string',
919
+ title: 'Search Type',
920
+ enum: ['fast', 'pro', 'auto'],
921
+ },
922
+ user_location: {
923
+ type: 'object',
924
+ title: 'UserLocation',
925
+ properties: {
926
+ city: {
927
+ type: 'string',
928
+ title: 'City',
929
+ },
930
+ country: {
931
+ type: 'string',
932
+ title: 'Country',
933
+ },
934
+ latitude: {
935
+ type: 'number',
936
+ title: 'Latitude',
937
+ },
938
+ longitude: {
939
+ type: 'number',
940
+ title: 'Longitude',
941
+ },
942
+ region: {
943
+ type: 'string',
944
+ title: 'Region',
945
+ },
946
+ },
947
+ },
948
+ },
949
+ },
950
+ },
951
+ required: ['messages', 'model', 'stream'],
952
+ },
953
+ ],
954
+ $defs: {
955
+ chat_message_input: {
956
+ type: 'object',
957
+ title: 'ChatMessage',
958
+ properties: {
959
+ content: {
960
+ anyOf: [
961
+ {
962
+ type: 'string',
963
+ },
964
+ {
965
+ type: 'array',
966
+ title: 'Structured Content',
967
+ items: {
968
+ anyOf: [
969
+ {
970
+ type: 'object',
971
+ title: 'ChatMessageContentTextChunk',
972
+ properties: {
973
+ text: {
974
+ type: 'string',
975
+ title: 'Text',
976
+ },
977
+ type: {
978
+ type: 'string',
979
+ title: 'Type',
980
+ enum: ['text'],
981
+ },
982
+ },
983
+ required: ['text', 'type'],
984
+ },
985
+ {
986
+ type: 'object',
987
+ title: 'ChatMessageContentImageChunk',
988
+ properties: {
989
+ image_url: {
990
+ anyOf: [
991
+ {
992
+ type: 'object',
993
+ title: 'URL',
994
+ properties: {
995
+ url: {
996
+ type: 'string',
997
+ title: 'Url',
998
+ },
999
+ },
1000
+ required: ['url'],
1001
+ },
1002
+ {
1003
+ type: 'string',
1004
+ },
1005
+ ],
1006
+ title: 'Image Url',
1007
+ },
1008
+ type: {
1009
+ type: 'string',
1010
+ title: 'Type',
1011
+ enum: ['image_url'],
1012
+ },
1013
+ },
1014
+ required: ['image_url', 'type'],
1015
+ },
1016
+ {
1017
+ type: 'object',
1018
+ title: 'ChatMessageContentFileChunk',
1019
+ properties: {
1020
+ file_url: {
1021
+ anyOf: [
1022
+ {
1023
+ type: 'object',
1024
+ title: 'URL',
1025
+ properties: {
1026
+ url: {
1027
+ type: 'string',
1028
+ title: 'Url',
1029
+ },
1030
+ },
1031
+ required: ['url'],
1032
+ },
1033
+ {
1034
+ type: 'string',
1035
+ },
1036
+ ],
1037
+ title: 'File Url',
1038
+ },
1039
+ type: {
1040
+ type: 'string',
1041
+ title: 'Type',
1042
+ enum: ['file_url'],
1043
+ },
1044
+ file_name: {
1045
+ type: 'string',
1046
+ title: 'File Name',
1047
+ },
1048
+ },
1049
+ required: ['file_url', 'type'],
1050
+ },
1051
+ {
1052
+ type: 'object',
1053
+ title: 'ChatMessageContentPDFChunk',
1054
+ properties: {
1055
+ pdf_url: {
1056
+ anyOf: [
1057
+ {
1058
+ type: 'object',
1059
+ title: 'URL',
1060
+ properties: {
1061
+ url: {
1062
+ type: 'string',
1063
+ title: 'Url',
1064
+ },
1065
+ },
1066
+ required: ['url'],
1067
+ },
1068
+ {
1069
+ type: 'string',
1070
+ },
1071
+ ],
1072
+ title: 'Pdf Url',
1073
+ },
1074
+ type: {
1075
+ type: 'string',
1076
+ title: 'Type',
1077
+ enum: ['pdf_url'],
1078
+ },
1079
+ },
1080
+ required: ['pdf_url', 'type'],
1081
+ },
1082
+ {
1083
+ type: 'object',
1084
+ title: 'ChatMessageContentVideoChunk',
1085
+ properties: {
1086
+ type: {
1087
+ type: 'string',
1088
+ title: 'Type',
1089
+ enum: ['video_url'],
1090
+ },
1091
+ video_url: {
1092
+ anyOf: [
1093
+ {
1094
+ type: 'object',
1095
+ title: 'VideoURL',
1096
+ properties: {
1097
+ url: {
1098
+ type: 'string',
1099
+ title: 'Url',
1100
+ },
1101
+ frame_interval: {
1102
+ anyOf: [
1103
+ {
1104
+ type: 'string',
1105
+ },
1106
+ {
1107
+ type: 'integer',
1108
+ },
1109
+ ],
1110
+ title: 'Frame Interval',
1111
+ },
1112
+ },
1113
+ required: ['url'],
1114
+ },
1115
+ {
1116
+ type: 'string',
1117
+ },
1118
+ ],
1119
+ title: 'Video Url',
1120
+ },
1121
+ },
1122
+ required: ['type', 'video_url'],
1123
+ },
1124
+ ],
1125
+ },
1126
+ },
1127
+ ],
1128
+ title: 'Content',
1129
+ },
1130
+ role: {
1131
+ type: 'string',
1132
+ title: 'ChatMessageRole',
1133
+ description: 'Chat roles enum',
1134
+ enum: ['system', 'user', 'assistant', 'tool'],
1135
+ },
1136
+ reasoning_steps: {
1137
+ type: 'array',
1138
+ title: 'Reasoning Steps',
1139
+ items: {
1140
+ type: 'object',
1141
+ title: 'ReasoningStep',
1142
+ description: 'Reasoning step wrapper class',
1143
+ properties: {
1144
+ thought: {
1145
+ type: 'string',
1146
+ title: 'Thought',
1147
+ },
1148
+ type: {
1149
+ type: 'string',
1150
+ title: 'Type',
1151
+ enum: [
1152
+ 'web_search',
1153
+ 'fetch_url_content',
1154
+ 'execute_python',
1155
+ 'agent_progress',
1156
+ 'browser_agent',
1157
+ 'browser_tool_execution',
1158
+ 'file_attachment_search',
1159
+ ],
1160
+ },
1161
+ agent_progress: {
1162
+ type: 'object',
1163
+ title: 'AgentProgressStepDetails',
1164
+ description: 'Agent progress class for live-browsing updates',
1165
+ properties: {
1166
+ action: {
1167
+ type: 'string',
1168
+ title: 'Action',
1169
+ },
1170
+ screenshot: {
1171
+ type: 'string',
1172
+ title: 'Screenshot',
1173
+ },
1174
+ url: {
1175
+ type: 'string',
1176
+ title: 'Url',
1177
+ },
1178
+ },
1179
+ required: ['action', 'screenshot', 'url'],
1180
+ },
1181
+ browser_agent: {
1182
+ type: 'object',
1183
+ title: 'BrowserAgentStepDetails',
1184
+ description: 'Browser agent step summary class',
1185
+ properties: {
1186
+ result: {
1187
+ type: 'string',
1188
+ title: 'Result',
1189
+ },
1190
+ url: {
1191
+ type: 'string',
1192
+ title: 'Url',
1193
+ },
1194
+ },
1195
+ required: ['result', 'url'],
1196
+ },
1197
+ browser_tool_execution: {
1198
+ type: 'object',
1199
+ title: 'BrowserToolExecutionDetails',
1200
+ description: 'Tool input for kicking off browser tool automation',
1201
+ properties: {
1202
+ tool: {
1203
+ type: 'object',
1204
+ title: 'Tool',
1205
+ additionalProperties: true,
1206
+ },
1207
+ },
1208
+ required: ['tool'],
1209
+ },
1210
+ execute_python: {
1211
+ type: 'object',
1212
+ title: 'ExecutePythonStepDetails',
1213
+ description: 'Code generation step details wrapper class',
1214
+ properties: {
1215
+ code: {
1216
+ type: 'string',
1217
+ title: 'Code',
1218
+ },
1219
+ result: {
1220
+ type: 'string',
1221
+ title: 'Result',
1222
+ },
1223
+ },
1224
+ required: ['code', 'result'],
1225
+ },
1226
+ fetch_url_content: {
1227
+ type: 'object',
1228
+ title: 'FetchUrlContentStepDetails',
1229
+ description: 'Fetch url content step details wrapper class',
1230
+ properties: {
1231
+ contents: {
1232
+ type: 'array',
1233
+ title: 'Contents',
1234
+ items: {
1235
+ $ref: '#/$defs/api_public_search_result',
1236
+ },
1237
+ },
1238
+ },
1239
+ required: ['contents'],
1240
+ },
1241
+ file_attachment_search: {
1242
+ type: 'object',
1243
+ title: 'FileAttachmentSearchStepDetails',
1244
+ description: 'File attachment search step details wrapper class',
1245
+ properties: {
1246
+ attachment_urls: {
1247
+ type: 'array',
1248
+ title: 'Attachment Urls',
1249
+ items: {
1250
+ type: 'string',
1251
+ },
1252
+ },
1253
+ },
1254
+ required: ['attachment_urls'],
1255
+ },
1256
+ web_search: {
1257
+ type: 'object',
1258
+ title: 'WebSearchStepDetails',
1259
+ description: 'Web search step details wrapper class',
1260
+ properties: {
1261
+ search_keywords: {
1262
+ type: 'array',
1263
+ title: 'Search Keywords',
1264
+ items: {
1265
+ type: 'string',
1266
+ },
1267
+ },
1268
+ search_results: {
1269
+ type: 'array',
1270
+ title: 'Search Results',
1271
+ items: {
1272
+ $ref: '#/$defs/api_public_search_result',
1273
+ },
1274
+ },
1275
+ },
1276
+ required: ['search_keywords', 'search_results'],
1277
+ },
1278
+ },
1279
+ required: ['thought', 'type'],
1280
+ },
1281
+ },
1282
+ tool_calls: {
1283
+ type: 'array',
1284
+ title: 'Tool Calls',
1285
+ items: {
1286
+ type: 'object',
1287
+ title: 'ToolCall',
1288
+ properties: {
1289
+ id: {
1290
+ type: 'string',
1291
+ title: 'Id',
1292
+ },
1293
+ function: {
1294
+ type: 'object',
1295
+ title: 'ToolCallFunction',
1296
+ properties: {
1297
+ arguments: {
1298
+ type: 'string',
1299
+ title: 'Arguments',
1300
+ },
1301
+ name: {
1302
+ type: 'string',
1303
+ title: 'Name',
1304
+ },
1305
+ },
1306
+ },
1307
+ type: {
1308
+ type: 'string',
1309
+ title: 'Type',
1310
+ enum: ['function'],
1311
+ },
1312
+ },
1313
+ },
1314
+ },
1315
+ },
1316
+ required: ['content', 'role'],
1317
+ },
1318
+ api_public_search_result: {
1319
+ type: 'object',
1320
+ title: 'ApiPublicSearchResult',
1321
+ properties: {
1322
+ title: {
1323
+ type: 'string',
1324
+ title: 'Title',
1325
+ },
1326
+ url: {
1327
+ type: 'string',
1328
+ title: 'Url',
1329
+ },
1330
+ date: {
1331
+ type: 'string',
1332
+ title: 'Date',
1333
+ },
1334
+ last_updated: {
1335
+ type: 'string',
1336
+ title: 'Last Updated',
1337
+ },
1338
+ snippet: {
1339
+ type: 'string',
1340
+ title: 'Snippet',
1341
+ },
1342
+ source: {
1343
+ type: 'string',
1344
+ title: 'Source',
1345
+ enum: ['web', 'attachment'],
1346
+ },
1347
+ },
1348
+ required: ['title', 'url'],
1349
+ },
1350
+ },
1351
+ },
1352
+ annotations: {},
1353
+ };
1354
+
1355
+ export const handler = async (client: Perplexity, args: Record<string, unknown> | undefined) => {
1356
+ const body = args as any;
1357
+ return asTextContentResult(await client.chat.completions.create(body));
1358
+ };
1359
+
1360
+ export default { metadata, tool, handler };