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

Handoff to Sommatic App

终止节点:将已完成工作流的结果移交给某个 Sommatic AI App。它会创建一个携带打开描述符的持久化 HITL 任务;若有活动的 Command Center 会话订阅,则立即打开该应用。它是 sommatic.app.execute(应用作为关卡)的对称形态;此节点是应用作为终点:工作流就此结束,不会恢复。

以 Markdown 查看
在以下应用中打开
人工介入 可用 sommatic.app.handoff 版本 1.0.0 执行方式: sync

终止交接:为用户创建携带应用打开描述符(应用 slug、路由、输入、启动模式)的任务,并返回该描述符,以便运行结果可打开应用。

工作原理

  1. 解析配置并合并到输入 payload 之上(配置优先);input_mapping 中的 {{ }} 在服务器端解析。
  2. 构建描述符:app_slug 取 target.app_slug,route_path 取 target.route(默认 /),launch_mode 取 target.launch_mode(默认 command-center),input_payload 取 input_mapping(默认 {})。
  3. 检查 app_slug、organization_id、assignee 和 task_title。
  4. 提交一个任务:用户负责人、状态 queued、source 为 workflow,并带 metadata.app_handoff_descriptor;后端会为该用户认领。task_type 默认 review,task_priority 默认 medium。
  5. 通过 out 在顶层返回 { app_handoff_descriptor, task_id, task_title },运行结果可从中获取描述符;之后打开该任务会重新启动预填数据的应用。

在工作流中

节点在工作流文件(draft_nodes[])中的写法,以及一次成功运行的 envelope。

{
  "node_id": "node-handoff-approval",
  "label": "Hand off to approval desk",
  "operator_slug": "sommatic.app.handoff",
  "operator_version": "1.0.0",
  "config": {
    "target": {
      "app_slug": "sommatic-approval-desk",
      "route": "/",
      "launch_mode": "command-center"
    },
    "input_mapping": {
      "order_id": "{{ $json.order_id }}",
      "amount": "{{ $json.amount }}"
    },
    "organization_id": "<organization_id>",
    "assignee": "approver@example.com",
    "task_title": "Approve order {{ $json.order_id }}"
  }
}

配置

target object 必填
app_slug string 必填

要移交的 Sommatic AI App 的 slug(例如 my-review-app)。

route string 可选

在应用内打开的路由(例如 /new-sentence)。默认为 /。

默认值: /

launch_mode string 可选

存在活动会话时应用的打开方式。

默认值: command-center

input_mapping object 可选

预填入应用的载荷,由服务端根据 {{...}} 表达式解析。

organization_id string 必填

拥有所创建任务的组织。

assignee string 必填

任务分配给的身份(邮箱)。

task_title string 必填

为此次移交创建的持久化 HITL 任务的标题。

task_type object 可选

任务类型描述符。默认为 review。

task_priority object 可选

任务优先级描述符。默认为 medium。

配置中会显示通用执行设置,但该节点目前不执行重试(retryOnFail、maxTries)。所有节点均未实现 continueOnFail。

代码中的行为

除 schema 描述之外,实现代码对这些键的实际处理。

task_type
默认对象为 { id: 1, name: "review", title: "Review" },而后端目录中 review 的 id 是 12。若收件箱按 id 过滤,请显式设置 task_type。
target
也会读取未声明的顶层备选键:app_slug、route、launch_mode、input_payload、title、type 和 priority。

输出端口

out 默认

任务已创建。运行应在此结束;不会挂起。

数据
{
  "port": "out",
  "app_handoff_descriptor": {
    "app_slug": "sommatic-approval-desk",
    "route_path": "/",
    "input_payload": {
      "order_id": "ord_123",
      "amount": 1250
    },
    "launch_mode": "command-center"
  },
  "task_id": "task-xxxxxxxxxxxxxxx",
  "task_title": "Approve order ord_123"
}
error

