module

Quartz::Agent

Agent: an LLM-driven loop that drives a Flipper via RPC to accomplish a goal.

Protocol: each step the model emits ONE JSON object: {"think": "...", "tool": "<name>", "args": {...}} or: {"think": "...", "done": true, "result": "..."}

Tools surface only safe, scoped operations (no rm, no write, no reboot, no arbitrary shell). Screen is rendered as 64x16 braille so the model can "see" without burning tokens on a 1024-byte XBM dump.

Constants

DEFAULT_MAX_STEPS = (ENV["QUARTZ_AGENT_MAX_STEPS"]? || "20").to_i
PLAN_ACTIONS = ["press", "long", "sleep", "screenshot", "alert", "app_start", "app_load", "app_exit"] of ::String
TOOLS = {"screen" => "capture the Flipper screen and return a 64x16 braille rendering", "press" => "send a short button press: args = {key: up|down|left|right|ok|back}", "long_press" => "send a long press: args = {key: up|down|left|right|ok|back}", "sleep" => "pause: args = {ms: <int>}", "ls" => "list a storage path: args = {path: '/ext'}", "app_start" => "launch a built-in app: args = {name: '...'} (optional args: '...')", "app_load" => "launch a .fap from disk: args = {path: '/ext/apps/...'}", "app_exit" => "ask current app to exit: args = {}", "screenshot" => "save one frame to disk: args = {path: '/tmp/shot.pbm'}", "info" => "report device info: args = {}", "done" => "declare goal completed: {result: 'summary string'}"}

Instance methods

plan(goal : String, backend : String | Nil = nil) : String

Ask the model to propose a macro (step list) for a goal WITHOUT talking to the device. Returns the raw YAML string; caller decides whether to save it or print for review.

Source
run(client : Quartz::RPC::Client, goal : String, opts : Options = Options.default, & : String -> ) : String

Run the agent loop. print is called with each human-readable line of progress so the CLI can decide formatting/colors.

Source
validate_plan(yaml_text : String) : Tuple(String, String, Array(Hash(String, YAML::Any)))

Validate YAML plan text against the Macro action vocabulary. Returns a (name, description, steps) tuple ready for Quartz::Macro.save.

Source

Nested types