@reminix/sdk 0.8.1 → 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.
Files changed (98) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +10 -43
  3. package/client.d.mts +5 -5
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +5 -5
  6. package/client.d.ts.map +1 -1
  7. package/client.js +3 -3
  8. package/client.js.map +1 -1
  9. package/client.mjs +3 -3
  10. package/client.mjs.map +1 -1
  11. package/core/streaming.d.mts +33 -0
  12. package/core/streaming.d.mts.map +1 -0
  13. package/core/streaming.d.ts +33 -0
  14. package/core/streaming.d.ts.map +1 -0
  15. package/core/streaming.js +263 -0
  16. package/core/streaming.js.map +1 -0
  17. package/core/streaming.mjs +258 -0
  18. package/core/streaming.mjs.map +1 -0
  19. package/index.d.mts +0 -1
  20. package/index.d.mts.map +1 -1
  21. package/index.d.ts +0 -1
  22. package/index.d.ts.map +1 -1
  23. package/index.js +1 -5
  24. package/index.js.map +1 -1
  25. package/index.mjs +0 -2
  26. package/index.mjs.map +1 -1
  27. package/internal/decoders/line.d.mts +17 -0
  28. package/internal/decoders/line.d.mts.map +1 -0
  29. package/internal/decoders/line.d.ts +17 -0
  30. package/internal/decoders/line.d.ts.map +1 -0
  31. package/internal/decoders/line.js +113 -0
  32. package/internal/decoders/line.js.map +1 -0
  33. package/internal/decoders/line.mjs +108 -0
  34. package/internal/decoders/line.mjs.map +1 -0
  35. package/internal/parse.d.mts.map +1 -1
  36. package/internal/parse.d.ts.map +1 -1
  37. package/internal/parse.js +10 -0
  38. package/internal/parse.js.map +1 -1
  39. package/internal/parse.mjs +10 -0
  40. package/internal/parse.mjs.map +1 -1
  41. package/internal/request-options.d.mts +2 -0
  42. package/internal/request-options.d.mts.map +1 -1
  43. package/internal/request-options.d.ts +2 -0
  44. package/internal/request-options.d.ts.map +1 -1
  45. package/internal/request-options.js.map +1 -1
  46. package/internal/request-options.mjs.map +1 -1
  47. package/package.json +1 -1
  48. package/resources/agents.d.mts +80 -56
  49. package/resources/agents.d.mts.map +1 -1
  50. package/resources/agents.d.ts +80 -56
  51. package/resources/agents.d.ts.map +1 -1
  52. package/resources/agents.js +7 -127
  53. package/resources/agents.js.map +1 -1
  54. package/resources/agents.mjs +7 -126
  55. package/resources/agents.mjs.map +1 -1
  56. package/resources/index.d.mts +2 -2
  57. package/resources/index.d.mts.map +1 -1
  58. package/resources/index.d.ts +2 -2
  59. package/resources/index.d.ts.map +1 -1
  60. package/resources/index.js +3 -3
  61. package/resources/index.js.map +1 -1
  62. package/resources/index.mjs +1 -1
  63. package/resources/index.mjs.map +1 -1
  64. package/resources/{project.d.mts → projects.d.mts} +31 -7
  65. package/resources/projects.d.mts.map +1 -0
  66. package/resources/{project.d.ts → projects.d.ts} +31 -7
  67. package/resources/projects.d.ts.map +1 -0
  68. package/resources/{project.js → projects.js} +8 -7
  69. package/resources/projects.js.map +1 -0
  70. package/resources/{project.mjs → projects.mjs} +6 -5
  71. package/resources/projects.mjs.map +1 -0
  72. package/src/client.ts +14 -4
  73. package/src/core/streaming.ts +315 -0
  74. package/src/index.ts +0 -4
  75. package/src/internal/decoders/line.ts +135 -0
  76. package/src/internal/parse.ts +14 -0
  77. package/src/internal/request-options.ts +2 -0
  78. package/src/resources/agents.ts +132 -84
  79. package/src/resources/index.ts +6 -1
  80. package/src/resources/{project.ts → projects.ts} +35 -7
  81. package/src/streaming.ts +2 -87
  82. package/src/version.ts +1 -1
  83. package/streaming.d.mts +1 -30
  84. package/streaming.d.mts.map +1 -1
  85. package/streaming.d.ts +1 -30
  86. package/streaming.d.ts.map +1 -1
  87. package/streaming.js +3 -80
  88. package/streaming.js.map +1 -1
  89. package/streaming.mjs +1 -78
  90. package/streaming.mjs.map +1 -1
  91. package/version.d.mts +1 -1
  92. package/version.d.ts +1 -1
  93. package/version.js +1 -1
  94. package/version.mjs +1 -1
  95. package/resources/project.d.mts.map +0 -1
  96. package/resources/project.d.ts.map +0 -1
  97. package/resources/project.js.map +0 -1
  98. 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 };
