@agentuity/core 0.0.47 → 0.0.49
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/services/_util.d.ts +2 -2
- package/dist/services/_util.d.ts.map +1 -1
- package/dist/services/_util.js +10 -10
- package/dist/services/_util.js.map +1 -1
- package/dist/services/adapter.d.ts +1 -1
- package/dist/services/adapter.d.ts.map +1 -1
- package/dist/services/evalrun.d.ts +40 -5
- package/dist/services/evalrun.d.ts.map +1 -1
- package/dist/services/exception.d.ts +2 -1
- package/dist/services/exception.d.ts.map +1 -1
- package/dist/services/exception.js +3 -1
- package/dist/services/exception.js.map +1 -1
- package/dist/services/keyvalue.d.ts +72 -0
- package/dist/services/keyvalue.d.ts.map +1 -1
- package/dist/services/keyvalue.js +103 -3
- package/dist/services/keyvalue.js.map +1 -1
- package/dist/services/objectstore.d.ts +100 -0
- package/dist/services/objectstore.d.ts.map +1 -1
- package/dist/services/objectstore.js +169 -4
- package/dist/services/objectstore.js.map +1 -1
- package/dist/services/session.d.ts +43 -5
- package/dist/services/session.d.ts.map +1 -1
- package/dist/services/stream.d.ts +60 -8
- package/dist/services/stream.d.ts.map +1 -1
- package/dist/services/stream.js +3 -3
- package/dist/services/stream.js.map +1 -1
- package/dist/services/vector.d.ts +103 -22
- package/dist/services/vector.d.ts.map +1 -1
- package/dist/services/vector.js +4 -4
- package/dist/services/vector.js.map +1 -1
- package/package.json +1 -1
- package/src/services/_util.ts +15 -9
- package/src/services/adapter.ts +1 -1
- package/src/services/evalrun.ts +40 -5
- package/src/services/exception.ts +3 -1
- package/src/services/keyvalue.ts +193 -3
- package/src/services/objectstore.ts +319 -4
- package/src/services/session.ts +43 -5
- package/src/services/stream.ts +63 -11
- package/src/services/vector.ts +107 -26
|
@@ -97,6 +97,26 @@ type ObjectStoreCreatePublicURLResponse =
|
|
|
97
97
|
| ObjectStoreCreatePublicURLSuccessResponse
|
|
98
98
|
| ObjectStoreCreatePublicURLErrorResponse;
|
|
99
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Information about an object in the object store
|
|
102
|
+
*/
|
|
103
|
+
export interface ObjectInfo {
|
|
104
|
+
key: string;
|
|
105
|
+
size: number;
|
|
106
|
+
etag: string;
|
|
107
|
+
created_at: string;
|
|
108
|
+
updated_at: string;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Information about a bucket in the object store
|
|
113
|
+
*/
|
|
114
|
+
export interface BucketInfo {
|
|
115
|
+
name: string;
|
|
116
|
+
object_count: number;
|
|
117
|
+
total_bytes: number;
|
|
118
|
+
}
|
|
119
|
+
|
|
100
120
|
/**
|
|
101
121
|
* Object store service for storing and retrieving binary data
|
|
102
122
|
*/
|
|
@@ -179,6 +199,85 @@ export interface ObjectStorage {
|
|
|
179
199
|
* ```
|
|
180
200
|
*/
|
|
181
201
|
createPublicURL(bucket: string, key: string, params?: CreatePublicURLParams): Promise<string>;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* List all buckets in the object store
|
|
205
|
+
*
|
|
206
|
+
* @returns array of bucket information
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```typescript
|
|
210
|
+
* const buckets = await objectStore.listBuckets();
|
|
211
|
+
* for (const bucket of buckets) {
|
|
212
|
+
* console.log(`${bucket.name}: ${bucket.object_count} objects, ${bucket.total_bytes} bytes`);
|
|
213
|
+
* }
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
listBuckets(): Promise<BucketInfo[]>;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* List all keys in a bucket
|
|
220
|
+
*
|
|
221
|
+
* @param bucket - the bucket to list keys from
|
|
222
|
+
* @returns array of object information
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```typescript
|
|
226
|
+
* const objects = await objectStore.listKeys('my-bucket');
|
|
227
|
+
* for (const obj of objects) {
|
|
228
|
+
* console.log(`${obj.key}: ${obj.size} bytes`);
|
|
229
|
+
* }
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
listKeys(bucket: string): Promise<ObjectInfo[]>;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* List objects in a bucket with optional filtering
|
|
236
|
+
*
|
|
237
|
+
* @param bucket - the bucket to list objects from
|
|
238
|
+
* @param options - optional filtering (prefix, limit)
|
|
239
|
+
* @returns array of object information
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```typescript
|
|
243
|
+
* const objects = await objectStore.listObjects('my-bucket', { prefix: 'docs/', limit: 100 });
|
|
244
|
+
* for (const obj of objects) {
|
|
245
|
+
* console.log(`${obj.key}: ${obj.size} bytes`);
|
|
246
|
+
* }
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
listObjects(
|
|
250
|
+
bucket: string,
|
|
251
|
+
options?: { prefix?: string; limit?: number }
|
|
252
|
+
): Promise<ObjectInfo[]>;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Get object metadata without retrieving the data
|
|
256
|
+
*
|
|
257
|
+
* @param bucket - the bucket containing the object
|
|
258
|
+
* @param key - the key of the object
|
|
259
|
+
* @returns object metadata (size, contentType, etc.)
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```typescript
|
|
263
|
+
* const metadata = await objectStore.headObject('my-bucket', 'my-key');
|
|
264
|
+
* console.log(`Size: ${metadata.size}, Type: ${metadata.contentType}`);
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
headObject(bucket: string, key: string): Promise<ObjectInfo>;
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Delete a bucket and all its contents
|
|
271
|
+
*
|
|
272
|
+
* @param bucket - the bucket to delete
|
|
273
|
+
* @returns true if the bucket was deleted
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* ```typescript
|
|
277
|
+
* await objectStore.deleteBucket('my-bucket');
|
|
278
|
+
* ```
|
|
279
|
+
*/
|
|
280
|
+
deleteBucket(bucket: string): Promise<boolean>;
|
|
182
281
|
}
|
|
183
282
|
|
|
184
283
|
/**
|
|
@@ -247,7 +346,7 @@ export class ObjectStorageService implements ObjectStorage {
|
|
|
247
346
|
} as ObjectResultFound;
|
|
248
347
|
} catch (err) {
|
|
249
348
|
if (err instanceof Response) {
|
|
250
|
-
throw await toServiceException(url, err);
|
|
349
|
+
throw await toServiceException(url, 'GET', err);
|
|
251
350
|
}
|
|
252
351
|
throw err;
|
|
253
352
|
}
|
|
@@ -342,7 +441,7 @@ export class ObjectStorageService implements ObjectStorage {
|
|
|
342
441
|
}
|
|
343
442
|
} catch (err) {
|
|
344
443
|
if (err instanceof Response) {
|
|
345
|
-
throw await toServiceException(url, err);
|
|
444
|
+
throw await toServiceException(url, 'PUT', err);
|
|
346
445
|
}
|
|
347
446
|
throw err;
|
|
348
447
|
}
|
|
@@ -390,7 +489,7 @@ export class ObjectStorageService implements ObjectStorage {
|
|
|
390
489
|
);
|
|
391
490
|
} catch (err) {
|
|
392
491
|
if (err instanceof Response) {
|
|
393
|
-
throw await toServiceException(url, err);
|
|
492
|
+
throw await toServiceException(url, 'DELETE', err);
|
|
394
493
|
}
|
|
395
494
|
throw err;
|
|
396
495
|
}
|
|
@@ -458,7 +557,223 @@ export class ObjectStorageService implements ObjectStorage {
|
|
|
458
557
|
throw err;
|
|
459
558
|
}
|
|
460
559
|
if (err instanceof Response) {
|
|
461
|
-
throw await toServiceException(url, err);
|
|
560
|
+
throw await toServiceException(url, 'POST', err);
|
|
561
|
+
}
|
|
562
|
+
throw err;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
async listBuckets(): Promise<BucketInfo[]> {
|
|
567
|
+
const url = buildUrl(this.#baseUrl, '/object/2025-03-17/buckets');
|
|
568
|
+
|
|
569
|
+
const signal = AbortSignal.timeout(10_000);
|
|
570
|
+
const options: FetchRequest = {
|
|
571
|
+
method: 'GET',
|
|
572
|
+
signal,
|
|
573
|
+
telemetry: {
|
|
574
|
+
name: 'agentuity.objectstore.listBuckets',
|
|
575
|
+
attributes: {},
|
|
576
|
+
},
|
|
577
|
+
};
|
|
578
|
+
|
|
579
|
+
try {
|
|
580
|
+
const result = await this.#adapter.invoke<{ buckets: BucketInfo[] }>(url, options);
|
|
581
|
+
|
|
582
|
+
if (!result.ok) {
|
|
583
|
+
throw new Error(
|
|
584
|
+
`Failed to list buckets: ${result.response.statusText} (${result.response.status})`
|
|
585
|
+
);
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
return result.data.buckets;
|
|
589
|
+
} catch (err) {
|
|
590
|
+
if (err instanceof Response) {
|
|
591
|
+
throw await toServiceException(url, 'GET', err);
|
|
592
|
+
}
|
|
593
|
+
throw err;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
async listKeys(bucket: string): Promise<ObjectInfo[]> {
|
|
598
|
+
if (!bucket?.trim()) {
|
|
599
|
+
throw new Error('bucket is required and cannot be empty');
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
const url = buildUrl(this.#baseUrl, `/object/2025-03-17/keys/${encodeURIComponent(bucket)}`);
|
|
603
|
+
|
|
604
|
+
const signal = AbortSignal.timeout(10_000);
|
|
605
|
+
const options: FetchRequest = {
|
|
606
|
+
method: 'GET',
|
|
607
|
+
signal,
|
|
608
|
+
telemetry: {
|
|
609
|
+
name: 'agentuity.objectstore.listKeys',
|
|
610
|
+
attributes: {
|
|
611
|
+
'objectstore.bucket': bucket,
|
|
612
|
+
},
|
|
613
|
+
},
|
|
614
|
+
};
|
|
615
|
+
|
|
616
|
+
try {
|
|
617
|
+
const result = await this.#adapter.invoke<{ bucket: string; objects: ObjectInfo[] }>(
|
|
618
|
+
url,
|
|
619
|
+
options
|
|
620
|
+
);
|
|
621
|
+
|
|
622
|
+
if (!result.ok) {
|
|
623
|
+
throw new Error(
|
|
624
|
+
`Failed to list keys: ${result.response.statusText} (${result.response.status})`
|
|
625
|
+
);
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
return result.data.objects;
|
|
629
|
+
} catch (err) {
|
|
630
|
+
if (err instanceof Response) {
|
|
631
|
+
throw await toServiceException(url, 'GET', err);
|
|
632
|
+
}
|
|
633
|
+
throw err;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
async listObjects(
|
|
638
|
+
bucket: string,
|
|
639
|
+
options?: { prefix?: string; limit?: number }
|
|
640
|
+
): Promise<ObjectInfo[]> {
|
|
641
|
+
if (!bucket?.trim()) {
|
|
642
|
+
throw new Error('bucket is required and cannot be empty');
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
const params = new URLSearchParams();
|
|
646
|
+
if (options?.prefix) {
|
|
647
|
+
params.set('prefix', options.prefix);
|
|
648
|
+
}
|
|
649
|
+
if (options?.limit) {
|
|
650
|
+
params.set('limit', options.limit.toString());
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
const queryString = params.toString();
|
|
654
|
+
const url = buildUrl(
|
|
655
|
+
this.#baseUrl,
|
|
656
|
+
`/object/2025-03-17/objects/${encodeURIComponent(bucket)}${queryString ? `?${queryString}` : ''}`
|
|
657
|
+
);
|
|
658
|
+
|
|
659
|
+
const signal = AbortSignal.timeout(10_000);
|
|
660
|
+
const fetchOptions: FetchRequest = {
|
|
661
|
+
method: 'GET',
|
|
662
|
+
signal,
|
|
663
|
+
telemetry: {
|
|
664
|
+
name: 'agentuity.objectstore.listObjects',
|
|
665
|
+
attributes: {
|
|
666
|
+
'objectstore.bucket': bucket,
|
|
667
|
+
'objectstore.prefix': options?.prefix || '',
|
|
668
|
+
'objectstore.limit': (options?.limit || 1000).toString(),
|
|
669
|
+
},
|
|
670
|
+
},
|
|
671
|
+
};
|
|
672
|
+
|
|
673
|
+
try {
|
|
674
|
+
const result = await this.#adapter.invoke<{ bucket: string; objects: ObjectInfo[] }>(
|
|
675
|
+
url,
|
|
676
|
+
fetchOptions
|
|
677
|
+
);
|
|
678
|
+
|
|
679
|
+
if (!result.ok) {
|
|
680
|
+
throw new Error(
|
|
681
|
+
`Failed to list objects: ${result.response.statusText} (${result.response.status})`
|
|
682
|
+
);
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
return result.data.objects;
|
|
686
|
+
} catch (err) {
|
|
687
|
+
if (err instanceof Response) {
|
|
688
|
+
throw await toServiceException(url, 'GET', err);
|
|
689
|
+
}
|
|
690
|
+
throw err;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
async headObject(bucket: string, key: string): Promise<ObjectInfo> {
|
|
695
|
+
if (!bucket?.trim()) {
|
|
696
|
+
throw new Error('bucket is required and cannot be empty');
|
|
697
|
+
}
|
|
698
|
+
if (!key?.trim()) {
|
|
699
|
+
throw new Error('key is required and cannot be empty');
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
const url = buildUrl(
|
|
703
|
+
this.#baseUrl,
|
|
704
|
+
`/object/2025-03-17/head/${encodeURIComponent(bucket)}/${encodeURIComponent(key)}`
|
|
705
|
+
);
|
|
706
|
+
|
|
707
|
+
const signal = AbortSignal.timeout(10_000);
|
|
708
|
+
const fetchOptions: FetchRequest = {
|
|
709
|
+
method: 'GET',
|
|
710
|
+
signal,
|
|
711
|
+
telemetry: {
|
|
712
|
+
name: 'agentuity.objectstore.headObject',
|
|
713
|
+
attributes: {
|
|
714
|
+
'objectstore.bucket': bucket,
|
|
715
|
+
'objectstore.key': key,
|
|
716
|
+
},
|
|
717
|
+
},
|
|
718
|
+
};
|
|
719
|
+
|
|
720
|
+
try {
|
|
721
|
+
const result = await this.#adapter.invoke<ObjectInfo>(url, fetchOptions);
|
|
722
|
+
|
|
723
|
+
if (!result.ok) {
|
|
724
|
+
if (result.response.status === 404) {
|
|
725
|
+
throw new Error('Object not found');
|
|
726
|
+
}
|
|
727
|
+
throw new Error(
|
|
728
|
+
`Failed to get object metadata: ${result.response.statusText} (${result.response.status})`
|
|
729
|
+
);
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
return result.data;
|
|
733
|
+
} catch (err) {
|
|
734
|
+
if (err instanceof Response) {
|
|
735
|
+
throw await toServiceException(url, 'GET', err);
|
|
736
|
+
}
|
|
737
|
+
throw err;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
async deleteBucket(bucket: string): Promise<boolean> {
|
|
742
|
+
if (!bucket?.trim()) {
|
|
743
|
+
throw new Error('bucket is required and cannot be empty');
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
const url = buildUrl(this.#baseUrl, `/object/2025-03-17/${encodeURIComponent(bucket)}`);
|
|
747
|
+
|
|
748
|
+
const signal = AbortSignal.timeout(30_000);
|
|
749
|
+
const options: FetchRequest = {
|
|
750
|
+
method: 'DELETE',
|
|
751
|
+
signal,
|
|
752
|
+
telemetry: {
|
|
753
|
+
name: 'agentuity.objectstore.deleteBucket',
|
|
754
|
+
attributes: {
|
|
755
|
+
'objectstore.bucket': bucket,
|
|
756
|
+
},
|
|
757
|
+
},
|
|
758
|
+
};
|
|
759
|
+
|
|
760
|
+
try {
|
|
761
|
+
const result = await this.#adapter.invoke(url, options);
|
|
762
|
+
|
|
763
|
+
if (result.response.status === 404) {
|
|
764
|
+
return false;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
if (result.response.status === 200) {
|
|
768
|
+
return true;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
throw new Error(
|
|
772
|
+
`Failed to delete bucket: ${result.response.statusText} (${result.response.status})`
|
|
773
|
+
);
|
|
774
|
+
} catch (err) {
|
|
775
|
+
if (err instanceof Response) {
|
|
776
|
+
throw await toServiceException(url, 'DELETE', err);
|
|
462
777
|
}
|
|
463
778
|
throw err;
|
|
464
779
|
}
|
package/src/services/session.ts
CHANGED
|
@@ -45,20 +45,58 @@ export const SessionCompleteEventDelayedSchema = z.intersection(
|
|
|
45
45
|
);
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
* SessionEventProvider is a provider for logging session events
|
|
48
|
+
* SessionEventProvider is a provider for logging and tracking agent session lifecycle events.
|
|
49
|
+
* Sessions represent individual agent executions triggered by API calls, cron jobs, or other sources.
|
|
49
50
|
*/
|
|
50
51
|
export interface SessionEventProvider {
|
|
51
52
|
/**
|
|
52
|
-
*
|
|
53
|
+
* Called when an agent session starts. Records the initial context and metadata
|
|
54
|
+
* for the session including trigger source, environment, and routing information.
|
|
53
55
|
*
|
|
54
|
-
* @param event SessionStartEvent
|
|
56
|
+
* @param event - SessionStartEvent containing session initialization data
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* await sessionProvider.start({
|
|
61
|
+
* id: 'session-123',
|
|
62
|
+
* threadId: 'thread-abc',
|
|
63
|
+
* orgId: 'org-456',
|
|
64
|
+
* projectId: 'proj-789',
|
|
65
|
+
* deploymentId: 'deploy-xyz',
|
|
66
|
+
* routeId: 'route-001',
|
|
67
|
+
* environment: 'production',
|
|
68
|
+
* devmode: false,
|
|
69
|
+
* url: '/api/agent/chat',
|
|
70
|
+
* method: 'POST',
|
|
71
|
+
* trigger: 'api'
|
|
72
|
+
* });
|
|
73
|
+
* ```
|
|
55
74
|
*/
|
|
56
75
|
start(event: SessionStartEvent): Promise<void>;
|
|
57
76
|
|
|
58
77
|
/**
|
|
59
|
-
*
|
|
78
|
+
* Called when an agent session completes (successfully or with error).
|
|
79
|
+
* Records final status, any errors, and which agents participated.
|
|
80
|
+
*
|
|
81
|
+
* @param event - SessionCompleteEvent containing completion status and results
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* // Successful completion
|
|
86
|
+
* await sessionProvider.complete({
|
|
87
|
+
* id: 'session-123',
|
|
88
|
+
* statusCode: 200,
|
|
89
|
+
* agentIds: ['agent-1', 'agent-2']
|
|
90
|
+
* });
|
|
60
91
|
*
|
|
61
|
-
*
|
|
92
|
+
* // Completion with error
|
|
93
|
+
* await sessionProvider.complete({
|
|
94
|
+
* id: 'session-123',
|
|
95
|
+
* statusCode: 500,
|
|
96
|
+
* error: 'Database connection timeout',
|
|
97
|
+
* agentIds: ['agent-1']
|
|
98
|
+
* });
|
|
99
|
+
* ```
|
|
62
100
|
*/
|
|
63
101
|
complete(event: SessionCompleteEvent): Promise<void>;
|
|
64
102
|
}
|
package/src/services/stream.ts
CHANGED
|
@@ -151,31 +151,83 @@ export interface Stream extends WritableStream {
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
/**
|
|
154
|
-
* Stream API for creating and managing streams
|
|
154
|
+
* Stream API for creating and managing durable, resumable data streams.
|
|
155
|
+
* Streams are backed by durable storage and provide public URLs for access.
|
|
155
156
|
*/
|
|
156
157
|
export interface StreamStorage {
|
|
157
158
|
/**
|
|
158
|
-
*
|
|
159
|
+
* Create a new stream for writing data that can be read multiple times
|
|
159
160
|
*
|
|
160
|
-
* @param name - the name of the stream (1-254 characters).
|
|
161
|
-
* @param props - optional properties
|
|
161
|
+
* @param name - the name of the stream (1-254 characters). Use names to group and organize streams.
|
|
162
|
+
* @param props - optional properties including metadata, content type, and compression
|
|
162
163
|
* @returns a Promise that resolves to the created Stream
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```typescript
|
|
167
|
+
* // Create a simple text stream
|
|
168
|
+
* const stream = await streams.create('agent-logs');
|
|
169
|
+
* await stream.write('Starting agent execution\n');
|
|
170
|
+
* await stream.write('Processing data...\n');
|
|
171
|
+
* await stream.close();
|
|
172
|
+
* console.log('Stream URL:', stream.url);
|
|
173
|
+
*
|
|
174
|
+
* // Create a compressed JSON stream with metadata
|
|
175
|
+
* const dataStream = await streams.create('data-export', {
|
|
176
|
+
* contentType: 'application/json',
|
|
177
|
+
* compress: true,
|
|
178
|
+
* metadata: { exportDate: '2024-01-15', version: '1.0' }
|
|
179
|
+
* });
|
|
180
|
+
* await dataStream.write({ records: [...] });
|
|
181
|
+
* await dataStream.close();
|
|
182
|
+
*
|
|
183
|
+
* // Read back from the stream
|
|
184
|
+
* const reader = dataStream.getReader();
|
|
185
|
+
* for await (const chunk of reader) {
|
|
186
|
+
* console.log('Chunk:', chunk);
|
|
187
|
+
* }
|
|
188
|
+
* ```
|
|
163
189
|
*/
|
|
164
190
|
create(name: string, props?: CreateStreamProps): Promise<Stream>;
|
|
165
191
|
|
|
166
192
|
/**
|
|
167
|
-
*
|
|
193
|
+
* List streams with optional filtering and pagination
|
|
168
194
|
*
|
|
169
195
|
* @param params - optional parameters for filtering and pagination
|
|
170
|
-
* @returns a Promise that resolves to the list of streams
|
|
196
|
+
* @returns a Promise that resolves to the list of streams with metadata
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```typescript
|
|
200
|
+
* // List all streams
|
|
201
|
+
* const all = await streams.list();
|
|
202
|
+
* console.log(`Found ${all.total} streams`);
|
|
203
|
+
*
|
|
204
|
+
* // Filter by name
|
|
205
|
+
* const logs = await streams.list({ name: 'agent-logs' });
|
|
206
|
+
*
|
|
207
|
+
* // Filter by metadata and paginate
|
|
208
|
+
* const filtered = await streams.list({
|
|
209
|
+
* metadata: { type: 'export' },
|
|
210
|
+
* limit: 50,
|
|
211
|
+
* offset: 100
|
|
212
|
+
* });
|
|
213
|
+
*
|
|
214
|
+
* for (const stream of filtered.streams) {
|
|
215
|
+
* console.log(`${stream.name}: ${stream.sizeBytes} bytes at ${stream.url}`);
|
|
216
|
+
* }
|
|
217
|
+
* ```
|
|
171
218
|
*/
|
|
172
219
|
list(params?: ListStreamsParams): Promise<ListStreamsResponse>;
|
|
173
220
|
|
|
174
221
|
/**
|
|
175
|
-
*
|
|
222
|
+
* Delete a stream by its ID
|
|
176
223
|
*
|
|
177
|
-
* @param id - the stream
|
|
224
|
+
* @param id - the stream ID to delete
|
|
178
225
|
* @returns a Promise that resolves when the stream is deleted
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* ```typescript
|
|
229
|
+
* await streams.delete('stream-id-123');
|
|
230
|
+
* ```
|
|
179
231
|
*/
|
|
180
232
|
delete(id: string): Promise<void>;
|
|
181
233
|
}
|
|
@@ -537,7 +589,7 @@ export class StreamStorageService implements StreamStorage {
|
|
|
537
589
|
|
|
538
590
|
return stream;
|
|
539
591
|
}
|
|
540
|
-
throw await toServiceException(url, res.response);
|
|
592
|
+
throw await toServiceException(url, 'POST', res.response);
|
|
541
593
|
}
|
|
542
594
|
|
|
543
595
|
async list(params?: ListStreamsParams): Promise<ListStreamsResponse> {
|
|
@@ -587,7 +639,7 @@ export class StreamStorageService implements StreamStorage {
|
|
|
587
639
|
if (res.ok) {
|
|
588
640
|
return res.data;
|
|
589
641
|
}
|
|
590
|
-
throw await toServiceException(url, res.response);
|
|
642
|
+
throw await toServiceException(url, 'POST', res.response);
|
|
591
643
|
}
|
|
592
644
|
|
|
593
645
|
async delete(id: string): Promise<void> {
|
|
@@ -609,6 +661,6 @@ export class StreamStorageService implements StreamStorage {
|
|
|
609
661
|
if (res.ok) {
|
|
610
662
|
return;
|
|
611
663
|
}
|
|
612
|
-
throw await toServiceException(url, res.response);
|
|
664
|
+
throw await toServiceException(url, 'DELETE', res.response);
|
|
613
665
|
}
|
|
614
666
|
}
|