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

fetch 接收 JSON,fetch_text 接收有大小限制的文本。两者共用重定向验证、响应分类和重试调度。retry 表示总尝试次数。上游 Retry-After 以秒数或 HTTP 日期设定最短等待时间,调用方取消会结束等待。读取成功响应时发生中断,会使用剩余尝试次数重试。写入已被接受后发生响应中断,会返回 operation_outcome_ambiguous,调用方需要先核对资源当前状态。

cache 是 GET 请求的新鲜度上限,单位为秒。请求头用于区分内容表示和凭据,响应中的 max-age 和 Age 进一步限制有效期。no-store、no-cache、private 和 Vary: * 禁用复用,文件写入采用原子替换。cache: 0 跳过已有缓存。

数据转换 ​

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_snapshot、compute_find、compute_click、compute_type、compute_press、compute_scroll、compute_screenshot、compute_assert、compute_session_start、compute_session_state 和 compute_session_end。

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

Registered actions ​

以下列出已注册的动作名称。

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 ​

传输适配器还提供 macOS AX、Windows UIA、Linux AT-SPI,以及剪贴板、应用和视觉操作,名称如下。

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

这些动作通过选中的传输提供方及其能力记录执行。src/engine/step-surface.ts 从步骤注册表和传输处理器表生成完整列表。

模板 ​

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

步骤 Schema 和实现在 src/engine/steps/ 中。修改流水线后,运行 npm run lint:adapters。

基于 Apache-2.0 许可证发布