@mastra/client-js 0.0.0-a2a-20250421213654 → 0.0.0-add-libsql-changeset-20250910154739

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 (72) hide show
  1. package/CHANGELOG.md +1915 -2
  2. package/LICENSE.md +11 -42
  3. package/README.md +7 -4
  4. package/dist/client.d.ts +280 -0
  5. package/dist/client.d.ts.map +1 -0
  6. package/dist/example.d.ts +2 -0
  7. package/dist/example.d.ts.map +1 -0
  8. package/dist/index.cjs +2653 -199
  9. package/dist/index.cjs.map +1 -0
  10. package/dist/index.d.ts +4 -733
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +2605 -153
  13. package/dist/index.js.map +1 -0
  14. package/dist/resources/a2a.d.ts +41 -0
  15. package/dist/resources/a2a.d.ts.map +1 -0
  16. package/dist/resources/agent-builder.d.ts +161 -0
  17. package/dist/resources/agent-builder.d.ts.map +1 -0
  18. package/dist/resources/agent.d.ts +155 -0
  19. package/dist/resources/agent.d.ts.map +1 -0
  20. package/dist/resources/base.d.ts +13 -0
  21. package/dist/resources/base.d.ts.map +1 -0
  22. package/dist/resources/index.d.ts +13 -0
  23. package/dist/resources/index.d.ts.map +1 -0
  24. package/dist/resources/legacy-workflow.d.ts +87 -0
  25. package/dist/resources/legacy-workflow.d.ts.map +1 -0
  26. package/dist/resources/mcp-tool.d.ts +27 -0
  27. package/dist/resources/mcp-tool.d.ts.map +1 -0
  28. package/dist/resources/memory-thread.d.ts +53 -0
  29. package/dist/resources/memory-thread.d.ts.map +1 -0
  30. package/dist/resources/network-memory-thread.d.ts +47 -0
  31. package/dist/resources/network-memory-thread.d.ts.map +1 -0
  32. package/dist/resources/network.d.ts +30 -0
  33. package/dist/resources/network.d.ts.map +1 -0
  34. package/dist/resources/observability.d.ts +19 -0
  35. package/dist/resources/observability.d.ts.map +1 -0
  36. package/dist/resources/tool.d.ts +23 -0
  37. package/dist/resources/tool.d.ts.map +1 -0
  38. package/dist/resources/vNextNetwork.d.ts +42 -0
  39. package/dist/resources/vNextNetwork.d.ts.map +1 -0
  40. package/dist/resources/vector.d.ts +48 -0
  41. package/dist/resources/vector.d.ts.map +1 -0
  42. package/dist/resources/workflow.d.ts +169 -0
  43. package/dist/resources/workflow.d.ts.map +1 -0
  44. package/dist/types.d.ts +462 -0
  45. package/dist/types.d.ts.map +1 -0
  46. package/dist/utils/index.d.ts +3 -0
  47. package/dist/utils/index.d.ts.map +1 -0
  48. package/dist/utils/process-client-tools.d.ts +3 -0
  49. package/dist/utils/process-client-tools.d.ts.map +1 -0
  50. package/dist/utils/process-mastra-stream.d.ts +7 -0
  51. package/dist/utils/process-mastra-stream.d.ts.map +1 -0
  52. package/dist/utils/zod-to-json-schema.d.ts +3 -0
  53. package/dist/utils/zod-to-json-schema.d.ts.map +1 -0
  54. package/package.json +41 -18
  55. package/dist/index.d.cts +0 -733
  56. package/eslint.config.js +0 -6
  57. package/src/client.ts +0 -230
  58. package/src/example.ts +0 -65
  59. package/src/index.test.ts +0 -710
  60. package/src/index.ts +0 -2
  61. package/src/resources/a2a.ts +0 -99
  62. package/src/resources/agent.ts +0 -205
  63. package/src/resources/base.ts +0 -70
  64. package/src/resources/index.ts +0 -8
  65. package/src/resources/memory-thread.ts +0 -60
  66. package/src/resources/network.ts +0 -92
  67. package/src/resources/tool.ts +0 -32
  68. package/src/resources/vector.ts +0 -83
  69. package/src/resources/workflow.ts +0 -215
  70. package/src/types.ts +0 -344
  71. package/tsconfig.json +0 -5
  72. package/vitest.config.js +0 -8
