synapse-layer 2.3.2__tar.gz → 2.4.0__tar.gz

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.
@@ -0,0 +1,17 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ Copyright 2026 Synapse Layer
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: synapse-layer
3
- Version: 2.3.2
4
- Summary: Persistent memory infrastructure for AI agentsState Continuity Layer.
3
+ Version: 2.4.0
4
+ Summary: Python SDK for Synapse Layerpersistent, encrypted, cross-agent memory for AI agents.
5
5
  Author-email: Synapse Layer <founder.synapselayer@proton.me>
6
6
  Project-URL: Homepage, https://synapselayer.org
7
7
  Project-URL: Bug Tracker, https://github.com/SynapseLayer/synapse-sdk-python/issues
@@ -14,19 +14,22 @@ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
14
14
  Classifier: Intended Audience :: Developers
15
15
  Requires-Python: >=3.9
16
16
  Description-Content-Type: text/markdown
17
+ License-File: LICENSE
17
18
  Requires-Dist: requests>=2.25.0
18
19
  Requires-Dist: pydantic>=2.0.0
20
+ Requires-Dist: aiohttp>=3.8.0
19
21
  Provides-Extra: langchain
20
22
  Requires-Dist: langchain-core>=0.1.0; extra == "langchain"
21
23
  Provides-Extra: crewai
22
24
  Requires-Dist: crewai>=0.1.0; extra == "crewai"
25
+ Dynamic: license-file
23
26
 
24
27
  # Synapse Layer
25
28
 
