import type { LoopRecord } from "../contracts/index.js"; export interface MilestoneState { version: 5; firstRunAt: string | null; runCount: number; successfulRunCount: number; failedRunCount: number; totalActualSpendUsd: number; totalEstimatedUncontrolledSpendUsd: number; totalSavedUsd: number; savingsConfidence: "confirmed" | "estimated" | "unavailable"; bestRunSavedUsd: number | null; bestRunAt: string | null; reposUsed: string[]; lastRunAt: string | null; dailyStreakDays: number; receiptsGenerated: number; rollbacksTriggered: number; verifierBlocks: number; currentRank: RankName; loopMilestones: { reached: number[]; }; streakMilestones: { reached: number[]; }; savingsMilestones: { reachedUsd: number[]; }; star: { shownCount: number; confirmed: boolean; lastShownAtSavedUsd?: number; }; feedback: { shownCount: number; lastShownAtSavedUsd?: number; lastShownAtRunCount?: number; scores: Array<{ score: number; runCount: number; }>; featureVotes: string[]; email: string | null; optedOut: boolean; lastDelivery?: IntakeDelivery; }; waitlist: { status: "not_asked" | "declined" | "joined"; declinedCount: number; email: string | null; shownAt: string | null; lastDelivery?: IntakeDelivery; }; suppressUntilRun: number; governedBadge: { ctaShownAt: string | null; }; } export type RankName = "Observer" | "Operator" | "Engineer" | "Architect" | "Control Plane" | "Infrastructure" | "Legend"; export type InlineMilestone = { kind: "streak_milestone"; days: number; } | { kind: "savings_milestone"; usd: number; }; export type InteractivePrompt = { kind: "loop_milestone"; count: number; } | { kind: "star"; hard: boolean; } | { kind: "feedback"; } | { kind: "waitlist"; } | null; export interface RunPromptResult { inlineMilestones: InlineMilestone[]; interactivePrompt: InteractivePrompt; } export declare function computeRank(successfulRunCount: number, totalSavedUsd: number): RankName; export declare function nextRank(rank: RankName): { name: RankName; loopsNeeded: number; savedNeeded: number; } | null; export declare function deriveSavingsConfidence(loop: LoopRecord): "confirmed" | "estimated" | "unavailable"; export declare function estimatedUncontrolledUsd(loop: LoopRecord): number; export declare function wasRollbackTaken(loop: LoopRecord): boolean; export declare function wasVerifierBlocked(loop: LoopRecord): boolean; export declare function recordRunAndGetPrompt(input: { success: boolean; repoRoot: string; actualSpendUsd: number; estimatedUncontrolledUsd: number; savingsConfidence: "confirmed" | "estimated" | "unavailable"; rollbackTaken: boolean; verifierBlock: boolean; }): Promise; export declare function recordStarConfirmed(): Promise; export type IntakePayload = { source: "martin-cli"; event: "feedback" | "pilot_interest"; cliVersion: string; email?: string; score?: number; featureVote?: string; consentToContact: boolean; platform: NodeJS.Platform; createdAt: string; }; export type IntakeSubmissionResult = { ok: true; status: "accepted" | "duplicate"; submissionId?: string; } | { ok: false; status: "timeout" | "network_error" | "rejected" | "server_error"; retryable: boolean; message: string; }; /** Privacy-safe local record of the most recent intake hand-off. */ export interface IntakeDelivery { status: "accepted" | "duplicate" | "queued" | "rejected"; recordedAt: string; submissionId?: string; } export declare function intakeDeliveryFromResult(result: IntakeSubmissionResult): IntakeDelivery; export declare function submitToIntake(payload: IntakePayload, options?: { queueOnFailure?: boolean; }): Promise; export declare function retryQueuedIntake(): Promise; export declare function recordWaitlistJoined(email: string): Promise; export declare function recordWaitlistDeclined(): Promise; export declare function recordFeedback(score: number, featureVote?: string, email?: string): Promise; export declare function readMilestoneState(): Promise; export declare function isBadgeCtaEligible(state: MilestoneState): boolean; export declare function recordBadgeCtaShown(): Promise;