UNPKG

@code-yeongyu/senpi

Version:

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

40 lines • 1.81 kB
export const GOAL_STOP_PAUSED_ENTRY = "goal-stop-paused"; export const GOAL_STOP_RESUMED_ENTRY = "goal-stop-resumed"; /** A user Stop, or a parent's Stop inherited by this child, holds the session paused; an interrupted run does not. */ export function stopHoldLive(ctx) { return (ctx .getPauseState?.() .holds.some((hold) => (hold.kind === "session_hold" && hold.key !== "interrupted-run") || hold.kind === "inherited_hold") === true); } /** The session reopened over a run that never finished: its process died mid-turn (senpi#4683, senpi#5755). */ export function interruptedRunHeld(ctx) { return (ctx.getPauseState?.().holds.some((hold) => hold.kind === "session_hold" && hold.key === "interrupted-run") === true); } export function markStopPaused(pi, goalId) { pi.appendEntry(GOAL_STOP_PAUSED_ENTRY, { goalId }); } export function markStopResumed(pi, goalId) { pi.appendEntry(GOAL_STOP_RESUMED_ENTRY, { goalId }); } /** Whether the user's Stop paused each goal, read without keeping a full-history view (senpi#2537). */ const stopPausedGoals = { initial: () => new Map(), add: (goals, entry) => { if (entry.type !== "custom") return goals; const goalId = entry.data?.goalId; if (typeof goalId !== "string") return goals; if (entry.customType === GOAL_STOP_PAUSED_ENTRY) goals.set(goalId, true); else if (entry.customType === GOAL_STOP_RESUMED_ENTRY) goals.set(goalId, false); return goals; }, }; /** A goal the user's Stop paused (not `/goal pause`) resumes with the session (senpi#3811). */ export function pausedByStop(ctx, goalId) { return ctx.sessionManager.reduceHistory(stopPausedGoals).get(goalId) === true; } //# sourceMappingURL=stop-pause.js.map