/**
 * Type definitions for the GrackleContext value.
 * Kept separate so both the real provider (in @grackle-ai/web) and
 * MockGrackleProvider can use them without circular dependencies.
 *
 * @module
 */

import type {
  UsageStats, UseKnowledgeResult,
  UseEnvironmentsResult, UseSessionsResult, UseWorkspacesResult,
  UseTasksResult, UseFindingsResult, UseTokensResult,
  UseCredentialsResult, UseCodespacesResult, UseDockerContainersResult, UsePersonasResult,
  UsePluginsResult,
  UseSchedulesResult,
  UseStreamsResult,
  UseGitHubAccountsResult,
  ConnectionStatus,
} from "../hooks/types.js";

/** Return type for the useGrackleSocket hook (and the GrackleContext value). */
export interface UseGrackleSocketResult {
  /** Current connection state of the event stream. */
  connectionStatus: ConnectionStatus;
  /** Environment state and actions. */
  environments: Omit<UseEnvironmentsResult, "handleEvent" | "handleLegacyMessage">;
  /** Session state and actions. */
  sessions: Omit<UseSessionsResult, "handleMessage" | "handleSessionEvent" | "handleLegacyMessage" | "loadSessions">;
  /** Workspace state and actions. */
  workspaces: Omit<UseWorkspacesResult, "handleEvent" | "onDisconnect">;
  /** Task state and actions. */
  tasks: Omit<UseTasksResult, "handleEvent" | "onDisconnect" | "handleLegacyMessage">;
  /** Finding state and actions. */
  findings: Omit<UseFindingsResult, "handleEvent">;
  /** Token state and actions. */
  tokens: Omit<UseTokensResult, "handleEvent">;
  /** Credential provider state and actions. */
  credentials: Omit<UseCredentialsResult, "handleEvent" | "loadCredentials">;
  /** GitHub Codespace state and actions. */
  codespaces: UseCodespacesResult;
  /** Docker container discovery (attach mode) state and actions. */
  dockerContainers: UseDockerContainersResult;
  /** Persona state and actions. */
  personas: Omit<UsePersonasResult, "handleEvent" | "loadPersonas">;
  /** Schedule state and actions. */
  schedules: Omit<UseSchedulesResult, "handleEvent" | "loadSchedules">;
  /** IPC stream state and actions. */
  streams: Omit<UseStreamsResult, "handleEvent">;
  /** Knowledge graph state and actions. */
  knowledge: Omit<UseKnowledgeResult, "handleEvent">;
  /** Plugin state and actions. */
  plugins: Omit<UsePluginsResult, "domainHook">;
  /** GitHub account state and actions. */
  githubAccounts: Omit<UseGitHubAccountsResult, "domainHook">;
  /** App-level default persona ID setting. */
  appDefaultPersonaId: string;
  /** Update the app-level default persona ID. */
  setAppDefaultPersonaId: (personaId: string) => Promise<void>;
  /** Whether the user has completed onboarding. */
  onboardingCompleted: boolean | undefined;
  /** Mark onboarding as completed. */
  completeOnboarding: () => Promise<void>;
  /** Cached usage statistics keyed by "scope:id". */
  usageCache: Record<string, UsageStats>;
  /** Load usage statistics for a given scope and ID. */
  loadUsage: (scope: string, id: string) => Promise<void>;
  /** Refresh environments, sessions, workspaces, and tokens from the server. */
  refresh: () => void;
}
