Skip to content

Commit ab0fdfa

Browse files
committed
feat(store): add ExtendedStore interface with health check, metrics and distributed lock
## Blocking fixes - Add ensureInitialized() check to all PostgresStore public methods - Replace connectionConfig: any with typed PostgresConfig interface - Add connection pool default config and error listener ## New features (ExtendedStore interface) - healthCheck(): database and filesystem health status - checkConsistency(): verify data consistency between DB and filesystem - getMetrics(): operation counts, latency stats, storage stats - acquireAgentLock(): distributed lock (PostgreSQL advisory lock / memory lock) - batchFork(): optimized bulk agent forking ## Other changes - Add createStore() and createExtendedStore() factory functions - Fix agentId format in docs and tests (agt: → agt-) - Add comprehensive tests for new features
1 parent 8c1e258 commit ab0fdfa

8 files changed

Lines changed: 1246 additions & 69 deletions

File tree

docs/database.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ interface MessageQueryFilter {
417417
}
418418

419419
const messages = await store.queryMessages({
420-
agentId: 'agt:abc123',
420+
agentId: 'agt-abc123',
421421
role: 'assistant',
422422
contentType: 'tool_use',
423423
limit: 50
@@ -490,7 +490,7 @@ interface StatsQueryFilter {
490490
agentId: string; // 必填:Agent ID
491491
}
492492

493-
const stats = await store.aggregateStats({ agentId: 'agt:abc123' });
493+
const stats = await store.aggregateStats({ agentId: 'agt-abc123' });
494494

495495
console.log({
496496
totalMessages: stats.totalMessages, // 消息总数
@@ -908,7 +908,7 @@ SELECT pg_reload_conf();
908908

909909
-- 2. 查看执行计划
910910
EXPLAIN ANALYZE
911-
SELECT * FROM messages WHERE agent_id = 'agt:abc123' ORDER BY seq;
911+
SELECT * FROM messages WHERE agent_id = 'agt-abc123' ORDER BY seq;
912912

913913
-- 3. 检查索引使用
914914
SELECT schemaname, tablename, indexname, idx_scan, idx_tup_read, idx_tup_fetch
@@ -960,7 +960,7 @@ A: 可以,但目前需要手动迁移。未来版本会提供迁移工具。
960960
```typescript
961961
// 1. 读取 JSONStore 数据
962962
const jsonStore = new JSONStore('./old-store');
963-
const agentIds = await jsonStore.list('agt:');
963+
const agentIds = await jsonStore.list('agt-');
964964

965965
// 2. 逐个迁移到数据库
966966
const dbStore = new SqliteStore('./agents.db', './new-store');

0 commit comments

Comments
 (0)