Repository navigation
Slice 5: record browser tasks with tyto learn - #9
Merged
Merged
Conversation
`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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 statuslists the typed inputs by name and field.tyto learn stop <name> --task "…" [--param input_N=name]saves a trace for the compiler (Slice 6).actionToArgvmaps the stream's internal action names (navigate,getbylabel,waitforurl, …) back to CLI argv. The mapping comes from agent-browser'scommands.rs.buildTrace:lossy;{{input_N}}, or{{param}}when kept;Recorderrecords only after aget urlsync marker.BrowserEventSourceandTraceStore, with fakes.StreamEventSourcemirrors agent-browser's socket-dir rules (AGENT_BROWSER_SOCKET_DIR, thenXDG_RUNTIME_DIR, then~/.agent-browser, with namespaces).FileTraceStore(0600).Found while probing
successfield isfalseeven for successful commands, so success is derived from the result'serror.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.agent-browser):{{species}}(example "Snowy owl");🤖 Generated with Claude Code