openclaw-cloudflare-vectorize-memory 0.1.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/LICENSE +674 -0
- package/README.md +197 -0
- package/dist/index.js +1459 -0
- package/dist/index.js.map +1 -0
- package/dist/types/cli.d.ts +17 -0
- package/dist/types/cloudflare-api.d.ts +8 -0
- package/dist/types/companion-store.d.ts +10 -0
- package/dist/types/config.d.ts +172 -0
- package/dist/types/constants.d.ts +31 -0
- package/dist/types/doctor.d.ts +6 -0
- package/dist/types/embeddings-client.d.ts +8 -0
- package/dist/types/errors.d.ts +11 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/migration.d.ts +35 -0
- package/dist/types/namespace.d.ts +7 -0
- package/dist/types/prompt.d.ts +2 -0
- package/dist/types/public-artifacts.d.ts +2 -0
- package/dist/types/record-mapper.d.ts +24 -0
- package/dist/types/runtime.d.ts +5 -0
- package/dist/types/search-manager.d.ts +24 -0
- package/dist/types/service-factory.d.ts +8 -0
- package/dist/types/service.d.ts +59 -0
- package/dist/types/tools.d.ts +5 -0
- package/dist/types/types.d.ts +169 -0
- package/dist/types/vectorize-client.d.ts +17 -0
- package/openclaw.plugin.json +169 -0
- package/package.json +63 -0
package/README.md
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# OpenClaw Cloudflare Vectorize Memory
|
|
2
|
+
|
|
3
|
+
OpenClaw memory plugin backed by **Cloudflare Vectorize** for storage/search and **Workers AI** for embeddings.
|
|
4
|
+
|
|
5
|
+
## What it provides
|
|
6
|
+
|
|
7
|
+
- `kind: "memory"` OpenClaw plugin
|
|
8
|
+
- Cloudflare Workers AI embedding provider adapter: `cloudflare-workers-ai`
|
|
9
|
+
- Cloudflare-backed memory tools:
|
|
10
|
+
- `cloudflare_memory_search`
|
|
11
|
+
- `cloudflare_memory_get`
|
|
12
|
+
- `cloudflare_memory_upsert`
|
|
13
|
+
- `cloudflare_memory_delete`
|
|
14
|
+
- CLI commands under `cf-memory`
|
|
15
|
+
- Two storage modes:
|
|
16
|
+
- `vectorize-inline` (default): stores retrievable text directly in Vectorize metadata
|
|
17
|
+
- `companion-store`: stores vectors in Vectorize and full payloads in a local JSON sidecar
|
|
18
|
+
- Migration support for legacy markdown-based memory corpora
|
|
19
|
+
|
|
20
|
+
## Requirements
|
|
21
|
+
|
|
22
|
+
- Node 22+
|
|
23
|
+
- OpenClaw 2026.4.11+
|
|
24
|
+
- A Cloudflare API token with the permissions needed for:
|
|
25
|
+
- **Workers AI**
|
|
26
|
+
- **Vectorize**
|
|
27
|
+
|
|
28
|
+
If you want the plugin to create the index for you, the token must include write permissions.
|
|
29
|
+
|
|
30
|
+
## Install
|
|
31
|
+
|
|
32
|
+
### npm
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
openclaw plugins install openclaw-cloudflare-vectorize-memory
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### ClawHub
|
|
39
|
+
|
|
40
|
+
Publish the package with the included `openclaw.plugin.json` manifest and install it through normal ClawHub/OpenClaw plugin flows.
|
|
41
|
+
|
|
42
|
+
## Publishing to npmjs
|
|
43
|
+
|
|
44
|
+
After authenticating with npm for the target package owner, publish with:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npm run publish:npmjs
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The script runs `check`, `test`, and `build` before calling `npm publish --access public`.
|
|
51
|
+
|
|
52
|
+
## Recommended environment variables
|
|
53
|
+
|
|
54
|
+
Cloudflare-standard variables:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
set CLOUDFLARE_ACCOUNT_ID=your-account-id
|
|
58
|
+
set CLOUDFLARE_API_TOKEN=your-api-token
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Plugin-specific variables:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
set CLOUDFLARE_VECTORIZE_INDEX_NAME=openclaw-memory
|
|
65
|
+
set CLOUDFLARE_WORKERS_AI_EMBEDDING_MODEL=@cf/baai/bge-base-en-v1.5
|
|
66
|
+
set CLOUDFLARE_VECTORIZE_TOP_K=5
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Optional:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
set CLOUDFLARE_VECTORIZE_NAMESPACE=my-shared-namespace
|
|
73
|
+
set OPENCLAW_CF_MEMORY_STORAGE_MODE=companion-store
|
|
74
|
+
set OPENCLAW_CF_MEMORY_COMPANION_PATH=C:\path\to\companion-store.json
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
If `CLOUDFLARE_VECTORIZE_NAMESPACE` is omitted, the plugin derives namespaces from the active OpenClaw agent/session when possible.
|
|
78
|
+
|
|
79
|
+
## Example plugin config
|
|
80
|
+
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"plugins": {
|
|
84
|
+
"entries": {
|
|
85
|
+
"memory-cloudflare-vectorize": {
|
|
86
|
+
"vectorize": {
|
|
87
|
+
"indexName": "openclaw-memory",
|
|
88
|
+
"topK": 8,
|
|
89
|
+
"createIndex": {
|
|
90
|
+
"metric": "cosine"
|
|
91
|
+
},
|
|
92
|
+
"metadataIndexedFields": ["topic", "tenant"]
|
|
93
|
+
},
|
|
94
|
+
"embeddings": {
|
|
95
|
+
"model": "@cf/baai/bge-base-en-v1.5"
|
|
96
|
+
},
|
|
97
|
+
"storage": {
|
|
98
|
+
"mode": "vectorize-inline"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
You can also store `cloudflare.apiToken` as an OpenClaw secret ref instead of plaintext.
|
|
107
|
+
|
|
108
|
+
## Setup and validation
|
|
109
|
+
|
|
110
|
+
Run:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
openclaw cf-memory doctor
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
To validate config and create the Vectorize index when missing:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
openclaw cf-memory doctor --create-index
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
The doctor flow checks:
|
|
123
|
+
|
|
124
|
+
- Cloudflare credentials
|
|
125
|
+
- Vectorize index reachability
|
|
126
|
+
- Workers AI embedding dimensions
|
|
127
|
+
- embedding/index dimension compatibility
|
|
128
|
+
- metadata-index guidance for filter-heavy queries
|
|
129
|
+
|
|
130
|
+
## CLI usage
|
|
131
|
+
|
|
132
|
+
Migrate the default OpenClaw markdown memory corpus from the current workspace:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
openclaw cf-memory migrate
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Preview a migration without writing anything:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
openclaw cf-memory migrate --dry-run
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Migrate specific markdown directories or glob patterns:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
openclaw cf-memory migrate memories docs\notes\*.md
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Import everything into a single namespace override:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
openclaw cf-memory migrate memories --namespace imported-legacy
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Derive namespaces from the first relative path segment instead:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
openclaw cf-memory migrate memories --derive-namespace-from-path
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Control duplicate handling on reruns:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
openclaw cf-memory migrate memories --if-exists skip
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
By default, `migrate` overwrites records with the same derived logical id so reruns refresh previously imported content. Supported v1 sources are:
|
|
169
|
+
|
|
170
|
+
- explicit markdown files, directories, and glob patterns
|
|
171
|
+
- the default OpenClaw memory provider's readable markdown corpus when no sources are passed
|
|
172
|
+
|
|
173
|
+
The migration command stores the original source path in record metadata and reuses the normal Cloudflare upsert pipeline so embeddings, namespace handling, and storage-mode behavior stay consistent.
|
|
174
|
+
|
|
175
|
+
Search:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
openclaw cf-memory search "preferred coding style" --limit 5
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Upsert:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
openclaw cf-memory upsert "Use Vitest for plugin tests." --id testing-style --metadata "{\"topic\":\"testing\"}"
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Delete:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
openclaw cf-memory delete testing-style
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Notes
|
|
194
|
+
|
|
195
|
+
- `vectorize-inline` is the easiest mode, but it is limited by Vectorize metadata size limits.
|
|
196
|
+
- Use `companion-store` when memory payloads are too large to fit comfortably in metadata.
|
|
197
|
+
- Metadata filters in Vectorize require metadata indexes on the Cloudflare side. Configure those before relying on filter-heavy recall.
|