本页内容
Sommatic 文档
打开控制台

Execution Context

当前运行、正在执行的工作流与节点的 id,以及环境。

以 Markdown 查看
在以下应用中打开

每个示例都在已部署的表达式引擎上、基于页面末尾的示例上下文运行过。

$execution

$execution

运行的身份标识。在消息、任务和日志中写入 $execution.id,任何人都能据此把一个案例追溯到对应的运行。当运行由 workflow.chain 启动时,id 是根运行的 id,因此链中所有工作流共用这个值;run_flow_instance_result_id 则保留本次运行自身的 id。

成员

签名 类型 说明
$execution.id string 运行的主 id:链的根运行的结果 id;没有链时为本次运行的结果 id。
$execution.flow_instance_result_id string | null 主结果 id(与 id 的值相同)。
$execution.root_flow_instance_result_id string | null 链的根运行的结果 id。
$execution.run_flow_instance_result_id string | null 本次运行的结果 id,在链中同样适用。
$execution.flow_instance_id string | null 流程实例的 id。
$execution.flow_definition_id string | null 工作流定义的 id。
$execution.flow_version_id string | null 正在运行的已发布版本的 id。
$execution.flow_slug string | null 工作流的 slug。
$execution.mode 保留 string 保留:用于区分测试运行与生产运行;目前始终为 'manual'。
$execution.resumeUrl 保留 undefined 保留:用于恢复已暂停的运行;目前始终为 undefined。
$execution.customData 保留 object 保留:始终为 {}。

示例

Case received. Reference: {{ $execution.id }}
结果 string
"Case received. Reference: fir-xxxx"
{{ ({ run: $execution.id, workflow: $execution.flow_slug, version: $execution.flow_version_id }) }}
结果 object
{"run":"fir-xxxx","workflow":"order-intake","version":"fv-xxxx"}

保留成员:每次运行的值都相同。

{{ $execution.mode }}
结果 string
"manual"

说明

  • 本次运行不具备的字段为 null。id 是不透明文本:只做比较,切勿解析。
  • 节点自身的 execution 配置字段(其重试设置)与 $execution 无关。

在 JSONata 中 $$execution.id

$workflow

$workflow

正在执行的工作流。请使用 slug 和 version;id、name 和 active 为保留成员,目前保存固定值(如需定义的 id,请读取 $execution.flow_definition_id)。

成员

签名 类型 说明
$workflow.slug string | null 工作流的 slug。
$workflow.version string | null 标识正在运行的版本(目前为已发布版本的 id)。请将其视为不透明值,而非数字。
$workflow.id 保留 string 保留:目前始终为 'unknown'。请使用 $execution.flow_definition_id。
$workflow.name 保留 string 保留:目前始终为 'Untitled'。
$workflow.active 保留 boolean 保留:目前始终为 false。

示例

{{ $workflow.slug + '@' + $workflow.version }}
结果 string
"order-intake@fv-xxxx"

完整对象,包括保留成员。

{{ $workflow }}
结果 object
{
  "id": "unknown",
  "name": "Untitled",
  "active": false,
  "slug": "order-intake",
  "version": "fv-xxxx"
}

在 JSONata 中 $$workflow.slug

$node

$node

正在执行的节点的元数据。它不能用来读取其他节点;如需读取,请使用 $('Node label')。

成员

签名 类型 说明
$node.id string 节点的 node_id。
$node.label string | null 节点的标签,与画布上显示的一致。
$node.name string | null 与 label 的值相同。

示例

Created by {{ $node.label }} in {{ $workflow.slug }}
结果 string
"Created by Notify customer in order-intake"
{{ $node.id }}
结果 string
"node-notify"

在 JSONata 中 $$node.label

$env

保留. 引擎尚未填充它:目前始终为 {}。

$env

用于存放为工作流运行所在环境声明的变量。引擎目前尚未填充它:它始终是空对象,并且绝不会暴露服务自身的环境。请通过触发器输入或 Git Sync 环境传递特定于环境的值,通过绑定到节点的凭据传递机密。

示例

{{ $env }}
结果 object
{}

在它为空时,默认值可让表达式照常工作。

{{ $ifEmpty($env.API_BASE_URL, 'https://api.example.com') }}
结果 string
"https://api.example.com"

在 JSONata 中 $$env

$vars

保留. 不会被填充:目前始终为 {}。

$vars

为工作流变量保留。它始终是空对象。切勿把机密放进变量:请改为给节点绑定凭据。

示例

{{ $vars }}
结果 object
{}

在 JSONata 中 $$vars

$nodeVersion

保留. 目前始终为 1。

$nodeVersion

用于表示执行当前节点的算子的版本。无论节点的 operator_version 是什么,它始终为 1。算子版本是工作流文件中节点定义的一部分。

示例

{{ $nodeVersion }}
结果 number
1

在 JSONata 中 $$nodeVersion

示例上下文

示例基于以下数据运行:当前节点的输入($json)、已运行的节点($(…))、本次运行的 ID 以及当前节点。时钟固定为 2026-11-26T14:30:00.000Z,服务器时区为 UTC,因此各页面中 $now 与 $today 的值都相同。

当前节点的输入 JSON
{
  "$json": {
    "body": {
      "order_id": "ord_1042",
      "email": "[email protected]",
      "customer": {
        "name": "Ana Pérez",
        "segment": "gold"
      },
      "priority": "",
      "items": [
        {
          "sku": "A-100",
          "qty": 2,
          "price": 10.5
        },
        {
          "sku": "B-200",
          "qty": 0,
          "price": 4
        },
        {
          "sku": "C-300",
          "qty": 1,
          "price": 25
        }
      ],
      "tags": [
        "new",
        "web",
        "new"
      ],
      "created_at": "2026-11-25T09:15:00Z"
    },
    "headers": {
      "content-type": "application/json"
    },
    "query": {},
    "method": "POST"
  }
}
已运行的节点(标签 → 输出) JSON
{
  "Webhook Receiver": "= $json",
  "Normalize input": {
    "correlation_id": "c-7f3a",
    "channel": "web"
  },
  "Classify": {
    "label": "billing",
    "confidence": 0.92
  }
}
运行与当前节点 JSON
{
  "$execution": {
    "id": "fir-xxxx",
    "flow_instance_id": "fi-xxxx",
    "flow_definition_id": "fd-xxxx",
    "flow_version_id": "fv-xxxx",
    "flow_slug": "order-intake"
  },
  "$node": {
    "id": "node-notify",
    "label": "Notify customer"
  }
}

示例运行所基于的编排器提交 31e874b

安装智能体工具

为你的编程智能体接入 Sommatic AI 官方文档:技能包、文档 MCP 服务器与 Markdown 页面,无需再抓取网页。

仅安装技能包,不会自动更新;需要时重新运行即可。

npx skills add https://docs.sommatic.ai
智能体如何读取本文档