diff --git a/src/agent/tasks.js b/src/agent/tasks.js index 74f65ae..9e5c9bb 100644 --- a/src/agent/tasks.js +++ b/src/agent/tasks.js @@ -126,16 +126,25 @@ class CookingCraftingTaskValidator { this.data = data; this.agent = agent; } - validate() { - const result = checkItemPresence(this.data, this.agent); - let score = 0; - if (result.success) { - score = 1; + validate(has_initiated) { + if (has_initiated) { + + const result = checkItemPresence(this.data, this.agent); + let score = 0; + if (result.success) { + score = 1; + } + return { + "valid": result.success, + "score": score, + }; + } + else { + return { + "valid": false, + "score": 0 + }; } - return { - "valid": result.success, - "score": score, - }; } } @@ -188,6 +197,7 @@ export class Task { this.name = this.agent.name; this.available_agents = settings.profiles.map((p) => JSON.parse(readFileSync(p, 'utf8')).name); + this.agent_initialized = false; } getAgentGoal() { @@ -239,7 +249,7 @@ export class Task { isDone() { let res = null; if (this.validator) - res = this.validator.validate(); + res = this.validator.validate(this.agent_initialized); if (res && res.valid) { return {"message": 'Task successful', "score": res.score}; } @@ -311,6 +321,8 @@ export class Task { await new Promise((resolve) => setTimeout(resolve, 500)); } + this.agent_initialized = true; + if (this.initiator) { await this.initiator.init(); }