@@ -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(name: string, body: AgentChatParams, options?: RequestOptions): APIPromise<AgentChatResponse> {
54
- return this._client.post(path`/agents/${name}/chat`, { body, ...options });
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(name: string, body: AgentInvokeParams, options?: RequestOptions): APIPromise<AgentInvokeResponse> {
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: Omit<AgentChatParams, 'stream'>,
114
+ body: AgentInvokeParamsNonStreaming,
115
115
  options?: RequestOptions,
116
- ): Promise<Stream<StreamChunk>> {
117
- const response = await this._client.post(path`/agents/${name}/chat`, {
118
- body: { ...body, stream: true },
119
- ...options,
120
- headers: { Accept: 'text/event-stream', ...options?.headers },
121
- __binaryResponse: true,
122
- });
123
- return new Stream<StreamChunk>(response as unknown as Response);
124
- }
125
-
126
- /**
127
- * Streaming variant of invoke(). Returns an async iterable of chunks.
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(
143
123
  name: string,
144
- body: Omit<AgentInvokeParams, 'stream'>,
124
+ body: AgentInvokeParamsBase,
145
125
  options?: RequestOptions,
146
- ): Promise<Stream<StreamChunk>> {
147
- const response = await this._client.post(path`/agents/${name}/invoke`, {
148
- body: { ...body, stream: true },
126
+ ): APIPromise<Stream<StreamChunk> | AgentInvokeResponse>;
127
+ invoke(
128
+ name: string,
129
+ body: AgentInvokeParams,
130
+ options?: RequestOptions,
131
+ ): APIPromise<AgentInvokeResponse> | APIPromise<Stream<StreamChunk>> {
132
+ return this._client.post(path`/agents/${name}/invoke`, {
133
+ body,
149
134
  ...options,
150
- headers: { Accept: 'text/event-stream', ...options?.headers },
151
- __binaryResponse: true,
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,39 +157,60 @@ export interface Context {
175
157
  user_id?: string;
176
158
  }
177
159
 
178
- export interface AgentChatResponse {
160
+ export interface StreamChunk {
179
161
  /**
180
- * Assistant message response
162
+ * Text chunk from the stream
181
163
  */
182
- message: AgentChatResponse.Message;
164
+ chunk: string;
183
165
  }
184
166
 
