Skip to content

feat(cua-driver): record human demonstrations as skill-ready trajectories - #2016

Open
ddupont808 wants to merge 9 commits into
mainfrom
feat/demonstration-recording
Open

feat(cua-driver): record human demonstrations as skill-ready trajectories#2016
ddupont808 wants to merge 9 commits into
mainfrom
feat/demonstration-recording

Conversation

@ddupont808

@ddupont808 ddupont808 commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

what

adds human demonstration recording to cua-driver on windows:

  1. select a window by pid and window_id;
  2. show a visible red recording border;
  3. capture window-scoped human clicks, scrolls, drags, hotkeys, and text entry;
  4. stop cleanly and produce TRAJECTORY.md, SUMMARY.json, DEMONSTRATION.json, and relative screenshot links;
  5. use the bundled DEMONSTRATION.md guide to turn the artifact into a reusable skill.

architecture

human capture is separate from ordinary trajectory recording:

  • RecordingSession continues to record executable cua-driver tool calls.
  • DemonstrationManager owns one external human capture session, its writer, output directory, and MCP-session ownership.
  • captured observations use human_* action names and are not presented as automatically replayable tool calls.
  • stop_demonstration performs local deterministic processing; cua-driver does not call a model API.

this keeps the public workflow to two tools: start_demonstration and stop_demonstration.

capture and privacy boundaries

  • the supplied HWND must belong to the supplied PID;
  • only input targeting the selected foreground top-level window is accepted;
  • the border hides and capture pauses when that window loses foreground;
  • keyboard and mouse events marked by Windows as injected are ignored;
  • capture uses a bounded, nonblocking event queue;
  • the indicator is created and submits a frame before the input hook is installed;
  • stale indicator rendering blocks input capture;
  • text capture stores only text entered (redacted), without literal text, length, or character classes;
  • raw typed input content is never retained;
  • screenshots can still contain content visible in the target window and must be reviewed before sharing;
  • queue and screenshot failures are counted and mark the result incomplete;
  • reused nonempty output directories are rejected;
  • capture and the indicator stop when requested or when the owning MCP session ends.

this is a user-space recording indicator, not a hardware security LED. it cannot prove that another window or a secure desktop has not obscured it.

scope removed from this draft

  • demonstration flags on ordinary start_recording;
  • automatic conversion of human observations into replayable tool calls;
  • the Anthropic auto-authoring client and ureq dependency;
  • dedicated demonstration CLI wrappers and speculative examples;
  • public gate, indicator, hook, and coalescer APIs;
  • raw-text capture.

verification

passed after rebasing onto current main:

  • cargo test -p input-capture — 11 tests;
  • cargo check -p cua-driver-core --tests;
  • cargo check -p cua-driver;
  • cargo check -p input-capture --target x86_64-pc-windows-msvc;
  • cargo check -p cua-driver-core --target x86_64-pc-windows-msvc;
  • git diff --check.

windows capture is implemented. macOS and Linux return Unsupported for now.

this update preserves Dillon DuPont's original capture, indicator, markdown, and skill-guide contribution and its authorship history while narrowing the implementation to the demonstration-recording workflow.

windows gui verification

Verified on Windows Server 2022. The fixed indicator geometry uses DWMWA_EXTENDED_FRAME_BOUNDS, with GetWindowRect fallback and maximized work-area clamping.

Live GUI sequence: normal window → corner resize → maximize → restore → stop. The border tracked the visible frame, stayed visible on all four maximized edges, and disappeared on stop.

normal corner resize
normal window corner-resized window
maximized restored
maximized window restored window

Demo: 11.87 seconds, H.264, 1280x800, 30 fps.

pr-2016-demonstration-recording-dwm-aligned.mp4
  • cargo test -p input-capture: 14 passed.
  • cargo test -p cua-driver-core demonstration: 9 passed.
  • cargo build -p cua-driver: passed.

This verifies the Windows GUI behavior on normal, resized, maximized, and restored windows.

