TeachReplay hero

TeachReplay

Teach once, replay anywhere.

๐ŸŒ Project website

TeachReplay is a harness-agnostic Teach-by-Demonstration engine: show a workflow once โ€” clicks, typed values, shell commands โ€” and it becomes a reusable, parameterized skill that can be replayed later with different inputs and an explicit success/failure verdict on real computers.

[![TeachReplay demo โ€” teach โ†’ compile โ†’ change parameters โ†’ replay โ†’ success](assets/teachreplay-demo.gif)](assets/teachreplay-demo.mp4) *Teach โ†’ Compile โ†’ change parameters โ†’ Replay โ†’ Success ยท 26 s ยท [watch in HD](assets/teachreplay-demo.mp4)*
--- ## What is TeachReplay? ```text Teach โ†’ Record โ†’ Compile โ†’ Replay โ†’ Verify ``` 1. **Teach** โ€” start a recording and demonstrate the task once on a computer. 2. **Record** โ€” the recorder watches the computer's *semantic* state (URLs, visible text, element roles and values) and diffs it into a versioned trajectory. Password fields stay masked; every value passes secret redaction. 3. **Compile** โ€” a deterministic compiler turns the trajectory into a **parameterized skill**: your demonstrated values become inputs with your values as defaults. GUI steps are grounded semantically (role + name, never raw coordinates); shell commands become real CLI steps with their recorded exit codes. 4. **Replay** โ€” the engine re-snapshots per step, matches targets semantically, acts, and verifies each step's effect. One bounded retry, an optional model-assisted recovery hook, then **explicit failure**. 5. **Verify** โ€” success requires the recorded condition (URL or confirmation text) to hold. "The engine stopped" is never success. ## Package overview | Package | Purpose | | --- | --- | | [`@teachreplay/core`](packages/core) | trajectory schema ยท recorder ยท parameterized skill compiler ยท parameter substitution ยท replay engine ยท verifier ยท file stores ยท `createTeachRuntime` orchestration | | [`@teachreplay/remote`](packages/remote) | generic SSH Linux computer backend (Xvfb + Chrome DevTools) with GUI + shell channels โ€” not provider-specific | | [`@teachreplay/mock`](packages/mock) | deterministic in-memory demo computer for tests and local demos | | [`@teachreplay/adapter-dsh`](packages/adapter-dsh) | DeepSeek Harness plugin registering `teach_*` tools | ## Architecture The core owns all Teach-by-Demonstration logic and depends on **nothing but Node.js** โ€” an enforced invariant ([independence test](packages/core/test/independence.test.ts)). Adapters contribute only backends, stores, and event sinks: | Integration | Status | | --- | --- | | **Standalone** (`createTeachRuntime` + file stores + mock/remote backends) | โœ… included โ€” see the [standalone demo](examples/standalone-demo) | | **OpenMausBot** ([TeachReplay-OpenMausBot](https://github.com/Ottohere-Mourn/TeachReplay-OpenMausBot)) | โœ… thin adapter โ€” the v0.1 integration rebuilt on the core | | **DeepSeek Harness** ([deepseek-ai/deepseek-harness](https://github.com/deepseek-ai/deepseek-harness)) | โœ… adapter targets the real DSH plugin API โ€” see below | ## TeachReplay for DeepSeek Harness [`@teachreplay/adapter-dsh`](packages/adapter-dsh) adds teach-by-demonstration tools to [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) agents: `teach_start` / `teach_stop` / `teach_compile` / `teach_replay` / `teach_shell` โ€” the same Record โ†’ Compile โ†’ Replay โ†’ Verify engine, no core logic duplicated. - **Targets the real DSH plugin API**: `@deepseek-ai/cordis` / `@deepseek-ai/dsh-tools` are `peerDependencies`, pinned as `devDependencies` (`4.0.1` / `0.1.1-rc.2`, the exact pair DSH resolves at `dsh-v0.1.1-rc.2`) so this repo's own build compiles the plugin against the real `defineTool`/`Plugin.Object` types โ€” no local shims. A prior DSH-native rewrite verified inside a full DSH workspace checkout (see the [adapter README](packages/adapter-dsh/README.md#supported-version)) is what this version is based on - **Installation**: `pnpm add @teachreplay/adapter-dsh` โ€” DSH's sub-packages are published to npm under the `next` dist-tag while DSH is in developer preview; see the [adapter README](packages/adapter-dsh/README.md) (โš ๏ธ DSH is in developer preview with compatibility-breaking changes; re-verify per release) - **Demo**: [`examples/dsh-demo`](examples/dsh-demo) runs `teach_start โ†’ demonstrate โ†’ teach_stop โ†’ teach_compile โ†’ change parameters โ†’ teach_replay โ†’ success` locally โ€” against the mock computer through `DshTeachSession` directly, not through DSH's real tool runtime *(DSH does not accept external pull requests while in developer preview โ€” see its own `CONTRIBUTING.md` โ€” so this ships as an independent package rather than an upstream PR.)* ## Quick start ```sh git clone https://github.com/Ottohere-Mourn/TeachReplay.git cd TeachReplay pnpm install pnpm build pnpm demo # standalone: record โ†’ compile โ†’ change parameters โ†’ replay โ†’ verify pnpm test # 50 tests, including the zero-harness-dependency invariant pnpm typecheck ``` The demo runs entirely on the built-in demo computer โ€” no credentials, no network, no harness. ## Real evaluation `scripts/mini-benchmark.mjs` runs 8 tasks / 14 replays against a real remote Linux computer (GUI + CLI, SSH env-configured). Every success is checked against ground truth on the machine, not just the replay's own verdict. Latest real run (results in [`scripts/teach-benchmark-results.json`](scripts/teach-benchmark-results.json)): | Metric | Result | | --- | --- | | Verdicts correct | **14/14** | | Normal replay success | **12/12** | | Changed-parameter replays | **6/6** | | GUI + CLI workflow | success, processed output matches | | Severe UI drift / missing element | **detected as explicit failures (2/2)** | | Ground-truth mismatches | **0** | An honest small-scale sanity check โ€” not a claim of state of the art. ## Limitations - Recording observes **state transitions** (polled, ~500 ms), not input events โ€” very fast actions can coalesce. Slow, deliberate demonstration is the intended input. - Clicks are inferred from state changes; ambiguous transitions record no click rather than a wrong one. - Model-assisted recovery is an optional hook (`ModelBackend`) โ€” adapters wire the agent. - Replay speed is SSH-round-trip bound (~4 s/step on the evaluation box). - DSH is in developer preview with compatibility-breaking changes โ€” re-verify per release. ## Attribution and license Apache-2.0 (see [LICENSE](LICENSE)). TeachReplay was extracted from TeachReplay v0.1, developed inside [OpenMausBot](https://github.com/milind-soni/OpenMausBot) (Apache-2.0) โ€” see [NOTICE](NOTICE) for the derived-work attributions, including the CDP helper derived from OpenMausBot's computer-use tooling. Record-to-skill is not a new idea โ€” TeachReplay's value is the working, verified combination of demonstration โ†’ structured trajectory โ†’ parameterized skill โ†’ executable replay โ†’ explicit verification across GUI + CLI.