@mastra/client-js 0.0.0-mcp-server-deploy-20250507160341 → 0.0.0-mcp-changeset-20250707162621
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/.turbo/turbo-build.log +19 -0
- package/CHANGELOG.md +753 -2
- package/README.md +1 -1
- package/dist/index.cjs +1365 -145
- package/dist/index.d.cts +504 -100
- package/dist/index.d.ts +504 -100
- package/dist/index.js +1364 -148
- package/package.json +22 -15
- package/src/adapters/agui.test.ts +180 -0
- package/src/adapters/agui.ts +239 -0
- package/src/client.ts +247 -33
- package/src/example.ts +33 -31
- package/src/index.test.ts +121 -1
- package/src/resources/a2a.ts +88 -0
- package/src/resources/agent.ts +603 -44
- package/src/resources/base.ts +2 -1
- package/src/resources/index.ts +4 -3
- package/src/resources/{vnext-workflow.ts → legacy-workflow.ts} +124 -139
- package/src/resources/mcp-tool.ts +48 -0
- package/src/resources/memory-thread.ts +13 -3
- package/src/resources/network-memory-thread.ts +63 -0
- package/src/resources/network.ts +6 -13
- package/src/resources/tool.ts +9 -2
- package/src/resources/vNextNetwork.ts +177 -0
- package/src/resources/workflow.ts +241 -96
- package/src/types.ts +175 -26
- package/src/utils/index.ts +11 -0
- package/src/utils/process-client-tools.ts +32 -0
- package/src/utils/zod-to-json-schema.ts +10 -0
- package/src/resources/mcp.ts +0 -22
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,235 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var client = require('@ag-ui/client');
|
|
4
|
+
var rxjs = require('rxjs');
|
|
3
5
|
var uiUtils = require('@ai-sdk/ui-utils');
|
|
4
6
|
var zod = require('zod');
|
|
5
|
-
var
|
|
7
|
+
var originalZodToJsonSchema = require('zod-to-json-schema');
|
|
8
|
+
var tools = require('@mastra/core/tools');
|
|
9
|
+
var runtimeContext = require('@mastra/core/runtime-context');
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
|
|
13
|
+
var originalZodToJsonSchema__default = /*#__PURE__*/_interopDefault(originalZodToJsonSchema);
|
|
14
|
+
|
|
15
|
+
// src/adapters/agui.ts
|
|
16
|
+
var AGUIAdapter = class extends client.AbstractAgent {
|
|
17
|
+
agent;
|
|
18
|
+
resourceId;
|
|
19
|
+
constructor({ agent, agentId, resourceId, ...rest }) {
|
|
20
|
+
super({
|
|
21
|
+
agentId,
|
|
22
|
+
...rest
|
|
23
|
+
});
|
|
24
|
+
this.agent = agent;
|
|
25
|
+
this.resourceId = resourceId;
|
|
26
|
+
}
|
|
27
|
+
run(input) {
|
|
28
|
+
return new rxjs.Observable((subscriber) => {
|
|
29
|
+
const convertedMessages = convertMessagesToMastraMessages(input.messages);
|
|
30
|
+
subscriber.next({
|
|
31
|
+
type: client.EventType.RUN_STARTED,
|
|
32
|
+
threadId: input.threadId,
|
|
33
|
+
runId: input.runId
|
|
34
|
+
});
|
|
35
|
+
this.agent.stream({
|
|
36
|
+
threadId: input.threadId,
|
|
37
|
+
resourceId: this.resourceId ?? "",
|
|
38
|
+
runId: input.runId,
|
|
39
|
+
messages: convertedMessages,
|
|
40
|
+
clientTools: input.tools.reduce(
|
|
41
|
+
(acc, tool) => {
|
|
42
|
+
acc[tool.name] = {
|
|
43
|
+
id: tool.name,
|
|
44
|
+
description: tool.description,
|
|
45
|
+
inputSchema: tool.parameters
|
|
46
|
+
};
|
|
47
|
+
return acc;
|
|
48
|
+
},
|
|
49
|
+
{}
|
|
50
|
+
)
|
|
51
|
+
}).then((response) => {
|
|
52
|
+
let currentMessageId = void 0;
|
|
53
|
+
let isInTextMessage = false;
|
|
54
|
+
return response.processDataStream({
|
|
55
|
+
onTextPart: (text) => {
|
|
56
|
+
if (currentMessageId === void 0) {
|
|
57
|
+
currentMessageId = generateUUID();
|
|
58
|
+
const message2 = {
|
|
59
|
+
type: client.EventType.TEXT_MESSAGE_START,
|
|
60
|
+
messageId: currentMessageId,
|
|
61
|
+
role: "assistant"
|
|
62
|
+
};
|
|
63
|
+
subscriber.next(message2);
|
|
64
|
+
isInTextMessage = true;
|
|
65
|
+
}
|
|
66
|
+
const message = {
|
|
67
|
+
type: client.EventType.TEXT_MESSAGE_CONTENT,
|
|
68
|
+
messageId: currentMessageId,
|
|
69
|
+
delta: text
|
|
70
|
+
};
|
|
71
|
+
subscriber.next(message);
|
|
72
|
+
},
|
|
73
|
+
onFinishMessagePart: () => {
|
|
74
|
+
if (currentMessageId !== void 0) {
|
|
75
|
+
const message = {
|
|
76
|
+
type: client.EventType.TEXT_MESSAGE_END,
|
|
77
|
+
messageId: currentMessageId
|
|
78
|
+
};
|
|
79
|
+
subscriber.next(message);
|
|
80
|
+
isInTextMessage = false;
|
|
81
|
+
}
|
|
82
|
+
subscriber.next({
|
|
83
|
+
type: client.EventType.RUN_FINISHED,
|
|
84
|
+
threadId: input.threadId,
|
|
85
|
+
runId: input.runId
|
|
86
|
+
});
|
|
87
|
+
subscriber.complete();
|
|
88
|
+
},
|
|
89
|
+
onToolCallPart(streamPart) {
|
|
90
|
+
const parentMessageId = currentMessageId || generateUUID();
|
|
91
|
+
if (isInTextMessage) {
|
|
92
|
+
const message = {
|
|
93
|
+
type: client.EventType.TEXT_MESSAGE_END,
|
|
94
|
+
messageId: parentMessageId
|
|
95
|
+
};
|
|
96
|
+
subscriber.next(message);
|
|
97
|
+
isInTextMessage = false;
|
|
98
|
+
}
|
|
99
|
+
subscriber.next({
|
|
100
|
+
type: client.EventType.TOOL_CALL_START,
|
|
101
|
+
toolCallId: streamPart.toolCallId,
|
|
102
|
+
toolCallName: streamPart.toolName,
|
|
103
|
+
parentMessageId
|
|
104
|
+
});
|
|
105
|
+
subscriber.next({
|
|
106
|
+
type: client.EventType.TOOL_CALL_ARGS,
|
|
107
|
+
toolCallId: streamPart.toolCallId,
|
|
108
|
+
delta: JSON.stringify(streamPart.args),
|
|
109
|
+
parentMessageId
|
|
110
|
+
});
|
|
111
|
+
subscriber.next({
|
|
112
|
+
type: client.EventType.TOOL_CALL_END,
|
|
113
|
+
toolCallId: streamPart.toolCallId,
|
|
114
|
+
parentMessageId
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}).catch((error) => {
|
|
119
|
+
console.error("error", error);
|
|
120
|
+
subscriber.error(error);
|
|
121
|
+
});
|
|
122
|
+
return () => {
|
|
123
|
+
};
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
function generateUUID() {
|
|
128
|
+
if (typeof crypto !== "undefined") {
|
|
129
|
+
if (typeof crypto.randomUUID === "function") {
|
|
130
|
+
return crypto.randomUUID();
|
|
131
|
+
}
|
|
132
|
+
if (typeof crypto.getRandomValues === "function") {
|
|
133
|
+
const buffer = new Uint8Array(16);
|
|
134
|
+
crypto.getRandomValues(buffer);
|
|
135
|
+
buffer[6] = buffer[6] & 15 | 64;
|
|
136
|
+
buffer[8] = buffer[8] & 63 | 128;
|
|
137
|
+
let hex = "";
|
|
138
|
+
for (let i = 0; i < 16; i++) {
|
|
139
|
+
hex += buffer[i].toString(16).padStart(2, "0");
|
|
140
|
+
if (i === 3 || i === 5 || i === 7 || i === 9) hex += "-";
|
|
141
|
+
}
|
|
142
|
+
return hex;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
146
|
+
const r = Math.random() * 16 | 0;
|
|
147
|
+
const v = c === "x" ? r : r & 3 | 8;
|
|
148
|
+
return v.toString(16);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function convertMessagesToMastraMessages(messages) {
|
|
152
|
+
const result = [];
|
|
153
|
+
for (const message of messages) {
|
|
154
|
+
if (message.role === "assistant") {
|
|
155
|
+
const parts = message.content ? [{ type: "text", text: message.content }] : [];
|
|
156
|
+
for (const toolCall of message.toolCalls ?? []) {
|
|
157
|
+
parts.push({
|
|
158
|
+
type: "tool-call",
|
|
159
|
+
toolCallId: toolCall.id,
|
|
160
|
+
toolName: toolCall.function.name,
|
|
161
|
+
args: JSON.parse(toolCall.function.arguments)
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
result.push({
|
|
165
|
+
role: "assistant",
|
|
166
|
+
content: parts
|
|
167
|
+
});
|
|
168
|
+
if (message.toolCalls?.length) {
|
|
169
|
+
result.push({
|
|
170
|
+
role: "tool",
|
|
171
|
+
content: message.toolCalls.map((toolCall) => ({
|
|
172
|
+
type: "tool-result",
|
|
173
|
+
toolCallId: toolCall.id,
|
|
174
|
+
toolName: toolCall.function.name,
|
|
175
|
+
result: JSON.parse(toolCall.function.arguments)
|
|
176
|
+
}))
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
} else if (message.role === "user") {
|
|
180
|
+
result.push({
|
|
181
|
+
role: "user",
|
|
182
|
+
content: message.content || ""
|
|
183
|
+
});
|
|
184
|
+
} else if (message.role === "tool") {
|
|
185
|
+
result.push({
|
|
186
|
+
role: "tool",
|
|
187
|
+
content: [
|
|
188
|
+
{
|
|
189
|
+
type: "tool-result",
|
|
190
|
+
toolCallId: message.toolCallId,
|
|
191
|
+
toolName: "unknown",
|
|
192
|
+
result: message.content
|
|
193
|
+
}
|
|
194
|
+
]
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
function zodToJsonSchema(zodSchema) {
|
|
201
|
+
if (!(zodSchema instanceof zod.ZodSchema)) {
|
|
202
|
+
return zodSchema;
|
|
203
|
+
}
|
|
204
|
+
return originalZodToJsonSchema__default.default(zodSchema, { $refStrategy: "none" });
|
|
205
|
+
}
|
|
206
|
+
function processClientTools(clientTools) {
|
|
207
|
+
if (!clientTools) {
|
|
208
|
+
return void 0;
|
|
209
|
+
}
|
|
210
|
+
return Object.fromEntries(
|
|
211
|
+
Object.entries(clientTools).map(([key, value]) => {
|
|
212
|
+
if (tools.isVercelTool(value)) {
|
|
213
|
+
return [
|
|
214
|
+
key,
|
|
215
|
+
{
|
|
216
|
+
...value,
|
|
217
|
+
parameters: value.parameters ? zodToJsonSchema(value.parameters) : void 0
|
|
218
|
+
}
|
|
219
|
+
];
|
|
220
|
+
} else {
|
|
221
|
+
return [
|
|
222
|
+
key,
|
|
223
|
+
{
|
|
224
|
+
...value,
|
|
225
|
+
inputSchema: value.inputSchema ? zodToJsonSchema(value.inputSchema) : void 0,
|
|
226
|
+
outputSchema: value.outputSchema ? zodToJsonSchema(value.outputSchema) : void 0
|
|
227
|
+
}
|
|
228
|
+
];
|
|
229
|
+
}
|
|
230
|
+
})
|
|
231
|
+
);
|
|
232
|
+
}
|
|
8
233
|
|
|
9
234
|
// src/resources/base.ts
|
|
10
235
|
var BaseResource = class {
|
|
@@ -24,9 +249,10 @@ var BaseResource = class {
|
|
|
24
249
|
let delay = backoffMs;
|
|
25
250
|
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
26
251
|
try {
|
|
27
|
-
const response = await fetch(`${baseUrl}${path}`, {
|
|
252
|
+
const response = await fetch(`${baseUrl.replace(/\/$/, "")}${path}`, {
|
|
28
253
|
...options,
|
|
29
254
|
headers: {
|
|
255
|
+
...options.method === "POST" || options.method === "PUT" ? { "content-type": "application/json" } : {},
|
|
30
256
|
...headers,
|
|
31
257
|
...options.headers
|
|
32
258
|
// TODO: Bring this back once we figure out what we/users need to do to make this work with cross-origin requests
|
|
@@ -64,8 +290,15 @@ var BaseResource = class {
|
|
|
64
290
|
throw lastError || new Error("Request failed");
|
|
65
291
|
}
|
|
66
292
|
};
|
|
67
|
-
|
|
68
|
-
|
|
293
|
+
function parseClientRuntimeContext(runtimeContext$1) {
|
|
294
|
+
if (runtimeContext$1) {
|
|
295
|
+
if (runtimeContext$1 instanceof runtimeContext.RuntimeContext) {
|
|
296
|
+
return Object.fromEntries(runtimeContext$1.entries());
|
|
297
|
+
}
|
|
298
|
+
return runtimeContext$1;
|
|
299
|
+
}
|
|
300
|
+
return void 0;
|
|
301
|
+
}
|
|
69
302
|
var AgentVoice = class extends BaseResource {
|
|
70
303
|
constructor(options, agentId) {
|
|
71
304
|
super(options);
|
|
@@ -112,6 +345,13 @@ var AgentVoice = class extends BaseResource {
|
|
|
112
345
|
getSpeakers() {
|
|
113
346
|
return this.request(`/api/agents/${this.agentId}/voice/speakers`);
|
|
114
347
|
}
|
|
348
|
+
/**
|
|
349
|
+
* Get the listener configuration for the agent's voice provider
|
|
350
|
+
* @returns Promise containing a check if the agent has listening capabilities
|
|
351
|
+
*/
|
|
352
|
+
getListener() {
|
|
353
|
+
return this.request(`/api/agents/${this.agentId}/voice/listener`);
|
|
354
|
+
}
|
|
115
355
|
};
|
|
116
356
|
var Agent = class extends BaseResource {
|
|
117
357
|
constructor(options, agentId) {
|
|
@@ -127,21 +367,318 @@ var Agent = class extends BaseResource {
|
|
|
127
367
|
details() {
|
|
128
368
|
return this.request(`/api/agents/${this.agentId}`);
|
|
129
369
|
}
|
|
130
|
-
|
|
131
|
-
* Generates a response from the agent
|
|
132
|
-
* @param params - Generation parameters including prompt
|
|
133
|
-
* @returns Promise containing the generated response
|
|
134
|
-
*/
|
|
135
|
-
generate(params) {
|
|
370
|
+
async generate(params) {
|
|
136
371
|
const processedParams = {
|
|
137
372
|
...params,
|
|
138
|
-
output: params.output
|
|
139
|
-
experimental_output: params.experimental_output
|
|
373
|
+
output: params.output ? zodToJsonSchema(params.output) : void 0,
|
|
374
|
+
experimental_output: params.experimental_output ? zodToJsonSchema(params.experimental_output) : void 0,
|
|
375
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext),
|
|
376
|
+
clientTools: processClientTools(params.clientTools)
|
|
140
377
|
};
|
|
141
|
-
|
|
378
|
+
const { runId, resourceId, threadId, runtimeContext } = processedParams;
|
|
379
|
+
const response = await this.request(`/api/agents/${this.agentId}/generate`, {
|
|
142
380
|
method: "POST",
|
|
143
381
|
body: processedParams
|
|
144
382
|
});
|
|
383
|
+
if (response.finishReason === "tool-calls") {
|
|
384
|
+
for (const toolCall of response.toolCalls) {
|
|
385
|
+
const clientTool = params.clientTools?.[toolCall.toolName];
|
|
386
|
+
if (clientTool && clientTool.execute) {
|
|
387
|
+
const result = await clientTool.execute(
|
|
388
|
+
{ context: toolCall?.args, runId, resourceId, threadId, runtimeContext },
|
|
389
|
+
{
|
|
390
|
+
messages: response.messages,
|
|
391
|
+
toolCallId: toolCall?.toolCallId
|
|
392
|
+
}
|
|
393
|
+
);
|
|
394
|
+
const updatedMessages = [
|
|
395
|
+
{
|
|
396
|
+
role: "user",
|
|
397
|
+
content: params.messages
|
|
398
|
+
},
|
|
399
|
+
...response.response.messages,
|
|
400
|
+
{
|
|
401
|
+
role: "tool",
|
|
402
|
+
content: [
|
|
403
|
+
{
|
|
404
|
+
type: "tool-result",
|
|
405
|
+
toolCallId: toolCall.toolCallId,
|
|
406
|
+
toolName: toolCall.toolName,
|
|
407
|
+
result
|
|
408
|
+
}
|
|
409
|
+
]
|
|
410
|
+
}
|
|
411
|
+
];
|
|
412
|
+
return this.generate({
|
|
413
|
+
...params,
|
|
414
|
+
messages: updatedMessages
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
return response;
|
|
420
|
+
}
|
|
421
|
+
async processChatResponse({
|
|
422
|
+
stream,
|
|
423
|
+
update,
|
|
424
|
+
onToolCall,
|
|
425
|
+
onFinish,
|
|
426
|
+
getCurrentDate = () => /* @__PURE__ */ new Date(),
|
|
427
|
+
lastMessage
|
|
428
|
+
}) {
|
|
429
|
+
const replaceLastMessage = lastMessage?.role === "assistant";
|
|
430
|
+
let step = replaceLastMessage ? 1 + // find max step in existing tool invocations:
|
|
431
|
+
(lastMessage.toolInvocations?.reduce((max, toolInvocation) => {
|
|
432
|
+
return Math.max(max, toolInvocation.step ?? 0);
|
|
433
|
+
}, 0) ?? 0) : 0;
|
|
434
|
+
const message = replaceLastMessage ? structuredClone(lastMessage) : {
|
|
435
|
+
id: crypto.randomUUID(),
|
|
436
|
+
createdAt: getCurrentDate(),
|
|
437
|
+
role: "assistant",
|
|
438
|
+
content: "",
|
|
439
|
+
parts: []
|
|
440
|
+
};
|
|
441
|
+
let currentTextPart = void 0;
|
|
442
|
+
let currentReasoningPart = void 0;
|
|
443
|
+
let currentReasoningTextDetail = void 0;
|
|
444
|
+
function updateToolInvocationPart(toolCallId, invocation) {
|
|
445
|
+
const part = message.parts.find(
|
|
446
|
+
(part2) => part2.type === "tool-invocation" && part2.toolInvocation.toolCallId === toolCallId
|
|
447
|
+
);
|
|
448
|
+
if (part != null) {
|
|
449
|
+
part.toolInvocation = invocation;
|
|
450
|
+
} else {
|
|
451
|
+
message.parts.push({
|
|
452
|
+
type: "tool-invocation",
|
|
453
|
+
toolInvocation: invocation
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
const data = [];
|
|
458
|
+
let messageAnnotations = replaceLastMessage ? lastMessage?.annotations : void 0;
|
|
459
|
+
const partialToolCalls = {};
|
|
460
|
+
let usage = {
|
|
461
|
+
completionTokens: NaN,
|
|
462
|
+
promptTokens: NaN,
|
|
463
|
+
totalTokens: NaN
|
|
464
|
+
};
|
|
465
|
+
let finishReason = "unknown";
|
|
466
|
+
function execUpdate() {
|
|
467
|
+
const copiedData = [...data];
|
|
468
|
+
if (messageAnnotations?.length) {
|
|
469
|
+
message.annotations = messageAnnotations;
|
|
470
|
+
}
|
|
471
|
+
const copiedMessage = {
|
|
472
|
+
// deep copy the message to ensure that deep changes (msg attachments) are updated
|
|
473
|
+
// with SolidJS. SolidJS uses referential integration of sub-objects to detect changes.
|
|
474
|
+
...structuredClone(message),
|
|
475
|
+
// add a revision id to ensure that the message is updated with SWR. SWR uses a
|
|
476
|
+
// hashing approach by default to detect changes, but it only works for shallow
|
|
477
|
+
// changes. This is why we need to add a revision id to ensure that the message
|
|
478
|
+
// is updated with SWR (without it, the changes get stuck in SWR and are not
|
|
479
|
+
// forwarded to rendering):
|
|
480
|
+
revisionId: crypto.randomUUID()
|
|
481
|
+
};
|
|
482
|
+
update({
|
|
483
|
+
message: copiedMessage,
|
|
484
|
+
data: copiedData,
|
|
485
|
+
replaceLastMessage
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
await uiUtils.processDataStream({
|
|
489
|
+
stream,
|
|
490
|
+
onTextPart(value) {
|
|
491
|
+
if (currentTextPart == null) {
|
|
492
|
+
currentTextPart = {
|
|
493
|
+
type: "text",
|
|
494
|
+
text: value
|
|
495
|
+
};
|
|
496
|
+
message.parts.push(currentTextPart);
|
|
497
|
+
} else {
|
|
498
|
+
currentTextPart.text += value;
|
|
499
|
+
}
|
|
500
|
+
message.content += value;
|
|
501
|
+
execUpdate();
|
|
502
|
+
},
|
|
503
|
+
onReasoningPart(value) {
|
|
504
|
+
if (currentReasoningTextDetail == null) {
|
|
505
|
+
currentReasoningTextDetail = { type: "text", text: value };
|
|
506
|
+
if (currentReasoningPart != null) {
|
|
507
|
+
currentReasoningPart.details.push(currentReasoningTextDetail);
|
|
508
|
+
}
|
|
509
|
+
} else {
|
|
510
|
+
currentReasoningTextDetail.text += value;
|
|
511
|
+
}
|
|
512
|
+
if (currentReasoningPart == null) {
|
|
513
|
+
currentReasoningPart = {
|
|
514
|
+
type: "reasoning",
|
|
515
|
+
reasoning: value,
|
|
516
|
+
details: [currentReasoningTextDetail]
|
|
517
|
+
};
|
|
518
|
+
message.parts.push(currentReasoningPart);
|
|
519
|
+
} else {
|
|
520
|
+
currentReasoningPart.reasoning += value;
|
|
521
|
+
}
|
|
522
|
+
message.reasoning = (message.reasoning ?? "") + value;
|
|
523
|
+
execUpdate();
|
|
524
|
+
},
|
|
525
|
+
onReasoningSignaturePart(value) {
|
|
526
|
+
if (currentReasoningTextDetail != null) {
|
|
527
|
+
currentReasoningTextDetail.signature = value.signature;
|
|
528
|
+
}
|
|
529
|
+
},
|
|
530
|
+
onRedactedReasoningPart(value) {
|
|
531
|
+
if (currentReasoningPart == null) {
|
|
532
|
+
currentReasoningPart = {
|
|
533
|
+
type: "reasoning",
|
|
534
|
+
reasoning: "",
|
|
535
|
+
details: []
|
|
536
|
+
};
|
|
537
|
+
message.parts.push(currentReasoningPart);
|
|
538
|
+
}
|
|
539
|
+
currentReasoningPart.details.push({
|
|
540
|
+
type: "redacted",
|
|
541
|
+
data: value.data
|
|
542
|
+
});
|
|
543
|
+
currentReasoningTextDetail = void 0;
|
|
544
|
+
execUpdate();
|
|
545
|
+
},
|
|
546
|
+
onFilePart(value) {
|
|
547
|
+
message.parts.push({
|
|
548
|
+
type: "file",
|
|
549
|
+
mimeType: value.mimeType,
|
|
550
|
+
data: value.data
|
|
551
|
+
});
|
|
552
|
+
execUpdate();
|
|
553
|
+
},
|
|
554
|
+
onSourcePart(value) {
|
|
555
|
+
message.parts.push({
|
|
556
|
+
type: "source",
|
|
557
|
+
source: value
|
|
558
|
+
});
|
|
559
|
+
execUpdate();
|
|
560
|
+
},
|
|
561
|
+
onToolCallStreamingStartPart(value) {
|
|
562
|
+
if (message.toolInvocations == null) {
|
|
563
|
+
message.toolInvocations = [];
|
|
564
|
+
}
|
|
565
|
+
partialToolCalls[value.toolCallId] = {
|
|
566
|
+
text: "",
|
|
567
|
+
step,
|
|
568
|
+
toolName: value.toolName,
|
|
569
|
+
index: message.toolInvocations.length
|
|
570
|
+
};
|
|
571
|
+
const invocation = {
|
|
572
|
+
state: "partial-call",
|
|
573
|
+
step,
|
|
574
|
+
toolCallId: value.toolCallId,
|
|
575
|
+
toolName: value.toolName,
|
|
576
|
+
args: void 0
|
|
577
|
+
};
|
|
578
|
+
message.toolInvocations.push(invocation);
|
|
579
|
+
updateToolInvocationPart(value.toolCallId, invocation);
|
|
580
|
+
execUpdate();
|
|
581
|
+
},
|
|
582
|
+
onToolCallDeltaPart(value) {
|
|
583
|
+
const partialToolCall = partialToolCalls[value.toolCallId];
|
|
584
|
+
partialToolCall.text += value.argsTextDelta;
|
|
585
|
+
const { value: partialArgs } = uiUtils.parsePartialJson(partialToolCall.text);
|
|
586
|
+
const invocation = {
|
|
587
|
+
state: "partial-call",
|
|
588
|
+
step: partialToolCall.step,
|
|
589
|
+
toolCallId: value.toolCallId,
|
|
590
|
+
toolName: partialToolCall.toolName,
|
|
591
|
+
args: partialArgs
|
|
592
|
+
};
|
|
593
|
+
message.toolInvocations[partialToolCall.index] = invocation;
|
|
594
|
+
updateToolInvocationPart(value.toolCallId, invocation);
|
|
595
|
+
execUpdate();
|
|
596
|
+
},
|
|
597
|
+
async onToolCallPart(value) {
|
|
598
|
+
const invocation = {
|
|
599
|
+
state: "call",
|
|
600
|
+
step,
|
|
601
|
+
...value
|
|
602
|
+
};
|
|
603
|
+
if (partialToolCalls[value.toolCallId] != null) {
|
|
604
|
+
message.toolInvocations[partialToolCalls[value.toolCallId].index] = invocation;
|
|
605
|
+
} else {
|
|
606
|
+
if (message.toolInvocations == null) {
|
|
607
|
+
message.toolInvocations = [];
|
|
608
|
+
}
|
|
609
|
+
message.toolInvocations.push(invocation);
|
|
610
|
+
}
|
|
611
|
+
updateToolInvocationPart(value.toolCallId, invocation);
|
|
612
|
+
execUpdate();
|
|
613
|
+
if (onToolCall) {
|
|
614
|
+
const result = await onToolCall({ toolCall: value });
|
|
615
|
+
if (result != null) {
|
|
616
|
+
const invocation2 = {
|
|
617
|
+
state: "result",
|
|
618
|
+
step,
|
|
619
|
+
...value,
|
|
620
|
+
result
|
|
621
|
+
};
|
|
622
|
+
message.toolInvocations[message.toolInvocations.length - 1] = invocation2;
|
|
623
|
+
updateToolInvocationPart(value.toolCallId, invocation2);
|
|
624
|
+
execUpdate();
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
},
|
|
628
|
+
onToolResultPart(value) {
|
|
629
|
+
const toolInvocations = message.toolInvocations;
|
|
630
|
+
if (toolInvocations == null) {
|
|
631
|
+
throw new Error("tool_result must be preceded by a tool_call");
|
|
632
|
+
}
|
|
633
|
+
const toolInvocationIndex = toolInvocations.findIndex((invocation2) => invocation2.toolCallId === value.toolCallId);
|
|
634
|
+
if (toolInvocationIndex === -1) {
|
|
635
|
+
throw new Error("tool_result must be preceded by a tool_call with the same toolCallId");
|
|
636
|
+
}
|
|
637
|
+
const invocation = {
|
|
638
|
+
...toolInvocations[toolInvocationIndex],
|
|
639
|
+
state: "result",
|
|
640
|
+
...value
|
|
641
|
+
};
|
|
642
|
+
toolInvocations[toolInvocationIndex] = invocation;
|
|
643
|
+
updateToolInvocationPart(value.toolCallId, invocation);
|
|
644
|
+
execUpdate();
|
|
645
|
+
},
|
|
646
|
+
onDataPart(value) {
|
|
647
|
+
data.push(...value);
|
|
648
|
+
execUpdate();
|
|
649
|
+
},
|
|
650
|
+
onMessageAnnotationsPart(value) {
|
|
651
|
+
if (messageAnnotations == null) {
|
|
652
|
+
messageAnnotations = [...value];
|
|
653
|
+
} else {
|
|
654
|
+
messageAnnotations.push(...value);
|
|
655
|
+
}
|
|
656
|
+
execUpdate();
|
|
657
|
+
},
|
|
658
|
+
onFinishStepPart(value) {
|
|
659
|
+
step += 1;
|
|
660
|
+
currentTextPart = value.isContinued ? currentTextPart : void 0;
|
|
661
|
+
currentReasoningPart = void 0;
|
|
662
|
+
currentReasoningTextDetail = void 0;
|
|
663
|
+
},
|
|
664
|
+
onStartStepPart(value) {
|
|
665
|
+
if (!replaceLastMessage) {
|
|
666
|
+
message.id = value.messageId;
|
|
667
|
+
}
|
|
668
|
+
message.parts.push({ type: "step-start" });
|
|
669
|
+
execUpdate();
|
|
670
|
+
},
|
|
671
|
+
onFinishMessagePart(value) {
|
|
672
|
+
finishReason = value.finishReason;
|
|
673
|
+
if (value.usage != null) {
|
|
674
|
+
usage = value.usage;
|
|
675
|
+
}
|
|
676
|
+
},
|
|
677
|
+
onErrorPart(error) {
|
|
678
|
+
throw new Error(error);
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
onFinish?.({ message, finishReason, usage });
|
|
145
682
|
}
|
|
146
683
|
/**
|
|
147
684
|
* Streams a response from the agent
|
|
@@ -151,9 +688,30 @@ var Agent = class extends BaseResource {
|
|
|
151
688
|
async stream(params) {
|
|
152
689
|
const processedParams = {
|
|
153
690
|
...params,
|
|
154
|
-
output: params.output
|
|
155
|
-
experimental_output: params.experimental_output
|
|
691
|
+
output: params.output ? zodToJsonSchema(params.output) : void 0,
|
|
692
|
+
experimental_output: params.experimental_output ? zodToJsonSchema(params.experimental_output) : void 0,
|
|
693
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext),
|
|
694
|
+
clientTools: processClientTools(params.clientTools)
|
|
695
|
+
};
|
|
696
|
+
const { readable, writable } = new TransformStream();
|
|
697
|
+
const response = await this.processStreamResponse(processedParams, writable);
|
|
698
|
+
const streamResponse = new Response(readable, {
|
|
699
|
+
status: response.status,
|
|
700
|
+
statusText: response.statusText,
|
|
701
|
+
headers: response.headers
|
|
702
|
+
});
|
|
703
|
+
streamResponse.processDataStream = async (options = {}) => {
|
|
704
|
+
await uiUtils.processDataStream({
|
|
705
|
+
stream: streamResponse.body,
|
|
706
|
+
...options
|
|
707
|
+
});
|
|
156
708
|
};
|
|
709
|
+
return streamResponse;
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* Processes the stream response and handles tool calls
|
|
713
|
+
*/
|
|
714
|
+
async processStreamResponse(processedParams, writable) {
|
|
157
715
|
const response = await this.request(`/api/agents/${this.agentId}/stream`, {
|
|
158
716
|
method: "POST",
|
|
159
717
|
body: processedParams,
|
|
@@ -162,12 +720,95 @@ var Agent = class extends BaseResource {
|
|
|
162
720
|
if (!response.body) {
|
|
163
721
|
throw new Error("No response body");
|
|
164
722
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
723
|
+
try {
|
|
724
|
+
let toolCalls = [];
|
|
725
|
+
let messages = [];
|
|
726
|
+
const [streamForWritable, streamForProcessing] = response.body.tee();
|
|
727
|
+
streamForWritable.pipeTo(writable, {
|
|
728
|
+
preventClose: true
|
|
729
|
+
}).catch((error) => {
|
|
730
|
+
console.error("Error piping to writable stream:", error);
|
|
169
731
|
});
|
|
170
|
-
|
|
732
|
+
this.processChatResponse({
|
|
733
|
+
stream: streamForProcessing,
|
|
734
|
+
update: ({ message }) => {
|
|
735
|
+
messages.push(message);
|
|
736
|
+
},
|
|
737
|
+
onFinish: async ({ finishReason, message }) => {
|
|
738
|
+
if (finishReason === "tool-calls") {
|
|
739
|
+
const toolCall = [...message?.parts ?? []].reverse().find((part) => part.type === "tool-invocation")?.toolInvocation;
|
|
740
|
+
if (toolCall) {
|
|
741
|
+
toolCalls.push(toolCall);
|
|
742
|
+
}
|
|
743
|
+
for (const toolCall2 of toolCalls) {
|
|
744
|
+
const clientTool = processedParams.clientTools?.[toolCall2.toolName];
|
|
745
|
+
if (clientTool && clientTool.execute) {
|
|
746
|
+
const result = await clientTool.execute(
|
|
747
|
+
{
|
|
748
|
+
context: toolCall2?.args,
|
|
749
|
+
runId: processedParams.runId,
|
|
750
|
+
resourceId: processedParams.resourceId,
|
|
751
|
+
threadId: processedParams.threadId,
|
|
752
|
+
runtimeContext: processedParams.runtimeContext
|
|
753
|
+
},
|
|
754
|
+
{
|
|
755
|
+
messages: response.messages,
|
|
756
|
+
toolCallId: toolCall2?.toolCallId
|
|
757
|
+
}
|
|
758
|
+
);
|
|
759
|
+
const lastMessage = JSON.parse(JSON.stringify(messages[messages.length - 1]));
|
|
760
|
+
const toolInvocationPart = lastMessage?.parts?.find(
|
|
761
|
+
(part) => part.type === "tool-invocation" && part.toolInvocation?.toolCallId === toolCall2.toolCallId
|
|
762
|
+
);
|
|
763
|
+
if (toolInvocationPart) {
|
|
764
|
+
toolInvocationPart.toolInvocation = {
|
|
765
|
+
...toolInvocationPart.toolInvocation,
|
|
766
|
+
state: "result",
|
|
767
|
+
result
|
|
768
|
+
};
|
|
769
|
+
}
|
|
770
|
+
const toolInvocation = lastMessage?.toolInvocations?.find(
|
|
771
|
+
(toolInvocation2) => toolInvocation2.toolCallId === toolCall2.toolCallId
|
|
772
|
+
);
|
|
773
|
+
if (toolInvocation) {
|
|
774
|
+
toolInvocation.state = "result";
|
|
775
|
+
toolInvocation.result = result;
|
|
776
|
+
}
|
|
777
|
+
const writer = writable.getWriter();
|
|
778
|
+
try {
|
|
779
|
+
await writer.write(
|
|
780
|
+
new TextEncoder().encode(
|
|
781
|
+
"a:" + JSON.stringify({
|
|
782
|
+
toolCallId: toolCall2.toolCallId,
|
|
783
|
+
result
|
|
784
|
+
}) + "\n"
|
|
785
|
+
)
|
|
786
|
+
);
|
|
787
|
+
} finally {
|
|
788
|
+
writer.releaseLock();
|
|
789
|
+
}
|
|
790
|
+
const originalMessages = processedParams.messages;
|
|
791
|
+
const messageArray = Array.isArray(originalMessages) ? originalMessages : [originalMessages];
|
|
792
|
+
this.processStreamResponse(
|
|
793
|
+
{
|
|
794
|
+
...processedParams,
|
|
795
|
+
messages: [...messageArray, ...messages, lastMessage]
|
|
796
|
+
},
|
|
797
|
+
writable
|
|
798
|
+
);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
} else {
|
|
802
|
+
setTimeout(() => {
|
|
803
|
+
writable.close();
|
|
804
|
+
}, 0);
|
|
805
|
+
}
|
|
806
|
+
},
|
|
807
|
+
lastMessage: void 0
|
|
808
|
+
});
|
|
809
|
+
} catch (error) {
|
|
810
|
+
console.error("Error processing stream response:", error);
|
|
811
|
+
}
|
|
171
812
|
return response;
|
|
172
813
|
}
|
|
173
814
|
/**
|
|
@@ -178,6 +819,22 @@ var Agent = class extends BaseResource {
|
|
|
178
819
|
getTool(toolId) {
|
|
179
820
|
return this.request(`/api/agents/${this.agentId}/tools/${toolId}`);
|
|
180
821
|
}
|
|
822
|
+
/**
|
|
823
|
+
* Executes a tool for the agent
|
|
824
|
+
* @param toolId - ID of the tool to execute
|
|
825
|
+
* @param params - Parameters required for tool execution
|
|
826
|
+
* @returns Promise containing the tool execution results
|
|
827
|
+
*/
|
|
828
|
+
executeTool(toolId, params) {
|
|
829
|
+
const body = {
|
|
830
|
+
data: params.data,
|
|
831
|
+
runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0
|
|
832
|
+
};
|
|
833
|
+
return this.request(`/api/agents/${this.agentId}/tools/${toolId}/execute`, {
|
|
834
|
+
method: "POST",
|
|
835
|
+
body
|
|
836
|
+
});
|
|
837
|
+
}
|
|
181
838
|
/**
|
|
182
839
|
* Retrieves evaluation results for the agent
|
|
183
840
|
* @returns Promise containing agent evaluations
|
|
@@ -213,8 +870,8 @@ var Network = class extends BaseResource {
|
|
|
213
870
|
generate(params) {
|
|
214
871
|
const processedParams = {
|
|
215
872
|
...params,
|
|
216
|
-
output:
|
|
217
|
-
experimental_output:
|
|
873
|
+
output: zodToJsonSchema(params.output),
|
|
874
|
+
experimental_output: zodToJsonSchema(params.experimental_output)
|
|
218
875
|
};
|
|
219
876
|
return this.request(`/api/networks/${this.networkId}/generate`, {
|
|
220
877
|
method: "POST",
|
|
@@ -229,8 +886,8 @@ var Network = class extends BaseResource {
|
|
|
229
886
|
async stream(params) {
|
|
230
887
|
const processedParams = {
|
|
231
888
|
...params,
|
|
232
|
-
output:
|
|
233
|
-
experimental_output:
|
|
889
|
+
output: zodToJsonSchema(params.output),
|
|
890
|
+
experimental_output: zodToJsonSchema(params.experimental_output)
|
|
234
891
|
};
|
|
235
892
|
const response = await this.request(`/api/networks/${this.networkId}/stream`, {
|
|
236
893
|
method: "POST",
|
|
@@ -286,10 +943,15 @@ var MemoryThread = class extends BaseResource {
|
|
|
286
943
|
}
|
|
287
944
|
/**
|
|
288
945
|
* Retrieves messages associated with the thread
|
|
946
|
+
* @param params - Optional parameters including limit for number of messages to retrieve
|
|
289
947
|
* @returns Promise containing thread messages and UI messages
|
|
290
948
|
*/
|
|
291
|
-
getMessages() {
|
|
292
|
-
|
|
949
|
+
getMessages(params) {
|
|
950
|
+
const query = new URLSearchParams({
|
|
951
|
+
agentId: this.agentId,
|
|
952
|
+
...params?.limit ? { limit: params.limit.toString() } : {}
|
|
953
|
+
});
|
|
954
|
+
return this.request(`/api/memory/threads/${this.threadId}/messages?${query.toString()}`);
|
|
293
955
|
}
|
|
294
956
|
};
|
|
295
957
|
|
|
@@ -359,24 +1021,24 @@ var Vector = class extends BaseResource {
|
|
|
359
1021
|
}
|
|
360
1022
|
};
|
|
361
1023
|
|
|
362
|
-
// src/resources/workflow.ts
|
|
1024
|
+
// src/resources/legacy-workflow.ts
|
|
363
1025
|
var RECORD_SEPARATOR = "";
|
|
364
|
-
var
|
|
1026
|
+
var LegacyWorkflow = class extends BaseResource {
|
|
365
1027
|
constructor(options, workflowId) {
|
|
366
1028
|
super(options);
|
|
367
1029
|
this.workflowId = workflowId;
|
|
368
1030
|
}
|
|
369
1031
|
/**
|
|
370
|
-
* Retrieves details about the workflow
|
|
371
|
-
* @returns Promise containing workflow details including steps and graphs
|
|
1032
|
+
* Retrieves details about the legacy workflow
|
|
1033
|
+
* @returns Promise containing legacy workflow details including steps and graphs
|
|
372
1034
|
*/
|
|
373
1035
|
details() {
|
|
374
|
-
return this.request(`/api/workflows/${this.workflowId}`);
|
|
1036
|
+
return this.request(`/api/workflows/legacy/${this.workflowId}`);
|
|
375
1037
|
}
|
|
376
1038
|
/**
|
|
377
|
-
* Retrieves all runs for a workflow
|
|
1039
|
+
* Retrieves all runs for a legacy workflow
|
|
378
1040
|
* @param params - Parameters for filtering runs
|
|
379
|
-
* @returns Promise containing workflow runs array
|
|
1041
|
+
* @returns Promise containing legacy workflow runs array
|
|
380
1042
|
*/
|
|
381
1043
|
runs(params) {
|
|
382
1044
|
const searchParams = new URLSearchParams();
|
|
@@ -396,25 +1058,13 @@ var Workflow = class extends BaseResource {
|
|
|
396
1058
|
searchParams.set("resourceId", params.resourceId);
|
|
397
1059
|
}
|
|
398
1060
|
if (searchParams.size) {
|
|
399
|
-
return this.request(`/api/workflows/${this.workflowId}/runs?${searchParams}`);
|
|
1061
|
+
return this.request(`/api/workflows/legacy/${this.workflowId}/runs?${searchParams}`);
|
|
400
1062
|
} else {
|
|
401
|
-
return this.request(`/api/workflows/${this.workflowId}/runs`);
|
|
1063
|
+
return this.request(`/api/workflows/legacy/${this.workflowId}/runs`);
|
|
402
1064
|
}
|
|
403
1065
|
}
|
|
404
1066
|
/**
|
|
405
|
-
*
|
|
406
|
-
* Executes the workflow with the provided parameters
|
|
407
|
-
* @param params - Parameters required for workflow execution
|
|
408
|
-
* @returns Promise containing the workflow execution results
|
|
409
|
-
*/
|
|
410
|
-
execute(params) {
|
|
411
|
-
return this.request(`/api/workflows/${this.workflowId}/execute`, {
|
|
412
|
-
method: "POST",
|
|
413
|
-
body: params
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
/**
|
|
417
|
-
* Creates a new workflow run
|
|
1067
|
+
* Creates a new legacy workflow run
|
|
418
1068
|
* @returns Promise containing the generated run ID
|
|
419
1069
|
*/
|
|
420
1070
|
createRun(params) {
|
|
@@ -422,34 +1072,34 @@ var Workflow = class extends BaseResource {
|
|
|
422
1072
|
if (!!params?.runId) {
|
|
423
1073
|
searchParams.set("runId", params.runId);
|
|
424
1074
|
}
|
|
425
|
-
return this.request(`/api/workflows/${this.workflowId}/
|
|
1075
|
+
return this.request(`/api/workflows/legacy/${this.workflowId}/create-run?${searchParams.toString()}`, {
|
|
426
1076
|
method: "POST"
|
|
427
1077
|
});
|
|
428
1078
|
}
|
|
429
1079
|
/**
|
|
430
|
-
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
1080
|
+
* Starts a legacy workflow run synchronously without waiting for the workflow to complete
|
|
431
1081
|
* @param params - Object containing the runId and triggerData
|
|
432
1082
|
* @returns Promise containing success message
|
|
433
1083
|
*/
|
|
434
1084
|
start(params) {
|
|
435
|
-
return this.request(`/api/workflows/${this.workflowId}/start?runId=${params.runId}`, {
|
|
1085
|
+
return this.request(`/api/workflows/legacy/${this.workflowId}/start?runId=${params.runId}`, {
|
|
436
1086
|
method: "POST",
|
|
437
1087
|
body: params?.triggerData
|
|
438
1088
|
});
|
|
439
1089
|
}
|
|
440
1090
|
/**
|
|
441
|
-
* Resumes a suspended workflow step synchronously without waiting for the workflow to complete
|
|
1091
|
+
* Resumes a suspended legacy workflow step synchronously without waiting for the workflow to complete
|
|
442
1092
|
* @param stepId - ID of the step to resume
|
|
443
|
-
* @param runId - ID of the workflow run
|
|
444
|
-
* @param context - Context to resume the workflow with
|
|
445
|
-
* @returns Promise containing the workflow resume results
|
|
1093
|
+
* @param runId - ID of the legacy workflow run
|
|
1094
|
+
* @param context - Context to resume the legacy workflow with
|
|
1095
|
+
* @returns Promise containing the legacy workflow resume results
|
|
446
1096
|
*/
|
|
447
1097
|
resume({
|
|
448
1098
|
stepId,
|
|
449
1099
|
runId,
|
|
450
1100
|
context
|
|
451
1101
|
}) {
|
|
452
|
-
return this.request(`/api/workflows/${this.workflowId}/resume?runId=${runId}`, {
|
|
1102
|
+
return this.request(`/api/workflows/legacy/${this.workflowId}/resume?runId=${runId}`, {
|
|
453
1103
|
method: "POST",
|
|
454
1104
|
body: {
|
|
455
1105
|
stepId,
|
|
@@ -467,18 +1117,18 @@ var Workflow = class extends BaseResource {
|
|
|
467
1117
|
if (!!params?.runId) {
|
|
468
1118
|
searchParams.set("runId", params.runId);
|
|
469
1119
|
}
|
|
470
|
-
return this.request(`/api/workflows/${this.workflowId}/start-async?${searchParams.toString()}`, {
|
|
1120
|
+
return this.request(`/api/workflows/legacy/${this.workflowId}/start-async?${searchParams.toString()}`, {
|
|
471
1121
|
method: "POST",
|
|
472
1122
|
body: params?.triggerData
|
|
473
1123
|
});
|
|
474
1124
|
}
|
|
475
1125
|
/**
|
|
476
|
-
* Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
|
|
1126
|
+
* Resumes a suspended legacy workflow step asynchronously and returns a promise that resolves when the workflow is complete
|
|
477
1127
|
* @param params - Object containing the runId, stepId, and context
|
|
478
1128
|
* @returns Promise containing the workflow resume results
|
|
479
1129
|
*/
|
|
480
1130
|
resumeAsync(params) {
|
|
481
|
-
return this.request(`/api/workflows/${this.workflowId}/resume-async?runId=${params.runId}`, {
|
|
1131
|
+
return this.request(`/api/workflows/legacy/${this.workflowId}/resume-async?runId=${params.runId}`, {
|
|
482
1132
|
method: "POST",
|
|
483
1133
|
body: {
|
|
484
1134
|
stepId: params.stepId,
|
|
@@ -532,16 +1182,16 @@ var Workflow = class extends BaseResource {
|
|
|
532
1182
|
}
|
|
533
1183
|
}
|
|
534
1184
|
/**
|
|
535
|
-
* Watches workflow transitions in real-time
|
|
1185
|
+
* Watches legacy workflow transitions in real-time
|
|
536
1186
|
* @param runId - Optional run ID to filter the watch stream
|
|
537
|
-
* @returns AsyncGenerator that yields parsed records from the workflow watch stream
|
|
1187
|
+
* @returns AsyncGenerator that yields parsed records from the legacy workflow watch stream
|
|
538
1188
|
*/
|
|
539
1189
|
async watch({ runId }, onRecord) {
|
|
540
|
-
const response = await this.request(`/api/workflows/${this.workflowId}/watch?runId=${runId}`, {
|
|
1190
|
+
const response = await this.request(`/api/workflows/legacy/${this.workflowId}/watch?runId=${runId}`, {
|
|
541
1191
|
stream: true
|
|
542
1192
|
});
|
|
543
1193
|
if (!response.ok) {
|
|
544
|
-
throw new Error(`Failed to watch workflow: ${response.statusText}`);
|
|
1194
|
+
throw new Error(`Failed to watch legacy workflow: ${response.statusText}`);
|
|
545
1195
|
}
|
|
546
1196
|
if (!response.body) {
|
|
547
1197
|
throw new Error("Response body is null");
|
|
@@ -553,7 +1203,7 @@ var Workflow = class extends BaseResource {
|
|
|
553
1203
|
};
|
|
554
1204
|
|
|
555
1205
|
// src/resources/tool.ts
|
|
556
|
-
var
|
|
1206
|
+
var Tool2 = class extends BaseResource {
|
|
557
1207
|
constructor(options, toolId) {
|
|
558
1208
|
super(options);
|
|
559
1209
|
this.toolId = toolId;
|
|
@@ -575,22 +1225,26 @@ var Tool = class extends BaseResource {
|
|
|
575
1225
|
if (params.runId) {
|
|
576
1226
|
url.set("runId", params.runId);
|
|
577
1227
|
}
|
|
1228
|
+
const body = {
|
|
1229
|
+
data: params.data,
|
|
1230
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
1231
|
+
};
|
|
578
1232
|
return this.request(`/api/tools/${this.toolId}/execute?${url.toString()}`, {
|
|
579
1233
|
method: "POST",
|
|
580
|
-
body
|
|
1234
|
+
body
|
|
581
1235
|
});
|
|
582
1236
|
}
|
|
583
1237
|
};
|
|
584
1238
|
|
|
585
|
-
// src/resources/
|
|
1239
|
+
// src/resources/workflow.ts
|
|
586
1240
|
var RECORD_SEPARATOR2 = "";
|
|
587
|
-
var
|
|
1241
|
+
var Workflow = class extends BaseResource {
|
|
588
1242
|
constructor(options, workflowId) {
|
|
589
1243
|
super(options);
|
|
590
1244
|
this.workflowId = workflowId;
|
|
591
1245
|
}
|
|
592
1246
|
/**
|
|
593
|
-
* Creates an async generator that processes a readable stream and yields
|
|
1247
|
+
* Creates an async generator that processes a readable stream and yields workflow records
|
|
594
1248
|
* separated by the Record Separator character (\x1E)
|
|
595
1249
|
*
|
|
596
1250
|
* @param stream - The readable stream to process
|
|
@@ -635,16 +1289,16 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
635
1289
|
}
|
|
636
1290
|
}
|
|
637
1291
|
/**
|
|
638
|
-
* Retrieves details about the
|
|
639
|
-
* @returns Promise containing
|
|
1292
|
+
* Retrieves details about the workflow
|
|
1293
|
+
* @returns Promise containing workflow details including steps and graphs
|
|
640
1294
|
*/
|
|
641
1295
|
details() {
|
|
642
|
-
return this.request(`/api/workflows
|
|
1296
|
+
return this.request(`/api/workflows/${this.workflowId}`);
|
|
643
1297
|
}
|
|
644
1298
|
/**
|
|
645
|
-
* Retrieves all runs for a
|
|
1299
|
+
* Retrieves all runs for a workflow
|
|
646
1300
|
* @param params - Parameters for filtering runs
|
|
647
|
-
* @returns Promise containing
|
|
1301
|
+
* @returns Promise containing workflow runs array
|
|
648
1302
|
*/
|
|
649
1303
|
runs(params) {
|
|
650
1304
|
const searchParams = new URLSearchParams();
|
|
@@ -654,23 +1308,60 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
654
1308
|
if (params?.toDate) {
|
|
655
1309
|
searchParams.set("toDate", params.toDate.toISOString());
|
|
656
1310
|
}
|
|
657
|
-
if (params?.limit) {
|
|
1311
|
+
if (params?.limit !== null && params?.limit !== void 0 && !isNaN(Number(params?.limit))) {
|
|
658
1312
|
searchParams.set("limit", String(params.limit));
|
|
659
1313
|
}
|
|
660
|
-
if (params?.offset) {
|
|
1314
|
+
if (params?.offset !== null && params?.offset !== void 0 && !isNaN(Number(params?.offset))) {
|
|
661
1315
|
searchParams.set("offset", String(params.offset));
|
|
662
1316
|
}
|
|
663
1317
|
if (params?.resourceId) {
|
|
664
1318
|
searchParams.set("resourceId", params.resourceId);
|
|
665
1319
|
}
|
|
666
1320
|
if (searchParams.size) {
|
|
667
|
-
return this.request(`/api/workflows
|
|
1321
|
+
return this.request(`/api/workflows/${this.workflowId}/runs?${searchParams}`);
|
|
668
1322
|
} else {
|
|
669
|
-
return this.request(`/api/workflows
|
|
1323
|
+
return this.request(`/api/workflows/${this.workflowId}/runs`);
|
|
670
1324
|
}
|
|
671
1325
|
}
|
|
672
1326
|
/**
|
|
673
|
-
*
|
|
1327
|
+
* Retrieves a specific workflow run by its ID
|
|
1328
|
+
* @param runId - The ID of the workflow run to retrieve
|
|
1329
|
+
* @returns Promise containing the workflow run details
|
|
1330
|
+
*/
|
|
1331
|
+
runById(runId) {
|
|
1332
|
+
return this.request(`/api/workflows/${this.workflowId}/runs/${runId}`);
|
|
1333
|
+
}
|
|
1334
|
+
/**
|
|
1335
|
+
* Retrieves the execution result for a specific workflow run by its ID
|
|
1336
|
+
* @param runId - The ID of the workflow run to retrieve the execution result for
|
|
1337
|
+
* @returns Promise containing the workflow run execution result
|
|
1338
|
+
*/
|
|
1339
|
+
runExecutionResult(runId) {
|
|
1340
|
+
return this.request(`/api/workflows/${this.workflowId}/runs/${runId}/execution-result`);
|
|
1341
|
+
}
|
|
1342
|
+
/**
|
|
1343
|
+
* Cancels a specific workflow run by its ID
|
|
1344
|
+
* @param runId - The ID of the workflow run to cancel
|
|
1345
|
+
* @returns Promise containing a success message
|
|
1346
|
+
*/
|
|
1347
|
+
cancelRun(runId) {
|
|
1348
|
+
return this.request(`/api/workflows/${this.workflowId}/runs/${runId}/cancel`, {
|
|
1349
|
+
method: "POST"
|
|
1350
|
+
});
|
|
1351
|
+
}
|
|
1352
|
+
/**
|
|
1353
|
+
* Sends an event to a specific workflow run by its ID
|
|
1354
|
+
* @param params - Object containing the runId, event and data
|
|
1355
|
+
* @returns Promise containing a success message
|
|
1356
|
+
*/
|
|
1357
|
+
sendRunEvent(params) {
|
|
1358
|
+
return this.request(`/api/workflows/${this.workflowId}/runs/${params.runId}/send-event`, {
|
|
1359
|
+
method: "POST",
|
|
1360
|
+
body: { event: params.event, data: params.data }
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1363
|
+
/**
|
|
1364
|
+
* Creates a new workflow run
|
|
674
1365
|
* @param params - Optional object containing the optional runId
|
|
675
1366
|
* @returns Promise containing the runId of the created run
|
|
676
1367
|
*/
|
|
@@ -679,23 +1370,24 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
679
1370
|
if (!!params?.runId) {
|
|
680
1371
|
searchParams.set("runId", params.runId);
|
|
681
1372
|
}
|
|
682
|
-
return this.request(`/api/workflows
|
|
1373
|
+
return this.request(`/api/workflows/${this.workflowId}/create-run?${searchParams.toString()}`, {
|
|
683
1374
|
method: "POST"
|
|
684
1375
|
});
|
|
685
1376
|
}
|
|
686
1377
|
/**
|
|
687
|
-
* Starts a
|
|
1378
|
+
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
688
1379
|
* @param params - Object containing the runId, inputData and runtimeContext
|
|
689
1380
|
* @returns Promise containing success message
|
|
690
1381
|
*/
|
|
691
1382
|
start(params) {
|
|
692
|
-
|
|
1383
|
+
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
1384
|
+
return this.request(`/api/workflows/${this.workflowId}/start?runId=${params.runId}`, {
|
|
693
1385
|
method: "POST",
|
|
694
|
-
body: { inputData: params?.inputData, runtimeContext
|
|
1386
|
+
body: { inputData: params?.inputData, runtimeContext }
|
|
695
1387
|
});
|
|
696
1388
|
}
|
|
697
1389
|
/**
|
|
698
|
-
* Resumes a suspended
|
|
1390
|
+
* Resumes a suspended workflow step synchronously without waiting for the workflow to complete
|
|
699
1391
|
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
700
1392
|
* @returns Promise containing success message
|
|
701
1393
|
*/
|
|
@@ -703,9 +1395,10 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
703
1395
|
step,
|
|
704
1396
|
runId,
|
|
705
1397
|
resumeData,
|
|
706
|
-
|
|
1398
|
+
...rest
|
|
707
1399
|
}) {
|
|
708
|
-
|
|
1400
|
+
const runtimeContext = parseClientRuntimeContext(rest.runtimeContext);
|
|
1401
|
+
return this.request(`/api/workflows/${this.workflowId}/resume?runId=${runId}`, {
|
|
709
1402
|
method: "POST",
|
|
710
1403
|
stream: true,
|
|
711
1404
|
body: {
|
|
@@ -716,82 +1409,440 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
716
1409
|
});
|
|
717
1410
|
}
|
|
718
1411
|
/**
|
|
719
|
-
* Starts a
|
|
1412
|
+
* Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
|
|
720
1413
|
* @param params - Object containing the optional runId, inputData and runtimeContext
|
|
721
|
-
* @returns Promise containing the
|
|
1414
|
+
* @returns Promise containing the workflow execution results
|
|
722
1415
|
*/
|
|
723
1416
|
startAsync(params) {
|
|
724
1417
|
const searchParams = new URLSearchParams();
|
|
725
1418
|
if (!!params?.runId) {
|
|
726
1419
|
searchParams.set("runId", params.runId);
|
|
727
1420
|
}
|
|
728
|
-
|
|
1421
|
+
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
1422
|
+
return this.request(`/api/workflows/${this.workflowId}/start-async?${searchParams.toString()}`, {
|
|
729
1423
|
method: "POST",
|
|
730
|
-
body: { inputData: params.inputData, runtimeContext
|
|
1424
|
+
body: { inputData: params.inputData, runtimeContext }
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1427
|
+
/**
|
|
1428
|
+
* Starts a workflow run and returns a stream
|
|
1429
|
+
* @param params - Object containing the optional runId, inputData and runtimeContext
|
|
1430
|
+
* @returns Promise containing the workflow execution results
|
|
1431
|
+
*/
|
|
1432
|
+
async stream(params) {
|
|
1433
|
+
const searchParams = new URLSearchParams();
|
|
1434
|
+
if (!!params?.runId) {
|
|
1435
|
+
searchParams.set("runId", params.runId);
|
|
1436
|
+
}
|
|
1437
|
+
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
1438
|
+
const response = await this.request(
|
|
1439
|
+
`/api/workflows/${this.workflowId}/stream?${searchParams.toString()}`,
|
|
1440
|
+
{
|
|
1441
|
+
method: "POST",
|
|
1442
|
+
body: { inputData: params.inputData, runtimeContext },
|
|
1443
|
+
stream: true
|
|
1444
|
+
}
|
|
1445
|
+
);
|
|
1446
|
+
if (!response.ok) {
|
|
1447
|
+
throw new Error(`Failed to stream vNext workflow: ${response.statusText}`);
|
|
1448
|
+
}
|
|
1449
|
+
if (!response.body) {
|
|
1450
|
+
throw new Error("Response body is null");
|
|
1451
|
+
}
|
|
1452
|
+
const transformStream = new TransformStream({
|
|
1453
|
+
start() {
|
|
1454
|
+
},
|
|
1455
|
+
async transform(chunk, controller) {
|
|
1456
|
+
try {
|
|
1457
|
+
const decoded = new TextDecoder().decode(chunk);
|
|
1458
|
+
const chunks = decoded.split(RECORD_SEPARATOR2);
|
|
1459
|
+
for (const chunk2 of chunks) {
|
|
1460
|
+
if (chunk2) {
|
|
1461
|
+
try {
|
|
1462
|
+
const parsedChunk = JSON.parse(chunk2);
|
|
1463
|
+
controller.enqueue(parsedChunk);
|
|
1464
|
+
} catch {
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
} catch {
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
731
1471
|
});
|
|
1472
|
+
return response.body.pipeThrough(transformStream);
|
|
732
1473
|
}
|
|
733
1474
|
/**
|
|
734
|
-
* Resumes a suspended
|
|
1475
|
+
* Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
|
|
735
1476
|
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
736
|
-
* @returns Promise containing the
|
|
1477
|
+
* @returns Promise containing the workflow resume results
|
|
737
1478
|
*/
|
|
738
1479
|
resumeAsync(params) {
|
|
739
|
-
|
|
1480
|
+
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
1481
|
+
return this.request(`/api/workflows/${this.workflowId}/resume-async?runId=${params.runId}`, {
|
|
740
1482
|
method: "POST",
|
|
741
1483
|
body: {
|
|
742
1484
|
step: params.step,
|
|
743
1485
|
resumeData: params.resumeData,
|
|
744
|
-
runtimeContext
|
|
1486
|
+
runtimeContext
|
|
745
1487
|
}
|
|
746
1488
|
});
|
|
747
1489
|
}
|
|
748
1490
|
/**
|
|
749
|
-
* Watches
|
|
1491
|
+
* Watches workflow transitions in real-time
|
|
750
1492
|
* @param runId - Optional run ID to filter the watch stream
|
|
751
|
-
* @returns AsyncGenerator that yields parsed records from the
|
|
1493
|
+
* @returns AsyncGenerator that yields parsed records from the workflow watch stream
|
|
752
1494
|
*/
|
|
753
1495
|
async watch({ runId }, onRecord) {
|
|
754
|
-
const response = await this.request(`/api/workflows
|
|
1496
|
+
const response = await this.request(`/api/workflows/${this.workflowId}/watch?runId=${runId}`, {
|
|
755
1497
|
stream: true
|
|
756
1498
|
});
|
|
757
1499
|
if (!response.ok) {
|
|
758
|
-
throw new Error(`Failed to watch
|
|
1500
|
+
throw new Error(`Failed to watch workflow: ${response.statusText}`);
|
|
759
1501
|
}
|
|
760
1502
|
if (!response.body) {
|
|
761
1503
|
throw new Error("Response body is null");
|
|
762
1504
|
}
|
|
763
1505
|
for await (const record of this.streamProcessor(response.body)) {
|
|
764
|
-
|
|
1506
|
+
if (typeof record === "string") {
|
|
1507
|
+
onRecord(JSON.parse(record));
|
|
1508
|
+
} else {
|
|
1509
|
+
onRecord(record);
|
|
1510
|
+
}
|
|
765
1511
|
}
|
|
766
1512
|
}
|
|
767
|
-
};
|
|
768
|
-
|
|
769
|
-
// src/resources/mcp.ts
|
|
770
|
-
var MCPServer = class extends BaseResource {
|
|
771
|
-
constructor(options, serverId) {
|
|
772
|
-
super(options);
|
|
773
|
-
this.serverId = serverId;
|
|
774
|
-
}
|
|
775
1513
|
/**
|
|
776
|
-
*
|
|
777
|
-
*
|
|
1514
|
+
* Creates a new ReadableStream from an iterable or async iterable of objects,
|
|
1515
|
+
* serializing each as JSON and separating them with the record separator (\x1E).
|
|
1516
|
+
*
|
|
1517
|
+
* @param records - An iterable or async iterable of objects to stream
|
|
1518
|
+
* @returns A ReadableStream emitting the records as JSON strings separated by the record separator
|
|
778
1519
|
*/
|
|
779
|
-
|
|
780
|
-
|
|
1520
|
+
static createRecordStream(records) {
|
|
1521
|
+
const encoder = new TextEncoder();
|
|
1522
|
+
return new ReadableStream({
|
|
1523
|
+
async start(controller) {
|
|
1524
|
+
try {
|
|
1525
|
+
for await (const record of records) {
|
|
1526
|
+
const json = JSON.stringify(record) + RECORD_SEPARATOR2;
|
|
1527
|
+
controller.enqueue(encoder.encode(json));
|
|
1528
|
+
}
|
|
1529
|
+
controller.close();
|
|
1530
|
+
} catch (err) {
|
|
1531
|
+
controller.error(err);
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
});
|
|
781
1535
|
}
|
|
782
1536
|
};
|
|
783
1537
|
|
|
784
|
-
// src/
|
|
785
|
-
var
|
|
786
|
-
constructor(options) {
|
|
1538
|
+
// src/resources/a2a.ts
|
|
1539
|
+
var A2A = class extends BaseResource {
|
|
1540
|
+
constructor(options, agentId) {
|
|
787
1541
|
super(options);
|
|
1542
|
+
this.agentId = agentId;
|
|
788
1543
|
}
|
|
789
1544
|
/**
|
|
790
|
-
*
|
|
791
|
-
* @returns Promise containing
|
|
1545
|
+
* Get the agent card with metadata about the agent
|
|
1546
|
+
* @returns Promise containing the agent card information
|
|
792
1547
|
*/
|
|
793
|
-
|
|
794
|
-
return this.request(
|
|
1548
|
+
async getCard() {
|
|
1549
|
+
return this.request(`/.well-known/${this.agentId}/agent.json`);
|
|
1550
|
+
}
|
|
1551
|
+
/**
|
|
1552
|
+
* Send a message to the agent and get a response
|
|
1553
|
+
* @param params - Parameters for the task
|
|
1554
|
+
* @returns Promise containing the task response
|
|
1555
|
+
*/
|
|
1556
|
+
async sendMessage(params) {
|
|
1557
|
+
const response = await this.request(`/a2a/${this.agentId}`, {
|
|
1558
|
+
method: "POST",
|
|
1559
|
+
body: {
|
|
1560
|
+
method: "tasks/send",
|
|
1561
|
+
params
|
|
1562
|
+
}
|
|
1563
|
+
});
|
|
1564
|
+
return { task: response.result };
|
|
1565
|
+
}
|
|
1566
|
+
/**
|
|
1567
|
+
* Get the status and result of a task
|
|
1568
|
+
* @param params - Parameters for querying the task
|
|
1569
|
+
* @returns Promise containing the task response
|
|
1570
|
+
*/
|
|
1571
|
+
async getTask(params) {
|
|
1572
|
+
const response = await this.request(`/a2a/${this.agentId}`, {
|
|
1573
|
+
method: "POST",
|
|
1574
|
+
body: {
|
|
1575
|
+
method: "tasks/get",
|
|
1576
|
+
params
|
|
1577
|
+
}
|
|
1578
|
+
});
|
|
1579
|
+
return response.result;
|
|
1580
|
+
}
|
|
1581
|
+
/**
|
|
1582
|
+
* Cancel a running task
|
|
1583
|
+
* @param params - Parameters identifying the task to cancel
|
|
1584
|
+
* @returns Promise containing the task response
|
|
1585
|
+
*/
|
|
1586
|
+
async cancelTask(params) {
|
|
1587
|
+
return this.request(`/a2a/${this.agentId}`, {
|
|
1588
|
+
method: "POST",
|
|
1589
|
+
body: {
|
|
1590
|
+
method: "tasks/cancel",
|
|
1591
|
+
params
|
|
1592
|
+
}
|
|
1593
|
+
});
|
|
1594
|
+
}
|
|
1595
|
+
/**
|
|
1596
|
+
* Send a message and subscribe to streaming updates (not fully implemented)
|
|
1597
|
+
* @param params - Parameters for the task
|
|
1598
|
+
* @returns Promise containing the task response
|
|
1599
|
+
*/
|
|
1600
|
+
async sendAndSubscribe(params) {
|
|
1601
|
+
return this.request(`/a2a/${this.agentId}`, {
|
|
1602
|
+
method: "POST",
|
|
1603
|
+
body: {
|
|
1604
|
+
method: "tasks/sendSubscribe",
|
|
1605
|
+
params
|
|
1606
|
+
},
|
|
1607
|
+
stream: true
|
|
1608
|
+
});
|
|
1609
|
+
}
|
|
1610
|
+
};
|
|
1611
|
+
|
|
1612
|
+
// src/resources/mcp-tool.ts
|
|
1613
|
+
var MCPTool = class extends BaseResource {
|
|
1614
|
+
serverId;
|
|
1615
|
+
toolId;
|
|
1616
|
+
constructor(options, serverId, toolId) {
|
|
1617
|
+
super(options);
|
|
1618
|
+
this.serverId = serverId;
|
|
1619
|
+
this.toolId = toolId;
|
|
1620
|
+
}
|
|
1621
|
+
/**
|
|
1622
|
+
* Retrieves details about this specific tool from the MCP server.
|
|
1623
|
+
* @returns Promise containing the tool's information (name, description, schema).
|
|
1624
|
+
*/
|
|
1625
|
+
details() {
|
|
1626
|
+
return this.request(`/api/mcp/${this.serverId}/tools/${this.toolId}`);
|
|
1627
|
+
}
|
|
1628
|
+
/**
|
|
1629
|
+
* Executes this specific tool on the MCP server.
|
|
1630
|
+
* @param params - Parameters for tool execution, including data/args and optional runtimeContext.
|
|
1631
|
+
* @returns Promise containing the result of the tool execution.
|
|
1632
|
+
*/
|
|
1633
|
+
execute(params) {
|
|
1634
|
+
const body = {};
|
|
1635
|
+
if (params.data !== void 0) body.data = params.data;
|
|
1636
|
+
if (params.runtimeContext !== void 0) {
|
|
1637
|
+
body.runtimeContext = params.runtimeContext;
|
|
1638
|
+
}
|
|
1639
|
+
return this.request(`/api/mcp/${this.serverId}/tools/${this.toolId}/execute`, {
|
|
1640
|
+
method: "POST",
|
|
1641
|
+
body: Object.keys(body).length > 0 ? body : void 0
|
|
1642
|
+
});
|
|
1643
|
+
}
|
|
1644
|
+
};
|
|
1645
|
+
|
|
1646
|
+
// src/resources/vNextNetwork.ts
|
|
1647
|
+
var RECORD_SEPARATOR3 = "";
|
|
1648
|
+
var VNextNetwork = class extends BaseResource {
|
|
1649
|
+
constructor(options, networkId) {
|
|
1650
|
+
super(options);
|
|
1651
|
+
this.networkId = networkId;
|
|
1652
|
+
}
|
|
1653
|
+
/**
|
|
1654
|
+
* Retrieves details about the network
|
|
1655
|
+
* @returns Promise containing vNext network details
|
|
1656
|
+
*/
|
|
1657
|
+
details() {
|
|
1658
|
+
return this.request(`/api/networks/v-next/${this.networkId}`);
|
|
1659
|
+
}
|
|
1660
|
+
/**
|
|
1661
|
+
* Generates a response from the v-next network
|
|
1662
|
+
* @param params - Generation parameters including message
|
|
1663
|
+
* @returns Promise containing the generated response
|
|
1664
|
+
*/
|
|
1665
|
+
generate(params) {
|
|
1666
|
+
return this.request(`/api/networks/v-next/${this.networkId}/generate`, {
|
|
1667
|
+
method: "POST",
|
|
1668
|
+
body: params
|
|
1669
|
+
});
|
|
1670
|
+
}
|
|
1671
|
+
/**
|
|
1672
|
+
* Generates a response from the v-next network using multiple primitives
|
|
1673
|
+
* @param params - Generation parameters including message
|
|
1674
|
+
* @returns Promise containing the generated response
|
|
1675
|
+
*/
|
|
1676
|
+
loop(params) {
|
|
1677
|
+
return this.request(`/api/networks/v-next/${this.networkId}/loop`, {
|
|
1678
|
+
method: "POST",
|
|
1679
|
+
body: params
|
|
1680
|
+
});
|
|
1681
|
+
}
|
|
1682
|
+
async *streamProcessor(stream) {
|
|
1683
|
+
const reader = stream.getReader();
|
|
1684
|
+
let doneReading = false;
|
|
1685
|
+
let buffer = "";
|
|
1686
|
+
try {
|
|
1687
|
+
while (!doneReading) {
|
|
1688
|
+
const { done, value } = await reader.read();
|
|
1689
|
+
doneReading = done;
|
|
1690
|
+
if (done && !value) continue;
|
|
1691
|
+
try {
|
|
1692
|
+
const decoded = value ? new TextDecoder().decode(value) : "";
|
|
1693
|
+
const chunks = (buffer + decoded).split(RECORD_SEPARATOR3);
|
|
1694
|
+
buffer = chunks.pop() || "";
|
|
1695
|
+
for (const chunk of chunks) {
|
|
1696
|
+
if (chunk) {
|
|
1697
|
+
if (typeof chunk === "string") {
|
|
1698
|
+
try {
|
|
1699
|
+
const parsedChunk = JSON.parse(chunk);
|
|
1700
|
+
yield parsedChunk;
|
|
1701
|
+
} catch {
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
} catch {
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
if (buffer) {
|
|
1710
|
+
try {
|
|
1711
|
+
yield JSON.parse(buffer);
|
|
1712
|
+
} catch {
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
} finally {
|
|
1716
|
+
reader.cancel().catch(() => {
|
|
1717
|
+
});
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
/**
|
|
1721
|
+
* Streams a response from the v-next network
|
|
1722
|
+
* @param params - Stream parameters including message
|
|
1723
|
+
* @returns Promise containing the results
|
|
1724
|
+
*/
|
|
1725
|
+
async stream(params, onRecord) {
|
|
1726
|
+
const response = await this.request(`/api/networks/v-next/${this.networkId}/stream`, {
|
|
1727
|
+
method: "POST",
|
|
1728
|
+
body: params,
|
|
1729
|
+
stream: true
|
|
1730
|
+
});
|
|
1731
|
+
if (!response.ok) {
|
|
1732
|
+
throw new Error(`Failed to stream vNext network: ${response.statusText}`);
|
|
1733
|
+
}
|
|
1734
|
+
if (!response.body) {
|
|
1735
|
+
throw new Error("Response body is null");
|
|
1736
|
+
}
|
|
1737
|
+
for await (const record of this.streamProcessor(response.body)) {
|
|
1738
|
+
if (typeof record === "string") {
|
|
1739
|
+
onRecord(JSON.parse(record));
|
|
1740
|
+
} else {
|
|
1741
|
+
onRecord(record);
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
/**
|
|
1746
|
+
* Streams a response from the v-next network loop
|
|
1747
|
+
* @param params - Stream parameters including message
|
|
1748
|
+
* @returns Promise containing the results
|
|
1749
|
+
*/
|
|
1750
|
+
async loopStream(params, onRecord) {
|
|
1751
|
+
const response = await this.request(`/api/networks/v-next/${this.networkId}/loop-stream`, {
|
|
1752
|
+
method: "POST",
|
|
1753
|
+
body: params,
|
|
1754
|
+
stream: true
|
|
1755
|
+
});
|
|
1756
|
+
if (!response.ok) {
|
|
1757
|
+
throw new Error(`Failed to stream vNext network loop: ${response.statusText}`);
|
|
1758
|
+
}
|
|
1759
|
+
if (!response.body) {
|
|
1760
|
+
throw new Error("Response body is null");
|
|
1761
|
+
}
|
|
1762
|
+
for await (const record of this.streamProcessor(response.body)) {
|
|
1763
|
+
if (typeof record === "string") {
|
|
1764
|
+
onRecord(JSON.parse(record));
|
|
1765
|
+
} else {
|
|
1766
|
+
onRecord(record);
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
};
|
|
1771
|
+
|
|
1772
|
+
// src/resources/network-memory-thread.ts
|
|
1773
|
+
var NetworkMemoryThread = class extends BaseResource {
|
|
1774
|
+
constructor(options, threadId, networkId) {
|
|
1775
|
+
super(options);
|
|
1776
|
+
this.threadId = threadId;
|
|
1777
|
+
this.networkId = networkId;
|
|
1778
|
+
}
|
|
1779
|
+
/**
|
|
1780
|
+
* Retrieves the memory thread details
|
|
1781
|
+
* @returns Promise containing thread details including title and metadata
|
|
1782
|
+
*/
|
|
1783
|
+
get() {
|
|
1784
|
+
return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`);
|
|
1785
|
+
}
|
|
1786
|
+
/**
|
|
1787
|
+
* Updates the memory thread properties
|
|
1788
|
+
* @param params - Update parameters including title and metadata
|
|
1789
|
+
* @returns Promise containing updated thread details
|
|
1790
|
+
*/
|
|
1791
|
+
update(params) {
|
|
1792
|
+
return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
|
|
1793
|
+
method: "PATCH",
|
|
1794
|
+
body: params
|
|
1795
|
+
});
|
|
1796
|
+
}
|
|
1797
|
+
/**
|
|
1798
|
+
* Deletes the memory thread
|
|
1799
|
+
* @returns Promise containing deletion result
|
|
1800
|
+
*/
|
|
1801
|
+
delete() {
|
|
1802
|
+
return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
|
|
1803
|
+
method: "DELETE"
|
|
1804
|
+
});
|
|
1805
|
+
}
|
|
1806
|
+
/**
|
|
1807
|
+
* Retrieves messages associated with the thread
|
|
1808
|
+
* @param params - Optional parameters including limit for number of messages to retrieve
|
|
1809
|
+
* @returns Promise containing thread messages and UI messages
|
|
1810
|
+
*/
|
|
1811
|
+
getMessages(params) {
|
|
1812
|
+
const query = new URLSearchParams({
|
|
1813
|
+
networkId: this.networkId,
|
|
1814
|
+
...params?.limit ? { limit: params.limit.toString() } : {}
|
|
1815
|
+
});
|
|
1816
|
+
return this.request(`/api/memory/network/threads/${this.threadId}/messages?${query.toString()}`);
|
|
1817
|
+
}
|
|
1818
|
+
};
|
|
1819
|
+
|
|
1820
|
+
// src/client.ts
|
|
1821
|
+
var MastraClient = class extends BaseResource {
|
|
1822
|
+
constructor(options) {
|
|
1823
|
+
super(options);
|
|
1824
|
+
}
|
|
1825
|
+
/**
|
|
1826
|
+
* Retrieves all available agents
|
|
1827
|
+
* @returns Promise containing map of agent IDs to agent details
|
|
1828
|
+
*/
|
|
1829
|
+
getAgents() {
|
|
1830
|
+
return this.request("/api/agents");
|
|
1831
|
+
}
|
|
1832
|
+
async getAGUI({ resourceId }) {
|
|
1833
|
+
const agents = await this.getAgents();
|
|
1834
|
+
return Object.entries(agents).reduce(
|
|
1835
|
+
(acc, [agentId]) => {
|
|
1836
|
+
const agent = this.getAgent(agentId);
|
|
1837
|
+
acc[agentId] = new AGUIAdapter({
|
|
1838
|
+
agentId,
|
|
1839
|
+
agent,
|
|
1840
|
+
resourceId
|
|
1841
|
+
});
|
|
1842
|
+
return acc;
|
|
1843
|
+
},
|
|
1844
|
+
{}
|
|
1845
|
+
);
|
|
795
1846
|
}
|
|
796
1847
|
/**
|
|
797
1848
|
* Gets an agent instance by ID
|
|
@@ -843,6 +1894,48 @@ var MastraClient = class extends BaseResource {
|
|
|
843
1894
|
getMemoryStatus(agentId) {
|
|
844
1895
|
return this.request(`/api/memory/status?agentId=${agentId}`);
|
|
845
1896
|
}
|
|
1897
|
+
/**
|
|
1898
|
+
* Retrieves memory threads for a resource
|
|
1899
|
+
* @param params - Parameters containing the resource ID
|
|
1900
|
+
* @returns Promise containing array of memory threads
|
|
1901
|
+
*/
|
|
1902
|
+
getNetworkMemoryThreads(params) {
|
|
1903
|
+
return this.request(`/api/memory/network/threads?resourceid=${params.resourceId}&networkId=${params.networkId}`);
|
|
1904
|
+
}
|
|
1905
|
+
/**
|
|
1906
|
+
* Creates a new memory thread
|
|
1907
|
+
* @param params - Parameters for creating the memory thread
|
|
1908
|
+
* @returns Promise containing the created memory thread
|
|
1909
|
+
*/
|
|
1910
|
+
createNetworkMemoryThread(params) {
|
|
1911
|
+
return this.request(`/api/memory/network/threads?networkId=${params.networkId}`, { method: "POST", body: params });
|
|
1912
|
+
}
|
|
1913
|
+
/**
|
|
1914
|
+
* Gets a memory thread instance by ID
|
|
1915
|
+
* @param threadId - ID of the memory thread to retrieve
|
|
1916
|
+
* @returns MemoryThread instance
|
|
1917
|
+
*/
|
|
1918
|
+
getNetworkMemoryThread(threadId, networkId) {
|
|
1919
|
+
return new NetworkMemoryThread(this.options, threadId, networkId);
|
|
1920
|
+
}
|
|
1921
|
+
/**
|
|
1922
|
+
* Saves messages to memory
|
|
1923
|
+
* @param params - Parameters containing messages to save
|
|
1924
|
+
* @returns Promise containing the saved messages
|
|
1925
|
+
*/
|
|
1926
|
+
saveNetworkMessageToMemory(params) {
|
|
1927
|
+
return this.request(`/api/memory/network/save-messages?networkId=${params.networkId}`, {
|
|
1928
|
+
method: "POST",
|
|
1929
|
+
body: params
|
|
1930
|
+
});
|
|
1931
|
+
}
|
|
1932
|
+
/**
|
|
1933
|
+
* Gets the status of the memory system
|
|
1934
|
+
* @returns Promise containing memory system status
|
|
1935
|
+
*/
|
|
1936
|
+
getNetworkMemoryStatus(networkId) {
|
|
1937
|
+
return this.request(`/api/memory/network/status?networkId=${networkId}`);
|
|
1938
|
+
}
|
|
846
1939
|
/**
|
|
847
1940
|
* Retrieves all available tools
|
|
848
1941
|
* @returns Promise containing map of tool IDs to tool details
|
|
@@ -856,7 +1949,22 @@ var MastraClient = class extends BaseResource {
|
|
|
856
1949
|
* @returns Tool instance
|
|
857
1950
|
*/
|
|
858
1951
|
getTool(toolId) {
|
|
859
|
-
return new
|
|
1952
|
+
return new Tool2(this.options, toolId);
|
|
1953
|
+
}
|
|
1954
|
+
/**
|
|
1955
|
+
* Retrieves all available legacy workflows
|
|
1956
|
+
* @returns Promise containing map of legacy workflow IDs to legacy workflow details
|
|
1957
|
+
*/
|
|
1958
|
+
getLegacyWorkflows() {
|
|
1959
|
+
return this.request("/api/workflows/legacy");
|
|
1960
|
+
}
|
|
1961
|
+
/**
|
|
1962
|
+
* Gets a legacy workflow instance by ID
|
|
1963
|
+
* @param workflowId - ID of the legacy workflow to retrieve
|
|
1964
|
+
* @returns Legacy Workflow instance
|
|
1965
|
+
*/
|
|
1966
|
+
getLegacyWorkflow(workflowId) {
|
|
1967
|
+
return new LegacyWorkflow(this.options, workflowId);
|
|
860
1968
|
}
|
|
861
1969
|
/**
|
|
862
1970
|
* Retrieves all available workflows
|
|
@@ -873,21 +1981,6 @@ var MastraClient = class extends BaseResource {
|
|
|
873
1981
|
getWorkflow(workflowId) {
|
|
874
1982
|
return new Workflow(this.options, workflowId);
|
|
875
1983
|
}
|
|
876
|
-
/**
|
|
877
|
-
* Retrieves all available vNext workflows
|
|
878
|
-
* @returns Promise containing map of vNext workflow IDs to vNext workflow details
|
|
879
|
-
*/
|
|
880
|
-
getVNextWorkflows() {
|
|
881
|
-
return this.request("/api/workflows/v-next");
|
|
882
|
-
}
|
|
883
|
-
/**
|
|
884
|
-
* Gets a vNext workflow instance by ID
|
|
885
|
-
* @param workflowId - ID of the vNext workflow to retrieve
|
|
886
|
-
* @returns vNext Workflow instance
|
|
887
|
-
*/
|
|
888
|
-
getVNextWorkflow(workflowId) {
|
|
889
|
-
return new VNextWorkflow(this.options, workflowId);
|
|
890
|
-
}
|
|
891
1984
|
/**
|
|
892
1985
|
* Gets a vector instance by name
|
|
893
1986
|
* @param vectorName - Name of the vector to retrieve
|
|
@@ -902,7 +1995,41 @@ var MastraClient = class extends BaseResource {
|
|
|
902
1995
|
* @returns Promise containing array of log messages
|
|
903
1996
|
*/
|
|
904
1997
|
getLogs(params) {
|
|
905
|
-
|
|
1998
|
+
const { transportId, fromDate, toDate, logLevel, filters, page, perPage } = params;
|
|
1999
|
+
const _filters = filters ? Object.entries(filters).map(([key, value]) => `${key}:${value}`) : [];
|
|
2000
|
+
const searchParams = new URLSearchParams();
|
|
2001
|
+
if (transportId) {
|
|
2002
|
+
searchParams.set("transportId", transportId);
|
|
2003
|
+
}
|
|
2004
|
+
if (fromDate) {
|
|
2005
|
+
searchParams.set("fromDate", fromDate.toISOString());
|
|
2006
|
+
}
|
|
2007
|
+
if (toDate) {
|
|
2008
|
+
searchParams.set("toDate", toDate.toISOString());
|
|
2009
|
+
}
|
|
2010
|
+
if (logLevel) {
|
|
2011
|
+
searchParams.set("logLevel", logLevel);
|
|
2012
|
+
}
|
|
2013
|
+
if (page) {
|
|
2014
|
+
searchParams.set("page", String(page));
|
|
2015
|
+
}
|
|
2016
|
+
if (perPage) {
|
|
2017
|
+
searchParams.set("perPage", String(perPage));
|
|
2018
|
+
}
|
|
2019
|
+
if (_filters) {
|
|
2020
|
+
if (Array.isArray(_filters)) {
|
|
2021
|
+
for (const filter of _filters) {
|
|
2022
|
+
searchParams.append("filters", filter);
|
|
2023
|
+
}
|
|
2024
|
+
} else {
|
|
2025
|
+
searchParams.set("filters", _filters);
|
|
2026
|
+
}
|
|
2027
|
+
}
|
|
2028
|
+
if (searchParams.size) {
|
|
2029
|
+
return this.request(`/api/logs?${searchParams}`);
|
|
2030
|
+
} else {
|
|
2031
|
+
return this.request(`/api/logs`);
|
|
2032
|
+
}
|
|
906
2033
|
}
|
|
907
2034
|
/**
|
|
908
2035
|
* Gets logs for a specific run
|
|
@@ -910,7 +2037,44 @@ var MastraClient = class extends BaseResource {
|
|
|
910
2037
|
* @returns Promise containing array of log messages
|
|
911
2038
|
*/
|
|
912
2039
|
getLogForRun(params) {
|
|
913
|
-
|
|
2040
|
+
const { runId, transportId, fromDate, toDate, logLevel, filters, page, perPage } = params;
|
|
2041
|
+
const _filters = filters ? Object.entries(filters).map(([key, value]) => `${key}:${value}`) : [];
|
|
2042
|
+
const searchParams = new URLSearchParams();
|
|
2043
|
+
if (runId) {
|
|
2044
|
+
searchParams.set("runId", runId);
|
|
2045
|
+
}
|
|
2046
|
+
if (transportId) {
|
|
2047
|
+
searchParams.set("transportId", transportId);
|
|
2048
|
+
}
|
|
2049
|
+
if (fromDate) {
|
|
2050
|
+
searchParams.set("fromDate", fromDate.toISOString());
|
|
2051
|
+
}
|
|
2052
|
+
if (toDate) {
|
|
2053
|
+
searchParams.set("toDate", toDate.toISOString());
|
|
2054
|
+
}
|
|
2055
|
+
if (logLevel) {
|
|
2056
|
+
searchParams.set("logLevel", logLevel);
|
|
2057
|
+
}
|
|
2058
|
+
if (page) {
|
|
2059
|
+
searchParams.set("page", String(page));
|
|
2060
|
+
}
|
|
2061
|
+
if (perPage) {
|
|
2062
|
+
searchParams.set("perPage", String(perPage));
|
|
2063
|
+
}
|
|
2064
|
+
if (_filters) {
|
|
2065
|
+
if (Array.isArray(_filters)) {
|
|
2066
|
+
for (const filter of _filters) {
|
|
2067
|
+
searchParams.append("filters", filter);
|
|
2068
|
+
}
|
|
2069
|
+
} else {
|
|
2070
|
+
searchParams.set("filters", _filters);
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
2073
|
+
if (searchParams.size) {
|
|
2074
|
+
return this.request(`/api/logs/${runId}?${searchParams}`);
|
|
2075
|
+
} else {
|
|
2076
|
+
return this.request(`/api/logs/${runId}`);
|
|
2077
|
+
}
|
|
914
2078
|
}
|
|
915
2079
|
/**
|
|
916
2080
|
* List of all log transports
|
|
@@ -968,6 +2132,13 @@ var MastraClient = class extends BaseResource {
|
|
|
968
2132
|
getNetworks() {
|
|
969
2133
|
return this.request("/api/networks");
|
|
970
2134
|
}
|
|
2135
|
+
/**
|
|
2136
|
+
* Retrieves all available vNext networks
|
|
2137
|
+
* @returns Promise containing map of vNext network IDs to vNext network details
|
|
2138
|
+
*/
|
|
2139
|
+
getVNextNetworks() {
|
|
2140
|
+
return this.request("/api/networks/v-next");
|
|
2141
|
+
}
|
|
971
2142
|
/**
|
|
972
2143
|
* Gets a network instance by ID
|
|
973
2144
|
* @param networkId - ID of the network to retrieve
|
|
@@ -977,19 +2148,68 @@ var MastraClient = class extends BaseResource {
|
|
|
977
2148
|
return new Network(this.options, networkId);
|
|
978
2149
|
}
|
|
979
2150
|
/**
|
|
980
|
-
*
|
|
981
|
-
* @
|
|
2151
|
+
* Gets a vNext network instance by ID
|
|
2152
|
+
* @param networkId - ID of the vNext network to retrieve
|
|
2153
|
+
* @returns vNext Network instance
|
|
2154
|
+
*/
|
|
2155
|
+
getVNextNetwork(networkId) {
|
|
2156
|
+
return new VNextNetwork(this.options, networkId);
|
|
2157
|
+
}
|
|
2158
|
+
/**
|
|
2159
|
+
* Retrieves a list of available MCP servers.
|
|
2160
|
+
* @param params - Optional parameters for pagination (limit, offset).
|
|
2161
|
+
* @returns Promise containing the list of MCP servers and pagination info.
|
|
2162
|
+
*/
|
|
2163
|
+
getMcpServers(params) {
|
|
2164
|
+
const searchParams = new URLSearchParams();
|
|
2165
|
+
if (params?.limit !== void 0) {
|
|
2166
|
+
searchParams.set("limit", String(params.limit));
|
|
2167
|
+
}
|
|
2168
|
+
if (params?.offset !== void 0) {
|
|
2169
|
+
searchParams.set("offset", String(params.offset));
|
|
2170
|
+
}
|
|
2171
|
+
const queryString = searchParams.toString();
|
|
2172
|
+
return this.request(`/api/mcp/v0/servers${queryString ? `?${queryString}` : ""}`);
|
|
2173
|
+
}
|
|
2174
|
+
/**
|
|
2175
|
+
* Retrieves detailed information for a specific MCP server.
|
|
2176
|
+
* @param serverId - The ID of the MCP server to retrieve.
|
|
2177
|
+
* @param params - Optional parameters, e.g., specific version.
|
|
2178
|
+
* @returns Promise containing the detailed MCP server information.
|
|
2179
|
+
*/
|
|
2180
|
+
getMcpServerDetails(serverId, params) {
|
|
2181
|
+
const searchParams = new URLSearchParams();
|
|
2182
|
+
if (params?.version) {
|
|
2183
|
+
searchParams.set("version", params.version);
|
|
2184
|
+
}
|
|
2185
|
+
const queryString = searchParams.toString();
|
|
2186
|
+
return this.request(`/api/mcp/v0/servers/${serverId}${queryString ? `?${queryString}` : ""}`);
|
|
2187
|
+
}
|
|
2188
|
+
/**
|
|
2189
|
+
* Retrieves a list of tools for a specific MCP server.
|
|
2190
|
+
* @param serverId - The ID of the MCP server.
|
|
2191
|
+
* @returns Promise containing the list of tools.
|
|
2192
|
+
*/
|
|
2193
|
+
getMcpServerTools(serverId) {
|
|
2194
|
+
return this.request(`/api/mcp/${serverId}/tools`);
|
|
2195
|
+
}
|
|
2196
|
+
/**
|
|
2197
|
+
* Gets an MCPTool resource instance for a specific tool on an MCP server.
|
|
2198
|
+
* This instance can then be used to fetch details or execute the tool.
|
|
2199
|
+
* @param serverId - The ID of the MCP server.
|
|
2200
|
+
* @param toolId - The ID of the tool.
|
|
2201
|
+
* @returns MCPTool instance.
|
|
982
2202
|
*/
|
|
983
|
-
|
|
984
|
-
return this.
|
|
2203
|
+
getMcpServerTool(serverId, toolId) {
|
|
2204
|
+
return new MCPTool(this.options, serverId, toolId);
|
|
985
2205
|
}
|
|
986
2206
|
/**
|
|
987
|
-
* Gets an
|
|
988
|
-
* @param
|
|
989
|
-
* @returns
|
|
2207
|
+
* Gets an A2A client for interacting with an agent via the A2A protocol
|
|
2208
|
+
* @param agentId - ID of the agent to interact with
|
|
2209
|
+
* @returns A2A client instance
|
|
990
2210
|
*/
|
|
991
|
-
|
|
992
|
-
return new
|
|
2211
|
+
getA2A(agentId) {
|
|
2212
|
+
return new A2A(this.options, agentId);
|
|
993
2213
|
}
|
|
994
2214
|
};
|
|
995
2215
|
|