alma-memory 0.5.0__py3-none-any.whl → 0.7.0__py3-none-any.whl
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.
- alma/__init__.py +296 -194
- alma/compression/__init__.py +33 -0
- alma/compression/pipeline.py +980 -0
- alma/confidence/__init__.py +47 -47
- alma/confidence/engine.py +540 -540
- alma/confidence/types.py +351 -351
- alma/config/loader.py +157 -157
- alma/consolidation/__init__.py +23 -23
- alma/consolidation/engine.py +678 -678
- alma/consolidation/prompts.py +84 -84
- alma/core.py +1189 -322
- alma/domains/__init__.py +30 -30
- alma/domains/factory.py +359 -359
- alma/domains/schemas.py +448 -448
- alma/domains/types.py +272 -272
- alma/events/__init__.py +75 -75
- alma/events/emitter.py +285 -284
- alma/events/storage_mixin.py +246 -246
- alma/events/types.py +126 -126
- alma/events/webhook.py +425 -425
- alma/exceptions.py +49 -49
- alma/extraction/__init__.py +31 -31
- alma/extraction/auto_learner.py +265 -264
- alma/extraction/extractor.py +420 -420
- alma/graph/__init__.py +106 -81
- alma/graph/backends/__init__.py +32 -18
- alma/graph/backends/kuzu.py +624 -0
- alma/graph/backends/memgraph.py +432 -0
- alma/graph/backends/memory.py +236 -236
- alma/graph/backends/neo4j.py +417 -417
- alma/graph/base.py +159 -159
- alma/graph/extraction.py +198 -198
- alma/graph/store.py +860 -860
- alma/harness/__init__.py +35 -35
- alma/harness/base.py +386 -386
- alma/harness/domains.py +705 -705
- alma/initializer/__init__.py +37 -37
- alma/initializer/initializer.py +418 -418
- alma/initializer/types.py +250 -250
- alma/integration/__init__.py +62 -62
- alma/integration/claude_agents.py +444 -432
- alma/integration/helena.py +423 -423
- alma/integration/victor.py +471 -471
- alma/learning/__init__.py +101 -86
- alma/learning/decay.py +878 -0
- alma/learning/forgetting.py +1446 -1446
- alma/learning/heuristic_extractor.py +390 -390
- alma/learning/protocols.py +374 -374
- alma/learning/validation.py +346 -346
- alma/mcp/__init__.py +123 -45
- alma/mcp/__main__.py +156 -156
- alma/mcp/resources.py +122 -122
- alma/mcp/server.py +955 -591
- alma/mcp/tools.py +3254 -511
- alma/observability/__init__.py +91 -0
- alma/observability/config.py +302 -0
- alma/observability/guidelines.py +170 -0
- alma/observability/logging.py +424 -0
- alma/observability/metrics.py +583 -0
- alma/observability/tracing.py +440 -0
- alma/progress/__init__.py +21 -21
- alma/progress/tracker.py +607 -607
- alma/progress/types.py +250 -250
- alma/retrieval/__init__.py +134 -53
- alma/retrieval/budget.py +525 -0
- alma/retrieval/cache.py +1304 -1061
- alma/retrieval/embeddings.py +202 -202
- alma/retrieval/engine.py +850 -366
- alma/retrieval/modes.py +365 -0
- alma/retrieval/progressive.py +560 -0
- alma/retrieval/scoring.py +344 -344
- alma/retrieval/trust_scoring.py +637 -0
- alma/retrieval/verification.py +797 -0
- alma/session/__init__.py +19 -19
- alma/session/manager.py +442 -399
- alma/session/types.py +288 -288
- alma/storage/__init__.py +101 -61
- alma/storage/archive.py +233 -0
- alma/storage/azure_cosmos.py +1259 -1048
- alma/storage/base.py +1083 -525
- alma/storage/chroma.py +1443 -1443
- alma/storage/constants.py +103 -0
- alma/storage/file_based.py +614 -619
- alma/storage/migrations/__init__.py +21 -0
- alma/storage/migrations/base.py +321 -0
- alma/storage/migrations/runner.py +323 -0
- alma/storage/migrations/version_stores.py +337 -0
- alma/storage/migrations/versions/__init__.py +11 -0
- alma/storage/migrations/versions/v1_0_0.py +373 -0
- alma/storage/migrations/versions/v1_1_0_workflow_context.py +551 -0
- alma/storage/pinecone.py +1080 -1080
- alma/storage/postgresql.py +1948 -1452
- alma/storage/qdrant.py +1306 -1306
- alma/storage/sqlite_local.py +3041 -1358
- alma/testing/__init__.py +46 -0
- alma/testing/factories.py +301 -0
- alma/testing/mocks.py +389 -0
- alma/types.py +292 -264
- alma/utils/__init__.py +19 -0
- alma/utils/tokenizer.py +521 -0
- alma/workflow/__init__.py +83 -0
- alma/workflow/artifacts.py +170 -0
- alma/workflow/checkpoint.py +311 -0
- alma/workflow/context.py +228 -0
- alma/workflow/outcomes.py +189 -0
- alma/workflow/reducers.py +393 -0
- {alma_memory-0.5.0.dist-info → alma_memory-0.7.0.dist-info}/METADATA +244 -72
- alma_memory-0.7.0.dist-info/RECORD +112 -0
- alma_memory-0.5.0.dist-info/RECORD +0 -76
- {alma_memory-0.5.0.dist-info → alma_memory-0.7.0.dist-info}/WHEEL +0 -0
- {alma_memory-0.5.0.dist-info → alma_memory-0.7.0.dist-info}/top_level.txt +0 -0
alma/mcp/resources.py
CHANGED
|
@@ -1,122 +1,122 @@
|
|
|
1
|
-
"""
|
|
2
|
-
ALMA MCP Resource Definitions.
|
|
3
|
-
|
|
4
|
-
Provides read-only resources that can be accessed via MCP protocol.
|
|
5
|
-
Resources represent configuration and metadata about the ALMA instance.
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
import logging
|
|
9
|
-
from typing import Any, Dict, List
|
|
10
|
-
|
|
11
|
-
from alma import ALMA
|
|
12
|
-
|
|
13
|
-
logger = logging.getLogger(__name__)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def get_config_resource(alma: ALMA) -> Dict[str, Any]:
|
|
17
|
-
"""
|
|
18
|
-
Get current ALMA configuration as a resource.
|
|
19
|
-
|
|
20
|
-
This exposes non-sensitive configuration information about
|
|
21
|
-
the ALMA instance.
|
|
22
|
-
|
|
23
|
-
Args:
|
|
24
|
-
alma: ALMA instance
|
|
25
|
-
|
|
26
|
-
Returns:
|
|
27
|
-
Dict with configuration details
|
|
28
|
-
"""
|
|
29
|
-
return {
|
|
30
|
-
"uri": "alma://config",
|
|
31
|
-
"name": "ALMA Configuration",
|
|
32
|
-
"description": "Current configuration of the ALMA memory system",
|
|
33
|
-
"mimeType": "application/json",
|
|
34
|
-
"content": {
|
|
35
|
-
"project_id": alma.project_id,
|
|
36
|
-
"storage_type": type(alma.storage).__name__,
|
|
37
|
-
"registered_agents": list(alma.scopes.keys()),
|
|
38
|
-
"scopes": {
|
|
39
|
-
name: {
|
|
40
|
-
"can_learn": scope.can_learn,
|
|
41
|
-
"cannot_learn": scope.cannot_learn,
|
|
42
|
-
"min_occurrences_for_heuristic": scope.min_occurrences_for_heuristic,
|
|
43
|
-
}
|
|
44
|
-
for name, scope in alma.scopes.items()
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
def get_agents_resource(alma: ALMA) -> Dict[str, Any]:
|
|
51
|
-
"""
|
|
52
|
-
Get registered agents and their scopes as a resource.
|
|
53
|
-
|
|
54
|
-
This provides detailed information about each registered agent
|
|
55
|
-
and their learning permissions.
|
|
56
|
-
|
|
57
|
-
Args:
|
|
58
|
-
alma: ALMA instance
|
|
59
|
-
|
|
60
|
-
Returns:
|
|
61
|
-
Dict with agent details
|
|
62
|
-
"""
|
|
63
|
-
agents = []
|
|
64
|
-
|
|
65
|
-
for name, scope in alma.scopes.items():
|
|
66
|
-
# Get stats for this agent
|
|
67
|
-
try:
|
|
68
|
-
stats = alma.get_stats(agent=name)
|
|
69
|
-
except Exception:
|
|
70
|
-
stats = {}
|
|
71
|
-
|
|
72
|
-
agents.append(
|
|
73
|
-
{
|
|
74
|
-
"name": name,
|
|
75
|
-
"scope": {
|
|
76
|
-
"can_learn": scope.can_learn,
|
|
77
|
-
"cannot_learn": scope.cannot_learn,
|
|
78
|
-
"min_occurrences_for_heuristic": scope.min_occurrences_for_heuristic,
|
|
79
|
-
},
|
|
80
|
-
"stats": {
|
|
81
|
-
"heuristics_count": stats.get("heuristics_count", 0),
|
|
82
|
-
"outcomes_count": stats.get("outcomes_count", 0),
|
|
83
|
-
"domain_knowledge_count": stats.get("domain_knowledge_count", 0),
|
|
84
|
-
"anti_patterns_count": stats.get("anti_patterns_count", 0),
|
|
85
|
-
},
|
|
86
|
-
}
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
return {
|
|
90
|
-
"uri": "alma://agents",
|
|
91
|
-
"name": "ALMA Registered Agents",
|
|
92
|
-
"description": "All registered agents and their memory scopes",
|
|
93
|
-
"mimeType": "application/json",
|
|
94
|
-
"content": {
|
|
95
|
-
"project_id": alma.project_id,
|
|
96
|
-
"agent_count": len(agents),
|
|
97
|
-
"agents": agents,
|
|
98
|
-
},
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
def list_resources() -> List[Dict[str, Any]]:
|
|
103
|
-
"""
|
|
104
|
-
List all available resources.
|
|
105
|
-
|
|
106
|
-
Returns:
|
|
107
|
-
List of resource descriptors
|
|
108
|
-
"""
|
|
109
|
-
return [
|
|
110
|
-
{
|
|
111
|
-
"uri": "alma://config",
|
|
112
|
-
"name": "ALMA Configuration",
|
|
113
|
-
"description": "Current configuration of the ALMA memory system",
|
|
114
|
-
"mimeType": "application/json",
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
"uri": "alma://agents",
|
|
118
|
-
"name": "ALMA Registered Agents",
|
|
119
|
-
"description": "All registered agents and their memory scopes",
|
|
120
|
-
"mimeType": "application/json",
|
|
121
|
-
},
|
|
122
|
-
]
|
|
1
|
+
"""
|
|
2
|
+
ALMA MCP Resource Definitions.
|
|
3
|
+
|
|
4
|
+
Provides read-only resources that can be accessed via MCP protocol.
|
|
5
|
+
Resources represent configuration and metadata about the ALMA instance.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import logging
|
|
9
|
+
from typing import Any, Dict, List
|
|
10
|
+
|
|
11
|
+
from alma import ALMA
|
|
12
|
+
|
|
13
|
+
logger = logging.getLogger(__name__)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def get_config_resource(alma: ALMA) -> Dict[str, Any]:
|
|
17
|
+
"""
|
|
18
|
+
Get current ALMA configuration as a resource.
|
|
19
|
+
|
|
20
|
+
This exposes non-sensitive configuration information about
|
|
21
|
+
the ALMA instance.
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
alma: ALMA instance
|
|
25
|
+
|
|
26
|
+
Returns:
|
|
27
|
+
Dict with configuration details
|
|
28
|
+
"""
|
|
29
|
+
return {
|
|
30
|
+
"uri": "alma://config",
|
|
31
|
+
"name": "ALMA Configuration",
|
|
32
|
+
"description": "Current configuration of the ALMA memory system",
|
|
33
|
+
"mimeType": "application/json",
|
|
34
|
+
"content": {
|
|
35
|
+
"project_id": alma.project_id,
|
|
36
|
+
"storage_type": type(alma.storage).__name__,
|
|
37
|
+
"registered_agents": list(alma.scopes.keys()),
|
|
38
|
+
"scopes": {
|
|
39
|
+
name: {
|
|
40
|
+
"can_learn": scope.can_learn,
|
|
41
|
+
"cannot_learn": scope.cannot_learn,
|
|
42
|
+
"min_occurrences_for_heuristic": scope.min_occurrences_for_heuristic,
|
|
43
|
+
}
|
|
44
|
+
for name, scope in alma.scopes.items()
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def get_agents_resource(alma: ALMA) -> Dict[str, Any]:
|
|
51
|
+
"""
|
|
52
|
+
Get registered agents and their scopes as a resource.
|
|
53
|
+
|
|
54
|
+
This provides detailed information about each registered agent
|
|
55
|
+
and their learning permissions.
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
alma: ALMA instance
|
|
59
|
+
|
|
60
|
+
Returns:
|
|
61
|
+
Dict with agent details
|
|
62
|
+
"""
|
|
63
|
+
agents = []
|
|
64
|
+
|
|
65
|
+
for name, scope in alma.scopes.items():
|
|
66
|
+
# Get stats for this agent
|
|
67
|
+
try:
|
|
68
|
+
stats = alma.get_stats(agent=name)
|
|
69
|
+
except Exception:
|
|
70
|
+
stats = {}
|
|
71
|
+
|
|
72
|
+
agents.append(
|
|
73
|
+
{
|
|
74
|
+
"name": name,
|
|
75
|
+
"scope": {
|
|
76
|
+
"can_learn": scope.can_learn,
|
|
77
|
+
"cannot_learn": scope.cannot_learn,
|
|
78
|
+
"min_occurrences_for_heuristic": scope.min_occurrences_for_heuristic,
|
|
79
|
+
},
|
|
80
|
+
"stats": {
|
|
81
|
+
"heuristics_count": stats.get("heuristics_count", 0),
|
|
82
|
+
"outcomes_count": stats.get("outcomes_count", 0),
|
|
83
|
+
"domain_knowledge_count": stats.get("domain_knowledge_count", 0),
|
|
84
|
+
"anti_patterns_count": stats.get("anti_patterns_count", 0),
|
|
85
|
+
},
|
|
86
|
+
}
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
"uri": "alma://agents",
|
|
91
|
+
"name": "ALMA Registered Agents",
|
|
92
|
+
"description": "All registered agents and their memory scopes",
|
|
93
|
+
"mimeType": "application/json",
|
|
94
|
+
"content": {
|
|
95
|
+
"project_id": alma.project_id,
|
|
96
|
+
"agent_count": len(agents),
|
|
97
|
+
"agents": agents,
|
|
98
|
+
},
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def list_resources() -> List[Dict[str, Any]]:
|
|
103
|
+
"""
|
|
104
|
+
List all available resources.
|
|
105
|
+
|
|
106
|
+
Returns:
|
|
107
|
+
List of resource descriptors
|
|
108
|
+
"""
|
|
109
|
+
return [
|
|
110
|
+
{
|
|
111
|
+
"uri": "alma://config",
|
|
112
|
+
"name": "ALMA Configuration",
|
|
113
|
+
"description": "Current configuration of the ALMA memory system",
|
|
114
|
+
"mimeType": "application/json",
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"uri": "alma://agents",
|
|
118
|
+
"name": "ALMA Registered Agents",
|
|
119
|
+
"description": "All registered agents and their memory scopes",
|
|
120
|
+
"mimeType": "application/json",
|
|
121
|
+
},
|
|
122
|
+
]
|