trisynapse-memory 0.1.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.
Files changed (63) hide show
  1. trisynapse_memory-0.1.0/LICENSE +201 -0
  2. trisynapse_memory-0.1.0/PKG-INFO +456 -0
  3. trisynapse_memory-0.1.0/README.md +404 -0
  4. trisynapse_memory-0.1.0/pyproject.toml +80 -0
  5. trisynapse_memory-0.1.0/setup.cfg +4 -0
  6. trisynapse_memory-0.1.0/src/trisynapse_memory/__init__.py +109 -0
  7. trisynapse_memory-0.1.0/src/trisynapse_memory/_version.py +34 -0
  8. trisynapse_memory-0.1.0/src/trisynapse_memory/adapters/__init__.py +10 -0
  9. trisynapse_memory-0.1.0/src/trisynapse_memory/adapters/agent_events.py +82 -0
  10. trisynapse_memory-0.1.0/src/trisynapse_memory/adapters/benchmarks/__init__.py +29 -0
  11. trisynapse_memory-0.1.0/src/trisynapse_memory/adapters/benchmarks/base.py +79 -0
  12. trisynapse_memory-0.1.0/src/trisynapse_memory/adapters/benchmarks/halumem.py +80 -0
  13. trisynapse_memory-0.1.0/src/trisynapse_memory/adapters/benchmarks/locomo.py +81 -0
  14. trisynapse_memory-0.1.0/src/trisynapse_memory/adapters/benchmarks/longmemeval.py +75 -0
  15. trisynapse_memory-0.1.0/src/trisynapse_memory/adapters/benchmarks/memorydoc.py +83 -0
  16. trisynapse_memory-0.1.0/src/trisynapse_memory/adapters/trisynapse_live.py +74 -0
  17. trisynapse_memory-0.1.0/src/trisynapse_memory/api.py +1325 -0
  18. trisynapse_memory-0.1.0/src/trisynapse_memory/benchmarks/__init__.py +18 -0
  19. trisynapse_memory-0.1.0/src/trisynapse_memory/benchmarks/evaluation.py +138 -0
  20. trisynapse_memory-0.1.0/src/trisynapse_memory/benchmarks/release.py +85 -0
  21. trisynapse_memory-0.1.0/src/trisynapse_memory/benchmarks/runner.py +213 -0
  22. trisynapse_memory-0.1.0/src/trisynapse_memory/cli.py +575 -0
  23. trisynapse_memory-0.1.0/src/trisynapse_memory/engine/__init__.py +111 -0
  24. trisynapse_memory-0.1.0/src/trisynapse_memory/engine/compilation.py +180 -0
  25. trisynapse_memory-0.1.0/src/trisynapse_memory/engine/embedding.py +130 -0
  26. trisynapse_memory-0.1.0/src/trisynapse_memory/engine/formation.py +181 -0
  27. trisynapse_memory-0.1.0/src/trisynapse_memory/engine/loaders.py +93 -0
  28. trisynapse_memory-0.1.0/src/trisynapse_memory/engine/memory.py +2148 -0
  29. trisynapse_memory-0.1.0/src/trisynapse_memory/engine/models.py +531 -0
  30. trisynapse_memory-0.1.0/src/trisynapse_memory/engine/privacy.py +87 -0
  31. trisynapse_memory-0.1.0/src/trisynapse_memory/engine/providers.py +611 -0
  32. trisynapse_memory-0.1.0/src/trisynapse_memory/engine/retrieval.py +588 -0
  33. trisynapse_memory-0.1.0/src/trisynapse_memory/engine/sources.py +600 -0
  34. trisynapse_memory-0.1.0/src/trisynapse_memory/engine/trace.py +1191 -0
  35. trisynapse_memory-0.1.0/src/trisynapse_memory/engine/vector_cache.py +98 -0
  36. trisynapse_memory-0.1.0/src/trisynapse_memory/prompts/__init__.py +59 -0
  37. trisynapse_memory-0.1.0/src/trisynapse_memory/prompts/answer.md +7 -0
  38. trisynapse_memory-0.1.0/src/trisynapse_memory/prompts/benchmark_judge.md +3 -0
  39. trisynapse_memory-0.1.0/src/trisynapse_memory/prompts/episode_recall.md +4 -0
  40. trisynapse_memory-0.1.0/src/trisynapse_memory/prompts/extraction.md +3 -0
  41. trisynapse_memory-0.1.0/src/trisynapse_memory/prompts/image_extraction.md +10 -0
  42. trisynapse_memory-0.1.0/src/trisynapse_memory/studio/dist/assets/graph-mPIvIbRV.js +327 -0
  43. trisynapse_memory-0.1.0/src/trisynapse_memory/studio/dist/assets/index-CnsjvBGs.css +1 -0
  44. trisynapse_memory-0.1.0/src/trisynapse_memory/studio/dist/assets/index-D54oQBbv.js +14 -0
  45. trisynapse_memory-0.1.0/src/trisynapse_memory/studio/dist/assets/logo-16WU-rcz.png +0 -0
  46. trisynapse_memory-0.1.0/src/trisynapse_memory/studio/dist/assets/markdown-ubUk7Dpl.js +29 -0
  47. trisynapse_memory-0.1.0/src/trisynapse_memory/studio/dist/assets/react-CvQExsv3.js +3 -0
  48. trisynapse_memory-0.1.0/src/trisynapse_memory/studio/dist/index.html +18 -0
  49. trisynapse_memory-0.1.0/src/trisynapse_memory/terminal.py +585 -0
  50. trisynapse_memory-0.1.0/src/trisynapse_memory.egg-info/PKG-INFO +456 -0
  51. trisynapse_memory-0.1.0/src/trisynapse_memory.egg-info/SOURCES.txt +61 -0
  52. trisynapse_memory-0.1.0/src/trisynapse_memory.egg-info/dependency_links.txt +1 -0
  53. trisynapse_memory-0.1.0/src/trisynapse_memory.egg-info/entry_points.txt +2 -0
  54. trisynapse_memory-0.1.0/src/trisynapse_memory.egg-info/requires.txt +38 -0
  55. trisynapse_memory-0.1.0/src/trisynapse_memory.egg-info/top_level.txt +1 -0
  56. trisynapse_memory-0.1.0/tests/test_api.py +60 -0
  57. trisynapse_memory-0.1.0/tests/test_benchmark_adapters.py +137 -0
  58. trisynapse_memory-0.1.0/tests/test_ingestion.py +366 -0
  59. trisynapse_memory-0.1.0/tests/test_model_configuration.py +263 -0
  60. trisynapse_memory-0.1.0/tests/test_productization.py +231 -0
  61. trisynapse_memory-0.1.0/tests/test_prompts_and_benchmarks.py +191 -0
  62. trisynapse_memory-0.1.0/tests/test_trace_recall_engine.py +111 -0
  63. trisynapse_memory-0.1.0/tests/test_versioning.py +40 -0
