@mastra/server 1.58.0-alpha.4 → 1.58.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/{agent-builder-DAiJH1u2.cjs → agent-builder-Bq8VQxPt.cjs} +2 -2
- package/dist/{agent-builder-DAiJH1u2.cjs.map → agent-builder-Bq8VQxPt.cjs.map} +1 -1
- package/dist/{agent-builder-gGFywDVq.js → agent-builder-DVv4fSab.js} +2 -2
- package/dist/{agent-builder-gGFywDVq.js.map → agent-builder-DVv4fSab.js.map} +1 -1
- package/dist/{api-schema-manifest-B4J_QYOr.js → api-schema-manifest-CtRYAXKX.js} +2 -2
- package/dist/{api-schema-manifest-B4J_QYOr.js.map → api-schema-manifest-CtRYAXKX.js.map} +1 -1
- package/dist/{api-schema-manifest-B3bC-D98.cjs → api-schema-manifest-tsMOBlmY.cjs} +2 -2
- package/dist/{api-schema-manifest-B3bC-D98.cjs.map → api-schema-manifest-tsMOBlmY.cjs.map} +1 -1
- package/dist/{dist-BKRMiJcn.js → dist-DkY6iCA4.js} +64 -35
- package/dist/dist-DkY6iCA4.js.map +1 -0
- package/dist/{dist-C2-SedDQ.cjs → dist-fvOsjRn_.cjs} +64 -35
- package/dist/dist-fvOsjRn_.cjs.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-server-routes.md +9 -9
- package/dist/{stored-workflows-OanG0TmB.js → dynamic-workflows-B4LI2B52.js} +61 -61
- package/dist/dynamic-workflows-B4LI2B52.js.map +1 -0
- package/dist/{stored-workflows-pCiWK305.cjs → dynamic-workflows-BXeywVEf.cjs} +70 -70
- package/dist/dynamic-workflows-BXeywVEf.cjs.map +1 -0
- package/dist/{routes-CZwPlO3-.cjs → routes-BRGPk2DE.cjs} +17 -17
- package/dist/routes-BRGPk2DE.cjs.map +1 -0
- package/dist/{routes-HUaCyUb7.js → routes-cMGFe7yS.js} +17 -17
- package/dist/routes-cMGFe7yS.js.map +1 -0
- package/dist/server/handlers/agent-builder.cjs +3 -3
- package/dist/server/handlers/agent-builder.d.ts +4 -4
- package/dist/server/handlers/agent-builder.js +3 -3
- package/dist/server/handlers/dynamic-workflows.cjs +6 -0
- package/dist/server/handlers/{stored-workflows.d.ts → dynamic-workflows.d.ts} +14 -14
- package/dist/server/handlers/{stored-workflows.d.ts.map → dynamic-workflows.d.ts.map} +1 -1
- package/dist/server/handlers/dynamic-workflows.js +2 -0
- package/dist/server/handlers/system.cjs +1 -1
- package/dist/server/handlers/system.js +1 -1
- package/dist/server/handlers/workflows.cjs +1 -1
- package/dist/server/handlers/workflows.d.ts +4 -4
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +7 -7
- package/dist/server/handlers.d.ts +1 -1
- package/dist/server/handlers.d.ts.map +1 -1
- package/dist/server/handlers.js +2 -2
- package/dist/server/schemas/{stored-workflows.d.ts → dynamic-workflows.d.ts} +13 -13
- package/dist/server/schemas/dynamic-workflows.d.ts.map +1 -0
- package/dist/server/schemas/index.cjs +2 -2
- package/dist/server/schemas/index.js +2 -2
- package/dist/server/schemas/workflows.d.ts +2 -2
- package/dist/server/server-adapter/index.cjs +1 -1
- package/dist/server/server-adapter/index.js +1 -1
- package/dist/server/server-adapter/routes/agent-builder.d.ts +4 -4
- package/dist/server/server-adapter/routes/dynamic-workflows.d.ts +16 -0
- package/dist/server/server-adapter/routes/dynamic-workflows.d.ts.map +1 -0
- package/dist/server/server-adapter/routes/index.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/workflows.d.ts +4 -4
- package/dist/{workflows-Dzxr6cmf.cjs → workflows-BPDvo87u.cjs} +2 -2
- package/dist/workflows-BPDvo87u.cjs.map +1 -0
- package/dist/{workflows-CMU5dz_4.js → workflows-Dzl1i83M.js} +2 -2
- package/dist/workflows-Dzl1i83M.js.map +1 -0
- package/package.json +8 -8
- package/dist/dist-BKRMiJcn.js.map +0 -1
- package/dist/dist-C2-SedDQ.cjs.map +0 -1
- package/dist/routes-CZwPlO3-.cjs.map +0 -1
- package/dist/routes-HUaCyUb7.js.map +0 -1
- package/dist/server/handlers/stored-workflows.cjs +0 -6
- package/dist/server/handlers/stored-workflows.js +0 -2
- package/dist/server/schemas/stored-workflows.d.ts.map +0 -1
- package/dist/server/server-adapter/routes/stored-workflows.d.ts +0 -16
- package/dist/server/server-adapter/routes/stored-workflows.d.ts.map +0 -1
- package/dist/stored-workflows-OanG0TmB.js.map +0 -1
- package/dist/stored-workflows-pCiWK305.cjs.map +0 -1
- package/dist/workflows-CMU5dz_4.js.map +0 -1
- package/dist/workflows-Dzxr6cmf.cjs.map +0 -1
|
@@ -5962,7 +5962,7 @@ function splitLines(text) {
|
|
|
5962
5962
|
return result;
|
|
5963
5963
|
}
|
|
5964
5964
|
//#endregion
|
|
5965
|
-
//#region ../memory/dist/src-
|
|
5965
|
+
//#region ../memory/dist/src-MScpLVRh.js
|
|
5966
5966
|
var __defProp$3 = Object.defineProperty;
|
|
5967
5967
|
var __exportAll = (all, no_symbols) => {
|
|
5968
5968
|
let target = {};
|
|
@@ -24383,33 +24383,62 @@ var TokenCounter = class TokenCounter {
|
|
|
24383
24383
|
if (isImageAttachment) await resolveImageDimensionsAsync(part);
|
|
24384
24384
|
return this.countAttachmentPartSync(part);
|
|
24385
24385
|
}
|
|
24386
|
+
/**
|
|
24387
|
+
* Count the name and the arguments of a tool call. Every state before the tool produces an
|
|
24388
|
+
* output holds the same call signature in the context window, so all of those states share
|
|
24389
|
+
* these cache kinds. `buildEstimateKey` hashes the text, so a shared kind stays correct and
|
|
24390
|
+
* keeps the estimate warm while the invocation moves from one state to the next.
|
|
24391
|
+
*/
|
|
24392
|
+
countToolCallSignature(part, invocation) {
|
|
24393
|
+
let tokens = 0;
|
|
24394
|
+
let overheadDelta = 0;
|
|
24395
|
+
if (invocation.toolName) tokens += this.readOrPersistPartEstimate(part, "tool-call-name", invocation.toolName);
|
|
24396
|
+
if (invocation.args) if (typeof invocation.args === "string") tokens += this.readOrPersistPartEstimate(part, "tool-call-args", invocation.args);
|
|
24397
|
+
else {
|
|
24398
|
+
const argsJson = JSON.stringify(invocation.args);
|
|
24399
|
+
tokens += this.readOrPersistPartEstimate(part, "tool-call-args-json", argsJson);
|
|
24400
|
+
overheadDelta -= 12;
|
|
24401
|
+
}
|
|
24402
|
+
return {
|
|
24403
|
+
tokens,
|
|
24404
|
+
overheadDelta
|
|
24405
|
+
};
|
|
24406
|
+
}
|
|
24386
24407
|
countNonAttachmentPart(part) {
|
|
24387
24408
|
let overheadDelta = 0;
|
|
24388
|
-
let
|
|
24409
|
+
let extraMessageDelta = 0;
|
|
24389
24410
|
if (part.type === "text") return {
|
|
24390
24411
|
tokens: this.readOrPersistPartEstimate(part, "text", part.text),
|
|
24391
24412
|
overheadDelta,
|
|
24392
|
-
|
|
24413
|
+
extraMessageDelta
|
|
24393
24414
|
};
|
|
24394
24415
|
if (part.type === "tool-invocation") {
|
|
24395
24416
|
const invocation = part.toolInvocation;
|
|
24417
|
+
const state = invocation.state;
|
|
24396
24418
|
let tokens = 0;
|
|
24397
|
-
if (
|
|
24398
|
-
|
|
24399
|
-
|
|
24400
|
-
|
|
24401
|
-
|
|
24402
|
-
|
|
24403
|
-
|
|
24404
|
-
|
|
24419
|
+
if (state === "call" || state === "partial-call" || state === "approval-requested") {
|
|
24420
|
+
const signature = this.countToolCallSignature(part, invocation);
|
|
24421
|
+
return {
|
|
24422
|
+
tokens: signature.tokens,
|
|
24423
|
+
overheadDelta: overheadDelta + signature.overheadDelta,
|
|
24424
|
+
extraMessageDelta
|
|
24425
|
+
};
|
|
24426
|
+
}
|
|
24427
|
+
if (state === "approval-responded") {
|
|
24428
|
+
extraMessageDelta++;
|
|
24429
|
+
const signature = this.countToolCallSignature(part, invocation);
|
|
24430
|
+
tokens += signature.tokens;
|
|
24431
|
+
overheadDelta += signature.overheadDelta;
|
|
24432
|
+
const reason = invocation.approval?.reason;
|
|
24433
|
+
if (reason) tokens += this.readOrPersistPartEstimate(part, "tool-approval-reason", reason);
|
|
24405
24434
|
return {
|
|
24406
24435
|
tokens,
|
|
24407
24436
|
overheadDelta,
|
|
24408
|
-
|
|
24437
|
+
extraMessageDelta
|
|
24409
24438
|
};
|
|
24410
24439
|
}
|
|
24411
|
-
if (
|
|
24412
|
-
|
|
24440
|
+
if (state === "result") {
|
|
24441
|
+
extraMessageDelta++;
|
|
24413
24442
|
const { value: resultForCounting, usingStoredModelOutput } = this.resolveToolResultForTokenCounting(part, invocation.result);
|
|
24414
24443
|
if (resultForCounting !== void 0) {
|
|
24415
24444
|
const contentTokens = this.countMultimodalToolResultContent(part, resultForCounting);
|
|
@@ -24423,47 +24452,45 @@ var TokenCounter = class TokenCounter {
|
|
|
24423
24452
|
return {
|
|
24424
24453
|
tokens,
|
|
24425
24454
|
overheadDelta,
|
|
24426
|
-
|
|
24455
|
+
extraMessageDelta
|
|
24427
24456
|
};
|
|
24428
24457
|
}
|
|
24429
|
-
if (
|
|
24430
|
-
|
|
24458
|
+
if (state === "output-denied") {
|
|
24459
|
+
extraMessageDelta++;
|
|
24431
24460
|
const reason = invocation.approval?.reason ?? "Tool call was not approved by the user";
|
|
24432
24461
|
tokens += this.readOrPersistPartEstimate(part, "tool-result-denied", reason);
|
|
24433
24462
|
return {
|
|
24434
24463
|
tokens,
|
|
24435
24464
|
overheadDelta,
|
|
24436
|
-
|
|
24465
|
+
extraMessageDelta
|
|
24437
24466
|
};
|
|
24438
24467
|
}
|
|
24439
|
-
if (
|
|
24440
|
-
|
|
24441
|
-
const
|
|
24442
|
-
const errorMessage = typeof errorText === "string" ? errorText : "Tool execution failed";
|
|
24468
|
+
if (state === "output-error") {
|
|
24469
|
+
extraMessageDelta++;
|
|
24470
|
+
const errorMessage = typeof invocation.errorText === "string" ? invocation.errorText : "Tool execution failed";
|
|
24443
24471
|
tokens += this.readOrPersistPartEstimate(part, "tool-result-error", errorMessage);
|
|
24444
24472
|
return {
|
|
24445
24473
|
tokens,
|
|
24446
24474
|
overheadDelta,
|
|
24447
|
-
|
|
24475
|
+
extraMessageDelta
|
|
24448
24476
|
};
|
|
24449
24477
|
}
|
|
24450
|
-
throw new Error(`Unhandled tool-invocation state '${part.toolInvocation?.state}' in token counting for part type '${part.type}'`);
|
|
24451
24478
|
}
|
|
24452
24479
|
if (typeof part.type === "string" && part.type.startsWith("data-")) return {
|
|
24453
24480
|
tokens: 0,
|
|
24454
24481
|
overheadDelta,
|
|
24455
|
-
|
|
24482
|
+
extraMessageDelta
|
|
24456
24483
|
};
|
|
24457
24484
|
if (part.type === "reasoning") return {
|
|
24458
24485
|
tokens: 0,
|
|
24459
24486
|
overheadDelta,
|
|
24460
|
-
|
|
24487
|
+
extraMessageDelta
|
|
24461
24488
|
};
|
|
24462
24489
|
const serialized = serializePartForTokenCounting(part);
|
|
24463
24490
|
return {
|
|
24464
24491
|
tokens: this.readOrPersistPartEstimate(part, `part-${part.type}`, serialized),
|
|
24465
24492
|
overheadDelta,
|
|
24466
|
-
|
|
24493
|
+
extraMessageDelta
|
|
24467
24494
|
};
|
|
24468
24495
|
}
|
|
24469
24496
|
/**
|
|
@@ -24472,7 +24499,7 @@ var TokenCounter = class TokenCounter {
|
|
|
24472
24499
|
countMessage(message) {
|
|
24473
24500
|
let payloadTokens = this.countString(message.role);
|
|
24474
24501
|
let overhead = TokenCounter.TOKENS_PER_MESSAGE;
|
|
24475
|
-
let
|
|
24502
|
+
let extraMessageCount = 0;
|
|
24476
24503
|
if (typeof message.content === "string") payloadTokens += this.readOrPersistMessageEstimate(message, "message-content", message.content);
|
|
24477
24504
|
else if (message.content && typeof message.content === "object") {
|
|
24478
24505
|
if (message.content.content && !Array.isArray(message.content.parts)) payloadTokens += this.readOrPersistMessageEstimate(message, "content-content", message.content.content);
|
|
@@ -24485,16 +24512,16 @@ var TokenCounter = class TokenCounter {
|
|
|
24485
24512
|
const result = this.countNonAttachmentPart(part);
|
|
24486
24513
|
payloadTokens += result.tokens;
|
|
24487
24514
|
overhead += result.overheadDelta;
|
|
24488
|
-
|
|
24515
|
+
extraMessageCount += result.extraMessageDelta;
|
|
24489
24516
|
}
|
|
24490
24517
|
}
|
|
24491
|
-
if (
|
|
24518
|
+
if (extraMessageCount > 0) overhead += extraMessageCount * TokenCounter.TOKENS_PER_MESSAGE;
|
|
24492
24519
|
return Math.round(payloadTokens + overhead);
|
|
24493
24520
|
}
|
|
24494
24521
|
async countMessageAsync(message) {
|
|
24495
24522
|
let payloadTokens = this.countString(message.role);
|
|
24496
24523
|
let overhead = TokenCounter.TOKENS_PER_MESSAGE;
|
|
24497
|
-
let
|
|
24524
|
+
let extraMessageCount = 0;
|
|
24498
24525
|
if (typeof message.content === "string") payloadTokens += this.readOrPersistMessageEstimate(message, "message-content", message.content);
|
|
24499
24526
|
else if (message.content && typeof message.content === "object") {
|
|
24500
24527
|
if (message.content.content && !Array.isArray(message.content.parts)) payloadTokens += this.readOrPersistMessageEstimate(message, "content-content", message.content.content);
|
|
@@ -24507,10 +24534,10 @@ var TokenCounter = class TokenCounter {
|
|
|
24507
24534
|
const result = this.countNonAttachmentPart(part);
|
|
24508
24535
|
payloadTokens += result.tokens;
|
|
24509
24536
|
overhead += result.overheadDelta;
|
|
24510
|
-
|
|
24537
|
+
extraMessageCount += result.extraMessageDelta;
|
|
24511
24538
|
}
|
|
24512
24539
|
}
|
|
24513
|
-
if (
|
|
24540
|
+
if (extraMessageCount > 0) overhead += extraMessageCount * TokenCounter.TOKENS_PER_MESSAGE;
|
|
24514
24541
|
return Math.round(payloadTokens + overhead);
|
|
24515
24542
|
}
|
|
24516
24543
|
/**
|
|
@@ -25605,6 +25632,7 @@ function deepMergeWorkingMemory(existing, update) {
|
|
|
25605
25632
|
for (const key of Object.keys(update)) {
|
|
25606
25633
|
const updateValue = update[key];
|
|
25607
25634
|
const existingValue = result[key];
|
|
25635
|
+
if (updateValue === void 0) continue;
|
|
25608
25636
|
if (updateValue === null) delete result[key];
|
|
25609
25637
|
else if (Array.isArray(updateValue)) result[key] = updateValue;
|
|
25610
25638
|
else if (typeof updateValue === "object" && updateValue !== null && typeof existingValue === "object" && existingValue !== null && !Array.isArray(existingValue)) result[key] = deepMergeWorkingMemory(existingValue, updateValue);
|
|
@@ -25657,7 +25685,7 @@ const updateWorkingMemoryTool = (memoryConfig) => {
|
|
|
25657
25685
|
version: 1,
|
|
25658
25686
|
vendor: "mastra",
|
|
25659
25687
|
validate: (value) => {
|
|
25660
|
-
const memoryValue = !!value && typeof value === "object" && !Array.isArray(value) && "memory" in value ? value.memory :
|
|
25688
|
+
const memoryValue = stripNullsFromOptional(!!value && typeof value === "object" && !Array.isArray(value) && "memory" in value ? value.memory : value, jsonSchema);
|
|
25661
25689
|
const result = validateMemory(memoryValue);
|
|
25662
25690
|
return result instanceof Promise ? result.then(toWrappedResult) : toWrappedResult(result);
|
|
25663
25691
|
},
|
|
@@ -25674,6 +25702,7 @@ const updateWorkingMemoryTool = (memoryConfig) => {
|
|
|
25674
25702
|
id: "update-working-memory",
|
|
25675
25703
|
description: schema ? useStateSignals ? `${stateSignalsPreamble} Data is merged with existing memory — only include fields you want to add or update.` : `Update the working memory with new information. Data is merged with existing memory - only include fields you want to add or update. To preserve existing data, omit the field entirely. Arrays are replaced entirely when provided, so pass the complete array or omit it to keep the existing values.` : useStateSignals ? `${stateSignalsPreamble} Pass the full updated Markdown blob as a string in the memory field.` : `Update the working memory with new information. Any data not included will be overwritten. Always pass data as string to the memory field. Never pass an object.`,
|
|
25676
25704
|
inputSchema,
|
|
25705
|
+
...usesMergeSemantics ? { strict: false } : {},
|
|
25677
25706
|
execute: async (inputData, context) => {
|
|
25678
25707
|
const workingMemoryInput = inputData;
|
|
25679
25708
|
const threadId = context?.agent?.threadId;
|
|
@@ -44749,4 +44778,4 @@ const agentBuilderWorkflows = {
|
|
|
44749
44778
|
//#endregion
|
|
44750
44779
|
exports.agentBuilderWorkflows = agentBuilderWorkflows;
|
|
44751
44780
|
|
|
44752
|
-
//# sourceMappingURL=dist-
|
|
44781
|
+
//# sourceMappingURL=dist-fvOsjRn_.cjs.map
|