Expand description
ocserve-plugin: opencode plugin compatibility via a Node sidecar (M4b).
Gate rationale (PLAN §10, evidence not assumption): the frozen plugins
import bun:sqlite, child_process, node:fs/crypto/url and TTY UI
modules (import audit of the actual artifacts). A quickjs embed would need
a dozen shims with a synchronous SQLite bridge — rejected as high-risk;
one Node sidecar (v25 present, node:sqlite built in) is the low-
maintenance host. Isolation: sidecar crash/restart cannot take down the
server; protocol = NDJSON on stdio; plugin chatter is forced to stderr by
the host so framing cannot corrupt.
Re-exports§
pub use normalize::Outcome as NormalizeOutcome;pub use normalize::normalize_or_raw_sync;
Modules§
- normalize
- Plugin entry normalization (D1 — bench/normalizer-spike/STRESS-RESULTS.md §Phase 3 dispositions; executable spec: bench/normalizer-spike/D1-PLAN.md).
Structs§
- Handle
- Cheap clone handle: hook dispatch drops the owner lock and awaits this.
- Inner
- Everything a request needs, shareable WITHOUT the owning
Sidecarlock. - Sidecar
- Sidecar owner: one Node process, NDJSON request/response, reader task.
Enums§
- Plugin
Runtime - Plugin-host runtime: Bun preferred (upstream runs plugins under Bun; real
bun:sqlite, TS plugins load, lower RSS floor), Node fallback.OCSERVE_PLUGIN_RUNTIME=node|bunforces one (lab A/B control).
Constants§
- HOST_
FILES - Host files (written next to the data dir once; content-addressed by embed).
- RPC_
TIMEOUT - Per-RPC timeout (hooks are local JS; anything longer is a runaway plugin).
Functions§
- hook_
budget - Per-hook budget. Upstream has NO hook timeout (
Effect.promise(...)awaits forever); any bound is our safety divergence, recorded as D-HOOK-TIMEOUT. Defaults come from measured maxima on a real install (27 prompts):v2.session.context15.3 s,tool.execute.after30.0 s,system.transform5.4 s.OCSERVE_HOOK_TIMEOUT_MS=0restores parity (unbounded) for an operator who needs it. - materialize_
host - Write host files into
dir(idempotent overwrite — embed is authoritative). - plugin_
runtime - resolve_
entry - Resolve a plugin spec to an entry file (loader.ts semantics, npm-install stage assumed already done by opencode’s cache — we re-use it read-only):