extra refactor cleanup

This commit is contained in:
JurassikLizard 2024-11-03 12:03:56 -05:00
parent 25a0f5c069
commit e13fd4afc4

View file

@ -1,12 +1,12 @@
import * as skills from '../library/skills.js'; import * as skills from '../library/skills.js';
import settings from '../../../settings.js'; import settings from '../../../settings.js';
function runAsAction (taskLabel, actionFn, resume = false, timeout = -1) { function runAsAction (actionLabel, actionFn, resume = false, timeout = -1) {
return async function (agent, ...args) { return async function (agent, ...args) {
const actionFnWithAgent = async () => { const actionFnWithAgent = async () => {
await actionFn(agent, ...args); await actionFn(agent, ...args);
}; };
const code_return = await agent.actions.runAction(`action:${taskLabel}`, actionFnWithAgent, { timeout, resume }); const code_return = await agent.actions.runAction(`action:${actionLabel}`, actionFnWithAgent, { timeout, resume });
if (code_return.interrupted && !code_return.timedout) if (code_return.interrupted && !code_return.timedout)
return; return;
return code_return.message; return code_return.message;
@ -224,7 +224,7 @@ export const actionsList = [
perform: runAsAction('collectAllBlocks', async (agent, type) => { perform: runAsAction('collectAllBlocks', async (agent, type) => {
let success = await skills.collectBlock(agent.bot, type, 1); let success = await skills.collectBlock(agent.bot, type, 1);
if (!success) if (!success)
agent.tasks.cancelResume(); agent.actions.cancelResume();
}, true, 3) // 3 minute timeout }, true, 3) // 3 minute timeout
}, },
{ {