@mastra/server 1.75.0-alpha.0 → 1.75.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/dist/{api-schema-manifest-BmraF-WX.js → api-schema-manifest-Cg5BAmJ6.js} +2 -2
- package/dist/{api-schema-manifest-BmraF-WX.js.map → api-schema-manifest-Cg5BAmJ6.js.map} +1 -1
- package/dist/{api-schema-manifest-Blh5-4VH.cjs → api-schema-manifest-hJw56vOw.cjs} +2 -2
- package/dist/{api-schema-manifest-Blh5-4VH.cjs.map → api-schema-manifest-hJw56vOw.cjs.map} +1 -1
- package/dist/{dist-DH39C5Bz.js → dist-BKGwFBci.js} +104 -38
- package/dist/{dist-DH39C5Bz.js.map → dist-BKGwFBci.js.map} +1 -1
- package/dist/{dist-IDt748Ya.cjs → dist-DL6nu99w.cjs} +104 -38
- package/dist/{dist-IDt748Ya.cjs.map → dist-DL6nu99w.cjs.map} +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/{routes-CcjyQojv.cjs → routes-mJga4N4C.cjs} +2 -2
- package/dist/{routes-CcjyQojv.cjs.map → routes-mJga4N4C.cjs.map} +1 -1
- package/dist/{routes-Boe1UThy.js → routes-obDo67aE.js} +2 -2
- package/dist/{routes-Boe1UThy.js.map → routes-obDo67aE.js.map} +1 -1
- package/dist/server/handlers/agent-builder.cjs +1 -1
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/agent-controller.cjs +1 -1
- package/dist/server/handlers/agent-controller.js +1 -1
- package/dist/server/handlers/agents.cjs +17 -1
- package/dist/server/handlers/agents.cjs.map +1 -1
- package/dist/server/handlers/agents.d.ts.map +1 -1
- package/dist/server/handlers/agents.js +17 -1
- package/dist/server/handlers/agents.js.map +1 -1
- package/dist/server/handlers/conversations.cjs +1 -1
- package/dist/server/handlers/conversations.js +1 -1
- package/dist/server/handlers/logs.cjs +1 -1
- package/dist/server/handlers/logs.js +1 -1
- package/dist/server/handlers/memory.cjs +1 -1
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers/plans.cjs +1 -1
- package/dist/server/handlers/plans.js +1 -1
- package/dist/server/handlers/responses.cjs +1 -1
- package/dist/server/handlers/responses.js +1 -1
- package/dist/server/handlers/responses.storage.cjs +1 -1
- package/dist/server/handlers/responses.storage.js +1 -1
- package/dist/server/handlers/system.cjs +1 -1
- package/dist/server/handlers/system.js +1 -1
- package/dist/server/handlers/tools.cjs +1 -1
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/utils.cjs +2 -1
- package/dist/server/handlers/utils.d.ts +6 -0
- package/dist/server/handlers/utils.d.ts.map +1 -1
- package/dist/server/handlers/utils.js +2 -2
- package/dist/server/handlers/workflow-builder.cjs +1 -1
- package/dist/server/handlers/workflow-builder.js +1 -1
- package/dist/server/handlers/workflows.cjs +1 -1
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/server-adapter/index.cjs +1 -1
- package/dist/server/server-adapter/index.js +1 -1
- package/dist/{utils-aIu3gkhJ.cjs → utils-HqDZJwRc.cjs} +31 -1
- package/dist/utils-HqDZJwRc.cjs.map +1 -0
- package/dist/{utils-KsERfbhc.js → utils-KcHk7C0D.js} +26 -2
- package/dist/utils-KcHk7C0D.js.map +1 -0
- package/dist/{workflow-builder-DTcM8ER3.cjs → workflow-builder-BSjQJCVD.cjs} +2 -2
- package/dist/{workflow-builder-DTcM8ER3.cjs.map → workflow-builder-BSjQJCVD.cjs.map} +1 -1
- package/dist/{workflow-builder-KRSpDol2.js → workflow-builder-DJ48IzXQ.js} +2 -2
- package/dist/{workflow-builder-KRSpDol2.js.map → workflow-builder-DJ48IzXQ.js.map} +1 -1
- package/package.json +6 -6
- package/dist/utils-KsERfbhc.js.map +0 -1
- package/dist/utils-aIu3gkhJ.cjs.map +0 -1
|
@@ -4637,7 +4637,7 @@ function splitLines(text) {
|
|
|
4637
4637
|
return result;
|
|
4638
4638
|
}
|
|
4639
4639
|
//#endregion
|
|
4640
|
-
//#region ../memory/dist/src-
|
|
4640
|
+
//#region ../memory/dist/src-CFTlELNa.js
|
|
4641
4641
|
var __defProp$3 = Object.defineProperty;
|
|
4642
4642
|
var __exportAll = (all, no_symbols) => {
|
|
4643
4643
|
let target = {};
|
|
@@ -37682,22 +37682,32 @@ var Memory = class Memory extends _mastra_core_memory.MastraMemory {
|
|
|
37682
37682
|
if (resourceScope && !resourceId && config?.semanticRecall && vectorSearchString) throw new Error("Memory error: Resource-scoped semantic recall is enabled but no resourceId was provided. Either provide a resourceId or explicitly set semanticRecall.scope to 'thread'.");
|
|
37683
37683
|
let usage;
|
|
37684
37684
|
if (config?.semanticRecall && vectorSearchString && this.vector) {
|
|
37685
|
-
const
|
|
37686
|
-
|
|
37687
|
-
const {
|
|
37688
|
-
|
|
37689
|
-
|
|
37690
|
-
if (typeof this.vector === `undefined`) throw new Error(`Tried to query vector index ${indexName} but this Memory instance doesn't have an attached vector db.`);
|
|
37691
|
-
const scopeFilter = resourceScope ? { resource_id: resourceId } : { thread_id: threadId };
|
|
37692
|
-
const userFilter = typeof config.semanticRecall === "object" ? config.semanticRecall.filter : void 0;
|
|
37693
|
-
const combinedFilter = userFilter ? { $and: [scopeFilter, userFilter] } : scopeFilter;
|
|
37685
|
+
const scopeFilter = resourceScope ? { resource_id: resourceId } : { thread_id: threadId };
|
|
37686
|
+
const userFilter = typeof config.semanticRecall === "object" ? config.semanticRecall.filter : void 0;
|
|
37687
|
+
const combinedFilter = userFilter ? { $and: [scopeFilter, userFilter] } : scopeFilter;
|
|
37688
|
+
if (this.isSelfEmbedding) {
|
|
37689
|
+
const { indexName } = await this.createEmbeddingIndex(void 0, config);
|
|
37694
37690
|
vectorResults.push(...await this.vector.query({
|
|
37695
37691
|
indexName,
|
|
37696
|
-
|
|
37692
|
+
queryText: vectorSearchString,
|
|
37697
37693
|
topK: vectorConfig.topK,
|
|
37698
37694
|
filter: combinedFilter
|
|
37699
37695
|
}));
|
|
37700
|
-
}
|
|
37696
|
+
} else {
|
|
37697
|
+
const result = await this.embedMessageContent(vectorSearchString);
|
|
37698
|
+
usage = result.usage;
|
|
37699
|
+
const { embeddings, dimension } = result;
|
|
37700
|
+
const { indexName } = await this.createEmbeddingIndex(dimension, config);
|
|
37701
|
+
await Promise.all(embeddings.map(async (embedding) => {
|
|
37702
|
+
if (typeof this.vector === `undefined`) throw new Error(`Tried to query vector index ${indexName} but this Memory instance doesn't have an attached vector db.`);
|
|
37703
|
+
vectorResults.push(...await this.vector.query({
|
|
37704
|
+
indexName,
|
|
37705
|
+
queryVector: embedding,
|
|
37706
|
+
topK: vectorConfig.topK,
|
|
37707
|
+
filter: combinedFilter
|
|
37708
|
+
}));
|
|
37709
|
+
}));
|
|
37710
|
+
}
|
|
37701
37711
|
}
|
|
37702
37712
|
const threshold = (typeof config.semanticRecall === "object" ? config.semanticRecall : void 0)?.threshold;
|
|
37703
37713
|
const filteredVectorResults = threshold !== void 0 ? vectorResults.filter((r) => r.score >= threshold) : vectorResults;
|
|
@@ -37855,11 +37865,13 @@ var Memory = class Memory extends _mastra_core_memory.MastraMemory {
|
|
|
37855
37865
|
if (this.vector) this.trackVectorCleanup(this.deleteThreadVectors(threadId));
|
|
37856
37866
|
}
|
|
37857
37867
|
/**
|
|
37858
|
-
* Prefix shared by every message index. The index for the default embedding
|
|
37859
|
-
*
|
|
37868
|
+
* Prefix shared by every message index. The index for the default embedding dimension is named
|
|
37869
|
+
* with the bare prefix; other dimensions add a dimension suffix, and a store that embeds the
|
|
37870
|
+
* text itself adds its own. Built here rather than read from `getEmbeddingIndexName()`, which
|
|
37871
|
+
* answers for one configuration and so would not match indexes written under another.
|
|
37860
37872
|
*/
|
|
37861
37873
|
get messageIndexPrefix() {
|
|
37862
|
-
return this.
|
|
37874
|
+
return `memory${this.vector?.indexSeparator ?? "_"}messages`;
|
|
37863
37875
|
}
|
|
37864
37876
|
/**
|
|
37865
37877
|
* Prefix shared by every observation index. Each observation index adds a dimension suffix.
|
|
@@ -38144,13 +38156,24 @@ ${workingMemory}`;
|
|
|
38144
38156
|
if (joined) textForEmbedding = joined;
|
|
38145
38157
|
}
|
|
38146
38158
|
if (!textForEmbedding) return;
|
|
38147
|
-
|
|
38148
|
-
|
|
38149
|
-
|
|
38159
|
+
let embeddings = [];
|
|
38160
|
+
let documents;
|
|
38161
|
+
let chunks;
|
|
38162
|
+
if (this.isSelfEmbedding) {
|
|
38163
|
+
chunks = this.chunkText(textForEmbedding);
|
|
38164
|
+
documents = chunks;
|
|
38165
|
+
} else {
|
|
38166
|
+
const result = await this.embedMessageContent(textForEmbedding);
|
|
38167
|
+
dimension = result.dimension;
|
|
38168
|
+
if (result.usage?.tokens) totalTokens += result.usage.tokens;
|
|
38169
|
+
embeddings = result.embeddings;
|
|
38170
|
+
chunks = result.chunks;
|
|
38171
|
+
}
|
|
38150
38172
|
const threadMetadata = message.threadId ? threadMetadataMap.get(message.threadId) || {} : {};
|
|
38151
38173
|
embeddingData.push({
|
|
38152
|
-
embeddings
|
|
38153
|
-
|
|
38174
|
+
embeddings,
|
|
38175
|
+
documents,
|
|
38176
|
+
metadata: chunks.map(() => ({
|
|
38154
38177
|
...threadMetadata,
|
|
38155
38178
|
message_id: message.id,
|
|
38156
38179
|
thread_id: message.threadId,
|
|
@@ -38161,16 +38184,23 @@ ${workingMemory}`;
|
|
|
38161
38184
|
}))
|
|
38162
38185
|
});
|
|
38163
38186
|
}));
|
|
38164
|
-
if (embeddingData.length > 0 && dimension !== void 0) {
|
|
38187
|
+
if (embeddingData.length > 0 && (this.isSelfEmbedding || dimension !== void 0)) {
|
|
38165
38188
|
if (typeof this.vector === `undefined`) throw new Error(`Tried to upsert embeddings but this Memory instance doesn't have an attached vector db.`);
|
|
38166
38189
|
const { indexName } = await this.createEmbeddingIndex(dimension, config);
|
|
38167
38190
|
const allVectors = [];
|
|
38168
38191
|
const allMetadata = [];
|
|
38192
|
+
const allDocuments = [];
|
|
38169
38193
|
for (const data of embeddingData) {
|
|
38170
38194
|
allVectors.push(...data.embeddings);
|
|
38195
|
+
if (data.documents) allDocuments.push(...data.documents);
|
|
38171
38196
|
allMetadata.push(...data.metadata);
|
|
38172
38197
|
}
|
|
38173
|
-
await this.vector.upsert({
|
|
38198
|
+
if (this.isSelfEmbedding) await this.vector.upsert({
|
|
38199
|
+
indexName,
|
|
38200
|
+
documents: allDocuments,
|
|
38201
|
+
metadata: allMetadata
|
|
38202
|
+
});
|
|
38203
|
+
else await this.vector.upsert({
|
|
38174
38204
|
indexName,
|
|
38175
38205
|
vectors: allVectors,
|
|
38176
38206
|
metadata: allMetadata
|
|
@@ -38955,11 +38985,22 @@ Notes:
|
|
|
38955
38985
|
}
|
|
38956
38986
|
}
|
|
38957
38987
|
if (textForEmbedding) {
|
|
38958
|
-
|
|
38959
|
-
|
|
38988
|
+
let embeddings = [];
|
|
38989
|
+
let documents;
|
|
38990
|
+
let chunks;
|
|
38991
|
+
if (this.isSelfEmbedding) {
|
|
38992
|
+
chunks = this.chunkText(textForEmbedding);
|
|
38993
|
+
documents = chunks;
|
|
38994
|
+
} else {
|
|
38995
|
+
const result = await this.embedMessageContent(textForEmbedding);
|
|
38996
|
+
dimension = result.dimension;
|
|
38997
|
+
embeddings = result.embeddings;
|
|
38998
|
+
chunks = result.chunks;
|
|
38999
|
+
}
|
|
38960
39000
|
embeddingData.push({
|
|
38961
|
-
embeddings
|
|
38962
|
-
|
|
39001
|
+
embeddings,
|
|
39002
|
+
documents,
|
|
39003
|
+
metadata: chunks.map(() => ({
|
|
38963
39004
|
message_id: message.id,
|
|
38964
39005
|
thread_id: existingMessage.threadId,
|
|
38965
39006
|
resource_id: existingMessage.resourceId,
|
|
@@ -38994,15 +39035,22 @@ Notes:
|
|
|
38994
39035
|
} catch {
|
|
38995
39036
|
this.logger.debug("Failed to clean up old vectors during message update");
|
|
38996
39037
|
}
|
|
38997
|
-
if (embeddingData.length > 0 && dimension !== void 0) {
|
|
39038
|
+
if (embeddingData.length > 0 && (this.isSelfEmbedding || dimension !== void 0)) {
|
|
38998
39039
|
const { indexName } = await this.createEmbeddingIndex(dimension, config);
|
|
38999
39040
|
const allVectors = [];
|
|
39000
39041
|
const allMetadata = [];
|
|
39042
|
+
const allDocuments = [];
|
|
39001
39043
|
for (const data of embeddingData) {
|
|
39002
39044
|
allVectors.push(...data.embeddings);
|
|
39045
|
+
if (data.documents) allDocuments.push(...data.documents);
|
|
39003
39046
|
allMetadata.push(...data.metadata);
|
|
39004
39047
|
}
|
|
39005
|
-
await this.vector.upsert({
|
|
39048
|
+
if (this.isSelfEmbedding) await this.vector.upsert({
|
|
39049
|
+
indexName,
|
|
39050
|
+
documents: allDocuments,
|
|
39051
|
+
metadata: allMetadata
|
|
39052
|
+
});
|
|
39053
|
+
else await this.vector.upsert({
|
|
39006
39054
|
indexName,
|
|
39007
39055
|
vectors: allVectors,
|
|
39008
39056
|
metadata: allMetadata
|
|
@@ -39189,7 +39237,7 @@ Notes:
|
|
|
39189
39237
|
await this.rollbackCopiedThread(memoryStore, result.thread, "OM clone", false, priorDestinationResourceWm);
|
|
39190
39238
|
throw error;
|
|
39191
39239
|
}
|
|
39192
|
-
if (this.vector && this.embedder && config.semanticRecall) try {
|
|
39240
|
+
if (this.vector && (this.embedder || this.isSelfEmbedding) && config.semanticRecall) try {
|
|
39193
39241
|
await this.embedCopiedMessagesInBatches(memoryStore, result, config);
|
|
39194
39242
|
} catch (error) {
|
|
39195
39243
|
await this.rollbackCopiedThread(memoryStore, result.thread, "embedding", true, priorDestinationResourceWm);
|
|
@@ -39258,7 +39306,7 @@ Notes:
|
|
|
39258
39306
|
async updateThreadResourceId({ threadId, resourceId, memoryConfig }) {
|
|
39259
39307
|
const memoryStore = await this.getMemoryStore();
|
|
39260
39308
|
const config = this.getMergedThreadConfig(memoryConfig);
|
|
39261
|
-
const migratesVectors = Boolean(this.vector && this.embedder && config.semanticRecall);
|
|
39309
|
+
const migratesVectors = Boolean(this.vector && (this.embedder || this.isSelfEmbedding) && config.semanticRecall);
|
|
39262
39310
|
if (!migratesVectors) {
|
|
39263
39311
|
const existing = await memoryStore.getThreadById({ threadId });
|
|
39264
39312
|
if (existing && existing.resourceId === resourceId) return existing;
|
|
@@ -39364,7 +39412,7 @@ Notes:
|
|
|
39364
39412
|
* This is similar to the embedding logic in saveMessages but operates on already-saved messages.
|
|
39365
39413
|
*/
|
|
39366
39414
|
async embedClonedMessages(messages, config) {
|
|
39367
|
-
if (!this.vector || !this.embedder) return;
|
|
39415
|
+
if (!this.vector || !this.embedder && !this.isSelfEmbedding) return;
|
|
39368
39416
|
const embeddingData = [];
|
|
39369
39417
|
let dimension;
|
|
39370
39418
|
await Promise.all(messages.map(async (message) => {
|
|
@@ -39375,11 +39423,22 @@ Notes:
|
|
|
39375
39423
|
if (joined) textForEmbedding = joined;
|
|
39376
39424
|
}
|
|
39377
39425
|
if (!textForEmbedding) return;
|
|
39378
|
-
|
|
39379
|
-
|
|
39426
|
+
let embeddings = [];
|
|
39427
|
+
let documents;
|
|
39428
|
+
let chunks;
|
|
39429
|
+
if (this.isSelfEmbedding) {
|
|
39430
|
+
chunks = this.chunkText(textForEmbedding);
|
|
39431
|
+
documents = chunks;
|
|
39432
|
+
} else {
|
|
39433
|
+
const result = await this.embedMessageContent(textForEmbedding);
|
|
39434
|
+
dimension = result.dimension;
|
|
39435
|
+
embeddings = result.embeddings;
|
|
39436
|
+
chunks = result.chunks;
|
|
39437
|
+
}
|
|
39380
39438
|
embeddingData.push({
|
|
39381
|
-
embeddings
|
|
39382
|
-
|
|
39439
|
+
embeddings,
|
|
39440
|
+
documents,
|
|
39441
|
+
metadata: chunks.map(() => ({
|
|
39383
39442
|
message_id: message.id,
|
|
39384
39443
|
thread_id: message.threadId,
|
|
39385
39444
|
resource_id: message.resourceId,
|
|
@@ -39389,15 +39448,22 @@ Notes:
|
|
|
39389
39448
|
}))
|
|
39390
39449
|
});
|
|
39391
39450
|
}));
|
|
39392
|
-
if (embeddingData.length > 0 && dimension !== void 0) {
|
|
39451
|
+
if (embeddingData.length > 0 && (this.isSelfEmbedding || dimension !== void 0)) {
|
|
39393
39452
|
const { indexName } = await this.createEmbeddingIndex(dimension, config);
|
|
39394
39453
|
const allVectors = [];
|
|
39395
39454
|
const allMetadata = [];
|
|
39455
|
+
const allDocuments = [];
|
|
39396
39456
|
for (const data of embeddingData) {
|
|
39397
39457
|
allVectors.push(...data.embeddings);
|
|
39458
|
+
if (data.documents) allDocuments.push(...data.documents);
|
|
39398
39459
|
allMetadata.push(...data.metadata);
|
|
39399
39460
|
}
|
|
39400
|
-
await this.vector.upsert({
|
|
39461
|
+
if (this.isSelfEmbedding) await this.vector.upsert({
|
|
39462
|
+
indexName,
|
|
39463
|
+
documents: allDocuments,
|
|
39464
|
+
metadata: allMetadata
|
|
39465
|
+
});
|
|
39466
|
+
else await this.vector.upsert({
|
|
39401
39467
|
indexName,
|
|
39402
39468
|
vectors: allVectors,
|
|
39403
39469
|
metadata: allMetadata
|
|
@@ -50374,4 +50440,4 @@ const agentBuilderWorkflows = {
|
|
|
50374
50440
|
//#endregion
|
|
50375
50441
|
exports.agentBuilderWorkflows = agentBuilderWorkflows;
|
|
50376
50442
|
|
|
50377
|
-
//# sourceMappingURL=dist-
|
|
50443
|
+
//# sourceMappingURL=dist-DL6nu99w.cjs.map
|