From 6bc751daebce1cef82d123d541c555e1c9a99bde Mon Sep 17 00:00:00 2001 From: uukelele-scratch Date: Sun, 9 Mar 2025 15:55:19 +0000 Subject: [PATCH 01/16] update gemini model version to 2.0-flash --- profiles/gemini.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/profiles/gemini.json b/profiles/gemini.json index 4f3cf43..9331aed 100644 --- a/profiles/gemini.json +++ b/profiles/gemini.json @@ -1,7 +1,7 @@ { "name": "gemini", - "model": "gemini-1.5-flash", + "model": "gemini-2.0-flash", "cooldown": 10000 } \ No newline at end of file From 8a00fed3a445d5349177cb946f24bf3cfa8e29e1 Mon Sep 17 00:00:00 2001 From: uukelele-scratch Date: Wed, 19 Mar 2025 15:28:27 +0000 Subject: [PATCH 02/16] add function to update settings dynamically --- settings.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/settings.js b/settings.js index e63c9fb..1ad5fa7 100644 --- a/settings.js +++ b/settings.js @@ -46,6 +46,11 @@ const settings = { "chat_bot_messages": true, // publicly chat messages to other bots } +// Function to update settings +export function updateSettings(newSettings) { + return Object.assign(settings, newSettings); +} + // these environment variables override certain settings if (process.env.MINECRAFT_PORT) { settings.port = process.env.MINECRAFT_PORT; From ee08e64cf8f2bd0776fa4a00ec7da5a987a93993 Mon Sep 17 00:00:00 2001 From: uukelele-scratch Date: Wed, 19 Mar 2025 15:42:36 +0000 Subject: [PATCH 03/16] create a styles.css file as I plan to add more html files to the mindserver --- src/server/public/index.html | 69 ++++-------------------------------- src/server/public/styles.css | 65 +++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 62 deletions(-) create mode 100644 src/server/public/styles.css diff --git a/src/server/public/index.html b/src/server/public/index.html index c66a986..6cb40a2 100644 --- a/src/server/public/index.html +++ b/src/server/public/index.html @@ -3,62 +3,7 @@ Mindcraft - +

Mindcraft

@@ -80,7 +25,7 @@ ${agent.in_game ? ` - + ` : ` `} @@ -111,10 +56,10 @@ function shutdown() { socket.emit('shutdown'); } - - function sendMessage(agentName, message) { - socket.emit('send-message', agentName, message) - } + + function sendMessage(agentName, message) { + socket.emit('send-message', agentName, message) + } - + diff --git a/src/server/public/styles.css b/src/server/public/styles.css new file mode 100644 index 0000000..92975ae --- /dev/null +++ b/src/server/public/styles.css @@ -0,0 +1,65 @@ +body { + font-family: Arial, sans-serif; + margin: 20px; + background: #1a1a1a; + color: #e0e0e0; +} + +#agents { + background: #2d2d2d; + padding: 20px; + border-radius: 8px; + box-shadow: 0 2px 4px rgba(0,0,0,0.2); +} + +h1 { + color: #ffffff; +} + +.agent { + margin: 10px 0; + padding: 10px; + background: #363636; + border-radius: 4px; + display: flex; + justify-content: space-between; + align-items: center; +} + +.restart-btn, .start-btn, .stop-btn { + color: white; + border: none; + padding: 5px 10px; + border-radius: 4px; + cursor: pointer; + margin-left: 5px; +} + +.restart-btn { + background: #4CAF50; +} + +.start-btn { + background: #2196F3; +} + +.stop-btn { + background: #f44336; +} + +.restart-btn:hover { background: #45a049; } +.start-btn:hover { background: #1976D2; } +.stop-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 From b236f2072bf4d0363cc2b7a4dd3bf180c8e660ca Mon Sep 17 00:00:00 2001 From: uukelele-scratch Date: Wed, 19 Mar 2025 20:37:20 +0000 Subject: [PATCH 04/16] Added settings frontend, mostly complete, excluding profile and only chat with list --- src/server/public/index.html | 126 +++++++++++++++++++++++++++++++++-- src/server/public/styles.css | 44 +++++++++--- 2 files changed, 155 insertions(+), 15 deletions(-) diff --git a/src/server/public/index.html b/src/server/public/index.html index 6cb40a2..ecd2390 100644 --- a/src/server/public/index.html +++ b/src/server/public/index.html @@ -7,7 +7,119 @@

Mindcraft

-
+
+
+

Edit settings

+
+ Edits won't take effect until restarting Mindcraft. +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
The base profile is shared by all bots for default prompts/examples/modes
+
+
+ +

I'll do this last, once I've finished the other settings options. It will take the style of a todo list app, with the delete/add/checkbox functionality.

+
+
+ + Yes + No +
+
+ + +
This message gets sent to all bots on spawn.
+
+
+ +

Will copy the style of the profile list once I've finished with that.

+
users that the bots listen to and send general messages to. if empty it will chat publicly
+
+
+ + Yes + No +
Allows all bots to speak through system text-to-speech.
This works on Windows and Mac, but on Linux you may need to run sudo apt install espeak first.
+
+
+ + +
Translates chat into specified language. Supported languages
+
+
+ + Yes + No +
Only supports 1.20.4 and previous versions.
These can be accessed at http://localhost:3000, 3001, 3002, etc. depending on which bot you want to view.
+
+
+ + Yes + No +
Allows newAction command and model can write/run code on your computer. Enable at your own risk (it's fine if nobody untrustworthy is playing with your bot).
+
+
+ + Yes + No +
Allows the vision model to interpret screenshots as inputs. Requires version 1.20.4 or less.
+
+
+ +

Will copy the style of the profile list once I've finished with that.

+
+
+ + +
Maximum number of previous messages to keep in context. Increasing it may produce longer response times and higher cost if using a paid API, but with the benefit of increasing memory.
+
+
+ + Yes + No +
Show full command syntax.
+
+
+ + Yes + No +
Chat simple, automatic actions for example Picking up item!
+
+
+ + Yes + No +
Publicly chat messages to other bots.
+
+
diff --git a/src/server/public/styles.css b/src/server/public/styles.css index 51bb8ec..1b88d7d 100644 --- a/src/server/public/styles.css +++ b/src/server/public/styles.css @@ -14,7 +14,8 @@ body { } .formOption { - background: #575757; + background: #5757574f; + backdrop-filter: blur(10px); padding: 10px; border-radius:4px; box-shadow: 0 2px 4px rgba(0,0,0,0.2); @@ -44,6 +45,24 @@ code { 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; +} + .agent { margin: 10px 0; padding: 10px; From 14d5f0b280b379a82519c476e5b7c8d57c7459da Mon Sep 17 00:00:00 2001 From: uukelele-scratch Date: Thu, 20 Mar 2025 08:00:06 +0000 Subject: [PATCH 07/16] added get settings function from mindserver --- src/server/mind_server.js | 5 +++++ src/server/public/index.html | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/src/server/mind_server.js b/src/server/mind_server.js index eed71d7..50d5014 100644 --- a/src/server/mind_server.js +++ b/src/server/mind_server.js @@ -3,6 +3,7 @@ import express from 'express'; import http from 'http'; import path from 'path'; import { fileURLToPath } from 'url'; +import settings from '../../settings.js'; // Module-level variables let io; @@ -128,6 +129,10 @@ export function createMindServer(port = 8080) { console.error('Error: ', error); } }); + + socket.on('get-settings', (callback) => { + callback(JSON.stringify(settings)); + }) }); server.listen(port, 'localhost', () => { diff --git a/src/server/public/index.html b/src/server/public/index.html index cc6a835..a6ea3f1 100644 --- a/src/server/public/index.html +++ b/src/server/public/index.html @@ -174,6 +174,14 @@ function sendMessage(agentName, message) { socket.emit('send-message', agentName, message) } + + let settings; + function getSettings() { + socket.emit('get-settings', (response) => { + settings = JSON.parse(response); + console.log(settings); + }) + } function addProfileItem(listName) { const itemDiv = document.createElement('div'); From 937d05074e0c4d4a4f516e555c9036d7602361dc Mon Sep 17 00:00:00 2001 From: uukelele-scratch Date: Thu, 20 Mar 2025 15:57:45 +0000 Subject: [PATCH 08/16] refactor get-settings handling to return settings object directly --- src/server/mind_server.js | 2 +- src/server/public/index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/mind_server.js b/src/server/mind_server.js index 50d5014..c35f519 100644 --- a/src/server/mind_server.js +++ b/src/server/mind_server.js @@ -131,7 +131,7 @@ export function createMindServer(port = 8080) { }); socket.on('get-settings', (callback) => { - callback(JSON.stringify(settings)); + callback(settings); }) }); diff --git a/src/server/public/index.html b/src/server/public/index.html index a6ea3f1..b4724f9 100644 --- a/src/server/public/index.html +++ b/src/server/public/index.html @@ -178,7 +178,7 @@ let settings; function getSettings() { socket.emit('get-settings', (response) => { - settings = JSON.parse(response); + settings = response; console.log(settings); }) } From 61c1310f39746f27c7c10399dfad60dca5a80196 Mon Sep 17 00:00:00 2001 From: uukelele-scratch Date: Thu, 20 Mar 2025 16:30:06 +0000 Subject: [PATCH 09/16] added settings viewing from actual settings data --- src/server/public/index.html | 65 ++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 10 deletions(-) diff --git a/src/server/public/index.html b/src/server/public/index.html index b4724f9..d30fb6c 100644 --- a/src/server/public/index.html +++ b/src/server/public/index.html @@ -19,10 +19,7 @@
- +
@@ -47,7 +44,7 @@
- +
@@ -62,8 +59,8 @@
- -
users that the bots listen to and send general messages to. if empty it will chat publicly
+ +
Users that the bots listen to and send general messages to. If empty, it will chat publicly.
@@ -96,11 +93,13 @@
-

Will copy the style of the profile list once I've finished with that.

+
+ +
Commands to disable and remove from the docs.
- +
Maximum number of previous messages to keep in context. Increasing it may produce longer response times and higher cost if using a paid API, but with the benefit of increasing memory.
@@ -180,19 +179,62 @@ socket.emit('get-settings', (response) => { settings = response; console.log(settings); + updateSettings(settings); }) } + + function updateListItem(listId, listContent) { + listContent.forEach(element => { + addProfileItem(listId, element); + }); + } + + function updateBooleanRadio(radioName, value) { + const trueRadio = document.querySelector(`input[name="${radioName}"][value="true"]`); + const falseRadio = document.querySelector(`input[name="${radioName}"][value="false"]`); + trueRadio.checked = value; + falseRadio.checked = !value; + } + + function updateSettings(settings) { + // string/integer fields + document.getElementById("mcVersion").value = settings["minecraft_version"]; + document.getElementById("mcHostSelector").value = settings["host"]; + document.getElementById("mcPort").value = settings["port"]; + document.getElementById("mcAuth").value = settings["auth"]; + document.getElementById("mcBaseProfile").value = settings["base_profile"]; + document.getElementById("mcInitMessage").value = settings["init_message"]; + document.getElementById("mcLanguage").value = settings["language"]; + document.getElementById("mcMessageHistory").value = settings["max_messages"]; + + // boolean fields + updateBooleanRadio("mcLoadMemory", settings["load_memory"]); + updateBooleanRadio("mcSpeak", settings["speak"]); + updateBooleanRadio("mcShowBotViews", settings["show_bot_views"]); + updateBooleanRadio("mcAllowInsecureCoding", settings["allow_insecure_coding"]); + updateBooleanRadio("mcAllowVision", settings["allow_vision"]); + updateBooleanRadio("mcVerboseCommands", settings["verbose_commands"]); + updateBooleanRadio("mcNarrateBehavior", settings["narrate_behavior"]); + updateBooleanRadio("mcChatBotMessages", settings["chat_bot_messages"]); + + // array/list fields + updateListItem("mcProfileList", settings["profiles"]); + updateListItem("mcBlockedActions", settings["blocked_actions"]); + updateListItem("mcOnlyChatWith", settings["only_chat_with"]); + } - function addProfileItem(listName) { + function addProfileItem(listName, itemNameArg) { const itemDiv = document.createElement('div'); itemDiv.className = 'list-item'; const itemName = document.createElement('input'); itemName.type = 'text'; itemName.className = 'name'; + itemName.value = itemNameArg; const itemCheckbox = document.createElement('input'); itemCheckbox.type = 'checkbox'; + itemCheckbox.checked = true; itemCheckbox.onchange = function() { if (itemCheckbox.checked) { itemName.classList.remove('not-selected'); @@ -223,6 +265,9 @@ console.log(names); return names; } + + + getSettings(); From e029c64e48d2a6f13dfaa4d76b2b0fa7b9775345 Mon Sep 17 00:00:00 2001 From: uukelele-scratch Date: Thu, 20 Mar 2025 16:47:04 +0000 Subject: [PATCH 10/16] improved button styling --- src/server/public/index.html | 6 +++++- src/server/public/styles.css | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/server/public/index.html b/src/server/public/index.html index d30fb6c..63deb0e 100644 --- a/src/server/public/index.html +++ b/src/server/public/index.html @@ -244,7 +244,11 @@ }; const deleteButton = document.createElement('button'); - deleteButton.innerText = 'Delete'; + deleteButton.innerHTML = `Delete`; + deleteButton.style.display = "flex"; + deleteButton.style.flexDirection = "row"; + deleteButton.style.alignItems = "center"; + deleteButton.style.padding = "3px 10px"; deleteButton.className = 'red-btn'; deleteButton.onclick = function() { itemDiv.remove(); diff --git a/src/server/public/styles.css b/src/server/public/styles.css index 1b88d7d..6ecacd4 100644 --- a/src/server/public/styles.css +++ b/src/server/public/styles.css @@ -80,6 +80,7 @@ button { border-radius: 4px; cursor: pointer; margin-left: 5px; + transition: all 0.3s ease } .green-btn { From c1e292fb5b40d19d69661c2febccd07dd5d41188 Mon Sep 17 00:00:00 2001 From: uukelele-scratch Date: Thu, 20 Mar 2025 17:24:29 +0000 Subject: [PATCH 11/16] show/hide settings toggle --- src/server/public/index.html | 228 ++++++++++++++++++----------------- src/server/public/styles.css | 13 +- 2 files changed, 129 insertions(+), 112 deletions(-) diff --git a/src/server/public/index.html b/src/server/public/index.html index 63deb0e..2e70cbe 100644 --- a/src/server/public/index.html +++ b/src/server/public/index.html @@ -9,116 +9,119 @@

Mindcraft

-

Edit settings

-
- Edits won't take effect until restarting Mindcraft. -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
The base profile is shared by all bots for default prompts/examples/modes
-
-
- -
- -
-
- - Yes - No -
-
- - -
This message gets sent to all bots on spawn.
-
-
- -
- -
Users that the bots listen to and send general messages to. If empty, it will chat publicly.
-
-
- - Yes - No -
Allows all bots to speak through system text-to-speech.
This works on Windows and Mac, but on Linux you may need to run sudo apt install espeak first.
-
-
- - -
Translates chat into specified language. Supported languages
-
-
- - Yes - No -
Only supports 1.20.4 and previous versions.
These can be accessed at http://localhost:3000, 3001, 3002, etc. depending on which bot you want to view.
-
-
- - Yes - No -
Allows newAction command and model can write/run code on your computer. Enable at your own risk (it's fine if nobody untrustworthy is playing with your bot).
-
-
- - Yes - No -
Allows the vision model to interpret screenshots as inputs. Requires version 1.20.4 or less.
-
-
- -
- -
Commands to disable and remove from the docs.
-
-
- - -
Maximum number of previous messages to keep in context. Increasing it may produce longer response times and higher cost if using a paid API, but with the benefit of increasing memory.
-
-
- - Yes - No -
Show full command syntax.
-
-
- - Yes - No -
Chat simple, automatic actions for example Picking up item!
-
-
- - Yes - No -
Publicly chat messages to other bots.
+

Edit Settings

+ +
@@ -174,6 +177,11 @@ socket.emit('send-message', agentName, message) } + function toggleSettings() { + document.getElementById("settingsContainer").style.display = document.getElementById("settingsContainer").style.display === "none" ? "block" : "none"; + document.getElementById("settingsToggler").innerText = document.getElementById("settingsToggler").innerText === "Show Settings" ? "Hide Settings" : "Show Settings"; + } + let settings; function getSettings() { socket.emit('get-settings', (response) => { diff --git a/src/server/public/styles.css b/src/server/public/styles.css index 6ecacd4..3477fb3 100644 --- a/src/server/public/styles.css +++ b/src/server/public/styles.css @@ -13,8 +13,16 @@ body { 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: #5757574f; + background: #2d2d2d4f; backdrop-filter: blur(10px); padding: 10px; border-radius:4px; @@ -80,7 +88,8 @@ button { border-radius: 4px; cursor: pointer; margin-left: 5px; - transition: all 0.3s ease + transition: all 0.3s ease; + background: #5c5c5c } .green-btn { From 3763fab3fe80791ec01e329ca1ea23b6d249ff13 Mon Sep 17 00:00:00 2001 From: uukelele-scratch Date: Thu, 20 Mar 2025 17:47:23 +0000 Subject: [PATCH 12/16] added function to get modified settings + enhanced button styling slightly --- src/server/public/index.html | 45 ++++++++++++++++++++++++++++++++---- src/server/public/styles.css | 12 ++++++++++ 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/src/server/public/index.html b/src/server/public/index.html index 2e70cbe..42e2567 100644 --- a/src/server/public/index.html +++ b/src/server/public/index.html @@ -46,7 +46,7 @@
- +
@@ -61,7 +61,7 @@
- +
Users that the bots listen to and send general messages to. If empty, it will chat publicly.
@@ -96,7 +96,7 @@
- +
Commands to disable and remove from the docs.
@@ -192,6 +192,7 @@ } function updateListItem(listId, listContent) { + document.getElementById(listId).innerHTML = ""; listContent.forEach(element => { addProfileItem(listId, element); }); @@ -204,6 +205,10 @@ falseRadio.checked = !value; } + function getBooleanRadio(radioName) { + return document.querySelector(`input[name="${radioName}"][value="true"]`).checked; + } + function updateSettings(settings) { // string/integer fields document.getElementById("mcVersion").value = settings["minecraft_version"]; @@ -230,6 +235,37 @@ updateListItem("mcBlockedActions", settings["blocked_actions"]); updateListItem("mcOnlyChatWith", settings["only_chat_with"]); } + + function getNewSettings() { + let settings = {}; + + // string/integer fields + settings["minecraft_version"] = document.getElementById("mcVersion").value; + settings["host"] = document.getElementById("mcHostSelector").value; + settings["port"] = parseInt(document.getElementById("mcPort").value, 10); // Convert to integer using base 10 + settings["auth"] = document.getElementById("mcAuth").value; + settings["base_profile"] = document.getElementById("mcBaseProfile").value; + settings["init_message"] = document.getElementById("mcInitMessage").value; + settings["language"] = document.getElementById("mcLanguage").value; + settings["max_messages"] = parseInt(document.getElementById("mcMessageHistory").value, 10); // Convert to integer using base 10 + + // boolean fields + settings["load_memory"] = getBooleanRadio("mcLoadMemory"); + settings["speak"] = getBooleanRadio("mcSpeak"); + settings["show_bot_views"] = getBooleanRadio("mcShowBotViews"); + settings["allow_insecure_coding"] = getBooleanRadio("mcAllowInsecureCoding"); + settings["allow_vision"] = getBooleanRadio("mcAllowVision"); + settings["verbose_commands"] = getBooleanRadio("mcVerboseCommands"); + settings["narrate_behavior"] = getBooleanRadio("mcNarrateBehavior"); + settings["chat_bot_messages"] = getBooleanRadio("mcChatBotMessages"); + + // array/list fields + settings["profiles"] = getItemNames("mcProfileList"); + settings["blocked_actions"] = getItemNames("mcBlockedActions"); + settings["only_chat_with"] = getItemNames("mcOnlyChatWith"); + + return settings; + } function addProfileItem(listName, itemNameArg) { const itemDiv = document.createElement('div'); @@ -270,11 +306,10 @@ } function getItemNames(listName) { - const items = document.querySelectorAll(`#${listName} .item`); + const items = document.querySelectorAll(`#${listName} .list-item`); const names = Array.from(items) .filter(item => item.querySelector('input[type="checkbox"]').checked) .map(item => item.querySelector('input[type="text"]').value); - console.log(names); return names; } diff --git a/src/server/public/styles.css b/src/server/public/styles.css index 3477fb3..0e5dfc6 100644 --- a/src/server/public/styles.css +++ b/src/server/public/styles.css @@ -92,6 +92,18 @@ button { background: #5c5c5c } +button:hover { + background: #444; +} + +.add-btn { + display: flex; + flex-direction: row; + align-items: center; + padding: 3px 10px; + justify-content: space-between; +} + .green-btn { background: #4CAF50; } From 2b42f3f6b081635643ec5edcbe96ce1b5acb8289 Mon Sep 17 00:00:00 2001 From: uukelele-scratch Date: Thu, 20 Mar 2025 18:48:04 +0000 Subject: [PATCH 13/16] added edit settings feature with save/reset buttons --- src/server/mind_server.js | 6 +++++- src/server/public/index.html | 9 +++++++++ src/server/public/styles.css | 4 ++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/server/mind_server.js b/src/server/mind_server.js index c35f519..f18299f 100644 --- a/src/server/mind_server.js +++ b/src/server/mind_server.js @@ -3,7 +3,7 @@ import express from 'express'; import http from 'http'; import path from 'path'; import { fileURLToPath } from 'url'; -import settings from '../../settings.js'; +import settings, { updateSettings } from '../../settings.js'; // Module-level variables let io; @@ -133,6 +133,10 @@ export function createMindServer(port = 8080) { socket.on('get-settings', (callback) => { callback(settings); }) + + socket.on('update-settings', (newSettings) => { + updateSettings(newSettings); + }) }); server.listen(port, 'localhost', () => { diff --git a/src/server/public/index.html b/src/server/public/index.html index 42e2567..090a5c7 100644 --- a/src/server/public/index.html +++ b/src/server/public/index.html @@ -122,6 +122,10 @@ No
Publicly chat messages to other bots.
+
+ + +
@@ -191,6 +195,11 @@ }) } + function saveSettings() { + const newSettings = getNewSettings(); + socket.emit('update-settings', newSettings); + } + function updateListItem(listId, listContent) { document.getElementById(listId).innerHTML = ""; listContent.forEach(element => { diff --git a/src/server/public/styles.css b/src/server/public/styles.css index 0e5dfc6..f20c2d2 100644 --- a/src/server/public/styles.css +++ b/src/server/public/styles.css @@ -104,6 +104,10 @@ button:hover { justify-content: space-between; } +.add-btn svg { + margin-right: 5px; +} + .green-btn { background: #4CAF50; } From 066848b7b86b8bf5cf8312845897fe927ef3860a Mon Sep 17 00:00:00 2001 From: uukelele-scratch Date: Thu, 20 Mar 2025 19:52:16 +0000 Subject: [PATCH 14/16] added functionality to load and save user-modified settings from a JSON file --- config.json | 47 ++++++++++++++++++++++++++++++++++ settings.js | 18 ++++++++++++- src/server/saved_settings.json | 1 + 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 config.json create mode 100644 src/server/saved_settings.json 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 1ad5fa7..1ad0087 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" @@ -46,9 +49,22 @@ const settings = { "chat_bot_messages": true, // publicly chat messages to other bots } +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) { - return Object.assign(settings, newSettings); + Object.assign(settings, newSettings); + fs.writeFileSync(configPath, JSON.stringify(settings, null, 4)); } // these environment variables override certain settings 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 From 669144ccc1cecdcd0c827cddfc626dde0cca9c09 Mon Sep 17 00:00:00 2001 From: uukelele-scratch Date: Thu, 10 Apr 2025 11:40:56 +0100 Subject: [PATCH 15/16] Merge --- src/server/mind_server.js | 18 ++++++++- src/server/public/index.html | 71 +++++++++++++++++++++++++++++++----- 2 files changed, 78 insertions(+), 11 deletions(-) diff --git a/src/server/mind_server.js b/src/server/mind_server.js index f18299f..165cb01 100644 --- a/src/server/mind_server.js +++ b/src/server/mind_server.js @@ -4,6 +4,7 @@ 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; @@ -132,11 +133,24 @@ export function createMindServer(port = 8080) { 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 090a5c7..4343abf 100644 --- a/src/server/public/index.html +++ b/src/server/public/index.html @@ -1,9 +1,11 @@ - + Mindcraft + +

Mindcraft

@@ -181,6 +183,14 @@ socket.emit('send-message', agentName, message) } + let pathProfiles; + function getProfilesFromPath() { + socket.emit('get-profile-dir', (response) => { + pathProfiles = response; + console.log(response); + }) + } + function toggleSettings() { document.getElementById("settingsContainer").style.display = document.getElementById("settingsContainer").style.display === "none" ? "block" : "none"; document.getElementById("settingsToggler").innerText = document.getElementById("settingsToggler").innerText === "Show Settings" ? "Hide Settings" : "Show Settings"; @@ -200,11 +210,37 @@ socket.emit('update-settings', newSettings); } - function updateListItem(listId, listContent) { - document.getElementById(listId).innerHTML = ""; - listContent.forEach(element => { - addProfileItem(listId, element); - }); + function updateListItem(listId, listContent, enabled = true, clear = true) { + if (clear) { + document.getElementById(listId).innerHTML = ""; + listContent.forEach(element => { + addProfileItem(listId, element, enabled); + }); + } else { + const list = document.getElementById(listId); + const existingItemsDivs = document.querySelectorAll(`#${listId} .list-item`); + let existingItems = Array.from(existingItemsDivs) + .map(item => item.querySelector('input[type="text"]').value); + listContent.forEach(element => { + if (existingItems.includes(element)) { + const item = Array.from(list.querySelectorAll('.list-item')) + .find(item => item.querySelector('input[type="text"]').value === element); + if (item) { + console.log(`Setting this to ${enabled}: `) + const checkbox = item.querySelector('input[type="checkbox"]'); + console.log(checkbox) + console.log(checkbox.checked) + checkbox.checked = enabled; + console.log("After: ") + console.log(checkbox.checked) + } else { + addProfileItem(listId, element, enabled); + } + } else { + addProfileItem(listId, element, enabled); + } + }) + } } function updateBooleanRadio(radioName, value) { @@ -240,9 +276,21 @@ updateBooleanRadio("mcChatBotMessages", settings["chat_bot_messages"]); // array/list fields - updateListItem("mcProfileList", settings["profiles"]); updateListItem("mcBlockedActions", settings["blocked_actions"]); updateListItem("mcOnlyChatWith", settings["only_chat_with"]); + + // handling profiles is special + updateListItem("mcProfileList", settings["profiles"]); + pathProfiles = undefined; + getProfilesFromPath(); + const intervalId = setInterval(() => { + if (pathProfiles !== undefined) { + clearInterval(intervalId); + updateListItem("mcProfileList", pathProfiles, enabled=false); + } + }, 50); + updateListItem("mcProfileList", settings["profiles"], enabled=true, clear = false); + console.log(`updated with ${settings["profiles"]}`); } function getNewSettings() { @@ -276,7 +324,7 @@ return settings; } - function addProfileItem(listName, itemNameArg) { + function addProfileItem(listName, itemNameArg, enabled) { const itemDiv = document.createElement('div'); itemDiv.className = 'list-item'; @@ -287,7 +335,12 @@ const itemCheckbox = document.createElement('input'); itemCheckbox.type = 'checkbox'; - itemCheckbox.checked = true; + itemCheckbox.checked = enabled; + if (itemCheckbox.checked) { + itemName.classList.remove('not-selected'); + } else { + itemName.classList.add('not-selected'); + } itemCheckbox.onchange = function() { if (itemCheckbox.checked) { itemName.classList.remove('not-selected'); From 3ee54b3cf0656f7aafe1f5ac345a7e3112638f59 Mon Sep 17 00:00:00 2001 From: uukelele-scratch Date: Thu, 10 Apr 2025 14:10:29 +0100 Subject: [PATCH 16/16] profile now shows all profiles in directory + other minor improvements --- src/server/public/index.html | 25 ++++++++++++++----------- src/server/public/styles.css | 1 + 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/server/public/index.html b/src/server/public/index.html index 4343abf..6dee613 100644 --- a/src/server/public/index.html +++ b/src/server/public/index.html @@ -187,13 +187,15 @@ function getProfilesFromPath() { socket.emit('get-profile-dir', (response) => { pathProfiles = response; - console.log(response); }) } function toggleSettings() { document.getElementById("settingsContainer").style.display = document.getElementById("settingsContainer").style.display === "none" ? "block" : "none"; document.getElementById("settingsToggler").innerText = document.getElementById("settingsToggler").innerText === "Show Settings" ? "Hide Settings" : "Show Settings"; + if (document.getElementById("settingsContainer").style.display = "block") { + getSettings(); + } } let settings; @@ -226,13 +228,18 @@ const item = Array.from(list.querySelectorAll('.list-item')) .find(item => item.querySelector('input[type="text"]').value === element); if (item) { - console.log(`Setting this to ${enabled}: `) const checkbox = item.querySelector('input[type="checkbox"]'); - console.log(checkbox) - console.log(checkbox.checked) + console.log(`Setting this to ${enabled}: `, checkbox); + console.log("Checkbox in DOM?", document.body.contains(checkbox)); + console.log("Before: ", checkbox.checked); checkbox.checked = enabled; - console.log("After: ") - console.log(checkbox.checked) + console.log("After: ", checkbox.checked); + const itemName = item.querySelector('.name'); + if (checkbox.checked) { + itemName.classList.remove('not-selected'); + } else { + itemName.classList.add('not-selected'); + } } else { addProfileItem(listId, element, enabled); } @@ -287,10 +294,9 @@ if (pathProfiles !== undefined) { clearInterval(intervalId); updateListItem("mcProfileList", pathProfiles, enabled=false); + updateListItem("mcProfileList", settings["profiles"], enabled=true, clear = false); } }, 50); - updateListItem("mcProfileList", settings["profiles"], enabled=true, clear = false); - console.log(`updated with ${settings["profiles"]}`); } function getNewSettings() { @@ -374,9 +380,6 @@ .map(item => item.querySelector('input[type="text"]').value); return names; } - - - getSettings(); diff --git a/src/server/public/styles.css b/src/server/public/styles.css index f20c2d2..7f22d1e 100644 --- a/src/server/public/styles.css +++ b/src/server/public/styles.css @@ -69,6 +69,7 @@ code { .list-item .name.not-selected { text-decoration: line-through; + color: #929292 } .agent {