@modootoday/pmcp 0.9.1 → 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 +177 -8
- 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-VQHNG3KM.js → chunk-VRZFM2M5.js} +53 -75
- package/dist/chunk-XEH4ZGGJ.js +336 -0
- package/dist/chunk-XOH2CW6P.js +297 -0
- package/dist/{chunk-QCOJ3WCM.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-BBZDjzWZ.d.ts → server-CwWcRjqz.d.ts} +135 -15
- 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-7DD2ADL2.js +0 -160
- package/dist/chunk-AJYMOFVX.js +0 -41
- package/dist/chunk-R2QPKEI4.js +0 -134
package/README.md
CHANGED
|
@@ -142,21 +142,25 @@ breaks the specification is reported, and `pmcp validate [<skill-dir>...]` check
|
|
|
142
142
|
directories or every skill the catalog reaches (name rules and length, description and
|
|
143
143
|
compatibility length, field types, name matching the directory, duplicate names).
|
|
144
144
|
|
|
145
|
-
`metadata` keeps strings, string lists and maps of those one level down
|
|
146
|
-
`requires: {mcp,
|
|
147
|
-
nesting is dropped.
|
|
145
|
+
`metadata` keeps strings, string lists and maps of those one level down; `skill_describe`
|
|
146
|
+
reports a map as dotted keys, so `requires: {mcp, gpu-gb}` arrives as `requires.mcp` and
|
|
147
|
+
`requires.gpu-gb`. Deeper nesting is dropped.
|
|
148
|
+
|
|
149
|
+
Output schemas accept additional properties, so a field added later does not break a
|
|
150
|
+
client that cached an earlier tool list. An answer to a call without the newer inputs keeps
|
|
151
|
+
the earlier shape.
|
|
148
152
|
|
|
149
153
|
Since 0.9.0 a skill can list `metadata.verified-runtimes`, a list drawn from `claude-code`,
|
|
150
154
|
`codex-cli`, `gemini-cli`, `grok-cli` and `antigravity`, meaning its effect was verified on
|
|
151
|
-
that runtime. `skill_find` and `skill_catalog`
|
|
152
|
-
|
|
155
|
+
that runtime. `skill_find` and `skill_catalog` accept `runtime` and `verifiedOnly`; when either
|
|
156
|
+
is given, items carry `verifiedRuntimes` (omitted when empty). `runtime` never removes a skill: it marks
|
|
153
157
|
each item `verified` and lists verified ones first (within a package group in
|
|
154
158
|
`skill_catalog`). `verifiedOnly` drops the rest, keeping those verified on `runtime`, or on
|
|
155
159
|
any runtime when none is given. Without `runtime` the answer is ordered exactly as before.
|
|
156
160
|
A server can opt in with `rankByClientRuntime: true`: then, when `runtime` is not passed and
|
|
157
161
|
the MCP client's name is recognised (`claude-code`, `codex`, `gemini`, `grok`,
|
|
158
162
|
`antigravity`), that runtime is used for the ordering only, never for filtering.
|
|
159
|
-
`skill_find` answers with `runtime`, the one the ordering used, or `null`.
|
|
163
|
+
`skill_find` then answers with `runtime`, the one the ordering used, or `null`.
|
|
160
164
|
|
|
161
165
|
`pmcp serve --prompts` also offers one prompt per skill, for hosts that turn prompts into
|
|
162
166
|
commands; the prompt's text is the skill body and its file list, with an optional `task`.
|
|
@@ -219,18 +223,183 @@ An MCP config (`.mcp.json`) is never served as written: every `env` and `headers
|
|
|
219
223
|
replaced with `<redacted>`, whichever entry reaches the file, and listed digests describe
|
|
220
224
|
the redacted bytes.
|
|
221
225
|
|
|
222
|
-
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
|
|
223
227
|
the catalog at start with `@huggingface/transformers` and the multilingual model, so an
|
|
224
228
|
intent in one language finds a description in another. Requests rank lexically until
|
|
225
229
|
`ready()` settles, and stay lexical when the encoder cannot load (`onError` says why).
|
|
226
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
|
+
|
|
227
385
|
## Runtime and licence
|
|
228
386
|
|
|
229
|
-
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
|
|
230
389
|
ranking (the `index` command, or the HTTP handler's `semantic` option) needs
|
|
231
390
|
`@huggingface/transformers` installed separately; it is not part of the default
|
|
232
391
|
installation. The default encoder is `Xenova/multilingual-e5-small` (MIT, about
|
|
233
392
|
130 MB), so vectors indexed with the earlier English-only default are re-encoded.
|
|
234
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
|
+
|
|
235
404
|
Elastic License 2.0. See `LICENSE` and `NOTICE` for terms and dependency notices.
|
|
236
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 };
|