@mastra/core 0.9.4 → 0.10.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/README.md +3 -2
- package/dist/agent/index.cjs +2 -2
- package/dist/agent/index.d.cts +13 -14
- package/dist/agent/index.d.ts +13 -14
- package/dist/agent/index.js +1 -1
- package/dist/{base-BCfssGt6.d.ts → base-DttB7sJD.d.ts} +1187 -886
- package/dist/{base-CAEcd6q2.d.cts → base-aJ3etsh5.d.cts} +1187 -886
- package/dist/{base-H7siSAfu.d.cts → base-aPYtPBT2.d.cts} +3 -3
- package/dist/{base-4Z34GQL8.d.ts → base-tc5kgDTD.d.ts} +3 -3
- package/dist/base.cjs +2 -2
- package/dist/base.d.cts +2 -3
- package/dist/base.d.ts +2 -3
- package/dist/base.js +1 -1
- package/dist/bundler/index.cjs +2 -2
- package/dist/bundler/index.d.cts +2 -3
- package/dist/bundler/index.d.ts +2 -3
- package/dist/bundler/index.js +1 -1
- package/dist/{chunk-W4BSLENO.js → chunk-2NTUAUGH.js} +1 -1
- package/dist/{chunk-S34QVMKE.js → chunk-2PW6UJMW.js} +77 -10
- package/dist/{chunk-WE36CRQV.cjs → chunk-2U7ZZUFO.cjs} +2 -2
- package/dist/{workflows/vNext/index.js → chunk-3SQ3G2EJ.js} +19 -16
- package/dist/chunk-5HULBQ2W.cjs +38 -0
- package/dist/{chunk-XRGDVLM4.cjs → chunk-5JRD3NDP.cjs} +15 -15
- package/dist/{chunk-GXKODTLA.cjs → chunk-5W2G7S44.cjs} +83 -68
- package/dist/chunk-75Z4BZEE.js +36 -0
- package/dist/{chunk-66GQROSI.cjs → chunk-AOGUTJUO.cjs} +58 -51
- package/dist/{chunk-WIKOYZ63.js → chunk-BPTSLJHA.js} +9 -9
- package/dist/{chunk-JBJ7KXN5.js → chunk-C3ICEF6E.js} +1 -1
- package/dist/{chunk-E4FAXBUV.cjs → chunk-CWSFP2HS.cjs} +2 -2
- package/dist/{chunk-FW5RS6WV.js → chunk-E7CLY6SK.js} +42 -35
- package/dist/{chunk-235X76GC.js → chunk-FI7R232B.js} +2 -2
- package/dist/chunk-GQ2XQ4UN.js +321 -0
- package/dist/{chunk-H4CEZSRM.js → chunk-J7GDGV6F.js} +1 -1
- package/dist/{chunk-NLBJOFNG.js → chunk-JW5TMK2L.js} +1 -1
- package/dist/{chunk-NOPY74PV.js → chunk-KJQFFEEQ.js} +1 -1
- package/dist/{chunk-V2Q2FEVO.cjs → chunk-KSPHQSZX.cjs} +2 -2
- package/dist/{chunk-NZV4OA6P.js → chunk-LHRZV5VG.js} +2 -23
- package/dist/chunk-NMDM4IZN.cjs +78 -0
- package/dist/chunk-OBEALYTK.js +74 -0
- package/dist/{chunk-PEK4TY3P.js → chunk-OCT2762Q.js} +1 -1
- package/dist/{chunk-5DUFC7TV.cjs → chunk-P7BGXOQV.cjs} +2 -2
- package/dist/{chunk-WQKOM7XM.cjs → chunk-PIZM25KI.cjs} +3 -24
- package/dist/{chunk-S7J63JOG.cjs → chunk-RVS6OUJN.cjs} +2 -2
- package/dist/{chunk-5JUWUTPJ.cjs → chunk-SKG2NIZW.cjs} +2 -2
- package/dist/chunk-SWW4EBUZ.cjs +96 -0
- package/dist/{chunk-RGE4UF6A.cjs → chunk-TMPFLJLG.cjs} +2 -2
- package/dist/{workflows/vNext/index.cjs → chunk-TTKQ37ZZ.cjs} +24 -21
- package/dist/{chunk-EJITEVAB.cjs → chunk-U3L3NEOM.cjs} +81 -10
- package/dist/chunk-VHLL4AZK.js +90 -0
- package/dist/{chunk-EG74VBSP.cjs → chunk-YEULQPUY.cjs} +6 -6
- package/dist/{chunk-SOLXHDNQ.js → chunk-ZB3LEHL2.js} +81 -66
- package/dist/{chunk-TAFOICHR.js → chunk-ZKN6HYYQ.js} +1 -1
- package/dist/chunk-ZZDAC5KD.cjs +325 -0
- package/dist/deployer/index.cjs +2 -2
- package/dist/deployer/index.d.cts +2 -3
- package/dist/deployer/index.d.ts +2 -3
- package/dist/deployer/index.js +1 -1
- package/dist/eval/index.d.cts +13 -14
- package/dist/eval/index.d.ts +13 -14
- package/dist/hooks/index.d.cts +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/index.cjs +88 -159
- package/dist/index.d.cts +17 -25
- package/dist/index.d.ts +17 -25
- package/dist/index.js +18 -25
- package/dist/integration/index.cjs +3 -3
- package/dist/integration/index.d.cts +12 -13
- package/dist/integration/index.d.ts +12 -13
- package/dist/integration/index.js +1 -1
- package/dist/llm/index.d.cts +13 -14
- package/dist/llm/index.d.ts +13 -14
- package/dist/logger/index.cjs +18 -17
- package/dist/logger/index.d.cts +42 -2
- package/dist/logger/index.d.ts +42 -2
- package/dist/logger/index.js +2 -1
- package/dist/{index-QV27jkxQ.d.ts → logger-EhZkzZOr.d.cts} +38 -52
- package/dist/{index-QV27jkxQ.d.cts → logger-EhZkzZOr.d.ts} +38 -52
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.cts +11 -12
- package/dist/mastra/index.d.ts +11 -12
- package/dist/mastra/index.js +1 -1
- package/dist/mcp/index.cjs +75 -17
- package/dist/mcp/index.d.cts +14 -15
- package/dist/mcp/index.d.ts +14 -15
- package/dist/mcp/index.js +69 -15
- package/dist/memory/index.cjs +4 -4
- package/dist/memory/index.d.cts +12 -13
- package/dist/memory/index.d.ts +12 -13
- package/dist/memory/index.js +1 -1
- package/dist/network/index.cjs +8 -8
- package/dist/network/index.d.cts +12 -13
- package/dist/network/index.d.ts +12 -13
- package/dist/network/index.js +5 -5
- package/dist/relevance/index.cjs +4 -4
- package/dist/relevance/index.d.cts +15 -16
- package/dist/relevance/index.d.ts +15 -16
- package/dist/relevance/index.js +1 -1
- package/dist/server/index.cjs +4 -0
- package/dist/server/index.d.cts +13 -12
- package/dist/server/index.d.ts +13 -12
- package/dist/server/index.js +4 -1
- package/dist/storage/index.cjs +184 -3
- package/dist/storage/index.d.cts +83 -13
- package/dist/storage/index.d.ts +83 -13
- package/dist/storage/index.js +186 -1
- package/dist/telemetry/index.d.cts +14 -15
- package/dist/telemetry/index.d.ts +14 -15
- package/dist/telemetry/otel-vendor.cjs +2 -2
- package/dist/telemetry/otel-vendor.d.cts +1 -1
- package/dist/telemetry/otel-vendor.d.ts +1 -1
- package/dist/telemetry/otel-vendor.js +1 -1
- package/dist/tools/index.cjs +4 -4
- package/dist/tools/index.d.cts +12 -13
- package/dist/tools/index.d.ts +12 -13
- package/dist/tools/index.js +1 -1
- package/dist/tts/index.cjs +2 -2
- package/dist/tts/index.d.cts +2 -3
- package/dist/tts/index.d.ts +2 -3
- package/dist/tts/index.js +1 -1
- package/dist/{types-BtMyV38I.d.ts → types-Bo1uigWx.d.cts} +1 -1
- package/dist/{types-BtMyV38I.d.cts → types-Bo1uigWx.d.ts} +1 -1
- package/dist/utils.cjs +28 -12
- package/dist/utils.d.cts +59 -16
- package/dist/utils.d.ts +59 -16
- package/dist/utils.js +1 -1
- package/dist/vector/filter/index.cjs +189 -7
- package/dist/vector/filter/index.js +190 -1
- package/dist/vector/index.cjs +2 -2
- package/dist/vector/index.d.cts +28 -20
- package/dist/vector/index.d.ts +28 -20
- package/dist/vector/index.js +1 -1
- package/dist/voice/index.cjs +4 -4
- package/dist/voice/index.d.cts +12 -13
- package/dist/voice/index.d.ts +12 -13
- package/dist/voice/index.js +1 -1
- package/dist/workflows/index.cjs +17 -69
- package/dist/workflows/index.d.cts +197 -77
- package/dist/workflows/index.d.ts +197 -77
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/legacy/index.cjs +90 -0
- package/dist/workflows/legacy/index.d.cts +87 -0
- package/dist/workflows/legacy/index.d.ts +87 -0
- package/dist/workflows/legacy/index.js +1 -0
- package/package.json +19 -40
- package/workflows/legacy.d.ts +1 -0
- package/dist/chunk-4WABQORE.js +0 -781
- package/dist/chunk-CIEPFV6B.js +0 -658
- package/dist/chunk-CMPPXW4U.js +0 -154
- package/dist/chunk-CTKNWYK2.js +0 -131
- package/dist/chunk-LGERQTJM.js +0 -190
- package/dist/chunk-O44MSFMZ.cjs +0 -168
- package/dist/chunk-QDAMIZY3.cjs +0 -783
- package/dist/chunk-QHDPLMHB.cjs +0 -667
- package/dist/chunk-RAQBTCIR.cjs +0 -134
- package/dist/chunk-YK3XJ52U.cjs +0 -192
- package/dist/storage/libsql/index.cjs +0 -581
- package/dist/storage/libsql/index.d.cts +0 -104
- package/dist/storage/libsql/index.d.ts +0 -104
- package/dist/storage/libsql/index.js +0 -578
- package/dist/vector/libsql/index.cjs +0 -14
- package/dist/vector/libsql/index.d.cts +0 -82
- package/dist/vector/libsql/index.d.ts +0 -82
- package/dist/vector/libsql/index.js +0 -1
- package/dist/workflows/vNext/index.d.cts +0 -209
- package/dist/workflows/vNext/index.d.ts +0 -209
- package/storage/libsql.d.ts +0 -1
- package/vector/libsql.d.ts +0 -1
- package/workflows/vNext.d.ts +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _opentelemetry_api from '@opentelemetry/api';
|
|
2
2
|
import { Tracer, Span, BaggageEntry, Context } from '@opentelemetry/api';
|
|
3
|
-
import { R as RegisteredLogger,
|
|
3
|
+
import { R as RegisteredLogger, I as IMastraLogger } from './logger-EhZkzZOr.cjs';
|
|
4
4
|
import { SpanExporter } from '@opentelemetry/sdk-trace-base';
|
|
5
5
|
|
|
6
6
|
/** Sampling strategy configuration for OpenTelemetry */
|
|
@@ -115,7 +115,7 @@ declare class Telemetry {
|
|
|
115
115
|
|
|
116
116
|
declare class MastraBase {
|
|
117
117
|
component: RegisteredLogger;
|
|
118
|
-
protected logger:
|
|
118
|
+
protected logger: IMastraLogger;
|
|
119
119
|
name?: string;
|
|
120
120
|
telemetry?: Telemetry;
|
|
121
121
|
constructor({ component, name }: {
|
|
@@ -126,7 +126,7 @@ declare class MastraBase {
|
|
|
126
126
|
* Set the logger for the agent
|
|
127
127
|
* @param logger
|
|
128
128
|
*/
|
|
129
|
-
__setLogger(logger:
|
|
129
|
+
__setLogger(logger: IMastraLogger): void;
|
|
130
130
|
/**
|
|
131
131
|
* Set the telemetry for the
|
|
132
132
|
* @param telemetry
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _opentelemetry_api from '@opentelemetry/api';
|
|
2
2
|
import { Tracer, Span, BaggageEntry, Context } from '@opentelemetry/api';
|
|
3
|
-
import { R as RegisteredLogger,
|
|
3
|
+
import { R as RegisteredLogger, I as IMastraLogger } from './logger-EhZkzZOr.js';
|
|
4
4
|
import { SpanExporter } from '@opentelemetry/sdk-trace-base';
|
|
5
5
|
|
|
6
6
|
/** Sampling strategy configuration for OpenTelemetry */
|
|
@@ -115,7 +115,7 @@ declare class Telemetry {
|
|
|
115
115
|
|
|
116
116
|
declare class MastraBase {
|
|
117
117
|
component: RegisteredLogger;
|
|
118
|
-
protected logger:
|
|
118
|
+
protected logger: IMastraLogger;
|
|
119
119
|
name?: string;
|
|
120
120
|
telemetry?: Telemetry;
|
|
121
121
|
constructor({ component, name }: {
|
|
@@ -126,7 +126,7 @@ declare class MastraBase {
|
|
|
126
126
|
* Set the logger for the agent
|
|
127
127
|
* @param logger
|
|
128
128
|
*/
|
|
129
|
-
__setLogger(logger:
|
|
129
|
+
__setLogger(logger: IMastraLogger): void;
|
|
130
130
|
/**
|
|
131
131
|
* Set the telemetry for the
|
|
132
132
|
* @param telemetry
|
package/dist/base.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkYEULQPUY_cjs = require('./chunk-YEULQPUY.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "MastraBase", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkYEULQPUY_cjs.MastraBase; }
|
|
10
10
|
});
|
package/dist/base.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import '@opentelemetry/api';
|
|
2
|
-
import './
|
|
3
|
-
export { M as MastraBase } from './base-
|
|
2
|
+
import './logger-EhZkzZOr.cjs';
|
|
3
|
+
export { M as MastraBase } from './base-aPYtPBT2.cjs';
|
|
4
4
|
import 'stream';
|
|
5
|
-
import 'pino';
|
|
6
5
|
import '@opentelemetry/sdk-trace-base';
|
package/dist/base.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import '@opentelemetry/api';
|
|
2
|
-
import './
|
|
3
|
-
export { M as MastraBase } from './base-
|
|
2
|
+
import './logger-EhZkzZOr.js';
|
|
3
|
+
export { M as MastraBase } from './base-tc5kgDTD.js';
|
|
4
4
|
import 'stream';
|
|
5
|
-
import 'pino';
|
|
6
5
|
import '@opentelemetry/sdk-trace-base';
|
package/dist/base.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { MastraBase } from './chunk-
|
|
1
|
+
export { MastraBase } from './chunk-FI7R232B.js';
|
package/dist/bundler/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkTMPFLJLG_cjs = require('../chunk-TMPFLJLG.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "MastraBundler", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkTMPFLJLG_cjs.MastraBundler; }
|
|
10
10
|
});
|
package/dist/bundler/index.d.cts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { M as MastraBase } from '../base-
|
|
1
|
+
import { M as MastraBase } from '../base-aPYtPBT2.cjs';
|
|
2
2
|
import '@opentelemetry/api';
|
|
3
|
-
import '../
|
|
3
|
+
import '../logger-EhZkzZOr.cjs';
|
|
4
4
|
import 'stream';
|
|
5
|
-
import 'pino';
|
|
6
5
|
import '@opentelemetry/sdk-trace-base';
|
|
7
6
|
|
|
8
7
|
interface IBundler {
|
package/dist/bundler/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { M as MastraBase } from '../base-
|
|
1
|
+
import { M as MastraBase } from '../base-tc5kgDTD.js';
|
|
2
2
|
import '@opentelemetry/api';
|
|
3
|
-
import '../
|
|
3
|
+
import '../logger-EhZkzZOr.js';
|
|
4
4
|
import 'stream';
|
|
5
|
-
import 'pino';
|
|
6
5
|
import '@opentelemetry/sdk-trace-base';
|
|
7
6
|
|
|
8
7
|
interface IBundler {
|
package/dist/bundler/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { MastraBundler } from '../chunk-
|
|
1
|
+
export { MastraBundler } from '../chunk-JW5TMK2L.js';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { MastraBase } from './chunk-FI7R232B.js';
|
|
1
2
|
import { RuntimeContext } from './chunk-SGGPJWRQ.js';
|
|
2
|
-
import { MastraBase } from './chunk-235X76GC.js';
|
|
3
3
|
import { createHash } from 'crypto';
|
|
4
4
|
import { convertToCoreMessages, jsonSchema, zodSchema } from 'ai';
|
|
5
5
|
import jsonSchemaToZod from 'json-schema-to-zod';
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
-
import {
|
|
7
|
+
import { convertJsonSchemaToZod } from 'zod-from-json-schema';
|
|
8
8
|
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
9
9
|
|
|
10
10
|
// src/tools/tool.ts
|
|
@@ -37,6 +37,16 @@ var ALL_NUMBER_CHECKS = [
|
|
|
37
37
|
];
|
|
38
38
|
var ALL_ARRAY_CHECKS = ["min", "max", "length"];
|
|
39
39
|
var UNSUPPORTED_ZOD_TYPES = ["ZodIntersection", "ZodNever", "ZodNull", "ZodTuple", "ZodUndefined"];
|
|
40
|
+
var SUPPORTED_ZOD_TYPES = [
|
|
41
|
+
"ZodObject",
|
|
42
|
+
"ZodArray",
|
|
43
|
+
"ZodUnion",
|
|
44
|
+
"ZodString",
|
|
45
|
+
"ZodNumber",
|
|
46
|
+
"ZodDate",
|
|
47
|
+
"ZodAny",
|
|
48
|
+
"ZodDefault"
|
|
49
|
+
];
|
|
40
50
|
var ToolCompatibility = class extends MastraBase {
|
|
41
51
|
model;
|
|
42
52
|
constructor(model) {
|
|
@@ -270,6 +280,13 @@ var ToolCompatibility = class extends MastraBase {
|
|
|
270
280
|
}
|
|
271
281
|
return result;
|
|
272
282
|
}
|
|
283
|
+
defaultZodOptionalHandler(value, handleTypes = SUPPORTED_ZOD_TYPES) {
|
|
284
|
+
if (handleTypes.includes(value._def.innerType._def.typeName)) {
|
|
285
|
+
return this.processZodType(value._def.innerType).optional();
|
|
286
|
+
} else {
|
|
287
|
+
return value;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
273
290
|
process(tool) {
|
|
274
291
|
if (isVercelTool(tool)) {
|
|
275
292
|
return {
|
|
@@ -299,6 +316,11 @@ var AnthropicToolCompat = class extends ToolCompatibility {
|
|
|
299
316
|
}
|
|
300
317
|
processZodType(value) {
|
|
301
318
|
switch (value._def.typeName) {
|
|
319
|
+
case "ZodOptional":
|
|
320
|
+
const handleTypes = ["ZodObject", "ZodArray", "ZodUnion", "ZodNever", "ZodUndefined"];
|
|
321
|
+
if (this.getModel().modelId.includes("claude-3.5-haiku")) handleTypes.push("ZodString");
|
|
322
|
+
if (this.getModel().modelId.includes("claude-3.7")) handleTypes.push("ZodTuple");
|
|
323
|
+
return this.defaultZodOptionalHandler(value, handleTypes);
|
|
302
324
|
case "ZodObject": {
|
|
303
325
|
return this.defaultZodObjectHandler(value);
|
|
304
326
|
}
|
|
@@ -340,6 +362,8 @@ var DeepSeekToolCompat = class extends ToolCompatibility {
|
|
|
340
362
|
}
|
|
341
363
|
processZodType(value) {
|
|
342
364
|
switch (value._def.typeName) {
|
|
365
|
+
case "ZodOptional":
|
|
366
|
+
return this.defaultZodOptionalHandler(value, ["ZodObject", "ZodArray", "ZodUnion", "ZodString", "ZodNumber"]);
|
|
343
367
|
case "ZodObject": {
|
|
344
368
|
return this.defaultZodObjectHandler(value);
|
|
345
369
|
}
|
|
@@ -371,6 +395,15 @@ var GoogleToolCompat = class extends ToolCompatibility {
|
|
|
371
395
|
}
|
|
372
396
|
processZodType(value) {
|
|
373
397
|
switch (value._def.typeName) {
|
|
398
|
+
case "ZodOptional":
|
|
399
|
+
return this.defaultZodOptionalHandler(value, [
|
|
400
|
+
"ZodObject",
|
|
401
|
+
"ZodArray",
|
|
402
|
+
"ZodUnion",
|
|
403
|
+
"ZodString",
|
|
404
|
+
"ZodNumber",
|
|
405
|
+
...UNSUPPORTED_ZOD_TYPES
|
|
406
|
+
]);
|
|
374
407
|
case "ZodObject": {
|
|
375
408
|
return this.defaultZodObjectHandler(value);
|
|
376
409
|
}
|
|
@@ -407,6 +440,8 @@ var MetaToolCompat = class extends ToolCompatibility {
|
|
|
407
440
|
}
|
|
408
441
|
processZodType(value) {
|
|
409
442
|
switch (value._def.typeName) {
|
|
443
|
+
case "ZodOptional":
|
|
444
|
+
return this.defaultZodOptionalHandler(value, ["ZodObject", "ZodArray", "ZodUnion", "ZodString", "ZodNumber"]);
|
|
410
445
|
case "ZodObject": {
|
|
411
446
|
return this.defaultZodObjectHandler(value);
|
|
412
447
|
}
|
|
@@ -444,6 +479,16 @@ var OpenAIToolCompat = class extends ToolCompatibility {
|
|
|
444
479
|
}
|
|
445
480
|
processZodType(value) {
|
|
446
481
|
switch (value._def.typeName) {
|
|
482
|
+
case "ZodOptional":
|
|
483
|
+
return this.defaultZodOptionalHandler(value, [
|
|
484
|
+
"ZodObject",
|
|
485
|
+
"ZodArray",
|
|
486
|
+
"ZodUnion",
|
|
487
|
+
"ZodString",
|
|
488
|
+
"ZodNever",
|
|
489
|
+
"ZodUndefined",
|
|
490
|
+
"ZodTuple"
|
|
491
|
+
]);
|
|
447
492
|
case "ZodObject": {
|
|
448
493
|
return this.defaultZodObjectHandler(value);
|
|
449
494
|
}
|
|
@@ -466,8 +511,6 @@ var OpenAIToolCompat = class extends ToolCompatibility {
|
|
|
466
511
|
}
|
|
467
512
|
}
|
|
468
513
|
};
|
|
469
|
-
|
|
470
|
-
// src/tools/tool-compatibility/provider-compats/openai-reasoning.ts
|
|
471
514
|
var OpenAIReasoningToolCompat = class extends ToolCompatibility {
|
|
472
515
|
constructor(model) {
|
|
473
516
|
super(model);
|
|
@@ -487,7 +530,8 @@ var OpenAIReasoningToolCompat = class extends ToolCompatibility {
|
|
|
487
530
|
processZodType(value) {
|
|
488
531
|
switch (value._def.typeName) {
|
|
489
532
|
case "ZodOptional":
|
|
490
|
-
|
|
533
|
+
const innerZodType = this.processZodType(value._def.innerType);
|
|
534
|
+
return innerZodType.nullable();
|
|
491
535
|
case "ZodObject": {
|
|
492
536
|
return this.defaultZodObjectHandler(value);
|
|
493
537
|
}
|
|
@@ -521,6 +565,12 @@ var OpenAIReasoningToolCompat = class extends ToolCompatibility {
|
|
|
521
565
|
case "ZodDate": {
|
|
522
566
|
return this.defaultZodDateHandler(value);
|
|
523
567
|
}
|
|
568
|
+
case "ZodAny": {
|
|
569
|
+
return z.string().describe(
|
|
570
|
+
(value.description ?? "") + `
|
|
571
|
+
Argument was an "any" type, but you (the LLM) do not support "any", so it was cast to a "string" type`
|
|
572
|
+
);
|
|
573
|
+
}
|
|
524
574
|
default:
|
|
525
575
|
return this.defaultUnsupportedZodTypeHandler(value);
|
|
526
576
|
}
|
|
@@ -549,8 +599,7 @@ function convertVercelToolParameters(tool) {
|
|
|
549
599
|
} else {
|
|
550
600
|
const jsonSchemaToConvert = "jsonSchema" in schema ? schema.jsonSchema : schema;
|
|
551
601
|
try {
|
|
552
|
-
|
|
553
|
-
return z.object(rawShape);
|
|
602
|
+
return convertJsonSchemaToZod(jsonSchemaToConvert);
|
|
554
603
|
} catch (e) {
|
|
555
604
|
const errorMessage = `[CoreToolBuilder] Failed to convert Vercel tool JSON schema parameters to Zod. Original schema: ${JSON.stringify(jsonSchemaToConvert)}`;
|
|
556
605
|
console.error(errorMessage, e);
|
|
@@ -565,8 +614,7 @@ function convertInputSchema(tool) {
|
|
|
565
614
|
return schema;
|
|
566
615
|
} else {
|
|
567
616
|
try {
|
|
568
|
-
|
|
569
|
-
return z.object(rawShape);
|
|
617
|
+
return convertJsonSchemaToZod(schema);
|
|
570
618
|
} catch (e) {
|
|
571
619
|
const errorMessage = `[CoreToolBuilder] Failed to convert tool input JSON schema to Zod. Original schema: ${JSON.stringify(schema)}`;
|
|
572
620
|
console.error(errorMessage, e);
|
|
@@ -945,5 +993,24 @@ ${JSON.stringify(message, null, 2)}
|
|
|
945
993
|
);
|
|
946
994
|
}).flat();
|
|
947
995
|
}
|
|
996
|
+
var SQL_IDENTIFIER_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
997
|
+
function parseSqlIdentifier(name, kind = "identifier") {
|
|
998
|
+
if (!SQL_IDENTIFIER_PATTERN.test(name) || name.length > 63) {
|
|
999
|
+
throw new Error(
|
|
1000
|
+
`Invalid ${kind}: ${name}. Must start with a letter or underscore, contain only letters, numbers, or underscores, and be at most 63 characters long.`
|
|
1001
|
+
);
|
|
1002
|
+
}
|
|
1003
|
+
return name;
|
|
1004
|
+
}
|
|
1005
|
+
function parseFieldKey(key) {
|
|
1006
|
+
if (!key) throw new Error("Field key cannot be empty");
|
|
1007
|
+
const segments = key.split(".");
|
|
1008
|
+
for (const segment of segments) {
|
|
1009
|
+
if (!SQL_IDENTIFIER_PATTERN.test(segment) || segment.length > 63) {
|
|
1010
|
+
throw new Error(`Invalid field key segment: ${segment} in ${key}`);
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
return key;
|
|
1014
|
+
}
|
|
948
1015
|
|
|
949
|
-
export { Tool, checkEvalStorageFields, createMastraProxy, createTool, deepMerge, delay, ensureAllMessagesAreCoreMessages, ensureToolProperties, isVercelTool, isZodType, makeCoreTool, maskStreamTags, resolveSerializedZodOutput };
|
|
1016
|
+
export { Tool, checkEvalStorageFields, createMastraProxy, createTool, deepMerge, delay, ensureAllMessagesAreCoreMessages, ensureToolProperties, isCoreMessage, isUiMessage, isVercelTool, isZodType, makeCoreTool, maskStreamTags, parseFieldKey, parseSqlIdentifier, resolveSerializedZodOutput };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkAOGUTJUO_cjs = require('./chunk-AOGUTJUO.cjs');
|
|
4
4
|
var cohereAi = require('cohere-ai');
|
|
5
5
|
|
|
6
6
|
var CohereRelevanceScorer = class {
|
|
@@ -38,7 +38,7 @@ Relevance score (0-1):`;
|
|
|
38
38
|
var MastraAgentRelevanceScorer = class {
|
|
39
39
|
agent;
|
|
40
40
|
constructor(name, model) {
|
|
41
|
-
this.agent = new
|
|
41
|
+
this.agent = new chunkAOGUTJUO_cjs.Agent({
|
|
42
42
|
name: `Relevance Scorer ${name}`,
|
|
43
43
|
instructions: `You are a specialized agent for evaluating the relevance of text to queries.
|
|
44
44
|
Your task is to rate how well a text passage answers a given query.
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Agent } from '
|
|
2
|
-
import { Tool } from '
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { Agent } from './chunk-E7CLY6SK.js';
|
|
2
|
+
import { Tool } from './chunk-2PW6UJMW.js';
|
|
3
|
+
import { MastraBase } from './chunk-FI7R232B.js';
|
|
4
|
+
import { RegisteredLogger } from './chunk-VHLL4AZK.js';
|
|
5
|
+
import { RuntimeContext } from './chunk-SGGPJWRQ.js';
|
|
6
6
|
import { randomUUID } from 'crypto';
|
|
7
7
|
import EventEmitter from 'events';
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
import { context, trace } from '@opentelemetry/api';
|
|
10
10
|
|
|
11
|
-
// src/workflows/
|
|
11
|
+
// src/workflows/execution-engine.ts
|
|
12
12
|
var ExecutionEngine = class extends MastraBase {
|
|
13
13
|
mastra;
|
|
14
14
|
constructor({ mastra }) {
|
|
@@ -20,7 +20,7 @@ var ExecutionEngine = class extends MastraBase {
|
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
// src/workflows/
|
|
23
|
+
// src/workflows/default.ts
|
|
24
24
|
var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
25
25
|
async fmtReturnValue(executionSpan, emitter, stepResults, lastOutput, error) {
|
|
26
26
|
const base = {
|
|
@@ -641,7 +641,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
641
641
|
}
|
|
642
642
|
};
|
|
643
643
|
|
|
644
|
-
// src/workflows/
|
|
644
|
+
// src/workflows/workflow.ts
|
|
645
645
|
function createStep(params) {
|
|
646
646
|
if (params instanceof Agent) {
|
|
647
647
|
return {
|
|
@@ -705,10 +705,10 @@ function cloneStep(step, opts) {
|
|
|
705
705
|
};
|
|
706
706
|
}
|
|
707
707
|
function createWorkflow(params) {
|
|
708
|
-
return new
|
|
708
|
+
return new Workflow(params);
|
|
709
709
|
}
|
|
710
710
|
function cloneWorkflow(workflow, opts) {
|
|
711
|
-
const wf = new
|
|
711
|
+
const wf = new Workflow({
|
|
712
712
|
id: opts.id,
|
|
713
713
|
inputSchema: workflow.inputSchema,
|
|
714
714
|
outputSchema: workflow.outputSchema,
|
|
@@ -719,7 +719,7 @@ function cloneWorkflow(workflow, opts) {
|
|
|
719
719
|
wf.commit();
|
|
720
720
|
return wf;
|
|
721
721
|
}
|
|
722
|
-
var
|
|
722
|
+
var Workflow = class extends MastraBase {
|
|
723
723
|
id;
|
|
724
724
|
description;
|
|
725
725
|
inputSchema;
|
|
@@ -1011,7 +1011,9 @@ var NewWorkflow = class extends MastraBase {
|
|
|
1011
1011
|
*/
|
|
1012
1012
|
createRun(options) {
|
|
1013
1013
|
if (this.stepFlow.length === 0) {
|
|
1014
|
-
throw new Error(
|
|
1014
|
+
throw new Error(
|
|
1015
|
+
"Execution flow of workflow is not defined. Add steps to the workflow via .then(), .branch(), etc."
|
|
1016
|
+
);
|
|
1015
1017
|
}
|
|
1016
1018
|
if (!this.executionGraph.steps) {
|
|
1017
1019
|
throw new Error("Uncommitted step flow changes detected. Call .commit() to register the steps.");
|
|
@@ -1035,14 +1037,15 @@ var NewWorkflow = class extends MastraBase {
|
|
|
1035
1037
|
suspend,
|
|
1036
1038
|
resume,
|
|
1037
1039
|
emitter,
|
|
1038
|
-
mastra
|
|
1040
|
+
mastra,
|
|
1041
|
+
runtimeContext
|
|
1039
1042
|
}) {
|
|
1040
1043
|
this.__registerMastra(mastra);
|
|
1041
1044
|
const run = resume?.steps?.length ? this.createRun({ runId: resume.runId }) : this.createRun();
|
|
1042
1045
|
const unwatch = run.watch((event) => {
|
|
1043
1046
|
emitter.emit("nested-watch", { event, workflowId: this.id, runId: run.runId, isResume: !!resume?.steps?.length });
|
|
1044
1047
|
});
|
|
1045
|
-
const res = resume?.steps?.length ? await run.resume({ resumeData, step: resume.steps }) : await run.start({ inputData });
|
|
1048
|
+
const res = resume?.steps?.length ? await run.resume({ resumeData, step: resume.steps, runtimeContext }) : await run.start({ inputData, runtimeContext });
|
|
1046
1049
|
unwatch();
|
|
1047
1050
|
const suspendedSteps = Object.entries(res.steps).filter(([_stepName, stepResult]) => {
|
|
1048
1051
|
const stepRes = stepResult;
|
|
@@ -1155,7 +1158,7 @@ var Run = class {
|
|
|
1155
1158
|
const { type, payload, eventTimestamp } = event;
|
|
1156
1159
|
const prefixedSteps = Object.fromEntries(
|
|
1157
1160
|
Object.entries(payload?.workflowState?.steps ?? {}).map(([stepId, step]) => [
|
|
1158
|
-
`${
|
|
1161
|
+
`${workflowId}.${stepId}`,
|
|
1159
1162
|
step
|
|
1160
1163
|
])
|
|
1161
1164
|
);
|
|
@@ -1250,4 +1253,4 @@ function deepMerge(a, b) {
|
|
|
1250
1253
|
return result;
|
|
1251
1254
|
}
|
|
1252
1255
|
|
|
1253
|
-
export { DefaultExecutionEngine, ExecutionEngine,
|
|
1256
|
+
export { DefaultExecutionEngine, ExecutionEngine, Run, Workflow, cloneStep, cloneWorkflow, createStep, createWorkflow };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/storage/storageWithInit.ts
|
|
4
|
+
var isAugmentedSymbol = Symbol("isAugmented");
|
|
5
|
+
function augmentWithInit(storage) {
|
|
6
|
+
let hasInitialized = null;
|
|
7
|
+
const ensureInit = async () => {
|
|
8
|
+
if (!hasInitialized) {
|
|
9
|
+
hasInitialized = storage.init();
|
|
10
|
+
}
|
|
11
|
+
await hasInitialized;
|
|
12
|
+
};
|
|
13
|
+
if (storage[isAugmentedSymbol]) {
|
|
14
|
+
return storage;
|
|
15
|
+
}
|
|
16
|
+
const proxy = new Proxy(storage, {
|
|
17
|
+
get(target, prop) {
|
|
18
|
+
const value = target[prop];
|
|
19
|
+
if (typeof value === "function" && prop !== "init") {
|
|
20
|
+
return async (...args) => {
|
|
21
|
+
await ensureInit();
|
|
22
|
+
return Reflect.apply(value, target, args);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return Reflect.get(target, prop);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(proxy, isAugmentedSymbol, {
|
|
29
|
+
value: true,
|
|
30
|
+
enumerable: false,
|
|
31
|
+
// Won't show up in Object.keys() or for...in loops
|
|
32
|
+
configurable: true
|
|
33
|
+
// Allows the property to be deleted or modified later if needed
|
|
34
|
+
});
|
|
35
|
+
return proxy;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
exports.augmentWithInit = augmentWithInit;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkU3L3NEOM_cjs = require('./chunk-U3L3NEOM.cjs');
|
|
4
|
+
var chunkYEULQPUY_cjs = require('./chunk-YEULQPUY.cjs');
|
|
5
|
+
var chunkSWW4EBUZ_cjs = require('./chunk-SWW4EBUZ.cjs');
|
|
6
6
|
var ai = require('ai');
|
|
7
7
|
var zod = require('zod');
|
|
8
8
|
|
|
9
9
|
// src/llm/model/base.ts
|
|
10
|
-
var MastraLLMBase = class extends
|
|
10
|
+
var MastraLLMBase = class extends chunkYEULQPUY_cjs.MastraBase {
|
|
11
11
|
// @ts-ignore
|
|
12
12
|
#mastra;
|
|
13
13
|
#model;
|
|
14
14
|
constructor({ name, model }) {
|
|
15
15
|
super({
|
|
16
|
-
component:
|
|
16
|
+
component: chunkSWW4EBUZ_cjs.RegisteredLogger.LLM,
|
|
17
17
|
name
|
|
18
18
|
});
|
|
19
19
|
this.#model = model;
|
|
@@ -151,7 +151,7 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
151
151
|
toolChoice,
|
|
152
152
|
maxSteps,
|
|
153
153
|
onStepFinish: async (props) => {
|
|
154
|
-
|
|
154
|
+
await onStepFinish?.(props);
|
|
155
155
|
this.logger.debug("[LLM] - Step Change:", {
|
|
156
156
|
text: props?.text,
|
|
157
157
|
toolCalls: props?.toolCalls,
|
|
@@ -162,7 +162,7 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
162
162
|
});
|
|
163
163
|
if (props?.response?.headers?.["x-ratelimit-remaining-tokens"] && parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"], 10) < 2e3) {
|
|
164
164
|
this.logger.warn("Rate limit approaching, waiting 10 seconds", { runId });
|
|
165
|
-
await
|
|
165
|
+
await chunkU3L3NEOM_cjs.delay(10 * 1e3);
|
|
166
166
|
}
|
|
167
167
|
},
|
|
168
168
|
...rest
|
|
@@ -220,7 +220,7 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
220
220
|
maxSteps,
|
|
221
221
|
toolChoice,
|
|
222
222
|
onStepFinish: async (props) => {
|
|
223
|
-
|
|
223
|
+
await onStepFinish?.(props);
|
|
224
224
|
this.logger.debug("[LLM] - Step Change:", {
|
|
225
225
|
text: props?.text,
|
|
226
226
|
toolCalls: props?.toolCalls,
|
|
@@ -231,7 +231,7 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
231
231
|
});
|
|
232
232
|
if (props?.response?.headers?.["x-ratelimit-remaining-tokens"] && parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"], 10) < 2e3) {
|
|
233
233
|
this.logger.warn("Rate limit approaching, waiting 10 seconds", { runId });
|
|
234
|
-
await
|
|
234
|
+
await chunkU3L3NEOM_cjs.delay(10 * 1e3);
|
|
235
235
|
}
|
|
236
236
|
},
|
|
237
237
|
...rest
|
|
@@ -293,7 +293,7 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
293
293
|
maxSteps,
|
|
294
294
|
toolChoice,
|
|
295
295
|
onStepFinish: async (props) => {
|
|
296
|
-
|
|
296
|
+
await onStepFinish?.(props);
|
|
297
297
|
this.logger.debug("[LLM] - Stream Step Change:", {
|
|
298
298
|
text: props?.text,
|
|
299
299
|
toolCalls: props?.toolCalls,
|
|
@@ -304,11 +304,11 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
304
304
|
});
|
|
305
305
|
if (props?.response?.headers?.["x-ratelimit-remaining-tokens"] && parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"], 10) < 2e3) {
|
|
306
306
|
this.logger.warn("Rate limit approaching, waiting 10 seconds", { runId });
|
|
307
|
-
await
|
|
307
|
+
await chunkU3L3NEOM_cjs.delay(10 * 1e3);
|
|
308
308
|
}
|
|
309
309
|
},
|
|
310
310
|
onFinish: async (props) => {
|
|
311
|
-
|
|
311
|
+
await onFinish?.(props);
|
|
312
312
|
this.logger.debug("[LLM] - Stream Finished:", {
|
|
313
313
|
text: props?.text,
|
|
314
314
|
toolCalls: props?.toolCalls,
|
|
@@ -382,7 +382,7 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
382
382
|
maxSteps,
|
|
383
383
|
toolChoice,
|
|
384
384
|
onStepFinish: async (props) => {
|
|
385
|
-
|
|
385
|
+
await onStepFinish?.(props);
|
|
386
386
|
this.logger.debug("[LLM] - Stream Step Change:", {
|
|
387
387
|
text: props?.text,
|
|
388
388
|
toolCalls: props?.toolCalls,
|
|
@@ -395,11 +395,11 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
395
395
|
});
|
|
396
396
|
if (props?.response?.headers?.["x-ratelimit-remaining-tokens"] && parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"], 10) < 2e3) {
|
|
397
397
|
this.logger.warn("Rate limit approaching, waiting 10 seconds", { runId });
|
|
398
|
-
await
|
|
398
|
+
await chunkU3L3NEOM_cjs.delay(10 * 1e3);
|
|
399
399
|
}
|
|
400
400
|
},
|
|
401
401
|
onFinish: async (props) => {
|
|
402
|
-
|
|
402
|
+
await onFinish?.(props);
|
|
403
403
|
this.logger.debug("[LLM] - Stream Finished:", {
|
|
404
404
|
text: props?.text,
|
|
405
405
|
toolCalls: props?.toolCalls,
|