26
29
  [![PyPI](https://img.shields.io/pypi/v/synapse-layer?label=PyPI&color=blue)](https://pypi.org/project/synapse-layer/)
27
30
  [![MCP Compatible](https://img.shields.io/badge/MCP-Compatible-6B4FBB)](https://modelcontextprotocol.io/)
28
31
  [![AES-256-GCM](https://img.shields.io/badge/AES--256--GCM-Encrypted_at_Rest-success)](https://github.com/SynapseLayer/synapse-sdk-python)
29
- [![Server Never Sees Plaintext](https://img.shields.io/badge/Server-Never_Sees_Plaintext-informational)](https://github.com/SynapseLayer/synapse-sdk-python)
32
+ [![State Continuity](https://img.shields.io/badge/State_Continuity-Layer-informational)](https://github.com/SynapseLayer/synapse-sdk-python)
30
33
  [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](./LICENSE)
31
34
  [![Tests Passing](https://img.shields.io/badge/Tests-Passing-brightgreen)](https://github.com/SynapseLayer/synapse-sdk-python)
32
35
 
@@ -36,6 +39,25 @@ Persistent memory infrastructure for AI agents — encrypted, governed, and cros
36
39
 
37
40
  ---
38
41
 
42
+ ## ⚡ 30-Second Quickstart
43
+
44
+ ```bash
45
+ pip install synapse-layer
46
+ ```
47
+
48
+ ```python
49
+ from synapse_layer import Synapse
50
+
51
+ s = Synapse(token="sk_connect_YOUR_TOKEN")
52
+
53
+ s.save("user likes coffee")
54
+ print(s.recall("what does user like?"))
55
+ ```
56
+
57
+ Get your token at [forge.synapselayer.org](https://forge.synapselayer.org) → Dashboard → Connect
58
+
59
+ ---
60
+
39
61
  ## Why Synapse?
40
62
 
41
63
  Superpowers proved agents need discipline. Synapse provides the **continuity layer** that makes that discipline persistent across sessions, tools, and handoffs.
@@ -45,7 +67,7 @@ Superpowers proved agents need discipline. Synapse provides the **continuity lay
45
67
  | Capability | Description |
46
68
  |---|---|
47
69
  | **State Continuity** | OAuth for AI Memory. Persistent context across sessions and models. |
48
- | **Privacy First** | Server never sees plaintext. AES-256-GCM client-side encryption. |
70
+ | **Privacy First** | Server never sees plaintext. AES-256-GCM encrypted at rest with per-operation random IV. |
49
71
  | **Agent-Native** | 30-second install. Built for the MCP ecosystem. |
50
72
  | **Cross-Agent** | Share memory between agents via A2A protocol. |
51
73
  | **Trust Quotient** | Weighted memory ranking: confidence, recency, and usage. |
@@ -163,7 +185,7 @@ recall_tool = SynapseRecallMemoryTool(api_key="your-key")
163
185
  | **Privacy** | Differential privacy via Gaussian noise on embeddings. |
164
186
  | **Validation** | Intent validation pipeline with confidence scoring. |
165
187
 
166
- > The server never sees plaintext. All sensitive data is encrypted before storage.
188
+ > Server never sees plaintext. All sensitive data is AES-256-GCM encrypted at rest with per-operation random IV. Designed for LGPD/GDPR alignment.
167
189
 
168
190
  ---
169
191
 
@@ -3,7 +3,7 @@
3
3
  [![PyPI](https://img.shields.io/pypi/v/synapse-layer?label=PyPI&color=blue)](https://pypi.org/project/synapse-layer/)
4
4
  [![MCP Compatible](https://img.shields.io/badge/MCP-Compatible-6B4FBB)](https://modelcontextprotocol.io/)
5
5
  [![AES-256-GCM](https://img.shields.io/badge/AES--256--GCM-Encrypted_at_Rest-success)](https://github.com/SynapseLayer/synapse-sdk-python)
6
- [![Server Never Sees Plaintext](https://img.shields.io/badge/Server-Never_Sees_Plaintext-informational)](https://github.com/SynapseLayer/synapse-sdk-python)
6
+ [![State Continuity](https://img.shields.io/badge/State_Continuity-Layer-informational)](https://github.com/SynapseLayer/synapse-sdk-python)
7
7
  [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](./LICENSE)
8
8
  [![Tests Passing](https://img.shields.io/badge/Tests-Passing-brightgreen)](https://github.com/SynapseLayer/synapse-sdk-python)
9
9
 
@@ -13,6 +13,25 @@ Persistent memory infrastructure for AI agents — encrypted, governed, and cros
13
13
 
14
14
  ---
15
15
 
16
+ ## ⚡ 30-Second Quickstart
17
+
18
+ ```bash
19
+ pip install synapse-layer
20
+ ```
21
+
22
+ ```python
23
+ from synapse_layer import Synapse
24
+
25
+ s = Synapse(token="sk_connect_YOUR_TOKEN")
26
+
27
+ s.save("user likes coffee")
28
+ print(s.recall("what does user like?"))
29
+ ```
30
+
31
+ Get your token at [forge.synapselayer.org](https://forge.synapselayer.org) → Dashboard → Connect
32
+
33
+ ---
34
+
16
35
  ## Why Synapse?
17
36
 
18
37
  Superpowers proved agents need discipline. Synapse provides the **continuity layer** that makes that discipline persistent across sessions, tools, and handoffs.
@@ -22,7 +41,7 @@ Superpowers proved agents need discipline. Synapse provides the **continuity lay
22
41
  | Capability | Description |
23
42
  |---|---|
24
43
  | **State Continuity** | OAuth for AI Memory. Persistent context across sessions and models. |
25
- | **Privacy First** | Server never sees plaintext. AES-256-GCM client-side encryption. |
44
+ | **Privacy First** | Server never sees plaintext. AES-256-GCM encrypted at rest with per-operation random IV. |
26
45
  | **Agent-Native** | 30-second install. Built for the MCP ecosystem. |
27
46
  | **Cross-Agent** | Share memory between agents via A2A protocol. |
28
47
  | **Trust Quotient** | Weighted memory ranking: confidence, recency, and usage. |
@@ -140,7 +159,7 @@ recall_tool = SynapseRecallMemoryTool(api_key="your-key")
140
159
  | **Privacy** | Differential privacy via Gaussian noise on embeddings. |
141
160
  | **Validation** | Intent validation pipeline with confidence scoring. |
142
161
 
143
- > The server never sees plaintext. All sensitive data is encrypted before storage.
162
+ > Server never sees plaintext. All sensitive data is AES-256-GCM encrypted at rest with per-operation random IV. Designed for LGPD/GDPR alignment.
144
163
 
145
164
  ---
146
165
 
@@ -4,11 +4,11 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "synapse-layer"
7
- version = "2.3.2"
7
+ version = "2.4.0"
8
8
  authors = [
9
9
  { name="Synapse Layer", email="founder.synapselayer@proton.me" },
10
10
  ]
11
- description = "Persistent memory infrastructure for AI agentsState Continuity Layer."
11
+ description = "Python SDK for Synapse Layerpersistent, encrypted, cross-agent memory for AI agents."
12
12
  readme = "README.md"
13
13
  requires-python = ">=3.9"
14
14
  classifiers = [
@@ -21,6 +21,7 @@ classifiers = [
21
21
  dependencies = [
22
22
  "requests>=2.25.0",
23
23
  "pydantic>=2.0.0",
24
+ "aiohttp>=3.8.0",
24
25
  ]
25
26
 
26
27
  [project.optional-dependencies]
@@ -14,10 +14,11 @@ CrewAI tools (requires crewai):
14
14
  from synapse_layer import SynapseStoreMemoryTool, SynapseRecallMemoryTool
15
15
  """
16
16
 
17
- __version__ = "2.3.2"
17
+ __version__ = "2.4.0"
18
18
 
19
19
  # Core — always importable, zero optional deps
20
20
  from .a2a_client import SynapseA2AClient
21
+ from .client import Synapse
21
22
 
22
23
 
23
24
  # ---------------------------------------------------------------------------
@@ -60,6 +61,7 @@ __all__ = [
60
61
  "__version__",
61
62
  # Core
62
63
  "SynapseA2AClient",
64
+ "Synapse",
63
65
  # LangChain (lazy)
64
66
  "SynapseMemory",
65
67
  "SynapseChatHistory",
@@ -21,7 +21,7 @@ import aiohttp
21
21
 
22
22
 
23
23
  # Constants
24
- DEFAULT_BASE_URL = "https://rbeycxzizrrdmxpilepc.supabase.co/functions/v1/mcp-server"
24
+ DEFAULT_BASE_URL = "https://forge.synapselayer.org/api/mcp"
25
25
  VALID_SKILL_IDS = {
26
26
  "store_memory",
27
27
  "recall_memory",
@@ -0,0 +1,217 @@
1
+ """Synapse Layer — Simple Sync Client.
2
+
3
+ Minimal sync HTTP client for Forge API. AES-256-GCM encryption at rest
4
+ is handled server-side; this client sends plaintext over HTTPS.
5
+
6
+ Usage::
7
+
8
+ from synapse_layer import Synapse
9
+
10
+ s = Synapse(token="sk_connect_YOUR_TOKEN")
11
+ s.save("user prefers dark mode")
12
+ results = s.recall("user preferences")
13
+ for r in results:
14
+ print(r["content"])
15
+
16
+ Get your token at https://forge.synapselayer.org → Dashboard → Connect
17
+ """
18
+
19
+ from __future__ import annotations
20
+
21
+ import os
22
+ import sys
23
+ import time
24
+ from typing import Any, Dict, List, Optional
25
+
26
+ import requests
27
+
28
+
29
+ _DEFAULT_BASE_URL = os.environ.get(
30
+ "SYNAPSE_FORGE_URL", "https://forge.synapselayer.org"
31
+ )
32
+ _DEFAULT_TIMEOUT = 15
33
+ _DEFAULT_AGENT = "sdk-client"
34
+
35
+
36
+ class SynapseError(Exception):
37
+ """Base exception for Synapse client errors."""
38
+
39
+
40
+ class SynapseAuthError(SynapseError):
41
+ """Authentication failed (401)."""
42
+
43
+
44
+ class SynapseRateLimitError(SynapseError):
45
+ """Rate limit exceeded (429)."""
46
+
47
+
48
+ class Synapse:
49
+ """Synchronous Synapse client — minimal one-liner API.
50
+
51
+ Args:
52
+ token: ``sk_connect_*`` token. Also accepts ``api_key`` kwarg
53
+ or ``SYNAPSE_TOKEN`` env var.
54
+ base_url: Forge base URL. Defaults to ``https://forge.synapselayer.org``.
55
+ agent_id: Agent identifier for memory tagging.
56
+ timeout: HTTP timeout in seconds.
57
+ """
58
+
59
+ def __init__(
60
+ self,
61
+ token: Optional[str] = None,
62
+ *,
63
+ api_key: Optional[str] = None,
64
+ base_url: str = _DEFAULT_BASE_URL,
65
+ agent_id: str = _DEFAULT_AGENT,
66
+ timeout: int = _DEFAULT_TIMEOUT,
67
+ ) -> None:
68
+ resolved = token or api_key or os.environ.get("SYNAPSE_TOKEN", "")
69
+ if not resolved:
70
+ print(
71
+ "\n\u274c Missing SYNAPSE_TOKEN — get one at "
72
+ "https://forge.synapselayer.org/dashboard/connect\n",
73
+ file=sys.stderr,
74
+ )
75
+ raise SynapseAuthError(
76
+ "Missing token. Set SYNAPSE_TOKEN env var or pass token= argument. "
77
+ "Get your token at https://forge.synapselayer.org/dashboard/connect"
78
+ )
79
+ if not resolved.startswith("sk_connect_"):
80
+ raise SynapseAuthError(
81
+ "Token must start with 'sk_connect_' — "
82
+ "get one at https://forge.synapselayer.org/dashboard/connect"
83
+ )
84
+
85
+ self._token = resolved
86
+ self._base = base_url.rstrip("/")
87
+ self._agent = agent_id
88
+ self._timeout = timeout
89
+ self._session: Optional[requests.Session] = None
90
+
91
+ def _get_session(self) -> requests.Session:
92
+ if self._session is None:
93
+ self._session = requests.Session()
94
+ self._session.headers.update({
95
+ "x-connect-token": self._token,
96
+ "Content-Type": "application/json",
97
+ })
98
+ return self._session
99
+
100
+ # ── Store ──────────────────────────────────────────────────────
101
+
102
+ def save(self, content: str, **kwargs: Any) -> Dict[str, Any]:
103
+ """Save a memory to Synapse.
104
+
105
+ Args:
106
+ content: Text to persist in encrypted memory.
107
+ **kwargs: Optional overrides (memory_type, metadata, agent).
108
+
109
+ Returns:
110
+ Dict with memory_id, tq_score, and other metadata.
111
+ """
112
+ payload: Dict[str, Any] = {
113
+ "content": content,
114
+ "agent": kwargs.get("agent", self._agent),
115
+ "memory_type": kwargs.get("memory_type", "long_term"),
116
+ }
117
+ if "metadata" in kwargs:
118
+ payload["metadata"] = kwargs["metadata"]
119
+
120
+ session = self._get_session()
121
+ resp = session.post(
122
+ f"{self._base}/api/mcp",
123
+ json={
124
+ "jsonrpc": "2.0",
125
+ "method": "tools/call",
126
+ "params": {
127
+ "name": "save_to_synapse",
128
+ "arguments": payload,
129
+ },
130
+ "id": 1,
131
+ },
132
+ timeout=self._timeout,
133
+ )
134
+ return self._handle(resp)
135
+
136
+ def remember(self, content: str, **kwargs: Any) -> Dict[str, Any]:
137
+ """Alias for :meth:`save`."""
138
+ return self.save(content, **kwargs)
139
+
140
+ def store(self, content: str, **kwargs: Any) -> Dict[str, Any]:
141
+ """Alias for :meth:`save`."""
142
+ return self.save(content, **kwargs)
143
+
144
+ # ── Recall ─────────────────────────────────────────────────────
145
+
146
+ def recall(self, query: str, *, limit: int = 5) -> List[Dict[str, Any]]:
147
+ """Recall relevant memories.
148
+
149
+ Args:
150
+ query: Natural language query.
151
+ limit: Max results (default 5).
152
+
153
+ Returns:
154
+ List of memory dicts with content, trust_quotient, etc.
155
+ """
156
+ session = self._get_session()
157
+ resp = session.post(
158
+ f"{self._base}/api/mcp",
159
+ json={
160
+ "jsonrpc": "2.0",
161
+ "method": "tools/call",
162
+ "params": {
163
+ "name": "recall",
164
+ "arguments": {"query": query, "limit": limit},
165
+ },
166
+ "id": 2,
167
+ },
168
+ timeout=self._timeout,
169
+ )
170
+ data = self._handle(resp)
171
+ # Extract memories list from MCP tool response
172
+ if isinstance(data, dict):
173
+ # MCP returns {content: [{type: "text", text: JSON}]}
174
+ content_list = data.get("content", [])
175
+ if content_list and isinstance(content_list, list):
176
+ import json as _json
177
+ try:
178
+ text = content_list[0].get("text", "{}")
179
+ parsed = _json.loads(text)
180
+ return parsed.get("memories", [])
181
+ except (ValueError, KeyError, IndexError):
182
+ pass
183
+ return data.get("memories", [])
184
+ return []
185
+
186
+ # ── Helpers ────────────────────────────────────────────────────
187
+
188
+ def _handle(self, resp: requests.Response) -> Dict[str, Any]:
189
+ if resp.status_code == 401:
190
+ raise SynapseAuthError(f"Authentication failed (401): {resp.text[:200]}")
191
+ if resp.status_code == 429:
192
+ raise SynapseRateLimitError(f"Rate limit exceeded (429)")
193
+ if resp.status_code != 200:
194
+ raise SynapseError(f"Request failed ({resp.status_code}): {resp.text[:200]}")
195
+
196
+ data = resp.json()
197
+ if "error" in data:
198
+ err = data["error"]
199
+ msg = err.get("message", str(err)) if isinstance(err, dict) else str(err)
200
+ raise SynapseError(f"API error: {msg}")
201
+
202
+ return data.get("result", data)
203
+
204
+ def close(self) -> None:
205
+ """Close the HTTP session."""
206
+ if self._session:
207
+ self._session.close()
208
+ self._session = None
209
+
210
+ def __enter__(self) -> "Synapse":
211
+ return self
212
+
213
+ def __exit__(self, *args: Any) -> None:
214
+ self.close()
215
+
216
+ def __repr__(self) -> str:
217
+ return f"Synapse(agent='{self._agent}', base='{self._base}')"
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: synapse-layer
3
- Version: 2.3.2
4
- Summary: Persistent memory infrastructure for AI agentsState Continuity Layer.
3
+ Version: 2.4.0
4
+ Summary: Python SDK for Synapse Layerpersistent, encrypted, cross-agent memory for AI agents.
5
5
  Author-email: Synapse Layer <founder.synapselayer@proton.me>
6
6
  Project-URL: Homepage, https://synapselayer.org
7
7
  Project-URL: Bug Tracker, https://github.com/SynapseLayer/synapse-sdk-python/issues
@@ -14,19 +14,22 @@ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
14
14
  Classifier: Intended Audience :: Developers
15
15
  Requires-Python: >=3.9
16
16
  Description-Content-Type: text/markdown
17
+ License-File: LICENSE
17
18
  Requires-Dist: requests>=2.25.0
18
19
  Requires-Dist: pydantic>=2.0.0
20
+ Requires-Dist: aiohttp>=3.8.0
19
21
  Provides-Extra: langchain
20
22
  Requires-Dist: langchain-core>=0.1.0; extra == "langchain"
21
23
  Provides-Extra: crewai
22
24
  Requires-Dist: crewai>=0.1.0; extra == "crewai"
25
+ Dynamic: license-file
23
26
 
24
27
  # Synapse Layer
25
28
 
26
29
  [![PyPI](https://img.shields.io/pypi/v/synapse-layer?label=PyPI&color=blue)](https://pypi.org/project/synapse-layer/)
27
30
  [![MCP Compatible](https://img.shields.io/badge/MCP-Compatible-6B4FBB)](https://modelcontextprotocol.io/)
28
31
  [![AES-256-GCM](https://img.shields.io/badge/AES--256--GCM-Encrypted_at_Rest-success)](https://github.com/SynapseLayer/synapse-sdk-python)
29
- [![Server Never Sees Plaintext](https://img.shields.io/badge/Server-Never_Sees_Plaintext-informational)](https://github.com/SynapseLayer/synapse-sdk-python)
32
+ [![State Continuity](https://img.shields.io/badge/State_Continuity-Layer-informational)](https://github.com/SynapseLayer/synapse-sdk-python)
30
33
  [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](./LICENSE)
31
34
  [![Tests Passing](https://img.shields.io/badge/Tests-Passing-brightgreen)](https://github.com/SynapseLayer/synapse-sdk-python)
32
35
 
@@ -36,6 +39,25 @@ Persistent memory infrastructure for AI agents — encrypted, governed, and cros
36
39
 
37
40
  ---
38
41
 
42
+ ## ⚡ 30-Second Quickstart
43
+
44
+ ```bash
45
+ pip install synapse-layer
46
+ ```
47
+
48
+ ```python
49
+ from synapse_layer import Synapse
50
+
51
+ s = Synapse(token="sk_connect_YOUR_TOKEN")
52
+
53
+ s.save("user likes coffee")
54
+ print(s.recall("what does user like?"))
55
+ ```
56
+
57
+ Get your token at [forge.synapselayer.org](https://forge.synapselayer.org) → Dashboard → Connect
58
+
59
+ ---
60
+
39
61
  ## Why Synapse?
40
62
 
41
63
  Superpowers proved agents need discipline. Synapse provides the **continuity layer** that makes that discipline persistent across sessions, tools, and handoffs.
@@ -45,7 +67,7 @@ Superpowers proved agents need discipline. Synapse provides the **continuity lay
45
67
  | Capability | Description |
46
68
  |---|---|
47
69
  | **State Continuity** | OAuth for AI Memory. Persistent context across sessions and models. |
48
- | **Privacy First** | Server never sees plaintext. AES-256-GCM client-side encryption. |
70
+ | **Privacy First** | Server never sees plaintext. AES-256-GCM encrypted at rest with per-operation random IV. |
49
71
  | **Agent-Native** | 30-second install. Built for the MCP ecosystem. |
50
72
  | **Cross-Agent** | Share memory between agents via A2A protocol. |
51
73
  | **Trust Quotient** | Weighted memory ranking: confidence, recency, and usage. |
@@ -163,7 +185,7 @@ recall_tool = SynapseRecallMemoryTool(api_key="your-key")
163
185
  | **Privacy** | Differential privacy via Gaussian noise on embeddings. |
164
186
  | **Validation** | Intent validation pipeline with confidence scoring. |
165
187
 
166
- > The server never sees plaintext. All sensitive data is encrypted before storage.
188
+ > Server never sees plaintext. All sensitive data is AES-256-GCM encrypted at rest with per-operation random IV. Designed for LGPD/GDPR alignment.
167
189
 
168
190
  ---
169
191
 
@@ -1,7 +1,9 @@
1
+ LICENSE
1
2
  README.md
2
3
  pyproject.toml
3
4
  synapse_layer/__init__.py
4
5
  synapse_layer/a2a_client.py
6
+ synapse_layer/client.py
5
7
  synapse_layer/crewai_tools.py
6
8
  synapse_layer/langchain_memory.py
7
9
  synapse_layer.egg-info/PKG-INFO
@@ -1,5 +1,6 @@
1
1
  requests>=2.25.0
2
2
  pydantic>=2.0.0
3
+ aiohttp>=3.8.0
3
4
 
4
5
  [crewai]
5
6
  crewai>=0.1.0
File without changes