bridgemem 0.1.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.
bridgemem/__init__.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"""Official zero-dependency Python client SDK for BridgeMem nodes (https://bridgemem.com)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import urllib.error
|
|
7
|
+
import urllib.request
|
|
8
|
+
from dataclasses import dataclass
|
|
9
|
+
from typing import Any, Dict, Optional
|
|
10
|
+
|
|
11
|
+
__all__ = ["BridgeMemClient", "BridgeMemError", "__version__"]
|
|
12
|
+
__version__ = "0.1.0"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class BridgeMemError(RuntimeError):
|
|
16
|
+
"""Raised when a BridgeMem HTTP or MCP call returns an error."""
|
|
17
|
+
|
|
18
|
+
def __init__(self, status: int, message: str) -> None:
|
|
19
|
+
super().__init__(f"BridgeMem HTTP {status}: {message}")
|
|
20
|
+
self.status = status
|
|
21
|
+
self.message = message
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@dataclass
|
|
25
|
+
class BridgeMemClient:
|
|
26
|
+
"""Lightweight stdlib-only HTTP & MCP JSON-RPC client for a BridgeMem Gate."""
|
|
27
|
+
|
|
28
|
+
endpoint: str = "http://127.0.0.1:8508"
|
|
29
|
+
bearer_token: Optional[str] = None
|
|
30
|
+
timeout_sec: float = 10.0
|
|
31
|
+
|
|
32
|
+
def _request(self, method: str, path: str, payload: Optional[Dict[str, Any]] = None) -> Any:
|
|
33
|
+
url = f"{self.endpoint.rstrip('/')}/{path.lstrip('/')}"
|
|
34
|
+
headers = {"Accept": "application/json"}
|
|
35
|
+
if self.bearer_token:
|
|
36
|
+
headers["Authorization"] = f"Bearer {self.bearer_token.strip()}"
|
|
37
|
+
raw = None
|
|
38
|
+
if payload is not None:
|
|
39
|
+
raw = json.dumps(payload).encode("utf-8")
|
|
40
|
+
headers["Content-Type"] = "application/json"
|
|
41
|
+
req = urllib.request.Request(url, data=raw, headers=headers, method=method)
|
|
42
|
+
try:
|
|
43
|
+
with urllib.request.urlopen(req, timeout=self.timeout_sec) as resp:
|
|
44
|
+
body = resp.read().decode("utf-8", errors="replace")
|
|
45
|
+
return json.loads(body) if body else {}
|
|
46
|
+
except urllib.error.HTTPError as exc:
|
|
47
|
+
detail = exc.read().decode("utf-8", errors="replace")
|
|
48
|
+
raise BridgeMemError(exc.code, detail) from exc
|
|
49
|
+
|
|
50
|
+
def health(self) -> Any:
|
|
51
|
+
return self._request("GET", "/healthz")
|
|
52
|
+
|
|
53
|
+
def search(self, section_id: str, query: str, top_k: int = 8) -> Any:
|
|
54
|
+
return self._request(
|
|
55
|
+
"POST",
|
|
56
|
+
"/api/v1/search",
|
|
57
|
+
{"section_id": section_id, "query": query, "top_k": max(1, min(100, int(top_k)))},
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
def mcp_list_tools(self) -> Any:
|
|
61
|
+
return self._request("POST", "/mcp", {"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}})
|
|
62
|
+
|
|
63
|
+
def mcp_call_tool(self, name: str, arguments: Optional[Dict[str, Any]] = None) -> Any:
|
|
64
|
+
return self._request(
|
|
65
|
+
"POST",
|
|
66
|
+
"/mcp",
|
|
67
|
+
{
|
|
68
|
+
"jsonrpc": "2.0",
|
|
69
|
+
"id": 2,
|
|
70
|
+
"method": "tools/call",
|
|
71
|
+
"params": {"name": name, "arguments": arguments or {}},
|
|
72
|
+
},
|
|
73
|
+
)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bridgemem
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official lightweight HTTP and Model Context Protocol (MCP) Python client SDK for BridgeMem autonomous AI memory nodes.
|
|
5
|
+
Author-email: BridgeMem <ccaiuss@gmail.com>
|
|
6
|
+
License-Expression: MIT OR Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://bridgemem.com
|
|
8
|
+
Project-URL: Documentation, https://bridgemem.org
|
|
9
|
+
Project-URL: Repository, https://github.com/bridgemem/bridgemem-py
|
|
10
|
+
Keywords: bridgemem,mcp,ai,memory,rag,zero-knowledge
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Topic :: Database
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
16
|
+
Requires-Python: >=3.9
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# BridgeMem Python SDK (`bridgemem`)
|
|
22
|
+
|
|
23
|
+
Official zero-dependency Python client for **BridgeMem** autonomous organizational memory and Zero-Knowledge AI vaults (`https://bridgemem.com` | specification at `https://bridgemem.org`).
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install bridgemem
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
from bridgemem import BridgeMemClient
|
|
35
|
+
|
|
36
|
+
client = BridgeMemClient("http://127.0.0.1:8508", bearer_token="brk_example_key")
|
|
37
|
+
print(client.search(section_id="default", query="invoice retention policy"))
|
|
38
|
+
```
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
bridgemem/__init__.py,sha256=b-FOuuKRg11jGTdR4NkiFHiyOQfmDl4ucKsxiS5knKQ,2682
|
|
2
|
+
bridgemem-0.1.0.dist-info/licenses/LICENSE,sha256=-iAn2A2er0Xf0yzlGL3MYJgSmP1tjQEkCh4xb2Dj82M,1066
|
|
3
|
+
bridgemem-0.1.0.dist-info/METADATA,sha256=w9kkbbsfrCHxlLKqIYot2Apfxl9F4-9GUv9LLJPCFAU,1330
|
|
4
|
+
bridgemem-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
5
|
+
bridgemem-0.1.0.dist-info/top_level.txt,sha256=FFjy4biuQPxW0i9bcKywvCP4ARI0Eejiz7_C1bP3veg,10
|
|
6
|
+
bridgemem-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 BridgeMem
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bridgemem
|