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,150 @@
1
+ import { exec, spawn } from 'child_process';
2
+ import { promises as fs } from 'fs';
3
+ import os from 'os';
4
+ import path from 'path';
5
+ import { TTSConfig as gptTTSConfig } from '../models/gpt.js';
6
+ import { TTSConfig as geminiTTSConfig } from '../models/gemini.js';
7
+
8
+ let speakingQueue = []; // each item: {text, model, audioData, ready}
9
+ let isSpeaking = false;
10
+
11
+ export function speak(text, speak_model) {
12
+ const model = speak_model || 'system';
13
+
14
+ const item = { text, model, audioData: null, ready: null };
15
+
16
+ if (model === 'system') {
17
+ // no preprocessing needed
18
+ item.ready = Promise.resolve();
19
+ } else {
20
+ item.ready = fetchRemoteAudio(text, model)
21
+ .then(data => { item.audioData = data; })
22
+ .catch(err => { item.error = err; });
23
+ }
24
+
25
+ speakingQueue.push(item);
26
+ if (!isSpeaking) processQueue();
27
+ }
28
+
29
+ async function fetchRemoteAudio(txt, model) {
30
+ function getModelUrl(prov) {
31
+ if (prov === 'openai') return gptTTSConfig.baseUrl;
32
+ if (prov === 'google') return geminiTTSConfig.baseUrl;
33
+ return 'https://api.openai.com/v1';
34
+ }
35
+
36
+ let prov, mdl, voice, url;
37
+ if (typeof model === 'string') {
38
+ [prov, mdl, voice] = model.split('/');
39
+ url = getModelUrl(prov);
40
+ } else {
41
+ prov = model.api;
42
+ mdl = model.model;
43
+ voice = model.voice;
44
+ url = model.url || getModelUrl(prov);
45
+ }
46
+
47
+ if (prov === 'openai') {
48
+ return gptTTSConfig.sendAudioRequest(txt, mdl, voice, url);
49
+ } else if (prov === 'google') {
50
+ return geminiTTSConfig.sendAudioRequest(txt, mdl, voice, url);
51
+ }
52
+ else {
53
+ throw new Error(`TTS Provider ${prov} is not supported.`);
54
+ }
55
+ }
56
+
57
+ async function processQueue() {
58
+ isSpeaking = true;
59
+ if (speakingQueue.length === 0) {
60
+ isSpeaking = false;
61
+ return;
62
+ }
63
+ const item = speakingQueue.shift();
64
+ const { text: txt, model, audioData } = item;
65
+ if (txt.trim() === '') {
66
+ isSpeaking = false;
67
+ processQueue();
68
+ return;
69
+ }
70
+
71
+ const isWin = process.platform === 'win32';
72
+ const isMac = process.platform === 'darwin';
73
+
74
+ // wait for preprocessing if needed
75
+ try {
76
+ await item.ready;
77
+ if (item.error) throw item.error;
78
+ } catch (err) {
79
+ console.error('[TTS] preprocess error', err);
80
+ isSpeaking = false;
81
+ processQueue();
82
+ return;
83
+ }
84
+
85
+ if (model === 'system') {
86
+ // system TTS
87
+ const cmd = isWin
88
+ ? `powershell -NoProfile -Command "Add-Type -AssemblyName System.Speech; \
89
+ $s=New-Object System.Speech.Synthesis.SpeechSynthesizer; $s.Rate=2; \
90
+ $s.Speak('${txt.replace(/'/g,"''")}'); $s.Dispose()"`
91
+ : isMac
92
+ ? `say "${txt.replace(/"/g,'\\"')}"`
93
+ : `espeak "${txt.replace(/"/g,'\\"')}"`;
94
+
95
+ exec(cmd, err => {
96
+ if (err) console.error('TTS error', err);
97
+ isSpeaking = false;
98
+ processQueue();
99
+ });
100
+
101
+ }
102
+ else {
103
+ // audioData was already fetched in speak()
104
+ const audioData = item.audioData;
105
+
106
+ if (!audioData) {
107
+ console.error('[TTS] No audio data ready');
108
+ isSpeaking = false;
109
+ processQueue();
110
+ return;
111
+ }
112
+
113
+ try {
114
+ if (isWin) {
115
+ const tmpPath = path.join(os.tmpdir(), `tts_${Date.now()}.mp3`);
116
+ await fs.writeFile(tmpPath, Buffer.from(audioData, 'base64'));
117
+
118
+ const player = spawn('ffplay', ['-nodisp', '-autoexit', '-loglevel', 'quiet', tmpPath], {
119
+ stdio: 'ignore', windowsHide: true
120
+ });
121
+ player.on('error', async (err) => {
122
+ console.error('[TTS] ffplay error', err);
123
+ try { await fs.unlink(tmpPath); } catch {}
124
+ isSpeaking = false;
125
+ processQueue();
126
+ });
127
+ player.on('exit', async () => {
128
+ try { await fs.unlink(tmpPath); } catch {}
129
+ isSpeaking = false;
130
+ processQueue();
131
+ });
132
+
133
+ } else {
134
+ const player = spawn('ffplay', ['-nodisp','-autoexit','pipe:0'], {
135
+ stdio: ['pipe','ignore','ignore']
136
+ });
137
+ player.stdin.write(Buffer.from(audioData, 'base64'));
138
+ player.stdin.end();
139
+ player.on('exit', () => {
140
+ isSpeaking = false;
141
+ processQueue();
142
+ });
143
+ }
144
+ } catch (e) {
145
+ console.error('[TTS] Audio error', e);
146
+ isSpeaking = false;
147
+ processQueue();
148
+ }
149
+ }
150
+ }