import type { Api, Model } from "@earendil-works/pi-ai"; /** Native SDK IDs stay distinct from the app's persisted connection routes. */ export type NativeSubscriptionProviderId = "github-copilot" | "xai"; export type NativeSubscriptionLogicalId = "github-copilot-subscription" | "xai-subscription"; export const NATIVE_SUBSCRIPTIONS = [ { providerId: "github-copilot", logicalId: "github-copilot-subscription", label: "GitHub Copilot" }, { providerId: "xai", logicalId: "xai-subscription", label: "Grok" }, ] as const; export interface SubscriptionPrompt { id: string; type: "text" | "secret" | "select" | "manual_code"; message: string; placeholder?: string; options?: readonly { id: string; label: string; description?: string }[]; } /** Only public device user codes, never the private device_code or tokens. */ export interface SubscriptionInteraction { attemptId: string; prompt?: SubscriptionPrompt; browser?: { id: string; url: string }; userCode?: string; progress?: string; } export interface NativeSubscriptionStatus { providerId: NativeSubscriptionProviderId; available: boolean; connected: boolean; pending: boolean; committing?: boolean; allowBackgroundUse: boolean; connectionId: string | null; epoch: number; authorityRevision: number; revision: number; error?: string; interaction?: SubscriptionInteraction; } /** Private inherited IPC also carries safe, SDK-supported catalog metadata. */ export interface NativeSubscriptionSnapshot { statuses: NativeSubscriptionStatus[]; models: Partial[]>>; } export interface NativeSubscriptionScope { providerId: NativeSubscriptionProviderId; connectionId: string; epoch: number; authorityRevision: number; selectedModelId: string; } export interface NativeSubscriptionControlBridge { status(): Promise; login(providerId: NativeSubscriptionProviderId, enabled?: boolean): Promise; cancel(providerId: NativeSubscriptionProviderId): Promise; respond(providerId: NativeSubscriptionProviderId, attemptId: string, promptId: string, value: string): Promise; open(providerId: NativeSubscriptionProviderId, attemptId: string, actionId: string): Promise; retry(providerId: NativeSubscriptionProviderId): Promise; disconnect(providerId: NativeSubscriptionProviderId): Promise; consent(providerId: NativeSubscriptionProviderId, enabled: boolean): Promise; onChange(listener: () => void): () => void; }