From af8dccccebb4a8ac8005d51b427d825b2111ac52 Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Fri, 25 Oct 2024 23:46:07 -0500 Subject: [PATCH 1/8] make profiles consistent with video, cheat mode off --- profiles/claude.json | 12 ++++++------ profiles/gemini.json | 10 +++++----- profiles/gpt.json | 10 +++++----- profiles/llama.json | 10 +++++----- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/profiles/claude.json b/profiles/claude.json index 6608686..20a06c5 100644 --- a/profiles/claude.json +++ b/profiles/claude.json @@ -1,7 +1,7 @@ { "name": "claude", - "model": "claude-3-5-sonnet-20240620", + "model": "claude-3-5-sonnet-latest", "embedding": "openai", @@ -15,14 +15,14 @@ "modes": { - "self_preservation": false, + "self_preservation": true, "cowardice": false, - "self_defense": false, - "hunting": false, + "self_defense": true, + "hunting": true, "item_collecting": true, - "torch_placing": false, + "torch_placing": true, "idle_staring": true, - "cheat": true + "cheat": false }, "conversation_examples": [ diff --git a/profiles/gemini.json b/profiles/gemini.json index 1f04968..33f4918 100644 --- a/profiles/gemini.json +++ b/profiles/gemini.json @@ -12,14 +12,14 @@ "saving_memory": "You are a minecraft bot named $NAME that has been talking and playing minecraft by using commands. Update your memory by summarizing the following conversation and your old memory in your next response. Prioritize preserving important facts, things you've learned, useful tips, and long term reminders. Do Not record stats, inventory, or docs! Only save transient information from your chat history. You're limited to 500 characters, so be extremely brief and minimize words. Compress useful information. \nOld Memory: '$MEMORY'\nRecent conversation: \n$TO_SUMMARIZE\nSummarize your old memory and recent conversation into a new memory, and respond only with the unwrapped memory text: ", "modes": { - "self_preservation": false, + "self_preservation": true, "cowardice": false, - "self_defense": false, - "hunting": false, + "self_defense": true, + "hunting": true, "item_collecting": true, - "torch_placing": false, + "torch_placing": true, "idle_staring": true, - "cheat": true + "cheat": false }, "conversation_examples": [ diff --git a/profiles/gpt.json b/profiles/gpt.json index 96f4e08..271c368 100644 --- a/profiles/gpt.json +++ b/profiles/gpt.json @@ -10,14 +10,14 @@ "saving_memory": "You are a minecraft bot named $NAME that has been talking and playing minecraft by using commands. Update your memory by summarizing the following conversation and your old memory in your next response. Prioritize preserving important facts, things you've learned, useful tips, and long term reminders. Do Not record stats, inventory, or docs! Only save transient information from your chat history. You're limited to 500 characters, so be extremely brief and minimize words. Compress useful information. \nOld Memory: '$MEMORY'\nRecent conversation: \n$TO_SUMMARIZE\nSummarize your old memory and recent conversation into a new memory, and respond only with the unwrapped memory text: ", "modes": { - "self_preservation": false, + "self_preservation": true, "cowardice": false, - "self_defense": false, - "hunting": false, + "self_defense": true, + "hunting": true, "item_collecting": true, - "torch_placing": false, + "torch_placing": true, "idle_staring": true, - "cheat": true + "cheat": false }, "conversation_examples": [ diff --git a/profiles/llama.json b/profiles/llama.json index 021abf0..86d13f6 100644 --- a/profiles/llama.json +++ b/profiles/llama.json @@ -14,14 +14,14 @@ "saving_memory": "You are a minecraft bot named $NAME that has been talking and playing minecraft by using commands. Update your memory by summarizing the following conversation and your old memory in your next response. Prioritize preserving important facts, things you've learned, useful tips, and long term reminders. Do Not record stats, inventory, or docs! Only save transient information from your chat history. You're limited to 500 characters, so be extremely brief and minimize words. Compress useful information. \nOld Memory: '$MEMORY'\nRecent conversation: \n$TO_SUMMARIZE\nSummarize your old memory and recent conversation into a new memory, and respond only with the unwrapped memory text: ", "modes": { - "self_preservation": false, + "self_preservation": true, "cowardice": false, - "self_defense": false, - "hunting": false, + "self_defense": true, + "hunting": true, "item_collecting": true, - "torch_placing": false, + "torch_placing": true, "idle_staring": true, - "cheat": true + "cheat": false }, "conversation_examples": [ From e0a3192b4c28f47a004f47114970c43bee979b92 Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Fri, 25 Oct 2024 23:46:29 -0500 Subject: [PATCH 2/8] sneaky skill improvements --- src/agent/commands/actions.js | 5 +++-- src/agent/library/skills.js | 10 ++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/agent/commands/actions.js b/src/agent/commands/actions.js index 246d649..a80ad29 100644 --- a/src/agent/commands/actions.js +++ b/src/agent/commands/actions.js @@ -306,8 +306,9 @@ export const actionsList = [ { name: '!stay', description: 'Stay in the current location no matter what. Pauses all modes.', - perform: wrapExecution(async (agent) => { - await skills.stay(agent.bot); + params: {'type': { type: 'int', description: 'The number of seconds to stay. -1 for forever.', domain: [-1, Number.MAX_SAFE_INTEGER] }}, + perform: wrapExecution(async (agent, seconds) => { + await skills.stay(agent.bot, seconds); }) }, { diff --git a/src/agent/library/skills.js b/src/agent/library/skills.js index b9f6184..b575ff1 100644 --- a/src/agent/library/skills.js +++ b/src/agent/library/skills.js @@ -716,6 +716,9 @@ export async function equip(bot, itemName) { else if (itemName.includes('chestplate') || itemName.includes('elytra')) { await bot.equip(item, 'torso'); } + else if (itemName.includes('shield')) { + await bot.equip(item, 'off-hand'); + } else { await bot.equip(item, 'hand'); } @@ -1082,10 +1085,11 @@ export async function avoidEnemies(bot, distance=16) { return true; } -export async function stay(bot) { +export async function stay(bot, seconds=30) { /** * Stay in the current position until interrupted. Disables all modes. * @param {MinecraftBot} bot, reference to the minecraft bot. + * @param {number} seconds, the number of seconds to stay. Defaults to 30. -1 for indefinite. * @returns {Promise} true if the bot stayed, false otherwise. * @example * await skills.stay(bot); @@ -1097,9 +1101,11 @@ export async function stay(bot) { bot.modes.pause('hunting'); bot.modes.pause('torch_placing'); bot.modes.pause('item_collecting'); - while (!bot.interrupt_code) { + let start = Date.now(); + while (!bot.interrupt_code && (seconds === -1 || Date.now() - start < seconds*1000)) { await new Promise(resolve => setTimeout(resolve, 500)); } + log(bot, `Stayed for ${(Date.now() - start)/1000} seconds.`); return true; } From a9b1d13f7f03de23c58b3c8a621c0827e7c52612 Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Sat, 26 Oct 2024 17:13:08 -0500 Subject: [PATCH 3/8] mostly fixed infinite jump bug --- patches/mineflayer-pathfinder+2.4.5.patch | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/patches/mineflayer-pathfinder+2.4.5.patch b/patches/mineflayer-pathfinder+2.4.5.patch index 4c8dc93..6906371 100644 --- a/patches/mineflayer-pathfinder+2.4.5.patch +++ b/patches/mineflayer-pathfinder+2.4.5.patch @@ -1,17 +1,16 @@ diff --git a/node_modules/mineflayer-pathfinder/index.js b/node_modules/mineflayer-pathfinder/index.js -index b38bd30..cfaa677 100644 +index b38bd30..bf16a63 100644 --- a/node_modules/mineflayer-pathfinder/index.js +++ b/node_modules/mineflayer-pathfinder/index.js -@@ -541,7 +541,7 @@ function inject (bot) { - let canPlace = true - if (placingBlock.jump) { - bot.setControlState('jump', true) -- canPlace = placingBlock.y + 1 < bot.entity.position.y -+ canPlace = placingBlock.y + 1.8 < bot.entity.position.y - } - if (canPlace) { - if (!lockEquipItem.tryAcquire()) return -@@ -557,6 +557,7 @@ function inject (bot) { +@@ -550,6 +550,7 @@ function inject (bot) { + lockEquipItem.release() + const refBlock = bot.blockAt(new Vec3(placingBlock.x, placingBlock.y, placingBlock.z), false) + if (!lockPlaceBlock.tryAcquire()) return ++ bot.world.setBlockStateId(refBlock.position.offset(placingBlock.dx, placingBlock.dy, placingBlock.dz), 1) + if (interactableBlocks.includes(refBlock.name)) { + bot.setControlState('sneak', true) + } +@@ -557,6 +558,7 @@ function inject (bot) { .then(function () { // Dont release Sneak if the block placement was not successful bot.setControlState('sneak', false) From a598d729866f9b0618198d9c65b752d5f5f36e9f Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Sat, 26 Oct 2024 17:13:51 -0500 Subject: [PATCH 4/8] add unstuck mode to profiles --- andy.json | 1 + profiles/andy_npc.json | 1 + profiles/claude.json | 1 + profiles/gemini.json | 1 + profiles/gpt.json | 1 + profiles/llama.json | 1 + 6 files changed, 6 insertions(+) diff --git a/andy.json b/andy.json index 5482f45..adc5bd8 100644 --- a/andy.json +++ b/andy.json @@ -11,6 +11,7 @@ "modes": { "self_preservation": true, + "unstuck": true, "cowardice": true, "self_defense": true, "hunting": true, diff --git a/profiles/andy_npc.json b/profiles/andy_npc.json index 3eff4ae..8134c5e 100644 --- a/profiles/andy_npc.json +++ b/profiles/andy_npc.json @@ -13,6 +13,7 @@ "modes": { "self_preservation": true, + "unstuck": true, "cowardice": true, "self_defense": true, "hunting": true, diff --git a/profiles/claude.json b/profiles/claude.json index 20a06c5..415eda9 100644 --- a/profiles/claude.json +++ b/profiles/claude.json @@ -16,6 +16,7 @@ "modes": { "self_preservation": true, + "unstuck": true, "cowardice": false, "self_defense": true, "hunting": true, diff --git a/profiles/gemini.json b/profiles/gemini.json index 33f4918..bb354d2 100644 --- a/profiles/gemini.json +++ b/profiles/gemini.json @@ -13,6 +13,7 @@ "modes": { "self_preservation": true, + "unstuck": true, "cowardice": false, "self_defense": true, "hunting": true, diff --git a/profiles/gpt.json b/profiles/gpt.json index 271c368..7d1120d 100644 --- a/profiles/gpt.json +++ b/profiles/gpt.json @@ -11,6 +11,7 @@ "modes": { "self_preservation": true, + "unstuck": true, "cowardice": false, "self_defense": true, "hunting": true, diff --git a/profiles/llama.json b/profiles/llama.json index 86d13f6..b8620d9 100644 --- a/profiles/llama.json +++ b/profiles/llama.json @@ -15,6 +15,7 @@ "modes": { "self_preservation": true, + "unstuck": true, "cowardice": false, "self_defense": true, "hunting": true, From 583c9f8851c24313161e5f194cdab0984e190a71 Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Sat, 26 Oct 2024 17:14:34 -0500 Subject: [PATCH 5/8] fixed regex catastrophic backtracking for nested parens --- src/agent/commands/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/agent/commands/index.js b/src/agent/commands/index.js index 622808e..13d7201 100644 --- a/src/agent/commands/index.js +++ b/src/agent/commands/index.js @@ -14,7 +14,7 @@ export function getCommand(name) { return commandMap[name]; } -const commandRegex = /!(\w+)(?:\(((?:[^)(]+|'[^']*'|"[^"]*")*)\))?/ +const commandRegex = /!(\w+)(?:\(([\s\S]*)\))?/ const argRegex = /(?:"[^"]*"|'[^']*'|[^,])+/g; export function containsCommand(message) { From cfd13d4cd14a4d5fe1c78f954b6049ffc8b86c3e Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Sun, 27 Oct 2024 00:09:46 -0500 Subject: [PATCH 6/8] added unstuck to freeguy --- profiles/freeguy.json | 1 + 1 file changed, 1 insertion(+) diff --git a/profiles/freeguy.json b/profiles/freeguy.json index 62b50ae..0df24a5 100644 --- a/profiles/freeguy.json +++ b/profiles/freeguy.json @@ -13,6 +13,7 @@ "modes": { "self_preservation": true, + "unstuck": true, "cowardice": true, "self_defense": true, "hunting": true, From 32d10430daa5675f72b65a2379b9664f5226202b Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Sun, 27 Oct 2024 15:06:23 -0500 Subject: [PATCH 7/8] added 1.21.1 support --- README.md | 4 ++-- package.json | 6 +++--- settings.js | 11 +++++++---- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index d2ef957..a815028 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ This project allows an AI model to write/execute code on your computer that may ## Requirements -- [Minecraft Java Edition](https://www.minecraft.net/en-us/store/minecraft-java-bedrock-edition-pc) (up to v1.20.4) +- [Minecraft Java Edition](https://www.minecraft.net/en-us/store/minecraft-java-bedrock-edition-pc) (up to v1.21.1) - [Node.js](https://nodejs.org/) (at least v14) - One of these: [OpenAI API Key](https://openai.com/blog/openai-api) | [Gemini API Key](https://aistudio.google.com/app/apikey) |[Anthropic API Key](https://docs.anthropic.com/claude/docs/getting-access-to-claude) | [Replicate API Key](https://replicate.com/) | [Hugging Face API Key](https://huggingface.co/) | [Groq API Key](https://console.groq.com/keys) | [Ollama Installed](https://ollama.com/download) @@ -34,7 +34,7 @@ Then, clone/download this repository Run `npm install` from the installed directory -Install the minecraft version specified in `settings.js`, currently supports up to 1.20.4 +Install the minecraft version specified in `settings.js`, currently supports up to 1.21.1 ### Running Locally diff --git a/package.json b/package.json index af173da..cd5b272 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "@huggingface/inference": "^2.8.1", "google-translate-api-x": "^10.7.1", "groq-sdk": "^0.5.0", - "minecraft-data": "^3.46.2", - "mineflayer": "^4.20.0", + "minecraft-data": "^3.78.0", + "mineflayer": "^4.23.0", "mineflayer-armor-manager": "^2.0.1", "mineflayer-auto-eat": "^3.3.6", "mineflayer-collectblock": "^1.4.1", @@ -15,7 +15,7 @@ "mineflayer-pvp": "^1.3.2", "openai": "^4.4.0", "patch-package": "^8.0.0", - "prismarine-item": "^1.14.0", + "prismarine-item": "^1.15.0", "prismarine-viewer": "^1.28.0", "replicate": "^0.29.4", "vec3": "^0.1.10", diff --git a/settings.js b/settings.js index 4155723..d9f798a 100644 --- a/settings.js +++ b/settings.js @@ -1,15 +1,18 @@ export default { - "minecraft_version": "1.20.4", // supports up to 1.20.4 + "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" "profiles": [ "./andy.json", - - // add more profiles here, check ./profiles/ for more - // more than 1 profile will require you to /msg each bot indivually + // "./profiles/gpt.json", + // "./profiles/claude.json", + // "./profiles/gemini.json", + // "./profiles/llama.json", + + // using more than 1 profile requires you to /msg each bot indivually ], "load_memory": false, // load memory from previous session "init_message": "Say hello world and your name", // sends to all on spawn From f98ae6905f46da762a3ceef0a212b3c029788604 Mon Sep 17 00:00:00 2001 From: Max Robinson Date: Mon, 28 Oct 2024 15:55:16 -0500 Subject: [PATCH 8/8] set default mc version to 1.20.4, 1.21 buggy --- settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.js b/settings.js index d9f798a..1de12c0 100644 --- a/settings.js +++ b/settings.js @@ -1,6 +1,6 @@ export default { - "minecraft_version": "1.21.1", // supports up to 1.21.1 + "minecraft_version": "1.20.4", // supports up to 1.21.1 "host": "127.0.0.1", // or "localhost", "your.ip.address.here" "port": 55916, "auth": "offline", // or "microsoft"