@@ -1,99 +0,0 @@
1
- import type {
2
- A2AMessage,
3
- A2ARequest,
4
- AgentCard,
5
- CancelTaskRequest,
6
- GetTaskRequest,
7
- JSONRPCResponse,
8
- SendTaskRequest,
9
- Task,
10
- } from '../types';
11
- import { BaseResource } from './base';
12
-
13
- /**
14
- * A2A Protocol resource for agent-to-agent communication
15
- */
16
- export class A2A extends BaseResource {
17
- /**
18
- * Sends an A2A protocol request to the server
19
- * @param request - The A2A protocol request
20
- * @returns Promise containing the A2A protocol response
21
- */
22
- public sendRequest(request: A2ARequest): Promise<JSONRPCResponse> {
23
- return this.request('/api/a2a', {
24
- method: 'POST',
25
- body: request,
26
- });
27
- }
28
-
29
- /**
30
- * Sends a task to an agent using the A2A protocol
31
- * @param params - Parameters for sending the task
32
- * @returns Promise containing the task
33
- */
34
- public sendTask(params: { id: string; message: A2AMessage; sessionId?: string }): Promise<Task> {
35
- const request: SendTaskRequest = {
36
- jsonrpc: '2.0',
37
- id: `send-${Date.now()}`,
38
- method: 'tasks/send',
39
- params,
40
- };
41
-
42
- return this.sendRequest(request).then(response => {
43
- if ('error' in response) {
44
- throw new Error(response.error.message);
45
- }
46
- return response.result as Task;
47
- });
48
- }
49
-
50
- /**
51
- * Gets a task by ID using the A2A protocol
52
- * @param params - Parameters for getting the task
53
- * @returns Promise containing the task
54
- */
55
- public getTask(params: { id: string; historyLength?: number }): Promise<Task> {
56
- const request: GetTaskRequest = {
57
- jsonrpc: '2.0',
58
- id: `get-${Date.now()}`,
59
- method: 'tasks/get',
60
- params,
61
- };
62
-
63
- return this.sendRequest(request).then(response => {
64
- if ('error' in response) {
65
- throw new Error(response.error.message);
66
- }
67
- return response.result as Task;
68
- });
69
- }
70
-
71
- /**
72
- * Cancels a task by ID using the A2A protocol
73
- * @param params - Parameters for canceling the task
74
- * @returns Promise containing the task
75
- */
76
- public cancelTask(params: { id: string }): Promise<Task> {
77
- const request: CancelTaskRequest = {
78
- jsonrpc: '2.0',
79
- id: `cancel-${Date.now()}`,
80
- method: 'tasks/cancel',
81
- params,
82
- };
83
-
84
- return this.sendRequest(request).then(response => {
85
- if ('error' in response) {
86
- throw new Error(response.error.message);
87
- }
88
- return response.result as Task;
89
- });
90
- }
91
-
92
- /**
93
- * Gets the agent card for the A2A protocol
94
- * @returns Promise containing the agent card
95
- */
96
- public getAgentCard(): Promise<AgentCard> {
97
- return this.request('/api/a2a/agent-card');
98
- }
99
- }
@@ -1,205 +0,0 @@
1
- import type { GenerateReturn } from '@mastra/core';
2
- import type { JSONSchema7 } from 'json-schema';
3
- import { ZodSchema } from 'zod';
4
- import { zodToJsonSchema } from 'zod-to-json-schema';
5
- import { processDataStream } from '@ai-sdk/ui-utils';
6
-
7
- import type {
8
- GenerateParams,
9
- GetAgentResponse,
10
- GetEvalsByAgentIdResponse,
11
- GetToolResponse,
12
- ClientOptions,
13
- StreamParams,
14
- } from '../types';
15
-
16
- import { BaseResource } from './base';
17
-
18
- export class AgentTool extends BaseResource {
19
- constructor(
20
- options: ClientOptions,
21
- private agentId: string,
22
- private toolId: string,
23
- ) {
24
- super(options);
25
- }
26
-
27
- /**
28
- * Executes a specific tool for an agent
29
- * @param params - Parameters required for tool execution
30
- * @returns Promise containing tool execution results
31
- */
32
- /** @deprecated use CreateRun/startRun */
33
- execute(params: { data: any }): Promise<any> {
34
- return this.request(`/api/agents/${this.agentId}/tools/${this.toolId}/execute`, {
35
- method: 'POST',
36
- body: params,
37
- });
38
- }
39
- }
40
-
41
- export class AgentVoice extends BaseResource {
42
- constructor(
43
- options: ClientOptions,
44
- private agentId: string,
45
- ) {
46
- super(options);
47
- this.agentId = agentId;
48
- }
49
-
50
- /**
51
- * Convert text to speech using the agent's voice provider
52
- * @param text - Text to convert to speech
53
- * @param options - Optional provider-specific options for speech generation
54
- * @returns Promise containing the audio data
55
- */
56
- async speak(text: string, options?: { speaker?: string; [key: string]: any }): Promise<Response> {
57
- return this.request<Response>(`/api/agents/${this.agentId}/voice/speak`, {
58
- method: 'POST',
59
- headers: {
60
- 'Content-Type': 'application/json',
61
- },
62
- body: { input: text, options },
63
- stream: true,
64
- });
65
- }
66
-
67
- /**
68
- * Convert speech to text using the agent's voice provider
69
- * @param audio - Audio data to transcribe
70
- * @param options - Optional provider-specific options
71
- * @returns Promise containing the transcribed text
72
- */
73
- listen(audio: Blob, options?: Record<string, any>): Promise<Response> {
74
- const formData = new FormData();
75
- formData.append('audio', audio);
76
-
77
- if (options) {
78
- formData.append('options', JSON.stringify(options));
79
- }
80
-
81
- return this.request(`/api/agents/${this.agentId}/voice/listen`, {
82
- method: 'POST',
83
- body: formData,
84
- });
85
- }
86
-
87
- /**
88
- * Get available speakers for the agent's voice provider
89
- * @returns Promise containing list of available speakers
90
- */
91
- getSpeakers(): Promise<Array<{ voiceId: string; [key: string]: any }>> {
92
- return this.request(`/api/agents/${this.agentId}/voice/speakers`);
93
- }
94
- }
95
-
96
- export class Agent extends BaseResource {
97
- public readonly voice: AgentVoice;
98
-
99
- constructor(
100
- options: ClientOptions,
101
- private agentId: string,
102
- ) {
103
- super(options);
104
- this.voice = new AgentVoice(options, this.agentId);
105
- }
106
-
107
- /**
108
- * Retrieves details about the agent
109
- * @returns Promise containing agent details including model and instructions
110
- */
111
- details(): Promise<GetAgentResponse> {
112
- return this.request(`/api/agents/${this.agentId}`);
113
- }
114
-
115
- /**
116
- * Generates a response from the agent
117
- * @param params - Generation parameters including prompt
118
- * @returns Promise containing the generated response
119
- */
120
- generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(
121
- params: GenerateParams<T>,
122
- ): Promise<GenerateReturn<T>> {
123
- const processedParams = {
124
- ...params,
125
- output: params.output instanceof ZodSchema ? zodToJsonSchema(params.output) : params.output,
126
- experimental_output:
127
- params.experimental_output instanceof ZodSchema
128
- ? zodToJsonSchema(params.experimental_output)
129
- : params.experimental_output,
130
- };
131
-
132
- return this.request(`/api/agents/${this.agentId}/generate`, {
133
- method: 'POST',
134
- body: processedParams,
135
- });
136
- }
137
-
138
- /**
139
- * Streams a response from the agent
140
- * @param params - Stream parameters including prompt
141
- * @returns Promise containing the enhanced Response object with processDataStream method
142
- */
143
- async stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(
144
- params: StreamParams<T>,
145
- ): Promise<
146
- Response & {
147
- processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
148
- }
149
- > {
150
- const processedParams = {
151
- ...params,
152
- output: params.output instanceof ZodSchema ? zodToJsonSchema(params.output) : params.output,
153
- experimental_output:
154
- params.experimental_output instanceof ZodSchema
155
- ? zodToJsonSchema(params.experimental_output)
156
- : params.experimental_output,
157
- };
158
-
159
- const response: Response & {
160
- processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
161
- } = await this.request(`/api/agents/${this.agentId}/stream`, {
162
- method: 'POST',
163
- body: processedParams,
164
- stream: true,
165
- });
166
-
167
- if (!response.body) {
168
- throw new Error('No response body');
169
- }
170
-
171
- response.processDataStream = async (options = {}) => {
172
- await processDataStream({
173
- stream: response.body as ReadableStream<Uint8Array>,
174
- ...options,
175
- });
176
- };
177
-
178
- return response;
179
- }
180
-
181
- /**
182
- * Gets details about a specific tool available to the agent
183
- * @param toolId - ID of the tool to retrieve
184
- * @returns Promise containing tool details
185
- */
186
- getTool(toolId: string): Promise<GetToolResponse> {
187
- return this.request(`/api/agents/${this.agentId}/tools/${toolId}`);
188
- }
189
-
190
- /**
191
- * Retrieves evaluation results for the agent
192
- * @returns Promise containing agent evaluations
193
- */
194
- evals(): Promise<GetEvalsByAgentIdResponse> {
195
- return this.request(`/api/agents/${this.agentId}/evals/ci`);
196
- }
197
-
198
- /**
199
- * Retrieves live evaluation results for the agent
200
- * @returns Promise containing live agent evaluations
201
- */
202
- liveEvals(): Promise<GetEvalsByAgentIdResponse> {
203
- return this.request(`/api/agents/${this.agentId}/evals/live`);
204
- }
205
- }
@@ -1,70 +0,0 @@
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
- let delay = backoffMs;
21
-
22
- for (let attempt = 0; attempt <= retries; attempt++) {
23
- try {
24
- const response = await fetch(`${baseUrl}${path}`, {
25
- ...options,
26
- headers: {
27
- ...headers,
28
- ...options.headers,
29
- // TODO: Bring this back once we figure out what we/users need to do to make this work with cross-origin requests
30
- // 'x-mastra-client-type': 'js',
31
- },
32
- body:
33
- options.body instanceof FormData ? options.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
- const errorJson = JSON.parse(errorBody);
41
- errorMessage += ` - ${JSON.stringify(errorJson)}`;
42
- } catch {
43
- if (errorBody) {
44
- errorMessage += ` - ${errorBody}`;
45
- }
46
- }
47
- throw new Error(errorMessage);
48
- }
49
-
50
- if (options.stream) {
51
- return response as unknown as T;
52
- }
53
-
54
- const data = await response.json();
55
- return data as T;
56
- } catch (error) {
57
- lastError = error as Error;
58
-
59
- if (attempt === retries) {
60
- break;
61
- }
62
-
63
- await new Promise(resolve => setTimeout(resolve, delay));
64
- delay = Math.min(delay * 2, maxBackoffMs);
65
- }
66
- }
67
-
68
- throw lastError || new Error('Request failed');
69
- }
70
- }
@@ -1,8 +0,0 @@
1
- export * from './agent';
2
- export * from './network';
3
- export * from './memory-thread';
4
- export * from './vector';
5
- export * from './workflow';
6
- export * from './tool';
7
- export * from './base';
8
- export * from './a2a';
@@ -1,60 +0,0 @@
1
- import type { StorageThreadType } from '@mastra/core';
2
-
3
- import type {
4
- CreateMemoryThreadParams,
5
- GetMemoryThreadMessagesResponse,
6
- GetMemoryThreadResponse,
7
- ClientOptions,
8
- SaveMessageToMemoryParams,
9
- UpdateMemoryThreadParams,
10
- } from '../types';
11
-
12
- import { BaseResource } from './base';
13
-
14
- export class MemoryThread extends BaseResource {
15
- constructor(
16
- options: ClientOptions,
17
- private threadId: string,
18
- private agentId: string,
19
- ) {
20
- super(options);
21
- }
22
-
23
- /**
24
- * Retrieves the memory thread details
25
- * @returns Promise containing thread details including title and metadata
26
- */
27
- get(): Promise<StorageThreadType> {
28
- return this.request(`/api/memory/threads/${this.threadId}?agentId=${this.agentId}`);
29
- }
30
-
31
- /**
32
- * Updates the memory thread properties
33
- * @param params - Update parameters including title and metadata
34
- * @returns Promise containing updated thread details
35
- */
36
- update(params: UpdateMemoryThreadParams): Promise<StorageThreadType> {
37
- return this.request(`/api/memory/threads/${this.threadId}?agentId=${this.agentId}`, {
38
- method: 'PATCH',
39
- body: params,
40
- });
41
- }
42
-
43
- /**
44
- * Deletes the memory thread
45
- * @returns Promise containing deletion result
46
- */
47
- delete(): Promise<{ result: string }> {
48
- return this.request(`/api/memory/threads/${this.threadId}?agentId=${this.agentId}`, {
49
- method: 'DELETE',
50
- });
51
- }
52
-
53
- /**
54
- * Retrieves messages associated with the thread
55
- * @returns Promise containing thread messages and UI messages
56
- */
57
- getMessages(): Promise<GetMemoryThreadMessagesResponse> {
58
- return this.request(`/api/memory/threads/${this.threadId}/messages?agentId=${this.agentId}`);
59
- }
60
- }
@@ -1,92 +0,0 @@
1
- import type { GenerateReturn } from '@mastra/core';
2
- import type { JSONSchema7 } from 'json-schema';
3
- import { ZodSchema } from 'zod';
4
- import { zodToJsonSchema } from 'zod-to-json-schema';
5
-
6
- import type { GenerateParams, ClientOptions, StreamParams, GetNetworkResponse } from '../types';
7
-
8
- import { BaseResource } from './base';
9
- import { processDataStream } from '@ai-sdk/ui-utils';
10
-
11
- export class Network extends BaseResource {
12
- constructor(
13
- options: ClientOptions,
14
- private networkId: string,
15
- ) {
16
- super(options);
17
- }
18
-
19
- /**
20
- * Retrieves details about the network
21
- * @returns Promise containing network details
22
- */
23
- details(): Promise<GetNetworkResponse> {
24
- return this.request(`/api/networks/${this.networkId}`);
25
- }
26
-
27
- /**
28
- * Generates a response from the agent
29
- * @param params - Generation parameters including prompt
30
- * @returns Promise containing the generated response
31
- */
32
- generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(
33
- params: GenerateParams<T>,
34
- ): Promise<GenerateReturn<T>> {
35
- const processedParams = {
36
- ...params,
37
- output: params.output instanceof ZodSchema ? zodToJsonSchema(params.output) : params.output,
38
- experimental_output:
39
- params.experimental_output instanceof ZodSchema
40
- ? zodToJsonSchema(params.experimental_output)
41
- : params.experimental_output,
42
- };
43
-
44
- return this.request(`/api/networks/${this.networkId}/generate`, {
45
- method: 'POST',
46
- body: processedParams,
47
- });
48
- }
49
-
50
- /**
51
- * Streams a response from the agent
52
- * @param params - Stream parameters including prompt
53
- * @returns Promise containing the enhanced Response object with processDataStream method
54
- */
55
- async stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(
56
- params: StreamParams<T>,
57
- ): Promise<
58
- Response & {
59
- processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
60
- }
61
- > {
62
- const processedParams = {
63
- ...params,
64
- output: params.output instanceof ZodSchema ? zodToJsonSchema(params.output) : params.output,
65
- experimental_output:
66
- params.experimental_output instanceof ZodSchema
67
- ? zodToJsonSchema(params.experimental_output)
68
- : params.experimental_output,
69
- };
70
-
71
- const response: Response & {
72
- processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
73
- } = await this.request(`/api/networks/${this.networkId}/stream`, {
74
- method: 'POST',
75
- body: processedParams,
76
- stream: true,
77
- });
78
-
79
- if (!response.body) {
80
- throw new Error('No response body');
81
- }
82
-
83
- response.processDataStream = async (options = {}) => {
84
- await processDataStream({
85
- stream: response.body as ReadableStream<Uint8Array>,
86
- ...options,
87
- });
88
- };
89
-
90
- return response;
91
- }
92
- }
@@ -1,32 +0,0 @@
1
- import type { GetToolResponse, ClientOptions } from '../types';
2
-
3
- import { BaseResource } from './base';
4
-
5
- export class Tool extends BaseResource {
6
- constructor(
7
- options: ClientOptions,
8
- private toolId: string,
9
- ) {
10
- super(options);
11
- }
12
-
13
- /**
14
- * Retrieves details about the tool
15
- * @returns Promise containing tool details including description and schemas
16
- */
17
- details(): Promise<GetToolResponse> {
18
- return this.request(`/api/tools/${this.toolId}`);
19
- }
20
-
21
- /**
22
- * Executes the tool with the provided parameters
23
- * @param params - Parameters required for tool execution
24
- * @returns Promise containing the tool execution results
25
- */
26
- execute(params: { data: any }): Promise<any> {
27
- return this.request(`/api/tools/${this.toolId}/execute`, {
28
- method: 'POST',
29
- body: params,
30
- });
31
- }
32
- }
@@ -1,83 +0,0 @@
1
- import type {
2
- CreateIndexParams,
3
- GetVectorIndexResponse,
4
- QueryVectorParams,
5
- QueryVectorResponse,
6
- ClientOptions,
7
- UpsertVectorParams,
8
- } from '../types';
9
-
10
- import { BaseResource } from './base';
11
-
12
- export class Vector extends BaseResource {
13
- constructor(
14
- options: ClientOptions,
15
- private vectorName: string,
16
- ) {
17
- super(options);
18
- }
19
-
20
- /**
21
- * Retrieves details about a specific vector index
22
- * @param indexName - Name of the index to get details for
23
- * @returns Promise containing vector index details
24
- */
25
- details(indexName: string): Promise<GetVectorIndexResponse> {
26
- return this.request(`/api/vector/${this.vectorName}/indexes/${indexName}`);
27
- }
28
-
29
- /**
30
- * Deletes a vector index
31
- * @param indexName - Name of the index to delete
32
- * @returns Promise indicating deletion success
33
- */
34
- delete(indexName: string): Promise<{ success: boolean }> {
35
- return this.request(`/api/vector/${this.vectorName}/indexes/${indexName}`, {
36
- method: 'DELETE',
37
- });
38
- }
39
-
40
- /**
41
- * Retrieves a list of all available indexes
42
- * @returns Promise containing array of index names
43
- */
44
- getIndexes(): Promise<{ indexes: string[] }> {
45
- return this.request(`/api/vector/${this.vectorName}/indexes`);
46
- }
47
-
48
- /**
49
- * Creates a new vector index
50
- * @param params - Parameters for index creation including dimension and metric
51
- * @returns Promise indicating creation success
52
- */
53
- createIndex(params: CreateIndexParams): Promise<{ success: boolean }> {
54
- return this.request(`/api/vector/${this.vectorName}/create-index`, {
55
- method: 'POST',
56
- body: params,
57
- });
58
- }
59
-
60
- /**
61
- * Upserts vectors into an index
62
- * @param params - Parameters containing vectors, metadata, and optional IDs
63
- * @returns Promise containing array of vector IDs
64
- */
65
- upsert(params: UpsertVectorParams): Promise<string[]> {
66
- return this.request(`/api/vector/${this.vectorName}/upsert`, {
67
- method: 'POST',
68
- body: params,
69
- });
70
- }
71
-
72
- /**
73
- * Queries vectors in an index
74
- * @param params - Query parameters including query vector and search options
75
- * @returns Promise containing query results
76
- */
77
- query(params: QueryVectorParams): Promise<QueryVectorResponse> {
78
- return this.request(`/api/vector/${this.vectorName}/query`, {
79
- method: 'POST',
80
- body: params,
81
- });
82
- }
83
- }