Download packages/shared/src/index.ts from myagent10101/codesync-collaborative-platform: direct link, hf CLI and curl.
- Browser
- Download file 7.04 kB
-
https://huggingface.co/myagent10101/codesync-collaborative-platform/resolve/main/packages/shared/src/index.ts
- Command line
-
hf download hf://myagent10101/codesync-collaborative-platform/packages/shared/src/index.ts
-
curl -L -o index.ts https://huggingface.co/myagent10101/codesync-collaborative-platform/resolve/main/packages/shared/src/index.ts
7.04 kB
| // βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| // @codesync/shared β Shared types and constants | |
| // βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| // User colors for cursor presence | |
| export const USER_COLORS = [ | |
| '#FF6B6B', '#4ECDC4', '#45B7D1', '#96CEB4', | |
| '#FFEAA7', '#DDA0DD', '#98D8C8', '#F7DC6F', | |
| '#BB8FCE', '#85C1E9', '#F8C471', '#82E0AA', | |
| ] as const; | |
| // Rate limiting configuration | |
| export const RATE_LIMITS = { | |
| AUTH: { windowMs: 15 * 60 * 1000, max: 10 }, | |
| API: { windowMs: 60 * 1000, max: 100 }, | |
| EXECUTION: { windowMs: 60 * 1000, max: 10 }, | |
| AI: { windowMs: 60 * 1000, max: 20 }, | |
| WEBSOCKET: { windowMs: 1000, max: 50 }, | |
| } as const; | |
| // Room constraints | |
| export const ROOM_LIMITS = { | |
| MAX_MEMBERS: 10, | |
| MAX_FILES: 20, | |
| MAX_FILE_SIZE: 1024 * 1024, | |
| MAX_MESSAGE_LENGTH: 4096, | |
| MAX_ROOM_NAME_LENGTH: 64, | |
| INVITE_CODE_LENGTH: 8, | |
| } as const; | |
| // Execution constraints | |
| export const EXECUTION_LIMITS = { | |
| MAX_CODE_SIZE: 64 * 1024, | |
| MAX_TIMEOUT: 30000, | |
| DEFAULT_TIMEOUT: 10000, | |
| MAX_OUTPUT_SIZE: 1024 * 1024, | |
| MAX_CONCURRENT: 5, | |
| } as const; | |
| // Language configurations | |
| export const LANGUAGE_CONFIG = { | |
| javascript: { | |
| name: 'JavaScript', extension: '.js', monacoId: 'javascript', | |
| dockerImage: 'codesync-sandbox-js', runCommand: 'node', | |
| timeout: 10000, memoryLimit: '128m', | |
| }, | |
| typescript: { | |
| name: 'TypeScript', extension: '.ts', monacoId: 'typescript', | |
| dockerImage: 'codesync-sandbox-js', runCommand: 'npx tsx', | |
| timeout: 15000, memoryLimit: '128m', | |
| }, | |
| python: { | |
| name: 'Python', extension: '.py', monacoId: 'python', | |
| dockerImage: 'codesync-sandbox-python', runCommand: 'python3', | |
| timeout: 10000, memoryLimit: '128m', | |
| }, | |
| cpp: { | |
| name: 'C++', extension: '.cpp', monacoId: 'cpp', | |
| dockerImage: 'codesync-sandbox-cpp', runCommand: 'g++', | |
| timeout: 15000, memoryLimit: '256m', | |
| }, | |
| java: { | |
| name: 'Java', extension: '.java', monacoId: 'java', | |
| dockerImage: 'codesync-sandbox-java', runCommand: 'javac', | |
| timeout: 20000, memoryLimit: '256m', | |
| }, | |
| } as const; | |
| // βββ Shared Types ββββββββββββββββββββββββββββββββββββββββββββ | |
| export interface User { | |
| id: string; | |
| email: string; | |
| name: string; | |
| avatar: string | null; | |
| provider: string; | |
| createdAt: string; | |
| } | |
| export interface AuthTokens { | |
| accessToken: string; | |
| refreshToken: string; | |
| } | |
| export interface Room { | |
| id: string; | |
| name: string; | |
| ownerId: string; | |
| language: string; | |
| isPublic: boolean; | |
| inviteCode: string; | |
| maxMembers: number; | |
| createdAt: string; | |
| updatedAt: string; | |
| } | |
| export interface RoomMember { | |
| userId: string; | |
| roomId: string; | |
| role: string; | |
| joinedAt: string; | |
| lastActive: string; | |
| user: User; | |
| } | |
| export interface RoomFile { | |
| id: string; | |
| roomId: string; | |
| name: string; | |
| path: string; | |
| content: string; | |
| language: string; | |
| createdAt: string; | |
| updatedAt: string; | |
| } | |
| export type ProgrammingLanguage = 'javascript' | 'typescript' | 'python' | 'cpp' | 'java'; | |
| export type RoomRole = 'owner' | 'editor' | 'viewer'; | |
| export type MessageType = 'text' | 'code' | 'file' | 'system'; | |
| export type AIAction = 'explain' | 'fix' | 'optimize' | 'comment' | 'debug'; | |
| export interface ChatMessage { | |
| id: string; | |
| content: string; | |
| userId: string; | |
| userName: string; | |
| userAvatar: string | null; | |
| roomId: string; | |
| type: MessageType; | |
| metadata?: any; | |
| createdAt: string; | |
| } | |
| export interface UserCursor { | |
| userId: string; | |
| userName: string; | |
| userColor: string; | |
| position: { lineNumber: number; column: number }; | |
| selection?: { | |
| startLineNumber: number; | |
| startColumn: number; | |
| endLineNumber: number; | |
| endColumn: number; | |
| }; | |
| } | |
| export interface UserPresence { | |
| userId: string; | |
| userName: string; | |
| userColor: string; | |
| isOnline: boolean; | |
| lastSeen: string; | |
| isTyping: boolean; | |
| } | |
| export interface ExecutionRequest { | |
| code: string; | |
| language: ProgrammingLanguage; | |
| stdin?: string; | |
| timeout?: number; | |
| } | |
| export interface ExecutionResult { | |
| id: string; | |
| stdout: string; | |
| stderr: string; | |
| exitCode: number; | |
| duration: number; | |
| memoryUsed: number; | |
| timedOut: boolean; | |
| } | |
| export interface CreateRoomPayload { | |
| name: string; | |
| language: ProgrammingLanguage; | |
| isPublic: boolean; | |
| maxMembers?: number; | |
| } | |
| export interface AIRequest { | |
| action: AIAction; | |
| code: string; | |
| language: ProgrammingLanguage; | |
| prompt?: string; | |
| error?: string; | |
| } | |
| export interface AIResponse { | |
| content: string; | |
| suggestions?: Array<{ description: string; code: string }>; | |
| } | |
| export interface AIMessage { | |
| id: string; | |
| role: 'user' | 'assistant'; | |
| content: string; | |
| timestamp: string; | |
| } | |
| export interface WebRTCSignal { | |
| type: 'offer' | 'answer' | 'ice-candidate'; | |
| from: string; | |
| to: string; | |
| payload: any; | |
| } | |
| export interface PeerConnection { | |
| peerId: string; | |
| peerName: string; | |
| isAudioEnabled: boolean; | |
| isVideoEnabled: boolean; | |
| isScreenSharing: boolean; | |
| } | |
| export interface DashboardStats { | |
| totalRooms: number; | |
| totalExecutions: number; | |
| totalCollaborationTime: number; | |
| recentActivity: any[]; | |
| } | |
| export interface Snippet { | |
| id: string; | |
| userId: string; | |
| title: string; | |
| code: string; | |
| language: string; | |
| description?: string; | |
| isPublic: boolean; | |
| createdAt: string; | |
| updatedAt: string; | |
| } | |
| // Socket event interfaces | |
| export interface ServerToClientEvents { | |
| 'room:joined': (data: any) => void; | |
| 'room:member-joined': (data: any) => void; | |
| 'room:member-left': (data: any) => void; | |
| 'doc:sync': (data: any) => void; | |
| 'doc:state': (data: any) => void; | |
| 'presence:update': (data: any) => void; | |
| 'cursor:update': (data: any) => void; | |
| 'chat:message': (data: any) => void; | |
| 'chat:typing': (data: any) => void; | |
| 'chat:history': (data: any) => void; | |
| 'exec:output': (data: any) => void; | |
| 'exec:complete': (data: any) => void; | |
| 'exec:error': (data: any) => void; | |
| 'webrtc:offer': (data: any) => void; | |
| 'webrtc:answer': (data: any) => void; | |
| 'webrtc:ice-candidate': (data: any) => void; | |
| 'webrtc:peer-joined': (data: any) => void; | |
| 'webrtc:peer-left': (data: any) => void; | |
| 'error': (data: any) => void; | |
| } | |
| export interface ClientToServerEvents { | |
| 'room:join': (data: any) => void; | |
| 'room:leave': (data: any) => void; | |
| 'doc:update': (data: any) => void; | |
| 'doc:request-state': (data: any) => void; | |
| 'presence:update': (data: any) => void; | |
| 'cursor:move': (data: any) => void; | |
| 'chat:send': (data: any) => void; | |
| 'chat:typing': (data: any) => void; | |
| 'chat:history': (data: any) => void; | |
| 'exec:run': (data: any) => void; | |
| 'exec:kill': (data: any) => void; | |
| 'webrtc:join': () => void; | |
| 'webrtc:leave': () => void; | |
| 'webrtc:offer': (data: any) => void; | |
| 'webrtc:answer': (data: any) => void; | |
| 'webrtc:ice-candidate': (data: any) => void; | |
| } | |