@mastra/core 0.16.2-alpha.0 → 0.16.3-alpha.0
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 +40 -0
- package/dist/agent/agent.d.ts +316 -0
- package/dist/agent/agent.d.ts.map +1 -0
- package/dist/agent/agent.types.d.ts +19 -2
- package/dist/agent/agent.types.d.ts.map +1 -1
- package/dist/agent/index.cjs +11 -11
- package/dist/agent/index.d.ts +4 -313
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +2 -2
- package/dist/agent/input-processor/index.cjs +6 -6
- package/dist/agent/input-processor/index.js +1 -1
- package/dist/agent/types.d.ts +8 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/ai-tracing/base.d.ts.map +1 -1
- package/dist/ai-tracing/context.d.ts.map +1 -1
- package/dist/ai-tracing/default.d.ts +1 -2
- package/dist/ai-tracing/default.d.ts.map +1 -1
- package/dist/ai-tracing/exporters/cloud.d.ts +32 -0
- package/dist/ai-tracing/exporters/cloud.d.ts.map +1 -0
- package/dist/ai-tracing/exporters/default.d.ts.map +1 -1
- package/dist/ai-tracing/exporters/index.d.ts +2 -0
- package/dist/ai-tracing/exporters/index.d.ts.map +1 -1
- package/dist/ai-tracing/index.cjs +36 -40
- package/dist/ai-tracing/index.js +1 -1
- package/dist/ai-tracing/no-op.d.ts +1 -0
- package/dist/ai-tracing/no-op.d.ts.map +1 -1
- package/dist/ai-tracing/registry.d.ts.map +1 -1
- package/dist/ai-tracing/types.d.ts +39 -14
- package/dist/ai-tracing/types.d.ts.map +1 -1
- package/dist/ai-tracing/utils.d.ts +29 -19
- package/dist/ai-tracing/utils.d.ts.map +1 -1
- package/dist/{chunk-YI3AIJJL.js → chunk-3JG5JEKX.js} +3 -3
- package/dist/{chunk-YI3AIJJL.js.map → chunk-3JG5JEKX.js.map} +1 -1
- package/dist/{chunk-RVNDGKE5.js → chunk-3WWYKE4R.js} +3 -3
- package/dist/{chunk-RVNDGKE5.js.map → chunk-3WWYKE4R.js.map} +1 -1
- package/dist/{chunk-YBKHXKRR.js → chunk-4MVIJIOL.js} +3 -3
- package/dist/{chunk-YBKHXKRR.js.map → chunk-4MVIJIOL.js.map} +1 -1
- package/dist/chunk-4WQYXT2I.cjs +12 -0
- package/dist/chunk-4WQYXT2I.cjs.map +1 -0
- package/dist/{chunk-YYRE76UM.js → chunk-6SPMCTI2.js} +4 -4
- package/dist/{chunk-YYRE76UM.js.map → chunk-6SPMCTI2.js.map} +1 -1
- package/dist/{chunk-P67M4R6G.js → chunk-ASFX33CM.js} +5 -5
- package/dist/{chunk-P67M4R6G.js.map → chunk-ASFX33CM.js.map} +1 -1
- package/dist/{chunk-SJO2HEVU.cjs → chunk-AV5QBG6P.cjs} +185 -125
- package/dist/chunk-AV5QBG6P.cjs.map +1 -0
- package/dist/{chunk-OYHHJUTH.cjs → chunk-EJB4UMEV.cjs} +12 -12
- package/dist/{chunk-OYHHJUTH.cjs.map → chunk-EJB4UMEV.cjs.map} +1 -1
- package/dist/{chunk-JLVFFZT7.cjs → chunk-GOA5GU6X.cjs} +4 -4
- package/dist/{chunk-JLVFFZT7.cjs.map → chunk-GOA5GU6X.cjs.map} +1 -1
- package/dist/{chunk-D3UG2YLU.cjs → chunk-HT57W63C.cjs} +4 -4
- package/dist/{chunk-D3UG2YLU.cjs.map → chunk-HT57W63C.cjs.map} +1 -1
- package/dist/{chunk-ZIDWSQFD.cjs → chunk-HYKEC3OC.cjs} +8 -8
- package/dist/{chunk-ZIDWSQFD.cjs.map → chunk-HYKEC3OC.cjs.map} +1 -1
- package/dist/chunk-KETY3ZMA.cjs +808 -0
- package/dist/chunk-KETY3ZMA.cjs.map +1 -0
- package/dist/{chunk-IMDDMIVR.cjs → chunk-L52VPDJB.cjs} +6 -6
- package/dist/{chunk-IMDDMIVR.cjs.map → chunk-L52VPDJB.cjs.map} +1 -1
- package/dist/chunk-NEBAQHIS.js +737 -0
- package/dist/chunk-NEBAQHIS.js.map +1 -0
- package/dist/chunk-PJKCPRYF.js +3 -0
- package/dist/chunk-PJKCPRYF.js.map +1 -0
- package/dist/{chunk-6RVOPJVP.cjs → chunk-PUTAA3ZN.cjs} +7 -7
- package/dist/{chunk-6RVOPJVP.cjs.map → chunk-PUTAA3ZN.cjs.map} +1 -1
- package/dist/{chunk-DUABZASJ.js → chunk-RAR5G5S3.js} +4 -4
- package/dist/{chunk-DUABZASJ.js.map → chunk-RAR5G5S3.js.map} +1 -1
- package/dist/{chunk-UGCG7DI3.cjs → chunk-VVUCWRGD.cjs} +855 -87
- package/dist/chunk-VVUCWRGD.cjs.map +1 -0
- package/dist/{chunk-2NKNTPFR.js → chunk-W5K2KOZX.js} +834 -85
- package/dist/chunk-W5K2KOZX.js.map +1 -0
- package/dist/{chunk-BQ43NQXK.js → chunk-WAN6BRTN.js} +182 -122
- package/dist/chunk-WAN6BRTN.js.map +1 -0
- package/dist/index.cjs +38 -38
- package/dist/index.js +7 -7
- package/dist/llm/model/base.types.d.ts +6 -4
- package/dist/llm/model/base.types.d.ts.map +1 -1
- package/dist/llm/model/model.d.ts +0 -2
- package/dist/llm/model/model.d.ts.map +1 -1
- package/dist/llm/model/model.loop.d.ts.map +1 -1
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +1 -1
- package/dist/loop/loop.d.ts.map +1 -1
- package/dist/loop/network/index.d.ts +139 -0
- package/dist/loop/network/index.d.ts.map +1 -0
- package/dist/loop/types.d.ts +2 -0
- package/dist/loop/types.d.ts.map +1 -1
- package/dist/loop/workflow/llm-execution.d.ts +5 -5
- package/dist/loop/workflow/llm-execution.d.ts.map +1 -1
- package/dist/loop/workflow/outer-llm-step.d.ts +2 -2
- package/dist/loop/workflow/schema.d.ts +12 -12
- package/dist/loop/workflow/stream.d.ts.map +1 -1
- package/dist/loop/workflow/tool-call-step.d.ts +10 -10
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +4 -4
- package/dist/memory/index.js +1 -1
- package/dist/network/index.cjs +6 -3
- package/dist/network/index.cjs.map +1 -1
- package/dist/network/index.js +5 -2
- package/dist/network/index.js.map +1 -1
- package/dist/network/network.d.ts.map +1 -1
- package/dist/network/vNext/index.cjs +32 -30
- package/dist/network/vNext/index.cjs.map +1 -1
- package/dist/network/vNext/index.d.ts +7 -7
- package/dist/network/vNext/index.d.ts.map +1 -1
- package/dist/network/vNext/index.js +5 -3
- package/dist/network/vNext/index.js.map +1 -1
- package/dist/processors/index.cjs +8 -8
- package/dist/processors/index.js +2 -2
- package/dist/processors/runner.d.ts +2 -2
- package/dist/processors/runner.d.ts.map +1 -1
- package/dist/relevance/index.cjs +4 -4
- package/dist/relevance/index.js +1 -1
- package/dist/scores/index.cjs +8 -8
- package/dist/scores/index.js +1 -1
- package/dist/scores/types.d.ts +2 -2
- package/dist/storage/index.cjs +3 -3
- package/dist/storage/index.js +1 -1
- package/dist/stream/MastraWorkflowStream.d.ts +1 -1
- package/dist/stream/base/output-format-handlers.d.ts.map +1 -1
- package/dist/stream/base/output.d.ts +13 -3
- package/dist/stream/base/output.d.ts.map +1 -1
- package/dist/stream/base/schema.d.ts +3 -2
- package/dist/stream/base/schema.d.ts.map +1 -1
- package/dist/stream/index.cjs +3 -3
- package/dist/stream/index.d.ts +1 -1
- package/dist/stream/index.d.ts.map +1 -1
- package/dist/stream/index.js +1 -1
- package/dist/stream/types.d.ts +139 -1
- package/dist/stream/types.d.ts.map +1 -1
- package/dist/test-utils/llm-mock.cjs +2 -2
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/utils.cjs +17 -17
- package/dist/utils.js +1 -1
- package/dist/workflows/default.d.ts +3 -2
- package/dist/workflows/default.d.ts.map +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/execution-engine.d.ts +2 -2
- package/dist/workflows/execution-engine.d.ts.map +1 -1
- package/dist/workflows/index.cjs +10 -10
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/legacy/index.cjs +22 -22
- package/dist/workflows/legacy/index.js +1 -1
- package/dist/workflows/legacy/machine.d.ts +1 -1
- package/dist/workflows/legacy/workflow.d.ts +1 -1
- package/dist/workflows/types.d.ts +5 -4
- package/dist/workflows/types.d.ts.map +1 -1
- package/dist/workflows/workflow.d.ts +8 -4
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/dist/zod-to-json.cjs +2 -2
- package/dist/zod-to-json.cjs.map +1 -1
- package/dist/zod-to-json.js +1 -1
- package/dist/zod-to-json.js.map +1 -1
- package/package.json +5 -5
- package/dist/chunk-2NKNTPFR.js.map +0 -1
- package/dist/chunk-3MSZBGO3.js +0 -15991
- package/dist/chunk-3MSZBGO3.js.map +0 -1
- package/dist/chunk-BJASJTXK.cjs +0 -16061
- package/dist/chunk-BJASJTXK.cjs.map +0 -1
- package/dist/chunk-BQ43NQXK.js.map +0 -1
- package/dist/chunk-KB4IEMPV.cjs +0 -548
- package/dist/chunk-KB4IEMPV.cjs.map +0 -1
- package/dist/chunk-SJO2HEVU.cjs.map +0 -1
- package/dist/chunk-TDLB5JKT.js +0 -527
- package/dist/chunk-TDLB5JKT.js.map +0 -1
- package/dist/chunk-UGCG7DI3.cjs.map +0 -1
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunkGPWMM745_cjs = require('./chunk-GPWMM745.cjs');
|
|
3
4
|
var chunkC73WLCY3_cjs = require('./chunk-C73WLCY3.cjs');
|
|
5
|
+
var chunkS6MAHT7F_cjs = require('./chunk-S6MAHT7F.cjs');
|
|
6
|
+
var chunkABRPHTOG_cjs = require('./chunk-ABRPHTOG.cjs');
|
|
4
7
|
var chunkKXCUCBEI_cjs = require('./chunk-KXCUCBEI.cjs');
|
|
5
8
|
var chunkV5WKCX3G_cjs = require('./chunk-V5WKCX3G.cjs');
|
|
9
|
+
var crypto$1 = require('crypto');
|
|
10
|
+
var jsonSchemaToZod = require('json-schema-to-zod');
|
|
11
|
+
var zod = require('zod');
|
|
12
|
+
var schemaCompat = require('@mastra/schema-compat');
|
|
13
|
+
|
|
14
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
|
|
16
|
+
var jsonSchemaToZod__default = /*#__PURE__*/_interopDefault(jsonSchemaToZod);
|
|
6
17
|
|
|
7
18
|
// src/ai-tracing/no-op.ts
|
|
8
19
|
var NoOpAISpan = class _NoOpAISpan {
|
|
@@ -49,6 +60,9 @@ var NoOpAISpan = class _NoOpAISpan {
|
|
|
49
60
|
get isRootSpan() {
|
|
50
61
|
return !this.parent;
|
|
51
62
|
}
|
|
63
|
+
get isValid() {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
52
66
|
};
|
|
53
67
|
|
|
54
68
|
// src/ai-tracing/types.ts
|
|
@@ -90,7 +104,7 @@ var MastraAITracing = class extends chunkKXCUCBEI_cjs.MastraBase {
|
|
|
90
104
|
super({ component: chunkV5WKCX3G_cjs.RegisteredLogger.AI_TRACING, name: config.serviceName });
|
|
91
105
|
this.config = {
|
|
92
106
|
serviceName: config.serviceName,
|
|
93
|
-
|
|
107
|
+
name: config.name,
|
|
94
108
|
sampling: config.sampling ?? { type: "always" /* ALWAYS */ },
|
|
95
109
|
exporters: config.exporters ?? [],
|
|
96
110
|
processors: config.processors ?? []
|
|
@@ -102,7 +116,7 @@ var MastraAITracing = class extends chunkKXCUCBEI_cjs.MastraBase {
|
|
|
102
116
|
__setLogger(logger) {
|
|
103
117
|
super.__setLogger(logger);
|
|
104
118
|
this.logger.debug(
|
|
105
|
-
`[AI Tracing] Initialized [service=${this.config.serviceName}] [instance=${this.config.
|
|
119
|
+
`[AI Tracing] Initialized [service=${this.config.serviceName}] [instance=${this.config.name}] [sampling=${this.config.sampling.type}]`
|
|
106
120
|
);
|
|
107
121
|
}
|
|
108
122
|
// ============================================================================
|
|
@@ -189,10 +203,18 @@ var MastraAITracing = class extends chunkKXCUCBEI_cjs.MastraBase {
|
|
|
189
203
|
const originalEnd = span.end.bind(span);
|
|
190
204
|
const originalUpdate = span.update.bind(span);
|
|
191
205
|
span.end = (options) => {
|
|
206
|
+
if (span.isEvent) {
|
|
207
|
+
this.logger.warn(`End event is not available on event spans`);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
192
210
|
originalEnd(options);
|
|
193
211
|
this.emitSpanEnded(span);
|
|
194
212
|
};
|
|
195
213
|
span.update = (options) => {
|
|
214
|
+
if (span.isEvent) {
|
|
215
|
+
this.logger.warn(`Update() is not available on event spans`);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
196
218
|
originalUpdate(options);
|
|
197
219
|
this.emitSpanUpdated(span);
|
|
198
220
|
};
|
|
@@ -313,6 +335,718 @@ var MastraAITracing = class extends chunkKXCUCBEI_cjs.MastraBase {
|
|
|
313
335
|
this.logger.info(`[AI Tracing] Shutdown completed [name=${this.name}]`);
|
|
314
336
|
}
|
|
315
337
|
};
|
|
338
|
+
var CoreToolBuilder = class extends chunkKXCUCBEI_cjs.MastraBase {
|
|
339
|
+
originalTool;
|
|
340
|
+
options;
|
|
341
|
+
logType;
|
|
342
|
+
constructor(input) {
|
|
343
|
+
super({ name: "CoreToolBuilder" });
|
|
344
|
+
this.originalTool = input.originalTool;
|
|
345
|
+
this.options = input.options;
|
|
346
|
+
this.logType = input.logType;
|
|
347
|
+
}
|
|
348
|
+
// Helper to get parameters based on tool type
|
|
349
|
+
getParameters = () => {
|
|
350
|
+
if (chunkABRPHTOG_cjs.isVercelTool(this.originalTool)) {
|
|
351
|
+
return this.originalTool.parameters ?? zod.z.object({});
|
|
352
|
+
}
|
|
353
|
+
return this.originalTool.inputSchema ?? zod.z.object({});
|
|
354
|
+
};
|
|
355
|
+
getOutputSchema = () => {
|
|
356
|
+
if ("outputSchema" in this.originalTool) return this.originalTool.outputSchema;
|
|
357
|
+
return null;
|
|
358
|
+
};
|
|
359
|
+
// For provider-defined tools, we need to include all required properties
|
|
360
|
+
buildProviderTool(tool) {
|
|
361
|
+
if ("type" in tool && tool.type === "provider-defined" && "id" in tool && typeof tool.id === "string" && tool.id.includes(".")) {
|
|
362
|
+
const parameters = this.getParameters();
|
|
363
|
+
const outputSchema = this.getOutputSchema();
|
|
364
|
+
return {
|
|
365
|
+
type: "provider-defined",
|
|
366
|
+
id: tool.id,
|
|
367
|
+
args: "args" in this.originalTool ? this.originalTool.args : {},
|
|
368
|
+
description: tool.description,
|
|
369
|
+
parameters: schemaCompat.convertZodSchemaToAISDKSchema(parameters),
|
|
370
|
+
...outputSchema ? { outputSchema: schemaCompat.convertZodSchemaToAISDKSchema(outputSchema) } : {},
|
|
371
|
+
execute: this.originalTool.execute ? this.createExecute(
|
|
372
|
+
this.originalTool,
|
|
373
|
+
{ ...this.options, description: this.originalTool.description },
|
|
374
|
+
this.logType
|
|
375
|
+
) : void 0
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
return void 0;
|
|
379
|
+
}
|
|
380
|
+
createLogMessageOptions({ agentName, toolName, type }) {
|
|
381
|
+
if (!agentName) {
|
|
382
|
+
return {
|
|
383
|
+
start: `Executing tool ${toolName}`,
|
|
384
|
+
error: `Failed tool execution`
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
const prefix = `[Agent:${agentName}]`;
|
|
388
|
+
const toolType = type === "toolset" ? "toolset" : "tool";
|
|
389
|
+
return {
|
|
390
|
+
start: `${prefix} - Executing ${toolType} ${toolName}`,
|
|
391
|
+
error: `${prefix} - Failed ${toolType} execution`
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
createExecute(tool, options, logType) {
|
|
395
|
+
const { logger, mastra: _mastra, memory: _memory, runtimeContext, ...rest } = options;
|
|
396
|
+
const { start, error } = this.createLogMessageOptions({
|
|
397
|
+
agentName: options.agentName,
|
|
398
|
+
toolName: options.name,
|
|
399
|
+
type: logType
|
|
400
|
+
});
|
|
401
|
+
const execFunction = async (args, execOptions) => {
|
|
402
|
+
const toolSpan = options.tracingContext?.currentSpan?.createChildSpan({
|
|
403
|
+
type: "tool_call" /* TOOL_CALL */,
|
|
404
|
+
name: `tool: '${options.name}'`,
|
|
405
|
+
input: args,
|
|
406
|
+
attributes: {
|
|
407
|
+
toolId: options.name,
|
|
408
|
+
toolDescription: options.description,
|
|
409
|
+
toolType: logType || "tool"
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
try {
|
|
413
|
+
let result;
|
|
414
|
+
if (chunkABRPHTOG_cjs.isVercelTool(tool)) {
|
|
415
|
+
result = await tool?.execute?.(args, execOptions);
|
|
416
|
+
} else {
|
|
417
|
+
const wrappedMastra = options.mastra ? wrapMastra(options.mastra, { currentSpan: toolSpan }) : options.mastra;
|
|
418
|
+
result = await tool?.execute?.(
|
|
419
|
+
{
|
|
420
|
+
context: args,
|
|
421
|
+
threadId: options.threadId,
|
|
422
|
+
resourceId: options.resourceId,
|
|
423
|
+
mastra: wrappedMastra,
|
|
424
|
+
memory: options.memory,
|
|
425
|
+
runId: options.runId,
|
|
426
|
+
runtimeContext: options.runtimeContext ?? new chunkGPWMM745_cjs.RuntimeContext(),
|
|
427
|
+
writer: new chunkS6MAHT7F_cjs.ToolStream(
|
|
428
|
+
{
|
|
429
|
+
prefix: "tool",
|
|
430
|
+
callId: execOptions.toolCallId,
|
|
431
|
+
name: options.name,
|
|
432
|
+
runId: options.runId
|
|
433
|
+
},
|
|
434
|
+
options.writableStream || execOptions.writableStream
|
|
435
|
+
),
|
|
436
|
+
tracingContext: { currentSpan: toolSpan }
|
|
437
|
+
},
|
|
438
|
+
execOptions
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
toolSpan?.end({ output: result });
|
|
442
|
+
return result ?? void 0;
|
|
443
|
+
} catch (error2) {
|
|
444
|
+
toolSpan?.error({ error: error2 });
|
|
445
|
+
throw error2;
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
return async (args, execOptions) => {
|
|
449
|
+
let logger2 = options.logger || this.logger;
|
|
450
|
+
try {
|
|
451
|
+
logger2.debug(start, { ...rest, args });
|
|
452
|
+
const parameters = this.getParameters();
|
|
453
|
+
const { data, error: error2 } = chunkABRPHTOG_cjs.validateToolInput(parameters, args, options.name);
|
|
454
|
+
if (error2) {
|
|
455
|
+
logger2.warn(`Tool input validation failed for '${options.name}'`, {
|
|
456
|
+
toolName: options.name,
|
|
457
|
+
errors: error2.validationErrors,
|
|
458
|
+
args
|
|
459
|
+
});
|
|
460
|
+
return error2;
|
|
461
|
+
}
|
|
462
|
+
args = data;
|
|
463
|
+
return await new Promise((resolve, reject) => {
|
|
464
|
+
setImmediate(async () => {
|
|
465
|
+
try {
|
|
466
|
+
const result = await execFunction(args, execOptions);
|
|
467
|
+
resolve(result);
|
|
468
|
+
} catch (err) {
|
|
469
|
+
reject(err);
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
});
|
|
473
|
+
} catch (err) {
|
|
474
|
+
const mastraError = new chunkC73WLCY3_cjs.MastraError(
|
|
475
|
+
{
|
|
476
|
+
id: "TOOL_EXECUTION_FAILED",
|
|
477
|
+
domain: "TOOL" /* TOOL */,
|
|
478
|
+
category: "USER" /* USER */,
|
|
479
|
+
details: {
|
|
480
|
+
errorMessage: String(error),
|
|
481
|
+
argsJson: JSON.stringify(args),
|
|
482
|
+
model: rest.model?.modelId ?? ""
|
|
483
|
+
}
|
|
484
|
+
},
|
|
485
|
+
err
|
|
486
|
+
);
|
|
487
|
+
logger2.trackException(mastraError);
|
|
488
|
+
logger2.error(error, { ...rest, error: mastraError, args });
|
|
489
|
+
return mastraError;
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
buildV5() {
|
|
494
|
+
const builtTool = this.build();
|
|
495
|
+
if (!builtTool.parameters) {
|
|
496
|
+
throw new Error("Tool parameters are required");
|
|
497
|
+
}
|
|
498
|
+
return {
|
|
499
|
+
...builtTool,
|
|
500
|
+
inputSchema: builtTool.parameters,
|
|
501
|
+
onInputStart: "onInputStart" in this.originalTool ? this.originalTool.onInputStart : void 0,
|
|
502
|
+
onInputDelta: "onInputDelta" in this.originalTool ? this.originalTool.onInputDelta : void 0,
|
|
503
|
+
onInputAvailable: "onInputAvailable" in this.originalTool ? this.originalTool.onInputAvailable : void 0
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
build() {
|
|
507
|
+
const providerTool = this.buildProviderTool(this.originalTool);
|
|
508
|
+
if (providerTool) {
|
|
509
|
+
return providerTool;
|
|
510
|
+
}
|
|
511
|
+
const definition = {
|
|
512
|
+
type: "function",
|
|
513
|
+
description: this.originalTool.description,
|
|
514
|
+
parameters: this.getParameters(),
|
|
515
|
+
outputSchema: this.getOutputSchema(),
|
|
516
|
+
execute: this.originalTool.execute ? this.createExecute(
|
|
517
|
+
this.originalTool,
|
|
518
|
+
{ ...this.options, description: this.originalTool.description },
|
|
519
|
+
this.logType
|
|
520
|
+
) : void 0
|
|
521
|
+
};
|
|
522
|
+
const model = this.options.model;
|
|
523
|
+
const schemaCompatLayers = [];
|
|
524
|
+
if (model) {
|
|
525
|
+
const supportsStructuredOutputs = model.specificationVersion !== "v2" ? model.supportsStructuredOutputs ?? false : false;
|
|
526
|
+
const modelInfo = {
|
|
527
|
+
modelId: model.modelId,
|
|
528
|
+
supportsStructuredOutputs,
|
|
529
|
+
provider: model.provider
|
|
530
|
+
};
|
|
531
|
+
schemaCompatLayers.push(
|
|
532
|
+
new schemaCompat.OpenAIReasoningSchemaCompatLayer(modelInfo),
|
|
533
|
+
new schemaCompat.OpenAISchemaCompatLayer(modelInfo),
|
|
534
|
+
new schemaCompat.GoogleSchemaCompatLayer(modelInfo),
|
|
535
|
+
new schemaCompat.AnthropicSchemaCompatLayer(modelInfo),
|
|
536
|
+
new schemaCompat.DeepSeekSchemaCompatLayer(modelInfo),
|
|
537
|
+
new schemaCompat.MetaSchemaCompatLayer(modelInfo)
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
const processedSchema = schemaCompat.applyCompatLayer({
|
|
541
|
+
schema: this.getParameters(),
|
|
542
|
+
compatLayers: schemaCompatLayers,
|
|
543
|
+
mode: "aiSdkSchema"
|
|
544
|
+
});
|
|
545
|
+
let processedOutputSchema;
|
|
546
|
+
if (this.getOutputSchema()) {
|
|
547
|
+
processedOutputSchema = schemaCompat.applyCompatLayer({
|
|
548
|
+
schema: this.getOutputSchema(),
|
|
549
|
+
compatLayers: schemaCompatLayers,
|
|
550
|
+
mode: "aiSdkSchema"
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
return {
|
|
554
|
+
...definition,
|
|
555
|
+
id: "id" in this.originalTool ? this.originalTool.id : void 0,
|
|
556
|
+
parameters: processedSchema,
|
|
557
|
+
outputSchema: processedOutputSchema
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
|
|
562
|
+
// src/utils.ts
|
|
563
|
+
var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
564
|
+
function deepMerge(target, source) {
|
|
565
|
+
const output = { ...target };
|
|
566
|
+
if (!source) return output;
|
|
567
|
+
Object.keys(source).forEach((key) => {
|
|
568
|
+
const targetValue = output[key];
|
|
569
|
+
const sourceValue = source[key];
|
|
570
|
+
if (Array.isArray(targetValue) && Array.isArray(sourceValue)) {
|
|
571
|
+
output[key] = sourceValue;
|
|
572
|
+
} else if (sourceValue instanceof Object && targetValue instanceof Object && !Array.isArray(sourceValue) && !Array.isArray(targetValue)) {
|
|
573
|
+
output[key] = deepMerge(targetValue, sourceValue);
|
|
574
|
+
} else if (sourceValue !== void 0) {
|
|
575
|
+
output[key] = sourceValue;
|
|
576
|
+
}
|
|
577
|
+
});
|
|
578
|
+
return output;
|
|
579
|
+
}
|
|
580
|
+
function generateEmptyFromSchema(schema) {
|
|
581
|
+
try {
|
|
582
|
+
const parsedSchema = JSON.parse(schema);
|
|
583
|
+
if (!parsedSchema || parsedSchema.type !== "object" || !parsedSchema.properties) return {};
|
|
584
|
+
const obj = {};
|
|
585
|
+
const TYPE_DEFAULTS = {
|
|
586
|
+
string: "",
|
|
587
|
+
array: [],
|
|
588
|
+
object: {},
|
|
589
|
+
number: 0,
|
|
590
|
+
integer: 0,
|
|
591
|
+
boolean: false
|
|
592
|
+
};
|
|
593
|
+
for (const [key, prop] of Object.entries(parsedSchema.properties)) {
|
|
594
|
+
obj[key] = TYPE_DEFAULTS[prop.type] ?? null;
|
|
595
|
+
}
|
|
596
|
+
return obj;
|
|
597
|
+
} catch {
|
|
598
|
+
return {};
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
async function* maskStreamTags(stream, tag, options = {}) {
|
|
602
|
+
const { onStart, onEnd, onMask } = options;
|
|
603
|
+
const openTag = `<${tag}>`;
|
|
604
|
+
const closeTag = `</${tag}>`;
|
|
605
|
+
let buffer = "";
|
|
606
|
+
let fullContent = "";
|
|
607
|
+
let isMasking = false;
|
|
608
|
+
let isBuffering = false;
|
|
609
|
+
const trimOutsideDelimiter = (text, delimiter, trim) => {
|
|
610
|
+
if (!text.includes(delimiter)) {
|
|
611
|
+
return text;
|
|
612
|
+
}
|
|
613
|
+
const parts = text.split(delimiter);
|
|
614
|
+
if (trim === `before-start`) {
|
|
615
|
+
return `${delimiter}${parts[1]}`;
|
|
616
|
+
}
|
|
617
|
+
return `${parts[0]}${delimiter}`;
|
|
618
|
+
};
|
|
619
|
+
const startsWith = (text, pattern) => {
|
|
620
|
+
if (pattern.includes(openTag.substring(0, 3))) {
|
|
621
|
+
pattern = trimOutsideDelimiter(pattern, `<`, `before-start`);
|
|
622
|
+
}
|
|
623
|
+
return text.trim().startsWith(pattern.trim());
|
|
624
|
+
};
|
|
625
|
+
for await (const chunk of stream) {
|
|
626
|
+
fullContent += chunk;
|
|
627
|
+
if (isBuffering) buffer += chunk;
|
|
628
|
+
const chunkHasTag = startsWith(chunk, openTag);
|
|
629
|
+
const bufferHasTag = !chunkHasTag && isBuffering && startsWith(openTag, buffer);
|
|
630
|
+
let toYieldBeforeMaskedStartTag = ``;
|
|
631
|
+
if (!isMasking && (chunkHasTag || bufferHasTag)) {
|
|
632
|
+
isMasking = true;
|
|
633
|
+
isBuffering = false;
|
|
634
|
+
const taggedTextToMask = trimOutsideDelimiter(buffer, `<`, `before-start`);
|
|
635
|
+
if (taggedTextToMask !== buffer.trim()) {
|
|
636
|
+
toYieldBeforeMaskedStartTag = buffer.replace(taggedTextToMask, ``);
|
|
637
|
+
}
|
|
638
|
+
buffer = "";
|
|
639
|
+
onStart?.();
|
|
640
|
+
}
|
|
641
|
+
if (!isMasking && !isBuffering && startsWith(openTag, chunk) && chunk.trim() !== "") {
|
|
642
|
+
isBuffering = true;
|
|
643
|
+
buffer += chunk;
|
|
644
|
+
continue;
|
|
645
|
+
}
|
|
646
|
+
if (isBuffering && buffer && !startsWith(openTag, buffer)) {
|
|
647
|
+
yield buffer;
|
|
648
|
+
buffer = "";
|
|
649
|
+
isBuffering = false;
|
|
650
|
+
continue;
|
|
651
|
+
}
|
|
652
|
+
if (isMasking && fullContent.includes(closeTag)) {
|
|
653
|
+
onMask?.(chunk);
|
|
654
|
+
onEnd?.();
|
|
655
|
+
isMasking = false;
|
|
656
|
+
const lastFullContent = fullContent;
|
|
657
|
+
fullContent = ``;
|
|
658
|
+
const textUntilEndTag = trimOutsideDelimiter(lastFullContent, closeTag, "after-end");
|
|
659
|
+
if (textUntilEndTag !== lastFullContent) {
|
|
660
|
+
yield lastFullContent.replace(textUntilEndTag, ``);
|
|
661
|
+
}
|
|
662
|
+
continue;
|
|
663
|
+
}
|
|
664
|
+
if (isMasking) {
|
|
665
|
+
onMask?.(chunk);
|
|
666
|
+
if (toYieldBeforeMaskedStartTag) {
|
|
667
|
+
yield toYieldBeforeMaskedStartTag;
|
|
668
|
+
}
|
|
669
|
+
continue;
|
|
670
|
+
}
|
|
671
|
+
yield chunk;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
function resolveSerializedZodOutput(schema) {
|
|
675
|
+
return Function("z", `"use strict";return (${schema});`)(zod.z);
|
|
676
|
+
}
|
|
677
|
+
function isZodType(value) {
|
|
678
|
+
return typeof value === "object" && value !== null && "_def" in value && "parse" in value && typeof value.parse === "function" && "safeParse" in value && typeof value.safeParse === "function";
|
|
679
|
+
}
|
|
680
|
+
function createDeterministicId(input) {
|
|
681
|
+
return crypto$1.createHash("sha256").update(input).digest("hex").slice(0, 8);
|
|
682
|
+
}
|
|
683
|
+
function setVercelToolProperties(tool) {
|
|
684
|
+
const inputSchema = convertVercelToolParameters(tool);
|
|
685
|
+
const toolId = !("id" in tool) ? tool.description ? `tool-${createDeterministicId(tool.description)}` : `tool-${Math.random().toString(36).substring(2, 9)}` : tool.id;
|
|
686
|
+
return {
|
|
687
|
+
...tool,
|
|
688
|
+
id: toolId,
|
|
689
|
+
inputSchema
|
|
690
|
+
};
|
|
691
|
+
}
|
|
692
|
+
function ensureToolProperties(tools) {
|
|
693
|
+
const toolsWithProperties = Object.keys(tools).reduce((acc, key) => {
|
|
694
|
+
const tool = tools?.[key];
|
|
695
|
+
if (tool) {
|
|
696
|
+
if (chunkABRPHTOG_cjs.isVercelTool(tool)) {
|
|
697
|
+
acc[key] = setVercelToolProperties(tool);
|
|
698
|
+
} else {
|
|
699
|
+
acc[key] = tool;
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
return acc;
|
|
703
|
+
}, {});
|
|
704
|
+
return toolsWithProperties;
|
|
705
|
+
}
|
|
706
|
+
function convertVercelToolParameters(tool) {
|
|
707
|
+
const schema = tool.parameters ?? zod.z.object({});
|
|
708
|
+
return isZodType(schema) ? schema : resolveSerializedZodOutput(jsonSchemaToZod__default.default(schema));
|
|
709
|
+
}
|
|
710
|
+
function makeCoreTool(originalTool, options, logType) {
|
|
711
|
+
return new CoreToolBuilder({ originalTool, options, logType }).build();
|
|
712
|
+
}
|
|
713
|
+
function makeCoreToolV5(originalTool, options, logType) {
|
|
714
|
+
return new CoreToolBuilder({ originalTool, options, logType }).buildV5();
|
|
715
|
+
}
|
|
716
|
+
function createMastraProxy({ mastra, logger }) {
|
|
717
|
+
return new Proxy(mastra, {
|
|
718
|
+
get(target, prop) {
|
|
719
|
+
const hasProp = Reflect.has(target, prop);
|
|
720
|
+
if (hasProp) {
|
|
721
|
+
const value = Reflect.get(target, prop);
|
|
722
|
+
const isFunction = typeof value === "function";
|
|
723
|
+
if (isFunction) {
|
|
724
|
+
return value.bind(target);
|
|
725
|
+
}
|
|
726
|
+
return value;
|
|
727
|
+
}
|
|
728
|
+
if (prop === "logger") {
|
|
729
|
+
logger.warn(`Please use 'getLogger' instead, logger is deprecated`);
|
|
730
|
+
return Reflect.apply(target.getLogger, target, []);
|
|
731
|
+
}
|
|
732
|
+
if (prop === "telemetry") {
|
|
733
|
+
logger.warn(`Please use 'getTelemetry' instead, telemetry is deprecated`);
|
|
734
|
+
return Reflect.apply(target.getTelemetry, target, []);
|
|
735
|
+
}
|
|
736
|
+
if (prop === "storage") {
|
|
737
|
+
logger.warn(`Please use 'getStorage' instead, storage is deprecated`);
|
|
738
|
+
return Reflect.get(target, "storage");
|
|
739
|
+
}
|
|
740
|
+
if (prop === "agents") {
|
|
741
|
+
logger.warn(`Please use 'getAgents' instead, agents is deprecated`);
|
|
742
|
+
return Reflect.apply(target.getAgents, target, []);
|
|
743
|
+
}
|
|
744
|
+
if (prop === "tts") {
|
|
745
|
+
logger.warn(`Please use 'getTTS' instead, tts is deprecated`);
|
|
746
|
+
return Reflect.apply(target.getTTS, target, []);
|
|
747
|
+
}
|
|
748
|
+
if (prop === "vectors") {
|
|
749
|
+
logger.warn(`Please use 'getVectors' instead, vectors is deprecated`);
|
|
750
|
+
return Reflect.apply(target.getVectors, target, []);
|
|
751
|
+
}
|
|
752
|
+
if (prop === "memory") {
|
|
753
|
+
logger.warn(`Please use 'getMemory' instead, memory is deprecated`);
|
|
754
|
+
return Reflect.get(target, "memory");
|
|
755
|
+
}
|
|
756
|
+
return Reflect.get(target, prop);
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
function checkEvalStorageFields(traceObject, logger) {
|
|
761
|
+
const missingFields = [];
|
|
762
|
+
if (!traceObject.input) missingFields.push("input");
|
|
763
|
+
if (!traceObject.output) missingFields.push("output");
|
|
764
|
+
if (!traceObject.agentName) missingFields.push("agent_name");
|
|
765
|
+
if (!traceObject.metricName) missingFields.push("metric_name");
|
|
766
|
+
if (!traceObject.instructions) missingFields.push("instructions");
|
|
767
|
+
if (!traceObject.globalRunId) missingFields.push("global_run_id");
|
|
768
|
+
if (!traceObject.runId) missingFields.push("run_id");
|
|
769
|
+
if (missingFields.length > 0) {
|
|
770
|
+
if (logger) {
|
|
771
|
+
logger.warn("Skipping evaluation storage due to missing required fields", {
|
|
772
|
+
missingFields,
|
|
773
|
+
runId: traceObject.runId,
|
|
774
|
+
agentName: traceObject.agentName
|
|
775
|
+
});
|
|
776
|
+
} else {
|
|
777
|
+
console.warn("Skipping evaluation storage due to missing required fields", {
|
|
778
|
+
missingFields,
|
|
779
|
+
runId: traceObject.runId,
|
|
780
|
+
agentName: traceObject.agentName
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
return false;
|
|
784
|
+
}
|
|
785
|
+
return true;
|
|
786
|
+
}
|
|
787
|
+
function detectSingleMessageCharacteristics(message) {
|
|
788
|
+
if (typeof message === "object" && message !== null && (message.role === "function" || // UI-only role
|
|
789
|
+
message.role === "data" || // UI-only role
|
|
790
|
+
"toolInvocations" in message || // UI-specific field
|
|
791
|
+
"parts" in message || // UI-specific field
|
|
792
|
+
"experimental_attachments" in message)) {
|
|
793
|
+
return "has-ui-specific-parts";
|
|
794
|
+
} else if (typeof message === "object" && message !== null && "content" in message && (Array.isArray(message.content) || // Core messages can have array content
|
|
795
|
+
"experimental_providerMetadata" in message || "providerOptions" in message)) {
|
|
796
|
+
return "has-core-specific-parts";
|
|
797
|
+
} else if (typeof message === "object" && message !== null && "role" in message && "content" in message && typeof message.content === "string" && ["system", "user", "assistant", "tool"].includes(message.role)) {
|
|
798
|
+
return "message";
|
|
799
|
+
} else {
|
|
800
|
+
return "other";
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
function isUiMessage(message) {
|
|
804
|
+
return detectSingleMessageCharacteristics(message) === `has-ui-specific-parts`;
|
|
805
|
+
}
|
|
806
|
+
function isCoreMessage(message) {
|
|
807
|
+
return [`has-core-specific-parts`, `message`].includes(detectSingleMessageCharacteristics(message));
|
|
808
|
+
}
|
|
809
|
+
var SQL_IDENTIFIER_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
810
|
+
function parseSqlIdentifier(name, kind = "identifier") {
|
|
811
|
+
if (!SQL_IDENTIFIER_PATTERN.test(name) || name.length > 63) {
|
|
812
|
+
throw new Error(
|
|
813
|
+
`Invalid ${kind}: ${name}. Must start with a letter or underscore, contain only letters, numbers, or underscores, and be at most 63 characters long.`
|
|
814
|
+
);
|
|
815
|
+
}
|
|
816
|
+
return name;
|
|
817
|
+
}
|
|
818
|
+
function parseFieldKey(key) {
|
|
819
|
+
if (!key) throw new Error("Field key cannot be empty");
|
|
820
|
+
const segments = key.split(".");
|
|
821
|
+
for (const segment of segments) {
|
|
822
|
+
if (!SQL_IDENTIFIER_PATTERN.test(segment) || segment.length > 63) {
|
|
823
|
+
throw new Error(`Invalid field key segment: ${segment} in ${key}`);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
return key;
|
|
827
|
+
}
|
|
828
|
+
async function fetchWithRetry(url, options = {}, maxRetries = 3) {
|
|
829
|
+
let retryCount = 0;
|
|
830
|
+
let lastError = null;
|
|
831
|
+
while (retryCount < maxRetries) {
|
|
832
|
+
try {
|
|
833
|
+
const response = await fetch(url, options);
|
|
834
|
+
if (!response.ok) {
|
|
835
|
+
throw new Error(`Request failed with status: ${response.status} ${response.statusText}`);
|
|
836
|
+
}
|
|
837
|
+
return response;
|
|
838
|
+
} catch (error) {
|
|
839
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
840
|
+
retryCount++;
|
|
841
|
+
if (retryCount >= maxRetries) {
|
|
842
|
+
break;
|
|
843
|
+
}
|
|
844
|
+
const delay2 = Math.min(1e3 * Math.pow(2, retryCount) * 1e3, 1e4);
|
|
845
|
+
await new Promise((resolve) => setTimeout(resolve, delay2));
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
throw lastError || new Error("Request failed after multiple retry attempts");
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
// src/ai-tracing/exporters/cloud.ts
|
|
852
|
+
var CloudExporter = class {
|
|
853
|
+
name = "mastra-cloud-ai-tracing-exporter";
|
|
854
|
+
config;
|
|
855
|
+
buffer;
|
|
856
|
+
flushTimer = null;
|
|
857
|
+
logger;
|
|
858
|
+
isDisabled = false;
|
|
859
|
+
constructor(config = {}) {
|
|
860
|
+
this.logger = config.logger ?? new chunkV5WKCX3G_cjs.ConsoleLogger({ level: chunkV5WKCX3G_cjs.LogLevel.INFO });
|
|
861
|
+
const accessToken = config.accessToken ?? process.env.MASTRA_CLOUD_ACCESS_TOKEN;
|
|
862
|
+
if (!accessToken) {
|
|
863
|
+
this.logger.warn(
|
|
864
|
+
"CloudExporter disabled: MASTRA_CLOUD_ACCESS_TOKEN environment variable not set. \u{1F680} Sign up for Mastra Cloud at https://cloud.mastra.ai to see your AI traces online and obtain your access token."
|
|
865
|
+
);
|
|
866
|
+
this.isDisabled = true;
|
|
867
|
+
}
|
|
868
|
+
const endpoint = config.endpoint ?? process.env.MASTRA_CLOUD_AI_TRACES_ENDPOINT ?? "https://api.mastra.ai/ai/spans/publish";
|
|
869
|
+
this.config = {
|
|
870
|
+
maxBatchSize: config.maxBatchSize ?? 1e3,
|
|
871
|
+
maxBatchWaitMs: config.maxBatchWaitMs ?? 5e3,
|
|
872
|
+
maxRetries: config.maxRetries ?? 3,
|
|
873
|
+
accessToken: accessToken || "",
|
|
874
|
+
// Empty string if no token
|
|
875
|
+
endpoint,
|
|
876
|
+
logger: this.logger
|
|
877
|
+
};
|
|
878
|
+
this.buffer = {
|
|
879
|
+
spans: [],
|
|
880
|
+
totalSize: 0
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
async exportEvent(event) {
|
|
884
|
+
if (this.isDisabled) {
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
if (event.type !== "span_ended" /* SPAN_ENDED */) {
|
|
888
|
+
return;
|
|
889
|
+
}
|
|
890
|
+
this.addToBuffer(event);
|
|
891
|
+
if (this.shouldFlush()) {
|
|
892
|
+
this.flush().catch((error) => {
|
|
893
|
+
this.logger.error("Batch flush failed", {
|
|
894
|
+
error: error instanceof Error ? error.message : String(error)
|
|
895
|
+
});
|
|
896
|
+
});
|
|
897
|
+
} else if (this.buffer.totalSize === 1) {
|
|
898
|
+
this.scheduleFlush();
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
addToBuffer(event) {
|
|
902
|
+
if (this.buffer.totalSize === 0) {
|
|
903
|
+
this.buffer.firstEventTime = /* @__PURE__ */ new Date();
|
|
904
|
+
}
|
|
905
|
+
const spanRecord = this.formatSpan(event.span);
|
|
906
|
+
this.buffer.spans.push(spanRecord);
|
|
907
|
+
this.buffer.totalSize++;
|
|
908
|
+
}
|
|
909
|
+
formatSpan(span) {
|
|
910
|
+
const spanRecord = {
|
|
911
|
+
traceId: span.traceId,
|
|
912
|
+
spanId: span.id,
|
|
913
|
+
parentSpanId: span.parent?.id ?? null,
|
|
914
|
+
name: span.name,
|
|
915
|
+
spanType: span.type,
|
|
916
|
+
attributes: span.attributes ?? null,
|
|
917
|
+
metadata: span.metadata ?? null,
|
|
918
|
+
startedAt: span.startTime,
|
|
919
|
+
endedAt: span.endTime ?? null,
|
|
920
|
+
input: span.input ?? null,
|
|
921
|
+
output: span.output ?? null,
|
|
922
|
+
error: span.errorInfo,
|
|
923
|
+
isEvent: span.isEvent,
|
|
924
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
925
|
+
updatedAt: null
|
|
926
|
+
};
|
|
927
|
+
return spanRecord;
|
|
928
|
+
}
|
|
929
|
+
shouldFlush() {
|
|
930
|
+
if (this.buffer.totalSize >= this.config.maxBatchSize) {
|
|
931
|
+
return true;
|
|
932
|
+
}
|
|
933
|
+
if (this.buffer.firstEventTime && this.buffer.totalSize > 0) {
|
|
934
|
+
const elapsed = Date.now() - this.buffer.firstEventTime.getTime();
|
|
935
|
+
if (elapsed >= this.config.maxBatchWaitMs) {
|
|
936
|
+
return true;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
return false;
|
|
940
|
+
}
|
|
941
|
+
scheduleFlush() {
|
|
942
|
+
if (this.flushTimer) {
|
|
943
|
+
clearTimeout(this.flushTimer);
|
|
944
|
+
}
|
|
945
|
+
this.flushTimer = setTimeout(() => {
|
|
946
|
+
this.flush().catch((error) => {
|
|
947
|
+
const mastraError = new chunkC73WLCY3_cjs.MastraError(
|
|
948
|
+
{
|
|
949
|
+
id: `CLOUD_AI_TRACING_FAILED_TO_SCHEDULE_FLUSH`,
|
|
950
|
+
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
951
|
+
category: "USER" /* USER */
|
|
952
|
+
},
|
|
953
|
+
error
|
|
954
|
+
);
|
|
955
|
+
this.logger.trackException(mastraError);
|
|
956
|
+
this.logger.error("Scheduled flush failed", mastraError);
|
|
957
|
+
});
|
|
958
|
+
}, this.config.maxBatchWaitMs);
|
|
959
|
+
}
|
|
960
|
+
async flush() {
|
|
961
|
+
if (this.flushTimer) {
|
|
962
|
+
clearTimeout(this.flushTimer);
|
|
963
|
+
this.flushTimer = null;
|
|
964
|
+
}
|
|
965
|
+
if (this.buffer.totalSize === 0) {
|
|
966
|
+
return;
|
|
967
|
+
}
|
|
968
|
+
const startTime = Date.now();
|
|
969
|
+
const spansCopy = [...this.buffer.spans];
|
|
970
|
+
const flushReason = this.buffer.totalSize >= this.config.maxBatchSize ? "size" : "time";
|
|
971
|
+
this.resetBuffer();
|
|
972
|
+
try {
|
|
973
|
+
await this.batchUpload(spansCopy);
|
|
974
|
+
const elapsed = Date.now() - startTime;
|
|
975
|
+
this.logger.debug("Batch flushed successfully", {
|
|
976
|
+
batchSize: spansCopy.length,
|
|
977
|
+
flushReason,
|
|
978
|
+
durationMs: elapsed
|
|
979
|
+
});
|
|
980
|
+
} catch (error) {
|
|
981
|
+
const mastraError = new chunkC73WLCY3_cjs.MastraError(
|
|
982
|
+
{
|
|
983
|
+
id: `CLOUD_AI_TRACING_FAILED_TO_BATCH_UPLOAD`,
|
|
984
|
+
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
985
|
+
category: "USER" /* USER */,
|
|
986
|
+
details: {
|
|
987
|
+
droppedBatchSize: spansCopy.length
|
|
988
|
+
}
|
|
989
|
+
},
|
|
990
|
+
error
|
|
991
|
+
);
|
|
992
|
+
this.logger.trackException(mastraError);
|
|
993
|
+
this.logger.error("Batch upload failed after all retries, dropping batch", mastraError);
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* Uploads spans to cloud API using fetchWithRetry for all retry logic
|
|
998
|
+
*/
|
|
999
|
+
async batchUpload(spans) {
|
|
1000
|
+
const url = `${this.config.endpoint}`;
|
|
1001
|
+
const headers = {
|
|
1002
|
+
Authorization: `Bearer ${this.config.accessToken}`,
|
|
1003
|
+
"Content-Type": "application/json"
|
|
1004
|
+
};
|
|
1005
|
+
const options = {
|
|
1006
|
+
method: "POST",
|
|
1007
|
+
headers,
|
|
1008
|
+
body: JSON.stringify({ spans })
|
|
1009
|
+
};
|
|
1010
|
+
await fetchWithRetry(url, options, this.config.maxRetries);
|
|
1011
|
+
}
|
|
1012
|
+
resetBuffer() {
|
|
1013
|
+
this.buffer.spans = [];
|
|
1014
|
+
this.buffer.firstEventTime = void 0;
|
|
1015
|
+
this.buffer.totalSize = 0;
|
|
1016
|
+
}
|
|
1017
|
+
async shutdown() {
|
|
1018
|
+
if (this.isDisabled) {
|
|
1019
|
+
return;
|
|
1020
|
+
}
|
|
1021
|
+
if (this.flushTimer) {
|
|
1022
|
+
clearTimeout(this.flushTimer);
|
|
1023
|
+
this.flushTimer = null;
|
|
1024
|
+
}
|
|
1025
|
+
if (this.buffer.totalSize > 0) {
|
|
1026
|
+
this.logger.info("Flushing remaining events on shutdown", {
|
|
1027
|
+
remainingEvents: this.buffer.totalSize
|
|
1028
|
+
});
|
|
1029
|
+
try {
|
|
1030
|
+
await this.flush();
|
|
1031
|
+
} catch (error) {
|
|
1032
|
+
const mastraError = new chunkC73WLCY3_cjs.MastraError(
|
|
1033
|
+
{
|
|
1034
|
+
id: `CLOUD_AI_TRACING_FAILED_TO_FLUSH_REMAINING_EVENTS_DURING_SHUTDOWN`,
|
|
1035
|
+
domain: "MASTRA_OBSERVABILITY" /* MASTRA_OBSERVABILITY */,
|
|
1036
|
+
category: "USER" /* USER */,
|
|
1037
|
+
details: {
|
|
1038
|
+
remainingEvents: this.buffer.totalSize
|
|
1039
|
+
}
|
|
1040
|
+
},
|
|
1041
|
+
error
|
|
1042
|
+
);
|
|
1043
|
+
this.logger.trackException(mastraError);
|
|
1044
|
+
this.logger.error("Failed to flush remaining events during shutdown", mastraError);
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
this.logger.info("CloudExporter shutdown complete");
|
|
1048
|
+
}
|
|
1049
|
+
};
|
|
316
1050
|
|
|
317
1051
|
// src/ai-tracing/exporters/console.ts
|
|
318
1052
|
var ConsoleExporter = class {
|
|
@@ -465,7 +1199,8 @@ var DefaultExporter = class {
|
|
|
465
1199
|
}
|
|
466
1200
|
const storage = this.mastra.getStorage();
|
|
467
1201
|
if (!storage) {
|
|
468
|
-
|
|
1202
|
+
this.logger.warn("DefaultExporter disabled: Storage not available. Traces will not be persisted.");
|
|
1203
|
+
return;
|
|
469
1204
|
}
|
|
470
1205
|
this.initializeStrategy(storage);
|
|
471
1206
|
}
|
|
@@ -781,12 +1516,12 @@ var DefaultExporter = class {
|
|
|
781
1516
|
*/
|
|
782
1517
|
async flush() {
|
|
783
1518
|
if (!this.mastra) {
|
|
784
|
-
this.logger.
|
|
1519
|
+
this.logger.debug("Cannot flush traces. Mastra instance not registered yet.");
|
|
785
1520
|
return;
|
|
786
1521
|
}
|
|
787
1522
|
const storage = this.mastra.getStorage();
|
|
788
1523
|
if (!storage) {
|
|
789
|
-
this.logger.
|
|
1524
|
+
this.logger.debug("Cannot flush traces. Mastra storage is not initialized");
|
|
790
1525
|
return;
|
|
791
1526
|
}
|
|
792
1527
|
if (this.flushTimer) {
|
|
@@ -866,12 +1601,12 @@ var DefaultExporter = class {
|
|
|
866
1601
|
}
|
|
867
1602
|
async exportEvent(event) {
|
|
868
1603
|
if (!this.mastra) {
|
|
869
|
-
this.logger.
|
|
1604
|
+
this.logger.debug("Cannot export AI tracing event. Mastra instance not registered yet.");
|
|
870
1605
|
return;
|
|
871
1606
|
}
|
|
872
1607
|
const storage = this.mastra.getStorage();
|
|
873
1608
|
if (!storage) {
|
|
874
|
-
this.logger.
|
|
1609
|
+
this.logger.debug("Cannot store traces. Mastra storage is not initialized");
|
|
875
1610
|
return;
|
|
876
1611
|
}
|
|
877
1612
|
if (!this.strategyInitialized) {
|
|
@@ -1025,59 +1760,77 @@ function isAITracingInstance(obj) {
|
|
|
1025
1760
|
return obj instanceof MastraAITracing;
|
|
1026
1761
|
}
|
|
1027
1762
|
function setupAITracing(config) {
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1763
|
+
if (!config) {
|
|
1764
|
+
return;
|
|
1765
|
+
}
|
|
1766
|
+
if (config.default?.enabled && config.configs?.["default"]) {
|
|
1767
|
+
throw new Error(
|
|
1768
|
+
"Cannot use 'default' as a custom config name when default tracing is enabled. Please rename your custom config to avoid conflicts."
|
|
1769
|
+
);
|
|
1770
|
+
}
|
|
1771
|
+
if (config.default?.enabled) {
|
|
1772
|
+
const defaultInstance = new DefaultAITracing({
|
|
1773
|
+
serviceName: "mastra",
|
|
1774
|
+
name: "default",
|
|
1775
|
+
sampling: { type: "always" /* ALWAYS */ },
|
|
1776
|
+
exporters: [new DefaultExporter(), new CloudExporter()],
|
|
1777
|
+
processors: [new SensitiveDataFilter()]
|
|
1778
|
+
});
|
|
1779
|
+
registerAITracing("default", defaultInstance, true);
|
|
1780
|
+
}
|
|
1781
|
+
if (config.configs) {
|
|
1782
|
+
const instances = Object.entries(config.configs);
|
|
1783
|
+
instances.forEach(([name, tracingDef], index) => {
|
|
1784
|
+
const instance = isAITracingInstance(tracingDef) ? tracingDef : new DefaultAITracing({ ...tracingDef, name });
|
|
1785
|
+
const isDefault = !config.default?.enabled && index === 0;
|
|
1786
|
+
registerAITracing(name, instance, isDefault);
|
|
1787
|
+
});
|
|
1788
|
+
}
|
|
1789
|
+
if (config.configSelector) {
|
|
1790
|
+
setAITracingSelector(config.configSelector);
|
|
1036
1791
|
}
|
|
1037
1792
|
}
|
|
1038
1793
|
|
|
1039
1794
|
// src/ai-tracing/utils.ts
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1795
|
+
var DEFAULT_KEYS_TO_STRIP = /* @__PURE__ */ new Set([
|
|
1796
|
+
"logger",
|
|
1797
|
+
"experimental_providerMetadata",
|
|
1798
|
+
"providerMetadata",
|
|
1799
|
+
"steps",
|
|
1800
|
+
"tracingContext"
|
|
1801
|
+
]);
|
|
1802
|
+
function deepClean(value, options = {}, _seen = /* @__PURE__ */ new WeakSet(), _depth = 0) {
|
|
1803
|
+
const { keysToStrip = DEFAULT_KEYS_TO_STRIP, maxDepth = 10 } = options;
|
|
1804
|
+
if (_depth > maxDepth) {
|
|
1805
|
+
return "[MaxDepth]";
|
|
1806
|
+
}
|
|
1807
|
+
if (value === null || typeof value !== "object") {
|
|
1043
1808
|
try {
|
|
1044
1809
|
JSON.stringify(value);
|
|
1045
|
-
|
|
1810
|
+
return value;
|
|
1046
1811
|
} catch (error) {
|
|
1047
|
-
|
|
1812
|
+
return `[${error instanceof Error ? error.message : String(error)}]`;
|
|
1048
1813
|
}
|
|
1049
1814
|
}
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1815
|
+
if (_seen.has(value)) {
|
|
1816
|
+
return "[Circular]";
|
|
1817
|
+
}
|
|
1818
|
+
_seen.add(value);
|
|
1819
|
+
if (Array.isArray(value)) {
|
|
1820
|
+
return value.map((item) => deepClean(item, options, _seen, _depth + 1));
|
|
1821
|
+
}
|
|
1822
|
+
const cleaned = {};
|
|
1823
|
+
for (const [key, val] of Object.entries(value)) {
|
|
1824
|
+
if (keysToStrip.has(key)) {
|
|
1825
|
+
continue;
|
|
1056
1826
|
}
|
|
1057
1827
|
try {
|
|
1058
|
-
|
|
1059
|
-
return item;
|
|
1828
|
+
cleaned[key] = deepClean(val, options, _seen, _depth + 1);
|
|
1060
1829
|
} catch (error) {
|
|
1061
|
-
|
|
1830
|
+
cleaned[key] = `[${error instanceof Error ? error.message : String(error)}]`;
|
|
1062
1831
|
}
|
|
1063
|
-
});
|
|
1064
|
-
}
|
|
1065
|
-
function shallowClean(value) {
|
|
1066
|
-
if (value === null || value === void 0) {
|
|
1067
|
-
return value;
|
|
1068
|
-
}
|
|
1069
|
-
if (Array.isArray(value)) {
|
|
1070
|
-
return shallowCleanArray(value);
|
|
1071
|
-
}
|
|
1072
|
-
if (typeof value === "object") {
|
|
1073
|
-
return shallowCleanObject(value);
|
|
1074
|
-
}
|
|
1075
|
-
try {
|
|
1076
|
-
JSON.stringify(value);
|
|
1077
|
-
return value;
|
|
1078
|
-
} catch (error) {
|
|
1079
|
-
return `[${error instanceof Error ? error.message : String(error)}]`;
|
|
1080
1832
|
}
|
|
1833
|
+
return cleaned;
|
|
1081
1834
|
}
|
|
1082
1835
|
function omitKeys(obj, keysToOmit) {
|
|
1083
1836
|
return Object.fromEntries(Object.entries(obj).filter(([key]) => !keysToOmit.includes(key)));
|
|
@@ -1115,12 +1868,17 @@ function setNestedValue(obj, path, value) {
|
|
|
1115
1868
|
target[lastKey] = value;
|
|
1116
1869
|
}
|
|
1117
1870
|
function getOrCreateSpan(options) {
|
|
1118
|
-
const { type, attributes, tracingContext, runtimeContext, ...rest } = options;
|
|
1871
|
+
const { type, attributes, tracingContext, tracingOptions, runtimeContext, ...rest } = options;
|
|
1872
|
+
const metadata = {
|
|
1873
|
+
...rest.metadata ?? {},
|
|
1874
|
+
...tracingOptions?.metadata ?? {}
|
|
1875
|
+
};
|
|
1119
1876
|
if (tracingContext?.currentSpan) {
|
|
1120
1877
|
return tracingContext.currentSpan.createChildSpan({
|
|
1121
1878
|
type,
|
|
1122
1879
|
attributes,
|
|
1123
|
-
...rest
|
|
1880
|
+
...rest,
|
|
1881
|
+
metadata
|
|
1124
1882
|
});
|
|
1125
1883
|
}
|
|
1126
1884
|
const aiTracing = getSelectedAITracing({
|
|
@@ -1132,9 +1890,13 @@ function getOrCreateSpan(options) {
|
|
|
1132
1890
|
startOptions: {
|
|
1133
1891
|
runtimeContext
|
|
1134
1892
|
},
|
|
1135
|
-
...rest
|
|
1893
|
+
...rest,
|
|
1894
|
+
metadata
|
|
1136
1895
|
});
|
|
1137
1896
|
}
|
|
1897
|
+
function getValidTraceId(span) {
|
|
1898
|
+
return span?.isValid ? span.traceId : void 0;
|
|
1899
|
+
}
|
|
1138
1900
|
|
|
1139
1901
|
// src/ai-tracing/default.ts
|
|
1140
1902
|
function generateSpanId() {
|
|
@@ -1174,51 +1936,43 @@ var DefaultAISpan = class {
|
|
|
1174
1936
|
output;
|
|
1175
1937
|
errorInfo;
|
|
1176
1938
|
metadata;
|
|
1177
|
-
logger;
|
|
1178
1939
|
constructor(options, aiTracing) {
|
|
1179
1940
|
this.id = generateSpanId();
|
|
1180
1941
|
this.name = options.name;
|
|
1181
1942
|
this.type = options.type;
|
|
1182
|
-
this.attributes =
|
|
1183
|
-
this.metadata =
|
|
1943
|
+
this.attributes = deepClean(options.attributes) || {};
|
|
1944
|
+
this.metadata = deepClean(options.metadata);
|
|
1184
1945
|
this.parent = options.parent;
|
|
1185
1946
|
this.startTime = /* @__PURE__ */ new Date();
|
|
1186
1947
|
this.aiTracing = aiTracing;
|
|
1187
|
-
this.input =
|
|
1948
|
+
this.input = deepClean(options.input);
|
|
1188
1949
|
this.isEvent = options.isEvent;
|
|
1189
|
-
this.logger = new chunkV5WKCX3G_cjs.ConsoleLogger({
|
|
1190
|
-
name: "default-ai-span",
|
|
1191
|
-
level: chunkV5WKCX3G_cjs.LogLevel.INFO
|
|
1192
|
-
// Set to INFO so that info() calls actually log
|
|
1193
|
-
});
|
|
1194
1950
|
if (!options.parent) {
|
|
1195
1951
|
this.traceId = generateTraceId();
|
|
1196
1952
|
} else {
|
|
1197
1953
|
this.traceId = options.parent.traceId;
|
|
1198
1954
|
}
|
|
1199
1955
|
if (this.isEvent) {
|
|
1200
|
-
this.output =
|
|
1956
|
+
this.output = deepClean(options.output);
|
|
1201
1957
|
}
|
|
1202
1958
|
}
|
|
1203
1959
|
end(options) {
|
|
1204
1960
|
if (this.isEvent) {
|
|
1205
|
-
this.logger.warn(`End event is not available on event spans`);
|
|
1206
1961
|
return;
|
|
1207
1962
|
}
|
|
1208
1963
|
this.endTime = /* @__PURE__ */ new Date();
|
|
1209
1964
|
if (options?.output !== void 0) {
|
|
1210
|
-
this.output =
|
|
1965
|
+
this.output = deepClean(options.output);
|
|
1211
1966
|
}
|
|
1212
1967
|
if (options?.attributes) {
|
|
1213
|
-
this.attributes = { ...this.attributes, ...
|
|
1968
|
+
this.attributes = { ...this.attributes, ...deepClean(options.attributes) };
|
|
1214
1969
|
}
|
|
1215
1970
|
if (options?.metadata) {
|
|
1216
|
-
this.metadata = { ...this.metadata, ...
|
|
1971
|
+
this.metadata = { ...this.metadata, ...deepClean(options.metadata) };
|
|
1217
1972
|
}
|
|
1218
1973
|
}
|
|
1219
1974
|
error(options) {
|
|
1220
1975
|
if (this.isEvent) {
|
|
1221
|
-
this.logger.warn(`Error event is not available on event spans`);
|
|
1222
1976
|
return;
|
|
1223
1977
|
}
|
|
1224
1978
|
const { error, endSpan = true, attributes, metadata } = options;
|
|
@@ -1232,10 +1986,10 @@ var DefaultAISpan = class {
|
|
|
1232
1986
|
message: error.message
|
|
1233
1987
|
};
|
|
1234
1988
|
if (attributes) {
|
|
1235
|
-
this.attributes = { ...this.attributes, ...
|
|
1989
|
+
this.attributes = { ...this.attributes, ...deepClean(attributes) };
|
|
1236
1990
|
}
|
|
1237
1991
|
if (metadata) {
|
|
1238
|
-
this.metadata = { ...this.metadata, ...
|
|
1992
|
+
this.metadata = { ...this.metadata, ...deepClean(metadata) };
|
|
1239
1993
|
}
|
|
1240
1994
|
if (endSpan) {
|
|
1241
1995
|
this.end();
|
|
@@ -1259,25 +2013,27 @@ var DefaultAISpan = class {
|
|
|
1259
2013
|
}
|
|
1260
2014
|
update(options) {
|
|
1261
2015
|
if (this.isEvent) {
|
|
1262
|
-
this.logger.warn(`Update() is not available on event spans`);
|
|
1263
2016
|
return;
|
|
1264
2017
|
}
|
|
1265
2018
|
if (options?.input !== void 0) {
|
|
1266
|
-
this.input =
|
|
2019
|
+
this.input = deepClean(options.input);
|
|
1267
2020
|
}
|
|
1268
2021
|
if (options?.output !== void 0) {
|
|
1269
|
-
this.output =
|
|
2022
|
+
this.output = deepClean(options.output);
|
|
1270
2023
|
}
|
|
1271
2024
|
if (options?.attributes) {
|
|
1272
|
-
this.attributes = { ...this.attributes, ...
|
|
2025
|
+
this.attributes = { ...this.attributes, ...deepClean(options.attributes) };
|
|
1273
2026
|
}
|
|
1274
2027
|
if (options?.metadata) {
|
|
1275
|
-
this.metadata = { ...this.metadata, ...
|
|
2028
|
+
this.metadata = { ...this.metadata, ...deepClean(options.metadata) };
|
|
1276
2029
|
}
|
|
1277
2030
|
}
|
|
1278
2031
|
get isRootSpan() {
|
|
1279
2032
|
return !this.parent;
|
|
1280
2033
|
}
|
|
2034
|
+
get isValid() {
|
|
2035
|
+
return true;
|
|
2036
|
+
}
|
|
1281
2037
|
async export() {
|
|
1282
2038
|
return JSON.stringify({
|
|
1283
2039
|
id: this.id,
|
|
@@ -1354,16 +2110,13 @@ var SensitiveDataFilter = class {
|
|
|
1354
2110
|
async shutdown() {
|
|
1355
2111
|
}
|
|
1356
2112
|
};
|
|
1357
|
-
var aiTracingDefaultConfig = {
|
|
1358
|
-
serviceName: "mastra-ai-service",
|
|
1359
|
-
instanceName: "default",
|
|
1360
|
-
sampling: { type: "always" /* ALWAYS */ },
|
|
1361
|
-
exporters: [new ConsoleExporter()],
|
|
1362
|
-
processors: [new SensitiveDataFilter()]
|
|
1363
|
-
};
|
|
1364
2113
|
var DefaultAITracing = class extends MastraAITracing {
|
|
1365
|
-
constructor(config
|
|
1366
|
-
|
|
2114
|
+
constructor(config) {
|
|
2115
|
+
const configWithDefaults = {
|
|
2116
|
+
...config,
|
|
2117
|
+
exporters: config.exporters?.length ? config.exporters : [new ConsoleExporter()]
|
|
2118
|
+
};
|
|
2119
|
+
super(configWithDefaults);
|
|
1367
2120
|
}
|
|
1368
2121
|
// ============================================================================
|
|
1369
2122
|
// Abstract Method Implementations
|
|
@@ -1379,7 +2132,7 @@ var AGENT_METHODS_TO_WRAP = ["generate", "stream", "generateVNext", "streamVNext
|
|
|
1379
2132
|
var WORKFLOW_GETTERS = ["getWorkflow", "getWorkflowById"];
|
|
1380
2133
|
var WORKFLOW_METHODS_TO_WRAP = ["execute", "createRun", "createRunAsync"];
|
|
1381
2134
|
function isNoOpSpan(span) {
|
|
1382
|
-
return span.constructor.name === "NoOpAISpan" || span.__isNoOp === true
|
|
2135
|
+
return span.constructor.name === "NoOpAISpan" || span.__isNoOp === true;
|
|
1383
2136
|
}
|
|
1384
2137
|
function isMastra(mastra) {
|
|
1385
2138
|
const hasAgentGetters = AGENT_GETTERS.every((method) => typeof mastra?.[method] === "function");
|
|
@@ -1522,31 +2275,46 @@ function wrapRun(run, tracingContext) {
|
|
|
1522
2275
|
|
|
1523
2276
|
exports.AISpanType = AISpanType;
|
|
1524
2277
|
exports.AITracingEventType = AITracingEventType;
|
|
2278
|
+
exports.CloudExporter = CloudExporter;
|
|
1525
2279
|
exports.ConsoleExporter = ConsoleExporter;
|
|
1526
2280
|
exports.DefaultAITracing = DefaultAITracing;
|
|
1527
2281
|
exports.DefaultExporter = DefaultExporter;
|
|
1528
2282
|
exports.MastraAITracing = MastraAITracing;
|
|
1529
2283
|
exports.SamplingStrategyType = SamplingStrategyType;
|
|
1530
2284
|
exports.SensitiveDataFilter = SensitiveDataFilter;
|
|
1531
|
-
exports.
|
|
2285
|
+
exports.checkEvalStorageFields = checkEvalStorageFields;
|
|
1532
2286
|
exports.clearAITracingRegistry = clearAITracingRegistry;
|
|
2287
|
+
exports.createMastraProxy = createMastraProxy;
|
|
2288
|
+
exports.deepClean = deepClean;
|
|
2289
|
+
exports.deepMerge = deepMerge;
|
|
2290
|
+
exports.delay = delay;
|
|
2291
|
+
exports.ensureToolProperties = ensureToolProperties;
|
|
2292
|
+
exports.fetchWithRetry = fetchWithRetry;
|
|
2293
|
+
exports.generateEmptyFromSchema = generateEmptyFromSchema;
|
|
1533
2294
|
exports.getAITracing = getAITracing;
|
|
1534
2295
|
exports.getAllAITracing = getAllAITracing;
|
|
1535
2296
|
exports.getDefaultAITracing = getDefaultAITracing;
|
|
1536
2297
|
exports.getOrCreateSpan = getOrCreateSpan;
|
|
1537
2298
|
exports.getSelectedAITracing = getSelectedAITracing;
|
|
2299
|
+
exports.getValidTraceId = getValidTraceId;
|
|
1538
2300
|
exports.hasAITracing = hasAITracing;
|
|
2301
|
+
exports.isCoreMessage = isCoreMessage;
|
|
1539
2302
|
exports.isMastra = isMastra;
|
|
2303
|
+
exports.isUiMessage = isUiMessage;
|
|
2304
|
+
exports.isZodType = isZodType;
|
|
2305
|
+
exports.makeCoreTool = makeCoreTool;
|
|
2306
|
+
exports.makeCoreToolV5 = makeCoreToolV5;
|
|
2307
|
+
exports.maskStreamTags = maskStreamTags;
|
|
1540
2308
|
exports.omitKeys = omitKeys;
|
|
2309
|
+
exports.parseFieldKey = parseFieldKey;
|
|
2310
|
+
exports.parseSqlIdentifier = parseSqlIdentifier;
|
|
1541
2311
|
exports.registerAITracing = registerAITracing;
|
|
2312
|
+
exports.resolveSerializedZodOutput = resolveSerializedZodOutput;
|
|
1542
2313
|
exports.selectFields = selectFields;
|
|
1543
2314
|
exports.setAITracingSelector = setAITracingSelector;
|
|
1544
2315
|
exports.setupAITracing = setupAITracing;
|
|
1545
|
-
exports.shallowClean = shallowClean;
|
|
1546
|
-
exports.shallowCleanArray = shallowCleanArray;
|
|
1547
|
-
exports.shallowCleanObject = shallowCleanObject;
|
|
1548
2316
|
exports.shutdownAITracingRegistry = shutdownAITracingRegistry;
|
|
1549
2317
|
exports.unregisterAITracing = unregisterAITracing;
|
|
1550
2318
|
exports.wrapMastra = wrapMastra;
|
|
1551
|
-
//# sourceMappingURL=chunk-
|
|
1552
|
-
//# sourceMappingURL=chunk-
|
|
2319
|
+
//# sourceMappingURL=chunk-VVUCWRGD.cjs.map
|
|
2320
|
+
//# sourceMappingURL=chunk-VVUCWRGD.cjs.map
|