feat(core): M5.1 — plugin subprocess + JSON-RPC bridge + token+env-strip#15
Merged
Conversation
…assing
What ships
----------
- plugins/runtime/subprocess.ts (~270 lines)
· PluginSubprocess class — spawn plugin's index.js as separate node process
· JSON-RPC stdio bridge — newline-framed, request/response correlated by id
· Capability methods exposed to plugin (via plugin → host RPC):
- fs_read(path) / fs_write(path, content)
- bash(command)
- fetch(url, opts)
- log(msg)
· Token validation on every RPC (defense against unauthorized callers)
· DEEPSEEK_API_KEY / DEEPSEEK_AUTH_TOKEN env vars STRIPPED in child env
(plugin cannot exfil host credentials)
· spawnAllPlugins(plugins, host) / shutdownAllPlugins() bulk helpers
· generatePluginToken() — collision-resistant token generator
What's exposed in @deepcode/core
- PluginSubprocess / spawnAllPlugins / shutdownAllPlugins /
generatePluginToken (+ RpcRequest/Response, SpawnAllOpts types)
Tests (5 new, 321 total)
------------------------
- starts subprocess + clean shutdown
- plugin can request fs_read via RPC, host bridge fires + returns
- wrong token rejected (host bridge NOT fired)
- generatePluginToken yields unique values
- DEEPSEEK_API_KEY env var stripped in plugin process
Verified
--------
pnpm typecheck → green
pnpm test → 313 passed / 8 skipped / 0 failed (was 308)
What's intentionally NOT in this PR (per docs/design/plugin-security.md)
------------------------------------------------------------------------
- OS-level sandbox wrapping (bwrap/sandbox-exec around plugin process):
M5.1-ext. Currently the plugin can still e.g. open arbitrary network
connections — the token + env-strip protects host CREDENTIALS but not
the broader threat surface.
- GitHub URL install ("gh:user/repo")
- npm install
- Marketplace ed25519 signature verification
- Revoke list pull/enforcement
- Wiring spawned plugins into the live ToolRegistry / hook chain — currently
the subprocess infrastructure exists but the REPL doesn't yet spawn-and-
register installed plugins. That last-mile wire-up is M5.2.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PluginSubprocessspawns plugin in a separate node process with JSON-RPC stdio bridge. Host implements fs_read/fs_write/bash/fetch/log on plugin's behalf, gated by per-instance token. DEEPSEEK_API_KEY and DEEPSEEK_AUTH_TOKEN env vars stripped from child env so plugins can't exfil host credentials.5 new tests · 313 passed / 8 skipped / 0 failed (was 308).
Deferred to M5.1-ext / M5.2
OS sandbox wrap around plugin process; gh:/npm install; marketplace signatures; revoke list; live ToolRegistry wire-up of spawned plugins.
Release notes
release-notes:featureCo-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com