Local Shell Command
在宿主机上执行 shell 命令。
通过运行 worker 的主机系统 shell 执行一条命令行,返回去除首尾空白后的 stdout 和 stderr。
工作原理
- 解析配置。
command、cwd和timeout(默认 10000 毫秒)缺失时回退到输入 payload 中的同名键。 command为空时从error失败输出。- 在 shell 中于
cwd(默认为编排器进程的工作目录)执行command,超过timeout毫秒后终止。 - 退出码为 0 时从
out输出去除首尾空白的{ stdout, stderr };非零退出、超时或启动失败时从error输出未处理的原始输出。
在工作流中
节点在工作流文件(draft_nodes[])中的写法,以及一次成功运行的 envelope。
{
"node_id": "node-list-exports",
"label": "List exports",
"operator_slug": "io.local.shell",
"operator_version": "1.0.0",
"config": {
"command": "ls /data/exports | grep orders",
"cwd": "/data",
"timeout": 10000
}
}{
"ok": true,
"data": {
"stdout": "orders-2026-11-25.csv\norders-2026-11-26.csv",
"stderr": ""
},
"port": "out"
}配置
-
commandstring 必填 -
要执行的命令
-
cwdstring 可选 -
当前工作目录
-
timeoutnumber 可选
代码中的行为
除 schema 描述之外,实现代码对这些键的实际处理。
-
command - 由 shell 解释执行:支持管道、重定向和
&&,通过表达式插入的值会成为命令行的一部分。如需将上游节点的数据作为参数传入,建议使用code.shell,它以参数列表运行程序,不经过 shell。
输出端口
out 默认 命令以退出码 0 结束。
数据
{
"stdout": "orders-2026-11-25.csv\norders-2026-11-26.csv",
"stderr": ""
}error 命令以非零码退出、超时、超出输出缓冲区或无法启动。数据为 { error, stderr, stdout };缺少 command 时仅为 { error }。
数据
{
"error": "Command failed: ls /data/missing\nls: /data/missing: No such file or directory\n",
"stderr": "ls: /data/missing: No such file or directory\n",
"stdout": ""
}在表达式中
后续节点可通过 $("Local Shell Command").item.json.<路径> 读取此节点输出中的内容(请把 Local Shell Command 换成你的节点标签)。Editor 标记工作流编辑器在 Previous Nodes 中提示的路径(输出契约);Worker 标记 worker 实际通过 out 返回的路径,依据“端口”一节所示的输出。
| 表达式 | Editor | Worker |
|---|---|---|
$("Local Shell Command").item.json.stdout | ||
$("Local Shell Command").item.json.stderr |
错误
| 消息 | 端口 | 原因与处理 |
|---|---|---|
command is required | error | 配置和输入 payload 中都没有命令。 |
Command failed: <command>
<stderr> | error | 命令以非零码退出,或在 timeout 毫秒后被终止。请查看 stderr 了解原因;对耗时较长的命令请调大 timeout。 |
stdout maxBuffer length exceeded | error | 命令向 stdout 或 stderr 写入了约 1 MB 以上的数据。请将大量输出写入文件,再用 io.local.file 读取。 |
输入契约
-
commandstring 必填 -
cwdstring 可选 -
timeoutnumber 可选
输出契约
-
stdoutstring 可选 -
stderrstring 可选
契约(JSON Schema)
与编排器声明完全一致的定义。All 是完整的 *.definition.js;可与上方各节对照,找出文档与 schema 之间的差异。发布前可用它校验节点。
{
"slug": "io.local.shell",
"name": "Local Shell Command",
"category": "io",
"version": "1.0.0",
"description": "Execute shell command on the host machine.",
"capabilities": [
"shell",
"local",
"terminal"
],
"config_schema": {
"type": "object",
"properties": {
"command": {
"type": "string",
"description": "Command to execute"
},
"cwd": {
"type": "string",
"description": "Current Working Directory"
},
"timeout": {
"type": "number",
"default": 10000
}
},
"required": [
"command"
]
},
"input_contract_schema": {
"type": "object",
"properties": {
"command": {
"type": "string"
},
"cwd": {
"type": "string"
},
"timeout": {
"type": "number"
}
},
"required": [
"command"
]
},
"output_contract_schema": {
"type": "object",
"properties": {
"stdout": {
"type": "string"
},
"stderr": {
"type": "string"
}
}
},
"ports": [
{
"port_id": "out",
"label": "Output",
"description": "Command executed successfully",
"is_default": true,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "Command returned non-zero exit code or failed",
"is_default": false,
"supports_condition": false
}
],
"execution_mode": "async",
"required_resources": [],
"compatible_worker_pools": [
"desktop-agent",
"local-agent"
],
"tags": [
"local",
"terminal"
],
"is_stateful": false,
"publisher": {
"identity": "org_link_loom",
"profile": {
"name": "Link Loom",
"verified": true,
"url": "https://me.veripass.com/link-loom",
"logo_url": null
}
}
}{
"type": "object",
"properties": {
"command": {
"type": "string",
"description": "Command to execute"
},
"cwd": {
"type": "string",
"description": "Current Working Directory"
},
"timeout": {
"type": "number",
"default": 10000
}
},
"required": [
"command"
]
}{
"type": "object",
"properties": {
"command": {
"type": "string"
},
"cwd": {
"type": "string"
},
"timeout": {
"type": "number"
}
},
"required": [
"command"
]
}{
"type": "object",
"properties": {
"stdout": {
"type": "string"
},
"stderr": {
"type": "string"
}
}
}[
{
"port_id": "out",
"label": "Output",
"description": "Command executed successfully",
"is_default": true,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "Command returned non-zero exit code or failed",
"is_default": false,
"supports_condition": false
}
]执行
- 执行方式
async- 有状态
- 否
- 能力
shelllocalterminal- 标签
localterminal
说明与限制
- 输出中不包含退出码;到达
out即表示退出码为 0。 - 命令在编排器 worker 所在的主机或容器上运行,使用该进程的用户和权限。
已对照编排器代码核实 · 31e874b · 2026-11-26