185
- export namespace AgentChatResponse {
167
+ export interface AgentChatResponse {
168
+ /**
169
+ * Full conversation history including the assistant response
170
+ */
171
+ messages: Array<AgentChatResponse.Message>;
172
+
186
173
  /**
187
- * Assistant message response
174
+ * Final assistant response text
188
175
  */
176
+ output: string;
177
+ }
178
+
179
+ export namespace AgentChatResponse {
189
180
  export interface Message {
190
- content: string | Array<unknown> | null;
181
+ /**
182
+ * Message content. Can be string, array (multimodal), or object (tool).
183
+ */
184
+ content: string | Array<Message.UnionMember1> | { [key: string]: unknown };
185
+
186
+ /**
187
+ * Message role
188
+ */
189
+ role: 'system' | 'user' | 'assistant' | 'tool';
191
190
 
192
- role: 'assistant';
191
+ /**
192
+ * Tool name (required when role is "tool")
193
+ */
194
+ name?: string;
193
195
 
194
- tool_calls?: Array<Message.ToolCall>;
196
+ /**
197
+ * Tool call ID (for tool role)
198
+ */
199
+ tool_call_id?: string;
195
200
  }
196
201
 
197
202
  export namespace Message {
198
- export interface ToolCall {
199
- id: string;
203
+ export interface UnionMember1 {
204
+ type: 'text' | 'image_url';
200
205
 
201
- function: ToolCall.Function;
206
+ image_url?: UnionMember1.ImageURL;
202
207
 
203
- type: 'function';
208
+ text?: string;
204
209
  }
205
210
 
206
- export namespace ToolCall {
207
- export interface Function {
208
- arguments: string;
209
-
210
- name: string;
211
+ export namespace UnionMember1 {
212
+ export interface ImageURL {
213
+ url: string;
211
214
  }
212
215
  }
213
216
  }
@@ -220,7 +223,9 @@ export interface AgentInvokeResponse {
220
223
  output?: unknown;
221
224
  }
222
225
 
223
- export interface AgentChatParams {
226
+ export type AgentChatParams = AgentChatParamsNonStreaming | AgentChatParamsStreaming;
227
+
228
+ export interface AgentChatParamsBase {
224
229
  /**
225
230
  * Conversation history. Must include at least one message.
226
231
  */
@@ -275,9 +280,28 @@ export namespace AgentChatParams {
275
280
  }
276
281
  }
277
282
  }
283
+
284
+ export type AgentChatParamsNonStreaming = AgentsAPI.AgentChatParamsNonStreaming;
285
+ export type AgentChatParamsStreaming = AgentsAPI.AgentChatParamsStreaming;
278
286
  }
279
287
 
280
- export interface AgentInvokeParams {
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;
300
+ }
301
+
302
+ export type AgentInvokeParams = AgentInvokeParamsNonStreaming | AgentInvokeParamsStreaming;
303
+
304
+ export interface AgentInvokeParamsBase {
281
305
  /**
282
306
  * Input data for the agent. Structure depends on agent implementation.
283
307
  */
@@ -294,12 +318,36 @@ export interface AgentInvokeParams {
294
318
  stream?: boolean;
295
319
  }
296
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
+
297
340
  export declare namespace Agents {
298
341
  export {
299
342
  type Context as Context,
343
+ type StreamChunk as StreamChunk,
300
344
  type AgentChatResponse as AgentChatResponse,
301
345
  type AgentInvokeResponse as AgentInvokeResponse,
302
346
  type AgentChatParams as AgentChatParams,
347
+ type AgentChatParamsNonStreaming as AgentChatParamsNonStreaming,
348
+ type AgentChatParamsStreaming as AgentChatParamsStreaming,
303
349
  type AgentInvokeParams as AgentInvokeParams,
350
+ type AgentInvokeParamsNonStreaming as AgentInvokeParamsNonStreaming,
351
+ type AgentInvokeParamsStreaming as AgentInvokeParamsStreaming,
304
352
  };
305
353
  }
@@ -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 { Project, type ProjectRetrieveResponse } from './project';
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 Project extends APIResource {
7
+ export class Projects extends APIResource {
8
8
  /**
9
- * Returns the project associated with the API key used for authentication.
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
- retrieve(options?: RequestOptions): APIPromise<ProjectRetrieveResponse> {
22
- return this._client.get('/project', options);
22
+ retrieveCurrent(options?: RequestOptions): APIPromise<ProjectRetrieveCurrentResponse> {
23
+ return this._client.get('/projects/current', options);
23
24
  }
24
25
  }
25
26
 
26
- export interface ProjectRetrieveResponse {
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 declare namespace Project {
59
- export { type ProjectRetrieveResponse as ProjectRetrieveResponse };
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
- // stainless-custom-start
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'; // x-release-please-version
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
@@ -1 +1 @@
1
- {"version":3,"file":"streaming.d.mts","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;GAUG;AACH,qBAAa,MAAM,CAAC,CAAC,CAAE,YAAW,aAAa,CAAC,CAAC,CAAC;IACpC,OAAO,CAAC,QAAQ;gBAAR,QAAQ,EAAE,QAAQ;IAE/B,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC;CAsDlD"}
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
@@ -1 +1 @@
1
- {"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;GAUG;AACH,qBAAa,MAAM,CAAC,CAAC,CAAE,YAAW,aAAa,CAAC,CAAC,CAAC;IACpC,OAAO,CAAC,QAAQ;gBAAR,QAAQ,EAAE,QAAQ;IAE/B,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC;CAsDlD"}
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
- exports.Stream = void 0;
12
- /**
13
- * An async iterable stream that parses SSE (Server-Sent Events) responses.
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":";AAAA,yBAAyB;AACzB;;;;;;GAMG;;;AAUH;;;;;;;;;;GAUG;AACH,MAAa,MAAM;IACjB,YAAoB,QAAkB;QAAlB,aAAQ,GAAR,QAAQ,CAAU;IAAG,CAAC;IAE1C,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC;QAC3B,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC;QAC/C,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QACnD,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;QAClC,IAAI,MAAM,GAAG,EAAE,CAAC;QAEhB,IAAI,CAAC;YACH,OAAO,IAAI,EAAE,CAAC;gBACZ,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;gBAC5C,IAAI,IAAI;oBAAE,MAAM;gBAEhB,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;gBAClD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBACjC,MAAM,GAAG,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC;gBAE3B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;oBACzB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;oBAC5B,IAAI,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;wBACjC,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;wBAC9B,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;4BACtB,OAAO;wBACT,CAAC;wBACD,IAAI,IAAI,EAAE,CAAC;4BACT,IAAI,CAAC;gCACH,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAM,CAAC;4BAC9B,CAAC;4BAAC,MAAM,CAAC;gCACP,sBAAsB;4BACxB,CAAC;wBACH,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;YAED,uCAAuC;YACvC,IAAI,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;gBAClB,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;gBAC9B,IAAI,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;oBACjC,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;oBAC9B,IAAI,IAAI,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;wBAC9B,IAAI,CAAC;4BACH,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAM,CAAC;wBAC9B,CAAC;wBAAC,MAAM,CAAC;4BACP,sBAAsB;wBACxB,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,MAAM,CAAC,WAAW,EAAE,CAAC;QACvB,CAAC;IACH,CAAC;CACF;AAzDD,wBAyDC;AACD,uBAAuB"}
1
+ {"version":3,"file":"streaming.js","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":";;;AAAA,uDAAuD;AACvD,8DAAiC"}