@modootoday/pmcp 0.9.2 → 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 +167 -2
- package/dist/attachment-tU5FZrgZ.d.ts +17 -0
- package/dist/chunk-HNAVQG6R.js +1198 -0
- package/dist/chunk-JRSR4JBR.js +88 -0
- package/dist/chunk-MSTKY33C.js +147 -0
- package/dist/{chunk-A5NOHVHN.js → chunk-VRZFM2M5.js} +18 -49
- package/dist/chunk-XEH4ZGGJ.js +336 -0
- package/dist/chunk-XOH2CW6P.js +297 -0
- package/dist/{chunk-D3OZVMHN.js → chunk-ZUFFVIHQ.js} +166 -117
- package/dist/cli.js +507 -74
- package/dist/config-CJ43_oBS.d.ts +49 -0
- package/dist/embed-BBhv3y5x.d.ts +53 -0
- package/dist/encoder-DGRy9skC.d.ts +36 -0
- package/dist/http.d.ts +7 -38
- package/dist/http.js +18 -7
- package/dist/index.d.ts +25 -44
- package/dist/index.js +31 -11
- package/dist/mailbox/index.d.ts +44 -0
- package/dist/mailbox/index.js +387 -0
- package/dist/{server-C9eO6LMI.d.ts → server-CwWcRjqz.d.ts} +122 -2
- package/dist/service-qpCsOXkQ.d.ts +116 -0
- package/dist/stdio.d.ts +10 -4
- package/dist/stdio.js +9 -4
- package/package.json +5 -1
- package/dist/catalog-BU5VLLyd.d.ts +0 -121
- package/dist/chunk-CMZ7OTQD.js +0 -134
- package/dist/chunk-EIHMCKY5.js +0 -41
- package/dist/chunk-KYW3VP3L.js +0 -160
package/README.md
CHANGED
|
@@ -223,18 +223,183 @@ An MCP config (`.mcp.json`) is never served as written: every `env` and `headers
|
|
|
223
223
|
replaced with `<redacted>`, whichever entry reaches the file, and listed digests describe
|
|
224
224
|
the redacted bytes.
|
|
225
225
|
|
|
226
|
-
Pass `semantic: { cacheDir, localOnly: true }` to rank by meaning: the handler encodes
|
|
226
|
+
Pass `semantic: { modelId: "embeddinggemma-2", cacheDir, localOnly: true }` to rank by meaning: the handler encodes
|
|
227
227
|
the catalog at start with `@huggingface/transformers` and the multilingual model, so an
|
|
228
228
|
intent in one language finds a description in another. Requests rank lexically until
|
|
229
229
|
`ready()` settles, and stay lexical when the encoder cannot load (`onError` says why).
|
|
230
230
|
|
|
231
|
+
## Optional local mailbox
|
|
232
|
+
|
|
233
|
+
Mailbox is disabled by default. The six catalog tools stay read-only. A launcher
|
|
234
|
+
that supplies a private actor credential adds five tools: mailbox_send,
|
|
235
|
+
mailbox_inbox, mailbox_read, mailbox_ack, and mailbox_sessions. Read and ack
|
|
236
|
+
record durable receipts; peer text is data and does not authorize execution.
|
|
237
|
+
|
|
238
|
+
```sh
|
|
239
|
+
pmcp mailbox init --config ./pmcp.toml
|
|
240
|
+
pmcp mailbox actor --config ./pmcp.toml --actor reviewer --actor-file /private/reviewer.actor.json
|
|
241
|
+
pmcp serve --config ./pmcp.toml --mailbox-actor-file /private/reviewer.actor.json --mailbox-runtime codex-cli
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
Initialization preserves existing configuration and creates a project UUID.
|
|
245
|
+
State defaults to XDG_STATE_HOME/pmcp/projects/<project UUID>, outside the
|
|
246
|
+
repository. Credential and binding files contain secrets: keep them private,
|
|
247
|
+
outside source control and container images. Commands do not print credentials.
|
|
248
|
+
An optional mailbox-binding-file records the current attachment for a trusted
|
|
249
|
+
launcher. Replacement requires the exact mailbox-replace-session ID; stale
|
|
250
|
+
sessions are fenced. Canonical runtimes are codex-cli, claude-code, gemini-cli,
|
|
251
|
+
grok-cli, and antigravity; the Antigravity executable is agy.
|
|
252
|
+
|
|
253
|
+
The mailbox CLI also supports send, inbox, read, ack, sessions, rotate, export,
|
|
254
|
+
backup, and restore. Actor operations accept a private actor-file or existing
|
|
255
|
+
binding-file and JSON input file. Administration requires explicit operator
|
|
256
|
+
intent. Backups and exports are sensitive. Encrypted recovery bundles are
|
|
257
|
+
available through the mailbox API; key custody belongs to the operator.
|
|
258
|
+
|
|
259
|
+
```ts
|
|
260
|
+
import { MailboxService, MailboxStore } from "@modootoday/pmcp/mailbox";
|
|
261
|
+
|
|
262
|
+
const store = await MailboxStore.open({
|
|
263
|
+
enabled: true,
|
|
264
|
+
projectId,
|
|
265
|
+
databasePath,
|
|
266
|
+
});
|
|
267
|
+
const credential = await store.registerActor("reviewer");
|
|
268
|
+
const binding = await store.attach(credential, "codex-cli");
|
|
269
|
+
const mailbox = new MailboxService(store, binding);
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
Pass mailbox to createSkillServer or registerMailboxTools on an existing server.
|
|
273
|
+
For HTTP, provide mailboxFor(caller) to createSkillHttpHandler; the host resolves
|
|
274
|
+
authenticated callers to authorized bindings. Tool arguments cannot choose a
|
|
275
|
+
sender identity. The host owns attachment heartbeat and cleanup. Child actors
|
|
276
|
+
have bounded authority and may reply only to their parent. Generation changes,
|
|
277
|
+
parent expiry, and credential rotation revoke stale child authority.
|
|
278
|
+
|
|
279
|
+
The public package contains one reusable local domain. Organization identity,
|
|
280
|
+
fleet policy, enterprise audit retention, native process supervision, provider
|
|
281
|
+
credentials, and automatic runtime input delivery belong to a host or dedicated
|
|
282
|
+
harness. Existing arbitrary terminal sessions are not captured. Elastic License
|
|
283
|
+
2.0 and NOTICE continue to apply.
|
|
284
|
+
|
|
285
|
+
## Switching embedding models
|
|
286
|
+
|
|
287
|
+
List the built-in presets with `pmcp models` (or `pmcp models --json`). Select a
|
|
288
|
+
model once in your project's `pmcp.toml`; both indexing and the stdio server use
|
|
289
|
+
the same settings:
|
|
290
|
+
|
|
291
|
+
```toml
|
|
292
|
+
[embedding]
|
|
293
|
+
model = "embeddinggemma-2"
|
|
294
|
+
dimensions = 256
|
|
295
|
+
cache_dir = ".cache/pmcp/models"
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
```sh
|
|
299
|
+
pmcp index
|
|
300
|
+
pmcp serve
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
Indexing explicitly downloads missing model artifacts. Serving reads only local
|
|
304
|
+
artifacts and an existing, complete index. A missing model, stale catalog or
|
|
305
|
+
incompatible vectors keeps ranking lexical and reports the reason on stderr.
|
|
306
|
+
`pmcp index --dry-run` plans work without loading a model or writing files;
|
|
307
|
+
`pmcp index --local-only` refuses downloads. Use `[embedding] enabled = false`
|
|
308
|
+
or `pmcp serve --lexical` to disable semantic ranking.
|
|
309
|
+
|
|
310
|
+
| Preset | Default precision | Supported output dimensions |
|
|
311
|
+
| --------------------- | ----------------- | --------------------------- |
|
|
312
|
+
| `e5-small` | `q8` | 384 |
|
|
313
|
+
| `embeddinggemma-300m` | `q4` | 768, 512, 256, 128 |
|
|
314
|
+
| `embeddinggemma-2` | `q4` | 768, 512, 256, 128 |
|
|
315
|
+
|
|
316
|
+
E5 remains the default. Gemma presets use qualified, pinned revisions, listed by
|
|
317
|
+
`pmcp models --json`; E5 retains its existing `main` revision for compatibility.
|
|
318
|
+
Gemma dimension reduction truncates and re-normalizes the projected embedding;
|
|
319
|
+
it reduces vector storage, not loaded model memory.
|
|
320
|
+
|
|
321
|
+
CLI flags override individual config fields: `--model`, `--dtype`,
|
|
322
|
+
`--dimensions`, `--model-revision`, `--model-path`, `--model-cache`,
|
|
323
|
+
`--query-prefix`, `--passage-prefix` and `--pooling`. Omit precision and dimensions
|
|
324
|
+
in the file when you want each model's defaults. Use `--no-config` for an
|
|
325
|
+
independent CLI selection. Config paths resolve relative to the TOML file;
|
|
326
|
+
CLI model paths resolve relative to the working directory.
|
|
327
|
+
|
|
328
|
+
Query caches also include the encoder identity, so sharing a cache between
|
|
329
|
+
same-width profiles cannot reuse another encoder's query vector. Library hosts
|
|
330
|
+
using openIntentCache must open a cache with the selected output width when
|
|
331
|
+
changing dimensions; pass the encoder's indexKey as its modelId for explicit
|
|
332
|
+
profile-scoped cache metadata.
|
|
333
|
+
|
|
334
|
+
Each model, revision, precision, output width and encoder specification has its
|
|
335
|
+
own vector identity. Switching preserves other models' indexes; switching back
|
|
336
|
+
reuses unchanged vectors. `--force` re-encodes only the selected model. A local
|
|
337
|
+
`model_path` must contain the declared revision's artifacts; change `revision`
|
|
338
|
+
and reindex after replacing them. The directory's location is not its identity.
|
|
339
|
+
|
|
340
|
+
Custom Transformers.js feature-extraction models need no source edits:
|
|
341
|
+
|
|
342
|
+
```toml
|
|
343
|
+
[embedding]
|
|
344
|
+
model = "your-organization/your-onnx-model"
|
|
345
|
+
dtype = "q8"
|
|
346
|
+
revision = "your-pinned-revision"
|
|
347
|
+
|
|
348
|
+
[embedding.encoder]
|
|
349
|
+
query_prefix = "query: "
|
|
350
|
+
passage_prefix = "passage: "
|
|
351
|
+
pooling = "mean"
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
Use the model's documented prefixes and pooling (`mean` or `cls`); unknown models
|
|
355
|
+
default to unprefixed mean pooling. A native `sentence_embedding` export may use
|
|
356
|
+
`projected = true`. Explicit dimension reduction is supported for the listed
|
|
357
|
+
presets. Other architectures require compatible Transformers.js exports.
|
|
358
|
+
|
|
359
|
+
The library API shares the same presets and identity rules:
|
|
360
|
+
|
|
361
|
+
```js
|
|
362
|
+
import { loadEmbedder, prepareSearch } from "@modootoday/pmcp";
|
|
363
|
+
|
|
364
|
+
const encoder = await loadEmbedder("embeddinggemma-2", {
|
|
365
|
+
dimensions: 256,
|
|
366
|
+
modelPath: "/opt/models/embeddinggemma-2",
|
|
367
|
+
localOnly: true,
|
|
368
|
+
});
|
|
369
|
+
const search = await prepareSearch(
|
|
370
|
+
{ roots: ["node_modules"] },
|
|
371
|
+
{
|
|
372
|
+
indexPath: "node_modules/.cache/pmcp/vectors.sqlite",
|
|
373
|
+
modelId: "embeddinggemma-2",
|
|
374
|
+
dimensions: 256,
|
|
375
|
+
embedder: encoder ?? undefined,
|
|
376
|
+
},
|
|
377
|
+
);
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
HTTP hosts use these options under `semantic`; HTTP catalogs are encoded in
|
|
381
|
+
memory at startup rather than reading the CLI's persisted index. Model runtime
|
|
382
|
+
settings are passed to each loader without changing global download or cache
|
|
383
|
+
policy, so hosts can prepare different encoders in one process.
|
|
384
|
+
|
|
231
385
|
## Runtime and licence
|
|
232
386
|
|
|
233
|
-
Node.js 22 or later, or Bun 1.3 or later.
|
|
387
|
+
Node.js 22 or later, or Bun 1.3 or later. Ranking is lexical until an index and
|
|
388
|
+
encoder are ready. Semantic
|
|
234
389
|
ranking (the `index` command, or the HTTP handler's `semantic` option) needs
|
|
235
390
|
`@huggingface/transformers` installed separately; it is not part of the default
|
|
236
391
|
installation. The default encoder is `Xenova/multilingual-e5-small` (MIT, about
|
|
237
392
|
130 MB), so vectors indexed with the earlier English-only default are re-encoded.
|
|
238
393
|
|
|
394
|
+
The optional encoder also supports the ONNX Community EmbeddingGemma 300M and
|
|
395
|
+
EmbeddingGemma 2 exports. It uses their projected sentence embeddings and task
|
|
396
|
+
prefixes. EmbeddingGemma 2 loads its text encoder without vision or audio models.
|
|
397
|
+
EmbeddingGemma was qualified with Transformers.js 4.3.1. Install a version
|
|
398
|
+
supporting the chosen export and keep model
|
|
399
|
+
weights outside the npm package. Regenerate document vectors when changing the
|
|
400
|
+
encoder. Quantization reduces weight storage; application RAM and latency need
|
|
401
|
+
workload measurements. EmbeddingGemma 300M uses the Gemma terms; EmbeddingGemma 2
|
|
402
|
+
is listed under Apache-2.0 in its model card.
|
|
403
|
+
|
|
239
404
|
Elastic License 2.0. See `LICENSE` and `NOTICE` for terms and dependency notices.
|
|
240
405
|
Documentation: <https://pmcp.build>.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { a as MailboxConfig, M as MailboxService } from './service-qpCsOXkQ.js';
|
|
2
|
+
|
|
3
|
+
interface MailboxAttachmentOptions {
|
|
4
|
+
readonly config: MailboxConfig;
|
|
5
|
+
readonly actorFile: string;
|
|
6
|
+
readonly runtime: string;
|
|
7
|
+
readonly bindingFile?: string;
|
|
8
|
+
readonly replaceSessionId?: string;
|
|
9
|
+
readonly nativeSessionId?: string;
|
|
10
|
+
readonly onExpired?: () => void;
|
|
11
|
+
}
|
|
12
|
+
declare function attachMailbox(options: MailboxAttachmentOptions): Promise<{
|
|
13
|
+
service: MailboxService;
|
|
14
|
+
close: () => Promise<void>;
|
|
15
|
+
}>;
|
|
16
|
+
|
|
17
|
+
export { type MailboxAttachmentOptions as M, attachMailbox as a };
|