continuityos 0.7.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.
- continuityos-0.7.0/LICENSE +177 -0
- continuityos-0.7.0/NOTICE +5 -0
- continuityos-0.7.0/PKG-INFO +288 -0
- continuityos-0.7.0/README.md +257 -0
- continuityos-0.7.0/continuityos/__init__.py +14 -0
- continuityos-0.7.0/continuityos/agents.py +76 -0
- continuityos-0.7.0/continuityos/api.py +36 -0
- continuityos-0.7.0/continuityos/cli.py +102 -0
- continuityos-0.7.0/continuityos/continuity.py +117 -0
- continuityos-0.7.0/continuityos/control.py +54 -0
- continuityos-0.7.0/continuityos/dedupe.py +131 -0
- continuityos-0.7.0/continuityos/embed.py +43 -0
- continuityos-0.7.0/continuityos/embedders.py +47 -0
- continuityos-0.7.0/continuityos/fork.py +68 -0
- continuityos-0.7.0/continuityos/gate/__init__.py +7 -0
- continuityos-0.7.0/continuityos/gate/classifier.py +58 -0
- continuityos-0.7.0/continuityos/gate/claude_hook.py +86 -0
- continuityos-0.7.0/continuityos/gate/cli.py +113 -0
- continuityos-0.7.0/continuityos/gate/engine.py +168 -0
- continuityos-0.7.0/continuityos/gate/ledger.py +45 -0
- continuityos-0.7.0/continuityos/gate/policy.py +36 -0
- continuityos-0.7.0/continuityos/gate/rollback.py +34 -0
- continuityos-0.7.0/continuityos/gate/spec.py +19 -0
- continuityos-0.7.0/continuityos/gc.py +112 -0
- continuityos-0.7.0/continuityos/index.py +37 -0
- continuityos-0.7.0/continuityos/mcp_server.py +139 -0
- continuityos-0.7.0/continuityos/memory.py +159 -0
- continuityos-0.7.0/continuityos/store.py +116 -0
- continuityos-0.7.0/continuityos/twin.py +57 -0
- continuityos-0.7.0/continuityos.egg-info/PKG-INFO +288 -0
- continuityos-0.7.0/continuityos.egg-info/SOURCES.txt +38 -0
- continuityos-0.7.0/continuityos.egg-info/dependency_links.txt +1 -0
- continuityos-0.7.0/continuityos.egg-info/entry_points.txt +3 -0
- continuityos-0.7.0/continuityos.egg-info/requires.txt +10 -0
- continuityos-0.7.0/continuityos.egg-info/top_level.txt +1 -0
- continuityos-0.7.0/pyproject.toml +42 -0
- continuityos-0.7.0/setup.cfg +4 -0
- continuityos-0.7.0/tests/test_gate.py +56 -0
- continuityos-0.7.0/tests/test_hook.py +23 -0
- continuityos-0.7.0/tests/test_memory.py +38 -0
|
@@ -0,0 +1,177 @@
|
|
|
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 Derivative
|
|
95
|
+
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; and
|
|
103
|
+
|
|
104
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
105
|
+
distribution, then any Derivative Works that You distribute must
|
|
106
|
+
include a readable copy of the attribution notices contained
|
|
107
|
+
within such NOTICE file.
|
|
108
|
+
|
|
109
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
110
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
111
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
112
|
+
this License, without any additional terms or conditions.
|
|
113
|
+
|
|
114
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
115
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
116
|
+
except as required for reasonable and customary use in describing the
|
|
117
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
118
|
+
|
|
119
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
120
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
121
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
122
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
123
|
+
implied, including, without limitation, any warranties or conditions
|
|
124
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
125
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
126
|
+
appropriateness of using or redistributing the Work and assume any
|
|
127
|
+
risks associated with Your exercise of permissions under this License.
|
|
128
|
+
|
|
129
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
130
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
131
|
+
unless required by applicable law (such as deliberate and grossly
|
|
132
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
133
|
+
liable to You for damages, including any direct, indirect, special,
|
|
134
|
+
incidental, or consequential damages of any character arising as a
|
|
135
|
+
result of this License or out of the use or inability to use the
|
|
136
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
137
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
138
|
+
other commercial damages or losses), even if such Contributor
|
|
139
|
+
has been advised of the possibility of such damages.
|
|
140
|
+
|
|
141
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
142
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
143
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
144
|
+
or other liability obligations and/or rights consistent with this
|
|
145
|
+
License. However, in accepting such obligations, You may act only
|
|
146
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
147
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
148
|
+
defend, and hold each Contributor harmless for any liability
|
|
149
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
150
|
+
of your accepting any such warranty or additional liability.
|
|
151
|
+
|
|
152
|
+
END OF TERMS AND CONDITIONS
|
|
153
|
+
|
|
154
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
155
|
+
|
|
156
|
+
To apply the Apache License to your work, attach the following
|
|
157
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
158
|
+
replaced with your own identifying information. (Don't include
|
|
159
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
160
|
+
comment syntax for the file format. We also recommend that a
|
|
161
|
+
file or class name and description of purpose be included on the
|
|
162
|
+
same "printed page" as the copyright notice for easier
|
|
163
|
+
identification within third-party archives.
|
|
164
|
+
|
|
165
|
+
Copyright 2026 ContinuityOS contributors
|
|
166
|
+
|
|
167
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
168
|
+
you may not use this file except in compliance with the License.
|
|
169
|
+
You may obtain a copy of the License at
|
|
170
|
+
|
|
171
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
172
|
+
|
|
173
|
+
Unless required by applicable law or agreed to in writing, software
|
|
174
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
175
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
176
|
+
See the License for the specific language governing permissions and
|
|
177
|
+
limitations under the License.
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: continuityos
|
|
3
|
+
Version: 0.7.0
|
|
4
|
+
Summary: Durable, hybrid (structural + semantic) memory for AI agents and humans. Local-first, zero external services.
|
|
5
|
+
Author: ContinuityOS contributors
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://sovereign-arena-site.vercel.app/continuityos
|
|
8
|
+
Project-URL: Source, https://github.com/bitmaster162/continuityos
|
|
9
|
+
Keywords: memory,ai-agents,mcp,semantic-search,vector,rag,llm,continuity
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
16
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
17
|
+
Classifier: Intended Audience :: Developers
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
License-File: NOTICE
|
|
23
|
+
Provides-Extra: sentence-transformers
|
|
24
|
+
Requires-Dist: sentence-transformers>=2.2; extra == "sentence-transformers"
|
|
25
|
+
Provides-Extra: fastembed
|
|
26
|
+
Requires-Dist: fastembed>=0.3; extra == "fastembed"
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
29
|
+
Requires-Dist: pytest-cov>=4; extra == "dev"
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# ContinuityOS
|
|
33
|
+
|
|
34
|
+
> ## 🛡️ ContinuityOS — AI Agent Governance Gateway
|
|
35
|
+
>
|
|
36
|
+
> **No dangerous tool runs unless ContinuityOS approves it.** A local-first, MCP-native
|
|
37
|
+
> hard-boundary that AI coding agents (Claude Code, Cursor, Codex CLI) must pass through:
|
|
38
|
+
> every risky shell/file/git action gets a preflight decision — `ALLOW · WARN · HOLD · DENY ·
|
|
39
|
+
> REQUIRE_CONFIRMATION · DRY_RUN_ONLY` — with reasons, an append-only tamper-evident audit
|
|
40
|
+
> ledger, and a rollback plan. Apache-2.0.
|
|
41
|
+
>
|
|
42
|
+
> ```bash
|
|
43
|
+
> continuity run shell -- rm -rf / # ⛔ BLOCKED — command was NOT executed
|
|
44
|
+
> continuity run shell -- npm test # ✓ ALLOW — runs
|
|
45
|
+
> ```
|
|
46
|
+
>
|
|
47
|
+
> ContinuityBench v0: **100% decision accuracy, 9/9 dangerous actions stopped** (vs 0/9 with no
|
|
48
|
+
> gateway). What makes it smarter than a static policy engine: it decides **with continuity
|
|
49
|
+
> context** (your canon/rules/state), not just regex. See [BUILD_GATE_STATUS.md](BUILD_GATE_STATUS.md).
|
|
50
|
+
>
|
|
51
|
+
> The memory + continuity layers below are the **context engine** that powers those decisions.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
**Durable memory + continuity layer for AI agents and humans.** Local-first, zero external services, Apache-2.0.
|
|
57
|
+
|
|
58
|
+
Not just a vector store — ContinuityOS keeps the *thread* between sessions and between versions of you and the model: **memory** (hybrid recall) **+ continuity** (canon, frontiers, loops, checkpoints, anti-drift doctor, handoff) **+ a multi-agent council** (many agents + you on one memory, authority levels & roles) **+ a digital twin** (a behavioral model built from your own memory — the human↔AI co-evolution / dyad layer) **+ an operator control plane** (correct, redact, rollback, export).
|
|
59
|
+
|
|
60
|
+
Your Claude / ChatGPT / agent forgets everything between sessions. ContinuityOS is a small local memory layer that stores what matters — who you are, your projects, your rules, decisions you've made — and gives it back when it's relevant. It recalls **both structurally** (folder-like namespaces + keyword search) **and semantically** (vector similarity), so the right memory surfaces whether you match the words or just the meaning.
|
|
61
|
+
|
|
62
|
+
Nothing leaves your machine. One SQLite file. No cloud, no account, no telemetry.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Why
|
|
67
|
+
|
|
68
|
+
- **Agents forget.** Every new session starts cold. ContinuityOS persists context across sessions and tools.
|
|
69
|
+
- **Hybrid recall.** Keyword-only memory misses paraphrases; pure-vector memory misses exact facts and structure. ContinuityOS blends both.
|
|
70
|
+
- **Structure like folders.** Memories live in namespaces — `identity`, `projects`, `rules`, `facts`, `events`, `notes` (or your own) — so recall can be scoped and a human can browse it.
|
|
71
|
+
- **For agents *and* humans.** Use it from your code, from the CLI, from an MCP-capable client (Claude Desktop / Claude Code), or over a tiny HTTP API.
|
|
72
|
+
- **Local-first & private.** Core is **stdlib-only** — no required dependencies, no services. Drop-in to anything.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Install
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
pip install continuityos # core (stdlib-only)
|
|
80
|
+
# optional, for production-grade embeddings:
|
|
81
|
+
pip install "continuityos[embeddings]"
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Requires Python 3.10+.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Quick start
|
|
89
|
+
|
|
90
|
+
### From the CLI
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
cos remember "Robert prefers Apache-2.0 licenses" -n rules -t license
|
|
94
|
+
cos remember "ContinuityOS = hybrid memory: FTS + vectors" -n projects
|
|
95
|
+
cos recall "which license should I pick?"
|
|
96
|
+
# 0.54 [rules] Robert prefers Apache-2.0 licenses (semantic 0.22 + keyword)
|
|
97
|
+
cos namespaces
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### From Python
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from continuityos import Memory
|
|
104
|
+
|
|
105
|
+
m = Memory("memory.db")
|
|
106
|
+
m.remember("The grid lab K=0.04 cohort led at +$1405 / 3 days", namespace="facts", tags=["trading"])
|
|
107
|
+
|
|
108
|
+
for hit in m.recall("best grid setup", k=3):
|
|
109
|
+
print(hit.score, hit.namespace, hit.text)
|
|
110
|
+
|
|
111
|
+
# inject straight into an agent prompt:
|
|
112
|
+
print(m.context("what do I know about grid trading?"))
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### As an MCP server (Claude Desktop / Claude Code)
|
|
116
|
+
|
|
117
|
+
ContinuityOS ships an MCP stdio server so an agent can `remember` and `recall` on its own. Add to your MCP client config:
|
|
118
|
+
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"mcpServers": {
|
|
122
|
+
"continuityos": {
|
|
123
|
+
"command": "cos",
|
|
124
|
+
"args": ["--db", "~/.continuityos/memory.db", "serve"]
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Tools exposed: `remember`, `recall`, `context`, `forget`, `list_namespaces`, `checkpoint`, `handoff`, `doctor`, `set_frontier`, `predict`, `alignment`, `preflight_action` — **12 tools**.
|
|
131
|
+
Now the agent pulls relevant memory automatically before answering — and writes new facts back as it learns it.
|
|
132
|
+
|
|
133
|
+
**Recommended:** use the cross-platform bridge instead of `cos serve`:
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
{
|
|
137
|
+
"mcpServers": {
|
|
138
|
+
"continuityos": {
|
|
139
|
+
"command": "python",
|
|
140
|
+
"args": ["/path/to/mcp_bridge.py"]
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
See [docs/MCP_INTEGRATION.md](docs/MCP_INTEGRATION.md) for Hermes, Claude Desktop, and Cursor setup.
|
|
147
|
+
|
|
148
|
+
### Over HTTP (optional)
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
cos api --port 8077
|
|
152
|
+
curl -s "localhost:8077/recall?q=license&k=3"
|
|
153
|
+
curl -s -XPOST localhost:8077/remember -d '{"text":"hello","namespace":"notes"}'
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Real semantic recall (recommended)
|
|
157
|
+
|
|
158
|
+
The default embedder is offline & dependency-free. For real semantic quality (synonyms, paraphrases), switch in one line:
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
from continuityos import Memory
|
|
162
|
+
from continuityos.embedders import FastEmbedEmbedder # pip install "continuityos[fast]"
|
|
163
|
+
m = Memory("memory.db", embedder=FastEmbedEmbedder()) # bge-small, ONNX, no torch
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Benchmark (see [BENCHMARKS.md](BENCHMARKS.md)): `recall@5` 0.50 → **1.00**, MRR 0.38 → 0.58. Real LoCoMo harness ready in `bench/locomo_bench.py`.
|
|
167
|
+
|
|
168
|
+
### With Docker
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
docker compose up -d # HTTP API on :8077, memory persisted in ./cos-data
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## More than memory — the continuity layer
|
|
177
|
+
|
|
178
|
+
A chat is a terminal, not memory. ContinuityOS persists the operating state that keeps work coherent across sessions:
|
|
179
|
+
|
|
180
|
+
- **Canon** — slow, non-negotiable truths (who you are, rules you don't break).
|
|
181
|
+
- **Frontiers** — `1 trunk + 1 cash + 1 lab` focus discipline; classify every idea.
|
|
182
|
+
- **Open loops** — what's still unfinished, bounded so it can't sprawl.
|
|
183
|
+
- **Checkpoints** — every session ends with `delta + next irreversible action + proof`.
|
|
184
|
+
- **Doctor** — an anti-drift check: is a cash frontier set? loops bounded? checkpoint fresh? proof attached?
|
|
185
|
+
- **Handoff pack** — one block (canon + frontiers + loops + last checkpoint) to resume in a new session or hand to another agent.
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
cos frontier trunk continuityos
|
|
189
|
+
cos frontier cash inner-circle
|
|
190
|
+
cos loop "ship v0.2 to GitHub"
|
|
191
|
+
cos checkpoint --summary "built continuity layer" --next "update sites" --proof continuity.py
|
|
192
|
+
cos doctor # ✅ healthy 5/5 (or flags drift)
|
|
193
|
+
cos handoff # paste this into the next session
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
```python
|
|
197
|
+
from continuityos import Continuity
|
|
198
|
+
c = Continuity(db="memory.db")
|
|
199
|
+
c.add_canon("Proof beats explanation. Closure beats branching.")
|
|
200
|
+
c.set_frontier("cash", "inner-circle")
|
|
201
|
+
c.checkpoint(summary="...", next_action="...", proof="path/to/artifact")
|
|
202
|
+
print(c.doctor()) # anti-drift report
|
|
203
|
+
print(c.handoff()) # resume-context block
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Over MCP the agent gets `checkpoint`, `handoff`, `doctor`, `set_frontier` tools too — so it maintains its own continuity, not just its recall.
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## How it works
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
remember(text, namespace, tags)
|
|
214
|
+
│
|
|
215
|
+
▼
|
|
216
|
+
┌───────────────────────────────┐
|
|
217
|
+
│ Store │ one local SQLite file
|
|
218
|
+
│ items + FTS5 + vectors │
|
|
219
|
+
└───────────────────────────────┘
|
|
220
|
+
▲
|
|
221
|
+
recall(query) │ HYBRID rank
|
|
222
|
+
┌───────────┴───────────┐
|
|
223
|
+
structural / keyword semantic / vector
|
|
224
|
+
(FTS5 + namespace) (cosine over embeddings)
|
|
225
|
+
└───────────┬───────────┘
|
|
226
|
+
blended score → top-k
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
- **Structural layer** — `namespace` (folder-like) + `tags` + FTS5 full-text index.
|
|
230
|
+
- **Semantic layer** — each memory is embedded to an L2-normalized vector; recall ranks by cosine similarity.
|
|
231
|
+
- **Hybrid score** — `semantic_weight · semantic + (1 − semantic_weight) · keyword` (tunable; default 0.6).
|
|
232
|
+
- **Embeddings are pluggable** — the default `HashingEmbedder` is deterministic and fully offline (great for privacy and tests). For best semantic quality, pass any `str → list[float]` callable (e.g. a `sentence-transformers` model):
|
|
233
|
+
|
|
234
|
+
```python
|
|
235
|
+
from sentence_transformers import SentenceTransformer
|
|
236
|
+
enc = SentenceTransformer("all-MiniLM-L6-v2")
|
|
237
|
+
m = Memory("memory.db", embedder=lambda t: enc.encode(t, normalize_embeddings=True).tolist())
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## Privacy
|
|
243
|
+
|
|
244
|
+
ContinuityOS never sends your data anywhere. Memory is a single SQLite file on your disk. `.gitignore` is pre-configured to keep `*.db`, `data/`, and `takeout/` out of version control by construction.
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Standards & competitive position
|
|
249
|
+
|
|
250
|
+
The 2026 consensus is that **guardrails belong at the gateway, not embedded in application code** — a control point that intercepts every tool invocation, scores its risk, and approves or blocks before execution. ContinuityOS is exactly that control point, and maps onto the frameworks enterprises are now audited against:
|
|
251
|
+
|
|
252
|
+
- **OWASP LLM Top 10** — preflight classifies and gates the agentic risks directly: prompt-injection-driven destructive commands, tool poisoning (D3 schema/forbidden-pattern checks), excessive agency (SAP capability passports), and missing audit (append-only ledger).
|
|
253
|
+
- **NIST AI RMF / EU AI Act (high-risk obligations, in force Aug 2026)** — the tamper-evident decision ledger + rollback plan provide the *record-level traceability* and *human-oversight* hooks these frameworks require. Every decision is logged with reasons, severity, and a restore command.
|
|
254
|
+
- **MCP-native** — runs as an MCP server; the same preflight governs MCP tool calls, the layer competitors (Cisco AI Defense, Lasso) now target.
|
|
255
|
+
|
|
256
|
+
**What no one else has.** The crowded 2026 field (Galileo Agent Control, Maxim Bifrost, Palo Alto Prisma AIRS, Lasso, Defend AI) enforces *generic* policy — regex, ML classifiers, org rules. ContinuityOS decides **with your continuity context**: the same engine that remembers *your* canon and non-negotiable rules uses them to judge each action (`_canon_check`). That makes it the only gateway whose verdicts are personalized to the operator, not just the org. Plus two things detection-only tools skip: an **instant local rollback module** (snapshot → `continuity rollback <id>`) and **sovereign-local execution** (zero data leaves the disk — no SaaS egress, which is itself the top enterprise blocker: only 14.4% of agents reached production with full security sign-off in 2026).
|
|
257
|
+
|
|
258
|
+
Honest scope: rollback covers local files only; it cannot undo irreversible external side effects (network, prod, third-party APIs). The gateway raises the floor — it is not a guarantee.
|
|
259
|
+
|
|
260
|
+
## Two-tier memory & cost-aware routing
|
|
261
|
+
|
|
262
|
+
The strongest 2026 agents don't win on a bigger context window — they win on *how they handle the finiteness of context*. ContinuityOS implements the two-tier pattern Anthropic and OpenAI both converge on:
|
|
263
|
+
|
|
264
|
+
- **Session memory** — the auto-compactible state of the current run (goal, live hypotheses, found IDs, tool outcomes, unresolved blockers). Carried forward instead of re-derived each turn.
|
|
265
|
+
- **Long-term memory** — durable lessons, stable user preferences, recurring patterns, anti-patterns, domain facts. **One lesson per file; update the existing note, don't spawn duplicates** — the same discipline this repo's memory files follow.
|
|
266
|
+
|
|
267
|
+
`context(query, k, max_tokens=…, compact=…)` packs the most relevant long-term memories until a token budget is hit, so recall stays cheap, and its output order is deterministic — which matters for **prompt-cache stability**.
|
|
268
|
+
|
|
269
|
+
**Cache-friendly memory rules** (preserve the prompt-cache hash; cache miss = paying full price every turn):
|
|
270
|
+
|
|
271
|
+
1. Never put volatile values (`datetime.now()`, random IDs, per-turn counters) in the system prompt or any cached prefix — they reset the cache every call. Put them in the body of the last user message.
|
|
272
|
+
2. Keep tool definitions and the memory block in a **stable, sorted order** so the cached prefix is byte-identical across turns (`compact=True` + deterministic packing does this).
|
|
273
|
+
3. The cache threshold on Opus-4.8 is ~1024 tokens — keep the cached prefix above it to actually benefit.
|
|
274
|
+
4. To change instructions mid-run without busting the cache, inject a `role:"system"` message *into the history* rather than editing the cached system prompt.
|
|
275
|
+
|
|
276
|
+
**Cost-aware routing.** `estimate_cost(text, model_id, output_tokens)` prices a context block against a built-in `MODEL_REGISTRY` (Fable 5, Mythos 5, Opus 4.8, Haiku 4.5, GPT-5.5, Gemini 3.1 Pro / 3.5 Flash, Grok 4.3, DeepSeek V4 Pro — mid-2026 pricing). Same block costs ~28× more on Fable 5 than DeepSeek V4 Pro, so callers can route *commodity → interactive → high-stakes* tiers instead of always paying frontier price for trivial work.
|
|
277
|
+
|
|
278
|
+
## Status
|
|
279
|
+
|
|
280
|
+
`v0.7.0` — **6 layers, 12 MCP tools, 18/18 tests, full audit passed.** Unified core, all tested (FastEmbed-accelerated recall, session rituals `boot/close/compress`, recall benchmark in `bench/`): **L1 Memory** (hybrid FTS+vector, WAL mode) · **L2 Continuity** (canon/frontiers/loops/checkpoints/doctor/handoff) · **L3 Council** (multi-agent, authority levels + roles) · **L4 Twin** (digital twin: profile/predict/alignment — now in CLI too) · **L5 Control Plane** (correct/redact/rollback/export) · **L6 Autopoiesis** (self-maintenance doctor). CLI (`cos` + `continuity`), MCP server (**12 tools**, cross-platform `mcp_bridge.py`), HTTP API, Docker. CI via GitHub Actions.
|
|
281
|
+
|
|
282
|
+
**Audit fixes applied:** WAL crash resilience · FastEmbed default + auto-fallback · Git-backed DB with daily backup cron · Gate enforcement via Hermes shell hooks · CANONICAL_TRUTH.md (3-store hierarchy) · predict/alignment in CLI · docs/ + quickstart example.
|
|
283
|
+
|
|
284
|
+
Roadmap: incremental vector index for large stores, optional reranking, import adapters (chat exports, notes), web memory browser.
|
|
285
|
+
|
|
286
|
+
## License
|
|
287
|
+
|
|
288
|
+
Apache-2.0. See [LICENSE](LICENSE).
|