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.
Files changed (40) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/README.md +1 -1
  3. package/dist/adapters/MemoryStoreAdapter.d.ts +75 -123
  4. package/dist/adapters/MemoryStoreAdapter.d.ts.map +1 -1
  5. package/dist/adapters/MemoryStoreAdapter.js +204 -219
  6. package/dist/adapters/MemoryStoreAdapter.js.map +1 -1
  7. package/dist/agents/AccessibilityAllyAgent.d.ts.map +1 -1
  8. package/dist/agents/AccessibilityAllyAgent.js +17 -1
  9. package/dist/agents/AccessibilityAllyAgent.js.map +1 -1
  10. package/dist/agents/BaseAgent.d.ts +18 -250
  11. package/dist/agents/BaseAgent.d.ts.map +1 -1
  12. package/dist/agents/BaseAgent.js +122 -520
  13. package/dist/agents/BaseAgent.js.map +1 -1
  14. package/dist/agents/utils/generators.d.ts +30 -0
  15. package/dist/agents/utils/generators.d.ts.map +1 -0
  16. package/dist/agents/utils/generators.js +44 -0
  17. package/dist/agents/utils/generators.js.map +1 -0
  18. package/dist/agents/utils/index.d.ts +10 -0
  19. package/dist/agents/utils/index.d.ts.map +1 -0
  20. package/dist/agents/utils/index.js +19 -0
  21. package/dist/agents/utils/index.js.map +1 -0
  22. package/dist/agents/utils/validation.d.ts +72 -0
  23. package/dist/agents/utils/validation.d.ts.map +1 -0
  24. package/dist/agents/utils/validation.js +75 -0
  25. package/dist/agents/utils/validation.js.map +1 -0
  26. package/dist/core/memory/HNSWVectorMemory.js +1 -1
  27. package/dist/core/memory/SwarmMemoryManager.d.ts +114 -90
  28. package/dist/core/memory/SwarmMemoryManager.d.ts.map +1 -1
  29. package/dist/core/memory/SwarmMemoryManager.js +277 -235
  30. package/dist/core/memory/SwarmMemoryManager.js.map +1 -1
  31. package/dist/learning/baselines/StandardTaskSuite.d.ts.map +1 -1
  32. package/dist/learning/baselines/StandardTaskSuite.js +38 -0
  33. package/dist/learning/baselines/StandardTaskSuite.js.map +1 -1
  34. package/dist/mcp/server-instructions.d.ts +1 -1
  35. package/dist/mcp/server-instructions.js +1 -1
  36. package/dist/types/memory-interfaces.d.ts +76 -68
  37. package/dist/types/memory-interfaces.d.ts.map +1 -1
  38. package/dist/types/memory-interfaces.js +3 -0
  39. package/dist/types/memory-interfaces.js.map +1 -1
  40. package/package.json +1 -1
