Skip to main content

Global Bindings

Four objects are injected into every script's global scope before it runs: console for logging, response for returning the result, variables for reading inputs, and responseStream for streaming progress (streaming executions only). Everything else — api, llm, connector, tools, mathUtils, waitUtils — is a helper library covered in the helper pages.

console​

Captured logging. Nothing goes to a server console — every call is recorded into the execution's log list with a timestamp and level, in the format [yyyy-MM-dd HH:mm:ss.SSS] [LEVEL] message. All five methods accept any number of arguments of any type; arguments are stringified and joined with single spaces.

  • Name
    console.log
    Type
    (...args) => void
    Description

    Records a LOG-level entry.

  • Name
    console.info
    Type
    (...args) => void
    Description

    Records an INFO-level entry.

  • Name
    console.warn
    Type
    (...args) => void
    Description

    Records a WARN-level entry.

  • Name
    console.error
    Type
    (...args) => void
    Description

    Records an ERROR-level entry.

  • Name
    console.debug
    Type
    (...args) => void
    Description

    Records a DEBUG-level entry.

console.log("processing", 3, "items");
// -> [2026-07-01 14:02:11.482] [LOG] processing 3 items

Arguments are converted with plain string coercion, not JSON serialization — a JS object logs as an unhelpful opaque string. Log JSON.stringify(obj) when you want to see the contents.

response​

How your script returns its result. Calling response.setResponse(...) is required. If the script finishes without calling it, the execution's final response is empty: a script tool returns no result to the agent, and a computed column writes no value. There is no implicit "last expression" return.

  • Name
    response.setResponse
    Type
    (value: string | any) => void
    Description

    Sets the script's final output. Pass a string. Non-string values are coerced with string conversion — so for structured data, always pass JSON.stringify(obj) rather than the object itself. Calling it again replaces the previous value; the last call wins.

  • Name
    response.getFinalResponse
    Type
    () => string
    Description

    Returns the value set so far (or nothing if setResponse hasn't been called). Occasionally useful for append-style patterns.

const result = { status: "ok", count: 42 };
response.setResponse(JSON.stringify(result)); // correct
// response.setResponse(result); // wrong: coerced to a string, not JSON

variables​

Read-only access to the script's inputs. In a script tool this map contains every @@{name} argument the tool declares — the same placeholder mechanism all Autessa tools use — plus platform context values such as AUTESSA_COMPANY_ID, AUTESSA_TOOL_NAME, and AUTESSA_AGENT_NAME. A tool config containing @@{customerName} means your script reads variables.get("customerName").

  • Name
    variables.get
    Type
    (key: string) => string
    Description

    Returns the value for key, or null if absent. In tool executions every value is a string — parse numbers and JSON yourself. (In computed columns, values keep their native column types; see Computed columns.)

  • Name
    variables.has
    Type
    (key: string) => boolean
    Description

    Whether key is present.

  • Name
    variables.keys
    Type
    () => string[]
    Description

    All variable names. Iterable from JavaScript.

  • Name
    variables.size
    Type
    () => number
    Description

    Number of variables.

if (!variables.has("orderId")) {
response.setResponse(JSON.stringify({ error: "orderId is required" }));
} else {
const orderId = variables.get("orderId"); // string, e.g. "1042"
const qty = parseInt(variables.get("quantity")); // parse it yourself
console.log("keys:", Array.from(variables.keys()).join(", "));
// ... work ...
response.setResponse(JSON.stringify({ orderId, qty }));
}

variables is a method-based accessor, not a plain object — variables.orderId and variables["orderId"] do not work. Always go through variables.get("orderId").

responseStream​

Intermediate progress messages for streaming executions only — for example a script tool invoked inside a live agent conversation. Each message is emitted to the caller immediately, before the script finishes; the final result still comes from response.setResponse(...).

  • Name
    responseStream.addStreamMessage
    Type
    (message: string) => void
    Description

    Emits one streaming message tagged with the tool name and invocation id.

responseStream.addStreamMessage("Fetching orders...");
const orders = JSON.parse(api.get(JSON.stringify({ endpoint: url })));
responseStream.addStreamMessage("Fetched " + orders.length + " orders, summarizing...");

When the execution is not streaming, responseStream is not bound at all — referencing it throws ReferenceError: responseStream is not defined. That includes computed columns and non-streaming tool runs. Guard if your script must work in both modes:

if (typeof responseStream !== "undefined") {
responseStream.addStreamMessage("working...");
}