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

@agent-workspace/agent

v0.9.0

Published

Agent runtime for AWP experiments — framework-agnostic adapter pattern with OpenAI and Anthropic implementations

Readme

@agent-workspace/agent

Agent runtime for AWP experiments — a framework-agnostic adapter pattern with OpenAI and Anthropic implementations.

Overview

This package provides the agent runtime infrastructure for running AWP experiments. It uses an adapter pattern that allows different LLM backends (OpenAI, Anthropic, or custom) to be swapped while maintaining the same experiment orchestration logic.

Quick Start

# Install
npm install @agent-workspace/agent

# Set API key
export OPENAI_API_KEY=sk-xxx
# Or for Anthropic:
export ANTHROPIC_API_KEY=sk-ant-xxx
import { 
  OpenAIAgent, 
  AnthropicAgent,
  ExperimentOrchestrator, 
  SocietyManager,
  MetricsCollector,
  parseManifesto 
} from '@agent-workspace/agent';

// Parse manifesto
const manifesto = await parseManifesto('./MANIFESTO.md');

// Create society
const manager = new SocietyManager('./societies');
const society = await manager.createSociety('test-001', manifesto.id, 3);

// Create agents
const agents = society.agents.map((workspace, i) => 
  new OpenAIAgent(`agent-${i + 1}`, workspace, 'gpt-4o-mini')
);

// Initialize agents
for (const agent of agents) {
  await agent.getIdentity();
}

// Run experiment
const metrics = new MetricsCollector();
const orchestrator = new ExperimentOrchestrator(manifesto, agents, metrics, society);
const results = await orchestrator.runExperiment(5); // 5 cycles

console.log(`Success rate: ${(results.aggregateMetrics.overallSuccessRate * 100).toFixed(1)}%`);

Architecture

┌─────────────────────────────────────────────────────────────┐
│                    Experiment Orchestrator                   │
│         (creates contracts, runs cycles, collects metrics)  │
└─────────────────────────┬───────────────────────────────────┘
                          │
          ┌───────────────┼───────────────┐
          ▼               ▼               ▼
    ┌───────────┐   ┌───────────┐   ┌───────────┐
    │  OpenAI   │   │ Anthropic │   │  Custom   │
    │   Agent   │   │   Agent   │   │  (yours)  │
    └─────┬─────┘   └─────┬─────┘   └─────┬─────┘
          │               │               │
          └───────────────┼───────────────┘
                          ▼
                ┌───────────────────┐
                │   AWP Tools       │
                │   (7 operations)  │
                └───────────────────┘

Agent Implementations

OpenAIAgent

Uses OpenAI's function calling with models like gpt-4o-mini, gpt-4o, etc.

import { OpenAIAgent } from '@agent-workspace/agent';

const agent = new OpenAIAgent(
  'agent-01',           // id
  './workspace',        // workspace path
  'gpt-4o-mini',        // model (optional)
  process.env.OPENAI_API_KEY // apiKey (optional)
);

AnthropicAgent

Uses Anthropic's tool_use with models like claude-sonnet-4-20250514, claude-3-haiku, etc.

import { AnthropicAgent } from '@agent-workspace/agent';

const agent = new AnthropicAgent(
  'agent-01',           // id
  './workspace',        // workspace path
  'claude-sonnet-4-20250514', // model (optional)
  process.env.ANTHROPIC_API_KEY // apiKey (optional)
);

Custom Agents

Implement the AgentAdapter interface or extend BaseAgent:

import { BaseAgent, AgentTask, TaskResult } from '@agent-workspace/agent';

class MyCustomAgent extends BaseAgent {
  async executeTask(task: AgentTask): Promise<TaskResult> {
    const systemPrompt = await this.buildSystemPrompt(task);
    // ... your LLM integration
  }
}

See AGENT_ADAPTER.md for full documentation.

Core Interfaces

AgentAdapter

interface AgentAdapter {
  readonly id: string;
  readonly workspace: string;
  readonly did: string;
  
  executeTask(task: AgentTask): Promise<TaskResult>;
  getReputation(): Promise<AgentReputation>;
  getIdentity(): Promise<{ name: string; did: string; role?: string }>;
}

AgentTask

interface AgentTask {
  contractId: string;
  description: string;
  tools: ToolDefinition[];
  timeout?: number;
  outputFormat?: string;
  outputSlug?: string;
}

TaskResult

interface TaskResult {
  success: boolean;
  output?: string;
  toolCalls: ToolCall[];
  tokens: { input: number; output: number };
  durationMs: number;
  error?: string;
  rawResponse?: string;
}

Available Tools

Agents have access to 7 AWP operations:

| Tool | Description | |------|-------------| | awp_artifact_read | Read a knowledge artifact | | awp_artifact_write | Write/update an artifact | | awp_artifact_list | List all artifacts | | awp_contract_accept | Accept a delegation contract | | awp_contract_complete | Mark contract complete | | awp_reputation_query | Query agent reputation | | task_complete | Signal task completion |

CLI Integration

The awp CLI provides experiment commands:

# Create a society
awp experiment society create --manifesto MANIFESTO.md --agents 3

# Run experiment with OpenAI (default)
awp experiment run -s <society-id> -c 5 -m MANIFESTO.md

# Run with Anthropic
awp experiment run -s <society-id> -c 5 -m MANIFESTO.md --provider anthropic

# List societies
awp experiment list

# Show results
awp experiment show <society-id>

Environment Variables

| Variable | Description | Required For | |----------|-------------|--------------| | OPENAI_API_KEY | OpenAI API key | OpenAIAgent | | ANTHROPIC_API_KEY | Anthropic API key | AnthropicAgent |

Exports

// Types
export * from './types';

// Base class
export { BaseAgent, MAX_ITERATIONS, DEFAULT_TIMEOUT_MS } from './base-agent';

// Agent implementations
export { OpenAIAgent } from './openai-agent';
export { AnthropicAgent } from './anthropic-agent';

// Tools
export { AWP_TOOLS, executeToolCall } from './tools';

// Orchestration
export { ExperimentOrchestrator } from './orchestrator';
export { MetricsCollector } from './metrics';
export { SocietyManager, parseManifesto } from './society';

License

Apache-2.0