membase-ai 0.2.0 → 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Unibase
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # membase-ai
2
2
 
3
- Membase — long-term memory for AI. The TypeScript client for the [Membase](https://membase.ai) API, hosted or local.
3
+ The Membase SDK for TypeScript: drop-in memory infrastructure for AI agents and apps, hosted in
4
+ your [Membase](https://www.unibase.com/memory) account or local. Docs:
5
+ [Membase](https://unibaseio.gitbook.io/unibase-docs/membase).
4
6
 
5
7
  ```bash
6
8
  npm install membase-ai
@@ -16,26 +18,29 @@ await client.add({ container: "mv-…", content: "Call notes with Acme: they wan
16
18
  const { results } = await client.search({ q: "what does Acme need before the pilot", limit: 5 });
17
19
  console.log(results[0].content);
18
20
 
19
- await client.profile({ q: "working hours" }); // who the user is (needs the profile tick on the key)
21
+ await client.profile({ q: "working hours" }); // who the user is (the key needs Profile access)
20
22
  await client.containers.list();
21
23
  await client.documents.list({ container: "mv-…" });
22
24
  await client.memories.add({ content: "The user prefers dark mode.", static: true });
23
25
  await client.documents.delete("srcitem_…", { confirm: true }); // Full access; confirm means the person agreed
24
26
  ```
25
27
 
28
+ Container ids come from `containers.list()`; document ids from `documents.list()` or the
29
+ `document_id` that `add()` returns.
30
+
26
31
  Every method is one operation of the Membase agent protocol; access level, reach and confirmation
27
32
  rules are enforced server-side. Errors are one class per HTTP status (`PermissionDeniedError`,
28
- `RateLimitError`, …) and carry the API's `code` and `traceId`. 429 and 5xx answers are retried
29
- twice with backoff; the default timeout is 90 s, because the first search after a quiet spell
30
- waits for the user's memory to wake.
33
+ `RateLimitError`, …) and carry the API's `code` and `traceId`. 408, 409, 429 and 5xx answers,
34
+ connection errors and timeouts are retried twice with backoff, honouring `Retry-After`; the
35
+ default timeout is 90 s per attempt, because the first search after a quiet spell waits for the
36
+ user's memory to wake.
31
37
 
32
- Node 18+ (global `fetch`), Deno and Bun. Zero dependencies. Works against a self-hosted Membase
33
- too: `new Membase({ baseUrl: "http://localhost:8080" })`.
38
+ Node 18+ (global `fetch`). Zero dependencies.
34
39
 
35
40
  ## Local memory
36
41
 
37
- Run the engine on your machine with the Python package and point the client at it — same
38
- methods, same answers:
42
+ Run the engine on your machine with the Python package (Python 3.12 or 3.13, with
43
+ `OPENAI_API_KEY` set for the server) and point the client at it — same methods:
39
44
 
40
45
  ```bash
41
46
  pip install 'membase-ai[local]'
@@ -46,4 +51,6 @@ membase --local serve # http://127.0.0.1:8787/v1, store under ~/.memb
46
51
  const local = new Membase({ apiKey: "local", baseUrl: "http://127.0.0.1:8787" });
47
52
  ```
48
53
 
54
+ If the server runs with `MEMBASE_LOCAL_TOKEN`, pass that token as `apiKey`.
55
+
49
56
  `membase-sdk` on npm is the earlier name of this package and keeps working as an alias.
package/dist/client.d.ts CHANGED
@@ -1,26 +1,12 @@
1
- /**
2
- * The Membase client: one developer key, the account's memory.
3
- *
4
- * import { Membase } from "membase-ai";
5
- *
6
- * const client = new Membase(); // MEMBASE_API_KEY, optional MEMBASE_BASE_URL
7
- * await client.add({ content: "Call notes …", container: "mv-…", customId: "call-1" });
8
- * await client.search({ q: "what did we decide about the ledger" });
9
- * await client.profile({ q: "working hours" });
10
- *
11
- * Every method is one operation of the agent protocol (the REST namespace under
12
- * `https://api.app.membase.io/v1`); the access level, reach and confirmation rules are enforced
13
- * server-side, so nothing here can do what the key cannot.
14
- */
1
+ /** The Membase client: one developer key, the account's memory. */
15
2
  export declare const VERSION = "0.2.0";
16
3
  export declare const DEFAULT_BASE_URL = "https://api.app.membase.io";
17
- /** A search is a turn inside the user's memory; the first one after a quiet spell can take up
18
- * to a minute while the memory wakes, so the default is generous. */
4
+ /** The first search after a quiet spell can take up to a minute while the memory wakes. */
19
5
  export declare const DEFAULT_TIMEOUT_MS = 90000;
20
6
  export declare const DEFAULT_MAX_RETRIES = 2;
21
7
  type Fetch = typeof fetch;
22
8
  export interface MembaseOptions {
23
- /** Defaults to `process.env.MEMBASE_API_KEY`. Connect › Developer keys in the Membase app. */
9
+ /** Defaults to `process.env.MEMBASE_API_KEY`. */
24
10
  apiKey?: string;
25
11
  /** Defaults to `process.env.MEMBASE_BASE_URL`, then `https://api.app.membase.io`. */
26
12
  baseUrl?: string;
@@ -114,9 +100,7 @@ export interface SearchParams {
114
100
  q: string;
115
101
  /** One container id; omit to search every container in reach. */
116
102
  container?: string;
117
- /** How many passages in all, not per container (1–50). A search over every container
118
- * splits this budget between them, best-of-each first; left unset it covers every
119
- * container in reach, so none goes unheard. */
103
+ /** How many passages in all, not per container (1–50). */
120
104
  limit?: number;
121
105
  }
122
106
  export declare class Membase {
@@ -136,40 +120,31 @@ export declare class Membase {
136
120
  }) => Promise<DocumentList>;
137
121
  /** One document, with whether its container has learned it yet. */
138
122
  get: (documentId: string) => Promise<Document>;
139
- /** Remove one document everywhere (the file goes to the Files trash). Needs Full access and
140
- * `confirm: true`; without it the answer is `status: confirmation_required` with a `how`
141
- * sentence to relay, not an error. */
123
+ /** Remove one document everywhere; needs Full access and `confirm: true`. */
142
124
  delete: (documentId: string, params?: {
143
125
  confirm?: boolean;
144
126
  }) => Promise<Json | ConfirmationRequired>;
145
127
  };
146
128
  readonly memories: {
147
- /** Save one fact. `static: true` is a standing fact about the user and goes to their profile;
148
- * otherwise a note the container reads. `container` may be omitted when exactly one is in reach. */
129
+ /** Save one fact; `static: true` records a standing fact in the user's profile. */
149
130
  add: (params: {
150
131
  content: string;
151
132
  container?: string;
152
133
  static?: boolean;
153
134
  title?: string;
154
135
  }) => Promise<Json>;
155
- /** Forget one learned fact. Same confirmation rule as `documents.delete`. */
136
+ /** Forget one learned fact; needs `confirm: true`, like `documents.delete`. */
156
137
  forget: (memoryId: string, params?: {
157
138
  container?: string;
158
139
  confirm?: boolean;
159
140
  }) => Promise<Json | ConfirmationRequired>;
160
141
  };
161
142
  constructor(opts?: MembaseOptions);
162
- /** Hand a document (its text, or a public `url` to fetch) to a container. Returns at once with
163
- * `status: queued` and a `document_id`; the container learns it in the background —
164
- * `documents.get(id).learned` turns true when it has. The same `customId` again is a no-op,
165
- * so retries are safe. */
143
+ /** Hand a document (its text, or a public `url` to fetch) to a container. */
166
144
  add(params: AddParams): Promise<AddDocumentResult>;
167
- /** Passages the containers hold on `q`, most relevant first, each naming its container.
168
- * `container` omitted searches every container in reach. Retrieval, not an answer — `ask` is
169
- * the agent's answer. `containers[]` marks any container that could not answer yet. */
145
+ /** Passages the containers hold on `q`, most relevant first, each naming its container. */
170
146
  search(params: SearchParams): Promise<SearchResult>;
171
- /** Who the user is: `static` (standing facts), `dynamic` (recently changed facts) and, with
172
- * `q`, `results` relevant to the topic. Needs a key minted with the profile tick. */
147
+ /** Who the user is: `static` (standing facts), `dynamic` (recently changed facts) and, with `q`, `results` relevant to the topic. */
173
148
  profile(params?: {
174
149
  q?: string;
175
150
  }): Promise<Profile>;
package/dist/client.js CHANGED
@@ -1,22 +1,8 @@
1
- /**
2
- * The Membase client: one developer key, the account's memory.
3
- *
4
- * import { Membase } from "membase-ai";
5
- *
6
- * const client = new Membase(); // MEMBASE_API_KEY, optional MEMBASE_BASE_URL
7
- * await client.add({ content: "Call notes …", container: "mv-…", customId: "call-1" });
8
- * await client.search({ q: "what did we decide about the ledger" });
9
- * await client.profile({ q: "working hours" });
10
- *
11
- * Every method is one operation of the agent protocol (the REST namespace under
12
- * `https://api.app.membase.io/v1`); the access level, reach and confirmation rules are enforced
13
- * server-side, so nothing here can do what the key cannot.
14
- */
1
+ /** The Membase client: one developer key, the account's memory. */
15
2
  import { APIConnectionError, APITimeoutError, errorFor } from "./errors.js";
16
3
  export const VERSION = "0.2.0";
17
4
  export const DEFAULT_BASE_URL = "https://api.app.membase.io";
18
- /** A search is a turn inside the user's memory; the first one after a quiet spell can take up
19
- * to a minute while the memory wakes, so the default is generous. */
5
+ /** The first search after a quiet spell can take up to a minute while the memory wakes. */
20
6
  export const DEFAULT_TIMEOUT_MS = 90_000;
21
7
  export const DEFAULT_MAX_RETRIES = 2;
22
8
  const RETRY_STATUSES = new Set([408, 409, 429]);
@@ -35,20 +21,17 @@ export class Membase {
35
21
  list: (params = {}) => this.request("GET", "/v1/documents", { query: { container: params.container } }),
36
22
  /** One document, with whether its container has learned it yet. */
37
23
  get: (documentId) => this.request("GET", `/v1/documents/${encodeURIComponent(documentId)}`),
38
- /** Remove one document everywhere (the file goes to the Files trash). Needs Full access and
39
- * `confirm: true`; without it the answer is `status: confirmation_required` with a `how`
40
- * sentence to relay, not an error. */
24
+ /** Remove one document everywhere; needs Full access and `confirm: true`. */
41
25
  delete: (documentId, params = {}) => this.request("DELETE", `/v1/documents/${encodeURIComponent(documentId)}`, {
42
26
  query: { confirm: params.confirm ? "true" : "false" },
43
27
  }),
44
28
  };
45
29
  memories = {
46
- /** Save one fact. `static: true` is a standing fact about the user and goes to their profile;
47
- * otherwise a note the container reads. `container` may be omitted when exactly one is in reach. */
30
+ /** Save one fact; `static: true` records a standing fact in the user's profile. */
48
31
  add: (params) => this.request("POST", "/v1/memories", {
49
32
  body: { content: params.content, container: params.container, static: params.static ?? false, title: params.title ?? "" },
50
33
  }),
51
- /** Forget one learned fact. Same confirmation rule as `documents.delete`. */
34
+ /** Forget one learned fact; needs `confirm: true`, like `documents.delete`. */
52
35
  forget: (memoryId, params = {}) => this.request("DELETE", `/v1/memories/${encodeURIComponent(memoryId)}`, {
53
36
  query: { container: params.container, confirm: params.confirm ? "true" : "false" },
54
37
  }),
@@ -65,10 +48,7 @@ export class Membase {
65
48
  this.maxRetries = Math.max(0, opts.maxRetries ?? DEFAULT_MAX_RETRIES);
66
49
  this.fetchImpl = opts.fetch ?? fetch;
67
50
  }
68
- /** Hand a document (its text, or a public `url` to fetch) to a container. Returns at once with
69
- * `status: queued` and a `document_id`; the container learns it in the background —
70
- * `documents.get(id).learned` turns true when it has. The same `customId` again is a no-op,
71
- * so retries are safe. */
51
+ /** Hand a document (its text, or a public `url` to fetch) to a container. */
72
52
  add(params) {
73
53
  return this.request("POST", "/v1/documents", {
74
54
  body: {
@@ -81,14 +61,11 @@ export class Membase {
81
61
  },
82
62
  });
83
63
  }
84
- /** Passages the containers hold on `q`, most relevant first, each naming its container.
85
- * `container` omitted searches every container in reach. Retrieval, not an answer — `ask` is
86
- * the agent's answer. `containers[]` marks any container that could not answer yet. */
64
+ /** Passages the containers hold on `q`, most relevant first, each naming its container. */
87
65
  search(params) {
88
66
  return this.request("POST", "/v1/search", { body: { q: params.q, container: params.container, limit: params.limit } });
89
67
  }
90
- /** Who the user is: `static` (standing facts), `dynamic` (recently changed facts) and, with
91
- * `q`, `results` relevant to the topic. Needs a key minted with the profile tick. */
68
+ /** Who the user is: `static` (standing facts), `dynamic` (recently changed facts) and, with `q`, `results` relevant to the topic. */
92
69
  profile(params = {}) {
93
70
  return this.request("GET", "/v1/profile", { query: { q: params.q } });
94
71
  }
@@ -100,7 +77,6 @@ export class Membase {
100
77
  rules() {
101
78
  return this.request("GET", "/v1/rules");
102
79
  }
103
- // -- plumbing --------------------------------------------------------------------------
104
80
  async request(method, path, opts = {}) {
105
81
  const url = new URL(this.baseUrl + path);
106
82
  for (const [k, v] of Object.entries(opts.query ?? {}))
package/dist/errors.d.ts CHANGED
@@ -1,12 +1,4 @@
1
- /**
2
- * Errors, one class per HTTP status class, all carrying the platform's error envelope.
3
- *
4
- * The API answers every failure as `{"error": {"code", "message", "details", "retryable",
5
- * "trace_id"}}`. The status decides the class (so a caller can `instanceof RateLimitError`),
6
- * `code` says which rule refused (`unauthorized` for a container outside the key's reach,
7
- * `capability_unavailable` when the account's memory cannot run a turn, …), and `traceId` is
8
- * what to quote when reporting a problem.
9
- */
1
+ /** Errors, one class per HTTP status class, all carrying the platform's error envelope. */
10
2
  export interface ErrorEnvelope {
11
3
  error?: {
12
4
  code?: string;
@@ -35,7 +27,7 @@ export declare class APIConnectionError extends MembaseError {
35
27
  /** The request ran past the client's timeout. */
36
28
  export declare class APITimeoutError extends APIConnectionError {
37
29
  }
38
- /** A non-2xx answer. Subclasses per status class below. */
30
+ /** A non-2xx answer. */
39
31
  export declare class APIStatusError extends MembaseError {
40
32
  }
41
33
  /** 400 — a malformed request: a missing `q`, both `content` and `url`, an ambiguous `container`. */
@@ -56,7 +48,7 @@ export declare class ConflictError extends APIStatusError {
56
48
  /** 422 — the account's memory cannot run a turn on this deployment (`capability_unavailable`). */
57
49
  export declare class UnprocessableEntityError extends APIStatusError {
58
50
  }
59
- /** 429 — the account's turn budget is spent for now. Retried automatically; retry later. */
51
+ /** 429 — the account's turn budget is spent for now. */
60
52
  export declare class RateLimitError extends APIStatusError {
61
53
  }
62
54
  /** 5xx. */
package/dist/errors.js CHANGED
@@ -1,12 +1,4 @@
1
- /**
2
- * Errors, one class per HTTP status class, all carrying the platform's error envelope.
3
- *
4
- * The API answers every failure as `{"error": {"code", "message", "details", "retryable",
5
- * "trace_id"}}`. The status decides the class (so a caller can `instanceof RateLimitError`),
6
- * `code` says which rule refused (`unauthorized` for a container outside the key's reach,
7
- * `capability_unavailable` when the account's memory cannot run a turn, …), and `traceId` is
8
- * what to quote when reporting a problem.
9
- */
1
+ /** Errors, one class per HTTP status class, all carrying the platform's error envelope. */
10
2
  export class MembaseError extends Error {
11
3
  status;
12
4
  body;
@@ -32,7 +24,7 @@ export class APIConnectionError extends MembaseError {
32
24
  /** The request ran past the client's timeout. */
33
25
  export class APITimeoutError extends APIConnectionError {
34
26
  }
35
- /** A non-2xx answer. Subclasses per status class below. */
27
+ /** A non-2xx answer. */
36
28
  export class APIStatusError extends MembaseError {
37
29
  }
38
30
  /** 400 — a malformed request: a missing `q`, both `content` and `url`, an ambiguous `container`. */
@@ -53,7 +45,7 @@ export class ConflictError extends APIStatusError {
53
45
  /** 422 — the account's memory cannot run a turn on this deployment (`capability_unavailable`). */
54
46
  export class UnprocessableEntityError extends APIStatusError {
55
47
  }
56
- /** 429 — the account's turn budget is spent for now. Retried automatically; retry later. */
48
+ /** 429 — the account's turn budget is spent for now. */
57
49
  export class RateLimitError extends APIStatusError {
58
50
  }
59
51
  /** 5xx. */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "membase-ai",
3
- "version": "0.2.0",
4
- "description": "Membase — long-term memory for AI. The TypeScript client for hosted Membase, or local memory via `membase serve`.",
3
+ "version": "0.2.1",
4
+ "description": "Membase SDK for TypeScript: drop-in memory infrastructure for AI agents and apps, hosted or local via `membase --local serve`.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "main": "./dist/index.js",
@@ -14,7 +14,8 @@
14
14
  },
15
15
  "files": [
16
16
  "dist",
17
- "README.md"
17
+ "README.md",
18
+ "LICENSE"
18
19
  ],
19
20
  "sideEffects": false,
20
21
  "engines": {
@@ -28,11 +29,13 @@
28
29
  "keywords": [
29
30
  "membase",
30
31
  "memory",
32
+ "agent-memory",
33
+ "long-term-memory",
34
+ "llm",
31
35
  "ai",
32
- "agents",
33
- "mcp"
36
+ "agents"
34
37
  ],
35
- "homepage": "https://membase.ai",
38
+ "homepage": "https://www.unibase.com/memory",
36
39
  "devDependencies": {
37
40
  "@types/node": "^20.19.43",
38
41
  "typescript": "^5.6.2",