Node.js Quick Start

View as Markdown

This quick start shows the smallest Node.js workflow that emits scope, tool, and LLM events.

Choose an Install Path

Pick the installation path that matches whether you are using a published package or a local checkout.

Install from a Package Manager

Use this path when you want the published package for application development.

$npm install nemo-relay-node

Install from the Repository

Use this path when you are working from a local checkout and need editable source behavior.

$npm install --ignore-scripts
$npm run build --workspace=nemo-relay-node

This path is for local source development when you need to build the binding from the repository checkout.

Run One Scope, One Tool Call, and One LLM Call

The example below runs one minimal instrumented workflow through the binding.

1const {
2 ScopeType,
3 registerSubscriber,
4 deregisterSubscriber,
5 flushSubscribers,
6 LlmRequest,
7 withScope,
8 event,
9 toolCallExecute,
10 llmCallExecute,
11} = require("nemo-relay-node");
12
13async function main() {
14 registerSubscriber("quickstart-printer", (runtimeEvent) => {
15 console.log(`event=${runtimeEvent.kind} name=${runtimeEvent.name}`);
16 });
17
18 await withScope("demo-agent", ScopeType.Agent, async (handle) => {
19 event("initialized", handle, { binding: "node" }, null);
20
21 const toolResult = await toolCallExecute(
22 "search",
23 { query: "hello" },
24 (args) => ({ echo: args.query }),
25 handle,
26 null,
27 null,
28 null,
29 );
30
31 const llmResult = await llmCallExecute(
32 "demo-provider",
33 new LlmRequest({}, { messages: [{ role: "user", content: "hi" }] }),
34 (request) => ({ ok: true, messages: request.content.messages }),
35 handle,
36 null,
37 null,
38 null,
39 null,
40 );
41
42 console.log(toolResult);
43 console.log(llmResult);
44 });
45
46 flushSubscribers();
47 deregisterSubscriber("quickstart-printer");
48}
49
50main().catch((error) => {
51 console.error(error);
52 process.exitCode = 1;
53});

What Success Looks Like

You should see:

  • Event lines for the scope, tool, LLM, and mark lifecycle
  • { echo: 'hello' } from the tool call
  • An object containing ok: true and the echoed message payload from the LLM callback

That combination tells you both the business callbacks and the instrumentation pipeline are working.

Where the Node.js Surface Lives

These package entry points are the main Node.js APIs to use from applications and integrations.

  • Runtime lifecycle APIs are exported from the package root.
  • Typed wrappers live in nemo-relay-node/typed.
  • Plugin helpers live in nemo-relay-node/plugin.
  • Adaptive helpers live in nemo-relay-node/adaptive.

What to Learn Next

Use these links to continue from the quick start into the core runtime concepts.