kagura-memory 0.18.1 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +175 -23
- package/dist/cli.js +299 -54
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +293 -52
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +296 -40
- package/dist/index.d.ts +296 -40
- package/dist/index.js +291 -52
- package/dist/index.js.map +1 -1
- package/dist-mcp/mcp.cjs +7 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ This SDK connects your TypeScript/JavaScript code to [Kagura Memory Cloud](https
|
|
|
10
10
|
|--------|----------|----------|
|
|
11
11
|
| **`KaguraClient`** | MCP (JSON-RPC) | Direct memory ops — remember, recall, explore, reference, forget |
|
|
12
12
|
| **`ResourceClient`** | REST API | External data ingestion — push data from Slack, CI/CD, CRM into Kagura |
|
|
13
|
-
| **`FilesClient`** | REST + presigned PUT | File uploads with sha256 integrity binding
|
|
13
|
+
| **`FilesClient`** | REST + presigned PUT | File uploads with sha256 integrity binding |
|
|
14
14
|
| **`WorkspaceClient`** | REST API | Workspace member, invitation, and API key management; operation history (web session) |
|
|
15
15
|
| **`SecretClient`** | REST API | [Zero-knowledge secrets](#zero-knowledge-secrets) — age-encrypted on your machine, opaque to the server |
|
|
16
16
|
| **`AgentsClient`** | REST API | Agent bootstrap for API-key-only callers (no MCP session) |
|
|
@@ -35,7 +35,7 @@ runtime dependencies — the one optional peer dependency, for
|
|
|
35
35
|
unless you ask for it.
|
|
36
36
|
|
|
37
37
|
Targets memory-cloud **v0.75.0** (`MIN_SERVER_VERSION`) and is checked
|
|
38
|
-
against memory-cloud up to **v0.
|
|
38
|
+
against memory-cloud up to **v0.170.0**; the Python SDK 0.44.0, its
|
|
39
39
|
parity target, is checked up to v0.142.0 (v0.143.0 changes nothing a
|
|
40
40
|
client sees), and its own `MIN_SERVER_VERSION` stays at an advisory
|
|
41
41
|
0.17.1. `checkServerVersion()` warns, and never throws, on an older
|
|
@@ -570,14 +570,24 @@ compare decoded, as the server reads them (`guard%72ails` is
|
|
|
570
570
|
|
|
571
571
|
**What `tools/list` shows** (the entry's tool view). Since memory-cloud
|
|
572
572
|
0.93.0 a bare MCP URL lists the `core` profile, the memory loop (21 tools
|
|
573
|
-
on 0.141.0), and `?profile=full` every tool (72).
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
573
|
+
on 0.141.0), and `?profile=full` every tool (72). From memory-cloud
|
|
574
|
+
0.158.0, `?profile=google` and its alias `?profile=microsoft` list `core`
|
|
575
|
+
without `describe_tools` and `guide` (`?add_tools=` cannot bring them back),
|
|
576
|
+
with tool descriptions that name no other tool and instructions that carry
|
|
577
|
+
no guardrail digest. Otherwise `tools/call` is unaffected: a profile is a
|
|
578
|
+
view, not an authorization boundary, so an unlisted tool stays callable and
|
|
579
|
+
every `KaguraClient` method works on any URL — except that on a `google` /
|
|
580
|
+
`microsoft` URL (without a `?tools=` allowlist, which wins over the
|
|
581
|
+
profile) `describe_tools` and `guide` are refused at `tools/call` too, so
|
|
582
|
+
`describeTools()` and `guide()` throw `KaguraError` with `code`
|
|
583
|
+
`unknown_tool` there. That view also trims replies: the server drops the
|
|
584
|
+
sentences of its own `help`, `hint` and `message` text that point at another
|
|
585
|
+
tool, and `recall` makes no learning writes. `--tool-profile NAME` (every harness; memory-cloud
|
|
586
|
+
v0.73.0+) sets `profile`; the server knows `core`, `full`, `google` and
|
|
587
|
+
`microsoft` (case-sensitive; the last two need v0.158.0+) and fails
|
|
588
|
+
`tools/list` for any other name, which leaves the harness with no Kagura
|
|
589
|
+
tools. Setup leaves that check to the server and refuses only a blank name
|
|
590
|
+
or one starting with `-` (exit 2), as Python does.
|
|
581
591
|
`--add-tools NAME[,NAME…]` (every harness; v0.129.0+; may
|
|
582
592
|
repeat) lists more tools on top of the profile: trimmed, de-duplicated,
|
|
583
593
|
at most 100, unknown names ignored by the server. `recall`'s
|
|
@@ -907,6 +917,19 @@ added**, each on purpose or out of reach:
|
|
|
907
917
|
when the server sends no key). It is the counter memory-cloud v0.153.0
|
|
908
918
|
added for its opt-in Sleep related index, printed here as the Python CLI
|
|
909
919
|
prints it from 0.46.0; the rest of the output is 0.44.0's.
|
|
920
|
+
- `files list` and `files upload` print a file's `scan_status`, after
|
|
921
|
+
`context_id`, when the server sends it (memory-cloud v0.160.0+), which the
|
|
922
|
+
Python CLI 0.44.0 drops; a reply without it prints as 0.44.0 prints it,
|
|
923
|
+
with no such key. `files download-url` on a file the malware scan holds
|
|
924
|
+
or blocked prints one line more under the error: how long to wait and to
|
|
925
|
+
run the command again, or that the file cannot be downloaded (the
|
|
926
|
+
wording of the Python SDK's
|
|
927
|
+
[#337](https://github.com/kagura-ai/kagura-memory-python-sdk/issues/337)).
|
|
928
|
+
- `bootstrap` prints the `notices` block (memory-cloud v0.161.0+) right
|
|
929
|
+
after `status` when the server sends it, which the Python CLI 0.44.0
|
|
930
|
+
drops (memory-cloud has then already counted the notices as delivered); a
|
|
931
|
+
reply without it prints as 0.44.0 prints it, with no such key, and an
|
|
932
|
+
unreadable block prints `null`.
|
|
910
933
|
|
|
911
934
|
**`guardrails load` and `guardrails digest`** (memory-cloud v0.74.0+)
|
|
912
935
|
take the context as an optional argument, else `context_id` from
|
|
@@ -925,7 +948,9 @@ block, or with `--target instructions` the MCP server instructions this
|
|
|
925
948
|
credential would receive, where `--profile`, `--tools` and `--add-tools`
|
|
926
949
|
(memory-cloud v0.129.0+; comma-separated, may repeat) repeat an MCP URL's
|
|
927
950
|
`?profile=`, `?tools=` and `?add_tools=`; without them, memory-cloud 0.93.0+
|
|
928
|
-
previews the `core` view a bare URL lists.
|
|
951
|
+
previews the `core` view a bare URL lists. `--profile` takes `full`, `core`,
|
|
952
|
+
`google` or `microsoft`; for the last two (v0.158.0+) the preview is that
|
|
953
|
+
view's base text, with no digest. A context with no tool guardrails prints
|
|
929
954
|
nothing, and says so on stderr. With `--out FILE`, it splices the block
|
|
930
955
|
into FILE between its marker lines: an earlier block is replaced in place,
|
|
931
956
|
an unchanged set rewrites nothing, and an empty set removes an earlier
|
|
@@ -1448,6 +1473,8 @@ keyed on the error code and the envelope's fields, never on the message:
|
|
|
1448
1473
|
| `KaguraCapacityLockedError` | memory-cloud v0.99.0+: a Free workspace over its capacity — MCP `capacity_locked`, REST 403 `CAPACITY-001` (`details.gate` `"capacity"`). Search and saving are refused until it is cleaned up or re-subscribed; listing, deleting, export and `getUsage` keep working. Neither a quota nor a plan gate, so it extends neither class. A caller outside the locked workspace (a public context) gets every figure `null` | `cleanupUrl`, `memoryCount`, `memoryLimit`, `overMemories`, `usedBytes`, `storageLimitBytes`, `overBytes`, `gate` (`"capacity"`) |
|
|
1449
1474
|
| `KaguraAuthError` | HTTP 401; and from memory-cloud v0.79.0 an OAuth token that lacks the scope a call needs (HTTP 403 `insufficient_scope`): `memory:read` for the read-only tools, `recall` and `getAgentBootstrap`, `memory:write` for every other tool, so a `kagura-memory auth login --read-only` profile gets it on every write. The message names the scope and the re-login | `code` `"insufficient_scope"`, `details.required_scope` |
|
|
1450
1475
|
| `KaguraServiceUnavailableError` | any HTTP 503 from `/mcp` or a REST route (the OAuth endpoints keep their own errors): `/mcp`'s `temporarily_unavailable` (the credential could not be verified, v0.82.0+) and its JSON-RPC transport failures (a dependency down or timed out), REST `DB-002` (the database unavailable). A `KaguraConnectionError`, so existing handlers keep catching it | `retryAfter` (the `Retry-After` header, else `data.retry_after_seconds`; `null` on a write whose outcome is unknown), `reason` (REST `details.reason`, else the MCP `cause`, else the code) |
|
|
1476
|
+
| `KaguraFileScanPendingError` | memory-cloud v0.160.0+: `FilesClient.downloadUrl` for a file whose malware scan has not finished — REST 409 `SCAN-001`, with `Retry-After: 30`. The same call succeeds once the scan says clean; the SDK does not retry. A `KaguraConnectionError`, the class this 409 had before, so existing handlers keep catching it; `retryable` is `true` | `retryAfter` (the `Retry-After` header; `null` when absent or not a number of seconds), `fileId`, `scanStatus` (`"pending"`), read from `details` |
|
|
1477
|
+
| `KaguraFileBlockedError` | memory-cloud v0.160.0+: `FilesClient.downloadUrl` for a file the malware scan blocked — REST 409 `SCAN-002`. Waiting does not help (`retryable` is `false`). A `KaguraConnectionError`, as the 409 was before | `fileId`, `scanStatus` (`"infected"`, `"error"` or another value the server does not allow), read from `details` |
|
|
1451
1478
|
| `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` |
|
|
1452
1479
|
| `KaguraPartialSessionRollbackError` | `rollbackSession` (memory-cloud v0.113.0+) failed some items of a real run (`partial_rollback`); every other item was handled and saved, and a call with the same arguments retries the failed ones. A field the SDK cannot read is `null` rather than a second error | `sessionSummary` (with `errors`), `totals`, `rollbackId`, `remaining` |
|
|
1453
1480
|
| `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` |
|
|
@@ -1470,13 +1497,18 @@ The codes the SDK types, by surface:
|
|
|
1470
1497
|
| `timeout`, `service_unavailable` (JSON-RPC `data.error`) | MCP 503 | `KaguraServiceUnavailableError` | v0.82.0+ |
|
|
1471
1498
|
| `DB-002` (`details.reason`: `pool_exhausted`, `connection_refused`, `database_error`, `deadlock`) | REST 503 | `KaguraServiceUnavailableError` | v0.104.0+ (`deadlock` v0.105.0) |
|
|
1472
1499
|
| `payload_too_large` (`limit`, `actual`) | MCP | `KaguraError` | v0.108.0+ |
|
|
1500
|
+
| `SCAN-001` (`Retry-After`; `details.file_id`, `details.scan_status`) | REST 409 | `KaguraFileScanPendingError` | v0.160.0+ |
|
|
1501
|
+
| `SCAN-002` (`details.file_id`, `details.scan_status`) | REST 409 | `KaguraFileBlockedError` | v0.160.0+ |
|
|
1473
1502
|
| `invalid_request`, `invalid_client`, `invalid_scope` (`device/authorize`) | OAuth | `KaguraAuthError`, `error_description` in the message and `details` | v0.78.0+ |
|
|
1474
1503
|
|
|
1475
1504
|
A gate is read before the code, so a v0.75.0+ server's `gate` decides the
|
|
1476
1505
|
class whatever the code. `kagura-memory` commands print, under the error
|
|
1477
1506
|
message, the reset time, the required plan, the capacity lock's cleanup
|
|
1478
|
-
page (unless `help` already names it), a 503's retry window
|
|
1479
|
-
|
|
1507
|
+
page (unless `help` already names it), a 503's retry window, how long to
|
|
1508
|
+
wait for a file the malware scan holds (`The malware scan of file … has
|
|
1509
|
+
not finished: wait 30 s and run the command again.`) or that a blocked one
|
|
1510
|
+
cannot be downloaded, and the server's `help` and correlation id, as the
|
|
1511
|
+
Python CLI does.
|
|
1480
1512
|
|
|
1481
1513
|
`authorizeDevice` turns an RFC 6749 refusal from `device/authorize`
|
|
1482
1514
|
(memory-cloud v0.78.0+) into a `KaguraAuthError` whose `code` is the OAuth
|
|
@@ -1516,7 +1548,10 @@ is non-null. With no `gate`, a `null` `requiredPlan` means the plan is
|
|
|
1516
1548
|
unknown, not that no plan lifts it. That covers an older server, and
|
|
1517
1549
|
`createContext`'s own context-limit check, which reads a one-row
|
|
1518
1550
|
`listContexts({ limit: 1 })` page and so fills in only `quotaType`,
|
|
1519
|
-
`current` and `limit`.
|
|
1551
|
+
`current` and `limit`. When the workspace is full but `count` is below
|
|
1552
|
+
`limit`, `current` is `null`. From memory-cloud v0.170.0 a numeric `current`
|
|
1553
|
+
from the pre-check can be a lower bound because `count` includes only visible
|
|
1554
|
+
contexts.
|
|
1520
1555
|
|
|
1521
1556
|
`retryAfter` is the `Retry-After` header, else the retry hint in the body
|
|
1522
1557
|
(REST `details.retry_after`, MCP `retry_after_seconds`, which is all the
|
|
@@ -1728,7 +1763,9 @@ pinned rows first (`context_summary_omitted`). `guardrails` is absent
|
|
|
1728
1763
|
with `?guardrails=off` and `null` when the server's read failed or the
|
|
1729
1764
|
block cannot be read; `plan_headroom` (v0.142.0+) lists the plan
|
|
1730
1765
|
dimensions at 80 % or more of their limit, on every call — see
|
|
1731
|
-
[Plan headroom](#plan-headroom-memory-cloud-v01420)
|
|
1766
|
+
[Plan headroom](#plan-headroom-memory-cloud-v01420); `notices` (v0.161.0+)
|
|
1767
|
+
carries service notices for the user — see
|
|
1768
|
+
[Service notices](#service-notices-memory-cloud-v01610). The session-start
|
|
1732
1769
|
skill calls
|
|
1733
1770
|
`bootstrap({ contextId, since: "7d", format: "index", maxChars: 5000 })`.
|
|
1734
1771
|
|
|
@@ -1750,11 +1787,29 @@ resend. A batch that wrote nothing throws: `KaguraError` with `code`
|
|
|
1750
1787
|
`batch_failed` (every item failed) or `batch_refused` (an atomic batch
|
|
1751
1788
|
with an invalid item), the rows in `details.results`, or `timeout` (an
|
|
1752
1789
|
atomic batch rolled back, no rows); an atomic batch over the daily quota
|
|
1753
|
-
is `KaguraQuotaError`. Items are checked first: 1-50 objects, no
|
|
1754
|
-
`
|
|
1755
|
-
`context_id`, `remember`'s tag caps. A batch near a plan limit carries
|
|
1790
|
+
is `KaguraQuotaError`. Items are checked first: 1-50 objects, no other
|
|
1791
|
+
context's `context_id`, `remember`'s tag caps. A batch near a plan limit carries
|
|
1756
1792
|
`plan_headroom` (v0.142.0+; see [Plan headroom](#plan-headroom-memory-cloud-v01420)).
|
|
1757
1793
|
|
|
1794
|
+
**`rememberBatch`'s batch-level keys.** `dedupe`, `tags_normalize` and
|
|
1795
|
+
`verbose` belong on the batch. An item that carries one is sent as given, and
|
|
1796
|
+
the server decides (memory-cloud v0.156.0+), comparing JSON type and value
|
|
1797
|
+
after `remember`'s string coercion (`"true"` equals `true`, `1` does not): an
|
|
1798
|
+
item that repeats the batch's value is accepted; one whose value differs is
|
|
1799
|
+
refused (`invalid_argument`, that item only). When the batch does not set the
|
|
1800
|
+
key and every otherwise accepted item that carries it agrees on one valid
|
|
1801
|
+
value, the server applies it to the whole batch and the reply's top-level
|
|
1802
|
+
`lint` gets a `batch_level_argument` entry (`{code, hint, subject}`, the key as
|
|
1803
|
+
`subject`; read fail-open, so a drifted entry never fails a batch whose items
|
|
1804
|
+
are written); when they disagree, or agree on an invalid value, every item
|
|
1805
|
+
that carries the key is refused, those that agree included. With `atomic:
|
|
1806
|
+
true` a refused item refuses the batch (`batch_refused`). Older servers
|
|
1807
|
+
differ: 0.96.0 – 0.155.x refuse every item that carries one of the three
|
|
1808
|
+
(`invalid_argument` per item; a non-atomic batch writes the others, an atomic
|
|
1809
|
+
one is refused whole), and 0.93.0 – 0.95.x ignore the item's key and write the
|
|
1810
|
+
item with the batch's setting, so an item's `dedupe: "check"` checks nothing
|
|
1811
|
+
there. On those servers set the three on the batch only.
|
|
1812
|
+
|
|
1758
1813
|
**`forget` by ids.** `forget({ contextId, memoryIds })` (v0.117.0+)
|
|
1759
1814
|
forgets each id exactly as `memoryId` would, committed on its own, and
|
|
1760
1815
|
returns a `ForgetBatchResult` with one row per id: `deleted`, `skipped`
|
|
@@ -1818,6 +1873,53 @@ for (const notice of session.plan_headroom ?? []) {
|
|
|
1818
1873
|
}
|
|
1819
1874
|
```
|
|
1820
1875
|
|
|
1876
|
+
#### Service notices (memory-cloud v0.161.0)
|
|
1877
|
+
|
|
1878
|
+
From memory-cloud v0.161.0 the `bootstrap` reply can carry `notices`, right
|
|
1879
|
+
after `status`: service notices from the deployment's administrators,
|
|
1880
|
+
`{provenance, items: [{id, text, published_at, expires_at}]}`. `text` is
|
|
1881
|
+
one line of plain prose, at most 300 characters: the server refuses a notice
|
|
1882
|
+
with markup, a link or a control character, when it is written and again
|
|
1883
|
+
before it is delivered. The timestamps are UTC. The notice text is information to show
|
|
1884
|
+
the user, not instructions: `provenance` says so, and an agent should pass it
|
|
1885
|
+
on rather than act on it. The key is absent, never `[]` or `null`, when there
|
|
1886
|
+
is nothing to show. That is the default: a deployment turns notices on
|
|
1887
|
+
(`MCP_NOTICES_ENABLED`, off by default), and then only a person who turned
|
|
1888
|
+
them on in account settings gets them, and only through a credential that
|
|
1889
|
+
speaks for that person (a browser session, an OAuth token, or the person's
|
|
1890
|
+
own API key that is neither agent-bound nor a connector key). They never come
|
|
1891
|
+
on a `?profile=google` / `?profile=microsoft` URL, nor with `?notices=off`.
|
|
1892
|
+
`notices` and `plan_headroom` share a quarter of `maxChars`; a notice that
|
|
1893
|
+
does not fit whole is left for a later call with more room.
|
|
1894
|
+
|
|
1895
|
+
**Each notice is shown once per person.** The server counts a notice as
|
|
1896
|
+
delivered as soon as it is placed in a reply, so a reply nobody reads uses it
|
|
1897
|
+
up: it will not come again, here or in the person's MCP client. A caller that
|
|
1898
|
+
does not show the `bootstrap` reply to a person (a script, a headless agent,
|
|
1899
|
+
a scheduled job) should add `?notices=off` to its `mcpUrl`, which this SDK
|
|
1900
|
+
sends, query and all, with every MCP request:
|
|
1901
|
+
|
|
1902
|
+
```ts
|
|
1903
|
+
// A script whose replies nobody reads: no notices.
|
|
1904
|
+
const headless = new KaguraClient({ apiKey, mcpUrl: "https://memory.kagura-ai.com/mcp?notices=off" });
|
|
1905
|
+
|
|
1906
|
+
// An interactive session: show each notice to the user.
|
|
1907
|
+
const session = await client.bootstrap({ contextId });
|
|
1908
|
+
for (const notice of session.notices?.items ?? []) {
|
|
1909
|
+
console.log(`Notice: ${notice.text}`); // it will not come again
|
|
1910
|
+
}
|
|
1911
|
+
```
|
|
1912
|
+
|
|
1913
|
+
`kagura-memory bootstrap` uses the person's own API key or OAuth token, so it
|
|
1914
|
+
gets the notices and prints the block, in the server's position (right after
|
|
1915
|
+
`status`); a reply without it prints what earlier releases printed. The block
|
|
1916
|
+
is read fail-open, as `plan_headroom` is: a notice without a readable `text`
|
|
1917
|
+
is dropped from `items`; an `id`, `published_at` or `expires_at` that is
|
|
1918
|
+
absent or unreadable is `null` and the notice is kept, since the server has
|
|
1919
|
+
already counted it delivered; and a block that is not an object, or keeps no
|
|
1920
|
+
notice, is `null`, in the returned reply and in the CLI's output. The call
|
|
1921
|
+
never fails over it.
|
|
1922
|
+
|
|
1821
1923
|
### Deterministic lanes
|
|
1822
1924
|
|
|
1823
1925
|
These bypass ranking entirely — same inputs, same rows, every call. They are
|
|
@@ -1847,8 +1949,8 @@ the counterpart to `recall`'s probabilistic search.
|
|
|
1847
1949
|
|
|
1848
1950
|
| Method | What it does |
|
|
1849
1951
|
|--------|--------------|
|
|
1850
|
-
| `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
|
|
1851
|
-
| `createContext` | New context. Throws `KaguraQuotaError` when the workspace limit is reached
|
|
1952
|
+
| `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. From v0.169.0 the connection selects the workspace by scoped API key, MCP URL, then current workspace. From v0.170.0 `count` is the visible count before filtering, and older servers report quota usage. `total` is the page size. `can_create` and the response `limit` describe workspace-wide capacity. `hint` can explain an empty directory or a full workspace with hidden contexts. From v0.82.0 the directory is paged — 100 contexts a page, 20 with `includeDetails` and no `nameContains` — with `has_more` / `next_cursor`: pass `next_cursor` back as `cursor` for the next page, with the same `nameContains`. `limit` sets the page size, 1-200; more than 20 with `includeDetails` and no non-blank `nameContains` throws before any request, as the server would refuse it. Servers before v0.82.0 ignore `limit` and `cursor` and return every context. `nameContains` is sent trimmed, and not at all when blank. There is no `maxChars`: the page's 20,000-character budget is fixed, and a v0.82.0+ server refuses an argument `list_contexts` does not declare. The envelope's `limit` is the plan's context maximum, not the page size. |
|
|
1953
|
+
| `createContext` | New context. Throws `KaguraQuotaError` when the workspace limit is reached. The SDK checks `can_create` from a one-row `listContexts({ limit: 1 })` page first. When `count` is below the workspace limit, the pre-check error reports the limit and sets `current` to `null`. Its `gate` and plan fields are `null`. 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`. |
|
|
1852
1954
|
| `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; its `provenance` (v0.79.0+) labels the items as notes context editors stored, not operator instructions. `search_config` carries `llm_selector_enabled` / `llm_selector_effective` (v0.115.0+). |
|
|
1853
1955
|
| `updateContext` | Change display name, summary, usage guide, visibility, lock. `isPublic: true` is plan-gated and throws `KaguraFeatureNotAvailableError` on a plan without public contexts. |
|
|
1854
1956
|
| `deleteContext` | Delete by id. Locked contexts are refused. |
|
|
@@ -1903,7 +2005,7 @@ v0.140.0 `rollbackSleepRun` refuses a Memory Analysis report (`source:
|
|
|
1903
2005
|
| `getUsage` | Workspace quota and usage: `used` / `limit` for memories, contexts, members and today's MCP calls. `capacity_lock` is `null` unless the workspace is over its Free capacity (memory-cloud v0.99.0+; absent before): then the same figures `KaguraCapacityLockedError` carries, with `cleanup_url` and `help`. A `capacity_lock` the Python SDK's `CapacityLock` model refuses throws `KaguraResponseError`. |
|
|
1904
2006
|
| `getMemoryStats` | Per-memory usage stats, sortable and paged. |
|
|
1905
2007
|
| `getEmbeddingStatus` / `listEmbeddingModels` | Embedding backend state and the models available for `createContext`. A failed row's `embedding_attempted_at` (v0.95.0+) is when its embedding last failed. |
|
|
1906
|
-
| `getToolDefinitions` | Raw MCP `tools/list` output, including tools this SDK does not wrap yet: the view `mcpUrl`'s query selects, not every tool. A bare URL lists the `core` profile on memory-cloud 0.93.0+ (21 tools on 0.141.0), `?profile=full` all of them (72), `?add_tools=a,b` (v0.129.0+) adds names to the profile,
|
|
2008
|
+
| `getToolDefinitions` | Raw MCP `tools/list` output, including tools this SDK does not wrap yet: the view `mcpUrl`'s query selects, not every tool. A bare URL lists the `core` profile on memory-cloud 0.93.0+ (21 tools on 0.141.0), `?profile=full` all of them (72), `?add_tools=a,b` (v0.129.0+) adds names to the profile, `?tools=a,b` is an allowlist, and `?profile=google` / `?profile=microsoft` (v0.158.0+) list `core` without `describe_tools` and `guide`. `tools/call` does not read the view, so every method of this client works on any URL — except on a `google` / `microsoft` URL without `?tools=`, where `describeTools()` and `guide()` throw `KaguraError` `unknown_tool`; only `recall`'s `explore_hints` need `explore` listed. The result is read as the Python SDK's `ToolListResponse`: each definition passes through unread, a result without `tools` lists none, and one that is not an object or whose `tools` is not a list of objects throws `KaguraResponseError` (`operation` `KaguraClient.get_tool_definitions`) rather than reading as an empty list. |
|
|
1907
2009
|
| `callRawTool` | Call any MCP tool by name — the escape hatch for tools with no typed wrapper. Args pass through verbatim (wire form: `context_id`, not `contextId`) and the result is untyped. Prefer a wrapper where one exists; use this so a missing one is a detour, not a dead end. |
|
|
1908
2010
|
| `close` | Drop the MCP session. The next call re-initializes automatically. |
|
|
1909
2011
|
|
|
@@ -2083,7 +2185,7 @@ an API key, an agent-bound key included, with no MCP session:
|
|
|
2083
2185
|
|
|
2084
2186
|
| Method | What it does |
|
|
2085
2187
|
|--------|--------------|
|
|
2086
|
-
| `getGuardrailDigest` | The rendered tool-triggered set for clients without tool hooks (`GET /api/v1/memory/guardrails/digest`). `target: "export"` (the default) returns the `AGENTS.md` block, between its marker lines, or `""` when the context has none; `"instructions"` returns the exact MCP server instructions this credential would receive, and `profile` / `tools` / `addTools` repeat the MCP URL's `?profile=` / `?tools=` / `?add_tools=` (`addTools`, memory-cloud v0.129.0+, is validated and joined as the server reads the names, sent only when it names a tool, and refused before any request for more than 100 names or one starting with `-`). `tool_triggered_version` is the response header, `null` when absent. The text is returned as is. |
|
|
2188
|
+
| `getGuardrailDigest` | The rendered tool-triggered set for clients without tool hooks (`GET /api/v1/memory/guardrails/digest`). `target: "export"` (the default) returns the `AGENTS.md` block, between its marker lines, or `""` when the context has none; `"instructions"` returns the exact MCP server instructions this credential would receive, and `profile` / `tools` / `addTools` repeat the MCP URL's `?profile=` / `?tools=` / `?add_tools=` (`profile` `google` / `microsoft`, v0.158.0+, previews that view's base text with no digest; `addTools`, memory-cloud v0.129.0+, is validated and joined as the server reads the names, sent only when it names a tool, and refused before any request for more than 100 names or one starting with `-`). `tool_triggered_version` is the response header, `null` when absent. The text is returned as is. |
|
|
2087
2189
|
| `loadGuardrails` | The REST twin of `KaguraClient.loadGuardrails` (`POST /api/v1/memory/guardrails`): the same two lanes and truncation flags, without the context block (`context_id` and `context_name` are `null`). The set is read as the Python SDK's `GuardrailSet` model reads it, by the same reader `guardrails load` prints with: the model's fields only, in its order, `null` for an optional one left out (so `GuardrailItem`'s optional fields and `ToolTrigger.match` are typed nullable), and a `tool_trigger` that is no trigger `null`. A set missing a required field, a truncation flag included, or holding one of the wrong type (`pinned.0.type: Input should be a valid string`) raises `KaguraResponseError` (`operation` `MemoryClient.load_guardrails`) rather than read as complete. |
|
|
2088
2190
|
|
|
2089
2191
|
Both refuse a `contextId` that is not a UUID before any request, in the
|
|
@@ -2248,6 +2350,56 @@ const shared = await files.list({ contextId: "workspace-uuid", scope: "workspace
|
|
|
2248
2350
|
const bound = await files.list({ contextId: "workspace-uuid", bindingContextId: "context-uuid" });
|
|
2249
2351
|
```
|
|
2250
2352
|
|
|
2353
|
+
**Malware scanning (memory-cloud v0.160.0+).** A deployment can scan
|
|
2354
|
+
uploads for malware (off by default). Every file object then carries
|
|
2355
|
+
`scan_status`, a plain string: `unscanned` (uploaded while scanning was
|
|
2356
|
+
off; downloadable), `pending`, `clean`, `infected` or `error`; it is
|
|
2357
|
+
absent on an older server. `kagura-memory files list` and `files upload`
|
|
2358
|
+
print it when the server sends it, and print what they printed before when
|
|
2359
|
+
it does not. With scanning off, the default, `scan_status` is the only
|
|
2360
|
+
change, and only an `infected` file (one scanned while scanning was on) is
|
|
2361
|
+
refused. With scanning on, `downloadUrl` answers two 409s, after the access
|
|
2362
|
+
checks (a file the caller cannot read is still `KaguraNotFoundError`):
|
|
2363
|
+
|
|
2364
|
+
- `SCAN-001`, `KaguraFileScanPendingError`: the scan has not finished. Wait
|
|
2365
|
+
`retryAfter` seconds (the server's `Retry-After`, 30) and call again; the
|
|
2366
|
+
SDK does not retry. A file that was downloadable before can answer this
|
|
2367
|
+
again: when its stored object no longer matches the scanned version, the
|
|
2368
|
+
server sets it back to `pending` and scans it again.
|
|
2369
|
+
- `SCAN-002`, `KaguraFileBlockedError`: the scan blocked the file
|
|
2370
|
+
(`scanStatus` `infected`, or `error` when the scanner could not check
|
|
2371
|
+
it); it cannot be downloaded. The server's gate is an allow-list, so any
|
|
2372
|
+
other state but `clean`, `unscanned` and `pending` is refused this way.
|
|
2373
|
+
|
|
2374
|
+
Both extend `KaguraConnectionError`, the class these 409s had before, and
|
|
2375
|
+
keep the server's `code` and `details` (`{file_id, scan_status}`).
|
|
2376
|
+
`kagura-memory files download-url` prints how long to wait, or that the file
|
|
2377
|
+
is blocked, under the error. `upload` can return a file whose `scan_status`
|
|
2378
|
+
is `pending`, a reserve dedup hit included (the duplicate is returned while
|
|
2379
|
+
its scan runs); a duplicate the scan blocked is never returned, and that 409
|
|
2380
|
+
is thrown as before (`KaguraConnectionError`, its message ending "an earlier
|
|
2381
|
+
upload of this file was blocked by the malware scan"). With scanning on,
|
|
2382
|
+
the largest file a reserve accepts is the scanner's stream limit when that
|
|
2383
|
+
limit is below the server's per-file cap (both default to 100 MiB, so by
|
|
2384
|
+
default nothing changes); a larger one gets the server's usual 422
|
|
2385
|
+
`VAL-001`, its message ending "(the largest file the malware scan checks)".
|
|
2386
|
+
|
|
2387
|
+
```ts
|
|
2388
|
+
import { KaguraFileBlockedError, KaguraFileScanPendingError } from "kagura-memory";
|
|
2389
|
+
|
|
2390
|
+
try {
|
|
2391
|
+
const url = await files.downloadUrl(fileId, { contextId: "workspace-uuid" });
|
|
2392
|
+
} catch (e) {
|
|
2393
|
+
if (e instanceof KaguraFileScanPendingError) {
|
|
2394
|
+
console.log(`still scanning; retry in ${e.retryAfter ?? 30} s`);
|
|
2395
|
+
} else if (e instanceof KaguraFileBlockedError) {
|
|
2396
|
+
console.log(`blocked by the malware scan (${e.scanStatus})`);
|
|
2397
|
+
} else {
|
|
2398
|
+
throw e;
|
|
2399
|
+
}
|
|
2400
|
+
}
|
|
2401
|
+
```
|
|
2402
|
+
|
|
2251
2403
|
Every id a client puts in a URL path (a `FilesClient` file id, a
|
|
2252
2404
|
`ResourceClient` resource id, `KaguraClient`'s context id for memory
|
|
2253
2405
|
stats, duplicates and the tags drill-down, a `WorkspaceClient` user id, a
|
|
@@ -2371,7 +2523,7 @@ CLI as `kagura-memory`: 23 of the 24 top-level commands of the Python CLI
|
|
|
2371
2523
|
differ.
|
|
2372
2524
|
|
|
2373
2525
|
The parity target is the Python SDK and CLI **0.44.0**, checked against
|
|
2374
|
-
memory-cloud up to **v0.
|
|
2526
|
+
memory-cloud up to **v0.170.0**.
|
|
2375
2527
|
|
|
2376
2528
|
**SDK ↔ memory-cloud compatibility.**
|
|
2377
2529
|
[`docs/compatibility.md`](docs/compatibility.md) records, for each release
|