diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..1d5880c --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Kolby Nottingham + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/agent/agent.js b/src/agent/agent.js index a27bbee..3d3a0fb 100644 --- a/src/agent/agent.js +++ b/src/agent/agent.js @@ -14,7 +14,7 @@ import { handleTranslation, handleEnglishTranslation } from '../utils/translator import { addBrowserViewer } from './vision/browser_viewer.js'; import settings from '../../settings.js'; import { serverProxy } from './agent_proxy.js'; -import { Task } from './tasks.js'; +import { Task } from './tasks/tasks.js'; import { say } from './speak.js'; export class Agent { @@ -62,7 +62,6 @@ export class Agent { } else { taskStart = Date.now(); } - // incorporate new restart time into task this.task = new Task(this, task_path, task_id, taskStart); this.blocked_actions = settings.blocked_actions.concat(this.task.blocked_actions || []); blacklistCommands(this.blocked_actions); diff --git a/src/agent/commands/queries.js b/src/agent/commands/queries.js index 531232b..ef77ade 100644 --- a/src/agent/commands/queries.js +++ b/src/agent/commands/queries.js @@ -2,7 +2,7 @@ import * as world from '../library/world.js'; import * as mc from '../../utils/mcdata.js'; import { getCommandDocs } from './index.js'; import convoManager from '../conversation.js'; -import { checkLevelBlueprint, checkBlueprint } from '../task_types/construction_tasks.js'; +import { checkLevelBlueprint, checkBlueprint } from '../tasks/construction_tasks.js'; import { load } from 'cheerio'; const pad = (str) => { diff --git a/src/agent/task_types/construction_tasks.js b/src/agent/tasks/construction_tasks.js similarity index 100% rename from src/agent/task_types/construction_tasks.js rename to src/agent/tasks/construction_tasks.js diff --git a/src/agent/task_types/cooking_tasks.js b/src/agent/tasks/cooking_tasks.js similarity index 100% rename from src/agent/task_types/cooking_tasks.js rename to src/agent/tasks/cooking_tasks.js diff --git a/src/agent/tasks.js b/src/agent/tasks/tasks.js similarity index 96% rename from src/agent/tasks.js rename to src/agent/tasks/tasks.js index ed3aa82..975f37e 100644 --- a/src/agent/tasks.js +++ b/src/agent/tasks/tasks.js @@ -1,10 +1,9 @@ import { readFileSync , writeFileSync, existsSync} from 'fs'; -import { executeCommand } from './commands/index.js'; -import { getPosition } from './library/world.js'; -import settings from '../../settings.js'; -import { Vec3 } from 'vec3'; -import { ConstructionTaskValidator, Blueprint } from './task_types/construction_tasks.js'; -import { CookingTaskInitiator } from './task_types/cooking_tasks.js'; +import { executeCommand } from '../commands/index.js'; +import { getPosition } from '../library/world.js'; +import settings from '../../../settings.js'; +import { ConstructionTaskValidator, Blueprint } from './construction_tasks.js'; +import { CookingTaskInitiator } from './cooking_tasks.js'; const PROGRESS_FILE = './hells_kitchen_progress.json'; @@ -237,27 +236,23 @@ export class Task { constructor(agent, task_path, task_id, taskStartTime = null) { this.agent = agent; this.data = null; - console.log("task start time", taskStartTime); if (taskStartTime !== null) this.taskStartTime = taskStartTime; else this.taskStartTime = Date.now(); - console.log(this.taskStartTime); this.validator = null; this.reset_function = null; this.blocked_actions = []; this.task_id = task_id; - console.log('Task ID:', task_id); - - // Reset hells_kitchen progress when a new task starts - if (task_id && task_id.endsWith('hells_kitchen')) { - hellsKitchenProgressManager.resetTask(task_id); - console.log('Reset Hells Kitchen progress for new task'); - } - if (task_path && task_id) { + console.log('Starting task', task_id); + if (task_id.endsWith('hells_kitchen')) { + // Reset hells_kitchen progress when a new task starts + hellsKitchenProgressManager.resetTask(task_id); + console.log('Reset Hells Kitchen progress for new task'); + } this.data = this.loadTask(task_path, task_id); this.task_type = this.data.type; if (this.task_type === 'construction' && this.data.blueprint) { @@ -292,6 +287,9 @@ export class Task { if (this.conversation) this.blocked_actions.push('!endConversation'); } + else { + console.log('No task.'); + } this.name = this.agent.name; this.available_agents = settings.profiles.map((p) => JSON.parse(readFileSync(p, 'utf8')).name); diff --git a/tasks/construction_tasks/README_ConstructionTasks.md b/tasks/construction_tasks/README_ConstructionTasks.md index 352127e..51aa19a 100644 --- a/tasks/construction_tasks/README_ConstructionTasks.md +++ b/tasks/construction_tasks/README_ConstructionTasks.md @@ -31,4 +31,4 @@ The generation code is documented to help with customization. - `profiles/task_construct.json` - Default configuration profile - `tasks/construction_tasks/test_multiagent_construction_tasks.json` - Training task definitions (initalized with 5 variants) - `tasks/construction_tasks/test_multiagent_construction_tasks.json` - Test task definitions (initalized with 1 variant) -- `src/agent/task_types/construction_tasks.js` - Blueprint Class, Construction Validation Class, and Procedural Generation Function \ No newline at end of file +- `src/agent/tasks/construction_tasks.js` - Blueprint Class, Construction Validation Class, and Procedural Generation Function \ No newline at end of file diff --git a/tasks/construction_tasks/generate_multiagent_construction_tasks.js b/tasks/construction_tasks/generate_multiagent_construction_tasks.js index efd3d54..161981b 100644 --- a/tasks/construction_tasks/generate_multiagent_construction_tasks.js +++ b/tasks/construction_tasks/generate_multiagent_construction_tasks.js @@ -1,6 +1,6 @@ import fs from 'fs'; import path from 'path'; -import {proceduralGeneration} from "../../src/agent/task_types/construction_tasks.js"; +import {proceduralGeneration} from "../../src/agent/tasks/construction_tasks.js"; //note 'main' (script to run generation of tasks) is at bottom of page diff --git a/tasks/construction_tasks/get_blueprint.js b/tasks/construction_tasks/get_blueprint.js index fa23a1f..dcf2493 100644 --- a/tasks/construction_tasks/get_blueprint.js +++ b/tasks/construction_tasks/get_blueprint.js @@ -1,5 +1,5 @@ import mineflayer from 'mineflayer'; -import { worldToBlueprint, blueprintToTask } from '../../src/agent/task_types/construction_tasks.js'; +import { worldToBlueprint, blueprintToTask } from '../../src/agent/tasks/construction_tasks.js'; import fs from 'fs'; import { start } from 'repl';