@mastra/server 1.23.0 → 1.24.0-alpha.1
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 +32 -0
- package/dist/{chunk-TX3IIDZN.js → chunk-3CXXUF4P.js} +137 -45
- package/dist/chunk-3CXXUF4P.js.map +1 -0
- package/dist/{chunk-7TKB6WYH.js → chunk-6NY3T42O.js} +5 -3
- package/dist/chunk-6NY3T42O.js.map +1 -0
- package/dist/{chunk-IGUQV25I.js → chunk-7K4TRBNS.js} +10 -4
- package/dist/chunk-7K4TRBNS.js.map +1 -0
- package/dist/{chunk-XO5PXSFC.js → chunk-GIIEDO2K.js} +3 -3
- package/dist/{chunk-XO5PXSFC.js.map → chunk-GIIEDO2K.js.map} +1 -1
- package/dist/{chunk-MO3ZKWYY.js → chunk-J4VUM7GK.js} +547 -389
- package/dist/chunk-J4VUM7GK.js.map +1 -0
- package/dist/{chunk-KU4DBPKJ.cjs → chunk-JYST3GVF.cjs} +10 -4
- package/dist/chunk-JYST3GVF.cjs.map +1 -0
- package/dist/{chunk-3D2IBKF6.cjs → chunk-KAIOMGUE.cjs} +51 -25
- package/dist/chunk-KAIOMGUE.cjs.map +1 -0
- package/dist/{chunk-WZ6XPWVK.js → chunk-LUSXAYXR.js} +45 -19
- package/dist/chunk-LUSXAYXR.js.map +1 -0
- package/dist/{chunk-2KF7EWOT.cjs → chunk-MPLSILC4.cjs} +149 -57
- package/dist/chunk-MPLSILC4.cjs.map +1 -0
- package/dist/{chunk-4HHL4C6V.cjs → chunk-NYZJMFML.cjs} +11 -11
- package/dist/{chunk-4HHL4C6V.cjs.map → chunk-NYZJMFML.cjs.map} +1 -1
- package/dist/{chunk-UI3SS2JO.cjs → chunk-P6CD6Y4Z.cjs} +4 -4
- package/dist/{chunk-UI3SS2JO.cjs.map → chunk-P6CD6Y4Z.cjs.map} +1 -1
- package/dist/{chunk-UHWF2UKO.cjs → chunk-QOTVR5LN.cjs} +546 -388
- package/dist/chunk-QOTVR5LN.cjs.map +1 -0
- package/dist/{chunk-GNVZDFY5.cjs → chunk-SAOJYYFE.cjs} +5 -3
- package/dist/chunk-SAOJYYFE.cjs.map +1 -0
- package/dist/{chunk-T4RZ3X4I.js → chunk-SLPNFGM2.js} +3 -3
- package/dist/{chunk-T4RZ3X4I.js.map → chunk-SLPNFGM2.js.map} +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/{observational-memory-OVRHDQRG-OCHV6RZ7.cjs → observational-memory-S6YN56D3-FSYUYFQG.cjs} +26 -26
- package/dist/{observational-memory-OVRHDQRG-OCHV6RZ7.cjs.map → observational-memory-S6YN56D3-FSYUYFQG.cjs.map} +1 -1
- package/dist/{observational-memory-OVRHDQRG-RC3PRA65.js → observational-memory-S6YN56D3-UNZI7MEB.js} +3 -3
- package/dist/{observational-memory-OVRHDQRG-RC3PRA65.js.map → observational-memory-S6YN56D3-UNZI7MEB.js.map} +1 -1
- package/dist/server/handlers/agent-builder.cjs +16 -16
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/agent-versions.cjs +8 -8
- package/dist/server/handlers/agent-versions.d.ts.map +1 -1
- package/dist/server/handlers/agent-versions.js +1 -1
- package/dist/server/handlers/conversations.cjs +5 -5
- package/dist/server/handlers/conversations.js +1 -1
- package/dist/server/handlers/responses.cjs +4 -4
- package/dist/server/handlers/responses.d.ts +2 -2
- package/dist/server/handlers/responses.d.ts.map +1 -1
- package/dist/server/handlers/responses.js +1 -1
- package/dist/server/handlers.cjs +6 -6
- package/dist/server/handlers.js +3 -3
- package/dist/server/schemas/index.cjs +25 -25
- package/dist/server/schemas/index.js +2 -2
- package/dist/server/schemas/responses.d.ts +1 -1
- package/dist/server/schemas/responses.d.ts.map +1 -1
- package/dist/server/server-adapter/index.cjs +31 -31
- package/dist/server/server-adapter/index.js +4 -4
- package/dist/server/server-adapter/routes/responses.d.ts +2 -2
- package/package.json +5 -5
- package/dist/chunk-2KF7EWOT.cjs.map +0 -1
- package/dist/chunk-3D2IBKF6.cjs.map +0 -1
- package/dist/chunk-7TKB6WYH.js.map +0 -1
- package/dist/chunk-GNVZDFY5.cjs.map +0 -1
- package/dist/chunk-IGUQV25I.js.map +0 -1
- package/dist/chunk-KU4DBPKJ.cjs.map +0 -1
- package/dist/chunk-MO3ZKWYY.js.map +0 -1
- package/dist/chunk-TX3IIDZN.js.map +0 -1
- package/dist/chunk-UHWF2UKO.cjs.map +0 -1
- package/dist/chunk-WZ6XPWVK.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @mastra/server
|
|
2
2
|
|
|
3
|
+
## 1.24.0-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- **Fixed publishing older agent versions** ([#15154](https://github.com/mastra-ai/mastra/pull/15154))
|
|
8
|
+
|
|
9
|
+
Fixed agent editor to allow publishing older read-only versions. Previously, the Publish button was disabled when viewing a previous version. Now a "Publish This Version" button appears, enabling users to set any older version as the published version.
|
|
10
|
+
|
|
11
|
+
**Fixed Publish button being clickable without a saved draft**
|
|
12
|
+
|
|
13
|
+
The Publish button is now disabled until a draft version is saved. Previously, making edits would enable the Publish button even without a saved draft, which caused an error when clicked.
|
|
14
|
+
|
|
15
|
+
**Eliminated spurious 404 error logs for code-only agents**
|
|
16
|
+
|
|
17
|
+
The agent versions endpoint now checks both code-registered and stored agents before returning 404, and the frontend conditionally fetches stored agent details only when versions exist. This prevents noisy error logs when navigating to the editor for agents that haven't been published yet.
|
|
18
|
+
|
|
19
|
+
**Changed editor sections to be collapsed by default**
|
|
20
|
+
|
|
21
|
+
The System Prompt, Tools, and Variables sections in the agent editor are now collapsed by default when navigating to the editor page.
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [[`8db7663`](https://github.com/mastra-ai/mastra/commit/8db7663c9a9c735828094c359d2e327fd4f8fba3), [`715710d`](https://github.com/mastra-ai/mastra/commit/715710d12fa47cf88e09d41f13843eddc29327b0), [`378c6c4`](https://github.com/mastra-ai/mastra/commit/378c6c4755726e8d8cf83a14809b350b90d46c62), [`9f91fd5`](https://github.com/mastra-ai/mastra/commit/9f91fd538ab2a44f8cc740bcad8e51205f74fbea), [`ba6fa9c`](https://github.com/mastra-ai/mastra/commit/ba6fa9cc0f3e1912c49fd70d4c3bb8c44903ddaa)]:
|
|
24
|
+
- @mastra/core@1.24.0-alpha.1
|
|
25
|
+
|
|
26
|
+
## 1.23.1-alpha.0
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- Fixed the Responses API to use the agent default model when create requests omit model. ([#15140](https://github.com/mastra-ai/mastra/pull/15140))
|
|
31
|
+
|
|
32
|
+
- Updated dependencies [[`153e864`](https://github.com/mastra-ai/mastra/commit/153e86476b425db7cd0dc8490050096e92964a38)]:
|
|
33
|
+
- @mastra/core@1.23.1-alpha.0
|
|
34
|
+
|
|
3
35
|
## 1.23.0
|
|
4
36
|
|
|
5
37
|
### Patch Changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __commonJS as __commonJS$3, require_token_error as require_token_error$2, __toESM as __toESM$3 } from './chunk-JWVHBH4H.js';
|
|
2
2
|
import { __commonJS as __commonJS$1, require_token_error, __toESM } from './chunk-BZZVTO7B.js';
|
|
3
3
|
import { __commonJS as __commonJS$2, require_token_error as require_token_error$1, __toESM as __toESM$1 } from './chunk-PWAXLHKP.js';
|
|
4
|
-
import { e, truncateStringByTokens, estimateTokenCount, resolveToolResultValue, formatToolResultForObserver } from './chunk-
|
|
4
|
+
import { e, truncateStringByTokens, estimateTokenCount, resolveToolResultValue, formatToolResultForObserver } from './chunk-J4VUM7GK.js';
|
|
5
5
|
import { openai } from './chunk-PALNMAC6.js';
|
|
6
6
|
import { LIST_WORKFLOWS_ROUTE, GET_WORKFLOW_BY_ID_ROUTE, LIST_WORKFLOW_RUNS_ROUTE, GET_WORKFLOW_RUN_BY_ID_ROUTE, CREATE_WORKFLOW_RUN_ROUTE, STREAM_WORKFLOW_ROUTE, START_ASYNC_WORKFLOW_ROUTE, START_WORKFLOW_RUN_ROUTE, OBSERVE_STREAM_WORKFLOW_ROUTE, RESUME_ASYNC_WORKFLOW_ROUTE, RESUME_WORKFLOW_ROUTE, RESUME_STREAM_WORKFLOW_ROUTE, CANCEL_WORKFLOW_RUN_ROUTE, STREAM_LEGACY_WORKFLOW_ROUTE, OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE } from './chunk-TTIBLMTX.js';
|
|
7
7
|
import { actionIdPathParams, actionRunPathParams, streamAgentBuilderBodySchema, startAsyncAgentBuilderBodySchema, resumeAgentBuilderBodySchema, streamLegacyAgentBuilderBodySchema } from './chunk-S7PYDU5I.js';
|
|
@@ -16118,10 +16118,16 @@ var DefaultEmbedManyResult3 = class {
|
|
|
16118
16118
|
};
|
|
16119
16119
|
createIdGenerator3({ prefix: "aiobj", size: 24 });
|
|
16120
16120
|
createIdGenerator3({ prefix: "aiobj", size: 24 });
|
|
16121
|
+
function getMessageParts(msg) {
|
|
16122
|
+
if (typeof msg.content === "string") return [];
|
|
16123
|
+
if (Array.isArray(msg.content)) return msg.content;
|
|
16124
|
+
const parts = msg.content?.parts;
|
|
16125
|
+
return Array.isArray(parts) ? parts : [];
|
|
16126
|
+
}
|
|
16121
16127
|
function hasVisibleParts(msg) {
|
|
16122
16128
|
if (typeof msg.content === "string") return msg.content.length > 0;
|
|
16123
|
-
const parts = msg
|
|
16124
|
-
if (
|
|
16129
|
+
const parts = getMessageParts(msg);
|
|
16130
|
+
if (parts.length === 0) return Boolean(msg.content?.content);
|
|
16125
16131
|
return parts.some((p) => !p.type?.startsWith("data-"));
|
|
16126
16132
|
}
|
|
16127
16133
|
function parseRangeFormat(cursor) {
|
|
@@ -16382,13 +16388,13 @@ function lowDetailPartLimit(type) {
|
|
|
16382
16388
|
if (type === "tool-result" || type === "tool-call") return AUTO_EXPAND_TOOL_TOKENS;
|
|
16383
16389
|
return LOW_DETAIL_PART_TOKENS;
|
|
16384
16390
|
}
|
|
16385
|
-
function makePart(msg, partIndex, type, fullText, detail) {
|
|
16391
|
+
function makePart(msg, partIndex, type, fullText, detail, toolName) {
|
|
16386
16392
|
if (detail === "high") {
|
|
16387
|
-
return { messageId: msg.id, partIndex, role: msg.role, type, text: fullText, fullText };
|
|
16393
|
+
return { messageId: msg.id, partIndex, role: msg.role, type, text: fullText, fullText, toolName };
|
|
16388
16394
|
}
|
|
16389
16395
|
const hint = `recall cursor="${msg.id}" partIndex=${partIndex} detail="high"`;
|
|
16390
16396
|
const { text: text42 } = truncateByTokens(fullText, lowDetailPartLimit(type), hint);
|
|
16391
|
-
return { messageId: msg.id, partIndex, role: msg.role, type, text: text42, fullText };
|
|
16397
|
+
return { messageId: msg.id, partIndex, role: msg.role, type, text: text42, fullText, toolName };
|
|
16392
16398
|
}
|
|
16393
16399
|
function formatMessageParts(msg, detail) {
|
|
16394
16400
|
const parts = [];
|
|
@@ -16396,32 +16402,73 @@ function formatMessageParts(msg, detail) {
|
|
|
16396
16402
|
parts.push(makePart(msg, 0, "text", msg.content, detail));
|
|
16397
16403
|
return parts;
|
|
16398
16404
|
}
|
|
16399
|
-
|
|
16400
|
-
|
|
16401
|
-
|
|
16405
|
+
const messageParts = getMessageParts(msg);
|
|
16406
|
+
if (messageParts.length > 0) {
|
|
16407
|
+
for (let i = 0; i < messageParts.length; i++) {
|
|
16408
|
+
const part = messageParts[i];
|
|
16402
16409
|
const partType = part.type;
|
|
16403
16410
|
if (partType === "text") {
|
|
16404
16411
|
const text42 = part.text;
|
|
16405
|
-
|
|
16412
|
+
if (text42) {
|
|
16413
|
+
parts.push(makePart(msg, i, "text", text42, detail));
|
|
16414
|
+
}
|
|
16406
16415
|
} else if (partType === "tool-invocation") {
|
|
16407
16416
|
const inv = part.toolInvocation;
|
|
16408
|
-
if (inv
|
|
16409
|
-
const
|
|
16410
|
-
|
|
16411
|
-
|
|
16412
|
-
);
|
|
16413
|
-
const resultStr = formatToolResultForObserver(resultValue, { maxTokens: HIGH_DETAIL_TOOL_RESULT_TOKENS });
|
|
16414
|
-
const fullText = `[Tool Result: ${inv.toolName}]
|
|
16415
|
-
${resultStr}`;
|
|
16416
|
-
parts.push(makePart(msg, i, "tool-result", fullText, detail));
|
|
16417
|
-
} else {
|
|
16418
|
-
const argsStr = detail === "low" ? "" : `
|
|
16417
|
+
if (inv?.toolName) {
|
|
16418
|
+
const hasArgs = inv.args != null;
|
|
16419
|
+
if (inv.state !== "partial-call" && hasArgs) {
|
|
16420
|
+
const argsStr = detail === "low" ? "" : `
|
|
16419
16421
|
${JSON.stringify(inv.args, null, 2)}`;
|
|
16420
|
-
|
|
16421
|
-
|
|
16422
|
+
const fullText = `[Tool Call: ${inv.toolName}]${argsStr}`;
|
|
16423
|
+
parts.push({
|
|
16424
|
+
messageId: msg.id,
|
|
16425
|
+
partIndex: i,
|
|
16426
|
+
role: msg.role,
|
|
16427
|
+
type: "tool-call",
|
|
16428
|
+
text: fullText,
|
|
16429
|
+
fullText,
|
|
16430
|
+
toolName: inv.toolName
|
|
16431
|
+
});
|
|
16432
|
+
}
|
|
16433
|
+
if (inv.state === "result") {
|
|
16434
|
+
const { value: resultValue } = resolveToolResultValue(
|
|
16435
|
+
part,
|
|
16436
|
+
inv.result
|
|
16437
|
+
);
|
|
16438
|
+
const resultStr = formatToolResultForObserver(resultValue, { maxTokens: HIGH_DETAIL_TOOL_RESULT_TOKENS });
|
|
16439
|
+
const fullText = `[Tool Result: ${inv.toolName}]
|
|
16440
|
+
${resultStr}`;
|
|
16441
|
+
parts.push(makePart(msg, i, "tool-result", fullText, detail, inv.toolName));
|
|
16442
|
+
}
|
|
16443
|
+
}
|
|
16444
|
+
} else if (partType === "tool-call") {
|
|
16445
|
+
const toolName = part.toolName;
|
|
16446
|
+
if (toolName) {
|
|
16447
|
+
const rawArgs = part.input ?? part.args;
|
|
16448
|
+
const argsStr = detail === "low" || rawArgs == null ? "" : `
|
|
16449
|
+
${typeof rawArgs === "string" ? rawArgs : JSON.stringify(rawArgs, null, 2)}`;
|
|
16450
|
+
const fullText = `[Tool Call: ${toolName}]${argsStr}`;
|
|
16451
|
+
parts.push({
|
|
16452
|
+
messageId: msg.id,
|
|
16453
|
+
partIndex: i,
|
|
16454
|
+
role: msg.role,
|
|
16455
|
+
type: "tool-call",
|
|
16456
|
+
text: fullText,
|
|
16457
|
+
fullText,
|
|
16458
|
+
toolName
|
|
16459
|
+
});
|
|
16460
|
+
}
|
|
16461
|
+
} else if (partType === "tool-result") {
|
|
16462
|
+
const toolName = part.toolName;
|
|
16463
|
+
if (toolName) {
|
|
16464
|
+
const rawResult = part.output ?? part.result;
|
|
16465
|
+
const resultStr = formatToolResultForObserver(rawResult, { maxTokens: HIGH_DETAIL_TOOL_RESULT_TOKENS });
|
|
16466
|
+
const fullText = `[Tool Result: ${toolName}]
|
|
16467
|
+
${resultStr}`;
|
|
16468
|
+
parts.push(makePart(msg, i, "tool-result", fullText, detail, toolName));
|
|
16422
16469
|
}
|
|
16423
16470
|
} else if (partType === "reasoning") {
|
|
16424
|
-
const reasoning = part.reasoning;
|
|
16471
|
+
const reasoning = part.reasoning ?? part.text;
|
|
16425
16472
|
if (reasoning) {
|
|
16426
16473
|
parts.push(makePart(msg, i, "reasoning", reasoning, detail));
|
|
16427
16474
|
}
|
|
@@ -16560,7 +16607,7 @@ async function recallPart({
|
|
|
16560
16607
|
`Message ${cursor} has no visible content (it may be an internal system message). Try a neighboring message ID instead.`
|
|
16561
16608
|
);
|
|
16562
16609
|
}
|
|
16563
|
-
const target = allParts.find((p) => p.partIndex === partIndex);
|
|
16610
|
+
const target = [...allParts].reverse().find((p) => p.partIndex === partIndex);
|
|
16564
16611
|
if (!target) {
|
|
16565
16612
|
const availableIndices = allParts.map((p) => p.partIndex).join(", ");
|
|
16566
16613
|
const highestVisiblePartIndex = Math.max(...allParts.map((p) => p.partIndex));
|
|
@@ -16613,6 +16660,8 @@ async function recallMessages({
|
|
|
16613
16660
|
page = 1,
|
|
16614
16661
|
limit = 20,
|
|
16615
16662
|
detail = "low",
|
|
16663
|
+
partType,
|
|
16664
|
+
toolName,
|
|
16616
16665
|
threadScope,
|
|
16617
16666
|
maxTokens = DEFAULT_MAX_RESULT_TOKENS
|
|
16618
16667
|
}) {
|
|
@@ -16702,12 +16751,18 @@ async function recallMessages({
|
|
|
16702
16751
|
}
|
|
16703
16752
|
const hasNextPage = isForward ? hasMore : pageIndex > 0;
|
|
16704
16753
|
const hasPrevPage = isForward ? pageIndex > 0 : hasMore;
|
|
16705
|
-
|
|
16754
|
+
let allParts = [];
|
|
16706
16755
|
const timestamps = /* @__PURE__ */ new Map();
|
|
16707
16756
|
for (const msg of messages) {
|
|
16708
16757
|
timestamps.set(msg.id, msg.createdAt);
|
|
16709
16758
|
allParts.push(...formatMessageParts(msg, detail));
|
|
16710
16759
|
}
|
|
16760
|
+
if (toolName) {
|
|
16761
|
+
allParts = allParts.filter((p) => (p.type === "tool-call" || p.type === "tool-result") && p.toolName === toolName);
|
|
16762
|
+
}
|
|
16763
|
+
if (partType) {
|
|
16764
|
+
allParts = allParts.filter((p) => p.type === partType);
|
|
16765
|
+
}
|
|
16711
16766
|
if (detail === "high" && allParts.length > 0) {
|
|
16712
16767
|
const firstPart = allParts[0];
|
|
16713
16768
|
const sameMsgParts = allParts.filter((p) => p.messageId === firstPart.messageId);
|
|
@@ -16744,8 +16799,9 @@ High detail returns 1 part at a time. To continue: ${hints.join(", or ")}.`;
|
|
|
16744
16799
|
};
|
|
16745
16800
|
}
|
|
16746
16801
|
const rendered = renderFormattedParts(allParts, timestamps, { maxTokens });
|
|
16802
|
+
const emptyMessage = allParts.length === 0 ? partType || toolName ? "(no message parts matched the current filters)" : "(no visible message parts found for this page)" : "(no messages found)";
|
|
16747
16803
|
return {
|
|
16748
|
-
messages: rendered.text,
|
|
16804
|
+
messages: rendered.text || emptyMessage,
|
|
16749
16805
|
count: messages.length,
|
|
16750
16806
|
cursor,
|
|
16751
16807
|
page: normalizedPage,
|
|
@@ -16764,6 +16820,9 @@ async function recallThreadFromStart({
|
|
|
16764
16820
|
page = 1,
|
|
16765
16821
|
limit = 20,
|
|
16766
16822
|
detail = "low",
|
|
16823
|
+
partType,
|
|
16824
|
+
toolName,
|
|
16825
|
+
anchor = "start",
|
|
16767
16826
|
maxTokens = DEFAULT_MAX_RESULT_TOKENS
|
|
16768
16827
|
}) {
|
|
16769
16828
|
if (!memory) {
|
|
@@ -16789,29 +16848,37 @@ async function recallThreadFromStart({
|
|
|
16789
16848
|
resourceId,
|
|
16790
16849
|
page: 0,
|
|
16791
16850
|
perPage: fetchCount,
|
|
16792
|
-
orderBy: { field: "createdAt", direction: "ASC" }
|
|
16851
|
+
orderBy: { field: "createdAt", direction: anchor === "end" ? "DESC" : "ASC" }
|
|
16793
16852
|
});
|
|
16794
|
-
const visibleMessages = result.messages.filter(hasVisibleParts);
|
|
16795
|
-
const total = visibleMessages.length;
|
|
16853
|
+
const visibleMessages = anchor === "end" ? result.messages.slice(0, fetchCount).filter(hasVisibleParts).reverse() : result.messages.slice(0, fetchCount).filter(hasVisibleParts);
|
|
16796
16854
|
const skip = pageIndex * normalizedLimit;
|
|
16797
|
-
const hasMore = total > skip + normalizedLimit;
|
|
16798
16855
|
const messages = visibleMessages.slice(skip, skip + normalizedLimit);
|
|
16799
|
-
const
|
|
16856
|
+
const hasExtraMessage = visibleMessages.length > skip + messages.length;
|
|
16857
|
+
const hasNextPage = messages.length > 0 ? anchor === "end" ? pageIndex > 0 : hasExtraMessage : false;
|
|
16858
|
+
const hasPrevPage = messages.length > 0 ? anchor === "end" ? hasExtraMessage : pageIndex > 0 : pageIndex > 0;
|
|
16859
|
+
let allParts = [];
|
|
16800
16860
|
const timestamps = /* @__PURE__ */ new Map();
|
|
16801
16861
|
for (const msg of messages) {
|
|
16802
16862
|
timestamps.set(msg.id, msg.createdAt);
|
|
16803
16863
|
allParts.push(...formatMessageParts(msg, detail));
|
|
16804
16864
|
}
|
|
16865
|
+
if (toolName) {
|
|
16866
|
+
allParts = allParts.filter((p) => (p.type === "tool-call" || p.type === "tool-result") && p.toolName === toolName);
|
|
16867
|
+
}
|
|
16868
|
+
if (partType) {
|
|
16869
|
+
allParts = allParts.filter((p) => p.type === partType);
|
|
16870
|
+
}
|
|
16805
16871
|
const rendered = renderFormattedParts(allParts, timestamps, { maxTokens });
|
|
16872
|
+
const emptyMessage = messages.length === 0 ? pageIndex > 0 ? `(no messages found on page ${normalizedPage} for this thread)` : "(no messages in this thread)" : partType || toolName ? "(no message parts matched the current filters)" : "(no messages found)";
|
|
16806
16873
|
return {
|
|
16807
|
-
messages: rendered.text ||
|
|
16874
|
+
messages: rendered.text || emptyMessage,
|
|
16808
16875
|
count: messages.length,
|
|
16809
16876
|
cursor: messages[0]?.id || "",
|
|
16810
16877
|
page: normalizedPage,
|
|
16811
16878
|
limit: normalizedLimit,
|
|
16812
16879
|
detail,
|
|
16813
|
-
hasNextPage
|
|
16814
|
-
hasPrevPage
|
|
16880
|
+
hasNextPage,
|
|
16881
|
+
hasPrevPage,
|
|
16815
16882
|
truncated: rendered.truncated,
|
|
16816
16883
|
tokenOffset: rendered.tokenOffset
|
|
16817
16884
|
};
|
|
@@ -16828,7 +16895,9 @@ var recallTool = (_memoryConfig, options) => {
|
|
|
16828
16895
|
mode: z.enum(["messages", "threads", "search"]).optional().describe(
|
|
16829
16896
|
'What to retrieve. "messages" (default) pages through message history. "threads" lists all threads for the current user. "search" finds messages by semantic similarity across all threads.'
|
|
16830
16897
|
),
|
|
16831
|
-
threadId: z.string().min(1).optional().describe(
|
|
16898
|
+
threadId: z.string().min(1).optional().describe(
|
|
16899
|
+
'Browse a different thread, or use "current" for the active thread. Use mode="threads" first to discover thread IDs.'
|
|
16900
|
+
),
|
|
16832
16901
|
before: z.string().optional().describe(
|
|
16833
16902
|
'For mode="threads": only show threads created before this date. ISO 8601 or natural date string (e.g. "2026-03-15", "2026-03-10T00:00:00Z").'
|
|
16834
16903
|
),
|
|
@@ -16844,6 +16913,9 @@ var recallTool = (_memoryConfig, options) => {
|
|
|
16844
16913
|
cursor: z.string().min(1).optional().describe(
|
|
16845
16914
|
'A message ID to use as the pagination cursor. For mode="messages", provide either cursor or threadId. If only cursor is provided, it must belong to the current thread. Extract it from the start or end of an observation group range.'
|
|
16846
16915
|
),
|
|
16916
|
+
anchor: z.enum(["start", "end"]).optional().describe(
|
|
16917
|
+
'For mode="messages" without a cursor, page from the start (oldest-first) or end (newest-first) of the thread. Defaults to "start".'
|
|
16918
|
+
),
|
|
16847
16919
|
page: z.number().int().min(-50).max(50).optional().describe(
|
|
16848
16920
|
"Pagination offset. For messages: positive pages move forward from cursor, negative move backward. For threads: page number (0-indexed). 0 is treated as 1 for messages."
|
|
16849
16921
|
),
|
|
@@ -16851,6 +16923,10 @@ var recallTool = (_memoryConfig, options) => {
|
|
|
16851
16923
|
detail: z.enum(["low", "high"]).optional().describe(
|
|
16852
16924
|
'Detail level for messages. "low" (default) returns truncated text and tool names. "high" returns full content with tool args/results.'
|
|
16853
16925
|
),
|
|
16926
|
+
partType: z.enum(["text", "tool-call", "tool-result", "reasoning", "image", "file"]).optional().describe('Filter results to only include parts of this type. Only applies to mode="messages".'),
|
|
16927
|
+
toolName: z.string().min(1).optional().describe(
|
|
16928
|
+
'Filter results to only include tool-call and tool-result parts matching this tool name. Only applies to mode="messages".'
|
|
16929
|
+
),
|
|
16854
16930
|
partIndex: z.number().int().min(0).optional().describe(
|
|
16855
16931
|
"Fetch a single part from the cursor message by its positional index. When provided, returns only that part at high detail. Indices are shown as [p0], [p1], etc. in recall results."
|
|
16856
16932
|
)
|
|
@@ -16860,9 +16936,12 @@ var recallTool = (_memoryConfig, options) => {
|
|
|
16860
16936
|
query,
|
|
16861
16937
|
cursor,
|
|
16862
16938
|
threadId: explicitThreadId,
|
|
16939
|
+
anchor,
|
|
16863
16940
|
page,
|
|
16864
16941
|
limit,
|
|
16865
16942
|
detail,
|
|
16943
|
+
partType,
|
|
16944
|
+
toolName,
|
|
16866
16945
|
partIndex,
|
|
16867
16946
|
before,
|
|
16868
16947
|
after
|
|
@@ -16870,9 +16949,13 @@ var recallTool = (_memoryConfig, options) => {
|
|
|
16870
16949
|
const memory = context2?.memory;
|
|
16871
16950
|
const currentThreadId = context2?.agent?.threadId;
|
|
16872
16951
|
const resourceId = context2?.agent?.resourceId;
|
|
16952
|
+
const resolvedExplicitThreadId = explicitThreadId === "current" ? currentThreadId : explicitThreadId;
|
|
16873
16953
|
if (!memory) {
|
|
16874
16954
|
throw new Error("Memory instance is required for recall");
|
|
16875
16955
|
}
|
|
16956
|
+
if (explicitThreadId === "current" && !currentThreadId) {
|
|
16957
|
+
throw new Error("Could not resolve current thread.");
|
|
16958
|
+
}
|
|
16876
16959
|
if (mode === "search") {
|
|
16877
16960
|
if (!query) {
|
|
16878
16961
|
throw new Error('query is required for mode="search"');
|
|
@@ -16888,11 +16971,12 @@ var recallTool = (_memoryConfig, options) => {
|
|
|
16888
16971
|
topK: limit ?? 10,
|
|
16889
16972
|
before,
|
|
16890
16973
|
after,
|
|
16891
|
-
threadScope: !isResourceScope ? currentThreadId || void 0 : void 0
|
|
16974
|
+
threadScope: !isResourceScope ? currentThreadId || void 0 : resolvedExplicitThreadId || void 0
|
|
16892
16975
|
});
|
|
16893
16976
|
}
|
|
16894
16977
|
if (mode === "threads") {
|
|
16895
|
-
|
|
16978
|
+
const requestedCurrentThread = explicitThreadId === "current";
|
|
16979
|
+
if (!isResourceScope || requestedCurrentThread) {
|
|
16896
16980
|
if (!currentThreadId || !memory.getThreadById) {
|
|
16897
16981
|
return { error: "Could not resolve current thread." };
|
|
16898
16982
|
}
|
|
@@ -16900,6 +16984,9 @@ var recallTool = (_memoryConfig, options) => {
|
|
|
16900
16984
|
if (!thread) {
|
|
16901
16985
|
return { error: "Could not resolve current thread." };
|
|
16902
16986
|
}
|
|
16987
|
+
if (isResourceScope && resourceId && thread.resourceId !== resourceId) {
|
|
16988
|
+
throw new Error("Thread does not belong to the active resource");
|
|
16989
|
+
}
|
|
16903
16990
|
return {
|
|
16904
16991
|
threads: `- **${thread.title || "(untitled)"}** \u2190 current
|
|
16905
16992
|
id: ${thread.id}
|
|
@@ -16922,7 +17009,7 @@ var recallTool = (_memoryConfig, options) => {
|
|
|
16922
17009
|
after
|
|
16923
17010
|
});
|
|
16924
17011
|
}
|
|
16925
|
-
const hasExplicitThreadId = typeof
|
|
17012
|
+
const hasExplicitThreadId = typeof resolvedExplicitThreadId === "string" && resolvedExplicitThreadId.length > 0;
|
|
16926
17013
|
const hasCursor = typeof cursor === "string" && cursor.length > 0;
|
|
16927
17014
|
if (!hasExplicitThreadId && !hasCursor) {
|
|
16928
17015
|
throw new Error('Either cursor or threadId is required for mode="messages"');
|
|
@@ -16939,7 +17026,7 @@ var recallTool = (_memoryConfig, options) => {
|
|
|
16939
17026
|
if (!memory.getThreadById) {
|
|
16940
17027
|
throw new Error("Memory instance cannot verify thread access for recall");
|
|
16941
17028
|
}
|
|
16942
|
-
const thread = await memory.getThreadById({ threadId:
|
|
17029
|
+
const thread = await memory.getThreadById({ threadId: resolvedExplicitThreadId });
|
|
16943
17030
|
if (!thread || thread.resourceId !== resourceId) {
|
|
16944
17031
|
throw new Error("Thread does not belong to the active resource");
|
|
16945
17032
|
}
|
|
@@ -16980,7 +17067,10 @@ var recallTool = (_memoryConfig, options) => {
|
|
|
16980
17067
|
resourceId: isResourceScope ? resourceId : void 0,
|
|
16981
17068
|
page: page ?? 1,
|
|
16982
17069
|
limit: limit ?? 20,
|
|
16983
|
-
detail: detail ?? "low"
|
|
17070
|
+
detail: detail ?? "low",
|
|
17071
|
+
partType,
|
|
17072
|
+
toolName,
|
|
17073
|
+
anchor: anchor ?? "start"
|
|
16984
17074
|
});
|
|
16985
17075
|
}
|
|
16986
17076
|
if (partIndex !== void 0 && partIndex !== null) {
|
|
@@ -17001,6 +17091,8 @@ var recallTool = (_memoryConfig, options) => {
|
|
|
17001
17091
|
page,
|
|
17002
17092
|
limit,
|
|
17003
17093
|
detail: detail ?? "low",
|
|
17094
|
+
partType,
|
|
17095
|
+
toolName,
|
|
17004
17096
|
threadScope
|
|
17005
17097
|
});
|
|
17006
17098
|
}
|
|
@@ -18126,7 +18218,7 @@ ${workingMemory}`;
|
|
|
18126
18218
|
"Observational memory requires @mastra/core support for request-response-id-rotation. Please bump @mastra/core to a newer version."
|
|
18127
18219
|
);
|
|
18128
18220
|
}
|
|
18129
|
-
const { ObservationalMemory: OMClass } = await import('./observational-memory-
|
|
18221
|
+
const { ObservationalMemory: OMClass } = await import('./observational-memory-S6YN56D3-UNZI7MEB.js');
|
|
18130
18222
|
const onIndexObservations = this.hasRetrievalSearch(omConfig.retrieval) ? async (observation) => {
|
|
18131
18223
|
await this.indexObservation(observation);
|
|
18132
18224
|
} : void 0;
|
|
@@ -19049,7 +19141,7 @@ Notes:
|
|
|
19049
19141
|
if (!effectiveConfig) return null;
|
|
19050
19142
|
const engine = await this.omEngine;
|
|
19051
19143
|
if (!engine) return null;
|
|
19052
|
-
const { ObservationalMemoryProcessor } = await import('./observational-memory-
|
|
19144
|
+
const { ObservationalMemoryProcessor } = await import('./observational-memory-S6YN56D3-UNZI7MEB.js');
|
|
19053
19145
|
return new ObservationalMemoryProcessor(engine, this);
|
|
19054
19146
|
}
|
|
19055
19147
|
};
|
|
@@ -30254,5 +30346,5 @@ var OBSERVE_STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE = createRoute({
|
|
|
30254
30346
|
});
|
|
30255
30347
|
|
|
30256
30348
|
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, LIST_AGENT_BUILDER_ACTIONS_ROUTE, LIST_AGENT_BUILDER_ACTION_RUNS_ROUTE, OBSERVE_STREAM_AGENT_BUILDER_ACTION_ROUTE, OBSERVE_STREAM_LEGACY_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, agent_builder_exports };
|
|
30257
|
-
//# sourceMappingURL=chunk-
|
|
30258
|
-
//# sourceMappingURL=chunk-
|
|
30349
|
+
//# sourceMappingURL=chunk-3CXXUF4P.js.map
|
|
30350
|
+
//# sourceMappingURL=chunk-3CXXUF4P.js.map
|