Skip to content
    ↑↓ select↵ openesc close
    English中文
    jackmazac

    Host Adapter

    v0.1.0Observability
    @mazac-fox/opencode-host-adapter

    Defensive wrapper for OpenCode plugins. Validates tool definitions, wraps execute in try/catch, filters bad system-transform output, and emits structured telemetry. Catches the codemem-style 'undefined is not an object (evaluating n._zod.def)' bug at regi

    GitHub stars

    0

    Monthly installs

    10

    5 in 7 days

    Composite scoreSCORE

    21.7

    Multi-signal model

    Last commit

    3 months ago

    2026-05-21

    Install and configure

    opencode.json

    Writes to this project's opencode.json — applies to this repository only.

    opencode.json

    {
      "$schema": "https://opencode.ai/config.json",
      "plugin": ["@mazac-fox/opencode-host-adapter@0.1.0"]
    }

    opencode loads npm dependencies through its embedded runtime on startup and caches them locally — no manual global install needed.

    Defensive boundary for OpenCode plugins: validate tool definitions and runtime args, wrap execution with structured failures, preserve OpenCode cancellation signals, propagate fleet correlation IDs, normalize hook outputs, and append canonical NDJSON telemetry.

    Re-exports @mazac-fox/opencode-fleet-contracts (fleetContracts / /contracts).

    What it does

    • wrapPlugin(plugin, { name, ... }) — production path for fleet plugins.
    • mergeToolExecuteBeforeHookArgs(inputArgs, outputArgs) — same merge semantics as tool.execute.before fleet propagation (output wins key overlaps); use in hook plugins that read args before the merged shape exists on output.args.
    • runPluginContractTests — loadability, tool shape, telemetry, arg validation harness.
    • validateToolDefinitions — CI preflight without loading OpenCode.

    No product logic (memory, locks, plans, graphs). Boundary options, error codes, and invariants: CONTRIBUTING.md, AGENTS.md.

    Host Adapter does not impose arbitrary tool execution deadlines. Plugin and runtime owners are responsible for cancellation policy; Host Adapter only preserves caller-provided ctx.abort / ctx.signal signals while wrapping execution.

    Quick start

    bun add @mazac-fox/opencode-host-adapter
    
    import { wrapPlugin } from "@mazac-fox/opencode-host-adapter";
    
    export default wrapPlugin(MyPlugin, { name: "my-plugin" });
    

    Development

    bun install
    bun run typecheck
    bun test
    

    Breaking boundary behavior: extend tests first; ripple to Conductor, Engram, Codemem, Fleet as needed. AGENTS.md.

    License

    MIT