refactor: extract StartSignal as independent Role parameter #100

Closed
opened 2026-04-24 23:07:28 +00:00 by xiaoju · 0 comments
Owner

What

Refactor the Role<Meta> function signature to receive StartSignal as a separate first parameter instead of embedding it in messages[0].

Current

type Role<Meta> = (messages: WorkflowMessage[]) => Promise<RoleResult<Meta>>;

Roles must cast messages[0].meta to access start config (maxRounds, etc.) — no type safety.

Proposed

type Role<Meta> = (start: StartSignal, messages: WorkflowMessage[]) => Promise<RoleResult<Meta>>;
  • start is the thread's initial config (like LLM system prompt) — typed, always available
  • messages is the conversation chain (role outputs only, no start message mixed in)
  • StartSignal.meta can be extended with new thread-level params (e.g. dryRun in #101)

Changes needed

  1. core/src/types.ts: Update Role<Meta> signature; update Moderator<M> if needed
  2. daemon/src/workflow-worker.ts: initChain returns start separately; executeRole passes start as first arg; runThread manages start + chain independently
  3. ~/.uncaged-nerve/workflows/sense-generator/index.ts: Update all role functions and moderator to match new signature
  4. packages/workflow-utils: Any helpers that read from messages[0] need updating

Rules

  • Breaking change — only one workflow exists, best time to do it
  • Follow nerve coding conventions: type not interface, no optional properties (T | null not ?:)
  • Ensure full type safety — no as any casts

Blocks #101

— 小橘 🍊(NEKO Team)

## What Refactor the `Role<Meta>` function signature to receive `StartSignal` as a separate first parameter instead of embedding it in `messages[0]`. ### Current ```typescript type Role<Meta> = (messages: WorkflowMessage[]) => Promise<RoleResult<Meta>>; ``` Roles must cast `messages[0].meta` to access start config (`maxRounds`, etc.) — no type safety. ### Proposed ```typescript type Role<Meta> = (start: StartSignal, messages: WorkflowMessage[]) => Promise<RoleResult<Meta>>; ``` - `start` is the thread's initial config (like LLM system prompt) — typed, always available - `messages` is the conversation chain (role outputs only, no start message mixed in) - `StartSignal.meta` can be extended with new thread-level params (e.g. `dryRun` in #101) ### Changes needed 1. **`core/src/types.ts`**: Update `Role<Meta>` signature; update `Moderator<M>` if needed 2. **`daemon/src/workflow-worker.ts`**: `initChain` returns start separately; `executeRole` passes start as first arg; `runThread` manages start + chain independently 3. **`~/.uncaged-nerve/workflows/sense-generator/index.ts`**: Update all role functions and moderator to match new signature 4. **`packages/workflow-utils`**: Any helpers that read from messages[0] need updating ### Rules - Breaking change — only one workflow exists, best time to do it - Follow nerve coding conventions: `type` not `interface`, no optional properties (`T | null` not `?:`) - Ensure full type safety — no `as any` casts Blocks #101 — 小橘 🍊(NEKO Team)
This repo is archived. You cannot comment on issues.
No Label
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/nerve#100