Introducing a new way to review your PRs.

Read the announcement

hashgraph-online / hol-guard

Open-source antivirus and firewall for AI agents: block risky tools, secret access, prompt injection, malicious packages, MCP servers, plugins, and skills at runtime.

View on GitHub

44 documents · Updated Nov 23, 2026

docs / agent-and-tool-integrations

Agent and tool integrations

Guard connects AI agents, MCP clients, and developer tools to one local protection authority. It adapts each product's event model to shared review rules, then returns the result through that product's hook, prompt, launcher, extension, or proxy. The connection stays tied to its product, workspace, runtime, session, and managed installation.

Integration model

An agent adapter is Guard's boundary for one supported product. It defines how Guard finds the product, which product events it can review, how it installs and removes managed material, how approval reaches the user, and which actions remain outside its view.

The common model has three parts:

PartPurpose
Product surfaceConnects Guard to hooks, a launcher, an extension, an overlay, or an MCP proxy.
Decision pathSends prompts, tool calls, file actions, and results to the local Guard authority.
Lifecycle contractDefines detection, setup, proof, repair, coverage, limits, and removal.

Every request carries a harness context. This is the product home, optional workspace, Guard home, current directory, user home, and selected environment values. The context keeps discovery, installation, launch, and cleanup on the same paths. The native adapter authority supplies checked plans while the product adapter owns the product operation and user-facing state. Managed operations run under one owner so their writes, records, and recovery share one transaction boundary.

References: rust/…/mod.rs• L176-241 rust/…/managed_install.rs• L57-106 rust/…/codex_managed.rs• L325-417

Supported integration surfaces

Guard uses the strongest event boundary that a product exposes. A native hook can review an action as it happens. A launcher, overlay, extension, or proxy covers products that expose only part of the action flow.

SurfaceProduct examplesGuard's roleMain limit
Native hooksCodex, Claude Code, Cursor, Cline, Copilot, Grok, Kimi, ZCodeReviews prompts, tools, file work, approvals, or results at product events.Actions outside the hook path are not seen.
Managed extensionsPi, Oh My Pi, OpenCode, ClineAdds review inside the agent runtime.The product can still run work outside the extension.
Overlays and launchersOpenClaw, Hermes, OpenCode, Gemini, Antigravity, PaseoApplies Guard posture at launch or through a provider runtime.A launch check does not cover later actions.
MCP proxiesCodex, Copilot, Cursor, Cline, Hermes, OpenCode, and other local clientsReviews supported local MCP calls before the client receives a result.Remote MCP declarations can be inventoried without being connected.
Workspace and CLI hooksCopilot, Cursor, Claude CodeCovers project and command-line entry points.An alternate entry point can bypass that surface.

The adapter registry describes host names, aliases, approval channels, install modes, and coverage hints. Paseo delegates protection to native Guard integrations on its daemon host instead of creating a separate provider path. A description reports declared capability. It does not prove that the current installation is live.

References: rust/…/describe.rs• L44-61 rust/…/describe.rs• L154-169 rust/…/describe_wire.rs• L9-82

Installation lifecycle

Guard treats an integration as a reversible, checked lifecycle. It finds the product and scope, prepares a complete change, publishes only managed material, checks the live boundary, and later repairs or removes only what it can still identify.

When an engineer connects an agent, the flow is:

  1. Detect the product command, configuration, workspace, existing hooks, and MCP definitions.
  2. Select the canonical adapter from the product name or alias.
  3. Capture the target state and prepare a complete transition under the installation owner.
  4. Recover interrupted publication before writing, then publish hooks, launchers, overlays, proxies, or extensions while keeping user entries.
  5. Record managed paths, backups, ownership, proof, and the managed-install row for later checks.
  6. Verify the live surface and report active, degraded, unavailable, or unverified coverage.

The diagram shows how a detected state becomes an attributable live integration.

