Quickstart

Install Harness, compose a small agent, and run one in-memory session.

Harness has one runtime dependency: Zod, which supplies typed tool schemas. Use Node 22.14 or newer.

npm install @nylorun/harness@beta zod

Build the agent

An agent starts with an identity, accepts named capabilities through .use(), binds exactly one model adapter with .with(), and becomes runnable after .build().

import { Agent, model, tool } from "@nylorun/harness";
import { z } from "zod";

const echo = tool({
  name: "echo",
  description: "Return the supplied text.",
  parameters: z.object({ text: z.string() }),
  async execute({ text }) {
    return { kind: "completed" as const, output: text };
  },
});

const adapter = model(async () => ({
  output: [{ type: "text" as const, text: "Hello from Harness." }],
  finishReason: "stop" as const,
}));

const agent = Agent({
  id: "hello",
  name: "Hello",
  instructions: "Reply briefly and clearly.",
})
  .use({ id: "echo", tools: [echo] })
  .with(adapter)
  .build();

model() and tool() preserve TypeScript inference while eagerly preparing their respective values. .with() is deliberately last: the returned bound builder exposes .build() but no more .use() calls.

Run a session

const session = agent.run({ userId: "user-42" });
const completion = await session.input("Say hello.").completed;

process.stdout.write(`${completion.status}\n`);
process.stdout.write(JSON.stringify(completion.events));

Harness keeps the session in memory. Connect a real provider with the Model guide, and make persistence or HTTP endpoints part of your host application.

Continue learning

On this page