@providerprotocol/ai 0.0.34 → 0.0.36

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 (136) hide show
  1. package/README.md +546 -3
  2. package/dist/anthropic/index.d.ts +2 -1
  3. package/dist/anthropic/index.js +151 -145
  4. package/dist/anthropic/index.js.map +1 -1
  5. package/dist/cerebras/index.d.ts +392 -0
  6. package/dist/cerebras/index.js +648 -0
  7. package/dist/cerebras/index.js.map +1 -0
  8. package/dist/chunk-2YXFLRQ6.js +49 -0
  9. package/dist/chunk-2YXFLRQ6.js.map +1 -0
  10. package/dist/chunk-4OGB7JZA.js +157 -0
  11. package/dist/chunk-4OGB7JZA.js.map +1 -0
  12. package/dist/chunk-4RX4VQCB.js +31 -0
  13. package/dist/chunk-4RX4VQCB.js.map +1 -0
  14. package/dist/chunk-5IWHCXKN.js +30 -0
  15. package/dist/chunk-5IWHCXKN.js.map +1 -0
  16. package/dist/{chunk-3C7O2RNO.js → chunk-A2IM7PGT.js} +6 -4
  17. package/dist/{chunk-3C7O2RNO.js.map → chunk-A2IM7PGT.js.map} +1 -1
  18. package/dist/{chunk-3D6XGGVG.js → chunk-ARVM24K2.js} +2 -2
  19. package/dist/{chunk-4J6OFUKX.js → chunk-AY55T37A.js} +70 -162
  20. package/dist/chunk-AY55T37A.js.map +1 -0
  21. package/dist/{chunk-ILR2D5PN.js → chunk-BRP5XJ6Q.js} +2 -86
  22. package/dist/chunk-BRP5XJ6Q.js.map +1 -0
  23. package/dist/chunk-C4JP64VW.js +298 -0
  24. package/dist/chunk-C4JP64VW.js.map +1 -0
  25. package/dist/chunk-COS4ON4G.js +111 -0
  26. package/dist/chunk-COS4ON4G.js.map +1 -0
  27. package/dist/chunk-CRP6Y7NF.js +31 -0
  28. package/dist/chunk-CRP6Y7NF.js.map +1 -0
  29. package/dist/chunk-EPB3GQNL.js +118 -0
  30. package/dist/chunk-EPB3GQNL.js.map +1 -0
  31. package/dist/chunk-ETBFOLQN.js +34 -0
  32. package/dist/chunk-ETBFOLQN.js.map +1 -0
  33. package/dist/chunk-I53CI6ZZ.js +142 -0
  34. package/dist/chunk-I53CI6ZZ.js.map +1 -0
  35. package/dist/chunk-IDZOVWP3.js +29 -0
  36. package/dist/chunk-IDZOVWP3.js.map +1 -0
  37. package/dist/chunk-JA3UZALR.js +88 -0
  38. package/dist/chunk-JA3UZALR.js.map +1 -0
  39. package/dist/{chunk-WAKD3OO5.js → chunk-N5DX5JW3.js} +31 -31
  40. package/dist/chunk-N5DX5JW3.js.map +1 -0
  41. package/dist/chunk-OIEWDFQU.js +97 -0
  42. package/dist/chunk-OIEWDFQU.js.map +1 -0
  43. package/dist/{chunk-TOJCZMVU.js → chunk-PMK5LZ5Z.js} +40 -40
  44. package/dist/chunk-PMK5LZ5Z.js.map +1 -0
  45. package/dist/{chunk-6S222DHN.js → chunk-RJGTRQ47.js} +20 -1
  46. package/dist/chunk-RJGTRQ47.js.map +1 -0
  47. package/dist/chunk-UFFJDYCE.js +94 -0
  48. package/dist/chunk-UFFJDYCE.js.map +1 -0
  49. package/dist/chunk-VGKZIGVI.js +222 -0
  50. package/dist/chunk-VGKZIGVI.js.map +1 -0
  51. package/dist/{chunk-KUPF5KHT.js → chunk-Y5H7C5J4.js} +2 -2
  52. package/dist/{embedding-D2BYIehX.d.ts → embedding-BXA72PlJ.d.ts} +1 -1
  53. package/dist/google/index.d.ts +2 -1
  54. package/dist/google/index.js +202 -199
  55. package/dist/google/index.js.map +1 -1
  56. package/dist/groq/index.d.ts +410 -0
  57. package/dist/groq/index.js +649 -0
  58. package/dist/groq/index.js.map +1 -0
  59. package/dist/http/index.d.ts +3 -2
  60. package/dist/http/index.js +5 -4
  61. package/dist/image-stream-CCgwB7ve.d.ts +11 -0
  62. package/dist/index.d.ts +8 -118
  63. package/dist/index.js +520 -769
  64. package/dist/index.js.map +1 -1
  65. package/dist/{llm-BQJZj3cD.d.ts → llm-ByUFPcFH.d.ts} +12 -1632
  66. package/dist/middleware/logging/index.d.ts +76 -0
  67. package/dist/middleware/logging/index.js +74 -0
  68. package/dist/middleware/logging/index.js.map +1 -0
  69. package/dist/middleware/parsed-object/index.d.ts +45 -0
  70. package/dist/middleware/parsed-object/index.js +73 -0
  71. package/dist/middleware/parsed-object/index.js.map +1 -0
  72. package/dist/middleware/pubsub/index.d.ts +97 -0
  73. package/dist/middleware/pubsub/index.js +160 -0
  74. package/dist/middleware/pubsub/index.js.map +1 -0
  75. package/dist/middleware/pubsub/server/express/index.d.ts +66 -0
  76. package/dist/middleware/pubsub/server/express/index.js +11 -0
  77. package/dist/middleware/pubsub/server/express/index.js.map +1 -0
  78. package/dist/middleware/pubsub/server/fastify/index.d.ts +67 -0
  79. package/dist/middleware/pubsub/server/fastify/index.js +11 -0
  80. package/dist/middleware/pubsub/server/fastify/index.js.map +1 -0
  81. package/dist/middleware/pubsub/server/h3/index.d.ts +70 -0
  82. package/dist/middleware/pubsub/server/h3/index.js +11 -0
  83. package/dist/middleware/pubsub/server/h3/index.js.map +1 -0
  84. package/dist/middleware/pubsub/server/index.d.ts +78 -0
  85. package/dist/middleware/pubsub/server/index.js +34 -0
  86. package/dist/middleware/pubsub/server/index.js.map +1 -0
  87. package/dist/middleware/pubsub/server/webapi/index.d.ts +63 -0
  88. package/dist/middleware/pubsub/server/webapi/index.js +11 -0
  89. package/dist/middleware/pubsub/server/webapi/index.js.map +1 -0
  90. package/dist/ollama/index.d.ts +2 -1
  91. package/dist/ollama/index.js +48 -45
  92. package/dist/ollama/index.js.map +1 -1
  93. package/dist/openai/index.d.ts +2 -1
  94. package/dist/openai/index.js +319 -313
  95. package/dist/openai/index.js.map +1 -1
  96. package/dist/openrouter/index.d.ts +2 -1
  97. package/dist/openrouter/index.js +381 -385
  98. package/dist/openrouter/index.js.map +1 -1
  99. package/dist/proxy/index.d.ts +10 -914
  100. package/dist/proxy/index.js +275 -1007
  101. package/dist/proxy/index.js.map +1 -1
  102. package/dist/proxy/server/express/index.d.ts +161 -0
  103. package/dist/proxy/server/express/index.js +24 -0
  104. package/dist/proxy/server/express/index.js.map +1 -0
  105. package/dist/proxy/server/fastify/index.d.ts +162 -0
  106. package/dist/proxy/server/fastify/index.js +24 -0
  107. package/dist/proxy/server/fastify/index.js.map +1 -0
  108. package/dist/proxy/server/h3/index.d.ts +189 -0
  109. package/dist/proxy/server/h3/index.js +28 -0
  110. package/dist/proxy/server/h3/index.js.map +1 -0
  111. package/dist/proxy/server/index.d.ts +151 -0
  112. package/dist/proxy/server/index.js +48 -0
  113. package/dist/proxy/server/index.js.map +1 -0
  114. package/dist/proxy/server/webapi/index.d.ts +278 -0
  115. package/dist/proxy/server/webapi/index.js +32 -0
  116. package/dist/proxy/server/webapi/index.js.map +1 -0
  117. package/dist/responses/index.d.ts +650 -0
  118. package/dist/responses/index.js +930 -0
  119. package/dist/responses/index.js.map +1 -0
  120. package/dist/{retry-8Ch-WWgX.d.ts → retry-BDMo4AVu.d.ts} +1 -1
  121. package/dist/stream-S7nwQRqM.d.ts +1643 -0
  122. package/dist/types-CE4B7pno.d.ts +96 -0
  123. package/dist/utils/index.d.ts +53 -0
  124. package/dist/utils/index.js +7 -0
  125. package/dist/utils/index.js.map +1 -0
  126. package/dist/xai/index.d.ts +2 -1
  127. package/dist/xai/index.js +310 -310
  128. package/dist/xai/index.js.map +1 -1
  129. package/package.json +82 -4
  130. package/dist/chunk-4J6OFUKX.js.map +0 -1
  131. package/dist/chunk-6S222DHN.js.map +0 -1
  132. package/dist/chunk-ILR2D5PN.js.map +0 -1
  133. package/dist/chunk-TOJCZMVU.js.map +0 -1
  134. package/dist/chunk-WAKD3OO5.js.map +0 -1
  135. /package/dist/{chunk-3D6XGGVG.js.map → chunk-ARVM24K2.js.map} +0 -0
  136. /package/dist/{chunk-KUPF5KHT.js.map → chunk-Y5H7C5J4.js.map} +0 -0
