mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-19 22:10:51 +00:00
14 lines
471 B
TypeScript
14 lines
471 B
TypeScript
import type { InteractiveReply, InteractiveReplyBlock } from "../../../interactive/payload.js";
|
|
|
|
export function reduceInteractiveReply<TState>(
|
|
interactive: InteractiveReply | undefined,
|
|
initialState: TState,
|
|
reduce: (state: TState, block: InteractiveReplyBlock, index: number) => TState,
|
|
): TState {
|
|
let state = initialState;
|
|
for (const [index, block] of (interactive?.blocks ?? []).entries()) {
|
|
state = reduce(state, block, index);
|
|
}
|
|
return state;
|
|
}
|