UNPKG

@code-yeongyu/senpi

Version:

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

31 lines • 1.92 kB
import { formatWorkingElapsedSeconds } from "./working-status.js"; const TOOL_PROGRESS_SPINNER_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]; /** The tool spinner glyph for a frame counter; shared by progress lines and the exploring header. */ export function toolSpinnerGlyph(frame) { return TOOL_PROGRESS_SPINNER_FRAMES[frame % TOOL_PROGRESS_SPINNER_FRAMES.length] ?? TOOL_PROGRESS_SPINNER_FRAMES[0]; } export function readToolProgress(details) { if (typeof details !== "object" || details === null || !("progress" in details)) return undefined; const progress = details.progress; if (typeof progress !== "object" || progress === null || !("startedAt" in progress)) return undefined; if (typeof progress.startedAt !== "number" || !Number.isFinite(progress.startedAt)) return undefined; if ("activity" in progress && typeof progress.activity !== "string") return undefined; if ("maxWaitMs" in progress && (typeof progress.maxWaitMs !== "number" || !Number.isFinite(progress.maxWaitMs))) { return undefined; } const activity = "activity" in progress && typeof progress.activity === "string" ? progress.activity : undefined; const maxWaitMs = "maxWaitMs" in progress && typeof progress.maxWaitMs === "number" ? progress.maxWaitMs : undefined; return { activity, startedAt: progress.startedAt, maxWaitMs }; } export function formatToolProgressLine(progress, now, spinnerFrame) { const activity = progress.activity || "working"; const elapsed = formatWorkingElapsedSeconds((now - progress.startedAt) / 1_000); const maxWait = progress.maxWaitMs === undefined ? "" : ` / max ${formatWorkingElapsedSeconds(progress.maxWaitMs / 1_000)}`; const spinner = toolSpinnerGlyph(spinnerFrame ?? 0); return `${spinner} ${activity} · ${elapsed}${maxWait}`; } //# sourceMappingURL=tool-progress.js.map