kagura-memory 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,7 +20,10 @@ This SDK connects your TypeScript/JavaScript code to [Kagura Memory Cloud](https
20
20
  npm install kagura-memory
21
21
  ```
22
22
 
23
- Requires Node.js >= 18 (native `fetch`). Zero runtime dependencies.
23
+ Requires Node.js >= 18 (native `fetch`). Zero runtime dependencies —
24
+ the one optional peer dependency, for
25
+ [zero-knowledge secrets](#the-crypto-package-is-opt-in), is never installed
26
+ unless you ask for it.
24
27
 
25
28
  ## Quick Start
26
29
 
@@ -291,6 +294,7 @@ Ephemeral, TTL-bounded, and excluded from recall — deliberately not memories.
291
294
  | `getMemoryStats` | Per-memory usage stats, sortable and paged. |
292
295
  | `getEmbeddingStatus` / `listEmbeddingModels` | Embedding backend state and the models available for `createContext`. |
293
296
  | `getToolDefinitions` | Raw MCP `tools/list` output — every tool the server exposes, including any this SDK does not wrap yet. |
297
+ | `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. |
294
298
  | `close` | Drop the MCP session. The next call re-initializes automatically. |
295
299
 
296
300
  Agent Registry and binding methods are covered in
@@ -364,13 +368,112 @@ too. Out-of-range coordinates throw locally rather than round-tripping.
364
368
  > server does not deep-merge. Round-trip `location` when updating details
365
369
  > or the memory silently drops off the spatial axis.
366
370
 
371
+ ## Zero-knowledge secrets
372
+
373
+ `SecretClient` is the fourth REST client, alongside Files, Resource and
374
+ Workspace. The server stores **only opaque ciphertext**: values are
375
+ encrypted to [age](https://age-encryption.org) recipients on your machine
376
+ and decrypted there, so a workspace admin — or the server operator — can
377
+ enumerate secret names and grants but never read a value.
378
+
379
+ ```ts
380
+ import { SecretClient, KeyManager, decrypt } from "kagura-memory";
381
+
382
+ const secrets = SecretClient.fromMcpUrl();
383
+
384
+ // One-time: enroll this machine's age key and register the public half.
385
+ // `store` is yours to supply — see "Key custody is yours to wire" below.
386
+ const keys = new KeyManager({ store: myKeyStore });
387
+ const { recipient, fingerprint } = await keys.enroll();
388
+ await secrets.registerPubkey(recipient, "ci-runner");
389
+ // ...an owner approves it (verify `fingerprint` out of band first).
390
+
391
+ // Store a value, encrypted to every approved recipient.
392
+ const active = (await secrets.listPubkeys()).filter((p) => p.status === "active");
393
+ await secrets.putSecretForRecipients({
394
+ name: "openai/api-key",
395
+ plaintext: "sk-live-...",
396
+ recipients: active,
397
+ });
398
+
399
+ // Read it back.
400
+ const { ciphertext } = await secrets.fetchSecret("openai/api-key");
401
+ const value = await decrypt(ciphertext, await keys.getIdentity());
402
+ ```
403
+
404
+ Also: `listSecrets`, `revokeGrant`, `deleteSecret`, `verifyAudit`,
405
+ `approvePubkey` / `revokePubkey` / `listMyPubkeys`, and the low-level
406
+ `putSecret` when you want to build the grant lists yourself.
407
+
408
+ Names may contain `/` — `cloudflare/api-token` is addressable, and each
409
+ segment is percent-encoded so the separators stay structural. `deleteSecret`
410
+ rejects a name with an empty, `.`, or `..` segment rather than encoding it:
411
+ those are RFC 3986 *unreserved*, so encoding does not neutralize them and the
412
+ URL parser would resolve them away — `cloudflare/../openai` would have
413
+ deleted `openai`.
414
+
415
+ ### The crypto package is opt-in
416
+
417
+ Encryption needs [`age-encryption`](https://www.npmjs.com/package/age-encryption)
418
+ (typage, by age's author — the counterpart of the Rust `pyrage` binding the
419
+ Python SDK uses). It is an **optional peer dependency**, so a plain
420
+ `npm install kagura-memory` still pulls in nothing:
421
+
422
+ ```bash
423
+ npm install age-encryption
424
+ ```
425
+
426
+ Everything except `putSecretForRecipients`, `encrypt`, `decrypt`,
427
+ `generateKeypair` and `recipientFromIdentity` works without it —
428
+ including the whole REST surface, `fingerprint()`, and the armor codec. Call
429
+ one of those without the package and you get a `KaguraCryptoError` naming
430
+ the install command, not a module-resolution stack trace.
431
+
432
+ > **On Node 18.** This SDK supports Node 18 and CI exercises the crypto
433
+ > round-trip there on every push. But `age-encryption`'s `@noble/*`
434
+ > dependencies declare `engines.node: ">= 20.19.0"`, so `npm install
435
+ > age-encryption` on Node 18 prints `EBADENGINE` warnings, and an
436
+ > `engine-strict=true` npmrc will refuse the install outright. It works —
437
+ > WebCrypto is not a global before Node 19, so the SDK installs
438
+ > `node:crypto`'s `webcrypto` itself — but if you want the warnings gone,
439
+ > use Node 20.19+.
440
+
441
+ Recipients are X25519-only. `age1pq1…` (post-quantum) and plugin
442
+ recipients are rejected even though `age-encryption` would accept them,
443
+ because `pyrage` cannot read them and the Python CLI has to be able to
444
+ decrypt whatever this SDK writes.
445
+
446
+ ### Key custody is yours to wire
447
+
448
+ Whoever holds the age private key can decrypt every ciphertext ever shared
449
+ with the matching recipient, so `KeyManager` takes a `KeyStore` and this SDK
450
+ ships **no default backend**:
451
+
452
+ ```ts
453
+ interface KeyStore {
454
+ get(name: string): Promise<string | null>;
455
+ set(name: string, value: string): Promise<void>;
456
+ delete(name: string): Promise<void>;
457
+ }
458
+ ```
459
+
460
+ The Python SDK defaults to the OS keychain via `keyring`. Node has no
461
+ stdlib equivalent, and every option is a native module — so a default here
462
+ would mean either a native runtime dependency or a plaintext file, and
463
+ Python explicitly refuses the latter. Asking you for a store keeps the
464
+ fail-closed property with no insecure fallback to land in by accident.
465
+ Back it with `keytar`/libsecret in an app, or with the ambient secret
466
+ manager in CI. Keys are stored under `identity:{profile}`, the same names
467
+ Python uses, so a shared backend interoperates.
468
+
367
469
  ## Relationship to the Python SDK
368
470
 
369
471
  This package ports the Python SDK's core (client, auth, REST clients,
370
472
  models). Of the `kagura` CLI only the `auth` subcommands are provided
371
473
  (`npx kagura-memory auth …`, above); the memory, context, and ingestion
372
- commands are not ported, nor are the document-ingestion pipeline
373
- (`FileIngestor`) and the zero-knowledge secrets client.
474
+ commands are not ported, nor is the document-ingestion pipeline
475
+ (`FileIngestor`). The zero-knowledge secret **client** is ported (above);
476
+ its `kagura secret` CLI subcommands are not.
374
477
  (`KaguraAgent` was removed from the Python SDK in v0.37.0 — the actor
375
478
  role lives in the [kagura-agent](https://pypi.org/project/kagura-agent/)
376
479
  package, so it will not be ported here.) Use the Python SDK for those;
package/dist/cli.js CHANGED
@@ -32,7 +32,7 @@ var KaguraConnectionError = class extends KaguraError {
32
32
  };
33
33
 
34
34
  // src/version.ts
35
- var SDK_VERSION = "0.6.0";
35
+ var SDK_VERSION = "0.7.0";
36
36
 
37
37
  // src/http.ts
38
38
  function baseUrlFromMcp(mcpUrl) {