@@ -2,32 +2,27 @@
2
2
  /**
3
3
  * MemoryStoreAdapter - Bridges MemoryStore interface to SwarmMemoryManager
4
4
  *
5
- * This adapter provides type-safe compatibility between the MemoryStore interface
6
- * used by BaseAgent and the SwarmMemoryManager expected by VerificationHookManager.
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
- * Key Features:
9
- * - Runtime validation of MemoryStore compatibility
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
- await this.memoryStore.store(namespacedKey, value, options.ttl);
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
- await this.memoryStore.delete(namespacedKey);
89
- }
90
- /**
91
- * Clear partition
92
- * Maps to MemoryStore.clear() with namespace support
93
- */
94
- async clear(partition = 'default') {
95
- await this.memoryStore.clear(partition);
96
- }
97
- /**
98
- * Post hint to blackboard
99
- * Stores as regular entry with hint: prefix
100
- */
101
- async postHint(hint) {
102
- await this.memoryStore.store(`hint:${hint.key}`, hint.value, hint.ttl);
103
- }
104
- /**
105
- * Read hints matching pattern
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
- * Clean expired entries
114
- * No-op for basic MemoryStore (relies on TTL)
115
- */
116
- async cleanExpired() {
117
- return 0;
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
- * Close connection
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: 0,
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
- // Table-specific methods (delegated with basic implementation)
152
- // ============================================================================
153
- async storeEvent(event) {
130
+ // Event operations
131
+ storeEvent(event) {
154
132
  const id = event.id || `event-${Date.now()}`;
155
- await this.store(`events:${id}`, event, { partition: 'events', ttl: event.ttl });
133
+ this.cache.set(`events:${id}`, { value: event, expiresAt: event.ttl ? Date.now() + event.ttl * 1000 : undefined });
156
134
  return id;
157
135
  }
158
- async queryEvents(_type) {
136
+ queryEvents(_type) {
159
137
  return [];
160
138
  }
161
- async getEventsBySource(_source) {
139
+ getEventsBySource(_source) {
162
140
  return [];
163
141
  }
164
- async storeWorkflowState(workflow) {
165
- await this.store(`workflow:${workflow.id}`, workflow, { partition: 'workflow_state' });
142
+ // Workflow operations
143
+ storeWorkflowState(workflow) {
144
+ this.cache.set(`workflow:${workflow.id}`, { value: workflow });
166
145
  }
167
- async getWorkflowState(id) {
168
- const data = await this.retrieve(`workflow:${id}`, { partition: 'workflow_state' });
169
- if (!data) {
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 data;
151
+ return entry.value;
173
152
  }
174
- async updateWorkflowState(id, updates) {
175
- const current = await this.getWorkflowState(id);
176
- await this.storeWorkflowState({ ...current, ...updates });
153
+ updateWorkflowState(id, updates) {
154
+ const current = this.getWorkflowState(id);
155
+ this.storeWorkflowState({ ...current, ...updates });
177
156
  }
178
- async queryWorkflowsByStatus(_status) {
157
+ queryWorkflowsByStatus(_status) {
179
158
  return [];
180
159
  }
181
- async storePattern(pattern) {
160
+ // Pattern operations
161
+ storePattern(pattern) {
182
162
  const id = pattern.id || `pattern-${Date.now()}`;
183
- await this.store(`patterns:${id}`, pattern, { partition: 'patterns', ttl: pattern.ttl });
163
+ this.cache.set(`patterns:${id}`, { value: pattern, expiresAt: pattern.ttl ? Date.now() + pattern.ttl * 1000 : undefined });
184
164
  return id;
185
165
  }
186
- async getPattern(patternName) {
187
- const data = await this.retrieve(`patterns:${patternName}`, { partition: 'patterns' });
188
- if (!data) {
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 data;
171
+ return entry.value;
192
172
  }
193
- async incrementPatternUsage(patternName) {
173
+ incrementPatternUsage(patternName) {
194
174
  try {
195
- const pattern = await this.getPattern(patternName);
175
+ const pattern = this.getPattern(patternName);
196
176
  pattern.usageCount++;
197
- await this.storePattern(pattern);
177
+ this.storePattern(pattern);
198
178
  }
199
179
  catch {
200
180
  // Pattern doesn't exist, ignore
201
181
  }
202
182
  }
203
- async queryPatternsByConfidence(_threshold) {
183
+ queryPatternsByConfidence(_threshold) {
204
184
  return [];
205
185
  }
206
- async createConsensusProposal(proposal) {
207
- await this.store(`consensus:${proposal.id}`, proposal, { partition: 'consensus', ttl: proposal.ttl });
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
- async getConsensusProposal(id) {
210
- const data = await this.retrieve(`consensus:${id}`, { partition: 'consensus' });
211
- if (!data) {
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 data;
195
+ return entry.value;
215
196
  }
216
- async voteOnConsensus(proposalId, agentId) {
217
- const proposal = await this.getConsensusProposal(proposalId);
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
- await this.createConsensusProposal(proposal);
206
+ this.createConsensusProposal(proposal);
226
207
  return approved;
227
208
  }
228
- async queryConsensusProposals(_status) {
209
+ queryConsensusProposals(_status) {
229
210
  return [];
230
211
  }
231
- async storePerformanceMetric(metric) {
212
+ // Performance metrics
213
+ storePerformanceMetric(metric) {
232
214
  const id = metric.id || `metric-${Date.now()}`;
233
- await this.store(`metrics:${id}`, metric, { partition: 'performance_metrics' });
215
+ this.cache.set(`metrics:${id}`, { value: metric });
234
216
  return id;
235
217
  }
236
- async queryPerformanceMetrics(_metricName) {
218
+ queryPerformanceMetrics(_metricName) {
237
219
  return [];
238
220
  }
239
- async getMetricsByAgent(_agentId) {
221
+ getMetricsByAgent(_agentId) {
240
222
  return [];
241
223
  }
242
- async getAverageMetric(_metricName) {
224
+ getAverageMetric(_metricName) {
243
225
  return 0;
244
226
  }
245
- async createArtifact(artifact) {
246
- await this.store(`artifact:${artifact.id}`, artifact, { partition: 'artifacts' });
227
+ // Artifact operations
228
+ createArtifact(artifact) {
229
+ this.cache.set(`artifact:${artifact.id}`, { value: artifact });
247
230
  }
248
- async getArtifact(id) {
249
- const data = await this.retrieve(`artifact:${id}`, { partition: 'artifacts' });
250
- if (!data) {
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 data;
236
+ return entry.value;
254
237
  }
255
- async queryArtifactsByKind(_kind) {
238
+ queryArtifactsByKind(_kind) {
256
239
  return [];
257
240
  }
258
- async queryArtifactsByTag(_tag) {
241
+ queryArtifactsByTag(_tag) {
259
242
  return [];
260
243
  }
261
- async createSession(session) {
262
- await this.store(`session:${session.id}`, session, { partition: 'sessions' });
244
+ // Session operations
245
+ createSession(session) {
246
+ this.cache.set(`session:${session.id}`, { value: session });
263
247
  }
264
- async getSession(id) {
265
- const data = await this.retrieve(`session:${id}`, { partition: 'sessions' });
266
- if (!data) {
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 data;
253
+ return entry.value;
270
254
  }
271
- async addSessionCheckpoint(sessionId, checkpoint) {
272
- const session = await this.getSession(sessionId);
255
+ addSessionCheckpoint(sessionId, checkpoint) {
256
+ const session = this.getSession(sessionId);
273
257
  session.checkpoints.push(checkpoint);
274
- await this.createSession(session);
258
+ this.createSession(session);
275
259
  }
276
- async getLatestCheckpoint(sessionId) {
277
- const session = await this.getSession(sessionId);
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
- async markSessionResumed(sessionId) {
283
- const session = await this.getSession(sessionId);
266
+ markSessionResumed(sessionId) {
267
+ const session = this.getSession(sessionId);
284
268
  session.lastResumed = Date.now();
285
- await this.createSession(session);
269
+ this.createSession(session);
286
270
  }
287
- async registerAgent(agent) {
288
- await this.store(`agent:${agent.id}`, agent, { partition: 'agent_registry' });
271
+ // Agent registry
272
+ registerAgent(agent) {
273
+ this.cache.set(`agent:${agent.id}`, { value: agent });
289
274
  }
290
- async getAgent(id) {
291
- const data = await this.retrieve(`agent:${id}`, { partition: 'agent_registry' });
292
- if (!data) {
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 data;
280
+ return entry.value;
296
281
  }
297
- async updateAgentStatus(agentId, status) {
298
- const agent = await this.getAgent(agentId);
282
+ updateAgentStatus(agentId, status) {
283
+ const agent = this.getAgent(agentId);
299
284
  agent.status = status;
300
285
  agent.updatedAt = Date.now();
301
- await this.registerAgent(agent);
286
+ this.registerAgent(agent);
302
287
  }
303
- async queryAgentsByStatus(_status) {
288
+ queryAgentsByStatus(_status) {
304
289
  return [];
305
290
  }
306
- async updateAgentPerformance(agentId, performance) {
307
- const agent = await this.getAgent(agentId);
291
+ updateAgentPerformance(agentId, performance) {
292
+ const agent = this.getAgent(agentId);
308
293
  agent.performance = performance;
309
294
  agent.updatedAt = Date.now();
310
- await this.registerAgent(agent);
295
+ this.registerAgent(agent);
311
296
  }
312
- async storeGOAPGoal(goal) {
313
- await this.store(`goap_goal:${goal.id}`, goal, { partition: 'goap_goals' });
297
+ // GOAP operations
298
+ storeGOAPGoal(goal) {
299
+ this.cache.set(`goap_goal:${goal.id}`, { value: goal });
314
300
  }
315
- async getGOAPGoal(id) {
316
- const data = await this.retrieve(`goap_goal:${id}`, { partition: 'goap_goals' });
317
- if (!data) {
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 data;
306
+ return entry.value;
321
307
  }
322
- async storeGOAPAction(action) {
323
- await this.store(`goap_action:${action.id}`, action, { partition: 'goap_actions' });
308
+ storeGOAPAction(action) {
309
+ this.cache.set(`goap_action:${action.id}`, { value: action });
324
310
  }
325
- async getGOAPAction(id) {
326
- const data = await this.retrieve(`goap_action:${id}`, { partition: 'goap_actions' });
327
- if (!data) {
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 data;
316
+ return entry.value;
331
317
  }
332
- async storeGOAPPlan(plan) {
333
- await this.store(`goap_plan:${plan.id}`, plan, { partition: 'goap_plans' });
318
+ storeGOAPPlan(plan) {
319
+ this.cache.set(`goap_plan:${plan.id}`, { value: plan });
334
320
  }
335
- async getGOAPPlan(id) {
336
- const data = await this.retrieve(`goap_plan:${id}`, { partition: 'goap_plans' });
337
- if (!data) {
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 data;
326
+ return entry.value;
341
327
  }
342
- async storeOODACycle(cycle) {
343
- await this.store(`ooda_cycle:${cycle.id}`, cycle, { partition: 'ooda_cycles' });
328
+ // OODA operations
329
+ storeOODACycle(cycle) {
330
+ this.cache.set(`ooda_cycle:${cycle.id}`, { value: cycle });
344
331
  }
345
- async getOODACycle(id) {
346
- const data = await this.retrieve(`ooda_cycle:${id}`, { partition: 'ooda_cycles' });
347
- if (!data) {
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 data;
337
+ return entry.value;
351
338
  }
352
- async updateOODAPhase(cycleId, phase, data) {
353
- const cycle = await this.getOODACycle(cycleId);
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
- await this.storeOODACycle(cycle);
356
+ this.storeOODACycle(cycle);
370
357
  }
371
- async completeOODACycle(cycleId, result) {
372
- const cycle = await this.getOODACycle(cycleId);
358
+ completeOODACycle(cycleId, result) {
359
+ const cycle = this.getOODACycle(cycleId);
373
360
  cycle.completed = true;
374
361
  cycle.result = result;
375
- await this.storeOODACycle(cycle);
362
+ this.storeOODACycle(cycle);
376
363
  }
377
- async queryOODACyclesByPhase(_phase) {
364
+ queryOODACyclesByPhase(_phase) {
378
365
  return [];
379
366
  }
380
- // ACL methods (basic implementation)
381
- async storeACL(acl) {
382
- await this.store(`acl:${acl.resourceId}`, acl, { partition: 'acl' });
367
+ // ACL operations
368
+ storeACL(acl) {
369
+ this.cache.set(`acl:${acl.resourceId}`, { value: acl });
383
370
  }
384
- async getACL(resourceId) {
385
- return await this.retrieve(`acl:${resourceId}`, { partition: 'acl' });
371
+ getACL(resourceId) {
372
+ const entry = this.cache.get(`acl:${resourceId}`);
373
+ return entry?.value || null;
386
374
  }
387
- async updateACL(resourceId, updates) {
388
- const existing = await this.getACL(resourceId);
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
- await this.storeACL({ ...existing, ...updates });
380
+ this.storeACL({ ...existing, ...updates });
393
381
  }
394
- async grantPermission(resourceId, agentId, permissions) {
395
- const acl = await this.getACL(resourceId);
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
- await this.storeACL(acl);
389
+ this.storeACL(acl);
402
390
  }
403
- async revokePermission(resourceId, agentId, _permissions) {
404
- const acl = await this.getACL(resourceId);
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
- await this.storeACL(acl);
399
+ this.storeACL(acl);
412
400
  }
413
- async blockAgent(resourceId, agentId) {
414
- const acl = await this.getACL(resourceId);
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
- await this.storeACL(acl);
410
+ this.storeACL(acl);
423
411
  }
424
- async unblockAgent(resourceId, agentId) {
425
- const acl = await this.getACL(resourceId);
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
- await this.storeACL(acl);
420
+ this.storeACL(acl);
433
421
  }
434
422
  getAccessControl() {
435
- return null; // Not implemented in basic adapter
423
+ return null;
436
424
  }
437
- // ============================================================================
438
- // Learning Operations (no-op implementations for basic MemoryStore adapter)
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
- async upsertQValue(_agentId, _stateKey, _actionKey, _qValue) {
445
- // No-op: basic MemoryStore doesn't support learning operations
429
+ upsertQValue(_agentId, _stateKey, _actionKey, _qValue) {
430
+ // No-op
446
431
  }
447
- async getAllQValues(_agentId) {
432
+ getAllQValues(_agentId) {
448
433
  return [];
449
434
  }
450
- async getQValue(_agentId, _stateKey, _actionKey) {
435
+ getQValue(_agentId, _stateKey, _actionKey) {
451
436
  return null;
452
437
  }
453
- async storeLearningSnapshot(_snapshot) {
454
- // No-op: basic MemoryStore doesn't support learning operations
438
+ storeLearningSnapshot(_snapshot) {
439
+ // No-op
455
440
  }
456
- async getLearningHistory(_agentId, _limit) {
441
+ getLearningHistory(_agentId, _limit) {
457
442
  return [];
458
443
  }
459
444
  }