Metadata-Version: 2.4
Name: fw-nodes-code
Version: 0.0.1a2
Summary: Code execution nodes for Flowire workflow automation
License-Expression: MIT
License-File: LICENSE
Requires-Python: >=3.13
Requires-Dist: flowire-sdk>=0.0.1a2
Requires-Dist: httpx>=0.26.0
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.4.0; extra == 'dev'
Description-Content-Type: text/markdown

# Flowire Code Nodes

[![PyPI version](https://img.shields.io/pypi/v/fw-nodes-code)](https://pypi.org/project/fw-nodes-code/)

Code execution node package for Flowire workflow automation.

This package is intentionally separate from `fw-nodes-core` so servers can opt into code execution support by installing this package.

## Installation

```bash
cd flowire-app/backend
uv pip install fw-nodes-code
```

Enable it in your `.env` file:

```bash
INSTALLED_NODE_PACKAGES=fw-nodes-core,fw-nodes-code
```

## Included Node

| Node | Description |
|------|-------------|
| `Code` | Execute JavaScript or Python code in an isolated sandbox |

The node supports a `runtime` input (default `latest`) so you can route
different versions to different sandbox services (for example `3.13`, `3.9`, `20`).

## Sandbox Services

This package includes the sandbox runtimes used by the Code node:

- `js-sandbox/` - JavaScript sandbox (isolated-vm + Fastify)
- `py-sandbox/` - Python sandbox (FastAPI + subprocess execution)

### Local sandbox commands

```bash
cd fw-nodes-code
just js-sandbox-install
just py-sandbox-install
just js-sandbox
just py-sandbox
```

## Environment Variables

- `CODE_NODE_SANDBOX_URL_MAP` - JSON object mapping runtime keys to sandbox URLs.

Example:

```bash
CODE_NODE_SANDBOX_URL_MAP='{
  "javascript@latest":"http://localhost:3100",
  "javascript@20":"http://localhost:3110",
  "python@latest":"http://localhost:3200",
  "python@3.13":"http://localhost:3213",
  "python@3.9":"http://localhost:3209"
}'
```

Runtime keys are resolved as:

1. `{language}@{runtime}` (for example `python@3.13`)
2. `{language}@latest`
3. (no fallback route; configuration must exist in the map)

If `CODE_NODE_SANDBOX_URL_MAP` is not set, defaults are used:

- `javascript@latest -> http://localhost:3100`
- `python@latest -> http://localhost:3200`

## Development

```bash
just install
just js-sandbox-install
just py-sandbox-install
just js-sandbox
just py-sandbox
just test
just lint
```
