Skip to main content

Consent-gated, operator-driven clipboard bridge between AI sessions. Includes versioned clipboard history daemon: every copy timestamped and queryable by both operator and AI.

Project description

clipboard-relay

Consent-gated, operator-driven clipboard bridge between AI sessions.

The lightweight middle between single-agent and multi-agent paradigms.

What it does

When you run two AI sessions in parallel — say, Codex on one repo and Claude Code on another — and you want the second to see what the first just produced, the conventional answers are heavy: MCP integration, agent-to-agent protocols, shared message buses, agent registries.

clipboard-relay is the lightweight middle: the operator's clipboard becomes a single-slot, last-write-wins event bus, and the operator's hands are the trigger.

[ Source AI session ] -- emits content -->
[ Operator hits ctrl+c ]
[ Receiving AI calls clipboard_relay.read(consent=...) ]
[ Receiving AI now has full context, no infrastructure ]

Boundary

The agent must not auto-poll. The agent must not read without an explicit operator request. The agent must surface what it read. The agent must flag credential-shaped content before processing further.

These are not omissions; they are refusals. The package's only public function refuses to run without a consent token.

See docs/doctrine.md for the full brotology contract.

Install

pip install clipboard-relay

With cascade-lattice receipt support:

pip install "clipboard-relay[provenance]"

Two surfaces

1. One-shot readclipboard_relay.read(consent=...). Returns the current clipboard once, with credential-shape detection. Single-slot, last-write-wins.

2. Versioned historyclipboard_relay.daemon watches the clipboard and appends every distinct copy to ~/.clipboard-relay/history.jsonl. The history is queryable by both the operator (CLI) and any consenting AI session (clipboard_relay.history.read(consent=...)).

The history surface upgrades the clipboard from single-slot to versioned timeline: every copy timestamped, no copy lost, no manual paste needed.

One-shot

from clipboard_relay import read

# The AI must NOT fabricate the consent token. It must trace to operator intent.
result = read(consent="user said: read what I just copied from codex")

print(result.platform)               # "windows" / "macos" / "linux"
print(result.byte_count)             # int
print(result.content_sha256)         # for receipts
print(result.preview)                # first 500 chars (safe for logging)

# Flag credentials BEFORE processing further:
if result.has_credential_warnings:
    for w in result.credential_warnings:
        print(f"WARNING: {w.kind} (confidence {w.confidence}): {w.note}")
    # Stop and confirm with operator before using `result.content`.
else:
    process(result.content)

Versioned history

Start the daemon (foreground; Ctrl-C to stop):

clipboard-relay daemon                    # default 1000ms poll
clipboard-relay daemon --interval-ms 500  # tighter polling

Inspect history (operator-side notepad):

clipboard-relay show                # last 20 entries, preview only
clipboard-relay show --limit 100    # last 100
clipboard-relay show --full         # full content of each entry
clipboard-relay where               # print path to ~/.clipboard-relay/history.jsonl

Read history programmatically (AI-side, consent-gated):

from clipboard_relay import history

entries = history.read(
    consent="user said: read clipboard history from the codex session",
    limit=20,
)
for e in entries:
    print(e.timestamp, e.byte_count, e.sha256[:12])
    if e.credential_warnings:
        print("  CREDENTIAL DETECTED — flag to operator before processing")
    else:
        print("  preview:", e.preview[:80])

Each entry on disk is one JSON line at ~/.clipboard-relay/history.jsonl. Format is stable; codex / cascade-lattice can ingest directly.

Platform support

OS Tool used Required
Windows powershell.exe Get-Clipboard -Raw bundled
macOS pbpaste bundled
Linux (X11) xclip -selection clipboard -o install xclip
Linux (Wayland) wl-paste --no-newline install wl-clipboard

Failure modes the package surfaces

  • ConsentRequiredErrorread() was called with empty / whitespace consent. The agent failed the consent gate.
  • ClipboardTooLargeError — clipboard exceeded max_bytes (default 1 MB).
  • UnsupportedPlatformError — no clipboard tool found on host.
  • Stale clipboard — operator copied something else after the source AI's emit. Not raised; up to the caller to confirm with the operator.

Lineage

Part of the Ouroboros ecosystem:

  • brotology-field-guide — the operator contract this package embodies.
  • cascade-lattice — optional receipt emission for relay events (anonymized; content hash only).
  • quinesmith — sibling primitive with the same agent prepares, operator runs boundary.

License

Apache-2.0. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clipboard_relay-0.2.1.tar.gz (17.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

clipboard_relay-0.2.1-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file clipboard_relay-0.2.1.tar.gz.

File metadata

  • Download URL: clipboard_relay-0.2.1.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for clipboard_relay-0.2.1.tar.gz
Algorithm Hash digest
SHA256 549f67140029676309993ae0c397ec01930ac7d4927f5a6d5408044c614595eb
MD5 052f1ffb1710db0c8a492b1504daab8a
BLAKE2b-256 6786e299e680c984fb16ee453ccf492416e0b80cbccad15a84f53cc3f4bc9116

See more details on using hashes here.

File details

Details for the file clipboard_relay-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for clipboard_relay-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 071f8b00c6ce2d352a0af96db91e1d484bedbda75302565b6d21e127b7d206a9
MD5 107d9ca5c86696286a7f7b04f8d99b27
BLAKE2b-256 d4b76b92747687a66bec878f9242fc01175d23e22291239dd3cdad67cb0b9403

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page