Skip to content
nod
Menu

Embed nod

@anturno/nod/sdk runs an agent inside your application. It is the same TypeScript runtime the CLI uses, imported as a library and running in-process on Bun. You provide the interface, credentials, instructions, and tools.

Start with the examples for a readline chat, an HTTP route, or an embedded terminal.

Install

bun add github:anturno/nod

Run an agent

Create an Agent, send a prompt, and read the Turn as it produces text:

import { createAgent } from "@anturno/nod/sdk";

const agent = await createAgent({
  auth: { provider: "codex" },
});

try {
  const turn = agent.prompt("Explain closures in two sentences.");
  for await (const event of turn) {
    if (event.type === "text_delta") process.stdout.write(event.delta);
  }
  await turn.result;
} finally {
  await agent.close();
}

{ provider: "codex" } reuses the session saved by nod login codex in ~/.nod. Pass { provider, token } to supply a subscription token your application obtained itself.

One agent owns one conversation. Keep it open for follow-up prompts, or save a checkpoint before closing it.

Choose a guide

Embed the terminal

Embedding the nod terminal is a separate use case. The Terminal embedding guide covers createTerminal(), xterm.js, storage, login, and workspace adapters.

To launch the CLI or connect an editor instead, see the CLI reference or ACP guide.

Version compatibility

The SDK ships inside the @anturno/nod package and follows its version. sdkApiVersion, currently 1, identifies the API revision described on these pages; check it when your application must refuse an incompatible runtime. There is no separate npm package and no WebAssembly build: the SDK runs wherever Bun runs.


Browse all nod documentation

View this page as Markdown · llms.txt