@modootoday/pmcp 0.9.2 → 0.11.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
@@ -114,6 +114,147 @@ overwritten. `doctor` calls no model: it reads `claude mcp list`,
114
114
  `codex mcp list`, `gemini skills list`, `gemini mcp list` and
115
115
  `grok inspect --json`, and skips a tool that is not installed.
116
116
 
117
+ ## Unified project MCP configuration
118
+
119
+ Antigravity receives a native project plugin at .agents/plugins/pmcp-mcp with
120
+ plugin.json and mcp_config.json. Projection removes only lock-owned entries
121
+ from the earlier .agents/mcp_config.json artifact and backs up both layouts.
122
+ Antigravity's global mcp list does not enumerate project plugin servers;
123
+ validate the generated plugin with agy plugin validate.
124
+ Its HTTP entries use serverUrl, accepted by the installed plugin validator.
125
+
126
+ Declare each MCP server once in pmcp.toml. The projector writes the native
127
+ project files for all selected runtimes. A server can narrow its targets:
128
+
129
+ ```toml
130
+ [mcp.docs]
131
+ url = "https://example.com/mcp"
132
+
133
+ [mcp.private-api]
134
+ url = "https://example.com/private-mcp"
135
+ targets = ["claude", "codex", "gemini", "grok"]
136
+ bearer_token_env_var = "PRIVATE_MCP_TOKEN"
137
+ header_env = { "X-Workspace" = "PRIVATE_MCP_WORKSPACE" }
138
+
139
+ [mcp.local-service]
140
+ command = "my-mcp-server"
141
+ env_vars = ["MY_SERVICE_KEY"]
142
+ cwd = "${PROJECT_ROOT}"
143
+
144
+ [mcp.local-service.native.codex]
145
+ startup_timeout_sec = 30
146
+
147
+ [mcp.local-service.native.gemini]
148
+ timeout = 120000
149
+ ```
150
+
151
+ url means Streamable HTTP; Gemini receives httpUrl. Legacy SSE is not imported
152
+ as HTTP. headers contains literal nonsecret headers, header_env maps header
153
+ names to environment variable names, and bearer_token_env_var references a
154
+ token without writing its value. Each runtime retains its own OAuth session.
155
+ Antigravity HTTP header projection is not qualified and is rejected; explicitly
156
+ limit those servers to supported targets. tools maps to Gemini includeTools and
157
+ Codex enabled_tools; it is not a cross-runtime security boundary. Native timeout
158
+ options retain each runtime's documented names and units. Unknown fields fail.
159
+
160
+ Import explicitly selected native configurations. Preview is the default:
161
+
162
+ ```sh
163
+ pmcp project import-mcp --source claude:/path/to/native.json
164
+ pmcp project import-mcp --source codex:/path/to/config.toml --name docs --write
165
+ pmcp project
166
+ pmcp project --check
167
+ ```
168
+
169
+ Repeat source and name to select multiple inputs. Conflicting aliases, missing
170
+ requested names, unsupported authentication fields and credential-bearing URLs
171
+ block import. Source contents and credential values are not printed. Sources
172
+ are never rewritten. Review plugin-provided servers separately to avoid
173
+ duplicating a server the runtime already loads.
174
+
175
+ Literal stdio environment values remain in their source file. The importer
176
+ stores an env_from reference containing file and an RFC 6901 JSON pointer:
177
+
178
+ ```toml
179
+ [mcp.local-service.env_from.MY_SERVICE_KEY]
180
+ file = "~/.config/my-client/settings.json"
181
+ pointer = "/mcpServers/local-service/env/MY_SERVICE_KEY"
182
+ ```
183
+
184
+ The generated entry invokes pmcp project exec-mcp for that declared server.
185
+ It reads only the referenced values and passes them to the child process, using
186
+ inherited stdio. JSON and TOML sources are supported. The source must remain
187
+ available; rotating its value takes effect on the next server launch. A project
188
+ installed CLI is referenced relative to the project; otherwise pmcp must be on
189
+ PATH. Configurations using env_from require this release on every runtime host.
190
+
191
+ Writes retain private backups in ~/.cache/pmcp/project-backups, outside the
192
+ project. Receipts record file hashes and absent paths. A conflicting unmanaged
193
+ native alias is refused before projection writes. The managed TOML block and
194
+ JSON keys preserve unrelated settings. Inspect the reported backup before
195
+ restoring any file that another process may have edited.
196
+
197
+ Configuration references: [Codex](https://developers.openai.com/codex/config-reference/),
198
+ [Claude Code](https://code.claude.com/docs/en/mcp),
199
+ [Gemini CLI](https://geminicli.com/docs/tools/mcp-server/),
200
+ and [Grok Build](https://docs.x.ai/build/features/mcp-servers).
201
+
202
+ ## Operator shell guards
203
+
204
+ Declare a project-owned guard explicitly to project it into Codex, Gemini or
205
+ Antigravity's native hooks. Without a declaration, pmcp generates no hooks.
206
+
207
+ ```toml
208
+ [[hooks.shell]]
209
+ name = "shell-command-policy"
210
+ command = ["node", ".agents/guards/shell-command-policy.mjs"]
211
+ targets = ["codex", "gemini", "antigravity"]
212
+ timeout_ms = 15000
213
+ ```
214
+
215
+ The guard script must exist under .agents/guards/ and cannot resolve outside
216
+ that directory. It receives one JSON object on stdin containing runtime,
217
+ event=before_shell, command and cwd. It returns a JSON object with
218
+ decision=allow or decision=deny and an optional reason. Malformed responses,
219
+ nonzero exits and timeouts deny the shell call. The guard receives PATH and
220
+ LANG rather than the native CLI's credential environment. Non-shell tools are
221
+ outside this contract.
222
+
223
+ Run pmcp project to write lock-owned adapter and policy artifacts under
224
+ .agents/pmcp-hooks/, plus the native entries in .codex/hooks.json,
225
+ .gemini/settings.json and .agents/hooks.json. Peer entries are retained.
226
+ Edited owned hook entries refuse projection for review. Removing a declaration
227
+ removes its generated entries and artifacts while preserving peer settings.
228
+ Writes retain private backups; pmcp project --check only reports drift.
229
+
230
+ Guard, policy and adapter fingerprints bind the generated command. Changing
231
+ guard code requires reprojection and native Codex hook review. Generated files
232
+ contain no trust bypass. Grok can load Claude project hooks, so this first scope
233
+ does not generate a second Grok guard. Hooks do not force pmcp catalog use,
234
+ inject reminders or replace the runtime's execution sandbox.
235
+
236
+ ## Native memory metadata
237
+
238
+ ```sh
239
+ pmcp doctor --memory --json
240
+ pmcp doctor --memory --tool codex
241
+ ```
242
+
243
+ This explicit operation reports selected runtimes' native memory configuration
244
+ and path existence. It reads no memory body, index or transcript, writes no
245
+ configuration, connects to no MCP server and makes no provider request.
246
+ Ordinary doctor output is unchanged.
247
+
248
+ The report distinguishes enabled, disabled, unknown and unsupported. Path
249
+ existence does not establish activation. Where native metadata cannot identify
250
+ a project-specific location, pathScope=base reports only the storage parent;
251
+ the project identifier is not guessed. Supported native home overrides are
252
+ respected. Codex uses its native features listing. Claude and Grok report
253
+ explicit user settings, with active session overrides and unverified project
254
+ trust left unknown. Gemini context filenames and the global GEMINI.md file
255
+ are separate from unexposed memory-tool activation. Antigravity trajectories
256
+ are not reported as a memory store. pmcp does not synchronize or inject memory.
257
+
117
258
  ## Package skills
118
259
 
119
260
  Skills are discovered by filename, including `skills/`, `.agents/skills/`,
@@ -223,18 +364,183 @@ An MCP config (`.mcp.json`) is never served as written: every `env` and `headers
223
364
  replaced with `<redacted>`, whichever entry reaches the file, and listed digests describe
224
365
  the redacted bytes.
225
366
 
226
- Pass `semantic: { cacheDir, localOnly: true }` to rank by meaning: the handler encodes
367
+ Pass `semantic: { modelId: "embeddinggemma-2", cacheDir, localOnly: true }` to rank by meaning: the handler encodes
227
368
  the catalog at start with `@huggingface/transformers` and the multilingual model, so an
228
369
  intent in one language finds a description in another. Requests rank lexically until
229
370
  `ready()` settles, and stay lexical when the encoder cannot load (`onError` says why).
230
371
 
372
+ ## Optional local mailbox
373
+
374
+ Mailbox is disabled by default. The six catalog tools stay read-only. A launcher
375
+ that supplies a private actor credential adds five tools: mailbox_send,
376
+ mailbox_inbox, mailbox_read, mailbox_ack, and mailbox_sessions. Read and ack
377
+ record durable receipts; peer text is data and does not authorize execution.
378
+
379
+ ```sh
380
+ pmcp mailbox init --config ./pmcp.toml
381
+ pmcp mailbox actor --config ./pmcp.toml --actor reviewer --actor-file /private/reviewer.actor.json
382
+ pmcp serve --config ./pmcp.toml --mailbox-actor-file /private/reviewer.actor.json --mailbox-runtime codex-cli
383
+ ```
384
+
385
+ Initialization preserves existing configuration and creates a project UUID.
386
+ State defaults to XDG_STATE_HOME/pmcp/projects/<project UUID>, outside the
387
+ repository. Credential and binding files contain secrets: keep them private,
388
+ outside source control and container images. Commands do not print credentials.
389
+ An optional mailbox-binding-file records the current attachment for a trusted
390
+ launcher. Replacement requires the exact mailbox-replace-session ID; stale
391
+ sessions are fenced. Canonical runtimes are codex-cli, claude-code, gemini-cli,
392
+ grok-cli, and antigravity; the Antigravity executable is agy.
393
+
394
+ The mailbox CLI also supports send, inbox, read, ack, sessions, rotate, export,
395
+ backup, and restore. Actor operations accept a private actor-file or existing
396
+ binding-file and JSON input file. Administration requires explicit operator
397
+ intent. Backups and exports are sensitive. Encrypted recovery bundles are
398
+ available through the mailbox API; key custody belongs to the operator.
399
+
400
+ ```ts
401
+ import { MailboxService, MailboxStore } from "@modootoday/pmcp/mailbox";
402
+
403
+ const store = await MailboxStore.open({
404
+ enabled: true,
405
+ projectId,
406
+ databasePath,
407
+ });
408
+ const credential = await store.registerActor("reviewer");
409
+ const binding = await store.attach(credential, "codex-cli");
410
+ const mailbox = new MailboxService(store, binding);
411
+ ```
412
+
413
+ Pass mailbox to createSkillServer or registerMailboxTools on an existing server.
414
+ For HTTP, provide mailboxFor(caller) to createSkillHttpHandler; the host resolves
415
+ authenticated callers to authorized bindings. Tool arguments cannot choose a
416
+ sender identity. The host owns attachment heartbeat and cleanup. Child actors
417
+ have bounded authority and may reply only to their parent. Generation changes,
418
+ parent expiry, and credential rotation revoke stale child authority.
419
+
420
+ The public package contains one reusable local domain. Organization identity,
421
+ fleet policy, enterprise audit retention, native process supervision, provider
422
+ credentials, and automatic runtime input delivery belong to a host or dedicated
423
+ harness. Existing arbitrary terminal sessions are not captured. Elastic License
424
+ 2.0 and NOTICE continue to apply.
425
+
426
+ ## Switching embedding models
427
+
428
+ List the built-in presets with `pmcp models` (or `pmcp models --json`). Select a
429
+ model once in your project's `pmcp.toml`; both indexing and the stdio server use
430
+ the same settings:
431
+
432
+ ```toml
433
+ [embedding]
434
+ model = "embeddinggemma-2"
435
+ dimensions = 256
436
+ cache_dir = ".cache/pmcp/models"
437
+ ```
438
+
439
+ ```sh
440
+ pmcp index
441
+ pmcp serve
442
+ ```
443
+
444
+ Indexing explicitly downloads missing model artifacts. Serving reads only local
445
+ artifacts and an existing, complete index. A missing model, stale catalog or
446
+ incompatible vectors keeps ranking lexical and reports the reason on stderr.
447
+ `pmcp index --dry-run` plans work without loading a model or writing files;
448
+ `pmcp index --local-only` refuses downloads. Use `[embedding] enabled = false`
449
+ or `pmcp serve --lexical` to disable semantic ranking.
450
+
451
+ | Preset | Default precision | Supported output dimensions |
452
+ | --------------------- | ----------------- | --------------------------- |
453
+ | `e5-small` | `q8` | 384 |
454
+ | `embeddinggemma-300m` | `q4` | 768, 512, 256, 128 |
455
+ | `embeddinggemma-2` | `q4` | 768, 512, 256, 128 |
456
+
457
+ E5 remains the default. Gemma presets use qualified, pinned revisions, listed by
458
+ `pmcp models --json`; E5 retains its existing `main` revision for compatibility.
459
+ Gemma dimension reduction truncates and re-normalizes the projected embedding;
460
+ it reduces vector storage, not loaded model memory.
461
+
462
+ CLI flags override individual config fields: `--model`, `--dtype`,
463
+ `--dimensions`, `--model-revision`, `--model-path`, `--model-cache`,
464
+ `--query-prefix`, `--passage-prefix` and `--pooling`. Omit precision and dimensions
465
+ in the file when you want each model's defaults. Use `--no-config` for an
466
+ independent CLI selection. Config paths resolve relative to the TOML file;
467
+ CLI model paths resolve relative to the working directory.
468
+
469
+ Query caches also include the encoder identity, so sharing a cache between
470
+ same-width profiles cannot reuse another encoder's query vector. Library hosts
471
+ using openIntentCache must open a cache with the selected output width when
472
+ changing dimensions; pass the encoder's indexKey as its modelId for explicit
473
+ profile-scoped cache metadata.
474
+
475
+ Each model, revision, precision, output width and encoder specification has its
476
+ own vector identity. Switching preserves other models' indexes; switching back
477
+ reuses unchanged vectors. `--force` re-encodes only the selected model. A local
478
+ `model_path` must contain the declared revision's artifacts; change `revision`
479
+ and reindex after replacing them. The directory's location is not its identity.
480
+
481
+ Custom Transformers.js feature-extraction models need no source edits:
482
+
483
+ ```toml
484
+ [embedding]
485
+ model = "your-organization/your-onnx-model"
486
+ dtype = "q8"
487
+ revision = "your-pinned-revision"
488
+
489
+ [embedding.encoder]
490
+ query_prefix = "query: "
491
+ passage_prefix = "passage: "
492
+ pooling = "mean"
493
+ ```
494
+
495
+ Use the model's documented prefixes and pooling (`mean` or `cls`); unknown models
496
+ default to unprefixed mean pooling. A native `sentence_embedding` export may use
497
+ `projected = true`. Explicit dimension reduction is supported for the listed
498
+ presets. Other architectures require compatible Transformers.js exports.
499
+
500
+ The library API shares the same presets and identity rules:
501
+
502
+ ```js
503
+ import { loadEmbedder, prepareSearch } from "@modootoday/pmcp";
504
+
505
+ const encoder = await loadEmbedder("embeddinggemma-2", {
506
+ dimensions: 256,
507
+ modelPath: "/opt/models/embeddinggemma-2",
508
+ localOnly: true,
509
+ });
510
+ const search = await prepareSearch(
511
+ { roots: ["node_modules"] },
512
+ {
513
+ indexPath: "node_modules/.cache/pmcp/vectors.sqlite",
514
+ modelId: "embeddinggemma-2",
515
+ dimensions: 256,
516
+ embedder: encoder ?? undefined,
517
+ },
518
+ );
519
+ ```
520
+
521
+ HTTP hosts use these options under `semantic`; HTTP catalogs are encoded in
522
+ memory at startup rather than reading the CLI's persisted index. Model runtime
523
+ settings are passed to each loader without changing global download or cache
524
+ policy, so hosts can prepare different encoders in one process.
525
+
231
526
  ## Runtime and licence
232
527
 
233
- Node.js 22 or later, or Bun 1.3 or later. Default ranking is lexical. Semantic
528
+ Node.js 22 or later, or Bun 1.3 or later. Ranking is lexical until an index and
529
+ encoder are ready. Semantic
234
530
  ranking (the `index` command, or the HTTP handler's `semantic` option) needs
235
531
  `@huggingface/transformers` installed separately; it is not part of the default
236
532
  installation. The default encoder is `Xenova/multilingual-e5-small` (MIT, about
237
533
  130 MB), so vectors indexed with the earlier English-only default are re-encoded.
238
534
 
535
+ The optional encoder also supports the ONNX Community EmbeddingGemma 300M and
536
+ EmbeddingGemma 2 exports. It uses their projected sentence embeddings and task
537
+ prefixes. EmbeddingGemma 2 loads its text encoder without vision or audio models.
538
+ EmbeddingGemma was qualified with Transformers.js 4.3.1. Install a version
539
+ supporting the chosen export and keep model
540
+ weights outside the npm package. Regenerate document vectors when changing the
541
+ encoder. Quantization reduces weight storage; application RAM and latency need
542
+ workload measurements. EmbeddingGemma 300M uses the Gemma terms; EmbeddingGemma 2
543
+ is listed under Apache-2.0 in its model card.
544
+
239
545
  Elastic License 2.0. See `LICENSE` and `NOTICE` for terms and dependency notices.
240
546
  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 };