@mrc2204/agent-smart-memo 4.1.3 → 5.0.0
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.
- package/README.md +317 -135
- package/dist/adapters/openclaw/tool-runtime.d.ts +29 -0
- package/dist/adapters/openclaw/tool-runtime.d.ts.map +1 -0
- package/dist/adapters/openclaw/tool-runtime.js +48 -0
- package/dist/adapters/openclaw/tool-runtime.js.map +1 -0
- package/dist/core/contracts/adapter-contracts.d.ts +31 -0
- package/dist/core/contracts/adapter-contracts.d.ts.map +1 -0
- package/dist/core/contracts/adapter-contracts.js +2 -0
- package/dist/core/contracts/adapter-contracts.js.map +1 -0
- package/dist/core/runtime-boundary.d.ts +23 -0
- package/dist/core/runtime-boundary.d.ts.map +1 -0
- package/dist/core/runtime-boundary.js +39 -0
- package/dist/core/runtime-boundary.js.map +1 -0
- package/dist/core/usecases/default-memory-usecase-port.d.ts +21 -0
- package/dist/core/usecases/default-memory-usecase-port.d.ts.map +1 -0
- package/dist/core/usecases/default-memory-usecase-port.js +263 -0
- package/dist/core/usecases/default-memory-usecase-port.js.map +1 -0
- package/dist/core/usecases/semantic-memory-usecase.d.ts +52 -0
- package/dist/core/usecases/semantic-memory-usecase.d.ts.map +1 -0
- package/dist/core/usecases/semantic-memory-usecase.js +136 -0
- package/dist/core/usecases/semantic-memory-usecase.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -9
- package/dist/index.js.map +1 -1
- package/dist/tools/graph-tools.d.ts +2 -0
- package/dist/tools/graph-tools.d.ts.map +1 -1
- package/dist/tools/graph-tools.js +126 -177
- package/dist/tools/graph-tools.js.map +1 -1
- package/dist/tools/semantic-memory-tools.d.ts +8 -0
- package/dist/tools/semantic-memory-tools.d.ts.map +1 -0
- package/dist/tools/semantic-memory-tools.js +111 -0
- package/dist/tools/semantic-memory-tools.js.map +1 -0
- package/dist/tools/slot-tools.d.ts +3 -1
- package/dist/tools/slot-tools.d.ts.map +1 -1
- package/dist/tools/slot-tools.js +82 -156
- package/dist/tools/slot-tools.js.map +1 -1
- package/package.json +25 -32
- package/dist/config.d.ts +0 -62
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -102
- package/dist/config.js.map +0 -1
- package/dist/scripts/reembed-collection.d.ts +0 -2
- package/dist/scripts/reembed-collection.d.ts.map +0 -1
- package/dist/scripts/reembed-collection.js +0 -165
- package/dist/scripts/reembed-collection.js.map +0 -1
- package/dist/tools/memory_search.d.ts +0 -89
- package/dist/tools/memory_search.d.ts.map +0 -1
- package/dist/tools/memory_search.js +0 -188
- package/dist/tools/memory_search.js.map +0 -1
- package/dist/tools/memory_store.d.ts +0 -65
- package/dist/tools/memory_store.d.ts.map +0 -1
- package/dist/tools/memory_store.js +0 -196
- package/dist/tools/memory_store.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,38 +1,116 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Agent Smart Memo
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> **Shared Agent Memory Platform** with runtime adapters for **OpenClaw**, **Paperclip**, and future agent systems.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
`agent-smart-memo` started as an OpenClaw memory plugin. It is now evolving into a **moduleized memory platform**:
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- **core** → contracts, use-cases, namespace policy, error model
|
|
8
|
+
- **adapter-openclaw** → plugin entry, tool registration, hook wiring, runtime bridge
|
|
9
|
+
- **adapter-paperclip** → runtime wrapper, caller integration, compatibility mapping
|
|
10
|
+
- **shared infra** → Qdrant, embeddings, SlotDB, GraphDB, packaging scripts
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
- **Essence Distillation** — Filters noise, keeps only decision-grade facts. Your agent's memory stays clean and useful
|
|
12
|
-
- **Slot Memory** — Structured key-value storage organized by categories (profile, preferences, project, environment)
|
|
13
|
-
- **Vector Search** — Find semantically similar memories using Qdrant
|
|
14
|
-
- **Multi-Agent Support** — Each agent maintains its own memory scope, no cross-contamination
|
|
12
|
+
That means this repository should no longer be understood as *only* an OpenClaw plugin repo.
|
|
13
|
+
It is a **shared memory engine with target-specific artifacts**.
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 1) What this project does
|
|
18
|
+
|
|
19
|
+
Agent Smart Memo provides a unified memory stack for AI agents:
|
|
20
|
+
|
|
21
|
+
- **Semantic memory** via Qdrant (`memory_search`, `memory_store`)
|
|
22
|
+
- **Structured slot memory** via SQLite (`memory_slot_*`)
|
|
23
|
+
- **Graph memory** for entity/relationship retrieval (`memory_graph_*`)
|
|
24
|
+
- **Auto-capture / auto-recall** for OpenClaw runtime
|
|
25
|
+
- **Shared runtime contracts** for multi-system memory callers
|
|
26
|
+
- **Target-based packaging** so each runtime only consumes the artifact it needs
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 2) Runtime targets
|
|
31
|
+
|
|
32
|
+
### OpenClaw target
|
|
33
|
+
Use this when you want Agent Smart Memo as an OpenClaw memory plugin.
|
|
34
|
+
|
|
35
|
+
Contains:
|
|
36
|
+
- core
|
|
37
|
+
- required infra
|
|
38
|
+
- OpenClaw adapter
|
|
39
|
+
- plugin entry / hooks / tool registration
|
|
40
|
+
|
|
41
|
+
Artifact intent:
|
|
42
|
+
- **OpenClaw plugin artifact**
|
|
43
|
+
|
|
44
|
+
### Paperclip target
|
|
45
|
+
Use this when you want a Paperclip runtime caller over the same memory core.
|
|
46
|
+
|
|
47
|
+
Contains:
|
|
48
|
+
- core
|
|
49
|
+
- required infra
|
|
50
|
+
- Paperclip adapter
|
|
51
|
+
- runtime wrapper / compatibility mapper
|
|
52
|
+
|
|
53
|
+
Artifact intent:
|
|
54
|
+
- **Paperclip runtime package**
|
|
55
|
+
|
|
56
|
+
### Core target
|
|
57
|
+
Use this when you only want shared contracts/use-cases for future systems.
|
|
58
|
+
|
|
59
|
+
Contains:
|
|
60
|
+
- core contracts
|
|
61
|
+
- use-case abstractions
|
|
62
|
+
- shared platform rules
|
|
63
|
+
|
|
64
|
+
Artifact intent:
|
|
65
|
+
- **runtime-agnostic shared memory core**
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## 3) Architecture principles
|
|
70
|
+
|
|
71
|
+
### Compatibility-first
|
|
72
|
+
Current OpenClaw behavior must not break while module boundaries are extracted.
|
|
73
|
+
|
|
74
|
+
### Target-based packaging
|
|
75
|
+
Do **not** treat the whole repository output as one OpenClaw-only artifact.
|
|
76
|
+
|
|
77
|
+
- OpenClaw artifact should contain only what OpenClaw needs
|
|
78
|
+
- Paperclip artifact should contain only what Paperclip needs
|
|
79
|
+
- Core artifact should stay reusable for future systems
|
|
80
|
+
|
|
81
|
+
### Shared contracts
|
|
82
|
+
The following should be shared across runtimes:
|
|
83
|
+
- namespace policy
|
|
84
|
+
- actor context contract
|
|
85
|
+
- error model
|
|
86
|
+
- use-case interfaces
|
|
87
|
+
- rollout guardrails
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## 4) Quick start for OpenClaw
|
|
92
|
+
|
|
93
|
+
If your current goal is still **“install the memory plugin into OpenClaw”**, use this section.
|
|
94
|
+
|
|
95
|
+
### Install
|
|
17
96
|
|
|
18
97
|
```bash
|
|
19
98
|
openclaw plugins install @mrc2204/agent-smart-memo
|
|
20
99
|
```
|
|
21
100
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
### 1. Prerequisites
|
|
101
|
+
### Prerequisites
|
|
25
102
|
|
|
26
|
-
You need
|
|
103
|
+
You need these services running:
|
|
27
104
|
|
|
28
|
-
| Service |
|
|
29
|
-
|
|
30
|
-
|
|
|
31
|
-
|
|
|
105
|
+
| Service | Purpose | Example |
|
|
106
|
+
|---|---|---|
|
|
107
|
+
| Qdrant | Semantic vector memory | `docker run -d -p 6333:6333 qdrant/qdrant` |
|
|
108
|
+
| Embedding backend | Embeddings for semantic memory | Ollama / OpenAI-compatible / docker adapter |
|
|
109
|
+
| LLM endpoint | Fact extraction / auto-capture | Any OpenAI-compatible API |
|
|
32
110
|
|
|
33
|
-
###
|
|
111
|
+
### OpenClaw config example
|
|
34
112
|
|
|
35
|
-
Add to
|
|
113
|
+
Add to `~/.openclaw/openclaw.json`:
|
|
36
114
|
|
|
37
115
|
```json5
|
|
38
116
|
{
|
|
@@ -45,25 +123,20 @@ Add to your `~/.openclaw/openclaw.json`:
|
|
|
45
123
|
"agent-smart-memo": {
|
|
46
124
|
enabled: true,
|
|
47
125
|
config: {
|
|
48
|
-
// Required: Qdrant connection
|
|
49
126
|
qdrantHost: "localhost",
|
|
50
127
|
qdrantPort: 6333,
|
|
51
128
|
qdrantCollection: "openclaw_memory",
|
|
52
129
|
|
|
53
|
-
// Required: Any OpenAI-compatible API for fact extraction
|
|
54
130
|
llmBaseUrl: "https://api.openai.com/v1",
|
|
55
131
|
llmApiKey: "sk-...",
|
|
56
132
|
llmModel: "gpt-4o-mini",
|
|
57
133
|
|
|
58
|
-
// Required: Embedding backend (additive, backward-compatible)
|
|
59
134
|
embedBaseUrl: "http://localhost:11434",
|
|
60
|
-
embedBackend: "ollama",
|
|
61
|
-
embedModel: "
|
|
135
|
+
embedBackend: "ollama",
|
|
136
|
+
embedModel: "qwen3-embedding:0.6b",
|
|
62
137
|
embedDimensions: 1024,
|
|
63
138
|
|
|
64
|
-
|
|
65
|
-
// Priority: OPENCLAW_SLOTDB_DIR > config.slotDbDir > ${OPENCLAW_STATE_DIR}/agent-memo
|
|
66
|
-
slotDbDir: "/Users/mrcagents/.openclaw/agent-memo"
|
|
139
|
+
slotDbDir: "/Users/your-user/.openclaw/agent-memo"
|
|
67
140
|
}
|
|
68
141
|
}
|
|
69
142
|
}
|
|
@@ -71,156 +144,265 @@ Add to your `~/.openclaw/openclaw.json`:
|
|
|
71
144
|
}
|
|
72
145
|
```
|
|
73
146
|
|
|
74
|
-
###
|
|
147
|
+
### OpenClaw target commands
|
|
75
148
|
|
|
76
|
-
|
|
149
|
+
```bash
|
|
150
|
+
npm install
|
|
151
|
+
npm run build
|
|
152
|
+
openclaw plugins install -l .
|
|
153
|
+
```
|
|
77
154
|
|
|
78
|
-
|
|
155
|
+
---
|
|
79
156
|
|
|
80
|
-
|
|
157
|
+
## 5) Quick start for Paperclip
|
|
81
158
|
|
|
82
|
-
|
|
83
|
-
- `docker` → `/engines/llama.cpp/v1/embeddings` body `{ model, input }`
|
|
84
|
-
- `openai` → `/v1/embeddings` body `{ model, input }`
|
|
159
|
+
If your goal is to let **Paperclip** consume the same memory core:
|
|
85
160
|
|
|
86
|
-
|
|
161
|
+
### Build the Paperclip target
|
|
87
162
|
|
|
88
|
-
|
|
163
|
+
```bash
|
|
164
|
+
npm install
|
|
165
|
+
npm run build:paperclip
|
|
166
|
+
npm run package:paperclip
|
|
167
|
+
npm run pack:paperclip
|
|
168
|
+
```
|
|
89
169
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
| `llmBaseUrl` | string | — | OpenAI-compatible API base URL |
|
|
96
|
-
| `llmApiKey` | string | — | API key for the LLM |
|
|
97
|
-
| `llmModel` | string | `"gpt-4o-mini"` | Model for fact extraction |
|
|
98
|
-
| `embedBaseUrl` | string | `"http://localhost:11434"` | Embedding service base URL |
|
|
99
|
-
| `embedBackend` | string | _unset_ | Optional backend selector: `ollama` \| `openai` \| `docker` (unset = legacy auto behavior) |
|
|
100
|
-
| `embedModel` | string | `"mxbai-embed-large"` | Embedding model name |
|
|
101
|
-
| `embedDimensions` | number | `1024` | Embedding vector dimensions |
|
|
102
|
-
| `slotDbDir` | string | `${OPENCLAW_STATE_DIR}/agent-memo` | Explicit SlotDB directory. Overridden by `OPENCLAW_SLOTDB_DIR` if set |
|
|
103
|
-
| `autoCaptureEnabled` | boolean | `true` | Enable automatic fact extraction |
|
|
104
|
-
| `autoCaptureMinConfidence` | number | `0.7` | Minimum confidence to store a fact (0-1) |
|
|
105
|
-
| `contextWindowMaxTokens` | number | `12000` | Max tokens sent to LLM for extraction |
|
|
106
|
-
| `summarizeEveryActions` | number | `6` | Auto-summarize project state every N turns |
|
|
107
|
-
| `slotCategories` | string[] | `["profile","preferences","project","environment","custom"]` | Allowed slot categories |
|
|
108
|
-
| `maxSlots` | number | `500` | Max slots per agent+user scope |
|
|
109
|
-
| `injectStateTokenBudget` | number | `500` | Max tokens for auto-recall context injection |
|
|
170
|
+
### What Paperclip consumes
|
|
171
|
+
Paperclip should consume:
|
|
172
|
+
- shared core contracts/use-cases
|
|
173
|
+
- Paperclip adapter runtime
|
|
174
|
+
- no OpenClaw plugin metadata/runtime dependency unless explicitly needed
|
|
110
175
|
|
|
111
|
-
|
|
176
|
+
### Current maturity
|
|
177
|
+
Paperclip path has:
|
|
178
|
+
- adapter contracts
|
|
179
|
+
- compatibility mapper
|
|
180
|
+
- runtime wrapper
|
|
181
|
+
- production-like smoke verification
|
|
112
182
|
|
|
113
|
-
|
|
183
|
+
But README intentionally does **not** overclaim this as full production-grade multi-runtime completion.
|
|
114
184
|
|
|
115
|
-
|
|
185
|
+
---
|
|
116
186
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
187
|
+
## 6) Build targets
|
|
188
|
+
|
|
189
|
+
### Default build
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
npm run build
|
|
193
|
+
```
|
|
120
194
|
|
|
121
|
-
|
|
195
|
+
Default build remains **OpenClaw-compatible** for backward compatibility.
|
|
122
196
|
|
|
123
|
-
|
|
124
|
-
- Legacy `new SlotDB("/Users/mrcagents/.openclaw")` still resolves to `/Users/mrcagents/.openclaw/agent-memo/slots.db`
|
|
125
|
-
- Passing `/Users/mrcagents/.openclaw/agent-memo` as the target dir will **not** create nested `/agent-memo/agent-memo`
|
|
197
|
+
### Explicit targets
|
|
126
198
|
|
|
199
|
+
```bash
|
|
200
|
+
npm run build:openclaw
|
|
201
|
+
npm run build:paperclip
|
|
202
|
+
npm run build:core
|
|
203
|
+
npm run build:all
|
|
204
|
+
```
|
|
127
205
|
|
|
128
|
-
|
|
206
|
+
### Packaging
|
|
129
207
|
|
|
208
|
+
```bash
|
|
209
|
+
npm run package:openclaw
|
|
210
|
+
npm run package:paperclip
|
|
211
|
+
npm run package:core
|
|
130
212
|
```
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
Facts stored in SlotDB + Qdrant
|
|
139
|
-
↓
|
|
140
|
-
Next conversation starts
|
|
141
|
-
↓
|
|
142
|
-
Auto-Recall searches relevant memories
|
|
143
|
-
↓
|
|
144
|
-
Context injected into agent prompt
|
|
145
|
-
↓
|
|
146
|
-
Agent "remembers" previous conversations ✨
|
|
213
|
+
|
|
214
|
+
### Pack tarballs
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
npm run pack:openclaw
|
|
218
|
+
npm run pack:paperclip
|
|
219
|
+
npm run pack:core
|
|
147
220
|
```
|
|
148
221
|
|
|
149
|
-
###
|
|
222
|
+
### Publish targets
|
|
150
223
|
|
|
151
|
-
|
|
224
|
+
```bash
|
|
225
|
+
npm run publish:openclaw
|
|
226
|
+
npm run publish:paperclip
|
|
227
|
+
npm run publish:core
|
|
228
|
+
```
|
|
152
229
|
|
|
153
|
-
|
|
154
|
-
|------|----------------------|---------------|
|
|
155
|
-
| `general` | Most conversations | Key decisions, rules, configurations |
|
|
156
|
-
| `principles` | Learning or teaching content | Core principles, atomic rules |
|
|
157
|
-
| `requirements` | Technical specs or constraints | Measurable requirements, acceptance criteria |
|
|
158
|
-
| `market_signal` | Financial or market discussions | Actionable signals, risk levels, triggers |
|
|
230
|
+
> Publish requires valid npm authentication. If `NPM_TOKEN` is missing, publish should be treated as not ready / dry-run only.
|
|
159
231
|
|
|
160
|
-
|
|
232
|
+
---
|
|
161
233
|
|
|
162
|
-
##
|
|
234
|
+
## 7) CI/CD model
|
|
163
235
|
|
|
164
|
-
|
|
236
|
+
GitHub Actions workflow: `.github/workflows/publish.yml`
|
|
165
237
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
| `memory_slot_delete` | Remove a slot |
|
|
174
|
-
| `memory_slot_list` | List all slots for current scope |
|
|
175
|
-
| `memory_graph_add` | Add a knowledge graph relation |
|
|
176
|
-
| `memory_graph_query` | Query the knowledge graph |
|
|
238
|
+
Current flow:
|
|
239
|
+
- matrix build for `openclaw`, `paperclip`, `core`
|
|
240
|
+
- build → package → pack `.tgz` → upload artifact
|
|
241
|
+
- target-aware tests
|
|
242
|
+
- `workflow_dispatch` for manual publish
|
|
243
|
+
- `dry_run` supported
|
|
244
|
+
- real publish gated by `NPM_TOKEN`
|
|
177
245
|
|
|
178
|
-
|
|
246
|
+
### Important distinction
|
|
247
|
+
A `work/...` branch is for:
|
|
248
|
+
- **CI checks**
|
|
249
|
+
- **PR review**
|
|
250
|
+
- **dry-run readiness**
|
|
179
251
|
|
|
180
|
-
|
|
252
|
+
It is **not** the same as:
|
|
253
|
+
- production deploy
|
|
254
|
+
- final release approval
|
|
255
|
+
- final npm publish approval
|
|
181
256
|
|
|
182
|
-
|
|
183
|
-
|----------|-------------|------------|
|
|
184
|
-
| OpenAI | `https://api.openai.com/v1` | `gpt-4o-mini` |
|
|
185
|
-
| Anthropic (via proxy) | Your proxy URL | `claude-sonnet-4-20250514` |
|
|
186
|
-
| Local (Ollama) | `http://localhost:11434/v1` | `llama3.2` |
|
|
187
|
-
| OpenRouter | `https://openrouter.ai/api/v1` | `google/gemini-2.5-flash` |
|
|
188
|
-
| Any proxy | Your proxy URL | Your model |
|
|
257
|
+
Recommended flow:
|
|
189
258
|
|
|
190
|
-
|
|
259
|
+
```text
|
|
260
|
+
work/... push -> CI checks -> PR review -> approve -> merge default branch -> publish/release/deploy
|
|
261
|
+
```
|
|
191
262
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## 8) Memory capabilities
|
|
266
|
+
|
|
267
|
+
### Semantic memory
|
|
268
|
+
- `memory_search`
|
|
269
|
+
- `memory_store`
|
|
270
|
+
- namespace-aware retrieval
|
|
271
|
+
- registry-aware alias normalization
|
|
272
|
+
- explicit unknown namespace validation
|
|
273
|
+
|
|
274
|
+
### Slot memory
|
|
275
|
+
- `memory_slot_get`
|
|
276
|
+
- `memory_slot_set`
|
|
277
|
+
- `memory_slot_delete`
|
|
278
|
+
- `memory_slot_list`
|
|
279
|
+
|
|
280
|
+
### Graph memory
|
|
281
|
+
- entity create/get/search
|
|
282
|
+
- relationship add/remove
|
|
283
|
+
- scoped traversal
|
|
195
284
|
|
|
196
|
-
|
|
197
|
-
|
|
285
|
+
### Runtime automation
|
|
286
|
+
- auto-capture
|
|
287
|
+
- auto-recall
|
|
288
|
+
- runtime identity injection where supported
|
|
198
289
|
|
|
199
|
-
|
|
200
|
-
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
## 9) Configuration notes
|
|
293
|
+
|
|
294
|
+
### Embedding backend mapping
|
|
295
|
+
When `embedBackend` is set:
|
|
296
|
+
- `ollama` → `/api/embeddings`
|
|
297
|
+
- `docker` → `/engines/llama.cpp/v1/embeddings`
|
|
298
|
+
- `openai` → `/v1/embeddings`
|
|
299
|
+
|
|
300
|
+
If omitted, legacy auto behavior is preserved.
|
|
301
|
+
|
|
302
|
+
### SlotDB path resolution
|
|
303
|
+
Resolution order:
|
|
304
|
+
1. `OPENCLAW_SLOTDB_DIR`
|
|
305
|
+
2. plugin config `slotDbDir`
|
|
306
|
+
3. `${OPENCLAW_STATE_DIR}/agent-memo`
|
|
201
307
|
|
|
202
|
-
|
|
203
|
-
|
|
308
|
+
---
|
|
309
|
+
|
|
310
|
+
## 10) Verification levels
|
|
311
|
+
|
|
312
|
+
### Build level
|
|
313
|
+
Confirms code compiles:
|
|
314
|
+
|
|
315
|
+
```bash
|
|
316
|
+
npm run build
|
|
317
|
+
npm run build:all
|
|
204
318
|
```
|
|
205
319
|
|
|
206
|
-
|
|
320
|
+
### Contract / integration level
|
|
207
321
|
|
|
208
322
|
```bash
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
323
|
+
npm test
|
|
324
|
+
npm run test:openclaw
|
|
325
|
+
npm run test:paperclip
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### Production-like runtime verification
|
|
329
|
+
Examples already added in this repo include:
|
|
330
|
+
- Paperclip runtime E2E
|
|
331
|
+
- OpenClaw anti-regression integration
|
|
332
|
+
- production-like smoke parity harness
|
|
333
|
+
|
|
334
|
+
This is stronger than mock-only testing, but still distinct from a full production deployment.
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
## 11) Repository layout (high level)
|
|
339
|
+
|
|
340
|
+
```text
|
|
341
|
+
src/
|
|
342
|
+
core/
|
|
343
|
+
contracts/
|
|
344
|
+
usecases/
|
|
345
|
+
adapters/
|
|
346
|
+
openclaw/
|
|
347
|
+
paperclip/
|
|
348
|
+
tools/
|
|
349
|
+
hooks/
|
|
350
|
+
entries/
|
|
351
|
+
services/
|
|
352
|
+
db/
|
|
353
|
+
shared/
|
|
354
|
+
|
|
355
|
+
scripts/
|
|
356
|
+
artifacts/
|
|
357
|
+
docs/architecture/
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
---
|
|
212
361
|
|
|
213
|
-
|
|
362
|
+
## 12) Current project status
|
|
363
|
+
|
|
364
|
+
Current repo status after ASM-43 work:
|
|
365
|
+
- architecture pack completed
|
|
366
|
+
- implementation pack substantially advanced
|
|
367
|
+
- runtime wiring exists for OpenClaw and Paperclip paths
|
|
368
|
+
- production-like smoke parity evidence exists
|
|
369
|
+
- target-based packaging/build pipeline exists
|
|
370
|
+
|
|
371
|
+
Still be precise about claims:
|
|
372
|
+
- strong progress beyond scaffold ✅
|
|
373
|
+
- compatibility-first runtime wiring ✅
|
|
374
|
+
- full production-grade multi-runtime completion should only be claimed with full runtime-host evidence and approved release flow
|
|
375
|
+
|
|
376
|
+
---
|
|
377
|
+
|
|
378
|
+
## 13) Useful commands
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
# install dependencies
|
|
214
382
|
npm install
|
|
383
|
+
|
|
384
|
+
# default build (OpenClaw target)
|
|
215
385
|
npm run build
|
|
216
386
|
|
|
217
|
-
#
|
|
218
|
-
|
|
387
|
+
# build all targets
|
|
388
|
+
npm run build:all
|
|
219
389
|
|
|
220
|
-
#
|
|
390
|
+
# test
|
|
221
391
|
npm test
|
|
392
|
+
npm run test:openclaw
|
|
393
|
+
npm run test:paperclip
|
|
394
|
+
|
|
395
|
+
# package / pack
|
|
396
|
+
npm run package:openclaw
|
|
397
|
+
npm run package:paperclip
|
|
398
|
+
npm run package:core
|
|
399
|
+
npm run pack:openclaw
|
|
400
|
+
npm run pack:paperclip
|
|
401
|
+
npm run pack:core
|
|
222
402
|
```
|
|
223
403
|
|
|
224
|
-
|
|
404
|
+
---
|
|
405
|
+
|
|
406
|
+
## 14) License
|
|
225
407
|
|
|
226
408
|
MIT © [mrc2204](https://github.com/cong91)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SlotDB } from "../../db/slot-db.js";
|
|
2
|
+
import type { MemoryUseCasePort } from "../../core/contracts/adapter-contracts.js";
|
|
3
|
+
import type { SemanticMemoryUseCase } from "../../core/usecases/semantic-memory-usecase.js";
|
|
4
|
+
import { type MemoryRuntimeConfig } from "../../core/runtime-boundary.js";
|
|
5
|
+
export declare function configureOpenClawRuntime(options?: {
|
|
6
|
+
stateDir?: string;
|
|
7
|
+
slotDbDir?: string;
|
|
8
|
+
semanticUseCaseFactory?: (slotDbDir: string) => SemanticMemoryUseCase | undefined;
|
|
9
|
+
}): MemoryRuntimeConfig;
|
|
10
|
+
export declare function getSessionKey(ctx: any): string;
|
|
11
|
+
export declare function parseOpenClawSessionIdentity(sessionKey: string): {
|
|
12
|
+
userId: string;
|
|
13
|
+
agentId: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function getSlotDBForContext(ctx: any): SlotDB;
|
|
16
|
+
export declare function getMemoryUseCasePortForContext(ctx: any): MemoryUseCasePort;
|
|
17
|
+
export declare function createOpenClawResult(text: string, isError?: boolean): {
|
|
18
|
+
content: {
|
|
19
|
+
type: "text";
|
|
20
|
+
text: string;
|
|
21
|
+
}[];
|
|
22
|
+
details: {
|
|
23
|
+
toolResult: {
|
|
24
|
+
text: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
isError: boolean;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=tool-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-runtime.d.ts","sourceRoot":"","sources":["../../../src/adapters/openclaw/tool-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AAC5F,OAAO,EAKL,KAAK,mBAAmB,EACzB,MAAM,gCAAgC,CAAC;AAQxC,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sBAAsB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,qBAAqB,GAAG,SAAS,CAAC;CACnF,GAAG,mBAAmB,CAStB;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAE9C;AAED,wBAAgB,4BAA4B,CAAC,UAAU,EAAE,MAAM,GAAG;IAChE,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,CAEA;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAQpD;AAED,wBAAgB,8BAA8B,CAAC,GAAG,EAAE,GAAG,GAAG,iBAAiB,CAU1E;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,UAAQ;;;;;;;;;;;EAEjE"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { SlotDB } from "../../db/slot-db.js";
|
|
2
|
+
import { DefaultMemoryUseCasePort } from "../../core/usecases/default-memory-usecase-port.js";
|
|
3
|
+
import { createInitialRuntimeConfig, createToolTextResult, parseSessionIdentity, resolveSlotDbDirForContext, } from "../../core/runtime-boundary.js";
|
|
4
|
+
// OpenClaw runtime adapter state
|
|
5
|
+
let runtimeConfig = createInitialRuntimeConfig();
|
|
6
|
+
const dbInstances = new Map();
|
|
7
|
+
const useCasePortInstances = new Map();
|
|
8
|
+
let semanticUseCaseFactory;
|
|
9
|
+
export function configureOpenClawRuntime(options) {
|
|
10
|
+
runtimeConfig = {
|
|
11
|
+
stateDir: options?.stateDir || runtimeConfig.stateDir,
|
|
12
|
+
slotDbDir: options?.slotDbDir || runtimeConfig.slotDbDir,
|
|
13
|
+
};
|
|
14
|
+
if (options?.semanticUseCaseFactory) {
|
|
15
|
+
semanticUseCaseFactory = options.semanticUseCaseFactory;
|
|
16
|
+
}
|
|
17
|
+
return runtimeConfig;
|
|
18
|
+
}
|
|
19
|
+
export function getSessionKey(ctx) {
|
|
20
|
+
return ctx?.sessionKey || "agent:main:default";
|
|
21
|
+
}
|
|
22
|
+
export function parseOpenClawSessionIdentity(sessionKey) {
|
|
23
|
+
return parseSessionIdentity(sessionKey);
|
|
24
|
+
}
|
|
25
|
+
export function getSlotDBForContext(ctx) {
|
|
26
|
+
const slotDbDir = resolveSlotDbDirForContext(ctx, runtimeConfig);
|
|
27
|
+
let db = dbInstances.get(slotDbDir);
|
|
28
|
+
if (!db) {
|
|
29
|
+
db = new SlotDB(runtimeConfig.stateDir, { slotDbDir });
|
|
30
|
+
dbInstances.set(slotDbDir, db);
|
|
31
|
+
}
|
|
32
|
+
return db;
|
|
33
|
+
}
|
|
34
|
+
export function getMemoryUseCasePortForContext(ctx) {
|
|
35
|
+
const slotDbDir = resolveSlotDbDirForContext(ctx, runtimeConfig);
|
|
36
|
+
let port = useCasePortInstances.get(slotDbDir);
|
|
37
|
+
if (!port) {
|
|
38
|
+
const db = getSlotDBForContext(ctx);
|
|
39
|
+
const semanticUseCase = semanticUseCaseFactory ? semanticUseCaseFactory(slotDbDir) : undefined;
|
|
40
|
+
port = new DefaultMemoryUseCasePort(db, semanticUseCase);
|
|
41
|
+
useCasePortInstances.set(slotDbDir, port);
|
|
42
|
+
}
|
|
43
|
+
return port;
|
|
44
|
+
}
|
|
45
|
+
export function createOpenClawResult(text, isError = false) {
|
|
46
|
+
return createToolTextResult(text, isError);
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=tool-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-runtime.js","sourceRoot":"","sources":["../../../src/adapters/openclaw/tool-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,oDAAoD,CAAC;AAG9F,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,EACpB,oBAAoB,EACpB,0BAA0B,GAE3B,MAAM,gCAAgC,CAAC;AAExC,iCAAiC;AACjC,IAAI,aAAa,GAAwB,0BAA0B,EAAE,CAAC;AACtE,MAAM,WAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;AAC9C,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAA6B,CAAC;AAClE,IAAI,sBAA8F,CAAC;AAEnG,MAAM,UAAU,wBAAwB,CAAC,OAIxC;IACC,aAAa,GAAG;QACd,QAAQ,EAAE,OAAO,EAAE,QAAQ,IAAI,aAAa,CAAC,QAAQ;QACrD,SAAS,EAAE,OAAO,EAAE,SAAS,IAAI,aAAa,CAAC,SAAS;KACzD,CAAC;IACF,IAAI,OAAO,EAAE,sBAAsB,EAAE,CAAC;QACpC,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAC1D,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,GAAQ;IACpC,OAAO,GAAG,EAAE,UAAU,IAAI,oBAAoB,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,UAAkB;IAI7D,OAAO,oBAAoB,CAAC,UAAU,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,GAAQ;IAC1C,MAAM,SAAS,GAAG,0BAA0B,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;IACjE,IAAI,EAAE,GAAG,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACpC,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,EAAE,GAAG,IAAI,MAAM,CAAC,aAAa,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;QACvD,WAAW,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,8BAA8B,CAAC,GAAQ;IACrD,MAAM,SAAS,GAAG,0BAA0B,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;IACjE,IAAI,IAAI,GAAG,oBAAoB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC/C,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,EAAE,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;QACpC,MAAM,eAAe,GAAG,sBAAsB,CAAC,CAAC,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC/F,IAAI,GAAG,IAAI,wBAAwB,CAAC,EAAE,EAAE,eAAe,CAAC,CAAC;QACzD,oBAAoB,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,IAAY,EAAE,OAAO,GAAG,KAAK;IAChE,OAAO,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { MemoryNamespace } from "../../shared/memory-config.js";
|
|
2
|
+
export interface MemoryContext {
|
|
3
|
+
userId: string;
|
|
4
|
+
agentId: string;
|
|
5
|
+
sessionId?: string;
|
|
6
|
+
traceId?: string;
|
|
7
|
+
metadata?: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
export interface CoreRequestEnvelope<TPayload> {
|
|
10
|
+
context: MemoryContext;
|
|
11
|
+
namespace?: MemoryNamespace;
|
|
12
|
+
payload: TPayload;
|
|
13
|
+
meta?: {
|
|
14
|
+
source: "openclaw" | "paperclip" | "cli" | "test";
|
|
15
|
+
traceId?: string;
|
|
16
|
+
toolName?: string;
|
|
17
|
+
requestId?: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export type MemoryUseCaseName = "slot.get" | "slot.set" | "slot.list" | "slot.delete" | "memory.capture" | "memory.search" | "graph.entity.get" | "graph.entity.set" | "graph.rel.add" | "graph.rel.remove" | "graph.search";
|
|
21
|
+
export interface MemoryUseCasePort {
|
|
22
|
+
run<TReq, TRes>(useCase: MemoryUseCaseName, req: CoreRequestEnvelope<TReq>): Promise<TRes>;
|
|
23
|
+
}
|
|
24
|
+
export interface RuntimeContextMapper<TRuntimeCtx> {
|
|
25
|
+
toMemoryContext(runtimeCtx: TRuntimeCtx): MemoryContext;
|
|
26
|
+
toNamespace(input: unknown): MemoryNamespace | undefined;
|
|
27
|
+
}
|
|
28
|
+
export interface RuntimeErrorPresenter<TRuntimeErr> {
|
|
29
|
+
fromMemoryError(error: unknown): TRuntimeErr;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=adapter-contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter-contracts.d.ts","sourceRoot":"","sources":["../../../src/core/contracts/adapter-contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAErE,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,mBAAmB,CAAC,QAAQ;IAC3C,OAAO,EAAE,aAAa,CAAC;IACvB,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,OAAO,EAAE,QAAQ,CAAC;IAClB,IAAI,CAAC,EAAE;QACL,MAAM,EAAE,UAAU,GAAG,WAAW,GAAG,KAAK,GAAG,MAAM,CAAC;QAClD,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,MAAM,MAAM,iBAAiB,GACzB,UAAU,GACV,UAAU,GACV,WAAW,GACX,aAAa,GACb,gBAAgB,GAChB,eAAe,GACf,kBAAkB,GAClB,kBAAkB,GAClB,eAAe,GACf,kBAAkB,GAClB,cAAc,CAAC;AAEnB,MAAM,WAAW,iBAAiB;IAChC,GAAG,CAAC,IAAI,EAAE,IAAI,EACZ,OAAO,EAAE,iBAAiB,EAC1B,GAAG,EAAE,mBAAmB,CAAC,IAAI,CAAC,GAC7B,OAAO,CAAC,IAAI,CAAC,CAAC;CAClB;AAED,MAAM,WAAW,oBAAoB,CAAC,WAAW;IAC/C,eAAe,CAAC,UAAU,EAAE,WAAW,GAAG,aAAa,CAAC;IACxD,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,SAAS,CAAC;CAC1D;AAED,MAAM,WAAW,qBAAqB,CAAC,WAAW;IAChD,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,CAAC;CAC9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter-contracts.js","sourceRoot":"","sources":["../../../src/core/contracts/adapter-contracts.ts"],"names":[],"mappings":""}
|