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 @@ - +