diff --git a/config.json b/config.json new file mode 100644 index 0000000..56b857a --- /dev/null +++ b/config.json @@ -0,0 +1,47 @@ +{ + "minecraft_version": "1.21.1", // supports up to 1.21.1 + "host": "127.0.0.1", // or "localhost", "your.ip.address.here" + "port": 55916, + "auth": "offline", // or "microsoft" + + // the mindserver manages all agents and hosts the UI + "host_mindserver": true, // if true, the mindserver will be hosted on this machine. otherwise, specify a public IP address + "mindserver_host": "localhost", + "mindserver_port": 8080, + + // the base profile is shared by all bots for default prompts/examples/modes + "base_profile": "./profiles/defaults/survival.json", // also see creative.json, god_mode.json + "profiles": [ + "./andy.json", + // "./profiles/gpt.json", + // "./profiles/claude.json", + // "./profiles/gemini.json", + // "./profiles/llama.json", + // "./profiles/qwen.json", + // "./profiles/grok.json", + // "./profiles/mistral.json", + // "./profiles/deepseek.json", + + // using more than 1 profile requires you to /msg each bot indivually + // individual profiles override values from the base profile + ], + "load_memory": false, // load memory from previous session + "init_message": "Respond with hello world and your name", // sends to all on spawn + "only_chat_with": [], // users that the bots listen to and send general messages to. if empty it will chat publicly + "speak": false, // allows all bots to speak through system text-to-speech. works on windows, mac, on linux you need to `apt install espeak` + "language": "en", // translate to/from this language. Supports these language names: https://cloud.google.com/translate/docs/languages + "show_bot_views": false, // show bot's view in browser at localhost:3000, 3001... + + "allow_insecure_coding": false, // allows newAction command and model can write/run code on your computer. enable at own risk + "allow_vision": false, // allows vision model to interpret screenshots as inputs + "blocked_actions" : [], // commands to disable and remove from docs. Ex: ["!setMode"] + "code_timeout_mins": -1, // minutes code is allowed to run. -1 for no timeout + "relevant_docs_count": 5, // number of relevant code function docs to select for prompting. -1 for all + + "max_messages": 15, // max number of messages to keep in context + "num_examples": 2, // number of examples to give to the model + "max_commands": -1, // max number of commands that can be used in consecutive responses. -1 for no limit + "verbose_commands": true, // show full command syntax + "narrate_behavior": true, // chat simple automatic actions ('Picking up item!') + "chat_bot_messages": true, // publicly chat messages to other bots +} \ No newline at end of file diff --git a/settings.js b/settings.js index b782097..e49c939 100644 --- a/settings.js +++ b/settings.js @@ -1,3 +1,6 @@ +import fs from 'fs'; +import path from 'path'; + const settings = { "minecraft_version": "1.21.1", // supports up to 1.21.1 "host": "127.0.0.1", // or "localhost", "your.ip.address.here" @@ -47,6 +50,24 @@ const settings = { "log_all_prompts": false, // log ALL prompts to file } +const configPath = path.resolve('./src/server/saved_settings.json'); // This is to save user-modified settings edited via the Mindserver. +if(fs.existsSync(configPath)) { + try { + const newSettings = JSON.parse(fs.readFileSync(configPath, 'utf8')); + Object.assign(settings, newSettings); + } catch (error) { + console.error("Error reading config.json. Using default settings.", error); + } +} else { + fs.writeFileSync(configPath, JSON.stringify(settings, null, 4)) +} + +// Function to update settings +export function updateSettings(newSettings) { + Object.assign(settings, newSettings); + fs.writeFileSync(configPath, JSON.stringify(settings, null, 4)); +} + // these environment variables override certain settings if (process.env.MINECRAFT_PORT) { settings.port = process.env.MINECRAFT_PORT; diff --git a/src/server/mind_server.js b/src/server/mind_server.js index eed71d7..165cb01 100644 --- a/src/server/mind_server.js +++ b/src/server/mind_server.js @@ -3,6 +3,8 @@ import express from 'express'; import http from 'http'; import path from 'path'; import { fileURLToPath } from 'url'; +import settings, { updateSettings } from '../../settings.js'; +import fs from 'fs'; // Module-level variables let io; @@ -128,6 +130,27 @@ export function createMindServer(port = 8080) { console.error('Error: ', error); } }); + + socket.on('get-settings', (callback) => { + callback(settings); + }); + + socket.on('update-settings', (newSettings) => { + updateSettings(newSettings); + }); + + socket.on('get-profile-dir', (callback) => { + const profileDir = path.join(__dirname, '../../profiles/'); + fs.readdir(profileDir, (err, files) => { + if (err) { + console.error("Could not list the profiles.", err); + callback([]); + } + + const fileNames = files.filter(file => file.endsWith('.json')).map(file => './profiles/' + file); + callback(fileNames); + }); + }); }); server.listen(port, 'localhost', () => { diff --git a/src/server/public/index.html b/src/server/public/index.html index c66a986..6dee613 100644 --- a/src/server/public/index.html +++ b/src/server/public/index.html @@ -1,68 +1,135 @@ - + Mindcraft - + + +

Mindcraft

-
+
+
+

Edit Settings

+ + +
- + diff --git a/src/server/public/styles.css b/src/server/public/styles.css new file mode 100644 index 0000000..7f22d1e --- /dev/null +++ b/src/server/public/styles.css @@ -0,0 +1,139 @@ +body { + font-family: Arial, sans-serif; + margin: 20px; + background: #1a1a1a; + color: #e0e0e0; +} + +.container { + background: #2d2d2d; + padding: 20px; + border-radius: 8px; + box-shadow: 0 2px 4px rgba(0,0,0,0.2); + margin:20px; +} + +.miniContainer { + background: linear-gradient(to bottom, #414141, #3f3f3f); + padding: 10px; + border-radius: 8px; + box-shadow: 0 2px 4px rgba(0,0,0,0.2); + margin: 10px; +} + +.formOption { + background: #2d2d2d4f; + backdrop-filter: blur(10px); + padding: 10px; + border-radius:4px; + box-shadow: 0 2px 4px rgba(0,0,0,0.2); + margin:10px; +} + +input[type="text"], input[type="number"], select { + background: #cfcfcf; + color: #000; + border-radius: 4px; + padding:5px; + border: none; +} + +h1 { + color: #ffffff; +} + +h5 { + margin-bottom:0; +} + +code { + background:#aaaaaa; + border-radius:4px; + padding:4px; + color:#000; +} + +.list-item { + display: flex; + align-items: center; + margin-bottom: 10px; +} + +.list-item input[type="text"] { + margin-right: 10px; +} + +.list-item input[type="checkbox"] { + margin-right: 10px; +} + +.list-item .name.not-selected { + text-decoration: line-through; + color: #929292 +} + +.agent { + margin: 10px 0; + padding: 10px; + background: #363636; + border-radius: 4px; + display: flex; + justify-content: space-between; + align-items: center; +} + +button { + color: white; + border: none; + padding: 5px 10px; + border-radius: 4px; + cursor: pointer; + margin-left: 5px; + transition: all 0.3s ease; + background: #5c5c5c +} + +button:hover { + background: #444; +} + +.add-btn { + display: flex; + flex-direction: row; + align-items: center; + padding: 3px 10px; + justify-content: space-between; +} + +.add-btn svg { + margin-right: 5px; +} + +.green-btn { + background: #4CAF50; +} + +.blue-btn { + background: #2196F3; +} + +.red-btn { + background: #f44336; +} + +.green-btn:hover { background: #45a049; } +.blue-btn:hover { background: #1976D2; } +.red-btn:hover { background: #d32f2f; } + +.status-icon { + font-size: 12px; + margin-right: 8px; +} + +.status-icon.online { + color: #4CAF50; +} + +.status-icon.offline { + color: #f44336; +} \ No newline at end of file diff --git a/src/server/saved_settings.json b/src/server/saved_settings.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/src/server/saved_settings.json @@ -0,0 +1 @@ +{} \ No newline at end of file