UNPKG

@hhoangphuoc/escape-room-cli

Version:

A CLI for playing AI-generated escape room games. Install globally with: npm install -g @hhoangphuoc/escape-room-cli

99 lines (98 loc) 3.21 kB
import React, { ReactNode } from 'react'; export interface ConversationTokenUsage { inputTokens: number; outputTokens: number; reasoningTokens?: number; totalTokens: number; } export interface ConversationEntry { id: string; timestamp: string; type: 'user_input' | 'agent_response' | 'system_message'; content: string; tokenUsage?: ConversationTokenUsage; metadata: { model?: string; requestType: 'command' | 'natural_language' | 'system'; cost?: number; gameId?: string; roomId?: string | number; }; reasoningProcess?: string; formattedTimestamp?: string; formattedTokens?: string; formattedCost?: string; } export interface ConversationContextStats { totalTokens: number; totalInputTokens: number; totalOutputTokens: number; totalReasoningTokens?: number; totalCost: number; entryCount: number; maxContextSize: number; currentContextSize: number; } export interface ConversationHistory { gameId: string; userId: string; sessionId: string; entries: ConversationEntry[]; contextStats: ConversationContextStats; gameMode: string; createdAt: string; updatedAt: string; completedAt?: string; } export type ContextWarningLevel = 'none' | 'low' | 'medium' | 'high' | 'critical'; export interface ContextSizeInfo { currentSize: number; maxSize: number; percentage: number; warningLevel: ContextWarningLevel; formattedSize: string; formattedMaxSize: string; } export interface CostTrackingState { currentSessionCost: number; currentSessionTokens: number; lastRequestCost: number; lastRequestTokens: number; totalCost: number; totalTokens: number; budgetAlert?: { type: 'warning' | 'limit'; message: string; threshold: number; }; } export interface AuthState { userId?: string; sessionToken?: string; userName?: string; apiKey?: string; apiKeyProvider?: 'openai' | 'anthropic'; costTracking?: CostTrackingState; conversationHistory?: ConversationHistory; contextInfo?: ContextSizeInfo; } export interface AuthContextType { auth: AuthState; login: (userData: AuthState) => void; logout: () => void; apiCall: (endpoint: string, options?: RequestInit) => Promise<any>; updateCostTracking: (costData: Partial<CostTrackingState>) => void; resetSessionCosts: () => void; addConversationEntry: (entry: Omit<ConversationEntry, 'id' | 'timestamp'>) => Promise<void>; updateContextInfo: (contextInfo: ContextSizeInfo) => void; getFormattedConversation: (gameId: string) => Promise<ConversationHistory | null>; persistConversation: (gameId: string) => Promise<boolean>; formatTokenCount: (tokens: number) => string; calculateContextWarning: (currentSize: number, maxSize: number) => ContextWarningLevel; createNewConversation: (gameId: string, sessionId: string, gameMode: string) => void; } export declare const AuthContext: React.Context<AuthContextType | undefined>; export declare const AuthProvider: React.FC<{ children: ReactNode; }>; export declare const useAuth: () => AuthContextType;