@mastra/client-js 0.10.24-alpha.0 → 0.11.0-alpha.2
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 +7 -7
- package/CHANGELOG.md +24 -0
- package/dist/adapters/agui.d.ts +1 -1
- package/dist/adapters/agui.d.ts.map +1 -1
- package/dist/client.d.ts +5 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/index.cjs +117 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +117 -53
- package/dist/index.js.map +1 -1
- package/dist/resources/agent.d.ts +10 -11
- package/dist/resources/agent.d.ts.map +1 -1
- package/dist/resources/base.d.ts.map +1 -1
- package/dist/resources/index.d.ts +1 -0
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/memory-thread.d.ts +1 -1
- package/dist/resources/memory-thread.d.ts.map +1 -1
- package/dist/resources/network-memory-thread.d.ts +1 -1
- package/dist/resources/network-memory-thread.d.ts.map +1 -1
- package/dist/resources/network.d.ts +1 -1
- package/dist/resources/network.d.ts.map +1 -1
- package/dist/resources/observability.d.ts +19 -0
- package/dist/resources/observability.d.ts.map +1 -0
- package/dist/resources/tool.d.ts.map +1 -1
- package/dist/resources/vNextNetwork.d.ts +1 -1
- package/dist/resources/vNextNetwork.d.ts.map +1 -1
- package/dist/types.d.ts +16 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/process-client-tools.d.ts.map +1 -1
- package/dist/utils/zod-to-json-schema.d.ts +2 -104
- package/dist/utils/zod-to-json-schema.d.ts.map +1 -1
- package/eslint.config.js +6 -1
- package/integration-tests/src/mastra/index.ts +2 -2
- package/package.json +6 -4
- package/src/adapters/agui.test.ts +0 -29
- package/src/adapters/agui.ts +1 -1
- package/src/client.ts +13 -0
- package/src/example.ts +1 -1
- package/src/index.test.ts +29 -2
- package/src/resources/agent.ts +30 -31
- package/src/resources/base.ts +2 -1
- package/src/resources/index.ts +1 -0
- package/src/resources/memory-thread.test.ts +1 -1
- package/src/resources/memory-thread.ts +1 -1
- package/src/resources/network-memory-thread.test.ts +1 -1
- package/src/resources/network-memory-thread.ts +1 -1
- package/src/resources/network.ts +1 -1
- package/src/resources/observability.ts +53 -0
- package/src/resources/tool.ts +1 -1
- package/src/resources/vNextNetwork.ts +2 -2
- package/src/resources/workflow.ts +1 -1
- package/src/types.ts +27 -16
- package/src/utils/process-client-tools.ts +1 -1
- package/src/utils/process-mastra-stream.test.ts +2 -2
- package/src/utils/zod-to-json-schema.ts +22 -3
- package/src/v2-messages.test.ts +1 -1
- package/tsconfig.json +2 -2
- package/tsup.config.ts +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/client-js@0.
|
|
2
|
+
> @mastra/client-js@0.11.0-alpha.2 build /home/runner/work/mastra/mastra/client-sdks/client-js
|
|
3
3
|
> tsup --config tsup.config.ts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
[34mCLI[39m Cleaning output folder
|
|
11
11
|
[34mESM[39m Build start
|
|
12
12
|
[34mCJS[39m Build start
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[
|
|
13
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m96.06 KB[39m
|
|
14
|
+
[32mCJS[39m [1mdist/index.cjs.map [22m[32m206.08 KB[39m
|
|
15
|
+
[32mCJS[39m ⚡️ Build success in 3341ms
|
|
16
|
+
[32mESM[39m [1mdist/index.js [22m[32m95.72 KB[39m
|
|
17
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m205.90 KB[39m
|
|
18
|
+
[32mESM[39m ⚡️ Build success in 3342ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @mastra/client-js
|
|
2
2
|
|
|
3
|
+
## 0.11.0-alpha.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`2e58325`](https://github.com/mastra-ai/mastra/commit/2e58325beb170f5b92f856e27d915cd26917e5e6)]:
|
|
8
|
+
- @mastra/core@0.14.2-alpha.2
|
|
9
|
+
|
|
10
|
+
## 0.11.0-alpha.1
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- [#6993](https://github.com/mastra-ai/mastra/pull/6993) [`82d9f64`](https://github.com/mastra-ai/mastra/commit/82d9f647fbe4f0177320e7c05073fce88599aa95) Thanks [@wardpeet](https://github.com/wardpeet)! - Improve types and fix linting issues
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#6967](https://github.com/mastra-ai/mastra/pull/6967) [`01be5d3`](https://github.com/mastra-ai/mastra/commit/01be5d358fad8faa101e5c69dfa54562c02cc0af) Thanks [@YujohnNattrass](https://github.com/YujohnNattrass)! - Implement AI traces for server apis and client sdk
|
|
19
|
+
|
|
20
|
+
- [#6972](https://github.com/mastra-ai/mastra/pull/6972) [`00ef6c1`](https://github.com/mastra-ai/mastra/commit/00ef6c1d3c76708712acd3de7f39c4d6b0f3b427) Thanks [@roaminro](https://github.com/roaminro)! - add credentials option for fetch requests
|
|
21
|
+
|
|
22
|
+
- [#6942](https://github.com/mastra-ai/mastra/pull/6942) [`ca8ec2f`](https://github.com/mastra-ai/mastra/commit/ca8ec2f61884b9dfec5fc0d5f4f29d281ad13c01) Thanks [@wardpeet](https://github.com/wardpeet)! - Add zod as peerdeps for all packages
|
|
23
|
+
|
|
24
|
+
- Updated dependencies [[`943a7f3`](https://github.com/mastra-ai/mastra/commit/943a7f3dbc6a8ab3f9b7bc7c8a1c5b319c3d7f56), [`be49354`](https://github.com/mastra-ai/mastra/commit/be493546dca540101923ec700feb31f9a13939f2), [`d591ab3`](https://github.com/mastra-ai/mastra/commit/d591ab3ecc985c1870c0db347f8d7a20f7360536), [`ba82abe`](https://github.com/mastra-ai/mastra/commit/ba82abe76e869316bb5a9c95e8ea3946f3436fae), [`727f7e5`](https://github.com/mastra-ai/mastra/commit/727f7e5086e62e0dfe3356fb6dcd8bcb420af246), [`82d9f64`](https://github.com/mastra-ai/mastra/commit/82d9f647fbe4f0177320e7c05073fce88599aa95), [`4189486`](https://github.com/mastra-ai/mastra/commit/4189486c6718fda78347bdf4ce4d3fc33b2236e1), [`ca8ec2f`](https://github.com/mastra-ai/mastra/commit/ca8ec2f61884b9dfec5fc0d5f4f29d281ad13c01)]:
|
|
25
|
+
- @mastra/core@0.14.2-alpha.1
|
|
26
|
+
|
|
3
27
|
## 0.10.24-alpha.0
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/dist/adapters/agui.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AgentConfig, BaseEvent, Message, RunAgentInput } from '@ag-ui/client';
|
|
2
2
|
import { AbstractAgent } from '@ag-ui/client';
|
|
3
|
-
import type { CoreMessage } from '@mastra/core';
|
|
3
|
+
import type { CoreMessage } from '@mastra/core/llm';
|
|
4
4
|
import { Observable } from 'rxjs';
|
|
5
5
|
import type { Agent } from '../resources/agent.js';
|
|
6
6
|
interface MastraAgentConfig extends AgentConfig {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agui.d.ts","sourceRoot":"","sources":["../../src/adapters/agui.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,SAAS,EACT,OAAO,EACP,aAAa,EASd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,aAAa,EAAa,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"agui.d.ts","sourceRoot":"","sources":["../../src/adapters/agui.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,SAAS,EACT,OAAO,EACP,aAAa,EASd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,aAAa,EAAa,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD,UAAU,iBAAkB,SAAQ,WAAW;IAC7C,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,WAAY,SAAQ,aAAa;IAC5C,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;gBACR,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,EAAE,iBAAiB;IAStE,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,aAAa,GAAG,UAAU,CAAC,SAAS,CAAC;CA+G3D;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAgCrC;AAED,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,WAAW,EAAE,CAoElF"}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { AbstractAgent } from '@ag-ui/client';
|
|
2
|
+
import type { AITraceRecord, AITracesPaginatedArg } from '@mastra/core';
|
|
2
3
|
import type { ServerDetailInfo } from '@mastra/core/mcp';
|
|
3
4
|
import { Agent, MemoryThread, Tool, Workflow, Vector, BaseResource, Network, A2A, MCPTool, LegacyWorkflow } from './resources/index.js';
|
|
4
5
|
import { NetworkMemoryThread } from './resources/network-memory-thread.js';
|
|
5
6
|
import { VNextNetwork } from './resources/vNextNetwork.js';
|
|
6
|
-
import type { ClientOptions, CreateMemoryThreadParams, CreateMemoryThreadResponse, GetAgentResponse, GetLogParams, GetLogsParams, GetLogsResponse, GetMemoryThreadParams, GetMemoryThreadResponse, GetNetworkResponse, GetTelemetryParams, GetTelemetryResponse, GetToolResponse, GetWorkflowResponse, SaveMessageToMemoryParams, SaveMessageToMemoryResponse, McpServerListResponse, McpServerToolListResponse, GetLegacyWorkflowResponse, GetVNextNetworkResponse, GetNetworkMemoryThreadParams, CreateNetworkMemoryThreadParams, SaveNetworkMessageToMemoryParams, GetScorerResponse, GetScoresByScorerIdParams, GetScoresResponse, GetScoresByRunIdParams, GetScoresByEntityIdParams, SaveScoreParams, SaveScoreResponse } from './types.js';
|
|
7
|
+
import type { ClientOptions, CreateMemoryThreadParams, CreateMemoryThreadResponse, GetAgentResponse, GetLogParams, GetLogsParams, GetLogsResponse, GetMemoryThreadParams, GetMemoryThreadResponse, GetNetworkResponse, GetTelemetryParams, GetTelemetryResponse, GetToolResponse, GetWorkflowResponse, SaveMessageToMemoryParams, SaveMessageToMemoryResponse, McpServerListResponse, McpServerToolListResponse, GetLegacyWorkflowResponse, GetVNextNetworkResponse, GetNetworkMemoryThreadParams, CreateNetworkMemoryThreadParams, SaveNetworkMessageToMemoryParams, GetScorerResponse, GetScoresByScorerIdParams, GetScoresResponse, GetScoresByRunIdParams, GetScoresByEntityIdParams, SaveScoreParams, SaveScoreResponse, GetAITracesResponse } from './types.js';
|
|
7
8
|
export declare class MastraClient extends BaseResource {
|
|
9
|
+
private observability;
|
|
8
10
|
constructor(options: ClientOptions);
|
|
9
11
|
/**
|
|
10
12
|
* Retrieves all available agents
|
|
@@ -266,5 +268,7 @@ export declare class MastraClient extends BaseResource {
|
|
|
266
268
|
* @returns Promise containing model providers with available keys
|
|
267
269
|
*/
|
|
268
270
|
getModelProviders(): Promise<string[]>;
|
|
271
|
+
getAITrace(traceId: string): Promise<AITraceRecord>;
|
|
272
|
+
getAITraces(params: AITracesPaginatedArg): Promise<GetAITracesResponse>;
|
|
269
273
|
}
|
|
270
274
|
//# sourceMappingURL=client.d.ts.map
|
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,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,EACL,KAAK,EACL,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,OAAO,EACP,GAAG,EACH,OAAO,EACP,cAAc,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,EACL,KAAK,EACL,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,OAAO,EACP,GAAG,EACH,OAAO,EACP,cAAc,EAEf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EACV,aAAa,EACb,wBAAwB,EACxB,0BAA0B,EAC1B,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,2BAA2B,EAC3B,qBAAqB,EACrB,yBAAyB,EACzB,yBAAyB,EACzB,uBAAuB,EACvB,4BAA4B,EAC5B,+BAA+B,EAC/B,gCAAgC,EAChC,iBAAiB,EACjB,yBAAyB,EACzB,iBAAiB,EACjB,sBAAsB,EACtB,y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AM,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
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
var client = require('@ag-ui/client');
|
|
4
4
|
var rxjs = require('rxjs');
|
|
5
5
|
var uiUtils = require('@ai-sdk/ui-utils');
|
|
6
|
-
var zod = require('zod');
|
|
7
|
-
var originalZodToJsonSchema = require('zod-to-json-schema');
|
|
8
|
-
var isVercelTool = require('@mastra/core/tools/is-vercel-tool');
|
|
9
6
|
var uuid = require('@lukeed/uuid');
|
|
10
7
|
var runtimeContext = require('@mastra/core/runtime-context');
|
|
8
|
+
var isVercelTool = require('@mastra/core/tools/is-vercel-tool');
|
|
9
|
+
var zod = require('zod');
|
|
10
|
+
var originalZodToJsonSchema = require('zod-to-json-schema');
|
|
11
11
|
|
|
12
12
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
13
|
|
|
@@ -212,12 +212,29 @@ function convertMessagesToMastraMessages(messages) {
|
|
|
212
212
|
}
|
|
213
213
|
return result;
|
|
214
214
|
}
|
|
215
|
+
function parseClientRuntimeContext(runtimeContext$1) {
|
|
216
|
+
if (runtimeContext$1) {
|
|
217
|
+
if (runtimeContext$1 instanceof runtimeContext.RuntimeContext) {
|
|
218
|
+
return Object.fromEntries(runtimeContext$1.entries());
|
|
219
|
+
}
|
|
220
|
+
return runtimeContext$1;
|
|
221
|
+
}
|
|
222
|
+
return void 0;
|
|
223
|
+
}
|
|
224
|
+
function isZodType(value) {
|
|
225
|
+
return typeof value === "object" && value !== null && "_def" in value && "parse" in value && typeof value.parse === "function" && "safeParse" in value && typeof value.safeParse === "function";
|
|
226
|
+
}
|
|
215
227
|
function zodToJsonSchema(zodSchema) {
|
|
216
|
-
if (!(zodSchema
|
|
228
|
+
if (!isZodType(zodSchema)) {
|
|
217
229
|
return zodSchema;
|
|
218
230
|
}
|
|
231
|
+
if ("toJSONSchema" in zod.z) {
|
|
232
|
+
return zod.z.toJSONSchema(zodSchema);
|
|
233
|
+
}
|
|
219
234
|
return originalZodToJsonSchema__default.default(zodSchema, { $refStrategy: "none" });
|
|
220
235
|
}
|
|
236
|
+
|
|
237
|
+
// src/utils/process-client-tools.ts
|
|
221
238
|
function processClientTools(clientTools) {
|
|
222
239
|
if (!clientTools) {
|
|
223
240
|
return void 0;
|
|
@@ -246,6 +263,42 @@ function processClientTools(clientTools) {
|
|
|
246
263
|
);
|
|
247
264
|
}
|
|
248
265
|
|
|
266
|
+
// src/utils/process-mastra-stream.ts
|
|
267
|
+
async function processMastraStream({
|
|
268
|
+
stream,
|
|
269
|
+
onChunk
|
|
270
|
+
}) {
|
|
271
|
+
const reader = stream.getReader();
|
|
272
|
+
const decoder = new TextDecoder();
|
|
273
|
+
let buffer = "";
|
|
274
|
+
try {
|
|
275
|
+
while (true) {
|
|
276
|
+
const { done, value } = await reader.read();
|
|
277
|
+
if (done) break;
|
|
278
|
+
buffer += decoder.decode(value, { stream: true });
|
|
279
|
+
const lines = buffer.split("\n\n");
|
|
280
|
+
buffer = lines.pop() || "";
|
|
281
|
+
for (const line of lines) {
|
|
282
|
+
if (line.startsWith("data: ")) {
|
|
283
|
+
const data = line.slice(6);
|
|
284
|
+
if (data === "[DONE]") {
|
|
285
|
+
console.log("\u{1F3C1} Stream finished");
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
try {
|
|
289
|
+
const json = JSON.parse(data);
|
|
290
|
+
await onChunk(json);
|
|
291
|
+
} catch (error) {
|
|
292
|
+
console.error("\u274C JSON parse error:", error, "Data:", data);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
} finally {
|
|
298
|
+
reader.releaseLock();
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
249
302
|
// src/resources/base.ts
|
|
250
303
|
var BaseResource = class {
|
|
251
304
|
options;
|
|
@@ -260,7 +313,7 @@ var BaseResource = class {
|
|
|
260
313
|
*/
|
|
261
314
|
async request(path, options = {}) {
|
|
262
315
|
let lastError = null;
|
|
263
|
-
const { baseUrl, retries = 3, backoffMs = 100, maxBackoffMs = 1e3, headers = {} } = this.options;
|
|
316
|
+
const { baseUrl, retries = 3, backoffMs = 100, maxBackoffMs = 1e3, headers = {}, credentials } = this.options;
|
|
264
317
|
let delay = backoffMs;
|
|
265
318
|
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
266
319
|
try {
|
|
@@ -274,6 +327,7 @@ var BaseResource = class {
|
|
|
274
327
|
// 'x-mastra-client-type': 'js',
|
|
275
328
|
},
|
|
276
329
|
signal: this.options.abortSignal,
|
|
330
|
+
credentials: options.credentials ?? credentials,
|
|
277
331
|
body: options.body instanceof FormData ? options.body : options.body ? JSON.stringify(options.body) : void 0
|
|
278
332
|
});
|
|
279
333
|
if (!response.ok) {
|
|
@@ -306,51 +360,6 @@ var BaseResource = class {
|
|
|
306
360
|
throw lastError || new Error("Request failed");
|
|
307
361
|
}
|
|
308
362
|
};
|
|
309
|
-
function parseClientRuntimeContext(runtimeContext$1) {
|
|
310
|
-
if (runtimeContext$1) {
|
|
311
|
-
if (runtimeContext$1 instanceof runtimeContext.RuntimeContext) {
|
|
312
|
-
return Object.fromEntries(runtimeContext$1.entries());
|
|
313
|
-
}
|
|
314
|
-
return runtimeContext$1;
|
|
315
|
-
}
|
|
316
|
-
return void 0;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
// src/utils/process-mastra-stream.ts
|
|
320
|
-
async function processMastraStream({
|
|
321
|
-
stream,
|
|
322
|
-
onChunk
|
|
323
|
-
}) {
|
|
324
|
-
const reader = stream.getReader();
|
|
325
|
-
const decoder = new TextDecoder();
|
|
326
|
-
let buffer = "";
|
|
327
|
-
try {
|
|
328
|
-
while (true) {
|
|
329
|
-
const { done, value } = await reader.read();
|
|
330
|
-
if (done) break;
|
|
331
|
-
buffer += decoder.decode(value, { stream: true });
|
|
332
|
-
const lines = buffer.split("\n\n");
|
|
333
|
-
buffer = lines.pop() || "";
|
|
334
|
-
for (const line of lines) {
|
|
335
|
-
if (line.startsWith("data: ")) {
|
|
336
|
-
const data = line.slice(6);
|
|
337
|
-
if (data === "[DONE]") {
|
|
338
|
-
console.log("\u{1F3C1} Stream finished");
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
try {
|
|
342
|
-
const json = JSON.parse(data);
|
|
343
|
-
await onChunk(json);
|
|
344
|
-
} catch (error) {
|
|
345
|
-
console.error("\u274C JSON parse error:", error, "Data:", data);
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
} finally {
|
|
351
|
-
reader.releaseLock();
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
363
|
|
|
355
364
|
// src/resources/agent.ts
|
|
356
365
|
async function executeToolCallAndRespond({
|
|
@@ -1778,7 +1787,7 @@ var LegacyWorkflow = class extends BaseResource {
|
|
|
1778
1787
|
};
|
|
1779
1788
|
|
|
1780
1789
|
// src/resources/tool.ts
|
|
1781
|
-
var
|
|
1790
|
+
var Tool = class extends BaseResource {
|
|
1782
1791
|
constructor(options, toolId) {
|
|
1783
1792
|
super(options);
|
|
1784
1793
|
this.toolId = toolId;
|
|
@@ -2047,7 +2056,7 @@ var Workflow = class extends BaseResource {
|
|
|
2047
2056
|
const parsedChunk = JSON.parse(newChunk);
|
|
2048
2057
|
controller.enqueue(parsedChunk);
|
|
2049
2058
|
failedChunk = void 0;
|
|
2050
|
-
} catch
|
|
2059
|
+
} catch {
|
|
2051
2060
|
failedChunk = newChunk;
|
|
2052
2061
|
}
|
|
2053
2062
|
}
|
|
@@ -2231,6 +2240,53 @@ var MCPTool = class extends BaseResource {
|
|
|
2231
2240
|
}
|
|
2232
2241
|
};
|
|
2233
2242
|
|
|
2243
|
+
// src/resources/observability.ts
|
|
2244
|
+
var Observability = class extends BaseResource {
|
|
2245
|
+
constructor(options) {
|
|
2246
|
+
super(options);
|
|
2247
|
+
}
|
|
2248
|
+
/**
|
|
2249
|
+
* Retrieves a specific AI trace by ID
|
|
2250
|
+
* @param traceId - ID of the trace to retrieve
|
|
2251
|
+
* @returns Promise containing the AI trace with all its spans
|
|
2252
|
+
*/
|
|
2253
|
+
getTrace(traceId) {
|
|
2254
|
+
return this.request(`/api/observability/traces/${traceId}`);
|
|
2255
|
+
}
|
|
2256
|
+
/**
|
|
2257
|
+
* Retrieves paginated list of AI traces with optional filtering
|
|
2258
|
+
* @param params - Parameters for pagination and filtering
|
|
2259
|
+
* @returns Promise containing paginated traces and pagination info
|
|
2260
|
+
*/
|
|
2261
|
+
getTraces(params) {
|
|
2262
|
+
const { pagination, filters } = params;
|
|
2263
|
+
const { page, perPage, dateRange } = pagination || {};
|
|
2264
|
+
const { name, spanType } = filters || {};
|
|
2265
|
+
const searchParams = new URLSearchParams();
|
|
2266
|
+
if (page !== void 0) {
|
|
2267
|
+
searchParams.set("page", String(page));
|
|
2268
|
+
}
|
|
2269
|
+
if (perPage !== void 0) {
|
|
2270
|
+
searchParams.set("perPage", String(perPage));
|
|
2271
|
+
}
|
|
2272
|
+
if (name) {
|
|
2273
|
+
searchParams.set("name", name);
|
|
2274
|
+
}
|
|
2275
|
+
if (spanType !== void 0) {
|
|
2276
|
+
searchParams.set("spanType", String(spanType));
|
|
2277
|
+
}
|
|
2278
|
+
if (dateRange) {
|
|
2279
|
+
const dateRangeStr = JSON.stringify({
|
|
2280
|
+
start: dateRange.start instanceof Date ? dateRange.start.toISOString() : dateRange.start,
|
|
2281
|
+
end: dateRange.end instanceof Date ? dateRange.end.toISOString() : dateRange.end
|
|
2282
|
+
});
|
|
2283
|
+
searchParams.set("dateRange", dateRangeStr);
|
|
2284
|
+
}
|
|
2285
|
+
const queryString = searchParams.toString();
|
|
2286
|
+
return this.request(`/api/observability/traces${queryString ? `?${queryString}` : ""}`);
|
|
2287
|
+
}
|
|
2288
|
+
};
|
|
2289
|
+
|
|
2234
2290
|
// src/resources/network-memory-thread.ts
|
|
2235
2291
|
var NetworkMemoryThread = class extends BaseResource {
|
|
2236
2292
|
constructor(options, threadId, networkId) {
|
|
@@ -2434,8 +2490,10 @@ var VNextNetwork = class extends BaseResource {
|
|
|
2434
2490
|
|
|
2435
2491
|
// src/client.ts
|
|
2436
2492
|
var MastraClient = class extends BaseResource {
|
|
2493
|
+
observability;
|
|
2437
2494
|
constructor(options) {
|
|
2438
2495
|
super(options);
|
|
2496
|
+
this.observability = new Observability(options);
|
|
2439
2497
|
}
|
|
2440
2498
|
/**
|
|
2441
2499
|
* Retrieves all available agents
|
|
@@ -2564,7 +2622,7 @@ var MastraClient = class extends BaseResource {
|
|
|
2564
2622
|
* @returns Tool instance
|
|
2565
2623
|
*/
|
|
2566
2624
|
getTool(toolId) {
|
|
2567
|
-
return new
|
|
2625
|
+
return new Tool(this.options, toolId);
|
|
2568
2626
|
}
|
|
2569
2627
|
/**
|
|
2570
2628
|
* Retrieves all available legacy workflows
|
|
@@ -2946,6 +3004,12 @@ var MastraClient = class extends BaseResource {
|
|
|
2946
3004
|
getModelProviders() {
|
|
2947
3005
|
return this.request(`/api/model-providers`);
|
|
2948
3006
|
}
|
|
3007
|
+
getAITrace(traceId) {
|
|
3008
|
+
return this.observability.getTrace(traceId);
|
|
3009
|
+
}
|
|
3010
|
+
getAITraces(params) {
|
|
3011
|
+
return this.observability.getTraces(params);
|
|
3012
|
+
}
|
|
2949
3013
|
};
|
|
2950
3014
|
|
|
2951
3015
|
exports.MastraClient = MastraClient;
|