WaQi
Tools

Execute Script

Write tool logic using JavaScript.

The execute script contains the logic that runs when a tool is invoked. The platform executes this script in a secure, isolated environment.

Structure

The script must export a default object containing an execute function. This function accepts a single argument containing the validated input, and it returns a Promise resolving to the result.

export default {
  async execute(input) {
    // Add your tool logic here
    return {
        message: `Hello, ${input.name}!`
    };
  }
}

Constraints

The isolated environment restricts access to the underlying operating system. It supports standard web APIs, such as fetch, but standard Node.js built-in modules are not available.

The function returns the result as a JSON object. If the script throws an error, the platform catches it and returns a formatted error message.

On this page