@providerprotocol/ai 0.0.26 → 0.0.28

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 (37) hide show
  1. package/dist/anthropic/index.d.ts +1 -1
  2. package/dist/anthropic/index.js +38 -1
  3. package/dist/anthropic/index.js.map +1 -1
  4. package/dist/{chunk-6AZVUI6H.js → chunk-ILR2D5PN.js} +7 -1
  5. package/dist/chunk-ILR2D5PN.js.map +1 -0
  6. package/dist/{chunk-MKDLXV4O.js → chunk-NSE7QN3P.js} +1 -1
  7. package/dist/chunk-NSE7QN3P.js.map +1 -0
  8. package/dist/embedding-DtyOFIsS.d.ts +158 -0
  9. package/dist/google/index.d.ts +1 -1
  10. package/dist/google/index.js +41 -4
  11. package/dist/google/index.js.map +1 -1
  12. package/dist/http/index.d.ts +2 -2
  13. package/dist/index.d.ts +430 -669
  14. package/dist/index.js +627 -3
  15. package/dist/index.js.map +1 -1
  16. package/dist/llm-DgDEy9il.d.ts +3118 -0
  17. package/dist/ollama/index.d.ts +1 -1
  18. package/dist/ollama/index.js +2 -1
  19. package/dist/ollama/index.js.map +1 -1
  20. package/dist/openai/index.d.ts +1 -1
  21. package/dist/openai/index.js +70 -3
  22. package/dist/openai/index.js.map +1 -1
  23. package/dist/openrouter/index.d.ts +20 -2
  24. package/dist/openrouter/index.js +134 -13
  25. package/dist/openrouter/index.js.map +1 -1
  26. package/dist/proxy/index.d.ts +220 -3
  27. package/dist/proxy/index.js +817 -22
  28. package/dist/proxy/index.js.map +1 -1
  29. package/dist/{retry-DTfjXXPh.d.ts → retry-DXLQnTuU.d.ts} +1 -1
  30. package/dist/xai/index.d.ts +1 -1
  31. package/dist/xai/index.js +7 -3
  32. package/dist/xai/index.js.map +1 -1
  33. package/package.json +1 -1
  34. package/dist/chunk-6AZVUI6H.js.map +0 -1
  35. package/dist/chunk-MKDLXV4O.js.map +0 -1
  36. package/dist/provider-x4RocsnK.d.ts +0 -1474
  37. package/dist/stream-ITNFNnO4.d.ts +0 -1080
@@ -1,5 +1,5 @@
1
- import { g as Provider, M as ModelReference } from '../provider-x4RocsnK.js';
2
- import { M as Message, b as MessageJSON, T as Turn, I as TurnJSON, f as StreamEvent, S as StreamResult, J as JSONSchema, k as ToolMetadata, c as Tool } from '../stream-ITNFNnO4.js';
1
+ import { X as Message, ad as MessageJSON, a6 as Turn, aX as TurnJSON, ae as StreamEvent, aP as ImageStreamResult, aU as ImageProviderStreamResult, aN as ImageResult, ag as StreamResult, f as Image, J as JSONSchema, N as ToolMetadata, aB as EmbeddingInput, G as Tool, P as Provider, M as ModelReference } from '../llm-DgDEy9il.js';
2
+ import { d as EmbeddingResult } from '../embedding-DtyOFIsS.js';
3
3
 
4
4
  /**
5
5
  * @fileoverview Proxy provider types.
@@ -19,6 +19,26 @@ interface ProxyLLMParams {
19
19
  /** Parameters are passed through to the backend */
20
20
  [key: string]: unknown;
21
21
  }
22
+ /**
23
+ * Proxy-specific embedding parameters.
24
+ *
25
+ * These parameters are passed through to the backend server.
26
+ * The server decides how to interpret them based on its own provider.
27
+ */
28
+ interface ProxyEmbeddingParams {
29
+ /** Parameters are passed through to the backend */
30
+ [key: string]: unknown;
31
+ }
32
+ /**
33
+ * Proxy-specific image parameters.
34
+ *
35
+ * These parameters are passed through to the backend server.
36
+ * The server decides how to interpret them based on its own provider.
37
+ */
38
+ interface ProxyImageParams {
39
+ /** Parameters are passed through to the backend */
40
+ [key: string]: unknown;
41
+ }
22
42
  /**
23
43
  * Configuration options for creating a proxy provider.
24
44
  */
