@mastra/client-js 0.0.0-generate-message-id-20250512171942 → 0.0.0-gl-test-20250917080133

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 (78) hide show
  1. package/CHANGELOG.md +1708 -4
  2. package/LICENSE.md +11 -42
  3. package/README.md +8 -9
  4. package/dist/client.d.ts +284 -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 +2790 -608
  9. package/dist/index.cjs.map +1 -0
  10. package/dist/index.d.ts +5 -790
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +2791 -611
  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 +160 -0
  17. package/dist/resources/agent-builder.d.ts.map +1 -0
  18. package/dist/resources/agent.d.ts +175 -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 +90 -0
  25. package/dist/resources/legacy-workflow.d.ts.map +1 -0
  26. package/dist/resources/mcp-tool.d.ts +28 -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 +32 -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 +24 -0
  37. package/dist/resources/tool.d.ts.map +1 -0
  38. package/dist/resources/vNextNetwork.d.ts +43 -0
  39. package/dist/resources/vNextNetwork.d.ts.map +1 -0
  40. package/dist/resources/vector.d.ts +51 -0
  41. package/dist/resources/vector.d.ts.map +1 -0
  42. package/dist/resources/workflow.d.ts +226 -0
  43. package/dist/resources/workflow.d.ts.map +1 -0
  44. package/dist/tools.d.ts +22 -0
  45. package/dist/tools.d.ts.map +1 -0
  46. package/dist/types.d.ts +469 -0
  47. package/dist/types.d.ts.map +1 -0
  48. package/dist/utils/index.d.ts +5 -0
  49. package/dist/utils/index.d.ts.map +1 -0
  50. package/dist/utils/process-client-tools.d.ts +3 -0
  51. package/dist/utils/process-client-tools.d.ts.map +1 -0
  52. package/dist/utils/process-mastra-stream.d.ts +11 -0
  53. package/dist/utils/process-mastra-stream.d.ts.map +1 -0
  54. package/dist/utils/zod-to-json-schema.d.ts +3 -0
  55. package/dist/utils/zod-to-json-schema.d.ts.map +1 -0
  56. package/package.json +37 -20
  57. package/dist/index.d.cts +0 -790
  58. package/eslint.config.js +0 -6
  59. package/src/adapters/agui.test.ts +0 -180
  60. package/src/adapters/agui.ts +0 -239
  61. package/src/client.ts +0 -268
  62. package/src/example.ts +0 -65
  63. package/src/index.test.ts +0 -710
  64. package/src/index.ts +0 -2
  65. package/src/resources/a2a.ts +0 -88
  66. package/src/resources/agent.ts +0 -196
  67. package/src/resources/base.ts +0 -70
  68. package/src/resources/index.ts +0 -9
  69. package/src/resources/memory-thread.ts +0 -53
  70. package/src/resources/network.ts +0 -86
  71. package/src/resources/tool.ts +0 -44
  72. package/src/resources/vector.ts +0 -83
  73. package/src/resources/vnext-workflow.ts +0 -261
  74. package/src/resources/workflow.ts +0 -251
  75. package/src/types.ts +0 -262
  76. package/src/utils/zod-to-json-schema.ts +0 -10
  77. package/tsconfig.json +0 -5
  78. package/vitest.config.js +0 -8
