naldo commited on
Commit ·
38fde3a
1
Parent(s): f7f70f2
Align runtime with official Voyager environment
Browse filesFiles changed (4)
- app.py+2-2
- minecraft_stack.py+40
- voyager_runner.py+6-8
- voyager_stack.py+19-5
62 unmodified lines63646566676869657 unmodified lines72772872973073173273362 unmodified linesAUX_MODEL_ALIAS = os.environ.get("AUX_MODEL_ALIAS", "qwen3-4b-instruct-2507-aux")AUX_MODEL_ALIASES = {AUX_MODEL_ALIAS, "voyager-aux-4b"}AUX_CTX = int(os.environ.get("AUX_CPU_CTX", "32768"))AUX_PRELOAD = os.environ.get("AUX_CPU_PRELOAD", "0") == "1"EMBED_REPO = os.environ.get("EMBED_REPO", "Qwen/Qwen3-Embedding-0.6B-GGUF")EMBED_FILE = os.environ.get("EMBED_FILE", "Qwen3-Embedding-0.6B-Q8_0.gguf")657 unmodified lines"model_family": "Qwen3-Coder-30B-A3B-Instruct","total_params_b": 30.5,"active_params_b": 3.3,"reasoning_policy": "voyager-all-agents-qwen3-coder-30b","aux_model": AUX_MODEL_ALIAS,"aux_model_repo": AUX_MODEL_REPO,"aux_model_file": AUX_MODEL_FILE,62 unmodified lines63646566676869657 unmodified lines72772872973073173273362 unmodified linesAUX_MODEL_ALIAS = os.environ.get("AUX_MODEL_ALIAS", "qwen3-4b-instruct-2507-aux")AUX_MODEL_ALIASES = {AUX_MODEL_ALIAS, "voyager-aux-4b"}AUX_CTX = int(os.environ.get("AUX_CPU_CTX", "32768"))AUX_PRELOAD = os.environ.get("AUX_CPU_PRELOAD", "1") == "1"EMBED_REPO = os.environ.get("EMBED_REPO", "Qwen/Qwen3-Embedding-0.6B-GGUF")EMBED_FILE = os.environ.get("EMBED_FILE", "Qwen3-Embedding-0.6B-Q8_0.gguf")657 unmodified lines"model_family": "Qwen3-Coder-30B-A3B-Instruct","total_params_b": 30.5,"active_params_b": 3.3,"reasoning_policy": "voyager-official-role-split-30b-critical-4b-aux","aux_model": AUX_MODEL_ALIAS,"aux_model_repo": AUX_MODEL_REPO,"aux_model_file": AUX_MODEL_FILE,
34 unmodified lines353637383940183 unmodified lines22422522622722822911 unmodified lines24124224324424524634 unmodified linesFABRIC_MC_VERSION = "1.19"FABRIC_LOADER_VERSION = "0.14.18"VIAPROXY_URL = "https://github.com/ViaVersion/ViaProxy/releases/download/v3.4.13/ViaProxy-3.4.13.jar"VIAPROXY_SHA256 = "4bbb6a6b9d3dd6a2028773ed44b97a98751e4a48e416aaad4bf6d9c860083be9"183 unmodified linesworld_link.symlink_to(WORLD_DIR, target_is_directory=True)_log(f"Persistent Minecraft world linked: {world_link} -> {WORLD_DIR}")def _ensure_fabric(self) -> Path:java = self._ensure_java()installer = _download(FABRIC_INSTALLER_URL, TOOLS_DIR / "fabric-installer-0.11.2.jar")11 unmodified linesJAVA_DIR,timeout=300,)(JAVA_DIR / "eula.txt").write_text("eula=true\n", encoding="utf-8")props = {"server-ip": "127.0.0.1",34 unmodified lines35363738394041424344454647484950183 unmodified lines23423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726811 unmodified lines28028128228328428528634 unmodified linesFABRIC_MC_VERSION = "1.19"FABRIC_LOADER_VERSION = "0.14.18"# Official Voyager Fabric 1.19 server-side mod stack.FABRIC_API_URL = "https://cdn.modrinth.com/data/P7dR8mSH/versions/0.58.0%2B1.19/fabric-api-0.58.0%2B1.19.jar"FABRIC_API_SHA256 = "0a3d2dba1ed45b002483ae7c08e2c0bcfcb8d2b166801a6c29d8ea64dba64370"COMPLETE_CONFIG_URL = "https://cdn.modrinth.com/data/GtqG8z1h/versions/2.0.0/completeconfig-2.0.0.jar"COMPLETE_CONFIG_SHA256 = "d34a3e167bf7942348d3f8c650fcefead6284878b39277ba43282ef69fa2d566"SERVER_PAUSE_URL = "https://mediafilez.forgecdn.net/files/3822/586/Multiplayer-Server-Pause-1.19-Fabric-1.1.0.jar"SERVER_PAUSE_SHA256 = "4f92d4a4cef4627acbdfa1c601f0c58e392eee4159a69515fd0d622d3eeccd66"BETTER_RESPAWN_URL = "https://cdn.modrinth.com/data/ZUQINcGy/versions/fabric-1.19-2.0.0/better-respawn-fabric-1.19-2.0.0.jar"BETTER_RESPAWN_SHA256 = "9405e2ae53f031d5c32505dc3ee774c3f723c2d465230aaed7e6f7b3cdec0948"VIAPROXY_URL = "https://github.com/ViaVersion/ViaProxy/releases/download/v3.4.13/ViaProxy-3.4.13.jar"VIAPROXY_SHA256 = "4bbb6a6b9d3dd6a2028773ed44b97a98751e4a48e416aaad4bf6d9c860083be9"183 unmodified linesworld_link.symlink_to(WORLD_DIR, target_is_directory=True)_log(f"Persistent Minecraft world linked: {world_link} -> {WORLD_DIR}")def _ensure_voyager_mods(self) -> None:mods_dir = JAVA_DIR / "mods"mods_dir.mkdir(parents=True, exist_ok=True)mods = (("fabric-api-0.58.0+1.19.jar", FABRIC_API_URL, FABRIC_API_SHA256),("completeconfig-2.0.0.jar", COMPLETE_CONFIG_URL, COMPLETE_CONFIG_SHA256),("Multiplayer-Server-Pause-1.19-Fabric-1.1.0.jar", SERVER_PAUSE_URL, SERVER_PAUSE_SHA256),("better-respawn-fabric-1.19-2.0.0.jar", BETTER_RESPAWN_URL, BETTER_RESPAWN_SHA256),)for filename, url, sha256 in mods:_download(url, mods_dir / filename, sha256)# Voyager documentation config for Better Respawn. The actual 1.19 mod# uses config/better_respawn/better_respawn.properties.config_dir = JAVA_DIR / "config" / "better_respawn"config_dir.mkdir(parents=True, exist_ok=True)(config_dir / "better_respawn.properties").write_text("respawn_block_range=32\n""max_respawn_distance=32\n""min_respawn_distance=0\n",encoding="utf-8",)_log("Official Voyager Fabric mods ready: Fabric API 0.58.0+1.19, ""CompleteConfig 2.0.0, Multiplayer Server Pause 1.1.0, ""Better Respawn 1.19-2.0.0. Mod Menu is client-only and is ""intentionally omitted on this headless dedicated server.")def _ensure_fabric(self) -> Path:java = self._ensure_java()installer = _download(FABRIC_INSTALLER_URL, TOOLS_DIR / "fabric-installer-0.11.2.jar")11 unmodified linesJAVA_DIR,timeout=300,)self._ensure_voyager_mods()(JAVA_DIR / "eula.txt").write_text("eula=true\n", encoding="utf-8")props = {"server-ip": "127.0.0.1",
19 unmodified lines2021222324252622 unmodified lines495051525354557 unmodified lines63646566676869707172737475767719 unmodified lines# Surface Mineflayer's subprocess logs as well as Python tracebacks.logging.basicConfig(level=logging.INFO, format="[%(name)s] %(levelname)s %(message)s")model = env("VOYAGER_MODEL", "qwen3-coder-30b-a3b-instruct")aux_model = env("VOYAGER_AUX_MODEL", model)base_url = env("VOYAGER_OPENAI_BASE", "http://127.0.0.1:7860/v1")api_key = env("VOYAGER_API_KEY", "local-voyager")ckpt_dir = env("VOYAGER_CKPT_DIR", "/persist/minecraft-friends/voyager/ckpt")22 unmodified linesopenai_api_key=api_key,server_port=int(env("MINEFLAYER_API_PORT", "3000")),env_wait_ticks=int(env("ENV_WAIT_TICKS", "20")),env_request_timeout=int(env("ENV_REQUEST_TIMEOUT", "60")),max_iterations=int(env("MAX_ITERATIONS", "160")),action_agent_model_name=model,action_agent_temperature=0,7 unmodified linesskill_manager_model_name=aux_model,skill_manager_temperature=0,skill_manager_retrieval_top_k=5,openai_api_request_timeout=int(env("OPENAI_API_REQUEST_TIMEOUT", "600")),ckpt_dir=ckpt_dir,resume=resume,)# Keep the same Mineflayer session across curriculum tasks. The original# Voyager default resets/reconnects the bot before every task, which makes# the player visibly leave/rejoin the server. Recovery resets are still# available inside Voyager when a real connection failure occurs.voyager.learn(reset_env=False)if __name__ == "__main__":19 unmodified lines2021222324252622 unmodified lines495051525354557 unmodified lines6364656667686970717273747519 unmodified lines# Surface Mineflayer's subprocess logs as well as Python tracebacks.logging.basicConfig(level=logging.INFO, format="[%(name)s] %(levelname)s %(message)s")model = env("VOYAGER_MODEL", "qwen3-coder-30b-a3b-instruct")aux_model = env("VOYAGER_AUX_MODEL", "qwen3-4b-instruct-2507-aux")base_url = env("VOYAGER_OPENAI_BASE", "http://127.0.0.1:7860/v1")api_key = env("VOYAGER_API_KEY", "local-voyager")ckpt_dir = env("VOYAGER_CKPT_DIR", "/persist/minecraft-friends/voyager/ckpt")22 unmodified linesopenai_api_key=api_key,server_port=int(env("MINEFLAYER_API_PORT", "3000")),env_wait_ticks=int(env("ENV_WAIT_TICKS", "20")),env_request_timeout=int(env("ENV_REQUEST_TIMEOUT", "600")),max_iterations=int(env("MAX_ITERATIONS", "160")),action_agent_model_name=model,action_agent_temperature=0,7 unmodified linesskill_manager_model_name=aux_model,skill_manager_temperature=0,skill_manager_retrieval_top_k=5,openai_api_request_timeout=int(env("OPENAI_API_REQUEST_TIMEOUT", "240")),ckpt_dir=ckpt_dir,resume=resume,)# Match the official Voyager learning loop: reset Mineflayer between tasks# so its inventory/world observations stay synchronized with Minecraft.voyager.learn()if __name__ == "__main__":
82 unmodified lines83848586878810 unmodified lines9910010110210310481 unmodified lines186187188189190191192230 unmodified lines42342442542642742842943043143243343443543689 unmodified lines52652752852953053153253382 unmodified lines' port: req.body.port, // minecraft server port\n username: process.env.MC_USERNAME || "Naldo_Bot",',' port: req.body.port, // minecraft server port\n version: "1.19", // server is pinned to Java 1.19; never auto-detect a different patch protocol\n username: process.env.MC_USERNAME || "Naldo_Bot",',)text = text.replace('app.post("/step", async (req, res) => {\n // import useful package','app.post("/step", async (req, res) => {\n if (!bot || !bot.entity) {\n res.status(503).json({ error: "Bot not spawned" });\n return;\n }\n // import useful package',10 unmodified lines' bot.once("error", onConnectionFailed);',''' bot.once("error", onConnectionFailed);\n\n // Mineflayer/pathfinder can occasionally generate NaN/Infinity movement\n // coordinates after a failed path/reset. Vanilla rejects those with\n // "Invalid move player packet received" and kicks the bot. Block only\n // malformed movement packets; valid movement is untouched.\n if (bot._client && typeof bot._client.write === "function") {\n const originalWrite = bot._client.write.bind(bot._client);\n bot._client.write = (name, data, ...args) => {\n if (data && ["position", "position_look", "look", "flying"].includes(name)) {\n const numericFields = ["x", "y", "z", "yaw", "pitch"];\n const invalid = numericFields.some((field) =>\n Object.prototype.hasOwnProperty.call(data, field) &&\n typeof data[field] === "number" &&\n !Number.isFinite(data[field])\n );\n if (invalid) {\n console.warn("Blocked invalid movement packet", name, data);\n return;\n }\n }\n return originalWrite(name, data, ...args);\n };\n }''',)text = text.replace('app.post("/stop", (req, res) => {\n bot.end();','app.post("/stop", (req, res) => {\n if (bot) bot.end();',81 unmodified linesinventory_rule = '''\nCRITICAL GROUND-TRUTH RULES:- The latest observed Inventory and Equipment are the truth about owned items. Nearby blocks are not inventory. Retrieved skills, QA context, old tasks and chat messages do not prove ownership or success.- Never assume, simulate or pretend to possess a missing item. Obtain/craft every missing prerequisite with the allowed primitives, then recheck the live inventory before the dependent step.- Count item quantities by summing item.count. NEVER use inventory.items().length, filter(...).length, or any array length as an item quantity; those values count occupied stacks, not items. Example: one stack with oak_log count=4 has array length 1 but quantity 4.- For crafting, prefer the official craftItem primitive and let Mineflayer's real recipe API determine whether ingredients are sufficient. Do not abort a crafting attempt based on a manual stack-length prerequisite check. craftItem count means recipe repetitions, so start with the minimum repetition needed and inspect the resulting live inventory.- A resolved primitive or a bot.chat message is not proof of success. Recheck inventory and world state after mining, crafting or placing, and throw an informative error if the prerequisite is still missing.- Logs are not planks, planks are not sticks, and an uncrafted/unplaced crafting table cannot be used. For a missing wooden pickaxe, actually craft planks, a crafting table and sticks before crafting the pickaxe; check quantities at every step.230 unmodified lines"VOYAGER_OPENAI_BASE": "http://127.0.0.1:7860/v1","VOYAGER_API_KEY": "local-voyager","VOYAGER_MODEL": "qwen3-coder-30b-a3b-instruct","VOYAGER_AUX_MODEL": "qwen3-coder-30b-a3b-instruct","VOYAGER_CKPT_DIR": str(CKPT_DIR),"MC_USERNAME": BOT_USERNAME,"BOT_DISPLAY_NAME": BOT_DISPLAY_NAME,"MC_PORT": "25565","MINEFLAYER_API_PORT": "3000","MAX_ITERATIONS": os.environ.get("MAX_ITERATIONS", "1000000"),"OPENAI_API_REQUEST_TIMEOUT": "600","ANONYMIZED_TELEMETRY": "False","NODE_PATH": node_path,"PYTHONPATH": str(SRC),89 unmodified lines"minecraft": "127.0.0.1:25565","openai_base": "http://127.0.0.1:7860/v1","model": "qwen3-coder-30b-a3b-instruct","aux_model": "qwen3-coder-30b-a3b-instruct","agent_routing": {"action": "30b", "curriculum": "30b", "critic": "30b", "qa": "30b", "skill_manager": "30b"},"bot_username": BOT_USERNAME,"bot_display_name": BOT_DISPLAY_NAME,"checkpoint_dir": str(CKPT_DIR),82 unmodified lines8384858687888990919293949510 unmodified lines10610710810911011111211311411511611711881 unmodified lines200201202203204205206230 unmodified lines43743843944044144244344444544644744844945089 unmodified lines54054154254354454554654782 unmodified lines' port: req.body.port, // minecraft server port\n username: process.env.MC_USERNAME || "Naldo_Bot",',' port: req.body.port, // minecraft server port\n version: "1.19", // server is pinned to Java 1.19; never auto-detect a different patch protocol\n username: process.env.MC_USERNAME || "Naldo_Bot",',)creative_spawn = ''' // Creative mode is the documented Voyager world mode. Keep a compact\n // working toolkit after every spawn/reset; any other vanilla item can\n // still be obtained explicitly with /give when the task requires it.\n bot.chat("/gamemode creative @s");\n const voyagerToolkit = [\n ["netherite_pickaxe", 1], ["netherite_axe", 1],\n ["netherite_shovel", 1], ["netherite_sword", 1],\n ["netherite_hoe", 1], ["shears", 1], ["flint_and_steel", 1],\n ["bow", 1], ["crossbow", 1], ["fishing_rod", 1],\n ["shield", 1], ["bucket", 1], ["arrow", 64],\n ["crafting_table", 1], ["furnace", 1]\n ];\n for (const [item, count] of voyagerToolkit) {\n const current = bot.inventory.items()\n .filter((stack) => stack.name === item)\n .reduce((sum, stack) => sum + stack.count, 0);\n if (current < count) {\n bot.chat(`/give @s minecraft:${item} ${count - current}`);\n itemTicks += 1;\n }\n }\n\n'''spawn_marker = " if (req.body.position) {\n"if creative_spawn.strip() not in text:if spawn_marker not in text:raise RuntimeError("Voyager spawn marker changed; refusing creative-mode patch")text = text.replace(spawn_marker, creative_spawn + spawn_marker, 1)text = text.replace('app.post("/step", async (req, res) => {\n // import useful package','app.post("/step", async (req, res) => {\n if (!bot || !bot.entity) {\n res.status(503).json({ error: "Bot not spawned" });\n return;\n }\n // import useful package',10 unmodified lines' bot.once("error", onConnectionFailed);',''' bot.once("error", onConnectionFailed);\n\n // Mineflayer/pathfinder can occasionally generate NaN/Infinity movement\n // coordinates after a failed path/reset. Vanilla rejects those with\n // "Invalid move player packet received" and kicks the bot. Block only\n // malformed movement packets; valid movement is untouched.\n if (bot._client && typeof bot._client.write === "function") {\n const originalWrite = bot._client.write.bind(bot._client);\n bot._client.write = (name, data, ...args) => {\n if (data && ["position", "position_look", "look", "flying"].includes(name)) {\n const numericFields = ["x", "y", "z", "yaw", "pitch"];\n const invalid = numericFields.some((field) =>\n Object.prototype.hasOwnProperty.call(data, field) &&\n typeof data[field] === "number" &&\n !Number.isFinite(data[field])\n );\n if (invalid) {\n console.warn("Blocked invalid movement packet", name, data);\n return;\n }\n }\n return originalWrite(name, data, ...args);\n };\n }''',)evaluate_marker = " async function evaluateCode(code, programs) {\n"inventory_guard = ''' // Official Voyager skills use bot.inventory.count(...) for quantities.\n // Reject stack-count code from the local LLM before it can consume resources.\n const directLengthBug = /bot\\.inventory\\.items\\(\\)(?:\\.filter\\([\\s\\S]{0,300}?\\))?\\.length\\b/;\n const assignedLengthBug = /(?:const|let|var)\\s+([A-Za-z_$][\\w$]*)\\s*=\\s*bot\\.inventory\\.items\\(\\)\\.filter\\([\\s\\S]{0,300}?\\);[\\s\\S]{0,500}?\\1\\.length\\b/;\n if (directLengthBug.test(code) || assignedLengthBug.test(code)) {\n throw new Error("Inventory quantity bug: array.length counts stacks, not items. Use bot.inventory.count(mcData.itemsByName.<item>.id) or sum item.count.");\n }\n'''if inventory_guard.strip() not in text:if evaluate_marker not in text:raise RuntimeError("Voyager evaluateCode marker changed; refusing inventory guard patch")text = text.replace(evaluate_marker, evaluate_marker + inventory_guard, 1)text = text.replace('app.post("/stop", (req, res) => {\n bot.end();','app.post("/stop", (req, res) => {\n if (bot) bot.end();',81 unmodified linesinventory_rule = '''\nCRITICAL GROUND-TRUTH RULES:- The latest observed Inventory and Equipment are the truth about owned items. Nearby blocks are not inventory. Retrieved skills, QA context, old tasks and chat messages do not prove ownership or success.- Never assume, simulate or pretend to possess a missing item. Obtain/craft every missing prerequisite with the allowed primitives, then recheck the live inventory before the dependent step.- Count item quantities with the official Voyager skill pattern `bot.inventory.count(mcData.itemsByName.<item>.id)` or by summing item.count. NEVER use inventory.items().length, filter(...).length, or any array length as an item quantity; those values count occupied stacks, not items. Example: one stack with oak_log count=4 has array length 1 but quantity 4.- For crafting, prefer the official craftItem primitive and let Mineflayer's real recipe API determine whether ingredients are sufficient. Do not abort a crafting attempt based on a manual stack-length prerequisite check. craftItem count means recipe repetitions, so start with the minimum repetition needed and inspect the resulting live inventory.- A resolved primitive or a bot.chat message is not proof of success. Recheck inventory and world state after mining, crafting or placing, and throw an informative error if the prerequisite is still missing.- Logs are not planks, planks are not sticks, and an uncrafted/unplaced crafting table cannot be used. For a missing wooden pickaxe, actually craft planks, a crafting table and sticks before crafting the pickaxe; check quantities at every step.230 unmodified lines"VOYAGER_OPENAI_BASE": "http://127.0.0.1:7860/v1","VOYAGER_API_KEY": "local-voyager","VOYAGER_MODEL": "qwen3-coder-30b-a3b-instruct","VOYAGER_AUX_MODEL": "qwen3-4b-instruct-2507-aux","VOYAGER_CKPT_DIR": str(CKPT_DIR),"MC_USERNAME": BOT_USERNAME,"BOT_DISPLAY_NAME": BOT_DISPLAY_NAME,"MC_PORT": "25565","MINEFLAYER_API_PORT": "3000","MAX_ITERATIONS": os.environ.get("MAX_ITERATIONS", "1000000"),"OPENAI_API_REQUEST_TIMEOUT": "240","ANONYMIZED_TELEMETRY": "False","NODE_PATH": node_path,"PYTHONPATH": str(SRC),89 unmodified lines"minecraft": "127.0.0.1:25565","openai_base": "http://127.0.0.1:7860/v1","model": "qwen3-coder-30b-a3b-instruct","aux_model": "qwen3-4b-instruct-2507-aux","agent_routing": {"action": "30b", "curriculum": "30b", "critic": "30b", "qa": "4b", "skill_manager": "4b"},"bot_username": BOT_USERNAME,"bot_display_name": BOT_DISPLAY_NAME,"checkpoint_dir": str(CKPT_DIR),
app.py+2-2
minecraft_stack.py+40
voyager_runner.py+6-8
voyager_stack.py+19-5