mindcraft 0.1.4-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/FAQ.md +38 -0
  2. package/LICENSE +21 -0
  3. package/README.md +255 -0
  4. package/andy.json +6 -0
  5. package/bin/mindcraft.js +80 -0
  6. package/keys.example.json +19 -0
  7. package/main.js +80 -0
  8. package/package.json +78 -0
  9. package/patches/minecraft-data+3.97.0.patch +13 -0
  10. package/patches/mineflayer+4.33.0.patch +54 -0
  11. package/patches/mineflayer-pathfinder+2.4.5.patch +265 -0
  12. package/patches/mineflayer-pvp+1.3.2.patch +13 -0
  13. package/patches/prismarine-viewer+1.33.0.patch +13 -0
  14. package/patches/protodef+1.19.0.patch +15 -0
  15. package/profiles/andy-4-reasoning.json +14 -0
  16. package/profiles/andy-4.json +7 -0
  17. package/profiles/azure.json +19 -0
  18. package/profiles/claude.json +7 -0
  19. package/profiles/claude_thinker.json +15 -0
  20. package/profiles/deepseek.json +7 -0
  21. package/profiles/defaults/_default.json +256 -0
  22. package/profiles/defaults/assistant.json +14 -0
  23. package/profiles/defaults/creative.json +14 -0
  24. package/profiles/defaults/god_mode.json +14 -0
  25. package/profiles/defaults/survival.json +14 -0
  26. package/profiles/freeguy.json +7 -0
  27. package/profiles/gemini.json +9 -0
  28. package/profiles/gpt.json +12 -0
  29. package/profiles/grok.json +7 -0
  30. package/profiles/llama.json +10 -0
  31. package/profiles/mercury.json +9 -0
  32. package/profiles/mistral.json +5 -0
  33. package/profiles/qwen.json +17 -0
  34. package/profiles/tasks/construction_profile.json +42 -0
  35. package/profiles/tasks/cooking_profile.json +11 -0
  36. package/profiles/tasks/crafting_profile.json +71 -0
  37. package/profiles/vllm.json +10 -0
  38. package/settings.js +64 -0
  39. package/src/agent/action_manager.js +177 -0
  40. package/src/agent/agent.js +561 -0
  41. package/src/agent/coder.js +229 -0
  42. package/src/agent/commands/actions.js +504 -0
  43. package/src/agent/commands/index.js +259 -0
  44. package/src/agent/commands/queries.js +347 -0
  45. package/src/agent/connection_handler.js +96 -0
  46. package/src/agent/conversation.js +353 -0
  47. package/src/agent/history.js +122 -0
  48. package/src/agent/library/full_state.js +89 -0
  49. package/src/agent/library/index.js +23 -0
  50. package/src/agent/library/lockdown.js +32 -0
  51. package/src/agent/library/skill_library.js +93 -0
  52. package/src/agent/library/skills.js +2093 -0
  53. package/src/agent/library/world.js +431 -0
  54. package/src/agent/memory_bank.js +25 -0
  55. package/src/agent/mindserver_proxy.js +136 -0
  56. package/src/agent/modes.js +446 -0
  57. package/src/agent/npc/build_goal.js +80 -0
  58. package/src/agent/npc/construction/dirt_shelter.json +38 -0
  59. package/src/agent/npc/construction/large_house.json +230 -0
  60. package/src/agent/npc/construction/small_stone_house.json +42 -0
  61. package/src/agent/npc/construction/small_wood_house.json +42 -0
  62. package/src/agent/npc/controller.js +261 -0
  63. package/src/agent/npc/data.js +50 -0
  64. package/src/agent/npc/item_goal.js +355 -0
  65. package/src/agent/npc/utils.js +126 -0
  66. package/src/agent/self_prompter.js +146 -0
  67. package/src/agent/settings.js +7 -0
  68. package/src/agent/speak.js +150 -0
  69. package/src/agent/tasks/construction_tasks.js +1104 -0
  70. package/src/agent/tasks/cooking_tasks.js +358 -0
  71. package/src/agent/tasks/tasks.js +594 -0
  72. package/src/agent/templates/execTemplate.js +6 -0
  73. package/src/agent/templates/lintTemplate.js +10 -0
  74. package/src/agent/vision/browser_viewer.js +8 -0
  75. package/src/agent/vision/camera.js +78 -0
  76. package/src/agent/vision/vision_interpreter.js +82 -0
  77. package/src/mindcraft/index.js +28 -0
  78. package/src/mindcraft/mcserver.js +154 -0
  79. package/src/mindcraft/mindcraft.js +111 -0
  80. package/src/mindcraft/mindserver.js +328 -0
  81. package/src/mindcraft/public/index.html +1253 -0
  82. package/src/mindcraft/public/settings_spec.json +145 -0
  83. package/src/mindcraft/userconfig.js +72 -0
  84. package/src/mindcraft-py/example.py +27 -0
  85. package/src/mindcraft-py/init-mindcraft.js +24 -0
  86. package/src/mindcraft-py/mindcraft.py +99 -0
  87. package/src/models/_model_map.js +89 -0
  88. package/src/models/azure.js +32 -0
  89. package/src/models/cerebras.js +61 -0
  90. package/src/models/claude.js +87 -0
  91. package/src/models/deepseek.js +59 -0
  92. package/src/models/gemini.js +176 -0
  93. package/src/models/glhf.js +71 -0
  94. package/src/models/gpt.js +147 -0
  95. package/src/models/grok.js +82 -0
  96. package/src/models/groq.js +95 -0
  97. package/src/models/huggingface.js +86 -0
  98. package/src/models/hyperbolic.js +114 -0
  99. package/src/models/lmstudio.js +74 -0
  100. package/src/models/mercury.js +95 -0
  101. package/src/models/mistral.js +94 -0
  102. package/src/models/novita.js +71 -0
  103. package/src/models/ollama.js +115 -0
  104. package/src/models/openrouter.js +77 -0
  105. package/src/models/prompter.js +366 -0
  106. package/src/models/qwen.js +80 -0
  107. package/src/models/replicate.js +60 -0
  108. package/src/models/vllm.js +81 -0
  109. package/src/process/agent_process.js +84 -0
  110. package/src/process/init_agent.js +54 -0
  111. package/src/utils/examples.js +83 -0
  112. package/src/utils/keys.js +34 -0
  113. package/src/utils/math.js +13 -0
  114. package/src/utils/mcdata.js +572 -0
  115. package/src/utils/text.js +78 -0
  116. package/src/utils/translator.js +30 -0
