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

@orchard9ai/companion-world-sdk

v1.1.0

Published

TypeScript SDK for Companion World API

Downloads

2

Readme

Companion World SDK

Official TypeScript SDK for the Companion World API - create and manage AI-powered virtual worlds with autonomous agents.

Installation

npm install @orchard9ai/companion-world-sdk

Quick Start

import { CompanionWorldClient } from '@orchard9ai/companion-world-sdk';

// Initialize the client
const client = new CompanionWorldClient({
  baseURL: 'https://agents.orchard9.ai/api/companion-world',
  apiKey: 'your-jwt-token',
  organizationId: 'your-org-id' // optional
});

// Create a world
const { world } = await client.initializeWorld({
  name: 'My AI World',
  config: {
    startTime: '2024-01-01T00:00:00Z',
    tickInterval: 15,
    timezone: 'America/Los_Angeles',
    planningHorizonMonths: 6
  }
});

// Generate population
const { job } = await client.generatePopulation(world.id, {
  count: 1000,
  batch_size: 50,
  config: {
    gender_distribution: { F: 1.0, M: 0.0 } // 100% female
  }
});

// Monitor progress
const stats = await client.getWorldStats(world.id);
console.log(`Total agents: ${stats.totalAgents}`);
console.log(`Pending: ${stats.pendingAgents}`);

Key Features

  • 🌍 World Management - Create and manage virtual worlds
  • 👥 Population Generation - Generate diverse AI agents at scale
  • 📍 Location System - Add cities and locations to your world
  • 📊 Real-time Monitoring - Track population generation progress
  • 🎭 Agent Personalities - Each agent has unique traits and behaviors

API Reference

World Management

// Initialize a new world
await client.initializeWorld({
  name: string,
  config: {
    startTime: string,        // ISO date
    tickInterval: number,     // minutes
    timezone: string,         // IANA timezone
    planningHorizonMonths: number
  }
});

// Get world details
await client.getWorld(worldId: string);

// List all worlds
await client.listWorlds({ page?: number, limit?: number });

Population Generation

// Start population generation
await client.generatePopulation(worldId: string, {
  count: number,
  batch_size: number,
  config?: {
    age_distribution?: Record<string, number>,
    gender_distribution?: Record<string, number>
  }
});

// Check job status
await client.getPopulationJob(worldId: string, jobId: string);

// List all jobs
await client.listPopulationJobs(worldId: string);

Agent Management

// List agents
await client.listAgents(worldId: string, {
  page?: number,
  limit?: number,
  gender?: string,
  location_id?: string
});

// Get agent details
await client.getAgent(worldId: string, agentId: string);

Helper Methods

// Get comprehensive world statistics
const stats = await client.getWorldStats(worldId: string);
// Returns: {
//   world: World,
//   totalAgents: number,
//   activeJobs: number,
//   completedJobs: number,
//   pendingAgents: number,
//   populationProgress: Array<{
//     id: string,
//     status: string,
//     total: number,
//     completed: number,
//     progress: number
//   }>
// }

Examples

Monitor Population Generation

async function monitorPopulation(worldId: string) {
  const stats = await client.getWorldStats(worldId);
  
  console.log(`World: ${stats.world.world_name}`);
  console.log(`Total Agents: ${stats.totalAgents}`);
  console.log(`Agents Being Generated: ${stats.pendingAgents}`);
  
  stats.populationProgress.forEach(job => {
    console.log(`Job ${job.id}: ${job.completed}/${job.total} (${job.progress.toFixed(1)}%)`);
  });
}

// Poll every 5 seconds
setInterval(() => monitorPopulation(worldId), 5000);

Create World with Cities

// Create world
const { world, locationId } = await client.initializeWorld({
  name: 'Urban World',
  config: {
    startTime: '2024-01-01T00:00:00Z',
    tickInterval: 15,
    timezone: 'America/Los_Angeles',
    planningHorizonMonths: 6
  }
});

// Add cities
await client.createLocationsBatch(world.id, {
  locations: [
    {
      name: 'San Francisco',
      type: 'GEOGRAPHIC',
      subtype: 'CITY',
      timezone: 'America/Los_Angeles',
      coordinates: {
        latitude: 37.7749,
        longitude: -122.4194
      }
    },
    {
      name: 'Los Angeles',
      type: 'GEOGRAPHIC', 
      subtype: 'CITY',
      timezone: 'America/Los_Angeles',
      coordinates: {
        latitude: 34.0522,
        longitude: -118.2437
      }
    }
  ],
  connect_nearby: true,
  max_connections: 5,
  connection_radius_km: 100
});

Error Handling

try {
  const world = await client.getWorld(worldId);
} catch (error) {
  if (error.response?.status === 404) {
    console.error('World not found');
  } else if (error.response?.status === 403) {
    console.error('Insufficient permissions');
  } else {
    console.error('Unexpected error:', error.message);
  }
}

License

MIT