@mastra/memory 1.37.1-alpha.0 → 1.37.1-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/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-memory-multi-user-threads.md +1 -1
- package/dist/docs/references/reference-memory-listThreads.md +1 -1
- package/dist/docs/references/reference-processors-token-limiter-processor.md +2 -2
- package/dist/docs/references/reference-vectors-libsql.md +1 -1
- package/dist/docs/references/reference-vectors-mongodb.md +2 -1
- package/dist/docs/references/reference-vectors-pg.md +16 -11
- package/dist/docs/references/reference-vectors-upstash.md +10 -4
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/processors/index.cjs +1 -1
- package/dist/processors/index.js +1 -1
- package/dist/processors/observational-memory/extraction-runner.d.ts.map +1 -1
- package/dist/processors/observational-memory/working-memory-extractor.d.ts.map +1 -1
- package/dist/{src-ThciS3vu.js → src-CYkACM_1.js} +30 -11
- package/dist/{src-ThciS3vu.js.map → src-CYkACM_1.js.map} +1 -1
- package/dist/{src-BpxX0T2g.cjs → src-DTJFmjDz.cjs} +30 -11
- package/dist/{src-BpxX0T2g.cjs.map → src-DTJFmjDz.cjs.map} +1 -1
- package/package.json +5 -5
package/dist/docs/SKILL.md
CHANGED
|
@@ -158,7 +158,7 @@ const memory = new Memory({
|
|
|
158
158
|
})
|
|
159
159
|
```
|
|
160
160
|
|
|
161
|
-
OM requires a storage adapter that supports it: `@mastra/libsql`, `@mastra/pg`, `@mastra/mongodb`, or `@mastra/oracledb`.
|
|
161
|
+
OM requires a storage adapter that supports it: `@mastra/libsql`, `@mastra/pg`, `@mastra/mongodb`, `@mastra/mysql`, `@mastra/convex`, or `@mastra/oracledb`.
|
|
162
162
|
|
|
163
163
|
> **Note:** If you switch the Observer to a less capable model and see facts attributed to a generic `User` instead of individual participants, use [`observation.instruction`](https://mastra.ai/reference/memory/observational-memory) to explain how to interpret the `<turn>` tag.
|
|
164
164
|
|
|
@@ -69,7 +69,7 @@ const result = await memory.listThreads({
|
|
|
69
69
|
|
|
70
70
|
**page** (`number`): Page number (0-indexed) to retrieve
|
|
71
71
|
|
|
72
|
-
**perPage** (`number | false`): Maximum number of threads to return per page, or false to fetch all
|
|
72
|
+
**perPage** (`number | false`): Maximum number of threads to return per page, or false to fetch all (Default: `100`)
|
|
73
73
|
|
|
74
74
|
**orderBy** (`{ field: 'createdAt' | 'updatedAt', direction: 'ASC' | 'DESC' }`): Sort configuration with field and direction (defaults to { field: 'createdAt', direction: 'DESC' })
|
|
75
75
|
|
|
@@ -28,7 +28,7 @@ const processor = new TokenLimiterProcessor({
|
|
|
28
28
|
|
|
29
29
|
**options.limit** (`number`): Maximum number of tokens to allow in the response
|
|
30
30
|
|
|
31
|
-
**options.encoding** (`
|
|
31
|
+
**options.encoding** (`unknown`): Deprecated. Accepted for backwards compatibility but ignored. Token counts are estimated with tokenx, so no encoder is needed.
|
|
32
32
|
|
|
33
33
|
**options.strategy** (`'truncate' | 'abort'`): Strategy when token limit is reached: 'truncate' stops emitting chunks, 'abort' calls abort() to stop the stream
|
|
34
34
|
|
|
@@ -40,7 +40,7 @@ const processor = new TokenLimiterProcessor({
|
|
|
40
40
|
|
|
41
41
|
**id** (`string`): Processor identifier set to 'token-limiter'
|
|
42
42
|
|
|
43
|
-
**name** (`string`):
|
|
43
|
+
**name** (`string`): Processor display name set to 'Token Limiter'
|
|
44
44
|
|
|
45
45
|
**processInput** (`(args: { messages: MastraDBMessage[]; abort: (reason?: string) => never }) => Promise<MastraDBMessage[]>`): Trims stored history to fit within the token limit before the agentic loop starts in 'memory-only' trim mode, prioritizing recent messages while preserving system messages and the current turn
|
|
46
46
|
|
|
@@ -121,7 +121,7 @@ Searches for similar vectors with optional metadata filtering.
|
|
|
121
121
|
|
|
122
122
|
**includeVector** (`boolean`): Whether to include vector data in results (Default: `false`)
|
|
123
123
|
|
|
124
|
-
**minScore** (`number`): Minimum similarity score threshold (Default: `
|
|
124
|
+
**minScore** (`number`): Minimum similarity score threshold (cosine similarity ranges from -1 to 1) (Default: `-1`)
|
|
125
125
|
|
|
126
126
|
### `describeIndex()`
|
|
127
127
|
|
|
@@ -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
|
|
|
@@ -82,7 +82,9 @@ const vectorStore = new PgVector({
|
|
|
82
82
|
|
|
83
83
|
**dimension** (`number`): Vector dimension (must match your embedding model)
|
|
84
84
|
|
|
85
|
-
**metric** (`'cosine' | 'euclidean' | 'dotproduct'`): Distance metric for similarity search (Default: `cosine`)
|
|
85
|
+
**metric** (`'cosine' | 'euclidean' | 'dotproduct' | 'hamming' | 'jaccard'`): Distance metric for similarity search. 'hamming' and 'jaccard' are only valid with vectorType 'bit', and 'jaccard' requires an HNSW index. (Default: `'cosine' ('hamming' when vectorType is 'bit')`)
|
|
86
|
+
|
|
87
|
+
**vectorType** (`'vector' | 'halfvec' | 'bit' | 'sparsevec'`): pgvector storage type for the embeddings (Default: `vector`)
|
|
86
88
|
|
|
87
89
|
**indexConfig** (`IndexConfig`): Index configuration (Default: `{ type: 'ivfflat' }`)
|
|
88
90
|
|
|
@@ -142,13 +144,11 @@ Higher M values or efConstruction values will increase memory requirements subst
|
|
|
142
144
|
|
|
143
145
|
**includeVector** (`boolean`): Whether to include the vector in the result (Default: `false`)
|
|
144
146
|
|
|
145
|
-
**minScore** (`number`): Minimum similarity score threshold (Default: `
|
|
146
|
-
|
|
147
|
-
**options** (`{ ef?: number; probes?: number }`): Additional options for HNSW and IVF indexes
|
|
147
|
+
**minScore** (`number`): Minimum similarity score threshold (Default: `-1`)
|
|
148
148
|
|
|
149
|
-
**
|
|
149
|
+
**ef** (`number`): HNSW search parameter. Higher values improve accuracy at the cost of speed.
|
|
150
150
|
|
|
151
|
-
**
|
|
151
|
+
**probes** (`number`): IVFFlat search parameter. Number of lists to visit during search.
|
|
152
152
|
|
|
153
153
|
### `listIndexes()`
|
|
154
154
|
|
|
@@ -164,8 +164,9 @@ Returns:
|
|
|
164
164
|
interface PGIndexStats {
|
|
165
165
|
dimension: number
|
|
166
166
|
count: number
|
|
167
|
-
metric: 'cosine' | 'euclidean' | 'dotproduct'
|
|
167
|
+
metric: 'cosine' | 'euclidean' | 'dotproduct' | 'hamming' | 'jaccard'
|
|
168
168
|
type: 'flat' | 'hnsw' | 'ivfflat'
|
|
169
|
+
vectorType: 'vector' | 'halfvec' | 'bit' | 'sparsevec'
|
|
169
170
|
config: {
|
|
170
171
|
m?: number
|
|
171
172
|
efConstruction?: number
|
|
@@ -246,7 +247,7 @@ Closes the database connection pool. Should be called when done using the store.
|
|
|
246
247
|
|
|
247
248
|
**indexName** (`string`): Name of the index to define
|
|
248
249
|
|
|
249
|
-
**metric** (`'cosine' | 'euclidean' | 'dotproduct'`): Distance metric for similarity search (Default: `cosine`)
|
|
250
|
+
**metric** (`'cosine' | 'euclidean' | 'dotproduct' | 'hamming' | 'jaccard'`): Distance metric for similarity search (Default: `cosine`)
|
|
250
251
|
|
|
251
252
|
**indexConfig** (`IndexConfig`): Configuration for the index type and parameters
|
|
252
253
|
|
|
@@ -291,17 +292,21 @@ interface QueryResult {
|
|
|
291
292
|
|
|
292
293
|
## Error handling
|
|
293
294
|
|
|
294
|
-
The store throws
|
|
295
|
+
The store throws `MastraError` instances from `@mastra/core/error`:
|
|
295
296
|
|
|
296
297
|
```typescript
|
|
298
|
+
import { MastraError } from '@mastra/core/error'
|
|
299
|
+
|
|
297
300
|
try {
|
|
298
301
|
await store.query({
|
|
299
302
|
indexName: 'index_name',
|
|
300
303
|
queryVector: queryVector,
|
|
301
304
|
})
|
|
302
305
|
} catch (error) {
|
|
303
|
-
if (error instanceof
|
|
304
|
-
console.log(error.
|
|
306
|
+
if (error instanceof MastraError) {
|
|
307
|
+
console.log(error.id) // 'MASTRA_VECTOR_PG_QUERY_FAILED'
|
|
308
|
+
console.log(error.domain) // 'MASTRA_VECTOR'
|
|
309
|
+
console.log(error.category) // 'USER' | 'THIRD_PARTY'
|
|
305
310
|
console.log(error.details) // Additional error context
|
|
306
311
|
}
|
|
307
312
|
}
|
|
@@ -8,6 +8,8 @@ The UpstashVector class provides vector search using [Upstash Vector](https://up
|
|
|
8
8
|
|
|
9
9
|
## Constructor options
|
|
10
10
|
|
|
11
|
+
**id** (`string`): Unique identifier for this vector store instance
|
|
12
|
+
|
|
11
13
|
**url** (`string`): Upstash Vector database URL
|
|
12
14
|
|
|
13
15
|
**token** (`string`): Upstash Vector API token
|
|
@@ -194,24 +196,28 @@ Query results are returned in this format:
|
|
|
194
196
|
interface QueryResult {
|
|
195
197
|
id: string
|
|
196
198
|
score: number
|
|
197
|
-
metadata
|
|
199
|
+
metadata?: Record<string, any>
|
|
198
200
|
vector?: number[] // Only included if includeVector is true
|
|
199
201
|
}
|
|
200
202
|
```
|
|
201
203
|
|
|
202
204
|
## Error handling
|
|
203
205
|
|
|
204
|
-
The store throws
|
|
206
|
+
The store throws `MastraError` instances from `@mastra/core/error`:
|
|
205
207
|
|
|
206
208
|
```typescript
|
|
209
|
+
import { MastraError } from '@mastra/core/error'
|
|
210
|
+
|
|
207
211
|
try {
|
|
208
212
|
await store.query({
|
|
209
213
|
indexName: 'index_name',
|
|
210
214
|
queryVector: queryVector,
|
|
211
215
|
})
|
|
212
216
|
} catch (error) {
|
|
213
|
-
if (error instanceof
|
|
214
|
-
console.log(error.
|
|
217
|
+
if (error instanceof MastraError) {
|
|
218
|
+
console.log(error.id) // 'MASTRA_VECTOR_UPSTASH_QUERY_FAILED'
|
|
219
|
+
console.log(error.domain) // 'STORAGE'
|
|
220
|
+
console.log(error.category) // 'USER' | 'THIRD_PARTY'
|
|
215
221
|
console.log(error.details) // Additional error context
|
|
216
222
|
}
|
|
217
223
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_src = require("./src-
|
|
2
|
+
const require_src = require("./src-DTJFmjDz.cjs");
|
|
3
3
|
let _mastra_core_processors = require("@mastra/core/processors");
|
|
4
4
|
exports.AUTO_MODEL_BY_PROVIDER = require_src.AUTO_MODEL_BY_PROVIDER;
|
|
5
5
|
exports.Extractor = require_src.Extractor;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as WorkingMemoryExtractor, E as summarizeConversation, G as Subconscious, K as KnowledgeSemanticIndexCoordinator, T as SUMMARIZE_THREAD_DEFAULTS, Y as ModelByInputTokens, a as extractWorkingMemoryContent, c as getObservationsAsOf, d as AUTO_MODEL_BY_PROVIDER, et as Extractor, f as resolveAutoModelId, h as WorkingMemoryStateProcessor, i as WorkingMemory, m as WORKING_MEMORY_STATE_PROCESSOR_ID, n as MessageHistory, o as extractWorkingMemoryTags, p as WORKING_MEMORY_STATE_ID, q as StaleKnowledgeSemanticIndexError, r as SemanticRecall, s as removeWorkingMemoryTags, t as Memory, w as deepMergeWorkingMemory } from "./src-
|
|
1
|
+
import { C as WorkingMemoryExtractor, E as summarizeConversation, G as Subconscious, K as KnowledgeSemanticIndexCoordinator, T as SUMMARIZE_THREAD_DEFAULTS, Y as ModelByInputTokens, a as extractWorkingMemoryContent, c as getObservationsAsOf, d as AUTO_MODEL_BY_PROVIDER, et as Extractor, f as resolveAutoModelId, h as WorkingMemoryStateProcessor, i as WorkingMemory, m as WORKING_MEMORY_STATE_PROCESSOR_ID, n as MessageHistory, o as extractWorkingMemoryTags, p as WORKING_MEMORY_STATE_ID, q as StaleKnowledgeSemanticIndexError, r as SemanticRecall, s as removeWorkingMemoryTags, t as Memory, w as deepMergeWorkingMemory } from "./src-CYkACM_1.js";
|
|
2
2
|
export { AUTO_MODEL_BY_PROVIDER, Extractor, KnowledgeSemanticIndexCoordinator, Memory, MessageHistory, ModelByInputTokens, SUMMARIZE_THREAD_DEFAULTS, SemanticRecall, StaleKnowledgeSemanticIndexError, Subconscious, WORKING_MEMORY_STATE_ID, WORKING_MEMORY_STATE_PROCESSOR_ID, WorkingMemory, WorkingMemoryExtractor, WorkingMemoryStateProcessor, deepMergeWorkingMemory, extractWorkingMemoryContent, extractWorkingMemoryTags, getObservationsAsOf, removeWorkingMemoryTags, resolveAutoModelId, summarizeConversation };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_src = require("../src-
|
|
2
|
+
const require_src = require("../src-DTJFmjDz.cjs");
|
|
3
3
|
exports.AUTO_MODEL_BY_PROVIDER = require_src.AUTO_MODEL_BY_PROVIDER;
|
|
4
4
|
exports.Extractor = require_src.Extractor;
|
|
5
5
|
exports.KnowledgeSemanticIndexCoordinator = require_src.KnowledgeSemanticIndexCoordinator;
|
package/dist/processors/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as renderSubconsciousActivity, A as buildObserverSystemPrompt, B as OBSERVATION_CONTEXT_INSTRUCTIONS, C as WorkingMemoryExtractor, D as TokenCounter, E as summarizeConversation, F as parseObserverOutput, G as Subconscious, H as OBSERVATION_CONTEXT_PROMPT_THREAD, I as injectAnchorIds, J as SubconsciousRemindExtractor, K as KnowledgeSemanticIndexCoordinator, L as parseAnchorId, M as formatMessagesForObserver, N as hasCurrentTaskSection, O as OBSERVER_SYSTEM_PROMPT, P as optimizeObservationsForContext, Q as publishSubconsciousActivity, R as stripEphemeralAnchorIds, S as wrapInObservationGroup, U as OBSERVATION_CONTINUATION_HINT, V as OBSERVATION_CONTEXT_PROMPT, W as getObservationContextPrompt, X as SUBCONSCIOUS_ACTIVITY_STATE_ID, Y as ModelByInputTokens, Z as buildSubconsciousActivitySnapshot, _ as deriveObservationGroupProvenance, b as renderObservationGroupsForReflection, c as getObservationsAsOf, d as AUTO_MODEL_BY_PROVIDER, et as Extractor, f as resolveAutoModelId, g as combineObservationGroupRanges, j as extractCurrentTask, k as buildObserverPrompt, l as ObservationalMemoryProcessor, q as StaleKnowledgeSemanticIndexError, u as ObservationalMemory, v as parseObservationGroups, x as stripObservationGroups, y as reconcileObservationGroupsFromReflection, z as OBSERVATIONAL_MEMORY_DEFAULTS } from "../src-
|
|
1
|
+
import { $ as renderSubconsciousActivity, A as buildObserverSystemPrompt, B as OBSERVATION_CONTEXT_INSTRUCTIONS, C as WorkingMemoryExtractor, D as TokenCounter, E as summarizeConversation, F as parseObserverOutput, G as Subconscious, H as OBSERVATION_CONTEXT_PROMPT_THREAD, I as injectAnchorIds, J as SubconsciousRemindExtractor, K as KnowledgeSemanticIndexCoordinator, L as parseAnchorId, M as formatMessagesForObserver, N as hasCurrentTaskSection, O as OBSERVER_SYSTEM_PROMPT, P as optimizeObservationsForContext, Q as publishSubconsciousActivity, R as stripEphemeralAnchorIds, S as wrapInObservationGroup, U as OBSERVATION_CONTINUATION_HINT, V as OBSERVATION_CONTEXT_PROMPT, W as getObservationContextPrompt, X as SUBCONSCIOUS_ACTIVITY_STATE_ID, Y as ModelByInputTokens, Z as buildSubconsciousActivitySnapshot, _ as deriveObservationGroupProvenance, b as renderObservationGroupsForReflection, c as getObservationsAsOf, d as AUTO_MODEL_BY_PROVIDER, et as Extractor, f as resolveAutoModelId, g as combineObservationGroupRanges, j as extractCurrentTask, k as buildObserverPrompt, l as ObservationalMemoryProcessor, q as StaleKnowledgeSemanticIndexError, u as ObservationalMemory, v as parseObservationGroups, x as stripObservationGroups, y as reconcileObservationGroupsFromReflection, z as OBSERVATIONAL_MEMORY_DEFAULTS } from "../src-CYkACM_1.js";
|
|
2
2
|
export { AUTO_MODEL_BY_PROVIDER, Extractor, KnowledgeSemanticIndexCoordinator, ModelByInputTokens, OBSERVATIONAL_MEMORY_DEFAULTS, OBSERVATION_CONTEXT_INSTRUCTIONS, OBSERVATION_CONTEXT_PROMPT, OBSERVATION_CONTEXT_PROMPT_THREAD, OBSERVATION_CONTINUATION_HINT, OBSERVER_SYSTEM_PROMPT, ObservationalMemory, ObservationalMemoryProcessor, SUBCONSCIOUS_ACTIVITY_STATE_ID, StaleKnowledgeSemanticIndexError, Subconscious, SubconsciousRemindExtractor, TokenCounter, WorkingMemoryExtractor, buildObserverPrompt, buildObserverSystemPrompt, buildSubconsciousActivitySnapshot, combineObservationGroupRanges, deriveObservationGroupProvenance, extractCurrentTask, formatMessagesForObserver, getObservationContextPrompt, getObservationsAsOf, hasCurrentTaskSection, injectAnchorIds, optimizeObservationsForContext, parseAnchorId, parseObservationGroups, parseObserverOutput, publishSubconsciousActivity, reconcileObservationGroupsFromReflection, renderObservationGroupsForReflection, renderSubconsciousActivity, resolveAutoModelId, stripEphemeralAnchorIds, stripObservationGroups, summarizeConversation, wrapInObservationGroup };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extraction-runner.d.ts","sourceRoot":"","sources":["../../../src/processors/observational-memory/extraction-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAGnE,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAI9D,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,QAAQ,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAClD;
|
|
1
|
+
{"version":3,"file":"extraction-runner.d.ts","sourceRoot":"","sources":["../../../src/processors/observational-memory/extraction-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAGnE,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAI9D,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,QAAQ,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAClD;AAwBD,wBAAsB,uBAAuB,CAAC,IAAI,EAAE;IAClD,KAAK,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IACjC,MAAM,EAAE,eAAe,CAAC;IACxB,UAAU,CAAC,EAAE,SAAS,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;IACvC,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/C,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAuItC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"working-memory-extractor.d.ts","sourceRoot":"","sources":["../../../src/processors/observational-memory/working-memory-extractor.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"working-memory-extractor.d.ts","sourceRoot":"","sources":["../../../src/processors/observational-memory/working-memory-extractor.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAoFxC,qBAAa,sBAAuB,SAAQ,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;;CA+C7F"}
|
|
@@ -19230,8 +19230,12 @@ function formatOmError(error) {
|
|
|
19230
19230
|
function isAbortError(error, abortSignal) {
|
|
19231
19231
|
return abortSignal?.aborted === true || hasAbortInChain(error);
|
|
19232
19232
|
}
|
|
19233
|
+
function hasEmptyObjectValue(object, extractor) {
|
|
19234
|
+
const value = object[extractor.slug];
|
|
19235
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length === 0;
|
|
19236
|
+
}
|
|
19233
19237
|
function shouldRetryEmptyStructuredObject(object, extractors) {
|
|
19234
|
-
return Object.keys(object).length === 0
|
|
19238
|
+
return extractors.some((extractor) => extractor.retryStructuredExtractionOnEmptyObject && (Object.keys(object).length === 0 || hasEmptyObjectValue(object, extractor)));
|
|
19235
19239
|
}
|
|
19236
19240
|
async function extractStructuredValues(opts) {
|
|
19237
19241
|
const structuredExtractors = (opts.extractors ?? []).filter((extractor) => extractor.mode === "structured");
|
|
@@ -19305,17 +19309,28 @@ ${extractorInstructions}${priorLines.length > 0 ? `\n\n## Prior Extracted Values
|
|
|
19305
19309
|
}
|
|
19306
19310
|
}
|
|
19307
19311
|
if (retryEmptyObject) try {
|
|
19308
|
-
|
|
19312
|
+
const fallbackJsonPromptInjection = coreFeatures.has("json-prompt-injection:inline") ? "inline" : true;
|
|
19313
|
+
object = {
|
|
19314
|
+
...object,
|
|
19315
|
+
...await streamWithStructuredOutput(fallbackJsonPromptInjection)
|
|
19316
|
+
};
|
|
19309
19317
|
} catch (fallbackError) {
|
|
19310
19318
|
if (isAbortError(fallbackError, opts.abortSignal)) throw fallbackError;
|
|
19311
19319
|
const message = fallbackError instanceof Error ? fallbackError.message : String(fallbackError);
|
|
19312
|
-
return {
|
|
19320
|
+
if (Object.keys(object).length === 0) return {
|
|
19313
19321
|
values,
|
|
19314
19322
|
failures: structuredExtractors.map((extractor) => ({
|
|
19315
19323
|
slug: extractor.slug,
|
|
19316
19324
|
error: message
|
|
19317
19325
|
}))
|
|
19318
19326
|
};
|
|
19327
|
+
for (const extractor of structuredExtractors) if (extractor.retryStructuredExtractionOnEmptyObject && hasEmptyObjectValue(object, extractor)) {
|
|
19328
|
+
failures.push({
|
|
19329
|
+
slug: extractor.slug,
|
|
19330
|
+
error: message
|
|
19331
|
+
});
|
|
19332
|
+
delete object[extractor.slug];
|
|
19333
|
+
}
|
|
19319
19334
|
}
|
|
19320
19335
|
for (const extractor of structuredExtractors) {
|
|
19321
19336
|
const value = object[extractor.slug];
|
|
@@ -24141,6 +24156,9 @@ async function validateAgainstConfiguredSchema(schema, value) {
|
|
|
24141
24156
|
}).join("; ");
|
|
24142
24157
|
throw new Error(`Working memory update does not match the configured schema, so it was not saved: ${details}`);
|
|
24143
24158
|
}
|
|
24159
|
+
function isEmptyPlainObject(value) {
|
|
24160
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length === 0;
|
|
24161
|
+
}
|
|
24144
24162
|
async function getWorkingMemoryDetails(context) {
|
|
24145
24163
|
const memory = context.memory;
|
|
24146
24164
|
const memoryConfig = parseMemoryRequestContext(context.requestContext)?.memoryConfig;
|
|
@@ -24188,8 +24206,9 @@ var WorkingMemoryExtractor = class extends Extractor {
|
|
|
24188
24206
|
const configuredSchema = memory.getMergedThreadConfig(memoryConfig ?? {}).workingMemory?.schema;
|
|
24189
24207
|
let document = current;
|
|
24190
24208
|
if (configuredSchema) {
|
|
24191
|
-
if (current === null) return;
|
|
24209
|
+
if (current === null || isEmptyPlainObject(current)) return;
|
|
24192
24210
|
document = await validateAgainstConfiguredSchema(configuredSchema, current);
|
|
24211
|
+
if (document === null || isEmptyPlainObject(document)) return;
|
|
24193
24212
|
}
|
|
24194
24213
|
const workingMemory = typeof document === "string" ? document : JSON.stringify(document) ?? "";
|
|
24195
24214
|
if (!workingMemory.trim()) return;
|
|
@@ -24376,10 +24395,10 @@ function filterObservedMessages(opts) {
|
|
|
24376
24395
|
const msg = allMessages[i];
|
|
24377
24396
|
if (msg?.id && msg.id !== "om-continuation" && !preserveMessageIds.has(msg.id) && !hasPendingToolResultPair(msg, pendingToolResultIds)) messagesToRemove.push(msg.id);
|
|
24378
24397
|
}
|
|
24379
|
-
if (messagesToRemove.length > 0) messageList.removeByIds(messagesToRemove);
|
|
24398
|
+
if (messagesToRemove.length > 0) messageList.removeByIds(messagesToRemove, { pruned: true });
|
|
24380
24399
|
const unobserved = getUnobservedPartsPreservingToolCallPairs(markerMessage);
|
|
24381
24400
|
if (unobserved.length === 0) {
|
|
24382
|
-
if (markerMessage.id) messageList.removeByIds([markerMessage.id]);
|
|
24401
|
+
if (markerMessage.id) messageList.removeByIds([markerMessage.id], { pruned: true });
|
|
24383
24402
|
} else if (unobserved.length < (markerMessage.content?.parts?.length ?? 0)) markerMessage.content.parts = unobserved;
|
|
24384
24403
|
} else if (record) {
|
|
24385
24404
|
const pendingToolResultIds = collectPendingToolResultIds(allMessages, observedIds);
|
|
@@ -24406,7 +24425,7 @@ function filterObservedMessages(opts) {
|
|
|
24406
24425
|
}
|
|
24407
24426
|
}
|
|
24408
24427
|
}
|
|
24409
|
-
if (messagesToRemove.length > 0) messageList.removeByIds(messagesToRemove);
|
|
24428
|
+
if (messagesToRemove.length > 0) messageList.removeByIds(messagesToRemove, { pruned: true });
|
|
24410
24429
|
}
|
|
24411
24430
|
}
|
|
24412
24431
|
function getBufferedChunks(record) {
|
|
@@ -28830,7 +28849,7 @@ var ObservationStep = class {
|
|
|
28830
28849
|
this.turn.setRecord(activation.record);
|
|
28831
28850
|
if (activation.activated) {
|
|
28832
28851
|
activated = true;
|
|
28833
|
-
if (activation.activatedMessageIds?.length) messageList.removeByIds(activation.activatedMessageIds);
|
|
28852
|
+
if (activation.activatedMessageIds?.length) messageList.removeByIds(activation.activatedMessageIds, { pruned: true });
|
|
28834
28853
|
await om.resetBufferingState({
|
|
28835
28854
|
threadId,
|
|
28836
28855
|
resourceId,
|
|
@@ -32425,7 +32444,7 @@ ${formattedMessages}
|
|
|
32425
32444
|
preserveMessageIds
|
|
32426
32445
|
});
|
|
32427
32446
|
if (messageList) {
|
|
32428
|
-
if (idsToRemoveList.length > 0) messageList.removeByIds(idsToRemoveList);
|
|
32447
|
+
if (idsToRemoveList.length > 0) messageList.removeByIds(idsToRemoveList, { pruned: true });
|
|
32429
32448
|
return messageList.get.all.db();
|
|
32430
32449
|
}
|
|
32431
32450
|
this.removeIdsFromArray(allMsgs, idsToRemoveList);
|
|
@@ -32450,7 +32469,7 @@ ${formattedMessages}
|
|
|
32450
32469
|
} else if (unobservedParts.length < (markerMsg.content?.parts?.length ?? 0)) markerMsg.content.parts = unobservedParts;
|
|
32451
32470
|
}
|
|
32452
32471
|
if (messageList) {
|
|
32453
|
-
if (idsToRemove.length > 0) messageList.removeByIds(idsToRemove);
|
|
32472
|
+
if (idsToRemove.length > 0) messageList.removeByIds(idsToRemove, { pruned: true });
|
|
32454
32473
|
if (messagesToSave.length > 0) await this.persistMessages(messagesToSave, threadId, resourceId);
|
|
32455
32474
|
omDebug(`[OM:cleanupMarker] removed ${idsToRemove.length} messages, saved ${messagesToSave.length}`);
|
|
32456
32475
|
return messageList.get.all.db();
|
|
@@ -36555,4 +36574,4 @@ Notes:
|
|
|
36555
36574
|
//#endregion
|
|
36556
36575
|
export { renderSubconsciousActivity as $, buildObserverSystemPrompt as A, OBSERVATION_CONTEXT_INSTRUCTIONS as B, WorkingMemoryExtractor as C, TokenCounter as D, summarizeConversation as E, parseObserverOutput as F, Subconscious as G, OBSERVATION_CONTEXT_PROMPT_THREAD as H, injectAnchorIds as I, SubconsciousRemindExtractor as J, KnowledgeSemanticIndexCoordinator as K, parseAnchorId as L, formatMessagesForObserver as M, hasCurrentTaskSection as N, OBSERVER_SYSTEM_PROMPT as O, optimizeObservationsForContext as P, publishSubconsciousActivity as Q, stripEphemeralAnchorIds as R, wrapInObservationGroup as S, SUMMARIZE_THREAD_DEFAULTS as T, OBSERVATION_CONTINUATION_HINT as U, OBSERVATION_CONTEXT_PROMPT as V, getObservationContextPrompt as W, SUBCONSCIOUS_ACTIVITY_STATE_ID as X, ModelByInputTokens as Y, buildSubconsciousActivitySnapshot as Z, deriveObservationGroupProvenance as _, extractWorkingMemoryContent as a, renderObservationGroupsForReflection as b, getObservationsAsOf as c, AUTO_MODEL_BY_PROVIDER as d, Extractor as et, resolveAutoModelId as f, combineObservationGroupRanges as g, WorkingMemoryStateProcessor as h, WorkingMemory as i, extractCurrentTask as j, buildObserverPrompt as k, ObservationalMemoryProcessor as l, WORKING_MEMORY_STATE_PROCESSOR_ID as m, MessageHistory$1 as n, extractWorkingMemoryTags as o, WORKING_MEMORY_STATE_ID as p, StaleKnowledgeSemanticIndexError as q, SemanticRecall as r, removeWorkingMemoryTags as s, Memory as t, ObservationalMemory as u, parseObservationGroups as v, deepMergeWorkingMemory as w, stripObservationGroups as x, reconcileObservationGroupsFromReflection as y, OBSERVATIONAL_MEMORY_DEFAULTS as z };
|
|
36557
36576
|
|
|
36558
|
-
//# sourceMappingURL=src-
|
|
36577
|
+
//# sourceMappingURL=src-CYkACM_1.js.map
|