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

@naylence/agent-sdk

v0.4.10

Published

Naylence Agent SDK for TypeScript

Downloads

228

Readme

Join our Discord

Naylence Agent SDK (TypeScript)

The Naylence Agent SDK is the official toolkit for building agents and clients on the Naylence Agentic Fabric. It gives you a clean, typed, async-first API for composing tasks, streaming results, and wiring agents together—locally or across a distributed fabric.

If you're new to Naylence, start here. For lower‑level transport/fabric internals, see @naylence/runtime.


Highlights

  • Ergonomic agent model — subclass BaseAgent (one-shot) or BackgroundTaskAgent (long‑running/streaming) and focus on your logic.
  • Typed messages & tasks — Zod models for Task, Message, Artifact, and JSON‑RPC A2A operations.
  • Async all the way — non‑blocking lifecycle with easy scatter‑gather helpers (Agent.broadcast, Agent.runMany).
  • Remote proxies — call agents by address or capabilities via Agent.remote* helpers.
  • Streaming & cancellation — subscribe to live status/artifacts; cancel in‑flight work.
  • FastAPI integration — drop‐in JSON‑RPC router (createAgentRouter) and /agent.json metadata endpoint.
  • Security ready — works with runtime security profiles; strict‑overlay requires the @naylence/advanced‑security add‑on.

Install

npm install @naylence/agent-sdk

Node.js 18+ is required.


Quickstart (minimal)

import { withFabric } from '@naylence/runtime';
import { Agent, BaseAgent } from '@naylence/agent-sdk';

class EchoAgent extends BaseAgent {
  async runTask(payload) {
    return payload;
  }
}

async function main() {
  await withFabric(async (fabric) => {
    const agentAddress = await fabric.serve(new EchoAgent());
    console.log(`Agent is listening at address: ${agentAddress}`);
    const remoteAgent = Agent.remoteByAddress(agentAddress);
    const result = await remoteAgent.runTask('Hello, World!');
    console.log(result);
  });
}

main().catch((error) => {
  console.error('quickstart example failed', error);
  process.exitCode = 1;
});

For a gentle, runnable tour—from single‑process to distributed orchestration—use the Examples repo: https://github.com/naylence/naylence-examples-ts.


Core concepts

Agents & tasks

  • Implement runTask(payload, id) for simple one‑shot work, or override startTask(...)/getTaskStatus(...) for background jobs.
  • Message.parts carries either text (TextPart) or structured data (DataPart).
  • Long‑running flows stream TaskStatusUpdateEvent and TaskArtifactUpdateEvent until terminal (COMPLETED/FAILED/CANCELED).

Remote proxies

  • Agent.remoteByAddress("[email protected]") to call a known address.
  • Agent.remoteByCapabilities(["agent"]) to call by capability (fabric does resolution).

Streaming & cancel

  • subscribeToTaskUpdates(...) yields status/artifacts live.
  • cancelTask(...) requests cooperative cancellation when supported by the agent.

RPC operations

  • A2A JSON‑RPC methods (tasks/send, .../get, .../cancel, etc.) are provided for task lifecycle.
  • Custom functions can be exposed via the RPC mixin in the underlying fabric (e.g., streaming operations).

FastAPI router

  • Use createAgentRouter(agent) to expose a JSON‑RPC endpoint (default: /fame/v1/jsonrpc) and GET /agent.json to return an AgentCard.

Choosing an agent base class

  • BaseAgent — great for synchronous/short tasks; the default fallback packages your return value into a Task(COMPLETED).
  • BackgroundTaskAgent — best for long‑running/streaming work. You implement runBackgroundTask(...); the base manages queues, TTLs, and end‑of‑stream.

Both base classes include sensible defaults (poll‑based streaming, simple auth pass‑through). You can override any part of the lifecycle.


Development workflow

  • Add your agents in a project with the SDK.
  • Use FameFabric.create() in tests or local scripts to host agents in‑process.
  • For distributed setups, operate a sentinel/fabric with @naylence/runtime (or your infra) and connect agents remotely.
  • Use the Examples repo (https://github.com/naylence/naylence-examples-ts) to learn patterns like scatter‑gather, RPC streaming, cancellation, and security tiers.

Generating API Documentation

The SDK includes TypeDoc configuration to generate Markdown-based API reference documentation. The output is compatible with Nextra and other Markdown-based documentation systems.

Generate docs locally

# Install dependencies (if not already done)
npm install

# Generate API documentation
npm run docs

This produces Markdown files in docs/reference/ts/_generated/.

Available scripts

| Script | Description | |--------|-------------| | npm run docs | Clean and regenerate API documentation | | npm run docs:gen | Generate documentation (without cleaning first) | | npm run docs:clean | Remove generated documentation files |

Documentation scope

Only the curated public API surface (exported from src/public-api.ts) is documented. Internal utilities and implementation details are excluded.


Security notes

The SDK runs on the Naylence fabric's security profiles:

  • direct / gated / overlay modes work out‑of‑the‑box with the open‑source stack.
  • strict‑overlay (sealed overlay encryption + SPIFFE/X.509 identities) is available only with the @naylence/advanced‑security package.

See repo links below for the advanced add‑on and images that bundle it.


Links

Docker images:

  • OSS: naylence/agent-sdk-node
  • Advanced: naylence/agent-sdk-adv-node (includes @naylence/advanced-security; BSL-licensed add-on)

License & support

  • License: Apache‑2.0 (SDK).
  • Issues: please use the appropriate GitHub repo (SDK, Runtime, Examples, Advanced Security).