@prestyj/ai 4.2.77 → 4.3.34
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/README.md +1 -1
- package/dist/index.cjs +606 -247
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -11
- package/dist/index.d.ts +24 -11
- package/dist/index.js +606 -247
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
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" | "openrouter" | "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;
|
|
@@ -171,6 +174,12 @@ interface StreamOptions {
|
|
|
171
174
|
* where the default `globalThis.fetch` doesn't support streaming properly.
|
|
172
175
|
* Passed directly to the underlying provider SDK. */
|
|
173
176
|
fetch?: typeof globalThis.fetch;
|
|
177
|
+
/** Use streaming transport (default: true). When false, providers issue a
|
|
178
|
+
* single non-streaming request and synthesize events from the full response.
|
|
179
|
+
* The agent loop flips this to `false` as a fallback after repeated stream
|
|
180
|
+
* stalls — broken SSE connections (transient CDN / proxy issues) often
|
|
181
|
+
* recover when the same request is issued over a plain HTTP request/response. */
|
|
182
|
+
streaming?: boolean;
|
|
174
183
|
}
|
|
175
184
|
|
|
176
185
|
/**
|
|
@@ -189,25 +198,29 @@ declare class EventStream<T = StreamEvent> implements AsyncIterable<T> {
|
|
|
189
198
|
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
190
199
|
}
|
|
191
200
|
/**
|
|
192
|
-
*
|
|
193
|
-
*
|
|
201
|
+
* Pull-based stream result. Wraps an async generator that yields
|
|
202
|
+
* StreamEvents and returns a StreamResponse. Also thenable so:
|
|
194
203
|
*
|
|
195
204
|
* const msg = await stream({...}) // awaits response
|
|
196
205
|
* for await (const e of stream({...})) {} // iterates events
|
|
206
|
+
*
|
|
207
|
+
* The generator is pumped eagerly — events flow into an internal
|
|
208
|
+
* buffer regardless of whether a consumer is iterating. This avoids
|
|
209
|
+
* the push-based EventStream's stall bugs (lost wakeups, single
|
|
210
|
+
* resolve field, iterator starvation).
|
|
197
211
|
*/
|
|
198
212
|
declare class StreamResult implements AsyncIterable<StreamEvent> {
|
|
199
|
-
readonly events: EventStream<StreamEvent>;
|
|
200
213
|
readonly response: Promise<StreamResponse>;
|
|
214
|
+
private buffer;
|
|
215
|
+
private done;
|
|
216
|
+
private error;
|
|
201
217
|
private resolveResponse;
|
|
202
218
|
private rejectResponse;
|
|
203
|
-
private
|
|
204
|
-
constructor();
|
|
205
|
-
|
|
206
|
-
complete(response: StreamResponse): void;
|
|
207
|
-
abort(error: Error): void;
|
|
219
|
+
private resolveWait;
|
|
220
|
+
constructor(generator: AsyncGenerator<StreamEvent, StreamResponse>);
|
|
221
|
+
private pump;
|
|
208
222
|
[Symbol.asyncIterator](): AsyncIterator<StreamEvent>;
|
|
209
223
|
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
224
|
}
|
|
212
225
|
|
|
213
226
|
/**
|
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" | "openrouter" | "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;
|
|
@@ -171,6 +174,12 @@ interface StreamOptions {
|
|
|
171
174
|
* where the default `globalThis.fetch` doesn't support streaming properly.
|
|
172
175
|
* Passed directly to the underlying provider SDK. */
|
|
173
176
|
fetch?: typeof globalThis.fetch;
|
|
177
|
+
/** Use streaming transport (default: true). When false, providers issue a
|
|
178
|
+
* single non-streaming request and synthesize events from the full response.
|
|
179
|
+
* The agent loop flips this to `false` as a fallback after repeated stream
|
|
180
|
+
* stalls — broken SSE connections (transient CDN / proxy issues) often
|
|
181
|
+
* recover when the same request is issued over a plain HTTP request/response. */
|
|
182
|
+
streaming?: boolean;
|
|
174
183
|
}
|
|
175
184
|
|
|
176
185
|
/**
|
|
@@ -189,25 +198,29 @@ declare class EventStream<T = StreamEvent> implements AsyncIterable<T> {
|
|
|
189
198
|
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
190
199
|
}
|
|
191
200
|
/**
|
|
192
|
-
*
|
|
193
|
-
*
|
|
201
|
+
* Pull-based stream result. Wraps an async generator that yields
|
|
202
|
+
* StreamEvents and returns a StreamResponse. Also thenable so:
|
|
194
203
|
*
|
|
195
204
|
* const msg = await stream({...}) // awaits response
|
|
196
205
|
* for await (const e of stream({...})) {} // iterates events
|
|
206
|
+
*
|
|
207
|
+
* The generator is pumped eagerly — events flow into an internal
|
|
208
|
+
* buffer regardless of whether a consumer is iterating. This avoids
|
|
209
|
+
* the push-based EventStream's stall bugs (lost wakeups, single
|
|
210
|
+
* resolve field, iterator starvation).
|
|
197
211
|
*/
|
|
198
212
|
declare class StreamResult implements AsyncIterable<StreamEvent> {
|
|
199
|
-
readonly events: EventStream<StreamEvent>;
|
|
200
213
|
readonly response: Promise<StreamResponse>;
|
|
214
|
+
private buffer;
|
|
215
|
+
private done;
|
|
216
|
+
private error;
|
|
201
217
|
private resolveResponse;
|
|
202
218
|
private rejectResponse;
|
|
203
|
-
private
|
|
204
|
-
constructor();
|
|
205
|
-
|
|
206
|
-
complete(response: StreamResponse): void;
|
|
207
|
-
abort(error: Error): void;
|
|
219
|
+
private resolveWait;
|
|
220
|
+
constructor(generator: AsyncGenerator<StreamEvent, StreamResponse>);
|
|
221
|
+
private pump;
|
|
208
222
|
[Symbol.asyncIterator](): AsyncIterator<StreamEvent>;
|
|
209
223
|
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
224
|
}
|
|
212
225
|
|
|
213
226
|
/**
|