@providerprotocol/ai 0.0.17 → 0.0.19

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 (45) hide show
  1. package/README.md +294 -114
  2. package/dist/anthropic/index.d.ts +1 -1
  3. package/dist/anthropic/index.js +5 -3
  4. package/dist/anthropic/index.js.map +1 -1
  5. package/dist/{chunk-MOU4U3PO.js → chunk-5FEAOEXV.js} +4 -68
  6. package/dist/chunk-5FEAOEXV.js.map +1 -0
  7. package/dist/chunk-DZQHVGNV.js +71 -0
  8. package/dist/chunk-DZQHVGNV.js.map +1 -0
  9. package/dist/chunk-SKY2JLA7.js +59 -0
  10. package/dist/chunk-SKY2JLA7.js.map +1 -0
  11. package/dist/{chunk-SVYROCLD.js → chunk-UMKWXGO3.js} +1 -1
  12. package/dist/chunk-UMKWXGO3.js.map +1 -0
  13. package/dist/chunk-WAKD3OO5.js +224 -0
  14. package/dist/chunk-WAKD3OO5.js.map +1 -0
  15. package/dist/content-DEl3z_W2.d.ts +276 -0
  16. package/dist/google/index.d.ts +3 -1
  17. package/dist/google/index.js +122 -4
  18. package/dist/google/index.js.map +1 -1
  19. package/dist/http/index.d.ts +2 -2
  20. package/dist/http/index.js +2 -1
  21. package/dist/image-Dhq-Yuq4.d.ts +456 -0
  22. package/dist/index.d.ts +59 -1460
  23. package/dist/index.js +89 -267
  24. package/dist/index.js.map +1 -1
  25. package/dist/ollama/index.d.ts +1 -1
  26. package/dist/ollama/index.js +5 -3
  27. package/dist/ollama/index.js.map +1 -1
  28. package/dist/openai/index.d.ts +47 -20
  29. package/dist/openai/index.js +309 -4
  30. package/dist/openai/index.js.map +1 -1
  31. package/dist/openrouter/index.d.ts +1 -1
  32. package/dist/openrouter/index.js +5 -3
  33. package/dist/openrouter/index.js.map +1 -1
  34. package/dist/{provider-D5MO3-pS.d.ts → provider-BBMBZuGn.d.ts} +11 -11
  35. package/dist/proxy/index.d.ts +652 -0
  36. package/dist/proxy/index.js +565 -0
  37. package/dist/proxy/index.js.map +1 -0
  38. package/dist/{retry-DZ4Sqmxp.d.ts → retry-DR7YRJDz.d.ts} +1 -1
  39. package/dist/stream-DRHy6q1a.d.ts +1013 -0
  40. package/dist/xai/index.d.ts +29 -1
  41. package/dist/xai/index.js +118 -4
  42. package/dist/xai/index.js.map +1 -1
  43. package/package.json +6 -1
  44. package/dist/chunk-MOU4U3PO.js.map +0 -1
  45. package/dist/chunk-SVYROCLD.js.map +0 -1
