kagura-memory 0.8.1 → 0.10.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 +258 -31
- package/dist/cli.js +2046 -335
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +580 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +894 -80
- package/dist/index.d.ts +894 -80
- package/dist/index.js +576 -47
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,6 +29,12 @@ the one optional peer dependency, for
|
|
|
29
29
|
[zero-knowledge secrets](#the-crypto-package-is-opt-in), is never installed
|
|
30
30
|
unless you ask for it.
|
|
31
31
|
|
|
32
|
+
Targets memory-cloud **v0.75.0** (`MIN_SERVER_VERSION`).
|
|
33
|
+
`checkServerVersion()` warns, and never throws, on an older server, which
|
|
34
|
+
still answers: it ignores options it predates, leaves out fields it
|
|
35
|
+
predates, and reports a tool it predates as not found. The method notes
|
|
36
|
+
below say which server version a feature needs.
|
|
37
|
+
|
|
32
38
|
## Quick Start
|
|
33
39
|
|
|
34
40
|
```ts
|
|
@@ -102,12 +108,14 @@ npx kagura-memory --help
|
|
|
102
108
|
| `files` | `upload` `list` `delete` `download-url` |
|
|
103
109
|
| `resource` | `tokens {list,create,update,revoke}` `list` `setup` `schema` `stats` `indexer-status` `events` `ingest` `ingest-batch` `import` |
|
|
104
110
|
| `secret` | `keygen` `list` `put` `get` `grant` `revoke` `rotate` `delete` `pubkeys` `approve` `audit-verify` `exec` |
|
|
105
|
-
|
|
|
111
|
+
| `setup` | `claude` `codex` `hermes` `openclaw` |
|
|
112
|
+
| other | `config show` `doctor` |
|
|
106
113
|
|
|
107
114
|
```bash
|
|
108
115
|
npx kagura-memory auth login --profile work --read-only
|
|
109
116
|
npx kagura-memory recall "OAuth setup" -c dev -k 10
|
|
110
117
|
npx kagura-memory remember -s "FastAPI DI" --content "Use Depends()" --tags "python,fastapi"
|
|
118
|
+
npx kagura-memory setup codex --dry-run # key from .kagura.json or KAGURA_API_KEY
|
|
111
119
|
npx kagura-memory doctor
|
|
112
120
|
```
|
|
113
121
|
|
|
@@ -116,6 +124,72 @@ The context id comes from `-c/--context-id`, or from `context_id` in
|
|
|
116
124
|
shared with the Python CLI, so either tool can create a profile the other
|
|
117
125
|
then uses.
|
|
118
126
|
|
|
127
|
+
**Connecting a harness.** Each `setup` subcommand writes `.kagura.json`
|
|
128
|
+
(0600, gitignored) and an MCP entry named `kagura-memory`: the URL plus a
|
|
129
|
+
Bearer header. The key comes from `--api-key`, else the `api_key` in
|
|
130
|
+
`.kagura.json`, else `KAGURA_API_KEY`. `.kagura.json` gets the URL as
|
|
131
|
+
given; the parameters that `--guardrails` and `--tool-profile` set go on
|
|
132
|
+
the entry's URL only. The key is never printed, and outside
|
|
133
|
+
Claude Code it never goes into the harness's config file. `setup codex`
|
|
134
|
+
also leaves a key it found in `KAGURA_API_KEY` out of `.kagura.json`.
|
|
135
|
+
|
|
136
|
+
| Subcommand | How the entry is applied | Where the key lives |
|
|
137
|
+
|---|---|---|
|
|
138
|
+
| `setup claude` | `.mcp.json` (`--scope project`, the default), or `claude mcp add-json --scope user …` | in the entry |
|
|
139
|
+
| `setup codex` | `codex mcp add … --bearer-token-env-var KAGURA_API_KEY` | `KAGURA_API_KEY`, exported in the shell that starts Codex |
|
|
140
|
+
| `setup hermes` | the `config.yaml` block is printed; `hermes mcp add` always prompts | `$HERMES_HOME/.env`, as `MCP_KAGURA_MEMORY_API_KEY` (`MCP_<NAME>_API_KEY` with `--name`) |
|
|
141
|
+
| `setup openclaw` | `openclaw mcp add … --transport streamable-http --no-probe` | `$OPENCLAW_STATE_DIR/.env` (default `~/.openclaw/.env`), as `KAGURA_API_KEY` |
|
|
142
|
+
|
|
143
|
+
This package has no TOML, YAML or JSON5 parser, so it never rewrites those
|
|
144
|
+
files. When the harness's CLI is not on `PATH`, the block is printed on
|
|
145
|
+
stderr with the file it belongs in (`$CODEX_HOME/config.toml`,
|
|
146
|
+
`$HERMES_HOME/config.yaml`, or `$OPENCLAW_CONFIG_PATH`, by default
|
|
147
|
+
`openclaw.json` in the OpenClaw state directory), and stdout stays one
|
|
148
|
+
JSON document. When Hermes's `config.yaml` already has an `mcp_servers:`
|
|
149
|
+
key, only the `kagura-memory` entry is printed, to go under it: a second
|
|
150
|
+
top-level `mcp_servers:` would replace the first, and every server in it.
|
|
151
|
+
On Windows, a CLI installed only as an npm `.cmd` shim counts as not
|
|
152
|
+
found: Node runs one only through a shell, which would re-parse the
|
|
153
|
+
arguments.
|
|
154
|
+
|
|
155
|
+
`--guardrails <context-id|off>` sets the URL's `guardrails` parameter on
|
|
156
|
+
`setup claude` and `setup codex`. Hermes and OpenClaw do not pass the
|
|
157
|
+
server's instructions to the model, so there `off` is refused and a
|
|
158
|
+
context id is dropped, whether it comes from the flag or from the URL.
|
|
159
|
+
`--tool-profile` (claude, codex) sets `profile` and refuses an empty name;
|
|
160
|
+
the server applies a `?tools=` allowlist already on the URL instead, so
|
|
161
|
+
that case gets a warning. Both go at the end of the query, `guardrails`
|
|
162
|
+
first, replacing any value already there, as the Python CLI writes them.
|
|
163
|
+
A `setup claude` run that leaves out a `guardrails` or `profile` value
|
|
164
|
+
the entry it replaces had says so in a note. `--name`, `--force` and
|
|
165
|
+
`--dry-run` (codex, hermes, openclaw) name the entry, replace an existing
|
|
166
|
+
one, and show what would be configured without changing anything. A name
|
|
167
|
+
starts with a letter or digit: it is a bare argument to `codex` and
|
|
168
|
+
`openclaw`, which would read `--help` as an option.
|
|
169
|
+
|
|
170
|
+
Claude Code uses the `kagura-memory` entry from the strongest scope
|
|
171
|
+
(local > project > user). It keys local scope by the git repository root
|
|
172
|
+
(a linked worktree's main working tree), and takes project scope from the
|
|
173
|
+
closest `.mcp.json` that defines the entry, in the directory it runs in or
|
|
174
|
+
any parent; `setup claude` and `doctor` read them the same way.
|
|
175
|
+
`setup claude` writes nothing when a stronger scope already defines one,
|
|
176
|
+
and prints the `claude mcp remove --scope …` command for it, after a `cd`
|
|
177
|
+
into the directory that command must run in when that is not the current
|
|
178
|
+
one. An entry the new one hides, in a weaker scope or in a parent's
|
|
179
|
+
`.mcp.json`, is noted.
|
|
180
|
+
With `--scope user`, an identical user-scope entry is left as it is and a
|
|
181
|
+
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 (if that
|
|
183
|
+
fails too, the error prints the command to add the new one by hand).
|
|
184
|
+
Without `claude` on `PATH`, `--scope user` prints the commands to run and
|
|
185
|
+
writes nothing, unless the user-scope entry is already identical. When
|
|
186
|
+
`claude plugin list --json` shows the Kagura Memory plugin enabled, the
|
|
187
|
+
notes list the plugin settings to enter. `doctor` reports the entry
|
|
188
|
+
Claude Code uses in the current directory, with its scope and file, and
|
|
189
|
+
warns about each entry that one hides. For a `type: "url"` entry, which
|
|
190
|
+
earlier releases wrote and Claude Code skips, it names the fix for the
|
|
191
|
+
entry's scope.
|
|
192
|
+
|
|
119
193
|
**Not ported.** `kagura ingest` needs the text-extraction pipeline (PDF,
|
|
120
194
|
Office, EPUB, audio) and `kagura process` needs the litellm-backed agent;
|
|
121
195
|
neither exists in this package and both would cost the zero-dependency
|
|
@@ -130,10 +204,10 @@ promise. Use the Python CLI for those.
|
|
|
130
204
|
from `KAGURA_AGE_IDENTITY` or `KAGURA_AGE_IDENTITY_FILE` and fails
|
|
131
205
|
closed when neither is set. **A key custodied by the Python CLI is not
|
|
132
206
|
readable here, and vice versa.**
|
|
133
|
-
- `setup
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
would fail at launch. The `--api-key` path works here.
|
|
207
|
+
- `setup … --profile` (the OAuth path) writes an entry that launches
|
|
208
|
+
Python's `kagura-mcp` stdio proxy, which this package does not install;
|
|
209
|
+
every `setup` subcommand reports the fact instead of writing a config
|
|
210
|
+
that would fail at launch. The `--api-key` path works here.
|
|
137
211
|
- `config show` does not reproduce Python's key mask
|
|
138
212
|
(`key[:8] + "..." + key[-4:]`), whose halves overlap below 12 characters
|
|
139
213
|
and print the whole secret twice.
|
|
@@ -144,6 +218,71 @@ An empty profile name would create a nameless profile and an empty scope
|
|
|
144
218
|
would go to the server verbatim. Every other option treats `--flag=` as
|
|
145
219
|
Python does.
|
|
146
220
|
|
|
221
|
+
**Sign-in rate limit.** memory-cloud v0.76.0 and later limit device sign-in
|
|
222
|
+
requests per client address. When the server refuses one with HTTP 429,
|
|
223
|
+
`auth login` says so and how many seconds to wait (from the `Retry-After`
|
|
224
|
+
header, 60 when it is missing or not a number of seconds), with the
|
|
225
|
+
server's reason, when it gives one, on the next line.
|
|
226
|
+
`login()` and `authorizeDevice` throw the same message as a
|
|
227
|
+
`KaguraAuthError`.
|
|
228
|
+
|
|
229
|
+
#### Signing up with an invite
|
|
230
|
+
|
|
231
|
+
On a deployment that admits new accounts only by beta invite, pass the
|
|
232
|
+
invite to `auth login`, either as the bare token or as the
|
|
233
|
+
`https://…/join/<token>` link it arrived in:
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
npx kagura-memory auth login --invite <link-or-token>
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Without it, a new user who starts from `auth login` is refused at sign-up:
|
|
240
|
+
the approval page sends a signed-out visitor to the login page, which does
|
|
241
|
+
not carry an invite. With it, once the device code is issued, the CLI asks
|
|
242
|
+
the server how to present the invite (`GET /api/v1/system/info`, which
|
|
243
|
+
takes no credentials, allowed 5 seconds):
|
|
244
|
+
|
|
245
|
+
- **The server supports the hand-off** (memory-cloud 0.76.0 or later,
|
|
246
|
+
`v0.76.0` and build suffixes included): one link,
|
|
247
|
+
`<frontend>/join/<token>?return_to=%2Fdevice%3Fuser_code%3D<code>`, that
|
|
248
|
+
signs up with the invite and lands on the approval page with the code
|
|
249
|
+
filled in. The browser opens that link. Below it, "If you land on the
|
|
250
|
+
dashboard instead, approve here:" and the approval URL cover a user who
|
|
251
|
+
is already signed in.
|
|
252
|
+
- **An older or unrecognised version, or the check failed**: two steps, in
|
|
253
|
+
order. The plain `/join/<token>` link, which the browser opens, then the
|
|
254
|
+
approval URL, and how long the code stays valid.
|
|
255
|
+
- **The server does not take invites** (a `features` object without
|
|
256
|
+
`beta_invites: true`): a one-line note, then the ordinary prompt. A body
|
|
257
|
+
with no `features` object says nothing about invites, so the version
|
|
258
|
+
decides.
|
|
259
|
+
|
|
260
|
+
`<frontend>` is the device response's approval URL with its final
|
|
261
|
+
`/device` removed, so a frontend under a base path gets its `/join` beside
|
|
262
|
+
its `/device`. When that URL does not end in `/device`, the CLI does not
|
|
263
|
+
guess where `/join` lives: it takes the two steps, with your own link as
|
|
264
|
+
step 1, or tells you to open the invite you were sent when you gave a bare
|
|
265
|
+
token. It takes the two steps too when memory-cloud's `/join` would drop
|
|
266
|
+
the `return_to` (a path starting with `//`, as a frontend URL configured
|
|
267
|
+
with a trailing slash produces, or one holding a backslash or a control
|
|
268
|
+
character), which would otherwise leave the new user on the dashboard.
|
|
269
|
+
|
|
270
|
+
The invite is checked before any request. A malformed one exits 2 with
|
|
271
|
+
`Error: Invalid value for '--invite': <reason>`, the Python CLI's reason,
|
|
272
|
+
which never quotes the value. A pasted link must be written out in full,
|
|
273
|
+
`https://<host>/…/join/<token>` (a browser would repair `https:/host/…`;
|
|
274
|
+
the CLI does not), and must be HTTPS, as `--server` must (plain HTTP only
|
|
275
|
+
on localhost). A `/join` link is never built on a plain-HTTP frontend: the
|
|
276
|
+
token would travel in the clear. A link for a different server than the one
|
|
277
|
+
being logged into aborts before the server is asked about invites and
|
|
278
|
+
before the device code is polled, so no profile is written; the error
|
|
279
|
+
suggests logging in with `--server` instead. The token is never saved, in
|
|
280
|
+
`credentials.json` or anywhere else, and never appears in an error message:
|
|
281
|
+
it is printed only inside a link. Every other `auth` subcommand rejects
|
|
282
|
+
`--invite` with exit 2 rather than ignoring it. `--no-browser` works as it
|
|
283
|
+
does without an invite, and when the browser cannot be opened the CLI says
|
|
284
|
+
which link above to open by hand.
|
|
285
|
+
|
|
147
286
|
#### Logging in from TypeScript
|
|
148
287
|
|
|
149
288
|
`login()` runs the OAuth 2.0 Device Authorization Grant (RFC 8628) and
|
|
@@ -196,6 +335,34 @@ primitives are exported too: `authorizeDevice`, `pollForToken`,
|
|
|
196
335
|
(`loadCredentialsFile`, `updateProfile`, `setDefaultProfile`,
|
|
197
336
|
`deleteProfile`, …).
|
|
198
337
|
|
|
338
|
+
For a new user holding a beta invite, `buildInviteLink` builds the same
|
|
339
|
+
sign-up-and-approve link the CLI's `--invite` prints. It takes the Python
|
|
340
|
+
SDK's `build_invite_link` arguments in the same order: the two approval
|
|
341
|
+
URLs from the device response, then the invite token. `onUserCode` is the
|
|
342
|
+
first point where both are known, so call it there. It is a pure function
|
|
343
|
+
and does not check the server version; that check is the CLI's own.
|
|
344
|
+
|
|
345
|
+
```ts
|
|
346
|
+
import { buildInviteLink, login } from "kagura-memory";
|
|
347
|
+
|
|
348
|
+
const token = "<token>"; // the last path segment of https://…/join/<token>
|
|
349
|
+
|
|
350
|
+
await login({
|
|
351
|
+
onUserCode: ({ verificationUri, verificationUriComplete }) => {
|
|
352
|
+
// null when /join cannot be placed: the approval URL does not end in
|
|
353
|
+
// /device, is plain HTTP off localhost, or is not a return_to that
|
|
354
|
+
// memory-cloud's /join keeps.
|
|
355
|
+
const link = buildInviteLink(verificationUri, verificationUriComplete, token);
|
|
356
|
+
if (link !== null) console.log(`Sign up and approve: ${link}`);
|
|
357
|
+
// A signed-in user, or a server older than memory-cloud 0.76.0, ends
|
|
358
|
+
// up on the dashboard instead; the pending code is approved here.
|
|
359
|
+
console.log(`Or approve at: ${verificationUriComplete}`);
|
|
360
|
+
},
|
|
361
|
+
});
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
A malformed token throws `KaguraAuthError`, whose message never quotes it.
|
|
365
|
+
|
|
199
366
|
#### Refreshing
|
|
200
367
|
|
|
201
368
|
Clients auto-refresh as tokens near expiry, so most code never calls this.
|
|
@@ -246,29 +413,84 @@ try {
|
|
|
246
413
|
```
|
|
247
414
|
|
|
248
415
|
Server-side domain errors (`{"status": "error", ...}`) are translated into
|
|
249
|
-
exceptions
|
|
250
|
-
|
|
251
|
-
|
|
416
|
+
exceptions, so you never need to inspect `result.status`. The class is
|
|
417
|
+
keyed on the error code and the envelope's fields, never on the message:
|
|
418
|
+
|
|
419
|
+
| Class | Raised for | Carries |
|
|
420
|
+
|-------|------------|---------|
|
|
421
|
+
| `KaguraNotFoundError` | missing contexts/memories/reports/agents/bindings (on `updateSearchConfig`, a missing context is a `KaguraPermissionError` instead) | — |
|
|
422
|
+
| `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` |
|
|
423
|
+
| `KaguraQuotaError` | MCP `quota_exceeded` / `CONNECTOR-001`; 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 |
|
|
424
|
+
| `KaguraPartialRollbackError` | `rollbackSleepRun` reversed some actions but not all | `reportId`, `summary` |
|
|
425
|
+
| `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` |
|
|
426
|
+
| `KaguraError` | any other code | — |
|
|
427
|
+
|
|
428
|
+
memory-cloud v0.75.0+ tags every plan and quota refusal with a `gate`
|
|
429
|
+
(`plan`, `quota`, `allowlist` or `deployment`), and the SDK chooses the
|
|
430
|
+
class from it first, falling back to the code for older servers. The
|
|
431
|
+
payload fields are `null` whenever the server did not send them. Against a
|
|
432
|
+
server older than v0.75.0, `current` and `limit` are read from the legacy
|
|
433
|
+
names the refusal carries instead (`used_today` / `limit_today`,
|
|
434
|
+
`owned_count` / `cap`, `active_connectors` / `max_connectors`).
|
|
435
|
+
|
|
436
|
+
Show `requiredPlanDisplay` (`"XL"`) to a user and decide with
|
|
437
|
+
`requiredPlan`, as long as `gate` is set. With a `gate`, both are `null`
|
|
438
|
+
when no plan lifts the refusal, which is what an `allowlist` or
|
|
439
|
+
`deployment` gate means, and a `quota` gate is set on every typed cap,
|
|
440
|
+
including one no tier raises, so an upgrade helps only when `requiredPlan`
|
|
441
|
+
is non-null. With no `gate`, a `null` `requiredPlan` means the plan is
|
|
442
|
+
unknown, not that no plan lifts it. That covers an older server, and
|
|
443
|
+
`createContext`'s own context-limit check, which reads `listContexts()`
|
|
444
|
+
and so fills in only `quotaType`, `current` and `limit`.
|
|
445
|
+
|
|
446
|
+
`retryAfter` is the `Retry-After` header, else the retry hint in the body
|
|
447
|
+
(REST `details.retry_after`, MCP `retry_after_seconds`, which is all the
|
|
448
|
+
resource events-per-hour quota sends), else it is derived from `resetsAt`
|
|
449
|
+
on a time-windowed quota such as `memories_per_day`. It is `null` on a
|
|
450
|
+
fixed cap that waiting will not lift.
|
|
451
|
+
|
|
452
|
+
An HTTP 429 keeps the class it always had on two surfaces.
|
|
453
|
+
`KaguraClient`'s own transport raises `KaguraRateLimitError` for the
|
|
454
|
+
per-minute rate limit and the daily call quota alike; from v0.75.0 the
|
|
455
|
+
quota also sets the `KaguraQuotaError` fields on it (`quotaType` is
|
|
456
|
+
`api_mcp_daily` or `api_rest_daily`), and they stay `null` on a
|
|
457
|
+
per-minute limit. `SecretClient` renders a 429 as `KaguraConnectionError`.
|
|
458
|
+
|
|
459
|
+
```ts
|
|
460
|
+
import { KaguraFeatureNotAvailableError, KaguraQuotaError } from "kagura-memory";
|
|
461
|
+
|
|
462
|
+
try {
|
|
463
|
+
await client.setupResource({ resourceId: "crm" });
|
|
464
|
+
} catch (e) {
|
|
465
|
+
if (e instanceof KaguraFeatureNotAvailableError) {
|
|
466
|
+
// null when no plan lifts it (allowlist / deployment gate) or, with no gate, unknown.
|
|
467
|
+
console.log(e.requiredPlanDisplay ? `upgrade to ${e.requiredPlanDisplay}` : e.message);
|
|
468
|
+
} else if (e instanceof KaguraQuotaError) {
|
|
469
|
+
console.log(`${e.quotaType}: ${e.current}/${e.limit}`);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
```
|
|
252
473
|
|
|
253
474
|
## `KaguraClient` method reference
|
|
254
475
|
|
|
255
476
|
Methods return the parsed server response. Most take a single camelCase
|
|
256
|
-
options object
|
|
257
|
-
`
|
|
258
|
-
(`
|
|
259
|
-
`
|
|
260
|
-
`getToolDefinitions`, `close`) take no arguments.
|
|
261
|
-
snake_case; optional fields are omitted from the request
|
|
477
|
+
options object (optional for `listContexts` and `listMemories`);
|
|
478
|
+
`getAgent`, `deleteAgent`, `listAgentBindings` and `deleteContext` take
|
|
479
|
+
the id directly, and the workspace-wide calls (`listAgents`, `getUsage`,
|
|
480
|
+
`getServerInfo`, `checkServerVersion`, `getEmbeddingStatus`,
|
|
481
|
+
`listEmbeddingModels`, `getToolDefinitions`, `close`) take no arguments.
|
|
482
|
+
The wire stays snake_case; optional fields are omitted from the request
|
|
483
|
+
when `undefined`.
|
|
262
484
|
|
|
263
485
|
### Memories
|
|
264
486
|
|
|
265
487
|
| Method | What it does |
|
|
266
488
|
|--------|--------------|
|
|
267
|
-
| `remember` | Store a memory. `details` accepts arbitrary JSON
|
|
268
|
-
| `recall` | Hybrid semantic + keyword search. Takes `filters` (`type`, `
|
|
489
|
+
| `remember` | Store a memory. `details` accepts arbitrary JSON, including `location` (see below) and the reserved `tool_trigger`, which marks a tool guardrail and needs context editor or above on a user (not agent) credential; `supersedes` declares this the newer version of an existing memory, shadowing the old one from default recall without destroying it; `deliveryMode: "always"` pins it. |
|
|
490
|
+
| `recall` | Hybrid semantic + keyword search. Takes `filters` (`type`, `scope`, `tags` with `tags_match` and `tags_normalize`, `importance` bounds, created/updated date bounds, `source_uri_prefix`, `source_type`, `trust_tier`, and the `near` / `within` geo filters), `searchMode`, `useRerank`, `includeExploreHints`, `includeSuperseded` (read back what `supersedes` shadowed, annotated with `superseded_by`), and `contextIds` for 2–20-context search. `useRerank` is tri-state (memory-cloud v0.69.0+): omit it to follow the context's search config (the first context's, with `contextIds`), `true` requests reranking where the context allows it, `false` skips it for the call. A tag filter that matches nothing can return `tag_suggestions`. When the semantic half is unavailable, the result is keyword-only and carries `degraded: true` and `degraded_reason` (v0.66.0+) — an empty one then means "search impaired", not "nothing stored". |
|
|
269
491
|
| `reference` | Full detail for one memory, under `result.memory`. |
|
|
270
|
-
| `updateMemory` | Update in place by `memoryId`, or upsert by `externalId`. `details` **replaces** the stored object wholesale — round-trip keys you want to keep. |
|
|
271
|
-
| `forget` | Soft-delete
|
|
492
|
+
| `updateMemory` | Update in place by `memoryId`, or upsert by `externalId`. `details` **replaces** the stored object wholesale — round-trip keys you want to keep; dropping `tool_trigger` turns a guardrail off. `dismissSupersedeCandidate: true` rejects the server's `supersede_candidate` suggestion; it needs `memoryId` and throws locally with `externalId`. |
|
|
493
|
+
| `forget` | Soft-delete by `memoryId` or by `query`. The rows are kept, but not restorable through the API, until the deployment's cleanup window passes (`CLEANUP_DELETED_MEMORIES_RETENTION_DAYS`, default 30 days). For a caller who may write to the workspace, a target it may not delete, or one already gone, is skipped silently — including every guardrail for a caller below context editor or on an agent credential — so `deleted_count` can be 0. A workspace viewer may not delete at all and is refused with `KaguraPermissionError` (`requiredRole: "member"`). |
|
|
272
494
|
| `listMemories` | Browse with substring, facet, and time-window filters. Omit `contextId` for the caller's cross-context view. |
|
|
273
495
|
|
|
274
496
|
### Deterministic lanes
|
|
@@ -279,7 +501,8 @@ the counterpart to `recall`'s probabilistic search.
|
|
|
279
501
|
| Method | Axis |
|
|
280
502
|
|--------|------|
|
|
281
503
|
| `loadPinned` | The complete, unranked `deliveryMode: "always"` set. Bounded: check `truncated` / `total_available` rather than assuming you got everything. |
|
|
282
|
-
| `
|
|
504
|
+
| `loadGuardrails` | The set a client-side tool hook matches against (server v0.74.0+): the pinned set plus every memory carrying `details.tool_trigger`, in two separately capped lanes — `cap` bounds only the tool-triggered one, so pins never crowd guardrails out. Check `tool_triggered_truncated` / `pinned_truncated`. |
|
|
505
|
+
| `recallUpcoming` | WHEN — `type: "time"` memories whose window overlaps `from`/`until`, soonest first. Items carry `trigger`, not `details` (server v0.73.0+); `includeDetails: true` returns the full `details` object instead. |
|
|
283
506
|
| `recallNearby` | WHERE — memories near a point, nearest first with `distance_m`. See [the WHERE axis](#the-where-axis--geospatial-memories). |
|
|
284
507
|
|
|
285
508
|
### Tags and the neural graph
|
|
@@ -297,14 +520,14 @@ the counterpart to `recall`'s probabilistic search.
|
|
|
297
520
|
|
|
298
521
|
| Method | What it does |
|
|
299
522
|
|--------|--------------|
|
|
300
|
-
| `listContexts` |
|
|
301
|
-
| `createContext` | New context. Throws `KaguraQuotaError` when the workspace limit is reached. `embeddingModel`
|
|
302
|
-
| `getContextInfo` | Metadata plus, by default, a memory-count breakdown. |
|
|
303
|
-
| `updateContext` | Change display name, summary, usage guide, visibility, lock. |
|
|
523
|
+
| `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+). |
|
|
525
|
+
| `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
|
+
| `updateContext` | Change display name, summary, usage guide, visibility, lock. `isPublic: true` is plan-gated and throws `KaguraFeatureNotAvailableError` on a plan without public contexts. |
|
|
304
527
|
| `deleteContext` | Delete by id. Locked contexts are refused. |
|
|
305
528
|
| `mergeContexts` | Move memories between contexts. Both must share an embedding model and workspace. |
|
|
306
|
-
| `updateSearchConfig` | Hybrid-search weights (must sum to 1.0 ±0.01)
|
|
307
|
-
| `setupResource` | Context + resource entity + ingestion token in one transaction. The returned token is plaintext and shown once. |
|
|
529
|
+
| `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. |
|
|
308
531
|
|
|
309
532
|
### Agent run-state
|
|
310
533
|
|
|
@@ -320,15 +543,15 @@ Ephemeral, TTL-bounded, and excluded from recall — deliberately not memories.
|
|
|
320
543
|
|--------|--------------|
|
|
321
544
|
| `getSleepHistory` | Recent runs, newest first. |
|
|
322
545
|
| `getSleepReport` | One run in detail, including the per-action audit log. |
|
|
323
|
-
| `rollbackSleepRun` | Reverse a completed run. The server commits per step, so a partial rollback is possible
|
|
546
|
+
| `rollbackSleepRun` | Reverse a completed or degraded run. The server commits per step, so a partial rollback is possible: it throws `KaguraPartialRollbackError` instead of returning, and the steps it did reverse stay reversed. There is no retry: the report is now `failed`, and the server will not roll back a `failed` report again. `err.summary` has the same counts a clean run returns, and the actions in `err.summary.errors` were not reversed and need handling some other way. |
|
|
324
547
|
|
|
325
548
|
### Workspace and server
|
|
326
549
|
|
|
327
550
|
| Method | What it does |
|
|
328
551
|
|--------|--------------|
|
|
329
|
-
| `getServerInfo` | Version and
|
|
330
|
-
| `checkServerVersion` | Compare against `MIN_SERVER_VERSION
|
|
331
|
-
| `getUsage` | Workspace quota and usage. |
|
|
552
|
+
| `getServerInfo` | Version, deployment feature flags, and (v0.69.0+) the reranker defaults new contexts start with, under `search_defaults`. |
|
|
553
|
+
| `checkServerVersion` | Compare against `MIN_SERVER_VERSION` (0.75.0). Advisory: logs, never throws. |
|
|
554
|
+
| `getUsage` | Workspace quota and usage: `used` / `limit` for memories, contexts, members and today's MCP calls. |
|
|
332
555
|
| `getMemoryStats` | Per-memory usage stats, sortable and paged. |
|
|
333
556
|
| `getEmbeddingStatus` / `listEmbeddingModels` | Embedding backend state and the models available for `createContext`. |
|
|
334
557
|
| `getToolDefinitions` | Raw MCP `tools/list` output — every tool the server exposes, including any this SDK does not wrap yet. |
|
|
@@ -363,6 +586,10 @@ const bootstrap = await client.getAgentBootstrap({
|
|
|
363
586
|
if (bootstrap.degraded) {
|
|
364
587
|
// some component failed fail-soft; inspect bootstrap.components
|
|
365
588
|
}
|
|
589
|
+
if (bootstrap.components?.recall?.degraded) {
|
|
590
|
+
// the recall ran keyword-only (degraded_reason says why); this also sets
|
|
591
|
+
// the top-level flag above, since server v0.66.0
|
|
592
|
+
}
|
|
366
593
|
```
|
|
367
594
|
|
|
368
595
|
Deployed agents holding only an API key (e.g. an agent-bound member key)
|
|
@@ -376,8 +603,8 @@ const bootstrap = await agents.bootstrap({ agentId: "agent-uuid" });
|
|
|
376
603
|
```
|
|
377
604
|
|
|
378
605
|
Requires memory-cloud **v0.49.0+** — older servers return MCP "tool not
|
|
379
|
-
found" / REST 404 on this surface
|
|
380
|
-
|
|
606
|
+
found" / REST 404 on this surface. The SDK as a whole targets v0.75.0
|
|
607
|
+
(see [Installation](#installation)).
|
|
381
608
|
|
|
382
609
|
## The WHERE axis — geospatial memories
|
|
383
610
|
|