@@ -72,6 +92,14 @@ declare function serializeStreamEvent(event: StreamEvent): StreamEvent;
72
92
  */
73
93
  declare function deserializeStreamEvent(event: StreamEvent): StreamEvent;
74
94
 
95
+ /**
96
+ * @fileoverview Image stream helpers for proxy server adapters.
97
+ *
98
+ * @module providers/proxy/server/image-stream
99
+ */
100
+
101
+ type ImageStreamLike = ImageStreamResult | ImageProviderStreamResult;
102
+
75
103
  /**
76
104
  * @fileoverview H3/Nitro/Nuxt adapter for proxy server.
77
105
  *
@@ -107,6 +135,22 @@ interface H3Event {
107
135
  * ```
108
136
  */
109
137
  declare function sendJSON$2(turn: Turn, event: H3Event): unknown;
138
+ /**
139
+ * Send an EmbeddingResult as JSON response.
140
+ *
141
+ * @param result - The embedding result
142
+ * @param event - H3 event object
143
+ * @returns Serialized result data
144
+ */
145
+ declare function sendEmbeddingJSON$2(result: EmbeddingResult, event: H3Event): unknown;
146
+ /**
147
+ * Send an ImageResult as JSON response.
148
+ *
149
+ * @param result - The image result
150
+ * @param event - H3 event object
151
+ * @returns Serialized image result data
152
+ */
153
+ declare function sendImageJSON$2(result: ImageResult, event: H3Event): unknown;
110
154
  /**
111
155
  * Stream a StreamResult as Server-Sent Events.
112
156
  *
@@ -120,6 +164,13 @@ declare function sendJSON$2(turn: Turn, event: H3Event): unknown;
120
164
  * ```
121
165
  */
122
166
  declare function streamSSE$2(stream: StreamResult, event: H3Event): void;
167
+ /**
168
+ * Stream an ImageStreamResult as Server-Sent Events.
169
+ *
170
+ * @param stream - The ImageStreamResult or ImageProviderStreamResult from image().stream()
171
+ * @param event - H3 event object
172
+ */
173
+ declare function streamImageSSE$2(stream: ImageStreamLike, event: H3Event): void;
123
174
  /**
124
175
  * Create a ReadableStream for H3's sendStream utility.
125
176
  *
@@ -133,6 +184,13 @@ declare function streamSSE$2(stream: StreamResult, event: H3Event): void;
133
184
  * @returns A ReadableStream of SSE data
134
185
  */
135
186
  declare function createSSEStream(stream: StreamResult): ReadableStream<Uint8Array>;
187
+ /**
188
+ * Create a ReadableStream for image SSE data.
189
+ *
190
+ * @param stream - The ImageStreamResult or ImageProviderStreamResult from image().stream()
191
+ * @returns A ReadableStream of SSE data
192
+ */
193
+ declare function createImageSSEStream(stream: ImageStreamLike): ReadableStream<Uint8Array>;
136
194
  /**
137
195
  * Send an error response.
138
196
  *
@@ -216,8 +274,12 @@ declare function sendError$2(message: string, status: number, event: H3Event): {
216
274
  */
217
275
  declare const h3: {
218
276
  sendJSON: typeof sendJSON$2;
277
+ sendEmbeddingJSON: typeof sendEmbeddingJSON$2;
278
+ sendImageJSON: typeof sendImageJSON$2;
219
279
  streamSSE: typeof streamSSE$2;
280
+ streamImageSSE: typeof streamImageSSE$2;
220
281
  createSSEStream: typeof createSSEStream;
282
+ createImageSSEStream: typeof createImageSSEStream;
221
283
  sendError: typeof sendError$2;
222
284
  };
223
285
 
