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.
Files changed (71) hide show
  1. package/README.md +87 -46
  2. package/dist/api/routes.d.ts.map +1 -1
  3. package/dist/api/routes.js +21 -5
  4. package/dist/api/routes.js.map +1 -1
  5. package/dist/cli.js +67 -67
  6. package/dist/coordination/index.d.ts +11 -0
  7. package/dist/coordination/index.d.ts.map +1 -0
  8. package/dist/coordination/index.js +39 -0
  9. package/dist/coordination/index.js.map +1 -0
  10. package/dist/coordination/mcp-tools.d.ts +8 -0
  11. package/dist/coordination/mcp-tools.d.ts.map +1 -0
  12. package/dist/coordination/mcp-tools.js +216 -0
  13. package/dist/coordination/mcp-tools.js.map +1 -0
  14. package/dist/coordination/routes.d.ts +9 -0
  15. package/dist/coordination/routes.d.ts.map +1 -0
  16. package/dist/coordination/routes.js +434 -0
  17. package/dist/coordination/routes.js.map +1 -0
  18. package/dist/coordination/schema.d.ts +12 -0
  19. package/dist/coordination/schema.d.ts.map +1 -0
  20. package/dist/coordination/schema.js +91 -0
  21. package/dist/coordination/schema.js.map +1 -0
  22. package/dist/coordination/schemas.d.ts +208 -0
  23. package/dist/coordination/schemas.d.ts.map +1 -0
  24. package/dist/coordination/schemas.js +109 -0
  25. package/dist/coordination/schemas.js.map +1 -0
  26. package/dist/coordination/stale.d.ts +25 -0
  27. package/dist/coordination/stale.d.ts.map +1 -0
  28. package/dist/coordination/stale.js +53 -0
  29. package/dist/coordination/stale.js.map +1 -0
  30. package/dist/index.js +21 -3
  31. package/dist/index.js.map +1 -1
  32. package/dist/mcp.js +90 -79
  33. package/dist/mcp.js.map +1 -1
  34. package/dist/storage/sqlite.d.ts +3 -0
  35. package/dist/storage/sqlite.d.ts.map +1 -1
  36. package/dist/storage/sqlite.js +285 -281
  37. package/dist/storage/sqlite.js.map +1 -1
  38. package/package.json +55 -55
  39. package/src/api/index.ts +3 -3
  40. package/src/api/routes.ts +551 -536
  41. package/src/cli.ts +397 -397
  42. package/src/coordination/index.ts +47 -0
  43. package/src/coordination/mcp-tools.ts +313 -0
  44. package/src/coordination/routes.ts +656 -0
  45. package/src/coordination/schema.ts +94 -0
  46. package/src/coordination/schemas.ts +136 -0
  47. package/src/coordination/stale.ts +89 -0
  48. package/src/core/decay.ts +63 -63
  49. package/src/core/embeddings.ts +88 -88
  50. package/src/core/hebbian.ts +93 -93
  51. package/src/core/index.ts +5 -5
  52. package/src/core/logger.ts +36 -36
  53. package/src/core/query-expander.ts +66 -66
  54. package/src/core/reranker.ts +101 -101
  55. package/src/engine/activation.ts +656 -656
  56. package/src/engine/connections.ts +103 -103
  57. package/src/engine/consolidation-scheduler.ts +125 -125
  58. package/src/engine/eval.ts +102 -102
  59. package/src/engine/eviction.ts +101 -101
  60. package/src/engine/index.ts +8 -8
  61. package/src/engine/retraction.ts +100 -100
  62. package/src/engine/staging.ts +74 -74
  63. package/src/index.ts +137 -121
  64. package/src/mcp.ts +1024 -1013
  65. package/src/storage/index.ts +3 -3
  66. package/src/storage/sqlite.ts +968 -963
  67. package/src/types/agent.ts +67 -67
  68. package/src/types/checkpoint.ts +46 -46
  69. package/src/types/engram.ts +217 -217
  70. package/src/types/eval.ts +100 -100
  71. 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
+ }
@@ -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';