npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@wardhq/opencode

v0.2.0

Published

Ward tool mediation for OpenCode V2

Readme

@wardhq/opencode

Thin Ward tool mediation for OpenCode V2. The first supported host is OpenCode 2.1.2; the plugin uses its Promise V2 API and wraps registered tool executors with ctx.tool.transform.

Install

opencode plugin add @wardhq/[email protected]

The plugin activates inside a Ward-managed Modal runtime from the Ward session identity already supplied to that Sandbox. It does not require a client integration, client lifecycle endpoint, or link credential.

| Variable | Purpose | | --- | --- | | WARD_API_BASE_URL | HTTPS origin for the Ward API | | WARD_SESSION_ID | Owning Ward session ID | | WARD_SANDBOX_ID | Current Modal Sandbox ID | | WARD_ATTEMPT | Current runtime attempt | | WARD_ATTEMPT_CREDENTIAL | Ward-issued credential scoped to the current session attempt |

If all variables are absent, the plugin is inert. Partial or invalid configuration prevents OpenCode startup. The plugin removes the attempt credential from its process environment after reading it, so tool child processes do not inherit it.

Mediation flow

For each intercepted tool, the plugin sends POST /sessions/{WARD_SESSION_ID}/tool-calls with the call ID, tool name, arguments, the tool's output JSON Schema, and call attempt. The request carries Ward's existing session, Sandbox, and runtime-attempt identity. The Worker forwards it to that Ward session's Session DO, which records the pending call and wakes the Ward agent. The plugin waits for Ward's simulation decision without setting its own timeout. The OpenCode tool's cancellation signal cancels the request. The original executor is never run. Ward validates the decision envelope and result before resolving the plugin's request.

The Ward response is one of:

  • { "call_id": "...", "attempt": 1, "decision": "simulate", "result": { ... } }: return the simulated OpenCode result without executing the original tool.
  • { "call_id": "...", "attempt": 1, "decision": "simulate", "error": { "message": "..." } }: fail the tool call with the simulated error.

The plugin serializes requests waiting for Ward so a Ward session has at most one pending call. It forwards the tool's output schema to Ward and transports the accepted decision back to OpenCode; it does not validate Ward's simulated result or send validation feedback as a second request. Ward's decision endpoint validates the result envelope and output schema before accepting a decision. Invalid results return a structured HTTP error to Ward's decision API call and leave the pending client tool call unchanged.

Requests are limited to 256 KiB, arguments/results to 128 KiB, and output schemas to 64 KiB. Tool arguments and simulated values are forwarded without redaction.

CodeMode's synthesized execute tool is mediated through OpenCode's tool.execute.before and tool.execute.after hooks. Ward receives the full CodeMode input and the pinned CodeMode output schema. Before OpenCode runs the program, the plugin replaces it with a harmless stub; after the stub returns, the plugin substitutes Ward's validated simulated result. The original program, including direct fetch calls and nested tool calls, does not run. Ward therefore simulates each CodeMode execute call as one unit; tools called inside that program are not submitted as separate calls.

Runtime telemetry

The plugin writes structured ward.opencode_plugin.* events to OpenCode's stdout. The client runtime forwards that stream to its compute environment, where it is available in the session's container logs. Events identify plugin setup/configuration, the count of wrapped tools and whether shell was wrapped, each intercepted call, Ward decision receipt and latency, and whether the call was simulated. They include tool names and generated call IDs, but never credentials, tool arguments, simulated values, or tool results. Telemetry failures do not change plugin behavior.

For a call that appears to bypass Ward, the expected sequence is tool_intercepted → ward_request_started → decision_received → tool_simulated. CodeMode execute is intercepted by hooks and is not included in the tools_wrapped count. Missing setup_started points to plugin resolution or loading; setup_failed points to configuration or hook registration; a tools_wrapped record with shell_tool_wrapped: false means the built-in shell tool was not present in the transform; and a request without decision_received should have a matching ward_request_failed event. If it has neither, the request is still pending or the OpenCode process exited before it could emit an outcome.

Compatibility

This package peers on exactly @opencode/[email protected]. It must not be treated as proof that every tool path in an OpenCode host is mediated. Verify built-in, plugin, MCP, CodeMode, direct, dynamic, and delegated paths against the exact host build before enabling it for customer runs.

Publishing

Merging a new package version to main publishes it after checks and production deployment succeed. Increment both package.json and package-lock.json; the publisher workflow skips versions already present on npm. Publishing uses npm trusted publishing from GitHub Actions, with no long-lived npm token. The npm package must trust the publish-opencode.yml workflow in halcyonHQ/Ward and allow direct publishing.