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
@@ -0,0 +1,358 @@
1
+ import { getPosition } from "../library/world.js";
2
+
3
+ export class CookingTaskInitiator {
4
+ constructor(data, bot) {
5
+ this.bot = bot;
6
+ this.data = data;
7
+ }
8
+
9
+ async init() {
10
+ let bot = this.bot;
11
+
12
+ //// Setting up the cooking world using minecraft cheats ////
13
+
14
+ // Only run the setup if the agent is the first one
15
+
16
+ // Clear and prepare the base area
17
+ await bot.chat(`/fill ~ ~-1 ~ ~50 ~-3 ~50 grass_block`);
18
+ await bot.chat(`/fill ~ ~-1 ~ ~-50 ~-3 ~50 grass_block`);
19
+ await bot.chat(`/fill ~ ~-1 ~ ~-50 ~-3 ~-50 grass_block`);
20
+ await bot.chat(`/fill ~ ~-1 ~ ~50 ~-3 ~-50 grass_block`);
21
+ await bot.chat(`/fill ~ ~ ~ ~50 ~10 ~50 air`);
22
+ await bot.chat(`/fill ~ ~ ~ ~-50 ~10 ~50 air`);
23
+ await bot.chat(`/fill ~ ~ ~ ~-50 ~10 ~-50 air`);
24
+ await bot.chat(`/fill ~ ~ ~ ~50 ~10 ~-50 air`);
25
+ console.log("Base area cleared and prepared.");
26
+
27
+ const position = getPosition(bot);
28
+ const botX = Math.floor(position.x);
29
+ const botZ = Math.floor(position.z);
30
+
31
+ // Region management system
32
+ const isOverlapping = (newXMin, newXMax, newZMin, newZMax, occupiedRegions) => {
33
+ for (const region of occupiedRegions) {
34
+ if (newXMin < region.xMax && newXMax > region.xMin &&
35
+ newZMin < region.zMax && newZMax > region.zMin) {
36
+ return true;
37
+ }
38
+ }
39
+ return false;
40
+ };
41
+
42
+ const findValidPosition = (width, depth, occupiedRegions) => {
43
+ const maxXStart = position.x + 25 - width; // Constrain to 50x50 area
44
+ const minXStart = position.x - 25;
45
+ const maxZStart = position.z + 25 - depth;
46
+ const minZStart = position.z - 25;
47
+
48
+ let attempts = 0;
49
+ while (attempts < 10000) {
50
+ const xStart = Math.floor(minXStart + Math.random() * (maxXStart - minXStart + 1));
51
+ const zStart = Math.floor(minZStart + Math.random() * (maxZStart - minZStart + 1));
52
+ const xMin = xStart;
53
+ const xMax = xStart + width - 1;
54
+ const zMin = zStart;
55
+ const zMax = zStart + depth - 1;
56
+
57
+ if (!isOverlapping(xMin, xMax, zMin, zMax, occupiedRegions)) {
58
+ return { xStart, zStart };
59
+ }
60
+ attempts++;
61
+ }
62
+ throw new Error('Failed to find non-overlapping position after 1000 attempts');
63
+ };
64
+
65
+ // Define all regions with their sizes
66
+ const regionsToPlace = [
67
+ { type: 'wheat', width: 3, depth: 3 },
68
+ { type: 'beetroots', width: 3, depth: 3 },
69
+ { type: 'mushrooms', width: 3, depth: 3 },
70
+ { type: 'potatoes', width: 3, depth: 3 },
71
+ { type: 'carrots', width: 3, depth: 3 },
72
+ { type: 'sugar_cane', width: 3, depth: 3 },
73
+ { type: 'sugar_cane', width: 3, depth: 3 },
74
+ { type: 'pumpkins', width: 5, depth: 1 },
75
+ { type: 'house', width: 11, depth: 11 }
76
+ ];
77
+
78
+ // Expand the regions of each type to make sure they don't overlap
79
+
80
+ for (let i = 0; i < regionsToPlace.length; i++) {
81
+ const region = regionsToPlace[i];
82
+ const { width, depth } = region;
83
+ regionsToPlace[i].width = width + 4;
84
+ regionsToPlace[i].depth = depth + 4;
85
+ }
86
+
87
+ const occupiedRegions = [{
88
+ xMin : botX - 1,
89
+ xMax : botX + 1,
90
+ zMin : botZ - 1,
91
+ zMax : botZ + 1
92
+ }];
93
+ const regionPositions = {};
94
+
95
+ // Calculate positions for all regions
96
+ for (const region of regionsToPlace) {
97
+ const { xStart, zStart } = findValidPosition(region.width, region.depth, occupiedRegions);
98
+
99
+ occupiedRegions.push({
100
+ xMin: xStart,
101
+ xMax: xStart + region.width - 1,
102
+ zMin: zStart,
103
+ zMax: zStart + region.depth - 1
104
+ });
105
+
106
+ if (region.type === 'sugar_cane') {
107
+ if (!regionPositions.sugar_cane) regionPositions.sugar_cane = [];
108
+ regionPositions.sugar_cane.push({ xStart, zStart });
109
+ } else {
110
+ regionPositions[region.type] = { xStart, zStart };
111
+ }
112
+ }
113
+
114
+ // Execute all planting
115
+ // await plantWheat(regionPositions.wheat.xStart, regionPositions.wheat.zStart);
116
+ await this.plantCrops(regionPositions.wheat.xStart, regionPositions.wheat.zStart, 'wheat[age=7]', true);
117
+ await this.plantCrops(regionPositions.beetroots.xStart, regionPositions.beetroots.zStart, 'beetroots[age=3]', true);
118
+ await this.plantMushrooms(regionPositions.mushrooms.xStart, regionPositions.mushrooms.zStart);
119
+ await new Promise(resolve => setTimeout(resolve, 300));
120
+ await this.plantCrops(regionPositions.potatoes.xStart, regionPositions.potatoes.zStart, 'potatoes[age=7]', true);
121
+ await this.plantCrops(regionPositions.carrots.xStart, regionPositions.carrots.zStart, 'carrots[age=7]', true);
122
+ await this.plantCrops(regionPositions.pumpkins.xStart, regionPositions.pumpkins.zStart, 'pumpkin', false);
123
+ await this.plantSugarCane(regionPositions.sugar_cane);
124
+ await new Promise(resolve => setTimeout(resolve, 300));
125
+ console.log("planted crops!");
126
+ // await plantPumpkins(regionPositions.pumpkins.xStart, regionPositions.pumpkins.zStart);
127
+ // await new Promise(resolve => setTimeout(resolve, 300));
128
+
129
+
130
+ await this.buildHouse(regionPositions.house.xStart, regionPositions.house.zStart);
131
+
132
+ console.log("House built!");
133
+
134
+ // Add a chest with cooking items near the bot
135
+ // const addChestWithItems = async () => {
136
+ // // Find a valid position near the bot (within 10 blocks)
137
+ // const findChestPosition = () => {
138
+ // const maxAttempts = 100;
139
+ // for (let attempt = 0; attempt < maxAttempts; attempt++) {
140
+ // const x = botX + Math.floor(Math.random() * 10 - 5); // Within ±5 blocks X
141
+ // const z = botZ + Math.floor(Math.random() * 10 - 5); // Within ±5 blocks Z
142
+ // const y = position.y;
143
+
144
+ // // Check if the position is not overlapping with existing structures
145
+ // if (!isOverlapping(x, x, z, z, occupiedRegions)) {
146
+ // return { x, y, z };
147
+ // }
148
+ // }
149
+ // throw new Error('Failed to find valid chest position');
150
+ // };
151
+
152
+ // const { x, y, z } = findChestPosition();
153
+
154
+ // // Place the chest
155
+ // await bot.chat(`/setblock ${x} ${y} ${z} chest`);
156
+
157
+ const cookingItems = [
158
+ ['minecraft:milk_bucket', 1], // Non-stackable
159
+ ['minecraft:egg', 16], // Stacks to 16
160
+ ['minecraft:dandelion', 64], // Stacks to 64
161
+ ['minecraft:sugar', 64],
162
+ ['minecraft:cocoa_beans', 64],
163
+ ['minecraft:apple', 64],
164
+ ['minecraft:milk_bucket', 1],
165
+ ['minecraft:milk_bucket', 1],
166
+ ['minecraft:salmon', 64],
167
+ ['minecraft:cod', 64],
168
+ ['minecraft:kelp', 64],
169
+ ['minecraft:dried_kelp', 64],
170
+ ['minecraft:sweet_berries', 64],
171
+ ['minecraft:honey_bottle', 1], // Non-stackable
172
+ ['minecraft:glow_berries', 64],
173
+ ['minecraft:bowl', 64],
174
+ ['minecraft:milk_bucket', 1],
175
+ ['minecraft:milk_bucket', 1],
176
+ ['minecraft:milk_bucket', 1],
177
+ ['minecraft:milk_bucket', 1],
178
+ ['minecraft:cooked_salmon', 64],
179
+ ['minecraft:cooked_cod', 64],
180
+ ['minecraft:gold_ingot', 64],
181
+ ['minecraft:oak_planks', 64],
182
+ ['minecraft:iron_ingot', 64],
183
+ ['minecraft:milk_bucket', 1],
184
+ ['minecraft:milk_bucket', 1],
185
+ ];
186
+
187
+ // // Fill the chest with random cooking items
188
+ // for (let slot = 0; slot < cookingItems.length; slot++) { // Chest has 27 slots
189
+ // const randomItem = cookingItems[slot];
190
+ // await bot.chat(`/item replace block ${x} ${y} ${z} container.${slot} with ${randomItem[0]} ${randomItem[1]}`);
191
+ // }
192
+
193
+ // // Mark the chest area as occupied
194
+ // occupiedRegions.push({
195
+ // xMin: x,
196
+ // xMax: x,
197
+ // zMin: z,
198
+ // zMax: z
199
+ // });
200
+ // };
201
+
202
+ // await addChestWithItems();
203
+ await new Promise(resolve => setTimeout(resolve, 300));
204
+
205
+ const animals = ['chicken', 'cow', 'llama', 'mooshroom', 'pig', 'rabbit', 'sheep'];
206
+
207
+ // Animal management
208
+ await this.killEntities(["item"]);
209
+ await this.killEntities(animals);
210
+ await this.killEntities(["item"]);
211
+
212
+ console.log("killed entities!");
213
+
214
+ await new Promise(resolve => setTimeout(resolve, 300));
215
+
216
+ // Summon new animals
217
+
218
+ await this.summonAnimals(animals, 8);
219
+ console.log("summoned animals!");
220
+ }
221
+
222
+ async plantCrops (xStart, zStart, crop_and_age, till=true) {
223
+ const position = getPosition(this.bot);
224
+ for (let i = 0; i < 6; i++) {
225
+ for (let j = 0; j < 6; j++) {
226
+ const x = xStart + i;
227
+ const z = zStart + j;
228
+ if (till) {
229
+ await this.bot.chat(`/setblock ${x} ${position.y - 1} ${z} farmland`);
230
+ }
231
+ await this.bot.chat(`/setblock ${x} ${position.y} ${z} ${crop_and_age}`);
232
+ }
233
+ }
234
+ await new Promise(resolve => setTimeout(resolve, 300));
235
+ }
236
+
237
+ async plantSugarCane (patches) {
238
+ const position = getPosition(this.bot);
239
+ for (const patch of patches) {
240
+ const xCenter = patch.xStart + 1;
241
+ const zCenter = patch.zStart + 1;
242
+ await this.bot.chat(`/setblock ${xCenter} ${position.y - 1} ${zCenter} water`);
243
+ const offsets = [[1, 0], [-1, 0], [0, 1], [0, -1]];
244
+ for (const [dx, dz] of offsets) {
245
+ await this.bot.chat(`/setblock ${xCenter + dx} ${position.y} ${zCenter + dz} sugar_cane[age=15]`);
246
+ }
247
+ }
248
+ };
249
+
250
+ async plantMushrooms(xStart, zStart) {
251
+ const position = getPosition(this.bot);
252
+ for (let i = 0; i < 4; i++) {
253
+ for (let j = 0; j < 5; j++) {
254
+ const x = xStart + i;
255
+ const z = zStart + j;
256
+ await this.bot.chat(`/setblock ${x} ${position.y - 1} ${z} mycelium`);
257
+ const mushroomType = (i + j) % 2 === 0 ? 'red_mushroom' : 'brown_mushroom';
258
+ await this.bot.chat(`/setblock ${x} ${position.y} ${z} ${mushroomType}`);
259
+ }
260
+ }
261
+ }
262
+
263
+ async summonAnimals (animals, amount) {
264
+ const position = getPosition(this.bot);
265
+ for (const animal of animals) {
266
+ for (let i = 0; i < amount; i++) {
267
+ const x = position.x - 25 + Math.random() * 50;
268
+ const z = position.z - 25 + Math.random() * 50;
269
+ await this.bot.chat(`/summon ${animal} ${Math.floor(x)} ${position.y} ${Math.floor(z)}`);
270
+ }
271
+ }
272
+ }
273
+
274
+ async killEntities(entities) {
275
+ for (const entity of entities) {
276
+ await this.bot.chat(`/kill @e[type=${entity},distance=..200]`);
277
+ }
278
+ }
279
+
280
+ async buildHouse (xStart, zStart) {
281
+ const position = getPosition(this.bot);
282
+ const startX = xStart;
283
+ const startY = position.y;
284
+ const startZ = zStart;
285
+ const width = 10;
286
+ const depth = 10;
287
+ const height = 5;
288
+
289
+ // Foundation and walls
290
+ for (let x = startX; x <= startX + depth; x++) {
291
+ for (let y = startY; y <= startY + height; y++) {
292
+ for (let z = startZ; z <= startZ + width; z++) {
293
+ if (y === startY) {
294
+ if (!(x === startX + depth - 1 && z === startZ + Math.floor(width / 2))) {
295
+ await this.bot.chat(`/setblock ${x} ${y} ${z} stone_bricks`);
296
+ }
297
+ continue;
298
+ }
299
+
300
+ if (x === startX || x === startX + depth ||
301
+ z === startZ || z === startZ + width ||
302
+ y === startY + height) {
303
+
304
+ const isWindow = (
305
+ (x === startX || x === startX + depth) &&
306
+ (z === startZ + 3 || z === startZ + width - 3) &&
307
+ (y === startY + 2 || y === startY + 3)
308
+ ) || (
309
+ (z === startZ || z === startZ + width) &&
310
+ (x === startX + 3 || x === startX + depth - 3) &&
311
+ (y === startY + 2 || y === startY + 3)
312
+ );
313
+
314
+ const isDoor = x === startX + depth &&
315
+ z === startZ + Math.floor(width / 2) &&
316
+ (y === startY + 1 || y === startY + 2);
317
+
318
+ if (!isWindow && !isDoor) {
319
+ await this.bot.chat(`/setblock ${x} ${y} ${z} stone_bricks`);
320
+ }
321
+ }
322
+ }
323
+ }
324
+ }
325
+
326
+ // Entrance features
327
+ const doorZ = startZ + Math.floor(width / 2);
328
+ await this.bot.chat(`/setblock ${startX + depth - 1} ${startY} ${doorZ} stone_brick_stairs[facing=west]`);
329
+ await this.bot.chat(`/setblock ${startX + depth} ${startY} ${doorZ} air`);
330
+ // await bot.chat(`/setblock ${startX + depth - 1} ${startY} ${doorZ - 1} stone_bricks`);
331
+ // await bot.chat(`/setblock ${startX + depth - 1} ${startY} ${doorZ + 1} stone_bricks`);
332
+ // await bot.chat(`/setblock ${startX + depth} ${startY} ${doorZ} oak_door[half=lower,hinge=left,facing=west,powered=false]`);
333
+ // await bot.chat(`/setblock ${startX + depth} ${startY + 1} ${doorZ} oak_door[half=upper,hinge=left,facing=west,powered=false]`);
334
+
335
+ // Roof construction
336
+ for (let i = 0; i < 3; i++) {
337
+ for (let x = startX + i; x <= startX + depth - i; x++) {
338
+ for (let z = startZ + i; z <= startZ + width - i; z++) {
339
+ if (x === startX + i || x === startX + depth - i ||
340
+ z === startZ + i || z === startZ + width - i) {
341
+ await this.bot.chat(`/setblock ${x} ${startY + height + i} ${z} cobblestone`);
342
+ }
343
+ }
344
+ }
345
+ }
346
+
347
+ // Interior items
348
+ await this.bot.chat(`/setblock ${startX + 4} ${startY + 1} ${startZ + 3} crafting_table`);
349
+ await this.bot.chat(`/setblock ${startX + 4} ${startY + 1} ${startZ + 5} furnace`);
350
+ // Add fuel to the furnace
351
+ await this.bot.chat(`/data merge block ${startX + 4} ${startY + 1} ${startZ + 5} {Items:[{Slot:1b,id:"minecraft:coal",Count:64b}]}`)
352
+ await this.bot.chat(`/setblock ${startX + 4} ${startY + 1} ${startZ + 7} smoker`);
353
+ // Add fuel to the smoker
354
+ await this.bot.chat(`/data merge block ${startX + 4} ${startY + 1} ${startZ + 7} {Items:[{Slot:1b,id:"minecraft:coal",Count:64b}]}`)
355
+ await this.bot.chat(`/setblock ${startX + depth - 3} ${startY + 1} ${startZ + 2} bed`);
356
+ await new Promise(resolve => setTimeout(resolve, 300));
357
+ }
358
+ }