@mastra/mongodb 1.23.0 → 1.23.1-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/_types/@internal_core/dist/memory/index.d.ts +102 -0
- package/dist/_types/@internal_core/package.json +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-storage-composite.md +34 -0
- package/dist/docs/references/reference-vectors-mongodb.md +2 -1
- package/dist/index.cjs +1033 -393
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1034 -394
- package/dist/index.js.map +1 -1
- package/dist/storage/connectors/MongoDBConnector.d.ts +10 -3
- package/dist/storage/connectors/MongoDBConnector.d.ts.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +31 -11
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/run-fencing.d.ts +39 -0
- package/dist/storage/domains/run-fencing.d.ts.map +1 -0
- package/dist/storage/domains/workflows/index.d.ts +26 -9
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/retention.d.ts +9 -5
- package/dist/storage/retention.d.ts.map +1 -1
- package/package.json +6 -5
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
//#region src/memory/index.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Shared rules for observational memory lifecycle writes. Every storage adapter applies
|
|
4
|
+
* these inside its own atomic section (lock, transaction, or conditional update), so the
|
|
5
|
+
* decisions are identical across adapters.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Observational memory columns that lifecycle writes depend on. Storage adapters merge these
|
|
9
|
+
* into the table schema they get from `@mastra/core`, so the columns exist even when the
|
|
10
|
+
* installed core predates them.
|
|
11
|
+
*/
|
|
12
|
+
declare const OBSERVATIONAL_MEMORY_LIFECYCLE_COLUMNS: {
|
|
13
|
+
readonly supersededBy: {
|
|
14
|
+
readonly type: 'text';
|
|
15
|
+
readonly nullable: true;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
/** `schema` plus {@link OBSERVATIONAL_MEMORY_LIFECYCLE_COLUMNS}; `undefined` when `schema` is. */
|
|
19
|
+
declare function withObservationalMemoryLifecycleColumns<T extends object>(schema: T | undefined): (T & typeof OBSERVATIONAL_MEMORY_LIFECYCLE_COLUMNS) | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Result of `commitActiveObservations`.
|
|
22
|
+
*/
|
|
23
|
+
interface UpdateActiveObservationsResult {
|
|
24
|
+
/** Whether the observations were written. */
|
|
25
|
+
applied: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Why nothing was written: `retired` — the target record was superseded by a newer
|
|
28
|
+
* generation; `conflict` — `expectedActiveObservations` no longer matches the stored text.
|
|
29
|
+
*/
|
|
30
|
+
reason?: 'retired' | 'conflict';
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Result of `appendBufferedObservations`.
|
|
34
|
+
*
|
|
35
|
+
* The append targets the head generation: when `input.id` was superseded, the chunk is
|
|
36
|
+
* appended to the current head instead. The append is skipped (`persisted: false`) when the
|
|
37
|
+
* head already holds a chunk with the same `cycleId`, or when the chunk is wholly covered by
|
|
38
|
+
* the head's cursor. Chunks carry `lastObservedAt = max message time + 1ms`, so a chunk is
|
|
39
|
+
* wholly covered iff `head.lastObservedAt >= chunk.lastObservedAt - 1ms`.
|
|
40
|
+
*/
|
|
41
|
+
interface UpdateBufferedObservationsResult {
|
|
42
|
+
/** Whether the chunk was stored. */
|
|
43
|
+
persisted: boolean;
|
|
44
|
+
/** The record the chunk was written to (or would have been written to). */
|
|
45
|
+
recordId: string;
|
|
46
|
+
}
|
|
47
|
+
/** The fields of an observational memory record that decide head order. */
|
|
48
|
+
interface ObservationalMemoryHeadOrderFields {
|
|
49
|
+
generationCount: number;
|
|
50
|
+
createdAt: Date | string;
|
|
51
|
+
id: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Canonical head order: `generationCount DESC, createdAt ASC, id ASC`.
|
|
55
|
+
* Returns a negative number when `a` sorts before `b` (i.e. `a` is the better head candidate).
|
|
56
|
+
*/
|
|
57
|
+
declare function compareObservationalMemoryHeadOrder(a: ObservationalMemoryHeadOrderFields, b: ObservationalMemoryHeadOrderFields): number;
|
|
58
|
+
/**
|
|
59
|
+
* A buffered chunk stores `lastObservedAt = max message time + 1ms`. It is wholly covered
|
|
60
|
+
* (every message it observed is already at or before the cursor) iff
|
|
61
|
+
* `cursor >= chunk.lastObservedAt - 1ms`.
|
|
62
|
+
*/
|
|
63
|
+
declare function isBufferedChunkCoveredByCursor(chunkLastObservedAt: Date | string, cursor: Date | string | null | undefined): boolean;
|
|
64
|
+
/** The later of two cursors; `undefined` only when both are absent. */
|
|
65
|
+
declare function maxObservationCursor(a: Date | string | null | undefined, b: Date | string | null | undefined): Date | undefined;
|
|
66
|
+
interface ReflectionTextPlan {
|
|
67
|
+
/** `equal`: stored text equals the snapshot. `append`: observations were appended after the snapshot. */
|
|
68
|
+
mode: 'equal' | 'append';
|
|
69
|
+
observations: string;
|
|
70
|
+
tokenCount: number;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Decide the new generation's text when a reflection built from `snapshot` commits against
|
|
74
|
+
* the stored record.
|
|
75
|
+
*
|
|
76
|
+
* - Stored text equals the snapshot: the reflection replaces it.
|
|
77
|
+
* - Stored text extends the snapshot (activation only appends): the appended tail is kept
|
|
78
|
+
* after the reflection, and its tokens are added.
|
|
79
|
+
* - Anything else (a non-append rewrite): `null` — the reflection must not be applied.
|
|
80
|
+
*/
|
|
81
|
+
declare function planReflectionGenerationText(input: {
|
|
82
|
+
storedObservations: string;
|
|
83
|
+
storedObservationTokenCount: number;
|
|
84
|
+
snapshotObservations: string;
|
|
85
|
+
snapshotObservationTokenCount: number;
|
|
86
|
+
reflection: string;
|
|
87
|
+
tokenCount: number;
|
|
88
|
+
}): ReflectionTextPlan | null;
|
|
89
|
+
/**
|
|
90
|
+
* Backs `updateActiveObservations` in adapters that implement `commitActiveObservations`.
|
|
91
|
+
* Callers of `updateActiveObservations` (which resolves `void`) can't see a commit result, so a
|
|
92
|
+
* write that was not applied throws instead of resolving as if it had committed.
|
|
93
|
+
*/
|
|
94
|
+
declare function assertActiveObservationsApplied(result: UpdateActiveObservationsResult, id: string): void;
|
|
95
|
+
/**
|
|
96
|
+
* Whether the stored text can still accept a reflection built from `snapshot`
|
|
97
|
+
* (equal, or only appended to since).
|
|
98
|
+
*/
|
|
99
|
+
declare function isAppendOnlySince(storedObservations: string, snapshotObservations: string): boolean;
|
|
100
|
+
//#endregion
|
|
101
|
+
export { OBSERVATIONAL_MEMORY_LIFECYCLE_COLUMNS, ObservationalMemoryHeadOrderFields, ReflectionTextPlan, UpdateActiveObservationsResult, UpdateBufferedObservationsResult, assertActiveObservationsApplied, compareObservationalMemoryHeadOrder, isAppendOnlySince, isBufferedChunkCoveredByCursor, maxObservationCursor, planReflectionGenerationText, withObservationalMemoryLifecycleColumns };
|
|
102
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -210,6 +210,40 @@ export const mastra = new Mastra({
|
|
|
210
210
|
|
|
211
211
|
**domains.experiments** (`ExperimentsStorage`): Storage for experiment runs and per-item experiment results.
|
|
212
212
|
|
|
213
|
+
**domains.workflowDefinitions** (`WorkflowDefinitionsStorage`): Storage for persisted workflow definitions.
|
|
214
|
+
|
|
215
|
+
**domains.promptBlocks** (`PromptBlocksStorage`): Storage for stored prompt blocks and their versions.
|
|
216
|
+
|
|
217
|
+
**domains.scorerDefinitions** (`ScorerDefinitionsStorage`): Storage for stored scorer definitions and their versions.
|
|
218
|
+
|
|
219
|
+
**domains.mcpClients** (`MCPClientsStorage`): Storage for stored MCP client configurations and their versions.
|
|
220
|
+
|
|
221
|
+
**domains.mcpServers** (`MCPServersStorage`): Storage for stored MCP server configurations and their versions.
|
|
222
|
+
|
|
223
|
+
**domains.workspaces** (`WorkspacesStorage`): Storage for stored workspace configurations and their versions.
|
|
224
|
+
|
|
225
|
+
**domains.skills** (`SkillsStorage`): Storage for stored skill definitions and their versions.
|
|
226
|
+
|
|
227
|
+
**domains.favorites** (`FavoritesStorage`): Storage for user favorites on stored entities.
|
|
228
|
+
|
|
229
|
+
**domains.blobs** (`BlobStore`): Content-addressable storage for file contents used by skill versioning.
|
|
230
|
+
|
|
231
|
+
**domains.backgroundTasks** (`BackgroundTasksStorage`): Storage for background task state.
|
|
232
|
+
|
|
233
|
+
**domains.schedules** (`SchedulesStorage`): Storage for schedules that the scheduler fires.
|
|
234
|
+
|
|
235
|
+
**domains.channels** (`ChannelsStorage`): Storage for channel installations and configuration.
|
|
236
|
+
|
|
237
|
+
**domains.harness** (`HarnessStorage`): Storage for harness sessions.
|
|
238
|
+
|
|
239
|
+
**domains.toolProviderConnections** (`ToolProviderConnectionsStorage`): Storage for authorized tool provider connections.
|
|
240
|
+
|
|
241
|
+
**domains.notifications** (`NotificationsStorage`): Storage for notifications and their delivery state.
|
|
242
|
+
|
|
243
|
+
**domains.threadState** (`ThreadStateStorage`): Storage for per-thread agent state, such as task lists and goals.
|
|
244
|
+
|
|
245
|
+
**domains.knowledge** (`KnowledgeStorage`): Storage for knowledge nodes and records. Experimental.
|
|
246
|
+
|
|
213
247
|
## Initialization
|
|
214
248
|
|
|
215
249
|
`MastraCompositeStore` initializes each configured domain independently. When passed to the Mastra class, `init()` is called automatically:
|
|
@@ -352,6 +352,7 @@ interface QueryResult {
|
|
|
352
352
|
score: number
|
|
353
353
|
metadata: Record<string, any>
|
|
354
354
|
vector?: number[] // Only included if includeVector is true
|
|
355
|
+
document?: string // Source text stored with the vector, when available
|
|
355
356
|
}
|
|
356
357
|
```
|
|
357
358
|
|
|
@@ -429,7 +430,7 @@ const results = await store.query({
|
|
|
429
430
|
|
|
430
431
|
**similarity** (`'cosine' | 'dotProduct' | 'euclidean'`): Vector similarity function. Defaults to MongoDB's own default when omitted.
|
|
431
432
|
|
|
432
|
-
**numDimensions** (`
|
|
433
|
+
**numDimensions** (`number`): Length of the generated embeddings. Common values are 256, 512, 1024, and 2048. (Default: `1024`)
|
|
433
434
|
|
|
434
435
|
**quantization** (`'float' | 'scalar' | 'binary' | 'binaryNoRescore'`): Storage format for the generated vectors. (Default: `scalar`)
|
|
435
436
|
|