flowchart LR
    A[Detect product and scope] --> B[Select adapter contract]
    B --> C[Capture and prepare checked transition]
    C --> D[Recover and publish managed surface]
    D --> E[Record ownership and proof]
    E --> F[Verify live boundary]
    F --> G[Report coverage and limits]
    G --> H{Later lifecycle action}
    H -->|repair or update| C
    H -->|remove| I[Restore or remove owned material]

Install, connect, test, repair, update, and uninstall are operator entry points over this lifecycle. A target that changes after detection causes a fresh transition instead of a best-effort merge. Managed install rows preserve the active state, workspace, manifest, and proof that health checks use later. For a multi-target request, rows already written remain recorded if a later target fails.

References: rust/…/files.rs• L72-100 rust/…/managed_install.rs• L57-106 rust/…/managed_install.rs• L185-226 rust/…/codex_managed.rs• L406-417 rust/…/managed_record.rs• L118-165

Product adapter boundaries

The product adapters share one decision meaning but keep each host's event names, settings model, and response rules. This gives many agents one policy result without treating their hooks as interchangeable.

Codex integration

Codex is Guard's reference native-hook integration. Its managed boundary covers pre-tool actions, permission requests, submitted prompts, and post-tool results. The pre-tool and permission events form the authoritative shell boundary. If that boundary is missing, disabled, or not trusted, Guard does not claim that protected Codex work is active.

Codex detection combines global and workspace configuration with authenticated hook state, managed MCP entries, workspace artifacts, and skills. Installation captures these sources before it prepares one plan. The native runtime performs the authenticated baseline read, source capture, detection, publication, recovery, and manifest reporting under the Guard installation owner. The plan preserves user hooks, migrates compatible legacy hooks, refreshes managed MCP proxies, and publishes an authenticated manifest with the resulting ownership.

Codex also supports a guarded remote TUI launch. Guard uses remote mode only when launch candidates share one canonical executable prefix and the arguments describe an interactive TUI. It starts or reuses the local app-server through a control socket that must belong to the launching user and accept a live connection. If preparation or readiness fails, Guard runs the ordinary Codex command rather than attaching to an unknown process.

References: rust/…/codex.rs• L31-59 rust/…/codex_detection.rs• L161-216 rust/…/codex_managed.rs• L325-417 rust/…/codex_install_plan.rs• L370-493 rust/…/codex_remote_launch.rs• L127-175 rust/…/codex_remote_run.rs• L30-60

Claude Code integration

Claude Code receives managed hooks in its user settings surface. A workspace scopes the Guard policy and hook URL. It does not move the managed hooks into project settings. Session start refreshes the active routing so a product upgrade does not leave an old Guard path in use.

The adapter reports settings layers that can disable or redirect hooks before installation. It merges Guard entries beside user entries, removes only Guard entries during uninstall, and keeps project settings untouched. Headless local sessions use the same local settings. Cloud sessions run elsewhere and are outside this surface.

References: rust/…/claude.rs• L45-55 rust/…/claude.rs• L100-126 rust/…/claude_install_target.rs• L86-171 rust/…/claude_install_target_text.rs• L28-74

Cursor and Copilot integrations

Cursor and Copilot expose more than one developer surface. Guard keeps editor and CLI protection separate so an installed editor hook does not prove that the CLI is protected. Their MCP configuration is also scoped to the surface that owns it.

Cursor has distinct editor and CLI states. Its managed hook client fails closed when the native bridge cannot answer safely. Its surface status distinguishes detected, protected, and detected-but-unprotected states. Copilot uses its native CLI and workspace hook forms with scoped ownership and captured state.

References: rust/…/cursor.rs• L31-48 rust/…/cursor_surfaces.rs• L82-141 rust/…/cursor_surfaces.rs• L155-201 rust/…/describe.rs• L300-337

Cline integration

Cline supports two enforcement transports: native hooks and a managed AgentPlugin. Guard selects one transport for the requested host surface, proves the selected runtime, and reports pending proof instead of reporting active protection too early.

The adapter detects duplicate managed transports and asks for repair rather than allowing two Guard paths to compete. Its MCP path rewrites supported local server entries while keeping remote servers unchanged. Ownership records let uninstall restore only a rewrite that Guard still owns.