@@ -0,0 +1,96 @@
1
+ import { S as StreamEvent } from './stream-S7nwQRqM.js';
2
+
3
+ /**
4
+ * @fileoverview Pub-sub middleware types for stream resumption.
5
+ *
6
+ * Defines interfaces for temporary stream storage, replay, and
7
+ * multi-client broadcast during active generation.
8
+ *
9
+ * @module middleware/pubsub/types
10
+ */
11
+
12
+ /**
13
+ * Stored stream state (in-flight only).
14
+ */
15
+ interface StoredStream {
16
+ readonly streamId: string;
17
+ readonly createdAt: number;
18
+ readonly events: readonly StreamEvent[];
19
+ }
20
+ /**
21
+ * Subscription callback for live events.
22
+ *
23
+ * @param event - Stream event payload
24
+ * @param cursor - Zero-based event index when adapter supports cursors
25
+ */
26
+ type SubscriptionCallback = (event: StreamEvent, cursor?: number) => void;
27
+ /**
28
+ * Completion callback when stream ends.
29
+ *
30
+ * Adapters should invoke this when {@link PubSubAdapter.remove} is called
31
+ * so subscriber streams can terminate before the stream is deleted.
32
+ */
33
+ type CompletionCallback = () => void;
34
+ /**
35
+ * Unsubscribe function returned by subscribe.
36
+ */
37
+ type Unsubscribe = () => void;
38
+ /**
39
+ * Storage adapter interface for pub-sub middleware.
40
+ *
41
+ * Stores in-flight streams only. Completed streams are removed immediately.
42
+ * Apps should persist completed conversations via `.then()` and serve from
43
+ * their own storage on reconnect.
44
+ */
45
+ interface PubSubAdapter {
46
+ /**
47
+ * Checks if a stream exists.
48
+ */
49
+ exists(streamId: string): Promise<boolean>;
50
+ /**
51
+ * Appends an event to the stream (creates lazily if needed).
52
+ */
53
+ append(streamId: string, event: StreamEvent): Promise<void>;
54
+ /**
55
+ * Fetches all events for replay.
56
+ */
57
+ getEvents(streamId: string): Promise<StreamEvent[]>;
58
+ /**
59
+ * Subscribes to live events (creates lazily if needed).
60
+ */
61
+ subscribe(streamId: string, onEvent: SubscriptionCallback, onComplete: CompletionCallback): Unsubscribe;
62
+ /**
63
+ * Publishes event to all subscribers.
64
+ */
65
+ publish(streamId: string, event: StreamEvent): void;
66
+ /**
67
+ * Notifies subscribers and removes stream from storage.
68
+ */
69
+ remove(streamId: string): Promise<void>;
70
+ }
71
+ /**
72
+ * Options for pub-sub middleware.
73
+ */
74
+ interface PubSubOptions {
75
+ /**
76
+ * Storage adapter instance.
77
+ * @default memoryAdapter()
78
+ */
79
+ adapter?: PubSubAdapter;
80
+ /**
81
+ * Stream identifier for pub-sub behavior.
82
+ */
83
+ streamId?: string;
84
+ }
85
+ /**
86
+ * Options for memory adapter.
87
+ */
88
+ interface MemoryAdapterOptions {
89
+ /**
90
+ * Max concurrent streams allowed. Throws if exceeded.
91
+ * @default 1000
92
+ */
93
+ maxStreams?: number;
94
+ }
95
+
96
+ export type { CompletionCallback as C, MemoryAdapterOptions as M, PubSubAdapter as P, StoredStream as S, Unsubscribe as U, PubSubOptions as a, SubscriptionCallback as b };
@@ -0,0 +1,53 @@
1
+ /**
2
+ * @fileoverview Partial JSON parser for streaming LLM responses.
3
+ *
4
+ * Enables incremental parsing of JSON data as it streams from LLM providers,
5
+ * allowing consumers to access usable partial objects during streaming rather
6
+ * than waiting for complete JSON.
7
+ *
8
+ * @module utils/partial-json
9
+ */
10
+ /**
11
+ * Result of parsing partial JSON.
12
+ *
13
+ * @typeParam T - The expected type of the parsed value
14
+ */
15
+ interface PartialParseResult<T = unknown> {
16
+ /** The parsed value, or undefined if parsing failed */
17
+ value: T | undefined;
18
+ /** Whether the JSON was complete and valid */
19
+ isComplete: boolean;
20
+ }
21
+ /**
22
+ * Parses potentially incomplete JSON, returning as much as can be extracted.
23
+ *
24
+ * Handles common incomplete states during streaming:
25
+ * - Incomplete strings: `{"name":"Jo` → `{name: "Jo"}`
26
+ * - Incomplete objects: `{"a":1,"b":` → `{a: 1}`
27
+ * - Incomplete arrays: `[1,2,` → `[1, 2]`
28
+ * - Incomplete numbers, booleans, null literals
29
+ * - Nested structures with partial completion
30
+ * - Unicode escape sequences
31
+ *
32
+ * @typeParam T - The expected type of the parsed value
33
+ * @param json - The potentially incomplete JSON string
34
+ * @returns A PartialParseResult with the parsed value and completion status
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * // Complete JSON
39
+ * parsePartialJson('{"name":"John"}');
40
+ * // => { value: { name: "John" }, isComplete: true }
41
+ *
42
+ * // Incomplete object
43
+ * parsePartialJson('{"user":{"firstName":"Jo');
44
+ * // => { value: { user: { firstName: "Jo" } }, isComplete: false }
45
+ *
46
+ * // Incomplete array
47
+ * parsePartialJson('[1, 2, 3');
48
+ * // => { value: [1, 2, 3], isComplete: false }
49
+ * ```
50
+ */
51
+ declare function parsePartialJson<T = unknown>(json: string): PartialParseResult<T>;
52
+
53
+ export { type PartialParseResult, parsePartialJson };
@@ -0,0 +1,7 @@
1
+ import {
2
+ parsePartialJson
3
+ } from "../chunk-I53CI6ZZ.js";
4
+ export {
5
+ parsePartialJson
6
+ };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,4 +1,5 @@
1
- import { P as Provider } from '../llm-BQJZj3cD.js';
1
+ import { d as Provider } from '../llm-ByUFPcFH.js';
2
+ import '../stream-S7nwQRqM.js';
2
3
 
3
4
  /**
4
5
  * xAI Chat Completions API parameters (OpenAI-compatible).