Fix: behaviors.py import Task → PrimaryTask for new task_queue
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
1c8e2a7c90
commit
5297ac664a
1 changed files with 14 additions and 24 deletions
|
|
@ -14,7 +14,7 @@ import random
|
||||||
import time
|
import time
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from dougbot.core.task_queue import Task, Priority
|
from dougbot.core.task_queue import PrimaryTask, SubTask, Priority, make_task
|
||||||
from dougbot.utils.logging import get_logger
|
from dougbot.utils.logging import get_logger
|
||||||
|
|
||||||
log = get_logger("core.behaviors")
|
log = get_logger("core.behaviors")
|
||||||
|
|
@ -278,37 +278,27 @@ class GoalManager:
|
||||||
active.sort(key=lambda g: g["priority"], reverse=True)
|
active.sort(key=lambda g: g["priority"], reverse=True)
|
||||||
return active[0]
|
return active[0]
|
||||||
|
|
||||||
def get_next_step(self, goal: dict, behaviors, memory) -> Task | None:
|
def get_next_step(self, goal: dict, behaviors, memory):
|
||||||
"""Get the next task from a goal's step list."""
|
"""Get the next step from a goal. Returns object with name/action/params/description/timeout."""
|
||||||
if goal["current_step"] >= len(goal["steps"]):
|
if goal["current_step"] >= len(goal["steps"]):
|
||||||
return None # All steps done
|
return None
|
||||||
|
|
||||||
step = goal["steps"][goal["current_step"]]
|
step = goal["steps"][goal["current_step"]]
|
||||||
goal["current_step"] += 1
|
goal["current_step"] += 1
|
||||||
|
|
||||||
# Build the task from the step
|
|
||||||
params = dict(step["params"])
|
params = dict(step["params"])
|
||||||
params.update(goal.get("extra_params", {}))
|
params.update(goal.get("extra_params", {}))
|
||||||
|
|
||||||
# For find_blocks, we need a callback to process the result
|
# Return a simple namespace with the fields the brain expects
|
||||||
if step["action"] == "find_blocks":
|
class StepInfo:
|
||||||
return Task(
|
pass
|
||||||
name=f"goal_{goal['name']}_find",
|
info = StepInfo()
|
||||||
priority=Priority.NORMAL,
|
info.name = f"goal_{goal['name']}_step{goal['current_step']}"
|
||||||
action=step["action"],
|
info.action = step["action"]
|
||||||
params=params,
|
info.params = params
|
||||||
description=step["description"],
|
info.description = step["description"]
|
||||||
timeout=15,
|
info.timeout = 20
|
||||||
)
|
return info
|
||||||
|
|
||||||
return Task(
|
|
||||||
name=f"goal_{goal['name']}_step{goal['current_step']}",
|
|
||||||
priority=Priority.NORMAL,
|
|
||||||
action=step["action"],
|
|
||||||
params=params,
|
|
||||||
description=step["description"],
|
|
||||||
timeout=20,
|
|
||||||
)
|
|
||||||
|
|
||||||
def complete_goal(self, name: str):
|
def complete_goal(self, name: str):
|
||||||
"""Mark a goal as complete."""
|
"""Mark a goal as complete."""
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue