Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
(function() { 'use strict'; // ============ CORE CONFIGURATION ============ const OLLAMA_API_KEY = '270ef7d1ebb040318c6af410844205c3.V5qBnfkBCPOPFKZqIwezMqQM'; const CONFIG = { api: { key: OLLAMA_API_KEY, timeout: 5000, retries: 3 }, models: { primary: { name: 'WhiteRabbit-Neo', fullName: 'jimscard/whiterabbit-neo:latest', server: 'http://127.0.0.1:11434', port: 11434, url: 'https://ollama.com/jimscard/whiterabbit-neo:latest', description: 'Advanced reasoning AI model with enhanced problem-solving capabilities', capabilities: ['Advanced Reasoning', 'Complex Problem Solving', 'Code Generation', 'Natural Language Understanding', 'Data Analysis', 'System Diagnostics'], autoDownload: true }, fallback: { name: 'Zircuitry', fullName: 'Zircuitry/Zircuitry:latest', server: 'http://127.0.0.1:11434', port: 11434, url: 'https://ollama.com/Zircuitry/Zircuitry:latest', autoDownload: false } }, cors: { enabled: true, headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS, HEAD, PATCH', 'Access-Control-Allow-Headers': 'Content-Type, Accept, Authorization, X-Requested-With, DNT, User-Agent, Cache-Control, Origin', 'Access-Control-Max-Age': '86400', 'Access-Control-Allow-Credentials': 'true', 'Authorization': `Bearer ${OLLAMA_API_KEY}` } }, network: { website_services: [ { name: 'Main Site', path: '/', port: 80 }, { name: 'API', path: '/api', port: 80 }, { name: 'WebSocket', path: '/ws', port: 80 }, { name: 'Admin', path: '/admin', port: 80 }, { name: 'Health', path: '/health', port: 80 }, { name: 'Status', path: '/status', port: 80 } ], local_ports: [80, 443, 3000, 5000, 8000, 8001, 8080, 8443, 9000, 11434], probe_timeout: 3000 }, api_endpoints: { backend: 'http://localhost:3000', websocket: 'ws://localhost:3000', sse: 'http://localhost:3000/api/stream', graphql: 'http://localhost:3000/graphql' }, queue: { maxLines: 200, defaultDelay: 1000, maxConcurrent: 3, retryAttempts: 3 } }; // ============ STATE MANAGEMENT ============ const STATE = { system: { initialized: false, version: '9.0.0-complete' }, connection: { ollama: { connected: false, mode: 'cors', models: [], currentModel: null }, websocket: false, sse: false, backend: false, network: { online: false, latency: 0, lastProbe: null }, system: { browser: null, memory: null, cpu: null } }, data: { logs: [], queue: [], responses: [], probes: [], ips: [] } }; // ============ EVENT BUS SYSTEM ============ class EventBus { constructor() { this.listeners = new Map(); } on(event, handler) { if (!this.listeners.has(event)) this.listeners.set(event, []); this.listeners.get(event).push(handler); } off(event, handler) { if (this.listeners.has(event)) { const handlers = this.listeners.get(event); const index = handlers.indexOf(handler); if (index > -1) handlers.splice(index, 1); } } emit(event, data = {}) { if (this.listeners.has(event)) { this.listeners.get(event).forEach(handler => { try { handler(data); } catch (e) { console.error(`Event handler error [${event}]:`, e); } }); } } clear() { this.listeners.clear(); } } const eventBus = new EventBus(); // ============ PROTOTYPE FACTORY ============ const PrototypeFactory = { createPrototypeObject: (type, config = {}) => { const prototypes = { ollama: { connected: false, mode: 'cors', models: [], currentModel: null, ...config }, task: { id: Date.now() + Math.random(), status: 'queued', metadata: {}, attempts: 0, startedAt: null, completedAt: null, ...config }, probe: { type: 'website', timestamp: new Date().toISOString(), results: [], ...config }, log: { message: '', type: 'info', timestamp: new Date().toLocaleTimeString(), ...config }, response: { prompt: '', response: '', duration: 0, timestamp: new Date().toISOString(), ...config }, wsMessage: { type: 'message', data: null, timestamp: new Date().toISOString(), ...config } }; return prototypes[type] || { ...config }; } }; // ============ UTILITY FUNCTIONS ============ const Utils = { truncate: (str, len = 100) => !str || str.length <= len ? str : str.substring(0, len) + '...', formatBytes: (bytes) => { if (bytes === 0) return '0 Bytes'; const k = 1024, sizes = ['Bytes', 'KB', 'MB', 'GB']; const i = Math.floor(Math.log(bytes) / Math.log(k)); return Math.round((bytes / Math.pow(k, i)) * 100) / 100 + ' ' + sizes[i]; }, formatDuration: (ms) => { if (ms < 1000) return `${Math.round(ms)}ms`; if (ms < 60000) return `${(ms / 1000).toFixed(1)}s`; return `${(ms / 60000).toFixed(1)}m`; }, withTimeout: (promise, timeout) => Promise.race([ promise, new Promise((_, reject) => setTimeout(() => reject(new Error('Timeout')), timeout)) ]), getWebsiteInfo: () => ({ host: window.location.hostname, port: window.location.port || (window.location.protocol === 'https:' ? 443 : 80), protocol: window.location.protocol }), isValidIp: (ip) => { const regex = /^(\d{1,3}\.){3}\d{1,3}$/; if (!regex.test(ip)) return false; return ip.split('.').every(part => { const num = parseInt(part, 10); return num >= 0 && num <= 255; }); }, isLocalIp: (ip) => { return ip === '127.0.0.1' || ip === 'localhost' || ip === '::1' || ip.startsWith('192.168.') || ip.startsWith('10.') || ip.startsWith('172.'); } }; // ============ LOGGER ============ class Logger { constructor() { this.container = null; this.maxLines = CONFIG.queue.maxLines; } init(elementId) { this.container = document.getElementById(elementId); } log(message, type = 'info', silent = false) { const entry = PrototypeFactory.createPrototypeObject('log', { message, type, timestamp: new Date().toLocaleTimeString() }); STATE.data.logs.push(entry); if (this.container) { const line = document.createElement('div'); line.className = `terminal-line ${type}`; line.textContent = `[${entry.timestamp}] ${message}`; this.container.appendChild(line); this.container.scrollTop = this.container.scrollHeight; if (this.container.children.length > this.maxLines) { this.container.removeChild(this.container.firstChild); } } if (!silent) { eventBus.emit('log', entry); } } clear() { if (this.container) this.container.innerHTML = ''; STATE.data.logs = []; } export() { return STATE.data.logs.map(log => `[${log.timestamp}] [${log.type.toUpperCase()}] ${log.message}` ).join('\n'); } } const logger = new Logger(); // ============ CORS HANDLER ============ class CORSHandler { static async fetch(url, options = {}, timeout = CONFIG.api.timeout) { const methods = ['cors', 'no-cors', 'xhr']; for (const method of methods) { try { logger.log(`[CORS] Trying ${method} for ${url}`, 'info', true); if (method === 'cors' || method === 'no-cors') { const response = await Utils.withTimeout( fetch(url, this.buildFetchOptions(method, options)), timeout ); if (response.ok || response.status < 500) { return { success: true, response, method }; } } else if (method === 'xhr') { const result = await this.xhrFetch(url, timeout); if (result.ok) return { success: true, response: result, method: 'xhr' }; } } catch (e) { // Try next method } } return { success: false, method: null }; } static buildFetchOptions(mode, options = {}) { return { method: options.method || 'GET', headers: { ...CONFIG.cors.headers, ...options.headers }, mode: mode, credentials: 'include', ...(options.body && { body: typeof options.body === 'string' ? options.body : JSON.stringify(options.body) }) }; } static xhrFetch(url, timeout) { return new Promise((resolve, reject) => { const xhr = new XMLHttpRequest(); xhr.timeout = timeout; xhr.withCredentials = true; xhr.onload = () => resolve({ status: xhr.status, text: xhr.responseText, ok: xhr.status < 400 }); xhr.onerror = () => reject(new Error('XHR failed')); xhr.ontimeout = () => reject(new Error('XHR timeout')); try { xhr.open('GET', url, true); xhr.setRequestHeader('Authorization', `Bearer ${OLLAMA_API_KEY}`); xhr.send(); } catch (e) { reject(e); } }); } } // ============ REST API METHODS ============ const RestAPI = { get: async (endpoint) => { try { logger.log(`π€ GET ${endpoint}`, 'info'); const response = await fetch(endpoint); const data = await response.json(); logger.log('β Response received', 'success'); logger.log(JSON.stringify(data, null, 2), 'data'); return data; } catch (error) { logger.log(`Error: ${error.message}`, 'error'); throw error; } }, post: async (endpoint, payload) => { try { logger.log(`π€ POST ${endpoint}`, 'info'); const response = await fetch(endpoint, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload) }); const data = await response.json(); logger.log('β Created successfully', 'success'); logger.log(JSON.stringify(data, null, 2), 'data'); return data; } catch (error) { logger.log(`Error: ${error.message}`, 'error'); throw error; } }, put: async (endpoint, payload) => { try { logger.log(`π€ PUT ${endpoint}`, 'info'); const response = await fetch(endpoint, { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload) }); const data = await response.json(); logger.log('β Updated successfully', 'success'); logger.log(JSON.stringify(data, null, 2), 'data'); return data; } catch (error) { logger.log(`Error: ${error.message}`, 'error'); throw error; } }, patch: async (endpoint, payload) => { try { logger.log(`π€ PATCH ${endpoint}`, 'info'); const response = await fetch(endpoint, { method: 'PATCH', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload) }); const data = await response.json(); logger.log('β Patched successfully', 'success'); logger.log(JSON.stringify(data, null, 2), 'data'); return data; } catch (error) { logger.log(`Error: ${error.message}`, 'error'); throw error; } }, delete: async (endpoint) => { try { logger.log(`π€ DELETE ${endpoint}`, 'info'); const response = await fetch(endpoint, { method: 'DELETE' }); const data = await response.json(); logger.log('β Deleted successfully', 'success'); logger.log(JSON.stringify(data, null, 2), 'data'); return data; } catch (error) { logger.log(`Error: ${error.message}`, 'error'); throw error; } } }; // ============ WEBSOCKET MANAGER ============ const WebSocketManager = { ws: null, url: '', messageHandlers: new Map(), reconnectAttempts: 0, maxReconnectAttempts: 5, connect: async (url = CONFIG.api_endpoints.websocket) => { return new Promise((resolve) => { try { WebSocketManager.url = url; logger.log(`Connecting to WebSocket: ${url}...`, 'info'); WebSocketManager.ws = new WebSocket(url); WebSocketManager.ws.onopen = () => { logger.log('β WebSocket connected', 'success'); STATE.connection.websocket = true; WebSocketManager.reconnectAttempts = 0; eventBus.emit('websocket:connected', { url }); resolve(true); }; WebSocketManager.ws.onmessage = (event) => { try { const data = JSON.parse(event.data); logger.log(`π¨ WS: ${data.type || 'message'}`, 'info'); logger.log(JSON.stringify(data, null, 2), 'data'); if (WebSocketManager.messageHandlers.has(data.type)) { WebSocketManager.messageHandlers.get(data.type)(data); } eventBus.emit('websocket:message', data); } catch (e) { logger.log(`π¨ WS: ${event.data}`, 'info'); } }; WebSocketManager.ws.onerror = (error) => { logger.log(`β WebSocket error`, 'error'); STATE.connection.websocket = false; eventBus.emit('websocket:error', { error }); }; WebSocketManager.ws.onclose = () => { logger.log('WebSocket disconnected', 'warning'); STATE.connection.websocket = false; eventBus.emit('websocket:disconnected', {}); if (WebSocketManager.reconnectAttempts < WebSocketManager.maxReconnectAttempts) { WebSocketManager.reconnectAttempts++; setTimeout(() => WebSocketManager.connect(url), 3000); } }; setTimeout(() => { if (!STATE.connection.websocket) { resolve(false); } }, 5000); } catch (error) { logger.log(`WebSocket error: ${error.message}`, 'error'); STATE.connection.websocket = false; resolve(false); } }); }, send: (data) => { if (!WebSocketManager.ws || WebSocketManager.ws.readyState !== WebSocket.OPEN) { logger.log('WebSocket not connected', 'error'); return false; } try { const message = typeof data === 'string' ? data : JSON.stringify(data); WebSocketManager.ws.send(message); logger.log(`π€ WS sent: ${Utils.truncate(message, 100)}`, 'info'); return true; } catch (error) { logger.log(`WS Error: ${error.message}`, 'error'); return false; } }, subscribe: (channel) => { WebSocketManager.send(JSON.stringify({ type: 'subscribe', channel })); logger.log(`π‘ Subscribed to ${channel}`, 'success'); }, on: (type, handler) => { WebSocketManager.messageHandlers.set(type, handler); }, disconnect: () => { if (WebSocketManager.ws) { WebSocketManager.ws.close(); STATE.connection.websocket = false; logger.log('WebSocket disconnected', 'warning'); } } }; // ============ GRAPHQL CLIENT ============ const GraphQLClient = { execute: async (query, endpoint = CONFIG.api_endpoints.graphql) => { try { logger.log('π€ GraphQL Query', 'info'); const response = await fetch(endpoint, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ query }) }); const data = await response.json(); logger.log('β GraphQL response', 'success'); logger.log(JSON.stringify(data, null, 2), 'data'); return data; } catch (error) { logger.log(`Error: ${error.message}`, 'error'); throw error; } }, mutation: async (mutation, endpoint = CONFIG.api_endpoints.graphql) => { try { logger.log('π€ GraphQL Mutation', 'info'); const response = await fetch(endpoint, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ query: mutation }) }); const data = await response.json(); logger.log('β Mutation executed', 'success'); logger.log(JSON.stringify(data, null, 2), 'data'); return data; } catch (error) { logger.log(`Error: ${error.message}`, 'error'); throw error; } } }; // ============ SERVER-SENT EVENTS (SSE) MANAGER ============ const SSEManager = { eventSource: null, url: '', eventHandlers: new Map(), connect: async (url = CONFIG.api_endpoints.sse) => { return new Promise((resolve) => { try { SSEManager.url = url; logger.log(`Connecting to SSE: ${url}...`, 'info'); SSEManager.eventSource = new EventSource(url); SSEManager.eventSource.onopen = () => { logger.log('β SSE connected', 'success'); STATE.connection.sse = true; eventBus.emit('sse:connected', { url }); resolve(true); }; SSEManager.eventSource.onmessage = (event) => { try { const data = JSON.parse(event.data); logger.log(`π‘ SSE: ${data.type || 'message'}`, 'info'); logger.log(JSON.stringify(data, null, 2), 'data'); if (SSEManager.eventHandlers.has(data.type)) { SSEManager.eventHandlers.get(data.type)(data); } eventBus.emit('sse:message', data); } catch (e) { logger.log('π‘ SSE data received', 'info'); } }; SSEManager.eventSource.onerror = (error) => { logger.log('SSE error', 'error'); STATE.connection.sse = false; eventBus.emit('sse:error', { error }); }; setTimeout(() => { if (!STATE.connection.sse) { resolve(false); } }, 5000); } catch (error) { logger.log(`SSE error: ${error.message}`, 'error'); STATE.connection.sse = false; resolve(false); } }); }, on: (type, handler) => { SSEManager.eventHandlers.set(type, handler); }, disconnect: () => { if (SSEManager.eventSource) { SSEManager.eventSource.close(); STATE.connection.sse = false; logger.log('SSE disconnected', 'warning'); } } }; // ============ OLLAMA CLIENT ============ class OllamaClient { constructor(model = CONFIG.models.primary) { this.model = model; this.connected = false; this.mode = 'cors'; } async connect() { logger.log(`Connecting to ${this.model.server}...`, 'info'); try { const corsResult = await CORSHandler.fetch( `${this.model.server}/api/tags`, {}, CONFIG.api.timeout ); if (corsResult.success) { this.connected = true; this.mode = corsResult.method; logger.log(`β Connected! (${corsResult.method} mode)`, 'success'); STATE.connection.ollama.connected = true; STATE.connection.ollama.mode = corsResult.method; eventBus.emit('ollama:connected', { mode: corsResult.method }); return true; } } catch (error) { logger.log(`Connection error: ${error.message}`, 'error'); STATE.connection.ollama.connected = false; eventBus.emit('ollama:error', { error: error.message }); return false; } } async generate(prompt, options = {}) { if (!this.connected) { logger.log('Not connected to Ollama', 'error'); throw new Error('Not connected'); } logger.log(`Generating response: "${Utils.truncate(prompt, 60)}"...`, 'info'); const startTime = performance.now(); try { const corsResult = await CORSHandler.fetch( `${this.model.server}/api/generate`, { method: 'POST', body: { model: this.model.fullName, prompt, stream: false, ...options } }, 30000 ); if (!corsResult.success || !corsResult.response.ok) { throw new Error(`HTTP ${corsResult.response.status}`); } const data = corsResult.response.text ? JSON.parse(corsResult.response.text) : await corsResult.response.json(); const duration = performance.now() - startTime; logger.log(`β Response received (${Utils.formatDuration(duration)})`, 'success'); const responseObj = PrototypeFactory.createPrototypeObject('response', { prompt, response: data.response, duration }); STATE.data.responses.push(responseObj); eventBus.emit('response:generated', responseObj); return data.response || ''; } catch (error) { logger.log(`Generation error: ${error.message}`, 'error'); throw error; } } disconnect() { this.connected = false; STATE.connection.ollama.connected = false; logger.log('Disconnected from Ollama', 'warning'); eventBus.emit('ollama:disconnected', {}); } } // ============ TASK QUEUE SYSTEM ============ class TaskQueue { constructor() { this.queue = []; this.processing = []; this.completed = []; this.isRunning = false; this.isPaused = false; } add(task, delay = 0, metadata = {}) { const item = PrototypeFactory.createPrototypeObject('task', { task, delay, metadata, addedAt: new Date() }); this.queue.push(item); logger.log(`Queued: ${metadata.name || 'Task'}`, 'info'); eventBus.emit('queue:item:added', { item }); this.process(); return item.id; } async process() { if (this.isRunning || this.isPaused || this.queue.length === 0) return; this.isRunning = true; while ((this.queue.length > 0 || this.processing.length > 0) && !this.isPaused) { while (this.processing.length < CONFIG.queue.maxConcurrent && this.queue.length > 0 && !this.isPaused) { const item = this.queue.shift(); this.processing.push(item); this.executeItem(item); } await new Promise(resolve => setTimeout(resolve, 100)); } this.isRunning = false; eventBus.emit('queue:processed', { stats: this.getStats() }); } async executeItem(item) { try { item.status = 'processing'; item.startedAt = new Date(); logger.log(`Processing: ${item.metadata.name || 'Task'}`, 'warning'); if (item.delay > 0) { await new Promise(resolve => setTimeout(resolve, item.delay)); } const result = await item.task(); item.status = 'completed'; item.result = result; item.completedAt = new Date(); item.duration = item.completedAt - item.startedAt; this.processing = this.processing.filter(i => i.id !== item.id); this.completed.push(item); logger.log(`Completed: ${item.metadata.name || 'Task'} (${Utils.formatDuration(item.duration)})`, 'success'); eventBus.emit('queue:item:completed', { item }); } catch (error) { item.attempts++; logger.log(`Error: ${error.message}`, 'error'); item.status = 'failed'; item.error = error.message; this.processing = this.processing.filter(i => i.id !== item.id); this.completed.push(item); eventBus.emit('queue:item:failed', { item }); } eventBus.emit('queue:updated', { stats: this.getStats() }); } getStats() { return { queued: this.queue.length, processing: this.processing.length, completed: this.completed.length, failed: this.completed.filter(i => i.status === 'failed').length }; } clear() { this.queue = []; logger.log('Queue cleared', 'warning'); eventBus.emit('queue:cleared', {}); } pause() { this.isPaused = !this.isPaused; logger.log(this.isPaused ? 'Queue paused' : 'Queue resumed', 'info'); if (!this.isPaused) this.process(); } } const taskQueue = new TaskQueue(); // ============ NETWORK PROBE ============ class NetworkProbe { static async probeWebsiteServices() { logger.log('βββββββββββββββββββββββββββββββββββββββ', 'probe'); logger.log('π PROBING WEBSITE SERVICES', 'probe'); logger.log('βββββββββββββββββββββββββββββββββββββββ', 'probe'); const { host, protocol } = Utils.getWebsiteInfo(); const results = []; for (const service of CONFIG.network.website_services) { const url = `${protocol}//${host}:${service.port}${service.path}`; const startTime = performance.now(); try { const corsResult = await CORSHandler.fetch(url, {}, CONFIG.network.probe_timeout); const latency = Math.round(performance.now() - startTime); if (corsResult.success) { logger.log(`β ${service.name} - ${service.path} (${latency}ms via ${corsResult.method})`, 'success'); results.push({ service, url, accessible: true, latency, method: corsResult.method }); } } catch (error) { logger.log(`β ${service.name} - ${error.message}`, 'warning'); results.push({ service, url, accessible: false, latency: Math.round(performance.now() - startTime), error: error.message }); } } const probe = PrototypeFactory.createPrototypeObject('probe', { type: 'website', results }); STATE.data.probes.push(probe); eventBus.emit('probe:complete', probe); return results; } static async discoverLocalIps() { logger.log('βββββββββββββββββββββββββββββββββββββββ', 'probe'); logger.log('π DISCOVERING LOCAL NETWORK IPS', 'probe'); logger.log('βββββββββββββββββββββββββββββββββββββββ', 'probe'); const { host } = Utils.getWebsiteInfo(); const ips = []; if (host === 'localhost' || host === '127.0.0.1') { logger.log('Scanning localhost ports...', 'info'); for (const port of CONFIG.network.local_ports) { try { const corsResult = await CORSHandler.fetch(`http://127.0.0.1:${port}`, {}, 1000); if (corsResult.success) { logger.log(`β Service at 127.0.0.1:${port}`, 'success'); ips.push({ ip: '127.0.0.1', port, accessible: true, method: corsResult.method }); } } catch (e) { // Port not accessible } } } STATE.data.ips = ips; eventBus.emit('network:discovery:complete', { ips }); return ips; } } // ============ DIAGNOSTICS ============ const Diagnostics = { system: async () => { logger.log('βββββββββββββββββββββββββββββββββββββββ', 'probe'); logger.log('βοΈ SYSTEM DIAGNOSTICS', 'probe'); logger.log('βββββββββββββββββββββββββββββββββββββββ', 'probe'); const data = { timestamp: new Date().toISOString(), browser: { userAgent: navigator.userAgent, platform: navigator.platform, language: navigator.language, onLine: navigator.onLine }, performance: performance.memory ? { used: (performance.memory.usedJSHeapSize / 1048576).toFixed(2) + ' MB', limit: (performance.memory.jsHeapSizeLimit / 1048576).toFixed(2) + ' MB' } : null, connections: STATE.connection, state: STATE }; logger.log(`Browser: ${data.browser.platform}`, 'info'); logger.log(`Online: ${data.browser.onLine}`, 'info'); if (data.performance) logger.log(`Memory: ${data.performance.used} / ${data.performance.limit}`, 'info'); eventBus.emit('diagnostics:complete', { data }); return data; } }; // ============ FILE OPERATIONS (IMPORT/EXPORT) ============ const FileOps = { write: async (filename, data) => { try { logger.log(`Saving: ${filename}`, 'info'); const blob = new Blob([typeof data === 'string' ? data : JSON.stringify(data, null, 2)], { type: 'text/plain' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = filename; a.click(); URL.revokeObjectURL(url); logger.log(`β Saved: ${filename}`, 'success'); return true; } catch (error) { logger.log(`Save error: ${error.message}`, 'error'); throw error; } }, read: async (file) => { try { logger.log(`Reading: ${file.name}`, 'info'); const text = await file.text(); const data = JSON.parse(text); logger.log(`β Loaded: ${file.name}`, 'success'); return data; } catch (error) { logger.log(`Read error: ${error.message}`, 'error'); throw error; } } }; // ============ UI CREATION ============ const UI = { createStyles: () => { const style = document.createElement('style'); style.textContent = ` .whiterabbit-terminal * { margin: 0; padding: 0; box-sizing: border-box; } .whiterabbit-terminal { font-family: 'Consolas', 'Monaco', monospace; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 100%); color: #00ff00; padding: 20px; overflow-y: auto; z-index: 999999; } .terminal-inner { max-width: 1400px; margin: 0 auto; } .terminal-inner h1 { text-align: center; color: #00ffff; text-shadow: 0 0 10px #00ffff; margin-bottom: 20px; font-size: 2.5em; } .terminal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; } @media (max-width: 768px) { .terminal-grid { grid-template-columns: 1fr; } } .terminal-panel { background: rgba(0, 255, 255, 0.05); border: 2px solid #00ffff; border-radius: 10px; padding: 20px; box-shadow: 0 0 20px rgba(0, 255, 255, 0.3); } .terminal-panel h2 { color: #00ffff; margin-bottom: 15px; border-bottom: 1px solid #00ffff; padding-bottom: 10px; } .terminal-panel input, .terminal-panel textarea { width: 100%; background: rgba(0, 0, 0, 0.5); border: 1px solid #00ff00; color: #00ff00; padding: 10px; border-radius: 5px; margin: 5px 0; font-family: inherit; } .terminal-panel button { background: linear-gradient(135deg, #00ff00 0%, #00ffff 100%); border: none; color: #000; padding: 10px 20px; border-radius: 5px; cursor: pointer; font-weight: bold; margin: 5px 5px 5px 0; transition: all 0.3s; } .terminal-panel button:hover { transform: scale(1.05); box-shadow: 0 0 20px rgba(0, 255, 255, 0.6); } .terminal-output { background: rgba(0, 0, 0, 0.8); border: 2px solid #00ff00; border-radius: 10px; padding: 15px; height: 400px; overflow-y: auto; font-size: 0.85em; line-height: 1.4; } .terminal-line { margin: 5px 0; } .terminal-line.success { color: #00ff00; } .terminal-line.error { color: #ff0000; } .terminal-line.info { color: #00ffff; } .terminal-line.warning { color: #ffff00; } .terminal-line.probe { color: #ffa500; font-weight: bold; } .terminal-line.data { color: #888; font-size: 0.9em; } .close-btn { position: fixed; top: 20px; right: 20px; background: #ff0000 !important; z-index: 1000000; padding: 15px 20px; } .stats { display: flex; gap: 20px; margin: 10px 0; } .stat { background: rgba(0, 0, 0, 0.3); padding: 10px; border-radius: 5px; text-align: center; } .stat-value { font-size: 1.5em; color: #00ffff; font-weight: bold; } .stat-label { font-size: 0.8em; color: #00ff00; } `; return style; }, init: () => { document.head.appendChild(UI.createStyles()); const container = document.createElement('div'); container.className = 'whiterabbit-terminal'; container.innerHTML = ` <button class="terminal-panel close-btn" onclick="window.whiteRabbit.destroy()">β Close</button> <div class="terminal-inner"> <h1>π° WHITERABBIT-NEO COMPLETE SYSTEM v9.0.0 π°</h1> <div class="terminal-grid"> <div class="terminal-panel"> <h2>π Ollama Connection</h2> <input type="text" id="ollamaUrl" placeholder="Server URL" value="http://127.0.0.1:11434"> <input type="text" id="modelName" placeholder="Model" value="jimscard/whiterabbit-neo:latest"> <div class="stats"> <div class="stat"> <div id="connStatus">β«</div> <div class="stat-label">Status</div> </div> </div> <button onclick="window.whiteRabbit.connect()">π Connect</button> <button onclick="window.whiteRabbit.disconnect()">π Disconnect</button> </div> <div class="terminal-panel"> <h2>π‘ Network & System</h2> <button onclick="window.whiteRabbit.probeWebsite()">π Probe Website</button> <button onclick="window.whiteRabbit.discoverIps()">π Discover IPs</button> <button onclick="window.whiteRabbit.diagnostics()">βοΈ Diagnostics</button> </div> </div> <div class="terminal-grid"> <div class="terminal-panel"> <h2>π¬ AI Prompt</h2> <textarea id="promptInput" placeholder="Enter prompt...">Hello WhiteRabbit-Neo!</textarea> <button onclick="window.whiteRabbit.send()">π€ Send</button> <button onclick="window.whiteRabbit.queue()">β Queue</button> <button onclick="window.whiteRabbit.saveResponse()">πΎ Save</button> </div> <div class="terminal-panel"> <h2>π Queue Status</h2> <div class="stats"> <div class="stat"><div class="stat-value" id="queuedCount">0</div><div class="stat-label">Queued</div></div> <div class="stat"><div class="stat-value" id="processingCount">0</div><div class="stat-label">Processing</div></div> <div class="stat"><div class="stat-value" id="completedCount">0</div><div class="stat-label">Completed</div></div> </div> <button onclick="window.whiteRabbit.clearQueue()">ποΈ Clear</button> <button onclick="window.whiteRabbit.pauseQueue()">βΈοΈ Pause</button> </div> </div> <div class="terminal-panel" style="grid-column: 1 / -1;"> <h2>π Terminal Output</h2> <div class="terminal-output" id="output"></div> <button onclick="window.whiteRabbit.clearTerminal()">ποΈ Clear</button> <button onclick="window.whiteRabbit.exportLogs()">π₯ Export Logs</button> <button onclick="window.whiteRabbit.exportData()">π Export Data</button> </div> </div> `; document.body.appendChild(container); logger.init('output'); } }; // ============ PUBLIC API ============ let ollamaClient = null; let lastResponse = ''; window.whiteRabbit = { init: () => { UI.init(); logger.log('βββββββββββββββββββββββββββββββββββββββ', 'probe'); logger.log('π° WHITERABBIT-NEO v9.0.0 COMPLETE π°', 'probe'); logger.log('βββββββββββββββββββββββββββββββββββββββ', 'probe'); logger.log('β Prototype Factory System', 'success'); logger.log('β Event Bus Integration', 'success'); logger.log('β CORS Bypass (3 methods)', 'success'); logger.log('β REST API Methods (GET/POST/PUT/PATCH/DELETE)', 'success'); logger.log('β WebSocket Manager (Auto-reconnect)', 'success'); logger.log('β GraphQL Client (Query/Mutation)', 'success'); logger.log('β SSE Manager (Server-Sent Events)', 'success'); logger.log('β Queue Management (Concurrent)', 'success'); logger.log('β Network Probe System', 'success'); logger.log('β IP Discovery System', 'success'); logger.log('β System Diagnostics', 'success'); logger.log('β Ollama AI Integration', 'success'); logger.log('β Import/Export Functions', 'success'); logger.log('β UI Terminal Interface', 'success'); logger.log('', 'info'); logger.log(`API Key: ${OLLAMA_API_KEY.substring(0, 10)}...`, 'info'); logger.log('All systems ready!', 'success'); STATE.system.initialized = true; eventBus.emit('system:initialized', {}); }, // REST API rest: { get: (endpoint) => RestAPI.get(endpoint), post: (endpoint, payload) => RestAPI.post(endpoint, payload), put: (endpoint, payload) => RestAPI.put(endpoint, payload), patch: (endpoint, payload) => RestAPI.patch(endpoint, payload), delete: (endpoint) => RestAPI.delete(endpoint) }, // WebSocket ws: { connect: (url) => WebSocketManager.connect(url), send: (data) => WebSocketManager.send(data), subscribe: (channel) => WebSocketManager.subscribe(channel), on: (type, handler) => WebSocketManager.on(type, handler), disconnect: () => WebSocketManager.disconnect(), isConnected: () => STATE.connection.websocket }, // GraphQL graphql: { execute: (query, endpoint) => GraphQLClient.execute(query, endpoint), mutation: (mutation, endpoint) => GraphQLClient.mutation(mutation, endpoint) }, // SSE sse: { connect: (url) => SSEManager.connect(url), on: (type, handler) => SSEManager.on(type, handler), disconnect: () => SSEManager.disconnect(), isConnected: () => STATE.connection.sse }, // Ollama connect: async () => { const url = document.getElementById('ollamaUrl').value; const model = document.getElementById('modelName').value; ollamaClient = new OllamaClient({ ...CONFIG.models.primary, server: url, fullName: model }); const connected = await ollamaClient.connect(); document.getElementById('connStatus').textContent = connected ? 'π’' : 'π΄'; return connected; }, disconnect: () => { if (ollamaClient) ollamaClient.disconnect(); document.getElementById('connStatus').textContent = 'π΄'; }, send: async () => { const prompt = document.getElementById('promptInput').value; if (!prompt) { logger.log('Enter a prompt', 'warning'); return; } if (!ollamaClient?.connected) { logger.log('Connect first', 'error'); return; } try { const response = await ollamaClient.generate(prompt); lastResponse = response; logger.log(`π ${Utils.truncate(response, 200)}`, 'info'); } catch (error) { logger.log(`Error: ${error.message}`, 'error'); } }, // Queue queue: () => { const prompt = document.getElementById('promptInput').value; if (!prompt) { logger.log('Enter a prompt', 'warning'); return; } if (!ollamaClient?.connected) { logger.log('Connect Ollama first', 'error'); return; } taskQueue.add( () => ollamaClient.generate(prompt), 0, { name: `Prompt: ${Utils.truncate(prompt, 30)}` } ); }, clearQueue: () => taskQueue.clear(), pauseQueue: () => taskQueue.pause(), getQueueStats: () => taskQueue.getStats(), // Network & Probe probeWebsite: async () => { return await NetworkProbe.probeWebsiteServices(); }, discoverIps: async () => { return await NetworkProbe.discoverLocalIps(); }, diagnostics: async () => { return await Diagnostics.system(); }, // File Operations saveResponse: async () => { if (!lastResponse) { logger.log('No response to save', 'warning'); return; } await FileOps.write(`response_${Date.now()}.txt`, lastResponse); }, save: async (filename, data) => { return await FileOps.write(filename, data); }, load: async (file) => { return await FileOps.read(file); }, exportLogs: async () => { return await FileOps.write(`logs_${Date.now()}.txt`, logger.export()); }, exportData: async () => { return await FileOps.write(`system_data_${Date.now()}.json`, STATE); }, exportState: async () => { return await FileOps.write(`state_${Date.now()}.json`, STATE); }, // Logger log: (message, type = 'info') => logger.log(message, type), clearLogs: () => logger.clear(), clearTerminal: () => logger.clear(), exportLogsText: () => logger.export(), // State getState: () => STATE, getStats: () => ({ logs: STATE.data.logs.length, responses: STATE.data.responses.length, probes: STATE.data.probes.length, queue: taskQueue.getStats(), connections: { ollama: STATE.connection.ollama.connected, websocket: STATE.connection.websocket, sse: STATE.connection.sse, backend: STATE.connection.backend } }), // Events on: (event, handler) => eventBus.on(event, handler), off: (event, handler) => eventBus.off(event, handler), emit: (event, data) => eventBus.emit(event, data), // Utilities truncate: Utils.truncate, formatDuration: Utils.formatDuration, formatBytes: Utils.formatBytes, // Connection Status status: () => ({ ollama: STATE.connection.ollama.connected ? 'Connected' : 'Disconnected', websocket: STATE.connection.websocket ? 'Connected' : 'Disconnected', sse: STATE.connection.sse ? 'Connected' : 'Disconnected', backend: STATE.connection.backend ? 'Connected' : 'Disconnected' }), // Cleanup destroy: () => { if (ollamaClient) ollamaClient.disconnect(); WebSocketManager.disconnect(); SSEManager.disconnect(); eventBus.clear(); STATE.data.logs = []; STATE.data.queue = []; const terminal = document.querySelector('.whiterabbit-terminal'); if (terminal) terminal.remove(); window.whiteRabbit = null; logger.log('System destroyed', 'warning'); } }; // ============ EVENT LISTENERS ============ eventBus.on('queue:updated', (data) => { console.log('π Queue updated:', data.stats); document.getElementById('queuedCount').textContent = data.stats.queued; document.getElementById('processingCount').textContent = data.stats.processing; document.getElementById('completedCount').textContent = data.stats.completed; }); eventBus.on('ollama:connected', (data) => { console.log('π° Ollama connected via:', data.mode); document.getElementById('connStatus').textContent = 'π’'; }); eventBus.on('ollama:disconnected', () => { document.getElementById('connStatus').textContent = 'π΄'; }); eventBus.on('response:generated', (data) => { console.log('π Response generated:', Utils.truncate(data.response, 100)); }); eventBus.on('websocket:connected', (data) => { console.log('π WebSocket connected:', data.url); }); eventBus.on('sse:connected', (data) => { console.log('π‘ SSE connected:', data.url); }); // ============ INITIALIZATION ============ window.whiteRabbit.init(); })();
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
API-Flaw Profit Guide
CSS | 18 min ago | 0.99 KB
This month smells like profit
CSS | 25 min ago | 0.99 KB
SchrΓΆdinger's Crit
1 day ago | 15.37 KB
PRCE internal cursor
2 days ago | 0.73 KB
AI Interaction Method
2 days ago | 1.60 KB
awkwrapper.c
C | 2 days ago | 2.35 KB
z66is_archive.zip.txt
2 days ago | 39.19 KB
Clients: Setting up 2FA
3 days ago | 1.44 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!