@mastra/client-js 0.11.3-alpha.3 → 0.11.3-alpha.4
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/CHANGELOG.md +16 -0
- package/dist/client.d.ts +12 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/index.cjs +398 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +398 -4
- package/dist/index.js.map +1 -1
- package/dist/resources/agent-builder.d.ts +148 -0
- package/dist/resources/agent-builder.d.ts.map +1 -0
- package/dist/resources/agent.d.ts +25 -0
- package/dist/resources/agent.d.ts.map +1 -1
- package/dist/resources/index.d.ts +1 -0
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/types.d.ts +33 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -4
- package/.turbo/turbo-build.log +0 -18
- package/eslint.config.js +0 -11
- package/integration-tests/agui-adapter.test.ts +0 -122
- package/integration-tests/package.json +0 -18
- package/integration-tests/src/mastra/index.ts +0 -35
- package/integration-tests/vitest.config.ts +0 -9
- package/src/adapters/agui.test.ts +0 -293
- package/src/adapters/agui.ts +0 -257
- package/src/client.ts +0 -644
- package/src/example.ts +0 -95
- package/src/index.test.ts +0 -1253
- package/src/index.ts +0 -3
- package/src/resources/a2a.ts +0 -98
- package/src/resources/agent.ts +0 -1460
- package/src/resources/base.ts +0 -77
- package/src/resources/index.ts +0 -11
- package/src/resources/legacy-workflow.ts +0 -242
- package/src/resources/mcp-tool.ts +0 -48
- package/src/resources/memory-thread.test.ts +0 -285
- package/src/resources/memory-thread.ts +0 -99
- package/src/resources/network-memory-thread.test.ts +0 -269
- package/src/resources/network-memory-thread.ts +0 -81
- package/src/resources/network.ts +0 -86
- package/src/resources/observability.ts +0 -53
- package/src/resources/tool.ts +0 -45
- package/src/resources/vNextNetwork.ts +0 -194
- package/src/resources/vector.ts +0 -83
- package/src/resources/workflow.ts +0 -410
- package/src/types.ts +0 -534
- package/src/utils/index.ts +0 -11
- package/src/utils/process-client-tools.ts +0 -32
- package/src/utils/process-mastra-stream.test.ts +0 -353
- package/src/utils/process-mastra-stream.ts +0 -49
- package/src/utils/zod-to-json-schema.ts +0 -30
- package/src/v2-messages.test.ts +0 -180
- package/tsconfig.build.json +0 -9
- package/tsconfig.json +0 -5
- package/tsup.config.ts +0 -17
- package/vitest.config.js +0 -8
package/src/client.ts
DELETED
|
@@ -1,644 +0,0 @@
|
|
|
1
|
-
import type { AbstractAgent } from '@ag-ui/client';
|
|
2
|
-
import type { AITraceRecord, AITracesPaginatedArg } from '@mastra/core';
|
|
3
|
-
import type { ServerDetailInfo } from '@mastra/core/mcp';
|
|
4
|
-
import { AGUIAdapter } from './adapters/agui';
|
|
5
|
-
import {
|
|
6
|
-
Agent,
|
|
7
|
-
MemoryThread,
|
|
8
|
-
Tool,
|
|
9
|
-
Workflow,
|
|
10
|
-
Vector,
|
|
11
|
-
BaseResource,
|
|
12
|
-
Network,
|
|
13
|
-
A2A,
|
|
14
|
-
MCPTool,
|
|
15
|
-
LegacyWorkflow,
|
|
16
|
-
Observability,
|
|
17
|
-
} from './resources';
|
|
18
|
-
import { NetworkMemoryThread } from './resources/network-memory-thread';
|
|
19
|
-
import { VNextNetwork } from './resources/vNextNetwork';
|
|
20
|
-
import type {
|
|
21
|
-
ClientOptions,
|
|
22
|
-
CreateMemoryThreadParams,
|
|
23
|
-
CreateMemoryThreadResponse,
|
|
24
|
-
GetAgentResponse,
|
|
25
|
-
GetLogParams,
|
|
26
|
-
GetLogsParams,
|
|
27
|
-
GetLogsResponse,
|
|
28
|
-
GetMemoryThreadParams,
|
|
29
|
-
GetMemoryThreadResponse,
|
|
30
|
-
GetNetworkResponse,
|
|
31
|
-
GetTelemetryParams,
|
|
32
|
-
GetTelemetryResponse,
|
|
33
|
-
GetToolResponse,
|
|
34
|
-
GetWorkflowResponse,
|
|
35
|
-
SaveMessageToMemoryParams,
|
|
36
|
-
SaveMessageToMemoryResponse,
|
|
37
|
-
McpServerListResponse,
|
|
38
|
-
McpServerToolListResponse,
|
|
39
|
-
GetLegacyWorkflowResponse,
|
|
40
|
-
GetVNextNetworkResponse,
|
|
41
|
-
GetNetworkMemoryThreadParams,
|
|
42
|
-
CreateNetworkMemoryThreadParams,
|
|
43
|
-
SaveNetworkMessageToMemoryParams,
|
|
44
|
-
GetScorerResponse,
|
|
45
|
-
GetScoresByScorerIdParams,
|
|
46
|
-
GetScoresResponse,
|
|
47
|
-
GetScoresByRunIdParams,
|
|
48
|
-
GetScoresByEntityIdParams,
|
|
49
|
-
SaveScoreParams,
|
|
50
|
-
SaveScoreResponse,
|
|
51
|
-
GetAITracesResponse,
|
|
52
|
-
} from './types';
|
|
53
|
-
|
|
54
|
-
export class MastraClient extends BaseResource {
|
|
55
|
-
private observability: Observability;
|
|
56
|
-
constructor(options: ClientOptions) {
|
|
57
|
-
super(options);
|
|
58
|
-
this.observability = new Observability(options);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Retrieves all available agents
|
|
63
|
-
* @returns Promise containing map of agent IDs to agent details
|
|
64
|
-
*/
|
|
65
|
-
public getAgents(): Promise<Record<string, GetAgentResponse>> {
|
|
66
|
-
return this.request('/api/agents');
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
public async getAGUI({ resourceId }: { resourceId: string }): Promise<Record<string, AbstractAgent>> {
|
|
70
|
-
const agents = await this.getAgents();
|
|
71
|
-
|
|
72
|
-
return Object.entries(agents).reduce(
|
|
73
|
-
(acc, [agentId]) => {
|
|
74
|
-
const agent = this.getAgent(agentId);
|
|
75
|
-
|
|
76
|
-
acc[agentId] = new AGUIAdapter({
|
|
77
|
-
agentId,
|
|
78
|
-
agent,
|
|
79
|
-
resourceId,
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
return acc;
|
|
83
|
-
},
|
|
84
|
-
{} as Record<string, AbstractAgent>,
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Gets an agent instance by ID
|
|
90
|
-
* @param agentId - ID of the agent to retrieve
|
|
91
|
-
* @returns Agent instance
|
|
92
|
-
*/
|
|
93
|
-
public getAgent(agentId: string) {
|
|
94
|
-
return new Agent(this.options, agentId);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Retrieves memory threads for a resource
|
|
99
|
-
* @param params - Parameters containing the resource ID
|
|
100
|
-
* @returns Promise containing array of memory threads
|
|
101
|
-
*/
|
|
102
|
-
public getMemoryThreads(params: GetMemoryThreadParams): Promise<GetMemoryThreadResponse> {
|
|
103
|
-
return this.request(`/api/memory/threads?resourceid=${params.resourceId}&agentId=${params.agentId}`);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Creates a new memory thread
|
|
108
|
-
* @param params - Parameters for creating the memory thread
|
|
109
|
-
* @returns Promise containing the created memory thread
|
|
110
|
-
*/
|
|
111
|
-
public createMemoryThread(params: CreateMemoryThreadParams): Promise<CreateMemoryThreadResponse> {
|
|
112
|
-
return this.request(`/api/memory/threads?agentId=${params.agentId}`, { method: 'POST', body: params });
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Gets a memory thread instance by ID
|
|
117
|
-
* @param threadId - ID of the memory thread to retrieve
|
|
118
|
-
* @returns MemoryThread instance
|
|
119
|
-
*/
|
|
120
|
-
public getMemoryThread(threadId: string, agentId: string) {
|
|
121
|
-
return new MemoryThread(this.options, threadId, agentId);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Saves messages to memory
|
|
126
|
-
* @param params - Parameters containing messages to save
|
|
127
|
-
* @returns Promise containing the saved messages
|
|
128
|
-
*/
|
|
129
|
-
public saveMessageToMemory(params: SaveMessageToMemoryParams): Promise<SaveMessageToMemoryResponse> {
|
|
130
|
-
return this.request(`/api/memory/save-messages?agentId=${params.agentId}`, {
|
|
131
|
-
method: 'POST',
|
|
132
|
-
body: params,
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Gets the status of the memory system
|
|
138
|
-
* @returns Promise containing memory system status
|
|
139
|
-
*/
|
|
140
|
-
public getMemoryStatus(agentId: string): Promise<{ result: boolean }> {
|
|
141
|
-
return this.request(`/api/memory/status?agentId=${agentId}`);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Retrieves memory threads for a resource
|
|
146
|
-
* @param params - Parameters containing the resource ID
|
|
147
|
-
* @returns Promise containing array of memory threads
|
|
148
|
-
*/
|
|
149
|
-
public getNetworkMemoryThreads(params: GetNetworkMemoryThreadParams): Promise<GetMemoryThreadResponse> {
|
|
150
|
-
return this.request(`/api/memory/network/threads?resourceid=${params.resourceId}&networkId=${params.networkId}`);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Creates a new memory thread
|
|
155
|
-
* @param params - Parameters for creating the memory thread
|
|
156
|
-
* @returns Promise containing the created memory thread
|
|
157
|
-
*/
|
|
158
|
-
public createNetworkMemoryThread(params: CreateNetworkMemoryThreadParams): Promise<CreateMemoryThreadResponse> {
|
|
159
|
-
return this.request(`/api/memory/network/threads?networkId=${params.networkId}`, { method: 'POST', body: params });
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Gets a memory thread instance by ID
|
|
164
|
-
* @param threadId - ID of the memory thread to retrieve
|
|
165
|
-
* @returns MemoryThread instance
|
|
166
|
-
*/
|
|
167
|
-
public getNetworkMemoryThread(threadId: string, networkId: string) {
|
|
168
|
-
return new NetworkMemoryThread(this.options, threadId, networkId);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Saves messages to memory
|
|
173
|
-
* @param params - Parameters containing messages to save
|
|
174
|
-
* @returns Promise containing the saved messages
|
|
175
|
-
*/
|
|
176
|
-
public saveNetworkMessageToMemory(params: SaveNetworkMessageToMemoryParams): Promise<SaveMessageToMemoryResponse> {
|
|
177
|
-
return this.request(`/api/memory/network/save-messages?networkId=${params.networkId}`, {
|
|
178
|
-
method: 'POST',
|
|
179
|
-
body: params,
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Gets the status of the memory system
|
|
185
|
-
* @returns Promise containing memory system status
|
|
186
|
-
*/
|
|
187
|
-
public getNetworkMemoryStatus(networkId: string): Promise<{ result: boolean }> {
|
|
188
|
-
return this.request(`/api/memory/network/status?networkId=${networkId}`);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Retrieves all available tools
|
|
193
|
-
* @returns Promise containing map of tool IDs to tool details
|
|
194
|
-
*/
|
|
195
|
-
public getTools(): Promise<Record<string, GetToolResponse>> {
|
|
196
|
-
return this.request('/api/tools');
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Gets a tool instance by ID
|
|
201
|
-
* @param toolId - ID of the tool to retrieve
|
|
202
|
-
* @returns Tool instance
|
|
203
|
-
*/
|
|
204
|
-
public getTool(toolId: string) {
|
|
205
|
-
return new Tool(this.options, toolId);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Retrieves all available legacy workflows
|
|
210
|
-
* @returns Promise containing map of legacy workflow IDs to legacy workflow details
|
|
211
|
-
*/
|
|
212
|
-
public getLegacyWorkflows(): Promise<Record<string, GetLegacyWorkflowResponse>> {
|
|
213
|
-
return this.request('/api/workflows/legacy');
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Gets a legacy workflow instance by ID
|
|
218
|
-
* @param workflowId - ID of the legacy workflow to retrieve
|
|
219
|
-
* @returns Legacy Workflow instance
|
|
220
|
-
*/
|
|
221
|
-
public getLegacyWorkflow(workflowId: string) {
|
|
222
|
-
return new LegacyWorkflow(this.options, workflowId);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Retrieves all available workflows
|
|
227
|
-
* @returns Promise containing map of workflow IDs to workflow details
|
|
228
|
-
*/
|
|
229
|
-
public getWorkflows(): Promise<Record<string, GetWorkflowResponse>> {
|
|
230
|
-
return this.request('/api/workflows');
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Gets a workflow instance by ID
|
|
235
|
-
* @param workflowId - ID of the workflow to retrieve
|
|
236
|
-
* @returns Workflow instance
|
|
237
|
-
*/
|
|
238
|
-
public getWorkflow(workflowId: string) {
|
|
239
|
-
return new Workflow(this.options, workflowId);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Gets a vector instance by name
|
|
244
|
-
* @param vectorName - Name of the vector to retrieve
|
|
245
|
-
* @returns Vector instance
|
|
246
|
-
*/
|
|
247
|
-
public getVector(vectorName: string) {
|
|
248
|
-
return new Vector(this.options, vectorName);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Retrieves logs
|
|
253
|
-
* @param params - Parameters for filtering logs
|
|
254
|
-
* @returns Promise containing array of log messages
|
|
255
|
-
*/
|
|
256
|
-
public getLogs(params: GetLogsParams): Promise<GetLogsResponse> {
|
|
257
|
-
const { transportId, fromDate, toDate, logLevel, filters, page, perPage } = params;
|
|
258
|
-
const _filters = filters ? Object.entries(filters).map(([key, value]) => `${key}:${value}`) : [];
|
|
259
|
-
|
|
260
|
-
const searchParams = new URLSearchParams();
|
|
261
|
-
if (transportId) {
|
|
262
|
-
searchParams.set('transportId', transportId);
|
|
263
|
-
}
|
|
264
|
-
if (fromDate) {
|
|
265
|
-
searchParams.set('fromDate', fromDate.toISOString());
|
|
266
|
-
}
|
|
267
|
-
if (toDate) {
|
|
268
|
-
searchParams.set('toDate', toDate.toISOString());
|
|
269
|
-
}
|
|
270
|
-
if (logLevel) {
|
|
271
|
-
searchParams.set('logLevel', logLevel);
|
|
272
|
-
}
|
|
273
|
-
if (page) {
|
|
274
|
-
searchParams.set('page', String(page));
|
|
275
|
-
}
|
|
276
|
-
if (perPage) {
|
|
277
|
-
searchParams.set('perPage', String(perPage));
|
|
278
|
-
}
|
|
279
|
-
if (_filters) {
|
|
280
|
-
if (Array.isArray(_filters)) {
|
|
281
|
-
for (const filter of _filters) {
|
|
282
|
-
searchParams.append('filters', filter);
|
|
283
|
-
}
|
|
284
|
-
} else {
|
|
285
|
-
searchParams.set('filters', _filters);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
if (searchParams.size) {
|
|
290
|
-
return this.request(`/api/logs?${searchParams}`);
|
|
291
|
-
} else {
|
|
292
|
-
return this.request(`/api/logs`);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* Gets logs for a specific run
|
|
298
|
-
* @param params - Parameters containing run ID to retrieve
|
|
299
|
-
* @returns Promise containing array of log messages
|
|
300
|
-
*/
|
|
301
|
-
public getLogForRun(params: GetLogParams): Promise<GetLogsResponse> {
|
|
302
|
-
const { runId, transportId, fromDate, toDate, logLevel, filters, page, perPage } = params;
|
|
303
|
-
|
|
304
|
-
const _filters = filters ? Object.entries(filters).map(([key, value]) => `${key}:${value}`) : [];
|
|
305
|
-
const searchParams = new URLSearchParams();
|
|
306
|
-
if (runId) {
|
|
307
|
-
searchParams.set('runId', runId);
|
|
308
|
-
}
|
|
309
|
-
if (transportId) {
|
|
310
|
-
searchParams.set('transportId', transportId);
|
|
311
|
-
}
|
|
312
|
-
if (fromDate) {
|
|
313
|
-
searchParams.set('fromDate', fromDate.toISOString());
|
|
314
|
-
}
|
|
315
|
-
if (toDate) {
|
|
316
|
-
searchParams.set('toDate', toDate.toISOString());
|
|
317
|
-
}
|
|
318
|
-
if (logLevel) {
|
|
319
|
-
searchParams.set('logLevel', logLevel);
|
|
320
|
-
}
|
|
321
|
-
if (page) {
|
|
322
|
-
searchParams.set('page', String(page));
|
|
323
|
-
}
|
|
324
|
-
if (perPage) {
|
|
325
|
-
searchParams.set('perPage', String(perPage));
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
if (_filters) {
|
|
329
|
-
if (Array.isArray(_filters)) {
|
|
330
|
-
for (const filter of _filters) {
|
|
331
|
-
searchParams.append('filters', filter);
|
|
332
|
-
}
|
|
333
|
-
} else {
|
|
334
|
-
searchParams.set('filters', _filters);
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
if (searchParams.size) {
|
|
339
|
-
return this.request(`/api/logs/${runId}?${searchParams}`);
|
|
340
|
-
} else {
|
|
341
|
-
return this.request(`/api/logs/${runId}`);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* List of all log transports
|
|
347
|
-
* @returns Promise containing list of log transports
|
|
348
|
-
*/
|
|
349
|
-
public getLogTransports(): Promise<{ transports: string[] }> {
|
|
350
|
-
return this.request('/api/logs/transports');
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* List of all traces (paged)
|
|
355
|
-
* @param params - Parameters for filtering traces
|
|
356
|
-
* @returns Promise containing telemetry data
|
|
357
|
-
*/
|
|
358
|
-
public getTelemetry(params?: GetTelemetryParams): Promise<GetTelemetryResponse> {
|
|
359
|
-
const { name, scope, page, perPage, attribute, fromDate, toDate } = params || {};
|
|
360
|
-
const _attribute = attribute ? Object.entries(attribute).map(([key, value]) => `${key}:${value}`) : [];
|
|
361
|
-
|
|
362
|
-
const searchParams = new URLSearchParams();
|
|
363
|
-
if (name) {
|
|
364
|
-
searchParams.set('name', name);
|
|
365
|
-
}
|
|
366
|
-
if (scope) {
|
|
367
|
-
searchParams.set('scope', scope);
|
|
368
|
-
}
|
|
369
|
-
if (page) {
|
|
370
|
-
searchParams.set('page', String(page));
|
|
371
|
-
}
|
|
372
|
-
if (perPage) {
|
|
373
|
-
searchParams.set('perPage', String(perPage));
|
|
374
|
-
}
|
|
375
|
-
if (_attribute) {
|
|
376
|
-
if (Array.isArray(_attribute)) {
|
|
377
|
-
for (const attr of _attribute) {
|
|
378
|
-
searchParams.append('attribute', attr);
|
|
379
|
-
}
|
|
380
|
-
} else {
|
|
381
|
-
searchParams.set('attribute', _attribute);
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
if (fromDate) {
|
|
385
|
-
searchParams.set('fromDate', fromDate.toISOString());
|
|
386
|
-
}
|
|
387
|
-
if (toDate) {
|
|
388
|
-
searchParams.set('toDate', toDate.toISOString());
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
if (searchParams.size) {
|
|
392
|
-
return this.request(`/api/telemetry?${searchParams}`);
|
|
393
|
-
} else {
|
|
394
|
-
return this.request(`/api/telemetry`);
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
/**
|
|
399
|
-
* Retrieves all available networks
|
|
400
|
-
* @returns Promise containing map of network IDs to network details
|
|
401
|
-
*/
|
|
402
|
-
public getNetworks(): Promise<Array<GetNetworkResponse>> {
|
|
403
|
-
return this.request('/api/networks');
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
/**
|
|
407
|
-
* Retrieves all available vNext networks
|
|
408
|
-
* @returns Promise containing map of vNext network IDs to vNext network details
|
|
409
|
-
*/
|
|
410
|
-
public getVNextNetworks(): Promise<Array<GetVNextNetworkResponse>> {
|
|
411
|
-
return this.request('/api/networks/v-next');
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
/**
|
|
415
|
-
* Gets a network instance by ID
|
|
416
|
-
* @param networkId - ID of the network to retrieve
|
|
417
|
-
* @returns Network instance
|
|
418
|
-
*/
|
|
419
|
-
public getNetwork(networkId: string) {
|
|
420
|
-
return new Network(this.options, networkId);
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
/**
|
|
424
|
-
* Gets a vNext network instance by ID
|
|
425
|
-
* @param networkId - ID of the vNext network to retrieve
|
|
426
|
-
* @returns vNext Network instance
|
|
427
|
-
*/
|
|
428
|
-
public getVNextNetwork(networkId: string) {
|
|
429
|
-
return new VNextNetwork(this.options, networkId);
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
/**
|
|
433
|
-
* Retrieves a list of available MCP servers.
|
|
434
|
-
* @param params - Optional parameters for pagination (limit, offset).
|
|
435
|
-
* @returns Promise containing the list of MCP servers and pagination info.
|
|
436
|
-
*/
|
|
437
|
-
public getMcpServers(params?: { limit?: number; offset?: number }): Promise<McpServerListResponse> {
|
|
438
|
-
const searchParams = new URLSearchParams();
|
|
439
|
-
if (params?.limit !== undefined) {
|
|
440
|
-
searchParams.set('limit', String(params.limit));
|
|
441
|
-
}
|
|
442
|
-
if (params?.offset !== undefined) {
|
|
443
|
-
searchParams.set('offset', String(params.offset));
|
|
444
|
-
}
|
|
445
|
-
const queryString = searchParams.toString();
|
|
446
|
-
return this.request(`/api/mcp/v0/servers${queryString ? `?${queryString}` : ''}`);
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
/**
|
|
450
|
-
* Retrieves detailed information for a specific MCP server.
|
|
451
|
-
* @param serverId - The ID of the MCP server to retrieve.
|
|
452
|
-
* @param params - Optional parameters, e.g., specific version.
|
|
453
|
-
* @returns Promise containing the detailed MCP server information.
|
|
454
|
-
*/
|
|
455
|
-
public getMcpServerDetails(serverId: string, params?: { version?: string }): Promise<ServerDetailInfo> {
|
|
456
|
-
const searchParams = new URLSearchParams();
|
|
457
|
-
if (params?.version) {
|
|
458
|
-
searchParams.set('version', params.version);
|
|
459
|
-
}
|
|
460
|
-
const queryString = searchParams.toString();
|
|
461
|
-
return this.request(`/api/mcp/v0/servers/${serverId}${queryString ? `?${queryString}` : ''}`);
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
/**
|
|
465
|
-
* Retrieves a list of tools for a specific MCP server.
|
|
466
|
-
* @param serverId - The ID of the MCP server.
|
|
467
|
-
* @returns Promise containing the list of tools.
|
|
468
|
-
*/
|
|
469
|
-
public getMcpServerTools(serverId: string): Promise<McpServerToolListResponse> {
|
|
470
|
-
return this.request(`/api/mcp/${serverId}/tools`);
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
/**
|
|
474
|
-
* Gets an MCPTool resource instance for a specific tool on an MCP server.
|
|
475
|
-
* This instance can then be used to fetch details or execute the tool.
|
|
476
|
-
* @param serverId - The ID of the MCP server.
|
|
477
|
-
* @param toolId - The ID of the tool.
|
|
478
|
-
* @returns MCPTool instance.
|
|
479
|
-
*/
|
|
480
|
-
public getMcpServerTool(serverId: string, toolId: string): MCPTool {
|
|
481
|
-
return new MCPTool(this.options, serverId, toolId);
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
/**
|
|
485
|
-
* Gets an A2A client for interacting with an agent via the A2A protocol
|
|
486
|
-
* @param agentId - ID of the agent to interact with
|
|
487
|
-
* @returns A2A client instance
|
|
488
|
-
*/
|
|
489
|
-
public getA2A(agentId: string) {
|
|
490
|
-
return new A2A(this.options, agentId);
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
/**
|
|
494
|
-
* Retrieves the working memory for a specific thread (optionally resource-scoped).
|
|
495
|
-
* @param agentId - ID of the agent.
|
|
496
|
-
* @param threadId - ID of the thread.
|
|
497
|
-
* @param resourceId - Optional ID of the resource.
|
|
498
|
-
* @returns Working memory for the specified thread or resource.
|
|
499
|
-
*/
|
|
500
|
-
public getWorkingMemory({
|
|
501
|
-
agentId,
|
|
502
|
-
threadId,
|
|
503
|
-
resourceId,
|
|
504
|
-
}: {
|
|
505
|
-
agentId: string;
|
|
506
|
-
threadId: string;
|
|
507
|
-
resourceId?: string;
|
|
508
|
-
}) {
|
|
509
|
-
return this.request(`/api/memory/threads/${threadId}/working-memory?agentId=${agentId}&resourceId=${resourceId}`);
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
/**
|
|
513
|
-
* Updates the working memory for a specific thread (optionally resource-scoped).
|
|
514
|
-
* @param agentId - ID of the agent.
|
|
515
|
-
* @param threadId - ID of the thread.
|
|
516
|
-
* @param workingMemory - The new working memory content.
|
|
517
|
-
* @param resourceId - Optional ID of the resource.
|
|
518
|
-
*/
|
|
519
|
-
public updateWorkingMemory({
|
|
520
|
-
agentId,
|
|
521
|
-
threadId,
|
|
522
|
-
workingMemory,
|
|
523
|
-
resourceId,
|
|
524
|
-
}: {
|
|
525
|
-
agentId: string;
|
|
526
|
-
threadId: string;
|
|
527
|
-
workingMemory: string;
|
|
528
|
-
resourceId?: string;
|
|
529
|
-
}) {
|
|
530
|
-
return this.request(`/api/memory/threads/${threadId}/working-memory?agentId=${agentId}`, {
|
|
531
|
-
method: 'POST',
|
|
532
|
-
body: {
|
|
533
|
-
workingMemory,
|
|
534
|
-
resourceId,
|
|
535
|
-
},
|
|
536
|
-
});
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
/**
|
|
540
|
-
* Retrieves all available scorers
|
|
541
|
-
* @returns Promise containing list of available scorers
|
|
542
|
-
*/
|
|
543
|
-
public getScorers(): Promise<Record<string, GetScorerResponse>> {
|
|
544
|
-
return this.request('/api/scores/scorers');
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
/**
|
|
548
|
-
* Retrieves a scorer by ID
|
|
549
|
-
* @param scorerId - ID of the scorer to retrieve
|
|
550
|
-
* @returns Promise containing the scorer
|
|
551
|
-
*/
|
|
552
|
-
public getScorer(scorerId: string): Promise<GetScorerResponse> {
|
|
553
|
-
return this.request(`/api/scores/scorers/${scorerId}`);
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
public getScoresByScorerId(params: GetScoresByScorerIdParams): Promise<GetScoresResponse> {
|
|
557
|
-
const { page, perPage, scorerId, entityId, entityType } = params;
|
|
558
|
-
const searchParams = new URLSearchParams();
|
|
559
|
-
|
|
560
|
-
if (entityId) {
|
|
561
|
-
searchParams.set('entityId', entityId);
|
|
562
|
-
}
|
|
563
|
-
if (entityType) {
|
|
564
|
-
searchParams.set('entityType', entityType);
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
if (page !== undefined) {
|
|
568
|
-
searchParams.set('page', String(page));
|
|
569
|
-
}
|
|
570
|
-
if (perPage !== undefined) {
|
|
571
|
-
searchParams.set('perPage', String(perPage));
|
|
572
|
-
}
|
|
573
|
-
const queryString = searchParams.toString();
|
|
574
|
-
return this.request(`/api/scores/scorer/${scorerId}${queryString ? `?${queryString}` : ''}`);
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
/**
|
|
578
|
-
* Retrieves scores by run ID
|
|
579
|
-
* @param params - Parameters containing run ID and pagination options
|
|
580
|
-
* @returns Promise containing scores and pagination info
|
|
581
|
-
*/
|
|
582
|
-
public getScoresByRunId(params: GetScoresByRunIdParams): Promise<GetScoresResponse> {
|
|
583
|
-
const { runId, page, perPage } = params;
|
|
584
|
-
const searchParams = new URLSearchParams();
|
|
585
|
-
|
|
586
|
-
if (page !== undefined) {
|
|
587
|
-
searchParams.set('page', String(page));
|
|
588
|
-
}
|
|
589
|
-
if (perPage !== undefined) {
|
|
590
|
-
searchParams.set('perPage', String(perPage));
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
const queryString = searchParams.toString();
|
|
594
|
-
return this.request(`/api/scores/run/${runId}${queryString ? `?${queryString}` : ''}`);
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
/**
|
|
598
|
-
* Retrieves scores by entity ID and type
|
|
599
|
-
* @param params - Parameters containing entity ID, type, and pagination options
|
|
600
|
-
* @returns Promise containing scores and pagination info
|
|
601
|
-
*/
|
|
602
|
-
public getScoresByEntityId(params: GetScoresByEntityIdParams): Promise<GetScoresResponse> {
|
|
603
|
-
const { entityId, entityType, page, perPage } = params;
|
|
604
|
-
const searchParams = new URLSearchParams();
|
|
605
|
-
|
|
606
|
-
if (page !== undefined) {
|
|
607
|
-
searchParams.set('page', String(page));
|
|
608
|
-
}
|
|
609
|
-
if (perPage !== undefined) {
|
|
610
|
-
searchParams.set('perPage', String(perPage));
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
const queryString = searchParams.toString();
|
|
614
|
-
return this.request(`/api/scores/entity/${entityType}/${entityId}${queryString ? `?${queryString}` : ''}`);
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
/**
|
|
618
|
-
* Saves a score
|
|
619
|
-
* @param params - Parameters containing the score data to save
|
|
620
|
-
* @returns Promise containing the saved score
|
|
621
|
-
*/
|
|
622
|
-
public saveScore(params: SaveScoreParams): Promise<SaveScoreResponse> {
|
|
623
|
-
return this.request('/api/scores', {
|
|
624
|
-
method: 'POST',
|
|
625
|
-
body: params,
|
|
626
|
-
});
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
/**
|
|
630
|
-
* Retrieves model providers with available keys
|
|
631
|
-
* @returns Promise containing model providers with available keys
|
|
632
|
-
*/
|
|
633
|
-
getModelProviders(): Promise<string[]> {
|
|
634
|
-
return this.request(`/api/model-providers`);
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
getAITrace(traceId: string): Promise<AITraceRecord> {
|
|
638
|
-
return this.observability.getTrace(traceId);
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
getAITraces(params: AITracesPaginatedArg): Promise<GetAITracesResponse> {
|
|
642
|
-
return this.observability.getTraces(params);
|
|
643
|
-
}
|
|
644
|
-
}
|