@agentuity/core 0.0.1

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/json.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Safely stringify an object to JSON, handling circular references
3
+ * @param obj - The object to stringify
4
+ * @returns JSON string representation
5
+ */
6
+ export declare function safeStringify(obj: unknown): string;
7
+ //# sourceMappingURL=json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAoBlD"}
@@ -0,0 +1,7 @@
1
+ import { Body } from './adapter';
2
+ import { ServiceException } from './exception';
3
+ export declare const buildUrl: (base: string, path: string, subpath?: string, query?: URLSearchParams) => string;
4
+ export declare function toServiceException(response: Response): Promise<ServiceException>;
5
+ export declare function toPayload(data: unknown): Promise<[Body, string]>;
6
+ export declare function fromResponse<T>(response: Response): Promise<T>;
7
+ //# sourceMappingURL=_util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_util.d.ts","sourceRoot":"","sources":["../../src/services/_util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,eAAO,MAAM,QAAQ,GACpB,MAAM,MAAM,EACZ,MAAM,MAAM,EACZ,UAAU,MAAM,EAChB,QAAQ,eAAe,KACrB,MAWF,CAAC;AAEF,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAgCtF;AAMD,wBAAsB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CA0CtE;AAED,wBAAsB,YAAY,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,CAYpE"}
@@ -0,0 +1,29 @@
1
+ export interface FetchSuccessResponse<TData> {
2
+ ok: true;
3
+ data: TData;
4
+ response: Response;
5
+ }
6
+ export interface FetchErrorResponse {
7
+ ok: false;
8
+ data: never;
9
+ response: Response;
10
+ }
11
+ export type FetchResponse<T> = FetchErrorResponse | FetchSuccessResponse<T>;
12
+ export type Body = string | Buffer | ArrayBuffer | ReadableStream;
13
+ export interface FetchRequest {
14
+ method: 'GET' | 'PUT' | 'POST' | 'DELETE';
15
+ body?: Body;
16
+ signal?: AbortSignal;
17
+ contentType?: string;
18
+ headers?: Record<string, string>;
19
+ telemetry?: {
20
+ name: string;
21
+ attributes?: Record<string, string>;
22
+ };
23
+ binary?: true;
24
+ duplex?: 'half';
25
+ }
26
+ export interface FetchAdapter {
27
+ invoke<T>(url: string, options: FetchRequest): Promise<FetchResponse<T>>;
28
+ }
29
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/services/adapter.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB,CAAC,KAAK;IAC1C,EAAE,EAAE,IAAI,CAAC;IACT,IAAI,EAAE,KAAK,CAAC;IACZ,QAAQ,EAAE,QAAQ,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IAClC,EAAE,EAAE,KAAK,CAAC;IACV,IAAI,EAAE,KAAK,CAAC;IACZ,QAAQ,EAAE,QAAQ,CAAC;CACnB;AAED,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,kBAAkB,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC;AAE5E,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,WAAW,GAAG,cAAc,CAAC;AAElE,MAAM,WAAW,YAAY;IAC5B,MAAM,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;IAC1C,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACpC,CAAC;IACF,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC5B,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;CACzE"}
@@ -0,0 +1,5 @@
1
+ export declare class ServiceException extends Error {
2
+ statusCode: number;
3
+ constructor(message: string, statusCode: number);
4
+ }
5
+ //# sourceMappingURL=exception.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exception.d.ts","sourceRoot":"","sources":["../../src/services/exception.ts"],"names":[],"mappings":"AAAA,qBAAa,gBAAiB,SAAQ,KAAK;IAC1C,UAAU,EAAE,MAAM,CAAC;gBACP,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;CAI/C"}
@@ -0,0 +1,8 @@
1
+ export * from './adapter';
2
+ export * from './exception';
3
+ export * from './keyvalue';
4
+ export * from './objectstore';
5
+ export * from './server';
6
+ export * from './stream';
7
+ export * from './vector';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
@@ -0,0 +1,76 @@
1
+ import { FetchAdapter } from './adapter';
2
+ /**
3
+ * the result of a data operation when the data is found
4
+ */
5
+ export interface DataResultFound<T> {
6
+ /**
7
+ * the data from the result of the operation
8
+ */
9
+ data: T;
10
+ /**
11
+ * the content type of the data
12
+ */
13
+ contentType: string;
14
+ /**
15
+ * the data was found
16
+ */
17
+ exists: true;
18
+ }
19
+ /**
20
+ * the result of a data operation when the data is not found
21
+ */
22
+ export interface DataResultNotFound {
23
+ data: never;
24
+ /**
25
+ * the data was not found
26
+ */
27
+ exists: false;
28
+ }
29
+ /**
30
+ * the result of a data operation
31
+ */
32
+ export type DataResult<T> = DataResultFound<T> | DataResultNotFound;
33
+ export interface KeyValueStorageSetParams {
34
+ /**
35
+ * the number of milliseconds to keep the value in the cache
36
+ */
37
+ ttl?: number;
38
+ /**
39
+ * the content type of the value
40
+ */
41
+ contentType?: string;
42
+ }
43
+ export interface KeyValueStorage {
44
+ /**
45
+ * get a value from the key value storage
46
+ *
47
+ * @param name - the name of the key value storage
48
+ * @param key - the key to get the value of
49
+ * @returns the DataResult object
50
+ */
51
+ get<T>(name: string, key: string): Promise<DataResult<T>>;
52
+ /**
53
+ * set a value in the key value storage
54
+ *
55
+ * @param name - the name of the key value storage
56
+ * @param key - the key to set the value of
57
+ * @param value - the value to set in any of the supported data types
58
+ * @param params - the KeyValueStorageSetParams
59
+ */
60
+ set<T = unknown>(name: string, key: string, value: T, params?: KeyValueStorageSetParams): Promise<void>;
61
+ /**
62
+ * delete a value from the key value storage
63
+ *
64
+ * @param name - the name of the key value storage
65
+ * @param key - the key to delete
66
+ */
67
+ delete(name: string, key: string): Promise<void>;
68
+ }
69
+ export declare class KeyValueStorageService implements KeyValueStorage {
70
+ #private;
71
+ constructor(baseUrl: string, adapter: FetchAdapter);
72
+ get<T>(name: string, key: string): Promise<DataResult<T>>;
73
+ set<T = unknown>(name: string, key: string, value: T, params?: KeyValueStorageSetParams): Promise<void>;
74
+ delete(name: string, key: string): Promise<void>;
75
+ }
76
+ //# sourceMappingURL=keyvalue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyvalue.d.ts","sourceRoot":"","sources":["../../src/services/keyvalue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGzC;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC;IACjC;;OAEG;IACH,IAAI,EAAE,CAAC,CAAC;IAER;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,MAAM,EAAE,IAAI,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,KAAK,CAAC;IACZ;;OAEG;IACH,MAAM,EAAE,KAAK,CAAC;CACd;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC;AAEpE,MAAM,WAAW,wBAAwB;IACxC;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC/B;;;;;;OAMG;IACH,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAE1D;;;;;;;OAOG;IACH,GAAG,CAAC,CAAC,GAAG,OAAO,EACd,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,CAAC,EACR,MAAM,CAAC,EAAE,wBAAwB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB;;;;;OAKG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACjD;AAED,qBAAa,sBAAuB,YAAW,eAAe;;gBAIjD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY;IAK5C,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IA8BzD,GAAG,CAAC,CAAC,GAAG,OAAO,EACpB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,CAAC,EACR,MAAM,CAAC,EAAE,wBAAwB,GAC/B,OAAO,CAAC,IAAI,CAAC;IAkCV,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAsBtD"}
@@ -0,0 +1,157 @@
1
+ import type { FetchAdapter } from './adapter';
2
+ /**
3
+ * Parameters for putting an object into the object store
4
+ */
5
+ export interface ObjectStorePutParams {
6
+ /**
7
+ * the content type of the object
8
+ */
9
+ contentType?: string;
10
+ /**
11
+ * the content encoding of the object
12
+ */
13
+ contentEncoding?: string;
14
+ /**
15
+ * the cache control header for the object
16
+ */
17
+ cacheControl?: string;
18
+ /**
19
+ * the content disposition header for the object
20
+ */
21
+ contentDisposition?: string;
22
+ /**
23
+ * the content language header for the object
24
+ */
25
+ contentLanguage?: string;
26
+ /**
27
+ * arbitrary metadata to attach to the object but not returned as part of the object when fetched via HTTP
28
+ */
29
+ metadata?: Record<string, string>;
30
+ }
31
+ /**
32
+ * Result when an object is found in the object store
33
+ */
34
+ export interface ObjectResultFound {
35
+ /**
36
+ * the object data
37
+ */
38
+ data: Uint8Array;
39
+ /**
40
+ * the content type of the object
41
+ */
42
+ contentType: string;
43
+ /**
44
+ * the object was found
45
+ */
46
+ exists: true;
47
+ }
48
+ /**
49
+ * Result when an object is not found in the object store
50
+ */
51
+ export interface ObjectResultNotFound {
52
+ data: never;
53
+ /**
54
+ * the object was not found
55
+ */
56
+ exists: false;
57
+ }
58
+ /**
59
+ * The result of an object store get operation
60
+ */
61
+ export type ObjectResult = ObjectResultFound | ObjectResultNotFound;
62
+ /**
63
+ * Parameters for creating a public URL
64
+ */
65
+ export interface CreatePublicURLParams {
66
+ /**
67
+ * the duration of the signed URL in milliseconds. If not provided, the default is 1 hour.
68
+ */
69
+ expiresDuration?: number;
70
+ }
71
+ /**
72
+ * Object store service for storing and retrieving binary data
73
+ */
74
+ export interface ObjectStorage {
75
+ /**
76
+ * Get an object from the object store
77
+ *
78
+ * @param bucket - the bucket to get the object from
79
+ * @param key - the key of the object to get
80
+ * @returns a Promise that resolves to the object result
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * const result = await objectStore.get('my-bucket', 'my-key');
85
+ * if (result.exists) {
86
+ * console.log('Content type:', result.contentType);
87
+ * console.log('Data:', result.data);
88
+ * }
89
+ * ```
90
+ */
91
+ get(bucket: string, key: string): Promise<ObjectResult>;
92
+ /**
93
+ * Put an object into the object store
94
+ *
95
+ * @param bucket - the bucket to put the object into
96
+ * @param key - the key of the object to put
97
+ * @param data - the data to put (Uint8Array, ArrayBuffer, or ReadableStream)
98
+ * @param params - optional parameters for the put operation
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * const data = new TextEncoder().encode('Hello, world!');
103
+ * await objectStore.put('my-bucket', 'greeting.txt', data, {
104
+ * contentType: 'text/plain',
105
+ * metadata: { author: 'user123' }
106
+ * });
107
+ * ```
108
+ */
109
+ put(bucket: string, key: string, data: Uint8Array | ArrayBuffer | ReadableStream, params?: ObjectStorePutParams): Promise<void>;
110
+ /**
111
+ * Delete an object from the object store
112
+ *
113
+ * @param bucket - the bucket to delete the object from
114
+ * @param key - the key of the object to delete
115
+ * @returns true if the object was deleted, false if the object did not exist
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * const deleted = await objectStore.delete('my-bucket', 'my-key');
120
+ * if (deleted) {
121
+ * console.log('Object was deleted');
122
+ * } else {
123
+ * console.log('Object did not exist');
124
+ * }
125
+ * ```
126
+ */
127
+ delete(bucket: string, key: string): Promise<boolean>;
128
+ /**
129
+ * Create a public URL for an object. This URL can be used to access the object without authentication.
130
+ *
131
+ * @param bucket - the bucket to create the signed URL for
132
+ * @param key - the key of the object to create the signed URL for
133
+ * @param params - optional parameters including expiration duration
134
+ * @returns the public URL
135
+ *
136
+ * @example
137
+ * ```typescript
138
+ * const url = await objectStore.createPublicURL('my-bucket', 'my-key', {
139
+ * expiresDuration: 3600000 // 1 hour in milliseconds
140
+ * });
141
+ * console.log('Public URL:', url);
142
+ * ```
143
+ */
144
+ createPublicURL(bucket: string, key: string, params?: CreatePublicURLParams): Promise<string>;
145
+ }
146
+ /**
147
+ * Implementation of the ObjectStorage interface
148
+ */
149
+ export declare class ObjectStorageService implements ObjectStorage {
150
+ #private;
151
+ constructor(baseUrl: string, adapter: FetchAdapter);
152
+ get(bucket: string, key: string): Promise<ObjectResult>;
153
+ put(bucket: string, key: string, data: Uint8Array | ArrayBuffer | ReadableStream, params?: ObjectStorePutParams): Promise<void>;
154
+ delete(bucket: string, key: string): Promise<boolean>;
155
+ createPublicURL(bucket: string, key: string, params?: CreatePublicURLParams): Promise<string>;
156
+ }
157
+ //# sourceMappingURL=objectstore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objectstore.d.ts","sourceRoot":"","sources":["../../src/services/objectstore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAsB,MAAM,WAAW,CAAC;AAGlE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IAC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C,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY;IAK5C,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IA4DvD,GAAG,CACR,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,UAAU,GAAG,WAAW,GAAG,cAAc,EAC/C,MAAM,CAAC,EAAE,oBAAoB,GAC3B,OAAO,CAAC,IAAI,CAAC;IA0FV,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAgDrD,eAAe,CACpB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,qBAAqB,GAC5B,OAAO,CAAC,MAAM,CAAC;CA+DlB"}
@@ -0,0 +1,22 @@
1
+ import type { FetchRequest, FetchResponse, FetchAdapter } from './adapter';
2
+ import { ServiceException } from './exception';
3
+ interface ServiceAdapterConfig {
4
+ headers: Record<string, string>;
5
+ onBefore?: (url: string, options: FetchRequest, invoke: () => Promise<void>) => Promise<void>;
6
+ onAfter?: <T>(url: string, options: FetchRequest, response: FetchResponse<T>, err?: ServiceException) => Promise<void>;
7
+ }
8
+ declare class ServerFetchAdapter implements FetchAdapter {
9
+ #private;
10
+ constructor(config: ServiceAdapterConfig);
11
+ private _invoke;
12
+ invoke<T>(url: string, options?: FetchRequest): Promise<FetchResponse<T>>;
13
+ }
14
+ /**
15
+ * Create a Server Side Fetch Adapter to allow the server to add headers and track outgoing requests
16
+ *
17
+ * @param config the service config
18
+ * @returns
19
+ */
20
+ export declare function createServerFetchAdapter(config: ServiceAdapterConfig): ServerFetchAdapter;
21
+ export {};
22
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/services/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAsB,aAAa,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE/F,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,UAAU,oBAAoB;IAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9F,OAAO,CAAC,EAAE,CAAC,CAAC,EACX,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,YAAY,EACrB,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,EAC1B,GAAG,CAAC,EAAE,gBAAgB,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC;CACnB;AAED,cAAM,kBAAmB,YAAW,YAAY;;gBAGnC,MAAM,EAAE,oBAAoB;YAG1B,OAAO;IA4Df,MAAM,CAAC,CAAC,EACb,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,YAAiC,GACxC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;CAmC5B;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,oBAAoB,sBAEpE"}
@@ -0,0 +1,167 @@
1
+ import { FetchAdapter } from './adapter';
2
+ /**
3
+ * Properties for creating a stream
4
+ */
5
+ export interface CreateStreamProps {
6
+ /**
7
+ * optional metadata for the stream
8
+ */
9
+ metadata?: Record<string, string>;
10
+ /**
11
+ * optional contentType for the stream data. If not set, defaults to application/octet-stream
12
+ */
13
+ contentType?: string;
14
+ /**
15
+ * optional flag to enable gzip compression of stream data during upload. if true, will also add
16
+ * add Content-Encoding: gzip header to responses. The client MUST be able to accept gzip
17
+ * compression for this to work or must be able to uncompress the raw data it receives.
18
+ */
19
+ compress?: true;
20
+ }
21
+ /**
22
+ * Parameters for listing streams
23
+ */
24
+ export interface ListStreamsParams {
25
+ /**
26
+ * optional name filter to search for streams
27
+ */
28
+ name?: string;
29
+ /**
30
+ * optional metadata filters to match streams
31
+ */
32
+ metadata?: Record<string, string>;
33
+ /**
34
+ * maximum number of streams to return (default: 100, max: 1000)
35
+ */
36
+ limit?: number;
37
+ /**
38
+ * number of streams to skip for pagination
39
+ */
40
+ offset?: number;
41
+ }
42
+ /**
43
+ * Stream information returned by list operation
44
+ */
45
+ export interface StreamInfo {
46
+ /**
47
+ * unique stream identifier
48
+ */
49
+ id: string;
50
+ /**
51
+ * the name of the stream
52
+ */
53
+ name: string;
54
+ /**
55
+ * the stream metadata
56
+ */
57
+ metadata: Record<string, string>;
58
+ /**
59
+ * the public URL to access the stream
60
+ */
61
+ url: string;
62
+ /**
63
+ * the size of the stream in bytes
64
+ */
65
+ sizeBytes: number;
66
+ }
67
+ /**
68
+ * Response from listing streams
69
+ */
70
+ export interface ListStreamsResponse {
71
+ /**
72
+ * whether the request was successful
73
+ */
74
+ success: boolean;
75
+ /**
76
+ * optional error message if not successful
77
+ */
78
+ message?: string;
79
+ /**
80
+ * array of streams matching the filter criteria
81
+ */
82
+ streams: StreamInfo[];
83
+ /**
84
+ * total count of streams matching the filter (useful for pagination)
85
+ */
86
+ total: number;
87
+ }
88
+ /**
89
+ * A durable and resumable stream that can be written to and read many times.
90
+ * The underlying stream is backed by a durable storage system and the URL
91
+ * returned is public and guaranteed to return the same data every time it is accessed.
92
+ * You can read from this stream internal in the agent using the getReader() method or
93
+ * return the URL to the stream to be used externally.
94
+ *
95
+ * You must write and close the stream before it can be read but if you attempt to read
96
+ * before any data is written, the reader will block until the first write occurs.
97
+ */
98
+ export interface Stream extends WritableStream {
99
+ /**
100
+ * unique stream identifier
101
+ */
102
+ id: string;
103
+ /**
104
+ * the unique stream url to consume the stream
105
+ */
106
+ url: string;
107
+ /**
108
+ * the total number of bytes written to the stream
109
+ */
110
+ readonly bytesWritten: number;
111
+ /**
112
+ * whether the stream is using compression
113
+ */
114
+ readonly compressed: boolean;
115
+ /**
116
+ * write data to the stream
117
+ */
118
+ write(chunk: string | Uint8Array | ArrayBuffer | Buffer | object): Promise<void>;
119
+ /**
120
+ * close the stream gracefully, handling already closed streams without error
121
+ */
122
+ close(): Promise<void>;
123
+ /**
124
+ * get a ReadableStream that streams from the internal URL
125
+ *
126
+ * Note: This method will block waiting for data until writes start to the Stream.
127
+ * The returned ReadableStream will remain open until the Stream is closed or an error occurs.
128
+ *
129
+ * @returns a ReadableStream that can be passed to response.stream()
130
+ */
131
+ getReader(): ReadableStream<Uint8Array>;
132
+ }
133
+ /**
134
+ * Stream API for creating and managing streams
135
+ */
136
+ export interface StreamStorage {
137
+ /**
138
+ * create a new stream
139
+ *
140
+ * @param name - the name of the stream (1-254 characters). you can group streams by name to organize them.
141
+ * @param props - optional properties for creating the stream
142
+ * @returns a Promise that resolves to the created Stream
143
+ */
144
+ create(name: string, props?: CreateStreamProps): Promise<Stream>;
145
+ /**
146
+ * list streams with optional filtering and pagination
147
+ *
148
+ * @param params - optional parameters for filtering and pagination
149
+ * @returns a Promise that resolves to the list of streams
150
+ */
151
+ list(params?: ListStreamsParams): Promise<ListStreamsResponse>;
152
+ /**
153
+ * delete a stream by id
154
+ *
155
+ * @param id - the stream id to delete
156
+ * @returns a Promise that resolves when the stream is deleted
157
+ */
158
+ delete(id: string): Promise<void>;
159
+ }
160
+ export declare class StreamStorageService implements StreamStorage {
161
+ #private;
162
+ constructor(baseUrl: string, adapter: FetchAdapter);
163
+ create(name: string, props?: CreateStreamProps): Promise<Stream>;
164
+ list(params?: ListStreamsParams): Promise<ListStreamsResponse>;
165
+ delete(id: string): Promise<void>;
166
+ }
167
+ //# sourceMappingURL=stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/services/stream.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAiB,MAAM,WAAW,CAAC;AAGxD;;GAEG;AACH,MAAM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