@@ -1,88 +0,0 @@
1
- import type { TaskSendParams, TaskQueryParams, TaskIdParams, Task, AgentCard, JSONRPCResponse } from '@mastra/core/a2a';
2
- import type { ClientOptions } from '../types';
3
- import { BaseResource } from './base';
4
-
5
- /**
6
- * Class for interacting with an agent via the A2A protocol
7
- */
8
- export class A2A extends BaseResource {
9
- constructor(
10
- options: ClientOptions,
11
- private agentId: string,
12
- ) {
13
- super(options);
14
- }
15
-
16
- /**
17
- * Get the agent card with metadata about the agent
18
- * @returns Promise containing the agent card information
19
- */
20
- async getCard(): Promise<AgentCard> {
21
- return this.request(`/.well-known/${this.agentId}/agent.json`);
22
- }
23
-
24
- /**
25
- * Send a message to the agent and get a response
26
- * @param params - Parameters for the task
27
- * @returns Promise containing the task response
28
- */
29
- async sendMessage(params: TaskSendParams): Promise<{ task: Task }> {
30
- const response = await this.request<JSONRPCResponse<Task>>(`/a2a/${this.agentId}`, {
31
- method: 'POST',
32
- body: {
33
- method: 'tasks/send',
34
- params,
35
- },
36
- });
37
-
38
- return { task: response.result! };
39
- }
40
-
41
- /**
42
- * Get the status and result of a task
43
- * @param params - Parameters for querying the task
44
- * @returns Promise containing the task response
45
- */
46
- async getTask(params: TaskQueryParams): Promise<Task> {
47
- const response = await this.request<JSONRPCResponse<Task>>(`/a2a/${this.agentId}`, {
48
- method: 'POST',
49
- body: {
50
- method: 'tasks/get',
51
- params,
52
- },
53
- });
54
-
55
- return response.result!;
56
- }
57
-
58
- /**
59
- * Cancel a running task
60
- * @param params - Parameters identifying the task to cancel
61
- * @returns Promise containing the task response
62
- */
63
- async cancelTask(params: TaskIdParams): Promise<{ task: Task }> {
64
- return this.request(`/a2a/${this.agentId}`, {
65
- method: 'POST',
66
- body: {
67
- method: 'tasks/cancel',
68
- params,
69
- },
70
- });
71
- }
72
-
73
- /**
74
- * Send a message and subscribe to streaming updates (not fully implemented)
75
- * @param params - Parameters for the task
76
- * @returns Promise containing the task response
77
- */
78
- async sendAndSubscribe(params: TaskSendParams): Promise<Response> {
79
- return this.request(`/a2a/${this.agentId}`, {
80
- method: 'POST',
81
- body: {
82
- method: 'tasks/sendSubscribe',
83
- params,
84
- },
85
- stream: true,
86
- });
87
- }
88
- }
@@ -1,196 +0,0 @@
1
- import { processDataStream } from '@ai-sdk/ui-utils';
2
- import type { GenerateReturn } from '@mastra/core';
3
- import type { JSONSchema7 } from 'json-schema';
4
- import { ZodSchema } from 'zod';
5
- import { zodToJsonSchema } from '../utils/zod-to-json-schema';
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
- import type { RuntimeContext } from '@mastra/core/di';
18
-
19
- export class AgentVoice extends BaseResource {
20
- constructor(
21
- options: ClientOptions,
22
- private agentId: string,
23
- ) {
24
- super(options);
25
- this.agentId = agentId;
26
- }
27
-
28
- /**
29
- * Convert text to speech using the agent's voice provider
30
- * @param text - Text to convert to speech
31
- * @param options - Optional provider-specific options for speech generation
32
- * @returns Promise containing the audio data
33
- */
34
- async speak(text: string, options?: { speaker?: string; [key: string]: any }): Promise<Response> {
35
- return this.request<Response>(`/api/agents/${this.agentId}/voice/speak`, {
36
- method: 'POST',
37
- headers: {
38
- 'Content-Type': 'application/json',
39
- },
40
- body: { input: text, options },
41
- stream: true,
42
- });
43
- }
44
-
45
- /**
46
- * Convert speech to text using the agent's voice provider
47
- * @param audio - Audio data to transcribe
48
- * @param options - Optional provider-specific options
49
- * @returns Promise containing the transcribed text
50
- */
51
- listen(audio: Blob, options?: Record<string, any>): Promise<Response> {
52
- const formData = new FormData();
53
- formData.append('audio', audio);
54
-
55
- if (options) {
56
- formData.append('options', JSON.stringify(options));
57
- }
58
-
59
- return this.request(`/api/agents/${this.agentId}/voice/listen`, {
60
- method: 'POST',
61
- body: formData,
62
- });
63
- }
64
-
65
- /**
66
- * Get available speakers for the agent's voice provider
67
- * @returns Promise containing list of available speakers
68
- */
69
- getSpeakers(): Promise<Array<{ voiceId: string; [key: string]: any }>> {
70
- return this.request(`/api/agents/${this.agentId}/voice/speakers`);
71
- }
72
- }
73
-
74
- export class Agent extends BaseResource {
75
- public readonly voice: AgentVoice;
76
-
77
- constructor(
78
- options: ClientOptions,
79
- private agentId: string,
80
- ) {
81
- super(options);
82
- this.voice = new AgentVoice(options, this.agentId);
83
- }
84
-
85
- /**
86
- * Retrieves details about the agent
87
- * @returns Promise containing agent details including model and instructions
88
- */
89
- details(): Promise<GetAgentResponse> {
90
- return this.request(`/api/agents/${this.agentId}`);
91
- }
92
-
93
- /**
94
- * Generates a response from the agent
95
- * @param params - Generation parameters including prompt
96
- * @returns Promise containing the generated response
97
- */
98
- generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(
99
- params: GenerateParams<T>,
100
- ): Promise<GenerateReturn<T>> {
101
- const processedParams = {
102
- ...params,
103
- output: zodToJsonSchema(params.output),
104
- experimental_output: zodToJsonSchema(params.experimental_output),
105
- runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : undefined,
106
- };
107
-
108
- return this.request(`/api/agents/${this.agentId}/generate`, {
109
- method: 'POST',
110
- body: processedParams,
111
- });
112
- }
113
-
114
- /**
115
- * Streams a response from the agent
116
- * @param params - Stream parameters including prompt
117
- * @returns Promise containing the enhanced Response object with processDataStream method
118
- */
119
- async stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(
120
- params: StreamParams<T>,
121
- ): Promise<
122
- Response & {
123
- processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
124
- }
125
- > {
126
- const processedParams = {
127
- ...params,
128
- output: zodToJsonSchema(params.output),
129
- experimental_output: zodToJsonSchema(params.experimental_output),
130
- runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : undefined,
131
- };
132
-
133
- const response: Response & {
134
- processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
135
- } = await this.request(`/api/agents/${this.agentId}/stream`, {
136
- method: 'POST',
137
- body: processedParams,
138
- stream: true,
139
- });
140
-
141
- if (!response.body) {
142
- throw new Error('No response body');
143
- }
144
-
145
- response.processDataStream = async (options = {}) => {
146
- await processDataStream({
147
- stream: response.body as ReadableStream<Uint8Array>,
148
- ...options,
149
- });
150
- };
151
-
152
- return response;
153
- }
154
-
155
- /**
156
- * Gets details about a specific tool available to the agent
157
- * @param toolId - ID of the tool to retrieve
158
- * @returns Promise containing tool details
159
- */
160
- getTool(toolId: string): Promise<GetToolResponse> {
161
- return this.request(`/api/agents/${this.agentId}/tools/${toolId}`);
162
- }
163
-
164
- /**
165
- * Executes a tool for the agent
166
- * @param toolId - ID of the tool to execute
167
- * @param params - Parameters required for tool execution
168
- * @returns Promise containing the tool execution results
169
- */
170
- executeTool(toolId: string, params: { data: any; runtimeContext?: RuntimeContext }): Promise<any> {
171
- const body = {
172
- data: params.data,
173
- runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : undefined,
174
- };
175
- return this.request(`/api/agents/${this.agentId}/tools/${toolId}/execute`, {
176
- method: 'POST',
177
- body,
178
- });
179
- }
180
-
181
- /**
182
- * Retrieves evaluation results for the agent
183
- * @returns Promise containing agent evaluations
184
- */
185
- evals(): Promise<GetEvalsByAgentIdResponse> {
186
- return this.request(`/api/agents/${this.agentId}/evals/ci`);
187
- }
188
-
189
- /**
190
- * Retrieves live evaluation results for the agent
191
- * @returns Promise containing live agent evaluations
192
- */
193
- liveEvals(): Promise<GetEvalsByAgentIdResponse> {
194
- return this.request(`/api/agents/${this.agentId}/evals/live`);
195
- }
196
- }
@@ -1,70 +0,0 @@
1
- import type { 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,9 +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 './vnext-workflow';
9
- export * from './a2a';
@@ -1,53 +0,0 @@
1
- import type { StorageThreadType } from '@mastra/core';
2
-
3
- import type { GetMemoryThreadMessagesResponse, ClientOptions, UpdateMemoryThreadParams } from '../types';
4
-
5
- import { BaseResource } from './base';
6
-
7
- export class MemoryThread extends BaseResource {
8
- constructor(
9
- options: ClientOptions,
10
- private threadId: string,
11
- private agentId: string,
12
- ) {
13
- super(options);
14
- }
15
-
16
- /**
17
- * Retrieves the memory thread details
18
- * @returns Promise containing thread details including title and metadata
19
- */
20
- get(): Promise<StorageThreadType> {
21
- return this.request(`/api/memory/threads/${this.threadId}?agentId=${this.agentId}`);
22
- }
23
-
24
- /**
25
- * Updates the memory thread properties
26
- * @param params - Update parameters including title and metadata
27
- * @returns Promise containing updated thread details
28
- */
29
- update(params: UpdateMemoryThreadParams): Promise<StorageThreadType> {
30
- return this.request(`/api/memory/threads/${this.threadId}?agentId=${this.agentId}`, {
31
- method: 'PATCH',
32
- body: params,
33
- });
34
- }
35
-
36
- /**
37
- * Deletes the memory thread
38
- * @returns Promise containing deletion result
39
- */
40
- delete(): Promise<{ result: string }> {
41
- return this.request(`/api/memory/threads/${this.threadId}?agentId=${this.agentId}`, {
42
- method: 'DELETE',
43
- });
44
- }
45
-
46
- /**
47
- * Retrieves messages associated with the thread
48
- * @returns Promise containing thread messages and UI messages
49
- */
50
- getMessages(): Promise<GetMemoryThreadMessagesResponse> {
51
- return this.request(`/api/memory/threads/${this.threadId}/messages?agentId=${this.agentId}`);
52
- }
53
- }
@@ -1,86 +0,0 @@
1
- import { processDataStream } from '@ai-sdk/ui-utils';
2
- import type { GenerateReturn } from '@mastra/core';
3
- import type { JSONSchema7 } from 'json-schema';
4
- import { ZodSchema } from 'zod';
5
- import { zodToJsonSchema } from '../utils/zod-to-json-schema';
6
-
7
- import type { GenerateParams, ClientOptions, StreamParams, GetNetworkResponse } from '../types';
8
-
9
- import { BaseResource } from './base';
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: zodToJsonSchema(params.output),
38
- experimental_output: zodToJsonSchema(params.experimental_output),
39
- };
40
-
41
- return this.request(`/api/networks/${this.networkId}/generate`, {
42
- method: 'POST',
43
- body: processedParams,
44
- });
45
- }
46
-
47
- /**
48
- * Streams a response from the agent
49
- * @param params - Stream parameters including prompt
50
- * @returns Promise containing the enhanced Response object with processDataStream method
51
- */
52
- async stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(
53
- params: StreamParams<T>,
54
- ): Promise<
55
- Response & {
56
- processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
57
- }
58
- > {
59
- const processedParams = {
60
- ...params,
61
- output: zodToJsonSchema(params.output),
62
- experimental_output: zodToJsonSchema(params.experimental_output),
63
- };
64
-
65
- const response: Response & {
66
- processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
67
- } = await this.request(`/api/networks/${this.networkId}/stream`, {
68
- method: 'POST',
69
- body: processedParams,
70
- stream: true,
71
- });
72
-
73
- if (!response.body) {
74
- throw new Error('No response body');
75
- }
76
-
77
- response.processDataStream = async (options = {}) => {
78
- await processDataStream({
79
- stream: response.body as ReadableStream<Uint8Array>,
80
- ...options,
81
- });
82
- };
83
-
84
- return response;
85
- }
86
- }
@@ -1,44 +0,0 @@
1
- import type { RuntimeContext } from '@mastra/core/di';
2
- import type { GetToolResponse, ClientOptions } from '../types';
3
-
4
- import { BaseResource } from './base';
5
-
6
- export class Tool extends BaseResource {
7
- constructor(
8
- options: ClientOptions,
9
- private toolId: string,
10
- ) {
11
- super(options);
12
- }
13
-
14
- /**
15
- * Retrieves details about the tool
16
- * @returns Promise containing tool details including description and schemas
17
- */
18
- details(): Promise<GetToolResponse> {
19
- return this.request(`/api/tools/${this.toolId}`);
20
- }
21
-
22
- /**
23
- * Executes the tool with the provided parameters
24
- * @param params - Parameters required for tool execution
25
- * @returns Promise containing the tool execution results
26
- */
27
- execute(params: { data: any; runId?: string; runtimeContext?: RuntimeContext }): Promise<any> {
28
- const url = new URLSearchParams();
29
-
30
- if (params.runId) {
31
- url.set('runId', params.runId);
32
- }
33
-
34
- const body = {
35
- data: params.data,
36
- runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : undefined,
37
- };
38
-
39
- return this.request(`/api/tools/${this.toolId}/execute?${url.toString()}`, {
40
- method: 'POST',
41
- body,
42
- });
43
- }
44
- }
@@ -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
- }