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

@opencomputer/agent

v0.5.2

Published

Reactive agent authoring API for OpenComputer.

Readme

OpenComputer Agent

Reactive authoring API for agent code deployed by OpenComputer.

import { useInput, useModel, useTool } from "@opencomputer/agent";

export default function Agent() {
  const input = useInput();
  useModel("anthropic/claude-sonnet-4.6");
  if (input.text?.includes("documentation")) useTool("search-docs");

  return "Help the user directly and clearly.";
}

The default export is rendered synchronously before each model call. Hooks describe that call; they do not perform I/O or run the durable agent loop.

  • useInput() reads the immutable input admitted for this turn. It is not a human-in-the-loop prompt; interactive clarification remains a tool action.
  • useModel() chooses a model. A string uses OpenRouter and retains its normal provider/model spelling.
  • useTool() and useSubagent() select declared capabilities.
  • useSessionData() reads the current durable session-data snapshot.
  • useMcpServer() conditionally selects a declared MCP server.

Use defineMcpServer() for stable MCP declarations. Never put credentials directly in these declarations: OpenComputer resolves referenced secrets through its managed gateway.

Secret-backed HTTP connections

Declare the destination and the exact place a secret may be injected. The secret reference is compiled into deployment metadata; its value never enters the agent artifact or runtime:

import {
  bearer,
  defineConnection,
  defineTool,
  useSecret,
  useTool,
} from "@opencomputer/agent";

const github = defineConnection({
  id: "github-api",
  origin: "https://api.github.com",
  methods: ["GET"],
  pathPrefix: "/repos/",
  redirectOrigins: [
    {
      origin: "https://codeload.github.com",
      pathPrefix: "/opencomputer/",
    },
  ],
  headers: {
    Authorization: bearer(useSecret("GITHUB_TOKEN")),
  },
});

const repository = defineTool({
  name: "github_repository",
  description: "Read a GitHub repository.",
  async run() {
    const response = await github.fetch("/repos/opencomputer/example");
    return await response.json();
  },
});

export default function Agent() {
  useTool(repository);
  return "Use GitHub when the user asks about a repository.";
}

defineConnection().fetch() sends a relative request through OpenComputer's managed egress gateway. The gateway checks the deployment, agent, environment, origin, path, and method before resolving and injecting the secret. Redirects are denied unless the connection declares a matching redirectOrigins entry. The gateway follows at most one redirect for GET or HEAD and never forwards the original request headers or managed secrets to the redirect destination.

Hooks may only be called while the managed runtime is rendering an agent.

Code-defined tools

Define executable capabilities with OpenComputer's harness-neutral tool() API, then enable them reactively with useTool():

import { tool } from "@opencomputer/agent";

export const hackerNews = tool<{ limit?: number }>({
  id: "hacker_news",
  description: "Fetch current Hacker News stories.",
  input: {
    type: "object",
    properties: {
      limit: { type: "integer", minimum: 1, maximum: 20, default: 5 },
    },
    additionalProperties: false,
  },
  async execute({ limit = 5 }) {
    return JSON.stringify({ limit });
  },
});
import { useInput, useTool } from "@opencomputer/agent";
import { hackerNews } from "./tools/hacker-news.js";

export default function Agent() {
  const input = useInput();
  if (/hacker news|\bhn\b/i.test(input.text ?? "")) useTool(hackerNews);
  return "Use live Hacker News data when that tool is enabled.";
}

Tool input uses JSON Schema. Tool code never imports OpenCode; OpenComputer registers definitions with the active managed harness. Customer-defined tools are excluded from codemode unless OpenComputer explicitly vets them.