缺少必填字段或后端调用失败。

数据
{
  "port": "error",
  "error": "Missing 'assignee'"
}

在表达式中

后续节点可通过 $("Handoff to Sommatic App").item.json.<路径> 读取此节点输出中的内容(请把 Handoff to Sommatic App 换成你的节点标签)。Editor 标记工作流编辑器在 Previous Nodes 中提示的路径(输出契约);Worker 标记 worker 实际通过 out 返回的路径,依据“端口”一节所示的输出。

表达式EditorWorker
$("Handoff to Sommatic App").item.json.app_handoff_descriptorobject= {…}
$("Handoff to Sommatic App").item.json.task_idstring= "task-xxxxxxxxxxxxxxx"
$("Handoff to Sommatic App").item.json.task_titlestring= "Approve order ord_123"
$("Handoff to Sommatic App").item.json.portstring编辑器不提示= "out"—
$("Handoff to Sommatic App").item.json.app_handoff_descriptor.app_slugstring编辑器不提示= "sommatic-approval-desk"—
$("Handoff to Sommatic App").item.json.app_handoff_descriptor.route_pathstring编辑器不提示= "/"—
$("Handoff to Sommatic App").item.json.app_handoff_descriptor.input_payloadobject编辑器不提示= {…}—
$("Handoff to Sommatic App").item.json.app_handoff_descriptor.launch_modestring编辑器不提示= "command-center"—

— Worker: worker 会返回它,但编辑器不会提示:请手动输入。对象内部的键可能取决于你的数据或配置(例如每个标签一个键)。

错误

消息 端口 原因与处理
Missing 'target.app_slug' error 没有 target.app_slug(顶层也没有 app_slug)。
Missing 'organization_id' error 配置和 payload 中都没有。
Missing 'assignee' error 交接始终需要用户身份(邮箱)。
Missing 'task_title' error task_title(或 title)为空。
Backend did not return a task id error 后端响应中没有 result.id。
Request failed with status code <status> error 后端拒绝了该任务。
services.apiManager.uri is not resolved in dependencies.config — check Link Loom Cloud environment config. error 编排器未配置后端地址。这是服务配置问题,与节点无关。

输入契约

target object 可选
input_mapping object 可选
organization_id string 可选
assignee string 可选
task_title string 可选

输出契约

app_handoff_descriptor object 可选
task_id string 可选
task_title string 可选

契约(JSON Schema)

与编排器声明完全一致的定义。All 是完整的 *.definition.js;可与上方各节对照,找出文档与 schema 之间的差异。发布前可用它校验节点。

