672 lines
16 KiB
HTML
672 lines
16 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>NEURAL-NET TERMINAL v2.1</title>
|
|
<style>
|
|
/* ============================================
|
|
AI BACKEND CONFIGURATION
|
|
Edit these settings to connect your AI
|
|
============================================ */
|
|
:root {
|
|
--crt-green: #33ff66;
|
|
--crt-green-dim: #1a8033;
|
|
--crt-green-bright: #66ff99;
|
|
--crt-bg: #0a0a0a;
|
|
--crt-bg-light: #0f1a0f;
|
|
--crt-border: #1a3d1a;
|
|
}
|
|
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
@font-face {
|
|
font-family: 'Terminal';
|
|
src: local('Courier New'), local('Consolas'), local('monospace');
|
|
}
|
|
|
|
body {
|
|
background: var(--crt-bg);
|
|
color: var(--crt-green);
|
|
font-family: 'Courier New', Consolas, monospace;
|
|
font-size: 14px;
|
|
line-height: 1.4;
|
|
min-height: 100vh;
|
|
overflow: hidden;
|
|
}
|
|
|
|
/* CRT Screen Effect */
|
|
.crt-overlay {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
pointer-events: none;
|
|
z-index: 1000;
|
|
}
|
|
|
|
.crt-overlay::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
background: repeating-linear-gradient(
|
|
0deg,
|
|
rgba(0, 0, 0, 0.15) 0px,
|
|
rgba(0, 0, 0, 0.15) 1px,
|
|
transparent 1px,
|
|
transparent 2px
|
|
);
|
|
}
|
|
|
|
.crt-overlay::after {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
background: radial-gradient(
|
|
ellipse at center,
|
|
transparent 0%,
|
|
rgba(0, 0, 0, 0.3) 100%
|
|
);
|
|
}
|
|
|
|
/* Terminal Container */
|
|
.terminal {
|
|
height: 100vh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
padding: 8px;
|
|
}
|
|
|
|
/* Header */
|
|
.header {
|
|
border: 1px solid var(--crt-green-dim);
|
|
padding: 8px 12px;
|
|
margin-bottom: 8px;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.header-title {
|
|
font-weight: bold;
|
|
letter-spacing: 2px;
|
|
}
|
|
|
|
.header-status {
|
|
display: flex;
|
|
gap: 16px;
|
|
font-size: 12px;
|
|
color: var(--crt-green-dim);
|
|
}
|
|
|
|
.status-indicator {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
}
|
|
|
|
.status-dot {
|
|
width: 8px;
|
|
height: 8px;
|
|
border-radius: 50%;
|
|
background: var(--crt-green-dim);
|
|
}
|
|
|
|
.status-dot.online {
|
|
background: var(--crt-green);
|
|
box-shadow: 0 0 6px var(--crt-green);
|
|
}
|
|
|
|
.status-dot.offline {
|
|
background: #ff3333;
|
|
box-shadow: 0 0 6px #ff3333;
|
|
}
|
|
|
|
/* Output Area */
|
|
.output {
|
|
flex: 1;
|
|
overflow-y: auto;
|
|
border: 1px solid var(--crt-green-dim);
|
|
padding: 12px;
|
|
margin-bottom: 8px;
|
|
scrollbar-width: none;
|
|
}
|
|
|
|
.output::-webkit-scrollbar {
|
|
display: none;
|
|
}
|
|
|
|
.output-line {
|
|
margin-bottom: 4px;
|
|
word-wrap: break-word;
|
|
}
|
|
|
|
.output-line.user {
|
|
color: var(--crt-green-bright);
|
|
}
|
|
|
|
.output-line.user::before {
|
|
content: '> ';
|
|
color: var(--crt-green-dim);
|
|
}
|
|
|
|
.output-line.system {
|
|
color: var(--crt-green-dim);
|
|
font-style: italic;
|
|
}
|
|
|
|
.output-line.ai {
|
|
color: var(--crt-green);
|
|
padding-left: 2ch;
|
|
}
|
|
|
|
.output-line.error {
|
|
color: #ff6666;
|
|
}
|
|
|
|
/* Input Area */
|
|
.input-area {
|
|
border: 1px solid var(--crt-green-dim);
|
|
padding: 8px 12px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.input-prompt {
|
|
color: var(--crt-green);
|
|
font-weight: bold;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.input-field {
|
|
flex: 1;
|
|
background: transparent;
|
|
border: none;
|
|
outline: none;
|
|
color: var(--crt-green);
|
|
font-family: inherit;
|
|
font-size: inherit;
|
|
caret-color: var(--crt-green);
|
|
caret-shape: block;
|
|
}
|
|
|
|
.input-field::placeholder {
|
|
color: var(--crt-green-dim);
|
|
}
|
|
|
|
/* Footer */
|
|
.footer {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
padding: 4px 0;
|
|
font-size: 11px;
|
|
color: var(--crt-green-dim);
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
/* Config Panel */
|
|
.config-panel {
|
|
display: none;
|
|
position: fixed;
|
|
top: 50%;
|
|
left: 50%;
|
|
transform: translate(-50%, -50%);
|
|
background: var(--crt-bg);
|
|
border: 2px solid var(--crt-green);
|
|
padding: 20px;
|
|
z-index: 100;
|
|
min-width: 400px;
|
|
max-width: 90vw;
|
|
}
|
|
|
|
.config-panel.visible {
|
|
display: block;
|
|
}
|
|
|
|
.config-panel h2 {
|
|
margin-bottom: 16px;
|
|
font-size: 14px;
|
|
letter-spacing: 2px;
|
|
}
|
|
|
|
.config-group {
|
|
margin-bottom: 12px;
|
|
}
|
|
|
|
.config-group label {
|
|
display: block;
|
|
margin-bottom: 4px;
|
|
color: var(--crt-green-dim);
|
|
font-size: 12px;
|
|
}
|
|
|
|
.config-group input,
|
|
.config-group select {
|
|
width: 100%;
|
|
background: var(--crt-bg-light);
|
|
border: 1px solid var(--crt-green-dim);
|
|
color: var(--crt-green);
|
|
padding: 6px 8px;
|
|
font-family: inherit;
|
|
font-size: 13px;
|
|
}
|
|
|
|
.config-group input:focus,
|
|
.config-group select:focus {
|
|
outline: none;
|
|
border-color: var(--crt-green);
|
|
}
|
|
|
|
.config-buttons {
|
|
display: flex;
|
|
gap: 8px;
|
|
margin-top: 16px;
|
|
}
|
|
|
|
.config-btn {
|
|
flex: 1;
|
|
background: transparent;
|
|
border: 1px solid var(--crt-green-dim);
|
|
color: var(--crt-green);
|
|
padding: 8px;
|
|
font-family: inherit;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.config-btn:hover {
|
|
background: var(--crt-green-dim);
|
|
color: var(--crt-bg);
|
|
}
|
|
|
|
.config-btn.primary {
|
|
border-color: var(--crt-green);
|
|
}
|
|
|
|
/* Screen flicker animation */
|
|
@keyframes flicker {
|
|
0%, 100% { opacity: 1; }
|
|
92% { opacity: 1; }
|
|
93% { opacity: 0.8; }
|
|
94% { opacity: 1; }
|
|
}
|
|
|
|
.terminal {
|
|
animation: flicker 8s infinite;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="crt-overlay"></div>
|
|
|
|
<div class="terminal">
|
|
<div class="header">
|
|
<span class="header-title">NEURAL-NET TERMINAL v2.1</span>
|
|
<div class="header-status">
|
|
<div class="status-indicator">
|
|
<span class="status-dot" id="statusDot"></span>
|
|
<span id="statusText">OFFLINE</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="output" id="output">
|
|
<div class="output-line system">NEURAL-NET TERMINAL v2.1 initialized</div>
|
|
<div class="output-line system">Type 'help' for available commands</div>
|
|
<div class="output-line system">Type 'config' to configure AI backend</div>
|
|
<div class="output-line system">─────────────────────────────────────</div>
|
|
</div>
|
|
|
|
<div class="input-area">
|
|
<span class="input-prompt">$</span>
|
|
<input type="text" class="input-field" id="inputField" placeholder="Enter command..." autofocus>
|
|
</div>
|
|
|
|
<div class="footer">
|
|
<span>COMMANDS: help | config | clear</span>
|
|
<span id="timeDisplay"></span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Config Panel -->
|
|
<div class="config-panel" id="configPanel">
|
|
<h2>[ AI BACKEND CONFIGURATION ]</h2>
|
|
|
|
<div class="config-group">
|
|
<label>PRESET</label>
|
|
<select id="presetSelect">
|
|
<option value="custom">Custom</option>
|
|
<option value="ollama">Ollama (localhost:11434)</option>
|
|
<option value="lmstudio">LM Studio (localhost:1234)</option>
|
|
<option value="gpt4all">GPT4All (localhost:4891)</option>
|
|
<option value="catgpt">Cat GPT (192.168.254.169)</option>
|
|
<option value="openai">OpenAI API</option>
|
|
<option value="claude">Claude API (Anthropic)</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="config-group">
|
|
<label>ENDPOINT URL</label>
|
|
<input type="text" id="endpointInput" placeholder="http://localhost:11434/api/chat">
|
|
</div>
|
|
|
|
<div class="config-group">
|
|
<label>MODEL NAME</label>
|
|
<input type="text" id="modelInput" placeholder="llama2">
|
|
</div>
|
|
|
|
<div class="config-group">
|
|
<label>API KEY (optional)</label>
|
|
<input type="text" id="apiKeyInput" placeholder="Leave empty for local models" autocomplete="off" data-form-type="other">
|
|
</div>
|
|
|
|
<div class="config-buttons">
|
|
<button class="config-btn" onclick="closeConfig()">CANCEL</button>
|
|
<button class="config-btn" onclick="testConnection()">TEST</button>
|
|
<button class="config-btn primary" onclick="saveConfig()">SAVE</button>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
/* ============================================
|
|
AI CONFIGURATION
|
|
============================================ */
|
|
let aiConfig = {
|
|
enabled: false,
|
|
endpoint: '',
|
|
model: '',
|
|
apiKey: '',
|
|
type: 'openai'
|
|
};
|
|
|
|
// Load saved config
|
|
const savedConfig = localStorage.getItem('neuralTerminalConfig');
|
|
if (savedConfig) {
|
|
aiConfig = JSON.parse(savedConfig);
|
|
}
|
|
|
|
/* ============================================
|
|
TERMINAL STATE
|
|
============================================ */
|
|
const output = document.getElementById('output');
|
|
const inputField = document.getElementById('inputField');
|
|
const statusDot = document.getElementById('statusDot');
|
|
const statusText = document.getElementById('statusText');
|
|
const timeDisplay = document.getElementById('timeDisplay');
|
|
const configPanel = document.getElementById('configPanel');
|
|
|
|
let commandHistory = [];
|
|
let historyIndex = -1;
|
|
let isProcessing = false;
|
|
|
|
/* ============================================
|
|
UI
|
|
============================================ */
|
|
function updateStatus() {
|
|
if (aiConfig.enabled) {
|
|
statusDot.className = 'status-dot online';
|
|
statusText.textContent = 'ONLINE';
|
|
} else {
|
|
statusDot.className = 'status-dot offline';
|
|
statusText.textContent = 'OFFLINE';
|
|
}
|
|
}
|
|
|
|
function updateTime() {
|
|
const now = new Date();
|
|
timeDisplay.textContent = now.toLocaleTimeString('en-US', { hour12: false });
|
|
}
|
|
|
|
function addLine(text, type = '') {
|
|
const line = document.createElement('div');
|
|
line.className = 'output-line' + (type ? ' ' + type : '');
|
|
line.textContent = text;
|
|
output.appendChild(line);
|
|
output.scrollTop = output.scrollHeight;
|
|
}
|
|
|
|
function clearOutput() {
|
|
output.innerHTML = '';
|
|
addLine('Screen cleared', 'system');
|
|
}
|
|
|
|
/* ============================================
|
|
CONFIG PANEL
|
|
============================================ */
|
|
function openConfig() {
|
|
document.getElementById('endpointInput').value = aiConfig.endpoint;
|
|
document.getElementById('modelInput').value = aiConfig.model;
|
|
document.getElementById('apiKeyInput').value = aiConfig.apiKey;
|
|
configPanel.classList.add('visible');
|
|
}
|
|
|
|
function closeConfig() {
|
|
configPanel.classList.remove('visible');
|
|
inputField.focus();
|
|
}
|
|
|
|
function saveConfig() {
|
|
aiConfig.endpoint = document.getElementById('endpointInput').value.trim();
|
|
aiConfig.model = document.getElementById('modelInput').value.trim();
|
|
aiConfig.apiKey = document.getElementById('apiKeyInput').value.trim();
|
|
aiConfig.enabled = aiConfig.endpoint !== '' && aiConfig.model !== '';
|
|
|
|
localStorage.setItem('neuralTerminalConfig', JSON.stringify(aiConfig));
|
|
updateStatus();
|
|
closeConfig();
|
|
addLine('Configuration saved', 'system');
|
|
}
|
|
|
|
/* ============================================
|
|
TEST CONNECTION (FIXED)
|
|
============================================ */
|
|
async function testConnection() {
|
|
const endpoint = document.getElementById('endpointInput').value.trim();
|
|
|
|
if (!endpoint) {
|
|
alert('Please enter endpoint');
|
|
return;
|
|
}
|
|
|
|
try {
|
|
// ONLY OpenAI-style test
|
|
const testUrl = endpoint.replace('/chat/completions', '/models');
|
|
|
|
const response = await fetch(testUrl, {
|
|
method: 'GET',
|
|
headers: aiConfig.apiKey
|
|
? { 'Authorization': 'Bearer ' + aiConfig.apiKey }
|
|
: {}
|
|
});
|
|
|
|
if (response.ok) {
|
|
alert('Connection successful!');
|
|
} else {
|
|
alert('Connection failed: ' + response.status);
|
|
}
|
|
} catch (e) {
|
|
alert('Connection error: ' + e.message);
|
|
}
|
|
}
|
|
|
|
/* ============================================
|
|
PRESETS (CLEAN)
|
|
============================================ */
|
|
document.getElementById('presetSelect').addEventListener('change', function () {
|
|
const presets = {
|
|
catgpt: {
|
|
endpoint: 'http://192.168.254.169:4891/v1/chat/completions',
|
|
model: 'cat-gpt',
|
|
type: 'openai'
|
|
},
|
|
|
|
local: {
|
|
endpoint: 'http://localhost:4891/v1/chat/completions',
|
|
model: 'local-model',
|
|
type: 'openai'
|
|
},
|
|
openai: {
|
|
endpoint: 'https://api.openai.com/v1/chat/completions',
|
|
model: 'gpt-4o-mini',
|
|
type: 'openai'
|
|
},
|
|
claude: {
|
|
endpoint: 'https://api.anthropic.com/v1/messages',
|
|
model: 'claude-sonnet-4-20250514',
|
|
type: 'claude'
|
|
}
|
|
};
|
|
|
|
const preset = presets[this.value];
|
|
if (preset) {
|
|
document.getElementById('endpointInput').value = preset.endpoint;
|
|
document.getElementById('modelInput').value = preset.model;
|
|
aiConfig.type = preset.type;
|
|
}
|
|
});
|
|
|
|
/* ============================================
|
|
HELPERS
|
|
============================================ */
|
|
function getFormattedDate() {
|
|
const now = new Date();
|
|
return `${String(now.getDate()).padStart(2, '0')}/${
|
|
String(now.getMonth() + 1).padStart(2, '0')
|
|
}/${now.getFullYear()}:${String(now.getHours()).padStart(2, '0')}/${
|
|
String(now.getMinutes()).padStart(2, '0')
|
|
}/${String(now.getSeconds()).padStart(2, '0')}`;
|
|
}
|
|
|
|
function getStatusInfo() {
|
|
return `[Connection: ${aiConfig.enabled ? 'ONLINE' : 'OFFLINE'}, Endpoint: ${aiConfig.endpoint || 'none'}, Model: ${aiConfig.model || 'none'}]`;
|
|
}
|
|
|
|
function preprocessMessage(message) {
|
|
return message
|
|
.replace(/\bdate\b/gi, `date (${getFormattedDate()})`)
|
|
.replace(/\bstatus\b/gi, `status ${getStatusInfo()}`);
|
|
}
|
|
|
|
/* ============================================
|
|
AI CALL (OPENAI ONLY)
|
|
============================================ */
|
|
async function queryAI(message) {
|
|
if (!aiConfig.enabled) {
|
|
addLine('AI is offline. Use config to connect.', 'error');
|
|
return;
|
|
}
|
|
|
|
isProcessing = true;
|
|
|
|
const processedMessage = preprocessMessage(message);
|
|
|
|
try {
|
|
const headers = { 'Content-Type': 'application/json' };
|
|
|
|
if (aiConfig.apiKey) {
|
|
headers['Authorization'] = 'Bearer ' + aiConfig.apiKey;
|
|
}
|
|
|
|
const response = await fetch(aiConfig.endpoint, {
|
|
method: 'POST',
|
|
headers,
|
|
body: JSON.stringify({
|
|
model: aiConfig.model,
|
|
messages: [{ role: 'user', content: processedMessage }],
|
|
stream: false
|
|
})
|
|
});
|
|
|
|
const data = await response.json();
|
|
|
|
if (data.choices && data.choices[0]) {
|
|
addLine(data.choices[0].message.content, 'ai');
|
|
} else if (data.error) {
|
|
addLine('Error: ' + (data.error.message || data.error), 'error');
|
|
} else {
|
|
addLine('Invalid response from server', 'error');
|
|
}
|
|
} catch (e) {
|
|
addLine('Connection error: ' + e.message, 'error');
|
|
}
|
|
|
|
isProcessing = false;
|
|
}
|
|
|
|
/* ============================================
|
|
COMMANDS
|
|
============================================ */
|
|
function processCommand(input) {
|
|
const trimmed = input.trim();
|
|
if (!trimmed) return;
|
|
|
|
addLine(trimmed, 'user');
|
|
commandHistory.unshift(trimmed);
|
|
historyIndex = -1;
|
|
|
|
switch (trimmed.toLowerCase()) {
|
|
case 'help':
|
|
addLine('help | config | clear | date | status', 'system');
|
|
break;
|
|
|
|
case 'config':
|
|
openConfig();
|
|
break;
|
|
|
|
case 'clear':
|
|
clearOutput();
|
|
break;
|
|
|
|
case 'date':
|
|
addLine(getFormattedDate(), 'system');
|
|
break;
|
|
|
|
case 'status':
|
|
addLine(getStatusInfo(), 'system');
|
|
break;
|
|
|
|
default:
|
|
queryAI(trimmed);
|
|
}
|
|
}
|
|
|
|
/* ============================================
|
|
INPUT
|
|
============================================ */
|
|
inputField.addEventListener('keydown', (e) => {
|
|
if (e.key === 'Enter' && !isProcessing) {
|
|
processCommand(inputField.value);
|
|
inputField.value = '';
|
|
}
|
|
});
|
|
|
|
/* ============================================
|
|
INIT
|
|
============================================ */
|
|
updateStatus();
|
|
updateTime();
|
|
setInterval(updateTime, 1000);
|
|
inputField.focus();
|
|
|
|
document.addEventListener('click', (e) => {
|
|
if (!configPanel.contains(e.target)) {
|
|
inputField.focus();
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|