diff --git a/settings.js b/settings.js index 4e191ec..19e1cc8 100644 --- a/settings.js +++ b/settings.js @@ -28,7 +28,7 @@ const settings = { "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 - "render_bot_views": false, // show bot's view in browser at localhost:3000, 3001... + "render_bot_view": 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 diff --git a/src/agent/agent.js b/src/agent/agent.js index 7bc692d..d989f24 100644 --- a/src/agent/agent.js +++ b/src/agent/agent.js @@ -23,10 +23,10 @@ export class Agent { this.count_id = count_id; // Initialize components with more detailed error handling - console.log(`Initializing agent ${this.name}...`); this.actions = new ActionManager(this); this.prompter = new Prompter(this, settings.profile); this.name = this.prompter.getName(); + console.log(`Initializing agent ${this.name}...`); this.history = new History(this); this.coder = new Coder(this); this.npc = new NPCContoller(this); diff --git a/src/mindcraft/default_settings.json b/src/mindcraft/default_settings.json deleted file mode 100644 index 3ec448b..0000000 --- a/src/mindcraft/default_settings.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "minecraft_version": "1.21.1", - "host": "127.0.0.1", - "port": 55916, - "auth": "offline", - "base_profile": "survival", - "load_memory": false, - "init_message": "Respond with hello world and your name", - "only_chat_with": [], - "speak": false, - "language": "en", - "allow_vision": false, - "blocked_actions" : ["!checkBlueprint", "!checkBlueprintLevel", "!getBlueprint", "!getBlueprintLevel"] , - "relevant_docs_count": 5, - "max_messages": 15, - "num_examples": 2, - "max_commands": -1, - "narrate_behavior": true, - "log_all_prompts": false, - "verbose_commands": true, - "chat_bot_messages": true, - "render_bot_view": false, - "allow_insecure_coding": false, - "code_timeout_mins": -1 -} \ No newline at end of file diff --git a/src/mindcraft/mindserver.js b/src/mindcraft/mindserver.js index 4449a23..c5b1c3a 100644 --- a/src/mindcraft/mindserver.js +++ b/src/mindcraft/mindserver.js @@ -16,7 +16,7 @@ let io; let server; const agent_connections = {}; -const default_settings = JSON.parse(readFileSync(path.join(__dirname, 'default_settings.json'), 'utf8')); +const settings_spec = JSON.parse(readFileSync(path.join(__dirname, 'public/settings_spec.json'), 'utf8')); class AgentConnection { constructor(settings) { @@ -58,7 +58,22 @@ export function createMindServer(host_public = false, port = 8080) { socket.on('create-agent', (settings, callback) => { console.log('API create agent...'); - settings = { ...default_settings, ...settings }; + for (let key in settings_spec) { + if (!(key in settings)) { + if (settings_spec[key].required) { + callback({ success: false, error: `Setting ${key} is required` }); + return; + } + else { + settings[key] = settings_spec[key].default; + } + } + } + for (let key in settings) { + if (!(key in settings_spec)) { + delete settings[key]; + } + } if (settings.profile?.name) { if (settings.profile.name in agent_connections) { callback({ success: false, error: 'Agent already exists' }); diff --git a/src/mindcraft/public/index.html b/src/mindcraft/public/index.html index f16105c..fd9f10b 100644 --- a/src/mindcraft/public/index.html +++ b/src/mindcraft/public/index.html @@ -58,97 +58,229 @@ .status-icon.offline { color: #f44336; } + #settingsForm { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); + gap: 8px; + margin-top: 10px; + } + .setting-wrapper { + display: flex; + align-items: center; + gap: 6px; + background: #3a3a3a; + padding: 6px 8px; + border-radius: 4px; + width: 100%; + box-sizing: border-box; + min-width: 0; + } + .setting-wrapper label { + flex: 0 0 50%; + font-size: 0.9em; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + .setting-wrapper input[type="text"], + .setting-wrapper input[type="number"] { + flex: 1 1 0; + background: #262626; + border: 1px solid #555; + color: #e0e0e0; + border-radius: 4px; + padding: 4px 6px; + max-width: 100%; + min-width: 0; + } + .setting-wrapper input[type="checkbox"] { + transform: scale(1.2); + } + .agent-viewer { + width: 200px; + height: 150px; + border: none; + margin-left: 10px; + } + .start-btn:disabled { + opacity: 0.4; + cursor: not-allowed; + } + .agent-view-container { + margin-top: 6px; + display: flex; + justify-content: flex-start; + }