@keb-org/consol 0.2.1 → 0.3.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
@@ -1,6 +1,7 @@
1
1
  # @keb-org/consol
2
2
 
3
- TypeScript SDK for the consol memory engine, for three uses:
3
+ The consol memory engine as one package: the MCP server (`npx -y @keb-org/consol`) and a TypeScript SDK.
4
+ The SDK has three uses:
4
5
 
5
6
  1. **Local**: a vault on disk (or S3), with the engine running in your own process as a native addon.
6
7
  2. **Hosted client**: the same `Vault` methods against a backend over HTTP.
@@ -9,6 +10,41 @@ TypeScript SDK for the consol memory engine, for three uses:
9
10
  Node >= 22 or Bun, no dependencies; `import` and `require` share one implementation. The behaviour
10
11
  is the same in every mode.
11
12
 
13
+ ## MCP server
14
+
15
+ `npx -y @keb-org/consol --vault PATH --agent NAME` serves MCP on stdio for one vault that already
16
+ exists (`consol create --vault PATH` makes it; the MCP never creates a vault). The engine runs in
17
+ its process through the same addon as the SDK, so it needs the database too: every `CONSOL_*`
18
+ variable of its process is an engine setting (`CONSOL_DB_URL` is required, `CONSOL_EMBED_*` turn on
19
+ embeddings). Engine logs go to stderr at the level of `RUST_LOG` (default `warn`).
20
+
21
+ | Flag | Variable | |
22
+ |---|---|---|
23
+ | `--vault` | `CONSOL_VAULT` | a directory or `s3://bucket/prefix/name`; with `--remote`, the vault's name on the backend |
24
+ | `--remote` | `CONSOL_REMOTE_URL` | a backend URL (use 3) to forward to, instead of opening a vault; its headers come from `CONSOL_REMOTE_HEADERS` (one `Name: value` per line) |
25
+ | `--agent` | `CONSOL_AGENT` | the default agent of every call; a call's `agent` argument overrides it |
26
+
27
+ In an MCP client, or in Claude Code (the options go before the name):
28
+
29
+ ```bash
30
+ claude mcp add --env CONSOL_DB_URL=postgres://postgres:pw@127.0.0.1:5432/postgres \
31
+ consol -- npx -y @keb-org/consol --vault /abs/path/vault --agent assistant
32
+ ```
33
+
34
+ ```json
35
+ { "mcpServers": { "consol": {
36
+ "command": "npx",
37
+ "args": ["-y", "@keb-org/consol", "--vault", "/abs/path/vault", "--agent", "assistant"],
38
+ "env": { "CONSOL_DB_URL": "postgres://postgres:pw@127.0.0.1:5432/postgres" }
39
+ } } }
40
+ ```
41
+
42
+ A hosted backend needs no database here:
43
+ `npx -y @keb-org/consol --remote https://api.acme.dev/v1/consol --vault demo --agent assistant`, with the
44
+ backend's credentials in `CONSOL_REMOTE_HEADERS`. The
45
+ tool list, the instructions and each result are the engine's, the same ones `consol serve` mounts
46
+ over streamable HTTP at `<path>/mcp`, which is unchanged.
47
+
12
48
  ## The engine addon and database
13
49
 
14
50
  The engine is the native addon `consol.node`, loaded the first time you start a vault or a
@@ -109,19 +145,25 @@ Each method takes one object with the tool's wire argument names, plus optional
109
145
 
110
146
  | Method | Arguments | Returns |
111
147
  |---|---|---|