@@ -0,0 +1,652 @@
1
+ import { d as Provider, f as ModelReference } from '../provider-BBMBZuGn.js';
2
+ import { M as Message, b as MessageJSON, T as Turn, H as TurnJSON, f as StreamEvent, S as StreamResult, J as JSONSchema, k as ToolMetadata, c as Tool } from '../stream-DRHy6q1a.js';
3
+ import '../content-DEl3z_W2.js';
4
+
5
+ /**
6
+ * @fileoverview Proxy provider types.
7
+ *
8
+ * Defines the configuration options and parameters for the proxy provider,
9
+ * which transports PP requests over HTTP to a backend server.
10
+ *
11
+ * @module providers/proxy/types
12
+ */
13
+ /**
14
+ * Proxy-specific LLM parameters.
15
+ *
16
+ * These parameters are passed through to the backend server.
17
+ * The server decides how to interpret them based on its own provider.
18
+ */
19
+ interface ProxyLLMParams {
20
+ /** Parameters are passed through to the backend */
21
+ [key: string]: unknown;
22
+ }
23
+ /**
24
+ * Configuration options for creating a proxy provider.
25
+ */
26
+ interface ProxyProviderOptions {
27
+ /** The endpoint URL to proxy requests to */
28
+ endpoint: string;
29
+ /** Default headers to include in all requests */
30
+ headers?: Record<string, string>;
31
+ /** Custom fetch implementation */
32
+ fetch?: typeof fetch;
33
+ /** Request timeout in milliseconds (default: 120000) */
34
+ timeout?: number;
35
+ }
36
+ /**
37
+ * Per-request options for proxy calls.
38
+ */
39
+ interface ProxyRequestOptions {
40
+ /** Additional headers for this request */
41
+ headers?: Record<string, string>;
42
+ }
43
+
44
+ /**
45
+ * @fileoverview Serialization utilities for proxy transport.
46
+ *
47
+ * Handles converting PP types to/from JSON for HTTP transport.
48
+ * These are pure functions with no side effects.
49
+ *
50
+ * @module providers/proxy/serialization
51
+ */
52
+
53
+ /**
54
+ * Convert a Message to MessageJSON format.
55
+ */
56
+ declare function serializeMessage(m: Message): MessageJSON;
57
+ /**
58
+ * Reconstruct a Message from MessageJSON format.
59
+ */
60
+ declare function deserializeMessage(json: MessageJSON): Message;
61
+ /**
62
+ * Serialize a Turn to JSON-transportable format.
63
+ */
64
+ declare function serializeTurn(turn: Turn): TurnJSON;
65
+ /**
66
+ * Serialize a StreamEvent for JSON transport.
67
+ * Converts Uint8Array data to base64 string.
68
+ */
69
+ declare function serializeStreamEvent(event: StreamEvent): StreamEvent;
70
+ /**
71
+ * Deserialize a StreamEvent from JSON transport.
72
+ * Converts base64 string data back to Uint8Array.
73
+ */
74
+ declare function deserializeStreamEvent(event: StreamEvent): StreamEvent;
75
+
76
+ /**
77
+ * @fileoverview H3/Nitro/Nuxt adapter for proxy server.
78
+ *
79
+ * Provides utilities for using PP proxy with H3-based servers
80
+ * (Nuxt, Nitro, or standalone H3).
81
+ *
82
+ * @module providers/proxy/server/h3
83
+ */
84
+
85
+ /**
86
+ * H3 Event interface (minimal type to avoid dependency).
87
+ */
88
+ interface H3Event {
89
+ node: {
90
+ res: {
91
+ setHeader(name: string, value: string): void;
92
+ write(chunk: string): boolean;
93
+ end(): void;
94
+ };
95
+ };
96
+ }
97
+ /**
98
+ * Send a Turn as JSON response.
99
+ *
100
+ * @param turn - The completed inference turn
101
+ * @param event - H3 event object
102
+ * @returns Serialized turn data
103
+ *
104
+ * @example
105
+ * ```typescript
106
+ * const turn = await instance.generate(messages);
107
+ * return h3Adapter.sendJSON(turn, event);
108
+ * ```
109
+ */
110
+ declare function sendJSON$2(turn: Turn, event: H3Event): unknown;
111
+ /**
112
+ * Stream a StreamResult as Server-Sent Events.
113
+ *
114
+ * @param stream - The StreamResult from instance.stream()
115
+ * @param event - H3 event object
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * const stream = instance.stream(messages);
120
+ * return h3Adapter.streamSSE(stream, event);
121
+ * ```
122
+ */
123
+ declare function streamSSE$2(stream: StreamResult, event: H3Event): void;
124
+ /**
125
+ * Create a ReadableStream for H3's sendStream utility.
126
+ *
127
+ * Use this with H3's sendStream for better integration:
128
+ * ```typescript
129
+ * import { sendStream } from 'h3';
130
+ * return sendStream(event, h3Adapter.createSSEStream(stream));
131
+ * ```
132
+ *
133
+ * @param stream - The StreamResult from instance.stream()
134
+ * @returns A ReadableStream of SSE data
135
+ */
136
+ declare function createSSEStream(stream: StreamResult): ReadableStream<Uint8Array>;
137
+ /**
138
+ * Send an error response.
139
+ *
140
+ * @param message - Error message
141
+ * @param status - HTTP status code
142
+ * @param event - H3 event object
143
+ * @returns Error object for H3 to serialize
144
+ */
145
+ declare function sendError$2(message: string, status: number, event: H3Event): {
146
+ error: string;
147
+ statusCode: number;
148
+ };
149
+ /**
150
+ * H3/Nitro/Nuxt adapter utilities.
151
+ *
152
+ * @example
153
+ * ```typescript
154
+ * // Nuxt server route: server/api/ai.post.ts
155
+ * import { llm, anthropic } from '@providerprotocol/ai';
156
+ * import { parseBody } from '@providerprotocol/ai/proxy';
157
+ * import { h3 as h3Adapter } from '@providerprotocol/ai/proxy/server';
158
+ *
159
+ * export default defineEventHandler(async (event) => {
160
+ * const body = await readBody(event);
161
+ * const { messages, system, params } = parseBody(body);
162
+ * const instance = llm({ model: anthropic('claude-sonnet-4-20250514'), system });
163
+ *
164
+ * const wantsStream = getHeader(event, 'accept')?.includes('text/event-stream');
165
+ * if (wantsStream) {
166
+ * return h3Adapter.streamSSE(instance.stream(messages), event);
167
+ * } else {
168
+ * const turn = await instance.generate(messages);
169
+ * return h3Adapter.sendJSON(turn, event);
170
+ * }
171
+ * });
172
+ * ```
173
+ */
174
+ declare const h3: {
175
+ sendJSON: typeof sendJSON$2;
176
+ streamSSE: typeof streamSSE$2;
177
+ createSSEStream: typeof createSSEStream;
178
+ sendError: typeof sendError$2;
179
+ };
180
+
181
+ /**
182
+ * @fileoverview Fastify adapter for proxy server.
183
+ *
184
+ * Provides utilities for using PP proxy with Fastify servers.
185
+ * These adapters convert PP types to Fastify-compatible responses.
186
+ *
187
+ * @module providers/proxy/server/fastify
188
+ */
189
+
190
+ /**
191
+ * Fastify Reply interface (minimal type to avoid dependency).
192
+ */
193
+ interface FastifyReply {
194
+ header(name: string, value: string): FastifyReply;
195
+ status(code: number): FastifyReply;
196
+ send(payload: unknown): FastifyReply;
197
+ raw: {
198
+ write(chunk: string): boolean;
199
+ end(): void;
200
+ };
201
+ }
202
+ /**
203
+ * Send a Turn as JSON response.
204
+ *
205
+ * @param turn - The completed inference turn
206
+ * @param reply - Fastify reply object
207
+ *
208
+ * @example
209
+ * ```typescript
210
+ * const turn = await instance.generate(messages);
211
+ * return fastifyAdapter.sendJSON(turn, reply);
212
+ * ```
213
+ */
214
+ declare function sendJSON$1(turn: Turn, reply: FastifyReply): FastifyReply;
215
+ /**
216
+ * Stream a StreamResult as Server-Sent Events.
217
+ *
218
+ * @param stream - The StreamResult from instance.stream()
219
+ * @param reply - Fastify reply object
220
+ *
221
+ * @example
222
+ * ```typescript
223
+ * const stream = instance.stream(messages);
224
+ * return fastifyAdapter.streamSSE(stream, reply);
225
+ * ```
226
+ */
227
+ declare function streamSSE$1(stream: StreamResult, reply: FastifyReply): FastifyReply;
228
+ /**
229
+ * Send an error response.
230
+ *
231
+ * @param message - Error message
232
+ * @param status - HTTP status code
233
+ * @param reply - Fastify reply object
234
+ */
235
+ declare function sendError$1(message: string, status: number, reply: FastifyReply): FastifyReply;
236
+ /**
237
+ * Fastify adapter utilities.
238
+ *
239
+ * @example
240
+ * ```typescript
241
+ * import Fastify from 'fastify';
242
+ * import { llm, anthropic } from '@providerprotocol/ai';
243
+ * import { parseBody } from '@providerprotocol/ai/proxy';
244
+ * import { fastify as fastifyAdapter } from '@providerprotocol/ai/proxy/server';
245
+ *
246
+ * const app = Fastify();
247
+ *
248
+ * app.post('/api/ai', async (request, reply) => {
249
+ * const { messages, system, params } = parseBody(request.body);
250
+ * const instance = llm({ model: anthropic('claude-sonnet-4-20250514'), system });
251
+ *
252
+ * if (request.headers.accept?.includes('text/event-stream')) {
253
+ * return fastifyAdapter.streamSSE(instance.stream(messages), reply);
254
+ * } else {
255
+ * const turn = await instance.generate(messages);
256
+ * return fastifyAdapter.sendJSON(turn, reply);
257
+ * }
258
+ * });
259
+ * ```
260
+ */
261
+ declare const fastify: {
262
+ sendJSON: typeof sendJSON$1;
263
+ streamSSE: typeof streamSSE$1;
264
+ sendError: typeof sendError$1;
265
+ };
266
+
267
+ /**
268
+ * @fileoverview Express/Connect adapter for proxy server.
269
+ *
270
+ * Provides utilities for using PP proxy with Express.js or Connect-based servers.
271
+ * These adapters convert PP types to Express-compatible responses.
272
+ *
273
+ * @module providers/proxy/server/express
274
+ */
275
+
276
+ /**
277
+ * Express Response interface (minimal type to avoid dependency).
278
+ */
279
+ interface ExpressResponse {
280
+ setHeader(name: string, value: string): void;
281
+ status(code: number): ExpressResponse;
282
+ write(chunk: string): boolean;
283
+ end(): void;
284
+ json(body: unknown): void;
285
+ }
286
+ /**
287
+ * Send a Turn as JSON response.
288
+ *
289
+ * @param turn - The completed inference turn
290
+ * @param res - Express response object
291
+ *
292
+ * @example
293
+ * ```typescript
294
+ * const turn = await instance.generate(messages);
295
+ * expressAdapter.sendJSON(turn, res);
296
+ * ```
297
+ */
298
+ declare function sendJSON(turn: Turn, res: ExpressResponse): void;
299
+ /**
300
+ * Stream a StreamResult as Server-Sent Events.
301
+ *
302
+ * @param stream - The StreamResult from instance.stream()
303
+ * @param res - Express response object
304
+ *
305
+ * @example
306
+ * ```typescript
307
+ * const stream = instance.stream(messages);
308
+ * expressAdapter.streamSSE(stream, res);
309
+ * ```
310
+ */
311
+ declare function streamSSE(stream: StreamResult, res: ExpressResponse): void;
312
+ /**
313
+ * Send an error response.
314
+ *
315
+ * @param message - Error message
316
+ * @param status - HTTP status code
317
+ * @param res - Express response object
318
+ */
319
+ declare function sendError(message: string, status: number, res: ExpressResponse): void;
320
+ /**
321
+ * Express adapter utilities.
322
+ *
323
+ * @example
324
+ * ```typescript
325
+ * import express from 'express';
326
+ * import { llm, anthropic } from '@providerprotocol/ai';
327
+ * import { parseBody, bindTools } from '@providerprotocol/ai/proxy';
328
+ * import { express as expressAdapter } from '@providerprotocol/ai/proxy/server';
329
+ *
330
+ * const app = express();
331
+ * app.use(express.json());
332
+ *
333
+ * app.post('/api/ai', async (req, res) => {
334
+ * const { messages, system, params } = parseBody(req.body);
335
+ * const instance = llm({ model: anthropic('claude-sonnet-4-20250514'), system });
336
+ *
337
+ * if (req.headers.accept?.includes('text/event-stream')) {
338
+ * expressAdapter.streamSSE(instance.stream(messages), res);
339
+ * } else {
340
+ * const turn = await instance.generate(messages);
341
+ * expressAdapter.sendJSON(turn, res);
342
+ * }
343
+ * });
344
+ * ```
345
+ */
346
+ declare const express: {
347
+ sendJSON: typeof sendJSON;
348
+ streamSSE: typeof streamSSE;
349
+ sendError: typeof sendError;
350
+ };
351
+
352
+ /**
353
+ * @fileoverview Web API adapter for proxy server.
354
+ *
355
+ * Provides utilities for using PP proxy with Web API native frameworks
356
+ * (Bun, Deno, Next.js App Router, Cloudflare Workers).
357
+ *
358
+ * These utilities return standard Web API Response objects that work
359
+ * directly with modern runtimes.
360
+ *
361
+ * @module providers/proxy/server/webapi
362
+ */
363
+
364
+ /**
365
+ * Parsed request body from a proxy HTTP request.
366
+ * This is just the deserialized PP data from the request body.
367
+ */
368
+ interface ParsedRequest {
369
+ messages: Message[];
370
+ system?: string | unknown[];
371
+ params?: Record<string, unknown>;
372
+ tools?: Array<{
373
+ name: string;
374
+ description: string;
375
+ parameters: JSONSchema;
376
+ metadata?: ToolMetadata;
377
+ }>;
378
+ structure?: JSONSchema;
379
+ }
380
+ /**
381
+ * Parse an HTTP request body into PP types.
382
+ *
383
+ * @param body - The JSON-parsed request body
384
+ * @returns Deserialized PP data
385
+ *
386
+ * @example
387
+ * ```typescript
388
+ * const body = await req.json();
389
+ * const { messages, system, params } = parseBody(body);
390
+ *
391
+ * const instance = llm({ model: anthropic('...'), system, params });
392
+ * const turn = await instance.generate(messages);
393
+ * ```
394
+ */
395
+ declare function parseBody(body: unknown): ParsedRequest;
396
+ /**
397
+ * Create a JSON Response from a Turn.
398
+ *
399
+ * @param turn - The completed inference turn
400
+ * @returns HTTP Response with JSON body
401
+ *
402
+ * @example
403
+ * ```typescript
404
+ * const turn = await instance.generate(messages);
405
+ * return toJSON(turn);
406
+ * ```
407
+ */
408
+ declare function toJSON(turn: Turn): Response;
409
+ /**
410
+ * Create an SSE Response from a StreamResult.
411
+ *
412
+ * Streams PP StreamEvents as SSE, then sends the final Turn data.
413
+ *
414
+ * @param stream - The StreamResult from instance.stream()
415
+ * @returns HTTP Response with SSE body
416
+ *
417
+ * @example
418
+ * ```typescript
419
+ * const stream = instance.stream(messages);
420
+ * return toSSE(stream);
421
+ * ```
422
+ */
423
+ declare function toSSE(stream: StreamResult): Response;
424
+ /**
425
+ * Create an error Response.
426
+ *
427
+ * @param message - Error message
428
+ * @param status - HTTP status code (default: 500)
429
+ * @returns HTTP Response with error body
430
+ */
431
+ declare function toError(message: string, status?: number): Response;
432
+ /**
433
+ * Bind tool schemas to implementation functions.
434
+ *
435
+ * Takes tool schemas from the request and binds them to your
436
+ * server-side implementations.
437
+ *
438
+ * @param schemas - Tool schemas from the request
439
+ * @param implementations - Map of tool name to implementation
440
+ * @returns Array of complete Tool objects
441
+ *
442
+ * @example
443
+ * ```typescript
444
+ * const { tools: schemas } = parseBody(body);
445
+ *
446
+ * const tools = bindTools(schemas, {
447
+ * get_weather: async ({ location }) => fetchWeather(location),
448
+ * search: async ({ query }) => searchDB(query),
449
+ * });
450
+ *
451
+ * const instance = llm({ model, tools });
452
+ * ```
453
+ */
454
+ declare function bindTools(schemas: ParsedRequest['tools'], implementations: Record<string, (params: unknown) => unknown | Promise<unknown>>): Tool[];
455
+ /**
456
+ * Web API adapter utilities.
457
+ *
458
+ * For use with Bun, Deno, Next.js App Router, Cloudflare Workers,
459
+ * and other frameworks that support Web API Response.
460
+ *
461
+ * @example
462
+ * ```typescript
463
+ * import { llm, anthropic } from '@providerprotocol/ai';
464
+ * import { parseBody, toJSON, toSSE } from '@providerprotocol/ai/proxy';
465
+ *
466
+ * // Bun.serve / Deno.serve / Next.js App Router
467
+ * export async function POST(req: Request) {
468
+ * const { messages, system } = parseBody(await req.json());
469
+ * const instance = llm({ model: anthropic('claude-sonnet-4-20250514'), system });
470
+ *
471
+ * if (req.headers.get('accept')?.includes('text/event-stream')) {
472
+ * return toSSE(instance.stream(messages));
473
+ * }
474
+ * return toJSON(await instance.generate(messages));
475
+ * }
476
+ * ```
477
+ */
478
+ declare const webapi: {
479
+ parseBody: typeof parseBody;
480
+ toJSON: typeof toJSON;
481
+ toSSE: typeof toSSE;
482
+ toError: typeof toError;
483
+ bindTools: typeof bindTools;
484
+ };
485
+
486
+ /**
487
+ * @fileoverview Shared types for proxy server adapters.
488
+ *
489
+ * @module providers/proxy/server/types
490
+ */
491
+
492
+ /**
493
+ * Parsed request body from a proxy HTTP request.
494
+ */
495
+ interface ParsedBody {
496
+ messages: Message[];
497
+ system?: string | unknown[];
498
+ params?: Record<string, unknown>;
499
+ tools?: Array<{
500
+ name: string;
501
+ description: string;
502
+ parameters: JSONSchema;
503
+ metadata?: ToolMetadata;
504
+ }>;
505
+ structure?: JSONSchema;
506
+ }
507
+ /**
508
+ * Handler function signature for proxy endpoints.
509
+ * Takes parsed request data and returns either a Turn or StreamResult.
510
+ */
511
+ type ProxyHandler = (body: ParsedBody, meta: RequestMeta) => Promise<Turn> | StreamResult | Promise<StreamResult>;
512
+ /**
513
+ * Metadata about the incoming request.
514
+ */
515
+ interface RequestMeta {
516
+ /** Whether the client wants a streaming response */
517
+ wantsStream: boolean;
518
+ /** Raw headers from the request */
519
+ headers: Record<string, string | undefined>;
520
+ }
521
+ /**
522
+ * Options for adapter middleware.
523
+ */
524
+ interface AdapterOptions {
525
+ /** Custom error handler */
526
+ onError?: (error: Error) => {
527
+ message: string;
528
+ status: number;
529
+ };
530
+ }
531
+
532
+ /**
533
+ * Server adapters namespace.
534
+ *
535
+ * Contains framework-specific adapters for Web API, Express, Fastify, and H3.
536
+ *
537
+ * @example Express
538
+ * ```typescript
539
+ * import { express } from '@providerprotocol/ai/proxy/server';
540
+ *
541
+ * app.post('/api/ai', async (req, res) => {
542
+ * const { messages } = parseBody(req.body);
543
+ * if (req.headers.accept?.includes('text/event-stream')) {
544
+ * express.streamSSE(instance.stream(messages), res);
545
+ * } else {
546
+ * express.sendJSON(await instance.generate(messages), res);
547
+ * }
548
+ * });
549
+ * ```
550
+ *
551
+ * @example Fastify
552
+ * ```typescript
553
+ * import { fastify } from '@providerprotocol/ai/proxy/server';
554
+ *
555
+ * app.post('/api/ai', async (request, reply) => {
556
+ * const { messages } = parseBody(request.body);
557
+ * if (request.headers.accept?.includes('text/event-stream')) {
558
+ * return fastify.streamSSE(instance.stream(messages), reply);
559
+ * }
560
+ * return fastify.sendJSON(await instance.generate(messages), reply);
561
+ * });
562
+ * ```
563
+ *
564
+ * @example H3/Nuxt
565
+ * ```typescript
566
+ * import { h3 } from '@providerprotocol/ai/proxy/server';
567
+ *
568
+ * export default defineEventHandler(async (event) => {
569
+ * const { messages } = parseBody(await readBody(event));
570
+ * if (getHeader(event, 'accept')?.includes('text/event-stream')) {
571
+ * return h3.streamSSE(instance.stream(messages), event);
572
+ * }
573
+ * return h3.sendJSON(await instance.generate(messages), event);
574
+ * });
575
+ * ```
576
+ */
577
+ declare const server: {
578
+ /** Web API adapter (Bun, Deno, Next.js, Workers) */
579
+ webapi: {
580
+ parseBody: typeof parseBody;
581
+ toJSON: typeof toJSON;
582
+ toSSE: typeof toSSE;
583
+ toError: typeof toError;
584
+ bindTools: typeof bindTools;
585
+ };
586
+ /** Express/Connect adapter */
587
+ express: {
588
+ sendJSON: typeof sendJSON;
589
+ streamSSE: typeof streamSSE;
590
+ sendError: typeof sendError;
591
+ };
592
+ /** Fastify adapter */
593
+ fastify: {
594
+ sendJSON: typeof sendJSON$1;
595
+ streamSSE: typeof streamSSE$1;
596
+ sendError: typeof sendError$1;
597
+ };
598
+ /** H3/Nitro/Nuxt adapter */
599
+ h3: {
600
+ sendJSON: typeof sendJSON$2;
601
+ streamSSE: typeof streamSSE$2;
602
+ createSSEStream: typeof createSSEStream;
603
+ sendError: typeof sendError$2;
604
+ };
605
+ };
606
+
607
+ /**
608
+ * Creates a proxy provider that transports PP requests over HTTP to a backend server.
609
+ *
610
+ * The proxy acts as a pure transport layer - PP types go in, PP types come out.
611
+ * The modelId is passed through to the backend, which decides which actual model to use.
612
+ *
613
+ * @param options - Configuration for the proxy endpoint
614
+ * @returns A provider that can be used with llm()
615
+ *
616
+ * @example
617
+ * ```typescript
618
+ * import { proxy } from './providers/proxy';
619
+ * import { llm } from './core/llm';
620
+ *
621
+ * const backend = proxy({ endpoint: '/api/ai' });
622
+ *
623
+ * const model = llm({
624
+ * model: backend('gpt-4o'),
625
+ * system: 'You are a helpful assistant.',
626
+ * });
627
+ *
628
+ * const turn = await model.generate('Hello!');
629
+ * ```
630
+ */
631
+ declare function proxy(options: ProxyProviderOptions): Provider<ProxyRequestOptions>;
632
+ /**
633
+ * Shorthand for creating a proxy model reference with default model ID.
634
+ *
635
+ * Creates a proxy provider and immediately returns a model reference using
636
+ * 'default' as the model identifier. Useful for simple single-endpoint setups.
637
+ *
638
+ * @param endpoint - The URL to proxy requests to
639
+ * @returns A model reference for use with llm()
640
+ *
641
+ * @example
642
+ * ```typescript
643
+ * import { proxyModel } from './providers/proxy';
644
+ * import { llm } from './core/llm';
645
+ *
646
+ * const model = llm({ model: proxyModel('/api/ai') });
647
+ * const turn = await model.generate('Hello!');
648
+ * ```
649
+ */
650
+ declare function proxyModel(endpoint: string): ModelReference<ProxyRequestOptions>;
651
+
652
+ export { type AdapterOptions, type ParsedBody, type ParsedRequest, type ProxyHandler, type ProxyLLMParams, type ProxyProviderOptions, type ProxyRequestOptions, type RequestMeta, TurnJSON, bindTools, deserializeMessage, deserializeStreamEvent, express, fastify, h3, parseBody, proxy, proxyModel, serializeMessage, serializeStreamEvent, serializeTurn, server, toError, toJSON, toSSE, webapi };