Skip to content

Pipeline steps

YAML pipeline 会把每个 action 的输出传给下一步。Uni-CLI 当前有 113 个 built-in action。

其中 58 个属于 registered pipeline action。

另外 55 个属于 transport-native action。

基本结构

yaml
pipeline:
  - fetch:
      url: https://api.example.com/items
  - select: data.items
  - map:
      title: ${{ item.title }}
      url: ${{ item.url }}
  - limit: ${{ args.limit }}

HTTP 与内容

Action用途
fetch请求 JSON 或其他结构化 HTTP 响应
fetch_text请求原始文字或 HTML
parse_rss解析 RSS 或 Atom
html_to_md把 HTML 转为 Markdown
download保存远程文件
oauth2-token请求并存储 OAuth 2 token
websocket通过 WebSocket 交换消息
yaml
- fetch:
    url: https://api.example.com/search
    method: GET
    params:
      q: ${{ args.query }}
    headers:
      Accept: application/json

数据转换

Action用途
select从当前值中读取路径
select-xml从 XML 中选择数据
extract从 HTML 或 DOM 提取字段
map把 item 映射为新对象
filter保留匹配 item
sort排序列表
limit保留前 N 项
to_entries把 object 转为 key/value entries
split_text拆分文本
set保存命名值
append向列表追加值
assert验证结果条件
yaml
- map:
    title: ${{ item.title }}
    author: ${{ item.by }}
- filter: item.title && !item.deleted
- sort:
    by: score
    order: desc
- limit: 10

Control flow

Action用途
if条件匹配时运行分支
each为每个 item 运行 child pipeline
parallel并发运行独立分支
rate_limit控制一个域名或资源的节奏
wait等待时间或目标条件
yaml
- each:
    parallel: 4
    pipeline:
      - fetch:
          url: https://api.example.com/items/${{ item.id }}

浏览器

Action用途
navigate打开 URL
evaluate运行页面 JavaScript
click点击选中元素
type输入文字
press发送按键
scroll滚动页面
snapshot读取页面 snapshot 与 ref
tap激活 ref
intercept捕获匹配的 browser request
yaml
- navigate:
    url: https://example.com
- snapshot:
    interactive: true
- click:
    selector: "#sign-in"

本地与桌面 orchestration

Action用途
exec用 argv array 启动可执行程序
write_temp为后续 action 创建临时文件
compute_*通过 compute 路由 snapshot、input、screenshot、assertion 和 session action

常用 compute action 包括 compute_snapshotcompute_findcompute_clickcompute_typecompute_presscompute_scrollcompute_screenshotcompute_assertcompute_session_startcompute_session_statecompute_session_end

yaml
- exec:
    command: ffprobe
    args: ["-v", "quiet", "-print_format", "json", ${{ args.file }}]
    parse: json
    timeout: 30000

Registered actions

当前 registered action 名称:

text
append, assert, click, compute_apps, compute_assert, compute_cdp_attach,
compute_click, compute_drag, compute_evaluate, compute_find, compute_launch,
compute_observe, compute_point_click, compute_point_scroll, compute_press,
compute_screenshot, compute_scroll, compute_session_end,
compute_session_escalate, compute_session_start, compute_session_state,
compute_snapshot, compute_text, compute_type, compute_wait, compute_windows,
download, each, evaluate, exec, extract, fetch, fetch_text, filter,
html_to_md, if, intercept, limit, map, navigate, oauth2-token, parallel,
parse_rss, press, rate_limit, scroll, select, select-xml, set, snapshot,
sort, split_text, tap, to_entries, type, wait, websocket, write_temp

Transport-native actions

Transport adapter 还提供 macOS AX、Windows UIA、Linux AT-SPI、clipboard、application 与 visual action:

text
applescript, ax_*, uia_*, atspi_*, clipboard_read, clipboard_write,
focus_window, launch_app, visual_*

这些 action 通过选中的 transport provider 与 capability row 执行。src/engine/step-surface.ts 会从 step registry 和 transport handler table 推导完整列表。

模板

表达式
${{ args.name }}命令参数
${{ item.field }}当前 item 字段
${{ index }}当前列表 index
${{ env.NAME }}环境变量

Step schema 与实现在 src/engine/steps/ 中。修改 pipeline 后运行 npm run lint:adapters

基于 Apache-2.0 许可证发布