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/agents-sdk

v0.1.0

Published

Official TypeScript SDK for OpenComputer Agents - Run AI agents programmatically

Readme

@opencomputer/agents-sdk

Official TypeScript SDK for OpenComputer Agents - Run AI agents programmatically.

Installation

npm install @opencomputer/agents-sdk

Quick Start

import { OCAgents } from '@opencomputer/agents-sdk';

const client = new OCAgents({ apiKey: 'flt_xxx' });
await client.connect();

// Run a task and wait for the result
const result = await client.agents.run('agent-id', {
  prompt: 'Analyze the sales data and provide a summary'
});

console.log(result.output); // Structured output (if agent has output_schema)
console.log(result.result); // Raw text output

Features

  • Real-time streaming - Get live output as the agent works
  • Task control - Cancel long-running tasks at any time
  • Structured output - Define schemas for typed responses
  • Auto-reconnect - Handles connection drops gracefully
  • Full TypeScript support - Complete type definitions

Usage

Simple: Run and Wait

const result = await client.agents.run('agent-id', {
  prompt: 'Analyze this data',
  timeout: 300000, // 5 minutes max
});

if (result.output) {
  // Typed structured output (if agent has output_schema)
  console.log(result.output.summary);
  console.log(result.output.confidence);
}

Advanced: Stream Events

const task = await client.agents.submit('agent-id', {
  prompt: 'Long running analysis task'
});

// Listen to real-time events
task.on('stdout', (data) => {
  process.stdout.write(data);
});

task.on('tool_start', (tool, input) => {
  console.log(`Using tool: ${tool}`);
});

task.on('tool_end', (tool, output, duration) => {
  console.log(`${tool} completed in ${duration}ms`);
});

task.on('status', (status) => {
  console.log(`Status: ${status}`);
});

// Cancel if needed
setTimeout(() => {
  task.cancel();
}, 60000);

// Wait for final result
try {
  const result = await task.result();
  console.log('Completed:', result.output);
} catch (error) {
  if (error instanceof TaskCancelledError) {
    console.log('Task was cancelled');
  }
}

List Agents

const agents = await client.agents.list();
for (const agent of agents) {
  console.log(`${agent.name} (${agent.id})`);
  console.log(`  Type: ${agent.type}`);
  console.log(`  Provider: ${agent.provider}`);
}

With Structured Output Types

// Define your output type
interface AnalysisResult {
  summary: string;
  sentiment: 'positive' | 'negative' | 'neutral';
  confidence: number;
  keyPoints: string[];
}

// Get typed result
const result = await client.agents.run<AnalysisResult>('agent-id', {
  prompt: 'Analyze this text...'
});

// TypeScript knows the shape of result.output
console.log(result.output?.summary);
console.log(result.output?.keyPoints.join(', '));

Error Handling

import {
  OCAgents,
  OCError,
  TaskCancelledError,
  TaskFailedError,
  TaskTimeoutError,
  AuthenticationError,
} from '@opencomputer/agents-sdk';

try {
  const result = await client.agents.run('agent-id', { prompt: '...' });
} catch (error) {
  if (error instanceof TaskCancelledError) {
    console.log('Task was cancelled');
  } else if (error instanceof TaskFailedError) {
    console.log('Task failed:', error.taskError);
  } else if (error instanceof TaskTimeoutError) {
    console.log('Task timed out after', error.timeout, 'ms');
  } else if (error instanceof AuthenticationError) {
    console.log('Invalid API key');
  } else if (error instanceof OCError) {
    console.log('OCAgents error:', error.message, error.code);
  }
}

Configuration

const client = new OCAgents({
  apiKey: 'flt_xxx',           // Required: Your API key
  baseUrl: 'https://api.opencomputer.dev', // Optional: API base URL
  timeout: 600000,              // Optional: Default timeout (10 min)
});

API Reference

OCAgents

Main client class.

  • constructor(config: OCAgentsConfig) - Create a new client
  • connect(): Promise<void> - Connect to OpenComputer Agents (required before using)
  • disconnect(): void - Disconnect from OpenComputer Agents
  • isConnected(): boolean - Check connection status
  • agents: AgentsResource - Access agents resource

AgentsResource

Resource for interacting with agents.

  • list(): Promise<Agent[]> - List all agents
  • get(agentId: string): Promise<Agent> - Get a specific agent
  • run<T>(agentId: string, options: RunOptions): Promise<TaskResult<T>> - Run a task and wait
  • submit<T>(agentId: string, options: SubmitOptions): TaskHandle<T> - Submit a task (non-blocking)

TaskHandle

Handle for managing a submitted task.

  • id: string - Task ID
  • agentId: string - Agent ID
  • on(event, handler) - Listen to events ('stdout', 'stderr', 'tool_start', 'tool_end', 'status')
  • cancel(): Promise<void> - Cancel the task
  • result(): Promise<TaskResult<T>> - Wait for the result
  • getStatus(): TaskStatus - Get current status
  • isFinished(): boolean - Check if task is done

License

MIT