From 902242006432b859f1e38559737000ca607eb7f4 Mon Sep 17 00:00:00 2001 From: Zhongxuan Wang Date: Sun, 31 May 2026 16:46:18 -0700 Subject: [PATCH] docs: fix Node.js quickstart scope handle and LLM request usage The Node.js quick start and the nemo-relay-node package README passed the informational handle from `withScope` straight into `event`, `toolCallExecute`, and `llmCallExecute`. Those APIs expect either `null` (the current scope) or a real `ScopeHandle`, so the plain handle object failed with "Failed to recover `ScopeHandle` type from napi value" on the first call. The rejected promise then skipped `deregisterSubscriber`, leaving the subscriber's ThreadsafeFunction ref'd and hanging the process. The LLM example also built the request with `new LlmRequest(...)`, but `llmCallExecute` takes a plain `{ headers, content }` JSON object. Update both examples to pass `null` for the active scope and a plain request object, matching the behavior covered by the Node binding tests. Signed-off-by: Zhongxuan Wang --- crates/node/README.md | 3 ++- docs/getting-started/quick-start/nodejs.mdx | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/node/README.md b/crates/node/README.md index 319154b3..e0e9497b 100644 --- a/crates/node/README.md +++ b/crates/node/README.md @@ -77,7 +77,8 @@ async function main() { }); await withScope("demo-agent", ScopeType.Agent, async (handle) => { - event("initialized", handle, { binding: "node" }, null); + // `handle` describes the active scope; pass null to target the current scope. + event("initialized", null, { binding: "node" }, null); }); deregisterSubscriber("printer"); diff --git a/docs/getting-started/quick-start/nodejs.mdx b/docs/getting-started/quick-start/nodejs.mdx index 7807d164..66327574 100644 --- a/docs/getting-started/quick-start/nodejs.mdx +++ b/docs/getting-started/quick-start/nodejs.mdx @@ -44,7 +44,6 @@ const { registerSubscriber, deregisterSubscriber, flushSubscribers, - LlmRequest, withScope, event, toolCallExecute, @@ -57,13 +56,15 @@ async function main() { }); await withScope("demo-agent", ScopeType.Agent, async (handle) => { - event("initialized", handle, { binding: "node" }, null); + // `handle` describes the active scope (handle.uuid, handle.name, handle.scopeType). + // For lifecycle calls inside the scope, pass null to target the current scope. + event("initialized", null, { binding: "node" }, null); const toolResult = await toolCallExecute( "search", { query: "hello" }, (args) => ({ echo: args.query }), - handle, + null, null, null, null, @@ -71,9 +72,9 @@ async function main() { const llmResult = await llmCallExecute( "demo-provider", - new LlmRequest({}, { messages: [{ role: "user", content: "hi" }] }), + { headers: {}, content: { messages: [{ role: "user", content: "hi" }] } }, (request) => ({ ok: true, messages: request.content.messages }), - handle, + null, null, null, null,