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

@viberlabs/opencode

v1.1.1

Published

OpenCode integration for VIBER Universal

Readme

@viberlabs/opencode

OpenCode integration for VIBER Labs / VIBER v2 - HTTP client and agent integration

Installation

npm install @viberlabs/opencode

Features

OpenCode Client

HTTP client for OpenCode API communication.

import { OpenCodeClient } from '@viberlabs/opencode';

const client = new OpenCodeClient({
  baseUrl: 'http://localhost:51262',
  username: 'opencode',
  password: 'your-password'
});

// Health check
const health = await client.healthCheck();
console.log(health.status); // 'ok'

// Create session
const session = await client.createSession({
  title: 'VIBER: Build authentication',
  model: 'claude-3-opus'
});

// Send message (synchronous)
const response = await client.sendMessage(session.id, {
  parts: [{ type: 'text', text: 'Build JWT authentication' }],
  agent: 'build'
});

// Send message (asynchronous)
await client.sendMessageAsync(session.id, {
  parts: [{ type: 'text', text: 'Implement feature X' }],
  agent: 'build'
});

// Get session
const retrieved = await client.getSession(session.id);

// Abort session
await client.abortSession(session.id);

Agent Integration

High-level agent spawning and result capture.

import { AgentIntegration } from '@viberlabs/opencode/integration';

const integration = new AgentIntegration(client, db);

// Spawn agent
const agent = await integration.spawnAgent({
  taskId: 'task-1',
  role: 'coder',
  model: 'claude-3-opus',
  instruction: 'Implement JWT authentication with refresh tokens'
});

// Wait for completion with timeout
const result = await integration.waitForCompletion(agent.id, {
  timeout: 300000, // 5 minutes
  onProgress: (progress) => {
    console.log('Progress:', progress);
  }
});

console.log(result.success); // true/false
console.log(result.summary); // Result summary
console.log(result.artifacts); // Files created/modified
console.log(result.duration); // Time taken

Event Streaming

Real-time event monitoring via SSE.

const events = client.subscribeToEvents();

events.on('server.connected', () => {
  console.log('Connected to OpenCode');
});

events.on('message.start', (event) => {
  console.log('Message started:', event.sessionId);
});

events.on('message.delta', (event) => {
  console.log('Progress:', event.delta);
});

events.on('message.complete', (event) => {
  console.log('Message completed:', event.message);
});

events.on('error', (error) => {
  console.error('Error:', error);
});

Authentication

OpenCode uses HTTP Basic Auth. Store credentials in .viber/opencode-auth.json:

{
  "username": "opencode",
  "password": "uuid-v4-password",
  "port": 51262
}

Port Discovery

The client automatically discovers the OpenCode server port:

  1. Try port from environment OPENCODE_SERVER_PORT
  2. Try port from auth file
  3. Try default port 51262
  4. Try alternative port 4096

API Reference

OpenCodeClient Methods

  • healthCheck() - Check server health
  • createSession(options) - Create new session
  • sendMessage(sessionId, message) - Send synchronous message
  • sendMessageAsync(sessionId, message) - Send asynchronous message
  • getSession(sessionId) - Retrieve session
  • abortSession(sessionId) - Abort active session
  • subscribeToEvents() - Subscribe to SSE events

AgentIntegration Methods

  • spawnAgent(config) - Spawn AI agent
  • waitForCompletion(agentId, options) - Wait for agent completion
  • captureResult(agentId) - Capture agent result
  • detectCompletion(sessionId) - Detect if session is complete

Error Handling

try {
  const session = await client.createSession({ title: 'Test' });
} catch (error) {
  if (error.code === 'ECONNREFUSED') {
    console.error('OpenCode server not running');
  } else if (error.code === 'UNAUTHORIZED') {
    console.error('Invalid credentials');
  } else {
    console.error('Error:', error.message);
  }
}

License

MIT

Links