@mastra/core 0.5.0-alpha.3 → 0.5.0-alpha.5
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/dist/agent/index.cjs +215 -108
- package/dist/agent/index.d.cts +8 -6
- package/dist/agent/index.d.ts +8 -6
- package/dist/agent/index.js +1 -1
- package/dist/{base-D90KQ4XI.d.ts → base-BZViaFTt.d.ts} +2 -0
- package/dist/{base-C_bOLlEO.d.cts → base-CTdONy0_.d.cts} +223 -52
- package/dist/{base-42kpYoR1.d.ts → base-DIn_km7X.d.ts} +223 -52
- package/dist/{base-hs9NDAZ2.d.cts → base-DboIg_Cd.d.cts} +2 -0
- package/dist/base.cjs +8 -1
- package/dist/base.d.cts +1 -1
- package/dist/base.d.ts +1 -1
- package/dist/base.js +1 -1
- package/dist/bundler/index.cjs +8 -1
- package/dist/bundler/index.d.cts +1 -1
- package/dist/bundler/index.d.ts +1 -1
- package/dist/bundler/index.js +1 -1
- package/dist/{chunk-MGBSRQQW.js → chunk-2AFZQAG5.js} +13 -2
- package/dist/{chunk-PHMSPCTC.js → chunk-3JSTLSIP.js} +8 -1
- package/dist/{chunk-5OJ3NYVN.js → chunk-4QEXJ5LA.js} +11 -7
- package/dist/{chunk-OZ4XVJ6F.js → chunk-4VHCCQ7P.js} +1 -1
- package/dist/{chunk-4YRYBCOZ.js → chunk-6PNJOPFO.js} +1 -1
- package/dist/{chunk-KQN7VU7J.js → chunk-7TZAPEAT.js} +1 -1
- package/dist/{chunk-QAAJAHDB.js → chunk-CLJYFFOS.js} +1 -1
- package/dist/{chunk-SVEAENO7.js → chunk-ECNK7OU3.js} +1 -1
- package/dist/{chunk-3GC7P4J6.js → chunk-HBHPTMAC.js} +109 -2
- package/dist/{chunk-C2YWDMSM.js → chunk-KBSR2LLT.js} +265 -34
- package/dist/{chunk-EACJF4XH.js → chunk-QABMKXI3.js} +1 -1
- package/dist/{chunk-VVMCBVUQ.js → chunk-QLYZGX5Z.js} +3 -3
- package/dist/{chunk-OKGRWTPL.js → chunk-QUAQPPRL.js} +13 -2
- package/dist/{chunk-FOBXIHHE.js → chunk-SWDQYPJS.js} +61 -110
- package/dist/{chunk-UFMLHP4G.js → chunk-WEUEIDDP.js} +8 -15
- package/dist/deployer/index.cjs +8 -1
- package/dist/deployer/index.d.cts +1 -1
- package/dist/deployer/index.d.ts +1 -1
- package/dist/deployer/index.js +1 -1
- package/dist/eval/index.d.cts +6 -4
- package/dist/eval/index.d.ts +6 -4
- package/dist/hooks/index.d.cts +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/index.cjs +588 -185
- package/dist/index.d.cts +13 -16
- package/dist/index.d.ts +13 -16
- package/dist/index.js +15 -15
- package/dist/integration/index.d.cts +10 -9
- package/dist/integration/index.d.ts +10 -9
- package/dist/llm/index.d.cts +8 -6
- package/dist/llm/index.d.ts +8 -6
- package/dist/logger/index.cjs +8 -1
- package/dist/logger/index.js +1 -1
- package/dist/mastra/index.cjs +26 -15
- package/dist/mastra/index.d.cts +11 -61
- package/dist/mastra/index.d.ts +11 -61
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +41 -8
- package/dist/memory/index.d.cts +6 -4
- package/dist/memory/index.d.ts +6 -4
- package/dist/memory/index.js +1 -1
- package/dist/relevance/index.cjs +215 -108
- package/dist/relevance/index.js +1 -1
- package/dist/storage/index.cjs +8 -1
- package/dist/storage/index.d.cts +6 -4
- package/dist/storage/index.d.ts +6 -4
- package/dist/storage/index.js +1 -1
- package/dist/storage/libsql/index.cjs +20 -2
- package/dist/storage/libsql/index.d.cts +6 -4
- package/dist/storage/libsql/index.d.ts +6 -4
- package/dist/storage/libsql/index.js +1 -1
- package/dist/telemetry/index.d.cts +6 -4
- package/dist/telemetry/index.d.ts +6 -4
- package/dist/telemetry/otel-vendor.cjs +5 -0
- package/dist/telemetry/otel-vendor.d.cts +1 -0
- package/dist/telemetry/otel-vendor.d.ts +1 -0
- package/dist/telemetry/otel-vendor.js +1 -0
- package/dist/tools/index.d.cts +14 -12
- package/dist/tools/index.d.ts +14 -12
- package/dist/tts/index.cjs +8 -1
- package/dist/tts/index.d.cts +1 -1
- package/dist/tts/index.d.ts +1 -1
- package/dist/tts/index.js +1 -1
- package/dist/{types-m9RryK9a.d.cts → types-CwTG2XyQ.d.cts} +1 -1
- package/dist/{types-m9RryK9a.d.ts → types-CwTG2XyQ.d.ts} +1 -1
- package/dist/utils.cjs +135 -0
- package/dist/utils.d.cts +62 -1
- package/dist/utils.d.ts +62 -1
- package/dist/utils.js +1 -1
- package/dist/vector/index.cjs +10 -3
- package/dist/vector/index.d.cts +3 -3
- package/dist/vector/index.d.ts +3 -3
- package/dist/vector/index.js +1 -1
- package/dist/vector/libsql/index.cjs +22 -4
- package/dist/vector/libsql/index.d.cts +1 -1
- package/dist/vector/libsql/index.d.ts +1 -1
- package/dist/vector/libsql/index.js +1 -1
- package/dist/voice/index.cjs +8 -1
- package/dist/voice/index.d.cts +1 -1
- package/dist/voice/index.d.ts +1 -1
- package/dist/voice/index.js +1 -1
- package/dist/workflows/index.cjs +311 -33
- package/dist/workflows/index.d.cts +9 -8
- package/dist/workflows/index.d.ts +9 -8
- package/dist/workflows/index.js +1 -1
- package/package.json +8 -2
- package/dist/workflow-CFuzV18A.d.ts +0 -96
- package/dist/workflow-CosscczK.d.cts +0 -96
package/dist/agent/index.cjs
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var crypto$1 = require('crypto');
|
|
4
|
-
var zod = require('zod');
|
|
5
4
|
var stream = require('stream');
|
|
6
5
|
var pino = require('pino');
|
|
7
6
|
var pretty = require('pino-pretty');
|
|
8
7
|
var ai = require('ai');
|
|
8
|
+
var zod = require('zod');
|
|
9
|
+
var jsonSchemaToZod = require('json-schema-to-zod');
|
|
9
10
|
var api = require('@opentelemetry/api');
|
|
10
11
|
|
|
11
12
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
13
|
|
|
13
14
|
var pino__default = /*#__PURE__*/_interopDefault(pino);
|
|
14
15
|
var pretty__default = /*#__PURE__*/_interopDefault(pretty);
|
|
16
|
+
var jsonSchemaToZod__default = /*#__PURE__*/_interopDefault(jsonSchemaToZod);
|
|
15
17
|
|
|
16
18
|
var __create = Object.create;
|
|
17
19
|
var __defProp = Object.defineProperty;
|
|
@@ -74,7 +76,14 @@ var Logger = class {
|
|
|
74
76
|
const transportsAry = Object.entries(this.transports);
|
|
75
77
|
this.logger = pino__default.default({
|
|
76
78
|
name: options.name || "app",
|
|
77
|
-
level: options.level || LogLevel.INFO
|
|
79
|
+
level: options.level || LogLevel.INFO,
|
|
80
|
+
formatters: {
|
|
81
|
+
level: label => {
|
|
82
|
+
return {
|
|
83
|
+
level: label
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
78
87
|
}, options.overrideDefaultTransports ? options?.transports?.default : transportsAry.length === 0 ? pretty__default.default({
|
|
79
88
|
colorize: true,
|
|
80
89
|
levelFirst: true,
|
|
@@ -354,7 +363,154 @@ var MastraLLMBase = class extends MastraBase {
|
|
|
354
363
|
throw new Error("Method not implemented.");
|
|
355
364
|
}
|
|
356
365
|
};
|
|
366
|
+
|
|
367
|
+
// src/tools/tool.ts
|
|
368
|
+
var Tool = class {
|
|
369
|
+
id;
|
|
370
|
+
description;
|
|
371
|
+
inputSchema;
|
|
372
|
+
outputSchema;
|
|
373
|
+
execute;
|
|
374
|
+
mastra;
|
|
375
|
+
constructor(opts) {
|
|
376
|
+
this.id = opts.id;
|
|
377
|
+
this.description = opts.description;
|
|
378
|
+
this.inputSchema = opts.inputSchema;
|
|
379
|
+
this.outputSchema = opts.outputSchema;
|
|
380
|
+
this.execute = opts.execute;
|
|
381
|
+
this.mastra = opts.mastra;
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
// src/utils.ts
|
|
357
386
|
var delay = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
387
|
+
function resolveSerializedZodOutput(schema) {
|
|
388
|
+
return Function("z", `"use strict";return (${schema});`)(zod.z);
|
|
389
|
+
}
|
|
390
|
+
function isVercelTool(tool) {
|
|
391
|
+
return !(tool instanceof Tool);
|
|
392
|
+
}
|
|
393
|
+
function createLogMessageOptions({
|
|
394
|
+
agentName,
|
|
395
|
+
toolName,
|
|
396
|
+
tool,
|
|
397
|
+
type
|
|
398
|
+
}) {
|
|
399
|
+
if (!agentName) {
|
|
400
|
+
return {
|
|
401
|
+
start: `Executing tool ${toolName}`,
|
|
402
|
+
error: `Failed tool execution`
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
const prefix = `[Agent:${agentName}]`;
|
|
406
|
+
const vercelPrefix = isVercelTool(tool) ? "Vercel " : "";
|
|
407
|
+
const toolType = type === "toolset" ? "toolset" : "tool";
|
|
408
|
+
return {
|
|
409
|
+
start: `${prefix} - Executing ${vercelPrefix}${toolType} ${toolName}`,
|
|
410
|
+
error: `${prefix} - Failed ${vercelPrefix}${toolType} execution`
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
function createExecute(tool, options, logType) {
|
|
414
|
+
const {
|
|
415
|
+
logger,
|
|
416
|
+
...rest
|
|
417
|
+
} = options;
|
|
418
|
+
const {
|
|
419
|
+
start,
|
|
420
|
+
error
|
|
421
|
+
} = createLogMessageOptions({
|
|
422
|
+
agentName: options.agentName,
|
|
423
|
+
toolName: options.name,
|
|
424
|
+
tool,
|
|
425
|
+
type: logType
|
|
426
|
+
});
|
|
427
|
+
const execFunction = async (args, execOptions) => {
|
|
428
|
+
if (isVercelTool(tool)) {
|
|
429
|
+
return tool?.execute?.(args, execOptions) ?? void 0;
|
|
430
|
+
}
|
|
431
|
+
return tool?.execute?.({
|
|
432
|
+
context: args,
|
|
433
|
+
threadId: options.threadId,
|
|
434
|
+
resourceId: options.resourceId,
|
|
435
|
+
mastra: options.mastra,
|
|
436
|
+
memory: options.memory,
|
|
437
|
+
runId: options.runId
|
|
438
|
+
}, execOptions) ?? void 0;
|
|
439
|
+
};
|
|
440
|
+
return async (args, execOptions) => {
|
|
441
|
+
try {
|
|
442
|
+
logger.debug(start, {
|
|
443
|
+
...rest,
|
|
444
|
+
args
|
|
445
|
+
});
|
|
446
|
+
return await execFunction(args, execOptions);
|
|
447
|
+
} catch (err) {
|
|
448
|
+
logger.error(error, {
|
|
449
|
+
...rest,
|
|
450
|
+
error: err,
|
|
451
|
+
args
|
|
452
|
+
});
|
|
453
|
+
throw err;
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
function makeCoreTool(tool, options, logType) {
|
|
458
|
+
const getParameters = () => {
|
|
459
|
+
if (isVercelTool(tool)) {
|
|
460
|
+
return tool.parameters instanceof zod.z.ZodType ? tool.parameters : resolveSerializedZodOutput(jsonSchemaToZod__default.default(tool.parameters));
|
|
461
|
+
}
|
|
462
|
+
return tool.inputSchema;
|
|
463
|
+
};
|
|
464
|
+
return {
|
|
465
|
+
description: tool.description,
|
|
466
|
+
parameters: getParameters(),
|
|
467
|
+
execute: tool.execute ? createExecute(tool, {
|
|
468
|
+
...options,
|
|
469
|
+
description: tool.description
|
|
470
|
+
}, logType) : void 0
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
function createMastraProxy({
|
|
474
|
+
mastra,
|
|
475
|
+
logger
|
|
476
|
+
}) {
|
|
477
|
+
return new Proxy(mastra, {
|
|
478
|
+
get(target, prop) {
|
|
479
|
+
if (Reflect.has(target, prop)) {
|
|
480
|
+
return Reflect.get(target, prop);
|
|
481
|
+
}
|
|
482
|
+
if (prop === "logger") {
|
|
483
|
+
logger.warn(`Please use 'getLogger' instead, logger is deprecated`);
|
|
484
|
+
return Reflect.apply(target.getLogger, target, []);
|
|
485
|
+
}
|
|
486
|
+
if (prop === "telemetry") {
|
|
487
|
+
logger.warn(`Please use 'getTelemetry' instead, telemetry is deprecated`);
|
|
488
|
+
return Reflect.apply(target.getTelemetry, target, []);
|
|
489
|
+
}
|
|
490
|
+
if (prop === "storage") {
|
|
491
|
+
logger.warn(`Please use 'getStorage' instead, storage is deprecated`);
|
|
492
|
+
return Reflect.get(target, "storage");
|
|
493
|
+
}
|
|
494
|
+
if (prop === "agents") {
|
|
495
|
+
logger.warn(`Please use 'getAgents' instead, agents is deprecated`);
|
|
496
|
+
return Reflect.apply(target.getAgents, target, []);
|
|
497
|
+
}
|
|
498
|
+
if (prop === "tts") {
|
|
499
|
+
logger.warn(`Please use 'getTTS' instead, tts is deprecated`);
|
|
500
|
+
return Reflect.apply(target.getTTS, target, []);
|
|
501
|
+
}
|
|
502
|
+
if (prop === "vectors") {
|
|
503
|
+
logger.warn(`Please use 'getVectors' instead, vectors is deprecated`);
|
|
504
|
+
return Reflect.apply(target.getVectors, target, []);
|
|
505
|
+
}
|
|
506
|
+
if (prop === "memory") {
|
|
507
|
+
logger.warn(`Please use 'getMemory' instead, memory is deprecated`);
|
|
508
|
+
return Reflect.get(target, "memory");
|
|
509
|
+
}
|
|
510
|
+
return Reflect.get(target, prop);
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
}
|
|
358
514
|
|
|
359
515
|
// src/llm/model/model.ts
|
|
360
516
|
var MastraLLM = class extends MastraLLMBase {
|
|
@@ -406,36 +562,16 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
406
562
|
const k = value[0];
|
|
407
563
|
const tool = value[1];
|
|
408
564
|
if (tool) {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
});
|
|
418
|
-
return tool?.execute?.({
|
|
419
|
-
context: props,
|
|
420
|
-
threadId,
|
|
421
|
-
resourceId,
|
|
422
|
-
mastra: this.#mastra,
|
|
423
|
-
memory,
|
|
424
|
-
runId
|
|
425
|
-
}, options) ?? void 0;
|
|
426
|
-
} catch (error) {
|
|
427
|
-
this.logger.error("Error executing tool", {
|
|
428
|
-
tool: k,
|
|
429
|
-
props,
|
|
430
|
-
error,
|
|
431
|
-
runId,
|
|
432
|
-
threadId,
|
|
433
|
-
resourceId
|
|
434
|
-
});
|
|
435
|
-
throw error;
|
|
436
|
-
}
|
|
437
|
-
} : void 0
|
|
565
|
+
const options = {
|
|
566
|
+
name: k,
|
|
567
|
+
runId,
|
|
568
|
+
threadId,
|
|
569
|
+
resourceId,
|
|
570
|
+
logger: this.logger,
|
|
571
|
+
memory,
|
|
572
|
+
mastra: this.#mastra
|
|
438
573
|
};
|
|
574
|
+
memo[k] = makeCoreTool(tool, options);
|
|
439
575
|
}
|
|
440
576
|
return memo;
|
|
441
577
|
}, {});
|
|
@@ -1024,7 +1160,10 @@ exports.Agent = class Agent extends (_a = MastraBase) {
|
|
|
1024
1160
|
this.tools = config.tools;
|
|
1025
1161
|
}
|
|
1026
1162
|
if (config.mastra) {
|
|
1027
|
-
this
|
|
1163
|
+
this.__registerPrimitives({
|
|
1164
|
+
telemetry: config.mastra.getTelemetry(),
|
|
1165
|
+
logger: config.mastra.getLogger()
|
|
1166
|
+
});
|
|
1028
1167
|
}
|
|
1029
1168
|
if (config.metrics) {
|
|
1030
1169
|
this.logger.warn("The metrics property is deprecated. Please use evals instead to add evaluation metrics.");
|
|
@@ -1062,12 +1201,14 @@ exports.Agent = class Agent extends (_a = MastraBase) {
|
|
|
1062
1201
|
this.__setLogger(p.logger);
|
|
1063
1202
|
}
|
|
1064
1203
|
this.llm.__registerPrimitives(p);
|
|
1065
|
-
this.#mastra = p;
|
|
1066
1204
|
this.logger.debug(`[Agents:${this.name}] initialized.`, {
|
|
1067
1205
|
model: this.model,
|
|
1068
1206
|
name: this.name
|
|
1069
1207
|
});
|
|
1070
1208
|
}
|
|
1209
|
+
__registerMastra(mastra) {
|
|
1210
|
+
this.#mastra = mastra;
|
|
1211
|
+
}
|
|
1071
1212
|
/**
|
|
1072
1213
|
* Set the concrete tools for the agent
|
|
1073
1214
|
* @param tools
|
|
@@ -1083,8 +1224,8 @@ exports.Agent = class Agent extends (_a = MastraBase) {
|
|
|
1083
1224
|
message
|
|
1084
1225
|
}) {
|
|
1085
1226
|
const {
|
|
1086
|
-
|
|
1087
|
-
} = await this.llm.
|
|
1227
|
+
text
|
|
1228
|
+
} = await this.llm.__text({
|
|
1088
1229
|
messages: [{
|
|
1089
1230
|
role: "system",
|
|
1090
1231
|
content: `
|
|
@@ -1092,23 +1233,22 @@ exports.Agent = class Agent extends (_a = MastraBase) {
|
|
|
1092
1233
|
- you will generate a short title based on the first message a user begins a conversation with
|
|
1093
1234
|
- ensure it is not more than 80 characters long
|
|
1094
1235
|
- the title should be a summary of the user's message
|
|
1095
|
-
- do not use quotes or colons
|
|
1236
|
+
- do not use quotes or colons
|
|
1237
|
+
- the entire text you return will be used as the title`
|
|
1096
1238
|
}, {
|
|
1097
1239
|
role: "user",
|
|
1098
1240
|
content: JSON.stringify(message)
|
|
1099
|
-
}]
|
|
1100
|
-
structuredOutput: zod.z.object({
|
|
1101
|
-
title: zod.z.string()
|
|
1102
|
-
})
|
|
1241
|
+
}]
|
|
1103
1242
|
});
|
|
1104
|
-
|
|
1243
|
+
const cleanedText = text.replace(/<think>[\s\S]*?<\/think>/g, "").trim();
|
|
1244
|
+
return cleanedText;
|
|
1105
1245
|
}
|
|
1106
1246
|
getMostRecentUserMessage(messages) {
|
|
1107
1247
|
const userMessages = messages.filter(message => message.role === "user");
|
|
1108
1248
|
return userMessages.at(-1);
|
|
1109
1249
|
}
|
|
1110
1250
|
async genTitle(userMessage) {
|
|
1111
|
-
let title =
|
|
1251
|
+
let title = `New Thread ${(/* @__PURE__ */new Date()).toISOString()}`;
|
|
1112
1252
|
try {
|
|
1113
1253
|
if (userMessage) {
|
|
1114
1254
|
title = await this.generateTitleFromUserMessage({
|
|
@@ -1130,17 +1270,18 @@ exports.Agent = class Agent extends (_a = MastraBase) {
|
|
|
1130
1270
|
const userMessage = this.getMostRecentUserMessage(userMessages);
|
|
1131
1271
|
const memory = this.getMemory();
|
|
1132
1272
|
if (memory) {
|
|
1273
|
+
const config = memory.getMergedThreadConfig(memoryConfig);
|
|
1133
1274
|
let thread;
|
|
1134
1275
|
if (!threadId) {
|
|
1135
1276
|
this.logger.debug(`No threadId, creating new thread for agent ${this.name}`, {
|
|
1136
1277
|
runId: runId || this.name
|
|
1137
1278
|
});
|
|
1138
|
-
const title = await this.genTitle(userMessage);
|
|
1279
|
+
const title = config?.threads?.generateTitle ? await this.genTitle(userMessage) : void 0;
|
|
1139
1280
|
thread = await memory.createThread({
|
|
1140
1281
|
threadId,
|
|
1141
1282
|
resourceId,
|
|
1142
|
-
|
|
1143
|
-
|
|
1283
|
+
memoryConfig,
|
|
1284
|
+
title
|
|
1144
1285
|
});
|
|
1145
1286
|
} else {
|
|
1146
1287
|
thread = await memory.getThreadById({
|
|
@@ -1150,7 +1291,7 @@ exports.Agent = class Agent extends (_a = MastraBase) {
|
|
|
1150
1291
|
this.logger.debug(`Thread with id ${threadId} not found, creating new thread for agent ${this.name}`, {
|
|
1151
1292
|
runId: runId || this.name
|
|
1152
1293
|
});
|
|
1153
|
-
const title = await this.genTitle(userMessage);
|
|
1294
|
+
const title = config?.threads?.generateTitle ? await this.genTitle(userMessage) : void 0;
|
|
1154
1295
|
thread = await memory.createThread({
|
|
1155
1296
|
threadId,
|
|
1156
1297
|
resourceId,
|
|
@@ -1359,43 +1500,30 @@ exports.Agent = class Agent extends (_a = MastraBase) {
|
|
|
1359
1500
|
resourceId
|
|
1360
1501
|
});
|
|
1361
1502
|
const memory = this.getMemory();
|
|
1362
|
-
const memoryTools = memory?.getTools();
|
|
1503
|
+
const memoryTools = memory?.getTools?.();
|
|
1504
|
+
let mastraProxy = void 0;
|
|
1505
|
+
const logger = this.logger;
|
|
1506
|
+
if (this.#mastra) {
|
|
1507
|
+
mastraProxy = createMastraProxy({
|
|
1508
|
+
mastra: this.#mastra,
|
|
1509
|
+
logger
|
|
1510
|
+
});
|
|
1511
|
+
}
|
|
1363
1512
|
const converted = Object.entries(this.tools || {}).reduce((memo, value) => {
|
|
1364
1513
|
const k = value[0];
|
|
1365
1514
|
const tool = this.tools[k];
|
|
1366
1515
|
if (tool) {
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
runId,
|
|
1377
|
-
threadId,
|
|
1378
|
-
resourceId
|
|
1379
|
-
});
|
|
1380
|
-
return tool?.execute?.({
|
|
1381
|
-
context: args,
|
|
1382
|
-
mastra: this.#mastra,
|
|
1383
|
-
memory,
|
|
1384
|
-
runId,
|
|
1385
|
-
threadId,
|
|
1386
|
-
resourceId
|
|
1387
|
-
}, options) ?? void 0;
|
|
1388
|
-
} catch (err) {
|
|
1389
|
-
this.logger.error(`[Agent:${this.name}] - Failed execution`, {
|
|
1390
|
-
error: err,
|
|
1391
|
-
runId,
|
|
1392
|
-
threadId,
|
|
1393
|
-
resourceId
|
|
1394
|
-
});
|
|
1395
|
-
throw err;
|
|
1396
|
-
}
|
|
1397
|
-
} : void 0
|
|
1516
|
+
const options = {
|
|
1517
|
+
name: k,
|
|
1518
|
+
runId,
|
|
1519
|
+
threadId,
|
|
1520
|
+
resourceId,
|
|
1521
|
+
logger: this.logger,
|
|
1522
|
+
mastra: mastraProxy,
|
|
1523
|
+
memory,
|
|
1524
|
+
agentName: this.name
|
|
1398
1525
|
};
|
|
1526
|
+
memo[k] = makeCoreTool(tool, options);
|
|
1399
1527
|
}
|
|
1400
1528
|
return memo;
|
|
1401
1529
|
}, {});
|
|
@@ -1415,7 +1543,7 @@ exports.Agent = class Agent extends (_a = MastraBase) {
|
|
|
1415
1543
|
});
|
|
1416
1544
|
return tool?.execute?.({
|
|
1417
1545
|
context: args,
|
|
1418
|
-
mastra:
|
|
1546
|
+
mastra: mastraProxy,
|
|
1419
1547
|
memory,
|
|
1420
1548
|
runId,
|
|
1421
1549
|
threadId,
|
|
@@ -1446,36 +1574,15 @@ exports.Agent = class Agent extends (_a = MastraBase) {
|
|
|
1446
1574
|
toolsFromToolsets.forEach(toolset => {
|
|
1447
1575
|
Object.entries(toolset).forEach(([toolName, tool]) => {
|
|
1448
1576
|
const toolObj = tool;
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
description: toolObj.description,
|
|
1457
|
-
args,
|
|
1458
|
-
runId,
|
|
1459
|
-
threadId,
|
|
1460
|
-
resourceId
|
|
1461
|
-
});
|
|
1462
|
-
return toolObj?.execute?.({
|
|
1463
|
-
context: args,
|
|
1464
|
-
runId,
|
|
1465
|
-
threadId,
|
|
1466
|
-
resourceId
|
|
1467
|
-
}, options) ?? void 0;
|
|
1468
|
-
} catch (error) {
|
|
1469
|
-
this.logger.error(`[Agent:${this.name}] - Failed toolset execution`, {
|
|
1470
|
-
error,
|
|
1471
|
-
runId,
|
|
1472
|
-
threadId,
|
|
1473
|
-
resourceId
|
|
1474
|
-
});
|
|
1475
|
-
throw error;
|
|
1476
|
-
}
|
|
1477
|
-
} : void 0
|
|
1577
|
+
const options = {
|
|
1578
|
+
name: toolName,
|
|
1579
|
+
runId,
|
|
1580
|
+
threadId,
|
|
1581
|
+
resourceId,
|
|
1582
|
+
logger: this.logger,
|
|
1583
|
+
agentName: this.name
|
|
1478
1584
|
};
|
|
1585
|
+
toolsFromToolsetsConverted[toolName] = makeCoreTool(toolObj, options, "toolset");
|
|
1479
1586
|
});
|
|
1480
1587
|
});
|
|
1481
1588
|
}
|
package/dist/agent/index.d.cts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
export { Message as AiMessageType } from 'ai';
|
|
2
2
|
import 'json-schema';
|
|
3
3
|
import 'zod';
|
|
4
|
-
export { A as Agent,
|
|
5
|
-
import '../base-
|
|
6
|
-
import '../types-
|
|
4
|
+
export { A as Agent, h as AgentConfig, au as AgentGenerateOptions, av as AgentStreamOptions, as as ToolsInput, at as ToolsetsInput } from '../base-CTdONy0_.cjs';
|
|
5
|
+
import '../base-DboIg_Cd.cjs';
|
|
6
|
+
import '../types-CwTG2XyQ.cjs';
|
|
7
7
|
import '../voice/index.cjs';
|
|
8
8
|
import 'sift';
|
|
9
|
-
import '../vector/index.cjs';
|
|
10
|
-
import '../vector/filter/index.cjs';
|
|
11
|
-
import '@opentelemetry/api';
|
|
12
9
|
import '../index-mKY1XrpK.cjs';
|
|
13
10
|
import 'stream';
|
|
14
11
|
import 'pino';
|
|
12
|
+
import '../deployer/index.cjs';
|
|
13
|
+
import '../bundler/index.cjs';
|
|
14
|
+
import '@opentelemetry/api';
|
|
15
15
|
import '@opentelemetry/sdk-trace-base';
|
|
16
|
+
import '../vector/index.cjs';
|
|
17
|
+
import '../vector/filter/index.cjs';
|
|
16
18
|
import '../tts/index.cjs';
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
export { Message as AiMessageType } from 'ai';
|
|
2
2
|
import 'json-schema';
|
|
3
3
|
import 'zod';
|
|
4
|
-
export { A as Agent,
|
|
5
|
-
import '../base-
|
|
6
|
-
import '../types-
|
|
4
|
+
export { A as Agent, h as AgentConfig, au as AgentGenerateOptions, av as AgentStreamOptions, as as ToolsInput, at as ToolsetsInput } from '../base-DIn_km7X.js';
|
|
5
|
+
import '../base-BZViaFTt.js';
|
|
6
|
+
import '../types-CwTG2XyQ.js';
|
|
7
7
|
import '../voice/index.js';
|
|
8
8
|
import 'sift';
|
|
9
|
-
import '../vector/index.js';
|
|
10
|
-
import '../vector/filter/index.js';
|
|
11
|
-
import '@opentelemetry/api';
|
|
12
9
|
import '../index-mKY1XrpK.js';
|
|
13
10
|
import 'stream';
|
|
14
11
|
import 'pino';
|
|
12
|
+
import '../deployer/index.js';
|
|
13
|
+
import '../bundler/index.js';
|
|
14
|
+
import '@opentelemetry/api';
|
|
15
15
|
import '@opentelemetry/sdk-trace-base';
|
|
16
|
+
import '../vector/index.js';
|
|
17
|
+
import '../vector/filter/index.js';
|
|
16
18
|
import '../tts/index.js';
|
package/dist/agent/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Agent } from '../chunk-
|
|
1
|
+
export { Agent } from '../chunk-SWDQYPJS.js';
|
|
@@ -38,6 +38,8 @@ type OtelConfig = {
|
|
|
38
38
|
export?: {
|
|
39
39
|
/** Export to an OTLP (OpenTelemetry Protocol) endpoint */
|
|
40
40
|
type: 'otlp';
|
|
41
|
+
/** Whether to use gRPC or HTTP for OTLP */
|
|
42
|
+
protocol?: 'grpc' | 'http';
|
|
41
43
|
/** OTLP endpoint URL */
|
|
42
44
|
endpoint?: string;
|
|
43
45
|
/** Optional headers for OTLP requests */
|