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