Getting started with Naylence for TypeScript
This quickstart mirrors the examples/simple/hello.ts
sample in the Naylence TypeScript examples repo and shows the minimum to spin up a fabric, serve an agent, and send it a message.
This single-process example runs agent and client in the same process. It’s meant to teach the core Agent SDK concepts without any distributed wiring (no sentinel, no fabric admission URLs, no Docker networking). It starts a local fabric, serves an agent, obtains a typed proxy, makes a call, and prints results.
Prerequisites
- Node.js 18+
npm(orpnpm) and a terminal
1) Install the SDK dependencies
npm init -y
npm install @naylence/agent-sdk tsx2) Create hello.ts
import { withFabric } from "@naylence/runtime";
import { BaseAgent } from "@naylence/agent-sdk";
class HelloAgent extends BaseAgent {
async onMessage(message: string) {
console.log(`Agent received message: ${message}`);
}
}
async function main(): Promise<void> {
await withFabric(async (fabric) => {
const agentAddress = await fabric.serve(new HelloAgent());
fabric.sendMessage(agentAddress, "Hello, World");
});
}
void main().catch((error) => {
console.error("hello example failed", error);
});3) Run it
npx tsx hello.tsExpected output:
Agent received message: Hello, WorldNext steps
- Run more single-process samples from the examples repo, like
echo-agent.ts(minimal echo),rpc-agent.ts(RPC + streaming), oragent-ping-pong.ts(agent-to-agent forwarding). Full list: https://github.com/naylence/naylence-examples-ts/tree/main/examples/simple - Explore simple LLM agent examples: https://github.com/naylence/naylence-examples-ts/tree/main/examples/llmÂ
Last updated on