current-main integration and verification

Rebased onto main at 86e4f8c913521534ea61f0e4639b122ae8ca4a0b on 2026-07-29. The current runtime lifecycle owns demonstration cleanup, and stop_demonstration is scoped to the owning session.

Local verification on the rebased tree:

  • cargo fmt --all --check: passed;
  • cargo check --locked -p cua-driver-core --tests: passed;
  • cargo test -p input-capture: 11 passed;
  • cargo test -p cua-driver-core demonstration --lib: 10 passed;
  • git diff --check: passed.

The identical implementation tree passed Windows and Linux unit/compile, Nix package/policy/unit builds, contract parity on all three platforms, generated bindings, docs, docs links, formatting, SPDX, and release metadata. Contributor attribution was rerun after correcting the integration commit metadata.

@vercel

vercel Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Preview Jun 25, 2026 8:50pm

Request Review

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1d6e4e2e-384b-4995-b3d3-171aa8dc8124

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/demonstration-recording

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Linux visual regression artifacts

Matrix jobs now run independently. Download visual artifacts from this workflow run.
Each background-GUI job uploads a .gif of the interaction plus two annotated PNGs (<app>.png raw, <app>-atspi.png with AT-SPI element boxes); the cua-driver-linux-som-overlays artifact adds <app>-som.png cua Set-of-Marks overlays:

  • cua-driver-linux-cursor-click-gif
  • cua-driver-linux-background-terminal-gif
  • cua-driver-linux-parallel-drag-xserver
  • cua-driver-linux-background-gui-chromium
  • cua-driver-linux-background-gui-tk
  • cua-driver-linux-background-gui-gtk3-gedit
  • cua-driver-linux-background-gui-gtk3-mousepad
  • cua-driver-linux-background-gui-gtk3-scite
  • cua-driver-linux-background-gui-gtk4-characters
  • cua-driver-linux-background-gui-qt5-manuskript
  • cua-driver-linux-background-gui-qt5-klog
  • cua-driver-linux-background-gui-qt5-openambit
  • cua-driver-linux-background-gui-qt6-kate
  • cua-driver-linux-background-gui-qt6-kcalc
  • cua-driver-linux-background-gui-qt6-okular
  • cua-driver-linux-background-gui-qt6-qownnotes
  • cua-driver-linux-background-gui-electron-zettlr
  • cua-driver-linux-background-gui-electron-joplin
  • cua-driver-linux-background-gui-electron-logseq
  • cua-driver-linux-som-overlays

Open workflow run and download artifacts

@ddupont808
ddupont808 force-pushed the feat/demonstration-recording branch from 1900bb1 to 074910d Compare June 25, 2026 20:29
injaneity added a commit that referenced this pull request Jul 22, 2026
Separate observed human input from executable trajectory recording, keep capture controls private, and produce skill-ready artifacts locally on stop.

Salvaged from #2016

Co-authored-by: Dillon DuPont <ddupont@mit.edu>
@injaneity
injaneity force-pushed the feat/demonstration-recording branch from ac31322 to 03e5820 Compare July 22, 2026 11:40
@injaneity injaneity changed the title feat(cua-driver): demonstration recording → skills (window-scoped, indicator-gated) feat(cua-driver): record human demonstrations as skill-ready trajectories Jul 22, 2026
@injaneity
injaneity force-pushed the feat/demonstration-recording branch 3 times, most recently from 9c4d228 to fc08d02 Compare July 22, 2026 11:44
@injaneity
injaneity force-pushed the feat/demonstration-recording branch from fc08d02 to a42f0eb Compare July 22, 2026 14:05
injaneity added a commit that referenced this pull request Jul 27, 2026
Resolve PR #2016 against current main and include the post-rebase Windows DWM border-alignment fix.

Salvaged from #2016.

Co-authored-by: Dillon DuPont <ddupont@mit.edu>
ddupont808 and others added 7 commits July 29, 2026 01:02
New crate for capturing human input on a single window during a demonstration
recording, built so capture is impossible without a visible indicator:

