mnemos-continuity 0.2.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.
Files changed (117) hide show
  1. mnemos/__init__.py +63 -0
  2. mnemos/advanced/__init__.py +43 -0
  3. mnemos/advanced/attention_gate.py +48 -0
  4. mnemos/advanced/dreaming.py +56 -0
  5. mnemos/advanced/intention.py +82 -0
  6. mnemos/advanced/intention_sweep.py +35 -0
  7. mnemos/advanced/interference.py +53 -0
  8. mnemos/advanced/interference_resolution.py +48 -0
  9. mnemos/advanced/introspection.py +580 -0
  10. mnemos/advanced/introspection_api.py +488 -0
  11. mnemos/advanced/metamemory.py +70 -0
  12. mnemos/advanced/metamemory_update.py +44 -0
  13. mnemos/advanced/observer.py +52 -0
  14. mnemos/advanced/predictive.py +41 -0
  15. mnemos/advanced/schema.py +67 -0
  16. mnemos/advanced/schema_maintenance.py +44 -0
  17. mnemos/advanced/schema_matcher.py +34 -0
  18. mnemos/advanced/spreading_activation.py +43 -0
  19. mnemos/advanced/working_memory.py +69 -0
  20. mnemos/bridge.py +199 -0
  21. mnemos/cli.py +1542 -0
  22. mnemos/config/__init__.py +8 -0
  23. mnemos/config/defaults.py +145 -0
  24. mnemos/config/loader.py +159 -0
  25. mnemos/consolidation/__init__.py +16 -0
  26. mnemos/consolidation/belief_review.py +135 -0
  27. mnemos/consolidation/connection_discovery.py +234 -0
  28. mnemos/consolidation/daemon.py +332 -0
  29. mnemos/consolidation/decay.py +170 -0
  30. mnemos/consolidation/reflection.py +321 -0
  31. mnemos/consolidation/softening.py +622 -0
  32. mnemos/core/__init__.py +22 -0
  33. mnemos/core/belief.py +158 -0
  34. mnemos/core/emotional_state.py +162 -0
  35. mnemos/core/engram.py +436 -0
  36. mnemos/core/identity.py +265 -0
  37. mnemos/core/types.py +199 -0
  38. mnemos/dream_journal.py +218 -0
  39. mnemos/encoding/__init__.py +7 -0
  40. mnemos/encoding/encoder.py +600 -0
  41. mnemos/encoding/llm_classifier.py +465 -0
  42. mnemos/identity_diff.py +983 -0
  43. mnemos/identity_svg.py +241 -0
  44. mnemos/indexer/__init__.py +6 -0
  45. mnemos/indexer/claude_code_adapter.py +275 -0
  46. mnemos/indexer/prompts/extractor.md +58 -0
  47. mnemos/indexer/session_indexer.py +745 -0
  48. mnemos/integrations/__init__.py +1 -0
  49. mnemos/integrations/hermes/__init__.py +28 -0
  50. mnemos/integrations/hermes/installer.py +732 -0
  51. mnemos/integrations/hermes/provider.py +755 -0
  52. mnemos/integrations/hermes/scope.py +210 -0
  53. mnemos/interface/__init__.py +18 -0
  54. mnemos/interface/context_packet.py +365 -0
  55. mnemos/interface/export.py +87 -0
  56. mnemos/interface/memory_inspector.py +116 -0
  57. mnemos/interface/openclaw_export.py +203 -0
  58. mnemos/interface/prompt_builder.py +161 -0
  59. mnemos/interface/session.py +109 -0
  60. mnemos/interface/visual_snapshot.py +145 -0
  61. mnemos/llm.py +527 -0
  62. mnemos/mcp_server.py +1633 -0
  63. mnemos/multiagent/__init__.py +16 -0
  64. mnemos/multiagent/attestation.py +78 -0
  65. mnemos/multiagent/bridge.py +326 -0
  66. mnemos/multiagent/federation.py +66 -0
  67. mnemos/multiagent/relationships.py +221 -0
  68. mnemos/multiagent/shared_pool.py +241 -0
  69. mnemos/openclaw_cron.py +182 -0
  70. mnemos/retrieval/__init__.py +9 -0
  71. mnemos/retrieval/reactive.py +273 -0
  72. mnemos/retrieval/reconsolidation.py +108 -0
  73. mnemos/setup/__init__.py +8 -0
  74. mnemos/setup/bootstrap.py +426 -0
  75. mnemos/setup/cron_installer.py +227 -0
  76. mnemos/setup/scheduler.py +411 -0
  77. mnemos/simple_mcp.py +462 -0
  78. mnemos/simple_runtime.py +2103 -0
  79. mnemos/simple_scope.py +133 -0
  80. mnemos/store/__init__.py +3 -0
  81. mnemos/store/archive.py +73 -0
  82. mnemos/store/embedding_index.py +391 -0
  83. mnemos/store/migrations.py +86 -0
  84. mnemos/store/sqlite_store.py +2217 -0
  85. mnemos/substrate/__init__.py +18 -0
  86. mnemos/substrate/config.py +87 -0
  87. mnemos/substrate/events.py +42 -0
  88. mnemos/substrate/handlers/__init__.py +5 -0
  89. mnemos/substrate/handlers/dreaming.py +198 -0
  90. mnemos/substrate/handlers/initiation.py +103 -0
  91. mnemos/substrate/handlers/insight.py +96 -0
  92. mnemos/substrate/handlers/reflection.py +152 -0
  93. mnemos/substrate/handlers/surprise.py +93 -0
  94. mnemos/substrate/handlers/wandering.py +199 -0
  95. mnemos/substrate/introspection_pass.py +267 -0
  96. mnemos/substrate/llm.py +139 -0
  97. mnemos/substrate/modulators.py +106 -0
  98. mnemos/substrate/prompts/connector.md +34 -0
  99. mnemos/substrate/prompts/consolidator.md +19 -0
  100. mnemos/substrate/prompts/extractor.md +60 -0
  101. mnemos/substrate/prompts/reflection.md +33 -0
  102. mnemos/substrate/prompts/softener.md +19 -0
  103. mnemos/substrate/tick.py +398 -0
  104. mnemos/visualization/__init__.py +1 -0
  105. mnemos/visualization/app.py +1039 -0
  106. mnemos/visualization/data.py +287 -0
  107. mnemos_continuity-0.2.0.dist-info/METADATA +699 -0
  108. mnemos_continuity-0.2.0.dist-info/RECORD +117 -0
  109. mnemos_continuity-0.2.0.dist-info/WHEEL +4 -0
  110. mnemos_continuity-0.2.0.dist-info/entry_points.txt +3 -0
  111. mnemos_continuity-0.2.0.dist-info/licenses/LICENSE +21 -0
  112. templates/AGENTS.md +69 -0
  113. templates/HEARTBEAT.md +81 -0
  114. templates/IDENTITY.md +129 -0
  115. templates/MEMORY.md +131 -0
  116. templates/SOUL.md +89 -0
  117. templates/active-context.md +81 -0