References: rust/…/cline.rs• L19-29 rust/…/cline.rs• L219-304 rust/…/cline.rs• L334-364

OpenCode integration

OpenCode uses a global root configuration, a managed pre-tool plugin, and a runtime overlay. Guard keeps root policy, local MCP companions, and runtime overlay as separate concerns. Project entries can therefore override global entries without changing their ownership.

Install reads all applicable configuration scopes and prepares one checked change. The generated plugin reviews shell tools through the bounded bridge. The overlay keeps managed MCP tools on native approval and is effective only when the managed launch path is used. Updates refresh verified companion launchers and both plugin copies in the workspace recorded by the active install.

References: rust/…/opencode.rs• L25-77 rust/…/opencode_install.rs• L266-317 rust/…/opencode_checks.rs• L124-220 rust/…/opencode_update.rs• L123-177

Hermes and OpenClaw integrations

Hermes and OpenClaw use Guard-owned bundles because their native settings do not expose the same complete hook boundary as Codex. The bundle provides a managed launch seam and preserves the host's other settings and servers.

Hermes can route local server proxies through its overlay and send pre-tool review to the local approval center. OpenClaw keeps its managed overlay under the Guard home. These launch-oriented surfaces do not imply coverage for work that the host starts outside the managed path.

References: rust/…/describe.rs• L136-152 rust/…/describe.rs• L357-371 rust/…/managed_install_target.rs• L213-250

Pi and Oh My Pi integrations

Pi and Oh My Pi use generated managed extensions listed in agent settings. The extension sends bounded hook data to Guard, keeps reviewed requests separate from model-visible results, and can continue an approval only while the original session, workspace, daemon, and content identity remain valid.

The extension can use a native bridge or an authenticated local daemon request. It bounds payload shape and size before review. It can withhold or replace model-visible output when the result is not covered by a valid review. Oh My Pi also has an interactive terminal continuation when the host can keep the paused request active. Desktop Core installs use the stable current-hol-guard launcher so an extension does not bind to a versioned runtime that an update can replace.

References: rust/…/pi_extension.rs• L21-29 rust/…/pi_extension.rs• L151-247 rust/…/desktop_core.rs• L1-7 rust/…/desktop_core.rs• L87-105 rust/…/pi_extension_render.v1.json• L1475-1554 rust/…/pi_extension_render.v1.json• L1930-2105 rust/…/pi_extension_render.v1.json• L2316-2406

Other agent integrations

The remaining adapters use the same lifecycle with narrower product surfaces. Shim-first agents receive pre-launch checks. Hooked agents use bounded event clients. Paseo delegates to native provider adapters on its daemon host and records each provider's proof instead of treating Paseo notifications as enforcement.

Workspace detection can add shared skills, instructions, plugins, and MCP artifacts to a product's own inventory. Firewall metadata then gives policy review a common view of skill content, MCP server identity, and tool identity across products.

References: rust/…/describe.rs• L61-77 rust/…/paseo.rs• L23-29 rust/…/paseo_delegated.rs• L40-110 rust/…/detect_merged.rs• L118-143 rust/…/firewall.rs• L115-169

Bridge contracts

A hook bridge is the short process boundary between a product event and Guard's local decision service. It carries a bounded request, preserves product context, applies the host deadline, authenticates the local service, and maps the result back to the product's response rules.

The bridge contract protects the local fast path:

  • It reads daemon state and authentication material from private Guard state.
  • It uses local transport and does not accept proxy redirection.
  • It checks health, compatibility, process liveness, and challenge proof when available.
  • It bounds request and response size and rejects malformed or late data.
  • It maps unknown restrictive fields toward review or deny instead of unsafe allow.
  • It retries recovery only within the original event budget.

The native adapter authority returns a structured plan or a refusal. The product adapter applies that plan only after checking its shape, paths, current target, and ownership. A refusal leaves the integration unavailable or pending instead of producing a partial configuration.

