agentic-qe 2.5.5 → 2.5.6
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 +70 -0
- package/README.md +1 -1
- package/dist/adapters/MemoryStoreAdapter.d.ts +75 -123
- package/dist/adapters/MemoryStoreAdapter.d.ts.map +1 -1
- package/dist/adapters/MemoryStoreAdapter.js +204 -219
- package/dist/adapters/MemoryStoreAdapter.js.map +1 -1
- package/dist/agents/AccessibilityAllyAgent.d.ts.map +1 -1
- package/dist/agents/AccessibilityAllyAgent.js +17 -1
- package/dist/agents/AccessibilityAllyAgent.js.map +1 -1
- package/dist/agents/BaseAgent.d.ts +18 -250
- package/dist/agents/BaseAgent.d.ts.map +1 -1
- package/dist/agents/BaseAgent.js +122 -520
- package/dist/agents/BaseAgent.js.map +1 -1
- package/dist/agents/utils/generators.d.ts +30 -0
- package/dist/agents/utils/generators.d.ts.map +1 -0
- package/dist/agents/utils/generators.js +44 -0
- package/dist/agents/utils/generators.js.map +1 -0
- package/dist/agents/utils/index.d.ts +10 -0
- package/dist/agents/utils/index.d.ts.map +1 -0
- package/dist/agents/utils/index.js +19 -0
- package/dist/agents/utils/index.js.map +1 -0
- package/dist/agents/utils/validation.d.ts +72 -0
- package/dist/agents/utils/validation.d.ts.map +1 -0
- package/dist/agents/utils/validation.js +75 -0
- package/dist/agents/utils/validation.js.map +1 -0
- package/dist/core/memory/HNSWVectorMemory.js +1 -1
- package/dist/core/memory/SwarmMemoryManager.d.ts +114 -90
- package/dist/core/memory/SwarmMemoryManager.d.ts.map +1 -1
- package/dist/core/memory/SwarmMemoryManager.js +277 -235
- package/dist/core/memory/SwarmMemoryManager.js.map +1 -1
- package/dist/learning/baselines/StandardTaskSuite.d.ts.map +1 -1
- package/dist/learning/baselines/StandardTaskSuite.js +38 -0
- package/dist/learning/baselines/StandardTaskSuite.js.map +1 -1
- package/dist/mcp/server-instructions.d.ts +1 -1
- package/dist/mcp/server-instructions.js +1 -1
- package/dist/types/memory-interfaces.d.ts +76 -68
- package/dist/types/memory-interfaces.d.ts.map +1 -1
- package/dist/types/memory-interfaces.js +3 -0
- package/dist/types/memory-interfaces.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,32 +2,27 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* MemoryStoreAdapter - Bridges MemoryStore interface to SwarmMemoryManager
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Issue #65: Updated to match synchronous API.
|
|
6
|
+
* Note: This adapter provides basic compatibility. For full functionality,
|
|
7
|
+
* use SwarmMemoryManager directly.
|
|
7
8
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* - Type-safe method delegation
|
|
11
|
-
* - Clear error messages for incompatible implementations
|
|
12
|
-
* - Full SwarmMemoryManager interface implementation
|
|
9
|
+
* BREAKING CHANGE: Methods now return sync values instead of Promises.
|
|
10
|
+
* The underlying MemoryStore operations are fire-and-forget for non-blocking calls.
|
|
13
11
|
*/
|
|
14
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
13
|
exports.MemoryStoreAdapter = void 0;
|
|
16
14
|
/**
|
|
17
15
|
* Adapter that wraps MemoryStore to provide ISwarmMemoryManager interface
|
|
16
|
+
* Issue #65: Now provides synchronous API with internal caching
|
|
18
17
|
*/
|
|
19
18
|
class MemoryStoreAdapter {
|
|
20
19
|
constructor(memoryStore) {
|
|
21
20
|
this.memoryStore = memoryStore;
|
|
22
21
|
this.initialized = false;
|
|
22
|
+
this.cache = new Map();
|
|
23
23
|
this.validateCompatibility();
|
|
24
24
|
}
|
|
25
|
-
/**
|
|
26
|
-
* Validates that MemoryStore has all required methods
|
|
27
|
-
* Throws clear error if incompatible
|
|
28
|
-
*/
|
|
29
25
|
validateCompatibility() {
|
|
30
|
-
// Check if memoryStore is null or undefined
|
|
31
26
|
if (!this.memoryStore || typeof this.memoryStore !== 'object') {
|
|
32
27
|
throw new Error('MemoryStoreAdapter requires a valid MemoryStore instance. ' +
|
|
33
28
|
`Received: ${this.memoryStore === null ? 'null' : typeof this.memoryStore}. ` +
|
|
@@ -45,91 +40,76 @@ class MemoryStoreAdapter {
|
|
|
45
40
|
`Cannot create VerificationHookManager with incompatible MemoryStore.`);
|
|
46
41
|
}
|
|
47
42
|
}
|
|
48
|
-
/**
|
|
49
|
-
* Initialize adapter (no-op, delegates to underlying MemoryStore)
|
|
50
|
-
*/
|
|
51
43
|
async initialize() {
|
|
52
44
|
this.initialized = true;
|
|
53
45
|
}
|
|
54
|
-
/**
|
|
55
|
-
* Store value with options
|
|
56
|
-
* Maps to MemoryStore.store() with TTL and partition support
|
|
57
|
-
*/
|
|
58
46
|
async store(key, value, options = {}) {
|
|
59
47
|
const partition = options.partition || 'default';
|
|
60
48
|
const namespacedKey = partition !== 'default' ? `${partition}:${key}` : key;
|
|
61
|
-
|
|
49
|
+
// Cache locally for sync access
|
|
50
|
+
this.cache.set(namespacedKey, {
|
|
51
|
+
value,
|
|
52
|
+
expiresAt: options.ttl ? Date.now() + options.ttl * 1000 : undefined
|
|
53
|
+
});
|
|
54
|
+
// Fire-and-forget to underlying store
|
|
55
|
+
this.memoryStore.store(namespacedKey, value, options.ttl).catch(() => { });
|
|
62
56
|
}
|
|
63
|
-
/**
|
|
64
|
-
* Retrieve value with options
|
|
65
|
-
* Maps to MemoryStore.retrieve() with partition support
|
|
66
|
-
*/
|
|
67
57
|
async retrieve(key, options = {}) {
|
|
68
58
|
const partition = options.partition || 'default';
|
|
69
59
|
const namespacedKey = partition !== 'default' ? `${partition}:${key}` : key;
|
|
60
|
+
// Check cache first
|
|
61
|
+
const cached = this.cache.get(namespacedKey);
|
|
62
|
+
if (cached) {
|
|
63
|
+
if (!cached.expiresAt || cached.expiresAt > Date.now()) {
|
|
64
|
+
return cached.value;
|
|
65
|
+
}
|
|
66
|
+
this.cache.delete(namespacedKey);
|
|
67
|
+
}
|
|
68
|
+
// Fallback to underlying store
|
|
70
69
|
return await this.memoryStore.retrieve(namespacedKey);
|
|
71
70
|
}
|
|
72
|
-
|
|
73
|
-
* Query entries matching pattern
|
|
74
|
-
* Note: MemoryStore doesn't have native pattern matching,
|
|
75
|
-
* so this returns empty array as safe fallback
|
|
76
|
-
*/
|
|
77
|
-
async query(_pattern, _options = {}) {
|
|
78
|
-
// MemoryStore doesn't support pattern queries
|
|
79
|
-
// Return empty array as safe fallback
|
|
71
|
+
query(_pattern, _options = {}) {
|
|
80
72
|
return [];
|
|
81
73
|
}
|
|
82
|
-
|
|
83
|
-
* Delete entry
|
|
84
|
-
* Maps to MemoryStore.delete() with partition support
|
|
85
|
-
*/
|
|
86
|
-
async delete(key, partition = 'default', _options = {}) {
|
|
74
|
+
delete(key, partition = 'default', _options = {}) {
|
|
87
75
|
const namespacedKey = partition !== 'default' ? `${partition}:${key}` : key;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
* Returns empty array as MemoryStore doesn't support pattern matching
|
|
107
|
-
*/
|
|
108
|
-
async readHints(_pattern) {
|
|
109
|
-
// MemoryStore doesn't support pattern queries
|
|
76
|
+
this.cache.delete(namespacedKey);
|
|
77
|
+
this.memoryStore.delete(namespacedKey).catch(() => { });
|
|
78
|
+
}
|
|
79
|
+
clear(partition = 'default') {
|
|
80
|
+
// Clear cache entries for partition
|
|
81
|
+
for (const key of this.cache.keys()) {
|
|
82
|
+
if (key.startsWith(`${partition}:`) || partition === 'default') {
|
|
83
|
+
this.cache.delete(key);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
this.memoryStore.clear(partition).catch(() => { });
|
|
87
|
+
}
|
|
88
|
+
postHint(hint) {
|
|
89
|
+
const key = `hint:${hint.key}`;
|
|
90
|
+
this.cache.set(key, { value: hint.value, expiresAt: hint.ttl ? Date.now() + hint.ttl * 1000 : undefined });
|
|
91
|
+
this.memoryStore.store(key, hint.value, hint.ttl).catch(() => { });
|
|
92
|
+
}
|
|
93
|
+
readHints(_pattern) {
|
|
110
94
|
return [];
|
|
111
95
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
96
|
+
cleanExpired() {
|
|
97
|
+
let cleaned = 0;
|
|
98
|
+
const now = Date.now();
|
|
99
|
+
for (const [key, entry] of this.cache.entries()) {
|
|
100
|
+
if (entry.expiresAt && entry.expiresAt < now) {
|
|
101
|
+
this.cache.delete(key);
|
|
102
|
+
cleaned++;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return cleaned;
|
|
118
106
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
* No-op for basic MemoryStore
|
|
122
|
-
*/
|
|
123
|
-
async close() {
|
|
124
|
-
// No-op
|
|
107
|
+
close() {
|
|
108
|
+
this.cache.clear();
|
|
125
109
|
}
|
|
126
|
-
|
|
127
|
-
* Get memory statistics
|
|
128
|
-
* Returns basic stats structure
|
|
129
|
-
*/
|
|
130
|
-
async stats() {
|
|
110
|
+
stats() {
|
|
131
111
|
return {
|
|
132
|
-
totalEntries:
|
|
112
|
+
totalEntries: this.cache.size,
|
|
133
113
|
totalHints: 0,
|
|
134
114
|
totalEvents: 0,
|
|
135
115
|
totalWorkflows: 0,
|
|
@@ -147,74 +127,75 @@ class MemoryStoreAdapter {
|
|
|
147
127
|
accessLevels: {}
|
|
148
128
|
};
|
|
149
129
|
}
|
|
150
|
-
//
|
|
151
|
-
|
|
152
|
-
// ============================================================================
|
|
153
|
-
async storeEvent(event) {
|
|
130
|
+
// Event operations
|
|
131
|
+
storeEvent(event) {
|
|
154
132
|
const id = event.id || `event-${Date.now()}`;
|
|
155
|
-
|
|
133
|
+
this.cache.set(`events:${id}`, { value: event, expiresAt: event.ttl ? Date.now() + event.ttl * 1000 : undefined });
|
|
156
134
|
return id;
|
|
157
135
|
}
|
|
158
|
-
|
|
136
|
+
queryEvents(_type) {
|
|
159
137
|
return [];
|
|
160
138
|
}
|
|
161
|
-
|
|
139
|
+
getEventsBySource(_source) {
|
|
162
140
|
return [];
|
|
163
141
|
}
|
|
164
|
-
|
|
165
|
-
|
|
142
|
+
// Workflow operations
|
|
143
|
+
storeWorkflowState(workflow) {
|
|
144
|
+
this.cache.set(`workflow:${workflow.id}`, { value: workflow });
|
|
166
145
|
}
|
|
167
|
-
|
|
168
|
-
const
|
|
169
|
-
if (!
|
|
146
|
+
getWorkflowState(id) {
|
|
147
|
+
const entry = this.cache.get(`workflow:${id}`);
|
|
148
|
+
if (!entry) {
|
|
170
149
|
throw new Error(`Workflow state not found: ${id}`);
|
|
171
150
|
}
|
|
172
|
-
return
|
|
151
|
+
return entry.value;
|
|
173
152
|
}
|
|
174
|
-
|
|
175
|
-
const current =
|
|
176
|
-
|
|
153
|
+
updateWorkflowState(id, updates) {
|
|
154
|
+
const current = this.getWorkflowState(id);
|
|
155
|
+
this.storeWorkflowState({ ...current, ...updates });
|
|
177
156
|
}
|
|
178
|
-
|
|
157
|
+
queryWorkflowsByStatus(_status) {
|
|
179
158
|
return [];
|
|
180
159
|
}
|
|
181
|
-
|
|
160
|
+
// Pattern operations
|
|
161
|
+
storePattern(pattern) {
|
|
182
162
|
const id = pattern.id || `pattern-${Date.now()}`;
|
|
183
|
-
|
|
163
|
+
this.cache.set(`patterns:${id}`, { value: pattern, expiresAt: pattern.ttl ? Date.now() + pattern.ttl * 1000 : undefined });
|
|
184
164
|
return id;
|
|
185
165
|
}
|
|
186
|
-
|
|
187
|
-
const
|
|
188
|
-
if (!
|
|
166
|
+
getPattern(patternName) {
|
|
167
|
+
const entry = this.cache.get(`patterns:${patternName}`);
|
|
168
|
+
if (!entry) {
|
|
189
169
|
throw new Error(`Pattern not found: ${patternName}`);
|
|
190
170
|
}
|
|
191
|
-
return
|
|
171
|
+
return entry.value;
|
|
192
172
|
}
|
|
193
|
-
|
|
173
|
+
incrementPatternUsage(patternName) {
|
|
194
174
|
try {
|
|
195
|
-
const pattern =
|
|
175
|
+
const pattern = this.getPattern(patternName);
|
|
196
176
|
pattern.usageCount++;
|
|
197
|
-
|
|
177
|
+
this.storePattern(pattern);
|
|
198
178
|
}
|
|
199
179
|
catch {
|
|
200
180
|
// Pattern doesn't exist, ignore
|
|
201
181
|
}
|
|
202
182
|
}
|
|
203
|
-
|
|
183
|
+
queryPatternsByConfidence(_threshold) {
|
|
204
184
|
return [];
|
|
205
185
|
}
|
|
206
|
-
|
|
207
|
-
|
|
186
|
+
// Consensus operations
|
|
187
|
+
createConsensusProposal(proposal) {
|
|
188
|
+
this.cache.set(`consensus:${proposal.id}`, { value: proposal, expiresAt: proposal.ttl ? Date.now() + proposal.ttl * 1000 : undefined });
|
|
208
189
|
}
|
|
209
|
-
|
|
210
|
-
const
|
|
211
|
-
if (!
|
|
190
|
+
getConsensusProposal(id) {
|
|
191
|
+
const entry = this.cache.get(`consensus:${id}`);
|
|
192
|
+
if (!entry) {
|
|
212
193
|
throw new Error(`Consensus proposal not found: ${id}`);
|
|
213
194
|
}
|
|
214
|
-
return
|
|
195
|
+
return entry.value;
|
|
215
196
|
}
|
|
216
|
-
|
|
217
|
-
const proposal =
|
|
197
|
+
voteOnConsensus(proposalId, agentId) {
|
|
198
|
+
const proposal = this.getConsensusProposal(proposalId);
|
|
218
199
|
if (!proposal.votes.includes(agentId)) {
|
|
219
200
|
proposal.votes.push(agentId);
|
|
220
201
|
}
|
|
@@ -222,135 +203,141 @@ class MemoryStoreAdapter {
|
|
|
222
203
|
if (approved) {
|
|
223
204
|
proposal.status = 'approved';
|
|
224
205
|
}
|
|
225
|
-
|
|
206
|
+
this.createConsensusProposal(proposal);
|
|
226
207
|
return approved;
|
|
227
208
|
}
|
|
228
|
-
|
|
209
|
+
queryConsensusProposals(_status) {
|
|
229
210
|
return [];
|
|
230
211
|
}
|
|
231
|
-
|
|
212
|
+
// Performance metrics
|
|
213
|
+
storePerformanceMetric(metric) {
|
|
232
214
|
const id = metric.id || `metric-${Date.now()}`;
|
|
233
|
-
|
|
215
|
+
this.cache.set(`metrics:${id}`, { value: metric });
|
|
234
216
|
return id;
|
|
235
217
|
}
|
|
236
|
-
|
|
218
|
+
queryPerformanceMetrics(_metricName) {
|
|
237
219
|
return [];
|
|
238
220
|
}
|
|
239
|
-
|
|
221
|
+
getMetricsByAgent(_agentId) {
|
|
240
222
|
return [];
|
|
241
223
|
}
|
|
242
|
-
|
|
224
|
+
getAverageMetric(_metricName) {
|
|
243
225
|
return 0;
|
|
244
226
|
}
|
|
245
|
-
|
|
246
|
-
|
|
227
|
+
// Artifact operations
|
|
228
|
+
createArtifact(artifact) {
|
|
229
|
+
this.cache.set(`artifact:${artifact.id}`, { value: artifact });
|
|
247
230
|
}
|
|
248
|
-
|
|
249
|
-
const
|
|
250
|
-
if (!
|
|
231
|
+
getArtifact(id) {
|
|
232
|
+
const entry = this.cache.get(`artifact:${id}`);
|
|
233
|
+
if (!entry) {
|
|
251
234
|
throw new Error(`Artifact not found: ${id}`);
|
|
252
235
|
}
|
|
253
|
-
return
|
|
236
|
+
return entry.value;
|
|
254
237
|
}
|
|
255
|
-
|
|
238
|
+
queryArtifactsByKind(_kind) {
|
|
256
239
|
return [];
|
|
257
240
|
}
|
|
258
|
-
|
|
241
|
+
queryArtifactsByTag(_tag) {
|
|
259
242
|
return [];
|
|
260
243
|
}
|
|
261
|
-
|
|
262
|
-
|
|
244
|
+
// Session operations
|
|
245
|
+
createSession(session) {
|
|
246
|
+
this.cache.set(`session:${session.id}`, { value: session });
|
|
263
247
|
}
|
|
264
|
-
|
|
265
|
-
const
|
|
266
|
-
if (!
|
|
248
|
+
getSession(id) {
|
|
249
|
+
const entry = this.cache.get(`session:${id}`);
|
|
250
|
+
if (!entry) {
|
|
267
251
|
throw new Error(`Session not found: ${id}`);
|
|
268
252
|
}
|
|
269
|
-
return
|
|
253
|
+
return entry.value;
|
|
270
254
|
}
|
|
271
|
-
|
|
272
|
-
const session =
|
|
255
|
+
addSessionCheckpoint(sessionId, checkpoint) {
|
|
256
|
+
const session = this.getSession(sessionId);
|
|
273
257
|
session.checkpoints.push(checkpoint);
|
|
274
|
-
|
|
258
|
+
this.createSession(session);
|
|
275
259
|
}
|
|
276
|
-
|
|
277
|
-
const session =
|
|
260
|
+
getLatestCheckpoint(sessionId) {
|
|
261
|
+
const session = this.getSession(sessionId);
|
|
278
262
|
return session.checkpoints.length > 0
|
|
279
263
|
? session.checkpoints[session.checkpoints.length - 1]
|
|
280
264
|
: undefined;
|
|
281
265
|
}
|
|
282
|
-
|
|
283
|
-
const session =
|
|
266
|
+
markSessionResumed(sessionId) {
|
|
267
|
+
const session = this.getSession(sessionId);
|
|
284
268
|
session.lastResumed = Date.now();
|
|
285
|
-
|
|
269
|
+
this.createSession(session);
|
|
286
270
|
}
|
|
287
|
-
|
|
288
|
-
|
|
271
|
+
// Agent registry
|
|
272
|
+
registerAgent(agent) {
|
|
273
|
+
this.cache.set(`agent:${agent.id}`, { value: agent });
|
|
289
274
|
}
|
|
290
|
-
|
|
291
|
-
const
|
|
292
|
-
if (!
|
|
275
|
+
getAgent(id) {
|
|
276
|
+
const entry = this.cache.get(`agent:${id}`);
|
|
277
|
+
if (!entry) {
|
|
293
278
|
throw new Error(`Agent not found: ${id}`);
|
|
294
279
|
}
|
|
295
|
-
return
|
|
280
|
+
return entry.value;
|
|
296
281
|
}
|
|
297
|
-
|
|
298
|
-
const agent =
|
|
282
|
+
updateAgentStatus(agentId, status) {
|
|
283
|
+
const agent = this.getAgent(agentId);
|
|
299
284
|
agent.status = status;
|
|
300
285
|
agent.updatedAt = Date.now();
|
|
301
|
-
|
|
286
|
+
this.registerAgent(agent);
|
|
302
287
|
}
|
|
303
|
-
|
|
288
|
+
queryAgentsByStatus(_status) {
|
|
304
289
|
return [];
|
|
305
290
|
}
|
|
306
|
-
|
|
307
|
-
const agent =
|
|
291
|
+
updateAgentPerformance(agentId, performance) {
|
|
292
|
+
const agent = this.getAgent(agentId);
|
|
308
293
|
agent.performance = performance;
|
|
309
294
|
agent.updatedAt = Date.now();
|
|
310
|
-
|
|
295
|
+
this.registerAgent(agent);
|
|
311
296
|
}
|
|
312
|
-
|
|
313
|
-
|
|
297
|
+
// GOAP operations
|
|
298
|
+
storeGOAPGoal(goal) {
|
|
299
|
+
this.cache.set(`goap_goal:${goal.id}`, { value: goal });
|
|
314
300
|
}
|
|
315
|
-
|
|
316
|
-
const
|
|
317
|
-
if (!
|
|
301
|
+
getGOAPGoal(id) {
|
|
302
|
+
const entry = this.cache.get(`goap_goal:${id}`);
|
|
303
|
+
if (!entry) {
|
|
318
304
|
throw new Error(`GOAP goal not found: ${id}`);
|
|
319
305
|
}
|
|
320
|
-
return
|
|
306
|
+
return entry.value;
|
|
321
307
|
}
|
|
322
|
-
|
|
323
|
-
|
|
308
|
+
storeGOAPAction(action) {
|
|
309
|
+
this.cache.set(`goap_action:${action.id}`, { value: action });
|
|
324
310
|
}
|
|
325
|
-
|
|
326
|
-
const
|
|
327
|
-
if (!
|
|
311
|
+
getGOAPAction(id) {
|
|
312
|
+
const entry = this.cache.get(`goap_action:${id}`);
|
|
313
|
+
if (!entry) {
|
|
328
314
|
throw new Error(`GOAP action not found: ${id}`);
|
|
329
315
|
}
|
|
330
|
-
return
|
|
316
|
+
return entry.value;
|
|
331
317
|
}
|
|
332
|
-
|
|
333
|
-
|
|
318
|
+
storeGOAPPlan(plan) {
|
|
319
|
+
this.cache.set(`goap_plan:${plan.id}`, { value: plan });
|
|
334
320
|
}
|
|
335
|
-
|
|
336
|
-
const
|
|
337
|
-
if (!
|
|
321
|
+
getGOAPPlan(id) {
|
|
322
|
+
const entry = this.cache.get(`goap_plan:${id}`);
|
|
323
|
+
if (!entry) {
|
|
338
324
|
throw new Error(`GOAP plan not found: ${id}`);
|
|
339
325
|
}
|
|
340
|
-
return
|
|
326
|
+
return entry.value;
|
|
341
327
|
}
|
|
342
|
-
|
|
343
|
-
|
|
328
|
+
// OODA operations
|
|
329
|
+
storeOODACycle(cycle) {
|
|
330
|
+
this.cache.set(`ooda_cycle:${cycle.id}`, { value: cycle });
|
|
344
331
|
}
|
|
345
|
-
|
|
346
|
-
const
|
|
347
|
-
if (!
|
|
332
|
+
getOODACycle(id) {
|
|
333
|
+
const entry = this.cache.get(`ooda_cycle:${id}`);
|
|
334
|
+
if (!entry) {
|
|
348
335
|
throw new Error(`OODA cycle not found: ${id}`);
|
|
349
336
|
}
|
|
350
|
-
return
|
|
337
|
+
return entry.value;
|
|
351
338
|
}
|
|
352
|
-
|
|
353
|
-
const cycle =
|
|
339
|
+
updateOODAPhase(cycleId, phase, data) {
|
|
340
|
+
const cycle = this.getOODACycle(cycleId);
|
|
354
341
|
cycle.phase = phase;
|
|
355
342
|
switch (phase) {
|
|
356
343
|
case 'observe':
|
|
@@ -366,52 +353,53 @@ class MemoryStoreAdapter {
|
|
|
366
353
|
cycle.action = data;
|
|
367
354
|
break;
|
|
368
355
|
}
|
|
369
|
-
|
|
356
|
+
this.storeOODACycle(cycle);
|
|
370
357
|
}
|
|
371
|
-
|
|
372
|
-
const cycle =
|
|
358
|
+
completeOODACycle(cycleId, result) {
|
|
359
|
+
const cycle = this.getOODACycle(cycleId);
|
|
373
360
|
cycle.completed = true;
|
|
374
361
|
cycle.result = result;
|
|
375
|
-
|
|
362
|
+
this.storeOODACycle(cycle);
|
|
376
363
|
}
|
|
377
|
-
|
|
364
|
+
queryOODACyclesByPhase(_phase) {
|
|
378
365
|
return [];
|
|
379
366
|
}
|
|
380
|
-
// ACL
|
|
381
|
-
|
|
382
|
-
|
|
367
|
+
// ACL operations
|
|
368
|
+
storeACL(acl) {
|
|
369
|
+
this.cache.set(`acl:${acl.resourceId}`, { value: acl });
|
|
383
370
|
}
|
|
384
|
-
|
|
385
|
-
|
|
371
|
+
getACL(resourceId) {
|
|
372
|
+
const entry = this.cache.get(`acl:${resourceId}`);
|
|
373
|
+
return entry?.value || null;
|
|
386
374
|
}
|
|
387
|
-
|
|
388
|
-
const existing =
|
|
375
|
+
updateACL(resourceId, updates) {
|
|
376
|
+
const existing = this.getACL(resourceId);
|
|
389
377
|
if (!existing) {
|
|
390
378
|
throw new Error(`ACL not found for resource: ${resourceId}`);
|
|
391
379
|
}
|
|
392
|
-
|
|
380
|
+
this.storeACL({ ...existing, ...updates });
|
|
393
381
|
}
|
|
394
|
-
|
|
395
|
-
const acl =
|
|
382
|
+
grantPermission(resourceId, agentId, permissions) {
|
|
383
|
+
const acl = this.getACL(resourceId);
|
|
396
384
|
if (!acl) {
|
|
397
385
|
throw new Error(`ACL not found for resource: ${resourceId}`);
|
|
398
386
|
}
|
|
399
387
|
acl.grantedPermissions = acl.grantedPermissions || {};
|
|
400
388
|
acl.grantedPermissions[agentId] = permissions;
|
|
401
|
-
|
|
389
|
+
this.storeACL(acl);
|
|
402
390
|
}
|
|
403
|
-
|
|
404
|
-
const acl =
|
|
391
|
+
revokePermission(resourceId, agentId, _permissions) {
|
|
392
|
+
const acl = this.getACL(resourceId);
|
|
405
393
|
if (!acl) {
|
|
406
394
|
throw new Error(`ACL not found for resource: ${resourceId}`);
|
|
407
395
|
}
|
|
408
396
|
if (acl.grantedPermissions && acl.grantedPermissions[agentId]) {
|
|
409
397
|
delete acl.grantedPermissions[agentId];
|
|
410
398
|
}
|
|
411
|
-
|
|
399
|
+
this.storeACL(acl);
|
|
412
400
|
}
|
|
413
|
-
|
|
414
|
-
const acl =
|
|
401
|
+
blockAgent(resourceId, agentId) {
|
|
402
|
+
const acl = this.getACL(resourceId);
|
|
415
403
|
if (!acl) {
|
|
416
404
|
throw new Error(`ACL not found for resource: ${resourceId}`);
|
|
417
405
|
}
|
|
@@ -419,41 +407,38 @@ class MemoryStoreAdapter {
|
|
|
419
407
|
if (!acl.blockedAgents.includes(agentId)) {
|
|
420
408
|
acl.blockedAgents.push(agentId);
|
|
421
409
|
}
|
|
422
|
-
|
|
410
|
+
this.storeACL(acl);
|
|
423
411
|
}
|
|
424
|
-
|
|
425
|
-
const acl =
|
|
412
|
+
unblockAgent(resourceId, agentId) {
|
|
413
|
+
const acl = this.getACL(resourceId);
|
|
426
414
|
if (!acl) {
|
|
427
415
|
throw new Error(`ACL not found for resource: ${resourceId}`);
|
|
428
416
|
}
|
|
429
417
|
if (acl.blockedAgents) {
|
|
430
418
|
acl.blockedAgents = acl.blockedAgents.filter((id) => id !== agentId);
|
|
431
419
|
}
|
|
432
|
-
|
|
420
|
+
this.storeACL(acl);
|
|
433
421
|
}
|
|
434
422
|
getAccessControl() {
|
|
435
|
-
return null;
|
|
423
|
+
return null;
|
|
436
424
|
}
|
|
437
|
-
//
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
async storeLearningExperience(_experience) {
|
|
441
|
-
// No-op: basic MemoryStore doesn't support learning operations
|
|
442
|
-
// Use SwarmMemoryManager directly for learning features
|
|
425
|
+
// Learning operations (no-op for basic adapter)
|
|
426
|
+
storeLearningExperience(_experience) {
|
|
427
|
+
// No-op: use SwarmMemoryManager directly for learning features
|
|
443
428
|
}
|
|
444
|
-
|
|
445
|
-
// No-op
|
|
429
|
+
upsertQValue(_agentId, _stateKey, _actionKey, _qValue) {
|
|
430
|
+
// No-op
|
|
446
431
|
}
|
|
447
|
-
|
|
432
|
+
getAllQValues(_agentId) {
|
|
448
433
|
return [];
|
|
449
434
|
}
|
|
450
|
-
|
|
435
|
+
getQValue(_agentId, _stateKey, _actionKey) {
|
|
451
436
|
return null;
|
|
452
437
|
}
|
|
453
|
-
|
|
454
|
-
// No-op
|
|
438
|
+
storeLearningSnapshot(_snapshot) {
|
|
439
|
+
// No-op
|
|
455
440
|
}
|
|
456
|
-
|
|
441
|
+
getLearningHistory(_agentId, _limit) {
|
|
457
442
|
return [];
|
|
458
443
|
}
|
|
459
444
|
}
|