Skip to main content

A hot-loading plugin microkernel for Python

Project description

uxok

Python 3.12+ MIT License Code style: ruff CI

Status: 0.x, pre-1.0. Functional and well-tested, but the public API is still settling and may change between releases. If you build on it now, pin to a commit and expect to adjust on upgrade.

A hot-loading plugin microkernel for building self-modifying agentic systems in Python.

Read the docs to learn more!

The docs are a WIP but I will be updating them actively: if you notice something off with them (or the code), please drop me an issue.

Installation

pip install uxok

Quick start

Basic functionality in a single script. The same program split into modules — the structure a real project uses — is in examples/getting_started/ and walked through by the Getting started tutorial. For a fuller host with hot reload and graceful shutdown, see examples/example_host/.

import asyncio
from uxok import Core, Plugin, event, hook

# Plugins are declared by subclassing `Plugin` and defining their name and what they provide in the capability metadata. 
class Model(Plugin):
    def __init__(self):
        super().__init__(name="model", provides={"llm"})

    # Methods are async so that other plugins can call them at random through capabilities.
    async def reply(self, text, persona):
        return f"{persona} you said '{text}'."

    # Hooks are set using a decorator and can be triggered by any plugin. 
    @hook("persona")
    async def voice(self):
        return "Cheerfully:"

# Other plugins can declare dependencies on other plugins' capabilities with "requires=". This builds a dependency graph the kernel resolves for you.
class Agent(Plugin):
    def __init__(self, done):
        super().__init__(name="agent", requires={"llm"})
        self.lines = ["hello there", "what's the weather like?"]
        self.done = done
    
    # Required capabilities are then acquired by name; the kernel hands back the provider.
    async def on_start(self):
        self.llm = await self.get_capability("llm")  # kernel wires it up
        await self.emit("turn")

    # Events are subscribed to in the same fashion as hooks. 
    @event("turn")
    async def speak(self, ev):
        if not self.lines:
            self.done.set()
            return
        line = self.lines.pop(0)
        persona = await self.hook("persona", firstresult=True)
        print(f"user:  {line}")
        print(f"agent: {await self.llm.reply(line, persona)}")
        await self.emit("turn")

# The main program just opens a core and loads plugins onto it; registration order matters, providers first.
async def main():
    done = asyncio.Event()
    async with Core() as core:                # async context manager starts/stops the kernel
        await core.register_plugin(Model())   # provider first
        await core.register_plugin(Agent(done))
        await done.wait()

asyncio.run(main())

Features

  • Hot-Loading — Add/remove/replace plugins at runtime without restart
  • Capability System — Kernel-style dependency resolution with tag-based selection
  • Event-Driven — Non-blocking pub/sub messaging for loose coupling
  • Hook System — Priority-based extension points for pipelines
  • Introspectable — Query the live plugin graph at runtime: filter by capability, hook, event, or status
  • Type Safety — Full protocol-based typing with mypy support

uxok has a microkernel-style architecture: the core provides only essential primitives for building extensible, self-modifying agentic applications — event-driven communication, hook-based extension points, hot-loading plugins with lifecycle management, and capability-based dependency resolution. Everything else is a plugin you can add, remove, or swap at runtime.

Development

git clone https://github.com/hiddenfalls42/uxok.git
cd uxok
pip install -e .[dev]

pytest                       # Run tests
ruff check src tests examples  # Lint
mypy src                     # Type check

Contributing

Contributions welcome!

License

MIT — 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

uxok-0.1.0.tar.gz (105.6 kB view details)

Uploaded Source

Built Distribution

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

uxok-0.1.0-py3-none-any.whl (111.5 kB view details)

Uploaded Python 3

File details

Details for the file uxok-0.1.0.tar.gz.

File metadata

  • Download URL: uxok-0.1.0.tar.gz
  • Upload date:
  • Size: 105.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for uxok-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c71dab786be21fce945a7fade148b25714e0de5802f9dcaf3036ae2b85d8570e
MD5 0fe1cda26b1af7c7b0c5275b81f1af53
BLAKE2b-256 02455cdf0a77d32d073e1bdfc7ec15afc770e9d87811134060c8dd7be913b34a

See more details on using hashes here.

Provenance

The following attestation bundles were made for uxok-0.1.0.tar.gz:

Publisher: release.yml on hiddenfalls42/uxok

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

File details

Details for the file uxok-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: uxok-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 111.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for uxok-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 016e76bb35bad28b3b1604150ddbe3a5eeebb6fd745688c057242c73ed48667d
MD5 ac1255883b9adbf16a7d91c63fd1d584
BLAKE2b-256 82bf77404c339ebd932c8335f8a6c60d4e9bb313867ce2772f3a500df248d418

See more details on using hashes here.

Provenance

The following attestation bundles were made for uxok-0.1.0-py3-none-any.whl:

Publisher: release.yml on hiddenfalls42/uxok

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