Spaces:
Configuration error
Configuration error
Download main.js from PROGAMER91234/Mindcraft: direct link, hf CLI and curl.
- Browser
- Download file 2.16 kB
-
https://huggingface.co/spaces/PROGAMER91234/Mindcraft/resolve/main/main.js
- Command line
-
hf download hf://spaces/PROGAMER91234/Mindcraft/main.js
-
curl -L -o main.js https://huggingface.co/spaces/PROGAMER91234/Mindcraft/resolve/main/main.js
2.16 kB
| import * as Mindcraft from './src/mindcraft/mindcraft.js'; | |
| import settings from './settings.js'; | |
| import yargs from 'yargs'; | |
| import { hideBin } from 'yargs/helpers'; | |
| import { readFileSync } from 'fs'; | |
| function parseArguments() { | |
| return yargs(hideBin(process.argv)) | |
| .option('profiles', { | |
| type: 'array', | |
| describe: 'List of agent profile paths', | |
| }) | |
| .option('task_path', { | |
| type: 'string', | |
| describe: 'Path to task file to execute' | |
| }) | |
| .option('task_id', { | |
| type: 'string', | |
| describe: 'Task ID to execute' | |
| }) | |
| .help() | |
| .alias('help', 'h') | |
| .parse(); | |
| } | |
| const args = parseArguments(); | |
| if (args.profiles) { | |
| settings.profiles = args.profiles; | |
| } | |
| if (args.task_path) { | |
| let tasks = JSON.parse(readFileSync(args.task_path, 'utf8')); | |
| if (args.task_id) { | |
| settings.task = tasks[args.task_id]; | |
| settings.task.task_id = args.task_id; | |
| } | |
| else { | |
| throw new Error('task_id is required when task_path is provided'); | |
| } | |
| } | |
| // these environment variables override certain settings | |
| if (process.env.MINECRAFT_PORT) { | |
| settings.port = process.env.MINECRAFT_PORT; | |
| } | |
| if (process.env.MINDSERVER_PORT) { | |
| settings.mindserver_port = process.env.MINDSERVER_PORT; | |
| } | |
| if (process.env.PROFILES && JSON.parse(process.env.PROFILES).length > 0) { | |
| settings.profiles = JSON.parse(process.env.PROFILES); | |
| } | |
| if (process.env.INSECURE_CODING) { | |
| settings.allow_insecure_coding = true; | |
| } | |
| if (process.env.BLOCKED_ACTIONS) { | |
| settings.blocked_actions = JSON.parse(process.env.BLOCKED_ACTIONS); | |
| } | |
| if (process.env.MAX_MESSAGES) { | |
| settings.max_messages = process.env.MAX_MESSAGES; | |
| } | |
| if (process.env.NUM_EXAMPLES) { | |
| settings.num_examples = process.env.NUM_EXAMPLES; | |
| } | |
| if (process.env.LOG_ALL) { | |
| settings.log_all_prompts = process.env.LOG_ALL; | |
| } | |
| Mindcraft.init(true, settings.mindserver_port, settings.auto_open_ui); | |
| for (let profile of settings.profiles) { | |
| const profile_json = JSON.parse(readFileSync(profile, 'utf8')); | |
| settings.profile = profile_json; | |
| Mindcraft.createAgent(settings); | |
| } |