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

tanstack-ai-opencode-console

v0.1.0

Published

TanStack AI adapter for the OpenCode v2 Console inference APIs

Readme

tanstack-ai-opencode-console

Community TanStack AI text adapter for the OpenCode v2 Console inference APIs. It calls https://opencode.ai/inference directly; it does not run the OpenCode CLI.

npm install @tanstack/ai tanstack-ai-opencode-console
import { chat } from "@tanstack/ai";
import { opencodeConsoleText } from "tanstack-ai-opencode-console";

const stream = chat({
  adapter: opencodeConsoleText("gpt-5.5"),
  messages: [{ role: "user", content: "Explain SSE in one sentence." }],
  modelOptions: { max_output_tokens: 256 },
});

for await (const event of stream) {
  if (event.type === "TEXT_MESSAGE_CONTENT") process.stdout.write(event.delta);
}

Set OPENCODE_API_KEY on the server or pass apiKey. Alternatively, use the server-only device sign-in helpers:

import {
  requestOpenCodeConsoleDeviceCode,
  completeOpenCodeConsoleDeviceSignIn,
  createOpenCodeConsoleSessionAuth,
} from "tanstack-ai-opencode-console/auth";
const device = await requestOpenCodeConsoleDeviceCode();
// Display only verificationUrl and userCode; keep deviceCode on the server.
const session = await completeOpenCodeConsoleDeviceSignIn(device);
const sessionAuth = createOpenCodeConsoleSessionAuth(session);
const adapter = opencodeConsoleText("gpt-5-nano", { session: sessionAuth });

Device sign-in requests workspace-scoped access. Console currently labels this package's own client ID "Unknown client". Token-bound workspaces cannot be switched locally. Account-wide sessions with multiple workspaces need sessionAuth.selectOrganization(id) before inference. A static session: {accessToken,orgId} or cancellable supplier also works. Session mode ignores the environment key and cannot be combined with an explicit apiKey.

The /auth entry also exports refreshOpenCodeConsoleSession and revokeOpenCodeConsoleSession. The supplier keeps rotated tokens in memory with per-session single-flight refresh. getSession() returns a copy for caller-managed secure storage. clear() deletes only local state; remote revocation is explicit. Do not send tokens to a browser. See authentication verification for evidence and limits.

Set apiKey: "" to omit authentication; gateway eligibility rules still apply. A live external free-tier call on October 5, 2026 returned HTTP 403 restricting usage to OpenCode clients. Use an eligible paid model. Requires Node 22.19+ and @tanstack/ai 0.65.x.

Exports opencodeConsoleText, OpenCodeConsoleTextAdapter, createOpenCodeConsole, listOpenCodeConsoleModels, parseOpenCodeConsoleModels, resolveOpenCodeConsoleApi, and OPENCODE_CONSOLE_BASE_URL. Import the browser-safe opencodeConsoleByok from tanstack-ai-opencode-console/byok.

The factory chooses Responses, Chat Completions, Anthropic Messages, or Gemini by model ID and accepts an explicit api override. Jev decision models are excluded. Discovery reports availability and inferred routing; it does not guarantee tools, multimodal input, or structured output. Input types default to text; declare verified inputModalities in the adapter config. Provider-specific parameters go in modelOptions.

Configuration supports a root baseURL, fetch, defaultHeaders, timeout (600000 ms), maxRetries (0), and apiKey or session authentication. Every protocol uses Console Bearer auth; sessions also send matching x-org-id and x-opencode-org-id headers. Persistent secret storage stays with the caller. Responses default to store:false; Messages defaults to max_tokens:4096. Cancellation, reasoning, tool calls, usage, and schema output delegate to the native TanStack adapters. Provider file handles are not exposed.

Go subscription inference can be configured with baseURL: "https://opencode.ai/inference/go", a stable x-opencode-session, your own User-Agent, and an explicit api where Go routing differs (MiniMax and Qwen use Messages). See Go configuration and verification for credential requirements and live evidence.

See full documentation and example app, the v2 inference reference, and the TanStack compatible adapter.

Unofficial community project. MIT license.