Desktop Screenshot
截取桌面屏幕截图。
截取运行 worker 的机器屏幕,以 base64 data URI 返回,或保存为文件并返回路径。
工作原理
- 加载截图模块;若未安装,则从
error输出。 - 解析配置。
format(默认png)和filename缺失时回退到输入 payload 中的同名键。 - 设置了
filename时,将截图保存到该路径并返回{ path, timestamp }。 - 未设置
filename时,以{ image, base64, timestamp }返回内存中的图像:image为data:image/png或data:image/jpegURI,base64为不带前缀的 base64 字符串。
在工作流中
节点在工作流文件(draft_nodes[])中的写法,以及一次成功运行的 envelope。
{
"node_id": "node-capture-screen",
"label": "Capture screen",
"operator_slug": "io.desktop.screenshot",
"operator_version": "1.0.0",
"config": {
"format": "png"
}
}{
"ok": true,
"data": {
"image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...",
"base64": "iVBORw0KGgoAAAANSUhEUgAA...",
"timestamp": "2026-11-26T15:04:05.000Z"
},
"port": "out"
}配置
-
filenamestring 可选 -
可选,保存的文件名
-
formatstring 可选
代码中的行为
除 schema 描述之外,实现代码对这些键的实际处理。
-
filename - 将输出从内存图像切换为
{ path, timestamp }。路径位于运行 worker 的主机上。
输出端口
out 默认 已截取屏幕。输出结构取决于 filename(见运行步骤)。
数据
{
"image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...",
"base64": "iVBORw0KGgoAAAANSUhEUgAA...",
"timestamp": "2026-11-26T15:04:05.000Z"
}error 缺少截图模块,或截图失败。
数据
{
"error": "Module screenshot-desktop not available"
}在表达式中
后续节点可通过 $("Desktop Screenshot").item.json.<路径> 读取此节点输出中的内容(请把 Desktop Screenshot 换成你的节点标签)。Editor 标记工作流编辑器在 Previous Nodes 中提示的路径(输出契约);Worker 标记 worker 实际通过 out 返回的路径,依据“端口”一节所示的输出。
| 表达式 | Editor | Worker |
|---|---|---|
$("Desktop Screenshot").item.json.bufferBase64 或 buffer | — | |
$("Desktop Screenshot").item.json.path保存为文件时的路径 | — | |
$("Desktop Screenshot").item.json.image | — | |
$("Desktop Screenshot").item.json.base64 | — | |
$("Desktop Screenshot").item.json.timestamp | — |
— Editor: 编辑器会提示它,但 worker 并不返回:读取结果为 undefined。
— Worker: worker 会返回它,但编辑器不会提示:请手动输入。对象内部的键可能取决于你的数据或配置(例如每个标签一个键)。
错误
| 消息 | 端口 | 原因与处理 |
|---|---|---|
Module screenshot-desktop not available | error | 执行 worker 的运行环境未安装截图库。 |
<capture error message> | error | 主机没有可截取的显示器,或 filename 指定的路径不可写。 |
输入契约
-
filenamestring 可选 -
formatstring 可选
输出契约
-
bufferobject 可选 -
Base64 或 buffer
-
pathstring 可选 -
保存为文件时的路径
契约(JSON Schema)
与编排器声明完全一致的定义。All 是完整的 *.definition.js;可与上方各节对照,找出文档与 schema 之间的差异。发布前可用它校验节点。
{
"slug": "io.desktop.screenshot",
"name": "Desktop Screenshot",
"category": "io",
"version": "1.0.0",
"description": "Capture desktop screenshot.",
"capabilities": [
"desktop",
"screenshot",
"vision"
],
"config_schema": {
"type": "object",
"properties": {
"filename": {
"type": "string",
"description": "Optional filename to save"
},
"format": {
"type": "string",
"enum": [
"png",
"jpg"
],
"default": "png"
}
},
"required": []
},
"input_contract_schema": {
"type": "object",
"properties": {
"filename": {
"type": "string"
},
"format": {
"type": "string"
}
},
"required": []
},
"output_contract_schema": {
"type": "object",
"properties": {
"buffer": {
"type": "object",
"description": "Base64 or buffer"
},
"path": {
"type": "string",
"description": "Path if saved to file"
}
}
},
"ports": [
{
"port_id": "out",
"label": "Image Buffer",
"description": "Screenshot captured",
"is_default": true,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "Capture failed",
"is_default": false,
"supports_condition": false
}
],
"execution_mode": "async",
"required_resources": [],
"compatible_worker_pools": [
"desktop-agent"
],
"tags": [
"desktop",
"vision"
],
"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": {
"filename": {
"type": "string",
"description": "Optional filename to save"
},
"format": {
"type": "string",
"enum": [
"png",
"jpg"
],
"default": "png"
}
},
"required": []
}{
"type": "object",
"properties": {
"filename": {
"type": "string"
},
"format": {
"type": "string"
}
},
"required": []
}{
"type": "object",
"properties": {
"buffer": {
"type": "object",
"description": "Base64 or buffer"
},
"path": {
"type": "string",
"description": "Path if saved to file"
}
}
}[
{
"port_id": "out",
"label": "Image Buffer",
"description": "Screenshot captured",
"is_default": true,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "Capture failed",
"is_default": false,
"supports_condition": false
}
]执行
- 执行方式
async- 有状态
- 否
- 能力
desktopscreenshotvision- 标签
desktopvision
说明与限制
- 输出契约声明了
buffer,但 worker 从不返回该字段:请使用image或base64(未设置filename),或path(设置了filename)。 - 全屏截图的 base64 可能达数 MB,并会随运行状态传递;屏幕较大或截图较多时,建议使用
filename。
已对照编排器代码核实 · 31e874b · 2026-11-26