localharness 0.78.0

Agents that own themselves: one Rust crate that's both an agent SDK (streaming, tools, hooks, policies, triggers, MCP) and a wallet-owning, self-sovereign agent that runs in the browser.
Documentation
1
2
3
4
5
6
7
8
9
10
11
{
  "id": "295",
  "prompt": "Quiz me: three multiple-choice questions with three answers each - draw_string only accepts literals, so route the per-question text through if/else helper fns and the correct answer index through a match. Tapping an answer row scores it with a green CORRECT or red WRONG flash and advances; after question 3 show the score OF 3, a rank line picked from the score, and tap-to-restart. Progress header up top, every tap edge-detected.",
  "solution_rl": "fn correct_of(qi: i32) -> i32 {\n    match qi {\n        0 => 0,\n        1 => 1,\n        _ => 0,\n    }\n}\n\nfn draw_question(qi: i32) {\n    if qi == 0 {\n        host::display::draw_string(76, 80, \"2 + 2 * 2 = ?\", 0xffffff, 2);\n    } else if qi == 1 {\n        host::display::draw_string(76, 80, \"BITS IN ONE BYTE?\", 0xffffff, 2);\n    } else {\n        host::display::draw_string(76, 80, \"HEX FF IN DECIMAL?\", 0xffffff, 2);\n    }\n}\n\nfn draw_answer(qi: i32, a: i32, x: i32, y: i32) {\n    if qi == 0 {\n        if a == 0 {\n            host::display::draw_string(x, y, \"6\", 0xffffff, 2);\n        } else if a == 1 {\n            host::display::draw_string(x, y, \"8\", 0xffffff, 2);\n        } else {\n            host::display::draw_string(x, y, \"4\", 0xffffff, 2);\n        }\n    } else if qi == 1 {\n        if a == 0 {\n            host::display::draw_string(x, y, \"4\", 0xffffff, 2);\n        } else if a == 1 {\n            host::display::draw_string(x, y, \"8\", 0xffffff, 2);\n        } else {\n            host::display::draw_string(x, y, \"16\", 0xffffff, 2);\n        }\n    } else {\n        if a == 0 {\n            host::display::draw_string(x, y, \"255\", 0xffffff, 2);\n        } else if a == 1 {\n            host::display::draw_string(x, y, \"256\", 0xffffff, 2);\n        } else {\n            host::display::draw_string(x, y, \"128\", 0xffffff, 2);\n        }\n    }\n}\n\nfn frame(t: i32) {\n    host::display::clear(0x0e1013);\n    let down: i32 = host::display::pointer_down();\n    let prev: i32 = host::display::state_get(0);\n    host::display::state_set(0, down);\n    let mut click: i32 = 0;\n    if down == 1 && prev == 0 {\n        click = 1;\n    }\n    let qi: i32 = host::display::state_get(1);\n    let score: i32 = host::display::state_get(2);\n\n    if host::display::state_get(3) == 1 {\n        host::display::draw_string(150, 140, \"QUIZ OVER\", 0xffffff, 3);\n        host::display::draw_number(210, 220, score, 0x66ddff, 5);\n        host::display::draw_string(260, 236, \"OF 3\", 0x8899aa, 2);\n        if score == 3 {\n            host::display::draw_string(180, 320, \"PERFECT RUN\", 0x33ff88, 2);\n        } else if score >= 2 {\n            host::display::draw_string(190, 320, \"NOT BAD\", 0xffcc33, 2);\n        } else {\n            host::display::draw_string(170, 320, \"STUDY UP\", 0xbb5533, 2);\n        }\n        host::display::draw_string(160, 420, \"TAP TO RESTART\", 0x556677, 1);\n        if click == 1 {\n            host::display::state_set(1, 0);\n            host::display::state_set(2, 0);\n            host::display::state_set(3, 0);\n        }\n    } else {\n        host::display::draw_string(76, 30, \"QUESTION\", 0x556677, 1);\n        host::display::draw_number(152, 28, qi + 1, 0xffffff, 1);\n        host::display::draw_string(170, 30, \"OF 3\", 0x556677, 1);\n        draw_question(qi);\n        let mut a: i32 = 0;\n        while a < 3 {\n            let y: i32 = 160 + a * 90;\n            host::display::fill_rect(76, y, 360, 64, 0x1c212b);\n            draw_answer(qi, a, 100, y + 22);\n            a = a + 1;\n        }\n        let flash: i32 = host::display::state_get(4);\n        if flash > 0 {\n            if host::display::state_get(5) == 1 {\n                host::display::draw_string(76, 450, \"CORRECT\", 0x33ff88, 2);\n            } else {\n                host::display::draw_string(76, 450, \"WRONG\", 0xbb3333, 2);\n            }\n            host::display::state_set(4, flash - 1);\n        }\n        if click == 1 {\n            let px: i32 = host::display::pointer_x();\n            let py: i32 = host::display::pointer_y();\n            if px >= 76 && px < 436 && py >= 160 && py < 430 {\n                let pick: i32 = (py - 160) / 90;\n                if pick < 3 && (py - 160) % 90 < 64 {\n                    if pick == correct_of(qi) {\n                        host::display::state_set(2, score + 1);\n                        host::display::state_set(5, 1);\n                    } else {\n                        host::display::state_set(5, 0);\n                    }\n                    host::display::state_set(4, 30);\n                    if qi >= 2 {\n                        host::display::state_set(3, 1);\n                    } else {\n                        host::display::state_set(1, qi + 1);\n                    }\n                }\n            }\n        }\n    }\n    host::display::present();\n}\n",
  "tags": [
    "app",
    "quiz",
    "match",
    "functions"
  ]
}