refactor(core): restructure ModeratorContext to { start, steps } #117
Reference in New Issue
Block a user
Delete Branch "refactor/110-moderator-context-restructure"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Restructure
ModeratorContextfrom a discriminated union to a flat{ start, steps }object, and simplifyModeratorsignature from 3 args to 1.Why
Moderator now receives full workflow history instead of just the latest event.
roundis derivable fromsteps.length,maxRoundsfromstart.meta.maxRounds. Simpler API, more powerful.Changes
packages/core/src/types.ts—ModeratorContextchanged from{ kind: "start" } | { kind: "step" }to{ start: StartStep; steps: RoleStep<M>[] }.Moderatorsignature reduced to(context) => role | ENDpackages/daemon/src/workflow-worker.ts— buildsstepsarray, passes{ start, steps }to moderator. Removed unusedModeratorContextimportpackages/core/README.md— updated type documentationOut-of-repo
~/.uncaged-nerve/workflows/sense-generator/index.ts— moderator adapted to new API (not tracked in git)Ref
Fixes #110
- ModeratorContext: discriminated union → { start: StartStep; steps: RoleStep<M>[] } - Moderator signature: (context, round, maxRounds) → (context) - round derivable from steps.length, maxRounds from start.meta.maxRounds - workflow-worker.ts: build steps array, pass full context to moderator - Remove unused ModeratorContext import from workflow-worker - Update README.md Refs #110LGTM 🟢
Discriminated union → flat { start, steps } 简洁多了,moderator 从 3 参数降到 1 参数,round/maxRounds 都可从 context 推导。
worker 里 resume 时从 roleMessages 重建 steps 数组的逻辑也正确。干净!