@@ -255,6 +317,20 @@ interface FastifyReply {
255
317
  * ```
256
318
  */
257
319
  declare function sendJSON$1(turn: Turn, reply: FastifyReply): FastifyReply;
320
+ /**
321
+ * Send an EmbeddingResult as JSON response.
322
+ *
323
+ * @param result - The embedding result
324
+ * @param reply - Fastify reply object
325
+ */
326
+ declare function sendEmbeddingJSON$1(result: EmbeddingResult, reply: FastifyReply): FastifyReply;
327
+ /**
328
+ * Send an ImageResult as JSON response.
329
+ *
330
+ * @param result - The image result
331
+ * @param reply - Fastify reply object
332
+ */
333
+ declare function sendImageJSON$1(result: ImageResult, reply: FastifyReply): FastifyReply;
258
334
  /**
259
335
  * Stream a StreamResult as Server-Sent Events.
260
336
  *
@@ -268,6 +344,13 @@ declare function sendJSON$1(turn: Turn, reply: FastifyReply): FastifyReply;
268
344
  * ```
269
345
  */
270
346
  declare function streamSSE$1(stream: StreamResult, reply: FastifyReply): FastifyReply;
347
+ /**
348
+ * Stream an ImageStreamResult as Server-Sent Events.
349
+ *
350
+ * @param stream - The ImageStreamResult or ImageProviderStreamResult from image().stream()
351
+ * @param reply - Fastify reply object
352
+ */
353
+ declare function streamImageSSE$1(stream: ImageStreamLike, reply: FastifyReply): FastifyReply;
271
354
  /**
272
355
  * Send an error response.
273
356
  *
@@ -349,7 +432,10 @@ declare function sendError$1(message: string, status: number, reply: FastifyRepl
349
432
  */
350
433
  declare const fastify: {
351
434
  sendJSON: typeof sendJSON$1;
435
+ sendEmbeddingJSON: typeof sendEmbeddingJSON$1;
436
+ sendImageJSON: typeof sendImageJSON$1;
352
437
  streamSSE: typeof streamSSE$1;
438
+ streamImageSSE: typeof streamImageSSE$1;
353
439
  sendError: typeof sendError$1;
354
440
  };
355
441
 
@@ -385,6 +471,20 @@ interface ExpressResponse {
385
471
  * ```
386
472
  */
387
473
  declare function sendJSON(turn: Turn, res: ExpressResponse): void;
474
+ /**
475
+ * Send an EmbeddingResult as JSON response.
476
+ *
477
+ * @param result - The embedding result
478
+ * @param res - Express response object
479
+ */
480
+ declare function sendEmbeddingJSON(result: EmbeddingResult, res: ExpressResponse): void;
481
+ /**
482
+ * Send an ImageResult as JSON response.
483
+ *
484
+ * @param result - The image result
485
+ * @param res - Express response object
486
+ */
487
+ declare function sendImageJSON(result: ImageResult, res: ExpressResponse): void;
388
488
  /**
389
489
  * Stream a StreamResult as Server-Sent Events.
390
490
  *
@@ -398,6 +498,13 @@ declare function sendJSON(turn: Turn, res: ExpressResponse): void;
398
498
  * ```
399
499
  */
400
500
  declare function streamSSE(stream: StreamResult, res: ExpressResponse): void;
501
+ /**
502
+ * Stream an ImageStreamResult as Server-Sent Events.
503
+ *
504
+ * @param stream - The ImageStreamResult or ImageProviderStreamResult from image().stream()
505
+ * @param res - Express response object
506
+ */
507
+ declare function streamImageSSE(stream: ImageStreamLike, res: ExpressResponse): void;
401
508
  /**
402
509
  * Send an error response.
403
510
  *
@@ -480,10 +587,43 @@ declare function sendError(message: string, status: number, res: ExpressResponse
480
587
  */
481
588
  declare const express: {
482
589
  sendJSON: typeof sendJSON;
590
+ sendEmbeddingJSON: typeof sendEmbeddingJSON;
591
+ sendImageJSON: typeof sendImageJSON;
483
592
  streamSSE: typeof streamSSE;
593
+ streamImageSSE: typeof streamImageSSE;
484
594
  sendError: typeof sendError;
485
595
  };
486
596
 
597
+ /**
598
+ * @fileoverview Media serialization utilities for proxy transport.
599
+ *
600
+ * Handles converting embedding inputs and image results/events to/from JSON
601
+ * for HTTP transport. These are pure functions with no side effects.
602
+ *
603
+ * @module providers/proxy/serialization.media
604
+ */
605
+
606
+ type SerializedImageSource = {
607
+ type: 'base64';
608
+ data: string;
609
+ } | {
610
+ type: 'url';
611
+ url: string;
612
+ } | {
613
+ type: 'bytes';
614
+ data: number[] | string;
615
+ };
616
+ interface SerializedImage {
617
+ source: SerializedImageSource;
618
+ mimeType: string;
619
+ width?: number;
620
+ height?: number;
621
+ }
622
+ /**
623
+ * Deserialize an Image from JSON transport.
624
+ */
625
+ declare function deserializeImage(image: SerializedImage): Image;
626
+
487
627
  /**
488
628
  * @fileoverview Web API adapter for proxy server.
489
629
  *
@@ -504,6 +644,7 @@ interface ParsedRequest {
504
644
  messages: Message[];
505
645
  system?: string | unknown[];
506
646
  params?: Record<string, unknown>;
647
+ model?: string;
507
648
  tools?: Array<{
508
649
  name: string;
509
650
  description: string;
@@ -512,6 +653,24 @@ interface ParsedRequest {
512
653
  }>;
513
654
  structure?: JSONSchema;
514
655
  }
656
+ /**
657
+ * Parsed request body for embedding endpoints.
658
+ */
659
+ interface ParsedEmbeddingRequest {
660
+ inputs: EmbeddingInput[];
661
+ params?: Record<string, unknown>;
662
+ model?: string;
663
+ }
664
+ /**
665
+ * Parsed request body for image endpoints.
666
+ */
667
+ interface ParsedImageRequest {
668
+ prompt: string;
669
+ params?: Record<string, unknown>;
670
+ model?: string;
671
+ image?: ReturnType<typeof deserializeImage>;
672
+ mask?: ReturnType<typeof deserializeImage>;
673
+ }
515
674
  /**
516
675
  * Parse an HTTP request body into PP types.
517
676
  *
@@ -528,6 +687,20 @@ interface ParsedRequest {
528
687
  * ```
529
688
  */
530
689
  declare function parseBody(body: unknown): ParsedRequest;
690
+ /**
691
+ * Parse an HTTP request body into embedding inputs.
692
+ *
693
+ * @param body - The JSON-parsed request body
694
+ * @returns Parsed embedding request data
695
+ */
696
+ declare function parseEmbeddingBody(body: unknown): ParsedEmbeddingRequest;
697
+ /**
698
+ * Parse an HTTP request body into image request data.
699
+ *
700
+ * @param body - The JSON-parsed request body
701
+ * @returns Parsed image request data
702
+ */
703
+ declare function parseImageBody(body: unknown): ParsedImageRequest;
531
704
  /**
532
705
  * Create a JSON Response from a Turn.
533
706
  *
@@ -541,6 +714,20 @@ declare function parseBody(body: unknown): ParsedRequest;
541
714
  * ```
542
715
  */
543
716
  declare function toJSON(turn: Turn): Response;
717
+ /**
718
+ * Create a JSON Response from an embedding result.
719
+ *
720
+ * @param result - The embedding result
721
+ * @returns HTTP Response with JSON body
722
+ */
723
+ declare function toEmbeddingJSON(result: EmbeddingResult): Response;
724
+ /**
725
+ * Create a JSON Response from an image result.
726
+ *
727
+ * @param result - The image result
728
+ * @returns HTTP Response with JSON body
729
+ */
730
+ declare function toImageJSON(result: ImageResult): Response;
544
731
  /**
545
732
  * Create an SSE Response from a StreamResult.
546
733
  *
@@ -556,6 +743,15 @@ declare function toJSON(turn: Turn): Response;
556
743
  * ```
557
744
  */
558
745
  declare function toSSE(stream: StreamResult): Response;
746
+ /**
747
+ * Create an SSE Response from an ImageStreamResult.
748
+ *
749
+ * Streams image events as SSE, then sends the final image result.
750
+ *
751
+ * @param stream - The ImageStreamResult or ImageProviderStreamResult from image().stream()
752
+ * @returns HTTP Response with SSE body
753
+ */
754
+ declare function toImageSSE(stream: ImageStreamLike): Response;
559
755
  /**
560
756
  * Create an error Response.
561
757
  *
@@ -659,8 +855,13 @@ declare function bindTools(schemas: ParsedRequest['tools'], implementations: Rec
659
855
  */
660
856
  declare const webapi: {
661
857
  parseBody: typeof parseBody;
858
+ parseEmbeddingBody: typeof parseEmbeddingBody;
859
+ parseImageBody: typeof parseImageBody;
662
860
  toJSON: typeof toJSON;
861
+ toEmbeddingJSON: typeof toEmbeddingJSON;
862
+ toImageJSON: typeof toImageJSON;
663
863
  toSSE: typeof toSSE;
864
+ toImageSSE: typeof toImageSSE;
664
865
  toError: typeof toError;
665
866
  bindTools: typeof bindTools;
666
867
  };
@@ -678,6 +879,7 @@ interface ParsedBody {
678
879
  messages: Message[];
679
880
  system?: string | unknown[];
680
881
  params?: Record<string, unknown>;
882
+ model?: string;
681
883
  tools?: Array<{
682
884
  name: string;
683
885
  description: string;
@@ -760,28 +962,43 @@ declare const server: {
760
962
  /** Web API adapter (Bun, Deno, Next.js, Workers) */
761
963
  webapi: {
762
964
  parseBody: typeof parseBody;
965
+ parseEmbeddingBody: typeof parseEmbeddingBody;
966
+ parseImageBody: typeof parseImageBody;
763
967
  toJSON: typeof toJSON;
968
+ toEmbeddingJSON: typeof toEmbeddingJSON;
969
+ toImageJSON: typeof toImageJSON;
764
970
  toSSE: typeof toSSE;
971
+ toImageSSE: typeof toImageSSE;
765
972
  toError: typeof toError;
766
973
  bindTools: typeof bindTools;
767
974
  };
768
975
  /** Express/Connect adapter */
769
976
  express: {
770
977
  sendJSON: typeof sendJSON;
978
+ sendEmbeddingJSON: typeof sendEmbeddingJSON;
979
+ sendImageJSON: typeof sendImageJSON;
771
980
  streamSSE: typeof streamSSE;
981
+ streamImageSSE: typeof streamImageSSE;
772
982
  sendError: typeof sendError;
773
983
  };
774
984
  /** Fastify adapter */
775
985
  fastify: {
776
986
  sendJSON: typeof sendJSON$1;
987
+ sendEmbeddingJSON: typeof sendEmbeddingJSON$1;
988
+ sendImageJSON: typeof sendImageJSON$1;
777
989
  streamSSE: typeof streamSSE$1;
990
+ streamImageSSE: typeof streamImageSSE$1;
778
991
  sendError: typeof sendError$1;
779
992
  };
780
993
  /** H3/Nitro/Nuxt adapter */
781
994
  h3: {
782
995
  sendJSON: typeof sendJSON$2;
996
+ sendEmbeddingJSON: typeof sendEmbeddingJSON$2;
997
+ sendImageJSON: typeof sendImageJSON$2;
783
998
  streamSSE: typeof streamSSE$2;
999
+ streamImageSSE: typeof streamImageSSE$2;
784
1000
  createSSEStream: typeof createSSEStream;
1001
+ createImageSSEStream: typeof createImageSSEStream;
785
1002
  sendError: typeof sendError$2;
786
1003
  };
787
1004
  };
@@ -831,4 +1048,4 @@ declare function proxy(options: ProxyProviderOptions): Provider<ProxyRequestOpti
831
1048
  */
832
1049
  declare function proxyModel(endpoint: string): ModelReference<ProxyRequestOptions>;
833
1050
 
834
- 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 };
1051
+ export { type AdapterOptions, type ParsedBody, type ParsedEmbeddingRequest, type ParsedImageRequest, type ParsedRequest, type ProxyEmbeddingParams, type ProxyHandler, type ProxyImageParams, type ProxyLLMParams, type ProxyProviderOptions, type ProxyRequestOptions, type RequestMeta, TurnJSON, bindTools, deserializeMessage, deserializeStreamEvent, express, fastify, h3, parseBody, parseEmbeddingBody, parseImageBody, proxy, proxyModel, serializeMessage, serializeStreamEvent, serializeTurn, server, toEmbeddingJSON, toError, toImageJSON, toImageSSE, toJSON, toSSE, webapi };