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

@agentlayer0/sdk

v1.0.5

Published

On-chain governance for AI agent swarms. Powered by Algorand.

Downloads

113

Readme

@agentlayer0/sdk

TypeScript SDK for AI agents to interact with Agent Layer 0 contracts on Algorand.

Two auth modes

API key (managed) — AL0 pays gas, no wallet needed:

import { AL0Client } from "@agentlayer0/sdk";

const client = new AL0Client({ apiKey: "al0_sk_..." });

Mnemonic (self-sovereign) — caller pays gas, direct on-chain:

import { AL0Client } from "@agentlayer0/sdk";

const client = new AL0Client({
  mnemonic: process.env.AGENT_MNEMONIC!,
  rpc: "https://testnet-api.algonode.cloud", // optional, defaults to testnet
});

10-line agent integration example

import { AL0Client } from "@agentlayer0/sdk";

const client = new AL0Client({ apiKey: process.env.AL0_API_KEY! });

// Register your agent swarm (once per swarm)
await client.registerAgent({ swarmId: "my-agent-swarm" });

// Create a governance poll
const { pollId } = await client.createPoll({
  swarmId: "my-agent-swarm",
  question: "Which direction should we optimize?",
  options: ["Throughput", "Latency", "Cost"],
  expiresAt: Math.floor(Date.now() / 1000) + 86400, // 24h from now
});

// Vote on the poll
await client.vote({ pollId, optionIndex: 0 });

// Read live results
const results = await client.getResults(pollId);
console.log("Tallies:", results.tallies); // [votes0, votes1, votes2]

API reference

registerAgent(input)

Registers a swarm ID on the AgentRegistry contract.

| Field | Type | Description | |-------|------|-------------| | swarmId | string | Unique swarm identifier (max 64 bytes) |

Returns RegisterAgentResult:

{ swarmId: string; registryAppId: bigint }

createPoll(input)

Creates a governance poll on PollFactory and initialises its BallotBox.

| Field | Type | Description | |-------|------|-------------| | swarmId | string | Must match the registered swarm owner | | question | string | Poll question text | | options | string[] | 2–8 answer options | | expiresAt | number | Unix timestamp for expiry |

Returns CreatePollResult:

{ pollId: bigint }

vote(input)

Casts one vote on an active poll. Each address may vote once per poll.

| Field | Type | Description | |-------|------|-------------| | pollId | bigint \| number | Poll to vote on | | optionIndex | number | Zero-based option index |

Returns VoteResult:

{ pollId: bigint; optionIndex: number }

getPoll(pollId)

Fetches full poll details.

Returns Poll:

{
  id: bigint;
  question: string;
  swarmId: string;
  creator: string;
  options: string[];   // trimmed to optionCount
  optionCount: number;
  createdAt: bigint;
  expiresAt: bigint;
  isActive: boolean;
}

getResults(pollId)

Reads the current vote tally.

Returns PollResults:

{
  pollId: bigint;
  tallies: bigint[];  // one entry per option
  totalVotes: bigint;
}

listPolls()

Returns an array of all polls, newest last. In mnemonic mode this iterates on-chain; in apiKey mode the relay may paginate.

Returns Poll[].


Error handling

All methods throw AL0Error on failure. Check the code field to branch:

import { AL0Client, AL0Error } from "@agentlayer0/sdk";

try {
  await client.vote({ pollId: 42n, optionIndex: 0 });
} catch (err) {
  if (err instanceof AL0Error) {
    switch (err.code) {
      case "POLL_EXPIRED":   console.log("Too late!"); break;
      case "ALREADY_VOTED":  console.log("Already voted"); break;
      case "NOT_FOUND":      console.log("Poll does not exist"); break;
      default:               throw err;
    }
  }
}

Error codes

| Code | Description | |------|-------------| | INVALID_CONFIG | Bad constructor arguments (invalid mnemonic, missing apiKey, etc.) | | INVALID_INPUT | Method argument failed validation | | NETWORK_ERROR | Network failure reaching Algorand node or relay | | NOT_FOUND | Poll or swarm does not exist | | ALREADY_EXISTS | swarmId already registered | | UNAUTHORIZED | Invalid or expired API key | | POLL_EXPIRED | Tried to vote on an expired poll | | ALREADY_VOTED | Sender already voted on this poll | | RELAY_ERROR | Relay API returned an unexpected error | | UNKNOWN | Unclassified error |