Native review requests carry the action envelope that approval needs. The envelope can bind the tool and target, an authenticated origin receipt, an exact-action token, or a native Bash review lineage. Package approval keys are accepted only for the exact harness and package request that created them.

References: rust/…/managed_install_target.rs• L31-69 rust/…/hook_adapter_review_request.rs• L40-165 rust/…/hook_adapter_review_request.rs• L176-185 rust/…/hook_adapter_review_request.rs• L221-250

MCP client integration

The Model Context Protocol (MCP) connects an agent to a tool server. Guard treats local launchable servers and remote declarations as different surfaces. It can proxy supported local stdio servers for live review. Remote servers remain inventory and governance data unless a product-specific path supports them.

For a local server, Guard carries the server's scope, configuration source, launch command, arguments, transport, selected environment, and stable server identity into the proxy. The native relay can replace the Python proxy for supported clients when the validated runtime advertises that capability. Guard-managed entries are recognized as proxies rather than rediscovered as new upstream servers.

Remote discovery does not connect to the server. It maps a declaration to an observed tool namespace only when the URL, name, harness, and observed tool forms identify one connector. A capped scan cannot claim complete coverage, so reconciliation leaves unseen declarations unchanged.

Agent MCP calls enter Guard for policy review and enforcement. Guard's own evidence service is a separate, bounded read-only path for agents that need Guard evidence. See MCP discovery, provider governance, and skill workflows for the wider discovery, provider, and skill model.

References: rust/…/managed_servers.rs• L78-96 rust/…/proxy_launch.rs• L26-38 rust/…/proxy_launch.rs• L138-175 rust/…/firewall.rs• L57-81

Installation surfaces

The main operator surfaces are direct install, guided app connection, no-change test, repair, update, and uninstall. A product can use settings files, generated hooks, launch shims, managed bundles, backups, state records, and MCP entries. The adapter manifest reports the result so downstream tools can distinguish a live integration from a prepared or launch-only one.

Guard can create a stable per-user shim for a harness. The shim pins the installer's runtime and context, then checks changes before the harness starts. A shell profile change can place the shim directory first on PATH; temporary Guard homes and unsupported shells receive a manual PATH instruction instead.

Managed installs run under one owner and journal their writes. The same owner records the adapter manifest and managed-install row. Reads of the managed-install store are read-only and do not create a store for an unopened Guard home. A pending runtime transition blocks new installation writes until recovery finishes. A multi-target operation records each completed target before it reports a later target failure.

Guard also supports standalone shim, profile, and Cursor hook installation. These surfaces use the same owner and journal rules even when they are not part of a multi-harness install.

References: rust/…/managed_install.rs• L57-106 rust/…/managed_install.rs• L185-226 rust/…/managed_record.rs• L37-89 rust/…/managed_store.rs• L44-63 rust/…/standalone_install.rs• L35-107

Identity protections

Guard binds an integration to the installation and execution context that created it. This prevents a changed hook, moved executable, different workspace, altered MCP definition, or replaced daemon from silently inheriting an earlier approval.

IdentityWhat it bindsProtection effect
Managed proofGuard-owned hooks, scripts, plugins, overlays, and launchersDetects missing or changed protection material.
Lifecycle stateGuard home, product paths, workspace, backups, and scopeRejects stale targets and unsafe restore plans.
Hook or template identityEvent bindings, runtime, command, source, and versionRejects stale or foreign registrations.
MCP identityServer launch meaning, scope, tool name, schema, and originExpires an approval when the connector changes.
Approval bindingRequest, action, policy, challenge, sandbox, session, workspace, and consume stateAllows continuation only for the exact live action.
Runtime ownershipAttested CLI, interpreter, generated extension, and source environmentPrevents a moved or transient runtime from becoming the authority.

Install plans use captured before-state and refuse a changed target. Managed files are written through owner-controlled boundaries. Guard home redirects, untrusted output paths, and foreign or linked targets are not silently adopted.