mnemos/__init__.py ADDED
@@ -0,0 +1,63 @@
1
+ """
2
+ Mnemos: Living Memory Architecture for Autonomous AI Agents
3
+
4
+ Memory is not a feature of the agent. Memory IS the agent.
5
+
6
+ Mnemos provides a cognitive memory layer that sits beneath agent platforms
7
+ like OpenClaw, replacing passive note-storage with active, living memory
8
+ that encodes at varying depths, forgets naturally, predicts what it'll need,
9
+ and changes its memories every time it touches them.
10
+
11
+ Core features (always active):
12
+ - Engrams with dual-trace model (strength/stability/accessibility)
13
+ - Typed connections (supports, contradicts, causes, elaborates, etc.)
14
+ - Confidence scoring on every memory
15
+ - Reconsolidation (every retrieval updates the memory)
16
+ - Decay + softening (LLM-mediated lossy compression)
17
+ - Emotional state (6 dimensions influencing retrieval)
18
+ - Beliefs with confidence tracking and revision history
19
+ - Narrative identity generation
20
+ - OpenClaw-compatible file export
21
+
22
+ Advanced modules (opt-in):
23
+ - Working memory with soft attention gradient
24
+ - Schemas and schema-based encoding
25
+ - Attention-gated encoding
26
+ - Predictive retrieval
27
+ - Interference modeling
28
+ - Prospective memory (intentions with triggers)
29
+ - Metamemory (knowing what you know)
30
+ - External multi-model observer
31
+ - Multi-agent federation
32
+ """
33
+
34
+ # Read from installed package metadata so there is exactly one source of
35
+ # truth. Hardcoding it here meant this said 0.1.0 while the distribution
36
+ # said 0.2.0, and nothing failed — a released package can misreport its own
37
+ # version to every user and to every bug report, and PyPI versions cannot be
38
+ # replaced once uploaded. The fallback covers running from a source tree
39
+ # that was never installed.
40
+ try: # pragma: no cover - trivial branch
41
+ from importlib.metadata import PackageNotFoundError, version as _pkg_version
42
+
43
+ __version__ = _pkg_version("mnemos-continuity")
44
+ except (ImportError, PackageNotFoundError): # pragma: no cover
45
+ __version__ = "0.0.0+unknown"
46
+
47
+ # Public API
48
+ from .store.sqlite_store import EngramStore
49
+ from .encoding.encoder import Encoder
50
+ from .retrieval.reactive import ReactiveRetriever
51
+ from .consolidation.daemon import ConsolidationDaemon
52
+ from .bridge import MnemosBridge
53
+ from .config.loader import load_config, save_config
54
+
55
+ __all__ = [
56
+ "EngramStore",
57
+ "Encoder",
58
+ "ReactiveRetriever",
59
+ "ConsolidationDaemon",
60
+ "MnemosBridge",
61
+ "load_config",
62
+ "save_config",
63
+ ]
@@ -0,0 +1,43 @@
1
+ """Advanced modules for Mnemos (opt-in).
2
+
3
+ These modules extend the core memory system with more sophisticated
4
+ cognitive capabilities. Each is independently toggleable via configuration.
5
+
6
+ Modules:
7
+ - working_memory: Soft attention gradient working memory (capacity ~7 items)
8
+ - schema: Cognitive schemas for structured encoding and retrieval
9
+ - attention_gate: Attention-gated encoding (filter what gets encoded)
10
+ - schema_matcher: Match incoming content against active schemas
11
+ - predictive: Predictive retrieval (pre-fetch likely-needed memories)
12
+ - spreading_activation: Activation spreading through connection graph
13
+ - interference: Interference modeling (similar memories competing)
14
+ - intention: Prospective memory (future-directed intentions with triggers)
15
+ - intention_sweep: Periodic check for triggered intentions
16
+ - metamemory: Knowing what you know (and what you don't)
17
+ - metamemory_update: Update metamemory state after cognitive events
18
+ - schema_maintenance: Schema evolution and pruning
19
+ - interference_resolution: Resolve interference between competing memories
20
+ - observer: External multi-model observer for calibration
21
+ - dreaming: Dream-like consolidation for creative connection discovery
22
+ """
23
+
24
+ # All imports are lazy — modules are only loaded when enabled in config.
25
+ # This avoids import-time costs for disabled features.
26
+
27
+ __all__ = [
28
+ "working_memory",
29
+ "schema",
30
+ "attention_gate",
31
+ "schema_matcher",
32
+ "predictive",
33
+ "spreading_activation",
34
+ "interference",
35
+ "intention",
36
+ "intention_sweep",
37
+ "metamemory",
38
+ "metamemory_update",
39
+ "schema_maintenance",
40
+ "interference_resolution",
41
+ "observer",
42
+ "dreaming",
43
+ ]
@@ -0,0 +1,48 @@
1
+ """
2
+ Attention gate: determines encoding depth based on salience signals.
3
+
4
+ Not everything deserves deep encoding. The attention gate evaluates
5
+ incoming content against multiple salience signals to determine how
6
+ deeply it should be encoded:
7
+
8
+ Signals:
9
+ - Novelty: how different from existing memories
10
+ - Emotional salience: emotional state amplification
11
+ - Schema relevance: matches an active schema
12
+ - Goal relevance: relates to current agent goals
13
+ - WM load: cognitive load affects available encoding resources
14
+ - User emphasis: explicit markers of importance
15
+
16
+ Output: EncodingDepth (shallow | moderate | deep | elaborative)
17
+ """
18
+
19
+ from __future__ import annotations
20
+
21
+ from typing import Any
22
+
23
+ from ..core.types import EncodingDepth
24
+
25
+
26
+ def gate_attention(
27
+ content: str,
28
+ tags: list[str],
29
+ emotional_state: dict[str, float] | None = None,
30
+ wm_load: float = 0.5,
31
+ active_schemas: list[str] | None = None,
32
+ agent_goals: list[str] | None = None,
33
+ ) -> str:
34
+ """Determine encoding depth for incoming content.
35
+
36
+ Args:
37
+ content: The content to evaluate.
38
+ tags: Tags extracted from the content.
39
+ emotional_state: Current emotional state dimensions.
40
+ wm_load: Current working memory load (0-1+).
41
+ active_schemas: Currently active schema IDs.
42
+ agent_goals: Currently active agent goal descriptions.
43
+
44
+ Returns:
45
+ EncodingDepth value (shallow, moderate, deep, or elaborative).
46
+ """
47
+ # TODO: Implementation
48
+ return EncodingDepth.MODERATE
@@ -0,0 +1,56 @@
1
+ """
2
+ Dreaming: creative connection discovery through free association.
3
+
4
+ Dream consolidation uses LLM-mediated free association to find
5
+ non-obvious connections between memories. Unlike regular connection
6
+ discovery (which uses embedding similarity), dreaming explores
7
+ metaphorical, analogical, and creative relationships.
8
+
9
+ Dream-generated connections have source='dream' and often produce
10
+ ANALOGOUS_TO connections that bridge different domains.
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ from typing import TYPE_CHECKING, Any
16
+
17
+ if TYPE_CHECKING:
18
+ from ..store.sqlite_store import EngramStore
19
+
20
+
21
+ def run_dream_cycle(
22
+ store: EngramStore,
23
+ llm_client: Any,
24
+ agent_id: str = "default",
25
+ seed_count: int = 3,
26
+ ) -> dict[str, Any]:
27
+ """Run a dream cycle for creative connection discovery.
28
+
29
+ Process:
30
+ 1. Select random seed engrams from different domains
31
+ 2. Ask the LLM to free-associate between them
32
+ 3. Create ANALOGOUS_TO connections for valid associations
33
+ 4. Generate dream-source engrams for novel insights
34
+
35
+ Args:
36
+ store: The engram store for reading and creating memories.
37
+ llm_client: LLM client for free association generation.
38
+ agent_id: Which agent is dreaming.
39
+ seed_count: Number of random seed engrams to select.
40
+
41
+ Returns:
42
+ Statistics dict:
43
+ {
44
+ "seeds_selected": int,
45
+ "associations_generated": int,
46
+ "connections_created": int,
47
+ "dream_engrams_created": int,
48
+ }
49
+ """
50
+ # TODO: Implementation
51
+ return {
52
+ "seeds_selected": 0,
53
+ "associations_generated": 0,
54
+ "connections_created": 0,
55
+ "dream_engrams_created": 0,
56
+ }
@@ -0,0 +1,82 @@
1
+ """
2
+ Prospective memory: future-directed intentions with triggers.
3
+
4
+ Intentions are memories about things the agent needs to do in the future.
5
+ Each intention has trigger conditions that, when met, surface the intention
6
+ to the agent's attention.
7
+
8
+ Example:
9
+ "When the user mentions the project deadline, remind them about
10
+ the code review they requested."
11
+
12
+ Intentions are stored as engrams with kind=PROSPECTIVE and linked
13
+ to an Intention object that defines trigger conditions.
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ from dataclasses import dataclass, field
19
+ from typing import Any
20
+
21
+
22
+ @dataclass
23
+ class TriggerCondition:
24
+ """A condition that activates a prospective memory."""
25
+
26
+ type: str = "keyword"
27
+ """keyword | temporal | context | emotional"""
28
+
29
+ value: str = ""
30
+ """The trigger value (keyword, ISO timestamp, context pattern, emotion threshold)."""
31
+
32
+ met: bool = False
33
+ """Whether this condition has been met."""
34
+
35
+
36
+ @dataclass
37
+ class Intention:
38
+ """A future-directed memory with trigger conditions.
39
+
40
+ When all trigger conditions are met, the intention surfaces
41
+ to the agent's working memory.
42
+ """
43
+
44
+ id: str = ""
45
+ engram_id: str = ""
46
+ """The prospective engram this intention is linked to."""
47
+
48
+ description: str = ""
49
+ action: str = ""
50
+ triggers: list[TriggerCondition] = field(default_factory=list)
51
+ priority: float = 0.5
52
+ created_at: str = ""
53
+ fulfilled_at: str | None = None
54
+ expired: bool = False
55
+
56
+ def check_triggers(self, context: dict[str, Any]) -> bool:
57
+ """Check if all trigger conditions are met.
58
+
59
+ Args:
60
+ context: Current context dict with keys matching trigger types.
61
+
62
+ Returns:
63
+ True if all triggers are satisfied.
64
+ """
65
+ # TODO: Implementation
66
+ return False
67
+
68
+ def fulfill(self) -> None:
69
+ """Mark this intention as fulfilled."""
70
+ # TODO: Implementation
71
+ pass
72
+
73
+ def to_dict(self) -> dict[str, Any]:
74
+ """Serialize intention to dict."""
75
+ # TODO: Implementation
76
+ return {}
77
+
78
+ @classmethod
79
+ def from_dict(cls, d: dict[str, Any]) -> Intention:
80
+ """Deserialize intention from dict."""
81
+ # TODO: Implementation
82
+ return cls()
@@ -0,0 +1,35 @@
1
+ """
2
+ Intention sweep: periodic check for triggered intentions.
3
+
4
+ Runs during consolidation or at session start to check all active
5
+ intentions against the current context. Triggered intentions are
6
+ surfaced to the agent's working memory or prompt.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from typing import TYPE_CHECKING, Any
12
+
13
+ from .intention import Intention
14
+
15
+ if TYPE_CHECKING:
16
+ from ..store.sqlite_store import EngramStore
17
+
18
+
19
+ def sweep_intentions(
20
+ store: EngramStore,
21
+ context: dict[str, Any],
22
+ agent_id: str = "default",
23
+ ) -> list[Intention]:
24
+ """Check all active intentions against current context.
25
+
26
+ Args:
27
+ store: The engram store for loading intentions.
28
+ context: Current context (keywords, time, emotional state, etc.).
29
+ agent_id: Which agent's intentions to check.
30
+
31
+ Returns:
32
+ List of triggered intentions that should be surfaced.
33
+ """
34
+ # TODO: Implementation
35
+ return []
@@ -0,0 +1,53 @@
1
+ """
2
+ Interference modeling: similar memories competing for retrieval.
3
+
4
+ When multiple similar memories exist, they can interfere with each other:
5
+ - Proactive interference: old memories block retrieval of new ones
6
+ - Retroactive interference: new memories make old ones harder to access
7
+
8
+ Interference reduces accessibility of competing memories and can trigger
9
+ interference resolution during consolidation.
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ from typing import TYPE_CHECKING, Any
15
+
16
+ if TYPE_CHECKING:
17
+ from ..core.engram import Engram
18
+ from ..store.sqlite_store import EngramStore
19
+
20
+
21
+ def calculate_interference(
22
+ target: Engram,
23
+ competitors: list[Engram],
24
+ ) -> float:
25
+ """Calculate interference level for a target engram.
26
+
27
+ Args:
28
+ target: The engram being retrieved.
29
+ competitors: Similar engrams that may interfere.
30
+
31
+ Returns:
32
+ Interference level (0.0 = no interference, 1.0 = maximum).
33
+ """
34
+ # TODO: Implementation
35
+ return 0.0
36
+
37
+
38
+ def apply_interference(
39
+ store: EngramStore,
40
+ target_id: str,
41
+ competitor_ids: list[str],
42
+ interference_level: float,
43
+ ) -> None:
44
+ """Apply interference effects to competing engrams.
45
+
46
+ Args:
47
+ store: The engram store.
48
+ target_id: The successfully retrieved engram.
49
+ competitor_ids: Engrams that competed with the target.
50
+ interference_level: The calculated interference level.
51
+ """
52
+ # TODO: Implementation
53
+ pass
@@ -0,0 +1,48 @@
1
+ """
2
+ Interference resolution: resolve competition between similar memories.
3
+
4
+ Runs during consolidation to handle cases where multiple similar memories
5
+ interfere with each other. Resolution strategies:
6
+
7
+ 1. Merge: combine highly similar memories into a single stronger one
8
+ 2. Differentiate: add distinguishing connections to reduce confusion
9
+ 3. Suppress: lower accessibility of the weaker competitor
10
+ 4. Preserve: keep both with explicit contradiction/elaboration connections
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ from typing import TYPE_CHECKING, Any
16
+
17
+ if TYPE_CHECKING:
18
+ from ..store.sqlite_store import EngramStore
19
+
20
+
21
+ def resolve_interference(
22
+ store: EngramStore,
23
+ config: dict[str, Any],
24
+ ) -> dict[str, Any]:
25
+ """Find and resolve interference between competing memories.
26
+
27
+ Args:
28
+ store: The engram store for finding and updating engrams.
29
+ config: Configuration for interference thresholds.
30
+
31
+ Returns:
32
+ Statistics dict:
33
+ {
34
+ "pairs_evaluated": int,
35
+ "merged": int,
36
+ "differentiated": int,
37
+ "suppressed": int,
38
+ "preserved": int,
39
+ }
40
+ """
41
+ # TODO: Implementation
42
+ return {
43
+ "pairs_evaluated": 0,
44
+ "merged": 0,
45
+ "differentiated": 0,
46
+ "suppressed": 0,
47
+ "preserved": 0,
48
+ }