agent-working-memory 0.5.4 → 0.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/README.md +87 -46
- package/dist/api/routes.d.ts.map +1 -1
- package/dist/api/routes.js +21 -5
- package/dist/api/routes.js.map +1 -1
- package/dist/cli.js +67 -67
- package/dist/coordination/index.d.ts +11 -0
- package/dist/coordination/index.d.ts.map +1 -0
- package/dist/coordination/index.js +39 -0
- package/dist/coordination/index.js.map +1 -0
- package/dist/coordination/mcp-tools.d.ts +8 -0
- package/dist/coordination/mcp-tools.d.ts.map +1 -0
- package/dist/coordination/mcp-tools.js +216 -0
- package/dist/coordination/mcp-tools.js.map +1 -0
- package/dist/coordination/routes.d.ts +9 -0
- package/dist/coordination/routes.d.ts.map +1 -0
- package/dist/coordination/routes.js +434 -0
- package/dist/coordination/routes.js.map +1 -0
- package/dist/coordination/schema.d.ts +12 -0
- package/dist/coordination/schema.d.ts.map +1 -0
- package/dist/coordination/schema.js +91 -0
- package/dist/coordination/schema.js.map +1 -0
- package/dist/coordination/schemas.d.ts +208 -0
- package/dist/coordination/schemas.d.ts.map +1 -0
- package/dist/coordination/schemas.js +109 -0
- package/dist/coordination/schemas.js.map +1 -0
- package/dist/coordination/stale.d.ts +25 -0
- package/dist/coordination/stale.d.ts.map +1 -0
- package/dist/coordination/stale.js +53 -0
- package/dist/coordination/stale.js.map +1 -0
- package/dist/index.js +21 -3
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +90 -79
- package/dist/mcp.js.map +1 -1
- package/dist/storage/sqlite.d.ts +3 -0
- package/dist/storage/sqlite.d.ts.map +1 -1
- package/dist/storage/sqlite.js +285 -281
- package/dist/storage/sqlite.js.map +1 -1
- package/package.json +55 -55
- package/src/api/index.ts +3 -3
- package/src/api/routes.ts +551 -536
- package/src/cli.ts +397 -397
- package/src/coordination/index.ts +47 -0
- package/src/coordination/mcp-tools.ts +313 -0
- package/src/coordination/routes.ts +656 -0
- package/src/coordination/schema.ts +94 -0
- package/src/coordination/schemas.ts +136 -0
- package/src/coordination/stale.ts +89 -0
- package/src/core/decay.ts +63 -63
- package/src/core/embeddings.ts +88 -88
- package/src/core/hebbian.ts +93 -93
- package/src/core/index.ts +5 -5
- package/src/core/logger.ts +36 -36
- package/src/core/query-expander.ts +66 -66
- package/src/core/reranker.ts +101 -101
- package/src/engine/activation.ts +656 -656
- package/src/engine/connections.ts +103 -103
- package/src/engine/consolidation-scheduler.ts +125 -125
- package/src/engine/eval.ts +102 -102
- package/src/engine/eviction.ts +101 -101
- package/src/engine/index.ts +8 -8
- package/src/engine/retraction.ts +100 -100
- package/src/engine/staging.ts +74 -74
- package/src/index.ts +137 -121
- package/src/mcp.ts +1024 -1013
- package/src/storage/index.ts +3 -3
- package/src/storage/sqlite.ts +968 -963
- package/src/types/agent.ts +67 -67
- package/src/types/checkpoint.ts +46 -46
- package/src/types/engram.ts +217 -217
- package/src/types/eval.ts +100 -100
- package/src/types/index.ts +6 -6
package/src/types/eval.ts
CHANGED
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
// Copyright 2026 Robert Winter / Complete Ideas
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
/**
|
|
4
|
-
* Evaluation types — measuring whether memory actually helps.
|
|
5
|
-
*
|
|
6
|
-
* Four measurement dimensions:
|
|
7
|
-
* 1. Retrieval quality (precision, recall, latency)
|
|
8
|
-
* 2. Connection quality (edge utility, stability)
|
|
9
|
-
* 3. Staging accuracy (promotion precision, discard regret)
|
|
10
|
-
* 4. Task impact (with/without memory comparison)
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Single activation event record — logged for offline analysis.
|
|
15
|
-
*/
|
|
16
|
-
export interface ActivationEvent {
|
|
17
|
-
id: string;
|
|
18
|
-
agentId: string;
|
|
19
|
-
timestamp: Date;
|
|
20
|
-
context: string;
|
|
21
|
-
resultsReturned: number;
|
|
22
|
-
topScore: number;
|
|
23
|
-
latencyMs: number;
|
|
24
|
-
engramIds: string[];
|
|
25
|
-
feedback?: RetrievalFeedbackEvent[];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface RetrievalFeedbackEvent {
|
|
29
|
-
engramId: string;
|
|
30
|
-
useful: boolean;
|
|
31
|
-
timestamp: Date;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Staging lifecycle event — tracks promote/discard decisions.
|
|
36
|
-
*/
|
|
37
|
-
export interface StagingEvent {
|
|
38
|
-
engramId: string;
|
|
39
|
-
agentId: string;
|
|
40
|
-
action: 'promoted' | 'discarded' | 'expired';
|
|
41
|
-
resonanceScore: number | null;
|
|
42
|
-
timestamp: Date;
|
|
43
|
-
ageMs: number; // How long it lived in staging
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Aggregate metrics snapshot — computed periodically.
|
|
48
|
-
*/
|
|
49
|
-
export interface EvalMetrics {
|
|
50
|
-
agentId: string;
|
|
51
|
-
timestamp: Date;
|
|
52
|
-
window: string; // e.g., "24h", "7d"
|
|
53
|
-
|
|
54
|
-
// Retrieval quality
|
|
55
|
-
activationCount: number;
|
|
56
|
-
avgPrecisionAtK: number; // Of returned results, % judged useful
|
|
57
|
-
avgLatencyMs: number;
|
|
58
|
-
p95LatencyMs: number;
|
|
59
|
-
|
|
60
|
-
// Connection quality
|
|
61
|
-
totalEdges: number;
|
|
62
|
-
edgesUsedInActivation: number;
|
|
63
|
-
edgeUtilityRate: number; // % of edges that contributed to retrieval
|
|
64
|
-
avgEdgeSurvivalDays: number;
|
|
65
|
-
|
|
66
|
-
// Staging accuracy
|
|
67
|
-
totalStaged: number;
|
|
68
|
-
promotedCount: number;
|
|
69
|
-
discardedCount: number;
|
|
70
|
-
promotionPrecision: number; // % of promoted items later used
|
|
71
|
-
discardRegret: number; // % of discarded items agent re-introduced
|
|
72
|
-
|
|
73
|
-
// Memory health
|
|
74
|
-
activeEngramCount: number;
|
|
75
|
-
stagingEngramCount: number;
|
|
76
|
-
retractedCount: number;
|
|
77
|
-
consolidatedCount: number;
|
|
78
|
-
avgConfidence: number;
|
|
79
|
-
|
|
80
|
-
// Contamination tracking
|
|
81
|
-
staleUsageCount: number; // Activations using outdated engrams
|
|
82
|
-
retractionRate: number; // Rate of memories being invalidated
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Task trial — for with/without memory comparison.
|
|
87
|
-
*/
|
|
88
|
-
export interface TaskTrial {
|
|
89
|
-
id: string;
|
|
90
|
-
agentId: string;
|
|
91
|
-
taskDescription: string;
|
|
92
|
-
memoryEnabled: boolean;
|
|
93
|
-
startedAt: Date;
|
|
94
|
-
completedAt: Date | null;
|
|
95
|
-
success: boolean | null;
|
|
96
|
-
stepsToCompletion: number;
|
|
97
|
-
errorsEncountered: number;
|
|
98
|
-
memoriesActivated: number;
|
|
99
|
-
userCorrections: number;
|
|
100
|
-
}
|
|
1
|
+
// Copyright 2026 Robert Winter / Complete Ideas
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
/**
|
|
4
|
+
* Evaluation types — measuring whether memory actually helps.
|
|
5
|
+
*
|
|
6
|
+
* Four measurement dimensions:
|
|
7
|
+
* 1. Retrieval quality (precision, recall, latency)
|
|
8
|
+
* 2. Connection quality (edge utility, stability)
|
|
9
|
+
* 3. Staging accuracy (promotion precision, discard regret)
|
|
10
|
+
* 4. Task impact (with/without memory comparison)
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Single activation event record — logged for offline analysis.
|
|
15
|
+
*/
|
|
16
|
+
export interface ActivationEvent {
|
|
17
|
+
id: string;
|
|
18
|
+
agentId: string;
|
|
19
|
+
timestamp: Date;
|
|
20
|
+
context: string;
|
|
21
|
+
resultsReturned: number;
|
|
22
|
+
topScore: number;
|
|
23
|
+
latencyMs: number;
|
|
24
|
+
engramIds: string[];
|
|
25
|
+
feedback?: RetrievalFeedbackEvent[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface RetrievalFeedbackEvent {
|
|
29
|
+
engramId: string;
|
|
30
|
+
useful: boolean;
|
|
31
|
+
timestamp: Date;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Staging lifecycle event — tracks promote/discard decisions.
|
|
36
|
+
*/
|
|
37
|
+
export interface StagingEvent {
|
|
38
|
+
engramId: string;
|
|
39
|
+
agentId: string;
|
|
40
|
+
action: 'promoted' | 'discarded' | 'expired';
|
|
41
|
+
resonanceScore: number | null;
|
|
42
|
+
timestamp: Date;
|
|
43
|
+
ageMs: number; // How long it lived in staging
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Aggregate metrics snapshot — computed periodically.
|
|
48
|
+
*/
|
|
49
|
+
export interface EvalMetrics {
|
|
50
|
+
agentId: string;
|
|
51
|
+
timestamp: Date;
|
|
52
|
+
window: string; // e.g., "24h", "7d"
|
|
53
|
+
|
|
54
|
+
// Retrieval quality
|
|
55
|
+
activationCount: number;
|
|
56
|
+
avgPrecisionAtK: number; // Of returned results, % judged useful
|
|
57
|
+
avgLatencyMs: number;
|
|
58
|
+
p95LatencyMs: number;
|
|
59
|
+
|
|
60
|
+
// Connection quality
|
|
61
|
+
totalEdges: number;
|
|
62
|
+
edgesUsedInActivation: number;
|
|
63
|
+
edgeUtilityRate: number; // % of edges that contributed to retrieval
|
|
64
|
+
avgEdgeSurvivalDays: number;
|
|
65
|
+
|
|
66
|
+
// Staging accuracy
|
|
67
|
+
totalStaged: number;
|
|
68
|
+
promotedCount: number;
|
|
69
|
+
discardedCount: number;
|
|
70
|
+
promotionPrecision: number; // % of promoted items later used
|
|
71
|
+
discardRegret: number; // % of discarded items agent re-introduced
|
|
72
|
+
|
|
73
|
+
// Memory health
|
|
74
|
+
activeEngramCount: number;
|
|
75
|
+
stagingEngramCount: number;
|
|
76
|
+
retractedCount: number;
|
|
77
|
+
consolidatedCount: number;
|
|
78
|
+
avgConfidence: number;
|
|
79
|
+
|
|
80
|
+
// Contamination tracking
|
|
81
|
+
staleUsageCount: number; // Activations using outdated engrams
|
|
82
|
+
retractionRate: number; // Rate of memories being invalidated
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Task trial — for with/without memory comparison.
|
|
87
|
+
*/
|
|
88
|
+
export interface TaskTrial {
|
|
89
|
+
id: string;
|
|
90
|
+
agentId: string;
|
|
91
|
+
taskDescription: string;
|
|
92
|
+
memoryEnabled: boolean;
|
|
93
|
+
startedAt: Date;
|
|
94
|
+
completedAt: Date | null;
|
|
95
|
+
success: boolean | null;
|
|
96
|
+
stepsToCompletion: number;
|
|
97
|
+
errorsEncountered: number;
|
|
98
|
+
memoriesActivated: number;
|
|
99
|
+
userCorrections: number;
|
|
100
|
+
}
|
package/src/types/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// Copyright 2026 Robert Winter / Complete Ideas
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
export * from './engram.js';
|
|
4
|
-
export * from './agent.js';
|
|
5
|
-
export * from './eval.js';
|
|
6
|
-
export * from './checkpoint.js';
|
|
1
|
+
// Copyright 2026 Robert Winter / Complete Ideas
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
export * from './engram.js';
|
|
4
|
+
export * from './agent.js';
|
|
5
|
+
export * from './eval.js';
|
|
6
|
+
export * from './checkpoint.js';
|