@@ -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 2026 trisynapse-memory contributors
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,456 @@
1
+ Metadata-Version: 2.4
2
+ Name: trisynapse-memory
3
+ Version: 0.1.0
4
+ Summary: Append-only, citation-first memory for AI agents using Trace & Recall.
5
+ License-Expression: Apache-2.0
6
+ Project-URL: Homepage, https://github.com/shanmukh05/trisynapse-memory
7
+ Project-URL: Repository, https://github.com/shanmukh05/trisynapse-memory
8
+ Project-URL: Documentation, https://github.com/shanmukh05/trisynapse-memory/tree/main/docs
9
+ Project-URL: Issues, https://github.com/shanmukh05/trisynapse-memory/issues
10
+ Keywords: ai,agents,memory,rag
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Requires-Python: >=3.11
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: google-genai>=1.0
19
+ Requires-Dist: lancedb>=0.20
20
+ Requires-Dist: numpy>=1.26
21
+ Requires-Dist: pydantic>=2.6
22
+ Requires-Dist: sentence-transformers>=3.0
23
+ Requires-Dist: typer>=0.16
24
+ Requires-Dist: rich>=13.9
25
+ Requires-Dist: textual>=2.1
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=7.4; extra == "dev"
28
+ Requires-Dist: ruff<0.15,>=0.9; extra == "dev"
29
+ Requires-Dist: httpx>=0.27; extra == "dev"
30
+ Provides-Extra: server
31
+ Requires-Dist: fastapi>=0.115; extra == "server"
32
+ Requires-Dist: uvicorn>=0.34; extra == "server"
33
+ Provides-Extra: files
34
+ Requires-Dist: pypdf>=5.0; extra == "files"
35
+ Provides-Extra: sources
36
+ Requires-Dist: pypdf>=5.0; extra == "sources"
37
+ Requires-Dist: python-docx>=1.1; extra == "sources"
38
+ Requires-Dist: python-pptx>=1.0; extra == "sources"
39
+ Requires-Dist: openpyxl>=3.1; extra == "sources"
40
+ Requires-Dist: PyYAML>=6.0; extra == "sources"
41
+ Requires-Dist: tree-sitter-language-pack>=0.9; extra == "sources"
42
+ Provides-Extra: all
43
+ Requires-Dist: fastapi>=0.115; extra == "all"
44
+ Requires-Dist: uvicorn>=0.34; extra == "all"
45
+ Requires-Dist: pypdf>=5.0; extra == "all"
46
+ Requires-Dist: python-docx>=1.1; extra == "all"
47
+ Requires-Dist: python-pptx>=1.0; extra == "all"
48
+ Requires-Dist: openpyxl>=3.1; extra == "all"
49
+ Requires-Dist: PyYAML>=6.0; extra == "all"
50
+ Requires-Dist: tree-sitter-language-pack>=0.9; extra == "all"
51
+ Dynamic: license-file
52
+
53
+ <div align="center">
54
+ <a href="https://github.com/shanmukh05/trisynapse-memory">
55
+ <img
56
+ src="https://raw.githubusercontent.com/shanmukh05/trisynapse-memory/main/public/assets/logo.png"
57
+ alt="Trisynapse Memory logo"
58
+ width="440"
59
+ />
60
+ </a>
61
+
62
+ <h1>Trisynapse Memory</h1>
63
+
64
+ <p><strong>Store traces. Recall meaning.</strong></p>
65
+
66
+ <p>
67
+ <a href="https://github.com/shanmukh05/trisynapse-memory/actions/workflows/test.yml"><img alt="Tests" src="https://img.shields.io/github/actions/workflow/status/shanmukh05/trisynapse-memory/test.yml?branch=main&amp;style=flat-square&amp;label=tests" /></a>
68
+ <a href="https://pypi.org/project/trisynapse-memory/"><img alt="PyPI version" src="https://img.shields.io/pypi/v/trisynapse-memory?style=flat-square&amp;logo=pypi&amp;logoColor=white&amp;color=3775A9" /></a>
69
+ <a href="https://pypi.org/project/trisynapse-memory/"><img alt="Supported Python versions" src="https://img.shields.io/pypi/pyversions/trisynapse-memory?style=flat-square&amp;logo=python&amp;logoColor=white" /></a>
70
+ <a href="LICENSE"><img alt="Apache 2.0 license" src="https://img.shields.io/github/license/shanmukh05/trisynapse-memory?style=flat-square" /></a>
71
+ <img alt="Project status: alpha" src="https://img.shields.io/badge/status-alpha-CB912F?style=flat-square" />
72
+ </p>
73
+
74
+ <p>
75
+ <a href="#install">Install</a> ·
76
+ <a href="#start-in-the-terminal">CLI</a> ·
77
+ <a href="#python-in-five-minutes">Python</a> ·
78
+ <a href="#rest-api-and-memory-studio">REST &amp; Studio</a> ·
79
+ <a href="#javascript-and-typescript-sdk">TypeScript</a> ·
80
+ <a href="docs/architecture.md">Architecture</a> ·
81
+ <a href="docs/api.md">API</a> ·
82
+ <a href="docs/operations.md">Operations</a>
83
+ </p>
84
+ </div>
85
+
86
+ ---
87
+
88
+ Trisynapse Memory is a local-first memory layer for AI agents. It keeps original evidence in a verifiable **Trace**, builds replaceable **Recall** views for fast retrieval, and answers from the evidence with citations.
89
+
90
+ > [!IMPORTANT]
91
+ > **Project status: pre-1.0 alpha.** The Python engine, unified source ingestion, REST API, TypeScript client, Memory Studio, full terminal, durable jobs, provider adapters, and benchmark runners are implemented. APIs may still change before the first stable release.
92
+
93
+ ## Install
94
+
95
+ macOS or Linux:
96
+
97
+ ```bash
98
+ curl -LsSf https://github.com/shanmukh05/trisynapse-memory/releases/latest/download/install.sh | sh
99
+ ```
100
+
101
+ Windows PowerShell:
102
+
103
+ ```powershell
104
+ irm https://github.com/shanmukh05/trisynapse-memory/releases/latest/download/install.ps1 | iex
105
+ ```
106
+
107
+ The installer uses `uv`, installs the PyPI package with all user-facing source loaders, adds the single `trisynapse-memory` command, records install metadata, and runs `check`. Re-run it to upgrade.
108
+
109
+ Or install from PyPI:
110
+
111
+ ```bash
112
+ pip install 'trisynapse-memory[all]'
113
+ ```
114
+
115
+ Python 3.11+ is required. Uninstall with `uv tool uninstall trisynapse-memory` or the matching `pip uninstall` command.
116
+
117
+ ## Start in the terminal
118
+
119
+ ```bash
120
+ trisynapse-memory init
121
+ trisynapse-memory
122
+ ```
123
+
124
+ With no arguments in a terminal, the interactive app opens. Ask a question as plain text, or use commands such as `/ingest`, `/sources`, `/search`, `/history`, `/forget`, `/remove`, `/jobs`, `/model`, and `/check`.
125
+
126
+ Start typing `/` to see live command recommendations. The list narrows with every character, while a ghost completion appears in the prompt. Press **Tab** or **Right Arrow** to accept it. Commands that need an argument also recommend matching local paths or recent memory IDs.
127
+
128
+ Scriptable commands remain available:
129
+
130
+ ```bash
131
+ trisynapse-memory --project-id demo ingest ./docs ./src/service.py https://example.com/guide
132
+ trisynapse-memory --project-id demo sources list
133
+ trisynapse-memory --project-id demo query "How does the service work?"
134
+ trisynapse-memory --json check
135
+ ```
136
+
137
+ Global flags include `--json`, `--quiet`, `--no-color`, `--yes`, `--path`, namespace flags, and `--version`. Put global flags before the command. JSON mode never prints the logo or progress text.
138
+
139
+ ## Python in five minutes
140
+
141
+ ```python
142
+ from trisynapse_memory import MemoryEngine, MemoryNamespace, SourceInput
143
+
144
+ namespace = MemoryNamespace(user_id="maya", project_id="assistant")
145
+ memory = MemoryEngine.from_env("~/.trisynapse-memory/store", namespace=namespace)
146
+
147
+ memory.add("Maya prefers short weekly updates.", episode_id="chat:1")
148
+
149
+ run = memory.ingest_many([
150
+ SourceInput(kind="file", path="./handbook.pdf"),
151
+ SourceInput(kind="directory", path="./src", source_key="app-source"),
152
+ SourceInput(kind="url", url="https://example.com/release-process"),
153
+ ])
154
+
155
+ for item in run.results:
156
+ print(item.index, item.status, item.source_id, item.error)
157
+
158
+ answer = memory.query("How should I write the weekly update?")
159
+ print(answer.answer)
160
+ for citation in answer.citations:
161
+ print(citation.delta_id, citation.locator)
162
+ ```
163
+
164
+ Mixed imports are independent: a bad item is reported as failed while valid items commit. Repeating the same `source_key + content_hash` is a no-op. Updating a source creates a new version and retracts the previous version only after the new one succeeds.
165
+
166
+ `add_batch()` still means “append already-normalized text observations.” Use `ingest_many()` for mixed files, URLs, repositories, archives, and images.
167
+
168
+ ## Sources
169
+
170
+ The source pipeline accepts:
171
+
172
+ - text, Markdown, HTML, PDF, JSON, JSONL, YAML, and CSV;
173
+ - DOCX, PPTX, and XLSX with paragraph, slide, sheet, row, and cell-aware locations;
174
+ - PNG, JPEG, and WebP through the configured vision-capable completion model;
175
+ - code files, directories, safe ZIP/TAR archives, notebooks, and public HTTPS Git repositories;
176
+ - one public web page per URL.
177
+
178
+ Code is split around symbols with Tree-sitter when supported, with bounded line chunks as the fallback. Citations retain paths, languages, symbol names/types, line ranges, imports, hashes, and Git commit metadata. Repository imports honor `.gitignore` and `.trisynapseignore`; dependencies, builds, caches, secret files, binaries, and symlinks are skipped and reported.
179
+
180
+ Accepted originals are deduplicated by SHA-256 under the memory store and included in backups. Store permissions are restricted, but **the source store is not encrypted**.
181
+
182
+ Image ingestion does not silently switch to OCR. It fails clearly if no completion provider is configured or the selected model rejects images.
183
+
184
+ ## Forget versus remove
185
+
186
+ ```python
187
+ memory.forget(delta_id=item.id, reason="no longer relevant")
188
+ memory.remove(delta_ids=[item.id], reason="approved privacy deletion")
189
+ memory.remove_source(source_id, reason="delete upload and derived memory")
190
+ ```
191
+
192
+ - `forget()` appends a logical retraction. The old content remains available to authorized audit/history operations.
193
+ - `remove()` physically redacts only the selected deltas, writes `[REMOVED]`, rebuilds the verifiable chain, clears derived caches, and records a `removal_audit` row.
194
+ - `remove_source()` removes the retained original when it is no longer shared and redacts every delta derived from that source.
195
+
196
+ There is intentionally no public `purge` alias. Historical `[PURGED]` rows from older stores remain unchanged and continue to verify.
197
+
198
+ ## One engine, four surfaces
199
+
200
+ | Surface | Start | Best for |
201
+ |---|---|---|
202
+ | Python | `MemoryEngine.from_env(...)` | In-process applications |
203
+ | Terminal/CLI | `trisynapse-memory` | Interactive use, scripts, and operations |
204
+ | REST + Studio | `trisynapse-memory serve --studio` | Shared local service and inspection |
205
+ | JavaScript/TypeScript | `@trisynapse/memory` | Node.js and web application backends |
206
+
207
+ All surfaces call the same Trace & Recall engine. A source ingested through REST is visible from Python, the terminal, Studio, and TypeScript when they use the same store and namespace.
208
+
209
+ ## REST API and Memory Studio
210
+
211
+ Install the server extra, initialize the store, and start the service:
212
+
213
+ ```bash
214
+ pip install 'trisynapse-memory[server,sources]'
215
+ trisynapse-memory init
216
+ trisynapse-memory serve --studio
217
+ ```
218
+
219
+ The default service address is `http://127.0.0.1:8765`. The root opens Memory Studio at [`/studio/`](http://127.0.0.1:8765/studio/), while OpenAPI is available at [`/openapi.json`](http://127.0.0.1:8765/openapi.json). The service binds to loopback unless `--host` is changed.
220
+
221
+ Studio has five focused areas:
222
+
223
+ - **Sources** is a searchable card inbox with mixed batch ingestion, safe previews, retained-original downloads, versions, and derived memory.
224
+ - **Queries** streams each retrieval stage into a clickable workflow and keeps the same workflow in namespace-scoped history.
225
+ - **Memory Viewer** switches between knowledge, source-lineage, and chronological Trace graphs.
226
+ - **Configuration** manages completion, embeddings, and revisioned retrieval defaults.
227
+ - **Connection** selects the server, bearer token, and active namespace without storing the token in memory SQLite.
228
+
229
+ `init` creates the administrator bearer token at `<store>/.api-key`. Health is public; memory operations require the token when authentication is enabled:
230
+
231
+ ```bash
232
+ export TRISYNAPSE_MEMORY_API_KEY="$(cat ~/.trisynapse-memory/store/.api-key)"
233
+
234
+ curl http://127.0.0.1:8765/api/v1/health
235
+
236
+ curl -X POST http://127.0.0.1:8765/api/v1/memory/observations \
237
+ -H "Authorization: Bearer $TRISYNAPSE_MEMORY_API_KEY" \
238
+ -H "Content-Type: application/json" \
239
+ -d '{
240
+ "text": "Maya prefers three-bullet updates.",
241
+ "episode_id": "chat:updates",
242
+ "namespace": {"user_id": "maya", "project_id": "demo"}
243
+ }'
244
+
245
+ curl -X POST http://127.0.0.1:8765/api/v1/query \
246
+ -H "Authorization: Bearer $TRISYNAPSE_MEMORY_API_KEY" \
247
+ -H "Content-Type: application/json" \
248
+ -d '{
249
+ "question": "How should Maya receive updates?",
250
+ "namespace": {"user_id": "maya", "project_id": "demo"}
251
+ }'
252
+ ```
253
+
254
+ ### Ingest sources through REST
255
+
256
+ Bulk source ingestion is asynchronous. The first response is `202 Accepted` with a durable run ID:
257
+
258
+ ```bash
259
+ curl -X POST http://127.0.0.1:8765/api/v1/sources/ingest \
260
+ -H "Authorization: Bearer $TRISYNAPSE_MEMORY_API_KEY" \
261
+ -H "Content-Type: application/json" \
262
+ -d '{
263
+ "namespace": {"user_id": "maya", "project_id": "demo"},
264
+ "sources": [
265
+ {"kind": "url", "url": "https://example.com/handbook"},
266
+ {"kind": "text", "source_key": "release-rule", "text": "Name an owner in every release note."}
267
+ ]
268
+ }'
269
+ ```
270
+
271
+ Follow and manage the run using its returned ID:
272
+
273
+ ```bash
274
+ curl -H "Authorization: Bearer $TRISYNAPSE_MEMORY_API_KEY" \
275
+ http://127.0.0.1:8765/api/v1/ingestion-runs/RUN_ID
276
+
277
+ curl -X POST -H "Authorization: Bearer $TRISYNAPSE_MEMORY_API_KEY" \
278
+ http://127.0.0.1:8765/api/v1/ingestion-runs/RUN_ID/retry
279
+ ```
280
+
281
+ Important REST routes:
282
+
283
+ | Area | Routes |
284
+ |---|---|
285
+ | Add and retrieve | `POST /memory/observations`, `POST /search`, `POST /query`, `GET /memories` |
286
+ | Query workflows | `POST/GET /query-runs`, `GET /query-runs/{id}/events`, confirmed history removal |
287
+ | Sources | `POST /sources/ingest`, filtered `GET /sources`, preview/content routes |
288
+ | Runs | `GET /ingestion-runs`, `GET /ingestion-runs/{id}`, retry |
289
+ | Memory graph | `GET /memory-graph`, node-neighborhood expansion |
290
+ | Lifecycle | corrections, `forget`, `POST /memory/remove`, `POST /sources/{id}/remove` |
291
+ | Models and retrieval | provider catalogs, `GET/PUT /model-configuration`, `GET/PUT /retrieval-configuration` |
292
+ | Operations | health, metrics, jobs, export, backups, benchmarks, and integration events |
293
+
294
+ All routes above are under `/api/v1`. Uploaded bytes are sent as `content_base64`. REST deliberately rejects arbitrary server filesystem paths. Defaults include 25 MiB per uploaded file, 250 MiB per run, 100 descriptors, safe archive limits, URL timeouts, redirect limits, and private-network blocking.
295
+
296
+ Use `trisynapse-memory serve --no-auth` only for trusted local development. See [API and Interfaces](docs/api.md) for complete request contracts and [Operations](docs/operations.md) for deployment guidance.
297
+
298
+ ## JavaScript and TypeScript SDK
299
+
300
+ The dependency-free Fetch client lives in [`packages/js-sdk`](packages/js-sdk) and its package name is `@trisynapse/memory`. It requires Node.js 18+ or another runtime with a compatible Fetch API.
301
+
302
+ ```bash
303
+ npm install @trisynapse/memory
304
+ # or: pnpm add @trisynapse/memory
305
+ ```
306
+
307
+ ```ts
308
+ import { TrisynapseMemory } from "@trisynapse/memory";
309
+
310
+ const memory = new TrisynapseMemory({
311
+ baseUrl: "http://127.0.0.1:8765",
312
+ apiKey: process.env.TRISYNAPSE_MEMORY_API_KEY,
313
+ namespace: { project_id: "demo", user_id: "maya" },
314
+ });
315
+
316
+ await memory.add("Maya prefers short weekly updates.", {
317
+ episodeId: "chat:updates",
318
+ });
319
+
320
+ const run = await memory.ingest([
321
+ { kind: "url", url: "https://example.com/guide" },
322
+ {
323
+ kind: "file",
324
+ filename: "release-notes.md",
325
+ content_base64: markdownBase64,
326
+ source_key: "release-notes",
327
+ },
328
+ ]);
329
+
330
+ let current = run;
331
+ while (current.status === "pending" || current.status === "running") {
332
+ await new Promise(resolve => setTimeout(resolve, 500));
333
+ current = await memory.getIngestionRun(run.id);
334
+ }
335
+
336
+ const answer = await memory.query("What does the guide require?");
337
+ console.log(answer.answer);
338
+ for (const citation of answer.citations) {
339
+ console.log(citation.delta_id, citation.locator);
340
+ }
341
+ ```
342
+
343
+ The client covers:
344
+
345
+ - `add()`, `addBatch()`, and the compatibility `addFile()`;
346
+ - `ingest()`, `listSources()`, `getSource()`, and `removeSource()`;
347
+ - `getIngestionRun()` and `retryIngestion()`;
348
+ - `search()`, `query()`, `list()`, `get()`, and `history()`;
349
+ - `correct()`, `forget()`, and physical `remove()`;
350
+ - profiles, feedback, health, typed deltas, citations, retrieval traces, sources, and run results.
351
+ - provider/model discovery, configuration, explicit connection tests, and embedding-rebuild status.
352
+
353
+ Lifecycle example:
354
+
355
+ ```ts
356
+ await memory.correct(memoryId, "Maya prefers at most three bullets.");
357
+ await memory.forget(memoryId, "Preference expired");
358
+ await memory.remove([sensitiveMemoryId], "Approved privacy deletion");
359
+ await memory.removeSource(sourceId, "Delete the upload and derived memory");
360
+ ```
361
+
362
+ The SDK contains no alternate memory algorithm; it is a typed client for the canonical Python REST service.
363
+
364
+ ## The memory idea
365
+
366
+ ```mermaid
367
+ flowchart TD
368
+ S["Sources and conversations"] --> P["Safe preprocessing + privacy filter"]
369
+ P --> T["Trace: original, ordered evidence"]
370
+ T --> R["Recall: replaceable indexes and summaries"]
371
+ Q["Question"] --> R
372
+ R --> D["Drill back to Trace"]
373
+ D --> A["Answer or abstain with citations"]
374
+ ```
375
+
376
+ Each Trace delta stores the hash of the previous delta plus its own content. Hashing does not hide the data. It answers a different question: “Was old evidence edited, deleted, reordered, or inserted outside the supported lifecycle?” Recall products can be rebuilt, so they never become the final evidence for an answer.
377
+
378
+ Read [Architecture](docs/architecture.md) first, then [API and Interfaces](docs/api.md), [Operations](docs/operations.md), and the [Production release runbook](docs/release-and-production.md).
379
+
380
+ Release versions are synchronized from `pyproject.toml` with one command:
381
+
382
+ ```bash
383
+ uv run python scripts/version.py set 0.2.0
384
+ uv run python scripts/version.py check --tag v0.2.0
385
+ ```
386
+
387
+ ## Models, providers, and benchmarks
388
+
389
+ Model choices are saved per memory store. API keys stay in environment variables and are never written to SQLite. Running `/model` opens the searchable terminal selector:
390
+
391
+ ```bash
392
+ export ANTHROPIC_API_KEY="your-key"
393
+ trisynapse-memory
394
+ # Enter /model completion
395
+ ```
396
+
397
+ Scriptable equivalents are available:
398
+
399
+ ```bash
400
+ trisynapse-memory models providers
401
+ trisynapse-memory models list --role completion --provider anthropic
402
+ trisynapse-memory models set completion anthropic claude-sonnet-4-5
403
+ trisynapse-memory models test --role completion
404
+ ```
405
+
406
+ Completion providers are OpenAI, OpenRouter, Gemini, Anthropic, DeepInfra, DeepSeek, Kimi, and custom OpenAI-compatible endpoints. Embeddings can use local SentenceTransformers, OpenAI, OpenRouter, Gemini, DeepInfra, or a custom OpenAI-compatible endpoint. Qwen models appear under OpenRouter or DeepInfra when those catalogs provide them.
407
+
408
+ | Provider | Completion | Embedding | Credential variable |
409
+ |---|:---:|:---:|---|
410
+ | OpenAI | ✓ | ✓ | `OPENAI_API_KEY` |
411
+ | OpenRouter | ✓ | ✓ | `OPENROUTER_API_KEY` |
412
+ | Gemini | ✓ | ✓ | `GEMINI_API_KEY` |
413
+ | Anthropic | ✓ | — | `ANTHROPIC_API_KEY` |
414
+ | DeepInfra | ✓ | ✓ | `DEEPINFRA_API_TOKEN` |
415
+ | DeepSeek | ✓ | — | `DEEPSEEK_API_KEY` |
416
+ | Kimi | ✓ | — | `MOONSHOT_API_KEY` |
417
+ | OpenAI-compatible | ✓ | ✓ | `OPENAI_COMPATIBLE_API_KEY` when required |
418
+ | SentenceTransformers | — | ✓ | none |
419
+
420
+ Changing completion affects future generation only. Changing embeddings requires confirmation and rebuilds a new vector index before switching away from the working index. See [Operations](docs/operations.md#completion-and-embedding-providers) for credentials and [API and Interfaces](docs/api.md#model-configuration) for every configuration surface.
421
+
422
+ The same change from Python:
423
+
424
+ ```python
425
+ from trisynapse_memory import ProviderSelection
426
+
427
+ configuration = memory.get_model_configuration()
428
+ configuration.completion = ProviderSelection(
429
+ provider="deepseek", model="deepseek-chat"
430
+ )
431
+ memory.set_model_configuration(configuration)
432
+ ```
433
+
434
+ Benchmark modes stay explicit:
435
+
436
+ - `retrieval` measures offline ingestion, retrieval, grounding, and extractive answers;
437
+ - `end-to-end` adds provider-backed extraction, Recall generation, answering, and judging.
438
+
439
+ Artifacts record provider/model and prompt version/hash provenance without credentials or provider URLs.
440
+
441
+ ```bash
442
+ trisynapse-memory bench run locomo --mode retrieval --data-root data/locomo --max-questions 100
443
+ trisynapse-memory bench gate --mode retrieval
444
+ ```
445
+
446
+ ## Development
447
+
448
+ ```bash
449
+ pip install -e '.[dev,all]'
450
+ pytest -q
451
+ ruff check src tests scripts
452
+ pnpm install --frozen-lockfile
453
+ pnpm --filter @trisynapse/memory check
454
+ ```
455
+
456
+ Trace & Recall is the only engine implementation. License: Apache-2.0.