package/FAQ.md ADDED
@@ -0,0 +1,38 @@
1
+ # Common Issues
2
+ - `Error: connect ECONNREFUSED`: Minecraft refused to connect with mindcraft program. Most likely due to:
3
+ - you have not opened your game to LAN in game settings
4
+ - your LAN port is incorrect, make sure the one you enter in game is the same as specified in `settings.js`
5
+ - you have the wrong version of minecraft, make sure your MC version is the same as specified in `settings.js`
6
+
7
+ - `ERR_MODULE_NOT_FOUND`: You are missing an npm package. run `npm install`
8
+
9
+ - Many issues are caused by out-of-date node module patches, especially after updates. A catch-all is to delete the `node_modules` folder, and run `npm install`
10
+
11
+ - **`npm install` fails with Python or C++ build errors**: This typically happens when building native modules like `gl`. Common solutions:
12
+ - **Python not found** (macOS/Linux): If you see `python: command not found`, create a symlink: `sudo ln -s $(which python3) /usr/local/bin/python`
13
+ - **C++20 errors or Node version issues**: If you see `"C++20 or later required"` errors, you're likely using Node v24 or newer. The `gl` package requires Node LTS (v18 or v20). Switch versions using:
14
+ ```bash
15
+ nvm install 20
16
+ nvm use 20
17
+ rm -rf node_modules package-lock.json
18
+ npm install
19
+ ```
20
+ - **Skip optional packages**: If you don't need the vision feature (disabled by default), you can skip the problematic `gl` package: `npm install --no-optional`
21
+
22
+ - `My brain disconnected, try again`: Something is wrong with the LLM api. You may have the wrong API key, exceeded your rate limits, or other. Check the program outputs for more details.
23
+
24
+ - `I'm stuck!` or other issues with constantly getting stuck:
25
+ - Mineflayer's pathfinder is imperfect. We have improved upon it with patches, but these might not have been applied properly. Make sure your code is up to date with main, delete the `node_modules` folder, and run `npm install`
26
+ - The bot will still get stuck occasionally, but not constantly.
27
+
28
+ - `Why I added the api key but still prompted that the key can't be found?`
29
+ - Possible reason 1: Did not modify keys.example.json to keys.json.
30
+ - Possible reason 2: If you use vscode to edit, you need to `ctrl+s` to save the file for the changes to take effect.
31
+ - Possible reason 3: Not setting the code path correctly in setting.js, use andy.js by default.
32
+
33
+ # Common Questions
34
+ - Mod Support? Mindcraft only supports client-side mods like optifine and sodium, though they can be tricky to set up. Mods that change minecraft game mechanics are not supported.
35
+
36
+ - Texture Packs? Apparently these cause issues and refuse to connect. Not sure why
37
+
38
+ - Baritone? Baritone is a mod that is completely different from mineflayer. There is currently no easy way to integrate the two programs.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Kolby Nottingham
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,255 @@
1
+ <h1 align="center">🧠mindcraft⛏️</h1>
2
+ <h1 align="center">
3
+ <a href="https://trendshift.io/repositories/9163" target="_blank"><img src="https://trendshift.io/api/badge/repositories/9163" alt="kolbytn%2Fmindcraft | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
4
+ </h1>
5
+
6
+ <p align="center">Crafting minds for Minecraft with LLMs and <a href="https://prismarinejs.github.io/mineflayer/#/">Mineflayer!</a></p>
7
+
8
+ <p align="center">
9
+ <a href="https://github.com/mindcraft-bots/mindcraft/blob/main/FAQ.md">FAQ</a> |
10
+ <a href="https://discord.gg/mp73p35dzC">Discord Support</a> |
11
+ <a href="https://www.youtube.com/watch?v=gRotoL8P8D8">Video Tutorial</a> |
12
+ <a href="https://kolbynottingham.com/mindcraft/">Blog Post</a> |
13
+ <a href="https://mindcraft-minecollab.github.io/index.html">Paper Website</a> |
14
+ <a href="https://github.com/mindcraft-bots/mindcraft/blob/main/minecollab.md">MineCollab</a>
15
+ </p>
16
+
17
+ > [!Caution]
18
+ Do not connect this bot to public servers with coding enabled. This project allows an LLM to write/execute code on your computer. The code is sandboxed, but still vulnerable to injection attacks. Code writing is disabled by default, you can enable it by setting `allow_insecure_coding` to `true` in `settings.js`. Ye be warned.
19
+
20
+ # Getting Started
21
+ ## Requirements
22
+
23
+ - [Minecraft Java Edition](https://www.minecraft.net/en-us/store/minecraft-java-bedrock-edition-pc) (up to v1.21.11, recommend v1.21.6)
24
+ - [Node.js Installed](https://nodejs.org/) (Node v18 or v20 LTS recommended. Node v24+ may cause issues with native dependencies)
25
+ - At least one API key from a supported API provider. See [supported APIs](#model-customization). OpenAI is the default.
26
+
27
+ > [!Important]
28
+ > If installing node on windows, ensure you check `Automatically install the necessary tools`
29
+ >
30
+ > If you encounter `npm install` errors on macOS, see the [FAQ](FAQ.md#common-issues) for troubleshooting native module build issues
31
+
32
+ ## Install and Run
33
+
34
+ 1. Make sure you have the requirements above.
35
+
36
+ 2. Download the [latest release](https://github.com/mindcraft-bots/mindcraft/releases/latest) and unzip it, or clone the repository.
37
+
38
+ 3. Rename `keys.example.json` to `keys.json` and fill in your API keys (you only need one). The desired model is set in `andy.json` or other profiles. For other models refer to the table below.
39
+
40
+ 4. In terminal/command prompt, run `npm install` from the installed directory
41
+
42
+ 5. Start a minecraft world and open it to LAN on localhost port `55916`
43
+
44
+ 6. Run `node main.js` from the installed directory
45
+
46
+ If you encounter issues, check the [FAQ](https://github.com/mindcraft-bots/mindcraft/blob/main/FAQ.md) or find support on [discord](https://discord.gg/mp73p35dzC). We are currently not very responsive to github issues. To run tasks please refer to [Minecollab Instructions](minecollab.md#installation)
47
+
48
+
49
+ # Configuration
50
+ ## Model Customization
51
+
52
+ You can configure project details in `settings.js`. [See file.](settings.js)
53
+
54
+ You can configure the agent's name, model, and prompts in their profile like `andy.json`. The model can be specified with the `model` field, with values like `model: "gemini-2.5-pro"`. You will need the correct API key for the API provider you choose. See all supported APIs below.
55
+
56
+ <details>
57
+ <summary><strong>⭐ VIEW SUPPORTED APIs ⭐</strong></summary>
58
+
59
+ | API Name | Config Variable| Docs |
60
+ |------|------|------|
61
+ | `openai` | `OPENAI_API_KEY` | [docs](https://platform.openai.com/docs/models) |
62
+ | `google` | `GEMINI_API_KEY` | [docs](https://ai.google.dev/gemini-api/docs/models/gemini) |
63
+ | `anthropic` | `ANTHROPIC_API_KEY` | [docs](https://docs.anthropic.com/claude/docs/models-overview) |
64
+ | `xai` | `XAI_API_KEY` | [docs](https://docs.x.ai/docs) |
65
+ | `deepseek` | `DEEPSEEK_API_KEY` | [docs](https://api-docs.deepseek.com/) |
66
+ | `ollama` (local) | n/a | [docs](https://ollama.com/library) |
67
+ | `qwen` | `QWEN_API_KEY` | [Intl.](https://www.alibabacloud.com/help/en/model-studio/developer-reference/use-qwen-by-calling-api)/[cn](https://help.aliyun.com/zh/model-studio/getting-started/models) |
68
+ | `mistral` | `MISTRAL_API_KEY` | [docs](https://docs.mistral.ai/getting-started/models/models_overview/) |
69
+ | `replicate` | `REPLICATE_API_KEY` | [docs](https://replicate.com/collections/language-models) |
70
+ | `groq` (not grok) | `GROQCLOUD_API_KEY` | [docs](https://console.groq.com/docs/models) |
71
+ | `huggingface` | `HUGGINGFACE_API_KEY` | [docs](https://huggingface.co/models) |
72
+ | `novita` | `NOVITA_API_KEY` | [docs](https://novita.ai/model-api/product/llm-api?utm_source=github_mindcraft&utm_medium=github_readme&utm_campaign=link) |
73
+ | `openrouter` | `OPENROUTER_API_KEY` | [docs](https://openrouter.ai/models) |
74
+ | `glhf` | `GHLF_API_KEY` | [docs](https://glhf.chat/user-settings/api) |
75
+ | `hyperbolic` | `HYPERBOLIC_API_KEY` | [docs](https://docs.hyperbolic.xyz/docs/getting-started) |
76
+ | `vllm` | n/a | n/a |
77
+ | `cerebras` | `CEREBRAS_API_KEY` | [docs](https://inference-docs.cerebras.ai/introduction) |
78
+ | `mercury` | `MERCURY_API_KEY` | [docs](https://www.inceptionlabs.ai/) |
79
+
80
+ </details>
81
+
82
+ For more comprehensive model configuration and syntax, see [Model Specifications](#model-specifications).
83
+
84
+ For local models we support [ollama](https://ollama.com/) and we provide our own finetuned models for you to use.
85
+ To install our models, install ollama and run the following terminal command:
86
+ ```bash
87
+ ollama pull sweaterdog/andy-4:micro-q8_0 && ollama pull embeddinggemma
88
+ ```
89
+
90
+ ## Online Servers
91
+ To connect to online servers your bot will need an official Microsoft/Minecraft account. You can use your own personal one, but will need another account if you want to connect too and play with it. To connect, change these lines in `settings.js`:
92
+ ```javascript
93
+ "host": "111.222.333.444",
94
+ "port": 55920,
95
+ "auth": "microsoft",
96
+
97
+ // rest is same...
98
+ ```
99
+ > [!Important]
100
+ > The bot's name in the profile.json must exactly match the Minecraft profile name! Otherwise the bot will spam talk to itself.
101
+
102
+ To use different accounts, Mindcraft will connect with the account that the Minecraft launcher is currently using. You can switch accounts in the launcher, then run `node main.js`, then switch to your main account after the bot has connected.
103
+
104
+ ## Tasks
105
+
106
+ Tasks automatically start the bot with a prompt and a goal item to acquire or blueprint to construct. To run a simple task that involves collecting 4 oak_logs run
107
+
108
+ `node main.js --task_path tasks/basic/single_agent.json --task_id gather_oak_logs`
109
+
110
+ Here is an example task json format:
111
+
112
+ ```
113
+ {
114
+ "gather_oak_logs": {
115
+ "goal": "Collect at least four logs",
116
+ "initial_inventory": {
117
+ "0": {
118
+ "wooden_axe": 1
119
+ }
120
+ },
121
+ "agent_count": 1,
122
+ "target": "oak_log",
123
+ "number_of_target": 4,
124
+ "type": "techtree",
125
+ "max_depth": 1,
126
+ "depth": 0,
127
+ "timeout": 300,
128
+ "blocked_actions": {
129
+ "0": [],
130
+ "1": []
131
+ },
132
+ "missing_items": [],
133
+ "requires_ctable": false
134
+ }
135
+ }
136
+ ```
137
+
138
+ The `initial_inventory` is what the bot will have at the start of the episode, `target` refers to the target item and `number_of_target` refers to the number of target items the agent needs to collect to successfully complete the task.
139
+
140
+ If you want more optimization and automatic launching of the minecraft world, you will need to follow the instructions in [Minecollab Instructions](minecollab.md#installation)
141
+
142
+ ## Docker Container
143
+
144
+ If you intend to `allow_insecure_coding`, it is a good idea to run the app in a docker container to reduce risks of running unknown code. This is strongly recommended before connecting to remote servers, although still does not guarantee complete safety.
145
+
146
+ ```bash
147
+ docker build -t mindcraft . && docker run --rm --add-host=host.docker.internal:host-gateway -p 8080:8080 -p 3000-3003:3000-3003 -e SETTINGS_JSON='{"auto_open_ui":false,"profiles":["./profiles/gemini.json"],"host":"host.docker.internal"}' --volume ./keys.json:/app/keys.json --name mindcraft mindcraft
148
+ ```
149
+ or simply
150
+ ```bash
151
+ docker-compose up --build
152
+ ```
153
+
154
+ When running in docker, if you want the bot to join your local minecraft server, you have to use a special host address `host.docker.internal` to call your localhost from inside your docker container. Put this into your [settings.js](settings.js):
155
+
156
+ ```javascript
157
+ "host": "host.docker.internal", // instead of "localhost", to join your local minecraft from inside the docker container
158
+ ```
159
+
160
+ To connect to an unsupported minecraft version, you can try to use [viaproxy](services/viaproxy/README.md)
161
+
162
+ # Bot Profiles
163
+
164
+ Bot profiles are json files (such as `andy.json`) that define:
165
+
166
+ 1. Bot backend LLMs to use for talking, coding, and embedding.
167
+ 2. Prompts used to influence the bot's behavior.
168
+ 3. Examples help the bot perform tasks.
169
+
170
+ ## Model Specifications
171
+
172
+ LLM models can be specified simply as `"model": "gpt-4o"`, or more specifically with `"{api}/{model}"`, like `"openrouter/google/gemini-2.5-pro"`. See all supported APIs [here](#model-customization).
173
+
174
+ The `model` field can be a string or an object. A model object must specify an `api`, and optionally a `model`, `url`, and additional `params`. You can also use different models/providers for chatting, coding, vision, embedding, and voice synthesis. See the example below.
175
+
176
+ ```json
177
+ "model": {
178
+ "api": "openai",
179
+ "model": "gpt-4o",
180
+ "url": "https://api.openai.com/v1/",
181
+ "params": {
182
+ "max_tokens": 1000,
183
+ "temperature": 1
184
+ }
185
+ },
186
+ "code_model": {
187
+ "api": "openai",
188
+ "model": "gpt-4",
189
+ "url": "https://api.openai.com/v1/"
190
+ },
191
+ "vision_model": {
192
+ "api": "openai",
193
+ "model": "gpt-4o",
194
+ "url": "https://api.openai.com/v1/"
195
+ },
196
+ "embedding": {
197
+ "api": "openai",
198
+ "url": "https://api.openai.com/v1/",
199
+ "model": "text-embedding-ada-002"
200
+ },
201
+ "speak_model": "openai/tts-1/echo"
202
+ ```
203
+
204
+ `model` is used for chat, `code_model` is used for newAction coding, `vision_model` is used for image interpretation, `embedding` is used to embed text for example selection, and `speak_model` is used for voice synthesis. `model` will be used by default for all other models if not specified. Not all APIs support embeddings, vision, or voice synthesis.
205
+
206
+ All apis have default models and urls, so those fields are optional. The `params` field is optional and can be used to specify additional parameters for the model. It accepts any key-value pairs supported by the api. Is not supported for embedding models.
207
+
208
+ ## Embedding Models
209
+
210
+ Embedding models are used to embed and efficiently select relevant examples for conversation and coding.
211
+
212
+ Supported Embedding APIs: `openai`, `google`, `replicate`, `huggingface`, `novita`
213
+
214
+ If you try to use an unsupported model, then it will default to a simple word-overlap method. Expect reduced performance. We recommend using supported embedding APIs.
215
+
216
+ ## Voice Synthesis Models
217
+
218
+ Voice synthesis models are used to narrate bot responses and specified with `speak_model`. This field is parsed differently than other models and only supports strings formatted as `"{api}/{model}/{voice}"`, like `"openai/tts-1/echo"`. We only support `openai` and `google` for voice synthesis.
219
+
220
+ ## Specifying Profiles via Command Line
221
+
222
+ By default, the program will use the profiles specified in `settings.js`. You can specify one or more agent profiles using the `--profiles` argument: `node main.js --profiles ./profiles/andy.json ./profiles/jill.json`
223
+
224
+
225
+ # Contributing
226
+
227
+ We welcome contributions to the project! We are generally less responsive to github issues, and more responsive to pull requests. Join the [discord](https://discord.gg/mp73p35dzC) for more active support and direction.
228
+
229
+ While AI generated code is allowed, please vet it carefully. Submitting tons of sloppy code and documentation actively harms development.
230
+
231
+ ## Patches
232
+
233
+ Some of the node modules that we depend on have bugs in them. To add a patch, change your local node module file and run `npx patch-package [package-name]`
234
+
235
+ ## Development Team
236
+ Thanks to all who contributed to the project, especially the official development team: [@MaxRobinsonTheGreat](https://github.com/MaxRobinsonTheGreat), [@kolbytn](https://github.com/kolbytn), [@icwhite](https://github.com/icwhite), [@Sweaterdog](https://github.com/Sweaterdog), [@Ninot1Quyi](https://github.com/Ninot1Quyi), [@riqvip](https://github.com/riqvip), [@uukelele-scratch](https://github.com/uukelele-scratch), [@mrelmida](https://github.com/mrelmida)
237
+
238
+
239
+ ## Citation:
240
+ This work is published in the paper [Collaborating Action by Action: A Multi-agent LLM Framework for Embodied Reasoning](https://arxiv.org/abs/2504.17950). Please use this citation if you use this project in your research:
241
+ ```
242
+ @article{mindcraft2025,
243
+ title = {Collaborating Action by Action: A Multi-agent LLM Framework for Embodied Reasoning},
244
+ author = {White*, Isadora and Nottingham*, Kolby and Maniar, Ayush and Robinson, Max and Lillemark, Hansen and Maheshwari, Mehul and Qin, Lianhui and Ammanabrolu, Prithviraj},
245
+ journal = {arXiv preprint arXiv:2504.17950},
246
+ year = {2025},
247
+ url = {https://arxiv.org/abs/2504.17950},
248
+ }
249
+ ```
250
+
251
+ ## Contributors
252
+
253
+ Thanks to everyone who has submitted issues on and off Github, made suggestions, and generally helped make this a better project.
254
+
255
+ ![Contributors](https://contrib.rocks/image?repo=mindcraft-bots/mindcraft)
package/andy.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "andy",
3
+
4
+ "model": "gpt-5.4-mini"
5
+
6
+ }
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env node
2
+ import { init, createAgent } from '../src/mindcraft/mindcraft.js';
3
+ import { overrideSpecDefaults } from '../src/mindcraft/mindserver.js';
4
+ import * as userconfig from '../src/mindcraft/userconfig.js';
5
+
6
+ const HELP = `
7
+ mindcraft — LLM agents for Minecraft
8
+
9
+ Usage:
10
+ npx mindcraft [ui] [options]
11
+
12
+ Commands:
13
+ ui (default) Start the mindserver web UI. Configure your API key,
14
+ Minecraft server, and bots from the browser.
15
+
16
+ Options:
17
+ --port <n> Web UI port [default: 8080]
18
+ --data-dir <dir> Where bot memories/histories live [default: ~/.config/mindcraft/bots]
19
+ --no-open Don't auto-open the browser
20
+ -h, --help Show this help
21
+
22
+ Config is stored under $XDG_CONFIG_HOME/mindcraft (default ~/.config/mindcraft).
23
+ `.trim();
24
+
25
+ function parseArgs(argv) {
26
+ const opts = {
27
+ cmd: 'ui',
28
+ port: 8080,
29
+ dataDir: userconfig.paths.BOTS_DIR,
30
+ open: true,
31
+ };
32
+ for (let i = 0; i < argv.length; i++) {
33
+ const a = argv[i];
34
+ if (a === '-h' || a === '--help') { console.log(HELP); process.exit(0); }
35
+ else if (a === 'ui') opts.cmd = 'ui';
36
+ else if (a === '--port') opts.port = parseInt(argv[++i], 10);
37
+ else if (a === '--data-dir') opts.dataDir = argv[++i];
38
+ else if (a === '--no-open') opts.open = false;
39
+ else { console.error(`Unknown argument: ${a}\n\n${HELP}`); process.exit(2); }
40
+ }
41
+ return opts;
42
+ }
43
+
44
+ async function main() {
45
+ const opts = parseArgs(process.argv.slice(2));
46
+ if (opts.cmd !== 'ui') return;
47
+
48
+ // Load persisted config from ~/.config/mindcraft so a restart picks up where the
49
+ // wizard left off: keys → process.env, server settings → spec defaults,
50
+ // saved bots → recreated.
51
+ userconfig.loadKeysIntoEnv();
52
+ const config = userconfig.getConfig();
53
+ overrideSpecDefaults({
54
+ data_dir: opts.dataDir,
55
+ ...(config?.server || {}),
56
+ });
57
+
58
+ await init(false, opts.port, opts.open);
59
+ console.log(`\nMindcraft UI: http://localhost:${opts.port}`);
60
+ console.log(`Bot data dir: ${opts.dataDir}`);
61
+
62
+ if (config?.bots?.length) {
63
+ const profiles = Object.fromEntries(userconfig.listProfiles().map(p => [p.name, p]));
64
+ for (const bot of config.bots) {
65
+ const profile = profiles[bot.profile];
66
+ if (!profile) { console.warn(`Skipping bot "${bot.profile}": profile not found`); continue; }
67
+ console.log(`Restoring bot: ${bot.profile}`);
68
+ await createAgent({
69
+ ...(config.server || {}),
70
+ data_dir: opts.dataDir,
71
+ base_profile: bot.base_profile || 'assistant',
72
+ profile,
73
+ });
74
+ }
75
+ } else {
76
+ console.log(`No saved bots — open the UI to run setup.\n`);
77
+ }
78
+ }
79
+
80
+ main().catch((err) => { console.error(err); process.exit(1); });
@@ -0,0 +1,19 @@
1
+ {
2
+ "OPENAI_API_KEY": "",
3
+ "OPENAI_ORG_ID": "",
4
+ "GEMINI_API_KEY": "",
5
+ "ANTHROPIC_API_KEY": "",
6
+ "REPLICATE_API_KEY": "",
7
+ "GROQCLOUD_API_KEY": "",
8
+ "HUGGINGFACE_API_KEY": "",
9
+ "QWEN_API_KEY": "",
10
+ "XAI_API_KEY": "",
11
+ "MISTRAL_API_KEY": "",
12
+ "DEEPSEEK_API_KEY": "",
13
+ "GHLF_API_KEY": "",
14
+ "HYPERBOLIC_API_KEY": "",
15
+ "NOVITA_API_KEY": "",
16
+ "OPENROUTER_API_KEY": "",
17
+ "CEREBRAS_API_KEY": "",
18
+ "MERCURY_API_KEY":""
19
+ }
package/main.js ADDED
@@ -0,0 +1,80 @@
1
+ import * as Mindcraft from './src/mindcraft/mindcraft.js';
2
+ import settings from './settings.js';
3
+ import yargs from 'yargs';
4
+ import { hideBin } from 'yargs/helpers';
5
+ import { readFileSync } from 'fs';
6
+
7
+ function parseArguments() {
8
+ return yargs(hideBin(process.argv))
9
+ .option('profiles', {
10
+ type: 'array',
11
+ describe: 'List of agent profile paths',
12
+ })
13
+ .option('task_path', {
14
+ type: 'string',
15
+ describe: 'Path to task file to execute'
16
+ })
17
+ .option('task_id', {
18
+ type: 'string',
19
+ describe: 'Task ID to execute'
20
+ })
21
+ .help()
22
+ .alias('help', 'h')
23
+ .parse();
24
+ }
25
+ const args = parseArguments();
26
+ if (args.profiles) {
27
+ settings.profiles = args.profiles;
28
+ }
29
+ if (args.task_path) {
30
+ let tasks = JSON.parse(readFileSync(args.task_path, 'utf8'));
31
+ if (args.task_id) {
32
+ settings.task = tasks[args.task_id];
33
+ settings.task.task_id = args.task_id;
34
+ }
35
+ else {
36
+ throw new Error('task_id is required when task_path is provided');
37
+ }
38
+ }
39
+
40
+ // these environment variables override certain settings
41
+ if (process.env.MINECRAFT_PORT) {
42
+ settings.port = process.env.MINECRAFT_PORT;
43
+ }
44
+ if (process.env.MINDSERVER_PORT) {
45
+ settings.mindserver_port = process.env.MINDSERVER_PORT;
46
+ }
47
+ if (process.env.PROFILES && JSON.parse(process.env.PROFILES).length > 0) {
48
+ settings.profiles = JSON.parse(process.env.PROFILES);
49
+ }
50
+ if (process.env.INSECURE_CODING) {
51
+ settings.allow_insecure_coding = true;
52
+ }
53
+ if (process.env.BLOCKED_ACTIONS) {
54
+ settings.blocked_actions = JSON.parse(process.env.BLOCKED_ACTIONS);
55
+ }
56
+ if (process.env.MAX_MESSAGES) {
57
+ settings.max_messages = process.env.MAX_MESSAGES;
58
+ }
59
+ if (process.env.NUM_EXAMPLES) {
60
+ settings.num_examples = process.env.NUM_EXAMPLES;
61
+ }
62
+ if (process.env.LOG_ALL) {
63
+ settings.log_all_prompts = process.env.LOG_ALL;
64
+ }
65
+ if (process.env.SETTINGS_JSON) {
66
+ try {
67
+ Object.assign(settings, JSON.parse(process.env.SETTINGS_JSON));
68
+ } catch (err) {
69
+ console.error("Failed to parse environment variable for SETTINGS_JSON:", err);
70
+ }
71
+ }
72
+
73
+
74
+ Mindcraft.init(false, settings.mindserver_port, settings.auto_open_ui);
75
+
76
+ for (let profile of settings.profiles) {
77
+ const profile_json = JSON.parse(readFileSync(profile, 'utf8'));
78
+ settings.profile = profile_json;
79
+ Mindcraft.createAgent(settings);
80
+ }
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "mindcraft",
3
+ "version": "0.1.4-0",
4
+ "type": "module",
5
+ "publishConfig": {
6
+ "tag": "latest"
7
+ },
8
+ "main": "./src/mindcraft/index.js",
9
+ "exports": {
10
+ ".": "./src/mindcraft/index.js",
11
+ "./settings-spec": "./src/mindcraft/public/settings_spec.json"
12
+ },
13
+ "bin": {
14
+ "mindcraft": "./bin/mindcraft.js"
15
+ },
16
+ "files": [
17
+ "bin",
18
+ "src",
19
+ "profiles",
20
+ "patches",
21
+ "main.js",
22
+ "settings.js",
23
+ "andy.json",
24
+ "keys.example.json",
25
+ "FAQ.md",
26
+ "README.md",
27
+ "LICENSE"
28
+ ],
29
+ "dependencies": {
30
+ "@anthropic-ai/sdk": "^0.17.1",
31
+ "@cerebras/cerebras_cloud_sdk": "^1.46.0",
32
+ "@eslint/js": "^9.13.0",
33
+ "@google/genai": "^1.15.0",
34
+ "@huggingface/inference": "^2.8.1",
35
+ "@mistralai/mistralai": "^1.1.0",
36
+ "cheerio": "^1.0.0",
37
+ "eslint": "^9.13.0",
38
+ "eslint-plugin-no-floating-promise": "^2.0.0",
39
+ "express": "^4.18.2",
40
+ "globals": "^15.11.0",
41
+ "google-translate-api-x": "^10.7.1",
42
+ "groq-sdk": "^0.15.0",
43
+ "minecraft-data": "^3.97.0",
44
+ "mineflayer": "^4.33.0",
45
+ "mineflayer-armor-manager": "^2.0.1",
46
+ "mineflayer-auto-eat": "^3.3.6",
47
+ "mineflayer-collectblock": "^1.4.1",
48
+ "mineflayer-pathfinder": "^2.4.5",
49
+ "mineflayer-pvp": "^1.3.2",
50
+ "open": "^10.2.0",
51
+ "openai": "^4.4.0",
52
+ "patch-package": "^8.0.0",
53
+ "prismarine-item": "^1.15.0",
54
+ "prismarine-viewer": "^1.32.0",
55
+ "replicate": "^0.29.4",
56
+ "ses": "^1.9.1",
57
+ "socket.io": "^4.7.2",
58
+ "socket.io-client": "^4.7.2",
59
+ "three": "^0.128.0",
60
+ "vec3": "^0.1.10",
61
+ "yargs": "^17.7.2"
62
+ },
63
+ "optionalDependencies": {
64
+ "canvas": "^3.1.0",
65
+ "node-canvas-webgl": "^0.3.0"
66
+ },
67
+ "overrides": {
68
+ "canvas": "^3.1.0",
69
+ "gl": "^8.1.6"
70
+ },
71
+ "scripts": {
72
+ "postinstall": "patch-package",
73
+ "start": "node main.js",
74
+ "reinstall": "npm run clean:modules && npm install",
75
+ "clean:modules": "node -e \"const fs=require('fs');const p=require('path');['node_modules','package-lock.json'].forEach(f=>{if(fs.existsSync(f)){if(fs.lstatSync(f).isDirectory()){fs.rmSync(f,{recursive:true,force:true});}else{fs.unlinkSync(f);}}});\""
76
+ },
77
+ "devDependencies": {}
78
+ }
@@ -0,0 +1,13 @@
1
+ diff --git a/node_modules/minecraft-data/minecraft-data/data/pc/1.21.6/protocol.json b/node_modules/minecraft-data/minecraft-data/data/pc/1.21.6/protocol.json
2
+ index f80b696..fafa347 100644
3
+ --- a/node_modules/minecraft-data/minecraft-data/data/pc/1.21.6/protocol.json
4
+ +++ b/node_modules/minecraft-data/minecraft-data/data/pc/1.21.6/protocol.json
5
+ @@ -9033,7 +9033,7 @@
6
+ },
7
+ {
8
+ "name": "checksum",
9
+ - "type": "i8"
10
+ + "type": "u8"
11
+ }
12
+ ]
13
+ ],
@@ -0,0 +1,54 @@
1
+ diff --git a/node_modules/mineflayer/lib/plugins/digging.js b/node_modules/mineflayer/lib/plugins/digging.js
2
+ index 496cf63..813a667 100644
3
+ --- a/node_modules/mineflayer/lib/plugins/digging.js
4
+ +++ b/node_modules/mineflayer/lib/plugins/digging.js
5
+ @@ -242,11 +242,14 @@ function inject (bot) {
6
+ enchantments = enchantments.concat(helmetEnchantments)
7
+ }
8
+
9
+ + if (block.material === 'incorrect_for_wooden_tool')
10
+ + block.material = 'mineable/pickaxe'
11
+ +
12
+ const creative = bot.game.gameMode === 'creative'
13
+ return block.digTime(
14
+ type,
15
+ creative,
16
+ - bot.entity.isInWater,
17
+ + false, // isInWater, water calc is bugged, so always false
18
+ !bot.entity.onGround,
19
+ enchantments,
20
+ bot.entity.effects
21
+ diff --git a/node_modules/mineflayer/lib/plugins/inventory.js b/node_modules/mineflayer/lib/plugins/inventory.js
22
+ index 70db312..93d2054 100644
23
+ --- a/node_modules/mineflayer/lib/plugins/inventory.js
24
+ +++ b/node_modules/mineflayer/lib/plugins/inventory.js
25
+ @@ -125,10 +125,15 @@ function inject (bot, { hideErrors }) {
26
+ cursorZ: -1
27
+ })
28
+ } else if (bot.supportFeature('useItemWithOwnPacket')) {
29
+ + const yawDeg = -bot.entity.yaw * 180 / Math.PI + 180 // invert + shift
30
+ + const pitchDeg = -bot.entity.pitch * 180 / Math.PI // invert
31
+ bot._client.write('use_item', {
32
+ hand: offHand ? 1 : 0,
33
+ sequence,
34
+ - rotation: { x: 0, y: 0 }
35
+ + rotation: {
36
+ + x: yawDeg,
37
+ + y: pitchDeg
38
+ + }
39
+ })
40
+ }
41
+ }
42
+ diff --git a/node_modules/mineflayer/lib/plugins/place_block.js b/node_modules/mineflayer/lib/plugins/place_block.js
43
+ index fdaec6b..08983b6 100644
44
+ --- a/node_modules/mineflayer/lib/plugins/place_block.js
45
+ +++ b/node_modules/mineflayer/lib/plugins/place_block.js
46
+ @@ -11,7 +11,7 @@ function inject (bot) {
47
+ let newBlock = bot.blockAt(dest)
48
+ if (oldBlock.type === newBlock.type) {
49
+ [oldBlock, newBlock] = await onceWithCleanup(bot, `blockUpdate:${dest}`, {
50
+ - timeout: 5000,
51
+ + timeout: 500,
52
+ // Condition to wait to receive block update actually changing the block type, in case the bot receives block updates with no changes
53
+ // oldBlock and newBlock will both be null when the world unloads
54
+ checkCondition: (oldBlock, newBlock) => !oldBlock || !newBlock || oldBlock.type !== newBlock.type