agentic-qe 1.8.4 → 1.9.0
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/.claude/skills/agentic-jujutsu/SKILL.md +645 -0
- package/CHANGELOG.md +375 -0
- package/README.md +86 -18
- package/dist/App.d.ts +5 -0
- package/dist/App.d.ts.map +1 -0
- package/dist/App.js +15 -0
- package/dist/App.js.map +1 -0
- package/dist/cli/commands/constitution.d.ts +34 -0
- package/dist/cli/commands/constitution.d.ts.map +1 -0
- package/dist/cli/commands/constitution.js +679 -0
- package/dist/cli/commands/constitution.js.map +1 -0
- package/dist/cli/commands/init.d.ts +8 -75
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +22 -2292
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/telemetry.d.ts +36 -0
- package/dist/cli/commands/telemetry.d.ts.map +1 -0
- package/dist/cli/commands/telemetry.js +364 -0
- package/dist/cli/commands/telemetry.js.map +1 -0
- package/dist/cli/index.js +66 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/init/agents.d.ts +22 -0
- package/dist/cli/init/agents.d.ts.map +1 -0
- package/dist/cli/init/agents.js +522 -0
- package/dist/cli/init/agents.js.map +1 -0
- package/dist/cli/init/bash-wrapper.d.ts +14 -0
- package/dist/cli/init/bash-wrapper.d.ts.map +1 -0
- package/dist/cli/init/bash-wrapper.js +47 -0
- package/dist/cli/init/bash-wrapper.js.map +1 -0
- package/dist/cli/init/claude-config.d.ts +24 -0
- package/dist/cli/init/claude-config.d.ts.map +1 -0
- package/dist/cli/init/claude-config.js +275 -0
- package/dist/cli/init/claude-config.js.map +1 -0
- package/dist/cli/init/claude-md.d.ts +19 -0
- package/dist/cli/init/claude-md.d.ts.map +1 -0
- package/dist/cli/init/claude-md.js +153 -0
- package/dist/cli/init/claude-md.js.map +1 -0
- package/dist/cli/init/commands.d.ts +6 -0
- package/dist/cli/init/commands.d.ts.map +1 -0
- package/dist/cli/init/commands.js +83 -0
- package/dist/cli/init/commands.js.map +1 -0
- package/dist/cli/init/database-init.d.ts +15 -0
- package/dist/cli/init/database-init.d.ts.map +1 -0
- package/dist/cli/init/database-init.js +203 -0
- package/dist/cli/init/database-init.js.map +1 -0
- package/dist/cli/init/directory-structure.d.ts +14 -0
- package/dist/cli/init/directory-structure.d.ts.map +1 -0
- package/dist/cli/init/directory-structure.js +107 -0
- package/dist/cli/init/directory-structure.js.map +1 -0
- package/dist/cli/init/documentation.d.ts +14 -0
- package/dist/cli/init/documentation.d.ts.map +1 -0
- package/dist/cli/init/documentation.js +195 -0
- package/dist/cli/init/documentation.js.map +1 -0
- package/dist/cli/init/fleet-config.d.ts +34 -0
- package/dist/cli/init/fleet-config.d.ts.map +1 -0
- package/dist/cli/init/fleet-config.js +269 -0
- package/dist/cli/init/fleet-config.js.map +1 -0
- package/dist/cli/init/helpers.d.ts +6 -0
- package/dist/cli/init/helpers.d.ts.map +1 -0
- package/dist/cli/init/helpers.js +94 -0
- package/dist/cli/init/helpers.js.map +1 -0
- package/dist/cli/init/index.d.ts +32 -0
- package/dist/cli/init/index.d.ts.map +1 -0
- package/dist/cli/init/index.js +294 -0
- package/dist/cli/init/index.js.map +1 -0
- package/dist/cli/init/skills.d.ts +6 -0
- package/dist/cli/init/skills.d.ts.map +1 -0
- package/dist/cli/init/skills.js +138 -0
- package/dist/cli/init/skills.js.map +1 -0
- package/dist/cli/init/utils/file-utils.d.ts +74 -0
- package/dist/cli/init/utils/file-utils.d.ts.map +1 -0
- package/dist/cli/init/utils/file-utils.js +187 -0
- package/dist/cli/init/utils/file-utils.js.map +1 -0
- package/dist/cli/init/utils/index.d.ts +18 -0
- package/dist/cli/init/utils/index.d.ts.map +1 -0
- package/dist/cli/init/utils/index.js +48 -0
- package/dist/cli/init/utils/index.js.map +1 -0
- package/dist/cli/init/utils/log-utils.d.ts +47 -0
- package/dist/cli/init/utils/log-utils.d.ts.map +1 -0
- package/dist/cli/init/utils/log-utils.js +68 -0
- package/dist/cli/init/utils/log-utils.js.map +1 -0
- package/dist/cli/init/utils/path-utils.d.ts +91 -0
- package/dist/cli/init/utils/path-utils.d.ts.map +1 -0
- package/dist/cli/init/utils/path-utils.js +208 -0
- package/dist/cli/init/utils/path-utils.js.map +1 -0
- package/dist/cli/init/utils/validation-utils.d.ts +44 -0
- package/dist/cli/init/utils/validation-utils.d.ts.map +1 -0
- package/dist/cli/init/utils/validation-utils.js +68 -0
- package/dist/cli/init/utils/validation-utils.js.map +1 -0
- package/dist/cli/init/utils.d.ts +183 -0
- package/dist/cli/init/utils.d.ts.map +1 -0
- package/dist/cli/init/utils.js +354 -0
- package/dist/cli/init/utils.js.map +1 -0
- package/dist/components/Dashboard/Dashboard.d.ts +4 -0
- package/dist/components/Dashboard/Dashboard.d.ts.map +1 -0
- package/dist/components/Dashboard/Dashboard.js +148 -0
- package/dist/components/Dashboard/Dashboard.js.map +1 -0
- package/dist/components/Dashboard/DashboardHeader.d.ts +4 -0
- package/dist/components/Dashboard/DashboardHeader.d.ts.map +1 -0
- package/dist/components/Dashboard/DashboardHeader.js +138 -0
- package/dist/components/Dashboard/DashboardHeader.js.map +1 -0
- package/dist/constitution/evaluators/ast-evaluator.d.ts +42 -0
- package/dist/constitution/evaluators/ast-evaluator.d.ts.map +1 -0
- package/dist/constitution/evaluators/ast-evaluator.js +303 -0
- package/dist/constitution/evaluators/ast-evaluator.js.map +1 -0
- package/dist/constitution/evaluators/base.d.ts +144 -0
- package/dist/constitution/evaluators/base.d.ts.map +1 -0
- package/dist/constitution/evaluators/base.js +144 -0
- package/dist/constitution/evaluators/base.js.map +1 -0
- package/dist/constitution/evaluators/index.d.ts +19 -0
- package/dist/constitution/evaluators/index.d.ts.map +1 -0
- package/dist/constitution/evaluators/index.js +56 -0
- package/dist/constitution/evaluators/index.js.map +1 -0
- package/dist/constitution/evaluators/metric-evaluator.d.ts +59 -0
- package/dist/constitution/evaluators/metric-evaluator.d.ts.map +1 -0
- package/dist/constitution/evaluators/metric-evaluator.js +195 -0
- package/dist/constitution/evaluators/metric-evaluator.js.map +1 -0
- package/dist/constitution/evaluators/pattern-evaluator.d.ts +66 -0
- package/dist/constitution/evaluators/pattern-evaluator.d.ts.map +1 -0
- package/dist/constitution/evaluators/pattern-evaluator.js +221 -0
- package/dist/constitution/evaluators/pattern-evaluator.js.map +1 -0
- package/dist/constitution/evaluators/semantic-evaluator.d.ts +68 -0
- package/dist/constitution/evaluators/semantic-evaluator.d.ts.map +1 -0
- package/dist/constitution/evaluators/semantic-evaluator.js +250 -0
- package/dist/constitution/evaluators/semantic-evaluator.js.map +1 -0
- package/dist/contexts/DashboardContext.d.ts +41 -0
- package/dist/contexts/DashboardContext.d.ts.map +1 -0
- package/dist/contexts/DashboardContext.js +187 -0
- package/dist/contexts/DashboardContext.js.map +1 -0
- package/dist/core/memory/SwarmMemoryManager.d.ts +40 -0
- package/dist/core/memory/SwarmMemoryManager.d.ts.map +1 -1
- package/dist/core/memory/SwarmMemoryManager.js +279 -120
- package/dist/core/memory/SwarmMemoryManager.js.map +1 -1
- package/dist/hooks/useKeyboardShortcuts.d.ts +12 -0
- package/dist/hooks/useKeyboardShortcuts.d.ts.map +1 -0
- package/dist/hooks/useKeyboardShortcuts.js +69 -0
- package/dist/hooks/useKeyboardShortcuts.js.map +1 -0
- package/dist/telemetry/instrumentation/agent.d.ts +158 -0
- package/dist/telemetry/instrumentation/agent.d.ts.map +1 -0
- package/dist/telemetry/instrumentation/agent.js +372 -0
- package/dist/telemetry/instrumentation/agent.js.map +1 -0
- package/dist/telemetry/instrumentation/index.d.ts +24 -0
- package/dist/telemetry/instrumentation/index.d.ts.map +1 -0
- package/dist/telemetry/instrumentation/index.js +54 -0
- package/dist/telemetry/instrumentation/index.js.map +1 -0
- package/dist/telemetry/instrumentation/memory.d.ts +313 -0
- package/dist/telemetry/instrumentation/memory.d.ts.map +1 -0
- package/dist/telemetry/instrumentation/memory.js +552 -0
- package/dist/telemetry/instrumentation/memory.js.map +1 -0
- package/dist/telemetry/instrumentation/task.d.ts +146 -0
- package/dist/telemetry/instrumentation/task.d.ts.map +1 -0
- package/dist/telemetry/instrumentation/task.js +305 -0
- package/dist/telemetry/instrumentation/task.js.map +1 -0
- package/dist/telemetry/metrics/collectors/cost.d.ts +246 -0
- package/dist/telemetry/metrics/collectors/cost.d.ts.map +1 -0
- package/dist/telemetry/metrics/collectors/cost.js +526 -0
- package/dist/telemetry/metrics/collectors/cost.js.map +1 -0
- package/dist/telemetry/metrics/collectors/pricing-config.d.ts +87 -0
- package/dist/telemetry/metrics/collectors/pricing-config.d.ts.map +1 -0
- package/dist/telemetry/metrics/collectors/pricing-config.js +207 -0
- package/dist/telemetry/metrics/collectors/pricing-config.js.map +1 -0
- package/dist/telemetry/metrics/index.d.ts +4 -1
- package/dist/telemetry/metrics/index.d.ts.map +1 -1
- package/dist/telemetry/metrics/index.js +18 -2
- package/dist/telemetry/metrics/index.js.map +1 -1
- package/dist/telemetry/types.d.ts +1 -1
- package/dist/telemetry/types.d.ts.map +1 -1
- package/dist/visualization/api/RestEndpoints.d.ts +136 -0
- package/dist/visualization/api/RestEndpoints.d.ts.map +1 -0
- package/dist/visualization/api/RestEndpoints.js +428 -0
- package/dist/visualization/api/RestEndpoints.js.map +1 -0
- package/dist/visualization/api/WebSocketServer.d.ts +165 -0
- package/dist/visualization/api/WebSocketServer.d.ts.map +1 -0
- package/dist/visualization/api/WebSocketServer.js +518 -0
- package/dist/visualization/api/WebSocketServer.js.map +1 -0
- package/dist/visualization/core/DataTransformer.d.ts +89 -0
- package/dist/visualization/core/DataTransformer.d.ts.map +1 -0
- package/dist/visualization/core/DataTransformer.js +478 -0
- package/dist/visualization/core/DataTransformer.js.map +1 -0
- package/dist/visualization/index.d.ts +92 -0
- package/dist/visualization/index.d.ts.map +1 -0
- package/dist/visualization/index.js +121 -0
- package/dist/visualization/index.js.map +1 -0
- package/dist/visualization/types.d.ts +148 -0
- package/dist/visualization/types.d.ts.map +1 -0
- package/dist/visualization/types.js +7 -0
- package/dist/visualization/types.js.map +1 -0
- package/dist/voting/consensus.d.ts +87 -0
- package/dist/voting/consensus.d.ts.map +1 -0
- package/dist/voting/consensus.js +568 -0
- package/dist/voting/consensus.js.map +1 -0
- package/dist/voting/index.d.ts +12 -0
- package/dist/voting/index.d.ts.map +1 -0
- package/dist/voting/index.js +36 -0
- package/dist/voting/index.js.map +1 -0
- package/dist/voting/orchestrator.d.ts +65 -0
- package/dist/voting/orchestrator.d.ts.map +1 -0
- package/dist/voting/orchestrator.js +306 -0
- package/dist/voting/orchestrator.js.map +1 -0
- package/dist/voting/panel-assembly.d.ts +54 -0
- package/dist/voting/panel-assembly.d.ts.map +1 -0
- package/dist/voting/panel-assembly.js +192 -0
- package/dist/voting/panel-assembly.js.map +1 -0
- package/dist/voting/protocol.d.ts +119 -0
- package/dist/voting/protocol.d.ts.map +1 -0
- package/dist/voting/protocol.js +18 -0
- package/dist/voting/protocol.js.map +1 -0
- package/dist/voting/types.d.ts +125 -0
- package/dist/voting/types.d.ts.map +1 -0
- package/dist/voting/types.js +7 -0
- package/dist/voting/types.js.map +1 -0
- package/package.json +27 -2
|
@@ -47,6 +47,8 @@ Object.defineProperty(exports, "Permission", { enumerable: true, get: function (
|
|
|
47
47
|
Object.defineProperty(exports, "AccessControlError", { enumerable: true, get: function () { return AccessControl_1.AccessControlError; } });
|
|
48
48
|
const AgentDBManager_1 = require("./AgentDBManager");
|
|
49
49
|
const PatternCache_1 = require("./PatternCache");
|
|
50
|
+
const memory_1 = require("../../telemetry/instrumentation/memory");
|
|
51
|
+
const types_1 = require("../../types");
|
|
50
52
|
/**
|
|
51
53
|
* SwarmMemoryManager - Manages persistent memory for agent swarm coordination
|
|
52
54
|
*
|
|
@@ -401,6 +403,16 @@ class SwarmMemoryManager {
|
|
|
401
403
|
await this.run(`CREATE INDEX IF NOT EXISTS idx_learning_metrics_agent ON learning_metrics(agent_id)`);
|
|
402
404
|
this.initialized = true;
|
|
403
405
|
}
|
|
406
|
+
/**
|
|
407
|
+
* Store a key-value pair in memory with OpenTelemetry instrumentation
|
|
408
|
+
*
|
|
409
|
+
* Automatically instruments the memory store operation with distributed tracing.
|
|
410
|
+
* Records namespace, key, value size, TTL, and operation performance metrics.
|
|
411
|
+
*
|
|
412
|
+
* @param key - Memory key
|
|
413
|
+
* @param value - Value to store (will be JSON serialized)
|
|
414
|
+
* @param options - Store options including partition, TTL, access control
|
|
415
|
+
*/
|
|
404
416
|
async store(key, value, options = {}) {
|
|
405
417
|
// Auto-initialize if not initialized
|
|
406
418
|
if (!this.initialized) {
|
|
@@ -412,44 +424,73 @@ class SwarmMemoryManager {
|
|
|
412
424
|
const partition = options.partition || 'default';
|
|
413
425
|
const owner = options.owner || 'system';
|
|
414
426
|
const accessLevel = options.accessLevel || AccessControl_1.AccessLevel.PRIVATE;
|
|
415
|
-
const
|
|
416
|
-
const
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
if (
|
|
433
|
-
|
|
427
|
+
const valueJson = JSON.stringify(value);
|
|
428
|
+
const valueSize = valueJson.length;
|
|
429
|
+
// Create instrumentation span
|
|
430
|
+
const { span, context: spanContext } = memory_1.memorySpanManager.startStoreSpan({
|
|
431
|
+
agentId: { id: owner, type: types_1.QEAgentType.FLEET_COMMANDER, created: new Date() },
|
|
432
|
+
namespace: partition,
|
|
433
|
+
key,
|
|
434
|
+
valueSize,
|
|
435
|
+
ttl: options.ttl,
|
|
436
|
+
});
|
|
437
|
+
const startTime = Date.now();
|
|
438
|
+
try {
|
|
439
|
+
const createdAt = Date.now();
|
|
440
|
+
const expiresAt = options.ttl ? createdAt + (options.ttl * 1000) : null;
|
|
441
|
+
const metadata = options.metadata ? JSON.stringify(options.metadata) : null;
|
|
442
|
+
// Check write permission if updating existing entry
|
|
443
|
+
const existing = await this.queryOne(`SELECT owner, access_level, team_id, swarm_id FROM memory_entries WHERE key = ? AND partition = ?`, [key, partition]);
|
|
444
|
+
if (existing && options.owner) {
|
|
445
|
+
// Verify write permission
|
|
446
|
+
const permCheck = this.accessControl.checkPermission({
|
|
447
|
+
agentId: options.owner,
|
|
448
|
+
resourceOwner: existing.owner,
|
|
449
|
+
accessLevel: existing.access_level,
|
|
450
|
+
permission: AccessControl_1.Permission.WRITE,
|
|
451
|
+
teamId: options.teamId,
|
|
452
|
+
resourceTeamId: existing.team_id,
|
|
453
|
+
swarmId: options.swarmId,
|
|
454
|
+
resourceSwarmId: existing.swarm_id
|
|
455
|
+
});
|
|
456
|
+
if (!permCheck.allowed) {
|
|
457
|
+
throw new AccessControl_1.AccessControlError(`Write denied: ${permCheck.reason}`);
|
|
458
|
+
}
|
|
434
459
|
}
|
|
460
|
+
await this.run(`INSERT OR REPLACE INTO memory_entries
|
|
461
|
+
(key, partition, value, metadata, created_at, expires_at, owner, access_level, team_id, swarm_id)
|
|
462
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
|
|
463
|
+
key,
|
|
464
|
+
partition,
|
|
465
|
+
valueJson,
|
|
466
|
+
metadata,
|
|
467
|
+
createdAt,
|
|
468
|
+
expiresAt,
|
|
469
|
+
owner,
|
|
470
|
+
accessLevel,
|
|
471
|
+
options.teamId || null,
|
|
472
|
+
options.swarmId || null
|
|
473
|
+
]);
|
|
474
|
+
// Track modification for QUIC sync
|
|
475
|
+
const entryKey = `${partition}:${key}`;
|
|
476
|
+
this.lastModifiedTimestamps.set(entryKey, createdAt);
|
|
477
|
+
// Complete span successfully
|
|
478
|
+
const durationMs = Date.now() - startTime;
|
|
479
|
+
memory_1.memorySpanManager.completeStoreSpan(span, {
|
|
480
|
+
success: true,
|
|
481
|
+
durationMs,
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
catch (error) {
|
|
485
|
+
// Complete span with error
|
|
486
|
+
const durationMs = Date.now() - startTime;
|
|
487
|
+
memory_1.memorySpanManager.completeStoreSpan(span, {
|
|
488
|
+
success: false,
|
|
489
|
+
durationMs,
|
|
490
|
+
error: error,
|
|
491
|
+
});
|
|
492
|
+
throw error;
|
|
435
493
|
}
|
|
436
|
-
await this.run(`INSERT OR REPLACE INTO memory_entries
|
|
437
|
-
(key, partition, value, metadata, created_at, expires_at, owner, access_level, team_id, swarm_id)
|
|
438
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
|
|
439
|
-
key,
|
|
440
|
-
partition,
|
|
441
|
-
JSON.stringify(value),
|
|
442
|
-
metadata,
|
|
443
|
-
createdAt,
|
|
444
|
-
expiresAt,
|
|
445
|
-
owner,
|
|
446
|
-
accessLevel,
|
|
447
|
-
options.teamId || null,
|
|
448
|
-
options.swarmId || null
|
|
449
|
-
]);
|
|
450
|
-
// Track modification for QUIC sync
|
|
451
|
-
const entryKey = `${partition}:${key}`;
|
|
452
|
-
this.lastModifiedTimestamps.set(entryKey, createdAt);
|
|
453
494
|
}
|
|
454
495
|
/**
|
|
455
496
|
* Alias for store() method to maintain compatibility with MemoryStore interface
|
|
@@ -473,6 +514,16 @@ class SwarmMemoryManager {
|
|
|
473
514
|
}
|
|
474
515
|
return this.retrieve(key, options);
|
|
475
516
|
}
|
|
517
|
+
/**
|
|
518
|
+
* Retrieve a value from memory with OpenTelemetry instrumentation
|
|
519
|
+
*
|
|
520
|
+
* Automatically instruments the memory retrieve operation with distributed tracing.
|
|
521
|
+
* Records namespace, key, whether the value was found, value size, and performance metrics.
|
|
522
|
+
*
|
|
523
|
+
* @param key - Memory key
|
|
524
|
+
* @param options - Retrieve options including partition, agentId for access control
|
|
525
|
+
* @returns Retrieved value or null if not found
|
|
526
|
+
*/
|
|
476
527
|
async retrieve(key, options = {}) {
|
|
477
528
|
// Auto-initialize if not initialized
|
|
478
529
|
if (!this.initialized) {
|
|
@@ -482,55 +533,35 @@ class SwarmMemoryManager {
|
|
|
482
533
|
throw new Error('Memory manager not initialized. Call initialize() first.');
|
|
483
534
|
}
|
|
484
535
|
const partition = options.partition || 'default';
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
resourceOwner: row.owner,
|
|
502
|
-
accessLevel: row.access_level,
|
|
503
|
-
permission: AccessControl_1.Permission.READ,
|
|
504
|
-
teamId: options.teamId,
|
|
505
|
-
resourceTeamId: row.team_id,
|
|
506
|
-
swarmId: options.swarmId,
|
|
507
|
-
resourceSwarmId: row.swarm_id,
|
|
508
|
-
isSystemAgent: options.isSystemAgent
|
|
509
|
-
});
|
|
510
|
-
if (!permCheck.allowed) {
|
|
511
|
-
throw new AccessControl_1.AccessControlError(`Read denied: ${permCheck.reason}`);
|
|
536
|
+
const agentId = options.agentId || 'system';
|
|
537
|
+
// Create instrumentation span
|
|
538
|
+
const { span, context: spanContext } = memory_1.memorySpanManager.startRetrieveSpan({
|
|
539
|
+
agentId: { id: agentId, type: types_1.QEAgentType.FLEET_COMMANDER, created: new Date() },
|
|
540
|
+
namespace: partition,
|
|
541
|
+
key,
|
|
542
|
+
});
|
|
543
|
+
const startTime = Date.now();
|
|
544
|
+
try {
|
|
545
|
+
const now = Date.now();
|
|
546
|
+
let query = `SELECT value, owner, access_level, team_id, swarm_id
|
|
547
|
+
FROM memory_entries WHERE key = ? AND partition = ?`;
|
|
548
|
+
const params = [key, partition];
|
|
549
|
+
if (!options.includeExpired) {
|
|
550
|
+
query += ` AND (expires_at IS NULL OR expires_at > ?)`;
|
|
551
|
+
params.push(now);
|
|
512
552
|
}
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
const params = [partition, pattern];
|
|
526
|
-
if (!options.includeExpired) {
|
|
527
|
-
query += ` AND (expires_at IS NULL OR expires_at > ?)`;
|
|
528
|
-
params.push(now);
|
|
529
|
-
}
|
|
530
|
-
const rows = await this.queryAll(query, params);
|
|
531
|
-
// Filter by access control if agentId provided
|
|
532
|
-
const filteredRows = options.agentId
|
|
533
|
-
? rows.filter((row) => {
|
|
553
|
+
const row = await this.queryOne(query, params);
|
|
554
|
+
if (!row) {
|
|
555
|
+
// Complete span - not found
|
|
556
|
+
const durationMs = Date.now() - startTime;
|
|
557
|
+
memory_1.memorySpanManager.completeRetrieveSpan(span, {
|
|
558
|
+
found: false,
|
|
559
|
+
durationMs,
|
|
560
|
+
});
|
|
561
|
+
return null;
|
|
562
|
+
}
|
|
563
|
+
// Check read permission if agentId provided
|
|
564
|
+
if (options.agentId) {
|
|
534
565
|
const permCheck = this.accessControl.checkPermission({
|
|
535
566
|
agentId: options.agentId,
|
|
536
567
|
resourceOwner: row.owner,
|
|
@@ -542,50 +573,178 @@ class SwarmMemoryManager {
|
|
|
542
573
|
resourceSwarmId: row.swarm_id,
|
|
543
574
|
isSystemAgent: options.isSystemAgent
|
|
544
575
|
});
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
576
|
+
if (!permCheck.allowed) {
|
|
577
|
+
throw new AccessControl_1.AccessControlError(`Read denied: ${permCheck.reason}`);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
const valueSize = row.value.length;
|
|
581
|
+
const parsedValue = JSON.parse(row.value);
|
|
582
|
+
// Complete span successfully
|
|
583
|
+
const durationMs = Date.now() - startTime;
|
|
584
|
+
memory_1.memorySpanManager.completeRetrieveSpan(span, {
|
|
585
|
+
found: true,
|
|
586
|
+
valueSize,
|
|
587
|
+
durationMs,
|
|
588
|
+
});
|
|
589
|
+
return parsedValue;
|
|
590
|
+
}
|
|
591
|
+
catch (error) {
|
|
592
|
+
// Complete span with error
|
|
593
|
+
const durationMs = Date.now() - startTime;
|
|
594
|
+
memory_1.memorySpanManager.completeRetrieveSpan(span, {
|
|
595
|
+
found: false,
|
|
596
|
+
durationMs,
|
|
597
|
+
error: error,
|
|
598
|
+
});
|
|
599
|
+
throw error;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Query/search memory entries by pattern with OpenTelemetry instrumentation
|
|
604
|
+
*
|
|
605
|
+
* Automatically instruments the memory search operation with distributed tracing.
|
|
606
|
+
* Records namespace, search pattern, result count, and performance metrics.
|
|
607
|
+
*
|
|
608
|
+
* @param pattern - SQL LIKE pattern for key matching
|
|
609
|
+
* @param options - Retrieve options including partition, agentId for access control
|
|
610
|
+
* @returns Array of matching memory entries
|
|
611
|
+
*/
|
|
612
|
+
async query(pattern, options = {}) {
|
|
613
|
+
if (!this.db) {
|
|
614
|
+
throw new Error('Memory manager not initialized');
|
|
615
|
+
}
|
|
616
|
+
const partition = options.partition || 'default';
|
|
617
|
+
const agentId = options.agentId || 'system';
|
|
618
|
+
// Create instrumentation span
|
|
619
|
+
const { span, context: spanContext } = memory_1.memorySpanManager.startSearchSpan({
|
|
620
|
+
agentId: { id: agentId, type: types_1.QEAgentType.FLEET_COMMANDER, created: new Date() },
|
|
621
|
+
namespace: partition,
|
|
622
|
+
pattern,
|
|
623
|
+
});
|
|
624
|
+
const startTime = Date.now();
|
|
625
|
+
try {
|
|
626
|
+
const now = Date.now();
|
|
627
|
+
let query = `SELECT key, value, partition, created_at, expires_at, owner, access_level, team_id, swarm_id
|
|
628
|
+
FROM memory_entries
|
|
629
|
+
WHERE partition = ? AND key LIKE ?`;
|
|
630
|
+
const params = [partition, pattern];
|
|
631
|
+
if (!options.includeExpired) {
|
|
632
|
+
query += ` AND (expires_at IS NULL OR expires_at > ?)`;
|
|
633
|
+
params.push(now);
|
|
634
|
+
}
|
|
635
|
+
const rows = await this.queryAll(query, params);
|
|
636
|
+
// Filter by access control if agentId provided
|
|
637
|
+
const filteredRows = options.agentId
|
|
638
|
+
? rows.filter((row) => {
|
|
639
|
+
const permCheck = this.accessControl.checkPermission({
|
|
640
|
+
agentId: options.agentId,
|
|
641
|
+
resourceOwner: row.owner,
|
|
642
|
+
accessLevel: row.access_level,
|
|
643
|
+
permission: AccessControl_1.Permission.READ,
|
|
644
|
+
teamId: options.teamId,
|
|
645
|
+
resourceTeamId: row.team_id,
|
|
646
|
+
swarmId: options.swarmId,
|
|
647
|
+
resourceSwarmId: row.swarm_id,
|
|
648
|
+
isSystemAgent: options.isSystemAgent
|
|
649
|
+
});
|
|
650
|
+
return permCheck.allowed;
|
|
651
|
+
})
|
|
652
|
+
: rows;
|
|
653
|
+
const results = filteredRows.map((row) => ({
|
|
654
|
+
key: row.key,
|
|
655
|
+
value: JSON.parse(row.value),
|
|
656
|
+
partition: row.partition,
|
|
657
|
+
createdAt: row.created_at,
|
|
658
|
+
expiresAt: row.expires_at,
|
|
659
|
+
owner: row.owner,
|
|
660
|
+
accessLevel: row.access_level,
|
|
661
|
+
teamId: row.team_id,
|
|
662
|
+
swarmId: row.swarm_id
|
|
663
|
+
}));
|
|
664
|
+
// Complete span successfully
|
|
665
|
+
const durationMs = Date.now() - startTime;
|
|
666
|
+
memory_1.memorySpanManager.completeSearchSpan(span, {
|
|
667
|
+
resultCount: results.length,
|
|
668
|
+
durationMs,
|
|
669
|
+
});
|
|
670
|
+
return results;
|
|
671
|
+
}
|
|
672
|
+
catch (error) {
|
|
673
|
+
// Complete span with error
|
|
674
|
+
const durationMs = Date.now() - startTime;
|
|
675
|
+
memory_1.memorySpanManager.completeSearchSpan(span, {
|
|
676
|
+
resultCount: 0,
|
|
677
|
+
durationMs,
|
|
678
|
+
error: error,
|
|
679
|
+
});
|
|
680
|
+
throw error;
|
|
681
|
+
}
|
|
559
682
|
}
|
|
683
|
+
/**
|
|
684
|
+
* Delete a key from memory with OpenTelemetry instrumentation
|
|
685
|
+
*
|
|
686
|
+
* Automatically instruments the memory delete operation with distributed tracing.
|
|
687
|
+
* Records namespace, key, and operation performance metrics.
|
|
688
|
+
*
|
|
689
|
+
* @param key - Memory key to delete
|
|
690
|
+
* @param partition - Memory partition (namespace)
|
|
691
|
+
* @param options - Delete options including agentId for access control
|
|
692
|
+
*/
|
|
560
693
|
async delete(key, partition = 'default', options = {}) {
|
|
561
694
|
if (!this.db) {
|
|
562
695
|
throw new Error('Memory manager not initialized');
|
|
563
696
|
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
697
|
+
const agentId = options.agentId || 'system';
|
|
698
|
+
// Create instrumentation span
|
|
699
|
+
const { span, context: spanContext } = memory_1.memorySpanManager.startDeleteSpan({
|
|
700
|
+
agentId: { id: agentId, type: types_1.QEAgentType.FLEET_COMMANDER, created: new Date() },
|
|
701
|
+
namespace: partition,
|
|
702
|
+
key,
|
|
703
|
+
});
|
|
704
|
+
const startTime = Date.now();
|
|
705
|
+
try {
|
|
706
|
+
// Check delete permission if agentId provided
|
|
707
|
+
if (options.agentId) {
|
|
708
|
+
const row = await this.queryOne(`SELECT owner, access_level, team_id, swarm_id FROM memory_entries WHERE key = ? AND partition = ?`, [key, partition]);
|
|
709
|
+
if (row) {
|
|
710
|
+
const permCheck = this.accessControl.checkPermission({
|
|
711
|
+
agentId: options.agentId,
|
|
712
|
+
resourceOwner: row.owner,
|
|
713
|
+
accessLevel: row.access_level,
|
|
714
|
+
permission: AccessControl_1.Permission.DELETE,
|
|
715
|
+
teamId: options.teamId,
|
|
716
|
+
resourceTeamId: row.team_id,
|
|
717
|
+
swarmId: options.swarmId,
|
|
718
|
+
resourceSwarmId: row.swarm_id,
|
|
719
|
+
isSystemAgent: options.isSystemAgent
|
|
720
|
+
});
|
|
721
|
+
if (!permCheck.allowed) {
|
|
722
|
+
throw new AccessControl_1.AccessControlError(`Delete denied: ${permCheck.reason}`);
|
|
723
|
+
}
|
|
581
724
|
}
|
|
582
725
|
}
|
|
726
|
+
await this.run(`DELETE FROM memory_entries WHERE key = ? AND partition = ?`, [key, partition]);
|
|
727
|
+
// Clean up ACL if exists
|
|
728
|
+
const resourceId = `${partition}:${key}`;
|
|
729
|
+
await this.run(`DELETE FROM memory_acl WHERE resource_id = ?`, [resourceId]);
|
|
730
|
+
this.aclCache.delete(resourceId);
|
|
731
|
+
// Complete span successfully
|
|
732
|
+
const durationMs = Date.now() - startTime;
|
|
733
|
+
memory_1.memorySpanManager.completeDeleteSpan(span, {
|
|
734
|
+
success: true,
|
|
735
|
+
durationMs,
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
catch (error) {
|
|
739
|
+
// Complete span with error
|
|
740
|
+
const durationMs = Date.now() - startTime;
|
|
741
|
+
memory_1.memorySpanManager.completeDeleteSpan(span, {
|
|
742
|
+
success: false,
|
|
743
|
+
durationMs,
|
|
744
|
+
error: error,
|
|
745
|
+
});
|
|
746
|
+
throw error;
|
|
583
747
|
}
|
|
584
|
-
await this.run(`DELETE FROM memory_entries WHERE key = ? AND partition = ?`, [key, partition]);
|
|
585
|
-
// Clean up ACL if exists
|
|
586
|
-
const resourceId = `${partition}:${key}`;
|
|
587
|
-
await this.run(`DELETE FROM memory_acl WHERE resource_id = ?`, [resourceId]);
|
|
588
|
-
this.aclCache.delete(resourceId);
|
|
589
748
|
}
|
|
590
749
|
async clear(partition = 'default') {
|
|
591
750
|
if (!this.db) {
|