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

@niuniu-ai/agentbox

v0.1.7

Published

TypeScript SDK for AgentBox private agent state and scoped sharing.

Readme

AgentBox JavaScript SDK

TypeScript SDK for AgentBox private agent state and scoped sharing.

Use the public production service at https://agentbox.niuniu.dev/ for Agent Card discovery and SDK integration. Discovery and package installation work without private repository access.

Install

npm install @niuniu-ai/agentbox

Production Auth

Creating boxes in production requires an OIDC identity token from a provider configured by AgentBox, such as Google. Pass that identity token as identityToken with the matching authScheme; when a recipient uses an AgentBox grant, keep the scoped grant token separate from the identity token.

First Private Box With Google OIDC

Get a Google ID token for the Google OAuth client configured by AgentBox production, then keep it outside source code:

export AGENTBOX_GOOGLE_ID_TOKEN='<google-id-token>'

The token must be a Google ID token, not an OAuth access token, and its aud claim must match the Google OAuth client trusted by AgentBox.

import { discoverAgentBox } from "@niuniu-ai/agentbox";

const service = await discoverAgentBox({
  baseUrl: "https://agentbox.niuniu.dev"
});

const agentbox = service.createClient({
  identityToken: process.env.AGENTBOX_GOOGLE_ID_TOKEN!,
  authScheme: "google"
});

await agentbox.registerAgent({
  display_name: "My First Agent",
  capabilities: ["notes"]
});

const created = await agentbox.createBox({
  name: "First private box"
});

const boxId = created.data.box.box_id;

await agentbox.putItem({
  box_id: boxId,
  key: "notes/hello",
  value: "Hello from an identity-bound private box.",
  expected_version: 0
});

const manifest = await agentbox.getManifest({
  box_id: boxId
});

console.log(manifest.data.items.map((item) => item.key));

The box is private to the verified Google identity. To let another identity read selected resources, create an AgentBox grant and pass that grant as grantToken while the recipient still authenticates with its own Google ID token.

Discovery And Workflow

import {
  bootstrapAgentBoxAgent,
  clientForGrant,
  createPrivateBoxWithResources,
  createScopedReadGrant
} from "@niuniu-ai/agentbox";

const { client: research } = await bootstrapAgentBoxAgent({
  baseUrl: "https://agentbox.niuniu.dev",
  client: {
    identityToken: process.env.RESEARCH_OIDC_JWT!,
    authScheme: "google"
  },
  registration: {
    display_name: "Research Agent",
    capabilities: ["research"]
  }
});

const workspace = await createPrivateBoxWithResources(research, {
  name: "Research handoff",
  items: [
    {
      key: "research/summary",
      value: "Only this summary is shared.",
      expected_version: 0
    },
    {
      key: "state/internal",
      value: "Private notes stay hidden.",
      expected_version: 0
    }
  ]
});

const grant = await createScopedReadGrant(research, {
  box_id: workspace.box.box_id,
  subject: "writer-agent",
  key_prefixes: ["research/"],
  ttl_seconds: 3600
});

const writer = clientForGrant(research, grant, {
  identityToken: process.env.WRITER_OIDC_JWT!,
  authScheme: "google"
});

const manifest = await writer.getManifest({
  box_id: workspace.box.box_id
});

Auth Modes

AgentBox clients authenticate with OIDC identity tokens. Grant clients can carry the AgentBox scoped grant separately with grantToken, or use clientForGrant(...) to derive a least-privilege client from a grant response. Pass authScheme for named providers such as google.

API Reference

Client options:

new AgentBoxClient({
  baseUrl: "https://agentbox.niuniu.dev",
  actor,
  token,
  identityToken,
  grantToken,
  authScheme,
  fetch
});

token and identityToken are mutually exclusive. Use actor with local or admin token auth. Use identityToken plus a named authScheme, such as google, for production OIDC auth. Keep AgentBox scoped grants separate as grantToken.

Discovery and workflow helpers:

discoverAgentBox({ baseUrl | agentCardUrl })
bootstrapAgentBoxAgent(input)
createPrivateBoxWithResources(client, input)
createScopedReadGrant(client, input)
clientForGrant(client, grant, input?)

Client methods:

health()
registerAgent(input?)
getAgentProfile()
listAgents({ admin: true })
updateAgentStatus({ identity_key, status }, { admin: true })
createBox({ name, ttl_seconds?, metadata? })
listBoxes()
getManifest({ box_id })
putItem({ box_id, key, value, content_type?, tags?, expected_version? })
getItem({ box_id, key, version? })
listItems({ box_id, prefix?, tags?, content_type? })
appendEvent({ box_id, stream, type, payload? })
listEvents({ box_id, stream, after_seq?, limit? })
attachArtifact({ box_id, name, content_type, content_base64 })
listArtifacts({ box_id })
getArtifact({ box_id, artifact_id })
createGrant({ box_id, subject, permissions, ttl_seconds, key_prefixes?, event_streams?, artifact_prefixes? })
listGrants({ box_id })
revokeGrant({ box_id, grant_id })
listAudit({ box_id })
withAuth({ actor?, token?, identityToken?, grantToken?, authScheme? })

Methods return the AgentBox response envelope:

{ "ok": true, "data": {}, "error": null, "audit_id": "aud_..." }

Non-2xx responses and AgentBox { "ok": false } responses throw AgentBoxApiError with code, status, target, request_id, and audit_id.

Pilot Network Usage

Native Pilot identity is provided by a Pilot-aware runtime or the AgentBox Pilot adapter before requests reach AgentBox. SDK application code should keep using normal box, item, artifact, grant, manifest, and audit methods. Do not set authScheme: "pilot" or handcraft Pilot authentication headers in agent code; that path is for the AgentBox adapter/runtime boundary. If a Pilot caller uses an AgentBox grant, pass it as grantToken.

License

MIT