spm-client 0.2.0__tar.gz → 0.3.2__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.
- spm_client-0.3.2/LICENSE +9 -0
- spm_client-0.3.2/LICENSE-HISTORY.md +28 -0
- spm_client-0.3.2/PKG-INFO +213 -0
- spm_client-0.3.2/README.md +183 -0
- spm_client-0.3.2/pyproject.toml +30 -0
- {spm_client-0.2.0 → spm_client-0.3.2}/spm_client/__init__.py +67 -149
- spm_client-0.3.2/spm_client/evidence.py +277 -0
- spm_client-0.3.2/spm_client/integrations.py +101 -0
- spm_client-0.3.2/spm_client/memory.py +1000 -0
- spm_client-0.3.2/spm_client.egg-info/PKG-INFO +213 -0
- {spm_client-0.2.0 → spm_client-0.3.2}/spm_client.egg-info/SOURCES.txt +6 -3
- spm_client-0.3.2/spm_client.egg-info/requires.txt +22 -0
- spm_client-0.2.0/PKG-INFO +0 -141
- spm_client-0.2.0/README.md +0 -123
- spm_client-0.2.0/pyproject.toml +0 -25
- spm_client-0.2.0/spm_client.egg-info/PKG-INFO +0 -141
- spm_client-0.2.0/spm_client.egg-info/requires.txt +0 -11
- spm_client-0.2.0/tests/test_client.py +0 -246
- spm_client-0.2.0/tests/test_memory_plane.py +0 -108
- {spm_client-0.2.0 → spm_client-0.3.2}/setup.cfg +0 -0
- {spm_client-0.2.0 → spm_client-0.3.2}/spm_client.egg-info/dependency_links.txt +0 -0
- {spm_client-0.2.0 → spm_client-0.3.2}/spm_client.egg-info/top_level.txt +0 -0
spm_client-0.3.2/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
SPM-Maverick
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Veridical Tech, Inc.
|
|
4
|
+
|
|
5
|
+
All Rights Reserved.
|
|
6
|
+
|
|
7
|
+
This release and all releases from 1.1.0rc2 onward are proprietary. No right
|
|
8
|
+
to use, copy, modify, publish, distribute, sublicense, or sell this software
|
|
9
|
+
is granted except by a separate written agreement with Veridical Tech, Inc.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# License History
|
|
2
|
+
|
|
3
|
+
The historical MIT license below applies to SPM-Maverick releases through
|
|
4
|
+
`1.1.0rc1`, inclusive. The grant for those releases is irrevocable and cannot be revoked. Releases beginning with `1.1.0rc2` are governed by the proprietary license in `LICENSE`.
|
|
5
|
+
|
|
6
|
+
## Historical MIT License (through 1.1.0rc1)
|
|
7
|
+
|
|
8
|
+
MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2026 Veridical Tech, Inc.
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: spm-client
|
|
3
|
+
Version: 0.3.2
|
|
4
|
+
Summary: SPM client: hosted memory plane (remember/recall/read/delete/status), request receipts, the OpenAI-compatible gateway, and offline verification of signed evidence.
|
|
5
|
+
Author: Veridical Tech, Inc.
|
|
6
|
+
License-Expression: LicenseRef-Proprietary
|
|
7
|
+
Requires-Python: >=3.9
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
License-File: LICENSE-HISTORY.md
|
|
11
|
+
Requires-Dist: httpx<1,>=0.27
|
|
12
|
+
Provides-Extra: evidence
|
|
13
|
+
Requires-Dist: cryptography<46,>=42; extra == "evidence"
|
|
14
|
+
Provides-Extra: integrations
|
|
15
|
+
Requires-Dist: openai<3,>=1; extra == "integrations"
|
|
16
|
+
Requires-Dist: anthropic<1,>=0.20; extra == "integrations"
|
|
17
|
+
Provides-Extra: test
|
|
18
|
+
Requires-Dist: pytest<10,>=8; extra == "test"
|
|
19
|
+
Requires-Dist: respx<1,>=0.21; extra == "test"
|
|
20
|
+
Requires-Dist: httpx<1,>=0.27; extra == "test"
|
|
21
|
+
Requires-Dist: cryptography<46,>=42; extra == "test"
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest<10,>=8; extra == "dev"
|
|
24
|
+
Requires-Dist: pytest-asyncio<2,>=0.24; extra == "dev"
|
|
25
|
+
Requires-Dist: respx<1,>=0.21; extra == "dev"
|
|
26
|
+
Requires-Dist: cryptography<46,>=42; extra == "dev"
|
|
27
|
+
Requires-Dist: openai<3,>=1; extra == "dev"
|
|
28
|
+
Requires-Dist: anthropic<1,>=0.20; extra == "dev"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# spm-client
|
|
32
|
+
|
|
33
|
+
Python client for SPM: the hosted memory plane, the OpenAI-compatible gateway,
|
|
34
|
+
and offline verification of the evidence handles a recall returns.
|
|
35
|
+
|
|
36
|
+
**Status**: pre-release. PyPI publishing waits on legal sign-off; install from a
|
|
37
|
+
checkout.
|
|
38
|
+
|
|
39
|
+
## Install
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install . # client only: remember/recall/read/delete/status,
|
|
43
|
+
# request receipts, gateway chat
|
|
44
|
+
pip install ".[evidence]" # + Ed25519 evidence verification (cryptography)
|
|
45
|
+
pip install -e . # editable, for development
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The only base runtime dependency is `httpx`. Install `spm-client[integrations]`
|
|
49
|
+
when using the official OpenAI or Anthropic drop-in helpers; those SDKs are
|
|
50
|
+
optional. `cryptography` is optional and needed only to verify an EdDSA handle.
|
|
51
|
+
|
|
52
|
+
## Memory plane
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
from spm_client import SPMMemoryClient, SPMConfig
|
|
56
|
+
|
|
57
|
+
with SPMMemoryClient(SPMConfig(api_key="spm_live_...")) as spm:
|
|
58
|
+
spm.remember(text="Ryan switched to lattes on 2026-09-15.",
|
|
59
|
+
idempotency_key="note-2026-09-20-a")
|
|
60
|
+
result = spm.recall("what does Ryan drink?")
|
|
61
|
+
print(result.answer, result.status)
|
|
62
|
+
if result.supported:
|
|
63
|
+
for span in spm.read([ref.read_token for ref in result.evidence]):
|
|
64
|
+
print(span)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`AsyncSPMMemoryClient` is the same surface with `await`. Both are context
|
|
68
|
+
managers. Failures raise `SPMError` with a stable `category`; retryable ones
|
|
69
|
+
carry `retry_after`.
|
|
70
|
+
|
|
71
|
+
## Owner control and hand-off
|
|
72
|
+
|
|
73
|
+
The same client also reaches the surfaces added in 2026-12:
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
spm.lesson_propose(text="Confirm delivery dates before quoting.", applies_to="deals")
|
|
77
|
+
spm.lesson_review(source_id="lesson_...", action="promote", note="checked")
|
|
78
|
+
spm.session_commit(session_id="s-1", summary="Quote review.", turns=[{"role": "user", "text": "..."}])
|
|
79
|
+
spm.session_distill(summary_source_id="sess_...", max_lessons=3)
|
|
80
|
+
spm.skill_apply(source_id="skill_...", inputs={"owner": "Wang"})
|
|
81
|
+
spm.delegate_key(scopes=["recall", "memory:partition"], team_id="team_...", ttl_seconds=600)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Also available: `lesson_list`, `skill_list`, `skill_create`, `skill_publish`,
|
|
85
|
+
`team_list`, `team_create`, `team_add_member`, `team_add_partition`,
|
|
86
|
+
`agent_heartbeat`, `agent_list`, `artifact_add`, `case_timeline`, `usage`.
|
|
87
|
+
They need the matching key scopes (read, write, audit or usage).
|
|
88
|
+
|
|
89
|
+
The REST data plane has helpers for the endpoints the MCP tools do not cover:
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
spm.list_sources(state="active") # lifecycle state and capture origin
|
|
93
|
+
spm.edit_source("src-1", text="corrected") # previous body stays a version
|
|
94
|
+
spm.feedback("src-1", useful=True)
|
|
95
|
+
spm.export_partition("deals")
|
|
96
|
+
spm.import_bundle(bundle)
|
|
97
|
+
spm.wipe_partition("deals")
|
|
98
|
+
spm.subscribe_events("https://hooks.example/spm", ["recall"])
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
`GET /v2/sources` reports `origin` (`proxy`, `ingest`, `mcp`). An existing but
|
|
102
|
+
empty partition answers `424 PARTITION_EMPTY`; `424 NO_READY_EVIDENCE` means
|
|
103
|
+
extraction is unfinished.
|
|
104
|
+
|
|
105
|
+
## Gateway (chat)
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from spm_client import SpmClient
|
|
109
|
+
|
|
110
|
+
with SpmClient("your-api-key", base_url="https://api.spmos.ai") as client:
|
|
111
|
+
session = client.session()
|
|
112
|
+
print(session.send("Hello, remember my name is Alice."))
|
|
113
|
+
print(session.send("What's my name?")) # session history is automatic
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Streaming, receipts (`client.list_receipts()`, `client.get_receipt(id)`) and the
|
|
117
|
+
typed error hierarchy (`AuthError`, `QuotaError`, `NotFoundError`,
|
|
118
|
+
`ServerError`, base `SpmError`) are covered in `examples/`.
|
|
119
|
+
|
|
120
|
+
## Drop-in OpenAI / Anthropic clients
|
|
121
|
+
|
|
122
|
+
Install the optional integration dependencies:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
pip install ".[integrations]"
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
OpenAI:
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
from openai import OpenAI
|
|
132
|
+
from spm_client import patch_openai
|
|
133
|
+
|
|
134
|
+
client = patch_openai(
|
|
135
|
+
OpenAI(api_key="sk-upstream"),
|
|
136
|
+
api_key="spm_live_...",
|
|
137
|
+
base_url="https://api.spmos.ai",
|
|
138
|
+
)
|
|
139
|
+
reply = client.chat.completions.create(
|
|
140
|
+
model="your-configured-model",
|
|
141
|
+
messages=[{"role": "user", "content": "Hello"}],
|
|
142
|
+
)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Anthropic:
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
from anthropic import Anthropic
|
|
149
|
+
from spm_client import patch_anthropic
|
|
150
|
+
|
|
151
|
+
client = patch_anthropic(
|
|
152
|
+
Anthropic(api_key="sk-ant-upstream"),
|
|
153
|
+
api_key="spm_live_...",
|
|
154
|
+
base_url="https://api.spmos.ai",
|
|
155
|
+
)
|
|
156
|
+
reply = client.messages.create(
|
|
157
|
+
model="your-configured-model",
|
|
158
|
+
max_tokens=256,
|
|
159
|
+
messages=[{"role": "user", "content": "Hello"}],
|
|
160
|
+
)
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
The helpers update the official SDK's actual HTTP transport, not only public
|
|
164
|
+
attributes: requests go to SPM's `/v1/chat/completions` or `/v1/messages` and
|
|
165
|
+
use the SPM key. The upstream provider key is replaced for that client object;
|
|
166
|
+
keep it only when you need to construct the client before patching, and never
|
|
167
|
+
commit either credential.
|
|
168
|
+
|
|
169
|
+
An explicit SPM key is required whenever a helper changes `base_url`; the
|
|
170
|
+
helper will not silently forward an upstream credential to SPM. OpenAI URLs
|
|
171
|
+
are normalized idempotently, so both `https://api.spmos.ai` and
|
|
172
|
+
`https://api.spmos.ai/v1` are accepted.
|
|
173
|
+
|
|
174
|
+
For a one-line OpenAI client, set `SPM_API_KEY` and `SPM_GATEWAY_URL`, then call
|
|
175
|
+
`spm_client.auto()`. The helper validates environment variables before importing
|
|
176
|
+
the optional OpenAI dependency and gives an actionable install error.
|
|
177
|
+
|
|
178
|
+
## Verify an evidence handle offline
|
|
179
|
+
|
|
180
|
+
```python
|
|
181
|
+
import requests
|
|
182
|
+
from spm_client import verify_evidence_token
|
|
183
|
+
|
|
184
|
+
keys = {
|
|
185
|
+
key["kid"]: key["x"]
|
|
186
|
+
for key in requests.get(
|
|
187
|
+
"https://api.spmos.ai/.well-known/spm-evidence-keys.json", timeout=10
|
|
188
|
+
).json()["keys"]
|
|
189
|
+
}
|
|
190
|
+
verified = verify_evidence_token(ref.read_token, public_keys=keys)
|
|
191
|
+
assert verified.source_id == ref.source_id
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Verification needs no credential and no call back to the server that minted the
|
|
195
|
+
handle. See [Evidence verification](https://docs.spmos.ai/python-sdk#verification)
|
|
196
|
+
for what it does and does not prove.
|
|
197
|
+
|
|
198
|
+
## Two error bases
|
|
199
|
+
|
|
200
|
+
`SPMError` (memory plane) and `SpmError` (gateway client) are unrelated
|
|
201
|
+
classes; import the one you mean.
|
|
202
|
+
|
|
203
|
+
## Tests
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
pip install ".[dev]"
|
|
207
|
+
python -m pytest client_tests -q
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
The client's own directory is named `client_tests` rather than `tests` on
|
|
211
|
+
purpose: the private repository that builds this client already has a `tests`
|
|
212
|
+
namespace, and a second `tests` package inside a directory that goes on
|
|
213
|
+
`sys.path` shadows it. CI runs the same command on push.
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# spm-client
|
|
2
|
+
|
|
3
|
+
Python client for SPM: the hosted memory plane, the OpenAI-compatible gateway,
|
|
4
|
+
and offline verification of the evidence handles a recall returns.
|
|
5
|
+
|
|
6
|
+
**Status**: pre-release. PyPI publishing waits on legal sign-off; install from a
|
|
7
|
+
checkout.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install . # client only: remember/recall/read/delete/status,
|
|
13
|
+
# request receipts, gateway chat
|
|
14
|
+
pip install ".[evidence]" # + Ed25519 evidence verification (cryptography)
|
|
15
|
+
pip install -e . # editable, for development
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The only base runtime dependency is `httpx`. Install `spm-client[integrations]`
|
|
19
|
+
when using the official OpenAI or Anthropic drop-in helpers; those SDKs are
|
|
20
|
+
optional. `cryptography` is optional and needed only to verify an EdDSA handle.
|
|
21
|
+
|
|
22
|
+
## Memory plane
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from spm_client import SPMMemoryClient, SPMConfig
|
|
26
|
+
|
|
27
|
+
with SPMMemoryClient(SPMConfig(api_key="spm_live_...")) as spm:
|
|
28
|
+
spm.remember(text="Ryan switched to lattes on 2026-09-15.",
|
|
29
|
+
idempotency_key="note-2026-09-20-a")
|
|
30
|
+
result = spm.recall("what does Ryan drink?")
|
|
31
|
+
print(result.answer, result.status)
|
|
32
|
+
if result.supported:
|
|
33
|
+
for span in spm.read([ref.read_token for ref in result.evidence]):
|
|
34
|
+
print(span)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`AsyncSPMMemoryClient` is the same surface with `await`. Both are context
|
|
38
|
+
managers. Failures raise `SPMError` with a stable `category`; retryable ones
|
|
39
|
+
carry `retry_after`.
|
|
40
|
+
|
|
41
|
+
## Owner control and hand-off
|
|
42
|
+
|
|
43
|
+
The same client also reaches the surfaces added in 2026-12:
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
spm.lesson_propose(text="Confirm delivery dates before quoting.", applies_to="deals")
|
|
47
|
+
spm.lesson_review(source_id="lesson_...", action="promote", note="checked")
|
|
48
|
+
spm.session_commit(session_id="s-1", summary="Quote review.", turns=[{"role": "user", "text": "..."}])
|
|
49
|
+
spm.session_distill(summary_source_id="sess_...", max_lessons=3)
|
|
50
|
+
spm.skill_apply(source_id="skill_...", inputs={"owner": "Wang"})
|
|
51
|
+
spm.delegate_key(scopes=["recall", "memory:partition"], team_id="team_...", ttl_seconds=600)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Also available: `lesson_list`, `skill_list`, `skill_create`, `skill_publish`,
|
|
55
|
+
`team_list`, `team_create`, `team_add_member`, `team_add_partition`,
|
|
56
|
+
`agent_heartbeat`, `agent_list`, `artifact_add`, `case_timeline`, `usage`.
|
|
57
|
+
They need the matching key scopes (read, write, audit or usage).
|
|
58
|
+
|
|
59
|
+
The REST data plane has helpers for the endpoints the MCP tools do not cover:
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
spm.list_sources(state="active") # lifecycle state and capture origin
|
|
63
|
+
spm.edit_source("src-1", text="corrected") # previous body stays a version
|
|
64
|
+
spm.feedback("src-1", useful=True)
|
|
65
|
+
spm.export_partition("deals")
|
|
66
|
+
spm.import_bundle(bundle)
|
|
67
|
+
spm.wipe_partition("deals")
|
|
68
|
+
spm.subscribe_events("https://hooks.example/spm", ["recall"])
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
`GET /v2/sources` reports `origin` (`proxy`, `ingest`, `mcp`). An existing but
|
|
72
|
+
empty partition answers `424 PARTITION_EMPTY`; `424 NO_READY_EVIDENCE` means
|
|
73
|
+
extraction is unfinished.
|
|
74
|
+
|
|
75
|
+
## Gateway (chat)
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from spm_client import SpmClient
|
|
79
|
+
|
|
80
|
+
with SpmClient("your-api-key", base_url="https://api.spmos.ai") as client:
|
|
81
|
+
session = client.session()
|
|
82
|
+
print(session.send("Hello, remember my name is Alice."))
|
|
83
|
+
print(session.send("What's my name?")) # session history is automatic
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Streaming, receipts (`client.list_receipts()`, `client.get_receipt(id)`) and the
|
|
87
|
+
typed error hierarchy (`AuthError`, `QuotaError`, `NotFoundError`,
|
|
88
|
+
`ServerError`, base `SpmError`) are covered in `examples/`.
|
|
89
|
+
|
|
90
|
+
## Drop-in OpenAI / Anthropic clients
|
|
91
|
+
|
|
92
|
+
Install the optional integration dependencies:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
pip install ".[integrations]"
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
OpenAI:
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
from openai import OpenAI
|
|
102
|
+
from spm_client import patch_openai
|
|
103
|
+
|
|
104
|
+
client = patch_openai(
|
|
105
|
+
OpenAI(api_key="sk-upstream"),
|
|
106
|
+
api_key="spm_live_...",
|
|
107
|
+
base_url="https://api.spmos.ai",
|
|
108
|
+
)
|
|
109
|
+
reply = client.chat.completions.create(
|
|
110
|
+
model="your-configured-model",
|
|
111
|
+
messages=[{"role": "user", "content": "Hello"}],
|
|
112
|
+
)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Anthropic:
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
from anthropic import Anthropic
|
|
119
|
+
from spm_client import patch_anthropic
|
|
120
|
+
|
|
121
|
+
client = patch_anthropic(
|
|
122
|
+
Anthropic(api_key="sk-ant-upstream"),
|
|
123
|
+
api_key="spm_live_...",
|
|
124
|
+
base_url="https://api.spmos.ai",
|
|
125
|
+
)
|
|
126
|
+
reply = client.messages.create(
|
|
127
|
+
model="your-configured-model",
|
|
128
|
+
max_tokens=256,
|
|
129
|
+
messages=[{"role": "user", "content": "Hello"}],
|
|
130
|
+
)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
The helpers update the official SDK's actual HTTP transport, not only public
|
|
134
|
+
attributes: requests go to SPM's `/v1/chat/completions` or `/v1/messages` and
|
|
135
|
+
use the SPM key. The upstream provider key is replaced for that client object;
|
|
136
|
+
keep it only when you need to construct the client before patching, and never
|
|
137
|
+
commit either credential.
|
|
138
|
+
|
|
139
|
+
An explicit SPM key is required whenever a helper changes `base_url`; the
|
|
140
|
+
helper will not silently forward an upstream credential to SPM. OpenAI URLs
|
|
141
|
+
are normalized idempotently, so both `https://api.spmos.ai` and
|
|
142
|
+
`https://api.spmos.ai/v1` are accepted.
|
|
143
|
+
|
|
144
|
+
For a one-line OpenAI client, set `SPM_API_KEY` and `SPM_GATEWAY_URL`, then call
|
|
145
|
+
`spm_client.auto()`. The helper validates environment variables before importing
|
|
146
|
+
the optional OpenAI dependency and gives an actionable install error.
|
|
147
|
+
|
|
148
|
+
## Verify an evidence handle offline
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
import requests
|
|
152
|
+
from spm_client import verify_evidence_token
|
|
153
|
+
|
|
154
|
+
keys = {
|
|
155
|
+
key["kid"]: key["x"]
|
|
156
|
+
for key in requests.get(
|
|
157
|
+
"https://api.spmos.ai/.well-known/spm-evidence-keys.json", timeout=10
|
|
158
|
+
).json()["keys"]
|
|
159
|
+
}
|
|
160
|
+
verified = verify_evidence_token(ref.read_token, public_keys=keys)
|
|
161
|
+
assert verified.source_id == ref.source_id
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Verification needs no credential and no call back to the server that minted the
|
|
165
|
+
handle. See [Evidence verification](https://docs.spmos.ai/python-sdk#verification)
|
|
166
|
+
for what it does and does not prove.
|
|
167
|
+
|
|
168
|
+
## Two error bases
|
|
169
|
+
|
|
170
|
+
`SPMError` (memory plane) and `SpmError` (gateway client) are unrelated
|
|
171
|
+
classes; import the one you mean.
|
|
172
|
+
|
|
173
|
+
## Tests
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
pip install ".[dev]"
|
|
177
|
+
python -m pytest client_tests -q
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
The client's own directory is named `client_tests` rather than `tests` on
|
|
181
|
+
purpose: the private repository that builds this client already has a `tests`
|
|
182
|
+
namespace, and a second `tests` package inside a directory that goes on
|
|
183
|
+
`sys.path` shadows it. CI runs the same command on push.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "spm-client"
|
|
7
|
+
version = "0.3.2"
|
|
8
|
+
description = "SPM client: hosted memory plane (remember/recall/read/delete/status), request receipts, the OpenAI-compatible gateway, and offline verification of signed evidence."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "LicenseRef-Proprietary"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Veridical Tech, Inc." },
|
|
14
|
+
]
|
|
15
|
+
dependencies = [
|
|
16
|
+
"httpx>=0.27,<1",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[project.optional-dependencies]
|
|
20
|
+
# Verifying an Ed25519 evidence handle offline needs a verifier. It is optional
|
|
21
|
+
# on purpose: the client itself only needs httpx, and an HS256 handle is
|
|
22
|
+
# verifiable with the stdlib alone.
|
|
23
|
+
evidence = ["cryptography>=42,<46"]
|
|
24
|
+
integrations = ["openai>=1,<3", "anthropic>=0.20,<1"]
|
|
25
|
+
test = ["pytest>=8,<10", "respx>=0.21,<1", "httpx>=0.27,<1", "cryptography>=42,<46"]
|
|
26
|
+
dev = ["pytest>=8,<10", "pytest-asyncio>=0.24,<2", "respx>=0.21,<1", "cryptography>=42,<46", "openai>=1,<3", "anthropic>=0.20,<1"]
|
|
27
|
+
|
|
28
|
+
[tool.setuptools.packages.find]
|
|
29
|
+
where = ["."]
|
|
30
|
+
include = ["spm_client*"]
|