Metadata-Version: 2.4
Name: openadapt-kernel
Version: 0.2.0
Summary: Minimal commit-boundary verification, macro-action staging, stepwise live-DOM healing, and shadow-to-autopilot kernel for GUI agents
Project-URL: Homepage, https://github.com/OpenAdaptAI/OpenAdapt/tree/main/packages/kernel
Project-URL: Repository, https://github.com/OpenAdaptAI/OpenAdapt/tree/main/packages/kernel
Project-URL: Documentation, https://github.com/OpenAdaptAI/OpenAdapt/blob/main/packages/kernel/README.md
Project-URL: Changelog, https://github.com/OpenAdaptAI/OpenAdapt/blob/main/packages/kernel/CHANGELOG.md
Project-URL: Issues, https://github.com/OpenAdaptAI/OpenAdapt/issues
Author-email: OpenAdapt <admin@openadapt.ai>
License-Expression: MIT
License-File: LICENSE
Keywords: browser-automation,commit-boundary,computer-use,gui-agents,mcp,verification
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Requires-Dist: cryptography>=42.0.0
Provides-Extra: browser
Requires-Dist: playwright>=1.45.0; extra == 'browser'
Provides-Extra: dev
Requires-Dist: mypy>=1.10; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Description-Content-Type: text/markdown

# openadapt-kernel

Self-contained runtime kernel (zero `openadapt-flow` dependencies, zero per-app code) implementing commit-boundary verification, cross-rail read-back, reversible occlusion probing, online ACI calibration, macro staging, stepwise live-DOM healing, and shadow-to-autopilot execution:

1. **Default-Deny Obligation, Capability, and Saga Ledger (`ledger.py`):** Episodes start `UNVERIFIED` and emit `VERIFIED` only when every obligation has an independent post-commit read-back proof and zero dirty form buffers remain. Step-limit timeouts, crashes, and unverified exits deterministically return `ESCALATED`. Carries both cross-screen `<MANDATORY_CONSTRAINTS>` and `<VERIFIED_CAPABILITIES>` (user consent and SSA opaque-ID provenance), with durable Saga checkpointing across multi-system workflows.
2. **Wire and DOM-Effect Commit Interceptor (`interceptor.py`):** Detects commits from actual network mutations (`POST`, `PUT`, `PATCH`, `DELETE`) or non-empty dirty form submissions instead of button-label regexes. Excludes search/filter inputs from dirty buffers and escapes escalation payloads safely.
3. **Full-DOM Macro Staging and Stepwise Live-DOM Healer (`macro.py`):** Extracts all interactive controls across the full scrollable page (`observe_schema`), fills an entire form in one pre-commit batch with SSA provenance enforcement (`stage_form`), and heals drifted UI plans step-by-step against the live mounted DOM (handling modals and dialogs that only exist after earlier clicks).
4. **Cross-Rail Read-Back Oracles (`oracles.py`):** Independent read-only SQLite queries (`mode=ro`), pure-stdlib PDF content-stream extraction (filtering `3 Tr` / `7 Tr` invisible text), and multi-tab / fresh-reload DOM verification.
5. **Reversible Pre-Click Probe & Online ACI Calibration (`probe.py`, `aci.py`):** Hit-tests commit controls via `elementsFromPoint` plus an 80ms hover/focus probe to block transparent-overlay click-jacking (`probe_before_click`), and calibrates anomaly thresholds across shifting UI themes via `SessionStartNormalizer` and Gibbs-Candes `OnlineACICalibrator`.
6. **Shadow-to-Autopilot, 4-Mutant Offline Qualification, Micro-Handoff, Live Runner, and MCP Server (`copilot.py`, `extension_bridge.py`, `runner.py`, `mcp_server.py`, `cli.py`):** Induces zero-PII `PortalPack` specs from live Chrome Co-Pilot `extension_evidence.jsonl` recordings, qualifies verifiers offline against four counterfactual mutants (zero staging DB), runs `Draft-to-Commit` or `Verified Autopilot` across main and child popup windows via Playwright or `--cdp-url`, signs `openadapt.kernel.receipt/v1` Ed25519 receipts, and serves tools over stdio JSON-RPC 2.0 MCP.

## CLI Quickstart

```bash
openadapt-kernel shadow-sync --dir ./recordings --pack-id portal-v1 --out pack.json
openadapt-kernel qualify --pack pack.json --evidence ./recordings/run_1/extension_evidence.jsonl
openadapt-kernel keygen --priv priv.pem --pub pub.pem
openadapt-kernel keygen --priv pack_priv.pem --pub pack_pub.pem
openadapt-kernel run --pack pack.json --dossier dossier.json --mode draft --cdp-url http://127.0.0.1:9222
openadapt-kernel publish-pack --pack promoted_pack.json --priv pack_priv.pem --registry-dir ./registry
openadapt-kernel run --pack ./registry/portal-v1-<digest>.pack.json --dossier dossier.json --mode autopilot --trusted-pack-pub pack_pub.pem --url https://portal.example --commit-selector '[data-testid="submit-btn"]' --priv priv.pem --receipt-out receipt.json
openadapt-kernel verify-receipt --receipt receipt.json --pub pub.pem
openadapt-kernel serve-mcp --output-root ./mcp-out
```

## Autopilot needs a signed, promoted pack

`--mode autopilot` submits only when the pack file is a signed
`openadapt.kernel.pack/v1` envelope that verifies against `--trusted-pack-pub`
and whose signed stage is `VERIFIED_AUTOPILOT`. An unsigned file, a pack signed
by another key, an envelope edited after signing, or a `SHADOW` or
`DRAFT_TO_COMMIT` stage returns `ESCALATED` before the browser opens, and
nothing is submitted. Draft mode accepts unsigned packs because it stops
before the commit control.

The signature also covers where the run may click. Autopilot refuses with
`autopilot_origin_not_signed` unless the page has exactly the pack's
`portal_origin` (scheme, host and port), checked before the browser opens,
after navigation or CDP attach, on any popup, and right before the commit
click.

Signing with `publish-pack` is the promotion step, so whoever holds the pack
key approves autopilot. Keep that key apart from the receipt key (`--priv`),
which the runner holds. A run never publishes or promotes its own pack.

Autopilot never repairs and commits in the same run. If staging fails or the
commit control is blocked, a coding agent may propose a repair inside the
zero-PHI twin; the run escalates with the proposal recorded and clicks nothing.
If read-back refutes persistence after the commit click, the run escalates with
`readback_refuted_after_commit` and never clicks or submits again. Any run that
clicked commit and did not end `VERIFIED` records an `uncertain_write_reconcile`
obligation in the signed receipt, so the write is reconciled rather than
retried.

`NonDomKernelExecutor.execute(autonomy_stage=...)` can only lower a pack's
stage, never raise it.

## MCP server limits

The model calling the MCP tools does not set how far a run may go. Autopilot,
the trusted pack key, the receipt key and the output root are `serve-mcp` flags
(`--allow-autopilot`, `--trusted-pack-pub`, `--priv`, `--output-root`). Tool
calls run in draft unless the server allows autopilot, cannot pass key paths,
and can write only under the output root (default `~/.openadapt/kernel/mcp`).
