@agentuity/runtime 0.0.43 → 0.0.44

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 (130) hide show
  1. package/AGENTS.md +11 -9
  2. package/README.md +4 -4
  3. package/dist/_context.d.ts +12 -4
  4. package/dist/_context.d.ts.map +1 -1
  5. package/dist/_server.d.ts +7 -4
  6. package/dist/_server.d.ts.map +1 -1
  7. package/dist/_services.d.ts +13 -2
  8. package/dist/_services.d.ts.map +1 -1
  9. package/dist/_util.d.ts +1 -1
  10. package/dist/_util.d.ts.map +1 -1
  11. package/dist/_waituntil.d.ts +1 -3
  12. package/dist/_waituntil.d.ts.map +1 -1
  13. package/dist/agent.d.ts +41 -14
  14. package/dist/agent.d.ts.map +1 -1
  15. package/dist/app.d.ts +90 -8
  16. package/dist/app.d.ts.map +1 -1
  17. package/dist/eval.d.ts +79 -0
  18. package/dist/eval.d.ts.map +1 -0
  19. package/dist/index.d.ts +6 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/io/email.d.ts +77 -0
  22. package/dist/io/email.d.ts.map +1 -0
  23. package/dist/logger/console.d.ts +7 -1
  24. package/dist/logger/console.d.ts.map +1 -1
  25. package/dist/logger/user.d.ts.map +1 -1
  26. package/dist/otel/config.d.ts +3 -1
  27. package/dist/otel/config.d.ts.map +1 -1
  28. package/dist/otel/console.d.ts +2 -1
  29. package/dist/otel/console.d.ts.map +1 -1
  30. package/dist/otel/exporters/index.d.ts +4 -0
  31. package/dist/otel/exporters/index.d.ts.map +1 -0
  32. package/dist/otel/exporters/jsonl-log-exporter.d.ts +36 -0
  33. package/dist/otel/exporters/jsonl-log-exporter.d.ts.map +1 -0
  34. package/dist/otel/exporters/jsonl-metric-exporter.d.ts +40 -0
  35. package/dist/otel/exporters/jsonl-metric-exporter.d.ts.map +1 -0
  36. package/dist/otel/exporters/jsonl-trace-exporter.d.ts +36 -0
  37. package/dist/otel/exporters/jsonl-trace-exporter.d.ts.map +1 -0
  38. package/dist/otel/http.d.ts.map +1 -1
  39. package/dist/otel/logger.d.ts +8 -6
  40. package/dist/otel/logger.d.ts.map +1 -1
  41. package/dist/otel/otel.d.ts +8 -2
  42. package/dist/otel/otel.d.ts.map +1 -1
  43. package/dist/router.d.ts +4 -1
  44. package/dist/router.d.ts.map +1 -1
  45. package/dist/services/evalrun/composite.d.ts +21 -0
  46. package/dist/services/evalrun/composite.d.ts.map +1 -0
  47. package/dist/services/evalrun/http.d.ts +24 -0
  48. package/dist/services/evalrun/http.d.ts.map +1 -0
  49. package/dist/services/evalrun/index.d.ts +5 -0
  50. package/dist/services/evalrun/index.d.ts.map +1 -0
  51. package/dist/services/evalrun/json.d.ts +21 -0
  52. package/dist/services/evalrun/json.d.ts.map +1 -0
  53. package/dist/services/evalrun/local.d.ts +19 -0
  54. package/dist/services/evalrun/local.d.ts.map +1 -0
  55. package/dist/services/local/_db.d.ts +4 -0
  56. package/dist/services/local/_db.d.ts.map +1 -0
  57. package/dist/services/local/_router.d.ts +3 -0
  58. package/dist/services/local/_router.d.ts.map +1 -0
  59. package/dist/services/local/_util.d.ts +18 -0
  60. package/dist/services/local/_util.d.ts.map +1 -0
  61. package/dist/services/local/index.d.ts +8 -0
  62. package/dist/services/local/index.d.ts.map +1 -0
  63. package/dist/services/local/keyvalue.d.ts +10 -0
  64. package/dist/services/local/keyvalue.d.ts.map +1 -0
  65. package/dist/services/local/objectstore.d.ts +11 -0
  66. package/dist/services/local/objectstore.d.ts.map +1 -0
  67. package/dist/services/local/stream.d.ts +10 -0
  68. package/dist/services/local/stream.d.ts.map +1 -0
  69. package/dist/services/local/vector.d.ts +13 -0
  70. package/dist/services/local/vector.d.ts.map +1 -0
  71. package/dist/services/session/composite.d.ts +21 -0
  72. package/dist/services/session/composite.d.ts.map +1 -0
  73. package/dist/services/session/http.d.ts +23 -0
  74. package/dist/services/session/http.d.ts.map +1 -0
  75. package/dist/services/session/index.d.ts +5 -0
  76. package/dist/services/session/index.d.ts.map +1 -0
  77. package/dist/services/session/json.d.ts +22 -0
  78. package/dist/services/session/json.d.ts.map +1 -0
  79. package/dist/services/session/local.d.ts +19 -0
  80. package/dist/services/session/local.d.ts.map +1 -0
  81. package/dist/session.d.ts +70 -0
  82. package/dist/session.d.ts.map +1 -0
  83. package/package.json +10 -6
  84. package/src/_config.ts +1 -1
  85. package/src/_context.ts +19 -16
  86. package/src/_server.ts +284 -42
  87. package/src/_services.ts +147 -34
  88. package/src/_util.ts +2 -3
  89. package/src/_waituntil.ts +5 -153
  90. package/src/agent.ts +667 -65
  91. package/src/app.ts +159 -13
  92. package/src/eval.ts +95 -0
  93. package/src/index.ts +6 -1
  94. package/src/io/email.ts +173 -0
  95. package/src/logger/console.ts +196 -17
  96. package/src/logger/user.ts +7 -3
  97. package/src/otel/config.ts +7 -44
  98. package/src/otel/console.ts +8 -4
  99. package/src/otel/exporters/README.md +217 -0
  100. package/src/otel/exporters/index.ts +3 -0
  101. package/src/otel/exporters/jsonl-log-exporter.ts +113 -0
  102. package/src/otel/exporters/jsonl-metric-exporter.ts +120 -0
  103. package/src/otel/exporters/jsonl-trace-exporter.ts +121 -0
  104. package/src/otel/http.ts +3 -1
  105. package/src/otel/logger.ts +87 -37
  106. package/src/otel/otel.ts +43 -22
  107. package/src/router.ts +44 -4
  108. package/src/services/evalrun/composite.ts +34 -0
  109. package/src/services/evalrun/http.ts +112 -0
  110. package/src/services/evalrun/index.ts +4 -0
  111. package/src/services/evalrun/json.ts +46 -0
  112. package/src/services/evalrun/local.ts +28 -0
  113. package/src/services/local/README.md +1576 -0
  114. package/src/services/local/_db.ts +182 -0
  115. package/src/services/local/_router.ts +86 -0
  116. package/src/services/local/_util.ts +49 -0
  117. package/src/services/local/index.ts +7 -0
  118. package/src/services/local/keyvalue.ts +118 -0
  119. package/src/services/local/objectstore.ts +152 -0
  120. package/src/services/local/stream.ts +296 -0
  121. package/src/services/local/vector.ts +264 -0
  122. package/src/services/session/composite.ts +33 -0
  123. package/src/services/session/http.ts +64 -0
  124. package/src/services/session/index.ts +4 -0
  125. package/src/services/session/json.ts +42 -0
  126. package/src/services/session/local.ts +28 -0
  127. package/src/session.ts +284 -0
  128. package/dist/_unauthenticated.d.ts +0 -26
  129. package/dist/_unauthenticated.d.ts.map +0 -1
  130. package/src/_unauthenticated.ts +0 -126
