Skip to main content

Theus Agentic Framework (formerly POP SDK) - Industrial Grade Process-Oriented Programming

Project description

Theus (formerly POP SDK)

The "Operating System" for AI Agents and Complex Systems.

PyPI version License: MIT

Theus (Process-Oriented Programming) is a paradigm shift designed for building robust, stateful AI agents. Unlike OOP which encapsulates state and behavior, Theus decouples them completely to ensure:

  1. Transactional Integrity: Every action is atomic.
  2. Safety by Default: Inputs are immutable; outputs are strictly contracted.
  3. Observability: Every state change is logged and reversible.

🌟 Key Features

🛡️ Safety & Security

  • Context Locking ("The Vault"): Prevents accidental state mutation from external code (main.py). Warning mode by default, Strict mode (crash) for CI.
  • Frozen Inputs: Process inputs are wrapped in FrozenList/FrozenDict. Side-effects are blocked at runtime.
  • Strict Contracts: Explicit @process(inputs=[...], outputs=[...]) decorators prevent "State Spaghetti".

⚡ Developer Experience

  • POP CLI: Bootstrap new projects instantly with pop init.
  • Hybrid Guard: Friendly warnings for rapid dev, Strict enforcement for interaction.
  • Zero-Dependency Core: Pure Python. Compatible with PyTorch, TensorFlow, or any other library.

📦 Installation

pip install theus

🚀 Quick Start (CLI)

The fastest way to start is using the CLI tool.

Note: We recommend using python -m theus to ensure compatibility across all operating systems.

# 1. Initialize a new project
python -m theus init my_agent

# 2. Enter directory
cd my_agent

# 3. Run the skeleton agent
python main.py

Arguments:

  • python -m theus init <name>: Create a new project folder.
  • python -m theus init .: Initialize in current directory.


🛠️ Advanced CLI Tools

Beyond initialization, Theus provides tools for Audit & Schema management.

Audit Generation

Start from code, generate the rules.

python -m theus audit gen-spec

Schema Generation

Generate Context Schema from your Pydantic models.

python -m theus schema gen --context-file src/context.py

📚 Manual Usage

1. Define Context (Data)

Using Pydantic V2 for robust verification.

from pydantic import BaseModel

class MyGlobal(BaseModel):
    counter: int = 0

class MySystem(BaseModel):
    global_ctx: MyGlobal
    # ... domain_ctx ...

2. Define Process (Logic)

from theus import process

@process(
    inputs=['global.counter'], 
    outputs=['global.counter']
)
def increment(ctx):
    # Valid: Declared in outputs
    ctx.global_ctx.counter += 1
    return "Incremented"

@process(inputs=['global.counter'], outputs=[])
def illegal_write(ctx):
    # INVALID: Read-Only Input
    # Raises ContractViolationError
    ctx.global_ctx.counter += 1 

3. Run Engine

from theus import POPEngine

system = MySystem(global_ctx=MyGlobal())
engine = POPEngine(system) # Default: Warning Mode

engine.register_process("inc", increment)
engine.run_process("inc")

⚙️ Configuration

You can control strictness via Environment Variables (supported in .env files):

Variable Values Description
THEUS_STRICT_MODE 1, true Crash on Violation: External code (Main Thread) cannot modify Context directly.
0, false Log Warning: External code can modify context, but it logs a LockViolationWarning.

Why Strict Mode? (The Vault)

Theus enforces Context Integrity.

  • In Strict Mode (1), the Context is "Vaulted". Only registered Processes can modify it. Any attempt to modify ctx.domain from main.py without using engine.edit() will raise an error and crash the agent. This is recommended for Production/CI to prevent "State Spaghetti".
  • In Warning Mode (0), violations are logged but permitted. This is useful for rapid prototyping.

(Legacy POP_STRICT_MODE is also supported for backward compatibility).

Safe External Mutation

To modify context from main.py without triggering warnings/errors, use the explicit API:

with engine.edit() as ctx:
    ctx.domain.my_var = 100

📄 License

MIT License. See LICENSE for details.

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

theus-0.1.4.tar.gz (29.9 kB view details)

Uploaded Source

Built Distribution

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

theus-0.1.4-py3-none-any.whl (26.0 kB view details)

Uploaded Python 3

File details

Details for the file theus-0.1.4.tar.gz.

File metadata

  • Download URL: theus-0.1.4.tar.gz
  • Upload date:
  • Size: 29.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for theus-0.1.4.tar.gz
Algorithm Hash digest
SHA256 9ba5746ef497576c6771014e98c1b326a1e169fc509cf9c5f33b79991c6b58a9
MD5 f2b2ea582672583957bb996b4674d853
BLAKE2b-256 78218ad147c8f41be517fcfa4d01ce939f25cfdb0485880216e05e4f13c8ff79

See more details on using hashes here.

File details

Details for the file theus-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: theus-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 26.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for theus-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b994440f7e49755a6d4a2fc61a0dd24c7bdaff7680d60053b207d14f3ccc704f
MD5 fb76a73e3e46358c29dd9c249aa2889b
BLAKE2b-256 43f09d2e675178a47f4457c47d9966a54b519e95f55aa7802ae61d96a64ffe9a

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