Skip to content

Slice 5: record browser tasks with tyto learn - #9

Merged
rvegajr merged 1 commit into
mainfrom
slice-5/recorder
Oct 13, 2026
Merged

rvegajr merged 1 commit into
mainfrom
slice-5/recorder

Conversation

@rvegajr

@rvegajr rvegajr commented Sep 30, 2026

Copy link
Copy Markdown
Member

Stacked on #8. Spec sentences are in docs/IMPLEMENTATION.md §4 Slice 5.

What

tyto learn <name> [--session s] records what an agent does in an agent-browser session, by listening to agent-browser's own event stream (no wrapper or shim). tyto learn status lists the typed inputs by name and field. tyto learn stop <name> --task "…" [--param input_N=name] saves a trace for the compiler (Slice 6).

  • Core
    • actionToArgv maps the stream's internal action names (navigate, getbylabel, waitforurl, …) back to CLI argv. The mapping comes from agent-browser's commands.rs.
    • buildTrace:
      • pairs command and result by id;
      • flags gaps (orphan result, missing result, closed socket) as lossy;
      • replaces typed values with {{input_N}}, or {{param}} when kept;
      • masks password-like fields;
      • reduces cookie and storage values to names and lengths;
      • redacts outputs.
    • Recorder records only after a get url sync marker.
    • New ports BrowserEventSource and TraceStore, with fakes.
  • agent-browser adapter: StreamEventSource mirrors agent-browser's socket-dir rules (AGENT_BROWSER_SOCKET_DIR, then XDG_RUNTIME_DIR, then ~/.agent-browser, with namespaces).
  • store: FileTraceStore (0600).
  • cli:
    • learn start/status/stop;
    • a detached listener that keeps typed values in memory only;
    • control over a unix socket in a 0700 directory.

Found while probing

  • The stream's success field is false even for successful commands, so success is derived from the result's error.
  • Typed values (passwords included) are broadcast in plaintext, so they're masked at build time and never written unless kept.

Tests

  • npm run check: 14 files, 122 tests, typecheck clean, gitleaks clean.
  • npm run test:live: 6 passed. The new test records a real session against a loopback page: 3 steps in CLI form, with only the named input kept.
  • Manual end to end (Wikipedia search, done through plain agent-browser):
    • 6 steps recorded in CLI form, no gaps;
    • the search term kept as {{species}} (example "Snowy owl");
    • snapshot and eval result ("Vulnerable") kept as evidence for the compiler;
    • trace written 0600; the listener exited on stop.

🤖 Generated with Claude Code

`tyto learn <name> [--session s]` records what an agent does in an
agent-browser session; `tyto learn stop <name> --task "…" --param
input_N=name` saves a trace the compiler (next slice) turns into a recipe.

- core: StreamEvent/Trace types; actionToArgv maps agent-browser's
  internal stream actions (navigate, getbylabel, waitforurl, …) back to
  CLI argv; buildTrace pairs command/result by id, flags gaps (orphan
  result, missing result, socket closed) as lossy, replaces typed values
  with {{input_N}} (or {{param}} when kept), masks password-like fields,
  reduces cookie/storage values to names and lengths, and redacts
  outputs. Recorder waits for a `get url` sync marker before recording.
  New ports BrowserEventSource and TraceStore, with fakes.
- agent-browser: StreamEventSource reads <socketDir>/<session>.stream
  (mirrors agent-browser's socket-dir rules) and yields events, dropping
  frames, ending with a closed event.
- store: FileTraceStore (0600).
- cli: learn start/status/stop and a detached listener that keeps typed
  values in memory only, controlled over a unix socket in a 0700 dir.

Found while probing: the stream's `success` is false even for successful
commands, so success comes from the result's error field.

Live: recorded a Wikipedia search → 6 steps in CLI form, the search term
kept as {{species}} (example "Snowy owl"), eval result captured, no gaps.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@rvegajr
rvegajr changed the base branch from slice-4/brief to main October 13, 2026 19:02
@rvegajr
rvegajr merged commit 0408e6b into main Oct 13, 2026
2 checks passed
@rvegajr
rvegajr deleted the slice-5/recorder branch October 13, 2026 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant