API Reference
Programmatic usage of Phoenix Agent's core modules.
PhoenixEngine
from phoenix_agent.core.engine import PhoenixEngine
engine = PhoenixEngine()
await engine.start()
# Execute a command
result = await engine.execute_command("/stats")
# Chat with AI
response = await engine.execute_command("ouvre le navigateur")
# Undo/Redo
engine.undo()
engine.redo()
# Timeline
history = engine.timeline
await engine.stop()
Event Bus
from phoenix_agent.core.events import EventBus, Event, EventType
bus = EventBus()
async def on_command(event: Event):
print(f"Command: {event.data['command']}")
bus.subscribe(EventType.COMMAND_EXECUTED, on_command)
await bus.publish(Event(type=EventType.COMMAND_EXECUTED, data={"command": "test"}))
Provider Manager
from phoenix_agent.providers.manager import ProviderManager
# List providers
providers = engine.providers.providers
# Set active
engine.providers.set_active("openai", "gpt-4o")
# Chat
response = await engine.providers.chat("Hello", system_prompt="...")
Security Manager
# Encrypt/decrypt API keys
engine.security.encrypt_api_key("openai", "sk-...")
key = engine.security.decrypt_api_key("openai")
# Trust mode
await engine.security.enable_trust()
await engine.security.disable_trust()
# Permissions
engine.security.grant_permission("mouse_control")
engine.security.check_permission("shell_execute")
# Audit log
log = engine.security.audit_log
Memory Store
# Conversations
engine.memory.add_message("user", "Hello")
recent = engine.memory.get_recent(20)
results = engine.memory.search("python")
# Knowledge base
engine.memory.store_knowledge("key", "value", tags=["tag1"])
value = engine.memory.get_knowledge("key")
results = engine.memory.search_knowledge("query")
Win32 Mouse
from phoenix_agent.mouse.win_native import WinMouse, WinKeyboard
mouse = WinMouse()
mouse.position() # (x, y)
mouse.move_to(500, 300)
mouse.click(500, 300)
mouse.double_click(500, 300)
mouse.right_click(500, 300)
mouse.scroll(-3) # scroll down
mouse.drag_to(800, 600)
mouse.screen_size() # (1920, 1080)
keyboard = WinKeyboard()
keyboard.type_text("Hello World")
keyboard.hotkey("ctrl", "c")
keyboard.press("enter")
Plugin Manager
# Discover plugins
plugins = engine.plugins.discover()
# Load/unload
plugin = engine.plugins.load("myplugin")
engine.plugins.unload("myplugin")
engine.plugins.reload("myplugin")
# Create template
path = engine.plugins.create_template("myplugin")
Decision Journal
engine.journal.record(
decision="executed_command",
reason="User requested file creation",
alternatives=["manual creation"],
context={"command": "mkdir test"}
)
recent = engine.journal.get_recent(10)
results = engine.journal.search("file")