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.
- package/FAQ.md +38 -0
- package/LICENSE +21 -0
- package/README.md +255 -0
- package/andy.json +6 -0
- package/bin/mindcraft.js +80 -0
- package/keys.example.json +19 -0
- package/main.js +80 -0
- package/package.json +78 -0
- package/patches/minecraft-data+3.97.0.patch +13 -0
- package/patches/mineflayer+4.33.0.patch +54 -0
- package/patches/mineflayer-pathfinder+2.4.5.patch +265 -0
- package/patches/mineflayer-pvp+1.3.2.patch +13 -0
- package/patches/prismarine-viewer+1.33.0.patch +13 -0
- package/patches/protodef+1.19.0.patch +15 -0
- package/profiles/andy-4-reasoning.json +14 -0
- package/profiles/andy-4.json +7 -0
- package/profiles/azure.json +19 -0
- package/profiles/claude.json +7 -0
- package/profiles/claude_thinker.json +15 -0
- package/profiles/deepseek.json +7 -0
- package/profiles/defaults/_default.json +256 -0
- package/profiles/defaults/assistant.json +14 -0
- package/profiles/defaults/creative.json +14 -0
- package/profiles/defaults/god_mode.json +14 -0
- package/profiles/defaults/survival.json +14 -0
- package/profiles/freeguy.json +7 -0
- package/profiles/gemini.json +9 -0
- package/profiles/gpt.json +12 -0
- package/profiles/grok.json +7 -0
- package/profiles/llama.json +10 -0
- package/profiles/mercury.json +9 -0
- package/profiles/mistral.json +5 -0
- package/profiles/qwen.json +17 -0
- package/profiles/tasks/construction_profile.json +42 -0
- package/profiles/tasks/cooking_profile.json +11 -0
- package/profiles/tasks/crafting_profile.json +71 -0
- package/profiles/vllm.json +10 -0
- package/settings.js +64 -0
- package/src/agent/action_manager.js +177 -0
- package/src/agent/agent.js +561 -0
- package/src/agent/coder.js +229 -0
- package/src/agent/commands/actions.js +504 -0
- package/src/agent/commands/index.js +259 -0
- package/src/agent/commands/queries.js +347 -0
- package/src/agent/connection_handler.js +96 -0
- package/src/agent/conversation.js +353 -0
- package/src/agent/history.js +122 -0
- package/src/agent/library/full_state.js +89 -0
- package/src/agent/library/index.js +23 -0
- package/src/agent/library/lockdown.js +32 -0
- package/src/agent/library/skill_library.js +93 -0
- package/src/agent/library/skills.js +2093 -0
- package/src/agent/library/world.js +431 -0
- package/src/agent/memory_bank.js +25 -0
- package/src/agent/mindserver_proxy.js +136 -0
- package/src/agent/modes.js +446 -0
- package/src/agent/npc/build_goal.js +80 -0
- package/src/agent/npc/construction/dirt_shelter.json +38 -0
- package/src/agent/npc/construction/large_house.json +230 -0
- package/src/agent/npc/construction/small_stone_house.json +42 -0
- package/src/agent/npc/construction/small_wood_house.json +42 -0
- package/src/agent/npc/controller.js +261 -0
- package/src/agent/npc/data.js +50 -0
- package/src/agent/npc/item_goal.js +355 -0
- package/src/agent/npc/utils.js +126 -0
- package/src/agent/self_prompter.js +146 -0
- package/src/agent/settings.js +7 -0
- package/src/agent/speak.js +150 -0
- package/src/agent/tasks/construction_tasks.js +1104 -0
- package/src/agent/tasks/cooking_tasks.js +358 -0
- package/src/agent/tasks/tasks.js +594 -0
- package/src/agent/templates/execTemplate.js +6 -0
- package/src/agent/templates/lintTemplate.js +10 -0
- package/src/agent/vision/browser_viewer.js +8 -0
- package/src/agent/vision/camera.js +78 -0
- package/src/agent/vision/vision_interpreter.js +82 -0
- package/src/mindcraft/index.js +28 -0
- package/src/mindcraft/mcserver.js +154 -0
- package/src/mindcraft/mindcraft.js +111 -0
- package/src/mindcraft/mindserver.js +328 -0
- package/src/mindcraft/public/index.html +1253 -0
- package/src/mindcraft/public/settings_spec.json +145 -0
- package/src/mindcraft/userconfig.js +72 -0
- package/src/mindcraft-py/example.py +27 -0
- package/src/mindcraft-py/init-mindcraft.js +24 -0
- package/src/mindcraft-py/mindcraft.py +99 -0
- package/src/models/_model_map.js +89 -0
- package/src/models/azure.js +32 -0
- package/src/models/cerebras.js +61 -0
- package/src/models/claude.js +87 -0
- package/src/models/deepseek.js +59 -0
- package/src/models/gemini.js +176 -0
- package/src/models/glhf.js +71 -0
- package/src/models/gpt.js +147 -0
- package/src/models/grok.js +82 -0
- package/src/models/groq.js +95 -0
- package/src/models/huggingface.js +86 -0
- package/src/models/hyperbolic.js +114 -0
- package/src/models/lmstudio.js +74 -0
- package/src/models/mercury.js +95 -0
- package/src/models/mistral.js +94 -0
- package/src/models/novita.js +71 -0
- package/src/models/ollama.js +115 -0
- package/src/models/openrouter.js +77 -0
- package/src/models/prompter.js +366 -0
- package/src/models/qwen.js +80 -0
- package/src/models/replicate.js +60 -0
- package/src/models/vllm.js +81 -0
- package/src/process/agent_process.js +84 -0
- package/src/process/init_agent.js +54 -0
- package/src/utils/examples.js +83 -0
- package/src/utils/keys.js +34 -0
- package/src/utils/math.js +13 -0
- package/src/utils/mcdata.js +572 -0
- package/src/utils/text.js +78 -0
- 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
|
+
}
|