kagura-memory 0.11.0 → 0.13.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 +533 -75
- package/dist/cli.js +9877 -5854
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +1598 -160
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +574 -38
- package/dist/index.d.ts +574 -38
- package/dist/index.js +1594 -160
- package/dist/index.js.map +1 -1
- package/dist-mcp/mcp.cjs +1864 -0
- package/package.json +8 -2
package/README.md
CHANGED
|
@@ -14,10 +14,15 @@ This SDK connects your TypeScript/JavaScript code to [Kagura Memory Cloud](https
|
|
|
14
14
|
| **`WorkspaceClient`** | REST API | Workspace member, invitation, and API key management |
|
|
15
15
|
| **`SecretClient`** | REST API | [Zero-knowledge secrets](#zero-knowledge-secrets) — age-encrypted on your machine, opaque to the server |
|
|
16
16
|
| **`AgentsClient`** | REST API | Agent bootstrap for API-key-only callers (no MCP session) |
|
|
17
|
+
| **`MemoryClient`** | REST API | [Tool guardrails](#tool-guardrails-over-rest-memory-cloud-v0740) for API-key-only callers — the `AGENTS.md` export digest and the guardrail set |
|
|
17
18
|
|
|
18
19
|
A `kagura-memory` command-line tool ships alongside it, mirroring the Python
|
|
19
20
|
CLI's `kagura` command — see [Command line](#command-line).
|
|
20
21
|
|
|
22
|
+
For Claude Desktop, the [MCPB extension](docs/mcpb.md) provides browser sign-in
|
|
23
|
+
and a refresh-aware connection without Python or a global CLI install. The npm
|
|
24
|
+
package also includes `kagura-memory-mcp`, a transparent stdio/HTTP proxy.
|
|
25
|
+
|
|
21
26
|
## Installation
|
|
22
27
|
|
|
23
28
|
```bash
|
|
@@ -32,8 +37,10 @@ unless you ask for it.
|
|
|
32
37
|
Targets memory-cloud **v0.75.0** (`MIN_SERVER_VERSION`).
|
|
33
38
|
`checkServerVersion()` warns, and never throws, on an older server, which
|
|
34
39
|
still answers: it ignores options it predates, leaves out fields it
|
|
35
|
-
predates, and reports a tool it predates as not found.
|
|
36
|
-
|
|
40
|
+
predates, and reports a tool it predates as not found. A pre-release of
|
|
41
|
+
the minimum (`0.75.0-rc1`) counts as older, and a version it cannot read
|
|
42
|
+
(`0.75`, `main-abc123`) gets no warning, as in the Python SDK. The method
|
|
43
|
+
notes below say which server version a feature needs.
|
|
37
44
|
|
|
38
45
|
## Quick Start
|
|
39
46
|
|
|
@@ -88,6 +95,16 @@ Four ways to authenticate, in resolution order:
|
|
|
88
95
|
}
|
|
89
96
|
```
|
|
90
97
|
|
|
98
|
+
Credentials travel over HTTPS only. Every client, `login()`, `auth login
|
|
99
|
+
--server` and the URL every `setup` subcommand puts in a harness entry
|
|
100
|
+
(`setup claude`, `setup codex`, `setup hermes` and `setup openclaw`)
|
|
101
|
+
refuse a plain-HTTP URL unless its host is `localhost`, `127.0.0.1` or
|
|
102
|
+
`[::1]`, and `doctor` fails a configured `mcp_url` like that. The URL is
|
|
103
|
+
read as `fetch` reads it, so the scheme in any case (`HTTP://`), without
|
|
104
|
+
its slashes (`http:host`), or with whitespace or control characters
|
|
105
|
+
around it or a tab or newline inside it is refused all the same, as in
|
|
106
|
+
the Python SDK.
|
|
107
|
+
|
|
91
108
|
### Command line
|
|
92
109
|
|
|
93
110
|
`kagura-memory` mirrors the Python CLI's `kagura` command: its subcommands
|
|
@@ -96,26 +113,53 @@ stdout and exits with the same codes (2 for a usage error, 1 for a runtime
|
|
|
96
113
|
failure). An option a command, a group or the root does not take is
|
|
97
114
|
refused in the words of click 8.3, the version the Python CLI's lockfile
|
|
98
115
|
pins: `Error: No such option: --x`, naming the option without any value
|
|
99
|
-
given in it
|
|
100
|
-
|
|
101
|
-
|
|
116
|
+
given in it, and for a long option close to one the command takes,
|
|
117
|
+
click's suggestion after it (`Did you mean --json?`, or `(Possible
|
|
118
|
+
options: --end, --period)` for more than one); click 8.4 and later write
|
|
119
|
+
`No such option '--x'.`. An option given no value is `Error: Option '-w'
|
|
120
|
+
requires an argument.`. Either error wins over `--help`, as click reads
|
|
121
|
+
the whole command line first, and only the first one is reported,
|
|
122
|
+
followed by the command's help (where click prints its usage line and a
|
|
123
|
+
`Try '… --help'` hint first). An unknown option does not win over
|
|
124
|
+
`--help` where the Python CLI passes such options on
|
|
125
|
+
(`ignore_unknown_options`: `secret exec`, and `measure record` for a
|
|
126
|
+
negative VALUE), so `secret exec --help --bogus` prints the help; without
|
|
127
|
+
`--help`, `secret exec` still refuses an unknown option before the child
|
|
128
|
+
command rather than running it as that command. The one command not
|
|
129
|
+
ported, the few options only this bin has, and the deliberate
|
|
102
130
|
differences are listed below.
|
|
103
131
|
|
|
132
|
+
Values are read as click reads them. A choice matches exactly, as click's
|
|
133
|
+
`Choice` does, except where the Python CLI declares one case-insensitive
|
|
134
|
+
(`--source-type`, `--progress`), casefolded as click folds it; a number
|
|
135
|
+
is read as Python's `int()` and `float()` read it, `1_000`, any decimal
|
|
136
|
+
digit (`١٢`, `12`) and the whitespace they skip included (a BOM is no
|
|
137
|
+
whitespace to them); an integer id argument (`TOKEN_ID`,
|
|
138
|
+
`INVITATION_ID`, `KEY_ID`) is sent exactly, however large; and an
|
|
139
|
+
out-of-range value is echoed as click converted it (`files upload
|
|
140
|
+
--importance 2` is refused as `2.0 is not in the range 0.0<=x<=1.0.`).
|
|
141
|
+
A failure prints `Error: <message>` on stderr, and a quota or plan
|
|
142
|
+
refusal adds the lines the Python CLI adds: ` Resets at: <time>`, in
|
|
143
|
+
Python's `isoformat()` form, and ` Required plan: <label> (<key>)`.
|
|
144
|
+
|
|
104
145
|
```bash
|
|
105
146
|
npx kagura-memory --help
|
|
106
147
|
```
|
|
107
148
|
|
|
108
149
|
| Group | Commands |
|
|
109
150
|
|---|---|
|
|
110
|
-
| `auth` | `login` `logout` `refresh` `status` `use` `list` `token` |
|
|
151
|
+
| `auth` | `login` `logout` `refresh` `status` `use` `list` `token` `create-key` `list-keys` `revoke-key` |
|
|
111
152
|
| `context` | `list` `create` `update` `delete` `search-config` (plus the `contexts` alias) |
|
|
112
153
|
| memory | `remember` `recall` `reference` `forget` `update-memory` `explore` |
|
|
113
154
|
| `edge` | `list` `create` `update` `delete` |
|
|
114
155
|
| `sleep` | `history` `report` `rollback` |
|
|
156
|
+
| `measure` | `record` `series` |
|
|
115
157
|
| `files` | `upload` `list` `delete` `download-url` |
|
|
158
|
+
| `guardrails` | `load` `digest` |
|
|
116
159
|
| `resource` | `tokens {list,create,update,revoke}` `list` `setup` `schema` `stats` `indexer-status` `events` `ingest` `ingest-batch` `import` |
|
|
117
160
|
| `secret` | `keygen` `list` `put` `get` `grant` `revoke` `rotate` `delete` `pubkeys` `approve` `audit-verify` `exec` |
|
|
118
161
|
| `setup` | `claude` `codex` `hermes` `openclaw` |
|
|
162
|
+
| `workspace` | `member {list,add,set-role,remove}` `invite {create,list,revoke}` |
|
|
119
163
|
| other | `config show` `doctor` |
|
|
120
164
|
|
|
121
165
|
```bash
|
|
@@ -123,6 +167,7 @@ npx kagura-memory auth login --profile work --read-only
|
|
|
123
167
|
npx kagura-memory recall "OAuth setup" -c dev -k 10
|
|
124
168
|
npx kagura-memory recall "dependency injection" --no-rerank # skip reranking; no flag follows the context config (v0.69.0+)
|
|
125
169
|
npx kagura-memory remember -s "FastAPI DI" --content "Use Depends()" --tags "python,fastapi"
|
|
170
|
+
npx kagura-memory measure record <context-id> weight_kg 71.5 --unit kg
|
|
126
171
|
npx kagura-memory setup codex --dry-run # show the command and the entry; change nothing
|
|
127
172
|
npx kagura-memory doctor
|
|
128
173
|
```
|
|
@@ -132,6 +177,82 @@ The context id comes from `-c/--context-id`, or from `context_id` in
|
|
|
132
177
|
shared with the Python CLI, so either tool can create a profile the other
|
|
133
178
|
then uses.
|
|
134
179
|
|
|
180
|
+
**`resource setup`** names the new context after the resource, or `-n/--name`
|
|
181
|
+
(lowercase letters, digits, `-` and `_`, at most 100), which a workspace
|
|
182
|
+
that already has a context of that name needs. It prints Python's six
|
|
183
|
+
fields, `context_id`, `context_name`, `resource_id`, `token`, `token_id`
|
|
184
|
+
and `warning` (null when the server sends none); the token is shown this
|
|
185
|
+
once. `--summary` is accepted and ignored, with a note on stderr, since
|
|
186
|
+
the server's `setup_resource` has no summary: the context's owner sets it
|
|
187
|
+
afterwards with `kagura-memory context update <context_id> --summary …`.
|
|
188
|
+
As in Python, `resource tokens revoke` prints `Token revoked.`, and
|
|
189
|
+
`resource schema` prints `No schema registered for this resource.` when
|
|
190
|
+
there is none (the route's 404).
|
|
191
|
+
|
|
192
|
+
**Records print as the Python CLI prints them.** `resource tokens
|
|
193
|
+
list|create|update`, `resource list|stats|indexer-status|events|schema`,
|
|
194
|
+
`resource ingest|ingest-batch|setup`, `files list` and `files upload`
|
|
195
|
+
print the result as the Python CLI does, `model_dump_json(indent=2)` of
|
|
196
|
+
the Python SDK's model
|
|
197
|
+
([#66](https://github.com/kagura-ai/kagura-memory-typescript-sdk/issues/66)):
|
|
198
|
+
the model's keys in its order, its default for a key the server left out
|
|
199
|
+
(`null`, `false`, `0`, `[]`, `{}`, `"success"`), and no key it does not
|
|
200
|
+
have. Each value is what the model's type makes of it: `"12"` for an int
|
|
201
|
+
prints `12`, a float prints as one (`1.0`, `1e-6`), a resource event's id
|
|
202
|
+
past 2^53 prints exactly, and a timestamp prints in pydantic's form
|
|
203
|
+
(`2026-06-01T09:00:00.5+00:00` as `2026-06-01T09:00:00.500000Z`), which
|
|
204
|
+
is the form memory-cloud already sends. A record the model refuses (a
|
|
205
|
+
required field missing, a value of the wrong type) exits 1 with the
|
|
206
|
+
Python SDK's `KaguraResponseError` text, e.g. `ResourceClient.list_tokens:
|
|
207
|
+
unexpected server response for PaginatedResourceTokensResponse
|
|
208
|
+
(tokens.0.created_at: Field required). …`, and so does a body that is no
|
|
209
|
+
record at all (`null`). An untyped mapping nested past pydantic's limit
|
|
210
|
+
(256 containers) exits 1 with pydantic's `Error serializing to JSON:
|
|
211
|
+
ValueError: Circular reference detected (depth exceeded)`. One limit
|
|
212
|
+
remains: inside an untyped mapping (an event's `payload`, a batch's
|
|
213
|
+
`errors`) a number is read as JavaScript reads it, so `1.0` prints `1`
|
|
214
|
+
and an integer past 2^53 loses its last digits.
|
|
215
|
+
|
|
216
|
+
**Files and imports.** The `files` commands take their workspace from the
|
|
217
|
+
credential's own source, as the Python CLI does (its #115): `-c` when
|
|
218
|
+
given, else the OAuth profile's workspace, else the `context_id` of the
|
|
219
|
+
`.kagura.json` that holds the key; a `KAGURA_API_KEY` key needs `-c`.
|
|
220
|
+
`files delete` prints `Deleted <file_id>` and `files download-url` the bare
|
|
221
|
+
URL. `files upload --remember` writes the memory the Python CLI writes
|
|
222
|
+
(`source_uri` the file's `file://` URI, `details` the file's id, sha256,
|
|
223
|
+
size and type), and prints `{"file": …, "memory": …}`, the file as its
|
|
224
|
+
model reads it. `resource import` detects the format by the file's
|
|
225
|
+
extension, so stdin needs `--format`, and reads CSV and JSON the way
|
|
226
|
+
Python's `csv` and `json` modules read them, with their error messages
|
|
227
|
+
(exit 1). A row keeps its keys in the order read, and a doc_id taken from
|
|
228
|
+
a number is Python's `str()` of it as written (`1234567890123456789`,
|
|
229
|
+
`10.0`, `1e+20`). A `NaN` or `Infinity` in the input fails the batch
|
|
230
|
+
holding it, as the Python CLI's request encoding does (`Out of range float
|
|
231
|
+
values are not JSON compliant: nan`), rather than being sent as `null`. A
|
|
232
|
+
doc_id outside 1-255 characters and a CSV row with more cells than the
|
|
233
|
+
header are refused before anything is sent, where the Python CLI stops
|
|
234
|
+
with a traceback. Two limits of JavaScript numbers remain: a number in the
|
|
235
|
+
payload is sent as JavaScript reads it, so an integer past 2^53 loses its
|
|
236
|
+
last digits and `10.0` is sent as `10`, where Python sends them as
|
|
237
|
+
written; and `-V` above 2^53 is refused as too large (exit 2), where
|
|
238
|
+
Python sends it.
|
|
239
|
+
|
|
240
|
+
**Progress.** `files upload` and `resource import` take `-v/--verbose`
|
|
241
|
+
(repeatable) and `--progress rich|json|none`. Progress goes to stderr, one
|
|
242
|
+
line per event, so stdout carries the same result either way.
|
|
243
|
+
`--progress json` writes the Python CLI's NDJSON,
|
|
244
|
+
`{"v": 1, "ts": …, "stage": …, "kind": …, "msg": …, "detail": …}`, whose
|
|
245
|
+
last event is the operation's single `success` or `error`; `-v`, or
|
|
246
|
+
`--progress rich`, writes the lines the Python CLI shows
|
|
247
|
+
(`→ Reserving upload report.pdf (1234 bytes)`, `✓ Upload complete`,
|
|
248
|
+
`✗ Upload failed: …`); `--progress none` is silent even with `-v`. Two
|
|
249
|
+
streams end more reliably than Python's: `files upload --remember`
|
|
250
|
+
reports success only once the linked memory is written (a failed write
|
|
251
|
+
ends the stream with that error), and `resource import` ends with an
|
|
252
|
+
error when the credential fails after its start event. A stderr closed
|
|
253
|
+
early (`2>&1 | head -1`) does not stop the upload or the import. Ctrl-C
|
|
254
|
+
ends the process without a final event.
|
|
255
|
+
|
|
135
256
|
**Connecting a harness.** Each `setup` subcommand sets up an MCP entry
|
|
136
257
|
named `kagura-memory`: the URL plus a Bearer header. The key is never
|
|
137
258
|
printed, and no harness CLI gets it on its command line.
|
|
@@ -140,18 +261,25 @@ printed, and no harness CLI gets it on its command line.
|
|
|
140
261
|
comes from `--api-key`, else the `api_key` in the project's own
|
|
141
262
|
`.kagura.json` (the one in `--project-dir`), else `KAGURA_API_KEY`; the
|
|
142
263
|
URL likewise from `--mcp-url`, else that file's `mcp_url`, else
|
|
143
|
-
`KAGURA_MCP_URL
|
|
264
|
+
`KAGURA_MCP_URL`, an empty `--mcp-url` counting as none, as Python's `or`
|
|
265
|
+
reads it. It never takes them from `~/.kagura.json`, nor, with
|
|
144
266
|
`--project-dir`, from the current directory's `.kagura.json`: those are
|
|
145
267
|
another project's credentials. `.kagura.json` gets the URL as given; the
|
|
146
268
|
parameters that `--guardrails` and `--tool-profile` set go on the entry's
|
|
147
|
-
URL only.
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
269
|
+
URL only. A plain-HTTP URL to a host other than localhost is refused,
|
|
270
|
+
whichever of the three it came from, before anything is written or run
|
|
271
|
+
(exit 1, `Connection failed: MCP URL must use HTTPS for security …`, the
|
|
272
|
+
Python CLI's words, whose connection test refuses it).
|
|
273
|
+
|
|
274
|
+
Without `--agents-md`, `setup codex`, `setup hermes` and `setup openclaw`
|
|
275
|
+
never see, write, print or pass the key, as in the Python CLI. The entry
|
|
276
|
+
names the environment variable the harness reads the key from, and the
|
|
277
|
+
notes say where to put it; a missing key is no error. These three write
|
|
278
|
+
no config file themselves: no `.kagura.json`, no `.gitignore` line, no
|
|
279
|
+
harness `.env`. The harness's own CLI writes the entry, or you add the
|
|
280
|
+
printed block. The one file they may write is the AGENTS.md export
|
|
281
|
+
(`--agents-md`, below), which is fetched with the usual credential: with
|
|
282
|
+
it, a missing credential stops setup (exit 1).
|
|
155
283
|
|
|
156
284
|
| Subcommand | How the entry is applied | Where the key goes |
|
|
157
285
|
|---|---|---|
|
|
@@ -171,10 +299,18 @@ OpenClaw's `$OPENCLAW_CONFIG_PATH` (default `openclaw.json` in the state
|
|
|
171
299
|
directory). The closing notes name the command that checks it:
|
|
172
300
|
`codex mcp get kagura-memory`, `hermes mcp test kagura-memory` or
|
|
173
301
|
`openclaw mcp doctor kagura-memory --probe`. `--mcp-url` defaults to the
|
|
174
|
-
configured `mcp_url`, then `https://memory.kagura-ai.com/mcp`.
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
302
|
+
configured `mcp_url`, then `https://memory.kagura-ai.com/mcp`. It is read
|
|
303
|
+
as a URL parser reads it, as in Python (python-sdk#279): whitespace and
|
|
304
|
+
control characters around it, and any tab or newline inside it, are
|
|
305
|
+
dropped before the checks, and the entry gets that URL. A plain `http://`
|
|
306
|
+
`--mcp-url` other than localhost, in any spelling, is a usage error
|
|
307
|
+
(exit 2), since the entry sends the key there with every request; so is
|
|
308
|
+
anything but an http(s) URL with a host (`--mcp-url=--help`,
|
|
309
|
+
`memory.kagura-ai.com/mcp`, `https://[::1/mcp`), which would go on the
|
|
310
|
+
harness's command line after `--url`. A configured `mcp_url` gets the same
|
|
311
|
+
checks, and exits 1 saying to pass `--mcp-url`. `$OPENCLAW_STATE_DIR`,
|
|
312
|
+
`$OPENCLAW_CONFIG_PATH` and `$OPENCLAW_WORKSPACE_DIR` are read as OpenClaw
|
|
313
|
+
reads them: stripped, with a leading `~` expanded.
|
|
178
314
|
|
|
179
315
|
This package has no TOML, YAML or JSON5 parser, so it never rewrites those
|
|
180
316
|
files. When the harness's CLI is not on `PATH`, the block is printed on
|
|
@@ -188,8 +324,11 @@ always; for Hermes and OpenClaw only with their CLI on `PATH`, since the
|
|
|
188
324
|
Python CLI finds their entries only through it. Without the CLI, setup
|
|
189
325
|
prints the block to go in place of the old entry and exits 0. A
|
|
190
326
|
`config.toml` that cannot be read stops `setup codex` (exit 1), as in
|
|
191
|
-
Python
|
|
192
|
-
|
|
327
|
+
Python. A Hermes `config.yaml` that cannot be read, or is not UTF-8,
|
|
328
|
+
stops nothing: setup prints the whole block with Python's note to put
|
|
329
|
+
only the entry under an `mcp_servers:` key the file may have. An OpenClaw
|
|
330
|
+
file that cannot be read stops nothing either, since Python never reads
|
|
331
|
+
it, and a note says setup could not look there.
|
|
193
332
|
On Windows, a CLI installed only as an npm `.cmd` shim counts as not
|
|
194
333
|
found: Node runs one only through a shell, which would re-parse the
|
|
195
334
|
arguments.
|
|
@@ -217,14 +356,17 @@ codex`, when neither the flag nor the MCP URL (`--mcp-url` or the
|
|
|
217
356
|
configured `mcp_url`) sets one, it defaults to `off` while the Kagura
|
|
218
357
|
plugin's Codex hooks are on for the entry (their `config.json` names its
|
|
219
358
|
table in `mcp_server`, `kagura-memory` by default), and otherwise to
|
|
220
|
-
`-c
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
359
|
+
`-c`. With a context there, the notes give the `kagura-memory guardrails
|
|
360
|
+
digest … --target instructions` command, which previews what Codex
|
|
361
|
+
receives. Hermes and OpenClaw do not read the server's instructions.
|
|
362
|
+
There `--guardrails off` is refused (exit 2), and a context id is not
|
|
363
|
+
written, whether it comes from the flag or from the URL: one warning
|
|
364
|
+
names what was dropped. A first `?guardrails=off` in the URL, the value
|
|
365
|
+
the server reads, is kept, alone and with a warning of its own. Names
|
|
366
|
+
compare decoded, as the server reads them (`guard%72ails` is
|
|
367
|
+
`guardrails`). All of this is as in Python. `--tool-profile` (claude,
|
|
368
|
+
codex; memory-cloud v0.73.0+) sets `profile` and refuses an empty name.
|
|
369
|
+
The server knows
|
|
228
370
|
`full` and `core` (case-sensitive) and fails `tools/list` for any other
|
|
229
371
|
name, which leaves the harness with no Kagura tools. It applies a
|
|
230
372
|
`?tools=` allowlist already on the URL instead, so that case gets a
|
|
@@ -234,9 +376,44 @@ A `setup claude` run that leaves out a `guardrails` or `profile` value
|
|
|
234
376
|
the entry it replaces had says so in a note. `--name`, `--force` and
|
|
235
377
|
`--dry-run` (codex, hermes, openclaw) name the entry, replace an existing
|
|
236
378
|
one, and show the command or block without changing anything. A name is
|
|
237
|
-
1-64 letters, digits, `-` or `_`,
|
|
238
|
-
|
|
239
|
-
|
|
379
|
+
1-64 letters, digits, `-` or `_`, starting with a letter or digit, as in
|
|
380
|
+
Python: it is a bare argument to `codex` and `openclaw`, which would read
|
|
381
|
+
`--help` as an option. Their `--context-id` must be a context UUID
|
|
382
|
+
(exit 2 otherwise, a padded or empty one included), as in Python without
|
|
383
|
+
`--profile`: this port lists no contexts.
|
|
384
|
+
|
|
385
|
+
**The AGENTS.md export.** `--agents-md [PATH]` on `setup codex`, `setup
|
|
386
|
+
hermes` and `setup openclaw` (memory-cloud v0.74.0+) fetches the
|
|
387
|
+
context's tool guardrail export block (`MemoryClient.getGuardrailDigest`)
|
|
388
|
+
and splices it into a file the harness loads every session, between its
|
|
389
|
+
`kagura-memory:guardrails` marker lines: an earlier block is replaced in
|
|
390
|
+
place, an unchanged set rewrites nothing, and the rest of the file is
|
|
391
|
+
kept, line endings and a symlink included. Without PATH the file is the
|
|
392
|
+
harness's own: `$CODEX_HOME/AGENTS.md` (`AGENTS.override.md` when that
|
|
393
|
+
exists); for Hermes the first of `.hermes.md`, `HERMES.md`,
|
|
394
|
+
`AGENTS.override.md`, `AGENTS.md` and `CLAUDE.md` in the current
|
|
395
|
+
directory, else `AGENTS.md`; for OpenClaw `AGENTS.md` in its workspace,
|
|
396
|
+
`$OPENCLAW_WORKSPACE_DIR`, else `workspace/` in the state directory. A
|
|
397
|
+
leading `~` or `~/` in PATH is expanded to your home directory (a
|
|
398
|
+
`~user` is left as written; see below), and missing directories are
|
|
399
|
+
created. The context is `--context-id`, else a `--guardrails` context
|
|
400
|
+
UUID, never the
|
|
401
|
+
URL's `?guardrails=` or `.kagura.json`; without one, `--agents-md` is a
|
|
402
|
+
usage error (exit 2). The block is fetched on the usual credential chain
|
|
403
|
+
(`KAGURA_API_KEY`, the OAuth profile, `.kagura.json`), which setup
|
|
404
|
+
settles before it runs anything, a dry run included: no credential, or
|
|
405
|
+
one for another server than the entry's, stops setup (exit 1) with
|
|
406
|
+
nothing run. The export comes after the entry is applied or printed.
|
|
407
|
+
`wrote` lists the file, and the notes carry Python's lines: the refresh
|
|
408
|
+
command (`kagura-memory guardrails digest <ctx> --out <file>`), a warning
|
|
409
|
+
past the 32 KiB Codex reads or the 20,000 characters OpenClaw reads, and
|
|
410
|
+
Hermes's prompt-injection note. An empty digest writes nothing and says
|
|
411
|
+
so; setup never removes a block, which `guardrails digest --out` does. A
|
|
412
|
+
failed export prints the report, then the error (exit 1). `--dry-run`
|
|
413
|
+
names what the export would do to the file (create it, append the block,
|
|
414
|
+
replace the block, or update a file it cannot read). On Hermes and
|
|
415
|
+
OpenClaw a run without the export ends with Python's "Re-run with
|
|
416
|
+
--agents-md --context-id <id> …" hint.
|
|
240
417
|
|
|
241
418
|
Claude Code uses the `kagura-memory` entry from the strongest scope
|
|
242
419
|
(local > project > user). It keys local scope by the git repository root
|
|
@@ -279,21 +456,14 @@ scope.
|
|
|
279
456
|
|
|
280
457
|
**Not ported.** `kagura ingest` needs the text-extraction pipeline (PDF,
|
|
281
458
|
Office, EPUB, audio), which does not exist in this package and would cost
|
|
282
|
-
the zero-dependency promise
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
`guardrails load` and `guardrails digest`; `measure record` and
|
|
286
|
-
`measure series`; the `-v/--verbose` and `--progress` options of
|
|
287
|
-
`files upload` and `resource import`; and the `--agents-md` option of
|
|
288
|
-
`setup codex`, `setup hermes` and `setup openclaw`, the guardrail export,
|
|
289
|
-
which needs `guardrails digest` first
|
|
290
|
-
([#57](https://github.com/kagura-ai/kagura-memory-typescript-sdk/issues/57))
|
|
291
|
-
and which this CLI rejects as an unknown option. Use the Python CLI for
|
|
292
|
-
all of these. The Claude Code extras of
|
|
293
|
-
`kagura setup claude` are not ported either: its SessionStart and
|
|
294
|
-
PostToolUse hooks and its `/kagura-recall` and `/kagura-remember`
|
|
459
|
+
the zero-dependency promise; use the Python CLI for it. The Claude Code
|
|
460
|
+
extras of `kagura setup claude` are not ported either: its SessionStart
|
|
461
|
+
and PostToolUse hooks and its `/kagura-recall` and `/kagura-remember`
|
|
295
462
|
commands. `setup claude` here writes `.kagura.json` and the MCP entry
|
|
296
|
-
only, and takes their flags as inert (see above).
|
|
463
|
+
only, and takes their flags as inert (see above). Every other command of
|
|
464
|
+
the Python CLI is here as of 0.12.0
|
|
465
|
+
([#57](https://github.com/kagura-ai/kagura-memory-typescript-sdk/issues/57)),
|
|
466
|
+
with the differences in options and output this section lists.
|
|
297
467
|
|
|
298
468
|
**Only in this bin.** `secret keygen --reveal`: keygen prints the private
|
|
299
469
|
key (see key custody below) and refuses to print it to a terminal without
|
|
@@ -310,7 +480,7 @@ older scripts still run. Neither does anything now, and a note says so.
|
|
|
310
480
|
`--api-key` beside `--profile` is still the usage error (exit 2) it was,
|
|
311
481
|
with `--url-form` too.
|
|
312
482
|
|
|
313
|
-
**
|
|
483
|
+
**Five deliberate divergences.**
|
|
314
484
|
|
|
315
485
|
- `secret` needs the optional `age-encryption` peer (`npm install
|
|
316
486
|
age-encryption`), exactly as Python's `[secret]` extra works. Key
|
|
@@ -327,10 +497,24 @@ with `--url-form` too.
|
|
|
327
497
|
here, and so does the URL form of the other three. With `--url-form`,
|
|
328
498
|
those three ignore `--profile`, with a note: the Python CLI uses it
|
|
329
499
|
there to check the login, list contexts and fetch the `AGENTS.md`
|
|
330
|
-
export
|
|
500
|
+
export with that profile alone. This port lists nothing and checks no
|
|
501
|
+
login, and fetches the export on the usual credential chain, where
|
|
502
|
+
`KAGURA_PROFILE` picks a profile.
|
|
331
503
|
- `config show` does not reproduce Python's key mask
|
|
332
504
|
(`key[:8] + "..." + key[-4:]`), whose halves overlap below 12 characters
|
|
333
505
|
and print the whole secret twice.
|
|
506
|
+
- `--progress rich`, and `-v` without `--progress`, print the Python CLI's
|
|
507
|
+
`→` / `✓` / `✗` lines as plain text, the text Rich writes when stderr is
|
|
508
|
+
not a terminal: no colours even on a terminal, no wrapping at its width,
|
|
509
|
+
and no Rich markup, so `report[bold].pdf` prints as written (Rich drops
|
|
510
|
+
the `[bold]`, and a `[/…]` in an error message makes it fail). `-vv` and
|
|
511
|
+
`-vvv` show one line per detail or debug event, where Rich draws a panel;
|
|
512
|
+
neither command emits one. `--progress json` is the same NDJSON.
|
|
513
|
+
- With no `.kagura.json`, the MCP-backed commands (`recall`, `guardrails
|
|
514
|
+
load`, `measure`, …) and `doctor` reach an OAuth profile's own server.
|
|
515
|
+
The Python CLI takes the default URL its config loader fills in for the
|
|
516
|
+
server, and sends the profile's token there. A `KAGURA_API_KEY` goes to
|
|
517
|
+
`KAGURA_MCP_URL`, else the default, in both.
|
|
334
518
|
|
|
335
519
|
**`setup codex`, `setup hermes` and `setup openclaw`** also differ from
|
|
336
520
|
the Python CLI in these ways, each on purpose:
|
|
@@ -340,20 +524,33 @@ the Python CLI in these ways, each on purpose:
|
|
|
340
524
|
Python requires it. Only that fallback needs the configuration: without
|
|
341
525
|
`--mcp-url`, a `.kagura.json` that cannot be loaded stops setup (exit 1);
|
|
342
526
|
with it, setup goes on with a note, as Python never reads that file.
|
|
343
|
-
-
|
|
344
|
-
|
|
345
|
-
- `setup codex --force` runs one `codex mcp add`, which overwrites the
|
|
346
|
-
entry. Python runs `codex mcp remove` first.
|
|
527
|
+
- `-c` must be a context UUID with `--url-form --profile` too (exit 2),
|
|
528
|
+
where Python looks a name up through the profile.
|
|
347
529
|
- `setup hermes` never runs `hermes mcp add`, which prompts; it prints the
|
|
348
530
|
block, as Python does under `-y`.
|
|
349
531
|
- An existing entry is found by scanning the file, and not described by
|
|
350
532
|
kind. A readable but malformed `config.toml` does not stop
|
|
351
533
|
`setup codex`.
|
|
352
|
-
- On
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
534
|
+
- On Codex, a `?guardrails=` already in the MCP URL (`--mcp-url` or the
|
|
535
|
+
configured `mcp_url`) beats the hooks and `-c` defaults.
|
|
536
|
+
- Nothing prompts, so `--agents-md` always needs a context, and the
|
|
537
|
+
export is never offered: a dry run of Hermes or OpenClaw says "not
|
|
538
|
+
offered: this port never prompts" (or "not offered with -y").
|
|
539
|
+
- When the entry was only printed (always for Hermes), a failed export
|
|
540
|
+
says "The MCP entry is printed for you to add", where Python says it is
|
|
541
|
+
set up. When the export credential is for another server, the message
|
|
542
|
+
says what moves it here, where Python's points at `--profile`: for
|
|
543
|
+
`KAGURA_API_KEY`, which outranks every profile, `KAGURA_MCP_URL` or
|
|
544
|
+
unsetting the key; otherwise `KAGURA_PROFILE`.
|
|
545
|
+
- `--agents-md=VALUE` takes VALUE literally even when it begins with a
|
|
546
|
+
dash, where click reads `--agents-md=-y` as the default file plus `-y`.
|
|
547
|
+
- The Codex size warning counts the bytes on disk, CRLFs included, where
|
|
548
|
+
Python counts the text with its line endings folded.
|
|
549
|
+
- A `~user` in an `OPENCLAW_*` variable or in `--agents-md PATH` is left
|
|
550
|
+
as written (`--agents-md '~root/x.md'` names `~root/x.md` in the
|
|
551
|
+
current directory), where Python looks the user up (`/root/x.md`) and
|
|
552
|
+
fails the whole setup for an unknown one. File errors of the export are
|
|
553
|
+
Node's words, not Python's `[Errno …]`.
|
|
357
554
|
- Output is one JSON document on stdout, with Python's sentences in
|
|
358
555
|
`notes` and the block on stderr. A non-ASCII URL is written as UTF-8
|
|
359
556
|
where Python writes `\uXXXX` escapes; both are valid.
|
|
@@ -367,6 +564,8 @@ would accept.
|
|
|
367
564
|
apart from `--external-id=` in the `update-memory` case below.
|
|
368
565
|
- `context update --lock --unlock` is a usage error (exit 2, "mutually
|
|
369
566
|
exclusive; pick one"), where click takes whichever flag comes last.
|
|
567
|
+
- `setup … --agents-md=' '` (a path of only whitespace) is a usage error
|
|
568
|
+
(exit 2), where Python writes a file named `" "`.
|
|
370
569
|
- `--rerank --no-rerank` is the same usage error, on `recall` and on
|
|
371
570
|
`context search-config`.
|
|
372
571
|
- `auth logout --all --profile NAME` is the same usage error, where click
|
|
@@ -377,11 +576,82 @@ would accept.
|
|
|
377
576
|
CLI refuses that too, as `updateMemory` does.
|
|
378
577
|
- `-k=5` (a short option, `=`, a value) reads `5`, where click reads `=5`
|
|
379
578
|
as the value and then refuses it.
|
|
579
|
+
- A float range such as `files upload --importance` refuses `nan`, which
|
|
580
|
+
click's `FloatRange` lets through (every comparison with NaN is false).
|
|
380
581
|
- An option that takes a value does not take a following argument that
|
|
381
582
|
begins with a dash and is not a number (a lone `-` is still a value):
|
|
382
|
-
`--name-contains -auth` is a missing value here
|
|
383
|
-
|
|
384
|
-
|
|
583
|
+
`--name-contains -auth` is a missing value here (`Error: Option
|
|
584
|
+
'--name-contains' requires an argument.`), where click takes `-auth`.
|
|
585
|
+
Write `--name-contains=-auth`. A number is anything `float()` reads,
|
|
586
|
+
so `-١` is one. `auth login --invite` is the exception, since an invite
|
|
587
|
+
token may begin with a dash.
|
|
588
|
+
- `guardrails digest --out ''` is a usage error (exit 2). Click takes the
|
|
589
|
+
empty path as the current directory, and the Python CLI then fails to
|
|
590
|
+
write to it (exit 1).
|
|
591
|
+
- An id the command puts in a URL path, `FILE_ID` (`files delete`, `files
|
|
592
|
+
download-url`), the resource id (`-r/--resource-id` of `resource stats`,
|
|
593
|
+
`indexer-status`, `schema`, `ingest`, `ingest-batch` and `import`, and
|
|
594
|
+
`resource events RESOURCE_ID`) and `USER_ID` / `--user`, is refused when
|
|
595
|
+
it is `.`, `..` or empty (exit 2, `Invalid value for 'FILE_ID': '..' is
|
|
596
|
+
not a valid file id.`), before anything is read or sent. The Python CLI
|
|
597
|
+
sends it, and URL resolution then drops or climbs the segment: `files
|
|
598
|
+
download-url ..` asks for `/api/v1/download-url`. (From 0.41.1 it
|
|
599
|
+
refuses a `USER_ID` as this bin does.) Any other id is sent
|
|
600
|
+
percent-encoded as one segment, so a `/`, `?` or `#` in it stays in the
|
|
601
|
+
id rather than reaching another route or replacing the query
|
|
602
|
+
(`files delete 'x?workspace_id=…'`).
|
|
603
|
+
|
|
604
|
+
**`guardrails load` and `guardrails digest`** (memory-cloud v0.74.0+)
|
|
605
|
+
take the context as an optional argument, else `context_id` from
|
|
606
|
+
`.kagura.json`. `load` calls the MCP `load_guardrails` tool and prints the
|
|
607
|
+
set as the Python CLI prints it: the model's fifteen keys in its order,
|
|
608
|
+
without the `context_display_name`, `context_is_private` and
|
|
609
|
+
`context_is_locked` the tool adds, each item's eleven keys, and `null` for
|
|
610
|
+
a `tool_trigger` the Python SDK cannot read (`match: null` is filled in
|
|
611
|
+
when a trigger has none). A set missing a required field, a truncation
|
|
612
|
+
flag above all, is refused with the Python SDK's `KaguraResponseError`
|
|
613
|
+
text (exit 1) rather than printed as complete. `--cap` takes 1-1000.
|
|
614
|
+
`digest` reads the REST digest route with the credential chain (an API
|
|
615
|
+
key or an OAuth profile) and prints the text: the `AGENTS.md` export
|
|
616
|
+
block, or with `--target instructions` the MCP server instructions this
|
|
617
|
+
credential would receive, where `--profile` and `--tools` repeat an MCP
|
|
618
|
+
URL's `?profile=` and `?tools=`. A context with no tool guardrails prints
|
|
619
|
+
nothing, and says so on stderr. With `--out FILE`, it splices the block
|
|
620
|
+
into FILE between its marker lines: an earlier block is replaced in place,
|
|
621
|
+
an unchanged set rewrites nothing, and an empty set removes an earlier
|
|
622
|
+
block. It then prints one JSON line, `{"path": …, "status":
|
|
623
|
+
"written"|"unchanged"|"removed", "tool_triggered_version": …}`, with the
|
|
624
|
+
path as Python's `pathlib` writes it (`./x/../X.md` reads `x/../X.md`).
|
|
625
|
+
As in Python, `--out` does not expand `~`, never creates a missing parent
|
|
626
|
+
directory, and keeps a symlink, the file's mode and its line endings.
|
|
627
|
+
Beside JSON's `1` for Python's `1.0` (an `importance`), two differences
|
|
628
|
+
remain: an item's `created_at` / `updated_at` is printed as
|
|
629
|
+
the server sent it, where Python reformats it and refuses one it cannot
|
|
630
|
+
parse; and a failed read or write of the `--out` file reads in Node's
|
|
631
|
+
words (`ENOENT: no such file or directory, open '…'`) rather than
|
|
632
|
+
Python's (`[Errno 2] No such file or directory: '…'`).
|
|
633
|
+
|
|
634
|
+
**`doctor`** checks the credentials, the `kagura-memory` entry Claude Code
|
|
635
|
+
uses, the optional `age-encryption` peer and the age identity, then the
|
|
636
|
+
server, whose checks are the Python CLI's: `Server reachable`, then
|
|
637
|
+
`Version: <version>` by the same comparison `checkServerVersion` makes
|
|
638
|
+
([#66](https://github.com/kagura-ai/kagura-memory-typescript-sdk/issues/66)).
|
|
639
|
+
The version passes at or above `MIN_SERVER_VERSION` (0.75.0), fails below
|
|
640
|
+
it (`Version: 0.74.0 is below minimum 0.75.0`, a pre-release of 0.75.0
|
|
641
|
+
included) and is `info` when it cannot be compared (`main-abc123`, `0.78`).
|
|
642
|
+
An unreachable server fails with `Server unreachable: …`, and an OAuth
|
|
643
|
+
profile the REST route refuses is `info`, in Python's words. The
|
|
644
|
+
`/system/info` body is read through Python's `ServerInfo` model, and one
|
|
645
|
+
it refuses (no `name`, a `version` that is no string) fails as
|
|
646
|
+
unreachable: `Server unreachable: Invalid response format: …`, naming the
|
|
647
|
+
problem in the SDK's words where Python prints pydantic's. A credential
|
|
648
|
+
that does not resolve fails the auth section with Python's
|
|
649
|
+
`Authentication could not be resolved: …` and skips the server check
|
|
650
|
+
(`info`), as in Python. With
|
|
651
|
+
`--profile NAME` the server is checked with that profile, as in Python
|
|
652
|
+
(`KAGURA_API_KEY` still comes first), not with the default. `--json`
|
|
653
|
+
prints Python's shape, with `details` on every check (`{}` when there are
|
|
654
|
+
none). Any failed check exits 1.
|
|
385
655
|
|
|
386
656
|
**Sign-in rate limit.** memory-cloud v0.76.0 and later limit device sign-in
|
|
387
657
|
requests per client address. When the server refuses one with HTTP 429,
|
|
@@ -393,10 +663,14 @@ server's reason, when it gives one, on the next line.
|
|
|
393
663
|
|
|
394
664
|
**`auth` subcommands.** Each takes only the options it reads, as in the
|
|
395
665
|
Python CLI: any other is refused with click's `Error: No such option: --x`
|
|
396
|
-
(exit 2),
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
666
|
+
(exit 2), except `--invite`, which every subcommand but `login` refuses
|
|
667
|
+
with `--invite applies only to 'auth login'.` (exit 2, where click says
|
|
668
|
+
`No such option: --invite`), with a value or without and before
|
|
669
|
+
`--help`, as click's error would be, so that a token beginning with a
|
|
670
|
+
dash is not read as options. `--help` lists only a subcommand's own
|
|
671
|
+
options. `auth status` ends with the `kagura-memory` entry Claude Code uses in the
|
|
672
|
+
current directory and each entry it hides, in the Python CLI's words
|
|
673
|
+
(nothing when no scope defines one). `auth list --json` emits Python's fields per profile (`profile`,
|
|
400
674
|
`default`, `user_email`, `workspace_name`, `workspace_id`, `server`,
|
|
401
675
|
`scope`, `expired`, `refreshable`, `expires_at`), never a token, and `[]`
|
|
402
676
|
when there is none, with non-ASCII escaped as `\uXXXX`, as Python's
|
|
@@ -412,7 +686,61 @@ logout that names no profile succeeds when nothing is stored, so
|
|
|
412
686
|
`logout --yes` stays idempotent in setup scripts; and `--all` with
|
|
413
687
|
`--profile` is a usage error (exit 2), where Python ignores `--profile`
|
|
414
688
|
and removes every profile. `auth login` with both `--read-only` and
|
|
415
|
-
`--scope` exits 1, as Python does.
|
|
689
|
+
`--scope` exits 1, as Python does. `auth use NAME` prints Python's line,
|
|
690
|
+
`Default profile set to '<name>' (workspace '<workspace>').`, and a note
|
|
691
|
+
when `KAGURA_PROFILE` is set and still overrides the new default; an
|
|
692
|
+
unknown name exits 1 and lists the stored profiles, and a missing or
|
|
693
|
+
extra argument is a usage error (exit 2).
|
|
694
|
+
|
|
695
|
+
**`workspace` and the `auth` key commands** (memory-cloud v0.42.0+)
|
|
696
|
+
manage a workspace's members, invitations and member API keys:
|
|
697
|
+
`workspace member list|add|set-role|remove`, `workspace invite
|
|
698
|
+
create|list|revoke`, and `auth create-key|list-keys|revoke-key`, which
|
|
699
|
+
mint, list and revoke a key for another member. The server takes only
|
|
700
|
+
the workspace owner's static API key here; an OAuth profile gets an
|
|
701
|
+
access-denied error that says so. As in the Python CLI, the workspace
|
|
702
|
+
comes from the same source as the key
|
|
703
|
+
([#115](https://github.com/kagura-ai/kagura-memory-python-sdk/issues/115)):
|
|
704
|
+
`-w/--workspace` when given, else the OAuth profile's workspace, else
|
|
705
|
+
`context_id` in the `.kagura.json` that holds the key. A `KAGURA_API_KEY`
|
|
706
|
+
key needs `-w`, since nothing binds it to a workspace:
|
|
707
|
+
`KAGURA_API_KEY=<owner key> kagura-memory workspace member list -w
|
|
708
|
+
<workspace-uuid>`. An empty or `auto` `-w` is refused (exit 1) rather
|
|
709
|
+
than falling back to the source's workspace. `member remove` and `auth
|
|
710
|
+
revoke-key` ask first, naming the workspace, unless `--yes` (`-y`).
|
|
711
|
+
`create-key` prints the key, and `invite create` the invitation URL,
|
|
712
|
+
once on stdout, after a warning on stderr. `list-keys` and `invite list`
|
|
713
|
+
never show either; their `--json`, like `member list --json`, prints
|
|
714
|
+
the Python model's fields in its order, `null` or `false` for what the
|
|
715
|
+
server left out, and drops any other. A record the model refuses (a
|
|
716
|
+
required field missing, a scalar, list or mapping of the wrong type)
|
|
717
|
+
exits 1 with its `KaguraResponseError` text; timestamps are printed as
|
|
718
|
+
the server wrote them. `--role` matches exactly, as
|
|
719
|
+
click's `Choice` does (`Admin` is refused). Four things differ from the
|
|
720
|
+
Python CLI, each on purpose: a workspace that is not a UUID is refused
|
|
721
|
+
before `member remove` or `revoke-key` asks, where Python asks first;
|
|
722
|
+
each `invite create -c` must be a context UUID (exit 1, `context_id must
|
|
723
|
+
be a UUID, got '…'`), where Python sends it as typed and the server
|
|
724
|
+
answers `HTTP 500`; a user id of `.`, `..` or nothing (`USER_ID` or
|
|
725
|
+
`--user`) is refused (exit 2) before anything is asked or sent, where
|
|
726
|
+
Python sends it and URL resolution turns `member remove ..` into a
|
|
727
|
+
`DELETE` of the workspace's own URL; and an invitation with no email prints `-`, as
|
|
728
|
+
`invite list` does, where Python prints `None`.
|
|
729
|
+
|
|
730
|
+
**`measure record` and `measure series`** take the context as their
|
|
731
|
+
first argument, never from `.kagura.json`: an observation recorded in the
|
|
732
|
+
wrong context cannot be deleted. As in the Python CLI, a negative VALUE
|
|
733
|
+
needs no `--` (`measure record <context-id> pnl_usd -120`). The price is
|
|
734
|
+
that `record` reads any option it does not declare as an argument: after
|
|
735
|
+
VALUE it is an extra argument, and in the CONTEXT_ID or METRIC slot it is
|
|
736
|
+
refused as `No such option: <token>`, even after `--`, as the Python CLI
|
|
737
|
+
refuses it. These errors name a `--name=value` token `--name`, as every
|
|
738
|
+
other command does, where click prints the whole token: the value may be
|
|
739
|
+
a key. `--period` and `--agg` match exactly (`Week` is refused).
|
|
740
|
+
When both are bad, the error names `--period`, where click names
|
|
741
|
+
whichever comes first. The result prints as the Python CLI prints the
|
|
742
|
+
model: its keys in its order, and `unit` `null` when there is none. A
|
|
743
|
+
whole-number float prints without its `.0` (`72` for `72.0`).
|
|
416
744
|
|
|
417
745
|
#### Signing up with an invite
|
|
418
746
|
|
|
@@ -431,7 +759,8 @@ the server how to present the invite (`GET /api/v1/system/info`, which
|
|
|
431
759
|
takes no credentials, allowed 5 seconds):
|
|
432
760
|
|
|
433
761
|
- **The server supports the hand-off** (memory-cloud 0.76.0 or later,
|
|
434
|
-
`v0.76.0` and build suffixes included
|
|
762
|
+
`v0.76.0` and build suffixes included; a pre-release of 0.76.0 such as
|
|
763
|
+
`0.76.0-rc1` comes before it, as in the Python CLI): one link,
|
|
435
764
|
`<frontend>/join/<token>?return_to=%2Fdevice%3Fuser_code%3D<code>`, that
|
|
436
765
|
signs up with the invite and lands on the approval page with the code
|
|
437
766
|
filled in. The browser opens that link. Below it, "If you land on the
|
|
@@ -610,8 +939,9 @@ keyed on the error code and the envelope's fields, never on the message:
|
|
|
610
939
|
|-------|------------|---------|
|
|
611
940
|
| `KaguraNotFoundError` | missing contexts/memories/reports/agents/bindings (on `updateSearchConfig`, a missing context is a `KaguraPermissionError` instead) | — |
|
|
612
941
|
| `KaguraFeatureNotAvailableError` | MCP `plan_required` / `feature_not_available`; REST 403 `FEAT-001` — the plan lacks a feature, or it is switched off | `feature`, `requiredPlan`, `requiredPlanDisplay`, `currentPlan`, `gate` |
|
|
613
|
-
| `KaguraQuotaError` | MCP `quota_exceeded` / `CONNECTOR-001
|
|
942
|
+
| `KaguraQuotaError` | MCP `quota_exceeded` / `CONNECTOR-001`, and `rate_limit_exceeded`, the daily MCP call cap every non-read-only tool checks (`quotaType` `api_mcp_daily`, `resetsAt` the next UTC midnight); REST `QUOTA-001`, `QUOTA-002` and `CONNECTOR-001` (the resource-token and connector seat caps answer **403**); any other 429 from a REST client but `SecretClient` | `quotaType`, `current`, `limit`, `usedToday`, `resetsAt`, `retryAfter`, and the plan fields above |
|
|
614
943
|
| `KaguraPartialRollbackError` | `rollbackSleepRun` reversed some actions but not all | `reportId`, `summary` |
|
|
944
|
+
| `KaguraResponseError` | a successful response the SDK cannot read, usually because the server is newer than this SDK. The message reads as the Python SDK's: the call, then the failing fields, never their values (`<operation>: unexpected server response for <Model> (<field>: Field required). …`), then a suggestion to upgrade. It is not a `KaguraConnectionError`: a retry fails the same way | `operation` |
|
|
615
945
|
| `KaguraPermissionError` | MCP `permission_denied` — usually the caller's role is too low. `updateSearchConfig` also sends it for a context that does not exist or that the caller cannot see. Only some tools send a role — `updateSearchConfig`, `updateContext`, `deleteContext`, the file tools and the analysis tools do not — so `requiredRole` is often `null`, and on `updateSearchConfig` it cannot tell a missing context from a role denial | `requiredRole` |
|
|
616
946
|
| `KaguraError` | any other code | — |
|
|
617
947
|
|
|
@@ -644,7 +974,9 @@ An HTTP 429 keeps the class it always had on two surfaces.
|
|
|
644
974
|
per-minute rate limit and the daily call quota alike; from v0.75.0 the
|
|
645
975
|
quota also sets the `KaguraQuotaError` fields on it (`quotaType` is
|
|
646
976
|
`api_mcp_daily` or `api_rest_daily`), and they stay `null` on a
|
|
647
|
-
per-minute limit.
|
|
977
|
+
per-minute limit. A tool that refuses the daily MCP cap itself, in its
|
|
978
|
+
reply rather than with a 429, raises the `KaguraQuotaError` above.
|
|
979
|
+
`SecretClient` renders a 429 as `KaguraConnectionError`.
|
|
648
980
|
|
|
649
981
|
```ts
|
|
650
982
|
import { KaguraFeatureNotAvailableError, KaguraQuotaError } from "kagura-memory";
|
|
@@ -682,7 +1014,7 @@ when `undefined`.
|
|
|
682
1014
|
| `reference` | Full detail for one memory, under `result.memory`. |
|
|
683
1015
|
| `updateMemory` | Update in place by `memoryId`, or upsert by `externalId`. `details` **replaces** the stored object wholesale — round-trip keys you want to keep; dropping `tool_trigger` turns a guardrail off. `dismissSupersedeCandidate: true` rejects the server's `supersede_candidate` suggestion; it needs `memoryId` and throws locally with `externalId`. |
|
|
684
1016
|
| `forget` | Soft-delete by `memoryId` or by `query`. The rows are kept, but not restorable through the API, until the deployment's cleanup window passes (`CLEANUP_DELETED_MEMORIES_RETENTION_DAYS`, default 30 days). For a caller who may write to the workspace, a target it may not delete, or one already gone, is skipped silently — including every guardrail for a caller below context editor or on an agent credential — so `deleted_count` can be 0. A workspace viewer may not delete at all and is refused with `KaguraPermissionError` (`requiredRole: "member"`). |
|
|
685
|
-
| `listMemories` | Browse with substring, facet,
|
|
1017
|
+
| `listMemories` | Browse with substring, facet, time-window and bounding-box filters. Omit `contextId` for the caller's cross-context view. `latMin` / `latMax` / `lonMin` / `lonMax` (server v0.54.0+) keep only memories with a location, each then carrying `location: { lat, lon }`; see [the WHERE axis](#the-where-axis--geospatial-memories). |
|
|
686
1018
|
|
|
687
1019
|
### Deterministic lanes
|
|
688
1020
|
|
|
@@ -695,12 +1027,14 @@ the counterpart to `recall`'s probabilistic search.
|
|
|
695
1027
|
| `loadGuardrails` | The set a client-side tool hook matches against (server v0.74.0+): the pinned set plus every memory carrying `details.tool_trigger`, in two separately capped lanes — `cap` bounds only the tool-triggered one, so pins never crowd guardrails out. Check `tool_triggered_truncated` / `pinned_truncated`. |
|
|
696
1028
|
| `recallUpcoming` | WHEN — `type: "time"` memories whose window overlaps `from`/`until`, soonest first. Items carry `trigger`, not `details` (server v0.73.0+); `includeDetails: true` returns the full `details` object instead. |
|
|
697
1029
|
| `recallNearby` | WHERE — memories near a point, nearest first with `distance_m`. See [the WHERE axis](#the-where-axis--geospatial-memories). |
|
|
1030
|
+
| `recordMeasurement` | HOW-MUCH — append one number to a metric's series (server v0.54.0+). Not a memory: never embedded, recalled or consolidated. Append-only, with no delete. See [the HOW-MUCH axis](#the-how-much-axis--measurement-series). |
|
|
1031
|
+
| `recallSeries` | HOW-MUCH — one metric's series, bucketed by `period` (`day`, `week`, `month`) and aggregated by `agg` (`avg`, `min`, `max`, `sum`, `count`, `last`), UTC-aligned, empty buckets omitted. `count` is buckets, not observations. |
|
|
698
1032
|
|
|
699
1033
|
### Tags and the neural graph
|
|
700
1034
|
|
|
701
1035
|
| Method | What it does |
|
|
702
1036
|
|--------|--------------|
|
|
703
|
-
| `listTags` | Tag vocabulary with counts and recency. `prefix` narrows by spelling; `withTags` is a multi-tag AND drill-down that also excludes those tags from the result — the two compose into server-side faceted browsing with no local index. A drill-down calls the REST tags endpoint, because the MCP tool ignores `withTags` (through server v0.76.0); the result has the same shape. Its values are trimmed and blank ones dropped, and at most 50 of up to 200 characters each are accepted. |
|
|
1037
|
+
| `listTags` | Tag vocabulary with counts and recency. `prefix` narrows by spelling; `withTags` is a multi-tag AND drill-down that also excludes those tags from the result — the two compose into server-side faceted browsing with no local index. A drill-down calls the REST tags endpoint, because the MCP tool ignores `withTags` (through server v0.76.0); the result has the same shape. Its `context_name` is the one the endpoint sends (server v0.77.0+), else one MCP `list_tags` call names the context, once per client. Its values are trimmed and blank ones dropped, and at most 50 of up to 200 characters each are accepted. |
|
|
704
1038
|
| `explore` | Graph traversal from a seed memory (`depth` 1–5, `minWeight`). |
|
|
705
1039
|
| `listEdges` | Edges touching a memory, incoming and outgoing, deduplicated. |
|
|
706
1040
|
| `createEdge` / `updateEdge` / `deleteEdge` | Manual edge curation. `(sourceId, targetId)` is the identity; self-loops are rejected. |
|
|
@@ -741,7 +1075,7 @@ Ephemeral, TTL-bounded, and excluded from recall — deliberately not memories.
|
|
|
741
1075
|
| Method | What it does |
|
|
742
1076
|
|--------|--------------|
|
|
743
1077
|
| `getServerInfo` | Version, deployment feature flags, and (v0.69.0+) the reranker defaults new contexts start with, under `search_defaults`. |
|
|
744
|
-
| `checkServerVersion` | Compare against `MIN_SERVER_VERSION` (0.75.0). Advisory: logs, never throws. |
|
|
1078
|
+
| `checkServerVersion` | Compare against `MIN_SERVER_VERSION` (0.75.0). Advisory: logs, never throws. Reads the version as the Python SDK does: `v0.75.0`, `0.75.0+build` and `0.75.0.post1` meet it, a pre-release of it (`0.75.0-rc1`, `0.75.0rc1`, `0.75.0.dev1`) does not, and a version it cannot read (`0.75`, or not a string) is not compared. |
|
|
745
1079
|
| `getUsage` | Workspace quota and usage: `used` / `limit` for memories, contexts, members and today's MCP calls. |
|
|
746
1080
|
| `getMemoryStats` | Per-memory usage stats, sortable and paged. |
|
|
747
1081
|
| `getEmbeddingStatus` / `listEmbeddingModels` | Embedding backend state and the models available for `createContext`. |
|
|
@@ -797,6 +1131,38 @@ Requires memory-cloud **v0.49.0+** — older servers return MCP "tool not
|
|
|
797
1131
|
found" / REST 404 on this surface. The SDK as a whole targets v0.75.0
|
|
798
1132
|
(see [Installation](#installation)).
|
|
799
1133
|
|
|
1134
|
+
## Tool guardrails over REST (memory-cloud v0.74.0+)
|
|
1135
|
+
|
|
1136
|
+
`MemoryClient` serves a context's tool guardrails to a caller holding only
|
|
1137
|
+
an API key, an agent-bound key included, with no MCP session:
|
|
1138
|
+
|
|
1139
|
+
| Method | What it does |
|
|
1140
|
+
|--------|--------------|
|
|
1141
|
+
| `getGuardrailDigest` | The rendered tool-triggered set for clients without tool hooks (`GET /api/v1/memory/guardrails/digest`). `target: "export"` (the default) returns the `AGENTS.md` block, between its marker lines, or `""` when the context has none; `"instructions"` returns the exact MCP server instructions this credential would receive, and `profile` / `tools` repeat the MCP URL's `?profile=` / `?tools=`. `tool_triggered_version` is the response header, `null` when absent. The text is returned as is. |
|
|
1142
|
+
| `loadGuardrails` | The REST twin of `KaguraClient.loadGuardrails` (`POST /api/v1/memory/guardrails`): the same two lanes and truncation flags, without the context block (`context_id` and `context_name` are `null`). The set is read as the Python SDK's `GuardrailSet` model reads it, by the same reader `guardrails load` prints with: the model's fields only, in its order, `null` for an optional one left out (so `GuardrailItem`'s optional fields and `ToolTrigger.match` are typed nullable), and a `tool_trigger` that is no trigger `null`. A set missing a required field, a truncation flag included, or holding one of the wrong type (`pinned.0.type: Input should be a valid string`) raises `KaguraResponseError` (`operation` `MemoryClient.load_guardrails`) rather than read as complete. |
|
|
1143
|
+
|
|
1144
|
+
Both refuse a `contextId` that is not a UUID before any request, in the
|
|
1145
|
+
Python SDK's words (`context_id must be a UUID, got '…'`), and send its
|
|
1146
|
+
canonical form. The 404 (`KaguraNotFoundError`) is uniform: an unknown
|
|
1147
|
+
context, one in another workspace, and one the credential may not read
|
|
1148
|
+
all look the same, and so does a server older than v0.74.0 answering
|
|
1149
|
+
`getGuardrailDigest`. That older server answers `loadGuardrails` with
|
|
1150
|
+
`HTTP 405` instead, a `KaguraConnectionError`, so a caller that detects
|
|
1151
|
+
an older server by catching `KaguraNotFoundError` must also expect the
|
|
1152
|
+
405. An OAuth token's scope follows the HTTP method, so
|
|
1153
|
+
`loadGuardrails`, a `POST`, needs `memory:write`: a `--read-only` login
|
|
1154
|
+
loads the set over MCP instead.
|
|
1155
|
+
|
|
1156
|
+
```ts
|
|
1157
|
+
import { MemoryClient } from "kagura-memory";
|
|
1158
|
+
|
|
1159
|
+
const memory = MemoryClient.fromMcpUrl();
|
|
1160
|
+
const digest = await memory.getGuardrailDigest("ctx-uuid");
|
|
1161
|
+
if (digest.text) {
|
|
1162
|
+
// The block between the kagura-memory:guardrails marker lines for AGENTS.md.
|
|
1163
|
+
}
|
|
1164
|
+
```
|
|
1165
|
+
|
|
800
1166
|
## The WHERE axis — geospatial memories
|
|
801
1167
|
|
|
802
1168
|
Any memory can carry a location under `details.location`, which makes it
|
|
@@ -820,10 +1186,103 @@ into `details`, so `"35.68"` is rejected server-side with HTTP 422.
|
|
|
820
1186
|
(`results[].distance_m`); `MemoryLocation` and `NearbyMemory` are exported
|
|
821
1187
|
too. Out-of-range coordinates throw locally rather than round-tripping.
|
|
822
1188
|
|
|
1189
|
+
`listMemories()` filters by a bounding box instead (server v0.54.0+):
|
|
1190
|
+
`latMin`, `latMax`, `lonMin` and `lonMax`, in any combination, keep only
|
|
1191
|
+
memories with a location, and each item carries `location: { lat, lon }`
|
|
1192
|
+
(`null` without one). `lonMin > lonMax` is the box across the
|
|
1193
|
+
antimeridian. A server older than v0.54.0 ignores the bounds and returns
|
|
1194
|
+
an unfiltered page.
|
|
1195
|
+
|
|
1196
|
+
```ts
|
|
1197
|
+
const pacific = await client.listMemories({ contextId, lonMin: 170, lonMax: -170 });
|
|
1198
|
+
```
|
|
1199
|
+
|
|
823
1200
|
> **Gotcha:** `updateMemory()` replaces `details` **wholesale** — the
|
|
824
1201
|
> server does not deep-merge. Round-trip `location` when updating details
|
|
825
1202
|
> or the memory silently drops off the spatial axis.
|
|
826
1203
|
|
|
1204
|
+
## The HOW-MUCH axis — measurement series
|
|
1205
|
+
|
|
1206
|
+
Numbers such as a weight, a daily revenue or a rep count go to a lane of
|
|
1207
|
+
their own (server v0.54.0+): never embedded, never returned by `recall()`,
|
|
1208
|
+
never merged or rewritten by Sleep. Keep prose ("hit goal weight") in
|
|
1209
|
+
`remember()`.
|
|
1210
|
+
|
|
1211
|
+
```ts
|
|
1212
|
+
await client.recordMeasurement({ contextId, metric: "weight_kg", value: 71.5, unit: "kg" });
|
|
1213
|
+
|
|
1214
|
+
const weekly = await client.recallSeries({ contextId, metric: "weight_kg", period: "week", agg: "avg" });
|
|
1215
|
+
// weekly.series: [{ bucket: "2026-08-24T00:00:00Z", value: 72, count: 3 }, ...]
|
|
1216
|
+
```
|
|
1217
|
+
|
|
1218
|
+
The lane is append-only: recording the same point twice stores two rows,
|
|
1219
|
+
and nothing deletes one, except the retention window an operator can set
|
|
1220
|
+
on the server (v0.55.0+, `SLEEP_MEASUREMENT_RETENTION_DAYS`), which Sleep
|
|
1221
|
+
rollback cannot undo. `measuredAt`, `start` and `end` take an ISO 8601
|
|
1222
|
+
string, sent as given (naive means UTC), or a `Date`. A series window
|
|
1223
|
+
defaults to the last 30 days and spans at most 365; the server refuses a
|
|
1224
|
+
wider one. The metric (1-64 characters), the value (a finite number) and
|
|
1225
|
+
the unit (1-32 characters) are checked before any request, with the Python
|
|
1226
|
+
SDK's messages. Both methods return the Python SDK's model, and a result
|
|
1227
|
+
that does not read as one throws `KaguraResponseError`. On the command
|
|
1228
|
+
line: `measure record` and `measure series`.
|
|
1229
|
+
|
|
1230
|
+
## Upload and ingest progress
|
|
1231
|
+
|
|
1232
|
+
`FilesClient.upload` and `ResourceClient.ingestEvents` take an
|
|
1233
|
+
`onProgress` callback, the Python SDK's `logger=` hook. Each event is the
|
|
1234
|
+
Python CLI's NDJSON line without its `v` and `ts`: `stage`, `kind`
|
|
1235
|
+
(`action`, then one `success` or `error`, the last event, even when the
|
|
1236
|
+
call throws), and `msg` and `detail` when they are not empty. Without a
|
|
1237
|
+
callback nothing is emitted, and a callback that throws, or an `async` one
|
|
1238
|
+
that rejects, is ignored; its promise is not awaited.
|
|
1239
|
+
|
|
1240
|
+
```ts
|
|
1241
|
+
import { FilesClient, type ProgressEvent } from "kagura-memory";
|
|
1242
|
+
|
|
1243
|
+
const files = FilesClient.fromMcpUrl();
|
|
1244
|
+
await files.upload({
|
|
1245
|
+
contextId: "workspace-uuid",
|
|
1246
|
+
source: "./report.pdf",
|
|
1247
|
+
onProgress: (e: ProgressEvent) => console.error(e.stage, e.kind, e.msg),
|
|
1248
|
+
});
|
|
1249
|
+
```
|
|
1250
|
+
|
|
1251
|
+
An upload reports `reserve`, `upload` and `confirm`, then `complete`: a
|
|
1252
|
+
`success` with `{ file_id, size_bytes }` (`{ file_id, deduped: true }` for
|
|
1253
|
+
a 409 dedup hit), or an `error` with how far it got,
|
|
1254
|
+
`{ reserved_file_id, uploaded, confirm_started, confirmed }`;
|
|
1255
|
+
`confirm_started` without `confirmed` means the file may be finalized
|
|
1256
|
+
after all, so check before uploading again. A batch reports
|
|
1257
|
+
`ingest_events`, then `{ created, failed }` or
|
|
1258
|
+
`{ events_attempted, resource_id }`. A 2xx answer neither call can read (a
|
|
1259
|
+
batch answered with `null`; a reserve, a confirm or a 409's existing file
|
|
1260
|
+
that the Python SDK's `FileReserveResponse` / `FileObject` model refuses,
|
|
1261
|
+
such as a confirm with no `created_at`) ends the stream with that `error`
|
|
1262
|
+
and throws a `KaguraResponseError` in the Python SDK's words, a reserve
|
|
1263
|
+
before the PUT; such a confirm is not `confirmed`. A reserve whose
|
|
1264
|
+
`file_id` is `.`, `..` or empty ends it the same way, before the PUT, with
|
|
1265
|
+
this SDK's own message (`file_id must be a file id, got "..": …`); the
|
|
1266
|
+
Python SDK accepts it and confirms at another route. `list` and
|
|
1267
|
+
`downloadUrl` read their body through the Python SDK's model too
|
|
1268
|
+
(`FileObject` for each item of a bare list, else `FileListResponse`;
|
|
1269
|
+
`FileDownloadUrlResponse`), and throw the same error for one it refuses. Every `FilesClient` method refuses a
|
|
1270
|
+
`contextId` that is not a UUID in the Python SDK's words (`context_id must
|
|
1271
|
+
be a UUID; got '…'`), and sends a `{braced}`, `urn:uuid:` or dashless one
|
|
1272
|
+
in its canonical form.
|
|
1273
|
+
|
|
1274
|
+
Every id a client puts in a URL path (a `FilesClient` file id, a
|
|
1275
|
+
`ResourceClient` resource id, `KaguraClient`'s context id for memory
|
|
1276
|
+
stats, duplicates and the tags drill-down, a `WorkspaceClient` user id, a
|
|
1277
|
+
`SecretClient` pubkey id) is percent-encoded as one segment, and an id
|
|
1278
|
+
that is `.`, `..` or empty throws before anything is sent
|
|
1279
|
+
(`fileId must be a file id, got "..": as a URL path segment it would
|
|
1280
|
+
address a different endpoint`): encoding leaves those as they are, and
|
|
1281
|
+
URL resolution would send the request elsewhere. The Python SDK sends
|
|
1282
|
+
them as typed, but for a workspace user id, which it refuses too from
|
|
1283
|
+
0.41.1
|
|
1284
|
+
([#66](https://github.com/kagura-ai/kagura-memory-typescript-sdk/issues/66)).
|
|
1285
|
+
|
|
827
1286
|
## Zero-knowledge secrets
|
|
828
1287
|
|
|
829
1288
|
`SecretClient` is the fourth REST client, alongside Files, Resource and
|
|
@@ -926,10 +1385,9 @@ Python uses, so a shared backend interoperates.
|
|
|
926
1385
|
|
|
927
1386
|
This package ports the Python SDK's core (client, auth, REST clients,
|
|
928
1387
|
models, the zero-knowledge secret client) and, since 0.8.0, its `kagura`
|
|
929
|
-
CLI as `kagura-memory`:
|
|
930
|
-
`contexts` alias.
|
|
931
|
-
|
|
932
|
-
`auth` key commands among them).
|
|
1388
|
+
CLI as `kagura-memory`: 20 of the 21 top-level commands, counting the
|
|
1389
|
+
`contexts` alias. Only `kagura ingest` is not ported (below);
|
|
1390
|
+
[Command line](#command-line) lists where the two CLIs still differ.
|
|
933
1391
|
|
|
934
1392
|
One thing is deliberately not ported, because it would cost the
|
|
935
1393
|
zero-dependency promise:
|