hkblockchaintechnology commited on
Commit
ba80edb
·
verified ·
1 Parent(s): 3a6a9f8

Publish tiny_computer_agent_app.py from marimo

Browse files
Files changed (1) hide show
  1. 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.1.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
- desktop = ["mss>=9.0", "pyautogui>=0.9", "pillow>=10"]
231
- vision = ["transformers>=4.48", "torch>=2.2", "pillow>=10"]
 
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 of packaging ready to publish")
 
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
- AgentLoop, DryRunExecutor, Element, FakeScreen, PlannerBrain, Policy,
373
- )
374
-
375
- _scripted_screen = FakeScreen(
376
- [
377
- (Element("Terminal", x=0, y=0, width=40, height=24),
378
- Element("Files", x=60, y=0, width=40, height=24)),
379
- (Element("Name", kind="input", x=100, y=120, width=200, height=24),
380
- Element("Save", x=320, y=120, width=80, height=24)),
381
- (Element("Save", x=320, y=120, width=80, height=24),),
382
- ],
383
- text="Untitled document - unsaved changes",
384
- )
385
 
386
- demo_episode = AgentLoop(
387
- screen=_scripted_screen,
388
  brain=PlannerBrain(),
389
  executor=DryRunExecutor(),
390
- policy=Policy(step_budget=6),
391
  ).run("click \'Save\' to save the document")
392
 
 
 
393
  mo.vstack(
394
  [
395
  mo.md(
396
- "**Scripted episode, dry run** — no model, no display, nothing touched. "
397
- "The planner waits for the dialog, clicks the label, and stops."
398
  ),
399
- mo.ui.table(demo_episode.to_rows(), selection=None),
400
- mo.md(f"`{demo_episode.render().splitlines()[1]}`"),
 
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