Apply StoneOS Industry Package
为某个业务单元提出行业包方案并预览,然后等待有权限的人员审批。由应用执行变更;该 worker 只负责提议、等待和恢复。
为业务单元提议一个 StoneOS 行业包,生成其预览并返回挂起信号;之后人员的决定会通过编排器的恢复操作映射到 applied、rejected、timeout 或 partial。
工作原理
- 解析配置并合并到输入 payload 之上(配置优先)。若结果中有
resume对象,则跳过提议,直接映射决定(见最后一步)。 - 检查
unit和package_id,以及 StoneOS 行业服务是否已配置。 - 以服务身份代表
approver_role(默认administrator)调用该服务。 - 创建变更,包含
package_id、business_unit_code(取自unit)、role(默认principal)、size、jurisdiction和reasons(reason,或包含包名的默认文本),然后请求预览,预览必须返回installation_id和installation_preview_hash。 - 返回
{ __signal: "SUSPEND", __metadata: { type: "stoneos_industry_change", id, installation_id, preview_hash, expires_in_ms, resume_on } }。信封没有端口,引擎将其路由到本节点未声明的out:分支结束,运行完成。 - 恢复:持有决定的系统调用编排器的恢复操作,传入
workflow_instance_id、node_id、可选的graph和input,以及resume{ change_id, state, port?, approver, applied_apps?, failed_app?, error_code? }。worker 以恢复模式再次运行,端口取resume.port或resume.state;若提供了graph和node_id,会从该端口相连的节点开始一次新运行,以data作为 payload。
在工作流中
节点在工作流文件(draft_nodes[])中的写法,以及一次成功运行的 envelope。
{
"node_id": "node-apply-industry",
"label": "Apply industry package",
"operator_slug": "stoneos.industry.apply",
"operator_version": "1.0.0",
"config": {
"unit": "{{ $json.business_unit_code }}",
"package_id": "<package_id>",
"role": "principal",
"reason": "New business unit onboarding",
"approver_role": "administrator",
"timeout_ms": 259200000
}
}{
"ok": true,
"data": {
"change_id": "chg-xxxxxxxxxxxx",
"state": "applied",
"applied_apps": [
"stoneos-notes",
"stoneos-todo"
],
"approver": "[email protected]"
},
"port": "applied",
"meta": {
"approver": "[email protected]"
}
}配置
-
unitstring 必填 -
业务单元代码(可使用表达式)
-
package_idstring 必填 -
proposal_idstring 可选 -
rolestring 可选 -
sizestring 可选 -
jurisdictionstring 可选 -
辖区代码;默认使用组织的辖区
-
reasonstring 可选 -
operationstring 可选 -
approver_rolestring 可选 -
timeout_msinteger 可选
配置中会显示通用执行设置,但该节点目前不执行重试(retryOnFail、maxTries)。所有节点均未实现 continueOnFail。
代码中的行为
除 schema 描述之外,实现代码对这些键的实际处理。
-
resume - 未声明。当配置或输入 payload 中带有
resume时,节点会将其映射到端口,而不是提议变更。 -
proposal_id - 已声明但被忽略,
operation同样如此。 -
timeout_ms - 默认 72 小时。仅作为
__metadata.expires_in_ms返回;编排器不会强制执行。timeout只会来自状态为timeout的恢复请求。
输出端口
applied 默认 恢复时状态为 applied 且带有 approver。唯一 ok: true 的端口。
{
"change_id": "chg-xxxxxxxxxxxx",
"state": "applied",
"applied_apps": [
"stoneos-notes",
"stoneos-todo"
],
"approver": "[email protected]"
}rejected 恢复时状态为 rejected 且带有 approver。
{
"change_id": "chg-xxxxxxxxxxxx",
"state": "rejected",
"applied_apps": [],
"approver": "[email protected]"
}timeout 恢复时状态为 timeout;不需要 approver。
{
"change_id": "chg-xxxxxxxxxxxx",
"state": "timeout",
"applied_apps": []
}partial 恢复时状态为 partial 且带有 approver:部分应用已应用,failed_app 指出失败的应用。
{
"change_id": "chg-xxxxxxxxxxxx",
"state": "partial",
"applied_apps": [
"stoneos-notes"
],
"failed_app": "stoneos-todo",
"approver": "[email protected]"
}error 提议步骤失败,或恢复请求无效或报告错误。data 只携带 error_code;消息位于信封的 error 字段,不会传到下一个节点。
{
"error_code": "missing_unit"
}在表达式中
后续节点可通过 $("Apply StoneOS Industry Package").item.json.<路径> 读取此节点输出中的内容(请把 Apply StoneOS Industry Package 换成你的节点标签)。Editor 标记工作流编辑器在 Previous Nodes 中提示的路径(输出契约);Worker 标记 worker 实际通过 applied 返回的路径,依据“端口”一节所示的输出。
| 表达式 | Editor | Worker |
|---|---|---|
$("Apply StoneOS Industry Package").item.json.change_id | ||
$("Apply StoneOS Industry Package").item.json.state | ||
$("Apply StoneOS Industry Package").item.json.applied_apps | ||
$("Apply StoneOS Industry Package").item.json.failed_app | — | |
$("Apply StoneOS Industry Package").item.json.approver | ||
$("Apply StoneOS Industry Package").item.json.error_code | — |
— Editor: 编辑器会提示它,但 worker 并不返回:读取结果为 undefined。
错误
| 消息 | 端口 | 原因与处理 |
|---|---|---|
Missing 'unit' | error | 缺少业务单元代码。error_code:missing_unit。 |
Missing 'package_id' | error | 缺少行业包。error_code:missing_package_id。 |
services.stoneosIndustry.uri is not resolved | error | 编排器未配置 StoneOS 行业服务。error_code:service_not_configured。 |
The change was not created | error | 服务响应中没有变更 id。error_code:change_not_created。 |
The change preview was not created | error | 预览中缺少 installation_id 或 installation_preview_hash。error_code:preview_failed。 |
<HTTP error message> | error | 服务拒绝了调用;若服务返回了自己的 error_code 则使用该值。error_code:request_failed。 |
Unknown resume state '<port>' | error | 恢复端口不是 applied、rejected、timeout、partial 或 error。error_code:unknown_resume_state。 |
The '<port>' port needs the person who approved | error | applied、rejected 和 partial 需要 resume.approver。error_code:approval_missing。 |
<resume error> | error | 恢复请求报告 port 或 state 为 error;data 保留恢复字段并附加 error_code(默认 apply_failed)。 |
输入契约
-
unitstring 可选 -
package_idstring 可选 -
proposal_idstring 可选 -
rolestring 可选 -
sizestring 可选 -
operationstring 可选 -
approver_rolestring 可选 -
timeout_msinteger 可选
输出契约
-
change_idstring 可选 -
statestring 可选 -
applied_appsarray<string> 可选 -
failed_appstring 可选 -
approverstring 可选 -
error_codestring 可选
契约(JSON Schema)
与编排器声明完全一致的定义。All 是完整的 *.definition.js;可与上方各节对照,找出文档与 schema 之间的差异。发布前可用它校验节点。
{
"slug": "stoneos.industry.apply",
"name": "Apply StoneOS Industry Package",
"category": "hitl",
"version": "1.0.0",
"description": "Proposes an industry package for a business unit, previews it and waits for a person with permission to approve. The app applies the change; the worker only proposes, waits and resumes.",
"capabilities": [
"industry",
"configuration",
"human"
],
"config_schema": {
"type": "object",
"required": [
"unit",
"package_id"
],
"properties": {
"unit": {
"type": "string",
"title": "Business unit",
"description": "Business unit code (expression allowed)"
},
"package_id": {
"type": "string",
"title": "Package"
},
"proposal_id": {
"type": "string",
"title": "Proposal"
},
"role": {
"type": "string",
"enum": [
"principal",
"complement"
],
"default": "principal"
},
"size": {
"type": "string",
"title": "Size"
},
"jurisdiction": {
"type": "string",
"title": "Jurisdiction",
"description": "Jurisdiction code; defaults to the organization one"
},
"reason": {
"type": "string",
"title": "Reason"
},
"operation": {
"type": "string",
"title": "Operation"
},
"approver_role": {
"type": "string",
"default": "administrator",
"title": "Approver role"
},
"timeout_ms": {
"type": "integer",
"default": 259200000
},
"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": {
"unit": {
"type": "string"
},
"package_id": {
"type": "string"
},
"proposal_id": {
"type": "string"
},
"role": {
"type": "string"
},
"size": {
"type": "string"
},
"operation": {
"type": "string"
},
"approver_role": {
"type": "string"
},
"timeout_ms": {
"type": "integer"
}
}
},
"output_contract_schema": {
"type": "object",
"properties": {
"change_id": {
"type": "string"
},
"state": {
"type": "string"
},
"applied_apps": {
"type": "array",
"items": {
"type": "string"
}
},
"failed_app": {
"type": "string"
},
"approver": {
"type": "string"
},
"error_code": {
"type": "string"
}
}
},
"ports": [
{
"port_id": "applied",
"label": "Applied",
"is_default": true,
"description": "Approved and applied"
},
{
"port_id": "rejected",
"label": "Rejected",
"description": "A person rejected the change"
},
{
"port_id": "timeout",
"label": "Timeout",
"description": "Nobody decided in time"
},
{
"port_id": "partial",
"label": "Partial",
"description": "Applied halfway; the flow decides"
},
{
"port_id": "error",
"label": "Error",
"description": "Carries error_code"
}
],
"execution_mode": "async",
"tags": [
"industry",
"configuration",
"human"
],
"is_stateful": true,
"publisher": {
"identity": "org_sommatic_ai",
"profile": {
"name": "Sommatic AI",
"verified": true,
"url": "https://me.veripass.com/sommatic",
"logo_url": null
}
}
}{
"type": "object",
"required": [
"unit",
"package_id"
],
"properties": {
"unit": {
"type": "string",
"title": "Business unit",
"description": "Business unit code (expression allowed)"
},
"package_id": {
"type": "string",
"title": "Package"
},
"proposal_id": {
"type": "string",
"title": "Proposal"
},
"role": {
"type": "string",
"enum": [
"principal",
"complement"
],
"default": "principal"
},
"size": {
"type": "string",
"title": "Size"
},
"jurisdiction": {
"type": "string",
"title": "Jurisdiction",
"description": "Jurisdiction code; defaults to the organization one"
},
"reason": {
"type": "string",
"title": "Reason"
},
"operation": {
"type": "string",
"title": "Operation"
},
"approver_role": {
"type": "string",
"default": "administrator",
"title": "Approver role"
},
"timeout_ms": {
"type": "integer",
"default": 259200000
},
"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
}
}
}
}
}{
"type": "object",
"properties": {
"unit": {
"type": "string"
},
"package_id": {
"type": "string"
},
"proposal_id": {
"type": "string"
},
"role": {
"type": "string"
},
"size": {
"type": "string"
},
"operation": {
"type": "string"
},
"approver_role": {
"type": "string"
},
"timeout_ms": {
"type": "integer"
}
}
}{
"type": "object",
"properties": {
"change_id": {
"type": "string"
},
"state": {
"type": "string"
},
"applied_apps": {
"type": "array",
"items": {
"type": "string"
}
},
"failed_app": {
"type": "string"
},
"approver": {
"type": "string"
},
"error_code": {
"type": "string"
}
}
}[
{
"port_id": "applied",
"label": "Applied",
"is_default": true,
"description": "Approved and applied"
},
{
"port_id": "rejected",
"label": "Rejected",
"description": "A person rejected the change"
},
{
"port_id": "timeout",
"label": "Timeout",
"description": "Nobody decided in time"
},
{
"port_id": "partial",
"label": "Partial",
"description": "Applied halfway; the flow decides"
},
{
"port_id": "error",
"label": "Error",
"description": "Carries error_code"
}
]执行
- 执行方式
async- 有状态
- 是
- 重试(
retryOnFail) - 否
- 凭据
- 在服务器端根据
connection_id解析,密钥不会进入工作流。 - 能力
industryconfigurationhuman- 标签
industryconfigurationhuman
说明与限制
- 变更请求中的
workflow_instance_id和node_id为空(worker 从运行时未设置的字段读取它们),因此服务无法得知是哪次运行提议了变更;调用恢复操作的一方必须提供workflow_instance_id、node_id和graph。 - 续跑是一次新的运行:本节点之前各节点的输出不可用(
$("Node")为空),$input为恢复请求中的input。 rejected、timeout和partial的ok为 false,但仍沿各自端口流转。worker 只负责提议和等待;行业包由 StoneOS 应用在批准后应用。
已对照编排器代码核实 · 31e874b · 2026-11-26