services/minecraft/README.md
This workspace runs AIRI's dedicated Minecraft bot. It connects a Mineflayer runtime to a Minecraft server, loads the cognitive stack in src/cognitive, and bridges status, context, and command traffic back to AIRI so the Stage settings shell can observe the service.
This service is on a deprecation path. The current Mineflayer-based bot is expected to be replaced by a Fabric mod based runtime, which will become the primary Minecraft integration surface going forward.
Use this service for current local development and maintenance, but avoid building new long-term features around the Mineflayer runtime unless they are also part of the migration plan.
Do not connect this bot to public servers you do not trust.
The runtime can execute JavaScript-generated action plans to control the bot. Those scripts run in an isolated environment, but they still drive a real local process with access to your Minecraft session, local network reachability, and other machine-side resources. A malicious or hostile server can still cause unwanted actions, or damage to your system.
Treat this service as a local-development and trusted-server tool only.
Install workspace dependencies from the repo root:
pnpm i
Copy the template:
cp services/minecraft/.env services/minecraft/.env.local
Edit services/minecraft/.env.local.
Start the service:
pnpm -F @proj-airi/minecraft-bot dev
Or, from services/minecraft/:
pnpm dev
The bot should automatically connect to both AIRI and the Minecraft server.
AIRI's Minecraft agent is built on a four-layered cognitive architecture inspired by cognitive science, enabling reactive, conscious, and physically grounded behaviors.
graph TB
subgraph "Layer A: Perception"
Events[Raw Events]
EM[Event Manager]
Events --> EM
end
subgraph "Layer B: Reflex (Subconscious)"
RM[Reflex Manager]
FSM[State Machine]
RM --> FSM
end
subgraph "Layer C: Conscious (Reasoning)"
ORC[Orchestrator]
Planner[Planning Agent (LLM)]
Chat[Chat Agent (LLM)]
ORC --> Planner
ORC --> Chat
end
subgraph "Layer D: Action (Execution)"
TE[Task Executor]
AA[Action Agent]
Planner -->|Plan| TE
TE -->|Action Steps| AA
end
EM -->|High Priority| RM
EM -->|All Events| ORC
RM -.->|Inhibition Signal| ORC
ORC -->|Execution Request| TE
style EM fill:#e1f5ff
style RM fill:#fff4e1
style ORC fill:#ffe1f5
style TE fill:#dcedc8
Location: src/cognitive/perception/
The perception layer acts as the sensory input hub, collecting raw Mineflayer signals and translating them into typed events/signals through an event registry + rule engine pipeline.
Pipeline:
events/definitions/* bind Mineflayer events to normalized raw events.EventRegistry emits raw:<modality>:<kind> events to the cognitive event bus.RuleEngine evaluates YAML rules and emits derived signal:* events consumed by Reflex/Conscious layers.Key files:
events/index.tsevents/definitions/*rules/engine.tsrules/*.yamlpipeline.tsLocation: src/cognitive/reflex/
The reflex layer handles immediate, instinctive reactions. It operates on a finite state machine (FSM) pattern for predictable, fast responses.
Components:
reflex-manager.ts): Coordinates reflex behaviorsLocation: src/cognitive/conscious/
The conscious layer handles complex reasoning, planning, and high-level decision-making. No physical execution happens here anymore.
Components:
brain.ts): Event queue orchestration, LLM turn lifecycle, safety/budget guards, debug REPL integration.js-planner.ts): Sandboxed planning/runtime execution against exposed tools/globals.query-dsl.ts): Read-only world/inventory/entity query helpers for planner scripts.task-state.ts): Cancellation token and task lifecycle primitives used by action execution.Location: src/cognitive/action/
The action layer is responsible for the actual execution of tasks in the world. It isolates "Doing" from "Thinking".
Components:
task-executor.ts): Runs normalized action instructions and emits action lifecycle events.action-registry.ts): Validates params and dispatches tool calls.llm-actions.ts): Action/tool definitions and schemas bound to mineflayer skills.Scenario: "Build a house"
Player: "build a house"
ā
[Perception] Event detected
ā
[Conscious] Architect plans the structure
ā
[Action] Executor takes the plan and manages the construction loop:
- Step 1: Collect wood (calls ActionRegistry tool)
- Step 2: Craft planks
- Step 3: Build walls
ā
[Conscious] Brain confirms completion: "House is ready!"
src/
āāā airi/ # AIRI bridge, module shell, status publishing
āāā cognitive/ # š§ Perception ā Reflex ā Conscious ā Action
ā āāā perception/ # Event definitions + rule evaluation
ā ā āāā events/
ā ā ā āāā index.ts
ā ā ā āāā definitions/*
ā ā āāā rules/
ā ā ā āāā *.yaml
ā ā ā āāā engine.ts
ā ā ā āāā loader.ts
ā ā ā āāā matcher.ts
ā ā āāā pipeline.ts
ā āāā reflex/ # Fast, rule-based reactions
ā ā āāā reflex-manager.ts
ā ā āāā runtime.ts
ā ā āāā context.ts
ā ā āāā behaviors/idle-gaze.ts
ā āāā conscious/ # LLM-powered reasoning
ā ā āāā brain.ts # Core reasoning loop/orchestration
ā ā āāā js-planner.ts # JS planning sandbox
ā ā āāā query-dsl.ts # Read-only query runtime
ā ā āāā llm-log.ts # Turn/log query helpers
ā ā āāā task-state.ts # Task lifecycle enums/helpers
ā ā āāā prompts/ # Prompt definitions (e.g., brain-prompt.ts)
ā āāā action/ # Task execution layer
ā ā āāā task-executor.ts # Executes actions and emits lifecycle events
ā ā āāā action-registry.ts # Tool dispatch + schema validation
ā ā āāā llm-actions.ts # Tool catalog
ā ā āāā types.ts
ā āāā event-bus.ts # Event bus core
ā āāā container.ts # Dependency injection wiring
ā āāā index.ts # Cognitive system entrypoint
ā āāā types.ts # Shared cognitive types
āāā composables/
ā āāā config.ts # Environment schema + defaults
ā āāā runtime-config.ts # Persisted local runtime config
ā āāā bot.ts
āāā debug/ # Debug dashboard, MCP REPL, viewer integration
āāā libs/
ā āāā mineflayer/ # Mineflayer bot wrapper/adapters
āāā skills/ # Atomic bot capabilities
āāā plugins/ # Mineflayer/bot plugins
āāā utils/ # Helpers
āāā minecraft-bot-runtime.ts # Bot lifecycle wrapper for reconnect/reconfigure
āāā main.ts # Bot entrypoint
Perception Layer:
Reflex Layer:
Conscious Layer:
pnpm dev - Start the bot in development modepnpm lint - Run ESLintpnpm typecheck - Run TypeScript type checkingpnpm test - Run testsContributions are welcome! Please feel free to submit a Pull Request.