UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

50 lines • 2.16 kB
import { isUserDirectedTurn } from "./engine-turn-limit.js"; export const ENGINE_PAUSED_ENTRY_TYPE = "engine-paused"; export function enginePauseSinceLastTurn(entries) { for (let index = entries.length - 1; index >= 0; index--) { const entry = entries[index]; if (entry.type === "message" && entry.message.role === "user") return false; if (entry.type === "custom_message" && isUserDirectedTurn(entry.customType)) return false; if (entry.type === "custom" && entry.customType === "engine-turn-start") return false; if (entry.type === "custom" && entry.customType === ENGINE_PAUSED_ENTRY_TYPE) return true; } return false; } /** The latest engine turn was the repetitive-turns correction and has not already reported a stop. */ export function settledRepetitiveTurnPause(entries) { let corrected = false; for (let index = entries.length - 1; index >= 0; index--) { const entry = entries[index]; if (entry.type === "message" && entry.message.role === "user") return false; if (entry.type === "custom_message" && isUserDirectedTurn(entry.customType)) return false; if (entry.type === "custom" && entry.customType === ENGINE_PAUSED_ENTRY_TYPE) return false; if (entry.type === "custom" && entry.customType === "engine-turn-start") { const data = entry.data; return (corrected && typeof data === "object" && data !== null && "customType" in data && data.customType === "ttsr-injection"); } if (entry.type !== "custom_message") continue; if (entry.customType !== "ttsr-injection") continue; const details = entry.details; corrected = typeof details === "object" && details !== null && "rules" in details && Array.isArray(details.rules) && details.rules.includes("repetitive-turns"); } return false; } //# sourceMappingURL=engine-paused.js.map