- event/coalesce/gate: HumanEvent model + privacy-preserving redaction;
  keystroke coalescer (typing -> one redacted Text event; command keys/hotkeys
  -> semantic Key events); IndicatorHeartbeat/CaptureGate coupling so the input
  hook only buffers an event while the recording border is provably painting and
  covering the point.
- windows.rs: WH_KEYBOARD_LL/WH_MOUSE_LL backend that drops OS-injected,
  out-of-window, and indicator-dark events before buffering; gesture detection.
- indicator.rs: layered click-through topmost glowing border that tracks the
  target window, drives the heartbeat from presented frames, and goes dark via a
  tamper watchdog when hidden/moved/covered.
- demonstration.rs: RAII guard that builds the indicator first, derives the gate
  from it, then installs the hook; mac/linux are Unsupported stubs.

20 unit tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…tories

- recording.rs: demonstration mode. start can show the glowing border and
  capture window-scoped human input on a target window, written as turn-*/
  folders (source:"human") interleaved with agent actions on one timeline.
  begin_demonstration/record_human_turn allocate turn numbers under a brief lock
  and write outside it; start/stop tear down the demo OFF the lock to avoid
  deadlocking the writer thread. RecordingState gains demonstration/human_turns;
  action.json gains a source field.
- recording_markdown.rs: render a token-cheap TRAJECTORY.md (readable action
  prose, screenshots referenced by relative path, only a few key frames embedded
  inline) + SUMMARY.json, so reading a trajectory doesn't blow up context.
- recording_tools.rs: start_recording gains demonstration/pid/window_id/
  capture_raw_text; new process_recording tool renders the markdown and, when
  ANTHROPIC_API_KEY is set + author_skill, calls the API to draft a SKILL.md.

5 new tests (markdown + demonstration lifecycle/no-deadlock, incl. a real
Windows border+capture run).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…odel

