# Author custom executors

Wrap trusted JavaScript/TypeScript bodies while retaining exact executor pins and the original timeout boundary.

Canonical URL: https://opennodeflow.dev/wiki/custom-executors/
JSON reference: https://opennodeflow.dev/wiki/custom-executors/index.json
Source snapshot: 2026-10-23

An executor is a reusable JavaScript/TypeScript adapter around another node or trigger's code body. It can instrument execution, transform arguments/results or apply an agreed code policy. It is selected by a published definition, rather than inserted as a standalone canvas operation.

## Wrapper contract

The executor wrapper receives the original `code`, resolved `inputs`, graph `config`, runtime `context`, and an `execute` function. A minimal wrapper delegates once:

```ts
const started = Date.now();
try {
  return await execute(code, inputs, config, context);
} finally {
  console.log('Attempt elapsed ms', Date.now() - started);
}
```

`execute(code, inputs, config, context)` transpiles and runs the original body and returns its output object. Preserve the intended output keys and selected routes. A wrapper that returns a differently shaped value can fail the consuming node's declared output contract.

The attempt timeout covers the wrapper and original code together. Time spent in instrumentation or preprocessing is not a separate unlimited budget. Logging also shares ordinary truncation and secret-redaction behavior.

## Choose an executor deliberately

Publish the Executor asset, choose it in the node/trigger definition editor and publish that consuming asset. The selected executor version is pinned into the new definition. Existing consumers retain their earlier executor pin even when a wrapper update is published.

An instance's inspector shows the executor chosen by its pinned definition. It is not a free-form per-instance executor dropdown. To change the wrapper, publish a new consuming definition with the desired executor dependency, then deliberately upgrade the relevant graph instance.

## Useful designs

Keep wrappers small and explicit. Timing a body, adding a consistent diagnostic label, checking an agreed precondition or normalising an internal envelope can be reasonable. Document which inputs/configuration are transformed, whether the body may be skipped, and what errors propagate.

Do not add hidden retries around effectful code. The engine already has an explicit node retry policy, and two retry layers can multiply external calls. A wrapper also cannot atomically roll back an API request, file write or immediately committed storage/variable mutation.

## Trust and runtime limits

Executor code runs as trusted code with the hosting user's permissions. It is not a hostile-code sandbox, container, remote agent or privilege boundary. Choosing a wrapper does not isolate files, network access, installed packages or credentials.

JavaScript executor adapters do not wrap native Python or PowerShell bodies. Those execute through their own runtime support and host executable requirements. Bash, per-asset managed package installation and distributed worker providers are not implied by this feature.

## Testing and adoption

The executor test bench runs a sample body through the wrapper. It executes real code; it does not provide declared-socket output/route validation for a consuming node or the workflow engine's retry behavior. Follow with a small synthetic workflow to verify the final node contract and error handling.

Write versioned documentation for wrapper behavior, runtime assumptions, possible effects and failure handling. Use [versioning](/wiki/versioning/) to adopt a new wrapper safely, and [debugging](/wiki/debugging/) to inspect its accepted execution.

---

## Documentation provenance

- `docs/AUTHORING.md`
- `docs/TYPES-AND-VERSIONING.md`
- `docs/RUNTIMES-AND-WORKERS.md`

This page describes maintained source, not a live inventory or an authorization to perform actions.
