kagura-memory 0.10.0 → 0.11.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 +261 -67
- package/dist/cli.js +1158 -407
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +159 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +88 -9
- package/dist/index.d.ts +88 -9
- package/dist/index.js +159 -33
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -90,9 +90,16 @@ Four ways to authenticate, in resolution order:
|
|
|
90
90
|
|
|
91
91
|
### Command line
|
|
92
92
|
|
|
93
|
-
`kagura-memory` mirrors the Python CLI's `kagura` command
|
|
94
|
-
|
|
95
|
-
a usage error, 1 for a runtime
|
|
93
|
+
`kagura-memory` mirrors the Python CLI's `kagura` command: its subcommands
|
|
94
|
+
and flags take the Python CLI's names, and it prints the same JSON on
|
|
95
|
+
stdout and exits with the same codes (2 for a usage error, 1 for a runtime
|
|
96
|
+
failure). An option a command, a group or the root does not take is
|
|
97
|
+
refused in the words of click 8.3, the version the Python CLI's lockfile
|
|
98
|
+
pins: `Error: No such option: --x`, naming the option without any value
|
|
99
|
+
given in it (click 8.4 and later write `No such option '--x'.`, and may
|
|
100
|
+
add a `Did you mean …?` this bin does not). The commands and options not
|
|
101
|
+
ported yet, the few options only this bin has, and the deliberate
|
|
102
|
+
differences are listed below.
|
|
96
103
|
|
|
97
104
|
```bash
|
|
98
105
|
npx kagura-memory --help
|
|
@@ -114,8 +121,9 @@ npx kagura-memory --help
|
|
|
114
121
|
```bash
|
|
115
122
|
npx kagura-memory auth login --profile work --read-only
|
|
116
123
|
npx kagura-memory recall "OAuth setup" -c dev -k 10
|
|
124
|
+
npx kagura-memory recall "dependency injection" --no-rerank # skip reranking; no flag follows the context config (v0.69.0+)
|
|
117
125
|
npx kagura-memory remember -s "FastAPI DI" --content "Use Depends()" --tags "python,fastapi"
|
|
118
|
-
npx kagura-memory setup codex --dry-run #
|
|
126
|
+
npx kagura-memory setup codex --dry-run # show the command and the entry; change nothing
|
|
119
127
|
npx kagura-memory doctor
|
|
120
128
|
```
|
|
121
129
|
|
|
@@ -124,48 +132,111 @@ The context id comes from `-c/--context-id`, or from `context_id` in
|
|
|
124
132
|
shared with the Python CLI, so either tool can create a profile the other
|
|
125
133
|
then uses.
|
|
126
134
|
|
|
127
|
-
**Connecting a harness.** Each `setup` subcommand
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
**Connecting a harness.** Each `setup` subcommand sets up an MCP entry
|
|
136
|
+
named `kagura-memory`: the URL plus a Bearer header. The key is never
|
|
137
|
+
printed, and no harness CLI gets it on its command line.
|
|
138
|
+
|
|
139
|
+
`setup claude` also writes `.kagura.json` (0600, gitignored). Its key
|
|
140
|
+
comes from `--api-key`, else the `api_key` in the project's own
|
|
141
|
+
`.kagura.json` (the one in `--project-dir`), else `KAGURA_API_KEY`; the
|
|
142
|
+
URL likewise from `--mcp-url`, else that file's `mcp_url`, else
|
|
143
|
+
`KAGURA_MCP_URL`. It never takes them from `~/.kagura.json`, nor, with
|
|
144
|
+
`--project-dir`, from the current directory's `.kagura.json`: those are
|
|
145
|
+
another project's credentials. `.kagura.json` gets the URL as given; the
|
|
146
|
+
parameters that `--guardrails` and `--tool-profile` set go on the entry's
|
|
147
|
+
URL only.
|
|
148
|
+
|
|
149
|
+
`setup codex`, `setup hermes` and `setup openclaw` never see, write, print
|
|
150
|
+
or pass the key, as in the Python CLI. The entry names the environment
|
|
151
|
+
variable the harness reads the key from, and the notes say where to put
|
|
152
|
+
it; a missing key is no error. These three write no file themselves:
|
|
153
|
+
no `.kagura.json`, no `.gitignore` line, no harness `.env`. The harness's
|
|
154
|
+
own CLI writes the entry, or you add the printed block.
|
|
155
|
+
|
|
156
|
+
| Subcommand | How the entry is applied | Where the key goes |
|
|
137
157
|
|---|---|---|
|
|
138
|
-
| `setup claude` | `.mcp.json` (`--scope project`, the default), or `claude mcp add-json --scope user …` | in
|
|
139
|
-
| `setup codex` | `codex mcp add … --bearer-token-env-var KAGURA_API_KEY` | `KAGURA_API_KEY
|
|
140
|
-
| `setup hermes` | the `config.yaml` block is printed; `hermes mcp add`
|
|
141
|
-
| `setup openclaw` | `openclaw mcp add … --transport streamable-http --no-probe` | `$OPENCLAW_STATE_DIR/.env` (default `~/.openclaw/.env`),
|
|
158
|
+
| `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 |
|
|
159
|
+
| `setup codex` | `codex mcp add … --bearer-token-env-var KAGURA_API_KEY` | `export KAGURA_API_KEY=…` in the shell profile that starts Codex |
|
|
160
|
+
| `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 |
|
|
161
|
+
| `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 |
|
|
162
|
+
|
|
163
|
+
`--api-key-env VAR` renames `KAGURA_API_KEY` for Codex and OpenClaw
|
|
164
|
+
(an upper-case letter or `_`, then upper-case letters, digits or `_`).
|
|
165
|
+
Hermes names its variable itself, so `setup hermes` refuses the option
|
|
166
|
+
(exit 2). The entry goes into Codex's `$CODEX_HOME/config.toml` (default
|
|
167
|
+
`~/.codex/config.toml`), into Hermes's `config.yaml` in `$HERMES_HOME` or
|
|
168
|
+
else the active Hermes profile's directory (`~/.hermes/profiles/<name>`
|
|
169
|
+
when `~/.hermes/active_profile` names one, else `~/.hermes`), or into
|
|
170
|
+
OpenClaw's `$OPENCLAW_CONFIG_PATH` (default `openclaw.json` in the state
|
|
171
|
+
directory). The closing notes name the command that checks it:
|
|
172
|
+
`codex mcp get kagura-memory`, `hermes mcp test kagura-memory` or
|
|
173
|
+
`openclaw mcp doctor kagura-memory --probe`. `--mcp-url` defaults to the
|
|
174
|
+
configured `mcp_url`, then `https://memory.kagura-ai.com/mcp`. A plain
|
|
175
|
+
`http://` `--mcp-url` other than localhost is a usage error (exit 2),
|
|
176
|
+
since the entry sends the key there with every request; a configured
|
|
177
|
+
`mcp_url` like that exits 1 and says to pass `--mcp-url`.
|
|
142
178
|
|
|
143
179
|
This package has no TOML, YAML or JSON5 parser, so it never rewrites those
|
|
144
180
|
files. When the harness's CLI is not on `PATH`, the block is printed on
|
|
145
|
-
stderr with the file it belongs in
|
|
146
|
-
|
|
147
|
-
`
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
181
|
+
stderr with the file it belongs in, and stdout stays one JSON document.
|
|
182
|
+
When Hermes's `config.yaml` already has an `mcp_servers:` key, only the
|
|
183
|
+
`kagura-memory` entry is printed, to go under it: a second top-level
|
|
184
|
+
`mcp_servers:` would replace the first, and every server in it. An entry
|
|
185
|
+
of the same name, which setup finds by scanning the file, stops the run
|
|
186
|
+
(exit 1, nothing changed) unless you pass `--force`. For Codex that holds
|
|
187
|
+
always; for Hermes and OpenClaw only with their CLI on `PATH`, since the
|
|
188
|
+
Python CLI finds their entries only through it. Without the CLI, setup
|
|
189
|
+
prints the block to go in place of the old entry and exits 0. A
|
|
190
|
+
`config.toml` that cannot be read stops `setup codex` (exit 1), as in
|
|
191
|
+
Python; a Hermes or OpenClaw file that cannot be read stops nothing, since
|
|
192
|
+
Python never reads those, and a note says setup could not look there.
|
|
151
193
|
On Windows, a CLI installed only as an npm `.cmd` shim counts as not
|
|
152
194
|
found: Node runs one only through a shell, which would re-parse the
|
|
153
195
|
arguments.
|
|
154
196
|
|
|
155
|
-
`--
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
the
|
|
161
|
-
|
|
197
|
+
With `--scope user`, the Claude Code entry does not hold the key: it
|
|
198
|
+
sends `Authorization: Bearer ${KAGURA_MCP_API_KEY}`, which Claude Code
|
|
199
|
+
fills in from its own environment each time it connects. The key is never
|
|
200
|
+
on the `claude mcp add-json` command line, where any local user could read
|
|
201
|
+
it in the process list, and never in `~/.claude.json`. Set the variable in
|
|
202
|
+
the environment that starts Claude Code, e.g. `export
|
|
203
|
+
KAGURA_MCP_API_KEY=kagura_xxx` in your shell profile; setup says whether
|
|
204
|
+
the current shell has it, and `doctor` warns when it is unset. It is a
|
|
205
|
+
separate variable from `KAGURA_API_KEY`, which the SDK ranks above
|
|
206
|
+
`.kagura.json` and OAuth profiles for every command. The entry is the one
|
|
207
|
+
the Python CLI writes, so a run of either CLI finds the other's entry up
|
|
208
|
+
to date. `--scope project` still writes the key into `.mcp.json`, so keep
|
|
209
|
+
that file out of version control (setup adds it to `.gitignore`). A
|
|
210
|
+
user-scope entry this CLI wrote before 0.11.0 still holds the key in
|
|
211
|
+
`~/.claude.json`: re-run `setup claude --scope user` with
|
|
212
|
+
`KAGURA_MCP_API_KEY` exported to replace it (`doctor` warns about one).
|
|
213
|
+
|
|
214
|
+
`--guardrails <context-id|off>` (memory-cloud v0.74.0+) sets the URL's
|
|
215
|
+
`guardrails` parameter on `setup claude` and `setup codex`. On `setup
|
|
216
|
+
codex`, when neither the flag nor the MCP URL (`--mcp-url` or the
|
|
217
|
+
configured `mcp_url`) sets one, it defaults to `off` while the Kagura
|
|
218
|
+
plugin's Codex hooks are on for the entry (their `config.json` names its
|
|
219
|
+
table in `mcp_server`, `kagura-memory` by default), and otherwise to
|
|
220
|
+
`-c` when that is a UUID. With a context there, the notes give the Python
|
|
221
|
+
CLI's `kagura guardrails digest … --target instructions` command, which
|
|
222
|
+
previews what Codex receives. Hermes and OpenClaw do not read the
|
|
223
|
+
server's instructions. There `--guardrails off` is refused (exit 2), and
|
|
224
|
+
a context id is not written, whether it comes from the flag or from the
|
|
225
|
+
URL. A `?guardrails=off` already in the URL is kept, with a warning, as
|
|
226
|
+
in Python. `--tool-profile` (claude, codex; memory-cloud
|
|
227
|
+
v0.73.0+) sets `profile` and refuses an empty name. The server knows
|
|
228
|
+
`full` and `core` (case-sensitive) and fails `tools/list` for any other
|
|
229
|
+
name, which leaves the harness with no Kagura tools. It applies a
|
|
230
|
+
`?tools=` allowlist already on the URL instead, so that case gets a
|
|
231
|
+
warning. Both go at the end of the query, `guardrails`
|
|
162
232
|
first, replacing any value already there, as the Python CLI writes them.
|
|
163
233
|
A `setup claude` run that leaves out a `guardrails` or `profile` value
|
|
164
234
|
the entry it replaces had says so in a note. `--name`, `--force` and
|
|
165
235
|
`--dry-run` (codex, hermes, openclaw) name the entry, replace an existing
|
|
166
|
-
one, and show
|
|
167
|
-
|
|
168
|
-
|
|
236
|
+
one, and show the command or block without changing anything. A name is
|
|
237
|
+
1-64 letters, digits, `-` or `_`, as in Python, and here it also starts
|
|
238
|
+
with a letter or digit: it is a bare argument to `codex` and `openclaw`,
|
|
239
|
+
which would read `--help` as an option.
|
|
169
240
|
|
|
170
241
|
Claude Code uses the `kagura-memory` entry from the strongest scope
|
|
171
242
|
(local > project > user). It keys local scope by the git repository root
|
|
@@ -176,24 +247,68 @@ any parent; `setup claude` and `doctor` read them the same way.
|
|
|
176
247
|
and prints the `claude mcp remove --scope …` command for it, after a `cd`
|
|
177
248
|
into the directory that command must run in when that is not the current
|
|
178
249
|
one. An entry the new one hides, in a weaker scope or in a parent's
|
|
179
|
-
`.mcp.json`, is noted.
|
|
250
|
+
`.mcp.json`, is noted. Messages name `~/.claude.json` by the file actually
|
|
251
|
+
read: `$CLAUDE_CONFIG_DIR/.claude.json` when that is set.
|
|
180
252
|
With `--scope user`, an identical user-scope entry is left as it is and a
|
|
181
253
|
different one is replaced: `claude mcp remove` runs before `claude mcp
|
|
182
|
-
add-json`, and if the add then fails, the old entry is put back
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
254
|
+
add-json`, and if the add then fails, the old entry is put back. An old
|
|
255
|
+
entry that holds a key (as this CLI wrote before 0.11.0) is never put
|
|
256
|
+
back, since that would pass the key on a command line; when it is not put
|
|
257
|
+
back, or putting it back fails, setup prints the command that re-adds it,
|
|
258
|
+
the key masked as `<your-api-key>`.
|
|
259
|
+
Without `claude` on `PATH`, `--scope user` prints the commands to run, and
|
|
260
|
+
where to set `KAGURA_MCP_API_KEY`, and writes nothing, unless the
|
|
261
|
+
user-scope entry is already identical. When `claude plugin list --json`
|
|
262
|
+
shows the Kagura Memory plugin enabled, the notes list the plugin settings
|
|
263
|
+
to enter, and say that the plugin has one guardrail context for every
|
|
264
|
+
project and authenticates only with a user API key. `setup claude` writes
|
|
265
|
+
`.kagura.json` and the MCP entry only; it installs none of the Python
|
|
266
|
+
CLI's hooks or `/kagura-recall` and `/kagura-remember` commands. Their
|
|
267
|
+
flags (`--[no-]session-hook`, `--[no-]sync-hook`, `--[no-]commands`) and
|
|
268
|
+
`--no-auto-context` are accepted, so a script written for the Python CLI
|
|
269
|
+
still runs, and change nothing. `doctor` reports the entry Claude Code
|
|
270
|
+
uses in the current directory, with its scope and file, and warns about
|
|
271
|
+
each entry that one hides. It also warns when a header of that entry
|
|
272
|
+
sends a `${VAR}` that is unset in the current environment, or when that
|
|
273
|
+
entry is in user or local scope and holds the key itself, in
|
|
274
|
+
`~/.claude.json`, saying how to replace it; and for a
|
|
275
|
+
`kagura-mcp` stdio entry (the Python CLI's `--profile` form) checks that
|
|
276
|
+
`kagura-mcp` is on `PATH`. For a `type: "url"` entry, which earlier
|
|
277
|
+
releases wrote and Claude Code skips, it names the fix for the entry's
|
|
278
|
+
scope.
|
|
192
279
|
|
|
193
280
|
**Not ported.** `kagura ingest` needs the text-extraction pipeline (PDF,
|
|
194
|
-
Office, EPUB, audio)
|
|
195
|
-
|
|
196
|
-
|
|
281
|
+
Office, EPUB, audio), which does not exist in this package and would cost
|
|
282
|
+
the zero-dependency promise. Not ported yet: `auth create-key`,
|
|
283
|
+
`auth list-keys` and `auth revoke-key`; the `workspace` group
|
|
284
|
+
(`member list|add|set-role|remove`, `invite create|list|revoke`);
|
|
285
|
+
`guardrails load` and `guardrails digest`; `measure record` and
|
|
286
|
+
`measure series`; the `-v/--verbose` and `--progress` options of
|
|
287
|
+
`files upload` and `resource import`; and the `--agents-md` option of
|
|
288
|
+
`setup codex`, `setup hermes` and `setup openclaw`, the guardrail export,
|
|
289
|
+
which needs `guardrails digest` first
|
|
290
|
+
([#57](https://github.com/kagura-ai/kagura-memory-typescript-sdk/issues/57))
|
|
291
|
+
and which this CLI rejects as an unknown option. Use the Python CLI for
|
|
292
|
+
all of these. The Claude Code extras of
|
|
293
|
+
`kagura setup claude` are not ported either: its SessionStart and
|
|
294
|
+
PostToolUse hooks and its `/kagura-recall` and `/kagura-remember`
|
|
295
|
+
commands. `setup claude` here writes `.kagura.json` and the MCP entry
|
|
296
|
+
only, and takes their flags as inert (see above).
|
|
297
|
+
|
|
298
|
+
**Only in this bin.** `secret keygen --reveal`: keygen prints the private
|
|
299
|
+
key (see key custody below) and refuses to print it to a terminal without
|
|
300
|
+
`--reveal`. `-c` is short for `--context-id` on every `setup` subcommand.
|
|
301
|
+
`setup codex` also takes `--tool-profile`, which the Python CLI has only on
|
|
302
|
+
`setup claude`. `auth refresh --no-browser`: a refresh that widens
|
|
303
|
+
`--scope` re-runs the device flow here too, and this skips opening the
|
|
304
|
+
browser, as on `auth login`; Python's `auth refresh` takes only
|
|
305
|
+
`--profile` and `--scope`. `-h` is short for `--help` everywhere, where
|
|
306
|
+
the Python CLI takes only `--help`. `setup codex`, `setup hermes` and
|
|
307
|
+
`setup openclaw` still
|
|
308
|
+
accept `--api-key` and `--project-dir`, which they took before 0.11.0, so
|
|
309
|
+
older scripts still run. Neither does anything now, and a note says so.
|
|
310
|
+
`--api-key` beside `--profile` is still the usage error (exit 2) it was,
|
|
311
|
+
with `--url-form` too.
|
|
197
312
|
|
|
198
313
|
**Three deliberate divergences.**
|
|
199
314
|
|
|
@@ -205,18 +320,68 @@ promise. Use the Python CLI for those.
|
|
|
205
320
|
closed when neither is set. **A key custodied by the Python CLI is not
|
|
206
321
|
readable here, and vice versa.**
|
|
207
322
|
- `setup … --profile` (the OAuth path) writes an entry that launches
|
|
208
|
-
Python's `kagura-mcp` stdio proxy, which this package does not install
|
|
209
|
-
|
|
210
|
-
|
|
323
|
+
Python's `kagura-mcp` stdio proxy, which this package does not install.
|
|
324
|
+
Every `setup` subcommand reports the fact, and names the Python CLI's
|
|
325
|
+
`kagura setup <harness> --profile` command, instead of writing a config
|
|
326
|
+
that would fail at launch. The `--api-key` path of `setup claude` works
|
|
327
|
+
here, and so does the URL form of the other three. With `--url-form`,
|
|
328
|
+
those three ignore `--profile`, with a note: the Python CLI uses it
|
|
329
|
+
there to check the login, list contexts and fetch the `AGENTS.md`
|
|
330
|
+
export, and this port never contacts the server.
|
|
211
331
|
- `config show` does not reproduce Python's key mask
|
|
212
332
|
(`key[:8] + "..." + key[-4:]`), whose halves overlap below 12 characters
|
|
213
333
|
and print the whole secret twice.
|
|
214
334
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
335
|
+
**`setup codex`, `setup hermes` and `setup openclaw`** also differ from
|
|
336
|
+
the Python CLI in these ways, each on purpose:
|
|
337
|
+
|
|
338
|
+
- Every entry here is the URL form, so `--url-form` is accepted and
|
|
339
|
+
changes nothing, and `--mcp-url` falls back to the configured URL where
|
|
340
|
+
Python requires it. Only that fallback needs the configuration: without
|
|
341
|
+
`--mcp-url`, a `.kagura.json` that cannot be loaded stops setup (exit 1);
|
|
342
|
+
with it, setup goes on with a note, as Python never reads that file.
|
|
343
|
+
- A `-c` that is not a UUID is not used for guardrails, and a note says
|
|
344
|
+
so. Python looks a name up through `--profile`, and without one exits 2.
|
|
345
|
+
- `setup codex --force` runs one `codex mcp add`, which overwrites the
|
|
346
|
+
entry. Python runs `codex mcp remove` first.
|
|
347
|
+
- `setup hermes` never runs `hermes mcp add`, which prompts; it prints the
|
|
348
|
+
block, as Python does under `-y`.
|
|
349
|
+
- An existing entry is found by scanning the file, and not described by
|
|
350
|
+
kind. A readable but malformed `config.toml` does not stop
|
|
351
|
+
`setup codex`.
|
|
352
|
+
- On Hermes and OpenClaw, a context id in `--mcp-url`'s `?guardrails=` is
|
|
353
|
+
dropped, where Python keeps it. On Codex, a `?guardrails=` already in
|
|
354
|
+
the MCP URL (`--mcp-url` or the configured `mcp_url`) beats the hooks
|
|
355
|
+
and `-c` defaults.
|
|
356
|
+
- OpenClaw's `.env` is in `$OPENCLAW_STATE_DIR` when that is set.
|
|
357
|
+
- Output is one JSON document on stdout, with Python's sentences in
|
|
358
|
+
`notes` and the block on stderr. A non-ASCII URL is written as UTF-8
|
|
359
|
+
where Python writes `\uXXXX` escapes; both are valid.
|
|
360
|
+
|
|
361
|
+
Some small divergences run the other way: this CLI refuses what click
|
|
362
|
+
would accept.
|
|
363
|
+
|
|
364
|
+
- `--profile=` and `--scope=` reject an explicitly empty value. An empty
|
|
365
|
+
profile name would create a nameless profile and an empty scope would go
|
|
366
|
+
to the server verbatim. Other options take `--flag=` as Python does,
|
|
367
|
+
apart from `--external-id=` in the `update-memory` case below.
|
|
368
|
+
- `context update --lock --unlock` is a usage error (exit 2, "mutually
|
|
369
|
+
exclusive; pick one"), where click takes whichever flag comes last.
|
|
370
|
+
- `--rerank --no-rerank` is the same usage error, on `recall` and on
|
|
371
|
+
`context search-config`.
|
|
372
|
+
- `auth logout --all --profile NAME` is the same usage error, where click
|
|
373
|
+
ignores `--profile` and logs out every profile.
|
|
374
|
+
- `update-memory --dismiss-supersede-candidate` exits 1 beside any
|
|
375
|
+
`--external-id`, before anything is sent. The Python CLI refuses only a
|
|
376
|
+
non-empty one, and sends an empty `--external-id=` to the server; this
|
|
377
|
+
CLI refuses that too, as `updateMemory` does.
|
|
378
|
+
- `-k=5` (a short option, `=`, a value) reads `5`, where click reads `=5`
|
|
379
|
+
as the value and then refuses it.
|
|
380
|
+
- An option that takes a value does not take a following argument that
|
|
381
|
+
begins with a dash and is not a number (a lone `-` is still a value):
|
|
382
|
+
`--name-contains -auth` is a missing value here, where click takes
|
|
383
|
+
`-auth`. Write `--name-contains=-auth`. `auth login --invite` is the
|
|
384
|
+
exception, since an invite token may begin with a dash.
|
|
220
385
|
|
|
221
386
|
**Sign-in rate limit.** memory-cloud v0.76.0 and later limit device sign-in
|
|
222
387
|
requests per client address. When the server refuses one with HTTP 429,
|
|
@@ -226,6 +391,29 @@ server's reason, when it gives one, on the next line.
|
|
|
226
391
|
`login()` and `authorizeDevice` throw the same message as a
|
|
227
392
|
`KaguraAuthError`.
|
|
228
393
|
|
|
394
|
+
**`auth` subcommands.** Each takes only the options it reads, as in the
|
|
395
|
+
Python CLI: any other is refused with click's `Error: No such option: --x`
|
|
396
|
+
(exit 2), and `--help` lists only its own. `auth status` ends with the
|
|
397
|
+
`kagura-memory` entry Claude Code uses in the current directory and each
|
|
398
|
+
entry it hides, in the Python CLI's words (nothing when no scope defines
|
|
399
|
+
one). `auth list --json` emits Python's fields per profile (`profile`,
|
|
400
|
+
`default`, `user_email`, `workspace_name`, `workspace_id`, `server`,
|
|
401
|
+
`scope`, `expired`, `refreshable`, `expires_at`), never a token, and `[]`
|
|
402
|
+
when there is none, with non-ASCII escaped as `\uXXXX`, as Python's
|
|
403
|
+
`json.dumps` default writes it. `auth list` and `auth status` without
|
|
404
|
+
profiles exit 1. `auth logout`
|
|
405
|
+
revokes the access
|
|
406
|
+
token on the server before it deletes the profile, best effort: the
|
|
407
|
+
profile is deleted even when that fails, with Python's warning (with
|
|
408
|
+
`--all`, silently, as in Python). It notes when `KAGURA_API_KEY` is still
|
|
409
|
+
set. Unlike the Python CLI, it asks before removing anything unless
|
|
410
|
+
`--yes` (`-y`) is given, rather than refusing `--all` without it; a
|
|
411
|
+
logout that names no profile succeeds when nothing is stored, so
|
|
412
|
+
`logout --yes` stays idempotent in setup scripts; and `--all` with
|
|
413
|
+
`--profile` is a usage error (exit 2), where Python ignores `--profile`
|
|
414
|
+
and removes every profile. `auth login` with both `--read-only` and
|
|
415
|
+
`--scope` exits 1, as Python does.
|
|
416
|
+
|
|
229
417
|
#### Signing up with an invite
|
|
230
418
|
|
|
231
419
|
On a deployment that admits new accounts only by beta invite, pass the
|
|
@@ -253,7 +441,9 @@ takes no credentials, allowed 5 seconds):
|
|
|
253
441
|
order. The plain `/join/<token>` link, which the browser opens, then the
|
|
254
442
|
approval URL, and how long the code stays valid.
|
|
255
443
|
- **The server does not take invites** (a `features` object without
|
|
256
|
-
`beta_invites: true
|
|
444
|
+
`beta_invites: true`: invites are turned off, or the server is older than
|
|
445
|
+
memory-cloud 0.70.0, which has no `/join`): a one-line note, then the
|
|
446
|
+
ordinary prompt. A body
|
|
257
447
|
with no `features` object says nothing about invites, so the version
|
|
258
448
|
decides.
|
|
259
449
|
|
|
@@ -460,6 +650,7 @@ per-minute limit. `SecretClient` renders a 429 as `KaguraConnectionError`.
|
|
|
460
650
|
import { KaguraFeatureNotAvailableError, KaguraQuotaError } from "kagura-memory";
|
|
461
651
|
|
|
462
652
|
try {
|
|
653
|
+
// The context is named after the resource unless you pass `name`.
|
|
463
654
|
await client.setupResource({ resourceId: "crm" });
|
|
464
655
|
} catch (e) {
|
|
465
656
|
if (e instanceof KaguraFeatureNotAvailableError) {
|
|
@@ -509,7 +700,7 @@ the counterpart to `recall`'s probabilistic search.
|
|
|
509
700
|
|
|
510
701
|
| Method | What it does |
|
|
511
702
|
|--------|--------------|
|
|
512
|
-
| `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. |
|
|
703
|
+
| `listTags` | Tag vocabulary with counts and recency. `prefix` narrows by spelling; `withTags` is a multi-tag AND drill-down that also excludes those tags from the result — the two compose into server-side faceted browsing with no local index. A drill-down calls the REST tags endpoint, because the MCP tool ignores `withTags` (through server v0.76.0); the result has the same shape. Its values are trimmed and blank ones dropped, and at most 50 of up to 200 characters each are accepted. |
|
|
513
704
|
| `explore` | Graph traversal from a seed memory (`depth` 1–5, `minWeight`). |
|
|
514
705
|
| `listEdges` | Edges touching a memory, incoming and outgoing, deduplicated. |
|
|
515
706
|
| `createEdge` / `updateEdge` / `deleteEdge` | Manual edge curation. `(sourceId, targetId)` is the identity; self-loops are rejected. |
|
|
@@ -521,13 +712,13 @@ the counterpart to `recall`'s probabilistic search.
|
|
|
521
712
|
| Method | What it does |
|
|
522
713
|
|--------|--------------|
|
|
523
714
|
| `listContexts` | The contexts you can see, most recently used first, as a slim name→id directory (`id`, `name`, `is_private`, `is_locked`, `last_used_at`; server v0.73.0+). `nameContains` filters (server v0.73.0+; older servers ignore it and return every context); `includeSummary` (capped at 300 chars), `includeDetails` (full `summary` + `embedding_model`) and `includeStats` (`memory_count`) add fields. `count` is quota usage and `total` the number returned; `can_create` is the quota flag, and `hint` appears when you can see no context. |
|
|
524
|
-
| `createContext` | New context. Throws `KaguraQuotaError` when the workspace limit is reached: the SDK checks `listContexts()` first, so that error carries `quotaType`, `current` and `limit` but no `gate` or plan fields (`requiredPlan` `null` means unknown). Also throws `KaguraFeatureNotAvailableError` for a shared one (`isPrivate: false`) on a plan without shared contexts (server v0.75.0+). `embeddingModel` cannot be changed through the API afterwards (an operator can migrate it server-side, v0.66.0+). |
|
|
715
|
+
| `createContext` | New context. Throws `KaguraQuotaError` when the workspace limit is reached: the SDK checks `listContexts()` first, so that error carries `quotaType`, `current` and `limit` but no `gate` or plan fields (`requiredPlan` `null` means unknown). Also throws `KaguraFeatureNotAvailableError` for a shared one (`isPrivate: false`) on a plan without shared contexts (server v0.75.0+). `embeddingModel` cannot be changed through the API afterwards (an operator can migrate it server-side, v0.66.0+). `resourceId` is deprecated and no longer sent, since the server ignores it: set it with `updateContext`, or use `setupResource`. |
|
|
525
716
|
| `getContextInfo` | Metadata plus, by default, a memory-count breakdown. On server v0.74.0+ also a trimmed `guardrails` block: absent when the MCP URL carries `?guardrails=off`, `null` when the server's read failed. |
|
|
526
717
|
| `updateContext` | Change display name, summary, usage guide, visibility, lock. `isPublic: true` is plan-gated and throws `KaguraFeatureNotAvailableError` on a plan without public contexts. |
|
|
527
718
|
| `deleteContext` | Delete by id. Locked contexts are refused. |
|
|
528
719
|
| `mergeContexts` | Move memories between contexts. Both must share an embedding model and workspace. |
|
|
529
720
|
| `updateSearchConfig` | Hybrid-search weights (must sum to 1.0 ±0.01), reranking (`useRerank`, which a `recall` that omits it follows) and the reranker (`voyage`, `cohere` or `self_hosted`), reinforce re-rank (`reinforceEnabled`, `reinforceMaxBoost`, `reinforceRequireHostArbitration`) and query routing (`routingMode`). Owner/editor only; a context that does not exist, or that the caller cannot see, also throws `KaguraPermissionError`. Returns the whole updated `config`, the only place the reinforce and routing fields come back. |
|
|
530
|
-
| `setupResource` | Context + resource entity + ingestion token in one transaction. The returned token is plaintext and shown once. Plan-gated: throws `KaguraFeatureNotAvailableError` on a plan without resources. |
|
|
721
|
+
| `setupResource` | Context + resource entity + ingestion token in one transaction. The returned token is plaintext and shown once. The context is named `name`, or `resourceId` when that is omitted. `summary` is deprecated and no longer sent, since the server ignores it: set it afterwards with `updateContext`. Plan-gated: throws `KaguraFeatureNotAvailableError` on a plan without resources. |
|
|
531
722
|
|
|
532
723
|
### Agent run-state
|
|
533
724
|
|
|
@@ -734,20 +925,23 @@ Python uses, so a shared backend interoperates.
|
|
|
734
925
|
## Relationship to the Python SDK
|
|
735
926
|
|
|
736
927
|
This package ports the Python SDK's core (client, auth, REST clients,
|
|
737
|
-
models, the zero-knowledge secret client) and, since 0.8.0,
|
|
738
|
-
`kagura
|
|
928
|
+
models, the zero-knowledge secret client) and, since 0.8.0, its `kagura`
|
|
929
|
+
CLI as `kagura-memory`: 17 of the 21 top-level commands, counting the
|
|
930
|
+
`contexts` alias. [Command line](#command-line) lists the commands and
|
|
931
|
+
options not ported yet (`guardrails`, `measure`, `workspace`, and the
|
|
932
|
+
`auth` key commands among them).
|
|
739
933
|
|
|
740
|
-
|
|
934
|
+
One thing is deliberately not ported, because it would cost the
|
|
741
935
|
zero-dependency promise:
|
|
742
936
|
|
|
743
937
|
- **The document-ingestion pipeline** (`FileIngestor`, `kagura ingest`),
|
|
744
938
|
which needs text extraction from PDF, Office, EPUB and audio plus LLM
|
|
745
939
|
providers.
|
|
746
|
-
- **`kagura process`**, which needs the litellm-backed agent.
|
|
747
940
|
|
|
748
|
-
(`KaguraAgent`
|
|
749
|
-
lives in the
|
|
750
|
-
package, so
|
|
941
|
+
(`KaguraAgent` and `kagura process` were removed from the Python SDK in
|
|
942
|
+
v0.37.0 — the actor role lives in the
|
|
943
|
+
[kagura-agent](https://pypi.org/project/kagura-agent/) package, so neither
|
|
944
|
+
will be ported here.)
|
|
751
945
|
|
|
752
946
|
Use the Python SDK for those. Both SDKs share the same credential files
|
|
753
947
|
and server APIs, so they interoperate — with one exception, noted above:
|