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-harbor/rest-client

v0.0.0

Published

Shared REST API client for Agent Harbor

Readme

@agent-harbor/rest-client

Shared REST API client for Agent Harbor.

Installation

yarn add @agent-harbor/rest-client

Usage

Creating a Client

import { createApiClient } from '@agent-harbor/rest-client';

// Simple usage with just a base URL
const client = createApiClient('http://localhost:8080/api/v1');

// With custom options
const client = createApiClient({
  baseUrl: 'http://localhost:8080/api/v1',
  headers: {
    Authorization: 'Bearer your-token',
  },
});

Creating a Task

import { createApiClient, CreateTaskRequest } from '@agent-harbor/rest-client';

const client = createApiClient('http://localhost:8080/api/v1');

const taskRequest: CreateTaskRequest = {
  prompt: 'Fix the bug in main.ts',
  repo: {
    mode: 'git',
    url: 'https://github.com/example/repo',
    branch: 'main',
  },
  runtime: {
    type: 'devcontainer',
  },
  agent: {
    type: 'claude-code',
    version: 'latest',
  },
  output: {
    format: 'stream-json',
    flavor: 'ah',
  },
};

const response = await client.createTask(taskRequest);
console.log('Created sessions:', response.session_ids);

Managing Sessions

// List sessions
const sessions = await client.listSessions({ status: 'running' });

// Get a specific session
const session = await client.getSession(sessionId);

// Stop a session gracefully
await client.stopSession(sessionId);

// Cancel a session immediately
await client.cancelSession(sessionId);

// Pause and resume
await client.pauseSession(sessionId);
await client.resumeSession(sessionId);

// Get session logs
const logs = await client.getSessionLogs(sessionId, 100); // Last 100 lines

Error Handling

import { createApiClient, ApiClientError } from '@agent-harbor/rest-client';

const client = createApiClient('http://localhost:8080/api/v1');

try {
  await client.getSession('non-existent-id');
} catch (error) {
  if (error instanceof ApiClientError) {
    console.error(`API Error: ${error.message}`);
    console.error(`Status: ${error.status}`);

    if (error.isNotFound()) {
      console.error('Session not found');
    }

    if (error.hasValidationErrors()) {
      console.error('Validation errors:', error.apiError?.errors);
    }
  }
}

SSE Events (Browser)

For browser environments, you can use the built-in EventSource support:

const eventSource = client.subscribeToSessionEvents(sessionId, event => {
  switch (event.type) {
    case 'status':
      console.log('Status changed:', event.status);
      break;
    case 'tool_execution':
      console.log('Tool executed:', event.tool_name);
      break;
    case 'thinking':
      console.log('Agent thinking:', event.thought);
      break;
  }
});

// Later: close the connection
eventSource.close();

For Node.js environments, use the @agent-harbor/sse-client package for more robust SSE handling.

API Reference

Client Methods

| Method | Description | | --------------------------------------- | -------------------------------------- | | createTask(data) | Create a new task | | listSessions(params?) | List sessions with optional filtering | | getSession(id) | Get a specific session | | stopSession(id) | Stop a session gracefully | | cancelSession(id) | Cancel a session immediately | | pauseSession(id) | Pause a running session | | resumeSession(id) | Resume a paused session | | getSessionLogs(id, tail?) | Get session logs | | sendMessage(id, message) | Send a message to a session | | getSessionEventsUrl(id) | Get SSE events URL | | subscribeToSessionEvents(id, onEvent) | Subscribe to SSE events (browser only) | | listAgents() | List available agent types | | listRuntimes() | List available runtime types | | listRepositories(params?) | List repositories | | getRepository(id) | Get a specific repository | | listDrafts() | List draft tasks | | createDraft(draft) | Create a draft task | | updateDraft(id, updates) | Update a draft task | | deleteDraft(id) | Delete a draft task |

Types

The package exports all types needed for working with the API:

  • Configuration: Repository, Runtime, Agent, Delivery, OutputConfig
  • Tasks: CreateTaskRequest, CreateTaskResponse
  • Sessions: Session, SessionStatus, SessionsListResponse
  • Events: SessionEvent, StatusEvent, LogEvent, ThinkingEvent, ToolExecutionEvent, FileEditEvent
  • Metadata: AgentType, RuntimeType, RepositoryItem
  • Drafts: DraftCreate, DraftTask, DraftUpdate
  • Feedback: FeedbackRequest, FeedbackResponse, FeedbackOption
  • Errors: ApiError, ApiClientError

License

Apache-2.0