diff --git a/README.md b/README.md index 7a7d8ac..c338813 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,6 @@ bun run index.ts 2. Once connected, you can: - Use `/help` to see available commands - Start conversations with the AI - - Join rooms using `/join roomname` - Select models using `/model modelname` ## Development and Contribution @@ -73,7 +72,6 @@ bun run index.ts - `index.ts`: Main entry point, sets up the SSH server - `clientSession.ts`: Manages individual client sessions and interactions -- `room.ts`: Implements room-based chat functionality - `database.ts`: Handles database operations - `types.ts`: Contains TypeScript type definitions - `utils.ts`: Utility functions diff --git a/clientSession.ts b/clientSession.ts index 4a98789..79df190 100644 --- a/clientSession.ts +++ b/clientSession.ts @@ -183,12 +183,6 @@ export class ClientSession implements IClientSession { await this.handleInteractiveAuth("login"); return true; - case "/join": - case "/leave": - case "/rooms": - this.writeCommandOutput("Room functionality is currently disabled."); - return true; - case "/char": if (!this.userId) { this.writeCommandOutput( diff --git a/database.ts b/database.ts index 83d2ca0..e09ac2c 100644 --- a/database.ts +++ b/database.ts @@ -16,16 +16,4 @@ export async function testDatabaseConnection() { } } -export async function resetCredits() { - try { - await sql` - UPDATE accounts SET credits = 30 WHERE credits < 30; - UPDATE accounts SET credits = 10 WHERE credits < 10 AND email IS NULL; - `; - console.log("Credits reset completed"); - } catch (error) { - console.error("Error resetting credits:", error); - } -} - export { sql }; diff --git a/index.ts b/index.ts index 2472161..bcd65d2 100644 --- a/index.ts +++ b/index.ts @@ -1,6 +1,6 @@ import { createServer, createHttpServer } from "./server"; -import { testDatabaseConnection, resetCredits } from "./database"; -import cron from "node-cron"; +import { testDatabaseConnection } from "./database"; + import OpenAI from "openai"; import { fetchAndCacheModelList } from "./clientSession"; @@ -21,11 +21,6 @@ export const openai = new OpenAI({ }, }); -cron.schedule("0 0 * * *", async () => { - console.log("Running daily credit reset"); - await resetCredits(); -}); - process.on("SIGINT", () => { console.log("\nShutting down servers..."); sshServer.close(); diff --git a/room.ts b/room.ts deleted file mode 100644 index 9f429b7..0000000 --- a/room.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { v4 as uuidv4 } from "uuid"; -import { Room as IRoom, ClientSession, DatabaseMessage } from "./types"; -import { sql, getRecentMessages } from "./database"; - -export class Room implements IRoom { - id: string; - name: string; - members: Set; - - constructor(id: string, name: string) { - this.id = id; - this.name = name; - this.members = new Set(); - console.log(`Room created: ${name} (${id})`); - } - - addMember(session: ClientSession) { - this.members.add(session); - console.log( - `User ${session.username || session.id} joined room ${this.name}` - ); - } - - removeMember(session: ClientSession) { - this.members.delete(session); - console.log( - `User ${session.username || session.id} left room ${this.name}` - ); - } - - async addMessage( - content: string, - userId: string | null, - isSystemMessage: boolean = false - ) { - try { - await sql` - INSERT INTO messages (id, room_id, user_id, content, is_system_message) - VALUES (${uuidv4()}, ${ - this.id - }, ${userId}, ${content}, ${isSystemMessage}) - `; - console.log( - `Message added to room ${this.name}: ${content.substring(0, 50)}${ - content.length > 50 ? "..." : "" - }` - ); - } catch (error) { - console.error(`Failed to add message to room ${this.name}:`, error); - } - } - - async broadcast(message: string, sender: ClientSession) { - await this.addMessage(message, sender.userId); - this.members.forEach((member) => { - if (member !== sender) { - member.writeToStream( - `\r\n[${this.name}] ${sender.username || sender.id}: ${message}\r\n> ` - ); - } - }); - } - - async getRecentMessages(limit: number = 20): Promise { - return getRecentMessages(this.id, limit); - } -} diff --git a/types.ts b/types.ts index 93052b3..7e7c071 100644 --- a/types.ts +++ b/types.ts @@ -34,21 +34,6 @@ export interface ClientSession { streamResponse(userMessage: string): Promise; } -export interface Room { - id: string; - name: string; - members: Set; - addMember(session: ClientSession): void; - removeMember(session: ClientSession): void; - addMessage( - content: string, - userId: string | null, - isSystemMessage?: boolean - ): Promise; - broadcast(message: string, sender: ClientSession): Promise; - getRecentMessages(limit?: number): Promise; -} - export interface Character { id: string; name: string; diff --git a/utils.ts b/utils.ts index 181dcec..b1504cc 100644 --- a/utils.ts +++ b/utils.ts @@ -59,9 +59,6 @@ Available Commands: /retry 0.8 /register - Register a new account /login - Login to an existing account - /join - Join a room (requires login) - /leave - Leave the current room (requires login) - /rooms - List all available rooms (requires login) /char - Manage characters (use /char for subcommands) /adventure - Start a text-based RPG adventure /model - List available models or select a model: