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.
BaseAgent (one-shot) or BackgroundTaskAgent (long‑running/streaming) and focus on your logic.Task, Message, Artifact, and JSON‑RPC A2A operations.Agent.broadcast, Agent.runMany).Agent.remote* helpers.createAgentRouter) and /agent.json metadata endpoint.@naylence/advanced‑security add‑on.npm install @naylence/agent-sdk
Node.js 18+ is required.
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.
Agents & tasks
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).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
tasks/send, .../get, .../cancel, etc.) are provided for task lifecycle.FastAPI router
createAgentRouter(agent) to expose a JSON‑RPC endpoint (default: /fame/v1/jsonrpc) and GET /agent.json to return an AgentCard.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.
FameFabric.create() in tests or local scripts to host agents in‑process.The SDK includes TypeDoc configuration to generate Markdown-based API reference documentation. The output is compatible with Nextra and other Markdown-based documentation systems.
# Install dependencies (if not already done)
npm install
# Generate API documentation
npm run docs
This produces Markdown files in docs/reference/ts/_generated/.
| 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 |
Only the curated public API surface (exported from src/public-api.ts) is documented. Internal utilities and implementation details are excluded.
The SDK runs on the Naylence fabric's security profiles:
@naylence/advanced‑security package.See repo links below for the advanced add‑on and images that bundle it.
Docker images:
naylence/agent-sdk-nodenaylence/agent-sdk-adv-node (includes @naylence/advanced-security; BSL-licensed add-on)Content type
Image
Digest
sha256:64a83bb71…
Size
111 MB
Last updated
5 months ago
docker pull naylence/agent-sdk-node