import type { ImageContent } from "@gajae-code/ai/core"; import type { CustomMessage } from "../session/messages"; import { type GhResult, type RunGh, runGhDefault } from "../utils/gh"; export type { GhResult, RunGh }; export { runGhDefault }; export declare const STAR_REMINDER_REPO = "Yeachan-Heo/gajae-code"; export declare const STAR_REMINDER_CUSTOM_TYPE = "star-reminder"; export declare const STARRED_CACHE_TTL_MS: number; export interface StarReminderState { declined: boolean; starred: boolean; /** ISO-8601 timestamp of the last authoritative star check, or "" if never. */ starredCheckedAt: string; } export type StarCheckStatus = "starred" | "unstarred" | "unavailable"; export interface StarReminderDeps { statePath?: string; now?: () => Date; runGh?: RunGh; sleep?: (ms: number) => Promise; } export declare function getStarReminderStatePath(): string; export declare function defaultStarReminderState(): StarReminderState; /** Read state without locking. Missing or malformed files return the default. */ export declare function readStarReminderStateUnlocked(statePath?: string): Promise; /** Whether a stored `starred:true` is still within the 24h cache window. */ export declare function isStarredCacheFresh(state: StarReminderState, now?: Date): boolean; /** * Lock-protected read-modify-write. The mutator receives the freshly re-read * state under the lock; callers MUST base monotonic decisions on that value, * not on any snapshot captured before the lock was held. */ export declare function updateStarReminderStateLocked(mutator: (current: StarReminderState) => StarReminderState | Promise, deps?: StarReminderDeps): Promise; /** A successful PUT is authoritative: always record starred and clear declined. */ export declare function recordStarredFromPut(deps?: StarReminderDeps): Promise; /** * Record the result of a fresh `gh` star check performed by this operation. * - "starred": authoritative, clears declined so all reminders stop. * - "unstarred": may downgrade, but only when the current state is not a * still-fresh confirmed star (which a concurrent process may have just * written); in that case the fresher confirmation wins. */ export declare function recordFreshStarCheck(status: "starred" | "unstarred", deps?: StarReminderDeps): Promise; /** Record a launch-nudge decline. Never downgrades a confirmed star. */ export declare function recordDeclinedAfterNo(deps?: StarReminderDeps): Promise; /** Classify the star state of the repo via `gh api`. */ export declare function checkGhStarred(deps?: StarReminderDeps): Promise; /** Star the repo via `gh api -X PUT`. Returns whether the PUT succeeded. */ export declare function autoStarRepo(deps?: StarReminderDeps): Promise; /** * Determine the star state for this session, hitting `gh` only when needed. * A fresh cached star skips `gh`; unstarred and declined states are rechecked. * Authoritative results are persisted via the monotonic helpers. */ export declare function refreshStarStateForSession(deps?: StarReminderDeps): Promise; export interface StarReminderPromptUI { /** Show a yes/no confirmation. Resolves true when the user accepts. */ confirm(title: string, message: string): Promise; /** Optional guard; when it returns false the nudge is skipped silently. */ isIdle?: () => boolean; } /** * Run the launch nudge once. Caller is responsible for the `startup.quiet`, * `starReminder.enabled`, and true-interactive gates. All errors are swallowed * so the launch path can never be broken by the reminder. */ export declare function maybeShowLaunchStarReminder(ui: StarReminderPromptUI, deps?: StarReminderDeps): Promise; /** * Schedule the launch nudge to run after the first render so the networked * `gh` check never blocks startup. Returns immediately. */ export declare function scheduleLaunchStarReminderAfterFirstRender(ui: StarReminderPromptUI, deps?: StarReminderDeps): void; export interface StarReminderLaunchGateInput { /** The `starReminder.enabled` setting. */ enabled: boolean; /** The `startup.quiet` setting. */ quiet: boolean; } export interface StarReminderLaunchGate { /** Whether to register the decline-driven injection contributor. */ register: boolean; /** Whether to schedule the launch nudge after first render. */ schedule: boolean; } /** * Pure decision for interactive wiring. The injection contributor is registered * whenever the feature is enabled; the launch nudge is additionally suppressed * by quiet startup. Centralizing this keeps the interactive gate testable. */ export declare function starReminderLaunchGate(input: StarReminderLaunchGateInput): StarReminderLaunchGate; export interface StarReminderSessionRef { getSessionId(): string | undefined; } export type StarReminderCustomMessage = Pick; export type InternalBeforeAgentStartContributor = (event: { prompt: string; images?: ImageContent[]; sessionId: string | undefined; }) => Promise; export declare function createStarReminderMessage(): StarReminderCustomMessage; /** * Build a before-agent-start contributor that injects the persuasion message * once per logical session id, for declined-and-still-unstarred users only. */ export declare function createStarReminderBeforeAgentStartContributor(session: StarReminderSessionRef, deps?: StarReminderDeps): InternalBeforeAgentStartContributor;