人工介入 Beta
任务、状态流转与任务事件流。
创建任务。
POST /work-management/task/
返回已创建的任务。
认证: Bearer 令牌
请求体
任务对象。
-
organization_idstring 必填 -
该任务所属组织的标识符。
-
project_idstring -
拥有该任务的项目 ID(租户作用域),可选。
-
titlestring 必填 -
简短易读的任务标题(目标)。
-
detailsstring -
可执行的说明,描述人员需要做什么以及原因。
-
typeWorkManagementTaskType 必填 -
任务类型对象,定义所需的人工干预类别。
可用类型(第一阶段):
- approval:人工批准/拒绝并说明理由
- data_completion:补全缺失的结构化数据
- review:人工核验/审阅某项内容
- resolution:人工解决检测到的问题/阻碍
- delegation:人工分派后续步骤并明确责任人
-
idinteger 必填 -
类型的数字标识符。
-
namestring 必填 -
机器可读的类型名称。
-
titlestring 必填 -
可读标签。
-
colorstring -
类型徽标的 UI 颜色,可选。
-
priorityWorkManagementTaskPriority 必填 -
任务优先级对象,用于收件箱排序和升级决策。
可用优先级(第一阶段):
- low、medium、high、critical
-
idinteger 必填 -
优先级的数字标识符。
-
namestring 必填 -
机器可读的优先级名称。
-
titlestring 必填 -
可读标签。
-
colorstring -
优先级徽标的 UI 颜色,可选。
-
assigneeWorkManagementTaskAssignee -
分派信息。记录预期的责任方(用户或群组),具体执行不在该实体内强制约束。
-
assignee_typestring 必填 -
定义分派对象是用户还是群组。
可选值usergroup -
userobject -
assignee_type 为 user 时被分派的用户引用。
-
idstring -
用户 ID。
-
namestring -
显示名称。
-
-
groupobject -
assignee_type 为 group 时被分派的群组引用。
-
idstring -
群组 ID。
-
namestring -
群组名称。
-
-
-
ownershipWorkManagementTaskOwnership -
归属(认领)信息。与 assignee 不同:assignee 表示应由谁处理,ownership 表示实际由谁认领。
-
is_claimedboolean 必填 -
表示任务是否已被认领。
-
claimed_byobject -
认领该任务的用户引用。
-
idstring -
用户 ID。
-
namestring -
显示名称。
-
-
claimed_atstring -
认领时间,字符串格式的 Unix 时间戳。
-
-
slaWorkManagementTaskSLA -
任务 SLA 对象(不是类型)。这是一个时间/约束对象,用于定义截止时间和服务预期。
SLA 以对象形式存储,因为它是一组与时间相关的属性,而非分类类型。
-
due_atstring 必填 -
任务截止时间,字符串格式的 Unix 时间戳。
-
sla_msinteger 必填 -
自任务创建起计算的 SLA 时长(毫秒)。
-
is_overdueboolean 必填 -
读取时计算。当前时间超过 due_at 时为 true。
-
-
required_outputWorkManagementTaskRequiredOutput 必填 -
定义人员完成任务时必须提供的内容。以类 JSON Schema 对象存储,以便进行确定性校验。
-
schemaobject 必填 -
所需输出的类 JSON Schema 描述。
-
ui_hintobject -
用于渲染默认完成表单的 UI 提示,可选。
-
-
outputsobject -
人员完成任务时提供的输出。当 BaseModel.status 变为 "completed" 时,必须符合 required_output.schema。
-
payloadWorkManagementTaskPayload -
任务的运行载荷。存储人员所需的证据块和软引用。任务上下文/证据应放在这里(而非 BaseModel.context)。
-
summarystring -
简要说明触发该任务的原因。
-
evidencearray<object> -
受控的证据块(已清洗)。
-
kindstring -
证据类型标签。
-
payloadobject -
证据载荷内容。
-
-
linked_entitiesarray<object> -
对相关实体的软引用(非硬依赖)。
-
system_domainstring -
相关领域。
-
system_entitystring -
相关实体名称。
-
system_entity_idstring -
相关实体 ID。
-
-
hitlobject -
人机协同(Human-in-the-Loop)控制载荷。自由格式对象,由
task.execution.app_slug中声明的 App Engine 应用使用。其结构由hitl.approval_type.name决定(binary_approval、tool_approval、plan_review、single_select_decision、multi_select_decision、review_edit_reject)。
-
-
executionWorkManagementTaskExecution -
用于 HITL(Human-in-the-Loop,人机协同)集成的任务执行上下文。定义任务的完成方式:通过 App Engine 应用或默认输出表单。
提供 app_slug 时,任务将输出收集委托给 App Engine 应用。该应用通过 input_payload 接收任务上下文,并通过 submitOutput() 返回结构化输出。
app_slug 为 null 或缺省时,任务使用根据 required_output.schema 自动生成的输出表单。
App Engine 会话已原生支持 execution_context_type: "task" 和 task_id。
-
app_slugstring -
用于收集 HITL 输出时要打开的 App Engine 应用的 slug。为 null 时,任务使用默认输出表单(根据 required_output.schema 自动生成)。
-
app_session_idstring -
打开应用时由 App Engine 创建的会话 ID。在用户打开应用时于运行时填充,而非在创建任务时。
-
launch_modestring -
应用的 App Engine 启动模式。
-
input_payloadobject -
启动时传给应用的附加数据。打开应用时会与 task.payload 合并。
-
响应
-
200成功。
curl -X POST https://api.sommatic.ai/work-management/task/ \
-H "Authorization: Bearer $SOMMATIC_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"organization_id": "org-123",
"title": "Approve billing exception",
"type": {
"id": 10,
"name": "approval",
"title": "Approval",
"color": "#0288d1"
},
"priority": {
"id": 3,
"name": "high",
"title": "High",
"color": "#f57c00"
},
"required_output": {
"schema": {
"type": "object",
"required": [
"decision",
"reason"
],
"properties": {
"decision": {
"type": "string",
"enum": [
"approved",
"rejected"
]
},
"reason": {
"type": "string"
},
"notes": {
"type": "string"
}
}
},
"ui_hint": {
"layout": "approval",
"require_reason": true
}
}
}'const response = await fetch('https://api.sommatic.ai/work-management/task/', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.SOMMATIC_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"organization_id": "org-123",
"title": "Approve billing exception",
"type": {
"id": 10,
"name": "approval",
"title": "Approval",
"color": "#0288d1"
},
"priority": {
"id": 3,
"name": "high",
"title": "High",
"color": "#f57c00"
},
"required_output": {
"schema": {
"type": "object",
"required": [
"decision",
"reason"
],
"properties": {
"decision": {
"type": "string",
"enum": [
"approved",
"rejected"
]
},
"reason": {
"type": "string"
},
"notes": {
"type": "string"
}
}
},
"ui_hint": {
"layout": "approval",
"require_reason": true
}
}
}),
});
const { success, message, result } = await response.json();import os
import requests
response = requests.post(
"https://api.sommatic.ai/work-management/task/",
headers={
"Authorization": f"Bearer {os.environ['SOMMATIC_TOKEN']}",
},
json={
"organization_id": "org-123",
"title": "Approve billing exception",
"type": {
"id": 10,
"name": "approval",
"title": "Approval",
"color": "#0288d1"
},
"priority": {
"id": 3,
"name": "high",
"title": "High",
"color": "#f57c00"
},
"required_output": {
"schema": {
"type": "object",
"required": [
"decision",
"reason"
],
"properties": {
"decision": {
"type": "string",
"enum": [
"approved",
"rejected"
]
},
"reason": {
"type": "string"
},
"notes": {
"type": "string"
}
}
},
"ui_hint": {
"layout": "approval",
"require_reason": True
}
}
},
)
data = response.json(){
"status": 200,
"success": true,
"message": "Operation completed successfully",
"result": {
"organization_id": "org-123",
"title": "Approve billing exception",
"type": {
"id": 10,
"name": "approval",
"title": "Approval",
"color": "#0288d1"
},
"priority": {
"id": 3,
"name": "high",
"title": "High",
"color": "#f57c00"
},
"required_output": {
"schema": {
"type": "object",
"required": [
"decision",
"reason"
],
"properties": {
"decision": {
"type": "string",
"enum": [
"approved",
"rejected"
]
},
"reason": {
"type": "string"
},
"notes": {
"type": "string"
}
}
},
"ui_hint": {
"layout": "approval",
"require_reason": true
}
}
}
}更新任务。
PATCH /work-management/task/
更新任务数据。
认证: Bearer 令牌
请求体
任务更新对象。
-
organization_idstring 必填 -
该任务所属组织的标识符。
-
project_idstring -
拥有该任务的项目 ID(租户作用域),可选。
-
titlestring 必填 -
简短易读的任务标题(目标)。
-
detailsstring -
可执行的说明,描述人员需要做什么以及原因。
-
typeWorkManagementTaskType 必填 -
任务类型对象,定义所需的人工干预类别。
可用类型(第一阶段):
- approval:人工批准/拒绝并说明理由
- data_completion:补全缺失的结构化数据
- review:人工核验/审阅某项内容
- resolution:人工解决检测到的问题/阻碍
- delegation:人工分派后续步骤并明确责任人
-
idinteger 必填 -
类型的数字标识符。
-
namestring 必填 -
机器可读的类型名称。
-
titlestring 必填 -
可读标签。
-
colorstring -
类型徽标的 UI 颜色,可选。
-
priorityWorkManagementTaskPriority 必填 -
任务优先级对象,用于收件箱排序和升级决策。
可用优先级(第一阶段):
- low、medium、high、critical
-
idinteger 必填 -
优先级的数字标识符。
-
namestring 必填 -
机器可读的优先级名称。
-
titlestring 必填 -
可读标签。
-
colorstring -
优先级徽标的 UI 颜色,可选。
-
assigneeWorkManagementTaskAssignee -
分派信息。记录预期的责任方(用户或群组),具体执行不在该实体内强制约束。
-
assignee_typestring 必填 -
定义分派对象是用户还是群组。
可选值usergroup -
userobject -
assignee_type 为 user 时被分派的用户引用。
-
idstring -
用户 ID。
-
namestring -
显示名称。
-
-
groupobject -
assignee_type 为 group 时被分派的群组引用。
-
idstring -
群组 ID。
-
namestring -
群组名称。
-
-
-
ownershipWorkManagementTaskOwnership -
归属(认领)信息。与 assignee 不同:assignee 表示应由谁处理,ownership 表示实际由谁认领。
-
is_claimedboolean 必填 -
表示任务是否已被认领。
-
claimed_byobject -
认领该任务的用户引用。
-
idstring -
用户 ID。
-
namestring -
显示名称。
-
-
claimed_atstring -
认领时间,字符串格式的 Unix 时间戳。
-
-
slaWorkManagementTaskSLA -
任务 SLA 对象(不是类型)。这是一个时间/约束对象,用于定义截止时间和服务预期。
SLA 以对象形式存储,因为它是一组与时间相关的属性,而非分类类型。
-
due_atstring 必填 -
任务截止时间,字符串格式的 Unix 时间戳。
-
sla_msinteger 必填 -
自任务创建起计算的 SLA 时长(毫秒)。
-
is_overdueboolean 必填 -
读取时计算。当前时间超过 due_at 时为 true。
-
-
required_outputWorkManagementTaskRequiredOutput 必填 -
定义人员完成任务时必须提供的内容。以类 JSON Schema 对象存储,以便进行确定性校验。
-
schemaobject 必填 -
所需输出的类 JSON Schema 描述。
-
ui_hintobject -
用于渲染默认完成表单的 UI 提示,可选。
-
-
outputsobject -
人员完成任务时提供的输出。当 BaseModel.status 变为 "completed" 时,必须符合 required_output.schema。
-
payloadWorkManagementTaskPayload -
任务的运行载荷。存储人员所需的证据块和软引用。任务上下文/证据应放在这里(而非 BaseModel.context)。
-
summarystring -
简要说明触发该任务的原因。
-
evidencearray<object> -
受控的证据块(已清洗)。
-
kindstring -
证据类型标签。
-
payloadobject -
证据载荷内容。
-
-
linked_entitiesarray<object> -
对相关实体的软引用(非硬依赖)。
-
system_domainstring -
相关领域。
-
system_entitystring -
相关实体名称。
-
system_entity_idstring -
相关实体 ID。
-
-
hitlobject -
人机协同(Human-in-the-Loop)控制载荷。自由格式对象,由
task.execution.app_slug中声明的 App Engine 应用使用。其结构由hitl.approval_type.name决定(binary_approval、tool_approval、plan_review、single_select_decision、multi_select_decision、review_edit_reject)。
-
-
executionWorkManagementTaskExecution -
用于 HITL(Human-in-the-Loop,人机协同)集成的任务执行上下文。定义任务的完成方式:通过 App Engine 应用或默认输出表单。
提供 app_slug 时,任务将输出收集委托给 App Engine 应用。该应用通过 input_payload 接收任务上下文,并通过 submitOutput() 返回结构化输出。
app_slug 为 null 或缺省时,任务使用根据 required_output.schema 自动生成的输出表单。
App Engine 会话已原生支持 execution_context_type: "task" 和 task_id。
-
app_slugstring -
用于收集 HITL 输出时要打开的 App Engine 应用的 slug。为 null 时,任务使用默认输出表单(根据 required_output.schema 自动生成)。
-
app_session_idstring -
打开应用时由 App Engine 创建的会话 ID。在用户打开应用时于运行时填充,而非在创建任务时。
-
launch_modestring -
应用的 App Engine 启动模式。
-
input_payloadobject -
启动时传给应用的附加数据。打开应用时会与 task.payload 合并。
-
响应
-
200成功。
curl -X PATCH https://api.sommatic.ai/work-management/task/ \
-H "Authorization: Bearer $SOMMATIC_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"organization_id": "org-123",
"title": "Approve billing exception",
"type": {
"id": 10,
"name": "approval",
"title": "Approval",
"color": "#0288d1"
},
"priority": {
"id": 3,
"name": "high",
"title": "High",
"color": "#f57c00"
},
"required_output": {
"schema": {
"type": "object",
"required": [
"decision",
"reason"
],
"properties": {
"decision": {
"type": "string",
"enum": [
"approved",
"rejected"
]
},
"reason": {
"type": "string"
},
"notes": {
"type": "string"
}
}
},
"ui_hint": {
"layout": "approval",
"require_reason": true
}
}
}'const response = await fetch('https://api.sommatic.ai/work-management/task/', {
method: 'PATCH',
headers: {
Authorization: `Bearer ${process.env.SOMMATIC_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"organization_id": "org-123",
"title": "Approve billing exception",
"type": {
"id": 10,
"name": "approval",
"title": "Approval",
"color": "#0288d1"
},
"priority": {
"id": 3,
"name": "high",
"title": "High",
"color": "#f57c00"
},
"required_output": {
"schema": {
"type": "object",
"required": [
"decision",
"reason"
],
"properties": {
"decision": {
"type": "string",
"enum": [
"approved",
"rejected"
]
},
"reason": {
"type": "string"
},
"notes": {
"type": "string"
}
}
},
"ui_hint": {
"layout": "approval",
"require_reason": true
}
}
}),
});
const { success, message, result } = await response.json();import os
import requests
response = requests.patch(
"https://api.sommatic.ai/work-management/task/",
headers={
"Authorization": f"Bearer {os.environ['SOMMATIC_TOKEN']}",
},
json={
"organization_id": "org-123",
"title": "Approve billing exception",
"type": {
"id": 10,
"name": "approval",
"title": "Approval",
"color": "#0288d1"
},
"priority": {
"id": 3,
"name": "high",
"title": "High",
"color": "#f57c00"
},
"required_output": {
"schema": {
"type": "object",
"required": [
"decision",
"reason"
],
"properties": {
"decision": {
"type": "string",
"enum": [
"approved",
"rejected"
]
},
"reason": {
"type": "string"
},
"notes": {
"type": "string"
}
}
},
"ui_hint": {
"layout": "approval",
"require_reason": True
}
}
},
)
data = response.json(){
"status": 200,
"success": true,
"message": "Operation completed successfully",
"result": {
"organization_id": "org-123",
"title": "Approve billing exception",
"type": {
"id": 10,
"name": "approval",
"title": "Approval",
"color": "#0288d1"
},
"priority": {
"id": 3,
"name": "high",
"title": "High",
"color": "#f57c00"
},
"required_output": {
"schema": {
"type": "object",
"required": [
"decision",
"reason"
],
"properties": {
"decision": {
"type": "string",
"enum": [
"approved",
"rejected"
]
},
"reason": {
"type": "string"
},
"notes": {
"type": "string"
}
}
},
"ui_hint": {
"layout": "approval",
"require_reason": true
}
}
}
}归档任务。
DELETE /work-management/task/
认证: Bearer 令牌
请求体
要删除或归档的任务 ID
-
idstring
响应
-
200成功。
curl -X DELETE https://api.sommatic.ai/work-management/task/ \
-H "Authorization: Bearer $SOMMATIC_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"id": "<id>"
}'const response = await fetch('https://api.sommatic.ai/work-management/task/', {
method: 'DELETE',
headers: {
Authorization: `Bearer ${process.env.SOMMATIC_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"id": "<id>"
}),
});
const { success, message, result } = await response.json();import os
import requests
response = requests.delete(
"https://api.sommatic.ai/work-management/task/",
headers={
"Authorization": f"Bearer {os.environ['SOMMATIC_TOKEN']}",
},
json={
"id": "<id>"
},
)
data = response.json()按查询选择器获取任务。
GET /work-management/task/{queryselector}
返回任务信息。使用 id 加 search 获取单个任务,或使用 all 加分页和状态筛选获取列表。
认证: Bearer 令牌
参数
-
queryselectorenum 路径 必填 -
筛选选择器
idinboxlistallstatusestypesprioritiestransitions -
searchstring 查询 -
当 queryselector 为 `id` 时的任务 ID。
-
organization_idstring 查询 -
按组织 ID 筛选任务。
-
include_statusstring 查询 -
要包含的状态名称,以逗号分隔(例如 queued,assigned,claimed)。
-
exclude_statusstring 查询 -
要排除的状态名称,以逗号分隔(例如 deleted)。
-
pageinteger 查询 -
页码,从 1 开始(默认 1)。
-
pageSizeinteger 查询 -
每页记录数(默认 25)。
响应
-
200成功。
curl -X GET https://api.sommatic.ai/work-management/task/id \
-H "Authorization: Bearer $SOMMATIC_TOKEN"const response = await fetch('https://api.sommatic.ai/work-management/task/id', {
method: 'GET',
headers: {
Authorization: `Bearer ${process.env.SOMMATIC_TOKEN}`,
},
});
const { success, message, result } = await response.json();import os
import requests
response = requests.get(
"https://api.sommatic.ai/work-management/task/id",
headers={
"Authorization": f"Bearer {os.environ['SOMMATIC_TOKEN']}",
},
)
data = response.json()任务通知的实时 SSE 流
GET /work-management/task/stream
按用户身份筛选的 Server-Sent Events 流。为已连接用户创建任务时,推送 task-assigned 事件。
认证: Bearer 令牌
参数
-
user[identity]string 查询 必填 -
用于筛选通知的用户身份
响应
-
200SSE 事件流(Content-Type text/event-stream)
curl -X GET https://api.sommatic.ai/work-management/task/stream?user[identity]=<user[identity]> \
-H "Authorization: Bearer $SOMMATIC_TOKEN" \
-Nconst response = await fetch('https://api.sommatic.ai/work-management/task/stream?user[identity]=<user[identity]>', {
method: 'GET',
headers: {
Authorization: `Bearer ${process.env.SOMMATIC_TOKEN}`,
},
});
const { success, message, result } = await response.json();import os
import requests
response = requests.get(
"https://api.sommatic.ai/work-management/task/stream?user[identity]=<user[identity]>",
headers={
"Authorization": f"Bearer {os.environ['SOMMATIC_TOKEN']}",
},
)
data = response.json()对任务执行生命周期状态转换。
PATCH /work-management/task/transition/
将任务转换为新状态(assign、claim、start、complete、reject、invalidate、expire)。
认证: Bearer 令牌
请求体
-
idstring 必填 -
任务 ID。
-
transition_namestring 必填 - 可选值
assignclaimstartcompleterejectinvalidateexpire -
payloadobject -
状态流转的附加数据(例如
assignee、outputs、claimed_by)。
响应
-
200成功。 -
500执行此操作时出错。
curl -X PATCH https://api.sommatic.ai/work-management/task/transition/ \
-H "Authorization: Bearer $SOMMATIC_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"id": "<id>",
"transition_name": "assign"
}'const response = await fetch('https://api.sommatic.ai/work-management/task/transition/', {
method: 'PATCH',
headers: {
Authorization: `Bearer ${process.env.SOMMATIC_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"id": "<id>",
"transition_name": "assign"
}),
});
const { success, message, result } = await response.json();import os
import requests
response = requests.patch(
"https://api.sommatic.ai/work-management/task/transition/",
headers={
"Authorization": f"Bearer {os.environ['SOMMATIC_TOKEN']}",
},
json={
"id": "<id>",
"transition_name": "assign"
},
)
data = response.json(){
"status": 200,
"success": true,
"message": "Operation completed successfully",
"result": {
"id": "<id>",
"transition_name": "assign"
}
}