@kedge-agentic/workflow
v0.1.0
Published
Framework-free workflow engine for ccaas. Cascade context, trigger registry, engine + state-change pipeline + types. Pairs with @kedge-agentic/workflow-nest (NestJS adapter) and @kedge-agentic/workflow-client (HTTP client) to form a three-sibling family.
Readme
@kedge-agentic/workflow
ccaas 的框架无关 workflow 引擎 — cascade 上下文、trigger 注册表、dispatch pipeline。
类型: 框架无关库 · 状态: public · v0.1.0
用途
@kedge-agentic/ontology 上的声明式 trigger 层。 Solution 注册 TriggerDef 对象 (when 谓词 + then action),引擎路由事件到匹配的 action。 灵感来自 Palantir Carbon。
零 NestJS 耦合 — 配套三件套:
- @kedge-agentic/workflow-nest — NestJS 适配 (module / controllers / 持久化)
- @kedge-agentic/workflow-client — 跨进程事件推送 HTTP 客户端
宿主应用注册 DI port (MANIFEST_ACCESSOR_PORT, INDICATOR_REGISTRY_PORT) 并通过 factory provider 实例化引擎; 经典接线见 workflow-nest 的 WorkflowModule。
主要导出
import {
WorkflowEngine,
WorkflowRegistry,
TriggerDef,
TriggerFireInput,
currentCascade,
withRootCascade,
withChildCascade,
} from '@kedge-agentic/workflow'
// 给 DI 宿主用的 port token
import {
MANIFEST_ACCESSOR_PORT,
INDICATOR_REGISTRY_PORT,
} from '@kedge-agentic/workflow/ports'用法
const CHAT_TURN_TRIGGER: TriggerDef = {
apiName: 'on_chat_turn_classify',
manifest: 'LessonSession',
kind: 'event',
watch: { stream: 'events' },
when: (input) => input.event?.payload?.type === 'chat_turn',
then: {
action: 'workflow-actions-chat-turn.classify_chat_turn_indicators',
args: (input) => ({ entityId: input.event.payload.studentId }),
as: 'admin',
},
}
registry.registerTrigger(CHAT_TURN_TRIGGER)
await engine.ingestEvent({ sessionId, payload: { type: 'chat_turn', ... } })依赖
- 运行时:
@kedge-agentic/ontology - 无 peerDeps,无框架耦合
关联包
- @kedge-agentic/workflow-nest — NestJS 绑定
- @kedge-agentic/workflow-client — HTTP 推送客户端
- @kedge-agentic/ontology — ObjectType / Manifest / Action 原语
构建 / 测试
npm run build:workflow
npm test -w @kedge-agentic/workflow