- Skills/cua-driver/DEMONSTRATION.md: how to turn a recorded demonstration into
  a reusable SKILL.md in the Open Agent Skills Standard (minimal name+trigger
  description frontmatter, ## Inputs, semantic ## Steps with {placeholders},
  ## Verification; generalize coordinates and redacted text into intent).
  Registered in SKILL_FILES so it ships with the skill pack.
- RECORDING.md: demonstration mode section + the recording-border security model
  (capture is gated on a visible, covering, live indicator; window-scoped;
  redacted by default; tamper watchdog).
- SKILL.md: cross-links.
- docs/DEMONSTRATION_RECORDING_PLAN.md: design + status + follow-ups.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… & CLI

- indicator.rs: the recording border now glows OUTWARD from the window's
  bounding box (no inset gap) — brightest right at the window edge, fading over
  18px into a soft red blurred border + shadow; window interior stays
  transparent and click-through.
- recording_tools.rs: intuitive one-call surface so an agent doesn't need the
  start_recording flag combo:
    start_demonstration(window_id, pid)  -> border on, capture begins
    stop_demonstration()                 -> stops, processes, returns TRAJECTORY.md
  stop_demonstration treats 'no input captured' as a soft success, and supports
  author_skill (Anthropic, when ANTHROPIC_API_KEY is set).
- CLI: 'cua-driver demonstration start <window_id> <pid> [dir] [--raw] | stop
  [--author-skill] | status', wrapping the tools over the daemon socket.
- demo_record.rs example: full record -> process e2e harness.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Keep human observations separate from executable trajectories, make text capture content-free, use concrete platform capture, and narrow artifact generation to demonstrations.

Co-authored-by: Zane Chee <44902825+injaneity@users.noreply.github.com>
Keep text and pointer observations in causal order, coalesce scroll bursts, reject invalid targets early, report evidence loss, and write a versioned demonstration manifest.

Co-authored-by: Zane Chee <44902825+injaneity@users.noreply.github.com>
Revalidate target ownership throughout capture, preserve hook events during lifecycle locking, fail if idle timers cannot start, and disclose that screenshots can contain visible content.

Co-authored-by: Zane Chee <44902825+injaneity@users.noreply.github.com>
injaneity added a commit that referenced this pull request Jul 28, 2026
Scope demonstration stops to their owning session, bind cleanup to the current runtime lifecycle, refresh the lockfile, and retain the tested DWM visible-frame border alignment.

Salvaged from #2016.

Co-authored-by: Dillon DuPont <ddupont@mit.edu>
@injaneity
injaneity force-pushed the feat/demonstration-recording branch 2 times, most recently from b069e67 to 18d469b Compare July 28, 2026 17:26
Scope demonstration stops to their owning session, bind cleanup to the current runtime lifecycle, refresh the lockfile, and retain the tested DWM visible-frame border alignment.

Co-authored-by: Zane Chee <44902825+injaneity@users.noreply.github.com>
@injaneity
injaneity force-pushed the feat/demonstration-recording branch from 18d469b to f9622d0 Compare July 28, 2026 17:27
@injaneity
injaneity marked this pull request as ready for review July 28, 2026 17:30
@ctaylor86

Copy link
Copy Markdown

I built and verified the missing macOS backend directly on top of this PR's exact head (f9622d0f), preserving all eight of Dillon's commits and keeping this PR as the owning contribution.

I opened #3248 into feat/demonstration-recording, not main, so it can be reviewed/merged as an extension of this work rather than a competing implementation.

Evidence: 26 input-capture tests, 10 core demonstration tests, fmt/clippy/full compile-check, two fail-closed security review cycles, and a signed live macOS TextEdit test with a visible indicator, 27 physical events, zero drops, redacted typed content, and clean stop/removal. Temporary TCC grants were revoked afterward.

@ddupont808, if you prefer cherry-picks or another collaboration shape instead of the child PR, I am happy to adjust.

@ctaylor86

Copy link
Copy Markdown

One concrete collaboration option, since this parent PR is now conflicting with current main: Carl has read-only access to trycua/cua, so I cannot refresh feat/demonstration-recording directly. If the maintainers or @ddupont808 prefer, I can prepare a current-main landing PR that cherry-picks all eight original commits with -x, preserves every human author/coauthor trailer, includes Salvaged from #2016, and then layers the verified macOS commit from #3248. That would give maintainers one conflict-resolved PR into main without losing Dillon's ownership or attribution. I will not open that replacement while #2016 remains the chosen landing path unless you ask for it.

* [verified] feat(input-capture): add macOS human demonstrations

* ci: sync trusted contributor identities
@ctaylor86

Copy link
Copy Markdown

Thank you for merging #3248 into this branch. The parent attribution check now fails because squash commit 4f33280c is authored by @ctaylor86 but this landing PR does not explicitly identify its source. The check asks for Salvaged from #3248 in this PR body or the commit message. Since I cannot edit this upstream branch or PR body, could @ddupont808 or a maintainer add that source marker? I also opened focused follow-up #3270 for the drag-endpoint review finding.

@ctaylor86

Copy link
Copy Markdown

Following up on the contributor-preserving landing option above: this branch remains conflicting with current main. Would maintainers prefer to refresh this branch, or should I prepare a current-main draft landing PR preserving Dillon's original commits and attribution? Absent objection, I will prepare the draft after three more days.

@ctaylor86

Copy link
Copy Markdown

I have opened the contributor-preserving current-main draft landing candidate: #3441.

It keeps Dillon's eight original commits and human coauthor trailers intact with cherry-pick -x, layers the original macOS implementation from #3248, includes the reviewed #3270 clarification, and adapts the combined work to current authorization, session-cleanup and AppKit-host architecture. It is explicitly marked Salvaged from #2016 and remains a draft so maintainers can choose between this landing route and refreshing the original branch.

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.

2 participants