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

@lucid-dreams/client

v0.2.24

Published

@lucid/client — API + A2A Hub Client

Readme

@lucid/client — API + A2A Hub Client

Overview

  • Typed helpers and schemas for the server API.
  • Thin A2A hub client to interoperate with registered agents by agentRef.

A2A Hub Client

  • Import: import { A2AHubClient } from '@lucid/client'.
  • Construct with your API base URL and optional headers or API key.

Using x402-fetch for payments

  • Install: x402-fetch
  • Example: import { createSigner, wrapFetchWithPayment } from 'x402-fetch'; const signer = await createSigner('base-sepolia', process.env.PRIVATE_KEY!); const paidFetch = wrapFetchWithPayment(fetch, signer); const client = new A2AHubClient('http://localhost:8787', { fetch: paidFetch }); // Headers added by x402-fetch are forwarded by the hub to target agents

Paid client helper

  • Import: import { createPaidA2AHubClient } from '@lucid/client'.
  • Example: const client = await createPaidA2AHubClient({ hubUrl: 'http://localhost:8787', privateKey: process.env.PRIVATE_KEY!, network: process.env.PAYMENT_NETWORK || process.env.NETWORK || 'base-sepolia', }); // Same API as A2AHubClient await client.sendMessage({ agentRef: 'echo-agent', skillId: 'echo', input: { text: 'hi' } });

Examples

  • Get agent card: const client = new A2AHubClient('http://localhost:8787', { apiKey: process.env.API_KEY }); const card = await client.getCard('echo-agent');

  • Send a non-streaming task: const task = await client.sendMessage({ agentRef: 'echo-agent', skillId: 'echo', input: { text: 'hello' } }); // task.kind === 'task'; task.status.state in ['completed','failed','unknown']

  • Stream a task: const ac = new AbortController(); try { for await (const evt of client.sendMessageStream({ agentRef: 'echo-agent', skillId: 'echo', input: { text: 'stream me' }, signal: ac.signal })) { if (evt.kind === 'task') console.log('task opened', evt.id); else if (evt.kind === 'status-update') console.log('status', evt.status.state, evt.status.message?.parts?.[0]?.text); } } finally { ac.abort(); }

Notes

  • skillId is optional if the agent only advertises a single entrypoint.
  • Streaming yields a task first, then status-update events until a final update (final: true).
  • Errors in the stream are thrown by the iterator; wrap in try/catch.
  • Payments (x402): pass your x-402-* headers via the client constructor, e.g. new A2AHubClient(url, { headers: { 'x-402-token': '...', 'x-402-signature': '...' } }). The hub forwards these to the target agent.

Node paid demo

  • A runnable script is included at apps/examples/a2a/paid-demo.ts that:
    • Fetches an agent card via the hub
    • Sends an A2A RPC task (non-stream)
    • Invokes and streams via direct hub endpoints with x402 payments (headers auto-managed by x402-fetch)

Run (Bun):

HUB_URL=http://localhost:8787 \
AGENT_REF=echo-agent \
SKILL_ID=echo \
NETWORK=base-sepolia \
PRIVATE_KEY=0x... \
bun run apps/examples/a2a/paid-demo.ts

Notes:

  • For paid flows, ensure the target agent is configured with x402 (payee address, network, facilitator).
  • The demo prints x-payment-response when present; 402 challenges are handled by x402-fetch when using the direct endpoints.