@mastra/server 1.0.0-beta.13 → 1.0.0-beta.14
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 +93 -0
- package/dist/{chunk-YD5BSLPJ.js → chunk-3BXS37TQ.js} +43 -7
- package/dist/chunk-3BXS37TQ.js.map +1 -0
- package/dist/{chunk-4MNOLEZO.cjs → chunk-BGSW46W5.cjs} +81 -56
- package/dist/chunk-BGSW46W5.cjs.map +1 -0
- package/dist/{chunk-7O3KPUJ4.cjs → chunk-JUYWLFVT.cjs} +13 -4
- package/dist/chunk-JUYWLFVT.cjs.map +1 -0
- package/dist/{chunk-4TDHAYN7.cjs → chunk-P6S2HIVE.cjs} +43 -7
- package/dist/chunk-P6S2HIVE.cjs.map +1 -0
- package/dist/{chunk-KEXR53KI.js → chunk-S5XBFHJL.js} +13 -4
- package/dist/chunk-S5XBFHJL.js.map +1 -0
- package/dist/{chunk-EEORY4VR.js → chunk-YBYNF4PS.js} +48 -23
- package/dist/chunk-YBYNF4PS.js.map +1 -0
- package/dist/server/handlers/a2a.cjs +9 -9
- package/dist/server/handlers/a2a.d.ts.map +1 -1
- package/dist/server/handlers/a2a.js +1 -1
- package/dist/server/handlers/agent-builder.cjs +19 -19
- package/dist/server/handlers/agent-builder.d.ts +21 -3
- package/dist/server/handlers/agent-builder.d.ts.map +1 -1
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/workflows.cjs +27 -27
- package/dist/server/handlers/workflows.d.ts +52 -6
- package/dist/server/handlers/workflows.d.ts.map +1 -1
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +6 -6
- package/dist/server/handlers.js +3 -3
- package/dist/server/schemas/workflows.d.ts +40 -3
- package/dist/server/schemas/workflows.d.ts.map +1 -1
- package/dist/server/server-adapter/index.cjs +48 -48
- package/dist/server/server-adapter/index.js +3 -3
- package/package.json +5 -5
- package/dist/chunk-4MNOLEZO.cjs.map +0 -1
- package/dist/chunk-4TDHAYN7.cjs.map +0 -1
- package/dist/chunk-7O3KPUJ4.cjs.map +0 -1
- package/dist/chunk-EEORY4VR.js.map +0 -1
- package/dist/chunk-KEXR53KI.js.map +0 -1
- package/dist/chunk-YD5BSLPJ.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __commonJS as __commonJS$2, require_token_error as require_token_error$1, __toESM as __toESM$2 } from './chunk-EUBTCHQC.js';
|
|
2
|
-
import { listWorkflowsResponseSchema, LIST_WORKFLOWS_ROUTE, workflowInfoSchema, GET_WORKFLOW_BY_ID_ROUTE, workflowRunsResponseSchema, listWorkflowRunsQuerySchema, LIST_WORKFLOW_RUNS_ROUTE, workflowRunResponseSchema, GET_WORKFLOW_RUN_BY_ID_ROUTE, workflowExecutionResultSchema, GET_WORKFLOW_RUN_EXECUTION_RESULT_ROUTE, createWorkflowRunResponseSchema, CREATE_WORKFLOW_RUN_ROUTE, streamWorkflowBodySchema, STREAM_WORKFLOW_ROUTE, STREAM_VNEXT_WORKFLOW_ROUTE, startAsyncWorkflowBodySchema, START_ASYNC_WORKFLOW_ROUTE, workflowControlResponseSchema, START_WORKFLOW_RUN_ROUTE, OBSERVE_STREAM_WORKFLOW_ROUTE, OBSERVE_STREAM_VNEXT_WORKFLOW_ROUTE, resumeBodySchema, RESUME_ASYNC_WORKFLOW_ROUTE, RESUME_WORKFLOW_ROUTE, RESUME_STREAM_WORKFLOW_ROUTE, CANCEL_WORKFLOW_RUN_ROUTE, streamLegacyWorkflowBodySchema, STREAM_LEGACY_WORKFLOW_ROUTE, OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE } from './chunk-
|
|
2
|
+
import { listWorkflowsResponseSchema, LIST_WORKFLOWS_ROUTE, workflowInfoSchema, GET_WORKFLOW_BY_ID_ROUTE, workflowRunsResponseSchema, listWorkflowRunsQuerySchema, LIST_WORKFLOW_RUNS_ROUTE, workflowRunResponseSchema, GET_WORKFLOW_RUN_BY_ID_ROUTE, workflowExecutionResultSchema, GET_WORKFLOW_RUN_EXECUTION_RESULT_ROUTE, createWorkflowRunResponseSchema, CREATE_WORKFLOW_RUN_ROUTE, streamWorkflowBodySchema, STREAM_WORKFLOW_ROUTE, STREAM_VNEXT_WORKFLOW_ROUTE, startAsyncWorkflowBodySchema, START_ASYNC_WORKFLOW_ROUTE, workflowControlResponseSchema, START_WORKFLOW_RUN_ROUTE, OBSERVE_STREAM_WORKFLOW_ROUTE, OBSERVE_STREAM_VNEXT_WORKFLOW_ROUTE, resumeBodySchema, RESUME_ASYNC_WORKFLOW_ROUTE, RESUME_WORKFLOW_ROUTE, RESUME_STREAM_WORKFLOW_ROUTE, CANCEL_WORKFLOW_RUN_ROUTE, streamLegacyWorkflowBodySchema, STREAM_LEGACY_WORKFLOW_ROUTE, OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE } from './chunk-3BXS37TQ.js';
|
|
3
3
|
import { __commonJS as __commonJS$1, require_token_error, __toESM } from './chunk-AZIH2QEC.js';
|
|
4
4
|
import { openai } from './chunk-SV4AUWGY.js';
|
|
5
5
|
import { WorkflowRegistry } from './chunk-WBLT2HL3.js';
|
|
@@ -9,7 +9,7 @@ import { createRoute } from './chunk-SXVANU23.js';
|
|
|
9
9
|
import { handleError } from './chunk-UXGQZUYZ.js';
|
|
10
10
|
import { HTTPException } from './chunk-6QWQZI4Q.js';
|
|
11
11
|
import { __commonJS, __export, __toESM as __toESM$1 } from './chunk-PR4QN5HX.js';
|
|
12
|
-
import { Agent, tryGenerateWithJsonFallback, tryStreamWithJsonFallback, MessageList } from '@mastra/core/agent';
|
|
12
|
+
import { Agent, isSupportedLanguageModel, tryGenerateWithJsonFallback, tryStreamWithJsonFallback, MessageList } from '@mastra/core/agent';
|
|
13
13
|
import z18, { z, ZodObject, ZodFirstPartyTypeKind } from 'zod';
|
|
14
14
|
import * as z42 from 'zod/v4';
|
|
15
15
|
import { z as z$1 } from 'zod/v4';
|
|
@@ -15843,6 +15843,35 @@ var __experimental_updateWorkingMemoryToolVNext = (config) => {
|
|
|
15843
15843
|
}
|
|
15844
15844
|
});
|
|
15845
15845
|
};
|
|
15846
|
+
var WORKING_MEMORY_START_TAG = "<working_memory>";
|
|
15847
|
+
var WORKING_MEMORY_END_TAG = "</working_memory>";
|
|
15848
|
+
function removeWorkingMemoryTags(text32) {
|
|
15849
|
+
let result = "";
|
|
15850
|
+
let pos = 0;
|
|
15851
|
+
while (pos < text32.length) {
|
|
15852
|
+
const start = text32.indexOf(WORKING_MEMORY_START_TAG, pos);
|
|
15853
|
+
if (start === -1) {
|
|
15854
|
+
result += text32.substring(pos);
|
|
15855
|
+
break;
|
|
15856
|
+
}
|
|
15857
|
+
result += text32.substring(pos, start);
|
|
15858
|
+
const end = text32.indexOf(WORKING_MEMORY_END_TAG, start + WORKING_MEMORY_START_TAG.length);
|
|
15859
|
+
if (end === -1) {
|
|
15860
|
+
result += text32.substring(start);
|
|
15861
|
+
break;
|
|
15862
|
+
}
|
|
15863
|
+
pos = end + WORKING_MEMORY_END_TAG.length;
|
|
15864
|
+
}
|
|
15865
|
+
return result;
|
|
15866
|
+
}
|
|
15867
|
+
function extractWorkingMemoryContent(text32) {
|
|
15868
|
+
const start = text32.indexOf(WORKING_MEMORY_START_TAG);
|
|
15869
|
+
if (start === -1) return null;
|
|
15870
|
+
const contentStart = start + WORKING_MEMORY_START_TAG.length;
|
|
15871
|
+
const end = text32.indexOf(WORKING_MEMORY_END_TAG, contentStart);
|
|
15872
|
+
if (end === -1) return null;
|
|
15873
|
+
return text32.substring(contentStart, end);
|
|
15874
|
+
}
|
|
15846
15875
|
var CHARS_PER_TOKEN = 4;
|
|
15847
15876
|
var DEFAULT_MESSAGE_RANGE = { before: 1, after: 1 };
|
|
15848
15877
|
var DEFAULT_TOP_K = 4;
|
|
@@ -16259,11 +16288,10 @@ ${workingMemory}`;
|
|
|
16259
16288
|
return result;
|
|
16260
16289
|
}
|
|
16261
16290
|
updateMessageToHideWorkingMemory(message) {
|
|
16262
|
-
const workingMemoryRegex = /<working_memory>([^]*?)<\/working_memory>/g;
|
|
16263
16291
|
if (typeof message?.content === `string`) {
|
|
16264
16292
|
return {
|
|
16265
16293
|
...message,
|
|
16266
|
-
content: message.content
|
|
16294
|
+
content: removeWorkingMemoryTags(message.content).trim()
|
|
16267
16295
|
};
|
|
16268
16296
|
} else if (Array.isArray(message?.content)) {
|
|
16269
16297
|
const filteredContent = message.content.filter(
|
|
@@ -16273,7 +16301,7 @@ ${workingMemory}`;
|
|
|
16273
16301
|
if (content.type === "text") {
|
|
16274
16302
|
return {
|
|
16275
16303
|
...content,
|
|
16276
|
-
text: content.text
|
|
16304
|
+
text: removeWorkingMemoryTags(content.text).trim()
|
|
16277
16305
|
};
|
|
16278
16306
|
}
|
|
16279
16307
|
return { ...content };
|
|
@@ -16285,13 +16313,12 @@ ${workingMemory}`;
|
|
|
16285
16313
|
}
|
|
16286
16314
|
}
|
|
16287
16315
|
updateMessageToHideWorkingMemoryV2(message) {
|
|
16288
|
-
const workingMemoryRegex = /<working_memory>([^]*?)<\/working_memory>/g;
|
|
16289
16316
|
const newMessage = { ...message };
|
|
16290
16317
|
if (message.content && typeof message.content === "object" && !Array.isArray(message.content)) {
|
|
16291
16318
|
newMessage.content = { ...message.content };
|
|
16292
16319
|
}
|
|
16293
16320
|
if (typeof newMessage.content?.content === "string" && newMessage.content.content.length > 0) {
|
|
16294
|
-
newMessage.content.content = newMessage.content.content
|
|
16321
|
+
newMessage.content.content = removeWorkingMemoryTags(newMessage.content.content).trim();
|
|
16295
16322
|
}
|
|
16296
16323
|
if (Array.isArray(newMessage.content?.parts)) {
|
|
16297
16324
|
newMessage.content.parts = newMessage.content.parts.filter((part) => {
|
|
@@ -16304,7 +16331,7 @@ ${workingMemory}`;
|
|
|
16304
16331
|
const text32 = typeof part.text === "string" ? part.text : "";
|
|
16305
16332
|
return {
|
|
16306
16333
|
...part,
|
|
16307
|
-
text: text32
|
|
16334
|
+
text: removeWorkingMemoryTags(text32).trim()
|
|
16308
16335
|
};
|
|
16309
16336
|
}
|
|
16310
16337
|
return part;
|
|
@@ -16317,13 +16344,8 @@ ${workingMemory}`;
|
|
|
16317
16344
|
}
|
|
16318
16345
|
parseWorkingMemory(text32) {
|
|
16319
16346
|
if (!this.threadConfig.workingMemory?.enabled) return null;
|
|
16320
|
-
const
|
|
16321
|
-
|
|
16322
|
-
const match = matches?.[0];
|
|
16323
|
-
if (match) {
|
|
16324
|
-
return match.replace(/<\/?working_memory>/g, "").trim();
|
|
16325
|
-
}
|
|
16326
|
-
return null;
|
|
16347
|
+
const content = extractWorkingMemoryContent(text32);
|
|
16348
|
+
return content?.trim() ?? null;
|
|
16327
16349
|
}
|
|
16328
16350
|
async getWorkingMemory({
|
|
16329
16351
|
threadId,
|
|
@@ -19991,7 +20013,8 @@ Return the actual exported names of the units, as well as the file names.`,
|
|
|
19991
20013
|
listDirectory: tools.listDirectory
|
|
19992
20014
|
}
|
|
19993
20015
|
});
|
|
19994
|
-
const
|
|
20016
|
+
const resolvedModel = await agent.getModel();
|
|
20017
|
+
const isSupported = isSupportedLanguageModel(resolvedModel);
|
|
19995
20018
|
const prompt = `Analyze the Mastra project directory structure at "${templateDir}".
|
|
19996
20019
|
|
|
19997
20020
|
List directory contents using listDirectory tool, and then analyze each file with readFile tool.
|
|
@@ -20010,7 +20033,7 @@ Return the actual exported names of the units, as well as the file names.`,
|
|
|
20010
20033
|
networks: z.array(z.object({ name: z.string(), file: z.string() })).optional(),
|
|
20011
20034
|
other: z.array(z.object({ name: z.string(), file: z.string() })).optional()
|
|
20012
20035
|
});
|
|
20013
|
-
const result =
|
|
20036
|
+
const result = isSupported ? await tryGenerateWithJsonFallback(agent, prompt, {
|
|
20014
20037
|
structuredOutput: {
|
|
20015
20038
|
schema: output
|
|
20016
20039
|
},
|
|
@@ -20760,8 +20783,9 @@ For each task:
|
|
|
20760
20783
|
|
|
20761
20784
|
Start by listing your tasks and work through them systematically!
|
|
20762
20785
|
`;
|
|
20763
|
-
const
|
|
20764
|
-
const
|
|
20786
|
+
const resolvedModel = await agentBuilder.getModel();
|
|
20787
|
+
const isSupported = isSupportedLanguageModel(resolvedModel);
|
|
20788
|
+
const result = isSupported ? await agentBuilder.stream(prompt) : await agentBuilder.streamLegacy(prompt);
|
|
20765
20789
|
const actualResolutions = [];
|
|
20766
20790
|
for await (const chunk of result.fullStream) {
|
|
20767
20791
|
if (chunk.type === "step-finish" || chunk.type === "step-start") {
|
|
@@ -21002,9 +21026,10 @@ Be thorough and methodical. Always use listDirectory to verify actual file exist
|
|
|
21002
21026
|
Start by running validateCode with all validation types to get a complete picture of any issues, then systematically fix them.` : `Continue validation and fixing for the template integration at ${targetPath}. This is iteration ${currentIteration} of validation.
|
|
21003
21027
|
|
|
21004
21028
|
Previous iterations may have fixed some issues, so start by re-running validateCode to see the current state, then fix any remaining issues.`;
|
|
21005
|
-
const
|
|
21029
|
+
const resolvedModel = await validationAgent.getModel();
|
|
21030
|
+
const isSupported = isSupportedLanguageModel(resolvedModel);
|
|
21006
21031
|
const output = z.object({ success: z.boolean() });
|
|
21007
|
-
const result =
|
|
21032
|
+
const result = isSupported ? await tryStreamWithJsonFallback(validationAgent, iterationPrompt, {
|
|
21008
21033
|
structuredOutput: {
|
|
21009
21034
|
schema: output
|
|
21010
21035
|
}
|
|
@@ -27498,5 +27523,5 @@ var OBSERVE_STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE = createRoute({
|
|
|
27498
27523
|
});
|
|
27499
27524
|
|
|
27500
27525
|
export { CANCEL_AGENT_BUILDER_ACTION_RUN_ROUTE, CREATE_AGENT_BUILDER_ACTION_RUN_ROUTE, GET_AGENT_BUILDER_ACTION_BY_ID_ROUTE, GET_AGENT_BUILDER_ACTION_RUN_BY_ID_ROUTE, GET_AGENT_BUILDER_ACTION_RUN_EXECUTION_RESULT_ROUTE, LIST_AGENT_BUILDER_ACTIONS_ROUTE, LIST_AGENT_BUILDER_ACTION_RUNS_ROUTE, OBSERVE_STREAM_AGENT_BUILDER_ACTION_ROUTE, OBSERVE_STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE, OBSERVE_STREAM_VNEXT_AGENT_BUILDER_ACTION_ROUTE, RESUME_AGENT_BUILDER_ACTION_ROUTE, RESUME_ASYNC_AGENT_BUILDER_ACTION_ROUTE, RESUME_STREAM_AGENT_BUILDER_ACTION_ROUTE, START_AGENT_BUILDER_ACTION_RUN_ROUTE, START_ASYNC_AGENT_BUILDER_ACTION_ROUTE, STREAM_AGENT_BUILDER_ACTION_ROUTE, STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE, STREAM_VNEXT_AGENT_BUILDER_ACTION_ROUTE, agent_builder_exports };
|
|
27501
|
-
//# sourceMappingURL=chunk-
|
|
27502
|
-
//# sourceMappingURL=chunk-
|
|
27526
|
+
//# sourceMappingURL=chunk-YBYNF4PS.js.map
|
|
27527
|
+
//# sourceMappingURL=chunk-YBYNF4PS.js.map
|