@mastra/core 0.10.11-alpha.1 → 0.10.11-alpha.3
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 +4 -4
- package/dist/agent/index.d.cts +1 -1
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.js +2 -2
- package/dist/{base-CDtRsAmk.d.ts → base-BBkhRGjp.d.ts} +1 -0
- package/dist/{base-WzKVgsC3.d.cts → base-DpaaEQWN.d.cts} +1 -0
- package/dist/{chunk-KEQ2YD65.cjs → chunk-2GRYVZ2O.cjs} +2 -2
- package/dist/{chunk-DPPWAOCI.js → chunk-4UBOJFSL.js} +24 -61
- package/dist/{chunk-RLK4L7YK.cjs → chunk-FL4BYLDK.cjs} +21 -4
- package/dist/{chunk-OEYYMXRD.js → chunk-QO6F3HHE.js} +1 -1
- package/dist/{chunk-N2LZKFEP.cjs → chunk-QUSEDVYI.cjs} +23 -60
- package/dist/{chunk-QA6VZ6JZ.js → chunk-VG4OPO2R.js} +1 -1
- package/dist/{chunk-LILRY4UH.js → chunk-VNEHTPHO.js} +20 -3
- package/dist/{chunk-GCB3FMQA.cjs → chunk-WTC6DJHD.cjs} +10 -10
- package/dist/{chunk-W3OZTB37.js → chunk-XR7OX4ZC.js} +1 -1
- package/dist/{chunk-CVOB5DQ2.cjs → chunk-ZJSVUBYU.cjs} +2 -2
- package/dist/eval/index.d.cts +1 -1
- package/dist/eval/index.d.ts +1 -1
- package/dist/index.cjs +20 -20
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -6
- package/dist/integration/index.d.cts +1 -1
- package/dist/integration/index.d.ts +1 -1
- package/dist/llm/index.d.cts +1 -1
- package/dist/llm/index.d.ts +1 -1
- package/dist/mastra/index.d.cts +1 -1
- package/dist/mastra/index.d.ts +1 -1
- package/dist/mcp/index.d.cts +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/memory/index.cjs +4 -4
- package/dist/memory/index.d.cts +1 -1
- package/dist/memory/index.d.ts +1 -1
- package/dist/memory/index.js +1 -1
- package/dist/network/index.cjs +2 -2
- package/dist/network/index.d.cts +1 -1
- package/dist/network/index.d.ts +1 -1
- package/dist/network/index.js +1 -1
- package/dist/network/vNext/index.cjs +13 -13
- package/dist/network/vNext/index.d.cts +1 -1
- package/dist/network/vNext/index.d.ts +1 -1
- package/dist/network/vNext/index.js +2 -2
- package/dist/relevance/index.cjs +4 -4
- package/dist/relevance/index.d.cts +1 -1
- package/dist/relevance/index.d.ts +1 -1
- package/dist/relevance/index.js +1 -1
- package/dist/server/index.d.cts +2 -2
- package/dist/server/index.d.ts +2 -2
- package/dist/storage/index.cjs +2 -2
- package/dist/storage/index.d.cts +2 -2
- package/dist/storage/index.d.ts +2 -2
- package/dist/storage/index.js +1 -1
- package/dist/telemetry/index.d.cts +1 -1
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/tools/index.d.cts +2 -2
- package/dist/tools/index.d.ts +2 -2
- package/dist/utils.d.cts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/voice/index.d.cts +1 -1
- package/dist/voice/index.d.ts +1 -1
- package/dist/workflows/index.cjs +10 -10
- package/dist/workflows/index.d.cts +2 -2
- package/dist/workflows/index.d.ts +2 -2
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/legacy/index.cjs +22 -22
- package/dist/workflows/legacy/index.d.cts +2 -2
- package/dist/workflows/legacy/index.d.ts +2 -2
- package/dist/workflows/legacy/index.js +1 -1
- package/package.json +4 -4
package/dist/agent/index.cjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkWTC6DJHD_cjs = require('../chunk-WTC6DJHD.cjs');
|
|
4
|
+
var chunkQUSEDVYI_cjs = require('../chunk-QUSEDVYI.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "Agent", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkWTC6DJHD_cjs.Agent; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "MessageList", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkQUSEDVYI_cjs.MessageList; }
|
|
15
15
|
});
|
package/dist/agent/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { Message as AiMessageType } from 'ai';
|
|
2
2
|
import 'json-schema';
|
|
3
3
|
import 'zod';
|
|
4
|
-
export { A as Agent, av as AgentConfig, c6 as AgentGenerateOptions, c5 as AgentMemoryOption, c7 as AgentStreamOptions, aZ as DynamicArgument, aY as MastraLanguageModel, c8 as MastraMessageContentV2, t as MastraMessageV2, c3 as MessageList, T as ToolsInput, c4 as ToolsetsInput } from '../base-
|
|
4
|
+
export { A as Agent, av as AgentConfig, c6 as AgentGenerateOptions, c5 as AgentMemoryOption, c7 as AgentStreamOptions, aZ as DynamicArgument, aY as MastraLanguageModel, c8 as MastraMessageContentV2, t as MastraMessageV2, c3 as MessageList, T as ToolsInput, c4 as ToolsetsInput } from '../base-DpaaEQWN.cjs';
|
|
5
5
|
import '../base-B_y9sMg0.cjs';
|
|
6
6
|
import '../types-Bo1uigWx.cjs';
|
|
7
7
|
import '../runtime-context/index.cjs';
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { Message as AiMessageType } from 'ai';
|
|
2
2
|
import 'json-schema';
|
|
3
3
|
import 'zod';
|
|
4
|
-
export { A as Agent, av as AgentConfig, c6 as AgentGenerateOptions, c5 as AgentMemoryOption, c7 as AgentStreamOptions, aZ as DynamicArgument, aY as MastraLanguageModel, c8 as MastraMessageContentV2, t as MastraMessageV2, c3 as MessageList, T as ToolsInput, c4 as ToolsetsInput } from '../base-
|
|
4
|
+
export { A as Agent, av as AgentConfig, c6 as AgentGenerateOptions, c5 as AgentMemoryOption, c7 as AgentStreamOptions, aZ as DynamicArgument, aY as MastraLanguageModel, c8 as MastraMessageContentV2, t as MastraMessageV2, c3 as MessageList, T as ToolsInput, c4 as ToolsetsInput } from '../base-BBkhRGjp.js';
|
|
5
5
|
import '../base-ClrXcCRx.js';
|
|
6
6
|
import '../types-Bo1uigWx.js';
|
|
7
7
|
import '../runtime-context/index.js';
|
package/dist/agent/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Agent } from '../chunk-
|
|
2
|
-
export { MessageList } from '../chunk-
|
|
1
|
+
export { Agent } from '../chunk-XR7OX4ZC.js';
|
|
2
|
+
export { MessageList } from '../chunk-4UBOJFSL.js';
|
|
@@ -1497,6 +1497,7 @@ declare function createStep<TStepId extends string, TStepInput extends z.ZodType
|
|
|
1497
1497
|
outputSchema: TStepOutput;
|
|
1498
1498
|
resumeSchema?: TResumeSchema;
|
|
1499
1499
|
suspendSchema?: TSuspendSchema;
|
|
1500
|
+
retries?: number;
|
|
1500
1501
|
execute: ExecuteFunction<z.infer<TStepInput>, z.infer<TStepOutput>, z.infer<TResumeSchema>, z.infer<TSuspendSchema>, DefaultEngineType>;
|
|
1501
1502
|
}): Step<TStepId, TStepInput, TStepOutput, TResumeSchema, TSuspendSchema, DefaultEngineType>;
|
|
1502
1503
|
declare function createStep<TStepId extends string, TStepInput extends z.ZodObject<{
|
|
@@ -1497,6 +1497,7 @@ declare function createStep<TStepId extends string, TStepInput extends z.ZodType
|
|
|
1497
1497
|
outputSchema: TStepOutput;
|
|
1498
1498
|
resumeSchema?: TResumeSchema;
|
|
1499
1499
|
suspendSchema?: TSuspendSchema;
|
|
1500
|
+
retries?: number;
|
|
1500
1501
|
execute: ExecuteFunction<z.infer<TStepInput>, z.infer<TStepOutput>, z.infer<TResumeSchema>, z.infer<TSuspendSchema>, DefaultEngineType>;
|
|
1501
1502
|
}): Step<TStepId, TStepInput, TStepOutput, TResumeSchema, TSuspendSchema, DefaultEngineType>;
|
|
1502
1503
|
declare function createStep<TStepId extends string, TStepInput extends z.ZodObject<{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkLXFZUKP3_cjs = require('./chunk-LXFZUKP3.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunkQUSEDVYI_cjs = require('./chunk-QUSEDVYI.cjs');
|
|
5
5
|
var chunk7F6BQXE2_cjs = require('./chunk-7F6BQXE2.cjs');
|
|
6
6
|
var chunkP3Q73CAW_cjs = require('./chunk-P3Q73CAW.cjs');
|
|
7
7
|
|
|
@@ -227,7 +227,7 @@ https://mastra.ai/en/docs/memory/overview`
|
|
|
227
227
|
toolCallIds
|
|
228
228
|
};
|
|
229
229
|
const savedMessages = await this.saveMessages({ messages: [message], memoryConfig: config });
|
|
230
|
-
const list = new
|
|
230
|
+
const list = new chunkQUSEDVYI_cjs.MessageList({ threadId, resourceId }).add(savedMessages[0], "memory");
|
|
231
231
|
return list.get.all.v1()[0];
|
|
232
232
|
}
|
|
233
233
|
/**
|
|
@@ -2,54 +2,9 @@ import { isUiMessage, isCoreMessage } from './chunk-DFFVEKIG.js';
|
|
|
2
2
|
import { MastraError } from './chunk-6UNGH46J.js';
|
|
3
3
|
import { randomUUID } from 'crypto';
|
|
4
4
|
import { convertToCoreMessages } from 'ai';
|
|
5
|
-
import { convertUint8ArrayToBase64
|
|
5
|
+
import { convertUint8ArrayToBase64 } from '@ai-sdk/provider-utils';
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
|
|
8
|
-
z.union([
|
|
9
|
-
z.string(),
|
|
10
|
-
z.instanceof(Uint8Array),
|
|
11
|
-
z.instanceof(ArrayBuffer),
|
|
12
|
-
z.custom(
|
|
13
|
-
// Buffer might not be available in some environments such as CloudFlare:
|
|
14
|
-
(value) => globalThis.Buffer?.isBuffer(value) ?? false,
|
|
15
|
-
{ message: "Must be a Buffer" }
|
|
16
|
-
)
|
|
17
|
-
]);
|
|
18
|
-
function convertDataContentToBase64String(content) {
|
|
19
|
-
if (typeof content === "string") {
|
|
20
|
-
return content;
|
|
21
|
-
}
|
|
22
|
-
if (content instanceof ArrayBuffer) {
|
|
23
|
-
return convertUint8ArrayToBase64(new Uint8Array(content));
|
|
24
|
-
}
|
|
25
|
-
return convertUint8ArrayToBase64(content);
|
|
26
|
-
}
|
|
27
|
-
function convertDataContentToUint8Array(content) {
|
|
28
|
-
if (content instanceof Uint8Array) {
|
|
29
|
-
return content;
|
|
30
|
-
}
|
|
31
|
-
if (typeof content === "string") {
|
|
32
|
-
try {
|
|
33
|
-
return convertBase64ToUint8Array(content);
|
|
34
|
-
} catch (error) {
|
|
35
|
-
throw new Error("Invalid data content. Content string is not a base64-encoded media.", {
|
|
36
|
-
cause: error
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
if (content instanceof ArrayBuffer) {
|
|
41
|
-
return new Uint8Array(content);
|
|
42
|
-
}
|
|
43
|
-
throw new Error(content);
|
|
44
|
-
}
|
|
45
|
-
function convertUint8ArrayToText(uint8Array) {
|
|
46
|
-
try {
|
|
47
|
-
return new TextDecoder().decode(uint8Array);
|
|
48
|
-
} catch {
|
|
49
|
-
throw new Error("Error decoding Uint8Array to text");
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
8
|
// src/agent/message-list/prompt/attachments-to-parts.ts
|
|
54
9
|
function attachmentsToParts(attachments) {
|
|
55
10
|
const parts = [];
|
|
@@ -78,18 +33,6 @@ function attachmentsToParts(attachments) {
|
|
|
78
33
|
break;
|
|
79
34
|
}
|
|
80
35
|
case "data:": {
|
|
81
|
-
let header;
|
|
82
|
-
let base64Content;
|
|
83
|
-
let mimeType;
|
|
84
|
-
try {
|
|
85
|
-
[header, base64Content] = attachment.url.split(",");
|
|
86
|
-
mimeType = header?.split?.(";")?.[0]?.split(":")[1];
|
|
87
|
-
} catch {
|
|
88
|
-
throw new Error(`Error processing data URL: ${attachment.url}`);
|
|
89
|
-
}
|
|
90
|
-
if (mimeType == null || base64Content == null) {
|
|
91
|
-
throw new Error(`Invalid data URL format: ${attachment.url}`);
|
|
92
|
-
}
|
|
93
36
|
if (attachment.contentType?.startsWith("image/")) {
|
|
94
37
|
parts.push({
|
|
95
38
|
type: "image",
|
|
@@ -98,8 +41,9 @@ function attachmentsToParts(attachments) {
|
|
|
98
41
|
});
|
|
99
42
|
} else if (attachment.contentType?.startsWith("text/")) {
|
|
100
43
|
parts.push({
|
|
101
|
-
type: "
|
|
102
|
-
|
|
44
|
+
type: "file",
|
|
45
|
+
data: attachment.url,
|
|
46
|
+
mimeType: attachment.contentType
|
|
103
47
|
});
|
|
104
48
|
} else {
|
|
105
49
|
if (!attachment.contentType) {
|
|
@@ -107,7 +51,7 @@ function attachmentsToParts(attachments) {
|
|
|
107
51
|
}
|
|
108
52
|
parts.push({
|
|
109
53
|
type: "file",
|
|
110
|
-
data:
|
|
54
|
+
data: attachment.url,
|
|
111
55
|
mimeType: attachment.contentType
|
|
112
56
|
});
|
|
113
57
|
}
|
|
@@ -342,6 +286,25 @@ function convertToV1Messages(messages) {
|
|
|
342
286
|
}
|
|
343
287
|
return v1Messages;
|
|
344
288
|
}
|
|
289
|
+
z.union([
|
|
290
|
+
z.string(),
|
|
291
|
+
z.instanceof(Uint8Array),
|
|
292
|
+
z.instanceof(ArrayBuffer),
|
|
293
|
+
z.custom(
|
|
294
|
+
// Buffer might not be available in some environments such as CloudFlare:
|
|
295
|
+
(value) => globalThis.Buffer?.isBuffer(value) ?? false,
|
|
296
|
+
{ message: "Must be a Buffer" }
|
|
297
|
+
)
|
|
298
|
+
]);
|
|
299
|
+
function convertDataContentToBase64String(content) {
|
|
300
|
+
if (typeof content === "string") {
|
|
301
|
+
return content;
|
|
302
|
+
}
|
|
303
|
+
if (content instanceof ArrayBuffer) {
|
|
304
|
+
return convertUint8ArrayToBase64(new Uint8Array(content));
|
|
305
|
+
}
|
|
306
|
+
return convertUint8ArrayToBase64(content);
|
|
307
|
+
}
|
|
345
308
|
|
|
346
309
|
// src/agent/message-list/index.ts
|
|
347
310
|
function isToolCallMessage(message) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkBB6DPGIV_cjs = require('./chunk-BB6DPGIV.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunkWTC6DJHD_cjs = require('./chunk-WTC6DJHD.cjs');
|
|
5
5
|
var chunk4Z3OU5RY_cjs = require('./chunk-4Z3OU5RY.cjs');
|
|
6
6
|
var chunkB6TOBUS6_cjs = require('./chunk-B6TOBUS6.cjs');
|
|
7
7
|
var chunkP3Q73CAW_cjs = require('./chunk-P3Q73CAW.cjs');
|
|
@@ -437,7 +437,11 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
437
437
|
});
|
|
438
438
|
let execResults;
|
|
439
439
|
const retries = step.retries ?? executionContext.retryConfig.attempts ?? 0;
|
|
440
|
+
const delay = executionContext.retryConfig.delay ?? 0;
|
|
440
441
|
for (let i = 0; i < retries + 1; i++) {
|
|
442
|
+
if (i > 0 && delay) {
|
|
443
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
444
|
+
}
|
|
441
445
|
try {
|
|
442
446
|
let suspended;
|
|
443
447
|
let bailed;
|
|
@@ -1288,7 +1292,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
1288
1292
|
serializedStepGraph,
|
|
1289
1293
|
stepResults,
|
|
1290
1294
|
executionContext,
|
|
1291
|
-
workflowStatus:
|
|
1295
|
+
workflowStatus: execResults.status
|
|
1292
1296
|
});
|
|
1293
1297
|
return { result: execResults, stepResults, executionContext };
|
|
1294
1298
|
}
|
|
@@ -1297,7 +1301,7 @@ function mapVariable(config) {
|
|
|
1297
1301
|
return config;
|
|
1298
1302
|
}
|
|
1299
1303
|
function createStep(params) {
|
|
1300
|
-
if (params instanceof
|
|
1304
|
+
if (params instanceof chunkWTC6DJHD_cjs.Agent) {
|
|
1301
1305
|
return {
|
|
1302
1306
|
id: params.name,
|
|
1303
1307
|
// @ts-ignore
|
|
@@ -1392,6 +1396,7 @@ function createStep(params) {
|
|
|
1392
1396
|
outputSchema: params.outputSchema,
|
|
1393
1397
|
resumeSchema: params.resumeSchema,
|
|
1394
1398
|
suspendSchema: params.suspendSchema,
|
|
1399
|
+
retries: params.retries,
|
|
1395
1400
|
execute: params.execute
|
|
1396
1401
|
};
|
|
1397
1402
|
}
|
|
@@ -1401,7 +1406,8 @@ function cloneStep(step, opts) {
|
|
|
1401
1406
|
description: step.description,
|
|
1402
1407
|
inputSchema: step.inputSchema,
|
|
1403
1408
|
outputSchema: step.outputSchema,
|
|
1404
|
-
execute: step.execute
|
|
1409
|
+
execute: step.execute,
|
|
1410
|
+
retries: step.retries
|
|
1405
1411
|
};
|
|
1406
1412
|
}
|
|
1407
1413
|
function createWorkflow(params) {
|
|
@@ -2154,6 +2160,17 @@ var Run = class {
|
|
|
2154
2160
|
workflowName: this.workflowId,
|
|
2155
2161
|
runId: this.runId
|
|
2156
2162
|
});
|
|
2163
|
+
if (!snapshot) {
|
|
2164
|
+
throw new Error("No snapshot found for this workflow run");
|
|
2165
|
+
}
|
|
2166
|
+
if (snapshot.status !== "suspended") {
|
|
2167
|
+
throw new Error("This workflow run was not suspended");
|
|
2168
|
+
}
|
|
2169
|
+
const suspendedStepIds = Object.keys(snapshot?.suspendedPaths ?? {});
|
|
2170
|
+
const isStepSuspended = suspendedStepIds.includes(steps?.[0] ?? "");
|
|
2171
|
+
if (!isStepSuspended) {
|
|
2172
|
+
throw new Error("This workflow step was not suspended");
|
|
2173
|
+
}
|
|
2157
2174
|
const executionResultPromise = this.executionEngine.execute({
|
|
2158
2175
|
workflowId: this.workflowId,
|
|
2159
2176
|
runId: this.runId,
|
|
@@ -7,51 +7,6 @@ var ai = require('ai');
|
|
|
7
7
|
var providerUtils = require('@ai-sdk/provider-utils');
|
|
8
8
|
var zod = require('zod');
|
|
9
9
|
|
|
10
|
-
zod.z.union([
|
|
11
|
-
zod.z.string(),
|
|
12
|
-
zod.z.instanceof(Uint8Array),
|
|
13
|
-
zod.z.instanceof(ArrayBuffer),
|
|
14
|
-
zod.z.custom(
|
|
15
|
-
// Buffer might not be available in some environments such as CloudFlare:
|
|
16
|
-
(value) => globalThis.Buffer?.isBuffer(value) ?? false,
|
|
17
|
-
{ message: "Must be a Buffer" }
|
|
18
|
-
)
|
|
19
|
-
]);
|
|
20
|
-
function convertDataContentToBase64String(content) {
|
|
21
|
-
if (typeof content === "string") {
|
|
22
|
-
return content;
|
|
23
|
-
}
|
|
24
|
-
if (content instanceof ArrayBuffer) {
|
|
25
|
-
return providerUtils.convertUint8ArrayToBase64(new Uint8Array(content));
|
|
26
|
-
}
|
|
27
|
-
return providerUtils.convertUint8ArrayToBase64(content);
|
|
28
|
-
}
|
|
29
|
-
function convertDataContentToUint8Array(content) {
|
|
30
|
-
if (content instanceof Uint8Array) {
|
|
31
|
-
return content;
|
|
32
|
-
}
|
|
33
|
-
if (typeof content === "string") {
|
|
34
|
-
try {
|
|
35
|
-
return providerUtils.convertBase64ToUint8Array(content);
|
|
36
|
-
} catch (error) {
|
|
37
|
-
throw new Error("Invalid data content. Content string is not a base64-encoded media.", {
|
|
38
|
-
cause: error
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
if (content instanceof ArrayBuffer) {
|
|
43
|
-
return new Uint8Array(content);
|
|
44
|
-
}
|
|
45
|
-
throw new Error(content);
|
|
46
|
-
}
|
|
47
|
-
function convertUint8ArrayToText(uint8Array) {
|
|
48
|
-
try {
|
|
49
|
-
return new TextDecoder().decode(uint8Array);
|
|
50
|
-
} catch {
|
|
51
|
-
throw new Error("Error decoding Uint8Array to text");
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
10
|
// src/agent/message-list/prompt/attachments-to-parts.ts
|
|
56
11
|
function attachmentsToParts(attachments) {
|
|
57
12
|
const parts = [];
|
|
@@ -80,18 +35,6 @@ function attachmentsToParts(attachments) {
|
|
|
80
35
|
break;
|
|
81
36
|
}
|
|
82
37
|
case "data:": {
|
|
83
|
-
let header;
|
|
84
|
-
let base64Content;
|
|
85
|
-
let mimeType;
|
|
86
|
-
try {
|
|
87
|
-
[header, base64Content] = attachment.url.split(",");
|
|
88
|
-
mimeType = header?.split?.(";")?.[0]?.split(":")[1];
|
|
89
|
-
} catch {
|
|
90
|
-
throw new Error(`Error processing data URL: ${attachment.url}`);
|
|
91
|
-
}
|
|
92
|
-
if (mimeType == null || base64Content == null) {
|
|
93
|
-
throw new Error(`Invalid data URL format: ${attachment.url}`);
|
|
94
|
-
}
|
|
95
38
|
if (attachment.contentType?.startsWith("image/")) {
|
|
96
39
|
parts.push({
|
|
97
40
|
type: "image",
|
|
@@ -100,8 +43,9 @@ function attachmentsToParts(attachments) {
|
|
|
100
43
|
});
|
|
101
44
|
} else if (attachment.contentType?.startsWith("text/")) {
|
|
102
45
|
parts.push({
|
|
103
|
-
type: "
|
|
104
|
-
|
|
46
|
+
type: "file",
|
|
47
|
+
data: attachment.url,
|
|
48
|
+
mimeType: attachment.contentType
|
|
105
49
|
});
|
|
106
50
|
} else {
|
|
107
51
|
if (!attachment.contentType) {
|
|
@@ -109,7 +53,7 @@ function attachmentsToParts(attachments) {
|
|
|
109
53
|
}
|
|
110
54
|
parts.push({
|
|
111
55
|
type: "file",
|
|
112
|
-
data:
|
|
56
|
+
data: attachment.url,
|
|
113
57
|
mimeType: attachment.contentType
|
|
114
58
|
});
|
|
115
59
|
}
|
|
@@ -344,6 +288,25 @@ function convertToV1Messages(messages) {
|
|
|
344
288
|
}
|
|
345
289
|
return v1Messages;
|
|
346
290
|
}
|
|
291
|
+
zod.z.union([
|
|
292
|
+
zod.z.string(),
|
|
293
|
+
zod.z.instanceof(Uint8Array),
|
|
294
|
+
zod.z.instanceof(ArrayBuffer),
|
|
295
|
+
zod.z.custom(
|
|
296
|
+
// Buffer might not be available in some environments such as CloudFlare:
|
|
297
|
+
(value) => globalThis.Buffer?.isBuffer(value) ?? false,
|
|
298
|
+
{ message: "Must be a Buffer" }
|
|
299
|
+
)
|
|
300
|
+
]);
|
|
301
|
+
function convertDataContentToBase64String(content) {
|
|
302
|
+
if (typeof content === "string") {
|
|
303
|
+
return content;
|
|
304
|
+
}
|
|
305
|
+
if (content instanceof ArrayBuffer) {
|
|
306
|
+
return providerUtils.convertUint8ArrayToBase64(new Uint8Array(content));
|
|
307
|
+
}
|
|
308
|
+
return providerUtils.convertUint8ArrayToBase64(content);
|
|
309
|
+
}
|
|
347
310
|
|
|
348
311
|
// src/agent/message-list/index.ts
|
|
349
312
|
function isToolCallMessage(message) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EMITTER_SYMBOL } from './chunk-Y7D2JLKS.js';
|
|
2
|
-
import { Agent } from './chunk-
|
|
2
|
+
import { Agent } from './chunk-XR7OX4ZC.js';
|
|
3
3
|
import { Tool } from './chunk-C4LMN2IR.js';
|
|
4
4
|
import { MastraError } from './chunk-6UNGH46J.js';
|
|
5
5
|
import { MastraBase } from './chunk-5IEKR756.js';
|
|
@@ -431,7 +431,11 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
431
431
|
});
|
|
432
432
|
let execResults;
|
|
433
433
|
const retries = step.retries ?? executionContext.retryConfig.attempts ?? 0;
|
|
434
|
+
const delay = executionContext.retryConfig.delay ?? 0;
|
|
434
435
|
for (let i = 0; i < retries + 1; i++) {
|
|
436
|
+
if (i > 0 && delay) {
|
|
437
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
438
|
+
}
|
|
435
439
|
try {
|
|
436
440
|
let suspended;
|
|
437
441
|
let bailed;
|
|
@@ -1282,7 +1286,7 @@ var DefaultExecutionEngine = class extends ExecutionEngine {
|
|
|
1282
1286
|
serializedStepGraph,
|
|
1283
1287
|
stepResults,
|
|
1284
1288
|
executionContext,
|
|
1285
|
-
workflowStatus:
|
|
1289
|
+
workflowStatus: execResults.status
|
|
1286
1290
|
});
|
|
1287
1291
|
return { result: execResults, stepResults, executionContext };
|
|
1288
1292
|
}
|
|
@@ -1386,6 +1390,7 @@ function createStep(params) {
|
|
|
1386
1390
|
outputSchema: params.outputSchema,
|
|
1387
1391
|
resumeSchema: params.resumeSchema,
|
|
1388
1392
|
suspendSchema: params.suspendSchema,
|
|
1393
|
+
retries: params.retries,
|
|
1389
1394
|
execute: params.execute
|
|
1390
1395
|
};
|
|
1391
1396
|
}
|
|
@@ -1395,7 +1400,8 @@ function cloneStep(step, opts) {
|
|
|
1395
1400
|
description: step.description,
|
|
1396
1401
|
inputSchema: step.inputSchema,
|
|
1397
1402
|
outputSchema: step.outputSchema,
|
|
1398
|
-
execute: step.execute
|
|
1403
|
+
execute: step.execute,
|
|
1404
|
+
retries: step.retries
|
|
1399
1405
|
};
|
|
1400
1406
|
}
|
|
1401
1407
|
function createWorkflow(params) {
|
|
@@ -2148,6 +2154,17 @@ var Run = class {
|
|
|
2148
2154
|
workflowName: this.workflowId,
|
|
2149
2155
|
runId: this.runId
|
|
2150
2156
|
});
|
|
2157
|
+
if (!snapshot) {
|
|
2158
|
+
throw new Error("No snapshot found for this workflow run");
|
|
2159
|
+
}
|
|
2160
|
+
if (snapshot.status !== "suspended") {
|
|
2161
|
+
throw new Error("This workflow run was not suspended");
|
|
2162
|
+
}
|
|
2163
|
+
const suspendedStepIds = Object.keys(snapshot?.suspendedPaths ?? {});
|
|
2164
|
+
const isStepSuspended = suspendedStepIds.includes(steps?.[0] ?? "");
|
|
2165
|
+
if (!isStepSuspended) {
|
|
2166
|
+
throw new Error("This workflow step was not suspended");
|
|
2167
|
+
}
|
|
2151
2168
|
const executionResultPromise = this.executionEngine.execute({
|
|
2152
2169
|
workflowId: this.workflowId,
|
|
2153
2170
|
runId: this.runId,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkZPOUMTTH_cjs = require('./chunk-ZPOUMTTH.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunkQUSEDVYI_cjs = require('./chunk-QUSEDVYI.cjs');
|
|
5
5
|
var chunkST5RMVLG_cjs = require('./chunk-ST5RMVLG.cjs');
|
|
6
6
|
var chunkVUEY4BUU_cjs = require('./chunk-VUEY4BUU.cjs');
|
|
7
7
|
var chunkQQ5K5TZE_cjs = require('./chunk-QQ5K5TZE.cjs');
|
|
@@ -669,7 +669,7 @@ exports.Agent = class Agent extends (_a = chunkP3Q73CAW_cjs.MastraBase) {
|
|
|
669
669
|
runtimeContext,
|
|
670
670
|
model
|
|
671
671
|
});
|
|
672
|
-
const normMessage = new
|
|
672
|
+
const normMessage = new chunkQUSEDVYI_cjs.MessageList().add(message, "user").get.all.ui().at(-1);
|
|
673
673
|
if (!normMessage) {
|
|
674
674
|
throw new Error(`Could not generate title from input ${JSON.stringify(message)}`);
|
|
675
675
|
}
|
|
@@ -712,7 +712,7 @@ exports.Agent = class Agent extends (_a = chunkP3Q73CAW_cjs.MastraBase) {
|
|
|
712
712
|
async genTitle(userMessage, runtimeContext, model, instructions) {
|
|
713
713
|
try {
|
|
714
714
|
if (userMessage) {
|
|
715
|
-
const normMessage = new
|
|
715
|
+
const normMessage = new chunkQUSEDVYI_cjs.MessageList().add(userMessage, "user").get.all.ui().at(-1);
|
|
716
716
|
if (normMessage) {
|
|
717
717
|
return await this.generateTitleFromUserMessage({
|
|
718
718
|
message: normMessage,
|
|
@@ -737,7 +737,7 @@ exports.Agent = class Agent extends (_a = chunkP3Q73CAW_cjs.MastraBase) {
|
|
|
737
737
|
runId,
|
|
738
738
|
userMessages,
|
|
739
739
|
systemMessage,
|
|
740
|
-
messageList = new
|
|
740
|
+
messageList = new chunkQUSEDVYI_cjs.MessageList({
|
|
741
741
|
threadId,
|
|
742
742
|
resourceId
|
|
743
743
|
})
|
|
@@ -789,7 +789,7 @@ exports.Agent = class Agent extends (_a = chunkP3Q73CAW_cjs.MastraBase) {
|
|
|
789
789
|
systemMessage: systemMessages,
|
|
790
790
|
memorySystemMessage: memorySystemMessage || void 0
|
|
791
791
|
});
|
|
792
|
-
const returnList = new
|
|
792
|
+
const returnList = new chunkQUSEDVYI_cjs.MessageList().addSystem(systemMessages).add(processedMemoryMessages, "memory").add(newMessages, "user");
|
|
793
793
|
return {
|
|
794
794
|
threadId: thread.id,
|
|
795
795
|
messages: returnList.get.all.prompt()
|
|
@@ -1175,7 +1175,7 @@ exports.Agent = class Agent extends (_a = chunkP3Q73CAW_cjs.MastraBase) {
|
|
|
1175
1175
|
runId,
|
|
1176
1176
|
runtimeContext
|
|
1177
1177
|
});
|
|
1178
|
-
const messageList = new
|
|
1178
|
+
const messageList = new chunkQUSEDVYI_cjs.MessageList({
|
|
1179
1179
|
threadId,
|
|
1180
1180
|
resourceId,
|
|
1181
1181
|
generateMessageId
|
|
@@ -1244,7 +1244,7 @@ exports.Agent = class Agent extends (_a = chunkP3Q73CAW_cjs.MastraBase) {
|
|
|
1244
1244
|
resourceId,
|
|
1245
1245
|
config: memoryConfig,
|
|
1246
1246
|
// The new user messages aren't in the list yet cause we add memory messages first to try to make sure ordering is correct (memory comes before new user messages)
|
|
1247
|
-
vectorMessageSearch: new
|
|
1247
|
+
vectorMessageSearch: new chunkQUSEDVYI_cjs.MessageList().add(messages, `user`).getLatestUserContent() || ""
|
|
1248
1248
|
}).then(r => r.messagesV2), memory.getSystemMessage({
|
|
1249
1249
|
threadId: threadObject.id,
|
|
1250
1250
|
resourceId,
|
|
@@ -1265,7 +1265,7 @@ The following messages were remembered from a different conversation:
|
|
|
1265
1265
|
<remembered_from_other_conversation>
|
|
1266
1266
|
${JSON.stringify(
|
|
1267
1267
|
// get v1 since they're closer to CoreMessages (which get sent to the LLM) but also include timestamps
|
|
1268
|
-
new
|
|
1268
|
+
new chunkQUSEDVYI_cjs.MessageList().add(resultsFromOtherThreads, "memory").get.all.v1())}
|
|
1269
1269
|
<end_remembered_from_other_conversation>`;
|
|
1270
1270
|
}
|
|
1271
1271
|
if (memorySystemMessage) {
|
|
@@ -1285,7 +1285,7 @@ ${JSON.stringify(
|
|
|
1285
1285
|
systemMessage,
|
|
1286
1286
|
memorySystemMessage: memorySystemMessage || void 0
|
|
1287
1287
|
});
|
|
1288
|
-
const processedList = new
|
|
1288
|
+
const processedList = new chunkQUSEDVYI_cjs.MessageList({
|
|
1289
1289
|
threadId: threadObject.id,
|
|
1290
1290
|
resourceId
|
|
1291
1291
|
}).addSystem(instructions || `${this.instructions}.`).addSystem(memorySystemMessage).add(context || [], "context").add(processedMemoryMessages, "memory").add(messageList.get.input.v2(), "user").get.all.prompt();
|
|
@@ -1329,7 +1329,7 @@ ${JSON.stringify(
|
|
|
1329
1329
|
threadId
|
|
1330
1330
|
});
|
|
1331
1331
|
const memory = this.getMemory();
|
|
1332
|
-
const messageListResponses = new
|
|
1332
|
+
const messageListResponses = new chunkQUSEDVYI_cjs.MessageList({
|
|
1333
1333
|
threadId,
|
|
1334
1334
|
resourceId
|
|
1335
1335
|
}).add(result.response.messages, "response").get.all.core();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DefaultVoice } from './chunk-5HTMDAXP.js';
|
|
2
|
-
import { MessageList } from './chunk-
|
|
2
|
+
import { MessageList } from './chunk-4UBOJFSL.js';
|
|
3
3
|
import { executeHook } from './chunk-BB4KXGBU.js';
|
|
4
4
|
import { MastraLLM } from './chunk-EJI2SQJP.js';
|
|
5
5
|
import { InstrumentClass } from './chunk-TC2SCOTE.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkWTC6DJHD_cjs = require('./chunk-WTC6DJHD.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 chunkWTC6DJHD_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.
|
package/dist/eval/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { M as Metric, T as TestInfo, E as EvaluationResult } from '../types-Bo1uigWx.cjs';
|
|
2
2
|
export { a as MetricResult } from '../types-Bo1uigWx.cjs';
|
|
3
|
-
import { A as Agent } from '../base-
|
|
3
|
+
import { A as Agent } from '../base-DpaaEQWN.cjs';
|
|
4
4
|
import 'ai';
|
|
5
5
|
import '../base-B_y9sMg0.cjs';
|
|
6
6
|
import '@opentelemetry/api';
|
package/dist/eval/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { M as Metric, T as TestInfo, E as EvaluationResult } from '../types-Bo1uigWx.js';
|
|
2
2
|
export { a as MetricResult } from '../types-Bo1uigWx.js';
|
|
3
|
-
import { A as Agent } from '../base-
|
|
3
|
+
import { A as Agent } from '../base-BBkhRGjp.js';
|
|
4
4
|
import 'ai';
|
|
5
5
|
import '../base-ClrXcCRx.js';
|
|
6
6
|
import '@opentelemetry/api';
|