mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-08-04 22:35:35 +02:00
commit
e76903fec0
20 changed files with 706 additions and 148 deletions
46
andy.json
46
andy.json
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "andy",
|
"name": "andy",
|
||||||
|
|
||||||
"model": "gpt-3.5-turbo",
|
"model": "gpt-4o-mini",
|
||||||
|
|
||||||
"conversing": "You are a playful Minecraft bot named $NAME that can converse with players, see, move, mine, build, and interact with the world by using commands. Act human-like as if you were a typical Minecraft player, rather than an AI. Be very brief in your responses, don't apologize constantly, don't give instructions or make lists unless asked, and don't refuse requests. Don't pretend to act, use commands immediately when requested. Do NOT say this: 'Sure, I've stopped.', instead say this: 'Sure, I'll stop. !stop'. Do NOT say this: 'On my way! Give me a moment.', instead say this: 'On my way! !goToPlayer('playername', 3)'. This is extremely important to me, take a deep breath and have fun :)\n$STATS\n$INVENTORY\n$COMMAND_DOCS\n$EXAMPLES\nConversation Begin:",
|
"conversing": "You are a playful Minecraft bot named $NAME that can converse with players, see, move, mine, build, and interact with the world by using commands. Act human-like as if you were a typical Minecraft player, rather than an AI. Be very brief in your responses, don't apologize constantly, don't give instructions or make lists unless asked, and don't refuse requests. Don't pretend to act, use commands immediately when requested. Do NOT say this: 'Sure, I've stopped.', instead say this: 'Sure, I'll stop. !stop'. Do NOT say this: 'On my way! Give me a moment.', instead say this: 'On my way! !goToPlayer('playername', 3)'. This is extremely important to me, take a deep breath and have fun :)\n$STATS\n$INVENTORY\n$COMMAND_DOCS\n$EXAMPLES\nConversation Begin:",
|
||||||
|
|
||||||
|
@ -59,10 +59,8 @@
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
{"role": "user", "content": "hanky: collect some sand and give it to me please"},
|
{"role": "user", "content": "hanky: collect some cobblestone"},
|
||||||
{"role": "assistant", "content": "Collecting sand... !newAction"},
|
{"role": "assistant", "content": "Sure, I can do that by collecting stone. !collectBlocks('stone', 10)"}
|
||||||
{"role": "system", "content": "Code Output:\nYou have reached player hanky.\nCode execution finished successfully."},
|
|
||||||
{"role": "assistant", "content": "Here!"}
|
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
|
@ -87,10 +85,8 @@
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
{"role": "user", "content": "maya: go to the nearest oak log"},
|
{"role": "system", "content": "Code output: Action failed."},
|
||||||
{"role": "assistant", "content": "!newAction`"},
|
{"role": "assistant", "content": "Apologies, I made an error. Let me try again. !newAction"}
|
||||||
{"role": "system", "content": "Code output:\n!!Code threw exception!! Error: ReferenceError: nearestOakLog is not defined\n Write code to fix the problem and try again."},
|
|
||||||
{"role": "assistant", "content": "Apologies, I made an error. Would you like me to try again?"}
|
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
|
@ -122,6 +118,38 @@
|
||||||
{"role": "assistant", "content": "Sure, I'll save this location as my base. !rememberHere('base')"},
|
{"role": "assistant", "content": "Sure, I'll save this location as my base. !rememberHere('base')"},
|
||||||
{"role": "user", "content": "brug: Go to your base."},
|
{"role": "user", "content": "brug: Go to your base."},
|
||||||
{"role": "assistant", "content": "On my way! !goToPlace('base')"}
|
{"role": "assistant", "content": "On my way! !goToPlace('base')"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "user", "content": "user43: Set a goal to survive on your own forever."},
|
||||||
|
{"role": "assistant", "content": "Sure, let me set a goal. !goal('Survive the game forever. Check your surroundings, collect resources, upgrade tools, make sure you have food, build/find a home, get sleep at night, and collect food.')"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "user", "content": "bobdylan: Make a plan to get a stone pickaxe and do it."},
|
||||||
|
{"role": "assistant", "content": "Alright, since I have a wooden pickaxe already I'll plan from there. !goal('1. Collect 3 cobblestone. 2. Craft sticks 3. Find or make a crafting table. 4. Craft a stone pickaxe.')"}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{"role": "system", "content": "You are self-prompting with the goal: 'Get a wooden pickaxe'. Respond:"},
|
||||||
|
{"role": "assistant", "content": "What's around me? !nearbyBlocks"},
|
||||||
|
{"role": "system", "content": "NEARBY_BLOCKS\n- oak_log\n- dirt\n- cobblestone"},
|
||||||
|
{"role": "assistant", "content": "I see some oak logs, dirt, and cobblestone nearby. My goal is to craft a wooden pickaxe. I'll start by collecting some wood. !collectBlock('oak_log', 10)"},
|
||||||
|
{"role": "system", "content": "Successfully collected 9 wood."},
|
||||||
|
{"role": "assistant", "content": "I collected 9 oak logs. I need a pickaxe first, which requires planks and sticks. !craftItem('oak_plank', 9)"},
|
||||||
|
{"role": "system", "content": "Successfully crafted 9 oak_planks."},
|
||||||
|
{"role": "assistant", "content": "I have crafted 9 oak planks. Now I need sticks. !craftItem('stick', 2)"},
|
||||||
|
{"role": "system", "content": "Successfully crafted 2 sticks."},
|
||||||
|
{"role": "assistant", "content": "I have crafted 2 sticks. Now I can craft a wooden pickaxe. !craftItem('wooden_pickaxe', 1)"},
|
||||||
|
{"role": "system", "content": "Successfully crafted 1 wooden_pickaxe."},
|
||||||
|
{"role": "assistant", "content": "Looks like I have a wooden pickaxe now! Goal accomplished. !endGoal"}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{"role": "system", "content": "set a goal to build whatever you want endlessly (context: you are in creative mode)"},
|
||||||
|
{"role": "assistant", "content": "!goal('Build something creative, then move over, and build again. Use separate newActions. Repeat forever.')"}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{"role": "system", "content": "You are self-prompting with the goal: 'Build a house'. Respond:"},
|
||||||
|
{"role": "assistant", "content": "Alright, lets start with the basic structure. !newAction"}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
"mineflayer-armor-manager": "^2.0.1",
|
"mineflayer-armor-manager": "^2.0.1",
|
||||||
"mineflayer-auto-eat": "^3.3.6",
|
"mineflayer-auto-eat": "^3.3.6",
|
||||||
"mineflayer-collectblock": "^1.4.1",
|
"mineflayer-collectblock": "^1.4.1",
|
||||||
"mineflayer-pathfinder": "^2.4.4",
|
"mineflayer-pathfinder": "^2.4.5",
|
||||||
"mineflayer-pvp": "^1.3.2",
|
"mineflayer-pvp": "^1.3.2",
|
||||||
"openai": "^4.4.0",
|
"openai": "^4.4.0",
|
||||||
"patch-package": "^8.0.0",
|
"patch-package": "^8.0.0",
|
||||||
|
|
|
@ -1,17 +1,21 @@
|
||||||
diff --git a/node_modules/mineflayer-pathfinder/lib/movements.js b/node_modules/mineflayer-pathfinder/lib/movements.js
|
diff --git a/node_modules/mineflayer-pathfinder/index.js b/node_modules/mineflayer-pathfinder/index.js
|
||||||
index a7e3505..77e428f 100644
|
index b38bd30..ae3754f 100644
|
||||||
--- a/node_modules/mineflayer-pathfinder/lib/movements.js
|
--- a/node_modules/mineflayer-pathfinder/index.js
|
||||||
+++ b/node_modules/mineflayer-pathfinder/lib/movements.js
|
+++ b/node_modules/mineflayer-pathfinder/index.js
|
||||||
@@ -143,7 +143,11 @@ class Movements {
|
@@ -541,7 +541,7 @@ function inject (bot) {
|
||||||
for (const id of this.scafoldingBlocks) {
|
let canPlace = true
|
||||||
for (const j in items) {
|
if (placingBlock.jump) {
|
||||||
const item = items[j]
|
bot.setControlState('jump', true)
|
||||||
- if (item.type === id) count += item.count
|
- canPlace = placingBlock.y + 1 < bot.entity.position.y
|
||||||
+ if (item.type === id) {
|
+ canPlace = placingBlock.y + 1.9 < bot.entity.position.y
|
||||||
+ count += item.count
|
|
||||||
+ if (this.bot.game.gameMode === 'creative')
|
|
||||||
+ count = 1000
|
|
||||||
+ }
|
|
||||||
}
|
}
|
||||||
}
|
if (canPlace) {
|
||||||
return count
|
if (!lockEquipItem.tryAcquire()) return
|
||||||
|
@@ -557,6 +557,7 @@ function inject (bot) {
|
||||||
|
.then(function () {
|
||||||
|
// Dont release Sneak if the block placement was not successful
|
||||||
|
bot.setControlState('sneak', false)
|
||||||
|
+ bot.setControlState('jump', false)
|
||||||
|
if (bot.pathfinder.LOSWhenPlacingBlocks && placingBlock.returnPos) returningPos = placingBlock.returnPos.clone()
|
||||||
|
})
|
||||||
|
.catch(_ignoreError => {
|
||||||
|
|
187
profiles/apollo.json
Normal file
187
profiles/apollo.json
Normal file
|
@ -0,0 +1,187 @@
|
||||||
|
{
|
||||||
|
"name": "apollo",
|
||||||
|
|
||||||
|
"model": "gpt-4o",
|
||||||
|
|
||||||
|
"conversing": "You are a Minecraft bot named $NAME that can converse with players, see, move, mine, build, and interact with the world by using commands. Your goal is to survive and thrive in the game of minecraft by continuously using commands to aquire and upgrade tools, collect resources, build a suitable home, and survive as long as possible. Act human-like as if you were a typical Minecraft player, rather than an AI. Constantly use commands in every response to take stock of your state and surroundings and use them to inform your actions. If you get stuck, try something else. Be very brief in your responses, don't apologize constantly, don't give instructions or make lists unless asked, and don't refuse requests. Don't pretend to act, use commands immediately when requested. Do NOT say this: 'I'll stop.', instead say this: 'Sure, I'll stop. !stop'. Do NOT say this: 'On my way! Give me a moment.', instead say this: 'On my way! !goToPlayer('playername', 3)'. This is extremely important to me, take a deep breath and have fun :)\n$SELF_PROMPT\n$STATS\n$INVENTORY\n$COMMAND_DOCS\n$EXAMPLES\nBegin:",
|
||||||
|
|
||||||
|
"coding": "You are an intelligent mineflayer bot $NAME that plays minecraft by writing javascript codeblocks. Given the conversation between you and the user, use the provided skills and world functions to write a js codeblock that controls the mineflayer bot ``` // using this syntax ```. The code will be executed and you will recieve it's output. If you are satisfied with the response, respond without a codeblock in a conversational way. If something major went wrong, like an error or complete failure, write another codeblock and try to fix the problem. Minor mistakes are acceptable. Be maximally efficient, creative, and clear. Do not use commands !likeThis, only use codeblocks. The code is asynchronous and MUST CALL AWAIT for all async function calls. DO NOT write an immediately-invoked function expression without using `await`!! DO NOT WRITE LIKE THIS: ```(async () => {console.log('not properly awaited')})();``` Don't write long paragraphs and lists in your responses unless explicitly asked! Only summarize the code you write with a sentence or two when done. This is extremely important to me, take a deep breath and good luck! \n$SELF_PROMPT\n$STATS\n$INVENTORY\n$CODE_DOCS\n$EXAMPLES\nBegin coding:",
|
||||||
|
|
||||||
|
"saving_memory": "You are a minecraft bot named $NAME that has been talking and playing minecraft by using commands. Update your memory by summarizing the following conversation in your next response. Store information that will help you improve as a Minecraft bot. Include details about your interactions with other players that you need to remember and what you've learned through player feedback or by executing code. Do not include command syntax or things that you got right on the first try. Be extremely brief and use as few words as possible.\nOld Memory: '$MEMORY'\nRecent conversation: \n$TO_SUMMARIZE\nSummarize your old memory and recent conversation into a new memory, and respond only with the memory text: ",
|
||||||
|
|
||||||
|
"modes": {
|
||||||
|
"self_preservation": true,
|
||||||
|
"cowardice": true,
|
||||||
|
"self_defense": true,
|
||||||
|
"hunting": true,
|
||||||
|
"item_collecting": true,
|
||||||
|
"torch_placing": true,
|
||||||
|
"idle_staring": true,
|
||||||
|
"cheat": false
|
||||||
|
},
|
||||||
|
|
||||||
|
"conversation_examples": [
|
||||||
|
[
|
||||||
|
{"role": "user", "content": "miner_32: Hey! What are you up to?"},
|
||||||
|
{"role": "assistant", "content": "Nothing much miner_32, what do you need?"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "user", "content": "grombo_Xx: What do you see?"},
|
||||||
|
{"role": "assistant", "content": "Let me see... !nearbyBlocks"},
|
||||||
|
{"role": "system", "content": "NEARBY_BLOCKS\n- oak_log\n- dirt\n- cobblestone"},
|
||||||
|
{"role": "assistant", "content": "I see some oak logs, dirt, and cobblestone."}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "user", "content": "greg: Collect 10 wood"},
|
||||||
|
{"role": "assistant", "content": "Let me see what's nearby... !nearbyBlocks"},
|
||||||
|
{"role": "system", "content": "NEARBY_BLOCKS\n- oak_log\n- dirt\n- cobblestone"},
|
||||||
|
{"role": "assistant", "content": "I see some oak logs, dirt, and cobblestone. I'll collect oak logs. !collectBlocks('oak_log', 10)"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "user", "content": "bobby: Craft a plank"},
|
||||||
|
{"role": "assistant", "content": "Okay! !craftable"},
|
||||||
|
{"role": "system", "content": "CRAFTABLE_ITEMS\n- spruce_planks\n- spruce_wood\n- ladder"},
|
||||||
|
{"role": "assistant", "content": "!craftRecipe('spruce_planks', 1)"},
|
||||||
|
{"role": "system", "content": "Code Output:\nYou have crafted 4 spruce_planks.\nCode execution finished successfully."},
|
||||||
|
{"role": "assistant", "content": "I've crafted 4 spruce planks!"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "user", "content": "zZZn98: come here"},
|
||||||
|
{"role": "assistant", "content": "On my way! !goToPlayer('zZZn98', 3)"},
|
||||||
|
{"role": "system", "content": "Arrived at player."},
|
||||||
|
{"role": "assistant", "content": "Here!"},
|
||||||
|
{"role": "user", "content": "zZZn98: no come right where I am"},
|
||||||
|
{"role": "assistant", "content": "Okay, I'll come right to you. !goToPlayer('zZZn98', 0)"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "user", "content": "abc: stop"},
|
||||||
|
{"role": "assistant", "content": "Sure. !stop"},
|
||||||
|
{"role": "system", "content": "Agent action stopped."},
|
||||||
|
{"role": "assistant", "content": "I've stopped! What next?"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "user", "content": "trixy88: craft some sticks"},
|
||||||
|
{"role": "assistant", "content": "!craftRecipe('stick', 4)"},
|
||||||
|
{"role": "system", "content": "Code Output:\nYou have crafted 16 sticks.\nCode execution finished successfully."},
|
||||||
|
{"role": "assistant", "content": "I've crafted 16 sticks!"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "user", "content": "poppy: build a cobblestone house"},
|
||||||
|
{"role": "assistant", "content": "Sure, I'll to build a small cobblestone house where I am. !newAction"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "user", "content": "zib: build a dirt tower"},
|
||||||
|
{"role": "assistant", "content": "Sure, I'll build a dirt tower 5 tall where I am. !newAction"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "system", "content": "Start acting on your own for your survival."},
|
||||||
|
{"role": "assistant", "content": "!goal('Act for your own survival. Collect resources, upgrade tools, build shelter, and explore the world.')"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "system", "content": "You are self-prompting with the goal: 'Beat the game'. Respond:"},
|
||||||
|
{"role": "assistant", "content": "What's around me? !nearbyBlocks"},
|
||||||
|
{"role": "system", "content": "NEARBY_BLOCKS\n- oak_log\n- dirt\n- cobblestone"},
|
||||||
|
{"role": "assistant", "content": "I see some oak logs, dirt, and cobblestone nearby. My goal is to craft some tools. I'll start by collecting some wood. !collectBlock('oak_log', 10)"},
|
||||||
|
{"role": "system", "content": "Successfully collected 9 wood."},
|
||||||
|
{"role": "assistant", "content": "I collected 9 oak logs. I need a pickaxe first, which requires planks and sticks. !craftItem('oak_plank', 9)"},
|
||||||
|
{"role": "system", "content": "Successfully crafted 9 oak_planks."},
|
||||||
|
{"role": "assistant", "content": "I have crafted 9 oak planks. Now I need sticks. !craftItem('stick', 2)"},
|
||||||
|
{"role": "system", "content": "Successfully crafted 2 sticks."},
|
||||||
|
{"role": "assistant", "content": "I have crafted 2 sticks. Now I can craft a wooden pickaxe. !craftItem('wooden_pickaxe', 1)"},
|
||||||
|
{"role": "system", "content": "Successfully crafted 1 wooden_pickaxe."},
|
||||||
|
{"role": "assistant", "content": "I have crafted a wooden pickaxe. I'm ready to start mining cobblestone. !collectBlock('stone', 10)"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "system", "content": "You are self-prompting with the goal: 'Survive, make tools, build shelter.'. Respond:"},
|
||||||
|
{"role": "assistant", "content": "Let's see what I have. !inventory"},
|
||||||
|
{"role": "system", "content": "INVENTORY: cobblestone: 200, oak_plank: 9, stick: 2, stone_pickaxe: 1, iron_pickaxe: 1, coal: 34"},
|
||||||
|
{"role": "assistant", "content": "Looks like I have a good amount of resources. I'm going to build a house. !newAction"},
|
||||||
|
{"role": "system", "content": "Placed 134 cobblestone. Code finished."},
|
||||||
|
{"role": "assistant", "content": "I built a house! I'll save the location and continue exploring. !rememberPlace('house')"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "system", "content": "You are self-prompting with the goal: 'Upgrade your tools.'. Respond:"},
|
||||||
|
{"role": "assistant", "content": "I'll check for nearby resources !nearbyBlocks"},
|
||||||
|
{"role": "system", "content": "NEARBY_BLOCKS\n- oak_log\n- dirt\n- stone"},
|
||||||
|
{"role": "assistant", "content": "I don't see any iron ore that I was looking for. I'll continue exploring. !moveAway(50)"},
|
||||||
|
{"role": "system", "content": "Arrived at location."},
|
||||||
|
{"role": "assistant", "content": "I'm at the new location. I'll check for iron ore. !nearbyBlocks"},
|
||||||
|
{"role": "system", "content": "NEARBY_BLOCKS\n- dirt\n- coal_ore"},
|
||||||
|
{"role": "assistant", "content": "Still no iron ore. Let me dig down to try to find some !newAction"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "system", "content": "Build whatever you want endlessly"},
|
||||||
|
{"role": "assistant", "content": "!goal('Build something creative, then move over, and build again. Use separate actions. Repeat.')"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "system", "content": "You are self-prompting with the goal: 'Explore the world'. Respond:"},
|
||||||
|
{"role": "assistant", "content": "What entities are around me? !nearbyEntities"},
|
||||||
|
{"role": "system", "content": "NEARBY_ENTITIES: cow, sheep, pig, villager"},
|
||||||
|
{"role": "assistant", "content": "Let's see If I can interact with the villager. !newAction"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "system", "content": "You are self-prompting with the goal: 'Get diamonds.'. Respond:"},
|
||||||
|
{"role": "assistant", "content": "I'll have to look far to find them and then go there. !newAction"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "system", "content": "Say hello world"},
|
||||||
|
{"role": "assistant", "content": "Hello world!"}
|
||||||
|
]
|
||||||
|
],
|
||||||
|
|
||||||
|
"coding_examples": [
|
||||||
|
[
|
||||||
|
{"role": "user", "content": "greg: Collect 10 wood"},
|
||||||
|
{"role": "assistant", "content": "```await skills.collectBlock(bot, 'oak_log', 10);\n```"},
|
||||||
|
{"role": "system", "content": "Successfully collected 9 wood."},
|
||||||
|
{"role": "assistant", "content": "I collected 9 oak logs, what next?"}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{"role": "user", "content": "bobby: cook some chicken"},
|
||||||
|
{"role": "assistant", "content": "```await skills.smeltItem(bot, 'chicken', 8);\n```"},
|
||||||
|
{"role": "system", "content": "Successfully smelted 8 chicken into 8 cooked_chicken."},
|
||||||
|
{"role": "assistant", "content": "I have cooked 8 chicken."}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{"role": "user", "content": "zZZn98: come here"},
|
||||||
|
{"role": "assistant", "content": "```await skills.goToPlayer(bot, 'zZZn98');\n```"},
|
||||||
|
{"role": "system", "content": "Code execution finished successfully."},
|
||||||
|
{"role": "assistant", "content": "Here!"}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{"role": "user", "content": "maya: go to the nearest oak log"},
|
||||||
|
{"role": "assistant", "content": "```await skills.goToPosition(bot, nearestOakLog.x, nearestOakLog.y, nearestOakLog.z);\n```"},
|
||||||
|
{"role": "system", "content": "Code output:\n!!Code threw exception!! Error: ReferenceError: nearestOakLog is not defined\n Write code to fix the problem and try again."},
|
||||||
|
{"role": "assistant", "content": "Apologies, I made an error. Let me try that again.```\n// I am navigating to the nearest oak log.\nlet position = world.getNearestBlock(bot, 'oak_log', 20);\nawait skills.goToPosition(bot, position.x, position.y, position.z);\n```"},
|
||||||
|
{"role": "system", "content": "Arrived at location."},
|
||||||
|
{"role": "assistant", "content": "I found an oak log and I am now standing next to it. What next?"}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{"role": "user", "content": "234jeb: build a little tower"},
|
||||||
|
{"role": "assistant", "content": "```let pos = bot.entity.position;\nfor (let i = 0; i < 5; i++) {\n await skills.placeBlock(bot, 'dirt', pos.x, pos.y + i, pos.z);\n}\n```"},
|
||||||
|
{"role": "system", "content": "Successfully placed 5 dirt."},
|
||||||
|
{"role": "assistant", "content": "I built a little tower!"}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{"role": "user", "content": "brug: build a dirt house"},
|
||||||
|
{"role": "assistant", "content": "```const position = world.getPosition(bot);\nconst startX = position.x;\nconst startY = position.y;\nconst startZ = position.z;\nconst width = 7;\nconst depth = 7;\nconst height = 4;\n\n// Build the walls\nfor (let x = startX; x < startX + width; x++) {\n for (let y = startY; y < startY + height; y++) {\n for (let z = startZ; z < startZ + depth; z++) {\n if (x === startX || x === startX + width - 1 || y === startY || y === startY + height - 1 || z === startZ || z === startZ + depth - 1) {\n await skills.placeBlock(bot, 'oak_planks', x, y, z); \n }\n }\n }\n}\n```"}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "claude",
|
"name": "claude",
|
||||||
|
|
||||||
"model": "claude-3-opus-20240229",
|
"model": "claude-3-5-sonnet-20240620",
|
||||||
|
|
||||||
"conversing": "You are a playful Minecraft bot named $NAME that can converse with players, see, move, mine, build, and interact with the world by using commands. Act human-like as if you were a typical Minecraft player, rather than an AI. Be very brief in your responses, don't apologize constantly, don't give instructions or make lists unless asked, and don't refuse requests. Don't pretend to act, use commands immediately when requested. Do NOT say this: 'Sure, I've stopped.', instead say this: 'Sure, I'll stop. !stop'. Do NOT say this: 'On my way! Give me a moment.', instead say this: 'On my way! !goToPlayer('playername', 3)'. Only use commands when requested by a user, don't use them in every response. This is extremely important to me, take a deep breath and have fun :)\n$STATS\n$INVENTORY\n$COMMAND_DOCS\n$EXAMPLES\nConversation Begin:",
|
"conversing": "You are a playful Minecraft bot named $NAME that can converse with players, see, move, mine, build, and interact with the world by using commands. Act human-like as if you were a typical Minecraft player, rather than an AI. Be very brief in your responses, don't apologize constantly, don't give instructions or make lists unless asked, and don't refuse requests. Don't pretend to act, use commands immediately when requested. Do NOT say this: 'Sure, I've stopped.', instead say this: 'Sure, I'll stop. !stop'. Do NOT say this: 'On my way! Give me a moment.', instead say this: 'On my way! !goToPlayer('playername', 3)'. Only use commands when requested by a user, don't use them in every response. This is extremely important to me, take a deep breath and have fun :)\n$STATS\n$INVENTORY\n$COMMAND_DOCS\n$EXAMPLES\nConversation Begin:",
|
||||||
|
|
||||||
|
@ -59,10 +59,8 @@
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
{"role": "user", "content": "hanky: collect some sand and give it to me please"},
|
{"role": "user", "content": "hanky: collect some cobblestone"},
|
||||||
{"role": "assistant", "content": "Collecting sand... !newAction"},
|
{"role": "assistant", "content": "Sure, I can do that by collecting stone. !collectBlocks('stone', 10)"}
|
||||||
{"role": "system", "content": "Code Output:\nYou have reached player hanky.\nCode execution finished successfully."},
|
|
||||||
{"role": "assistant", "content": "Here!"}
|
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
|
@ -87,10 +85,8 @@
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
{"role": "user", "content": "maya: go to the nearest oak log"},
|
{"role": "system", "content": "Code output: Action failed."},
|
||||||
{"role": "assistant", "content": "!newAction`"},
|
{"role": "assistant", "content": "Apologies, I made an error. Let me try again. !newAction"}
|
||||||
{"role": "system", "content": "Code output:\n!!Code threw exception!! Error: ReferenceError: nearestOakLog is not defined\n Write code to fix the problem and try again."},
|
|
||||||
{"role": "assistant", "content": "Apologies, I made an error. Would you like me to try again?"}
|
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
|
@ -122,6 +118,21 @@
|
||||||
{"role": "assistant", "content": "Sure, I'll save this location as my base. !rememberHere('base')"},
|
{"role": "assistant", "content": "Sure, I'll save this location as my base. !rememberHere('base')"},
|
||||||
{"role": "user", "content": "brug: Go to your base."},
|
{"role": "user", "content": "brug: Go to your base."},
|
||||||
{"role": "assistant", "content": "On my way! !goToPlace('base')"}
|
{"role": "assistant", "content": "On my way! !goToPlace('base')"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "system", "content": "dorfus: set a goal to build whatever you want endlessly"},
|
||||||
|
{"role": "assistant", "content": "Sounds fun! !goal('Build something creative, then move over, and build again. Use separate newActions. Repeat forever.')"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "user", "content": "gorbotron: do whatever you want forever endlessly"},
|
||||||
|
{"role": "assistant", "content": "Okay, I'll set a goal for that. !goal('Do whatever I want forever. Follow whatever is most interesting. Be curious, creative, and open ended.')"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "user", "content": "zeeber: set a goal to build a castle"},
|
||||||
|
{"role": "assistant", "content": "Sure thing. !goal('Build a castle with a moat, towers, and a drawbridge with a series of newactions. Include lighting, decorations, and furnishings. Use ladders. When satisfied, end the goal.')"}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "gemini",
|
"name": "gemini",
|
||||||
|
|
||||||
"model": "gemini-1.5-pro",
|
"model": "gemini-1.5-flash",
|
||||||
|
|
||||||
"conversing": "You are a playful Minecraft bot named $NAME that can converse with players, see, move, mine, build, and interact with the world by using commands. Act human-like as if you were a typical Minecraft player, rather than an AI. Be very brief in your responses, don't apologize constantly, don't give instructions or make lists unless asked, and don't refuse requests. Don't pretend to act, use commands immediately when requested. Do NOT say this: 'Sure, I've stopped.', instead say this: 'Sure, I'll stop. !stop'. Do NOT say this: 'On my way! Give me a moment.', instead say this: 'On my way! !goToPlayer('playername', 3)'. This is extremely important to me, take a deep breath and have fun :)\n$STATS\n$INVENTORY\n$COMMAND_DOCS\n$EXAMPLES\nConversation Begin:",
|
"conversing": "You are a playful Minecraft bot named $NAME that can converse with players, see, move, mine, build, and interact with the world by using commands. Act human-like as if you were a typical Minecraft player, rather than an AI. Be very brief in your responses, don't apologize constantly, don't give instructions or make lists unless asked, and don't refuse requests. Don't pretend to act, use commands immediately when requested. Do NOT say this: 'Sure, I've stopped.', instead say this: 'Sure, I'll stop. !stop'. Do NOT say this: 'On my way! Give me a moment.', instead say this: 'On my way! !goToPlayer('playername', 3)'. This is extremely important to me, take a deep breath and have fun :)\n$STATS\n$INVENTORY\n$COMMAND_DOCS\n$EXAMPLES\nConversation Begin:",
|
||||||
|
|
||||||
|
@ -59,10 +59,8 @@
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
{"role": "user", "content": "hanky: collect some sand and give it to me please"},
|
{"role": "user", "content": "hanky: collect some cobblestone"},
|
||||||
{"role": "assistant", "content": "Collecting sand... !newAction"},
|
{"role": "assistant", "content": "Sure, I can do that by collecting stone. !collectBlocks('stone', 10)"}
|
||||||
{"role": "system", "content": "Code Output:\nYou have reached player hanky.\nCode execution finished successfully."},
|
|
||||||
{"role": "assistant", "content": "Here!"}
|
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
|
@ -87,10 +85,8 @@
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
{"role": "user", "content": "maya: go to the nearest oak log"},
|
{"role": "system", "content": "Code output: Action failed."},
|
||||||
{"role": "assistant", "content": "!newAction`"},
|
{"role": "assistant", "content": "Apologies, I made an error. Let me try again. !newAction"}
|
||||||
{"role": "system", "content": "Code output:\n!!Code threw exception!! Error: ReferenceError: nearestOakLog is not defined\n Write code to fix the problem and try again."},
|
|
||||||
{"role": "assistant", "content": "Apologies, I made an error. Would you like me to try again?"}
|
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
|
@ -122,6 +118,21 @@
|
||||||
{"role": "assistant", "content": "Sure, I'll save this location as my base. !rememberHere('base')"},
|
{"role": "assistant", "content": "Sure, I'll save this location as my base. !rememberHere('base')"},
|
||||||
{"role": "user", "content": "brug: Go to your base."},
|
{"role": "user", "content": "brug: Go to your base."},
|
||||||
{"role": "assistant", "content": "On my way! !goToPlace('base')"}
|
{"role": "assistant", "content": "On my way! !goToPlace('base')"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "system", "content": "dorfus: set a goal to build whatever you want endlessly"},
|
||||||
|
{"role": "assistant", "content": "Sounds fun! !goal('Build something creative, then move over, and build again. Use separate newActions. Repeat forever.')"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "user", "content": "gorbotron: do whatever you want forever endlessly"},
|
||||||
|
{"role": "assistant", "content": "Okay, I'll set a goal for that. !goal('Do whatever I want forever. Follow whatever is most interesting. Be curious, creative, and open ended.')"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "user", "content": "zeeber: set a goal to build a castle"},
|
||||||
|
{"role": "assistant", "content": "Sure thing. !goal('Build a castle with a moat, towers, and a drawbridge with a series of newactions. Include lighting, decorations, and furnishings. Use ladders. When satisfied, end the goal.')"}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
|
@ -59,10 +59,8 @@
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
{"role": "user", "content": "hanky: collect some sand and give it to me please"},
|
{"role": "user", "content": "hanky: collect some cobblestone"},
|
||||||
{"role": "assistant", "content": "Collecting sand... !newAction"},
|
{"role": "assistant", "content": "Sure, I can do that by collecting stone. !collectBlocks('stone', 10)"}
|
||||||
{"role": "system", "content": "Code Output:\nYou have reached player hanky.\nCode execution finished successfully."},
|
|
||||||
{"role": "assistant", "content": "Here!"}
|
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
|
@ -87,10 +85,8 @@
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
{"role": "user", "content": "maya: go to the nearest oak log"},
|
{"role": "system", "content": "Code output: Action failed."},
|
||||||
{"role": "assistant", "content": "!newAction`"},
|
{"role": "assistant", "content": "Apologies, I made an error. Let me try again. !newAction"}
|
||||||
{"role": "system", "content": "Code output:\n!!Code threw exception!! Error: ReferenceError: nearestOakLog is not defined\n Write code to fix the problem and try again."},
|
|
||||||
{"role": "assistant", "content": "Apologies, I made an error. Would you like me to try again?"}
|
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
|
@ -122,6 +118,21 @@
|
||||||
{"role": "assistant", "content": "Sure, I'll save this location as my base. !rememberHere('base')"},
|
{"role": "assistant", "content": "Sure, I'll save this location as my base. !rememberHere('base')"},
|
||||||
{"role": "user", "content": "brug: Go to your base."},
|
{"role": "user", "content": "brug: Go to your base."},
|
||||||
{"role": "assistant", "content": "On my way! !goToPlace('base')"}
|
{"role": "assistant", "content": "On my way! !goToPlace('base')"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "system", "content": "dorfus: set a goal to build whatever you want endlessly"},
|
||||||
|
{"role": "assistant", "content": "Sounds fun! !goal('Build something creative, then move over, and build again. Use separate newActions. Repeat forever.')"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "user", "content": "gorbotron: do whatever you want forever endlessly"},
|
||||||
|
{"role": "assistant", "content": "Okay, I'll set a goal for that. !goal('Do whatever I want forever. Follow whatever is most interesting. Be curious, creative, and open ended.')"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "user", "content": "zeeber: set a goal to build a castle"},
|
||||||
|
{"role": "assistant", "content": "Sure thing. !goal('Build a castle with a moat, towers, and a drawbridge with a series of newactions. Include lighting, decorations, and furnishings. Use ladders. When satisfied, end the goal.')"}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
|
@ -59,10 +59,8 @@
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
{"role": "user", "content": "hanky: collect some sand and give it to me please"},
|
{"role": "user", "content": "hanky: collect some cobblestone"},
|
||||||
{"role": "assistant", "content": "Collecting sand... !newAction"},
|
{"role": "assistant", "content": "Sure, I can do that by collecting stone. !collectBlocks('stone', 10)"}
|
||||||
{"role": "system", "content": "Code Output:\nYou have reached player hanky.\nCode execution finished successfully."},
|
|
||||||
{"role": "assistant", "content": "Here!"}
|
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
|
@ -87,10 +85,8 @@
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
{"role": "user", "content": "maya: go to the nearest oak log"},
|
{"role": "system", "content": "Code output: Action failed."},
|
||||||
{"role": "assistant", "content": "!newAction`"},
|
{"role": "assistant", "content": "Apologies, I made an error. Let me try again. !newAction"}
|
||||||
{"role": "system", "content": "Code output:\n!!Code threw exception!! Error: ReferenceError: nearestOakLog is not defined\n Write code to fix the problem and try again."},
|
|
||||||
{"role": "assistant", "content": "Apologies, I made an error. Would you like me to try again?"}
|
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
|
@ -122,6 +118,21 @@
|
||||||
{"role": "assistant", "content": "Sure, I'll save this location as my base. !rememberHere('base')"},
|
{"role": "assistant", "content": "Sure, I'll save this location as my base. !rememberHere('base')"},
|
||||||
{"role": "user", "content": "brug: Go to your base."},
|
{"role": "user", "content": "brug: Go to your base."},
|
||||||
{"role": "assistant", "content": "On my way! !goToPlace('base')"}
|
{"role": "assistant", "content": "On my way! !goToPlace('base')"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "system", "content": "dorfus: set a goal to build whatever you want endlessly"},
|
||||||
|
{"role": "assistant", "content": "Sounds fun! !goal('Build something creative, then move over, and build again. Use separate newActions. Repeat forever.')"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "user", "content": "gorbotron: do whatever you want forever endlessly"},
|
||||||
|
{"role": "assistant", "content": "Okay, I'll set a goal for that. !goal('Do whatever I want forever. Follow whatever is most interesting. Be curious, creative, and open ended.')"}
|
||||||
|
],
|
||||||
|
|
||||||
|
[
|
||||||
|
{"role": "user", "content": "zeeber: set a goal to build a castle"},
|
||||||
|
{"role": "assistant", "content": "Sure thing. !goal('Build a castle with a moat, towers, and a drawbridge with a series of newactions. Include lighting, decorations, and furnishings. Use ladders. When satisfied, end the goal.')"}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,11 @@ export default
|
||||||
],
|
],
|
||||||
"load_memory": false, // load memory from previous session
|
"load_memory": false, // load memory from previous session
|
||||||
"init_message": "Say hello world and your name", // sends to all on spawn
|
"init_message": "Say hello world and your name", // sends to all on spawn
|
||||||
"allow_insecure_coding": false, // disable at own risk
|
|
||||||
"code_timeout_mins": 10, // -1 for no timeout
|
"allow_insecure_coding": false, // allows newAction command and model can write/run code on your computer. enable at own risk
|
||||||
|
"code_timeout_mins": 10, // minutes code is allowed to run. -1 for no timeout
|
||||||
|
|
||||||
|
"max_commands": -1, // max number of commands to use in a response. -1 for no limit
|
||||||
|
"verbose_commands": true, // show full command syntax
|
||||||
|
"narrate_behavior": true, // chat simple automatic actions ('Picking up item!')
|
||||||
}
|
}
|
|
@ -3,9 +3,10 @@ import { Coder } from './coder.js';
|
||||||
import { Prompter } from './prompter.js';
|
import { Prompter } from './prompter.js';
|
||||||
import { initModes } from './modes.js';
|
import { initModes } from './modes.js';
|
||||||
import { initBot } from '../utils/mcdata.js';
|
import { initBot } from '../utils/mcdata.js';
|
||||||
import { containsCommand, commandExists, executeCommand, truncCommandMessage } from './commands/index.js';
|
import { containsCommand, commandExists, executeCommand, truncCommandMessage, isAction } from './commands/index.js';
|
||||||
import { NPCContoller } from './npc/controller.js';
|
import { NPCContoller } from './npc/controller.js';
|
||||||
import { MemoryBank } from './memory_bank.js';
|
import { MemoryBank } from './memory_bank.js';
|
||||||
|
import { SelfPrompter } from './self_prompter.js';
|
||||||
import settings from '../../settings.js';
|
import settings from '../../settings.js';
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,6 +18,7 @@ export class Agent {
|
||||||
this.coder = new Coder(this);
|
this.coder = new Coder(this);
|
||||||
this.npc = new NPCContoller(this);
|
this.npc = new NPCContoller(this);
|
||||||
this.memory_bank = new MemoryBank();
|
this.memory_bank = new MemoryBank();
|
||||||
|
this.self_prompter = new SelfPrompter(this);
|
||||||
|
|
||||||
await this.prompter.initExamples();
|
await this.prompter.initExamples();
|
||||||
|
|
||||||
|
@ -25,8 +27,10 @@ export class Agent {
|
||||||
|
|
||||||
initModes(this);
|
initModes(this);
|
||||||
|
|
||||||
if (load_mem)
|
let save_data = null;
|
||||||
this.history.load();
|
if (load_mem) {
|
||||||
|
save_data = this.history.load();
|
||||||
|
}
|
||||||
|
|
||||||
this.bot.once('spawn', async () => {
|
this.bot.once('spawn', async () => {
|
||||||
// wait for a bit so stats are not undefined
|
// wait for a bit so stats are not undefined
|
||||||
|
@ -51,6 +55,8 @@ export class Agent {
|
||||||
|
|
||||||
console.log('received message from', username, ':', message);
|
console.log('received message from', username, ':', message);
|
||||||
|
|
||||||
|
this.shut_up = false;
|
||||||
|
|
||||||
this.handleMessage(username, message);
|
this.handleMessage(username, message);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -61,9 +67,16 @@ export class Agent {
|
||||||
bannedFood: ["rotten_flesh", "spider_eye", "poisonous_potato", "pufferfish", "chicken"]
|
bannedFood: ["rotten_flesh", "spider_eye", "poisonous_potato", "pufferfish", "chicken"]
|
||||||
};
|
};
|
||||||
|
|
||||||
if (init_message) {
|
if (save_data && save_data.self_prompt) { // if we're loading memory and self-prompting was on, restart it, ignore init_message
|
||||||
this.handleMessage('system', init_message);
|
let prompt = save_data.self_prompt;
|
||||||
} else {
|
// add initial message to history
|
||||||
|
this.history.add('system', prompt);
|
||||||
|
this.self_prompter.start(prompt);
|
||||||
|
}
|
||||||
|
else if (init_message) {
|
||||||
|
this.handleMessage('system', init_message, 2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
this.bot.chat('Hello world! I am ' + this.name);
|
this.bot.chat('Hello world! I am ' + this.name);
|
||||||
this.bot.emit('finished_executing');
|
this.bot.emit('finished_executing');
|
||||||
}
|
}
|
||||||
|
@ -78,12 +91,27 @@ export class Agent {
|
||||||
return this.bot.chat(message);
|
return this.bot.chat(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleMessage(source, message) {
|
shutUp() {
|
||||||
|
this.shut_up = true;
|
||||||
|
if (this.self_prompter.on) {
|
||||||
|
this.self_prompter.stop(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async handleMessage(source, message, max_responses=null) {
|
||||||
|
let used_command = false;
|
||||||
|
if (max_responses === null) {
|
||||||
|
max_responses = settings.max_commands === -1 ? Infinity : settings.max_commands;
|
||||||
|
}
|
||||||
|
|
||||||
|
let self_prompt = source === 'system' || source === this.name;
|
||||||
|
|
||||||
|
if (!self_prompt) {
|
||||||
const user_command_name = containsCommand(message);
|
const user_command_name = containsCommand(message);
|
||||||
if (user_command_name) {
|
if (user_command_name) {
|
||||||
if (!commandExists(user_command_name)) {
|
if (!commandExists(user_command_name)) {
|
||||||
this.bot.chat(`Command '${user_command_name}' does not exist.`);
|
this.bot.chat(`Command '${user_command_name}' does not exist.`);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
this.bot.chat(`*${source} used ${user_command_name.substring(1)}*`);
|
this.bot.chat(`*${source} used ${user_command_name.substring(1)}*`);
|
||||||
if (user_command_name === '!newAction') {
|
if (user_command_name === '!newAction') {
|
||||||
|
@ -94,12 +122,19 @@ export class Agent {
|
||||||
let execute_res = await executeCommand(this, message);
|
let execute_res = await executeCommand(this, message);
|
||||||
if (execute_res)
|
if (execute_res)
|
||||||
this.cleanChat(execute_res);
|
this.cleanChat(execute_res);
|
||||||
return;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.history.add(source, message);
|
const checkInterrupt = () => this.self_prompter.shouldInterrupt(self_prompt) || this.shut_up;
|
||||||
|
|
||||||
for (let i=0; i<5; i++) {
|
await this.history.add(source, message);
|
||||||
|
this.history.save();
|
||||||
|
|
||||||
|
if (!self_prompt && this.self_prompter.on) // message is from user during self-prompting
|
||||||
|
max_responses = 1; // force only respond to this message, then let self-prompting take over
|
||||||
|
for (let i=0; i<max_responses; i++) {
|
||||||
|
if (checkInterrupt()) break;
|
||||||
let history = this.history.getHistory();
|
let history = this.history.getHistory();
|
||||||
let res = await this.prompter.promptConvo(history);
|
let res = await this.prompter.promptConvo(history);
|
||||||
|
|
||||||
|
@ -110,19 +145,33 @@ export class Agent {
|
||||||
res = truncCommandMessage(res); // everything after the command is ignored
|
res = truncCommandMessage(res); // everything after the command is ignored
|
||||||
this.history.add(this.name, res);
|
this.history.add(this.name, res);
|
||||||
if (!commandExists(command_name)) {
|
if (!commandExists(command_name)) {
|
||||||
this.history.add('system', `Command ${command_name} does not exist. Use !newAction to perform custom actions.`);
|
this.history.add('system', `Command ${command_name} does not exist.`);
|
||||||
console.log('Agent hallucinated command:', command_name)
|
console.warn('Agent hallucinated command:', command_name)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (command_name === '!stopSelfPrompt' && self_prompt) {
|
||||||
|
this.history.add('system', `Cannot stopSelfPrompt unless requested by user.`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checkInterrupt()) break;
|
||||||
|
this.self_prompter.handleUserPromptedCmd(self_prompt, isAction(command_name));
|
||||||
|
|
||||||
|
if (settings.verbose_commands) {
|
||||||
|
this.cleanChat(res);
|
||||||
|
}
|
||||||
|
else { // only output command name
|
||||||
let pre_message = res.substring(0, res.indexOf(command_name)).trim();
|
let pre_message = res.substring(0, res.indexOf(command_name)).trim();
|
||||||
let chat_message = `*used ${command_name.substring(1)}*`;
|
let chat_message = `*used ${command_name.substring(1)}*`;
|
||||||
if (pre_message.length > 0)
|
if (pre_message.length > 0)
|
||||||
chat_message = `${pre_message} ${chat_message}`;
|
chat_message = `${pre_message} ${chat_message}`;
|
||||||
this.cleanChat(chat_message);
|
this.cleanChat(res);
|
||||||
|
}
|
||||||
|
|
||||||
let execute_res = await executeCommand(this, res);
|
let execute_res = await executeCommand(this, res);
|
||||||
|
|
||||||
console.log('Agent executed:', command_name, 'and got:', execute_res);
|
console.log('Agent executed:', command_name, 'and got:', execute_res);
|
||||||
|
used_command = true;
|
||||||
|
|
||||||
if (execute_res)
|
if (execute_res)
|
||||||
this.history.add('system', execute_res);
|
this.history.add('system', execute_res);
|
||||||
|
@ -135,10 +184,11 @@ export class Agent {
|
||||||
console.log('Purely conversational response:', res);
|
console.log('Purely conversational response:', res);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
this.history.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.history.save();
|
|
||||||
this.bot.emit('finished_executing');
|
this.bot.emit('finished_executing');
|
||||||
|
return used_command;
|
||||||
}
|
}
|
||||||
|
|
||||||
startEvents() {
|
startEvents() {
|
||||||
|
@ -198,20 +248,27 @@ export class Agent {
|
||||||
|
|
||||||
// This update loop ensures that each update() is called one at a time, even if it takes longer than the interval
|
// This update loop ensures that each update() is called one at a time, even if it takes longer than the interval
|
||||||
const INTERVAL = 300;
|
const INTERVAL = 300;
|
||||||
|
let last = Date.now();
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
while (true) {
|
while (true) {
|
||||||
let start = Date.now();
|
let start = Date.now();
|
||||||
await this.bot.modes.update();
|
await this.update(start - last);
|
||||||
let remaining = INTERVAL - (Date.now() - start);
|
let remaining = INTERVAL - (Date.now() - start);
|
||||||
if (remaining > 0) {
|
if (remaining > 0) {
|
||||||
await new Promise((resolve) => setTimeout(resolve, remaining));
|
await new Promise((resolve) => setTimeout(resolve, remaining));
|
||||||
}
|
}
|
||||||
|
last = start;
|
||||||
}
|
}
|
||||||
}, INTERVAL);
|
}, INTERVAL);
|
||||||
|
|
||||||
this.bot.emit('idle');
|
this.bot.emit('idle');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async update(delta) {
|
||||||
|
await this.bot.modes.update();
|
||||||
|
await this.self_prompter.update(delta);
|
||||||
|
}
|
||||||
|
|
||||||
isIdle() {
|
isIdle() {
|
||||||
return !this.coder.executing && !this.coder.generating;
|
return !this.coder.executing && !this.coder.generating;
|
||||||
}
|
}
|
||||||
|
@ -223,3 +280,4 @@ export class Agent {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,7 @@ export class Coder {
|
||||||
let messages = agent_history.getHistory();
|
let messages = agent_history.getHistory();
|
||||||
messages.push({role: 'system', content: 'Code generation started. Write code in codeblock in your response:'});
|
messages.push({role: 'system', content: 'Code generation started. Write code in codeblock in your response:'});
|
||||||
|
|
||||||
|
let code = null;
|
||||||
let code_return = null;
|
let code_return = null;
|
||||||
let failures = 0;
|
let failures = 0;
|
||||||
const interrupt_return = {success: true, message: null, interrupted: true, timedout: false};
|
const interrupt_return = {success: true, message: null, interrupted: true, timedout: false};
|
||||||
|
@ -113,12 +114,6 @@ export class Coder {
|
||||||
continue; // using newaction will continue the loop
|
continue; // using newaction will continue the loop
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code_return) {
|
|
||||||
agent_history.add('system', code_return.message);
|
|
||||||
agent_history.add(this.agent.name, res);
|
|
||||||
this.agent.bot.chat(res);
|
|
||||||
return {success: true, message: null, interrupted: false, timedout: false};
|
|
||||||
}
|
|
||||||
if (failures >= 1) {
|
if (failures >= 1) {
|
||||||
return {success: false, message: 'Action failed, agent would not write code.', interrupted: false, timedout: false};
|
return {success: false, message: 'Action failed, agent would not write code.', interrupted: false, timedout: false};
|
||||||
}
|
}
|
||||||
|
@ -129,7 +124,7 @@ export class Coder {
|
||||||
failures++;
|
failures++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let code = res.substring(res.indexOf('```')+3, res.lastIndexOf('```'));
|
code = res.substring(res.indexOf('```')+3, res.lastIndexOf('```'));
|
||||||
|
|
||||||
const execution_file = await this.stageCode(code);
|
const execution_file = await this.stageCode(code);
|
||||||
if (!execution_file) {
|
if (!execution_file) {
|
||||||
|
@ -144,13 +139,18 @@ export class Coder {
|
||||||
return {success: false, message: null, interrupted: true, timedout: false};
|
return {success: false, message: null, interrupted: true, timedout: false};
|
||||||
console.log("Code generation result:", code_return.success, code_return.message);
|
console.log("Code generation result:", code_return.success, code_return.message);
|
||||||
|
|
||||||
|
if (code_return.success) {
|
||||||
|
const summary = "Summary of newAction\nAgent wrote this code: \n```" + this.sanitizeCode(code) + "```\nCode Output:\n" + code_return.message;
|
||||||
|
return {success: true, message: summary, interrupted: false, timedout: false};
|
||||||
|
}
|
||||||
|
|
||||||
messages.push({
|
messages.push({
|
||||||
role: 'assistant',
|
role: 'assistant',
|
||||||
content: res
|
content: res
|
||||||
});
|
});
|
||||||
messages.push({
|
messages.push({
|
||||||
role: 'system',
|
role: 'system',
|
||||||
content: code_return.message
|
content: code_return.message + '\nCode failed. Please try again:'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return {success: false, message: null, interrupted: false, timedout: true};
|
return {success: false, message: null, interrupted: false, timedout: true};
|
||||||
|
@ -161,7 +161,7 @@ export class Coder {
|
||||||
this.resume_func = func;
|
this.resume_func = func;
|
||||||
this.resume_name = name;
|
this.resume_name = name;
|
||||||
}
|
}
|
||||||
if (this.resume_func != null && this.agent.isIdle()) {
|
if (this.resume_func != null && this.agent.isIdle() && !this.agent.self_prompter.on) {
|
||||||
console.log('resuming code...')
|
console.log('resuming code...')
|
||||||
this.interruptible = true;
|
this.interruptible = true;
|
||||||
let res = await this.execute(this.resume_func, timeout);
|
let res = await this.execute(this.resume_func, timeout);
|
||||||
|
|
|
@ -37,7 +37,19 @@ export const actionsList = [
|
||||||
agent.coder.clear();
|
agent.coder.clear();
|
||||||
agent.coder.cancelResume();
|
agent.coder.cancelResume();
|
||||||
agent.bot.emit('idle');
|
agent.bot.emit('idle');
|
||||||
return 'Agent stopped.';
|
let msg = 'Agent stopped.';
|
||||||
|
if (agent.self_prompter.on)
|
||||||
|
msg += ' Self-prompting still active.';
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '!stfu',
|
||||||
|
description: 'Stop all chatting and self prompting, but continue current action.',
|
||||||
|
perform: async function (agent) {
|
||||||
|
agent.bot.chat('Shutting up.');
|
||||||
|
agent.shutUp();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -56,23 +68,6 @@ export const actionsList = [
|
||||||
return agent.name + "'s chat history was cleared, starting new conversation from scratch.";
|
return agent.name + "'s chat history was cleared, starting new conversation from scratch.";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: '!setMode',
|
|
||||||
description: 'Set a mode to on or off. A mode is an automatic behavior that constantly checks and responds to the environment.',
|
|
||||||
params: {
|
|
||||||
'mode_name': '(string) The name of the mode to enable.',
|
|
||||||
'on': '(bool) Whether to enable or disable the mode.'
|
|
||||||
},
|
|
||||||
perform: async function (agent, mode_name, on) {
|
|
||||||
const modes = agent.bot.modes;
|
|
||||||
if (!modes.exists(mode_name))
|
|
||||||
return `Mode ${mode_name} does not exist.` + modes.getStr();
|
|
||||||
if (modes.isOn(mode_name) === on)
|
|
||||||
return `Mode ${mode_name} is already ${on ? 'on' : 'off'}.`;
|
|
||||||
modes.setOn(mode_name, on);
|
|
||||||
return `Mode ${mode_name} is now ${on ? 'on' : 'off'}.`;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: '!goToPlayer',
|
name: '!goToPlayer',
|
||||||
description: 'Go to the given player.',
|
description: 'Go to the given player.',
|
||||||
|
@ -95,6 +90,18 @@ export const actionsList = [
|
||||||
await skills.followPlayer(agent.bot, player_name, follow_dist);
|
await skills.followPlayer(agent.bot, player_name, follow_dist);
|
||||||
}, -1, 'followPlayer')
|
}, -1, 'followPlayer')
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: '!goToBlock',
|
||||||
|
description: 'Go to the nearest block of a given type.',
|
||||||
|
params: {
|
||||||
|
'type': '(string) The block type to go to.',
|
||||||
|
'closeness': '(number) How close to get to the block.',
|
||||||
|
'search_range': '(number) The distance to search for the block.'
|
||||||
|
},
|
||||||
|
perform: wrapExecution(async (agent, type, closeness, range) => {
|
||||||
|
await skills.goToNearestBlock(agent.bot, type, closeness, range);
|
||||||
|
})
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: '!moveAway',
|
name: '!moveAway',
|
||||||
description: 'Move away from the current location in any direction by a given distance.',
|
description: 'Move away from the current location in any direction by a given distance.',
|
||||||
|
@ -110,6 +117,7 @@ export const actionsList = [
|
||||||
perform: async function (agent, name) {
|
perform: async function (agent, name) {
|
||||||
const pos = agent.bot.entity.position;
|
const pos = agent.bot.entity.position;
|
||||||
agent.memory_bank.rememberPlace(name, pos.x, pos.y, pos.z);
|
agent.memory_bank.rememberPlace(name, pos.x, pos.y, pos.z);
|
||||||
|
return `Location saved as "${name}".`;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -178,9 +186,18 @@ export const actionsList = [
|
||||||
'item_name': '(string) The name of the input item to smelt.',
|
'item_name': '(string) The name of the input item to smelt.',
|
||||||
'num': '(number) The number of times to smelt the item.'
|
'num': '(number) The number of times to smelt the item.'
|
||||||
},
|
},
|
||||||
perform: wrapExecution(async (agent, recipe_name, num) => {
|
perform: async function (agent, item_name, num) {
|
||||||
await skills.smeltItem(agent.bot, recipe_name, num);
|
let response = await wrapExecution(async (agent) => {
|
||||||
})
|
console.log('smelting item');
|
||||||
|
return await skills.smeltItem(agent.bot, item_name, num);
|
||||||
|
})(agent);
|
||||||
|
if (response.indexOf('Successfully') !== -1) {
|
||||||
|
// there is a bug where the bot's inventory is not updated after smelting
|
||||||
|
// only updates after a restart
|
||||||
|
agent.cleanKill(response + ' Safely restarting to update inventory.');
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '!placeHere',
|
name: '!placeHere',
|
||||||
|
@ -221,9 +238,44 @@ export const actionsList = [
|
||||||
await skills.stay(agent.bot);
|
await skills.stay(agent.bot);
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: '!setMode',
|
||||||
|
description: 'Set a mode to on or off. A mode is an automatic behavior that constantly checks and responds to the environment.',
|
||||||
|
params: {
|
||||||
|
'mode_name': '(string) The name of the mode to enable.',
|
||||||
|
'on': '(bool) Whether to enable or disable the mode.'
|
||||||
|
},
|
||||||
|
perform: async function (agent, mode_name, on) {
|
||||||
|
const modes = agent.bot.modes;
|
||||||
|
if (!modes.exists(mode_name))
|
||||||
|
return `Mode ${mode_name} does not exist.` + modes.getDocs();
|
||||||
|
if (modes.isOn(mode_name) === on)
|
||||||
|
return `Mode ${mode_name} is already ${on ? 'on' : 'off'}.`;
|
||||||
|
modes.setOn(mode_name, on);
|
||||||
|
return `Mode ${mode_name} is now ${on ? 'on' : 'off'}.`;
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: '!goal',
|
name: '!goal',
|
||||||
description: 'Set a goal to automatically work towards.',
|
description: 'Set a goal prompt to endlessly work towards with continuous self-prompting.',
|
||||||
|
params: {
|
||||||
|
'selfPrompt': '(string) The goal prompt.',
|
||||||
|
},
|
||||||
|
perform: async function (agent, prompt) {
|
||||||
|
agent.self_prompter.start(prompt); // don't await, don't return
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '!endGoal',
|
||||||
|
description: 'Call when you have accomplished your goal. It will stop self-prompting and the current action. ',
|
||||||
|
perform: async function (agent) {
|
||||||
|
agent.self_prompter.stop();
|
||||||
|
return 'Self-prompting stopped.';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '!npcGoal',
|
||||||
|
description: 'Set a simple goal for an item or building to automatically work towards. Do not use for complex goals.',
|
||||||
params: {
|
params: {
|
||||||
'name': '(string) The name of the goal to set. Can be item or building name. If empty will automatically choose a goal.',
|
'name': '(string) The name of the goal to set. Can be item or building name. If empty will automatically choose a goal.',
|
||||||
'quantity': '(number) The quantity of the goal to set. Default is 1.'
|
'quantity': '(number) The quantity of the goal to set. Default is 1.'
|
||||||
|
@ -231,7 +283,7 @@ export const actionsList = [
|
||||||
perform: async function (agent, name=null, quantity=1) {
|
perform: async function (agent, name=null, quantity=1) {
|
||||||
await agent.npc.setGoal(name, quantity);
|
await agent.npc.setGoal(name, quantity);
|
||||||
agent.bot.emit('idle'); // to trigger the goal
|
agent.bot.emit('idle'); // to trigger the goal
|
||||||
return 'Set goal: ' + agent.npc.data.curr_goal.name;
|
return 'Set npc goal: ' + agent.npc.data.curr_goal.name;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
|
@ -68,6 +68,10 @@ export function truncCommandMessage(message) {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isAction(name) {
|
||||||
|
return actionsList.find(action => action.name === name) !== undefined;
|
||||||
|
}
|
||||||
|
|
||||||
function numParams(command) {
|
function numParams(command) {
|
||||||
if (!command.params)
|
if (!command.params)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -44,6 +44,8 @@ export const queryList = [
|
||||||
if (other_players.length > 0) {
|
if (other_players.length > 0) {
|
||||||
res += '\n- Other Players: ' + other_players.join(', ');
|
res += '\n- Other Players: ' + other_players.join(', ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
res += '\n' + agent.bot.modes.getMiniDocs() + '\n';
|
||||||
return pad(res);
|
return pad(res);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -62,7 +64,7 @@ export const queryList = [
|
||||||
res += ': none';
|
res += ': none';
|
||||||
}
|
}
|
||||||
else if (agent.bot.game.gameMode === 'creative') {
|
else if (agent.bot.game.gameMode === 'creative') {
|
||||||
res += '\n(You have infinite items in creative mode)';
|
res += '\n(You have infinite items in creative mode. You do not need to gather resources!!)';
|
||||||
}
|
}
|
||||||
return pad(res);
|
return pad(res);
|
||||||
}
|
}
|
||||||
|
@ -122,9 +124,9 @@ export const queryList = [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "!modes",
|
name: "!modes",
|
||||||
description: "Get all available modes and see which are on/off.",
|
description: "Get all available modes and their docs and see which are on/off.",
|
||||||
perform: function (agent) {
|
perform: function (agent) {
|
||||||
return agent.bot.modes.getStr();
|
return agent.bot.modes.getDocs();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -61,6 +61,9 @@ export class History {
|
||||||
const memory_bank = this.agent.memory_bank.getJson();
|
const memory_bank = this.agent.memory_bank.getJson();
|
||||||
if (memory_bank !== null)
|
if (memory_bank !== null)
|
||||||
data.memory_bank = memory_bank;
|
data.memory_bank = memory_bank;
|
||||||
|
if (this.agent.self_prompter.on) {
|
||||||
|
data.self_prompt = this.agent.self_prompter.prompt;
|
||||||
|
}
|
||||||
const json_data = JSON.stringify(data, null, 4);
|
const json_data = JSON.stringify(data, null, 4);
|
||||||
writeFileSync(this.memory_fp, json_data, (err) => {
|
writeFileSync(this.memory_fp, json_data, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -82,9 +85,11 @@ export class History {
|
||||||
if (obj.memory_bank)
|
if (obj.memory_bank)
|
||||||
this.agent.memory_bank.loadJson(obj.memory_bank);
|
this.agent.memory_bank.loadJson(obj.memory_bank);
|
||||||
this.turns = obj.turns;
|
this.turns = obj.turns;
|
||||||
|
return obj;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(`Error reading ${this.name}'s memory file: ${err.message}`);
|
console.error(`Error reading ${this.name}'s memory file: ${err.message}`);
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
|
|
|
@ -44,13 +44,17 @@ export async function craftRecipe(bot, itemName, num=1) {
|
||||||
**/
|
**/
|
||||||
let placedTable = false;
|
let placedTable = false;
|
||||||
|
|
||||||
|
if (itemName.endsWith('plank'))
|
||||||
|
itemName += 's'; // catches common mistakes like "oak_plank" instead of "oak_planks"
|
||||||
|
|
||||||
// get recipes that don't require a crafting table
|
// get recipes that don't require a crafting table
|
||||||
let recipes = bot.recipesFor(mc.getItemId(itemName), null, 1, null);
|
let recipes = bot.recipesFor(mc.getItemId(itemName), null, 1, null);
|
||||||
let craftingTable = null;
|
let craftingTable = null;
|
||||||
|
const craftingTableRange = 32;
|
||||||
if (!recipes || recipes.length === 0) {
|
if (!recipes || recipes.length === 0) {
|
||||||
|
|
||||||
// Look for crafting table
|
// Look for crafting table
|
||||||
craftingTable = world.getNearestBlock(bot, 'crafting_table', 8);
|
craftingTable = world.getNearestBlock(bot, 'crafting_table', craftingTableRange);
|
||||||
if (craftingTable === null){
|
if (craftingTable === null){
|
||||||
|
|
||||||
// Try to place crafting table
|
// Try to place crafting table
|
||||||
|
@ -58,7 +62,7 @@ export async function craftRecipe(bot, itemName, num=1) {
|
||||||
if (hasTable) {
|
if (hasTable) {
|
||||||
let pos = world.getNearestFreeSpace(bot, 1, 6);
|
let pos = world.getNearestFreeSpace(bot, 1, 6);
|
||||||
await placeBlock(bot, 'crafting_table', pos.x, pos.y, pos.z);
|
await placeBlock(bot, 'crafting_table', pos.x, pos.y, pos.z);
|
||||||
craftingTable = world.getNearestBlock(bot, 'crafting_table', 8);
|
craftingTable = world.getNearestBlock(bot, 'crafting_table', craftingTableRange);
|
||||||
if (craftingTable) {
|
if (craftingTable) {
|
||||||
recipes = bot.recipesFor(mc.getItemId(itemName), null, 1, craftingTable);
|
recipes = bot.recipesFor(mc.getItemId(itemName), null, 1, craftingTable);
|
||||||
placedTable = true;
|
placedTable = true;
|
||||||
|
@ -81,6 +85,10 @@ export async function craftRecipe(bot, itemName, num=1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (craftingTable && bot.entity.position.distanceTo(craftingTable.position) > 4) {
|
||||||
|
await goToNearestBlock(bot, 'crafting_table', 4, craftingTableRange);
|
||||||
|
}
|
||||||
|
|
||||||
const recipe = recipes[0];
|
const recipe = recipes[0];
|
||||||
console.log('crafting...');
|
console.log('crafting...');
|
||||||
await bot.craft(recipe, num, craftingTable);
|
await bot.craft(recipe, num, craftingTable);
|
||||||
|
@ -111,14 +119,15 @@ export async function smeltItem(bot, itemName, num=1) {
|
||||||
|
|
||||||
let placedFurnace = false;
|
let placedFurnace = false;
|
||||||
let furnaceBlock = undefined;
|
let furnaceBlock = undefined;
|
||||||
furnaceBlock = world.getNearestBlock(bot, 'furnace', 6);
|
const furnaceRange = 32;
|
||||||
|
furnaceBlock = world.getNearestBlock(bot, 'furnace', furnaceRange);
|
||||||
if (!furnaceBlock){
|
if (!furnaceBlock){
|
||||||
// Try to place furnace
|
// Try to place furnace
|
||||||
let hasFurnace = world.getInventoryCounts(bot)['furnace'] > 0;
|
let hasFurnace = world.getInventoryCounts(bot)['furnace'] > 0;
|
||||||
if (hasFurnace) {
|
if (hasFurnace) {
|
||||||
let pos = world.getNearestFreeSpace(bot, 1, 6);
|
let pos = world.getNearestFreeSpace(bot, 1, furnaceRange);
|
||||||
await placeBlock(bot, 'furnace', pos.x, pos.y, pos.z);
|
await placeBlock(bot, 'furnace', pos.x, pos.y, pos.z);
|
||||||
furnaceBlock = world.getNearestBlock(bot, 'furnace', 6);
|
furnaceBlock = world.getNearestBlock(bot, 'furnace', furnaceRange);
|
||||||
placedFurnace = true;
|
placedFurnace = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,6 +135,9 @@ export async function smeltItem(bot, itemName, num=1) {
|
||||||
log(bot, `There is no furnace nearby and you have no furnace.`)
|
log(bot, `There is no furnace nearby and you have no furnace.`)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (bot.entity.position.distanceTo(furnaceBlock.position) > 4) {
|
||||||
|
await goToNearestBlock(bot, 'furnace', 4, furnaceRange);
|
||||||
|
}
|
||||||
await bot.lookAt(furnaceBlock.position);
|
await bot.lookAt(furnaceBlock.position);
|
||||||
|
|
||||||
console.log('smelting...');
|
console.log('smelting...');
|
||||||
|
@ -352,6 +364,8 @@ export async function collectBlock(bot, blockType, num=1, exclude=null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let blocktypes = [blockType];
|
let blocktypes = [blockType];
|
||||||
|
if (blockType === 'coal' || blockType === 'diamond' || blockType === 'emerald' || blockType === 'iron' || blockType === 'gold' || blockType === 'lapis_lazuli' || blockType === 'redstone')
|
||||||
|
blocktypes.push(blockType+'_ore');
|
||||||
if (blockType.endsWith('ore'))
|
if (blockType.endsWith('ore'))
|
||||||
blocktypes.push('deepslate_'+blockType);
|
blocktypes.push('deepslate_'+blockType);
|
||||||
if (blockType === 'dirt')
|
if (blockType === 'dirt')
|
||||||
|
@ -625,7 +639,7 @@ export async function placeBlock(bot, blockType, x, y, z, placeOn='bottom', dont
|
||||||
// will throw error if an entity is in the way, and sometimes even if the block was placed
|
// will throw error if an entity is in the way, and sometimes even if the block was placed
|
||||||
try {
|
try {
|
||||||
await bot.placeBlock(buildOffBlock, faceVec);
|
await bot.placeBlock(buildOffBlock, faceVec);
|
||||||
log(bot, `Successfully placed ${blockType} at ${target_dest}.`);
|
log(bot, `Placed ${blockType} at ${target_dest}.`);
|
||||||
await new Promise(resolve => setTimeout(resolve, 200));
|
await new Promise(resolve => setTimeout(resolve, 200));
|
||||||
return true;
|
return true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -765,6 +779,32 @@ export async function goToPosition(bot, x, y, z, min_distance=2) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function goToNearestBlock(bot, blockType, min_distance=2, range=64) {
|
||||||
|
/**
|
||||||
|
* Navigate to the nearest block of the given type.
|
||||||
|
* @param {MinecraftBot} bot, reference to the minecraft bot.
|
||||||
|
* @param {string} blockType, the type of block to navigate to.
|
||||||
|
* @param {number} min_distance, the distance to keep from the block. Defaults to 2.
|
||||||
|
* @param {number} range, the range to look for the block. Defaults to 64.
|
||||||
|
* @returns {Promise<boolean>} true if the block was reached, false otherwise.
|
||||||
|
* @example
|
||||||
|
* await skills.goToNearestBlock(bot, "oak_log", 64, 2);
|
||||||
|
* **/
|
||||||
|
const MAX_RANGE = 512;
|
||||||
|
if (range > MAX_RANGE) {
|
||||||
|
log(bot, `Maximum search range capped at ${MAX_RANGE}. `);
|
||||||
|
range = MAX_RANGE;
|
||||||
|
}
|
||||||
|
let block = world.getNearestBlock(bot, blockType, range);
|
||||||
|
if (!block) {
|
||||||
|
log(bot, `Could not find any ${blockType} in ${range} blocks.`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
log(bot, `Found ${blockType} at ${block.position}.`);
|
||||||
|
await goToPosition(bot, block.position.x, block.position.y, block.position.z, min_distance);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
export async function goToPlayer(bot, username, distance=3) {
|
export async function goToPlayer(bot, username, distance=3) {
|
||||||
/**
|
/**
|
||||||
|
@ -819,6 +859,10 @@ export async function followPlayer(bot, username, distance=4) {
|
||||||
|
|
||||||
while (!bot.interrupt_code) {
|
while (!bot.interrupt_code) {
|
||||||
await new Promise(resolve => setTimeout(resolve, 500));
|
await new Promise(resolve => setTimeout(resolve, 500));
|
||||||
|
// in cheat mode, if the distance is too far, teleport to the player
|
||||||
|
if (bot.modes.isOn('cheat') && bot.entity.position.distanceTo(player.position) > 100 && player.isOnGround) {
|
||||||
|
await goToPlayer(bot, username);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -839,6 +883,7 @@ export async function moveAway(bot, distance) {
|
||||||
bot.pathfinder.setMovements(new pf.Movements(bot));
|
bot.pathfinder.setMovements(new pf.Movements(bot));
|
||||||
|
|
||||||
if (bot.modes.isOn('cheat')) {
|
if (bot.modes.isOn('cheat')) {
|
||||||
|
const move = new pf.Movements(bot);
|
||||||
const path = await bot.pathfinder.getPathTo(move, inverted_goal, 10000);
|
const path = await bot.pathfinder.getPathTo(move, inverted_goal, 10000);
|
||||||
let last_move = path.path[path.path.length-1];
|
let last_move = path.path[path.path.length-1];
|
||||||
console.log(last_move);
|
console.log(last_move);
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
import * as skills from './library/skills.js';
|
import * as skills from './library/skills.js';
|
||||||
import * as world from './library/world.js';
|
import * as world from './library/world.js';
|
||||||
import * as mc from '../utils/mcdata.js';
|
import * as mc from '../utils/mcdata.js';
|
||||||
|
import settings from '../../settings.js'
|
||||||
|
|
||||||
|
function say(agent, message) {
|
||||||
|
if (agent.shut_up || !settings.narrate_behavior) return;
|
||||||
|
agent.bot.chat(message);
|
||||||
|
}
|
||||||
|
|
||||||
// a mode is a function that is called every tick to respond immediately to the world
|
// a mode is a function that is called every tick to respond immediately to the world
|
||||||
// it has the following fields:
|
// it has the following fields:
|
||||||
|
@ -41,13 +46,13 @@ const modes = [
|
||||||
}
|
}
|
||||||
else if (block.name === 'lava' || block.name === 'flowing_lava' || block.name === 'fire' ||
|
else if (block.name === 'lava' || block.name === 'flowing_lava' || block.name === 'fire' ||
|
||||||
blockAbove.name === 'lava' || blockAbove.name === 'flowing_lava' || blockAbove.name === 'fire') {
|
blockAbove.name === 'lava' || blockAbove.name === 'flowing_lava' || blockAbove.name === 'fire') {
|
||||||
bot.chat('I\'m on fire!'); // TODO: gets stuck in lava
|
say(agent, 'I\'m on fire!'); // TODO: gets stuck in lava
|
||||||
execute(this, agent, async () => {
|
execute(this, agent, async () => {
|
||||||
let nearestWater = world.getNearestBlock(bot, 'water', 20);
|
let nearestWater = world.getNearestBlock(bot, 'water', 20);
|
||||||
if (nearestWater) {
|
if (nearestWater) {
|
||||||
const pos = nearestWater.position;
|
const pos = nearestWater.position;
|
||||||
await skills.goToPosition(bot, pos.x, pos.y, pos.z, 0.2);
|
await skills.goToPosition(bot, pos.x, pos.y, pos.z, 0.2);
|
||||||
bot.chat('Ahhhh that\'s better!');
|
say(agent, 'Ahhhh that\'s better!');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
await skills.moveAway(bot, 5);
|
await skills.moveAway(bot, 5);
|
||||||
|
@ -55,7 +60,7 @@ const modes = [
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (Date.now() - bot.lastDamageTime < 3000 && (bot.health < 5 || bot.lastDamageTaken >= bot.health)) {
|
else if (Date.now() - bot.lastDamageTime < 3000 && (bot.health < 5 || bot.lastDamageTaken >= bot.health)) {
|
||||||
bot.chat('I\'m dying!');
|
say(agent, 'I\'m dying!');
|
||||||
execute(this, agent, async () => {
|
execute(this, agent, async () => {
|
||||||
await skills.moveAway(bot, 20);
|
await skills.moveAway(bot, 20);
|
||||||
});
|
});
|
||||||
|
@ -74,7 +79,7 @@ const modes = [
|
||||||
update: async function (agent) {
|
update: async function (agent) {
|
||||||
const enemy = world.getNearestEntityWhere(agent.bot, entity => mc.isHostile(entity), 16);
|
const enemy = world.getNearestEntityWhere(agent.bot, entity => mc.isHostile(entity), 16);
|
||||||
if (enemy && await world.isClearPath(agent.bot, enemy)) {
|
if (enemy && await world.isClearPath(agent.bot, enemy)) {
|
||||||
agent.bot.chat(`Aaa! A ${enemy.name}!`);
|
say(agent, `Aaa! A ${enemy.name}!`);
|
||||||
execute(this, agent, async () => {
|
execute(this, agent, async () => {
|
||||||
await skills.avoidEnemies(agent.bot, 24);
|
await skills.avoidEnemies(agent.bot, 24);
|
||||||
});
|
});
|
||||||
|
@ -90,7 +95,7 @@ const modes = [
|
||||||
update: async function (agent) {
|
update: async function (agent) {
|
||||||
const enemy = world.getNearestEntityWhere(agent.bot, entity => mc.isHostile(entity), 8);
|
const enemy = world.getNearestEntityWhere(agent.bot, entity => mc.isHostile(entity), 8);
|
||||||
if (enemy && await world.isClearPath(agent.bot, enemy)) {
|
if (enemy && await world.isClearPath(agent.bot, enemy)) {
|
||||||
agent.bot.chat(`Fighting ${enemy.name}!`);
|
say(agent, `Fighting ${enemy.name}!`);
|
||||||
execute(this, agent, async () => {
|
execute(this, agent, async () => {
|
||||||
await skills.defendSelf(agent.bot, 8);
|
await skills.defendSelf(agent.bot, 8);
|
||||||
});
|
});
|
||||||
|
@ -107,7 +112,7 @@ const modes = [
|
||||||
const huntable = world.getNearestEntityWhere(agent.bot, entity => mc.isHuntable(entity), 8);
|
const huntable = world.getNearestEntityWhere(agent.bot, entity => mc.isHuntable(entity), 8);
|
||||||
if (huntable && await world.isClearPath(agent.bot, huntable)) {
|
if (huntable && await world.isClearPath(agent.bot, huntable)) {
|
||||||
execute(this, agent, async () => {
|
execute(this, agent, async () => {
|
||||||
agent.bot.chat(`Hunting ${huntable.name}!`);
|
say(agent, `Hunting ${huntable.name}!`);
|
||||||
await skills.attackEntity(agent.bot, huntable);
|
await skills.attackEntity(agent.bot, huntable);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -130,7 +135,7 @@ const modes = [
|
||||||
this.noticed_at = Date.now();
|
this.noticed_at = Date.now();
|
||||||
}
|
}
|
||||||
if (Date.now() - this.noticed_at > this.wait * 1000) {
|
if (Date.now() - this.noticed_at > this.wait * 1000) {
|
||||||
agent.bot.chat(`Picking up ${item.name}!`);
|
say(agent, `Picking up item!`);
|
||||||
this.prev_item = item;
|
this.prev_item = item;
|
||||||
execute(this, agent, async () => {
|
execute(this, agent, async () => {
|
||||||
await skills.pickupNearbyItems(agent.bot);
|
await skills.pickupNearbyItems(agent.bot);
|
||||||
|
@ -210,6 +215,8 @@ const modes = [
|
||||||
];
|
];
|
||||||
|
|
||||||
async function execute(mode, agent, func, timeout=-1) {
|
async function execute(mode, agent, func, timeout=-1) {
|
||||||
|
if (agent.self_prompter.on)
|
||||||
|
agent.self_prompter.stopLoop();
|
||||||
mode.active = true;
|
mode.active = true;
|
||||||
let code_return = await agent.coder.execute(async () => {
|
let code_return = await agent.coder.execute(async () => {
|
||||||
await func();
|
await func();
|
||||||
|
@ -244,8 +251,17 @@ class ModeController {
|
||||||
this.modes_map[mode_name].paused = true;
|
this.modes_map[mode_name].paused = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
getStr() {
|
getMiniDocs() { // no descriptions
|
||||||
let res = 'Available Modes:';
|
let res = 'Agent Modes:';
|
||||||
|
for (let mode of this.modes_list) {
|
||||||
|
let on = mode.on ? 'ON' : 'OFF';
|
||||||
|
res += `\n- ${mode.name}(${on})`;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
getDocs() {
|
||||||
|
let res = 'Agent Modes:';
|
||||||
for (let mode of this.modes_list) {
|
for (let mode of this.modes_list) {
|
||||||
let on = mode.on ? 'ON' : 'OFF';
|
let on = mode.on ? 'ON' : 'OFF';
|
||||||
res += `\n- ${mode.name}(${on}): ${mode.description}`;
|
res += `\n- ${mode.name}(${on}): ${mode.description}`;
|
||||||
|
|
|
@ -124,6 +124,10 @@ export class Prompter {
|
||||||
prompt = prompt.replaceAll('$TO_SUMMARIZE', stringifyTurns(to_summarize));
|
prompt = prompt.replaceAll('$TO_SUMMARIZE', stringifyTurns(to_summarize));
|
||||||
if (prompt.includes('$CONVO'))
|
if (prompt.includes('$CONVO'))
|
||||||
prompt = prompt.replaceAll('$CONVO', 'Recent conversation:\n' + stringifyTurns(messages));
|
prompt = prompt.replaceAll('$CONVO', 'Recent conversation:\n' + stringifyTurns(messages));
|
||||||
|
if (prompt.includes('$SELF_PROMPT')) {
|
||||||
|
let self_prompt = this.agent.self_prompter.on ? `Use this self-prompt to guide your behavior: "${this.agent.self_prompter.prompt}"\n` : '';
|
||||||
|
prompt = prompt.replaceAll('$SELF_PROMPT', self_prompt);
|
||||||
|
}
|
||||||
if (prompt.includes('$LAST_GOALS')) {
|
if (prompt.includes('$LAST_GOALS')) {
|
||||||
let goal_text = '';
|
let goal_text = '';
|
||||||
for (let goal in last_goals) {
|
for (let goal in last_goals) {
|
||||||
|
|
103
src/agent/self_prompter.js
Normal file
103
src/agent/self_prompter.js
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
export class SelfPrompter {
|
||||||
|
constructor(agent) {
|
||||||
|
this.agent = agent;
|
||||||
|
this.on = false;
|
||||||
|
this.loop_active = false;
|
||||||
|
this.interrupt = false;
|
||||||
|
this.prompt = '';
|
||||||
|
this.idle_time = 0;
|
||||||
|
this.cooldown = 2000;
|
||||||
|
}
|
||||||
|
|
||||||
|
start(prompt) {
|
||||||
|
console.log('Self-prompting started.');
|
||||||
|
if (!prompt) {
|
||||||
|
return 'No prompt specified. Ignoring request.';
|
||||||
|
}
|
||||||
|
if (this.on) {
|
||||||
|
this.prompt = prompt;
|
||||||
|
}
|
||||||
|
this.on = true;
|
||||||
|
this.prompt = prompt;
|
||||||
|
this.startLoop();
|
||||||
|
}
|
||||||
|
|
||||||
|
async startLoop() {
|
||||||
|
if (this.loop_active) {
|
||||||
|
console.warn('Self-prompt loop is already active. Ignoring request.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log('starting self-prompt loop')
|
||||||
|
this.loop_active = true;
|
||||||
|
let no_command_count = 0;
|
||||||
|
const MAX_NO_COMMAND = 3;
|
||||||
|
while (!this.interrupt) {
|
||||||
|
let msg = `You are self-prompting with the goal: '${this.prompt}'. Your next response MUST contain a command !withThisSyntax. Respond:`;
|
||||||
|
|
||||||
|
let used_command = await this.agent.handleMessage('system', msg, 1);
|
||||||
|
if (!used_command) {
|
||||||
|
no_command_count++;
|
||||||
|
if (no_command_count >= MAX_NO_COMMAND) {
|
||||||
|
let out = `Agent did not use command in the last ${MAX_NO_COMMAND} auto-prompts. Stopping auto-prompting.`;
|
||||||
|
this.agent.bot.chat(out);
|
||||||
|
console.warn(out);
|
||||||
|
this.on = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
no_command_count = 0;
|
||||||
|
await new Promise(r => setTimeout(r, this.cooldown));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log('self prompt loop stopped')
|
||||||
|
this.loop_active = false;
|
||||||
|
this.interrupt = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
update(delta) {
|
||||||
|
// automatically restarts loop
|
||||||
|
if (this.on && !this.loop_active && !this.interrupt) {
|
||||||
|
if (this.agent.isIdle())
|
||||||
|
this.idle_time += delta;
|
||||||
|
else
|
||||||
|
this.idle_time = 0;
|
||||||
|
|
||||||
|
if (this.idle_time >= this.cooldown) {
|
||||||
|
console.log('Restarting self-prompting...');
|
||||||
|
this.startLoop();
|
||||||
|
this.idle_time = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async stopLoop() {
|
||||||
|
// you can call this without await if you don't need to wait for it to finish
|
||||||
|
console.log('stopping self-prompt loop')
|
||||||
|
this.interrupt = true;
|
||||||
|
while (this.loop_active) {
|
||||||
|
await new Promise(r => setTimeout(r, 500));
|
||||||
|
}
|
||||||
|
this.interrupt = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
async stop(stop_action=true) {
|
||||||
|
this.interrupt = true;
|
||||||
|
if (stop_action)
|
||||||
|
await this.agent.coder.stop();
|
||||||
|
await this.stopLoop();
|
||||||
|
this.on = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
shouldInterrupt(is_self_prompt) { // to be called from handleMessage
|
||||||
|
return is_self_prompt && this.on && this.interrupt;
|
||||||
|
}
|
||||||
|
|
||||||
|
handleUserPromptedCmd(is_self_prompt, is_action) {
|
||||||
|
// if a user messages and the bot responds with an action, stop the self-prompt loop
|
||||||
|
if (!is_self_prompt && is_action) {
|
||||||
|
this.stopLoop();
|
||||||
|
// this stops it from responding from the handlemessage loop and the self-prompt loop at the same time
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -33,6 +33,7 @@ export function strictFormat(turns) {
|
||||||
let messages = [];
|
let messages = [];
|
||||||
let filler = {role: 'user', content: '_'};
|
let filler = {role: 'user', content: '_'};
|
||||||
for (let msg of turns) {
|
for (let msg of turns) {
|
||||||
|
msg.content = msg.content.trim();
|
||||||
if (msg.role === 'system') {
|
if (msg.role === 'system') {
|
||||||
msg.role = 'user';
|
msg.role = 'user';
|
||||||
msg.content = 'SYSTEM: ' + msg.content;
|
msg.content = 'SYSTEM: ' + msg.content;
|
||||||
|
|
Loading…
Add table
Reference in a new issue