{
  "slug": "sommatic.app.handoff",
  "name": "Handoff to Sommatic App",
  "category": "hitl",
  "version": "1.0.0",
  "description": "Terminal node: hands a finished workflow's result to a Sommatic AI App. Creates a durable HITL Task carrying the open descriptor and, if a live Command Center session is subscribed, opens the app instantly. Symmetric counterpart of sommatic.app.execute (app-as-gate); this is app-as-terminal — the workflow ends and does not resume.",
  "capabilities": [
    "ui",
    "human",
    "terminal"
  ],
  "config_schema": {
    "type": "object",
    "required": [
      "target",
      "organization_id",
      "assignee",
      "task_title"
    ],
    "properties": {
      "target": {
        "type": "object",
        "title": "Target App",
        "required": [
          "app_slug"
        ],
        "properties": {
          "app_slug": {
            "type": "string",
            "title": "App Slug",
            "description": "Slug of the Sommatic AI App to hand off to (e.g. my-review-app)."
          },
          "route": {
            "type": "string",
            "title": "Route Path",
            "description": "Route opened inside the app (e.g. /new-sentence). Defaults to /.",
            "default": "/"
          },
          "launch_mode": {
            "type": "string",
            "title": "Launch Mode",
            "description": "How the app is opened when a live session exists.",
            "default": "command-center"
          }
        }
      },
      "input_mapping": {
        "type": "object",
        "title": "Input Payload",
        "description": "Payload pre-filled into the app, resolved server-side from {{...}} expressions."
      },
      "organization_id": {
        "type": "string",
        "title": "Organization",
        "description": "Organization that owns the created Task."
      },
      "assignee": {
        "type": "string",
        "title": "Assignee",
        "ui_widget": "user_picker",
        "description": "Identity (email) the Task is assigned to."
      },
      "task_title": {
        "type": "string",
        "title": "Task Title",
        "description": "Title of the durable HITL Task created for the handoff."
      },
      "task_type": {
        "type": "object",
        "title": "Task Type",
        "description": "Task type descriptor. Defaults to review."
      },
      "task_priority": {
        "type": "object",
        "title": "Task Priority",
        "description": "Task priority descriptor. Defaults to medium."
      },
      "execution": {
        "type": "object",
        "title": "Execution Settings",
        "properties": {
          "alwaysOutputData": {
            "type": "boolean",
            "title": "Always Output Data",
            "description": "Always output data, even on error (if configured).",
            "default": false
          },
          "retryOnFail": {
            "type": "boolean",
            "title": "Retry On Fail",
            "description": "Retry the execution if it fails.",
            "default": false
          },
          "maxTries": {
            "type": "integer",
            "title": "Max Retries",
            "description": "Number of retries.",
            "default": 3,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "waitBetweenTries": {
            "type": "integer",
            "title": "Wait Between Retries (ms)",
            "default": 1000,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "continueOnFail": {
            "type": "boolean",
            "title": "Continue On Fail",
            "description": "Do not crash workflow on error.",
            "default": false
          },
          "timeout_ms": {
            "type": "integer",
            "title": "Timeout (ms)",
            "description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
            "default": 300000
          }
        }
      }
    }
  },
  "input_contract_schema": {
    "type": "object",
    "properties": {
      "target": {
        "type": "object"
      },
      "input_mapping": {
        "type": "object"
      },
      "organization_id": {
        "type": "string"
      },
      "assignee": {
        "type": "string"
      },
      "task_title": {
        "type": "string"
      }
    }
  },
  "output_contract_schema": {
    "type": "object",
    "properties": {
      "app_handoff_descriptor": {
        "type": "object"
      },
      "task_id": {
        "type": "string"
      },
      "task_title": {
        "type": "string"
      }
    }
  },
  "ports": [
    {
      "port_id": "out",
      "label": "Out",
      "is_default": true,
      "description": "Handoff delivered (Task created; app opened if live session)."
    },
    {
      "port_id": "error",
      "label": "Error"
    }
  ],
  "execution_mode": "sync",
  "tags": [
    "ui",
    "terminal",
    "handoff"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_sommatic_ai",
    "profile": {
      "name": "Sommatic AI",
      "verified": true,
      "url": "https://me.veripass.com/sommatic",
      "logo_url": null
    }
  }
}

执行

执行方式
sync
有状态
否
重试(retryOnFail)
否
能力
uihumanterminal
标签
uiterminalhandoff

说明与限制

  • 不会挂起或等待:连接到 out 的节点会立即执行。请将其作为运行的最后一个节点。
  • 任务的 context.workflow_instance_id 和 context.trace_id 以空值发送:worker 从运行时未设置的字段读取它们,因此任务不会关联到本次运行。
  • 非幂等:每次执行都会创建新任务。HTTP 调用不会重试。
  • worker 将字段直接放在信封顶层、不使用 data,因此引擎把整个信封(包括 port 键)作为下一个节点的 payload。
  • worker 不设置 ok(示例中显示为 true);引擎只按 port 路由。

已对照编排器代码核实 · 31e874b · 2026-11-26

安装智能体工具

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

安装 Sommatic AI CLI,并为检测到的智能体配置合适的插件。

npx @sommatic/cli agent setup
智能体如何读取本文档