@prestyj/ai 4.2.76 → 4.3.15
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.
- package/dist/index.cjs +360 -237
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -11
- package/dist/index.d.ts +18 -11
- package/dist/index.js +360 -237
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
type Provider = "anthropic" | "openai" | "glm" | "moonshot" | "palsu";
|
|
3
|
+
type Provider = "anthropic" | "xiaomi" | "openai" | "glm" | "moonshot" | "minimax" | "palsu";
|
|
4
4
|
type ThinkingLevel = "low" | "medium" | "high" | "max";
|
|
5
5
|
type CacheRetention = "none" | "short" | "long";
|
|
6
6
|
interface TextContent {
|
|
@@ -119,7 +119,10 @@ interface ServerToolResultEvent {
|
|
|
119
119
|
resultType: string;
|
|
120
120
|
data: unknown;
|
|
121
121
|
}
|
|
122
|
-
|
|
122
|
+
interface KeepaliveEvent {
|
|
123
|
+
type: "keepalive";
|
|
124
|
+
}
|
|
125
|
+
type StreamEvent = TextDeltaEvent | ThinkingDeltaEvent | ToolCallDeltaEvent | ToolCallDoneEvent | ServerToolCallEvent | ServerToolResultEvent | DoneEvent | ErrorEvent | KeepaliveEvent;
|
|
123
126
|
type StopReason = "end_turn" | "tool_use" | "max_tokens" | "pause_turn" | "stop_sequence" | "refusal" | "error";
|
|
124
127
|
interface StreamResponse {
|
|
125
128
|
message: AssistantMessage;
|
|
@@ -189,25 +192,29 @@ declare class EventStream<T = StreamEvent> implements AsyncIterable<T> {
|
|
|
189
192
|
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
190
193
|
}
|
|
191
194
|
/**
|
|
192
|
-
*
|
|
193
|
-
*
|
|
195
|
+
* Pull-based stream result. Wraps an async generator that yields
|
|
196
|
+
* StreamEvents and returns a StreamResponse. Also thenable so:
|
|
194
197
|
*
|
|
195
198
|
* const msg = await stream({...}) // awaits response
|
|
196
199
|
* for await (const e of stream({...})) {} // iterates events
|
|
200
|
+
*
|
|
201
|
+
* The generator is pumped eagerly — events flow into an internal
|
|
202
|
+
* buffer regardless of whether a consumer is iterating. This avoids
|
|
203
|
+
* the push-based EventStream's stall bugs (lost wakeups, single
|
|
204
|
+
* resolve field, iterator starvation).
|
|
197
205
|
*/
|
|
198
206
|
declare class StreamResult implements AsyncIterable<StreamEvent> {
|
|
199
|
-
readonly events: EventStream<StreamEvent>;
|
|
200
207
|
readonly response: Promise<StreamResponse>;
|
|
208
|
+
private buffer;
|
|
209
|
+
private done;
|
|
210
|
+
private error;
|
|
201
211
|
private resolveResponse;
|
|
202
212
|
private rejectResponse;
|
|
203
|
-
private
|
|
204
|
-
constructor();
|
|
205
|
-
|
|
206
|
-
complete(response: StreamResponse): void;
|
|
207
|
-
abort(error: Error): void;
|
|
213
|
+
private resolveWait;
|
|
214
|
+
constructor(generator: AsyncGenerator<StreamEvent, StreamResponse>);
|
|
215
|
+
private pump;
|
|
208
216
|
[Symbol.asyncIterator](): AsyncIterator<StreamEvent>;
|
|
209
217
|
then<TResult1 = StreamResponse, TResult2 = never>(onfulfilled?: ((value: StreamResponse) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
210
|
-
private drainEvents;
|
|
211
218
|
}
|
|
212
219
|
|
|
213
220
|
/**
|