@mastra/client-js 0.1.0-alpha.6 → 0.1.0-alpha.7

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/src/example.ts ADDED
@@ -0,0 +1,34 @@
1
+ import { MastraClient } from "./client";
2
+
3
+
4
+ (async () => {
5
+ const client = new MastraClient({
6
+ baseUrl: 'http://localhost:4111',
7
+ });
8
+
9
+ try {
10
+ const agent = client.getAgent('weatherAgent');
11
+ const response = await agent.stream({
12
+ messages: [{
13
+ role: 'user',
14
+ content: 'Hello, world!',
15
+ id: '1',
16
+ createdAt: new Date(),
17
+ threadId: '1',
18
+ type: 'text',
19
+ }],
20
+ })
21
+
22
+
23
+ const reader = response?.getReader()
24
+ while (true) {
25
+ const { done, value } = await reader.read();
26
+ if (done) break;
27
+
28
+ const text = new TextDecoder().decode(value);
29
+ console.log(text);
30
+ }
31
+ } catch (error) {
32
+ console.error(error);
33
+ }
34
+ })()
package/src/index.test.ts CHANGED
@@ -7,26 +7,43 @@ global.fetch = vi.fn();
7
7
 
8
8
  describe('MastraClient Resources', () => {
9
9
  let client: MastraClient;
10
+ const clientOptions = {
11
+ baseUrl: 'http://localhost:4111',
12
+ headers: {
13
+ 'Authorization': 'Bearer test-key'
14
+ }
15
+ };
10
16
 
11
17
  // Helper to mock successful API responses
12
- const mockFetchResponse = (data: any) => {
13
- (global.fetch as any).mockResolvedValueOnce({
14
- ok: true,
15
- json: async () => data
16
- });
18
+ const mockFetchResponse = (data: any, options: { isStream?: boolean } = {}) => {
19
+ if (options.isStream) {
20
+ const stream = new ReadableStream({
21
+ start(controller) {
22
+ controller.enqueue(new TextEncoder().encode(JSON.stringify(data)));
23
+ controller.close();
24
+ }
25
+ });
26
+ (global.fetch as any).mockResolvedValueOnce({
27
+ ok: true,
28
+ headers: {
29
+ get: (name: string) => name === 'Content-Type' ? 'text/event-stream' : null
30
+ },
31
+ body: stream
32
+ });
33
+ } else {
34
+ (global.fetch as any).mockResolvedValueOnce({
35
+ ok: true,
36
+ headers: {
37
+ get: (name: string) => name === 'Content-Type' ? 'application/json' : null
38
+ },
39
+ json: async () => data
40
+ });
41
+ }
17
42
  };
18
43
 
19
44
  beforeEach(() => {
20
- // Reset mocks
21
45
  vi.clearAllMocks();
22
-
23
- // Create fresh client for each test
24
- client = new MastraClient({
25
- baseUrl: 'http://localhost:4111',
26
- headers: {
27
- 'Authorization': 'Bearer test-key'
28
- }
29
- });
46
+ client = new MastraClient(clientOptions);
30
47
  });
31
48
 
32
49
  describe('Vector Resource', () => {
@@ -48,8 +65,10 @@ describe('MastraClient Resources', () => {
48
65
  const result = await vector.details('test-index');
49
66
  expect(result).toEqual(mockResponse);
50
67
  expect(global.fetch).toHaveBeenCalledWith(
51
- `${client.baseUrl}/api/vector/test-vector/indexes/test-index`,
52
- expect.any(Object)
68
+ `${clientOptions.baseUrl}/api/vector/test-vector/indexes/test-index`,
69
+ expect.objectContaining({
70
+ headers: expect.objectContaining(clientOptions.headers)
71
+ })
53
72
  );
54
73
  });
55
74
 
@@ -58,8 +77,11 @@ describe('MastraClient Resources', () => {
58
77
  const result = await vector.delete('test-index');
59
78
  expect(result).toEqual({ success: true });
60
79
  expect(global.fetch).toHaveBeenCalledWith(
61
- `${client.baseUrl}/api/vector/test-vector/indexes/test-index`,
62
- expect.objectContaining({ method: 'DELETE' })
80
+ `${clientOptions.baseUrl}/api/vector/test-vector/indexes/test-index`,
81
+ expect.objectContaining({
82
+ method: 'DELETE',
83
+ headers: expect.objectContaining(clientOptions.headers)
84
+ })
63
85
  );
64
86
  });
65
87
 
@@ -69,8 +91,10 @@ describe('MastraClient Resources', () => {
69
91
  const result = await vector.getIndexes();
70
92
  expect(result).toEqual(mockResponse);
71
93
  expect(global.fetch).toHaveBeenCalledWith(
72
- `${client.baseUrl}/api/vector/test-vector/indexes`,
73
- expect.any(Object)
94
+ `${clientOptions.baseUrl}/api/vector/test-vector/indexes`,
95
+ expect.objectContaining({
96
+ headers: expect.objectContaining(clientOptions.headers)
97
+ })
74
98
  );
75
99
  });
76
100
 
@@ -83,9 +107,10 @@ describe('MastraClient Resources', () => {
83
107
  });
84
108
  expect(result).toEqual({ success: true });
85
109
  expect(global.fetch).toHaveBeenCalledWith(
86
- `${client.baseUrl}/api/vector/test-vector/create-index`,
110
+ `${clientOptions.baseUrl}/api/vector/test-vector/create-index`,
87
111
  expect.objectContaining({
88
112
  method: 'POST',
113
+ headers: expect.objectContaining(clientOptions.headers),
89
114
  body: JSON.stringify({
90
115
  indexName: 'test-index',
91
116
  dimension: 128,
@@ -106,9 +131,10 @@ describe('MastraClient Resources', () => {
106
131
  });
107
132
  expect(result).toEqual(mockResponse);
108
133
  expect(global.fetch).toHaveBeenCalledWith(
109
- `${client.baseUrl}/api/vector/test-vector/upsert`,
134
+ `${clientOptions.baseUrl}/api/vector/test-vector/upsert`,
110
135
  expect.objectContaining({
111
136
  method: 'POST',
137
+ headers: expect.objectContaining(clientOptions.headers),
112
138
  body: JSON.stringify({
113
139
  indexName: 'test-index',
114
140
  vectors: [[1, 2], [3, 4]],
@@ -138,9 +164,10 @@ describe('MastraClient Resources', () => {
138
164
  });
139
165
  expect(result).toEqual(mockResponse);
140
166
  expect(global.fetch).toHaveBeenCalledWith(
141
- `${client.baseUrl}/api/vector/test-vector/query`,
167
+ `${clientOptions.baseUrl}/api/vector/test-vector/query`,
142
168
  expect.objectContaining({
143
169
  method: 'POST',
170
+ headers: expect.objectContaining(clientOptions.headers),
144
171
  body: JSON.stringify({
145
172
  indexName: 'test-index',
146
173
  queryVector: [1, 2],
@@ -170,8 +197,10 @@ describe('MastraClient Resources', () => {
170
197
  const result = await client.getAgents();
171
198
  expect(result).toEqual(mockResponse);
172
199
  expect(global.fetch).toHaveBeenCalledWith(
173
- `${client.baseUrl}/api/agents`,
174
- expect.any(Object)
200
+ `${clientOptions.baseUrl}/api/agents`,
201
+ expect.objectContaining({
202
+ headers: expect.objectContaining(clientOptions.headers)
203
+ })
175
204
  );
176
205
  });
177
206
 
@@ -187,8 +216,10 @@ describe('MastraClient Resources', () => {
187
216
  const result = await agent.details();
188
217
  expect(result).toEqual(mockResponse);
189
218
  expect(global.fetch).toHaveBeenCalledWith(
190
- `${client.baseUrl}/api/agents/test-agent`,
191
- expect.any(Object)
219
+ `${clientOptions.baseUrl}/api/agents/test-agent`,
220
+ expect.objectContaining({
221
+ headers: expect.objectContaining(clientOptions.headers)
222
+ })
192
223
  );
193
224
  });
194
225
 
@@ -206,9 +237,10 @@ describe('MastraClient Resources', () => {
206
237
  });
207
238
  expect(result).toEqual(mockResponse);
208
239
  expect(global.fetch).toHaveBeenCalledWith(
209
- `${client.baseUrl}/api/agents/test-agent/generate`,
240
+ `${clientOptions.baseUrl}/api/agents/test-agent/generate`,
210
241
  expect.objectContaining({
211
242
  method: 'POST',
243
+ headers: expect.objectContaining(clientOptions.headers),
212
244
  body: JSON.stringify({
213
245
  messages: [],
214
246
  threadId: 'test-thread',
@@ -220,31 +252,29 @@ describe('MastraClient Resources', () => {
220
252
  });
221
253
 
222
254
  it('should stream responses', async () => {
223
- const mockResponse = {
224
- stream: true,
225
- chunks: ['chunk1', 'chunk2']
226
- };
227
- mockFetchResponse(mockResponse);
228
- const result = await agent.stream({
229
- messages: [],
230
- threadId: 'test-thread',
231
- resourceid: 'test-resource',
232
- output: undefined
255
+ const mockChunk = { content: 'test response' };
256
+ mockFetchResponse(mockChunk, { isStream: true });
257
+
258
+ const response = await agent.stream({
259
+ messages: [{
260
+ role: 'user',
261
+ content: 'test',
262
+ id: '1',
263
+ createdAt: new Date(),
264
+ threadId: '1',
265
+ type: 'text'
266
+ }]
233
267
  });
234
- expect(result).toEqual(mockResponse);
235
- expect(global.fetch).toHaveBeenCalledWith(
236
- `${client.baseUrl}/api/agents/test-agent/generate`,
237
- expect.objectContaining({
238
- method: 'POST',
239
- body: JSON.stringify({
240
- messages: [],
241
- threadId: 'test-thread',
242
- resourceid: 'test-resource',
243
- output: undefined,
244
- stream: true
245
- })
246
- })
247
- );
268
+
269
+ expect(response).toBeInstanceOf(ReadableStream);
270
+ const reader = response?.getReader();
271
+ expect(reader).toBeDefined();
272
+
273
+ if (reader) {
274
+ const { value, done } = await reader.read();
275
+ expect(done).toBe(false);
276
+ expect(new TextDecoder().decode(value)).toBe(JSON.stringify(mockChunk));
277
+ }
248
278
  });
249
279
 
250
280
  it('should get agent tool', async () => {
@@ -256,8 +286,10 @@ describe('MastraClient Resources', () => {
256
286
  const result = await agent.getTool('tool1');
257
287
  expect(result).toEqual(mockResponse);
258
288
  expect(global.fetch).toHaveBeenCalledWith(
259
- `${client.baseUrl}/api/agents/test-agent/tools/tool1`,
260
- expect.any(Object)
289
+ `${clientOptions.baseUrl}/api/agents/test-agent/tools/tool1`,
290
+ expect.objectContaining({
291
+ headers: expect.objectContaining(clientOptions.headers)
292
+ })
261
293
  );
262
294
  });
263
295
 
@@ -270,8 +302,10 @@ describe('MastraClient Resources', () => {
270
302
  const result = await agent.evals();
271
303
  expect(result).toEqual(mockResponse);
272
304
  expect(global.fetch).toHaveBeenCalledWith(
273
- `${client.baseUrl}/api/agents/test-agent/evals`,
274
- expect.any(Object)
305
+ `${clientOptions.baseUrl}/api/agents/test-agent/evals`,
306
+ expect.objectContaining({
307
+ headers: expect.objectContaining(clientOptions.headers)
308
+ })
275
309
  );
276
310
  });
277
311
 
@@ -284,8 +318,10 @@ describe('MastraClient Resources', () => {
284
318
  const result = await agent.liveEvals();
285
319
  expect(result).toEqual(mockResponse);
286
320
  expect(global.fetch).toHaveBeenCalledWith(
287
- `${client.baseUrl}/api/agents/test-agent/evals/live`,
288
- expect.any(Object)
321
+ `${clientOptions.baseUrl}/api/agents/test-agent/evals/live`,
322
+ expect.objectContaining({
323
+ headers: expect.objectContaining(clientOptions.headers)
324
+ })
289
325
  );
290
326
  });
291
327
  });
@@ -309,8 +345,10 @@ describe('MastraClient Resources', () => {
309
345
  const result = await memoryThread.get();
310
346
  expect(result).toEqual(mockResponse);
311
347
  expect(global.fetch).toHaveBeenCalledWith(
312
- `${client.baseUrl}/api/memory/threads/test-thread`,
313
- expect.any(Object)
348
+ `${clientOptions.baseUrl}/api/memory/threads/test-thread`,
349
+ expect.objectContaining({
350
+ headers: expect.objectContaining(clientOptions.headers)
351
+ })
314
352
  );
315
353
  });
316
354
 
@@ -329,9 +367,10 @@ describe('MastraClient Resources', () => {
329
367
  });
330
368
  expect(result).toEqual(mockResponse);
331
369
  expect(global.fetch).toHaveBeenCalledWith(
332
- `${client.baseUrl}/api/memory/threads/test-thread`,
370
+ `${clientOptions.baseUrl}/api/memory/threads/test-thread`,
333
371
  expect.objectContaining({
334
- method: 'PATCH'
372
+ method: 'PATCH',
373
+ headers: expect.objectContaining(clientOptions.headers)
335
374
  })
336
375
  );
337
376
  });
@@ -342,8 +381,11 @@ describe('MastraClient Resources', () => {
342
381
  const result = await memoryThread.delete();
343
382
  expect(result).toEqual(mockResponse);
344
383
  expect(global.fetch).toHaveBeenCalledWith(
345
- `${client.baseUrl}/api/memory/threads/test-thread`,
346
- expect.objectContaining({ method: 'DELETE' })
384
+ `${clientOptions.baseUrl}/api/memory/threads/test-thread`,
385
+ expect.objectContaining({
386
+ method: 'DELETE',
387
+ headers: expect.objectContaining(clientOptions.headers)
388
+ })
347
389
  );
348
390
  });
349
391
 
@@ -353,8 +395,10 @@ describe('MastraClient Resources', () => {
353
395
  const result = await client.getMemoryStatus();
354
396
  expect(result).toEqual(mockResponse);
355
397
  expect(global.fetch).toHaveBeenCalledWith(
356
- `${client.baseUrl}/api/memory/status`,
357
- expect.any(Object)
398
+ `${clientOptions.baseUrl}/api/memory/status`,
399
+ expect.objectContaining({
400
+ headers: expect.objectContaining(clientOptions.headers)
401
+ })
358
402
  );
359
403
  });
360
404
 
@@ -371,9 +415,10 @@ describe('MastraClient Resources', () => {
371
415
  const result = await client.saveMessageToMemory({ messages });
372
416
  expect(result).toEqual(messages);
373
417
  expect(global.fetch).toHaveBeenCalledWith(
374
- `${client.baseUrl}/api/memory/save-messages`,
418
+ `${clientOptions.baseUrl}/api/memory/save-messages`,
375
419
  expect.objectContaining({
376
420
  method: 'POST',
421
+ headers: expect.objectContaining(clientOptions.headers),
377
422
  body: JSON.stringify({ messages })
378
423
  })
379
424
  );
@@ -400,8 +445,10 @@ describe('MastraClient Resources', () => {
400
445
  const result = await tool.details();
401
446
  expect(result).toEqual(mockResponse);
402
447
  expect(global.fetch).toHaveBeenCalledWith(
403
- `${client.baseUrl}/api/tools/test-tool`,
404
- expect.any(Object)
448
+ `${clientOptions.baseUrl}/api/tools/test-tool`,
449
+ expect.objectContaining({
450
+ headers: expect.objectContaining(clientOptions.headers)
451
+ })
405
452
  );
406
453
  });
407
454
 
@@ -414,9 +461,10 @@ describe('MastraClient Resources', () => {
414
461
  const result = await tool.execute({ input: 'test' });
415
462
  expect(result).toEqual(mockResponse);
416
463
  expect(global.fetch).toHaveBeenCalledWith(
417
- `${client.baseUrl}/api/tools/test-tool/execute`,
464
+ `${clientOptions.baseUrl}/api/tools/test-tool/execute`,
418
465
  expect.objectContaining({
419
466
  method: 'POST',
467
+ headers: expect.objectContaining(clientOptions.headers),
420
468
  body: JSON.stringify({ input: 'test' })
421
469
  })
422
470
  );
@@ -444,8 +492,10 @@ describe('MastraClient Resources', () => {
444
492
  const result = await workflow.details();
445
493
  expect(result).toEqual(mockResponse);
446
494
  expect(global.fetch).toHaveBeenCalledWith(
447
- `${client.baseUrl}/api/workflows/test-workflow`,
448
- expect.any(Object)
495
+ `${clientOptions.baseUrl}/api/workflows/test-workflow`,
496
+ expect.objectContaining({
497
+ headers: expect.objectContaining(clientOptions.headers)
498
+ })
449
499
  );
450
500
  });
451
501
 
@@ -458,9 +508,10 @@ describe('MastraClient Resources', () => {
458
508
  const result = await workflow.execute({ trigger: 'test' });
459
509
  expect(result).toEqual(mockResponse);
460
510
  expect(global.fetch).toHaveBeenCalledWith(
461
- `${client.baseUrl}/api/workflows/test-workflow/execute`,
511
+ `${clientOptions.baseUrl}/api/workflows/test-workflow/execute`,
462
512
  expect.objectContaining({
463
513
  method: 'POST',
514
+ headers: expect.objectContaining(clientOptions.headers),
464
515
  body: JSON.stringify({ trigger: 'test' })
465
516
  })
466
517
  );
@@ -475,6 +526,9 @@ describe('MastraClient Resources', () => {
475
526
  .mockRejectedValueOnce(new Error('Network error'))
476
527
  .mockResolvedValueOnce({
477
528
  ok: true,
529
+ headers: {
530
+ get: () => 'application/json'
531
+ },
478
532
  json: async () => ({ success: true })
479
533
  });
480
534
 
@@ -509,6 +563,9 @@ describe('MastraClient Resources', () => {
509
563
  .mockRejectedValueOnce(new Error('Network error'))
510
564
  .mockResolvedValueOnce({
511
565
  ok: true,
566
+ headers: {
567
+ get: () => 'application/json'
568
+ },
512
569
  json: async () => ({ success: true })
513
570
  });
514
571
 
@@ -3,7 +3,7 @@ import type {
3
3
  GetAgentResponse,
4
4
  GetEvalsByAgentIdResponse,
5
5
  GetToolResponse,
6
- RequestFunction,
6
+ ClientOptions,
7
7
  StreamParams,
8
8
  } from '../types';
9
9
  import type {
@@ -13,13 +13,16 @@ import type {
13
13
  import type { JSONSchema7 } from 'json-schema';
14
14
  import { ZodSchema } from "zod";
15
15
  import { zodToJsonSchema } from 'zod-to-json-schema';
16
+ import { BaseResource } from './base';
16
17
 
17
- export class AgentTool {
18
+ export class AgentTool extends BaseResource {
18
19
  constructor(
19
- private request: RequestFunction,
20
+ options: ClientOptions,
20
21
  private agentId: string,
21
22
  private toolId: string
22
- ) { }
23
+ ) {
24
+ super(options);
25
+ }
23
26
 
24
27
  /**
25
28
  * Executes a specific tool for an agent
@@ -34,11 +37,13 @@ export class AgentTool {
34
37
  }
35
38
  }
36
39
 
37
- export class Agent {
40
+ export class Agent extends BaseResource {
38
41
  constructor(
39
- private request: RequestFunction,
42
+ options: ClientOptions,
40
43
  private agentId: string
41
- ) { }
44
+ ) {
45
+ super(options);
46
+ }
42
47
 
43
48
  /**
44
49
  * Retrieves details about the agent
@@ -70,17 +75,17 @@ export class Agent {
70
75
  * @param params - Stream parameters including prompt
71
76
  * @returns Promise containing the streamed response
72
77
  */
73
- stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: StreamParams<T>): Promise<StreamReturn<T>> {
78
+ stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: StreamParams<T>) {
74
79
  const processedParams = {
75
80
  ...params,
76
81
  output: params.output instanceof ZodSchema ? zodToJsonSchema(params.output) : params.output,
77
82
  stream: true
78
83
  };
79
84
 
80
- return this.request(`/api/agents/${this.agentId}/generate`, {
85
+ return this.request(`/api/agents/${this.agentId}/stream`, {
81
86
  method: 'POST',
82
87
  body: processedParams,
83
- });
88
+ }) as T extends undefined ? Promise<ReadableStream<Uint8Array>> : Promise<Response>;
84
89
  }
85
90
 
86
91
  /**
@@ -0,0 +1,79 @@
1
+ import type { RequestFunction, RequestOptions, ClientOptions } from '../types';
2
+
3
+ export class BaseResource {
4
+ readonly options: ClientOptions
5
+
6
+ constructor(options: ClientOptions) {
7
+ this.options = options;
8
+ }
9
+
10
+ /**
11
+ * Makes an HTTP request to the API with retries and exponential backoff
12
+ * @param path - The API endpoint path
13
+ * @param options - Optional request configuration
14
+ * @returns Promise containing the response data
15
+ */
16
+ public async request<T>(path: string, options: RequestOptions = {}): Promise<T> {
17
+ let lastError: Error | null = null;
18
+ const { baseUrl, retries = 3, backoffMs = 100, maxBackoffMs = 1000, headers = {} } = this.options;
19
+
20
+
21
+ let delay = backoffMs;
22
+
23
+
24
+ for (let attempt = 0; attempt <= retries; attempt++) {
25
+ try {
26
+ const response = await fetch(`${baseUrl}${path}`, {
27
+ ...options,
28
+ headers: {
29
+ 'Content-Type': 'application/json',
30
+ ...headers,
31
+ ...options.headers,
32
+ },
33
+ body: options.body ? JSON.stringify(options.body) : undefined,
34
+ });
35
+
36
+ if (!response.ok) {
37
+ const errorBody = await response.text();
38
+ let errorMessage = `HTTP error! status: ${response.status}`;
39
+ try {
40
+ // Try to parse as JSON for structured error messages
41
+ const errorJson = JSON.parse(errorBody);
42
+ errorMessage += ` - ${JSON.stringify(errorJson)}`;
43
+ } catch {
44
+ // If not JSON, include the raw error body if present
45
+ if (errorBody) {
46
+ errorMessage += ` - ${errorBody}`;
47
+ }
48
+ }
49
+ throw new Error(errorMessage);
50
+ }
51
+
52
+ // For streaming responses, return the stream directly
53
+ if (response.headers.get('Content-Type')?.includes('text/event-stream')) {
54
+ return response.body as T;
55
+ }
56
+
57
+ // For unknown responses, return the response as is
58
+ if (response.headers.get('Content-Type')?.includes('text/x-unknown')) {
59
+ return response as T;
60
+ }
61
+
62
+ const data = await response.json();
63
+ return data as T;
64
+ } catch (error) {
65
+ lastError = error as Error;
66
+
67
+ if (attempt === retries) {
68
+ break;
69
+ }
70
+
71
+ // Wait with exponential backoff
72
+ await new Promise(resolve => setTimeout(resolve, delay));
73
+ delay = Math.min(delay * 2, maxBackoffMs);
74
+ }
75
+ }
76
+
77
+ throw lastError || new Error('Request failed');
78
+ }
79
+ }
@@ -1,5 +1,6 @@
1
1
  export * from './agent';
2
2
  export * from './memory-thread';
3
- export * from './tool';
3
+ export * from './vector';
4
4
  export * from './workflow';
5
- export * from './vector';
5
+ export * from './tool';
6
+ export * from './base';
@@ -1,15 +1,21 @@
1
- import type { StorageThreadType } from '@mastra/core/memory';
1
+ import type { StorageThreadType } from '@mastra/core';
2
2
  import type {
3
+ CreateMemoryThreadParams,
3
4
  GetMemoryThreadMessagesResponse,
5
+ GetMemoryThreadResponse,
6
+ ClientOptions,
7
+ SaveMessageToMemoryParams,
4
8
  UpdateMemoryThreadParams,
5
- RequestFunction
6
9
  } from '../types';
10
+ import { BaseResource } from './base';
7
11
 
8
- export class MemoryThread {
12
+ export class MemoryThread extends BaseResource {
9
13
  constructor(
10
- private request: RequestFunction,
14
+ options: ClientOptions,
11
15
  private threadId: string
12
- ) { }
16
+ ) {
17
+ super(options);
18
+ }
13
19
 
14
20
  /**
15
21
  * Retrieves the memory thread details
@@ -1,10 +1,13 @@
1
- import type { GetToolResponse, RequestFunction } from '../types';
1
+ import type { GetToolResponse, ClientOptions } from '../types';
2
+ import { BaseResource } from './base';
2
3
 
3
- export class Tool {
4
+ export class Tool extends BaseResource {
4
5
  constructor(
5
- private request: RequestFunction,
6
+ options: ClientOptions,
6
7
  private toolId: string
7
- ) { }
8
+ ) {
9
+ super(options);
10
+ }
8
11
 
9
12
  /**
10
13
  * Retrieves details about the tool
@@ -3,15 +3,18 @@ import type {
3
3
  GetVectorIndexResponse,
4
4
  QueryVectorParams,
5
5
  QueryVectorResponse,
6
+ ClientOptions,
6
7
  UpsertVectorParams,
7
- RequestFunction
8
8
  } from '../types';
9
+ import { BaseResource } from './base';
9
10
 
10
- export class Vector {
11
+ export class Vector extends BaseResource {
11
12
  constructor(
12
- private request: RequestFunction,
13
+ options: ClientOptions,
13
14
  private vectorName: string
14
- ) { }
15
+ ) {
16
+ super(options);
17
+ }
15
18
 
16
19
  /**
17
20
  * Retrieves details about a specific vector index
@@ -1,10 +1,13 @@
1
- import type { GetWorkflowResponse, RequestFunction } from '../types';
1
+ import type { GetWorkflowResponse, ClientOptions } from '../types';
2
+ import { BaseResource } from './base';
2
3
 
3
- export class Workflow {
4
+ export class Workflow extends BaseResource {
4
5
  constructor(
5
- private request: RequestFunction,
6
+ options: ClientOptions,
6
7
  private workflowId: string
7
- ) { }
8
+ ) {
9
+ super(options);
10
+ }
8
11
 
9
12
  /**
10
13
  * Retrieves details about the workflow