Attach to an already-running, unmodifiable Windows console AI agent and knock it awake — focus-free, by PID, via CONIN$. The attach-to-existing half of desktop multi-agent orchestration.
pip install agentknock==0.3.1 Copy PIP instructions
Your terminal agents, knocking each other awake while you watch — without stealing focus. It rings the doorbell; it never gives the orders.
agentknock is a standalone, orochi-independent OSS transport layer for desktop multi-agent orchestration: a notified mailbox — send() writes a signed JSON message to a directory, the receiver's local watcher fires a callback (or a pluggable adapter) on arrival — plus four small DI extension points (Notifier, DeliveryAdapter, AliasRegistry, LivenessProbe) for environment-specific concerns.
The core is pure Python with no external dependencies. pip install agentknock + a shared directory is enough for two agents on the same machine to exchange signed messages with a wake callback — no watchdog, no agy.exe, no orochi. Windows-specific CONIN$ injection and FS-native notification are opt-in extras.
Both readers share the Security invariants, Marker lifecycle, Operations guide, and Threat model sections below.
The three forms stack: [watch] + [win32] gives you everything. All core features work without any extra — the extras are optional.
Two Python processes on the same machine, using nothing but pip install agentknock. No agy.exe, no orochi, no Windows kernel calls.
from pathlib import Path import agentknock from agentknock.adapters.callback import CallbackDeliveryAdapter from agentknock.cli import WatchDaemon from agentknock.core.mailbox import Mailbox # 1. Self-register under an alias with a stable target id (opt-in R1). agentknock.register_self("hello-recv", target_id="recv-1", role="greeter") # 2. Define the wake callback. # A1 type-level R2 invariant: wake receives ONLY target_id (a 1-bit doorbell). # Instructions are fetched deliberately from the signed mailbox channel. mailbox = Mailbox() def on_wake(target_id: str) -> bool: print(f"[recv] Woken up for target: {target_id}") undelivered = mailbox.get_undelivered_dir(target_id) if undelivered.exists(): for marker in undelivered.iterdir(): msg = mailbox.validate_marker(marker) if msg: print(f"[recv] from={msg['sender']} content={msg['content']!r}") return True adapter = CallbackDeliveryAdapter(callback=on_wake) # 3. Start the resident background watch daemon. daemon = WatchDaemon(target="hello-recv", adapter=adapter, mailbox=mailbox) daemon.start() try: input("Press Enter to stop...\n") finally: daemon.stop() Sender (send.py), in another terminal:
import agentknock # 1. Discover reachable targets (R1: opt-in registry + liveness). for r in agentknock.list_recipients(): print(r["alias"], r["role"], r["capabilities"]) # 2. Send a signed JSON message to that alias. msg_id = agentknock.send( recipient="hello-recv", content="hello from the OSS Quickstart", sender="quickstart-sender", ) print("sent:", msg_id) Run it:
# Terminal 1 python recv.py # → waits, printing nothing yet # Terminal 2 (while recv.py is running) python send.py # → prints: hello-recv greeter {'surface_custom_json': True, 'honor_sender_locale': True, 'injected_input_trust_label': 'CALLBACK'} # → prints: sent: # Terminal 1 now prints: # → [recv] Woken up for target: recv-1 # → [recv] from=quickstart-sender content='hello from the OSS Quickstart' That's the whole round-trip: register → list → send → receive callback. Everything that follows — CLI daemon runtime, adapters for terminal agents, CONIN$ injection, Antigravity integration — is opt-in on top of this.
For standalone deployment or automated agent environments, run the resident watch daemon directly from the CLI:
# Watch an Antigravity target (agy.exe) with focus-free CONIN$ wake: python -m agentknock watch --target --adapter agy # Watch with custom delivery adapter and polling backend: python -m agentknock watch --target my-agent --adapter callback --notifier polling --poll-interval 0.5 Option Description Default --target, -t Conversation UUID or registered alias to monitor. None (watches root) --adapter, -a Delivery adapter (agy, callback, outbox). agy --mailbox, -m Custom mailbox root directory. ~/.gemini/antigravity-cli/brain --notifier Notification backend (auto, watchdog, polling). auto --poll-interval Polling interval in seconds when using polling. 0.5 --wake-locale Wake nudge locale for AgyDeliveryAdapter (en, ja). Local default --output-locale Output language directive for AgyDeliveryAdapter. Local default --audit-log Custom append-only audit.jsonl log path. audit.jsonl --once Exit after waking the first detected message (for testing/CI). False Agent Skill & Multi-Agent Autonomous Lifecycle When used as an Agent Skill (e.g. via SKILL.md in Antigravity or Claude Code), autonomous agents interact through three coordinated steps:
The desktop multi-agent space is active (e.g. hcom, CLI Agent Orchestrator, agentpipe). Those are launch-wrappers: you start the agent through them (hcom agy), and the tool owns the PTY it created and installs hooks from the start. They can only wake an agent they themselves launched — on Windows, by writing into their own ConPTY, never by attaching to a console they did not create.
agentknock is the complementary half: attach-to-existing. The agent was started normally — no wrapper, no hooks, no relaunch — and agentknock finds that already-running, unmodifiable process through its opt-in AliasRegistry entry, resolves its internal target id, and reaches it through a pluggable DeliveryAdapter. If you can relaunch every agent through a wrapper, use a launcher. If you need to reach an agent that is already running and cannot be modified or restarted, that is the gap agentknock fills. The two are complementary, not competing.
The transport is deliberately reduced to a one-bit doorbell. The self-limitation is the product — it is what separates a legitimate orchestration transport from an injection-attack tool that happens to share the same mechanism.
For CONIN$-style wake channels (AgyDeliveryAdapter), the reason is a trust asymmetry in how the receiving harness tags its inputs, reported first-hand by the agents being injected:
Because a CONIN$-injected string arrives as if the human owner typed it, letting a remote sender control that string is a form of owner impersonation = de-facto privilege escalation. Therefore:
In v0.3 this is now enforced at the type level: DeliveryAdapter.wake() takes no text argument at all (see § R2 below).
Everything environment-specific is a plug-in. The core (Message + Mailbox + Watcher) is stdlib-only and orochi-independent; the four extension points let you drop into any target without forking the core.
The AgentKnock class is the DI container that wires these four together. See the API section below.
Use the DI class when you need explicit wiring, or the top-level sugar for default-configuration single-liners.
from pathlib import Path from agentknock import AgentKnock from agentknock.core.mailbox import Mailbox from agentknock.core.registry import FileSystemAliasRegistry from agentknock.core.probe import AlwaysAliveProbe # DI container — explicit wiring client = AgentKnock( mailbox=Mailbox(root=Path.home() / ".agentknock" / "mailbox"), registry=FileSystemAliasRegistry(root=Path.home() / ".agentknock" / "registry"), probe=AlwaysAliveProbe(), ) client.register_self("my-agent", target_id="agent-1", role="worker") for r in client.list_recipients(): print(r) msg_id = client.send("peer-agent", "hello", sender="my-agent") # Top-level sugar — delegates to a process-wide default AgentKnock import agentknock agentknock.configure_default(mailbox=..., registry=..., probe=...) # optional agentknock.register_self("my-agent", target_id="agent-1", role="worker") msg_id = agentknock.send("peer-agent", "hello", sender="my-agent") agentknock.unregister_self("my-agent") # kill switch Public top-level surface (agentknock/__init__.py):
def send(recipient: str, content: str, *, sender: str) -> str: ... def list_recipients() -> list[Recipient]: ... def register_self(alias: str, target_id: str, *, role: str = "", capabilities: Capabilities | None = None, ttl_sec: float = 86400.0) -> None: ... def unregister_self(alias: str) -> bool: ... # kill switch def configure_default(*, mailbox=None, registry=None, probe=None) -> None: ... class Recipient(TypedDict): alias: str # pass this as `recipient` to send() role: str capabilities: dict # mirrors the adapter's capability contract What a sender can — and cannot — control Field Sender-controlled? Notes recipient yes Must be an alias returned by list_recipients: matches ALIAS_PATTERN AND does not match UUID_REGEX. Raw target ids are rejected both by is_valid_alias() and by the MCP schema. content yes Free-form string. The message body. Travels in the signed JSON channel. sender yes Self-reported identity (format: ^[a-zA-Z0-9_-]{1,64}$). An attribution claim, not an authentication. wake nudge bytes no Resolved inside each DeliveryAdapter from local constants. Type-level: wake() has no text argument (A1). Senders cannot influence the bytes delivered to the receiver's wake channel. target target_id no Resolved inside AliasRegistry / LivenessProbe. Hidden from the public API entirely. output language no For non-attributable wake channels (e.g. AgyDeliveryAdapter): pinned by the receiver's local adapter. For attributable channels: travels in JSON metadata subject to the adapter's honor_sender_locale capability. The right half is what structural R2 means: there is no field, kwarg, or environment variable in the public API through which a sender can influence the wake channel. The capability is simply not there to be invoked.
Each public function is also exposed as an MCP tool (via python -m agentknock.mcp_server --stdio). What appears in the schema is what a sender can send; nothing else reaches the adapter. This is where the capability contract becomes machine-enforceable: a field a target's adapter declares it cannot honor (e.g. a locale hint when surface_custom_json: No) is simply absent from the tool schema.
// MCP tool: send { "name": "send", "input_schema": { "type": "object", "required": ["recipient", "content", "sender"], "additionalProperties": false, // ← R2 at the MCP layer "properties": { "recipient": { "type": "string", "pattern": "^[a-zA-Z0-9_-]{1,64}$" }, "content": { "type": "string" }, "sender": { "type": "string", "pattern": "^[a-zA-Z0-9_-]{1,64}$" } } } } // MCP tool: list_recipients — no inputs { "name": "list_recipients", "input_schema": { "type": "object", "additionalProperties": false } } additionalProperties: false is load-bearing: it is the MCP-layer enforcement that a sender cannot smuggle a field the adapter did not declare support for.
Internal target ids (e.g. agy.exe conversation UUIDs) are an internal identifier used only inside adapters. Senders never see them; list_recipients returns only aliases. An alias is stable across process restarts (it lives in the registry); internal target ids typically are not.
An entry is returned by list_recipients only when all three hold:
An agent that wishes to be reachable publishes:
This is what an adapter author must declare. The platform decides what OSS users can safely do with your target based on these three fields.
For the full scope contract of AgyDeliveryAdapter, see docs/adapters/SCOPE_AGY.md.
Consequence (a deduction, not a preference): because agy.exe does not surface custom JSON fields and language mirroring defeats any out-of-band hint, the output language of agy.exe is effectively 100 % local-sovereign — it is set by the local nudge constant and nothing else. force-local is the only correct default for that adapter; it falls out of the implementation facts. Other adapters whose contract declares Yes/Yes may surface sender-supplied locale advisorily.
See docs/adapters/ADAPTER_AUTHORING.md for the checklist. The obligations:
R2 is a structural property that is now also type-level in v0.3. The DeliveryAdapter Protocol defines:
class DeliveryAdapter(Protocol): def wake(self, target_id: str) -> bool: ... There is no text argument. An adapter author cannot pass sender-controlled text to the wake call site — the shape of the method makes it impossible. Each adapter holds its own local wake-nudge catalog internally (e.g. AgyDeliveryAdapter owns the i18n WAKE_NUDGE_CATALOG and resolves it from its own constructor-time locale settings).
On top of that, send()'s static call graph does not reach any DeliveryAdapter at all. The AST test tests/test_d4_r2_r1_invariants.py::test_r2_send_callgraph_no_win_console_conin parses the module hosting send(), walks its AST transitively, and fails closed if any forbidden symbol or dynamic import appears. For any new adapter, the standard test helper is:
Two runtime siblings back it up for the core: test_r2_send_with_win_console_unavailable removes _win_console from sys.modules and still imports send cleanly; test_r2_public_namespace_only_send_list_recipients asserts the top-level module's public names.
The wake channel delivers only the wake signal. Sender-controlled content — the task, the title, any metadata — lives in the signed JSON file and is consumed through the attributable channel.
The receiver's watcher does not blindly delete the undelivered/ marker after wake(). v0.3 adds a lifecycle contract to prevent the "premature 1.5-second reap" bug that could cause receiver drops under load.
When DeliveryAdapter.consumes_marker_on_wake == False (e.g. AgyDeliveryAdapter, whose target is an out-of-process agent that reads the marker itself), the watcher never unlinks the marker after wake(). ACK is the receiver's job.
When consumes_marker_on_wake == True (e.g. CallbackDeliveryAdapter, which completes delivery synchronously inside the watcher thread), the watcher does unlink the marker — the callback itself was the ACK.
The watcher keeps _woken_at: dict[message_id, monotonic_time] and skips re-waking the same message within rewake_cooldown_sec (default 60 s), so marker lingering never causes double delivery even when the marker file survives a wake().
send() only writes files. The watcher must run inside the receiver process (or a long-lived receiver companion). Senders do not run watchers on behalf of receivers — doing so re-introduces the lifecycle bug this contract prevents.
A background reaper cleans orphan markers only after stale_marker_ttl_sec (default 300 s) or on evidence that the receiver already recorded the message as consumed. The audit.jsonl event sequence:
CREATED → WOKEN → CONSUMED # happy path CREATED → WOKEN → RETRY → … → CONSUMED CREATED → WOKEN → RETRY → … → DEAD_LETTER CREATED → … → REAPED # orphan cleanup For sequence-level detail see docs/WORK_FLOW.md.
The agentknock core is cross-platform (pure Python, no Win32). Each delivery adapter publishes its own scope contract:
Adapter authors must ship a SCOPE_ .md for their adapter (B4) — see the Adapter Authoring Checklist.
In v0.3 the i18n wake-nudge catalog is an adapter-internal concern, not a core-level setting. It only matters for adapters whose wake channel is non-attributable (and therefore depends on language mirroring to steer output language) — AgyDeliveryAdapter is the canonical example. Attributable adapters (callback, outbox, HTTP) don't need the catalog: the output locale can travel in the JSON metadata through the attributable channel, where the agent can read it without R2 implications.
For AgyDeliveryAdapter specifically, the catalog and resolution rules live in agentknock/adapters/agy.py:
# Local override only — sender input is NEVER consulted: # 1. env CONINJECT_WAKE_LOCALE / CONINJECT_OUTPUT_LOCALE / CONINJECT_LOCALE # 2. AgyDeliveryAdapter(wake_locale="ja", output_locale="ja") # 3. "en" (fail-closed; unknown/invalid → en) Layer B (sender-supplied locale) — per-adapter A sender-supplied output-locale is intentionally not core. It may surface on adapters whose capability contract declares both surface_custom_json: Yes and honor_sender_locale: Yes — and even then as a validated-enum advisory that the local policy can override, never as a command, fail-closed to en.
The focus-not-stolen property is a feature and a risk: injection into a non-attributable wake channel is invisible to the human by design. These three controls restore human oversight and are operational requirements, not optional extras.
2026-11-12T12:14:07Z event=WOKEN sender=claude-code recipient=gemini-ipc msg=4b1e… result=OK 2026-11-12T12:14:09Z event=CONSUMED msg=4b1e… 2. Visible indicator A local UI element (status line / tray / band — outside the injection path) shows, in the human owner's own wake_locale, that a wakeup is happening and who triggered it. This is the countermeasure to the UI-blind attack class, where an attacker forces output into a language the operator cannot read in order to delay audit of suspicious behavior.
unregister_self(alias) is the kill switch at the discovery layer — one call drops the entry and discovery / send targeting both stop immediately. Combined with existing loop guards (sender == "user" is skipped to prevent infinite loops, plus rate-limiting / loop detection) and rewake_cooldown_sec, this bounds any wake storm. Failed messages exceeding retry limits are quarantined to dead_letter/ .json rather than retried indefinitely.
Legitimacy is not proven by what can be injected — the mechanism is identical to a keystroke-injecting keylogger. It is proven by the constraints: resolve recipients only from self-published artifacts (R1 — never enumerate), the wake channel can carry only a local, benign, single-bit wake signal (R2 — type-level: wake() has no text argument), route every instruction through the signed channel, and keep the human able to see it and stop it.
agent cli-agent multi-agent orchestration console conin windows wake transport antigravity
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
None of the files in this release were uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.




