44 lines
1.1 KiB
Python
44 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, field
|
|
from typing import TYPE_CHECKING, Any
|
|
|
|
from core.models import Scene
|
|
from runtime.context import TaskContext
|
|
|
|
if TYPE_CHECKING:
|
|
from world.models import WorldState
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class PlannedStep:
|
|
action: str
|
|
description: str
|
|
args: dict[str, Any] = field(default_factory=dict)
|
|
expected_text: str | None = None
|
|
|
|
|
|
class Planner:
|
|
def plan(
|
|
self,
|
|
*,
|
|
goal: str,
|
|
scene: Scene,
|
|
context: TaskContext,
|
|
world: "WorldState | None" = None,
|
|
) -> list[PlannedStep]:
|
|
if context.step_results:
|
|
return []
|
|
return [
|
|
PlannedStep(
|
|
action="describe_screen",
|
|
description=f"Observe current screen for goal: {goal}",
|
|
args={},
|
|
)
|
|
]
|
|
|
|
def goal_reached(self, *, goal: str, scene: Scene, context: TaskContext) -> bool:
|
|
return bool(context.step_results) and all(
|
|
result.success for result in context.step_results
|
|
)
|