> For the complete documentation index, see [llms.txt](https://docs.tryleia.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tryleia.ai/architecture/images-and-media.md).

# Advanced Workflow

#### [Initialization & Setup](/architecture/images-and-media.md)

1. **Start Leia AI Agent**:

```java
bun start --advanced --agent-type "strategy-agent"
```

2. **Load Game Context**:

```java
const gameContext = {
  playerID: "0xabcdef1234567890",
  resources: { gold: 500, wood: 100 },
  turn: 7,
  availableActions: ["build", "attack", "trade"],
};

leia.loadContext(gameContext);
```

#### Goal Execution:

```java
const goal = {
  description: "Build a fortress to protect resources",
  subgoals: [
    { action: "GATHER_RESOURCES", conditions: { wood: 200, stone: 100 } },
    { action: "BUILD_FORTRESS", conditions: { location: [50, 75], resourcesSpent: { wood: 150, stone: 100 } } },
  ],
};

leia.executeGoal(goal);
```

#### Dynamic Monitoring:

```java
// Monitoring agent's actions and reasoning
leia.on("action:start", (data) => {
  console.log(`🔄 Agent action started: ${data.action}`);
});

leia.on("action:complete", (data) => {
  console.log(`✅ Action completed: ${data.action.type} with result: ${data.result}`);
});
```
