Skip to content

Agents can execute JavaScript code using Node.js in their sandboxed workspace. This is useful for working with JSON APIs, building quick prototypes, processing data with JavaScript libraries, and any task where JavaScript is the best fit.

What you can ask agents to do

  • "Fetch data from this REST API and format it as a table"
  • "Write a Node.js script to process this JSON file"
  • "Create a simple Express server that serves this data"
  • "Parse this HTML and extract all the links"
  • "Transform this data using lodash"

How it works

When an agent runs Node.js code:

  1. The code executes with node in the agent's workspace directory
  2. Standard output and errors are captured
  3. The result is returned to the agent for use in its response

Agents can install npm packages using the shell tool when needed:

  • "Install axios and then fetch data from this API"
  • "Use cheerio to scrape this webpage"

Sandbox

All Node.js code runs inside the agent's sandbox. The sandbox controls which files the agent can access, which network destinations it can reach, and how long scripts can run. You configure these restrictions per agent in the agent settings.

When to use Node.js vs. other tools

ScenarioBest tool
Working with JSON APIsNode.js
Async operations and promisesNode.js
Frontend prototypingNode.js
Data processing and analysisPython
CSV/XML file parsingPython
System commands (ls, curl, git)Shell

Tips

  • Specify Node.js if you have a preference. If you don't specify, the agent may choose Python for general scripting tasks. Say "Use Node.js to..." if you want JavaScript.
  • Agents can install packages. Just ask: "Install cheerio and parse this HTML."
  • Good for API work. Node.js shines when working with REST APIs, webhooks, and JSON data.

Next steps