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

@resourcexjs/arp

v1.1.0

Published

ARP (Agent Resource Protocol) - A URL protocol for AI agents to access resources

Readme

@resourcexjs/arp

Agent Resource Protocol - Low-level I/O primitives for ResourceX.

Installation

bun add @resourcexjs/arp

Overview

ARP (Agent Resource Protocol) provides a URL-based abstraction layer for resource I/O operations.

URL Format

arp:{semantic}:{transport}://{location}
  • semantic: Content interpretation (text, binary)
  • transport: Storage backend (file, http, https, agentvm)
  • location: Resource location (path, URL)

Examples

arp:text:file://~/data.txt
arp:binary:https://example.com/image.png
arp:text:agentvm://sandbox/config.json

Usage

Basic Operations

import { createARP } from "@resourcexjs/arp";

const arp = createARP();

// Parse ARP URL
const arl = arp.parse("arp:text:file://./data.txt");

// Read
const resource = await arl.resolve();
console.log(resource.content); // string (text semantic)

// Write
await arl.deposit("Hello, World!");

// Check existence
if (await arl.exists()) {
  console.log("File exists");
}

// Delete
await arl.delete();

Text Semantic

const arl = arp.parse("arp:text:file://./hello.txt");

// Write text
await arl.deposit("Hello, World!");

// Read text
const resource = await arl.resolve();
console.log(resource.content); // "Hello, World!" (string)

Binary Semantic

const arl = arp.parse("arp:binary:file://./data.bin");

// Write binary
const buffer = Buffer.from([1, 2, 3, 4]);
await arl.deposit(buffer);

// Read binary
const resource = await arl.resolve();
console.log(resource.content); // Buffer

API Reference

createARP(config?)

Create ARP instance with registered handlers.

Parameters:

  • config?: ARPConfig - Optional configuration

Returns: ARP

const arp = createARP();

ARP.parse(url: string): ARL

Parse ARP URL and return ARL (Agent Resource Locator).

Parameters:

  • url: string - ARP URL

Returns: ARL

Throws: ParseError if URL is invalid

const arl = arp.parse("arp:text:file://./data.txt");

ARL Operations

resolve(): Promise<Resource>

Read resource from location.

Returns: Promise<Resource>

  • { content: string } for text semantic
  • { content: Buffer } for binary semantic

Throws: TransportError if operation fails

const resource = await arl.resolve();
console.log(resource.content);

deposit(data: string | Buffer): Promise<void>

Write resource to location.

Parameters:

  • data: string | Buffer - Content to write

Throws: TransportError if operation fails

await arl.deposit("Hello");
await arl.deposit(Buffer.from([1, 2, 3]));

exists(): Promise<boolean>

Check if resource exists.

Returns: Promise<boolean>

if (await arl.exists()) {
  console.log("Resource exists");
}

delete(): Promise<void>

Delete resource from location.

Throws: TransportError if operation fails

await arl.delete();

Semantic Handlers

Text Semantic (text)

Interprets content as UTF-8 text.

  • Input: string or Buffer
  • Output: string
const arl = arp.parse("arp:text:file://./file.txt");
await arl.deposit("Hello"); // string
const { content } = await arl.resolve(); // string

Binary Semantic (binary)

Interprets content as raw bytes.

  • Input: Buffer or string
  • Output: Buffer
const arl = arp.parse("arp:binary:file://./file.bin");
await arl.deposit(Buffer.from([1, 2, 3]));
const { content } = await arl.resolve(); // Buffer

Transport Handlers

File Transport (file)

Local filesystem operations.

// Absolute path
arp.parse("arp:text:file:///absolute/path/file.txt");

// Relative path
arp.parse("arp:text:file://./relative/path/file.txt");

// Home directory
arp.parse("arp:text:file://~/file.txt");

Operations:

  • ✅ resolve (read)
  • ✅ deposit (write)
  • ✅ exists
  • ✅ delete

HTTP/HTTPS Transport

Network resource operations (read-only).

arp.parse("arp:text:https://example.com/data.txt");
arp.parse("arp:binary:https://example.com/image.png");

Operations:

  • ✅ resolve (read)
  • ❌ deposit (not supported)
  • ❌ exists (not supported)
  • ❌ delete (not supported)

AgentVM Transport (agentvm)

AgentVM sandbox storage (~/.agentvm/).

arp.parse("arp:text:agentvm://sandbox/config.json");
// Maps to: ~/.agentvm/sandbox/config.json

Operations:

  • ✅ resolve (read)
  • ✅ deposit (write)
  • ✅ exists
  • ✅ delete

Error Handling

import { ParseError, TransportError, SemanticError } from "@resourcexjs/arp";

try {
  const arl = arp.parse("arp:invalid:url");
} catch (error) {
  if (error instanceof ParseError) {
    console.error("Invalid ARP URL");
  }
}

try {
  await arl.resolve();
} catch (error) {
  if (error instanceof TransportError) {
    console.error("Transport operation failed");
  }
}

Error Types

  • ParseError: Invalid ARP URL format
  • TransportError: Transport operation failed
  • SemanticError: Semantic handler error

Examples

Copy File

const source = arp.parse("arp:binary:file://./source.bin");
const dest = arp.parse("arp:binary:file://./dest.bin");

// Read from source
const { content } = await source.resolve();

// Write to destination
await dest.deposit(content);

Download and Save

// Download from URL
const remote = arp.parse("arp:text:https://example.com/data.txt");
const { content } = await remote.resolve();

// Save locally
const local = arp.parse("arp:text:file://./downloaded.txt");
await local.deposit(content);

Conditional Write

const arl = arp.parse("arp:text:file://./file.txt");

if (!(await arl.exists())) {
  await arl.deposit("New content");
}

Custom Handlers

Custom Transport

import type { TransportHandler } from "@resourcexjs/arp";

class S3Transport implements TransportHandler {
  protocol = "s3";

  async resolve(location: string) {
    // Fetch from S3
    const data = await s3.getObject({ Bucket: "...", Key: location });
    return data.Body;
  }

  async deposit(location: string, data: Buffer) {
    // Upload to S3
    await s3.putObject({ Bucket: "...", Key: location, Body: data });
  }

  // ... other methods
}

// Register
const arp = createARP();
arp.registerTransport(new S3Transport());

// Use
const arl = arp.parse("arp:binary:s3://my-bucket/file.bin");

Custom Semantic

import type { SemanticHandler } from "@resourcexjs/arp";

class JsonSemantic implements SemanticHandler {
  name = "json";

  async encode(data: unknown): Promise<Buffer> {
    const json = JSON.stringify(data, null, 2);
    return Buffer.from(json, "utf-8");
  }

  async decode(buffer: Buffer): Promise<unknown> {
    const text = buffer.toString("utf-8");
    return JSON.parse(text);
  }
}

// Register
arp.registerSemantic(new JsonSemantic());

// Use
const arl = arp.parse("arp:json:file://./data.json");
await arl.deposit({ key: "value" });
const { content } = await arl.resolve(); // parsed JSON

Architecture

┌──────────────────────────────────────┐
│             ARP                      │
└────────────┬─────────────────────────┘
             │
      ┌──────┴──────┐
      │   parse()   │
      └──────┬──────┘
             │
      ┌──────▼──────┐
      │    ARL      │ (Agent Resource Locator)
      └──────┬──────┘
             │
    ┌────────┴────────┐
    │                 │
┌───▼───┐      ┌──────▼──────┐
│Semantic│     │  Transport  │
│Handler │     │  Handler    │
└────────┘     └─────────────┘

License

MIT