Skip to main content

Guards plugin for Axio TUI

Project description

axio-tui-guards

PyPI Python License: MIT

Permission guard plugins for axio-tui.

Guards intercept tool calls before execution and can allow, modify, or deny them. Ships two guards: a path-access guard that asks the user before touching filesystem locations, and an LLM-based guard that reviews tool calls for safety.

Features

  • PathGuard — intercepts tools that touch the filesystem; prompts the user once per directory and remembers the decision for the session
  • LLMGuard — runs a secondary LLM call to review each tool invocation before allowing it
  • PermissionGuard protocol — both guards implement axio.PermissionGuard and compose cleanly
  • TUI-aware — prompts appear as native axio-tui dialogs, not blocking stdin reads

Installation

pip install axio-tui-guards

Or install as part of the TUI bundle:

pip install "axio-tui[guards]"

Guards

PathGuard

Intercepts tool calls that contain filesystem paths (file_path, filename, directory, path, cwd). On the first access to a new directory it asks the user to allow, allow all (subtree), or deny.

from axio_tui_guards.guards import PathGuard
from axio_tools_local.write_file import WriteFile
from axio.tool import Tool

guard = PathGuard()   # uses TUI prompt_fn by default

tool = Tool(
    name="write_file",
    description="Write a file",
    handler=WriteFile,
    guards=(guard,),
)

Decision caching:

  • Allow — grants access to the parent directory for the current session
  • Allow all — grants access to the directory and all subdirectories
  • Deny — blocks this path; raises GuardError immediately on retry

LLMGuard

Uses a secondary LLM call to review the tool handler arguments before execution. If the reviewer deems the call unsafe it raises GuardError with the reason.

from axio_tui_guards.guards import LLMGuard
from axio.agent import Agent
from axio.context import MemoryContextStore
from axio.testing import StubTransport, make_text_response

reviewer = Agent(system="", tools=[], transport=StubTransport([make_text_response("allow")]))
guard = LLMGuard(agent=reviewer, context=MemoryContextStore())

Composing guards

Guards are applied in order — attach both for layered protection:

from axio_tui_guards.guards import PathGuard, LLMGuard
from axio_tools_local.shell import Shell
from axio.agent import Agent
from axio.context import MemoryContextStore
from axio.testing import StubTransport, make_text_response
from axio.tool import Tool

reviewer = Agent(system="", tools=[], transport=StubTransport([make_text_response("allow")]))
tool = Tool(
    name="shell",
    description="Run shell commands",
    handler=Shell,
    guards=(PathGuard(), LLMGuard(agent=reviewer, context=MemoryContextStore())),
)

Custom guards

Implement the PermissionGuard protocol to write your own:

from axio.permission import PermissionGuard
from axio.exceptions import GuardError

class MyGuard(PermissionGuard):
    async def check(self, handler):
        if "rm -rf" in getattr(handler, "command", ""):
            raise GuardError("Refusing to run rm -rf")
        return handler

Plugin registration

[project.entry-points."axio.guards"]
path = "axio_tui_guards.guards:PathGuard"
llm  = "axio_tui_guards.guards:LLMGuard"

Part of the axio ecosystem

axio · axio-tui · axio-tui-rag

License

MIT

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

axio_tui_guards-0.6.0.tar.gz (86.3 kB view details)

Uploaded Source

Built Distribution

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

axio_tui_guards-0.6.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file axio_tui_guards-0.6.0.tar.gz.

File metadata

  • Download URL: axio_tui_guards-0.6.0.tar.gz
  • Upload date:
  • Size: 86.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for axio_tui_guards-0.6.0.tar.gz
Algorithm Hash digest
SHA256 ea40f4507f1f8675a8e575e156c391c3ccf6947e2be125c917b7f0cfd4834c88
MD5 5f12e7fe2e3ac9173c789ff6149b6f70
BLAKE2b-256 03dde74def8881b96d43fa059475368adb5b14b188b0f496a728eff7ff0d44db

See more details on using hashes here.

Provenance

The following attestation bundles were made for axio_tui_guards-0.6.0.tar.gz:

Publisher: publish.yml on axio-agent/monorepo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file axio_tui_guards-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for axio_tui_guards-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a765725962449bd830aa1781e42522da19d667e1c04f6627f6cdfdb1a1fa3631
MD5 cb8d8c1b27008805cfd9c0408f0a5c77
BLAKE2b-256 0be9da841f2ba958d00a65db2f035ec37f3473eb6ebbd8d05906aabd71dc11c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for axio_tui_guards-0.6.0-py3-none-any.whl:

Publisher: publish.yml on axio-agent/monorepo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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