Skip to main content

Scripts

Use a Script for a calculation, transformation or procedure that ordinary actions do not express conveniently. A Script belongs to its workflow step. Its source, inputs and capabilities are saved and published with the workflow.

Configure a Scriptโ€‹

Add a Script step, define its input fields and author JavaScript exporting main(input, tools). It must return a JSON object, directly or through a Promise. Select only the tools and record access the code needs.

For example, define a required text input named request_name and use:

export function main(input) {
return { task_title: `Review: ${input.request_name}` };
}

Map the trigger's display name to request_name. A following Create Task can use output.task_title in its title. Ensure the resolved Task title fits its 255-character limit. This example needs no tools.

Tourfold analyzes the source to infer the output structure. Incomplete source can remain a draft with diagnostics, but publication requires a provable output contract. Analysis does not run the code. Runtime still checks actual output values, so successful analysis does not guarantee every input will execute successfully.

Publish with the workflowโ€‹

Publish the workflow to freeze the Script together with every other step. To change the code, edit a new workflow draft and publish it. Existing runs retain their original configuration. Copying a workflow or version copies its Script configuration independently.

A new inline Script can initialize mappings from its preceding step. Copied workflow versions retain their input contracts. Review input mappings whenever changing the surrounding graph.

Tools, limits and failuresโ€‹

Scripts can call explicitly permitted tools for reading, creating, updating and completing Tasks, record reads/updates/upserts, and Tour operations. Available tools expose their argument and output contracts. There is no general network, filesystem, credential or arbitrary module-import access.

Execution is bounded, including one second of guest CPU, 25 seconds of wall time and at most 16 permitted tool calls. Long-running work should not be placed in one Script; use workflow Wait steps for deliberate waits.

Run inspection shows accepted input/output, bounded logs, failures and committed effects. An interrupted Script is not automatically restarted from the beginning to recreate its in-memory state. Earlier committed effects remain if later code fails. Inspect them before deliberately starting another run.

Preview never executes Scripts. See the Script API reference for source, schema and tool details.