indusagi 0.12.13 → 0.12.15
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/agent/tools/registry.d.ts +1 -1
- package/dist/agent/tools/registry.d.ts.map +1 -1
- package/dist/agent/types.d.ts +1 -0
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/ai/models.generated.d.ts +621 -53
- package/dist/ai/models.generated.d.ts.map +1 -1
- package/dist/ai/models.generated.js +548 -0
- package/dist/ai/models.generated.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/client-pool.d.ts +106 -0
- package/dist/mcp/client-pool.d.ts.map +1 -0
- package/dist/mcp/client-pool.js +233 -0
- package/dist/mcp/client-pool.js.map +1 -0
- package/dist/mcp/client.d.ts +158 -0
- package/dist/mcp/client.d.ts.map +1 -0
- package/dist/mcp/client.js +586 -0
- package/dist/mcp/client.js.map +1 -0
- package/dist/mcp/config.d.ts +61 -0
- package/dist/mcp/config.d.ts.map +1 -0
- package/dist/mcp/config.js +250 -0
- package/dist/mcp/config.js.map +1 -0
- package/dist/mcp/errors.d.ts +104 -0
- package/dist/mcp/errors.d.ts.map +1 -0
- package/dist/mcp/errors.js +138 -0
- package/dist/mcp/errors.js.map +1 -0
- package/dist/mcp/index.d.ts +56 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +83 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/schema-converter.d.ts +68 -0
- package/dist/mcp/schema-converter.d.ts.map +1 -0
- package/dist/mcp/schema-converter.js +230 -0
- package/dist/mcp/schema-converter.js.map +1 -0
- package/dist/mcp/server.d.ts +111 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +300 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tool-factory.d.ts +63 -0
- package/dist/mcp/tool-factory.d.ts.map +1 -0
- package/dist/mcp/tool-factory.js +228 -0
- package/dist/mcp/tool-factory.js.map +1 -0
- package/dist/mcp/types.d.ts +289 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +8 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/mcp.d.ts +6 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +6 -0
- package/dist/mcp.js.map +1 -0
- package/dist/memory/embedder/base.d.ts +41 -0
- package/dist/memory/embedder/base.d.ts.map +1 -0
- package/dist/memory/embedder/base.js +10 -0
- package/dist/memory/embedder/base.js.map +1 -0
- package/dist/memory/embedder/index.d.ts +8 -0
- package/dist/memory/embedder/index.d.ts.map +1 -0
- package/dist/memory/embedder/index.js +6 -0
- package/dist/memory/embedder/index.js.map +1 -0
- package/dist/memory/embedder/openai.d.ts +35 -0
- package/dist/memory/embedder/openai.d.ts.map +1 -0
- package/dist/memory/embedder/openai.js +103 -0
- package/dist/memory/embedder/openai.js.map +1 -0
- package/dist/memory/index.d.ts +33 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +31 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/memory.d.ts +126 -0
- package/dist/memory/memory.d.ts.map +1 -0
- package/dist/memory/memory.js +280 -0
- package/dist/memory/memory.js.map +1 -0
- package/dist/memory/processors/base.d.ts +42 -0
- package/dist/memory/processors/base.d.ts.map +1 -0
- package/dist/memory/processors/base.js +6 -0
- package/dist/memory/processors/base.js.map +1 -0
- package/dist/memory/processors/index.d.ts +16 -0
- package/dist/memory/processors/index.d.ts.map +1 -0
- package/dist/memory/processors/index.js +18 -0
- package/dist/memory/processors/index.js.map +1 -0
- package/dist/memory/processors/message-history.d.ts +35 -0
- package/dist/memory/processors/message-history.d.ts.map +1 -0
- package/dist/memory/processors/message-history.js +51 -0
- package/dist/memory/processors/message-history.js.map +1 -0
- package/dist/memory/processors/observational-memory/index.d.ts +82 -0
- package/dist/memory/processors/observational-memory/index.d.ts.map +1 -0
- package/dist/memory/processors/observational-memory/index.js +234 -0
- package/dist/memory/processors/observational-memory/index.js.map +1 -0
- package/dist/memory/processors/observational-memory/observer-agent.d.ts +64 -0
- package/dist/memory/processors/observational-memory/observer-agent.d.ts.map +1 -0
- package/dist/memory/processors/observational-memory/observer-agent.js +362 -0
- package/dist/memory/processors/observational-memory/observer-agent.js.map +1 -0
- package/dist/memory/processors/observational-memory/reflector-agent.d.ts +38 -0
- package/dist/memory/processors/observational-memory/reflector-agent.d.ts.map +1 -0
- package/dist/memory/processors/observational-memory/reflector-agent.js +213 -0
- package/dist/memory/processors/observational-memory/reflector-agent.js.map +1 -0
- package/dist/memory/processors/observational-memory/token-counter.d.ts +35 -0
- package/dist/memory/processors/observational-memory/token-counter.d.ts.map +1 -0
- package/dist/memory/processors/observational-memory/token-counter.js +90 -0
- package/dist/memory/processors/observational-memory/token-counter.js.map +1 -0
- package/dist/memory/processors/semantic-recall.d.ts +55 -0
- package/dist/memory/processors/semantic-recall.d.ts.map +1 -0
- package/dist/memory/processors/semantic-recall.js +143 -0
- package/dist/memory/processors/semantic-recall.js.map +1 -0
- package/dist/memory/processors/working-memory.d.ts +41 -0
- package/dist/memory/processors/working-memory.d.ts.map +1 -0
- package/dist/memory/processors/working-memory.js +82 -0
- package/dist/memory/processors/working-memory.js.map +1 -0
- package/dist/memory/storage/base.d.ts +288 -0
- package/dist/memory/storage/base.d.ts.map +1 -0
- package/dist/memory/storage/base.js +211 -0
- package/dist/memory/storage/base.js.map +1 -0
- package/dist/memory/storage/index.d.ts +9 -0
- package/dist/memory/storage/index.d.ts.map +1 -0
- package/dist/memory/storage/index.js +7 -0
- package/dist/memory/storage/index.js.map +1 -0
- package/dist/memory/storage/inmemory.d.ts +93 -0
- package/dist/memory/storage/inmemory.d.ts.map +1 -0
- package/dist/memory/storage/inmemory.js +646 -0
- package/dist/memory/storage/inmemory.js.map +1 -0
- package/dist/memory/tools/working-memory.d.ts +100 -0
- package/dist/memory/tools/working-memory.d.ts.map +1 -0
- package/dist/memory/tools/working-memory.js +237 -0
- package/dist/memory/tools/working-memory.js.map +1 -0
- package/dist/memory/types.d.ts +386 -0
- package/dist/memory/types.d.ts.map +1 -0
- package/dist/memory/types.js +58 -0
- package/dist/memory/types.js.map +1 -0
- package/dist/memory/vector/base.d.ts +145 -0
- package/dist/memory/vector/base.d.ts.map +1 -0
- package/dist/memory/vector/base.js +83 -0
- package/dist/memory/vector/base.js.map +1 -0
- package/dist/memory/vector/index.d.ts +8 -0
- package/dist/memory/vector/index.d.ts.map +1 -0
- package/dist/memory/vector/index.js +7 -0
- package/dist/memory/vector/index.js.map +1 -0
- package/dist/memory/vector/inmemory.d.ts +47 -0
- package/dist/memory/vector/inmemory.d.ts.map +1 -0
- package/dist/memory/vector/inmemory.js +234 -0
- package/dist/memory/vector/inmemory.js.map +1 -0
- package/package.json +32 -2
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main Memory Class
|
|
3
|
+
* Based on Mastra Memory implementation
|
|
4
|
+
*/
|
|
5
|
+
import type { CoreMessage, MemoryConfig, StorageThreadType, SharedMemoryConfig, WorkingMemoryTemplate } from "./types.js";
|
|
6
|
+
/**
|
|
7
|
+
* Memory class that orchestrates all memory processors and storage
|
|
8
|
+
*/
|
|
9
|
+
export declare class Memory {
|
|
10
|
+
private storage;
|
|
11
|
+
private vector?;
|
|
12
|
+
private embedder?;
|
|
13
|
+
private embedderOptions?;
|
|
14
|
+
private config;
|
|
15
|
+
private processors;
|
|
16
|
+
constructor(options?: SharedMemoryConfig);
|
|
17
|
+
private initializeProcessors;
|
|
18
|
+
/**
|
|
19
|
+
* Initialize memory system
|
|
20
|
+
*/
|
|
21
|
+
init(): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Process messages before sending to LLM
|
|
24
|
+
*/
|
|
25
|
+
processInput(args: {
|
|
26
|
+
messages: CoreMessage[];
|
|
27
|
+
threadId: string;
|
|
28
|
+
resourceId: string;
|
|
29
|
+
memoryConfig?: MemoryConfig;
|
|
30
|
+
signal?: AbortSignal;
|
|
31
|
+
}): Promise<CoreMessage[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Process messages after receiving from LLM
|
|
34
|
+
*/
|
|
35
|
+
processOutput(args: {
|
|
36
|
+
messages: CoreMessage[];
|
|
37
|
+
threadId: string;
|
|
38
|
+
resourceId: string;
|
|
39
|
+
memoryConfig?: MemoryConfig;
|
|
40
|
+
signal?: AbortSignal;
|
|
41
|
+
}): Promise<CoreMessage[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Get a thread by ID
|
|
44
|
+
*/
|
|
45
|
+
getThread(threadId: string): Promise<StorageThreadType | null>;
|
|
46
|
+
/**
|
|
47
|
+
* Create a new thread
|
|
48
|
+
*/
|
|
49
|
+
createThread(args: {
|
|
50
|
+
threadId?: string;
|
|
51
|
+
resourceId: string;
|
|
52
|
+
title?: string;
|
|
53
|
+
metadata?: Record<string, unknown>;
|
|
54
|
+
}): Promise<StorageThreadType>;
|
|
55
|
+
/**
|
|
56
|
+
* List threads
|
|
57
|
+
*/
|
|
58
|
+
listThreads(args: {
|
|
59
|
+
resourceId: string;
|
|
60
|
+
limit?: number;
|
|
61
|
+
offset?: number;
|
|
62
|
+
}): Promise<{
|
|
63
|
+
threads: StorageThreadType[];
|
|
64
|
+
total: number;
|
|
65
|
+
}>;
|
|
66
|
+
/**
|
|
67
|
+
* Delete a thread
|
|
68
|
+
*/
|
|
69
|
+
deleteThread(threadId: string): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Get messages for a thread
|
|
72
|
+
*/
|
|
73
|
+
getMessages(args: {
|
|
74
|
+
threadId: string;
|
|
75
|
+
limit?: number;
|
|
76
|
+
offset?: number;
|
|
77
|
+
}): Promise<{
|
|
78
|
+
messages: CoreMessage[];
|
|
79
|
+
total: number;
|
|
80
|
+
}>;
|
|
81
|
+
/**
|
|
82
|
+
* Save messages
|
|
83
|
+
*/
|
|
84
|
+
saveMessages(threadId: string, messages: CoreMessage[]): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Get working memory
|
|
87
|
+
*/
|
|
88
|
+
getWorkingMemory(args: {
|
|
89
|
+
threadId: string;
|
|
90
|
+
resourceId?: string;
|
|
91
|
+
scope?: "thread" | "resource";
|
|
92
|
+
}): Promise<string | null>;
|
|
93
|
+
/**
|
|
94
|
+
* Update working memory
|
|
95
|
+
*/
|
|
96
|
+
updateWorkingMemory(args: {
|
|
97
|
+
threadId: string;
|
|
98
|
+
resourceId?: string;
|
|
99
|
+
workingMemory: string;
|
|
100
|
+
scope?: "thread" | "resource";
|
|
101
|
+
}): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Get working memory template
|
|
104
|
+
*/
|
|
105
|
+
getWorkingMemoryTemplate(args: {
|
|
106
|
+
memoryConfig?: MemoryConfig;
|
|
107
|
+
}): Promise<WorkingMemoryTemplate | null>;
|
|
108
|
+
/**
|
|
109
|
+
* Get a resource by ID
|
|
110
|
+
*/
|
|
111
|
+
getResource(resourceId: string): Promise<{
|
|
112
|
+
id: string;
|
|
113
|
+
workingMemory?: string;
|
|
114
|
+
metadata?: Record<string, unknown>;
|
|
115
|
+
} | null>;
|
|
116
|
+
/**
|
|
117
|
+
* Get memory configuration
|
|
118
|
+
*/
|
|
119
|
+
getConfig(): MemoryConfig;
|
|
120
|
+
/**
|
|
121
|
+
* Get merged thread configuration
|
|
122
|
+
*/
|
|
123
|
+
getMergedThreadConfig(config?: MemoryConfig): MemoryConfig;
|
|
124
|
+
private getEmbeddingIndexName;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/memory/memory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,iBAAiB,EAAE,k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,EAAE,YAAY,CAAC;KAC7B,GAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;IAoBzC;;OAEG;IACG,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,GAAG,IAAI,CAAC;IAUjI;;OAEG;IACH,SAAS,IAAI,YAAY;IAIzB;;OAEG;IACH,qBAAqB,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,YAAY;IAQ1D,OAAO,CAAC,qBAAqB;CAS9B"}
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main Memory Class
|
|
3
|
+
* Based on Mastra Memory implementation
|
|
4
|
+
*/
|
|
5
|
+
import { memoryDefaultOptions, DEFAULT_SEMANTIC_RECALL } from "./types.js";
|
|
6
|
+
import { InMemoryStorage } from "./storage/inmemory.js";
|
|
7
|
+
import { WorkingMemory } from "./processors/working-memory.js";
|
|
8
|
+
import { SemanticRecall } from "./processors/semantic-recall.js";
|
|
9
|
+
import { MessageHistory } from "./processors/message-history.js";
|
|
10
|
+
/**
|
|
11
|
+
* Memory class that orchestrates all memory processors and storage
|
|
12
|
+
*/
|
|
13
|
+
export class Memory {
|
|
14
|
+
constructor(options = {}) {
|
|
15
|
+
this.processors = [];
|
|
16
|
+
this.storage = options.storage ?? new InMemoryStorage();
|
|
17
|
+
this.vector = options.vector;
|
|
18
|
+
this.embedder = options.embedder;
|
|
19
|
+
this.embedderOptions = options.embedderOptions;
|
|
20
|
+
this.config = { ...memoryDefaultOptions, ...options.options };
|
|
21
|
+
this.initializeProcessors();
|
|
22
|
+
}
|
|
23
|
+
// ========================================================================
|
|
24
|
+
// Initialization
|
|
25
|
+
// ========================================================================
|
|
26
|
+
initializeProcessors() {
|
|
27
|
+
// Working memory processor
|
|
28
|
+
if (this.config.workingMemory &&
|
|
29
|
+
typeof this.config.workingMemory === "object" &&
|
|
30
|
+
this.config.workingMemory.enabled !== false) {
|
|
31
|
+
this.processors.push(new WorkingMemory({
|
|
32
|
+
storage: this.storage,
|
|
33
|
+
scope: typeof this.config.workingMemory === "object"
|
|
34
|
+
? this.config.workingMemory.scope
|
|
35
|
+
: "resource",
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
// Semantic recall processor
|
|
39
|
+
if (this.config.semanticRecall && this.vector && this.embedder) {
|
|
40
|
+
const semanticConfig = typeof this.config.semanticRecall === "object"
|
|
41
|
+
? this.config.semanticRecall
|
|
42
|
+
: DEFAULT_SEMANTIC_RECALL;
|
|
43
|
+
const indexName = this.getEmbeddingIndexName();
|
|
44
|
+
this.processors.push(new SemanticRecall({
|
|
45
|
+
storage: this.storage,
|
|
46
|
+
vector: this.vector,
|
|
47
|
+
embedder: this.embedder,
|
|
48
|
+
embedderOptions: this.embedderOptions,
|
|
49
|
+
indexName,
|
|
50
|
+
topK: semanticConfig.topK,
|
|
51
|
+
messageRange: semanticConfig.messageRange,
|
|
52
|
+
scope: semanticConfig.scope,
|
|
53
|
+
threshold: semanticConfig.threshold,
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
// Message history processor
|
|
57
|
+
if (this.config.lastMessages) {
|
|
58
|
+
this.processors.push(new MessageHistory({
|
|
59
|
+
storage: this.storage,
|
|
60
|
+
lastMessages: typeof this.config.lastMessages === "number"
|
|
61
|
+
? this.config.lastMessages
|
|
62
|
+
: 10,
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Initialize memory system
|
|
68
|
+
*/
|
|
69
|
+
async init() {
|
|
70
|
+
await this.storage.init();
|
|
71
|
+
// Create vector index if needed
|
|
72
|
+
if (this.vector && this.embedder) {
|
|
73
|
+
const indexName = this.getEmbeddingIndexName();
|
|
74
|
+
const indexes = await this.vector.listIndexes();
|
|
75
|
+
if (!indexes.includes(indexName)) {
|
|
76
|
+
await this.vector.createIndex({
|
|
77
|
+
indexName,
|
|
78
|
+
dimension: this.embedder.dimensions,
|
|
79
|
+
metric: "cosine",
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// ========================================================================
|
|
85
|
+
// Processor Pipeline
|
|
86
|
+
// ========================================================================
|
|
87
|
+
/**
|
|
88
|
+
* Process messages before sending to LLM
|
|
89
|
+
*/
|
|
90
|
+
async processInput(args) {
|
|
91
|
+
let result = args.messages;
|
|
92
|
+
const context = {
|
|
93
|
+
threadId: args.threadId,
|
|
94
|
+
resourceId: args.resourceId,
|
|
95
|
+
memoryConfig: args.memoryConfig ?? this.config,
|
|
96
|
+
signal: args.signal,
|
|
97
|
+
};
|
|
98
|
+
for (const processor of this.processors) {
|
|
99
|
+
if (processor.processInputStep) {
|
|
100
|
+
result = await processor.processInputStep({ messages: result, context });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Process messages after receiving from LLM
|
|
107
|
+
*/
|
|
108
|
+
async processOutput(args) {
|
|
109
|
+
let result = args.messages;
|
|
110
|
+
const context = {
|
|
111
|
+
threadId: args.threadId,
|
|
112
|
+
resourceId: args.resourceId,
|
|
113
|
+
memoryConfig: args.memoryConfig ?? this.config,
|
|
114
|
+
signal: args.signal,
|
|
115
|
+
};
|
|
116
|
+
for (const processor of this.processors) {
|
|
117
|
+
if (processor.processOutputResult) {
|
|
118
|
+
result = await processor.processOutputResult({ messages: result, context });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
123
|
+
// ========================================================================
|
|
124
|
+
// Thread Operations
|
|
125
|
+
// ========================================================================
|
|
126
|
+
/**
|
|
127
|
+
* Get a thread by ID
|
|
128
|
+
*/
|
|
129
|
+
async getThread(threadId) {
|
|
130
|
+
return this.storage.getThreadById({ threadId });
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Create a new thread
|
|
134
|
+
*/
|
|
135
|
+
async createThread(args) {
|
|
136
|
+
const thread = {
|
|
137
|
+
id: args.threadId ?? crypto.randomUUID(),
|
|
138
|
+
resourceId: args.resourceId,
|
|
139
|
+
title: args.title,
|
|
140
|
+
createdAt: new Date(),
|
|
141
|
+
updatedAt: new Date(),
|
|
142
|
+
metadata: args.metadata,
|
|
143
|
+
};
|
|
144
|
+
return this.storage.saveThread({ thread });
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* List threads
|
|
148
|
+
*/
|
|
149
|
+
async listThreads(args) {
|
|
150
|
+
const result = await this.storage.listThreads({
|
|
151
|
+
filter: { resourceId: args.resourceId },
|
|
152
|
+
perPage: args.limit ?? 50,
|
|
153
|
+
page: args.offset ? Math.floor(args.offset / (args.limit ?? 50)) : 0,
|
|
154
|
+
});
|
|
155
|
+
return { threads: result.threads, total: result.total };
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Delete a thread
|
|
159
|
+
*/
|
|
160
|
+
async deleteThread(threadId) {
|
|
161
|
+
return this.storage.deleteThread({ threadId });
|
|
162
|
+
}
|
|
163
|
+
// ========================================================================
|
|
164
|
+
// Message Operations
|
|
165
|
+
// ========================================================================
|
|
166
|
+
/**
|
|
167
|
+
* Get messages for a thread
|
|
168
|
+
*/
|
|
169
|
+
async getMessages(args) {
|
|
170
|
+
const result = await this.storage.listMessages({
|
|
171
|
+
threadId: args.threadId,
|
|
172
|
+
perPage: args.limit ?? 100,
|
|
173
|
+
page: args.offset ? Math.floor(args.offset / (args.limit ?? 100)) : 0,
|
|
174
|
+
});
|
|
175
|
+
return { messages: result.messages, total: result.total };
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Save messages
|
|
179
|
+
*/
|
|
180
|
+
async saveMessages(threadId, messages) {
|
|
181
|
+
const messagesWithThreadId = messages.map(m => ({
|
|
182
|
+
...m,
|
|
183
|
+
threadId: m.threadId ?? threadId,
|
|
184
|
+
}));
|
|
185
|
+
await this.storage.saveMessages({ messages: messagesWithThreadId });
|
|
186
|
+
}
|
|
187
|
+
// ========================================================================
|
|
188
|
+
// Working Memory Operations
|
|
189
|
+
// ========================================================================
|
|
190
|
+
/**
|
|
191
|
+
* Get working memory
|
|
192
|
+
*/
|
|
193
|
+
async getWorkingMemory(args) {
|
|
194
|
+
const scope = args.scope ?? "resource";
|
|
195
|
+
if (scope === "thread") {
|
|
196
|
+
const thread = await this.storage.getThreadById({ threadId: args.threadId });
|
|
197
|
+
return thread?.metadata?.workingMemory ?? null;
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
const resource = await this.storage.getResourceById({ resourceId: args.resourceId ?? "" });
|
|
201
|
+
return resource?.workingMemory ?? null;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Update working memory
|
|
206
|
+
*/
|
|
207
|
+
async updateWorkingMemory(args) {
|
|
208
|
+
const scope = args.scope ?? "resource";
|
|
209
|
+
if (scope === "thread") {
|
|
210
|
+
const thread = await this.storage.getThreadById({ threadId: args.threadId });
|
|
211
|
+
if (thread) {
|
|
212
|
+
await this.storage.updateThread({
|
|
213
|
+
id: args.threadId,
|
|
214
|
+
metadata: { ...thread.metadata, workingMemory: args.workingMemory },
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
await this.storage.updateResource({
|
|
220
|
+
resourceId: args.resourceId ?? "",
|
|
221
|
+
workingMemory: args.workingMemory,
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Get working memory template
|
|
227
|
+
*/
|
|
228
|
+
async getWorkingMemoryTemplate(args) {
|
|
229
|
+
const config = args.memoryConfig ?? this.config;
|
|
230
|
+
if (config.workingMemory &&
|
|
231
|
+
typeof config.workingMemory === "object" &&
|
|
232
|
+
"template" in config.workingMemory &&
|
|
233
|
+
config.workingMemory.template) {
|
|
234
|
+
return {
|
|
235
|
+
format: "markdown",
|
|
236
|
+
content: config.workingMemory.template,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
// ========================================================================
|
|
242
|
+
// Resource Operations
|
|
243
|
+
// ========================================================================
|
|
244
|
+
/**
|
|
245
|
+
* Get a resource by ID
|
|
246
|
+
*/
|
|
247
|
+
async getResource(resourceId) {
|
|
248
|
+
const resource = await this.storage.getResourceById({ resourceId });
|
|
249
|
+
if (!resource)
|
|
250
|
+
return null;
|
|
251
|
+
return { id: resourceId, workingMemory: resource.workingMemory, metadata: resource.metadata };
|
|
252
|
+
}
|
|
253
|
+
// ========================================================================
|
|
254
|
+
// Configuration
|
|
255
|
+
// ========================================================================
|
|
256
|
+
/**
|
|
257
|
+
* Get memory configuration
|
|
258
|
+
*/
|
|
259
|
+
getConfig() {
|
|
260
|
+
return { ...this.config };
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Get merged thread configuration
|
|
264
|
+
*/
|
|
265
|
+
getMergedThreadConfig(config) {
|
|
266
|
+
return { ...this.config, ...config };
|
|
267
|
+
}
|
|
268
|
+
// ========================================================================
|
|
269
|
+
// Private Helpers
|
|
270
|
+
// ========================================================================
|
|
271
|
+
getEmbeddingIndexName() {
|
|
272
|
+
const defaultDimensions = 1536;
|
|
273
|
+
const dimensions = this.embedder?.dimensions ?? defaultDimensions;
|
|
274
|
+
const separator = this.vector?.indexSeparator ?? "_";
|
|
275
|
+
return dimensions === defaultDimensions
|
|
276
|
+
? `memory${separator}messages`
|
|
277
|
+
: `memory${separator}messages${separator}${dimensions}`;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
//# sourceMappingURL=memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/memory/memory.ts"],"names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AAC;IAED;;OAEG;IACH,qBAAqB,CAAC,MAAqB;QACzC,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IACvC,CAAC;IAED,2EAA2E;IAC3E,kBAAkB;IAClB,2EAA2E;IAEnE,qBAAqB;QAC3B,MAAM,iBAAiB,GAAG,IAAI,CAAC;QAC/B,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,UAAU,IAAI,iBAAiB,CAAC;QAClE,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,cAAc,IAAI,GAAG,CAAC;QAErD,OAAO,UAAU,KAAK,iBAAiB;YACrC,CAAC,CAAC,SAAS,SAAS,UAAU;YAC9B,CAAC,CAAC,SAAS,SAAS,WAAW,SAAS,GAAG,UAAU,EAAE,CAAC;IAC5D,CAAC;CACF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory Processor Interface
|
|
3
|
+
* Based on Mastra processor patterns
|
|
4
|
+
*/
|
|
5
|
+
import type { CoreMessage, MemoryConfig } from "../types.js";
|
|
6
|
+
/**
|
|
7
|
+
* Processor context passed to processors
|
|
8
|
+
*/
|
|
9
|
+
export interface ProcessorContext {
|
|
10
|
+
threadId: string;
|
|
11
|
+
resourceId: string;
|
|
12
|
+
memoryConfig?: MemoryConfig;
|
|
13
|
+
signal?: AbortSignal;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Base processor interface
|
|
17
|
+
*/
|
|
18
|
+
export interface MemoryProcessor {
|
|
19
|
+
/**
|
|
20
|
+
* Processor identifier
|
|
21
|
+
*/
|
|
22
|
+
readonly id: string;
|
|
23
|
+
/**
|
|
24
|
+
* Processor name
|
|
25
|
+
*/
|
|
26
|
+
readonly name: string;
|
|
27
|
+
/**
|
|
28
|
+
* Process messages before sending to LLM (input phase)
|
|
29
|
+
*/
|
|
30
|
+
processInputStep?(args: {
|
|
31
|
+
messages: CoreMessage[];
|
|
32
|
+
context: ProcessorContext;
|
|
33
|
+
}): Promise<CoreMessage[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Process messages after receiving from LLM (output phase)
|
|
36
|
+
*/
|
|
37
|
+
processOutputResult?(args: {
|
|
38
|
+
messages: CoreMessage[];
|
|
39
|
+
context: ProcessorContext;
|
|
40
|
+
}): Promise<CoreMessage[]>;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/memory/processors/base.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,gBAAgB,CAAC,CAAC,IAAI,EAAE;QACtB,QAAQ,EAAE,WAAW,EAAE,CAAC;QACxB,OAAO,EAAE,gBAAgB,CAAC;KAC3B,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAE3B;;OAEG;IACH,mBAAmB,CAAC,CAAC,IAAI,EAAE;QACzB,QAAQ,EAAE,WAAW,EAAE,CAAC;QACxB,OAAO,EAAE,gBAAgB,CAAC;KAC3B,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;CAC5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/memory/processors/base.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Processors Module Exports
|
|
3
|
+
*/
|
|
4
|
+
export type { MemoryProcessor, ProcessorContext } from "./base.js";
|
|
5
|
+
export { WorkingMemory } from "./working-memory.js";
|
|
6
|
+
export type { WorkingMemoryProcessorConfig } from "./working-memory.js";
|
|
7
|
+
export { SemanticRecall } from "./semantic-recall.js";
|
|
8
|
+
export type { SemanticRecallProcessorConfig } from "./semantic-recall.js";
|
|
9
|
+
export { MessageHistory } from "./message-history.js";
|
|
10
|
+
export type { MessageHistoryProcessorConfig } from "./message-history.js";
|
|
11
|
+
export { ObservationalMemory, OBSERVATIONAL_MEMORY_DEFAULTS, OBSERVATION_CONTINUATION_HINT, } from "./observational-memory/index.js";
|
|
12
|
+
export type { ObservationalMemoryProcessorConfig } from "./observational-memory/index.js";
|
|
13
|
+
export { TokenCounter, createTokenCounter } from "./observational-memory/token-counter.js";
|
|
14
|
+
export { OBSERVER_SYSTEM_PROMPT, OBSERVER_EXTRACTION_INSTRUCTIONS, OBSERVER_OUTPUT_FORMAT_BASE, OBSERVER_GUIDELINES, buildObserverSystemPrompt, buildObserverPrompt, parseObserverOutput, formatMessagesForObserver, sanitizeObservationLines, detectDegenerateRepetition, optimizeObservationsForContext, type ObserverResult, } from "./observational-memory/observer-agent.js";
|
|
15
|
+
export { REFLECTOR_SYSTEM_PROMPT, COMPRESSION_GUIDANCE, buildReflectorSystemPrompt, buildReflectorPrompt, parseReflectorOutput, validateCompression, type ReflectorResult, } from "./observational-memory/reflector-agent.js";
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/memory/processors/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAGnE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAGxE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAG1E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAG1E,OAAO,EACL,mBAAmB,EACnB,6BAA6B,EAC7B,6BAA6B,GAC9B,MAAM,iCAAiC,CAAC;AACzC,YAAY,EAAE,kCAAkC,EAAE,MAAM,iCAAiC,CAAC;AAG1F,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAG3F,OAAO,EACL,sBAAsB,EACtB,gCAAgC,EAChC,2BAA2B,EAC3B,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,EACnB,mBAAmB,EACnB,yBAAyB,EACzB,wBAAwB,EACxB,0BAA0B,EAC1B,8BAA8B,EAC9B,KAAK,cAAc,GACpB,MAAM,0CAA0C,CAAC;AAGlD,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,KAAK,eAAe,GACrB,MAAM,2CAA2C,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Processors Module Exports
|
|
3
|
+
*/
|
|
4
|
+
// Working memory processor
|
|
5
|
+
export { WorkingMemory } from "./working-memory.js";
|
|
6
|
+
// Semantic recall processor
|
|
7
|
+
export { SemanticRecall } from "./semantic-recall.js";
|
|
8
|
+
// Message history processor
|
|
9
|
+
export { MessageHistory } from "./message-history.js";
|
|
10
|
+
// Observational memory processor
|
|
11
|
+
export { ObservationalMemory, OBSERVATIONAL_MEMORY_DEFAULTS, OBSERVATION_CONTINUATION_HINT, } from "./observational-memory/index.js";
|
|
12
|
+
// Token counter
|
|
13
|
+
export { TokenCounter, createTokenCounter } from "./observational-memory/token-counter.js";
|
|
14
|
+
// Observer agent
|
|
15
|
+
export { OBSERVER_SYSTEM_PROMPT, OBSERVER_EXTRACTION_INSTRUCTIONS, OBSERVER_OUTPUT_FORMAT_BASE, OBSERVER_GUIDELINES, buildObserverSystemPrompt, buildObserverPrompt, parseObserverOutput, formatMessagesForObserver, sanitizeObservationLines, detectDegenerateRepetition, optimizeObservationsForContext, } from "./observational-memory/observer-agent.js";
|
|
16
|
+
// Reflector agent
|
|
17
|
+
export { REFLECTOR_SYSTEM_PROMPT, COMPRESSION_GUIDANCE, buildReflectorSystemPrompt, buildReflectorPrompt, parseReflectorOutput, validateCompression, } from "./observational-memory/reflector-agent.js";
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/memory/processors/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,2BAA2B;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,4BAA4B;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,4BAA4B;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,iCAAiC;AACjC,OAAO,EACL,mBAAmB,EACnB,6BAA6B,EAC7B,6BAA6B,GAC9B,MAAM,iCAAiC,CAAC;AAGzC,gBAAgB;AAChB,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAE3F,iBAAiB;AACjB,OAAO,EACL,sBAAsB,EACtB,gCAAgC,EAChC,2BAA2B,EAC3B,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,EACnB,mBAAmB,EACnB,yBAAyB,EACzB,wBAAwB,EACxB,0BAA0B,EAC1B,8BAA8B,GAE/B,MAAM,0CAA0C,CAAC;AAElD,kBAAkB;AAClB,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,GAEpB,MAAM,2CAA2C,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message History Processor
|
|
3
|
+
* Based on Mastra MessageHistory processor
|
|
4
|
+
*/
|
|
5
|
+
import type { MemoryProcessor, ProcessorContext } from "./base.js";
|
|
6
|
+
import type { CoreMessage } from "../types.js";
|
|
7
|
+
import type { MemoryStorage } from "../storage/base.js";
|
|
8
|
+
/**
|
|
9
|
+
* Message history processor configuration
|
|
10
|
+
*/
|
|
11
|
+
export interface MessageHistoryProcessorConfig {
|
|
12
|
+
storage: MemoryStorage;
|
|
13
|
+
lastMessages?: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Message History Processor
|
|
17
|
+
*
|
|
18
|
+
* Retrieves recent messages from storage for context continuity.
|
|
19
|
+
*/
|
|
20
|
+
export declare class MessageHistory implements MemoryProcessor {
|
|
21
|
+
readonly id = "message-history";
|
|
22
|
+
readonly name = "Message History Processor";
|
|
23
|
+
private storage;
|
|
24
|
+
private lastMessages;
|
|
25
|
+
constructor(config: MessageHistoryProcessorConfig);
|
|
26
|
+
processInputStep(args: {
|
|
27
|
+
messages: CoreMessage[];
|
|
28
|
+
context: ProcessorContext;
|
|
29
|
+
}): Promise<CoreMessage[]>;
|
|
30
|
+
processOutputResult(args: {
|
|
31
|
+
messages: CoreMessage[];
|
|
32
|
+
context: ProcessorContext;
|
|
33
|
+
}): Promise<CoreMessage[]>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=message-history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-history.d.ts","sourceRoot":"","sources":["../../../src/memory/processors/message-history.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C,OAAO,EAAE,aAAa,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,qBAAa,cAAe,YAAW,eAAe;IACpD,QAAQ,CAAC,EAAE,qBAAqB;IAChC,QAAQ,CAAC,IAAI,+BAA+B;IAE5C,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,YAAY,CAAS;gBAEjB,MAAM,EAAE,6BAA6B;IAK3C,gBAAgB,CAAC,IAAI,EAAE;QAC3B,QAAQ,EAAE,WAAW,EAAE,CAAC;QACxB,OAAO,EAAE,gBAAgB,CAAC;KAC3B,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAoBpB,mBAAmB,CAAC,IAAI,EAAE;QAC9B,QAAQ,EAAE,WAAW,EAAE,CAAC;QACxB,OAAO,EAAE,gBAAgB,CAAC;KAC3B,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;CAuB3B"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message History Processor
|
|
3
|
+
* Based on Mastra MessageHistory processor
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Message History Processor
|
|
7
|
+
*
|
|
8
|
+
* Retrieves recent messages from storage for context continuity.
|
|
9
|
+
*/
|
|
10
|
+
export class MessageHistory {
|
|
11
|
+
constructor(config) {
|
|
12
|
+
this.id = "message-history";
|
|
13
|
+
this.name = "Message History Processor";
|
|
14
|
+
this.storage = config.storage;
|
|
15
|
+
this.lastMessages = config.lastMessages ?? 10;
|
|
16
|
+
}
|
|
17
|
+
async processInputStep(args) {
|
|
18
|
+
const { messages, context } = args;
|
|
19
|
+
// Get recent messages from storage
|
|
20
|
+
const { messages: storedMessages } = await this.storage.listMessages({
|
|
21
|
+
threadId: context.threadId,
|
|
22
|
+
perPage: this.lastMessages,
|
|
23
|
+
orderBy: { field: "createdAt", direction: "DESC" },
|
|
24
|
+
});
|
|
25
|
+
// Reverse to get chronological order
|
|
26
|
+
const chronologicalMessages = storedMessages.reverse();
|
|
27
|
+
// Merge with incoming messages, avoiding duplicates
|
|
28
|
+
const incomingIds = new Set(messages.map(m => m.id));
|
|
29
|
+
const newMessages = chronologicalMessages.filter(m => !incomingIds.has(m.id));
|
|
30
|
+
return [...newMessages, ...messages];
|
|
31
|
+
}
|
|
32
|
+
async processOutputResult(args) {
|
|
33
|
+
const { messages, context } = args;
|
|
34
|
+
// Check if read-only
|
|
35
|
+
if (context.memoryConfig?.readOnly) {
|
|
36
|
+
return messages;
|
|
37
|
+
}
|
|
38
|
+
// Save new messages to storage
|
|
39
|
+
const existingMessages = await this.storage.listMessages({
|
|
40
|
+
threadId: context.threadId,
|
|
41
|
+
perPage: 1000,
|
|
42
|
+
});
|
|
43
|
+
const existingIds = new Set(existingMessages.messages.map(m => m.id));
|
|
44
|
+
const newMessages = messages.filter(m => !existingIds.has(m.id));
|
|
45
|
+
if (newMessages.length > 0) {
|
|
46
|
+
await this.storage.saveMessages({ messages: newMessages });
|
|
47
|
+
}
|
|
48
|
+
return messages;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=message-history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-history.js","sourceRoot":"","sources":["../../../src/memory/processors/message-history.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAcH;;;;GAIG;AACH,MAAM,OAAO,cAAc;IAOzB,YAAY,MAAqC;QANxC,OAAE,GAAG,iBAAiB,CAAC;QACvB,SAAI,GAAG,2BAA2B,CAAC;QAM1C,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC9B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