Open source CapCut alternative.
TypeScript
docs: document background-by-default input mode
David Led761870eea01
diff --git a/docs/README.md b/docs/README.mdindex 70185d30..16e79785 100644--- a/docs/README.md+++ b/docs/README.md@@ -11,11 +11,43 @@ local model weight setup are not part of the supported install path.## Guides-Supported product and engineering guides live in `docs/guides/`.+Supported product and engineering guides live in `docs/guides/`. This list is the canonical index — keep it in sync when you add or rename a guide.-Add or update a guide there when behavior becomes supported. Do not maintain duplicate guide indexes in subdirectories or app folders; use descriptive filenames and link directly from related docs only when the relationship helps a maintainer.+**The agent**-Write and edit docs following `docs/guides/eng-doc-style.md`. It defines the required structure, sentence-level rules, and the post-writing test for every engineering doc.+- [Agent Harness](guides/agent-harness.md) — the runtime loop that turns a request into completed work: plan, act, verify, recover, and the safety invariants.+- [Harness Deep Dive](guides/harness-deep-dive.md) — subsystem mechanics, one level below the architecture loop.+- [Decision System](guides/decision-system.md) — how a turn becomes a conversation, a question, a permission request, or guarded action, and what counts as done.+- [Donkey Vision](guides/donkey-vision.md) — the observation layer that turns on-screen windows into structured UI the agent can reason about.+- [Background Input](guides/background-input.md) — driving an app without taking over the cursor or raising it: the foreground/background decision and the delivery lanes.++**Mac app surfaces**++- [Notch](guides/notch.md) — the always-on top-center surface: task states, controls, and streaming narration.+- [User Query Overlay](guides/user-query-overlay.md) — the floating prompt composer and agent cursors, and their grounded-only, cosmetic contract.+- [Permission Pre-Gate](guides/permission-gate.md) — how macOS permissions are approved in the notch before the system dialog appears.++**Extending the agent**++- [Authoring Skills](guides/authoring-skills.md) — writing reusable skill packs that teach the agent app-specific workflows.++**Site and backend**++- [Backend API Guide](guides/backend-apis.md) — the hosted routes the Mac app and site call for model-backed work.+- [Frontend and Next.js Guidelines](guides/frontend-nextjs-guidelines.md) — route structure, server/client boundaries, styling, and data access in the site app.++**Operations**++- [Install Donkey Locally](guides/install-donkey.md) — building the app bundle and disk image for local testing.+- [Releasing Donkey](guides/releasing-donkey.md) — how production releases are built and shipped.++**Working in this repo**++- [Swift MVC Guide](guides/swift-mvc.md) — keeping product state, UI rendering, and AppKit orchestration separate in the app.+- [Code Review Guide](guides/code-review.md) — what makes a change reviewable, and how we review.+- [Engineering Doc Style Guide](guides/eng-doc-style.md) — the required structure, sentence-level rules, and post-writing test for every doc here.++Add or update an entry here when behavior becomes supported. Don't duplicate this index in subdirectories or app folders; link directly between related docs only when the relationship helps a maintainer. Write and edit docs following the [Engineering Doc Style Guide](guides/eng-doc-style.md).## Navigation Rules@@ -25,4 +57,4 @@ Write and edit docs following `docs/guides/eng-doc-style.md`. It defines the req- Product guides should explain supported behavior, boundaries, and verification.- Engineering guides should explain patterns current code must follow, not speculative architecture.- Guides should not duplicate implementation. Prefer intent, rules, and concise source entrypoints over code listings or long file inventories.-- New docs do not need to be registered in multiple places. Prefer one canonical file in `docs/` and selective cross-links only where they carry context.+- Register a new guide once, in the Guides index above; beyond that prefer one canonical file in `docs/` and selective cross-links only where they carry context.diff --git a/docs/guides/agent-harness.md b/docs/guides/agent-harness.mdindex a125eee4..f6bb3d85 100644--- a/docs/guides/agent-harness.md+++ b/docs/guides/agent-harness.md@@ -86,9 +86,14 @@ Accessibility roles — but never the raw string.**2. Understand once, then loop.** Before the per-step loop starts, anunderstanding boundary restates the goal, names the target app (or leaves it-empty for system-tool tasks), extracts parameters and success criteria, and-flags whether clarification is needed. Every later step plans against this-stable, typed goal instead of re-reading the user's words.+empty for system-tool tasks), extracts parameters and success criteria, flags+whether clarification is needed, and chooses whether the work runs in the+background (the agent acts without taking over the cursor or raising the app)+or the foreground (the user is meant to watch — pulling something up, a+walkthrough). Background is the default; foreground is the typed exception, and+like every other field it is decided here, never matched from raw text. Every+later step plans against this stable, typed goal instead of re-reading the+user's words.Context sent to the model is always bounded. Compaction keeps the currentturn, relevant task state, recent useful evidence, summaries, memory snippets,@@ -228,7 +233,14 @@ Two invariants:these checks. If the target window lost focus between observe and act, theguard attempts one recovery activation of the target app (never any otherapp) before denying — and a denial names whatever is in front, so the- planner can react to the blocking window instead of failing opaquely.+ planner can react to the blocking window instead of failing opaquely. On a+ background turn, the guard skips activation for a safe, on-screen target:+ a native Accessibility action runs as a focus-neutral cross-process call,+ and coordinate clicks, scrolling, dragging, and keystrokes are delivered to+ the target process directly — neither path raises the app or moves the+ cursor. The guard still refuses background for a sensitive surface (login,+ password, payment, system), falling back to the foreground activation path+ so the work still completes.2. **Done means evidence.** A task isn't complete because the right app isfocused. The harness needs post-action proof: a guarded command trace,visible text, selected state, an app-reported result, or a@@ -241,7 +253,9 @@ labeling its path) is cosmetic and separate from input. AX, AppleScript,keyboard input, or guarded coordinate fallback do the real work. The overlaynarrates every step, not just clicks: steps that move the pointer animate thecursor, and steps that don't (observe, shell, wait, verify) hold it in place-and update its label, so a silent step never looks like a hang.+and update its label, so a silent step never looks like a hang. On a background+turn the agent moves no real pointer, so the traveling cursor is suppressed and+progress is narrated through the notch text alone.## AppleScriptdiff --git a/docs/guides/background-input.md b/docs/guides/background-input.mdnew file mode 100644index 00000000..37bb0ad6--- /dev/null+++ b/docs/guides/background-input.md@@ -0,0 +1,98 @@+# Background Input++Donkey runs the user's work in the background by default: it drives a target+app — clicking, typing, scrolling — without taking over the real cursor or+pulling the app to the front. The user keeps working in whatever they are+focused on while the agent acts on another window. Foreground driving, where+the agent visibly takes over the screen, is the exception, reserved for turns+whose whole point is for the user to watch (pulling something up, a+walkthrough, "how do I…").++**The one rule:** whether a turn runs in the background or the foreground is a+typed decision made once by the request-understanding step, never inferred from+the user's words. Deterministic code reads that one field; it never inspects+the raw request. If you're tempted to check whether a command "sounds like" a+show-me request, that classification belongs in the understanding step, which+returns a typed preference the rest of the system obeys.++## How It Works++```text+understand the turn ──► preference: background (default) or foreground+ │+ per action:+ ▼+ guard: is background safe for this target? ┌─ no ─► foreground: raise the+ • the turn asked for background │ app (one recovery), act+ • the window is a safe surface │ through the real cursor+ • it is on-screen (so on the active Space) │+ │ yes │+ ▼ │+ deliver to the target, no raise, no cursor move ◄─┘ (foreground is always available)+ • Accessibility action — for a control that advertises one+ • event to the process — for clicks, scroll, drag, keystrokes+```++The understanding step decides *whether* to run in the background; the guard+decides *whether that is safe* for the resolved window; the delivery lane+decides *how* the action reaches the app. A reader who remembers only that+split makes correct decisions.++Because a target window is resolved from the on-screen window list, a resolved+target is already on the active desktop and not minimized — so the guard needs+no separate desktop check, and a window on another desktop simply isn't found.++## The Two Background Lanes++Both reach the target process directly, so neither moves the cursor nor changes+which app is in front.++| Lane | Used for | How it acts |+|---|---|---|+| Accessibility action | a control that advertises a native action (press, open, show-menu, pick, confirm, cancel) | a cross-process Accessibility call on the exact control the agent observed |+| Event to the process | coordinate clicks, scrolling, dragging, typing, key chords | a synthetic event delivered to the target process |++The Accessibility lane is preferred wherever it applies — it activates the+control regardless of where it sits on screen. The event lane covers everything+the Accessibility lane can't express, including web-page content and text+entry.++## Delivery Falls Back, Never Flags++Background event delivery tries the richest path first and degrades on its own.+There is no switch to turn it on; it is enabled by detecting whether the system+entry points it needs are present.++1. The SkyLight path — cursor-neutral delivery that carries the live-input+ signal and the key-authentication envelope some apps (Chromium, Electron)+ require — is used when those private system entry points resolve.+2. Otherwise the public per-process post, also cursor-neutral, carries the+ event.+3. If neither can deliver to the process — or the control isn't drivable in the+ background, or the surface is unsafe — the action falls back to the+ foreground path, bringing the app to the front so the work still completes.++The richer paths are private and version-fragile, so they are isolated to one+place and treated as best-effort: a missing entry point means the next path+runs, never a dropped action.++## Invariants++1. **Every input is guarded.** Foreground input requires the target frontmost,+ recovering focus once before denying. Background input requires a safe,+ on-screen target and a cursor-neutral delivery lane. A sensitive surface —+ login, password, payment, system — is never driven in the background; it+ degrades to foreground so the user sees it.+2. **Done means evidence.** A background action runs where the user isn't+ looking, so the agent re-observes and confirms the effect. A completion whose+ last state-changing action has no later succeeded verification is rejected.+3. **The overlay stays cosmetic.** Background turns suppress the traveling+ cursor and narrate progress through the notch text alone; the overlay never+ delivers real input, and no real pointer moves.++## Where It Lives++The guard and the input lanes — Accessibility actions and the process-delivery+path — live in the runtime layer that owns guarded execution; the typed+background preference is set in the request-understanding step and threaded into+the act tools.diff --git a/docs/guides/decision-system.md b/docs/guides/decision-system.mdindex 37e4651e..cea8be07 100644--- a/docs/guides/decision-system.md+++ b/docs/guides/decision-system.md@@ -57,8 +57,11 @@ instead of guessing.## ValidationEvery planned tool call is validated before execution: the tool must exist in-the registry, its permissions must be granted, the target window must hold-focus, and its safety class must allow the action. AppleScript runs only as+the registry, its permissions must be granted, its safety class must allow the+action, and the target must pass the focus guard — frontmost for a foreground+turn, or a safe on-screen window driven cursor-neutrally (a focus-neutral+Accessibility action, or input delivered to the target process) for a+background turn. AppleScript runs only asvalidated generated artifacts — free-form planner text is never executeddirectly. Completion requires evidence: the runtime rejects a completion whoselast state-changing step has no later succeeded verification step.