112
- | `recall` | `{ query, include_history?, limit?, intents?, agent? }` | `RecallResult`: `text` is the progressive disclosure to give a model (cards by tier, intent block, hints); `candidates` are the same cards as data. Cards are leads: read a note before relying on it |
148
+ | `recall` | `{ query, agent? }` | `RecallResult`: `text` is the progressive disclosure to give a model (cards by tier, the blocks the query's symbols ask for, hints); `candidates` are the same cards as data. Cards are leads: read a note before relying on it |
113
149
  | `read` | `{ id, continuation?, agent? }` | `ReadResult`; `text` is the exact file |
114
- | `remember` | `{ id, content?, expected_version?, summary?, entities?, facets?, scope?, team?, valid_from?, valid_to?, reflection?, agent? }` | `RememberResult` |
115
- | `remove` | `{ id, expected_version, reflection?, agent? }` | `RemoveResult`: the note is archived, its body stays readable |
116
- | `reflect` | one mode: `{}` discovery, `{ ids }`, `{ work_ids }` or `{ decisions }`; `limit?`, `agent?` | `ReflectResult`; delivered sources carry their `text` |
150
+ | `remember` | `{ id, content?, meta?, expected_version?, token?, agent? }`; `meta` is `{ summary?, entities?, facets?, scope?, team?, valid_from?, valid_to? }` | `RememberResult` |
151
+ | `remove` | `{ id, expected_version, token?, agent? }` | `RemoveResult`: the note is archived, its body stays readable |
152
+ | `reflect` | `{ focus?, decisions?, agent? }`; call it with no arguments and follow `next` | `ReflectResult`: `next`, the delivered `items` (sources carry their `text`), every unresolved `writes` entry, the `blocked` tokens |
117
153
  | `callTool` | `(name, args)` with raw wire arguments | the raw `Reply`; tool errors come back as `reply.error` |
118
154
  | `close` | | final and idempotent |
119
155
 
120
156
  - `remember` without `expected_version` is create-only. To update, pass `source.content_version`
121
- from your last `read`; a stale one fails with `version_conflict`. Omitted or `null` fields keep
122
- their stored value, `""` or `[]` clears them.
123
- - `remember` and `remove` also take `{ resume: true, reflection, agent? }` to resume a pending
124
- reflection-bound write. `reflection` is `{ work_id, basis_hash, action_key }`.
157
+ from your last `read`; a stale one fails with `version_conflict`. Omitted or `null` `content` keeps
158
+ the body. In `meta` a key left out keeps its stored value, `null`, `""` or `[]` clears it (not
159
+ `scope` or `team`); a key the server does not know is ignored and listed in the receipt's
160
+ `ignored`.
161
+ - `token` on `remember` and `remove` is an item's work token from `reflect`: it binds that one write to the
162
+ work (the server derives the write's key). `{ token, agent? }` alone, with a write token from
163
+ `reflect().writes` or a write receipt, resumes that write.
164
+ - `reflect` holds nothing between calls: a cold `reflect()` lists every unresolved write, the open work and
165
+ the blocked work. Decide an item with `{ token, verdict, reason, refs?, outputs? }`, `verdict` one of the
166
+ item's `verdicts`; the server sizes each batch (about 64 KiB of source Markdown, at most 16 items).
125
167
  - `byte_range` values are UTF-8 byte offsets: `sliceUtf8(text, start, end)` slices a JS string by them.
126
168
  - `vault.serverVersion` is the server version of the last reply. An agent exists from its first
127
169
  `remember`; reading as an agent that wrote nothing finds nothing.
@@ -147,7 +189,7 @@ Markdown inline.
147
189
 
148
190
  The tool list is not on the wire. `consol schema` prints its JSON Schema: `oneOf` holds one
149
191
  envelope per tool, with the `args` schema and the description the model reads. An MCP client can
150
- use `consol mcp` instead.
192
+ use the MCP server of this package instead (above).
151
193
 
152
194
  ## Loading many notes
153
195
 
@@ -181,8 +223,8 @@ try {
181
223
  ```
182
224
 
183
225
  - `ConsolError.is(error)` also works across duplicate copies of the package, where `instanceof` fails.
184
- - `field` names the input at fault, relative to the call's arguments (`limit`,
185
- `decisions[2].temporal`), `tool` the tool, and `result` keeps the raw `Reply` of a failed tool
226
+ - `field` names the input at fault, relative to the call's arguments (`query`,
227
+ `decisions[2].refs[0]`), `tool` the tool, and `result` keeps the raw `Reply` of a failed tool
186
228
  call, including the durable state of a pending write (`error.result.result`).
187
229
  - Tool codes (contract section 4; accept unknown future ones): `invalid_argument`, `forbidden`,
188
230
  `not_found`, `already_exists`, `version_conflict`, `team_not_attached`, `secret_rejected`,
@@ -216,7 +258,7 @@ the default for `db`), so a stray host variable cannot change the agent or the v
216
258
  | `vaultRoot` / `vault` | `Consol.start`: a directory or `s3://` prefix of many vaults, or one vault |
217
259
  | `agent` | default agent of every call; a call's `agent` argument overrides it |
218
260
  | `db` | database URL (`CONSOL_DB_URL`): PostgreSQL with pgvector, or CockroachDB |
219
- | `embedding` | `{ url, model, apiKey?, dims?, queryPrefix?, batchSize?, timeoutMs? }` (`CONSOL_EMBED_*`); without it recall is lexical-only |
261
+ | `embedding` | `{ url, model, apiKey?, dims?, timeoutMs? }` (`CONSOL_EMBED_*`); without it recall is lexical-only |
220
262
  | `jev` | `{ url?, apiKey?, model?, auto? }` (`CONSOL_JEV_*`); experimental advice |
221
263
  | `env` | any other engine setting (a `CONSOL_*` name), applied last |
222
264
  | `addonPath` | the `consol.node` to load, see above |
package/dist/index.d.ts CHANGED
@@ -2,5 +2,5 @@ export { ConsolError, type ConsolErrorCode } from "./errors";
2
2
  export { Consol, httpStatus, type ConsolOptions } from "./consol";
3
3
  export type { CallOptions, Context } from "./transport";
4
4
  export type { EmbeddingOptions, EngineOptions, JevOptions } from "./native";
5
- export { Vault, createVault, openVault, sliceUtf8, type VaultOptions, type HostedOptions, type Intent, type RecallArgs, type ReadArgs, type RememberArgs, type RemoveArgs, type ResumeArgs, type ReflectArgs, type ReflectionContext, type Decision, type InspectedSource, type InspectedSpan, type TemporalAssessment, type PairAssertion, } from "./vault";
6
- export type { Reply, ToolError, Unavailable, Status, ByteRange, Scope, SourceRef, RelationshipKind, Relationship, RecallRetrieval, SourceExcerpt, RecallCard, RecallResult, ReadResult, RememberResult, RemoveResult, ReflectResult, AffectedDoc, EntityAffectedGroup, WriteState, WriteFailureCode, WriteReceipt, WriteResolution, WriteOutcome, ReflectionWork, SourceWork, PairWork, HubWork, PromotionWork, DeliveredSource, CompleteDelivery, FailedDelivery, ReflectDelivery, DecisionReceipt, SourceDisposition, PairDisposition, } from "./types";
5
+ export { Vault, createVault, openVault, sliceUtf8, type VaultOptions, type HostedOptions, type RecallArgs, type ReadArgs, type RememberArgs, type RemoveArgs, type ResumeArgs, type ReflectArgs, type Decision, } from "./vault";
6
+ export type { Reply, ToolError, Unavailable, Status, ByteRange, Scope, SourceRef, RelationshipKind, Relationship, RecallRetrieval, SourceExcerpt, RecallCard, RecallResult, ReadResult, RememberResult, RemoveResult, ReflectResult, AffectedDoc, EntityAffectedGroup, WriteState, WriteFailureCode, WriteReceipt, WriteResolution, WriteOutcome, UnresolvedWrite, ReflectItem, SourceItem, PairItem, HubItem, PromotionItem, DeliveredSource, DecisionReceipt, FocusError, ReflectNext, } from "./types";
package/dist/index.js CHANGED
@@ -193,10 +193,6 @@ function engineSettings(o) {
193
193
  s.CONSOL_EMBED_MODEL = e.model;
194
194
  if (e.dims !== undefined)
195
195
  s.CONSOL_EMBED_DIMS = String(e.dims);
196
- if (e.queryPrefix !== undefined)
197
- s.CONSOL_EMBED_QUERY_PREFIX = e.queryPrefix;
198
- if (e.batchSize !== undefined)
199
- s.CONSOL_EMBED_BATCH = String(e.batchSize);
200
196
  if (e.timeoutMs !== undefined)
201
197
  s.CONSOL_EMBED_TIMEOUT_MS = String(e.timeoutMs);
202
198
  }
@@ -373,7 +369,7 @@ function sliceUtf8(text, start, end) {
373
369
  }
374
370
 
375
371
  // src/vault.ts
376
- var CLIENT_INFO = { name: "consol-js-client", version: "0.2.1" };
372
+ var CLIENT_INFO = { name: "consol-js-client", version: "0.3.0" };
377
373
  var LOCAL = "default";
378
374
  function payload(tool, reply) {
379
375
  const error = replyError(reply, tool);
package/dist/mcp.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};