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/settings.js ADDED
@@ -0,0 +1,64 @@
1
+ const settings = {
2
+ "minecraft_version": "auto", // or specific version like "1.21.6"
3
+ "host": "127.0.0.1", // or "localhost", "your.ip.address.here"
4
+ "port": 55916, // set to -1 to automatically scan for open ports
5
+ "auth": "offline", // or "microsoft"
6
+ "data_dir": "./bots", // where bot memories, histories, screenshots, and generated code are written
7
+
8
+ // the mindserver manages all agents and hosts the UI
9
+ "mindserver_port": 8080,
10
+ "auto_open_ui": true, // opens UI in browser on startup
11
+
12
+ "base_profile": "assistant", // survival, assistant, creative, or god_mode
13
+ "profiles": [
14
+ "./andy.json",
15
+ // "./profiles/gpt.json",
16
+ // "./profiles/claude.json",
17
+ // "./profiles/gemini.json",
18
+ // "./profiles/llama.json",
19
+ // "./profiles/qwen.json",
20
+ // "./profiles/grok.json",
21
+ // "./profiles/mistral.json",
22
+ // "./profiles/deepseek.json",
23
+ // "./profiles/mercury.json",
24
+ // "./profiles/andy-4.json", // Supports up to 75 messages!
25
+
26
+ // using more than 1 profile requires you to /msg each bot indivually
27
+ // individual profiles override values from the base profile
28
+ ],
29
+
30
+ "load_memory": false, // load memory from previous session
31
+ "init_message": "Respond with hello world and your name", // sends to all on spawn
32
+ "only_chat_with": [], // users that the bots listen to and send general messages to. if empty it will chat publicly
33
+
34
+ "speak": false,
35
+ // allows all bots to speak through text-to-speech.
36
+ // specify speech model inside each profile with format: {provider}/{model}/{voice}.
37
+ // if set to "system" it will use basic system text-to-speech.
38
+ // Works on windows and mac, but linux requires you to install the espeak package through your package manager eg: `apt install espeak` `pacman -S espeak`.
39
+
40
+ "chat_ingame": true, // bot responses are shown in minecraft chat
41
+ "language": "en", // translate to/from this language. Supports these language names: https://cloud.google.com/translate/docs/languages
42
+ "render_bot_view": false, // show bot's view in browser at localhost:3000, 3001...
43
+
44
+ "allow_insecure_coding": false, // allows newAction command and model can write/run code on your computer. enable at own risk
45
+ "allow_vision": false, // allows vision model to interpret screenshots as inputs
46
+ "blocked_actions" : ["!checkBlueprint", "!checkBlueprintLevel", "!getBlueprint", "!getBlueprintLevel"] , // commands to disable and remove from docs. Ex: ["!setMode"]
47
+ "code_timeout_mins": -1, // minutes code is allowed to run. -1 for no timeout
48
+ "relevant_docs_count": 5, // number of relevant code function docs to select for prompting. -1 for all
49
+
50
+ "max_messages": 15, // max number of messages to keep in context
51
+ "num_examples": 2, // number of examples to give to the model
52
+ "max_commands": -1, // max number of commands that can be used in consecutive responses. -1 for no limit
53
+ "show_command_syntax": "full", // "full", "shortened", or "none"
54
+ "narrate_behavior": true, // chat simple automatic actions ('Picking up item!')
55
+ "chat_bot_messages": true, // publicly chat messages to other bots
56
+
57
+ "spawn_timeout": 30, // num seconds allowed for the bot to spawn before throwing error. Increase when spawning takes a while.
58
+ "block_place_delay": 0, // delay between placing blocks (ms) if using newAction. helps avoid bot being kicked by anti-cheat mechanisms on servers.
59
+
60
+ "log_all_prompts": false, // log ALL prompts to file
61
+
62
+ }
63
+
64
+ export default settings;
@@ -0,0 +1,177 @@
1
+ export class ActionManager {
2
+ constructor(agent) {
3
+ this.agent = agent;
4
+ this.executing = false;
5
+ this.currentActionLabel = '';
6
+ this.currentActionFn = null;
7
+ this.timedout = false;
8
+ this.resume_func = null;
9
+ this.resume_name = '';
10
+ this.last_action_time = 0;
11
+ this.recent_action_counter = 0;
12
+ }
13
+
14
+ async resumeAction(actionFn, timeout) {
15
+ return this._executeResume(actionFn, timeout);
16
+ }
17
+
18
+ async runAction(actionLabel, actionFn, { timeout, resume = false } = {}) {
19
+ if (resume) {
20
+ return this._executeResume(actionLabel, actionFn, timeout);
21
+ } else {
22
+ return this._executeAction(actionLabel, actionFn, timeout);
23
+ }
24
+ }
25
+
26
+ async stop() {
27
+ if (!this.executing) return;
28
+ const timeout = setTimeout(() => {
29
+ this.agent.cleanKill('Code execution refused stop after 10 seconds. Killing process.');
30
+ }, 10000);
31
+ while (this.executing) {
32
+ this.agent.requestInterrupt();
33
+ console.log('waiting for code to finish executing...');
34
+ await new Promise(resolve => setTimeout(resolve, 300));
35
+ }
36
+ clearTimeout(timeout);
37
+ }
38
+
39
+ cancelResume() {
40
+ this.resume_func = null;
41
+ this.resume_name = null;
42
+ }
43
+
44
+ async _executeResume(actionLabel = null, actionFn = null, timeout = 10) {
45
+ const new_resume = actionFn != null;
46
+ if (new_resume) { // start new resume
47
+ this.resume_func = actionFn;
48
+ assert(actionLabel != null, 'actionLabel is required for new resume');
49
+ this.resume_name = actionLabel;
50
+ }
51
+ if (this.resume_func != null && (this.agent.isIdle() || new_resume) && (!this.agent.self_prompter.isActive() || new_resume)) {
52
+ this.currentActionLabel = this.resume_name;
53
+ let res = await this._executeAction(this.resume_name, this.resume_func, timeout);
54
+ this.currentActionLabel = '';
55
+ return res;
56
+ } else {
57
+ return { success: false, message: null, interrupted: false, timedout: false };
58
+ }
59
+ }
60
+
61
+ async _executeAction(actionLabel, actionFn, timeout = 10) {
62
+ let TIMEOUT;
63
+ try {
64
+ if (this.last_action_time > 0) {
65
+ let time_diff = Date.now() - this.last_action_time;
66
+ if (time_diff < 20) {
67
+ this.recent_action_counter++;
68
+ }
69
+ else {
70
+ this.recent_action_counter = 0;
71
+ }
72
+ if (this.recent_action_counter > 3) {
73
+ console.warn('Fast action loop detected, cancelling resume.');
74
+ this.cancelResume(); // likely cause of repetition
75
+ }
76
+ if (this.recent_action_counter > 5) {
77
+ console.error('Infinite action loop detected, shutting down.');
78
+ this.agent.cleanKill('Infinite action loop detected, shutting down.');
79
+ return { success: false, message: 'Infinite action loop detected, shutting down.', interrupted: false, timedout: false };
80
+ }
81
+ }
82
+ this.last_action_time = Date.now();
83
+ console.log('executing code...\n');
84
+
85
+ // await current action to finish (executing=false), with 10 seconds timeout
86
+ // also tell agent.bot to stop various actions
87
+ if (this.executing) {
88
+ console.log(`action "${actionLabel}" trying to interrupt current action "${this.currentActionLabel}"`);
89
+ }
90
+ await this.stop();
91
+
92
+ // clear bot logs and reset interrupt code
93
+ this.agent.clearBotLogs();
94
+
95
+ this.executing = true;
96
+ this.currentActionLabel = actionLabel;
97
+ this.currentActionFn = actionFn;
98
+
99
+ // timeout in minutes
100
+ if (timeout > 0) {
101
+ TIMEOUT = this._startTimeout(timeout);
102
+ }
103
+
104
+ // start the action
105
+ await actionFn();
106
+
107
+ // mark action as finished + cleanup
108
+ this.executing = false;
109
+ this.currentActionLabel = '';
110
+ this.currentActionFn = null;
111
+ clearTimeout(TIMEOUT);
112
+
113
+ // get bot activity summary
114
+ let output = this.getBotOutputSummary();
115
+ let interrupted = this.agent.bot.interrupt_code;
116
+ let timedout = this.timedout;
117
+ this.agent.clearBotLogs();
118
+
119
+ // if not interrupted and not generating, emit idle event
120
+ if (!interrupted) {
121
+ this.agent.bot.emit('idle');
122
+ }
123
+
124
+ // return action status report
125
+ return { success: true, message: output, interrupted, timedout };
126
+ } catch (err) {
127
+ this.executing = false;
128
+ this.currentActionLabel = '';
129
+ this.currentActionFn = null;
130
+ clearTimeout(TIMEOUT);
131
+ this.cancelResume();
132
+ console.error("Code execution triggered catch:", err);
133
+ // Log the full stack trace
134
+ console.error(err.stack);
135
+ await this.stop();
136
+ err = err.toString();
137
+
138
+ let message = this.getBotOutputSummary() +
139
+ '!!Code threw exception!!\n' +
140
+ 'Error: ' + err + '\n' +
141
+ 'Stack trace:\n' + err.stack+'\n';
142
+
143
+ let interrupted = this.agent.bot.interrupt_code;
144
+ this.agent.clearBotLogs();
145
+ if (!interrupted) {
146
+ this.agent.bot.emit('idle');
147
+ }
148
+ return { success: false, message, interrupted, timedout: false };
149
+ }
150
+ }
151
+
152
+ getBotOutputSummary() {
153
+ const { bot } = this.agent;
154
+ if (bot.interrupt_code && !this.timedout) return '';
155
+ let output = bot.output;
156
+ const MAX_OUT = 500;
157
+ if (output.length > MAX_OUT) {
158
+ output = `Action output is very long (${output.length} chars) and has been shortened.\n
159
+ First outputs:\n${output.substring(0, MAX_OUT / 2)}\n...skipping many lines.\nFinal outputs:\n ${output.substring(output.length - MAX_OUT / 2)}`;
160
+ }
161
+ else {
162
+ output = 'Action output:\n' + output.toString();
163
+ }
164
+ bot.output = '';
165
+ return output;
166
+ }
167
+
168
+ _startTimeout(TIMEOUT_MINS = 10) {
169
+ return setTimeout(async () => {
170
+ console.warn(`Code execution timed out after ${TIMEOUT_MINS} minutes. Attempting force stop.`);
171
+ this.timedout = true;
172
+ this.agent.history.add('system', `Code execution timed out after ${TIMEOUT_MINS} minutes. Attempting force stop.`);
173
+ await this.stop(); // last attempt to stop
174
+ }, TIMEOUT_MINS * 60 * 1000);
175
+ }
176
+
177
+ }