AIOS API Reference

Built for Developers. Powered by Performance.

Overview

The AIOS API exposes a set of core developer utilities that make addon development faster, cleaner, and more efficient. This page serves as the central documentation hub for AIOS Core and its built-in Lean optimization layer.

AIOS provides services through its ServiceRegistry and exposes global helper functions for memory pooling, logging, and inter-addon communication.

Core API

FunctionDescription
AIOS:CoreLog(msg, level?, tag?) Writes a structured log message to the AIOS logging system or prints it to chat if no logger service exists.
AIOS:SetLogLevel(level) Changes the active logging verbosity. Levels: 1=ERROR, 2=WARN, 3=INFO, 4=DEBUG.
AIOS:GetLogLevel() Returns the current logging level.
AIOS:GetDiagnostics() Returns a lightweight diagnostic summary: registered services, plugins, event count, and system state.
AIOS:GetMeta() Provides full metadata: version, expansion, Lean metrics, and system features.
AIOS:WithLean(fn) Executes a function inside a pooled table environment, automatically recycling memory on completion.
AIOS.ServiceRegistry:Define(name, version, factory, options) Registers a service globally within AIOS Core. Each service defines its interface and version.
AIOS.ServiceRegistry:Get(name) Retrieves an active service instance from the registry.
AIOS.SignalHub:Emit(event, ...) Sends cross-addon signals to all listeners subscribed through SignalHub.

Lean Memory Engine

The Lean subsystem provides a high-performance memory pooling system for tables and strings. It can operate automatically or be accessed directly by developers for granular control.

FunctionDescription
AIOS.Lean:getMetrics() Returns runtime statistics: recycled tables, strings interned, memory saved, lazy loads, and mode.
AIOS.Lean:getPoolStats() Provides a breakdown of total pool count and active tables.
AIOS.Lean:setPerformanceMode(mode) Switches between modes: "minimal", "balanced", "aggressive".
AIOS.Lean:getTable(size) Allocates a table from the pool (or creates one) for temporary operations.
AIOS.Lean:recycleTable(tbl) Recycles a table back into the Lean pool for reuse.
AIOS.Lean:forceGarbageCollection() Triggers an explicit memory cleanup for benchmarking and profiling.
-- Example: Lean Performance Mode Switch
AIOS.Lean:setPerformanceMode("aggressive")

-- Example: Temporary memory-safe computation
local result = AIOS:WithLean(function(temp)
    temp.data = "optimized"
    return #temp.data
end)
print("Result:", result)

Signals & Events

AIOS provides two independent communication systems for inter-addon and in-addon signaling:

-- Example: Listening for an AIOS signal
AIOS.SignalHub:Listen("AIOS_Core_Ready", function()
    print("AIOS Core Ready - Begin Initialization")
end)

-- Example: Emitting a signal
AIOS.SignalHub:Emit("MyAddon_Ready", "Plugin active")

Slash Commands

AIOS Core includes several built-in commands for developers to monitor performance and system state.

CommandAction
/aiosdiagShows a summary of AIOS Core status and Lean memory metrics.
/aiosdiag fullDisplays complete diagnostic output for services, signals, and Lean.
/aiosleanDisplays current Lean status, pools, and optimization mode.
/aioslean mode [mode]Changes Lean performance profile.
/aioslean gcForces a manual garbage collection cycle.

Developer FAQ

Can AIOS replace Ace3?

Yes. AIOS provides similar architecture benefits but is lighter, faster, and more modular. It uses a true registry model instead of global tables.

Is Lean required?

No. Lean automatically initializes with AIOS but can be disabled if memory optimization is undesired.

Can addons share data through AIOS?

Yes. Addons can communicate via SignalHub and ServiceRegistry, allowing safe cross-addon collaboration.

How secure is AIOS Core?

AIOS has been built to comply with Blizzard’s sandbox rules. It operates entirely within Lua’s secure environment with no taint propagation.