@mastra/lance 1.3.0-alpha.0 → 1.3.0-alpha.2
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 +28 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/guides-rag-vector-databases.md +41 -0
- package/dist/index.cjs +15 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -6
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +10 -2
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @mastra/lance
|
|
2
2
|
|
|
3
|
+
## 1.3.0-alpha.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed generated thread titles being clobbered during a turn ([#21041](https://github.com/mastra-ai/mastra/pull/21041))
|
|
8
|
+
|
|
9
|
+
`updateThread` required both `title` and `metadata`, so callers that only needed to
|
|
10
|
+
change metadata (message persistence, working memory, observational memory, channel
|
|
11
|
+
subscriptions) had to read the thread and pass its title back. When title generation
|
|
12
|
+
finished between that read and the write, the freshly generated title was overwritten
|
|
13
|
+
with the stale one.
|
|
14
|
+
|
|
15
|
+
`title` and `metadata` are now independently optional: omitting one leaves that column
|
|
16
|
+
untouched. Callers that only change metadata no longer send a title, and message
|
|
17
|
+
persistence no longer rewrites a thread row it just read.
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [[`1c75e32`](https://github.com/mastra-ai/mastra/commit/1c75e32f7fc0b9fb6f548b4407feaec8a1440212), [`c47165c`](https://github.com/mastra-ai/mastra/commit/c47165c983c87594c6952f1fd2fa51a90205034c), [`e08e789`](https://github.com/mastra-ai/mastra/commit/e08e789c1bf4cd2fe46363f7a4728536ceccc9bd), [`35cc901`](https://github.com/mastra-ai/mastra/commit/35cc90102cf834a84827acaf9eee0b6d6d1e2a3b), [`a8b4cf0`](https://github.com/mastra-ai/mastra/commit/a8b4cf02823cffebc4751a53337dfacf097c1ae1), [`f33264f`](https://github.com/mastra-ai/mastra/commit/f33264f517ae603279afd5c4251e2b40f6dd3618), [`689f2c4`](https://github.com/mastra-ai/mastra/commit/689f2c4b6c0835fe455702b01d21daa8abcd9331), [`eeae63e`](https://github.com/mastra-ai/mastra/commit/eeae63e7fbe8e1f237adc69bca6e2ac13c5ca907), [`4c186a0`](https://github.com/mastra-ai/mastra/commit/4c186a017275f45e6ed4c09de0f89550e2d09e8c), [`b0fa077`](https://github.com/mastra-ai/mastra/commit/b0fa077bcbc9b08551846fe372a0d3d15b71ed72)]:
|
|
20
|
+
- @mastra/core@1.58.0-alpha.8
|
|
21
|
+
|
|
22
|
+
## 1.3.0-alpha.1
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Fixed resource-scoped message includes across storage adapters so included context cannot cross resource boundaries. ([#20984](https://github.com/mastra-ai/mastra/pull/20984))
|
|
27
|
+
|
|
28
|
+
- Updated dependencies [[`6445eba`](https://github.com/mastra-ai/mastra/commit/6445eba6020abac681aba1cc9289f446cb400cbe), [`df31eb0`](https://github.com/mastra-ai/mastra/commit/df31eb0c7087d782a0d9346e467f9a4af4b0eef6), [`fcd0667`](https://github.com/mastra-ai/mastra/commit/fcd0667a4e378be35c9a1b1eb19cce78fbfd7282), [`bab06b1`](https://github.com/mastra-ai/mastra/commit/bab06b18923873a584bdfc71a6b4ec7fb4727fb7)]:
|
|
29
|
+
- @mastra/core@1.58.0-alpha.5
|
|
30
|
+
|
|
3
31
|
## 1.3.0-alpha.0
|
|
4
32
|
|
|
5
33
|
### Minor Changes
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -78,6 +78,35 @@ await store.upsert({
|
|
|
78
78
|
|
|
79
79
|
PostgreSQL with the pgvector extension is a good solution for teams already using PostgreSQL who want to minimize infrastructure complexity. For detailed setup instructions and best practices, see the [official pgvector repository](https://github.com/pgvector/pgvector).
|
|
80
80
|
|
|
81
|
+
**OracleDB**:
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import { OracleVector } from '@mastra/oracledb'
|
|
85
|
+
|
|
86
|
+
const store = new OracleVector({
|
|
87
|
+
id: 'oracle-vector',
|
|
88
|
+
user: process.env.ORACLE_DATABASE_USER,
|
|
89
|
+
password: process.env.ORACLE_DATABASE_PASSWORD,
|
|
90
|
+
connectString: process.env.ORACLE_DATABASE_CONNECT_STRING,
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
await store.createIndex({
|
|
94
|
+
indexName: 'myCollection',
|
|
95
|
+
dimension: 1536,
|
|
96
|
+
indexConfig: { type: 'none' },
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
await store.upsert({
|
|
100
|
+
indexName: 'myCollection',
|
|
101
|
+
vectors: embeddings,
|
|
102
|
+
metadata: chunks.map(chunk => ({ text: chunk.text })),
|
|
103
|
+
})
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Using Oracle Database Vector Search
|
|
107
|
+
|
|
108
|
+
OracleDB stores embeddings in native `VECTOR` columns and metadata in Oracle JSON. Exact search is the default; HNSW and IVF indexes can be configured for tuned deployments.
|
|
109
|
+
|
|
81
110
|
**Pinecone**:
|
|
82
111
|
|
|
83
112
|
```ts
|
|
@@ -410,6 +439,18 @@ Index names must:
|
|
|
410
439
|
- Example: `my_index_123` is valid
|
|
411
440
|
- Example: `my-index` is not valid (contains hyphen)
|
|
412
441
|
|
|
442
|
+
**OracleDB**:
|
|
443
|
+
|
|
444
|
+
Index names are logical Mastra names. OracleDB maps each logical index to a physical Oracle table internally.
|
|
445
|
+
|
|
446
|
+
Logical index names must:
|
|
447
|
+
|
|
448
|
+
- Be non-empty
|
|
449
|
+
- Be 512 characters or fewer
|
|
450
|
+
- Be stable for the lifetime of the vector index
|
|
451
|
+
- Example: `my_collection_123` is valid
|
|
452
|
+
- Example: `customer-support/docs:v1` is valid and is mapped to a safe Oracle table name
|
|
453
|
+
|
|
413
454
|
**Pinecone**:
|
|
414
455
|
|
|
415
456
|
Index names must:
|
package/dist/index.cjs
CHANGED
|
@@ -756,7 +756,7 @@ var StoreMemoryLance = class extends _mastra_core_storage.MemoryStorage {
|
|
|
756
756
|
};
|
|
757
757
|
const record = {
|
|
758
758
|
id,
|
|
759
|
-
title,
|
|
759
|
+
title: title ?? current.title,
|
|
760
760
|
metadata: JSON.stringify(mergedMetadata),
|
|
761
761
|
updatedAt: (/* @__PURE__ */ new Date()).getTime()
|
|
762
762
|
};
|
|
@@ -869,7 +869,7 @@ var StoreMemoryLance = class extends _mastra_core_storage.MemoryStorage {
|
|
|
869
869
|
hasMore: false
|
|
870
870
|
};
|
|
871
871
|
if (perPage === 0 && include && include.length > 0) {
|
|
872
|
-
const includedMessages = await this._getIncludedMessages(table, include);
|
|
872
|
+
const includedMessages = await this._getIncludedMessages(table, include, resourceId);
|
|
873
873
|
const list = new _mastra_core_agent.MessageList().add(includedMessages, "memory");
|
|
874
874
|
return {
|
|
875
875
|
messages: this._sortMessages(list.get.all.db(), field, direction),
|
|
@@ -902,7 +902,7 @@ var StoreMemoryLance = class extends _mastra_core_storage.MemoryStorage {
|
|
|
902
902
|
const primaryPageCount = messages.length;
|
|
903
903
|
const messageIds = new Set(messages.map((m) => m.id));
|
|
904
904
|
if (include && include.length > 0) {
|
|
905
|
-
const includedMessages = await this._getIncludedMessages(table, include);
|
|
905
|
+
const includedMessages = await this._getIncludedMessages(table, include, resourceId);
|
|
906
906
|
for (const includeMsg of includedMessages) if (!messageIds.has(includeMsg.id)) {
|
|
907
907
|
messages.push(includeMsg);
|
|
908
908
|
messageIds.add(includeMsg.id);
|
|
@@ -1060,16 +1060,25 @@ var StoreMemoryLance = class extends _mastra_core_storage.MemoryStorage {
|
|
|
1060
1060
|
return direction === "ASC" ? aValue - bValue : bValue - aValue;
|
|
1061
1061
|
});
|
|
1062
1062
|
}
|
|
1063
|
-
|
|
1063
|
+
/**
|
|
1064
|
+
* Fetches the messages named by `include` together with their surrounding context.
|
|
1065
|
+
*
|
|
1066
|
+
* @param table - Open handle to the messages table.
|
|
1067
|
+
* @param include - Message ids to pin, each with an optional before/after window.
|
|
1068
|
+
* @param resourceId - When set, restricts both the pinned messages and their context
|
|
1069
|
+
* to that resource so an id from another resource returns nothing.
|
|
1070
|
+
*/
|
|
1071
|
+
async _getIncludedMessages(table, include, resourceId) {
|
|
1064
1072
|
if (include.length === 0) return [];
|
|
1073
|
+
const resourceCondition = resourceId ? ` AND resourceId = '${this.escapeSql(resourceId)}'` : "";
|
|
1065
1074
|
const targetIds = include.map((item) => item.id);
|
|
1066
1075
|
const idCondition = targetIds.length === 1 ? `id = '${this.escapeSql(targetIds[0])}'` : `id IN (${targetIds.map((id) => `'${this.escapeSql(id)}'`).join(", ")})`;
|
|
1067
|
-
const targetRecords = await table.query().where(idCondition).toArray();
|
|
1076
|
+
const targetRecords = await table.query().where(`${idCondition}${resourceCondition}`).toArray();
|
|
1068
1077
|
if (!include.some((item) => item.withPreviousMessages || item.withNextMessages)) return targetRecords.map((row) => this.normalizeMessage(row));
|
|
1069
1078
|
const threadIdsToFetch = [...new Set(targetRecords.map((r) => r.thread_id))];
|
|
1070
1079
|
const threadCache = /* @__PURE__ */ new Map();
|
|
1071
1080
|
for (const tid of threadIdsToFetch) {
|
|
1072
|
-
const threadRecords = await table.query().where(`thread_id = '${this.escapeSql(tid)}'`).toArray();
|
|
1081
|
+
const threadRecords = await table.query().where(`thread_id = '${this.escapeSql(tid)}'${resourceCondition}`).toArray();
|
|
1073
1082
|
threadRecords.sort((a, b) => a.createdAt - b.createdAt);
|
|
1074
1083
|
threadCache.set(tid, threadRecords);
|
|
1075
1084
|
}
|