| name | workflow-node-code |
| description | Builds or updates frontend code-node data for deterministic Python or browser tasks. |
| allowed-tools | ["execute_node_skill_script","update_current_graph"] |
Workflow Code Node
Use type: code for deterministic processing, API integration, or browser automation.
Node Schema
build_node.data only contains business fields. Do not provide id, type,
position, or status; the script generates or fills them. New code node IDs
follow the frontend rule: code-<uuid> with a uniqueness suffix only if needed.
| Field | Type | Required | Meaning | Notes |
|---|
title | string | no | Display title | Defaults to 编码节点 |
description | string | no | Node description | |
inputs | array | no | Typed function inputs | Defaults to one input string |
outputs | array | no | Typed function outputs | Defaults to one code_result object |
config | object | no | Code execution settings | Defaults match frontend code node |
Each input/output item contains name, type, and optional description.
| Config field | Type | Required | Meaning |
|---|
codeLanguage | string | yes | Must be python |
codeCapability | string | yes | python or browser |
codeSource | string | yes | sandbox_file, sandbox_snippet, or inline |
codeFilePath | string | conditional | Required for sandbox_file |
codeEntryFunction | string | yes | Normally main |
outputKey | string | no | Primary declared output |
Input Variables
Inputs expose exactly two user-facing modes:
- Custom string:
{"field": "separator", "sourceType": "literal", "source": ",", "valueType": "String"}.
- Upstream reference:
{"field": "input", "sourceType": "node", "source": "start.input", "valueType": "String"}.
context is a legacy runtime source type, not a Skill input mode. Do not emit
it. The start-node input is referenced as a normal node output, such as
start.input.
Before building or changing any node-reference input, execute
list_input_sources. For a new node pass the IDs of its intended direct
predecessors from the confirmed topology. For an existing node pass node_id.
Only use an exact source returned by the script.
For a node mapping, copy the returned source type into both the input type
and mapping valueType. For a literal mapping, the input and valueType
must both be String.
Output Variables
Supported output types are:
String, Integer, Number, Boolean, Time, Object, Image, Video,
Array, Array<String>, Array<Integer>, Array<Number>,
Array<Boolean>, Array<Time>, Array<Object>, Array<Image>, and
Array<Video>.
Output names must be unique identifiers using letters, numbers, and
underscores, and must not start with a number.
The Python main return value is the node output object. Every declared output
must be returned under the same top-level key and with a compatible value:
async def main(args: Args) -> Output:
input_value = args.params["input"]
return {
"code_result": {"value": input_value},
"item_count": 1,
}
For this example, declare code_result: Object and item_count: Integer.
outputKey must be empty or exactly one declared output name. Do not declare
outputs that the code does not return.
Default code node generated by build_node:
{
"id": "code-<uuid>",
"title": "编码节点",
"type": "code",
"description": "在调试沙箱中执行 Python 代码,转换并返回结构化结果。",
"inputs": [
{
"name": "input",
"type": "String",
"description": "传入代码的上下文对象"
}
],
"outputs": [
{
"name": "code_result",
"type": "Object",
"description": "代码执行结果"
}
],
"config": {
"prompt":
Rules
- Python entry signature is
async def main(args: Args) -> Output:.
- Return an object whose keys match declared outputs.
- Never invent a
node mapping source. Use list_input_sources.
inputs and config.inputMappings must have one complete matching entry per
input field.
- Keep
outputKey aligned with a declared output (code_result by default).
- Browser capability and sandbox files require an available bound sandbox.
- Do not embed secrets in code or node config.
- Prefer LLM nodes for semantic generation and selector nodes for simple branching.
Scripts
list_input_sources
- Path:
workflow-node-code/scripts/node.py
- Entry:
list_input_sources
- Description: list valid upstream variables for input mappings.
- New-node arguments:
{"upstream_node_ids": ["intended-direct-predecessor-id"]}
- Existing-node arguments:
{"node_id": "existing-id"}
- Returns:
{"sources": [{"source": "node-id.field", "nodeTitle": "...", "field": "...", "type": "...", "description": "..."}], "allowed_source_values": [...]}
build_node
- Path:
workflow-node-code/scripts/node.py
- Entry:
build_node
- Description: build a complete new code node and generate
id and type.
- Arguments:
{"data": <Node Schema business fields>, "upstream_node_ids": ["direct-predecessor-id"]}
- Returns:
{"node": <complete node>}
update_node
- Path:
workflow-node-code/scripts/node.py
- Entry:
update_node
- Description: find the current code node by ID and apply changed fields.
- Arguments:
{"node_id": "existing-id", "changes": <changed fields>}
- Returns:
{"node": <complete updated node>}
Objects merge recursively; arrays replace the entire old array; scalars replace
directly; omitted fields stay unchanged. Submit complete arrays when changing
inputs, outputs, or config.inputMappings.