@agentuity/stream 3.0.11 → 3.1.0

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.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { StreamStorageService, StreamStorage, Stream, type CreateStreamProps, type ListStreamsParams, type ListStreamsResponse, type StreamInfo, type StreamSortField, STREAM_MIN_TTL_SECONDS, STREAM_MAX_TTL_SECONDS, STREAM_DEFAULT_TTL_SECONDS, CreateStreamPropsSchema, ListStreamsParamsSchema, ListStreamsResponseSchema, StreamInfoSchema, StreamSortFieldSchema, } from '@agentuity/core/stream';
2
- import { type CreateStreamProps, type ListStreamsParams, type ListStreamsResponse, type StreamInfo, type Stream } from '@agentuity/core/stream';
3
- import { type Logger } from '@agentuity/adapter';
1
+ export * from './service.ts';
2
+ import { type CreateStreamProps, type ListStreamsParams, type ListStreamsResponse, type StreamInfo, type Stream } from './service.ts';
3
+ import { type Logger } from '@agentuity/client';
4
4
  import { z } from 'zod';
5
5
  export declare const StreamClientOptionsSchema: z.ZodObject<{
6
6
  apiKey: z.ZodOptional<z.ZodString>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,oBAAoB,EACpB,aAAa,EACb,MAAM,EACN,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,sBAAsB,EACtB,sBAAsB,EACtB,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,EACvB,yBAAyB,EACzB,gBAAgB,EAChB,qBAAqB,GACrB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAEN,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,KAAK,MAAM,EACX,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAgD,KAAK,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wB;IAgB7C;;OAEG;IACG,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAI3E;;OAEG;IACG,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAI1C;;OAEG;IACG,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAI/D;;OAEG;IACG,IAAI,CAAC,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAIpE;;OAEG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGvC"}
package/dist/index.js CHANGED
@@ -1,13 +1,8 @@
1
- export { StreamStorageService, STREAM_MIN_TTL_SECONDS, STREAM_MAX_TTL_SECONDS, STREAM_DEFAULT_TTL_SECONDS, CreateStreamPropsSchema, ListStreamsParamsSchema, ListStreamsResponseSchema, StreamInfoSchema, StreamSortFieldSchema, } from '@agentuity/core/stream';
2
- import { StreamStorageService, } from '@agentuity/core/stream';
3
- import { createServerFetchAdapter, buildClientHeaders } from '@agentuity/adapter';
4
- import { createMinimalLogger } from '@agentuity/core';
5
- import { getEnv } from '@agentuity/core';
6
- import { getServiceUrls } from '@agentuity/core/config';
1
+ export * from "./service.js";
2
+ import { StreamStorageService, } from "./service.js";
3
+ import { getServiceUrls } from '@agentuity/config';
4
+ import { createServiceAdapter, isLogger, resolveApiKey, resolveRegion, resolveServiceUrl, } from '@agentuity/client';
7
5
  import { z } from 'zod';
8
- const isLogger = (val) => typeof val === 'object' &&
9
- val !== null &&
10
- ['info', 'warn', 'error', 'debug', 'trace'].every((m) => typeof val[m] === 'function');
11
6
  export const StreamClientOptionsSchema = z.object({
12
7
  apiKey: z.string().optional().describe('API key for authentication'),
13
8
  url: z.string().optional().describe('Base URL for the Stream API'),
@@ -18,16 +13,17 @@ export class StreamClient {
18
13
  #service;
19
14
  constructor(options = {}) {
20
15
  const validatedOptions = StreamClientOptionsSchema.parse(options);
21
- const apiKey = validatedOptions.apiKey || getEnv('AGENTUITY_SDK_KEY') || getEnv('AGENTUITY_CLI_KEY');
22
- const region = getEnv('AGENTUITY_REGION') ?? 'usc';
23
- const serviceUrls = getServiceUrls(region);
24
- const url = validatedOptions.url || getEnv('AGENTUITY_STREAM_URL') || serviceUrls.stream;
25
- const logger = validatedOptions.logger ?? createMinimalLogger();
26
- const headers = buildClientHeaders({
27
- apiKey,
16
+ const serviceUrls = getServiceUrls(resolveRegion());
17
+ const url = resolveServiceUrl({
18
+ url: validatedOptions.url,
19
+ envKey: 'AGENTUITY_STREAM_URL',
20
+ fallback: serviceUrls.stream,
21
+ });
22
+ const { adapter } = createServiceAdapter({
23
+ apiKey: resolveApiKey(validatedOptions.apiKey),
28
24
  orgId: validatedOptions.orgId,
25
+ logger: validatedOptions.logger,
29
26
  });
30
- const adapter = createServerFetchAdapter({ headers }, logger);
31
27
  this.#service = new StreamStorageService(url, adapter);
32
28
  }
33
29
  /**
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,oBAAoB,EAQpB,sBAAsB,EACtB,sBAAsB,EACtB,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,EACvB,yBAAyB,EACzB,gBAAgB,EAChB,qBAAqB,GACrB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACN,oBAAoB,GAMpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAe,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,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,IAAI,CAAC,QAAQ,GAAG,IAAI,oBAAoB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,SAAiB,EAAE,KAAyB;QACxD,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAC/C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAG,CAAC,EAAU;QACnB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ,CAAC,EAAU;QACxB,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI,CAAC,MAA0B;QACpC,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,EAAU;QACtB,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC;CACD"}
@@ -0,0 +1,264 @@
1
+ import type { FetchAdapter } from '@agentuity/adapter';
2
+ import { z } from 'zod';
3
+ /**
4
+ * Minimum TTL value in seconds (1 minute)
5
+ */
6
+ export declare const STREAM_MIN_TTL_SECONDS = 60;
7
+ /**
8
+ * Maximum TTL value in seconds (90 days)
9
+ */
10
+ export declare const STREAM_MAX_TTL_SECONDS = 7776000;
11
+ /**
12
+ * Default TTL value in seconds (30 days) - used when no TTL is specified
13
+ */
14
+ export declare const STREAM_DEFAULT_TTL_SECONDS = 2592000;
15
+ /**
16
+ * Properties for creating a stream
17
+ */
18
+ export declare const CreateStreamPropsSchema: z.ZodObject<{
19
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
20
+ contentType: z.ZodOptional<z.ZodString>;
21
+ compress: z.ZodOptional<z.ZodLiteral<true>>;
22
+ ttl: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
23
+ }, z.core.$strip>;
24
+ export type CreateStreamProps = z.infer<typeof CreateStreamPropsSchema>;
25
+ export declare const StreamSortFieldSchema: z.ZodEnum<{
26
+ name: "name";
27
+ created: "created";
28
+ updated: "updated";
29
+ size: "size";
30
+ count: "count";
31
+ lastUsed: "lastUsed";
32
+ }>;
33
+ export type StreamSortField = z.infer<typeof StreamSortFieldSchema>;
34
+ /**
35
+ * Parameters for listing streams.
36
+ *
37
+ * Note: If both `namespace` and `name` are provided, `namespace` takes precedence
38
+ * and `name` is ignored in the API request body.
39
+ */
40
+ export declare const ListStreamsParamsSchema: z.ZodObject<{
41
+ limit: z.ZodOptional<z.ZodNumber>;
42
+ offset: z.ZodOptional<z.ZodNumber>;
43
+ sort: z.ZodOptional<z.ZodEnum<{
44
+ name: "name";
45
+ created: "created";
46
+ updated: "updated";
47
+ size: "size";
48
+ count: "count";
49
+ lastUsed: "lastUsed";
50
+ }>>;
51
+ direction: z.ZodOptional<z.ZodEnum<{
52
+ asc: "asc";
53
+ desc: "desc";
54
+ }>>;
55
+ namespace: z.ZodOptional<z.ZodString>;
56
+ name: z.ZodOptional<z.ZodString>;
57
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
58
+ }, z.core.$strip>;
59
+ export type ListStreamsParams = z.infer<typeof ListStreamsParamsSchema>;
60
+ /**
61
+ * Stream information returned by list operation
62
+ */
63
+ export declare const StreamInfoSchema: z.ZodObject<{
64
+ id: z.ZodString;
65
+ namespace: z.ZodString;
66
+ metadata: z.ZodRecord<z.ZodString, z.ZodString>;
67
+ url: z.ZodString;
68
+ sizeBytes: z.ZodNumber;
69
+ expiresAt: z.ZodNullable<z.ZodString>;
70
+ }, z.core.$strip>;
71
+ export type StreamInfo = z.infer<typeof StreamInfoSchema>;
72
+ /**
73
+ * Response from listing streams
74
+ */
75
+ export declare const ListStreamsResponseSchema: z.ZodObject<{
76
+ success: z.ZodBoolean;
77
+ message: z.ZodOptional<z.ZodString>;
78
+ streams: z.ZodArray<z.ZodObject<{
79
+ id: z.ZodString;
80
+ namespace: z.ZodString;
81
+ metadata: z.ZodRecord<z.ZodString, z.ZodString>;
82
+ url: z.ZodString;
83
+ sizeBytes: z.ZodNumber;
84
+ expiresAt: z.ZodNullable<z.ZodString>;
85
+ }, z.core.$strip>>;
86
+ total: z.ZodNumber;
87
+ }, z.core.$strip>;
88
+ export type ListStreamsResponse = z.infer<typeof ListStreamsResponseSchema>;
89
+ /**
90
+ * A durable and resumable stream that can be written to and read many times.
91
+ * The underlying stream is backed by a durable storage system and the URL
92
+ * returned is public and guaranteed to return the same data every time it is accessed.
93
+ * You can read from this stream internal in the agent using the getReader() method or
94
+ * return the URL to the stream to be used externally.
95
+ *
96
+ * You must write and close the stream before it can be read but if you attempt to read
97
+ * before any data is written, the reader will block until the first write occurs.
98
+ */
99
+ export interface Stream extends WritableStream {
100
+ /**
101
+ * unique stream identifier
102
+ */
103
+ id: string;
104
+ /**
105
+ * the unique stream url to consume the stream
106
+ */
107
+ url: string;
108
+ /**
109
+ * the total number of bytes written to the stream
110
+ */
111
+ readonly bytesWritten: number;
112
+ /**
113
+ * whether the stream is using compression
114
+ */
115
+ readonly compressed: boolean;
116
+ /**
117
+ * Write data to the stream.
118
+ *
119
+ * Each write call can send up to 5MB of data. For larger payloads, split the data
120
+ * across multiple write calls.
121
+ *
122
+ * @param chunk - The data to write (string, binary, or object that will be JSON-serialized)
123
+ * @throws ServiceException with status 413 if chunk exceeds 5MB
124
+ */
125
+ write(chunk: string | Uint8Array | ArrayBuffer | object): Promise<void>;
126
+ /**
127
+ * close the stream gracefully, handling already closed streams without error
128
+ */
129
+ close(): Promise<void>;
130
+ /**
131
+ * get a ReadableStream that streams from the internal URL
132
+ *
133
+ * Note: This method will block waiting for data until writes start to the Stream.
134
+ * The returned ReadableStream will remain open until the Stream is closed or an error occurs.
135
+ *
136
+ * @returns a ReadableStream that can be passed to response.stream()
137
+ */
138
+ getReader(): ReadableStream<Uint8Array>;
139
+ }
140
+ /**
141
+ * Stream API for creating and managing durable, resumable data streams.
142
+ * Streams are backed by durable storage and provide public URLs for access.
143
+ */
144
+ export interface StreamStorage {
145
+ /**
146
+ * Create a new stream for writing data that can be read multiple times
147
+ *
148
+ * @param namespace - the namespace of the stream (1-254 characters). Use namespaces to group and organize streams.
149
+ * @param props - optional properties including metadata, content type, compression, and TTL
150
+ * @returns a Promise that resolves to the created Stream
151
+ *
152
+ * @example
153
+ * ```typescript
154
+ * // Create a simple text stream (expires in 30 days by default)
155
+ * const stream = await streams.create('agent-logs');
156
+ * await stream.write('Starting agent execution\n');
157
+ * await stream.write('Processing data...\n');
158
+ * await stream.close();
159
+ * console.log('Stream URL:', stream.url);
160
+ *
161
+ * // Create a stream with custom TTL (expires in 1 hour)
162
+ * const tempStream = await streams.create('temp-data', {
163
+ * ttl: 3600 // 1 hour in seconds
164
+ * });
165
+ *
166
+ * // Create a stream that never expires
167
+ * const permanentStream = await streams.create('permanent-data', {
168
+ * ttl: null // or ttl: 0
169
+ * });
170
+ *
171
+ * // Create a compressed JSON stream with metadata
172
+ * const dataStream = await streams.create('data-export', {
173
+ * contentType: 'application/json',
174
+ * compress: true,
175
+ * metadata: { exportDate: '2024-01-15', version: '1.0' }
176
+ * });
177
+ * await dataStream.write({ records: [...] });
178
+ * await dataStream.close();
179
+ *
180
+ * // Read back from the stream
181
+ * const reader = dataStream.getReader();
182
+ * for await (const chunk of reader) {
183
+ * console.log('Chunk:', chunk);
184
+ * }
185
+ * ```
186
+ */
187
+ create(namespace: string, props?: CreateStreamProps): Promise<Stream>;
188
+ /**
189
+ * Get stream metadata by ID
190
+ *
191
+ * @param id - the stream ID
192
+ * @returns a Promise that resolves to the stream information
193
+ *
194
+ * @example
195
+ * ```typescript
196
+ * const stream = await streams.get('stream_0199a52b06e3767dbe2f10afabb5e5e4');
197
+ * console.log(`Namespace: ${stream.namespace}, Size: ${stream.sizeBytes} bytes`);
198
+ * ```
199
+ */
200
+ get(id: string): Promise<StreamInfo>;
201
+ /**
202
+ * Download stream content
203
+ *
204
+ * @param id - the stream ID to download
205
+ * @returns a Promise that resolves to a ReadableStream of the content
206
+ *
207
+ * @example
208
+ * ```typescript
209
+ * const readable = await streams.download('stream_0199a52b06e3767dbe2f10afabb5e5e4');
210
+ * // Pipe to a file or process the stream
211
+ * ```
212
+ */
213
+ download(id: string): Promise<ReadableStream<Uint8Array>>;
214
+ /**
215
+ * List streams with optional filtering and pagination
216
+ *
217
+ * @param params - optional parameters for filtering and pagination
218
+ * @returns a Promise that resolves to the list of streams with metadata
219
+ *
220
+ * @example
221
+ * ```typescript
222
+ * // List all streams
223
+ * const all = await streams.list();
224
+ * console.log(`Found ${all.total} streams`);
225
+ *
226
+ * // Filter by namespace
227
+ * const logs = await streams.list({ namespace: 'agent-logs' });
228
+ *
229
+ * // Filter by metadata and paginate
230
+ * const filtered = await streams.list({
231
+ * metadata: { type: 'export' },
232
+ * limit: 50,
233
+ * offset: 100
234
+ * });
235
+ *
236
+ * for (const stream of filtered.streams) {
237
+ * console.log(`${stream.namespace}: ${stream.sizeBytes} bytes at ${stream.url}`);
238
+ * }
239
+ * ```
240
+ */
241
+ list(params?: ListStreamsParams): Promise<ListStreamsResponse>;
242
+ /**
243
+ * Delete a stream by its ID
244
+ *
245
+ * @param id - the stream ID to delete
246
+ * @returns a Promise that resolves when the stream is deleted
247
+ *
248
+ * @example
249
+ * ```typescript
250
+ * await streams.delete('stream-id-123');
251
+ * ```
252
+ */
253
+ delete(id: string): Promise<void>;
254
+ }
255
+ export declare class StreamStorageService implements StreamStorage {
256
+ #private;
257
+ constructor(baseUrl: string, adapter: FetchAdapter);
258
+ create(namespace: string, props?: CreateStreamProps): Promise<Stream>;
259
+ list(params?: ListStreamsParams): Promise<ListStreamsResponse>;
260
+ get(id: string): Promise<StreamInfo>;
261
+ download(id: string): Promise<ReadableStream<Uint8Array>>;
262
+ delete(id: string): Promise<void>;
263
+ }
264
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC;;GAEG;AACH,eAAO,MAAM,sBAAsB,UAAU,CAAC;AAE9C;;GAEG;AACH,eAAO,MAAM,0BAA0B,UAAU,CAAC;AAQlD;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;iBAkDlC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,eAAO,MAAM,qBAAqB;;;;;;;EAOhC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;iBAkBlC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;iBAiC3B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;iBAoBpC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E;;;;;;;;;GASG;AACH,MAAM,WAAW,MAAO,SAAQ,cAAc;IAC7C;;OAEG;IACH,EAAE,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