zerosloney/dsh-state-graph
zerosloney★ 0TypeScriptLast synced: 2026-08-16
StateGraph orchestration engine as a DeepSeek Harness plugin: declarative directed state graphs with conditional routing, loopback, iteration guards.
README excerpt
dsh-state-graph 把 StateGraph 有向状态图编排引擎 移植为 DeepSeek Harness (dsh) 插件 :用声明式的节点 / 静态边 / 条件边把 Harness 单向线性的 ReAct 调度提升为支持多分支条件路由、循环重试与迭代熔断的图编排运行时(子图嵌套可经节点内调用 ctx.graph.create() 组合实现;并行汇聚暂未内置)。 这是什么 dsh-state-graph 是一个 dsh bundle 包 :导出一个 cordis 插件( state-graph ),提供 ctx.graph 服务。插件的核心是设计文档《状态图(StateGraph)编排引擎技术方案与架构设计》中的有向状态图运行时内核: 能力 落点 声明式拓扑构造(Fluent API:addNode / addEdge / addConditionalEdge) StateGraph 纯函数增量补丁:节点只返回 Partial ,引擎不可变合并 StateGraph.run 防死循环熔断(默认 25 次迭代,超限抛错) StateGraph 内置 双向事件流观测( graph/ 事件,追加式轨迹) ctx.emit 事件总线 隔离的状态图实例工厂 ctx.graph.create() 核心接口 接口 / 类型 签名 说明 NodeHandler (state: T, ctx: Context) = Promise \ Partial 节点业务执行体,返回需合并的状态增量 ConditionHandler (state: T, ctx: Context) = string \ Promise 动态路由,返回下一个 NodeName 或 " END " GraphExecutionResult { graphId: string; finalState: T; trajectory: string[]; iterations: number } 实例标识、最终状态、全量跳转轨迹、迭代次数 ctx.graph.create (maxIterations?) → StateGraph 创建隔离的图实例 事件( ctx.on("graph/…") 订阅) 事件 载荷 时机 graph/start { graphId, initialState, entryPoint } 图开始执行 graph/node-start { graphId, node, state, iteration } 每个节点执行前 graph/node-end { graphId, node, state } 节点补丁合并后 graph/node-error { graphId, node, error } 节点抛错(随后上抛) graph/error { graphId, erro…
View full README on GitHub →