@@ -0,0 +1,28 @@
1
+ import {
2
+ type SessionEventProvider,
3
+ type SessionStartEvent,
4
+ type SessionCompleteEvent,
5
+ } from '@agentuity/core';
6
+
7
+ /**
8
+ * An implementation of the SessionEventProvider which is no-op
9
+ */
10
+ export class LocalSessionEventProvider implements SessionEventProvider {
11
+ /**
12
+ * called when the session starts
13
+ *
14
+ * @param event SessionStartEvent
15
+ */
16
+ async start(_event: SessionStartEvent): Promise<void> {
17
+ // no op
18
+ }
19
+
20
+ /**
21
+ * called when the session completes
22
+ *
23
+ * @param event SessionCompleteEvent
24
+ */
25
+ async complete(_event: SessionCompleteEvent): Promise<void> {
26
+ // no op
27
+ }
28
+ }
package/src/session.ts ADDED
@@ -0,0 +1,284 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ /** biome-ignore-all lint/suspicious/noExplicitAny: anys are great */
3
+ import type { Context } from 'hono';
4
+ import { getCookie, setCookie } from 'hono/cookie';
5
+ import { type Env, fireEvent } from './app';
6
+
7
+ export type ThreadEventName = 'destroyed';
8
+ export type SessionEventName = 'completed';
9
+
10
+ type ThreadEventCallback<T extends Thread> = (
11
+ eventName: 'destroyed',
12
+ thread: T
13
+ ) => Promise<void> | void;
14
+
15
+ type SessionEventCallback<T extends Session> = (
16
+ eventName: 'completed',
17
+ session: T
18
+ ) => Promise<void> | void;
19
+
20
+ export interface Thread {
21
+ id: string;
22
+ state: Map<string, unknown>;
23
+ addEventListener(
24
+ eventName: 'destroyed',
25
+ callback: (eventName: 'destroyed', thread: Thread) => Promise<void> | void
26
+ ): void;
27
+ removeEventListener(
28
+ eventName: 'destroyed',
29
+ callback: (eventName: 'destroyed', thread: Thread) => Promise<void> | void
30
+ ): void;
31
+ destroy(): Promise<void>;
32
+ }
33
+
34
+ export interface Session {
35
+ id: string;
36
+ thread: Thread;
37
+ state: Map<string, unknown>;
38
+ addEventListener(
39
+ eventName: 'completed',
40
+ callback: (eventName: 'completed', session: Session) => Promise<void> | void
41
+ ): void;
42
+ removeEventListener(
43
+ eventName: 'completed',
44
+ callback: (eventName: 'completed', session: Session) => Promise<void> | void
45
+ ): void;
46
+ }
47
+
48
+ export interface ThreadProvider {
49
+ initialize(): Promise<void>;
50
+ restore(ctx: Context<Env>): Promise<Thread>;
51
+ save(thread: Thread): Promise<void>;
52
+ destroy(thread: Thread): Promise<void>;
53
+ }
54
+
55
+ export interface SessionProvider {
56
+ initialize(): Promise<void>;
57
+ restore(thread: Thread, sessionId: string): Promise<Session>;
58
+ save(session: Session): Promise<void>;
59
+ }
60
+
61
+ // WeakMap to store event listeners for Thread and Session instances
62
+ const threadEventListeners = new WeakMap<
63
+ Thread,
64
+ Map<ThreadEventName, Set<ThreadEventCallback<any>>>
65
+ >();
66
+ const sessionEventListeners = new WeakMap<
67
+ Session,
68
+ Map<SessionEventName, Set<SessionEventCallback<any>>>
69
+ >();
70
+
71
+ // Helper to fire thread event listeners
72
+ async function fireThreadEvent(thread: Thread, eventName: ThreadEventName): Promise<void> {
73
+ const listeners = threadEventListeners.get(thread);
74
+ if (!listeners) return;
75
+
76
+ const callbacks = listeners.get(eventName);
77
+ if (!callbacks || callbacks.size === 0) return;
78
+
79
+ for (const callback of callbacks) {
80
+ await (callback as any)(eventName, thread);
81
+ }
82
+ }
83
+
84
+ // Helper to fire session event listeners
85
+ async function fireSessionEvent(session: Session, eventName: SessionEventName): Promise<void> {
86
+ const listeners = sessionEventListeners.get(session);
87
+ if (!listeners) return;
88
+
89
+ const callbacks = listeners.get(eventName);
90
+ if (!callbacks || callbacks.size === 0) return;
91
+
92
+ for (const callback of callbacks) {
93
+ await (callback as any)(eventName, session);
94
+ }
95
+ }
96
+
97
+ // Generate thread or session ID
98
+ export function generateId(prefix?: string): string {
99
+ const arr = new Uint8Array(16);
100
+ crypto.getRandomValues(arr);
101
+ return `${prefix}${prefix ? '_' : ''}${arr.toHex()}`;
102
+ }
103
+
104
+ export class DefaultThread implements Thread {
105
+ #lastUsed: number;
106
+ readonly id: string;
107
+ readonly state: Map<string, unknown>;
108
+ private provider: ThreadProvider;
109
+
110
+ constructor(provider: ThreadProvider, id: string) {
111
+ this.provider = provider;
112
+ this.id = id;
113
+ this.state = new Map();
114
+ this.#lastUsed = Date.now();
115
+ }
116
+
117
+ addEventListener(eventName: ThreadEventName, callback: ThreadEventCallback<any>): void {
118
+ let listeners = threadEventListeners.get(this);
119
+ if (!listeners) {
120
+ listeners = new Map();
121
+ threadEventListeners.set(this, listeners);
122
+ }
123
+ let callbacks = listeners.get(eventName);
124
+ if (!callbacks) {
125
+ callbacks = new Set();
126
+ listeners.set(eventName, callbacks);
127
+ }
128
+ callbacks.add(callback);
129
+ }
130
+
131
+ removeEventListener(eventName: ThreadEventName, callback: ThreadEventCallback<any>): void {
132
+ const listeners = threadEventListeners.get(this);
133
+ if (!listeners) return;
134
+ const callbacks = listeners.get(eventName);
135
+ if (!callbacks) return;
136
+ callbacks.delete(callback);
137
+ }
138
+
139
+ async fireEvent(eventName: ThreadEventName): Promise<void> {
140
+ await fireThreadEvent(this, eventName);
141
+ }
142
+
143
+ async destroy(): Promise<void> {
144
+ this.provider.destroy(this);
145
+ }
146
+
147
+ touch() {
148
+ this.#lastUsed = Date.now();
149
+ }
150
+
151
+ expired() {
152
+ return Date.now() - this.#lastUsed >= 3.6e6; // 1 hour
153
+ }
154
+ }
155
+
156
+ export class DefaultSession implements Session {
157
+ readonly id: string;
158
+ readonly thread: Thread;
159
+ readonly state: Map<string, unknown>;
160
+
161
+ constructor(thread: Thread, id: string) {
162
+ this.id = id;
163
+ this.thread = thread;
164
+ this.state = new Map();
165
+ }
166
+
167
+ addEventListener(eventName: SessionEventName, callback: SessionEventCallback<any>): void {
168
+ let listeners = sessionEventListeners.get(this);
169
+ if (!listeners) {
170
+ listeners = new Map();
171
+ sessionEventListeners.set(this, listeners);
172
+ }
173
+ let callbacks = listeners.get(eventName);
174
+ if (!callbacks) {
175
+ callbacks = new Set();
176
+ listeners.set(eventName, callbacks);
177
+ }
178
+ callbacks.add(callback);
179
+ }
180
+
181
+ removeEventListener(eventName: SessionEventName, callback: SessionEventCallback<any>): void {
182
+ const listeners = sessionEventListeners.get(this);
183
+ if (!listeners) return;
184
+ const callbacks = listeners.get(eventName);
185
+ if (!callbacks) return;
186
+ callbacks.delete(callback);
187
+ }
188
+
189
+ async fireEvent(eventName: SessionEventName): Promise<void> {
190
+ await fireSessionEvent(this, eventName);
191
+ }
192
+ }
193
+
194
+ export class DefaultThreadProvider implements ThreadProvider {
195
+ private threads = new Map<string, DefaultThread>();
196
+
197
+ async initialize(): Promise<void> {
198
+ setInterval(() => {
199
+ for (const [, thread] of this.threads) {
200
+ if (thread.expired()) {
201
+ void (async () => {
202
+ try {
203
+ await this.destroy(thread);
204
+ } catch (err) {
205
+ console.error('Failed to destroy expired thread', err);
206
+ }
207
+ })();
208
+ }
209
+ }
210
+ }, 60_000).unref();
211
+ }
212
+
213
+ async restore(ctx: Context<Env>): Promise<Thread> {
214
+ const cookie = getCookie(ctx);
215
+ let threadId: string | undefined;
216
+
217
+ if (cookie.atid?.startsWith('thrd_')) {
218
+ threadId = cookie.atid;
219
+ }
220
+
221
+ threadId = threadId || generateId('thrd');
222
+
223
+ if (threadId) {
224
+ setCookie(ctx, 'atid', threadId);
225
+ const existing = this.threads.get(threadId);
226
+ if (existing) {
227
+ return existing;
228
+ }
229
+ }
230
+
231
+ const thread = new DefaultThread(this, threadId);
232
+ this.threads.set(thread.id, thread);
233
+ await fireEvent('thread.created', thread);
234
+ return thread;
235
+ }
236
+
237
+ async save(thread: Thread): Promise<void> {
238
+ if (thread instanceof DefaultThread) {
239
+ thread.touch();
240
+ }
241
+ }
242
+
243
+ async destroy(thread: Thread): Promise<void> {
244
+ if (thread instanceof DefaultThread) {
245
+ try {
246
+ await thread.fireEvent('destroyed');
247
+ await fireEvent('thread.destroyed', thread);
248
+ } finally {
249
+ this.threads.delete(thread.id);
250
+ threadEventListeners.delete(thread);
251
+ }
252
+ }
253
+ }
254
+ }
255
+
256
+ export class DefaultSessionProvider implements SessionProvider {
257
+ private sessions = new Map<string, DefaultSession>();
258
+
259
+ async initialize(): Promise<void> {
260
+ // No initialization needed for in-memory provider
261
+ }
262
+
263
+ async restore(thread: Thread, sessionId: string): Promise<Session> {
264
+ let session = this.sessions.get(sessionId);
265
+ if (!session) {
266
+ session = new DefaultSession(thread, sessionId);
267
+ this.sessions.set(sessionId, session);
268
+ await fireEvent('session.started', session);
269
+ }
270
+ return session;
271
+ }
272
+
273
+ async save(session: Session): Promise<void> {
274
+ if (session instanceof DefaultSession) {
275
+ try {
276
+ await session.fireEvent('completed');
277
+ await fireEvent('session.completed', session);
278
+ } finally {
279
+ this.sessions.delete(session.id);
280
+ sessionEventListeners.delete(session);
281
+ }
282
+ }
283
+ }
284
+ }
@@ -1,26 +0,0 @@
1
- import type { KeyValueStorage, ObjectStorage, StreamStorage, VectorStorage, DataResult, KeyValueStorageSetParams, ObjectResult, ObjectStorePutParams, CreatePublicURLParams, Stream, CreateStreamProps, ListStreamsParams, ListStreamsResponse, VectorUpsertParams, VectorUpsertResult, VectorResult, VectorSearchResultWithDocument, VectorSearchParams, VectorSearchResult } from '@agentuity/core';
2
- export declare class UnauthenticatedKeyValueStorage implements KeyValueStorage {
3
- get<T>(_name: string, _key: string): Promise<DataResult<T>>;
4
- set<T = unknown>(_name: string, _key: string, _value: T, _params?: KeyValueStorageSetParams): Promise<void>;
5
- delete(_name: string, _key: string): Promise<void>;
6
- }
7
- export declare class UnauthenticatedObjectStorage implements ObjectStorage {
8
- get(_bucket: string, _key: string): Promise<ObjectResult>;
9
- put(_bucket: string, _key: string, _data: Uint8Array | ArrayBuffer | ReadableStream, _params?: ObjectStorePutParams): Promise<void>;
10
- delete(_bucket: string, _key: string): Promise<boolean>;
11
- createPublicURL(_bucket: string, _key: string, _params?: CreatePublicURLParams): Promise<string>;
12
- }
13
- export declare class UnauthenticatedStreamStorage implements StreamStorage {
14
- create(_name: string, _props?: CreateStreamProps): Promise<Stream>;
15
- list(_params?: ListStreamsParams): Promise<ListStreamsResponse>;
16
- delete(_id: string): Promise<void>;
17
- }
18
- export declare class UnauthenticatedVectorStorage implements VectorStorage {
19
- upsert(_name: string, ..._documents: VectorUpsertParams[]): Promise<VectorUpsertResult[]>;
20
- get<T extends Record<string, unknown> = Record<string, unknown>>(_name: string, _key: string): Promise<VectorResult<T>>;
21
- getMany<T extends Record<string, unknown> = Record<string, unknown>>(_name: string, ..._keys: string[]): Promise<Map<string, VectorSearchResultWithDocument<T>>>;
22
- search<T extends Record<string, unknown> = Record<string, unknown>>(_name: string, _params: VectorSearchParams<T>): Promise<VectorSearchResult<T>[]>;
23
- delete(_name: string, ..._keys: string[]): Promise<number>;
24
- exists(_name: string): Promise<boolean>;
25
- }
26
- //# sourceMappingURL=_unauthenticated.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_unauthenticated.d.ts","sourceRoot":"","sources":["../src/_unauthenticated.ts"],"names":[],"mappings":"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"}
@@ -1,126 +0,0 @@
1
- import type {
2
- KeyValueStorage,
3
- ObjectStorage,
4
- StreamStorage,
5
- VectorStorage,
6
- DataResult,
7
- KeyValueStorageSetParams,
8
- ObjectResult,
9
- ObjectStorePutParams,
10
- CreatePublicURLParams,
11
- Stream,
12
- CreateStreamProps,
13
- ListStreamsParams,
14
- ListStreamsResponse,
15
- VectorUpsertParams,
16
- VectorUpsertResult,
17
- VectorResult,
18
- VectorSearchResultWithDocument,
19
- VectorSearchParams,
20
- VectorSearchResult,
21
- } from '@agentuity/core';
22
-
23
- const UNAUTHENTICATED_ERROR =
24
- 'You must authenticate to use Agentuity services. Set the AGENTUITY_SDK_KEY environment variable or provide custom service implementations in your app config.';
25
-
26
- class UnauthenticatedError extends Error {
27
- constructor() {
28
- super(UNAUTHENTICATED_ERROR);
29
- this.name = 'UnauthenticatedError';
30
- }
31
- }
32
-
33
- export class UnauthenticatedKeyValueStorage implements KeyValueStorage {
34
- async get<T>(_name: string, _key: string): Promise<DataResult<T>> {
35
- throw new UnauthenticatedError();
36
- }
37
-
38
- async set<T = unknown>(
39
- _name: string,
40
- _key: string,
41
- _value: T,
42
- _params?: KeyValueStorageSetParams
43
- ): Promise<void> {
44
- throw new UnauthenticatedError();
45
- }
46
-
47
- async delete(_name: string, _key: string): Promise<void> {
48
- throw new UnauthenticatedError();
49
- }
50
- }
51
-
52
- export class UnauthenticatedObjectStorage implements ObjectStorage {
53
- async get(_bucket: string, _key: string): Promise<ObjectResult> {
54
- throw new UnauthenticatedError();
55
- }
56
-
57
- async put(
58
- _bucket: string,
59
- _key: string,
60
- _data: Uint8Array | ArrayBuffer | ReadableStream,
61
- _params?: ObjectStorePutParams
62
- ): Promise<void> {
63
- throw new UnauthenticatedError();
64
- }
65
-
66
- async delete(_bucket: string, _key: string): Promise<boolean> {
67
- throw new UnauthenticatedError();
68
- }
69
-
70
- async createPublicURL(
71
- _bucket: string,
72
- _key: string,
73
- _params?: CreatePublicURLParams
74
- ): Promise<string> {
75
- throw new UnauthenticatedError();
76
- }
77
- }
78
-
79
- export class UnauthenticatedStreamStorage implements StreamStorage {
80
- async create(_name: string, _props?: CreateStreamProps): Promise<Stream> {
81
- throw new UnauthenticatedError();
82
- }
83
-
84
- async list(_params?: ListStreamsParams): Promise<ListStreamsResponse> {
85
- throw new UnauthenticatedError();
86
- }
87
-
88
- async delete(_id: string): Promise<void> {
89
- throw new UnauthenticatedError();
90
- }
91
- }
92
-
93
- export class UnauthenticatedVectorStorage implements VectorStorage {
94
- async upsert(_name: string, ..._documents: VectorUpsertParams[]): Promise<VectorUpsertResult[]> {
95
- throw new UnauthenticatedError();
96
- }
97
-
98
- async get<T extends Record<string, unknown> = Record<string, unknown>>(
99
- _name: string,
100
- _key: string
101
- ): Promise<VectorResult<T>> {
102
- throw new UnauthenticatedError();
103
- }
104
-
105
- async getMany<T extends Record<string, unknown> = Record<string, unknown>>(
106
- _name: string,
107
- ..._keys: string[]
108
- ): Promise<Map<string, VectorSearchResultWithDocument<T>>> {
109
- throw new UnauthenticatedError();
110
- }
111
-
112
- async search<T extends Record<string, unknown> = Record<string, unknown>>(
113
- _name: string,
114
- _params: VectorSearchParams<T>
115
- ): Promise<VectorSearchResult<T>[]> {
116
- throw new UnauthenticatedError();
117
- }
118
-
119
- async delete(_name: string, ..._keys: string[]): Promise<number> {
120
- throw new UnauthenticatedError();
121
- }
122
-
123
- async exists(_name: string): Promise<boolean> {
124
- throw new UnauthenticatedError();
125
- }
126
- }