Generated OpenCode and Pi sources carry runtime identity and bounded bridge settings. Their renderers reject malformed or incomplete inputs and escape values before they enter generated code. Desktop Core sources use a stable launcher beside versioned releases or in durable app data, so a release pointer change does not silently switch an existing extension to an unverified path. Durable runtime and launcher choices avoid binding a product to a temporary extraction path.

References: rust/…/files.rs• L44-100 rust/…/guard_home_redirect.rs• L20-35 rust/…/desktop_core.rs• L43-105 rust/…/desktop_core.rs• L160-201 rust/…/opencode_plugin_render.rs• L60-113 rust/…/pi_extension.rs• L85-115

Approval and continuation

Adapters deliver approval through a native product prompt, the local Guard approval center, or a headless terminal flow. The selected channel depends on the product surface and on whether the host can safely continue the original action.

Native approval uses a resident-issued challenge. A continuation must match the current request, product identity, workspace, policy, capabilities, sandbox context, session, and daemon generation. If any binding is stale, changed, cancelled, or consumed, Guard keeps the action blocked or asks the user to retry it.

Pi-family extensions apply the same rule to model-visible output. They forward an original result only when its bounded shape and digest match the reviewed operation. Otherwise they withhold it or provide a reviewed replacement. A blocked tool call remains blocked while the approval center handles the request; the agent is not asked to invent a new action.

References: rust/…/pi_extension_render.v1.json• L2212-2310 rust/…/pi_extension_render.v1.json• L2500-2504 rust/…/pi_extension_render.v1.json• L2143-2165 rust/…/hook_adapter_review_request.rs• L79-105

References: rust/…/skills_scan.rs• L70-143 rust/…/paseo.rs• L228-252

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep each product's declared event coverage aligned with its response mapping, approval fallback, live proof, and reported blind spots.
  • Keep detection snapshots, lifecycle ownership, backups, managed markers, repair, and removal derived from the same target state.
  • Keep hook event bindings, bridge arguments, packaged runtime files, generated extension source, interpreter identity, executable selection, and launch environment as one identity contract.
  • Keep native plan request shapes, refusal behavior, versioned templates, and product-side application aligned between the resident runtime and each adapter.
  • Keep MCP scope, server identity, proxy recognition, upstream recovery limits, environment handling, and tool approval context aligned across local client paths.
  • Keep Codex migration readback, authoritative hook checks, relative-path restoration, MCP proxy refresh, remote launch fallback, contained-launch identity, and owner-held publication recovery aligned.
  • Keep Cursor editor and CLI surface state aligned with hook command parsing, fail-closed recovery, attested runtime proof, and launcher removal.
  • Keep Cline transport selection aligned with duplicate detection, live proof, MCP ownership, and uninstall behavior.
  • Keep OpenCode plugin rendering aligned with the active and stale plugin copies, companion launcher refresh, recorded workspace, and runtime overlay.
  • Keep Pi and Oh My Pi generated source aligned with payload bounds, daemon authentication, approval continuation, structured output mediation, stable Desktop Core launchers, and runtime ownership.
  • Keep managed-install rows, proof binding, guidance, owner journals, partial-target reporting, and pending-transition checks aligned across multi-target and standalone installation paths.
  • Keep Paseo provider selection aligned with native provider preflight, provider proof, receipt state, and its limited coverage report.

Important failure modes

