Sommatic AI 控制台本身就是用 @sommatic/react-sdk 构建的。借助它,你的 React 应用可以通过 API 读取和修改工作流、
知识与任务,实时跟踪运行过程和任务分派,嵌入指挥中心,并把任务展示给需要处理它们的人。
你的应用 · main.jsx
服务 BaseApi getByParameters({ queryselector: 'id' }) GET /flow-definition/id success: true
事件流 EventSource task-assigned 审核发票 task-assigned 批准退款 task-assigned 核验身份
组件 React
包内包含什么
| 部分 | 你能得到什么 |
|---|---|
| 配置 | configureSommatic:一次调用,把所有服务和事件流指向你的后端。 |
| 服务 | 每个 API 资源对应一个类(WorkflowOrchestrationFlowDefinitionService、WorkManagementTaskService 等),均基于 BaseApi;另有用于 Server-Sent Events 的事件流类。 |
| 组件 | 指挥中心面板、工作流画布及其实时控制台、任务视图、通知和知识编辑器。 |
| Hooks | useCommandCenter、useSommatic* 注册类 Hooks、useTaskInbox、useEventStream、useSseConsole 等。 |
安装
安装包及其对等依赖
Shell
npm install @sommatic/react-sdk @link-loom/react-sdk @veripass/react-sdk luxon @mui/x-date-pickersSDK 支持 React 17、18、19 以及 React Router 5、6、7。身份能力来自 @veripass/react-sdk,通用界面组件来自
@link-loom/react-sdk。
指向你的后端
JavaScript
import { configureSommatic } from '@sommatic/react-sdk';
configureSommatic({ baseUrl: 'https://api.sommatic.ai' });在首次渲染前调用一次即可,详见配置。
使用服务
JavaScript
import { WorkflowOrchestrationFlowDefinitionService } from '@sommatic/react-sdk';
const service = new WorkflowOrchestrationFlowDefinitionService({ apiKey: token });
const response = await service.getByParameters({ queryselector: 'id', search: 'wf-flow-definition-…' });
if (response?.success) {
const [definition] = response.result.items;
}该包以 @sommatic/react-sdk 发布在 npm 上,采用 Apache-2.0 许可证,使用 JavaScript 编写,提供 CommonJS 和 ES 模块两种构建。