@reminix/sdk 0.8.2 → 0.8.3
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/CHANGELOG.md +23 -0
- package/README.md +10 -43
- package/client.d.mts +5 -5
- package/client.d.mts.map +1 -1
- package/client.d.ts +5 -5
- package/client.d.ts.map +1 -1
- package/client.js +3 -3
- package/client.js.map +1 -1
- package/client.mjs +3 -3
- package/client.mjs.map +1 -1
- package/core/streaming.d.mts +33 -0
- package/core/streaming.d.mts.map +1 -0
- package/core/streaming.d.ts +33 -0
- package/core/streaming.d.ts.map +1 -0
- package/core/streaming.js +263 -0
- package/core/streaming.js.map +1 -0
- package/core/streaming.mjs +258 -0
- package/core/streaming.mjs.map +1 -0
- package/index.d.mts +0 -1
- package/index.d.mts.map +1 -1
- package/index.d.ts +0 -1
- package/index.d.ts.map +1 -1
- package/index.js +1 -5
- package/index.js.map +1 -1
- package/index.mjs +0 -2
- package/index.mjs.map +1 -1
- package/internal/decoders/line.d.mts +17 -0
- package/internal/decoders/line.d.mts.map +1 -0
- package/internal/decoders/line.d.ts +17 -0
- package/internal/decoders/line.d.ts.map +1 -0
- package/internal/decoders/line.js +113 -0
- package/internal/decoders/line.js.map +1 -0
- package/internal/decoders/line.mjs +108 -0
- package/internal/decoders/line.mjs.map +1 -0
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js +10 -0
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +10 -0
- package/internal/parse.mjs.map +1 -1
- package/internal/request-options.d.mts +2 -0
- package/internal/request-options.d.mts.map +1 -1
- package/internal/request-options.d.ts +2 -0
- package/internal/request-options.d.ts.map +1 -1
- package/internal/request-options.js.map +1 -1
- package/internal/request-options.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/agents.d.mts +49 -40
- package/resources/agents.d.mts.map +1 -1
- package/resources/agents.d.ts +49 -40
- package/resources/agents.d.ts.map +1 -1
- package/resources/agents.js +7 -127
- package/resources/agents.js.map +1 -1
- package/resources/agents.mjs +7 -126
- package/resources/agents.mjs.map +1 -1
- package/resources/index.d.mts +2 -2
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +2 -2
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +3 -3
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/{project.d.mts → projects.d.mts} +31 -7
- package/resources/projects.d.mts.map +1 -0
- package/resources/{project.d.ts → projects.d.ts} +31 -7
- package/resources/projects.d.ts.map +1 -0
- package/resources/{project.js → projects.js} +8 -7
- package/resources/projects.js.map +1 -0
- package/resources/{project.mjs → projects.mjs} +6 -5
- package/resources/projects.mjs.map +1 -0
- package/src/client.ts +14 -4
- package/src/core/streaming.ts +315 -0
- package/src/index.ts +0 -4
- package/src/internal/decoders/line.ts +135 -0
- package/src/internal/parse.ts +14 -0
- package/src/internal/request-options.ts +2 -0
- package/src/resources/agents.ts +101 -67
- package/src/resources/index.ts +6 -1
- package/src/resources/{project.ts → projects.ts} +35 -7
- package/src/streaming.ts +2 -87
- package/src/version.ts +1 -1
- package/streaming.d.mts +1 -30
- package/streaming.d.mts.map +1 -1
- package/streaming.d.ts +1 -30
- package/streaming.d.ts.map +1 -1
- package/streaming.js +3 -80
- package/streaming.js.map +1 -1
- package/streaming.mjs +1 -78
- package/streaming.mjs.map +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
- package/resources/project.d.mts.map +0 -1
- package/resources/project.d.ts.map +0 -1
- package/resources/project.js.map +0 -1
- package/resources/project.mjs.map +0 -1
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { NullableHeaders } from './headers';
|
|
4
4
|
|
|
5
5
|
import type { BodyInit } from './builtin-types';
|
|
6
|
+
import { Stream } from '../core/streaming';
|
|
6
7
|
import type { HTTPMethod, MergedRequestInit } from './types';
|
|
7
8
|
import { type HeadersLike } from './headers';
|
|
8
9
|
|
|
@@ -76,6 +77,7 @@ export type RequestOptions = {
|
|
|
76
77
|
defaultBaseURL?: string | undefined;
|
|
77
78
|
|
|
78
79
|
__binaryResponse?: boolean | undefined;
|
|
80
|
+
__streamClass?: typeof Stream;
|
|
79
81
|
};
|
|
80
82
|
|
|
81
83
|
export type EncodedContent = { bodyHeaders: HeadersLike; body: BodyInit };
|
package/src/resources/agents.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
3
|
import { APIResource } from '../core/resource';
|
|
4
|
+
import * as AgentsAPI from './agents';
|
|
4
5
|
import { APIPromise } from '../core/api-promise';
|
|
6
|
+
import { Stream } from '../core/streaming';
|
|
5
7
|
import { RequestOptions } from '../internal/request-options';
|
|
6
8
|
import { path } from '../internal/utils/path';
|
|
7
9
|
|
|
8
|
-
// stainless-custom-start
|
|
9
|
-
import { Stream, StreamChunk } from '../streaming';
|
|
10
|
-
// stainless-custom-end
|
|
11
|
-
|
|
12
10
|
export class Agents extends APIResource {
|
|
13
11
|
/**
|
|
14
12
|
* Have a conversational interaction with an agent. This endpoint maintains
|
|
@@ -50,8 +48,31 @@ export class Agents extends APIResource {
|
|
|
50
48
|
* });
|
|
51
49
|
* ```
|
|
52
50
|
*/
|
|
53
|
-
chat(
|
|
54
|
-
|
|
51
|
+
chat(
|
|
52
|
+
name: string,
|
|
53
|
+
body: AgentChatParamsNonStreaming,
|
|
54
|
+
options?: RequestOptions,
|
|
55
|
+
): APIPromise<AgentChatResponse>;
|
|
56
|
+
chat(
|
|
57
|
+
name: string,
|
|
58
|
+
body: AgentChatParamsStreaming,
|
|
59
|
+
options?: RequestOptions,
|
|
60
|
+
): APIPromise<Stream<StreamChunk>>;
|
|
61
|
+
chat(
|
|
62
|
+
name: string,
|
|
63
|
+
body: AgentChatParamsBase,
|
|
64
|
+
options?: RequestOptions,
|
|
65
|
+
): APIPromise<Stream<StreamChunk> | AgentChatResponse>;
|
|
66
|
+
chat(
|
|
67
|
+
name: string,
|
|
68
|
+
body: AgentChatParams,
|
|
69
|
+
options?: RequestOptions,
|
|
70
|
+
): APIPromise<AgentChatResponse> | APIPromise<Stream<StreamChunk>> {
|
|
71
|
+
return this._client.post(path`/agents/${name}/chat`, {
|
|
72
|
+
body,
|
|
73
|
+
...options,
|
|
74
|
+
stream: body.stream ?? false,
|
|
75
|
+
}) as APIPromise<AgentChatResponse> | APIPromise<Stream<StreamChunk>>;
|
|
55
76
|
}
|
|
56
77
|
|
|
57
78
|
/**
|
|
@@ -88,71 +109,32 @@ export class Agents extends APIResource {
|
|
|
88
109
|
* });
|
|
89
110
|
* ```
|
|
90
111
|
*/
|
|
91
|
-
invoke(
|
|
92
|
-
return this._client.post(path`/agents/${name}/invoke`, { body, ...options });
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// stainless-custom-start
|
|
96
|
-
/**
|
|
97
|
-
* Streaming variant of chat(). Returns an async iterable of chunks.
|
|
98
|
-
*
|
|
99
|
-
* Have a conversational interaction with an agent with real-time streaming.
|
|
100
|
-
* Each chunk contains a portion of the response as it's generated.
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* ```ts
|
|
104
|
-
* const stream = await client.agents.chatStream('my-agent', {
|
|
105
|
-
* messages: [{ role: 'user', content: 'Tell me a story' }],
|
|
106
|
-
* });
|
|
107
|
-
* for await (const chunk of stream) {
|
|
108
|
-
* process.stdout.write(chunk.chunk);
|
|
109
|
-
* }
|
|
110
|
-
* ```
|
|
111
|
-
*/
|
|
112
|
-
async chatStream(
|
|
112
|
+
invoke(
|
|
113
113
|
name: string,
|
|
114
|
-
body:
|
|
114
|
+
body: AgentInvokeParamsNonStreaming,
|
|
115
115
|
options?: RequestOptions,
|
|
116
|
-
):
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
*
|
|
129
|
-
* Execute a one-shot task with an agent with real-time streaming.
|
|
130
|
-
* Each chunk contains a portion of the response as it's generated.
|
|
131
|
-
*
|
|
132
|
-
* @example
|
|
133
|
-
* ```ts
|
|
134
|
-
* const stream = await client.agents.invokeStream('my-agent', {
|
|
135
|
-
* input: { task: 'generate', prompt: 'Write a poem' },
|
|
136
|
-
* });
|
|
137
|
-
* for await (const chunk of stream) {
|
|
138
|
-
* process.stdout.write(chunk.chunk);
|
|
139
|
-
* }
|
|
140
|
-
* ```
|
|
141
|
-
*/
|
|
142
|
-
async invokeStream(
|
|
116
|
+
): APIPromise<AgentInvokeResponse>;
|
|
117
|
+
invoke(
|
|
118
|
+
name: string,
|
|
119
|
+
body: AgentInvokeParamsStreaming,
|
|
120
|
+
options?: RequestOptions,
|
|
121
|
+
): APIPromise<Stream<StreamChunk>>;
|
|
122
|
+
invoke(
|
|
123
|
+
name: string,
|
|
124
|
+
body: AgentInvokeParamsBase,
|
|
125
|
+
options?: RequestOptions,
|
|
126
|
+
): APIPromise<Stream<StreamChunk> | AgentInvokeResponse>;
|
|
127
|
+
invoke(
|
|
143
128
|
name: string,
|
|
144
|
-
body:
|
|
129
|
+
body: AgentInvokeParams,
|
|
145
130
|
options?: RequestOptions,
|
|
146
|
-
):
|
|
147
|
-
|
|
148
|
-
body
|
|
131
|
+
): APIPromise<AgentInvokeResponse> | APIPromise<Stream<StreamChunk>> {
|
|
132
|
+
return this._client.post(path`/agents/${name}/invoke`, {
|
|
133
|
+
body,
|
|
149
134
|
...options,
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
});
|
|
153
|
-
return new Stream<StreamChunk>(response as unknown as Response);
|
|
135
|
+
stream: body.stream ?? false,
|
|
136
|
+
}) as APIPromise<AgentInvokeResponse> | APIPromise<Stream<StreamChunk>>;
|
|
154
137
|
}
|
|
155
|
-
// stainless-custom-end
|
|
156
138
|
}
|
|
157
139
|
|
|
158
140
|
/**
|
|
@@ -175,6 +157,13 @@ export interface Context {
|
|
|
175
157
|
user_id?: string;
|
|
176
158
|
}
|
|
177
159
|
|
|
160
|
+
export interface StreamChunk {
|
|
161
|
+
/**
|
|
162
|
+
* Text chunk from the stream
|
|
163
|
+
*/
|
|
164
|
+
chunk: string;
|
|
165
|
+
}
|
|
166
|
+
|
|
178
167
|
export interface AgentChatResponse {
|
|
179
168
|
/**
|
|
180
169
|
* Full conversation history including the assistant response
|
|
@@ -234,7 +223,9 @@ export interface AgentInvokeResponse {
|
|
|
234
223
|
output?: unknown;
|
|
235
224
|
}
|
|
236
225
|
|
|
237
|
-
export
|
|
226
|
+
export type AgentChatParams = AgentChatParamsNonStreaming | AgentChatParamsStreaming;
|
|
227
|
+
|
|
228
|
+
export interface AgentChatParamsBase {
|
|
238
229
|
/**
|
|
239
230
|
* Conversation history. Must include at least one message.
|
|
240
231
|
*/
|
|
@@ -289,9 +280,28 @@ export namespace AgentChatParams {
|
|
|
289
280
|
}
|
|
290
281
|
}
|
|
291
282
|
}
|
|
283
|
+
|
|
284
|
+
export type AgentChatParamsNonStreaming = AgentsAPI.AgentChatParamsNonStreaming;
|
|
285
|
+
export type AgentChatParamsStreaming = AgentsAPI.AgentChatParamsStreaming;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export interface AgentChatParamsNonStreaming extends AgentChatParamsBase {
|
|
289
|
+
/**
|
|
290
|
+
* Whether to stream the response as SSE.
|
|
291
|
+
*/
|
|
292
|
+
stream?: false;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export interface AgentChatParamsStreaming extends AgentChatParamsBase {
|
|
296
|
+
/**
|
|
297
|
+
* Whether to stream the response as SSE.
|
|
298
|
+
*/
|
|
299
|
+
stream: true;
|
|
292
300
|
}
|
|
293
301
|
|
|
294
|
-
export
|
|
302
|
+
export type AgentInvokeParams = AgentInvokeParamsNonStreaming | AgentInvokeParamsStreaming;
|
|
303
|
+
|
|
304
|
+
export interface AgentInvokeParamsBase {
|
|
295
305
|
/**
|
|
296
306
|
* Input data for the agent. Structure depends on agent implementation.
|
|
297
307
|
*/
|
|
@@ -308,12 +318,36 @@ export interface AgentInvokeParams {
|
|
|
308
318
|
stream?: boolean;
|
|
309
319
|
}
|
|
310
320
|
|
|
321
|
+
export namespace AgentInvokeParams {
|
|
322
|
+
export type AgentInvokeParamsNonStreaming = AgentsAPI.AgentInvokeParamsNonStreaming;
|
|
323
|
+
export type AgentInvokeParamsStreaming = AgentsAPI.AgentInvokeParamsStreaming;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export interface AgentInvokeParamsNonStreaming extends AgentInvokeParamsBase {
|
|
327
|
+
/**
|
|
328
|
+
* Whether to stream the response as SSE.
|
|
329
|
+
*/
|
|
330
|
+
stream?: false;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export interface AgentInvokeParamsStreaming extends AgentInvokeParamsBase {
|
|
334
|
+
/**
|
|
335
|
+
* Whether to stream the response as SSE.
|
|
336
|
+
*/
|
|
337
|
+
stream: true;
|
|
338
|
+
}
|
|
339
|
+
|
|
311
340
|
export declare namespace Agents {
|
|
312
341
|
export {
|
|
313
342
|
type Context as Context,
|
|
343
|
+
type StreamChunk as StreamChunk,
|
|
314
344
|
type AgentChatResponse as AgentChatResponse,
|
|
315
345
|
type AgentInvokeResponse as AgentInvokeResponse,
|
|
316
346
|
type AgentChatParams as AgentChatParams,
|
|
347
|
+
type AgentChatParamsNonStreaming as AgentChatParamsNonStreaming,
|
|
348
|
+
type AgentChatParamsStreaming as AgentChatParamsStreaming,
|
|
317
349
|
type AgentInvokeParams as AgentInvokeParams,
|
|
350
|
+
type AgentInvokeParamsNonStreaming as AgentInvokeParamsNonStreaming,
|
|
351
|
+
type AgentInvokeParamsStreaming as AgentInvokeParamsStreaming,
|
|
318
352
|
};
|
|
319
353
|
}
|
package/src/resources/index.ts
CHANGED
|
@@ -3,9 +3,14 @@
|
|
|
3
3
|
export {
|
|
4
4
|
Agents,
|
|
5
5
|
type Context,
|
|
6
|
+
type StreamChunk,
|
|
6
7
|
type AgentChatResponse,
|
|
7
8
|
type AgentInvokeResponse,
|
|
8
9
|
type AgentChatParams,
|
|
10
|
+
type AgentChatParamsNonStreaming,
|
|
11
|
+
type AgentChatParamsStreaming,
|
|
9
12
|
type AgentInvokeParams,
|
|
13
|
+
type AgentInvokeParamsNonStreaming,
|
|
14
|
+
type AgentInvokeParamsStreaming,
|
|
10
15
|
} from './agents';
|
|
11
|
-
export {
|
|
16
|
+
export { Projects, type ProjectRetrieveCurrentResponse } from './projects';
|
|
@@ -4,26 +4,27 @@ import { APIResource } from '../core/resource';
|
|
|
4
4
|
import { APIPromise } from '../core/api-promise';
|
|
5
5
|
import { RequestOptions } from '../internal/request-options';
|
|
6
6
|
|
|
7
|
-
export class
|
|
7
|
+
export class Projects extends APIResource {
|
|
8
8
|
/**
|
|
9
|
-
* Returns the project associated with the API key
|
|
9
|
+
* Returns the project associated with the API key or X-Project header.
|
|
10
10
|
*
|
|
11
11
|
* The project contains metadata about your organization's configuration,
|
|
12
12
|
* including:
|
|
13
13
|
*
|
|
14
14
|
* - Project ID and organization ID
|
|
15
15
|
* - Project name and slug
|
|
16
|
+
* - Organization details
|
|
16
17
|
* - Creation and update timestamps
|
|
17
18
|
*
|
|
18
19
|
* This endpoint is useful for verifying your API key is valid and retrieving
|
|
19
20
|
* project details.
|
|
20
21
|
*/
|
|
21
|
-
|
|
22
|
-
return this._client.get('/
|
|
22
|
+
retrieveCurrent(options?: RequestOptions): APIPromise<ProjectRetrieveCurrentResponse> {
|
|
23
|
+
return this._client.get('/projects/current', options);
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
export interface
|
|
27
|
+
export interface ProjectRetrieveCurrentResponse {
|
|
27
28
|
/**
|
|
28
29
|
* Unique identifier for the project
|
|
29
30
|
*/
|
|
@@ -39,6 +40,11 @@ export interface ProjectRetrieveResponse {
|
|
|
39
40
|
*/
|
|
40
41
|
name: string;
|
|
41
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Organization that owns this project
|
|
45
|
+
*/
|
|
46
|
+
organization: ProjectRetrieveCurrentResponse.Organization;
|
|
47
|
+
|
|
42
48
|
/**
|
|
43
49
|
* ID of the organization that owns this project
|
|
44
50
|
*/
|
|
@@ -55,6 +61,28 @@ export interface ProjectRetrieveResponse {
|
|
|
55
61
|
updatedAt: string;
|
|
56
62
|
}
|
|
57
63
|
|
|
58
|
-
export
|
|
59
|
-
|
|
64
|
+
export namespace ProjectRetrieveCurrentResponse {
|
|
65
|
+
/**
|
|
66
|
+
* Organization that owns this project
|
|
67
|
+
*/
|
|
68
|
+
export interface Organization {
|
|
69
|
+
/**
|
|
70
|
+
* Unique identifier for the organization
|
|
71
|
+
*/
|
|
72
|
+
id: string;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Human-readable name of the organization
|
|
76
|
+
*/
|
|
77
|
+
name: string;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* URL-friendly identifier for the organization
|
|
81
|
+
*/
|
|
82
|
+
slug: string;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export declare namespace Projects {
|
|
87
|
+
export { type ProjectRetrieveCurrentResponse as ProjectRetrieveCurrentResponse };
|
|
60
88
|
}
|
package/src/streaming.ts
CHANGED
|
@@ -1,87 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* Streaming utilities for SSE (Server-Sent Events) responses.
|
|
4
|
-
*
|
|
5
|
-
* This module provides streaming support for the Reminix API.
|
|
6
|
-
* When you upgrade to Stainless Pro, you can remove this file
|
|
7
|
-
* and use the built-in streaming support.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* A chunk from a streaming response.
|
|
12
|
-
*/
|
|
13
|
-
export interface StreamChunk {
|
|
14
|
-
/** Text chunk from the stream */
|
|
15
|
-
chunk: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* An async iterable stream that parses SSE (Server-Sent Events) responses.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```ts
|
|
23
|
-
* const stream = await client.agents.chatStream('agent', { messages: [...] });
|
|
24
|
-
* for await (const chunk of stream) {
|
|
25
|
-
* process.stdout.write(chunk.chunk);
|
|
26
|
-
* }
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
export class Stream<T> implements AsyncIterable<T> {
|
|
30
|
-
constructor(private response: Response) {}
|
|
31
|
-
|
|
32
|
-
async *[Symbol.asyncIterator](): AsyncIterator<T> {
|
|
33
|
-
const reader = this.response.body?.getReader();
|
|
34
|
-
if (!reader) {
|
|
35
|
-
throw new Error('Response body is not readable');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const decoder = new TextDecoder();
|
|
39
|
-
let buffer = '';
|
|
40
|
-
|
|
41
|
-
try {
|
|
42
|
-
while (true) {
|
|
43
|
-
const { done, value } = await reader.read();
|
|
44
|
-
if (done) break;
|
|
45
|
-
|
|
46
|
-
buffer += decoder.decode(value, { stream: true });
|
|
47
|
-
const lines = buffer.split('\n');
|
|
48
|
-
buffer = lines.pop() || '';
|
|
49
|
-
|
|
50
|
-
for (const line of lines) {
|
|
51
|
-
const trimmed = line.trim();
|
|
52
|
-
if (trimmed.startsWith('data: ')) {
|
|
53
|
-
const data = trimmed.slice(6);
|
|
54
|
-
if (data === '[DONE]') {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
if (data) {
|
|
58
|
-
try {
|
|
59
|
-
yield JSON.parse(data) as T;
|
|
60
|
-
} catch {
|
|
61
|
-
// Skip malformed JSON
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Process any remaining data in buffer
|
|
69
|
-
if (buffer.trim()) {
|
|
70
|
-
const trimmed = buffer.trim();
|
|
71
|
-
if (trimmed.startsWith('data: ')) {
|
|
72
|
-
const data = trimmed.slice(6);
|
|
73
|
-
if (data && data !== '[DONE]') {
|
|
74
|
-
try {
|
|
75
|
-
yield JSON.parse(data) as T;
|
|
76
|
-
} catch {
|
|
77
|
-
// Skip malformed JSON
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
} finally {
|
|
83
|
-
reader.releaseLock();
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
// stainless-custom-end
|
|
1
|
+
/** @deprecated Import from ./core/streaming instead */
|
|
2
|
+
export * from './core/streaming';
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.8.
|
|
1
|
+
export const VERSION = '0.8.3'; // x-release-please-version
|
package/streaming.d.mts
CHANGED
|
@@ -1,31 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Streaming utilities for SSE (Server-Sent Events) responses.
|
|
3
|
-
*
|
|
4
|
-
* This module provides streaming support for the Reminix API.
|
|
5
|
-
* When you upgrade to Stainless Pro, you can remove this file
|
|
6
|
-
* and use the built-in streaming support.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* A chunk from a streaming response.
|
|
10
|
-
*/
|
|
11
|
-
export interface StreamChunk {
|
|
12
|
-
/** Text chunk from the stream */
|
|
13
|
-
chunk: string;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* An async iterable stream that parses SSE (Server-Sent Events) responses.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```ts
|
|
20
|
-
* const stream = await client.agents.chatStream('agent', { messages: [...] });
|
|
21
|
-
* for await (const chunk of stream) {
|
|
22
|
-
* process.stdout.write(chunk.chunk);
|
|
23
|
-
* }
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
export declare class Stream<T> implements AsyncIterable<T> {
|
|
27
|
-
private response;
|
|
28
|
-
constructor(response: Response);
|
|
29
|
-
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
30
|
-
}
|
|
1
|
+
export * from "./core/streaming.mjs";
|
|
31
2
|
//# sourceMappingURL=streaming.d.mts.map
|
package/streaming.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streaming.d.mts","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"streaming.d.mts","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":""}
|
package/streaming.d.ts
CHANGED
|
@@ -1,31 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Streaming utilities for SSE (Server-Sent Events) responses.
|
|
3
|
-
*
|
|
4
|
-
* This module provides streaming support for the Reminix API.
|
|
5
|
-
* When you upgrade to Stainless Pro, you can remove this file
|
|
6
|
-
* and use the built-in streaming support.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* A chunk from a streaming response.
|
|
10
|
-
*/
|
|
11
|
-
export interface StreamChunk {
|
|
12
|
-
/** Text chunk from the stream */
|
|
13
|
-
chunk: string;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* An async iterable stream that parses SSE (Server-Sent Events) responses.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```ts
|
|
20
|
-
* const stream = await client.agents.chatStream('agent', { messages: [...] });
|
|
21
|
-
* for await (const chunk of stream) {
|
|
22
|
-
* process.stdout.write(chunk.chunk);
|
|
23
|
-
* }
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
export declare class Stream<T> implements AsyncIterable<T> {
|
|
27
|
-
private response;
|
|
28
|
-
constructor(response: Response);
|
|
29
|
-
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
30
|
-
}
|
|
1
|
+
export * from "./core/streaming.js";
|
|
31
2
|
//# sourceMappingURL=streaming.d.ts.map
|
package/streaming.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":""}
|
package/streaming.js
CHANGED
|
@@ -1,83 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// stainless-custom-start
|
|
3
|
-
/**
|
|
4
|
-
* Streaming utilities for SSE (Server-Sent Events) responses.
|
|
5
|
-
*
|
|
6
|
-
* This module provides streaming support for the Reminix API.
|
|
7
|
-
* When you upgrade to Stainless Pro, you can remove this file
|
|
8
|
-
* and use the built-in streaming support.
|
|
9
|
-
*/
|
|
10
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```ts
|
|
17
|
-
* const stream = await client.agents.chatStream('agent', { messages: [...] });
|
|
18
|
-
* for await (const chunk of stream) {
|
|
19
|
-
* process.stdout.write(chunk.chunk);
|
|
20
|
-
* }
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
class Stream {
|
|
24
|
-
constructor(response) {
|
|
25
|
-
this.response = response;
|
|
26
|
-
}
|
|
27
|
-
async *[Symbol.asyncIterator]() {
|
|
28
|
-
const reader = this.response.body?.getReader();
|
|
29
|
-
if (!reader) {
|
|
30
|
-
throw new Error('Response body is not readable');
|
|
31
|
-
}
|
|
32
|
-
const decoder = new TextDecoder();
|
|
33
|
-
let buffer = '';
|
|
34
|
-
try {
|
|
35
|
-
while (true) {
|
|
36
|
-
const { done, value } = await reader.read();
|
|
37
|
-
if (done)
|
|
38
|
-
break;
|
|
39
|
-
buffer += decoder.decode(value, { stream: true });
|
|
40
|
-
const lines = buffer.split('\n');
|
|
41
|
-
buffer = lines.pop() || '';
|
|
42
|
-
for (const line of lines) {
|
|
43
|
-
const trimmed = line.trim();
|
|
44
|
-
if (trimmed.startsWith('data: ')) {
|
|
45
|
-
const data = trimmed.slice(6);
|
|
46
|
-
if (data === '[DONE]') {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
if (data) {
|
|
50
|
-
try {
|
|
51
|
-
yield JSON.parse(data);
|
|
52
|
-
}
|
|
53
|
-
catch {
|
|
54
|
-
// Skip malformed JSON
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
// Process any remaining data in buffer
|
|
61
|
-
if (buffer.trim()) {
|
|
62
|
-
const trimmed = buffer.trim();
|
|
63
|
-
if (trimmed.startsWith('data: ')) {
|
|
64
|
-
const data = trimmed.slice(6);
|
|
65
|
-
if (data && data !== '[DONE]') {
|
|
66
|
-
try {
|
|
67
|
-
yield JSON.parse(data);
|
|
68
|
-
}
|
|
69
|
-
catch {
|
|
70
|
-
// Skip malformed JSON
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
finally {
|
|
77
|
-
reader.releaseLock();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
exports.Stream = Stream;
|
|
82
|
-
// stainless-custom-end
|
|
3
|
+
const tslib_1 = require("./internal/tslib.js");
|
|
4
|
+
/** @deprecated Import from ./core/streaming instead */
|
|
5
|
+
tslib_1.__exportStar(require("./core/streaming.js"), exports);
|
|
83
6
|
//# sourceMappingURL=streaming.js.map
|
package/streaming.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streaming.js","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"streaming.js","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":";;;AAAA,uDAAuD;AACvD,8DAAiC"}
|
package/streaming.mjs
CHANGED
|
@@ -1,79 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Streaming utilities for SSE (Server-Sent Events) responses.
|
|
4
|
-
*
|
|
5
|
-
* This module provides streaming support for the Reminix API.
|
|
6
|
-
* When you upgrade to Stainless Pro, you can remove this file
|
|
7
|
-
* and use the built-in streaming support.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* An async iterable stream that parses SSE (Server-Sent Events) responses.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* const stream = await client.agents.chatStream('agent', { messages: [...] });
|
|
15
|
-
* for await (const chunk of stream) {
|
|
16
|
-
* process.stdout.write(chunk.chunk);
|
|
17
|
-
* }
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export class Stream {
|
|
21
|
-
constructor(response) {
|
|
22
|
-
this.response = response;
|
|
23
|
-
}
|
|
24
|
-
async *[Symbol.asyncIterator]() {
|
|
25
|
-
const reader = this.response.body?.getReader();
|
|
26
|
-
if (!reader) {
|
|
27
|
-
throw new Error('Response body is not readable');
|
|
28
|
-
}
|
|
29
|
-
const decoder = new TextDecoder();
|
|
30
|
-
let buffer = '';
|
|
31
|
-
try {
|
|
32
|
-
while (true) {
|
|
33
|
-
const { done, value } = await reader.read();
|
|
34
|
-
if (done)
|
|
35
|
-
break;
|
|
36
|
-
buffer += decoder.decode(value, { stream: true });
|
|
37
|
-
const lines = buffer.split('\n');
|
|
38
|
-
buffer = lines.pop() || '';
|
|
39
|
-
for (const line of lines) {
|
|
40
|
-
const trimmed = line.trim();
|
|
41
|
-
if (trimmed.startsWith('data: ')) {
|
|
42
|
-
const data = trimmed.slice(6);
|
|
43
|
-
if (data === '[DONE]') {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
if (data) {
|
|
47
|
-
try {
|
|
48
|
-
yield JSON.parse(data);
|
|
49
|
-
}
|
|
50
|
-
catch {
|
|
51
|
-
// Skip malformed JSON
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
// Process any remaining data in buffer
|
|
58
|
-
if (buffer.trim()) {
|
|
59
|
-
const trimmed = buffer.trim();
|
|
60
|
-
if (trimmed.startsWith('data: ')) {
|
|
61
|
-
const data = trimmed.slice(6);
|
|
62
|
-
if (data && data !== '[DONE]') {
|
|
63
|
-
try {
|
|
64
|
-
yield JSON.parse(data);
|
|
65
|
-
}
|
|
66
|
-
catch {
|
|
67
|
-
// Skip malformed JSON
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
finally {
|
|
74
|
-
reader.releaseLock();
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
// stainless-custom-end
|
|
1
|
+
export * from "./core/streaming.mjs";
|
|
79
2
|
//# sourceMappingURL=streaming.mjs.map
|