Skip to main content

Crate ocserve_plugin

Crate ocserve_plugin 

Source
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§

Sidecar
Sidecar handle: one Node process, NDJSON request/response, reader task.

Enums§

PluginRuntime
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|bun forces one (lab A/B control).

Constants§

HOST_FILES
Host files (written next to the data dir once; content-addressed by embed).
OOM_CHILD_WRAPPER
sh -c WRAPPER sh <prog> <args…> → raise oom_score_adj, move into the L2 kids cgroup (if the partition dance published one), then exec. Kept identical in ocserve-mcp + ocserve-plugin (no shared dep) — A3/L2.
RPC_TIMEOUT
Per-RPC timeout (hooks are local JS; anything longer is a runaway plugin).

Functions§

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):
set_kids_cgroup