kagura-memory 0.13.0 → 0.14.1
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 +326 -80
- package/dist/cli.js +3642 -2098
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +3008 -2247
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +121 -37
- package/dist/index.d.ts +121 -37
- package/dist/index.js +3008 -2247
- package/dist/index.js.map +1 -1
- package/dist-mcp/mcp.cjs +489 -32
- package/package.json +11 -2
package/README.md
CHANGED
|
@@ -34,7 +34,9 @@ the one optional peer dependency, for
|
|
|
34
34
|
[zero-knowledge secrets](#the-crypto-package-is-opt-in), is never installed
|
|
35
35
|
unless you ask for it.
|
|
36
36
|
|
|
37
|
-
Targets memory-cloud **v0.75.0** (`MIN_SERVER_VERSION`)
|
|
37
|
+
Targets memory-cloud **v0.75.0** (`MIN_SERVER_VERSION`) and is checked
|
|
38
|
+
against memory-cloud up to **v0.77.0**, as the Python SDK 0.42.0 is (whose
|
|
39
|
+
own `MIN_SERVER_VERSION` stays at an advisory 0.17.1).
|
|
38
40
|
`checkServerVersion()` warns, and never throws, on an older server, which
|
|
39
41
|
still answers: it ignores options it predates, leaves out fields it
|
|
40
42
|
predates, and reports a tool it predates as not found. A pre-release of
|
|
@@ -99,7 +101,9 @@ Credentials travel over HTTPS only. Every client, `login()`, `auth login
|
|
|
99
101
|
--server` and the URL every `setup` subcommand puts in a harness entry
|
|
100
102
|
(`setup claude`, `setup codex`, `setup hermes` and `setup openclaw`)
|
|
101
103
|
refuse a plain-HTTP URL unless its host is `localhost`, `127.0.0.1` or
|
|
102
|
-
`[::1]
|
|
104
|
+
`[::1]`; `doctor` warns about a resolved MCP URL like that and skips the
|
|
105
|
+
server check, as the Python CLI does, and fails a configured `mcp_url`
|
|
106
|
+
like that which the credential does not use (see `doctor`). The URL is
|
|
103
107
|
read as `fetch` reads it, so the scheme in any case (`HTTP://`), without
|
|
104
108
|
its slashes (`http:host`), or with whitespace or control characters
|
|
105
109
|
around it or a tab or newline inside it is refused all the same, as in
|
|
@@ -127,15 +131,17 @@ negative VALUE), so `secret exec --help --bogus` prints the help; without
|
|
|
127
131
|
`--help`, `secret exec` still refuses an unknown option before the child
|
|
128
132
|
command rather than running it as that command. The one command not
|
|
129
133
|
ported, the few options only this bin has, and the deliberate
|
|
130
|
-
differences are listed below.
|
|
134
|
+
differences are listed below. The parity target is the Python CLI
|
|
135
|
+
**0.42.0**.
|
|
131
136
|
|
|
132
137
|
Values are read as click reads them. A choice matches exactly, as click's
|
|
133
138
|
`Choice` does, except where the Python CLI declares one case-insensitive
|
|
134
139
|
(`--source-type`, `--progress`), casefolded as click folds it; a number
|
|
135
140
|
is read as Python's `int()` and `float()` read it, `1_000`, any decimal
|
|
136
141
|
digit (`١٢`, `12`) and the whitespace they skip included (a BOM is no
|
|
137
|
-
whitespace to them); an
|
|
138
|
-
`
|
|
142
|
+
whitespace to them); an id argument (`TOKEN_ID`, `INVITATION_ID`,
|
|
143
|
+
`KEY_ID`) is sent exactly, an integer however large, or a string id
|
|
144
|
+
(`rtok_…`, `winv_…`, `akey_…`, memory-cloud v0.89.0+) as typed; and an
|
|
139
145
|
out-of-range value is echoed as click converted it (`files upload
|
|
140
146
|
--importance 2` is refused as `2.0 is not in the range 0.0<=x<=1.0.`).
|
|
141
147
|
A failure prints `Error: <message>` on stderr, and a quota or plan
|
|
@@ -208,10 +214,38 @@ unexpected server response for PaginatedResourceTokensResponse
|
|
|
208
214
|
(tokens.0.created_at: Field required). …`, and so does a body that is no
|
|
209
215
|
record at all (`null`). An untyped mapping nested past pydantic's limit
|
|
210
216
|
(256 containers) exits 1 with pydantic's `Error serializing to JSON:
|
|
211
|
-
ValueError: Circular reference detected (depth exceeded)`.
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
217
|
+
ValueError: Circular reference detected (depth exceeded)`. The body is
|
|
218
|
+
read as Python's `json.loads` reads it
|
|
219
|
+
([#69](https://github.com/kagura-ai/kagura-memory-typescript-sdk/issues/69)),
|
|
220
|
+
so an int field sent `9007199254740993` prints exactly, one sent `1e20`
|
|
221
|
+
exits 1 as pydantic refuses it (`Unable to parse input string as an
|
|
222
|
+
integer, exceeded maximum size`), and a float field sent `-0` prints
|
|
223
|
+
`0.0`. Inside an untyped mapping (an event's `payload`, a batch's
|
|
224
|
+
`errors`) the keys print in the server's order (`{"b": 1, "2": 2}` stays
|
|
225
|
+
so) and each number as Python read it (`1.0`, `1e+16`, `-0.0`, an
|
|
226
|
+
integer past 2^53 exactly). `NaN` and `Infinity` are read, and print
|
|
227
|
+
`null` as pydantic writes them; an integer of more than 4,300 digits
|
|
228
|
+
makes the body non-JSON, as Python's `int()` limit does; and a body
|
|
229
|
+
nested deeper than 973 containers exits 1 with Python's `maximum
|
|
230
|
+
recursion depth exceeded while decoding a JSON array from a unicode
|
|
231
|
+
string`. A string value holding a lone surrogate (`"\ud800"`) exits 1
|
|
232
|
+
with pydantic's `Error serializing to JSON: UnicodeEncodeError: 'utf-8'
|
|
233
|
+
codec can't encode character '\ud800' in position 0: surrogates not
|
|
234
|
+
allowed`; a key of the untyped mapping itself holding one prints as
|
|
235
|
+
three U+FFFD, as pydantic converts it, and a key of a mapping nested
|
|
236
|
+
inside it exits 1 like a value. Three differences remain. Python's depth
|
|
237
|
+
is its recursion limit less the stack in use: 973 is what these commands
|
|
238
|
+
reach, and `doctor` given such a `/api/v1/system/info` body reports a
|
|
239
|
+
failed server check where Python stops with a traceback. The body is
|
|
240
|
+
decoded as UTF-8, as `fetch` decodes every body: one that is not valid
|
|
241
|
+
UTF-8 is read with U+FFFD in place of the bad bytes, where Python calls
|
|
242
|
+
it non-JSON, or, for a lone surrogate sent as its three raw bytes
|
|
243
|
+
(`ED A0 80`), reads it and then refuses the dump; and a UTF-16 or UTF-32
|
|
244
|
+
body, with or without a BOM, which Python's `json.loads` detects and
|
|
245
|
+
reads, is non-JSON here (`Server returned a non-JSON body (HTTP 200)
|
|
246
|
+
…`). No memory-cloud server sends either. And only REST bodies are read
|
|
247
|
+
this way: the MCP commands (`recall`, `remember`, …) still print a whole
|
|
248
|
+
float as `1` and list an object's integer keys first.
|
|
215
249
|
|
|
216
250
|
**Files and imports.** The `files` commands take their workspace from the
|
|
217
251
|
credential's own source, as the Python CLI does (its #115): `-c` when
|
|
@@ -235,7 +269,16 @@ with a traceback. Two limits of JavaScript numbers remain: a number in the
|
|
|
235
269
|
payload is sent as JavaScript reads it, so an integer past 2^53 loses its
|
|
236
270
|
last digits and `10.0` is sent as `10`, where Python sends them as
|
|
237
271
|
written; and `-V` above 2^53 is refused as too large (exit 2), where
|
|
238
|
-
Python sends it.
|
|
272
|
+
Python sends it. The summary prints as Python's `json.dumps` prints it
|
|
273
|
+
([#69](https://github.com/kagura-ai/kagura-memory-typescript-sdk/issues/69)):
|
|
274
|
+
`created` and `failed` add up exactly past 2^53, and each error keeps
|
|
275
|
+
the server's key order and numbers (`1.0`, `1e+16`, `NaN`); a lone
|
|
276
|
+
surrogate in an error's string or key prints as `?` (one per code unit,
|
|
277
|
+
`"😀???x"`), as the Python CLI's UTF-8 stdout with `errors="replace"`
|
|
278
|
+
writes what `json.dumps` kept. The counts in
|
|
279
|
+
`--progress json`'s events (`detail.created_so_far`, the success event's
|
|
280
|
+
`detail.created`) are still JavaScript numbers, so past 2^53 they are
|
|
281
|
+
rounded where Python's are exact; `-v` prints no counts.
|
|
239
282
|
|
|
240
283
|
**Progress.** `files upload` and `resource import` take `-v/--verbose`
|
|
241
284
|
(repeatable) and `--progress rich|json|none`. Progress goes to stderr, one
|
|
@@ -245,17 +288,21 @@ line per event, so stdout carries the same result either way.
|
|
|
245
288
|
last event is the operation's single `success` or `error`; `-v`, or
|
|
246
289
|
`--progress rich`, writes the lines the Python CLI shows
|
|
247
290
|
(`→ Reserving upload report.pdf (1234 bytes)`, `✓ Upload complete`,
|
|
248
|
-
`✗ Upload failed: …`); `--progress none` is silent even with `-v`.
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
early (`2>&1 | head -1`) does not stop the upload or the
|
|
254
|
-
ends the process without a final event
|
|
291
|
+
`✗ Upload failed: …`); `--progress none` is silent even with `-v`.
|
|
292
|
+
As in the Python CLI (0.41.1+), `files upload --remember` reports success
|
|
293
|
+
only once the linked memory is written (a failed write ends the stream
|
|
294
|
+
with that error), and `resource import` starts its stream only once its
|
|
295
|
+
client is built, so a credential that fails prints the error alone. A
|
|
296
|
+
stderr closed early (`2>&1 | head -1`) does not stop the upload or the
|
|
297
|
+
import. Ctrl-C ends the process without a final event (Node's default
|
|
298
|
+
SIGINT handling exits at once), where the Python CLI catches the
|
|
299
|
+
interrupt and ends the stream with `error`.
|
|
255
300
|
|
|
256
301
|
**Connecting a harness.** Each `setup` subcommand sets up an MCP entry
|
|
257
|
-
named `kagura-memory`: the URL plus a Bearer header
|
|
258
|
-
|
|
302
|
+
named `kagura-memory`: the URL plus a Bearer header, or, with
|
|
303
|
+
`--url-form --oauth` (below), the URL alone, which the harness signs in
|
|
304
|
+
to itself. The key is never printed, and no harness CLI gets it on its
|
|
305
|
+
command line.
|
|
259
306
|
|
|
260
307
|
`setup claude` also writes `.kagura.json` (0600, gitignored). Its key
|
|
261
308
|
comes from `--api-key`, else the `api_key` in the project's own
|
|
@@ -284,9 +331,9 @@ it, a missing credential stops setup (exit 1).
|
|
|
284
331
|
| Subcommand | How the entry is applied | Where the key goes |
|
|
285
332
|
|---|---|---|
|
|
286
333
|
| `setup claude` | `.mcp.json` (`--scope project`, the default), or `claude mcp add-json --scope user …` | `--scope project`: in `.mcp.json`; `--scope user`: `KAGURA_MCP_API_KEY`, exported where Claude Code starts |
|
|
287
|
-
| `setup codex` | `codex mcp add … --bearer-token-env-var KAGURA_API_KEY` | `export KAGURA_API_KEY=…` in the shell profile that starts Codex |
|
|
288
|
-
| `setup hermes` | the `config.yaml` block is printed; `hermes mcp add` is interactive, and this port never prompts | `MCP_KAGURA_MEMORY_API_KEY=…` (`MCP_<NAME>_API_KEY` with `--name`) in the `.env` beside `config.yaml`, added with an editor |
|
|
289
|
-
| `setup openclaw` | `openclaw mcp add … --transport streamable-http --no-probe`, or `openclaw mcp set`
|
|
334
|
+
| `setup codex` | `codex mcp add … --bearer-token-env-var KAGURA_API_KEY` (with `--oauth`: `codex mcp add NAME --url URL`, attached, when there is a terminal and no `-y`) | `export KAGURA_API_KEY=…` in the shell profile that starts Codex |
|
|
335
|
+
| `setup hermes` | the `config.yaml` block is printed; `hermes mcp add` is interactive, and this port never prompts (with `--oauth`: `hermes mcp add … --auth oauth`, attached, when there is a terminal and no `-y`) | `MCP_KAGURA_MEMORY_API_KEY=…` (`MCP_<NAME>_API_KEY` with `--name`) in the `.env` beside `config.yaml`, added with an editor |
|
|
336
|
+
| `setup openclaw` | `openclaw mcp add … --transport streamable-http --no-probe`, or `openclaw mcp set` with `--force` (with `--oauth`: the same two commands with `--auth oauth` and no header) | `KAGURA_API_KEY=…` in `$OPENCLAW_STATE_DIR/.env` (default `~/.openclaw/.env`), added with an editor |
|
|
290
337
|
|
|
291
338
|
`--api-key-env VAR` renames `KAGURA_API_KEY` for Codex and OpenClaw
|
|
292
339
|
(an upper-case letter or `_`, then upper-case letters, digits or `_`).
|
|
@@ -312,6 +359,49 @@ checks, and exits 1 saying to pass `--mcp-url`. `$OPENCLAW_STATE_DIR`,
|
|
|
312
359
|
`$OPENCLAW_CONFIG_PATH` and `$OPENCLAW_WORKSPACE_DIR` are read as OpenClaw
|
|
313
360
|
reads them: stripped, with a leading `~` expanded.
|
|
314
361
|
|
|
362
|
+
**The OAuth URL form** (memory-cloud 0.77.0+). From 0.77.0 memory-cloud's
|
|
363
|
+
dynamic client registration accepts the three harnesses' own OAuth clients
|
|
364
|
+
on a loopback redirect
|
|
365
|
+
([memory-cloud#1657](https://github.com/kagura-ai/memory-cloud/issues/1657)),
|
|
366
|
+
so `--url-form --oauth --mcp-url https://memory.kagura-ai.com/mcp/w/<workspace-id>`
|
|
367
|
+
writes a URL entry with no key, no header and no key variable: the harness
|
|
368
|
+
registers its own client, signs in itself and keeps the token in its own
|
|
369
|
+
store. Setup never sees the token, never runs a harness `login`, and never
|
|
370
|
+
picks this form on its own. Before it detects, runs or writes anything,
|
|
371
|
+
a real run sends one unauthenticated `GET /api/v1/system/info` to the
|
|
372
|
+
`--mcp-url` server and stops (exit 1) unless it reports 0.77.0 or later; a
|
|
373
|
+
version setup cannot read (no answer, not a 200, unparseable) stops it
|
|
374
|
+
too. `--dry-run` sends no request. `--oauth` needs `--url-form` and
|
|
375
|
+
`--mcp-url` and refuses `--api-key-env` (exit 2).
|
|
376
|
+
|
|
377
|
+
```bash
|
|
378
|
+
npx kagura-memory setup codex --url-form --oauth --mcp-url https://memory.kagura-ai.com/mcp/w/<workspace-id>
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
| | The entry | Written with | Sign in | The harness keeps the token in |
|
|
382
|
+
|---|---|---|---|---|
|
|
383
|
+
| Codex | `url` only (Codex's `auth` defaults to OAuth) | `codex mcp add <name> --url <url>`, which saves the entry and then starts Codex's browser sign-in, so setup runs it attached to your terminal (its output on stderr), only with a terminal on stdin and without `-y`; otherwise it prints the table and edits nothing (`--force`: the same add, which signs in again) | `codex mcp login <name>` (`--no-browser` when the browser cannot reach the callback) | the OS keyring (`Codex MCP Credentials`; on Windows, Codex's encrypted secrets store in `~/.codex`), else `~/.codex/.credentials.json` (`$CODEX_HOME`), keyed on the entry's URL |
|
|
384
|
+
| Hermes Agent | `url` + `auth: oauth` | `hermes mcp add <name> --url <url> --auth oauth --connect-timeout 315`, attached, with a terminal and without `-y`: its probe runs the browser sign-in, which its default 30 s bound would cut short. Setup then reads the entry back with `hermes config get mcp_servers.<name> --json`: an entry Hermes kept, saved without `auth: oauth`, or saved disabled (`enabled: false`, after the sign-in did not finish) stops setup (exit 1) with the command that fixes it, and skips the `AGENTS.md` export | `hermes mcp login <name>` (the browser flow), or on memory-cloud 0.78.0+ `hermes mcp login <name> --flow device` (a code entered at the server's `/device` page; no loopback callback, [memory-cloud#1671](https://github.com/kagura-ai/memory-cloud/issues/1671)) | `~/.hermes/mcp-tokens/<name>.json` (`$HERMES_HOME`, or the active Hermes profile's) |
|
|
385
|
+
| OpenClaw | `url`, `transport: "streamable-http"`, `auth: "oauth"` | `openclaw mcp add <name> --url <url> --transport streamable-http --auth oauth`, which saves an OAuth entry without probing (`--force`: `openclaw mcp set`, even when no entry exists, where Python then uses `mcp add`) | `openclaw mcp login <name>` (`--code <code>` when the browser cannot reach the callback), then `openclaw mcp doctor <name> --probe` | its state database, `~/.openclaw/state/openclaw.sqlite` (`$OPENCLAW_STATE_DIR/state/`) |
|
|
386
|
+
|
|
387
|
+
memory-cloud's consent screen shows the client name the harness sends,
|
|
388
|
+
which nothing verifies: approve only a sign-in you started. For Codex,
|
|
389
|
+
`-c` or `--guardrails` goes on the URL as `?guardrails=`; Codex keys its
|
|
390
|
+
token on the URL, so changing it later means signing in again. With the
|
|
391
|
+
plugin's hooks on, an `--oauth` entry does not get `?guardrails=off` (the
|
|
392
|
+
hooks cannot read it), and setup says so. The `--guardrails` preview runs
|
|
393
|
+
on this CLI's own credential when that is on the `--mcp-url` server;
|
|
394
|
+
otherwise it names the stored profiles there and runs on the first, or,
|
|
395
|
+
when there is none, names the `kagura-memory auth login --server` to run
|
|
396
|
+
first. What Codex receives depends on the account it signed in with.
|
|
397
|
+
|
|
398
|
+
What has been checked (python-sdk#284): on 2026-09-25 each harness signed
|
|
399
|
+
in end to end on a `/mcp/w/<workspace-id>` URL against memory-cloud
|
|
400
|
+
0.78.0, through entries the Python CLI's `setup … --url-form --oauth`
|
|
401
|
+
wrote, and reached `tools/list`: Codex 0.157.0, Hermes Agent v2026.9.24
|
|
402
|
+
(the browser sign-in and `hermes mcp login --flow device`) and OpenClaw
|
|
403
|
+
2026.9.6. This bin writes the same entries with the same harness commands.
|
|
404
|
+
|
|
315
405
|
This package has no TOML, YAML or JSON5 parser, so it never rewrites those
|
|
316
406
|
files. When the harness's CLI is not on `PATH`, the block is printed on
|
|
317
407
|
stderr with the file it belongs in, and stdout stays one JSON document.
|
|
@@ -390,14 +480,21 @@ and splices it into a file the harness loads every session, between its
|
|
|
390
480
|
place, an unchanged set rewrites nothing, and the rest of the file is
|
|
391
481
|
kept, line endings and a symlink included. Without PATH the file is the
|
|
392
482
|
harness's own: `$CODEX_HOME/AGENTS.md` (`AGENTS.override.md` when that
|
|
393
|
-
exists); for Hermes the
|
|
394
|
-
|
|
395
|
-
|
|
483
|
+
exists); for Hermes the file Hermes loads from the current directory, found as
|
|
484
|
+
Hermes finds it: the nearest `.hermes.md` or `HERMES.md` up to the git
|
|
485
|
+
root (an empty one ends that search), else this directory's
|
|
486
|
+
`AGENTS.override.md`, `AGENTS.md` or `agents.md` (a new `AGENTS.md` when
|
|
487
|
+
only a parent directory's loads), else its `CLAUDE.md` or `claude.md`,
|
|
488
|
+
else a new `AGENTS.md`, so your own file keeps loading. With only Cursor
|
|
489
|
+
rules (`.cursorrules`, `.cursor/rules/*.mdc`) there is no default, since a
|
|
490
|
+
new `AGENTS.md` would stop Hermes loading them: `--agents-md` then needs a
|
|
491
|
+
PATH (exit 1, nothing run), and a dry run says the export is not offered;
|
|
492
|
+
for OpenClaw `AGENTS.md` in its workspace,
|
|
396
493
|
`$OPENCLAW_WORKSPACE_DIR`, else `workspace/` in the state directory. A
|
|
397
494
|
leading `~` or `~/` in PATH is expanded to your home directory (a
|
|
398
|
-
`~user` is left as written
|
|
399
|
-
created. The context is `--context-id`, else a
|
|
400
|
-
UUID, never the
|
|
495
|
+
`~user` is left as written, as in the Python CLI), and missing
|
|
496
|
+
directories are created. The context is `--context-id`, else a
|
|
497
|
+
`--guardrails` context UUID, never the
|
|
401
498
|
URL's `?guardrails=` or `.kagura.json`; without one, `--agents-md` is a
|
|
402
499
|
usage error (exit 2). The block is fetched on the usual credential chain
|
|
403
500
|
(`KAGURA_API_KEY`, the OAuth profile, `.kagura.json`), which setup
|
|
@@ -407,13 +504,15 @@ nothing run. The export comes after the entry is applied or printed.
|
|
|
407
504
|
`wrote` lists the file, and the notes carry Python's lines: the refresh
|
|
408
505
|
command (`kagura-memory guardrails digest <ctx> --out <file>`), a warning
|
|
409
506
|
past the 32 KiB Codex reads or the 20,000 characters OpenClaw reads, and
|
|
410
|
-
Hermes's prompt-injection note. An empty digest
|
|
411
|
-
|
|
412
|
-
failed export prints the report, then the error
|
|
507
|
+
Hermes's prompt-injection note. An empty digest removes an earlier block,
|
|
508
|
+
as `guardrails digest --out` does, and otherwise writes nothing, creating
|
|
509
|
+
no file or directory. A failed export prints the report, then the error
|
|
510
|
+
(exit 1). `--dry-run`
|
|
413
511
|
names what the export would do to the file (create it, append the block,
|
|
414
512
|
replace the block, or update a file it cannot read). On Hermes and
|
|
415
513
|
OpenClaw a run without the export ends with Python's "Re-run with
|
|
416
|
-
--agents-md --context-id <id> …" hint
|
|
514
|
+
--agents-md --context-id <id> …" hint, except where Hermes has no default
|
|
515
|
+
file.
|
|
417
516
|
|
|
418
517
|
Claude Code uses the `kagura-memory` entry from the strongest scope
|
|
419
518
|
(local > project > user). It keys local scope by the git repository root
|
|
@@ -460,8 +559,14 @@ the zero-dependency promise; use the Python CLI for it. The Claude Code
|
|
|
460
559
|
extras of `kagura setup claude` are not ported either: its SessionStart
|
|
461
560
|
and PostToolUse hooks and its `/kagura-recall` and `/kagura-remember`
|
|
462
561
|
commands. `setup claude` here writes `.kagura.json` and the MCP entry
|
|
463
|
-
only, and takes their flags as inert (see above).
|
|
464
|
-
|
|
562
|
+
only, and takes their flags as inert (see above).
|
|
563
|
+
|
|
564
|
+
Nor are the skills of the Python CLI's Claude Code plugin, such as the
|
|
565
|
+
`memory` skill of 0.42.0 (python-sdk #248), which walks an agent through
|
|
566
|
+
`remember`, `recall`, `reference`, `update-memory` and `forget` and their
|
|
567
|
+
`--details`/`--location` rules: this package ships no Claude Code plugin.
|
|
568
|
+
|
|
569
|
+
Every other command of the Python CLI is here as of 0.12.0
|
|
465
570
|
([#57](https://github.com/kagura-ai/kagura-memory-typescript-sdk/issues/57)),
|
|
466
571
|
with the differences in options and output this section lists.
|
|
467
572
|
|
|
@@ -520,40 +625,50 @@ with `--url-form` too.
|
|
|
520
625
|
the Python CLI in these ways, each on purpose:
|
|
521
626
|
|
|
522
627
|
- Every entry here is the URL form, so `--url-form` is accepted and
|
|
523
|
-
changes nothing
|
|
524
|
-
|
|
628
|
+
changes nothing by itself (`--oauth` needs it, as in Python), and
|
|
629
|
+
`--mcp-url` falls back to the configured URL where Python requires it
|
|
630
|
+
(not with `--oauth`). Only that fallback needs the configuration: without
|
|
525
631
|
`--mcp-url`, a `.kagura.json` that cannot be loaded stops setup (exit 1);
|
|
526
632
|
with it, setup goes on with a note, as Python never reads that file.
|
|
527
633
|
- `-c` must be a context UUID with `--url-form --profile` too (exit 2),
|
|
528
634
|
where Python looks a name up through the profile.
|
|
529
|
-
- `setup hermes` never runs `hermes mcp add
|
|
530
|
-
block, as Python does under `-y`.
|
|
635
|
+
- `setup hermes` never runs `hermes mcp add` for the API-key form, which
|
|
636
|
+
prompts for the key; it prints the block, as Python does under `-y`.
|
|
637
|
+
With `--oauth` it runs it attached, as Python does.
|
|
638
|
+
- So nothing is read back with `hermes config get` for that form either:
|
|
639
|
+
the Python CLI 0.41.1's stops after the add (an entry Hermes kept in
|
|
640
|
+
place of the one asked for, an entry saved disabled, which points to
|
|
641
|
+
`hermes mcp test`) and its warning for a URL entry saved without an
|
|
642
|
+
`Authorization` header cannot arise for the printed block.
|
|
531
643
|
- An existing entry is found by scanning the file, and not described by
|
|
532
644
|
kind. A readable but malformed `config.toml` does not stop
|
|
533
645
|
`setup codex`.
|
|
534
646
|
- On Codex, a `?guardrails=` already in the MCP URL (`--mcp-url` or the
|
|
535
647
|
configured `mcp_url`) beats the hooks and `-c` defaults.
|
|
536
|
-
- Nothing prompts
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
648
|
+
- Nothing prompts here (setup only hands the terminal to an `--oauth`
|
|
649
|
+
`codex mcp add` or `hermes mcp add`), so `--agents-md` always needs a
|
|
650
|
+
context, and the export is never offered: a dry run of Hermes or
|
|
651
|
+
OpenClaw says "not offered: this port never prompts" (or "not offered
|
|
652
|
+
with -y").
|
|
653
|
+
- When the export credential is for another server, the message
|
|
542
654
|
says what moves it here, where Python's points at `--profile`: for
|
|
543
655
|
`KAGURA_API_KEY`, which outranks every profile, `KAGURA_MCP_URL` or
|
|
544
656
|
unsetting the key; otherwise `KAGURA_PROFILE`.
|
|
545
|
-
-
|
|
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 …]`.
|
|
657
|
+
- File errors of the export are Node's words, not Python's `[Errno …]`.
|
|
554
658
|
- Output is one JSON document on stdout, with Python's sentences in
|
|
555
659
|
`notes` and the block on stderr. A non-ASCII URL is written as UTF-8
|
|
556
660
|
where Python writes `\uXXXX` escapes; both are valid.
|
|
661
|
+
- `--oauth`: a harness CLI run attached writes its output to stderr, so
|
|
662
|
+
stdout stays one JSON document. The server-check refusal ends "Use
|
|
663
|
+
--url-form with an API key instead (no --oauth).", where Python also
|
|
664
|
+
offers its stdio entry, which this bin cannot write. The Codex hooks
|
|
665
|
+
warning appears only when the plugin's hooks are on for the entry (this
|
|
666
|
+
bin does not read an existing entry's bearer), and setup does not ask
|
|
667
|
+
"Write the --oauth entry anyway?": it warns and goes on, as Python does
|
|
668
|
+
under `-y`. The `--guardrails` preview never names `--profile`, which is
|
|
669
|
+
inert here, and also names a `.kagura.json` that is JSON but not an
|
|
670
|
+
object, which every command of this bin refuses (Python's loader takes
|
|
671
|
+
one). Sentences Python wraps at 78 columns are one line here.
|
|
557
672
|
|
|
558
673
|
Some small divergences run the other way: this CLI refuses what click
|
|
559
674
|
would accept.
|
|
@@ -564,8 +679,6 @@ would accept.
|
|
|
564
679
|
apart from `--external-id=` in the `update-memory` case below.
|
|
565
680
|
- `context update --lock --unlock` is a usage error (exit 2, "mutually
|
|
566
681
|
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 `" "`.
|
|
569
682
|
- `--rerank --no-rerank` is the same usage error, on `recall` and on
|
|
570
683
|
`context search-config`.
|
|
571
684
|
- `auth logout --all --profile NAME` is the same usage error, where click
|
|
@@ -576,8 +689,6 @@ would accept.
|
|
|
576
689
|
CLI refuses that too, as `updateMemory` does.
|
|
577
690
|
- `-k=5` (a short option, `=`, a value) reads `5`, where click reads `=5`
|
|
578
691
|
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).
|
|
581
692
|
- An option that takes a value does not take a following argument that
|
|
582
693
|
begins with a dash and is not a number (a lone `-` is still a value):
|
|
583
694
|
`--name-contains -auth` is a missing value here (`Error: Option
|
|
@@ -585,9 +696,6 @@ would accept.
|
|
|
585
696
|
Write `--name-contains=-auth`. A number is anything `float()` reads,
|
|
586
697
|
so `-١` is one. `auth login --invite` is the exception, since an invite
|
|
587
698
|
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
699
|
- An id the command puts in a URL path, `FILE_ID` (`files delete`, `files
|
|
592
700
|
download-url`), the resource id (`-r/--resource-id` of `resource stats`,
|
|
593
701
|
`indexer-status`, `schema`, `ingest`, `ingest-batch` and `import`, and
|
|
@@ -601,6 +709,35 @@ would accept.
|
|
|
601
709
|
id rather than reaching another route or replacing the query
|
|
602
710
|
(`files delete 'x?workspace_id=…'`).
|
|
603
711
|
|
|
712
|
+
**Differences from the Python CLI 0.42.0 in what it added**, each on
|
|
713
|
+
purpose or out of reach:
|
|
714
|
+
|
|
715
|
+
- `update-memory --details` and `remember --details` refuse text that is
|
|
716
|
+
not JSON with JavaScript's parser message after `Invalid JSON for
|
|
717
|
+
--details:`, where Python prints its `json` module's.
|
|
718
|
+
- `update-memory --merge-details` prints the size of a bounded
|
|
719
|
+
`reference` reply when `details_total_chars` is a whole number sent as a
|
|
720
|
+
float (`24000.0`), which Python leaves out: JSON.parse cannot tell it
|
|
721
|
+
from `24000`.
|
|
722
|
+
- `getServerInfo`, `checkServerVersion`, `getEmbeddingStatus`,
|
|
723
|
+
`getMemoryStats`, `findDuplicates` and `listEmbeddingModels` check the
|
|
724
|
+
body against the Python model and return it as the server sent it:
|
|
725
|
+
keys the model does not have stay, and a lax value such as `"3"` for an
|
|
726
|
+
int is not converted, where Python returns the model.
|
|
727
|
+
- `getMemoryStats` accepts rows without `use_count`, which memory-cloud
|
|
728
|
+
v0.34.0 and later never send. The Python SDK 0.42.0's model still
|
|
729
|
+
requires it, so it refuses every non-empty page
|
|
730
|
+
(`memories.0.use_count: Field required`).
|
|
731
|
+
- `listMemories` returns its body unchecked. The Python SDK has read it
|
|
732
|
+
through `MemoryListResponse` since 0.40.0.
|
|
733
|
+
- The kept Hermes OAuth entry of 0.41.3 (python-sdk #287) cannot arise
|
|
734
|
+
here. In Python it arises when the API-key form runs `hermes mcp add`,
|
|
735
|
+
its overwrite prompt is declined, and an `auth: oauth` entry at the
|
|
736
|
+
same URL stays in place. An `--oauth` request already matches that
|
|
737
|
+
entry, so it never stops there. This port's API-key form never runs
|
|
738
|
+
`hermes mcp add`: it prints the entry to put in place of the existing
|
|
739
|
+
one, as Python does under `-y`.
|
|
740
|
+
|
|
604
741
|
**`guardrails load` and `guardrails digest`** (memory-cloud v0.74.0+)
|
|
605
742
|
take the context as an optional argument, else `context_id` from
|
|
606
743
|
`.kagura.json`. `load` calls the MCP `load_guardrails` tool and prints the
|
|
@@ -642,14 +779,35 @@ included) and is `info` when it cannot be compared (`main-abc123`, `0.78`).
|
|
|
642
779
|
An unreachable server fails with `Server unreachable: …`, and an OAuth
|
|
643
780
|
profile the REST route refuses is `info`, in Python's words. The
|
|
644
781
|
`/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
|
-
|
|
647
|
-
|
|
782
|
+
it refuses (no `name`, a `version` that is no string) fails as the Python
|
|
783
|
+
CLI 0.42.0 fails it: `Server answered, but the SDK could not read
|
|
784
|
+
/api/v1/system/info: KaguraClient.get_server_info: unexpected server
|
|
785
|
+
response for ServerInfo (…). The server may be newer than this SDK;
|
|
786
|
+
upgrading kagura-memory may help.` Any other error from the probe, such
|
|
787
|
+
as a 429, fails the check with its own message (`Rate limit exceeded (HTTP
|
|
788
|
+
429): …`). A body that is not JSON is still `Server unreachable: Invalid
|
|
789
|
+
response format: …`, in the words of Python's `json` module (`Expecting
|
|
790
|
+
value: line 1 column 1 (char 0)`), since the body is read as `json.loads`
|
|
791
|
+
reads it. A credential
|
|
648
792
|
that does not resolve fails the auth section with Python's
|
|
649
793
|
`Authentication could not be resolved: …` and skips the server check
|
|
650
|
-
(`info`), as in Python.
|
|
651
|
-
|
|
652
|
-
(`
|
|
794
|
+
(`info`), as in Python. The credential is resolved as a bare client
|
|
795
|
+
resolves it, as in Python: `KAGURA_API_KEY`, then the OAuth profile
|
|
796
|
+
(`--profile NAME`, `KAGURA_PROFILE` or the default; an empty `--profile`
|
|
797
|
+
is the default), then `.kagura.json`. A selected profile that does not
|
|
798
|
+
exist fails the auth section once, with the resolution's message, and
|
|
799
|
+
with `KAGURA_API_KEY` set an expired or missing profile is no failure, as
|
|
800
|
+
in Python, whose warning is that the key shadows the profile. A resolved
|
|
801
|
+
MCP URL that is not HTTPS is a warning and the server is not contacted
|
|
802
|
+
(`Server connectivity check skipped because the MCP URL is insecure`),
|
|
803
|
+
whichever source it came from:
|
|
804
|
+
an OAuth profile's URL, `KAGURA_MCP_URL`, or the `mcp_url` of the
|
|
805
|
+
`.kagura.json` the credential resolved from (exit 0, as in Python). One
|
|
806
|
+
remaining difference: a plain-HTTP `.kagura.json` `mcp_url` that the
|
|
807
|
+
credential does not use, because `KAGURA_API_KEY` or an OAuth profile
|
|
808
|
+
brings its own URL, still fails the `mcp` section here (`mcp_url is not
|
|
809
|
+
HTTPS: …`, exit 1), since `setup claude` would refuse that URL; the
|
|
810
|
+
Python CLI's `doctor` never reads the file's `mcp_url`. `--json`
|
|
653
811
|
prints Python's shape, with `details` on every check (`{}` when there are
|
|
654
812
|
none). Any failed check exits 1.
|
|
655
813
|
|
|
@@ -716,16 +874,19 @@ server left out, and drops any other. A record the model refuses (a
|
|
|
716
874
|
required field missing, a scalar, list or mapping of the wrong type)
|
|
717
875
|
exits 1 with its `KaguraResponseError` text; timestamps are printed as
|
|
718
876
|
the server wrote them. `--role` matches exactly, as
|
|
719
|
-
click's `Choice` does (`Admin` is refused).
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
`--user`) is refused (exit 2) before anything is
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
`invite list` does
|
|
877
|
+
click's `Choice` does (`Admin` is refused). As in the Python CLI (0.41.1+):
|
|
878
|
+
a workspace that is not a UUID is refused before `member remove` or
|
|
879
|
+
`revoke-key` asks, and the question names it in canonical form; each
|
|
880
|
+
`invite create -c` must be a context UUID (exit 2, `Invalid value for
|
|
881
|
+
'--context' / '-c': 'x' is not a valid context UUID.`, before anything
|
|
882
|
+
is read) and is sent in canonical form; a user id of `.`, `..` or
|
|
883
|
+
nothing (`USER_ID` or `--user`) is refused (exit 2) before anything is
|
|
884
|
+
asked or sent; a `context_id` in `.kagura.json` that is not a string
|
|
885
|
+
reads as absent; and an invitation with no email prints `-`, as
|
|
886
|
+
`invite list` does. When more than one of these is wrong, the error
|
|
887
|
+
names them in declaration order (`EMAIL`, `--role`, `-c`,
|
|
888
|
+
`--expires-days`), where click names whichever comes first on the
|
|
889
|
+
command line.
|
|
729
890
|
|
|
730
891
|
**`measure record` and `measure series`** take the context as their
|
|
731
892
|
first argument, never from `.kagura.json`: an observation recorded in the
|
|
@@ -940,11 +1101,19 @@ keyed on the error code and the envelope's fields, never on the message:
|
|
|
940
1101
|
| `KaguraNotFoundError` | missing contexts/memories/reports/agents/bindings (on `updateSearchConfig`, a missing context is a `KaguraPermissionError` instead) | — |
|
|
941
1102
|
| `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` |
|
|
942
1103
|
| `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 |
|
|
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` |
|
|
1104
|
+
| `KaguraPartialRollbackError` | `rollbackSleepRun` reversed some actions but not all. A `rollback_summary` the SDK cannot read adds ` (rollback_summary could not be read)` to the message, as Python's does, with `summary` `{}` (Python: `None`) and the `KaguraResponseError` as `cause` | `reportId`, `summary` |
|
|
1105
|
+
| `KaguraResponseError` | a successful response the SDK cannot read, usually because the server is newer than this SDK. That includes `getServerInfo`, `checkServerVersion` (as `KaguraClient.get_server_info`), `getEmbeddingStatus`, `getMemoryStats`, `findDuplicates` and `listEmbeddingModels`, which check the body against the Python model and return it as sent. 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` |
|
|
945
1106
|
| `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` |
|
|
946
1107
|
| `KaguraError` | any other code | — |
|
|
947
1108
|
|
|
1109
|
+
`ResourceClient`'s readers check each 2xx body against the Python SDK's
|
|
1110
|
+
model, as Python's `_parse` does, and throw `KaguraResponseError` for one
|
|
1111
|
+
it refuses (`ingestEvents` after its `error` progress event). A body the
|
|
1112
|
+
model accepts is returned as it arrived: its extra keys and lax values
|
|
1113
|
+
(`"6"` for an int) are kept, where Python returns the model's coerced
|
|
1114
|
+
copy. `ingestEvents`'s `success` event carries the model's counts, as
|
|
1115
|
+
Python's does (`failed` is `0` when the body has no `failed_count`).
|
|
1116
|
+
|
|
948
1117
|
memory-cloud v0.75.0+ tags every plan and quota refusal with a `gate`
|
|
949
1118
|
(`plan`, `quota`, `allowlist` or `deployment`), and the SDK chooses the
|
|
950
1119
|
class from it first, falling back to the code for older servers. The
|
|
@@ -1034,7 +1203,7 @@ the counterpart to `recall`'s probabilistic search.
|
|
|
1034
1203
|
|
|
1035
1204
|
| Method | What it does |
|
|
1036
1205
|
|--------|--------------|
|
|
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
|
|
1206
|
+
| `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 on every server, because the MCP tool has `with_tags` only from server v0.77.0 and an older one ignores it; 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. |
|
|
1038
1207
|
| `explore` | Graph traversal from a seed memory (`depth` 1–5, `minWeight`). |
|
|
1039
1208
|
| `listEdges` | Edges touching a memory, incoming and outgoing, deduplicated. |
|
|
1040
1209
|
| `createEdge` / `updateEdge` / `deleteEdge` | Manual edge curation. `(sourceId, targetId)` is the identity; self-loops are rejected. |
|
|
@@ -1075,7 +1244,7 @@ Ephemeral, TTL-bounded, and excluded from recall — deliberately not memories.
|
|
|
1075
1244
|
| Method | What it does |
|
|
1076
1245
|
|--------|--------------|
|
|
1077
1246
|
| `getServerInfo` | Version, deployment feature flags, and (v0.69.0+) the reranker defaults new contexts start with, under `search_defaults`. |
|
|
1078
|
-
| `checkServerVersion` | Compare against `MIN_SERVER_VERSION` (0.75.0). Advisory: logs, never throws
|
|
1247
|
+
| `checkServerVersion` | Compare against `MIN_SERVER_VERSION` (0.75.0). Advisory: logs, and never throws on an old version; a body that is not a `ServerInfo` throws `KaguraResponseError`, as in `getServerInfo`. 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`, `main-abc123`) is not compared. |
|
|
1079
1248
|
| `getUsage` | Workspace quota and usage: `used` / `limit` for memories, contexts, members and today's MCP calls. |
|
|
1080
1249
|
| `getMemoryStats` | Per-memory usage stats, sortable and paged. |
|
|
1081
1250
|
| `getEmbeddingStatus` / `listEmbeddingModels` | Embedding backend state and the models available for `createContext`. |
|
|
@@ -1282,6 +1451,10 @@ URL resolution would send the request elsewhere. The Python SDK sends
|
|
|
1282
1451
|
them as typed, but for a workspace user id, which it refuses too from
|
|
1283
1452
|
0.41.1
|
|
1284
1453
|
([#66](https://github.com/kagura-ai/kagura-memory-typescript-sdk/issues/66)).
|
|
1454
|
+
`createInvitation` refuses an `allowedContextIds` entry that is not a
|
|
1455
|
+
UUID before sending anything (`allowedContextIds must be a UUID, got
|
|
1456
|
+
'ctx-1'`), and sends each in canonical form, as the Python SDK does from
|
|
1457
|
+
0.41.1; it and every workspace id take the spellings `uuid.UUID` takes.
|
|
1285
1458
|
|
|
1286
1459
|
## Zero-knowledge secrets
|
|
1287
1460
|
|
|
@@ -1389,6 +1562,9 @@ CLI as `kagura-memory`: 20 of the 21 top-level commands, counting the
|
|
|
1389
1562
|
`contexts` alias. Only `kagura ingest` is not ported (below);
|
|
1390
1563
|
[Command line](#command-line) lists where the two CLIs still differ.
|
|
1391
1564
|
|
|
1565
|
+
The parity target is the Python SDK and CLI **0.42.0**, checked against
|
|
1566
|
+
memory-cloud up to **v0.77.0**.
|
|
1567
|
+
|
|
1392
1568
|
One thing is deliberately not ported, because it would cost the
|
|
1393
1569
|
zero-dependency promise:
|
|
1394
1570
|
|
|
@@ -1408,6 +1584,76 @@ the two. See
|
|
|
1408
1584
|
[`docs/design/2026-07-05-typescript-port-design.md`](docs/design/2026-07-05-typescript-port-design.md)
|
|
1409
1585
|
for the original scope decisions.
|
|
1410
1586
|
|
|
1587
|
+
**Reading responses.** The SDK reads each field of a response as the
|
|
1588
|
+
Python SDK's pydantic model reads it in lax mode, with pydantic's
|
|
1589
|
+
messages ([#66](https://github.com/kagura-ai/kagura-memory-typescript-sdk/issues/66),
|
|
1590
|
+
[#69](https://github.com/kagura-ai/kagura-memory-typescript-sdk/issues/69)):
|
|
1591
|
+
an int field takes `"0-1"` (-1) and `"0__7"` and refuses a digit run past
|
|
1592
|
+
4,300 characters, a float field follows pydantic's `str_as_float` rather
|
|
1593
|
+
than Python's `float()`, and a string holding a lone surrogate is refused
|
|
1594
|
+
in any field but a `str`. Three limits of JavaScript numbers remain. An
|
|
1595
|
+
int field of a typed result (`recallSeries`' `count`, the guardrail caps,
|
|
1596
|
+
a member key's or invitation's `id`) holds a `number`, so a value past
|
|
1597
|
+
2^53 is the nearest double and one of 2^1024 or more (309 digits) is
|
|
1598
|
+
`Infinity`, where Python keeps the exact int; widening those types would
|
|
1599
|
+
break callers. The other two hold only where a body is read with
|
|
1600
|
+
`JSON.parse`, which cannot tell `1e20` from `100000000000000000000` or
|
|
1601
|
+
`9223372036854775807` from 2^63: the text of an MCP tool result
|
|
1602
|
+
(`recallSeries`' `count`, a bucket's `count`,
|
|
1603
|
+
`ResourceClient.setupResource`'s `token_id`). Every REST reader
|
|
1604
|
+
(`ResourceClient`, `FilesClient`, `MemoryClient`, `WorkspaceClient`,
|
|
1605
|
+
`KaguraClient`'s REST methods, so the `resource` and `files` dumps too)
|
|
1606
|
+
keeps the literal and agrees with pydantic. In a tool result, an int
|
|
1607
|
+
field sent a whole float literal of 2^63 or more (`1e20`,
|
|
1608
|
+
`9223372036854775808.0`) reads it as that double, where pydantic refuses
|
|
1609
|
+
it with `Unable to parse input string as an integer, exceeded maximum
|
|
1610
|
+
size` and accepts the int literal exactly. And a bool field sent the JSON number
|
|
1611
|
+
9223372036854775807 or -9223372036854775808 would read it as the double
|
|
1612
|
+
+/-2^63 and say `Input should be a valid boolean`, where pydantic says
|
|
1613
|
+
`…, unable to interpret input`; no MCP tool result has a bool field
|
|
1614
|
+
today, so this is the coercer's limit rather than any field's.
|
|
1615
|
+
|
|
1616
|
+
**The MCP envelope.** A JSON-RPC or tool error is rendered as the Python
|
|
1617
|
+
SDK renders it, with Python's `str()` of whatever the server sent
|
|
1618
|
+
(`MCP error: {'code': -32603}`, `t failed (None): …`), and a `null`
|
|
1619
|
+
JSON-RPC body reads as no result. Three differences remain. A JSON-RPC
|
|
1620
|
+
`error` that is no object (`{"error": "boom"}`, `null`, `[1]`) reads
|
|
1621
|
+
`MCP error: boom` (`None`, `[1]`), where the Python SDK stops with an
|
|
1622
|
+
`AttributeError`; likewise a JSON-RPC body that is no object (`5`, `"x"`,
|
|
1623
|
+
`[1]`, an empty body) and a `result` that is no object read as no result
|
|
1624
|
+
(`{}`), where the Python SDK stops with a `TypeError`, an
|
|
1625
|
+
`AttributeError` or a raw `JSONDecodeError`: Python has no words to port
|
|
1626
|
+
there. A number literal in a code or message is rendered from the
|
|
1627
|
+
JavaScript number (`1.0` reads `1`, `1e2` `100`, `-0.0` `0`, an int past
|
|
1628
|
+
2^53 its nearest double) and an object's integer-like keys print first,
|
|
1629
|
+
where Python prints the literal and keeps the key order: the JSON-RPC
|
|
1630
|
+
body and the tool text are read with `JSON.parse`. And
|
|
1631
|
+
`KaguraPartialRollbackError.summary` is the `rollback_summary` as it
|
|
1632
|
+
arrived, once checked against Python's `RollbackSummary` (an
|
|
1633
|
+
`edges_deleted` of `"6"` stays the string, an unknown key stays), where
|
|
1634
|
+
Python's model holds `6` and drops the key; `rollbackSleepRun`'s success
|
|
1635
|
+
result is returned the same way.
|
|
1636
|
+
|
|
1637
|
+
**Hand-edited credentials.** A profile in `~/.kagura/credentials.json`
|
|
1638
|
+
whose `access_token` is no string, or whose `refresh_token` is `null`, is
|
|
1639
|
+
read as the Python SDK reads it: the token is sent as Python's `str()` of
|
|
1640
|
+
it (`Bearer 123`) and a falsy refresh token means none. The file is read
|
|
1641
|
+
as Python's `json.loads` reads it, so a number literal in a token is
|
|
1642
|
+
rendered as Python renders it (`1.0` sends `Bearer 1.0`, `1e16` `Bearer
|
|
1643
|
+
1e+16`, an int past 2^53 exactly, `NaN` `Bearer nan`, which is also a
|
|
1644
|
+
truthy refresh token) and an object token keeps its key order. When this
|
|
1645
|
+
SDK rewrites the file (a refresh, `auth
|
|
1646
|
+
use`), it writes those two tokens as strings (`"123"`, `""`) where Python
|
|
1647
|
+
writes them back as they were; both SDKs read either form the same way,
|
|
1648
|
+
so after a rewrite of a number token Python sends the rendered string too.
|
|
1649
|
+
Two more differences are on the Python side of such a file: the Python
|
|
1650
|
+
CLI's own `auth status` stops with a `TypeError` on a number token (its
|
|
1651
|
+
`_redact_token` takes the token's `len`), where `kagura-memory auth
|
|
1652
|
+
status` prints the profile; and `auth token` on a profile whose
|
|
1653
|
+
`access_token` is `null` prints an empty line there (`click.echo(None)`)
|
|
1654
|
+
and `None` here, the token being rendered when the file is read, while
|
|
1655
|
+
the header is `Bearer None` in both.
|
|
1656
|
+
|
|
1411
1657
|
## Development
|
|
1412
1658
|
|
|
1413
1659
|
```bash
|