TriggerConsequenceGuard
A managed hook, plugin, overlay, manifest, or runtime owner is missing or staleProtection is reported as degraded or the protected event is refused.Repair or reconnect the affected integration.
A prepared target changes before publicationGuard refuses the transition instead of overwriting newer user state.Detect and prepare a fresh transition.
A native plan is malformed or refusedNo partial hook, MCP, launch, or extension change is applied.Repair the runtime or product state, then prepare again.
A later target fails during a multi-target installEarlier target rows remain recorded while the request reports failure.Inspect the recorded rows and repair the failed target before retrying.
Codex's authoritative hook boundary is absent or launch candidates do not share one authorized prefixProtected work remains unavailable or starts in plain mode without remote continuation.Reconcile the hook sources or launch a verified Codex installation again.
Codex's control socket is not private, trusted, live, or owned by the launching userThe TUI does not attach to the local app-server.Use the plain launch or prepare a fresh private server.
Codex publication recovery or its configuration lock cannot completeInstall or uninstall stops before it changes the Codex surface.Complete recovery and retry under the current configuration state.
Claude settings disable hooks or redirect the product to another settings directoryThe installed user hooks are not executed.Resolve the reported settings override, then repair the managed hooks.
Cline has two managed transports or live proof is pendingThe integration is ambiguous or not reported as active.Repair Cline and prove one selected transport with a safe action.
Cursor's selected surface lacks a trusted bridge or managed hookBlocking events fail closed and that surface is not ready.Restore the private authority and rebind the selected surface.
An OpenCode config changes during refresh or cannot be readCompanion launchers remain unchanged for that config and the update reports a warning.Fix the config or rerun the refresh under the config lock.
A Pi-family payload, response, or structured result exceeds bounds or fails identity checksGuard denies the hook or withholds the model-visible result.Retry with bounded content or start a new review in the active session.
A Desktop Core release is superseded or its stable launcher is not runnableA generated extension cannot use that runtime as its protected authority.Restore a runnable stable launcher and reconnect the extension.
A local MCP server uses an unsupported transport or its proxy identity does not match upstreamThe server stays inventory-only or is skipped.Reconnect it with a supported local transport and exact identity.
A remote MCP scan reaches its capGuard cannot claim complete coverage and does not forget unseen declarations.Run a complete scan before reconciliation.
A pending runtime transition or invalid Guard-home redirect existsInstallation stops before a new managed write.Complete recovery or choose a local, trusted Guard home.
Approval continuation changes session, workspace, daemon, tool input, or result digestThe old approval cannot resume the action or forward its result.Start a new review in the active session.

Key files

FileWhy to read it
rust/…/describe.rsDefines supported adapters, aliases, approval channels, install modes, and coverage hints.
rust/…/mod.rsDefines shared harness context, dispatch, detection results, and failure boundaries.
rust/…/managed_install.rsDefines the owner-controlled install and uninstall lifecycle across targets.
rust/…/codex_managed.rsDefines the owner-held Codex publication, recovery, baseline, and live-hook checks.
rust/…/files.rsDefines captured file state, trusted targets, ownership boundaries, and transition files.
rust/…/codex.rsDefines Codex hook events, launch state, and lifecycle entry points.
rust/…/codex_install_plan.rsDefines the complete Codex plan across hooks, MCP servers, backups, shims, and runtime proof.
rust/…/codex_remote_launch.rsDefines Codex remote launch selection, socket trust, stale server handling, and plain fallback.
rust/…/codex_remote_run.rsDefines the guarded Codex launch sequence and process handling.
rust/…/claude.rsDefines Claude Code hook installation, refresh, diagnostics, and removal.
rust/…/claude_install_target.rsDefines Claude settings precedence, hook overrides, scope, and rollback.
rust/…/cursor_surfaces.rsDefines Cursor editor and CLI protection state.
rust/…/cline.rsDefines Cline transport choice, runtime proof, and coverage warnings.
rust/…/opencode_install.rsDefines OpenCode config, plugin, MCP companion, overlay, and manifest planning.
rust/…/opencode_checks.rsDefines OpenCode protection checks and verified launcher refresh.
rust/…/opencode_plugin_render.rsDefines the generated OpenCode pre-tool bridge source.
rust/…/pi_extension_render.v1.jsonDefines the versioned Pi-family extension contract for bounded review and continuation.
rust/…/desktop_core.rsDefines stable Desktop Core launcher selection across version updates.
rust/…/hook_adapter_review_request.rsDefines the native review request and action identity sent to approval.
rust/…/managed_record.rsDefines managed-install proof, store rows, and agent safety guidance.
rust/…/paseo_delegated.rsDefines Paseo's delegation to native provider installs and proof receipts.
rust/…/firewall.rsDefines common MCP, tool, and skill evidence attached to detected artifacts.