@mastra/client-js 0.11.3 → 0.12.0-alpha.1
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 +27 -0
- package/dist/client.d.ts +0 -4
- package/dist/client.d.ts.map +1 -1
- package/dist/index.cjs +15 -225
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -225
- package/dist/index.js.map +1 -1
- package/dist/resources/agent-builder.d.ts +15 -2
- package/dist/resources/agent-builder.d.ts.map +1 -1
- package/dist/types.d.ts +0 -21
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -7
- package/dist/adapters/agui.d.ts +0 -23
- package/dist/adapters/agui.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @mastra/client-js
|
|
2
2
|
|
|
3
|
+
## 0.12.0-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [8fbf79e]
|
|
8
|
+
- @mastra/core@0.16.0-alpha.1
|
|
9
|
+
|
|
10
|
+
## 0.12.0-alpha.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- 6155cfc: Remove AGUI implementation from client-js
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- cf4e353: Agent Builder Template - adding in UI components to use agent builder template actions
|
|
19
|
+
- 5397eb4: Add public URL support when adding files in Multi Modal
|
|
20
|
+
- Updated dependencies [fd83526]
|
|
21
|
+
- Updated dependencies [d0b90ab]
|
|
22
|
+
- Updated dependencies [6f5eb7a]
|
|
23
|
+
- Updated dependencies [a01cf14]
|
|
24
|
+
- Updated dependencies [a9e50ee]
|
|
25
|
+
- Updated dependencies [5397eb4]
|
|
26
|
+
- Updated dependencies [c9f4e4a]
|
|
27
|
+
- Updated dependencies [0acbc80]
|
|
28
|
+
- @mastra/core@0.16.0-alpha.0
|
|
29
|
+
|
|
3
30
|
## 0.11.3
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { AbstractAgent } from '@ag-ui/client';
|
|
2
1
|
import type { AITraceRecord, AITracesPaginatedArg, WorkflowInfo } from '@mastra/core';
|
|
3
2
|
import type { ServerDetailInfo } from '@mastra/core/mcp';
|
|
4
3
|
import { Agent, MemoryThread, Tool, Workflow, Vector, BaseResource, Network, A2A, MCPTool, LegacyWorkflow, AgentBuilder } from './resources/index.js';
|
|
@@ -13,9 +12,6 @@ export declare class MastraClient extends BaseResource {
|
|
|
13
12
|
* @returns Promise containing map of agent IDs to agent details
|
|
14
13
|
*/
|
|
15
14
|
getAgents(): Promise<Record<string, GetAgentResponse>>;
|
|
16
|
-
getAGUI({ resourceId }: {
|
|
17
|
-
resourceId: string;
|
|
18
|
-
}): Promise<Record<string, AbstractAgent>>;
|
|
19
15
|
/**
|
|
20
16
|
* Gets an agent instance by ID
|
|
21
17
|
* @param agentId - ID of the agent to retrieve
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EACL,KAAK,EACL,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,OAAO,EACP,GAAG,EACH,OAAO,EACP,cAAc,EACd,YAAY,EAEb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,mBAAmB,EAA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EACzB,OAAO,EACP,QAAQ,EACR,aAAa,EACb,UAAU,GACX,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,aAAa,EAAE,MAAM,CAAC;QACtB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB;IAUD;;;OAGG;IACI,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAI/D;;;;OAIG;IACI,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAIvD,mBAAmB,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAqBzF;;;;OAIG;IACI,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAenF;;;;OAIG;IACI,mBAAmB,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAezF;;;;OAIG;IACI,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAOrE;;;OAGG;IACH,iBAAiB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAItC,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAInD,WAAW,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAGxE"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var client = require('@ag-ui/client');
|
|
4
|
-
var rxjs = require('rxjs');
|
|
5
3
|
var uiUtils = require('@ai-sdk/ui-utils');
|
|
6
4
|
var uuid = require('@lukeed/uuid');
|
|
7
5
|
var runtimeContext = require('@mastra/core/runtime-context');
|
|
@@ -13,205 +11,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
13
11
|
|
|
14
12
|
var originalZodToJsonSchema__default = /*#__PURE__*/_interopDefault(originalZodToJsonSchema);
|
|
15
13
|
|
|
16
|
-
// src/
|
|
17
|
-
var AGUIAdapter = class extends client.AbstractAgent {
|
|
18
|
-
agent;
|
|
19
|
-
resourceId;
|
|
20
|
-
constructor({ agent, agentId, resourceId, ...rest }) {
|
|
21
|
-
super({
|
|
22
|
-
agentId,
|
|
23
|
-
...rest
|
|
24
|
-
});
|
|
25
|
-
this.agent = agent;
|
|
26
|
-
this.resourceId = resourceId;
|
|
27
|
-
}
|
|
28
|
-
run(input) {
|
|
29
|
-
return new rxjs.Observable((subscriber) => {
|
|
30
|
-
const convertedMessages = convertMessagesToMastraMessages(input.messages);
|
|
31
|
-
subscriber.next({
|
|
32
|
-
type: client.EventType.RUN_STARTED,
|
|
33
|
-
threadId: input.threadId,
|
|
34
|
-
runId: input.runId
|
|
35
|
-
});
|
|
36
|
-
this.agent.stream({
|
|
37
|
-
threadId: input.threadId,
|
|
38
|
-
resourceId: this.resourceId ?? "",
|
|
39
|
-
runId: input.runId,
|
|
40
|
-
messages: convertedMessages,
|
|
41
|
-
clientTools: input.tools.reduce(
|
|
42
|
-
(acc, tool) => {
|
|
43
|
-
acc[tool.name] = {
|
|
44
|
-
id: tool.name,
|
|
45
|
-
description: tool.description,
|
|
46
|
-
inputSchema: tool.parameters
|
|
47
|
-
};
|
|
48
|
-
return acc;
|
|
49
|
-
},
|
|
50
|
-
{}
|
|
51
|
-
)
|
|
52
|
-
}).then((response) => {
|
|
53
|
-
let currentMessageId = void 0;
|
|
54
|
-
let isInTextMessage = false;
|
|
55
|
-
return response.processDataStream({
|
|
56
|
-
onTextPart: (text) => {
|
|
57
|
-
if (currentMessageId === void 0) {
|
|
58
|
-
currentMessageId = generateUUID();
|
|
59
|
-
const message2 = {
|
|
60
|
-
type: client.EventType.TEXT_MESSAGE_START,
|
|
61
|
-
messageId: currentMessageId,
|
|
62
|
-
role: "assistant"
|
|
63
|
-
};
|
|
64
|
-
subscriber.next(message2);
|
|
65
|
-
isInTextMessage = true;
|
|
66
|
-
}
|
|
67
|
-
const message = {
|
|
68
|
-
type: client.EventType.TEXT_MESSAGE_CONTENT,
|
|
69
|
-
messageId: currentMessageId,
|
|
70
|
-
delta: text
|
|
71
|
-
};
|
|
72
|
-
subscriber.next(message);
|
|
73
|
-
},
|
|
74
|
-
onFinishMessagePart: () => {
|
|
75
|
-
if (currentMessageId !== void 0) {
|
|
76
|
-
const message = {
|
|
77
|
-
type: client.EventType.TEXT_MESSAGE_END,
|
|
78
|
-
messageId: currentMessageId
|
|
79
|
-
};
|
|
80
|
-
subscriber.next(message);
|
|
81
|
-
isInTextMessage = false;
|
|
82
|
-
}
|
|
83
|
-
subscriber.next({
|
|
84
|
-
type: client.EventType.RUN_FINISHED,
|
|
85
|
-
threadId: input.threadId,
|
|
86
|
-
runId: input.runId
|
|
87
|
-
});
|
|
88
|
-
subscriber.complete();
|
|
89
|
-
},
|
|
90
|
-
onToolCallPart(streamPart) {
|
|
91
|
-
const parentMessageId = currentMessageId || generateUUID();
|
|
92
|
-
if (isInTextMessage) {
|
|
93
|
-
const message = {
|
|
94
|
-
type: client.EventType.TEXT_MESSAGE_END,
|
|
95
|
-
messageId: parentMessageId
|
|
96
|
-
};
|
|
97
|
-
subscriber.next(message);
|
|
98
|
-
isInTextMessage = false;
|
|
99
|
-
}
|
|
100
|
-
subscriber.next({
|
|
101
|
-
type: client.EventType.TOOL_CALL_START,
|
|
102
|
-
toolCallId: streamPart.toolCallId,
|
|
103
|
-
toolCallName: streamPart.toolName,
|
|
104
|
-
parentMessageId
|
|
105
|
-
});
|
|
106
|
-
subscriber.next({
|
|
107
|
-
type: client.EventType.TOOL_CALL_ARGS,
|
|
108
|
-
toolCallId: streamPart.toolCallId,
|
|
109
|
-
delta: JSON.stringify(streamPart.args),
|
|
110
|
-
parentMessageId
|
|
111
|
-
});
|
|
112
|
-
subscriber.next({
|
|
113
|
-
type: client.EventType.TOOL_CALL_END,
|
|
114
|
-
toolCallId: streamPart.toolCallId,
|
|
115
|
-
parentMessageId
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}).catch((error) => {
|
|
120
|
-
console.error("error", error);
|
|
121
|
-
subscriber.error(error);
|
|
122
|
-
});
|
|
123
|
-
return () => {
|
|
124
|
-
};
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
function generateUUID() {
|
|
129
|
-
if (typeof crypto !== "undefined") {
|
|
130
|
-
if (typeof crypto.randomUUID === "function") {
|
|
131
|
-
return crypto.randomUUID();
|
|
132
|
-
}
|
|
133
|
-
if (typeof crypto.getRandomValues === "function") {
|
|
134
|
-
const buffer = new Uint8Array(16);
|
|
135
|
-
crypto.getRandomValues(buffer);
|
|
136
|
-
buffer[6] = buffer[6] & 15 | 64;
|
|
137
|
-
buffer[8] = buffer[8] & 63 | 128;
|
|
138
|
-
let hex = "";
|
|
139
|
-
for (let i = 0; i < 16; i++) {
|
|
140
|
-
hex += buffer[i].toString(16).padStart(2, "0");
|
|
141
|
-
if (i === 3 || i === 5 || i === 7 || i === 9) hex += "-";
|
|
142
|
-
}
|
|
143
|
-
return hex;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
147
|
-
const r = Math.random() * 16 | 0;
|
|
148
|
-
const v = c === "x" ? r : r & 3 | 8;
|
|
149
|
-
return v.toString(16);
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
function convertMessagesToMastraMessages(messages) {
|
|
153
|
-
const result = [];
|
|
154
|
-
const toolCallsWithResults = /* @__PURE__ */ new Set();
|
|
155
|
-
for (const message of messages) {
|
|
156
|
-
if (message.role === "tool" && message.toolCallId) {
|
|
157
|
-
toolCallsWithResults.add(message.toolCallId);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
for (const message of messages) {
|
|
161
|
-
if (message.role === "assistant") {
|
|
162
|
-
const parts = message.content ? [{ type: "text", text: message.content }] : [];
|
|
163
|
-
for (const toolCall of message.toolCalls ?? []) {
|
|
164
|
-
parts.push({
|
|
165
|
-
type: "tool-call",
|
|
166
|
-
toolCallId: toolCall.id,
|
|
167
|
-
toolName: toolCall.function.name,
|
|
168
|
-
args: JSON.parse(toolCall.function.arguments)
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
result.push({
|
|
172
|
-
role: "assistant",
|
|
173
|
-
content: parts
|
|
174
|
-
});
|
|
175
|
-
if (message.toolCalls?.length) {
|
|
176
|
-
for (const toolCall of message.toolCalls) {
|
|
177
|
-
if (!toolCallsWithResults.has(toolCall.id)) {
|
|
178
|
-
result.push({
|
|
179
|
-
role: "tool",
|
|
180
|
-
content: [
|
|
181
|
-
{
|
|
182
|
-
type: "tool-result",
|
|
183
|
-
toolCallId: toolCall.id,
|
|
184
|
-
toolName: toolCall.function.name,
|
|
185
|
-
result: JSON.parse(toolCall.function.arguments)
|
|
186
|
-
// This is still wrong but matches test expectations
|
|
187
|
-
}
|
|
188
|
-
]
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
} else if (message.role === "user") {
|
|
194
|
-
result.push({
|
|
195
|
-
role: "user",
|
|
196
|
-
content: message.content || ""
|
|
197
|
-
});
|
|
198
|
-
} else if (message.role === "tool") {
|
|
199
|
-
result.push({
|
|
200
|
-
role: "tool",
|
|
201
|
-
content: [
|
|
202
|
-
{
|
|
203
|
-
type: "tool-result",
|
|
204
|
-
toolCallId: message.toolCallId || "unknown",
|
|
205
|
-
toolName: "unknown",
|
|
206
|
-
// toolName is not available in tool messages from CopilotKit
|
|
207
|
-
result: message.content
|
|
208
|
-
}
|
|
209
|
-
]
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
return result;
|
|
214
|
-
}
|
|
14
|
+
// src/resources/agent.ts
|
|
215
15
|
function parseClientRuntimeContext(runtimeContext$1) {
|
|
216
16
|
if (runtimeContext$1) {
|
|
217
17
|
if (runtimeContext$1 instanceof runtimeContext.RuntimeContext) {
|
|
@@ -2316,19 +2116,24 @@ var AgentBuilder = class extends BaseResource {
|
|
|
2316
2116
|
* Creates a new agent builder action run and returns the runId.
|
|
2317
2117
|
* This calls `/api/agent-builder/:actionId/create-run`.
|
|
2318
2118
|
*/
|
|
2319
|
-
async createRun(params
|
|
2119
|
+
async createRun(params) {
|
|
2320
2120
|
const searchParams = new URLSearchParams();
|
|
2321
|
-
if (runId) {
|
|
2322
|
-
searchParams.set("runId", runId);
|
|
2121
|
+
if (!!params?.runId) {
|
|
2122
|
+
searchParams.set("runId", params.runId);
|
|
2323
2123
|
}
|
|
2324
|
-
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
2325
|
-
const { runtimeContext: _, ...actionParams } = params;
|
|
2326
2124
|
const url = `/api/agent-builder/${this.actionId}/create-run${searchParams.toString() ? `?${searchParams.toString()}` : ""}`;
|
|
2327
2125
|
return this.request(url, {
|
|
2328
|
-
method: "POST"
|
|
2329
|
-
body: { ...actionParams, runtimeContext }
|
|
2126
|
+
method: "POST"
|
|
2330
2127
|
});
|
|
2331
2128
|
}
|
|
2129
|
+
/**
|
|
2130
|
+
* Creates a new workflow run (alias for createRun)
|
|
2131
|
+
* @param params - Optional object containing the optional runId
|
|
2132
|
+
* @returns Promise containing the runId of the created run
|
|
2133
|
+
*/
|
|
2134
|
+
createRunAsync(params) {
|
|
2135
|
+
return this.createRun(params);
|
|
2136
|
+
}
|
|
2332
2137
|
/**
|
|
2333
2138
|
* Starts agent builder action asynchronously and waits for completion.
|
|
2334
2139
|
* This calls `/api/agent-builder/:actionId/start-async`.
|
|
@@ -2542,8 +2347,8 @@ var AgentBuilder = class extends BaseResource {
|
|
|
2542
2347
|
* and streams any remaining progress.
|
|
2543
2348
|
* This calls `/api/agent-builder/:actionId/watch`.
|
|
2544
2349
|
*/
|
|
2545
|
-
async watch({ runId }, onRecord) {
|
|
2546
|
-
const url = `/api/agent-builder/${this.actionId}/watch?runId=${runId}`;
|
|
2350
|
+
async watch({ runId, eventType }, onRecord) {
|
|
2351
|
+
const url = `/api/agent-builder/${this.actionId}/watch?runId=${runId}${eventType ? `&eventType=${eventType}` : ""}`;
|
|
2547
2352
|
const response = await this.request(url, {
|
|
2548
2353
|
method: "GET",
|
|
2549
2354
|
stream: true
|
|
@@ -2901,21 +2706,6 @@ var MastraClient = class extends BaseResource {
|
|
|
2901
2706
|
getAgents() {
|
|
2902
2707
|
return this.request("/api/agents");
|
|
2903
2708
|
}
|
|
2904
|
-
async getAGUI({ resourceId }) {
|
|
2905
|
-
const agents = await this.getAgents();
|
|
2906
|
-
return Object.entries(agents).reduce(
|
|
2907
|
-
(acc, [agentId]) => {
|
|
2908
|
-
const agent = this.getAgent(agentId);
|
|
2909
|
-
acc[agentId] = new AGUIAdapter({
|
|
2910
|
-
agentId,
|
|
2911
|
-
agent,
|
|
2912
|
-
resourceId
|
|
2913
|
-
});
|
|
2914
|
-
return acc;
|
|
2915
|
-
},
|
|
2916
|
-
{}
|
|
2917
|
-
);
|
|
2918
|
-
}
|
|
2919
2709
|
/**
|
|
2920
2710
|
* Gets an agent instance by ID
|
|
2921
2711
|
* @param agentId - ID of the agent to retrieve
|