Publish tiny_computer_agent_app.py from marimo
Browse files- tiny_computer_agent_app.py +37 -25
tiny_computer_agent_app.py
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import marimo
|
| 2 |
|
| 3 |
__generated_with = "0.25.2"
|
|
@@ -211,7 +218,7 @@ def repo_files():
|
|
| 211 |
|
| 212 |
[project]
|
| 213 |
name = "tiny-computer-agent"
|
| 214 |
-
version = "0.
|
| 215 |
description = "An agentic harness that drives a real computer with a tiny, fully local model - no cloud API."
|
| 216 |
readme = "README.md"
|
| 217 |
requires-python = ">=3.10"
|
|
@@ -227,8 +234,9 @@ def repo_files():
|
|
| 227 |
dependencies = [] # the harness core imports nothing outside the standard library
|
| 228 |
|
| 229 |
[project.optional-dependencies]
|
| 230 |
-
|
| 231 |
-
|
|
|
|
| 232 |
dev = ["pytest>=8"]
|
| 233 |
|
| 234 |
[project.scripts]
|
|
@@ -280,7 +288,8 @@ def repo_files():
|
|
| 280 |
.DS_Store
|
| 281 |
'''
|
| 282 |
|
| 283 |
-
mo.md(f"{len(pyproject_toml) + len(license_txt) + len(gitignore_txt)} chars
|
|
|
|
| 284 |
|
| 285 |
return gitignore_txt, license_txt, pyproject_toml
|
| 286 |
|
|
@@ -368,36 +377,39 @@ def publish_status(
|
|
| 368 |
|
| 369 |
@app.cell
|
| 370 |
def demo():
|
| 371 |
-
from tiny_computer_agent import
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
|
| 386 |
-
|
| 387 |
-
screen=
|
| 388 |
brain=PlannerBrain(),
|
| 389 |
executor=DryRunExecutor(),
|
| 390 |
-
policy=Policy(step_budget=
|
| 391 |
).run("click \'Save\' to save the document")
|
| 392 |
|
|
|
|
|
|
|
| 393 |
mo.vstack(
|
| 394 |
[
|
| 395 |
mo.md(
|
| 396 |
-
"**
|
| 397 |
-
"
|
| 398 |
),
|
| 399 |
-
mo.ui.table(
|
| 400 |
-
mo.md(f"`{
|
|
|
|
| 401 |
]
|
| 402 |
)
|
| 403 |
|
|
|
|
| 1 |
+
# /// script
|
| 2 |
+
# requires-python = ">=3.13"
|
| 3 |
+
# dependencies = [
|
| 4 |
+
# "rapidocr-onnxruntime==1.4.4",
|
| 5 |
+
# ]
|
| 6 |
+
# ///
|
| 7 |
+
|
| 8 |
import marimo
|
| 9 |
|
| 10 |
__generated_with = "0.25.2"
|
|
|
|
| 218 |
|
| 219 |
[project]
|
| 220 |
name = "tiny-computer-agent"
|
| 221 |
+
version = "0.2.0"
|
| 222 |
description = "An agentic harness that drives a real computer with a tiny, fully local model - no cloud API."
|
| 223 |
readme = "README.md"
|
| 224 |
requires-python = ">=3.10"
|
|
|
|
| 234 |
dependencies = [] # the harness core imports nothing outside the standard library
|
| 235 |
|
| 236 |
[project.optional-dependencies]
|
| 237 |
+
ocr = ["rapidocr-onnxruntime>=1.3"] # labels from pixels, no system binary
|
| 238 |
+
desktop = ["mss>=9.0", "pyautogui>=0.9", "pillow>=10"] # capture + real input
|
| 239 |
+
vision = ["transformers>=4.48", "torch>=2.2", "pillow>=10"] # tiny model brains
|
| 240 |
dev = ["pytest>=8"]
|
| 241 |
|
| 242 |
[project.scripts]
|
|
|
|
| 288 |
.DS_Store
|
| 289 |
'''
|
| 290 |
|
| 291 |
+
mo.md(f"packaging: {len(pyproject_toml) + len(license_txt) + len(gitignore_txt)} chars, "
|
| 292 |
+
f"v0.2.0 with ocr/desktop/vision extras")
|
| 293 |
|
| 294 |
return gitignore_txt, license_txt, pyproject_toml
|
| 295 |
|
|
|
|
| 377 |
|
| 378 |
@app.cell
|
| 379 |
def demo():
|
| 380 |
+
from tiny_computer_agent import AgentLoop, DryRunExecutor, PlannerBrain, Policy
|
| 381 |
+
from tiny_computer_agent.demo import fake_desktop
|
| 382 |
+
from tiny_computer_agent.observe import ImageScreen
|
| 383 |
+
from tiny_computer_agent.perception import IndexedScreen, OcrDetector
|
| 384 |
+
|
| 385 |
+
# A real screenshot -> real OCR -> labelled, clickable elements. No display needed:
|
| 386 |
+
# this is the same path --image takes, and it is what makes a tiny model viable.
|
| 387 |
+
_detector = OcrDetector()
|
| 388 |
+
_observation = IndexedScreen(ImageScreen(fake_desktop()), _detector).capture()
|
| 389 |
+
|
| 390 |
+
perception_rows = [
|
| 391 |
+
{"label": e.label, "kind": e.kind, "x": e.x, "y": e.y, "w": e.width, "h": e.height}
|
| 392 |
+
for e in _observation.elements
|
| 393 |
+
]
|
| 394 |
|
| 395 |
+
perception_episode = AgentLoop(
|
| 396 |
+
screen=IndexedScreen(ImageScreen(fake_desktop()), _detector),
|
| 397 |
brain=PlannerBrain(),
|
| 398 |
executor=DryRunExecutor(),
|
| 399 |
+
policy=Policy(step_budget=4),
|
| 400 |
).run("click \'Save\' to save the document")
|
| 401 |
|
| 402 |
+
_clicked = next((s.result.note for s in perception_episode.steps if s.action and s.action.kind == "click"), "n/a")
|
| 403 |
+
|
| 404 |
mo.vstack(
|
| 405 |
[
|
| 406 |
mo.md(
|
| 407 |
+
f"**Perception, from pixels.** OCR read **{len(perception_rows)} labels** off a "
|
| 408 |
+
f"synthetic screenshot; the planner then chose one and the harness resolved it to a real pixel."
|
| 409 |
),
|
| 410 |
+
mo.ui.table(perception_rows, selection=None),
|
| 411 |
+
mo.md(f"`{_clicked}`"),
|
| 412 |
+
mo.md(f"`{perception_episode.render().splitlines()[1]}`"),
|
| 413 |
]
|
| 414 |
)
|
| 415 |
|