neural-memory 0.2.0__py3-none-any.whl → 0.3.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.
neural_memory/__init__.py CHANGED
@@ -13,7 +13,7 @@ from neural_memory.core.synapse import Direction, Synapse, SynapseType
13
13
  from neural_memory.engine.encoder import EncodingResult, MemoryEncoder
14
14
  from neural_memory.engine.retrieval import DepthLevel, ReflexPipeline, RetrievalResult
15
15
 
16
- __version__ = "0.2.0"
16
+ __version__ = "0.3.0"
17
17
 
18
18
  __all__ = [
19
19
  "__version__",
neural_memory/cli/main.py CHANGED
@@ -2768,6 +2768,150 @@ def prompt(
2768
2768
  typer.echo(text)
2769
2769
 
2770
2770
 
2771
+ @app.command(name="export")
2772
+ def export_brain_cmd(
2773
+ output: Annotated[
2774
+ str, typer.Argument(help="Output file path (e.g., my-brain.json)")
2775
+ ],
2776
+ brain: Annotated[
2777
+ str | None, typer.Option("--brain", "-b", help="Brain to export (default: current)")
2778
+ ] = None,
2779
+ ) -> None:
2780
+ """Export brain to JSON file for backup or sharing.
2781
+
2782
+ Examples:
2783
+ nmem export backup.json # Export current brain
2784
+ nmem export work.json -b work # Export specific brain
2785
+ """
2786
+ from pathlib import Path
2787
+
2788
+ from neural_memory.unified_config import get_config, get_shared_storage
2789
+
2790
+ async def _export() -> None:
2791
+ config = get_config()
2792
+ brain_name = brain or config.current_brain
2793
+ storage = await get_shared_storage(brain_name)
2794
+
2795
+ snapshot = await storage.export_brain(brain_name)
2796
+
2797
+ output_path = Path(output)
2798
+ export_data = {
2799
+ "brain_id": snapshot.brain_id,
2800
+ "brain_name": snapshot.brain_name,
2801
+ "exported_at": snapshot.exported_at.isoformat(),
2802
+ "version": snapshot.version,
2803
+ "neurons": snapshot.neurons,
2804
+ "synapses": snapshot.synapses,
2805
+ "fibers": snapshot.fibers,
2806
+ "config": snapshot.config,
2807
+ "metadata": snapshot.metadata,
2808
+ }
2809
+
2810
+ output_path.write_text(json.dumps(export_data, indent=2, default=str))
2811
+
2812
+ typer.echo(f"Exported brain '{brain_name}' to {output_path}")
2813
+ typer.echo(f" Neurons: {len(snapshot.neurons)}")
2814
+ typer.echo(f" Synapses: {len(snapshot.synapses)}")
2815
+ typer.echo(f" Fibers: {len(snapshot.fibers)}")
2816
+
2817
+ asyncio.run(_export())
2818
+
2819
+
2820
+ @app.command(name="import")
2821
+ def import_brain_cmd(
2822
+ input_file: Annotated[
2823
+ str, typer.Argument(help="Input file path (e.g., my-brain.json)")
2824
+ ],
2825
+ brain: Annotated[
2826
+ str | None, typer.Option("--brain", "-b", help="Target brain name (default: from file)")
2827
+ ] = None,
2828
+ merge: Annotated[
2829
+ bool, typer.Option("--merge", "-m", help="Merge with existing brain")
2830
+ ] = False,
2831
+ ) -> None:
2832
+ """Import brain from JSON file.
2833
+
2834
+ Examples:
2835
+ nmem import backup.json # Import as original brain name
2836
+ nmem import backup.json -b new # Import as 'new' brain
2837
+ nmem import backup.json --merge # Merge into existing brain
2838
+ """
2839
+ from pathlib import Path
2840
+
2841
+ from neural_memory.core.brain import BrainSnapshot
2842
+ from neural_memory.unified_config import get_shared_storage
2843
+
2844
+ async def _import() -> None:
2845
+ input_path = Path(input_file)
2846
+ if not input_path.exists():
2847
+ typer.echo(f"Error: File not found: {input_path}", err=True)
2848
+ raise typer.Exit(1)
2849
+
2850
+ data = json.loads(input_path.read_text())
2851
+
2852
+ brain_name = brain or data.get("brain_name", "imported")
2853
+ storage = await get_shared_storage(brain_name)
2854
+
2855
+ snapshot = BrainSnapshot(
2856
+ brain_id=data.get("brain_id", brain_name),
2857
+ brain_name=data["brain_name"],
2858
+ exported_at=datetime.fromisoformat(data["exported_at"]),
2859
+ version=data["version"],
2860
+ neurons=data["neurons"],
2861
+ synapses=data["synapses"],
2862
+ fibers=data["fibers"],
2863
+ config=data["config"],
2864
+ metadata=data.get("metadata", {}),
2865
+ )
2866
+
2867
+ imported_id = await storage.import_brain(snapshot, brain_name)
2868
+
2869
+ typer.echo(f"Imported brain '{brain_name}' from {input_path}")
2870
+ typer.echo(f" Neurons: {len(snapshot.neurons)}")
2871
+ typer.echo(f" Synapses: {len(snapshot.synapses)}")
2872
+ typer.echo(f" Fibers: {len(snapshot.fibers)}")
2873
+
2874
+ asyncio.run(_import())
2875
+
2876
+
2877
+ @app.command()
2878
+ def serve(
2879
+ host: Annotated[
2880
+ str, typer.Option("--host", "-h", help="Host to bind to")
2881
+ ] = "127.0.0.1",
2882
+ port: Annotated[
2883
+ int, typer.Option("--port", "-p", help="Port to bind to")
2884
+ ] = 8000,
2885
+ reload: Annotated[
2886
+ bool, typer.Option("--reload", "-r", help="Enable auto-reload for development")
2887
+ ] = False,
2888
+ ) -> None:
2889
+ """Run the NeuralMemory API server.
2890
+
2891
+ Examples:
2892
+ nmem serve # Run on localhost:8000
2893
+ nmem serve -p 9000 # Run on port 9000
2894
+ nmem serve --host 0.0.0.0 # Expose to network
2895
+ nmem serve --reload # Development mode
2896
+ """
2897
+ try:
2898
+ import uvicorn
2899
+ except ImportError:
2900
+ typer.echo("Error: uvicorn not installed. Run: pip install neural-memory[server]", err=True)
2901
+ raise typer.Exit(1)
2902
+
2903
+ typer.echo(f"Starting NeuralMemory API server on http://{host}:{port}")
2904
+ typer.echo("API docs: http://{host}:{port}/docs")
2905
+
2906
+ uvicorn.run(
2907
+ "neural_memory.server.app:create_app",
2908
+ host=host,
2909
+ port=port,
2910
+ reload=reload,
2911
+ factory=True,
2912
+ )
2913
+
2914
+
2771
2915
  @app.command()
2772
2916
  def version() -> None:
2773
2917
  """Show version information."""
@@ -603,7 +603,7 @@ async def handle_message(server: MCPServer, message: dict[str, Any]) -> dict[str
603
603
  "id": msg_id,
604
604
  "result": {
605
605
  "protocolVersion": "2024-11-05",
606
- "serverInfo": {"name": "neural-memory", "version": "0.2.0"},
606
+ "serverInfo": {"name": "neural-memory", "version": "0.3.0"},
607
607
  "capabilities": {"tools": {}, "resources": {}},
608
608
  },
609
609
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: neural-memory
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Reflex-based memory system for AI agents - retrieval through activation, not search
5
5
  Project-URL: Homepage, https://github.com/nhadaututtheky/neural-memory
6
6
  Project-URL: Documentation, https://github.com/nhadaututtheky/neural-memory#readme
@@ -1,10 +1,10 @@
1
- neural_memory/__init__.py,sha256=m2XAEkY23Kd3_yNBOcQRIl7kcDPJ4MO6fYrFI79qt_E,970
1
+ neural_memory/__init__.py,sha256=98W3ehXo6Pf4-bL0DpVt3W_aTIZPbyDqp4nXnI_uj0U,970
2
2
  neural_memory/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  neural_memory/unified_config.py,sha256=BySYLNJmnBcz9A83kKztJ53ShkScJ5qOVqBNGQls0Rs,10208
4
4
  neural_memory/cli/__init__.py,sha256=4srWgYwiGcs-mG6dm91gRbYCN-om2hfkuxd-fYkgIGI,409
5
5
  neural_memory/cli/__main__.py,sha256=TnhrDVCqsaagmqua7QH1yaP9YXLNRvLxQ0pFrMxDYRw,132
6
6
  neural_memory/cli/config.py,sha256=3kuYeWyTJms_2H_xAgx0qXEN1FbaYwvcU0oKPdiGO2Y,5612
7
- neural_memory/cli/main.py,sha256=wA4qLKzP2-H9PfyYHBVqw_OVFYQrxmgCVHDyGoI1Hxc,95060
7
+ neural_memory/cli/main.py,sha256=rQra4oGAmd18yJ0e3xbw18IKg3--FpQSqvdyZGRO8tM,99873
8
8
  neural_memory/cli/storage.py,sha256=xiIk9Nmygw2G-nBDuRaSh6ZY6Ccu3zX_1l_eyeOlIsM,6044
9
9
  neural_memory/cli/tui.py,sha256=3D0uhQD2LpP7caBOns7EeOsx-JsORl4-DyzSsS1HN64,16335
10
10
  neural_memory/core/__init__.py,sha256=j9oPfDRg6n3Jr1OwwjY1OufH1zEPcL5aZol23R8vik0,1181
@@ -27,7 +27,7 @@ neural_memory/extraction/temporal.py,sha256=uESwr-NWTMNiRJHDryKBdSS3swnkp_FBwjUw
27
27
  neural_memory/mcp/__init__.py,sha256=8qo502ZfwryBv5htRaUJWsk3q9tbZX6TBtjmO6H0iTA,332
28
28
  neural_memory/mcp/__main__.py,sha256=BETnISNHCDaqFhvOo51fSV1DcB2yMu9iefu-b6mA0bk,137
29
29
  neural_memory/mcp/prompt.py,sha256=PTTWJ5ZxSPFq42ojU7UH8DKqgJxepg8ZMZmj9xYcaKQ,5003
30
- neural_memory/mcp/server.py,sha256=MITUs-5DXieZ2Wr5n9f9MTlOWoanmK10L6FvCm_HPCk,26121
30
+ neural_memory/mcp/server.py,sha256=lQ9kfNOU8nkBd8mza506h9N9b08uyBqNkp8AoUT_6dc,26121
31
31
  neural_memory/safety/__init__.py,sha256=25_pdeXu-UI3dNsPYiCsC3Rvq26ma-tCd3h1ow7Ny3w,679
32
32
  neural_memory/safety/freshness.py,sha256=nwUdybjsDK_8uwa_mJRPflx0XGZXVwDwJCw-LEVyh9c,6748
33
33
  neural_memory/safety/sensitive.py,sha256=3dCv951D1JOMo6V4vu11d0OxUFhxCITZ2w05HhJ3CtA,9359
@@ -49,8 +49,8 @@ neural_memory/sync/__init__.py,sha256=epKpdAsHzwUYXrWawlHPckSEgK5CZYb-B29AAcdTnV
49
49
  neural_memory/sync/client.py,sha256=kiKqRlteXVe9P-IzgayV7bwdT9Ovu2UgV_XJtEUIbxQ,13421
50
50
  neural_memory/utils/__init__.py,sha256=vZM_jKQ_BUUd6jXtz9BGq5A1d-kFRMcMXt96XVhRv2M,135
51
51
  neural_memory/utils/config.py,sha256=jgDaHksEibusC2gub1I_USUBOJyP6gBHcfgS7RkL4dc,3086
52
- neural_memory-0.2.0.dist-info/METADATA,sha256=wdXskPmp9hpl_wVG0yQl8sik8IoSUjFDpe8zTVRWp88,10305
53
- neural_memory-0.2.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
54
- neural_memory-0.2.0.dist-info/entry_points.txt,sha256=u0ZGaAD6uU98g0Wheyj1WjrSchm_zlAkyzz1HRbKOnE,121
55
- neural_memory-0.2.0.dist-info/licenses/LICENSE,sha256=uuCGDPgkW8shclBRpQNK5I0T97ZQy9HHolwo9Qr3Bbc,1082
56
- neural_memory-0.2.0.dist-info/RECORD,,
52
+ neural_memory-0.3.0.dist-info/METADATA,sha256=UarxhykY-BWQ-PhREpptBF9MUDnD5ejnHmpxKNGAmKI,10305
53
+ neural_memory-0.3.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
54
+ neural_memory-0.3.0.dist-info/entry_points.txt,sha256=u0ZGaAD6uU98g0Wheyj1WjrSchm_zlAkyzz1HRbKOnE,121
55
+ neural_memory-0.3.0.dist-info/licenses/LICENSE,sha256=uuCGDPgkW8shclBRpQNK5I0T97ZQy9HHolwo9Qr3Bbc,1082
56
+ neural_memory-0.3.0.dist-info/RECORD,,