densemem 2.6.6rc12__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.
- densemem-2.6.6rc12/.gitignore +70 -0
- densemem-2.6.6rc12/LICENSE +201 -0
- densemem-2.6.6rc12/PKG-INFO +188 -0
- densemem-2.6.6rc12/README.md +167 -0
- densemem-2.6.6rc12/examples/remember.py +46 -0
- densemem-2.6.6rc12/examples/session.py +34 -0
- densemem-2.6.6rc12/pyproject.toml +49 -0
- densemem-2.6.6rc12/requirements-dev.txt +11 -0
- densemem-2.6.6rc12/scripts/check.sh +92 -0
- densemem-2.6.6rc12/scripts/e2e.sh +19 -0
- densemem-2.6.6rc12/scripts/matrix.sh +41 -0
- densemem-2.6.6rc12/scripts/release.py +198 -0
- densemem-2.6.6rc12/src/densemem/__init__.py +44 -0
- densemem-2.6.6rc12/src/densemem/client.py +310 -0
- densemem-2.6.6rc12/src/densemem/errors.py +68 -0
- densemem-2.6.6rc12/src/densemem/py.typed +0 -0
- densemem-2.6.6rc12/src/densemem/requests.py +115 -0
- densemem-2.6.6rc12/src/densemem/results.py +112 -0
- densemem-2.6.6rc12/tests/conftest.py +118 -0
- densemem-2.6.6rc12/tests/e2e.py +380 -0
- densemem-2.6.6rc12/tests/e2e_support.py +246 -0
- densemem-2.6.6rc12/tests/test_release.py +237 -0
- densemem-2.6.6rc12/tests/test_transport.py +349 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Dependencies
|
|
2
|
+
node_modules/
|
|
3
|
+
bun.lockb
|
|
4
|
+
|
|
5
|
+
# Build outputs
|
|
6
|
+
dist/
|
|
7
|
+
build/
|
|
8
|
+
user-dist/
|
|
9
|
+
*.tsbuildinfo
|
|
10
|
+
|
|
11
|
+
# Environment files
|
|
12
|
+
.env
|
|
13
|
+
.env.local
|
|
14
|
+
.env.*.local
|
|
15
|
+
# Local Docker Compose overrides
|
|
16
|
+
docker-compose.override.yml
|
|
17
|
+
|
|
18
|
+
# IDE
|
|
19
|
+
.vscode/
|
|
20
|
+
.idea/
|
|
21
|
+
*.swp
|
|
22
|
+
*.swo
|
|
23
|
+
|
|
24
|
+
# OS
|
|
25
|
+
.DS_Store
|
|
26
|
+
Thumbs.db
|
|
27
|
+
|
|
28
|
+
# Logs
|
|
29
|
+
logs/
|
|
30
|
+
*.log
|
|
31
|
+
npm-debug.log*
|
|
32
|
+
bun-debug.log*
|
|
33
|
+
|
|
34
|
+
# Test
|
|
35
|
+
coverage/
|
|
36
|
+
coverage.out
|
|
37
|
+
.nyc_output/
|
|
38
|
+
tests/uat/test-results/
|
|
39
|
+
tests/uat/playwright-report/
|
|
40
|
+
web/test-results/
|
|
41
|
+
web/playwright-report/
|
|
42
|
+
|
|
43
|
+
# Temporary
|
|
44
|
+
tmp/
|
|
45
|
+
temp/
|
|
46
|
+
*.tmp
|
|
47
|
+
|
|
48
|
+
# VCP
|
|
49
|
+
.vcp
|
|
50
|
+
|
|
51
|
+
# Claude Code local state
|
|
52
|
+
.claude/scheduled_tasks.lock
|
|
53
|
+
.claude/settings.local.json
|
|
54
|
+
|
|
55
|
+
# Editor backups
|
|
56
|
+
*.bak
|
|
57
|
+
telemetry-scrape-token
|
|
58
|
+
prometheus.yml
|
|
59
|
+
# Codex local state and credentials; only the staging-test workflow is shared.
|
|
60
|
+
.codex/*
|
|
61
|
+
.claude
|
|
62
|
+
.mcp.json
|
|
63
|
+
# Python package development and validation
|
|
64
|
+
__pycache__/
|
|
65
|
+
*.py[cod]
|
|
66
|
+
*.egg-info/
|
|
67
|
+
.venv/
|
|
68
|
+
.pytest_cache/
|
|
69
|
+
.mypy_cache/
|
|
70
|
+
.ruff_cache/
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: densemem
|
|
3
|
+
Version: 2.6.6rc12
|
|
4
|
+
Summary: Typed async and sync clients for Dense-Mem MCP
|
|
5
|
+
Project-URL: Source, https://github.com/markhuangai/dense-mem/tree/fbca1dc3969b8e49078dcd67a0b6f368d137995e
|
|
6
|
+
Project-URL: Repository, https://github.com/markhuangai/dense-mem
|
|
7
|
+
Project-URL: Documentation, https://github.com/markhuangai/dense-mem/wiki/Framework-Integrations
|
|
8
|
+
Project-URL: Issues, https://github.com/markhuangai/dense-mem/issues
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Classifier: Typing :: Typed
|
|
17
|
+
Requires-Python: <3.15,>=3.11
|
|
18
|
+
Requires-Dist: httpx<1,>=0.28.1
|
|
19
|
+
Requires-Dist: mcp<2,>=1.30.0
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# densemem Python client
|
|
23
|
+
|
|
24
|
+
The Dense-Mem Python core client uses the official MCP SDK. It supports Python
|
|
25
|
+
3.11–3.14 and MCP SDK 1.30 through the compatible 1.x line. This package is being
|
|
26
|
+
prepared for release; PyPI publication is pending. Install a verified wheel:
|
|
27
|
+
|
|
28
|
+
~~~bash
|
|
29
|
+
python -m pip install /path/to/densemem-VERSION-py3-none-any.whl
|
|
30
|
+
~~~
|
|
31
|
+
|
|
32
|
+
ADK and LangChain adapters/extras will arrive with issues #220 and #221.
|
|
33
|
+
The core installs neither framework.
|
|
34
|
+
|
|
35
|
+
## Authentication and operations
|
|
36
|
+
|
|
37
|
+
~~~python
|
|
38
|
+
from densemem import DenseMemClient
|
|
39
|
+
|
|
40
|
+
client = DenseMemClient("https://memory.example.com/teams/TEAM_UUID/mcp", token=api_key)
|
|
41
|
+
tools = await client.list_tools()
|
|
42
|
+
~~~
|
|
43
|
+
|
|
44
|
+
Pass exactly one of token or token_provider. A provider is an async callable
|
|
45
|
+
returning a caller-owned access token. The client resolves it once per operation;
|
|
46
|
+
it does not acquire or refresh OAuth credentials. Use an authenticated team URL
|
|
47
|
+
or /mcp. Credentials belong only in the bearer header, never the URL. Configure
|
|
48
|
+
transport trust through the environment's certificate store when using a private CA.
|
|
49
|
+
|
|
50
|
+
Each call owns its SDK session, initialization and transport cleanup. The default
|
|
51
|
+
190-second total deadline allows the server's bounded 180-second write processing.
|
|
52
|
+
A shorter positive finite timeout is supported through the timeout constructor
|
|
53
|
+
argument. The synchronous SyncDenseMemClient exposes the same methods and rejects
|
|
54
|
+
use inside an active event loop.
|
|
55
|
+
|
|
56
|
+
Methods are initialize, list_tools, remember, ingest_session, recall_memory and
|
|
57
|
+
trace_memory. Requests/results are typed dictionaries with py.typed. Server
|
|
58
|
+
validation and authenticated discovery remain authoritative. Current-server
|
|
59
|
+
compatibility is dense-mem.v2.6.8, including server-supported historical terminal
|
|
60
|
+
replay versions; this does not promise compatibility with older deployments.
|
|
61
|
+
|
|
62
|
+
## Complete Remember request and safe replay
|
|
63
|
+
|
|
64
|
+
~~~python
|
|
65
|
+
from densemem import RememberRequest
|
|
66
|
+
|
|
67
|
+
request: RememberRequest = {
|
|
68
|
+
"idempotency_key": retained_operation_key,
|
|
69
|
+
"evidence": [
|
|
70
|
+
{
|
|
71
|
+
"content": "Dense-Mem stores durable memory in PostgreSQL.",
|
|
72
|
+
"source_type": "manual",
|
|
73
|
+
"source": "Python core example",
|
|
74
|
+
"metadata": {"origin": "python-example"},
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
"relationships": [
|
|
78
|
+
{
|
|
79
|
+
"ref": "durable-store",
|
|
80
|
+
"subject": {"name": "Dense-Mem", "entity_kind": "project"},
|
|
81
|
+
"predicate": {"proposed_key": "stores_durable_memory_in"},
|
|
82
|
+
"object": {"entity": {"name": "PostgreSQL", "entity_kind": "product"}},
|
|
83
|
+
"polarity": "+",
|
|
84
|
+
"evidence_indices": [0],
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
}
|
|
88
|
+
result = await client.remember(request)
|
|
89
|
+
~~~
|
|
90
|
+
|
|
91
|
+
Create the operation key once for a deliberate new operation, and retain this
|
|
92
|
+
entire request before sending it. For a replay, resend this unchanged request,
|
|
93
|
+
including metadata and key. Never rotate a key to bypass a conflict. The client
|
|
94
|
+
never retries automatically or fills in keys/defaults. Remember requires at least
|
|
95
|
+
one proposal citing every evidence item. The client does not infer Relationships.
|
|
96
|
+
|
|
97
|
+
Inspect evidence and relationship_results: completed processing can include
|
|
98
|
+
not_stored proposals and remediation. Returned warnings remain visible. Recall
|
|
99
|
+
results preserve server order, equivalent IDs, conflicts, topic communities,
|
|
100
|
+
hypotheses, provenance, search states and degradations. These frontiers do not
|
|
101
|
+
establish new factual support. Trace requires a returned relationship_id.
|
|
102
|
+
|
|
103
|
+
## Exact private session ingestion
|
|
104
|
+
|
|
105
|
+
~~~python
|
|
106
|
+
from densemem import SessionRequest
|
|
107
|
+
|
|
108
|
+
request: SessionRequest = {
|
|
109
|
+
"idempotency_key": retained_session_operation_key,
|
|
110
|
+
"framework": "generic",
|
|
111
|
+
"app_name": "python-example",
|
|
112
|
+
"user_id": "external-user-1",
|
|
113
|
+
"session_id": "session-1",
|
|
114
|
+
"events": [
|
|
115
|
+
{
|
|
116
|
+
"event_id": "user-event-1",
|
|
117
|
+
"text": " Ari uses Go. café 🧭\n",
|
|
118
|
+
"occurred_at": "2026-10-11T12:00:00Z",
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
}
|
|
122
|
+
result = await client.ingest_session(request)
|
|
123
|
+
~~~
|
|
124
|
+
|
|
125
|
+
Send only exact user-authored events. Event IDs/text/timestamps are immutable;
|
|
126
|
+
the server owns chunking and extraction. External identifiers are provenance,
|
|
127
|
+
never authorization or private-space selection. The server must enable session
|
|
128
|
+
ingestion and the credential must have a writable private binding; discovery
|
|
129
|
+
hides unavailable tools. Remember retains its separate proposal requirements.
|
|
130
|
+
Session semantic acceptance is atomic across the request. A no-fact completed
|
|
131
|
+
result with search_state not_required is valid.
|
|
132
|
+
|
|
133
|
+
## Failures and unknown outcomes
|
|
134
|
+
|
|
135
|
+
DenseMemAuthenticationError reports token acquisition or HTTP 401/403 failures.
|
|
136
|
+
DenseMemTransportError reports network/HTTP failure. DenseMemProtocolError
|
|
137
|
+
reports MCP/response failure. DenseMemOperationError preserves actionable public
|
|
138
|
+
errors and failed receipts in result, with code, reason_code, retryable,
|
|
139
|
+
next_action, remediation, correlation_id and submission_id when returned.
|
|
140
|
+
DenseMemTimeoutError reports deadlines. DenseMemCancelledError subclasses
|
|
141
|
+
asyncio.CancelledError and preserves a returned cancellation receipt if present.
|
|
142
|
+
|
|
143
|
+
A local timeout, disconnect or cancellation can lose a response after a commit.
|
|
144
|
+
An absent receipt means unknown outcome, not a fabricated failed submission.
|
|
145
|
+
Recovery uses only the unchanged original request/key. There is no polling,
|
|
146
|
+
status tool, background readiness loop or automatic new-key recovery.
|
|
147
|
+
|
|
148
|
+
SDK 1.30 negotiates protocol 2025-11-25. Local cancellation closes the client's
|
|
149
|
+
resources; the server can continue processing under this older protocol and may
|
|
150
|
+
commit or reach its bounded deadline. Cancellation does not prove that a write
|
|
151
|
+
was prevented. Retain the unchanged request/key for recovery.
|
|
152
|
+
|
|
153
|
+
## Development and release
|
|
154
|
+
|
|
155
|
+
Run packages/python/scripts/check.sh for lint/type/async tests, installed-wheel
|
|
156
|
+
checks, reproducible wheel/sdist builds, vulnerability scanning and SBOM. Run
|
|
157
|
+
packages/python/scripts/matrix.sh with a new output directory for the Python
|
|
158
|
+
version matrix, and scripts/e2e.sh python_client for real server boundaries.
|
|
159
|
+
The example scripts require DENSEMEM_ENDPOINT, DENSEMEM_TOKEN and a retained
|
|
160
|
+
DENSEMEM_OPERATION_KEY. Keep the exact request unchanged when rerunning them.
|
|
161
|
+
|
|
162
|
+
The server prerelease and stable-release workflows call publish-python to build
|
|
163
|
+
and verify artifacts after their release gates pass, then upload through their own
|
|
164
|
+
top-level publishing jobs. Manual recovery uploads directly from publish-python;
|
|
165
|
+
the reusable invocation never uploads to PyPI. Only tags whose exact source belongs
|
|
166
|
+
to merged main are eligible;
|
|
167
|
+
PR branches cannot publish. Python shares the server release version: v2.6.6-rc.10
|
|
168
|
+
becomes 2.6.6rc10 and v2.6.6 becomes 2.6.6. The checkout's 0.0.0 version is for local
|
|
169
|
+
development; release builds stamp the selected tag's version and exact Source URL
|
|
170
|
+
into artifact metadata without changing Git history.
|
|
171
|
+
|
|
172
|
+
Change detection compares packages/python with the last successfully published
|
|
173
|
+
Python source recorded on PyPI. Unchanged prereleases are skipped, and publishing
|
|
174
|
+
a final version after a Python RC does not require another code change. Incomplete
|
|
175
|
+
uploads remain eligible; retries verify every existing artifact's SHA-256 before
|
|
176
|
+
uploading missing files. The manual publish-python workflow accepts the same shared
|
|
177
|
+
tag for recovery. Never overwrite an existing version or silently accept different
|
|
178
|
+
bytes; a broken prerelease may be yanked through a separate maintainer action.
|
|
179
|
+
|
|
180
|
+
Verify control of the densemem PyPI name and register trusted publishers for
|
|
181
|
+
markhuangai/dense-mem, workflows release-rc.yml, release.yml and publish-python.yml,
|
|
182
|
+
each with environment pypi. For a new project, configure one pending publisher for
|
|
183
|
+
the first publishing workflow; after it creates the project, register the other
|
|
184
|
+
two as normal project publishers before using those paths. PyPI does not support
|
|
185
|
+
reusable workflows as trusted publishers. This repository does not register
|
|
186
|
+
publishers or change account settings. Release builds retain the
|
|
187
|
+
installed-wheel/version matrix, reproducibility,
|
|
188
|
+
vulnerability scan, SBOM and provenance gates.
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# densemem Python client
|
|
2
|
+
|
|
3
|
+
The Dense-Mem Python core client uses the official MCP SDK. It supports Python
|
|
4
|
+
3.11–3.14 and MCP SDK 1.30 through the compatible 1.x line. This package is being
|
|
5
|
+
prepared for release; PyPI publication is pending. Install a verified wheel:
|
|
6
|
+
|
|
7
|
+
~~~bash
|
|
8
|
+
python -m pip install /path/to/densemem-VERSION-py3-none-any.whl
|
|
9
|
+
~~~
|
|
10
|
+
|
|
11
|
+
ADK and LangChain adapters/extras will arrive with issues #220 and #221.
|
|
12
|
+
The core installs neither framework.
|
|
13
|
+
|
|
14
|
+
## Authentication and operations
|
|
15
|
+
|
|
16
|
+
~~~python
|
|
17
|
+
from densemem import DenseMemClient
|
|
18
|
+
|
|
19
|
+
client = DenseMemClient("https://memory.example.com/teams/TEAM_UUID/mcp", token=api_key)
|
|
20
|
+
tools = await client.list_tools()
|
|
21
|
+
~~~
|
|
22
|
+
|
|
23
|
+
Pass exactly one of token or token_provider. A provider is an async callable
|
|
24
|
+
returning a caller-owned access token. The client resolves it once per operation;
|
|
25
|
+
it does not acquire or refresh OAuth credentials. Use an authenticated team URL
|
|
26
|
+
or /mcp. Credentials belong only in the bearer header, never the URL. Configure
|
|
27
|
+
transport trust through the environment's certificate store when using a private CA.
|
|
28
|
+
|
|
29
|
+
Each call owns its SDK session, initialization and transport cleanup. The default
|
|
30
|
+
190-second total deadline allows the server's bounded 180-second write processing.
|
|
31
|
+
A shorter positive finite timeout is supported through the timeout constructor
|
|
32
|
+
argument. The synchronous SyncDenseMemClient exposes the same methods and rejects
|
|
33
|
+
use inside an active event loop.
|
|
34
|
+
|
|
35
|
+
Methods are initialize, list_tools, remember, ingest_session, recall_memory and
|
|
36
|
+
trace_memory. Requests/results are typed dictionaries with py.typed. Server
|
|
37
|
+
validation and authenticated discovery remain authoritative. Current-server
|
|
38
|
+
compatibility is dense-mem.v2.6.8, including server-supported historical terminal
|
|
39
|
+
replay versions; this does not promise compatibility with older deployments.
|
|
40
|
+
|
|
41
|
+
## Complete Remember request and safe replay
|
|
42
|
+
|
|
43
|
+
~~~python
|
|
44
|
+
from densemem import RememberRequest
|
|
45
|
+
|
|
46
|
+
request: RememberRequest = {
|
|
47
|
+
"idempotency_key": retained_operation_key,
|
|
48
|
+
"evidence": [
|
|
49
|
+
{
|
|
50
|
+
"content": "Dense-Mem stores durable memory in PostgreSQL.",
|
|
51
|
+
"source_type": "manual",
|
|
52
|
+
"source": "Python core example",
|
|
53
|
+
"metadata": {"origin": "python-example"},
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
"relationships": [
|
|
57
|
+
{
|
|
58
|
+
"ref": "durable-store",
|
|
59
|
+
"subject": {"name": "Dense-Mem", "entity_kind": "project"},
|
|
60
|
+
"predicate": {"proposed_key": "stores_durable_memory_in"},
|
|
61
|
+
"object": {"entity": {"name": "PostgreSQL", "entity_kind": "product"}},
|
|
62
|
+
"polarity": "+",
|
|
63
|
+
"evidence_indices": [0],
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
}
|
|
67
|
+
result = await client.remember(request)
|
|
68
|
+
~~~
|
|
69
|
+
|
|
70
|
+
Create the operation key once for a deliberate new operation, and retain this
|
|
71
|
+
entire request before sending it. For a replay, resend this unchanged request,
|
|
72
|
+
including metadata and key. Never rotate a key to bypass a conflict. The client
|
|
73
|
+
never retries automatically or fills in keys/defaults. Remember requires at least
|
|
74
|
+
one proposal citing every evidence item. The client does not infer Relationships.
|
|
75
|
+
|
|
76
|
+
Inspect evidence and relationship_results: completed processing can include
|
|
77
|
+
not_stored proposals and remediation. Returned warnings remain visible. Recall
|
|
78
|
+
results preserve server order, equivalent IDs, conflicts, topic communities,
|
|
79
|
+
hypotheses, provenance, search states and degradations. These frontiers do not
|
|
80
|
+
establish new factual support. Trace requires a returned relationship_id.
|
|
81
|
+
|
|
82
|
+
## Exact private session ingestion
|
|
83
|
+
|
|
84
|
+
~~~python
|
|
85
|
+
from densemem import SessionRequest
|
|
86
|
+
|
|
87
|
+
request: SessionRequest = {
|
|
88
|
+
"idempotency_key": retained_session_operation_key,
|
|
89
|
+
"framework": "generic",
|
|
90
|
+
"app_name": "python-example",
|
|
91
|
+
"user_id": "external-user-1",
|
|
92
|
+
"session_id": "session-1",
|
|
93
|
+
"events": [
|
|
94
|
+
{
|
|
95
|
+
"event_id": "user-event-1",
|
|
96
|
+
"text": " Ari uses Go. café 🧭\n",
|
|
97
|
+
"occurred_at": "2026-10-11T12:00:00Z",
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
}
|
|
101
|
+
result = await client.ingest_session(request)
|
|
102
|
+
~~~
|
|
103
|
+
|
|
104
|
+
Send only exact user-authored events. Event IDs/text/timestamps are immutable;
|
|
105
|
+
the server owns chunking and extraction. External identifiers are provenance,
|
|
106
|
+
never authorization or private-space selection. The server must enable session
|
|
107
|
+
ingestion and the credential must have a writable private binding; discovery
|
|
108
|
+
hides unavailable tools. Remember retains its separate proposal requirements.
|
|
109
|
+
Session semantic acceptance is atomic across the request. A no-fact completed
|
|
110
|
+
result with search_state not_required is valid.
|
|
111
|
+
|
|
112
|
+
## Failures and unknown outcomes
|
|
113
|
+
|
|
114
|
+
DenseMemAuthenticationError reports token acquisition or HTTP 401/403 failures.
|
|
115
|
+
DenseMemTransportError reports network/HTTP failure. DenseMemProtocolError
|
|
116
|
+
reports MCP/response failure. DenseMemOperationError preserves actionable public
|
|
117
|
+
errors and failed receipts in result, with code, reason_code, retryable,
|
|
118
|
+
next_action, remediation, correlation_id and submission_id when returned.
|
|
119
|
+
DenseMemTimeoutError reports deadlines. DenseMemCancelledError subclasses
|
|
120
|
+
asyncio.CancelledError and preserves a returned cancellation receipt if present.
|
|
121
|
+
|
|
122
|
+
A local timeout, disconnect or cancellation can lose a response after a commit.
|
|
123
|
+
An absent receipt means unknown outcome, not a fabricated failed submission.
|
|
124
|
+
Recovery uses only the unchanged original request/key. There is no polling,
|
|
125
|
+
status tool, background readiness loop or automatic new-key recovery.
|
|
126
|
+
|
|
127
|
+
SDK 1.30 negotiates protocol 2025-11-25. Local cancellation closes the client's
|
|
128
|
+
resources; the server can continue processing under this older protocol and may
|
|
129
|
+
commit or reach its bounded deadline. Cancellation does not prove that a write
|
|
130
|
+
was prevented. Retain the unchanged request/key for recovery.
|
|
131
|
+
|
|
132
|
+
## Development and release
|
|
133
|
+
|
|
134
|
+
Run packages/python/scripts/check.sh for lint/type/async tests, installed-wheel
|
|
135
|
+
checks, reproducible wheel/sdist builds, vulnerability scanning and SBOM. Run
|
|
136
|
+
packages/python/scripts/matrix.sh with a new output directory for the Python
|
|
137
|
+
version matrix, and scripts/e2e.sh python_client for real server boundaries.
|
|
138
|
+
The example scripts require DENSEMEM_ENDPOINT, DENSEMEM_TOKEN and a retained
|
|
139
|
+
DENSEMEM_OPERATION_KEY. Keep the exact request unchanged when rerunning them.
|
|
140
|
+
|
|
141
|
+
The server prerelease and stable-release workflows call publish-python to build
|
|
142
|
+
and verify artifacts after their release gates pass, then upload through their own
|
|
143
|
+
top-level publishing jobs. Manual recovery uploads directly from publish-python;
|
|
144
|
+
the reusable invocation never uploads to PyPI. Only tags whose exact source belongs
|
|
145
|
+
to merged main are eligible;
|
|
146
|
+
PR branches cannot publish. Python shares the server release version: v2.6.6-rc.10
|
|
147
|
+
becomes 2.6.6rc10 and v2.6.6 becomes 2.6.6. The checkout's 0.0.0 version is for local
|
|
148
|
+
development; release builds stamp the selected tag's version and exact Source URL
|
|
149
|
+
into artifact metadata without changing Git history.
|
|
150
|
+
|
|
151
|
+
Change detection compares packages/python with the last successfully published
|
|
152
|
+
Python source recorded on PyPI. Unchanged prereleases are skipped, and publishing
|
|
153
|
+
a final version after a Python RC does not require another code change. Incomplete
|
|
154
|
+
uploads remain eligible; retries verify every existing artifact's SHA-256 before
|
|
155
|
+
uploading missing files. The manual publish-python workflow accepts the same shared
|
|
156
|
+
tag for recovery. Never overwrite an existing version or silently accept different
|
|
157
|
+
bytes; a broken prerelease may be yanked through a separate maintainer action.
|
|
158
|
+
|
|
159
|
+
Verify control of the densemem PyPI name and register trusted publishers for
|
|
160
|
+
markhuangai/dense-mem, workflows release-rc.yml, release.yml and publish-python.yml,
|
|
161
|
+
each with environment pypi. For a new project, configure one pending publisher for
|
|
162
|
+
the first publishing workflow; after it creates the project, register the other
|
|
163
|
+
two as normal project publishers before using those paths. PyPI does not support
|
|
164
|
+
reusable workflows as trusted publishers. This repository does not register
|
|
165
|
+
publishers or change account settings. Release builds retain the
|
|
166
|
+
installed-wheel/version matrix, reproducibility,
|
|
167
|
+
vulnerability scan, SBOM and provenance gates.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from densemem import DenseMemClient, RememberRequest, RememberResult
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def make_request(key: str) -> RememberRequest:
|
|
8
|
+
return {
|
|
9
|
+
"idempotency_key": key,
|
|
10
|
+
"evidence": [
|
|
11
|
+
{
|
|
12
|
+
"content": "Dense-Mem stores durable memory in PostgreSQL.",
|
|
13
|
+
"source_type": "manual",
|
|
14
|
+
"source": "Python core example",
|
|
15
|
+
"metadata": {"origin": "python-example"},
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"relationships": [
|
|
19
|
+
{
|
|
20
|
+
"ref": "durable-store",
|
|
21
|
+
"subject": {"name": "Dense-Mem", "entity_kind": "project"},
|
|
22
|
+
"predicate": {"proposed_key": "stores_durable_memory_in"},
|
|
23
|
+
"object": {"entity": {"name": "PostgreSQL", "entity_kind": "product"}},
|
|
24
|
+
"polarity": "+",
|
|
25
|
+
"evidence_indices": [0],
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
async def run(client: DenseMemClient, key: str) -> RememberResult:
|
|
32
|
+
request = make_request(key)
|
|
33
|
+
result = await client.remember(request)
|
|
34
|
+
replay = await client.remember(request)
|
|
35
|
+
assert replay == result
|
|
36
|
+
await client.recall_memory({"query": "Dense-Mem durable memory PostgreSQL", "limit": 5})
|
|
37
|
+
for proposal in result["relationship_results"]:
|
|
38
|
+
for split in proposal["splits"]:
|
|
39
|
+
await client.trace_memory({"relationship_id": split["relationship_id"]})
|
|
40
|
+
return result
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
if __name__ == "__main__":
|
|
44
|
+
client = DenseMemClient(os.environ["DENSEMEM_ENDPOINT"], token=os.environ["DENSEMEM_TOKEN"])
|
|
45
|
+
result = asyncio.run(run(client, os.environ["DENSEMEM_OPERATION_KEY"]))
|
|
46
|
+
print(result["processing_state"])
|