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