# 23swccp/m9a architecture

> Architecture diagram of the GitHub repository 23swccp/m9a, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/23swccp/m9a
- Repository: https://github.com/23swccp/m9a

## Overview

M9A automates gameplay through image recognition and simulated control, with MaaFramework hosting the agent runtime. The principal flow is client launch → agent startup and custom registration → task dispatch to recognition and action handlers → in-game results. The README documents a broad set of daily, combat, event, account, and reward tasks. Resource checks and hot updates support runtime operation. The graph groups task handlers by domain; some feature mappings are documented but their internal dispatch paths were not sampled, so those links are omitted.

Main entry points: [`agent/agent_runtime.py`](https://github.com/23swccp/m9a/blob/main/agent/agent_runtime.py) (Agent runtime), [`agent/utils/resource_updater.py`](https://github.com/23swccp/m9a/blob/main/agent/utils/resource_updater.py) (Resource updater), [`agent/utils/maa_types.py`](https://github.com/23swccp/m9a/blob/main/agent/utils/maa_types.py) (Recognition types), [`agent/custom/reco/auto_promotion.py`](https://github.com/23swccp/m9a/blob/main/agent/custom/reco/auto_promotion.py) (Auto promotion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Agent runtime"]
  node_entry["Agent entry<br/>[main.py]"]
  node_agent_runtime["Agent runtime<br/>[agent_runtime.py]"]
  node_custom_registry["Custom registration<br/>[__init__.py]"]
end

subgraph group_gameplay["Gameplay tasks"]
  node_activity_tasks["Daily &amp; activity tasks"]
  node_combat_task["Combat task<br/>[combat.py]"]
  node_induction_task["Induction task"]
  node_silence_task["Silence event task"]
  node_account_tasks["Account &amp; codes"]
  node_other_tasks["Special event tasks"]
end

subgraph group_recognition["Recognition logic"]
  node_promotion_reco["Auto promotion<br/>[auto_promotion.py]"]
  node_trail_reco["Auto trail<br/>[auto_trail.py]"]
  node_combat_reco["Combat recognition<br/>[combat.py]"]
  node_general_reco["General recognition<br/>[general.py]"]
  node_sos_reco["Silence recognition"]
end

subgraph group_support["Runtime support"]
  node_resource_version["Resource version check"]
  node_resource_update["Resource updater"]
  node_http["HTTP session<br/>[http_session.py]"]
  node_params["Parameter handling<br/>[params.py]"]
  node_maa_types["Recognition types<br/>[maa_types.py]"]
  node_logger["Logging<br/>[logger.py]"]
  node_time["Time utilities<br/>[time.py]"]
end

node_client(("Maa client"))
node_maa["MaaFramework"]

node_client -->|"launches"| node_entry
node_entry -->|"calls"| node_agent_runtime
node_agent_runtime -->|"registers"| node_custom_registry
node_agent_runtime -->|"starts agent"| node_maa
node_agent_runtime -->|"checks versions"| node_resource_version
node_agent_runtime -->|"updates resources"| node_resource_update
node_resource_version -->|"uses"| node_http
node_resource_update -->|"uses"| node_http
node_combat_task -->|"uses"| node_combat_reco
node_promotion_reco -->|"resets state"| node_trail_reco
node_silence_task -->|"uses"| node_maa_types
node_promotion_reco -->|"parses parameters"| node_params
node_combat_reco -->|"uses"| node_maa_types
node_general_reco -->|"uses"| node_maa_types
node_resource_update -->|"uses"| node_time
node_agent_runtime -->|"logs"| node_logger

click node_entry "https://github.com/23swccp/m9a/blob/main/agent/main.py"
click node_agent_runtime "https://github.com/23swccp/m9a/blob/main/agent/agent_runtime.py"
click node_custom_registry "https://github.com/23swccp/m9a/blob/main/agent/custom/__init__.py"
click node_activity_tasks "https://github.com/23swccp/m9a/tree/main/agent/custom/action"
click node_combat_task "https://github.com/23swccp/m9a/blob/main/agent/custom/action/combat.py"
click node_induction_task "https://github.com/23swccp/m9a/blob/main/agent/custom/action/complete_induction.py"
click node_silence_task "https://github.com/23swccp/m9a/blob/main/agent/custom/action/syndrome_of_silence.py"
click node_account_tasks "https://github.com/23swccp/m9a/tree/main/agent/custom/action"
click node_other_tasks "https://github.com/23swccp/m9a/tree/main/agent/custom/action"
click node_promotion_reco "https://github.com/23swccp/m9a/blob/main/agent/custom/reco/auto_promotion.py"
click node_trail_reco "https://github.com/23swccp/m9a/blob/main/agent/custom/reco/auto_trail.py"
click node_combat_reco "https://github.com/23swccp/m9a/blob/main/agent/custom/reco/combat.py"
click node_general_reco "https://github.com/23swccp/m9a/blob/main/agent/custom/reco/general.py"
click node_sos_reco "https://github.com/23swccp/m9a/blob/main/agent/custom/reco/syndrome_of_silence.py"
click node_resource_version "https://github.com/23swccp/m9a/blob/main/agent/utils/manifest_checker.py"
click node_resource_update "https://github.com/23swccp/m9a/blob/main/agent/utils/resource_updater.py"
click node_http "https://github.com/23swccp/m9a/blob/main/agent/utils/http_session.py"
click node_params "https://github.com/23swccp/m9a/blob/main/agent/utils/params.py"
click node_maa_types "https://github.com/23swccp/m9a/blob/main/agent/utils/maa_types.py"
click node_logger "https://github.com/23swccp/m9a/blob/main/agent/utils/logger.py"
click node_time "https://github.com/23swccp/m9a/blob/main/agent/utils/time.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_agent_runtime,node_custom_registry,node_client toneBlue
class node_activity_tasks,node_combat_task,node_induction_task,node_silence_task,node_account_tasks,node_other_tasks toneAmber
class node_promotion_reco,node_trail_reco,node_combat_reco,node_general_reco,node_sos_reco toneMint
class node_resource_version,node_resource_update,node_http,node_params,node_maa_types,node_logger,node_time toneRose
class node_maa toneIndigo
```

## Components

### Agent runtime

- [Agent entry](https://github.com/23swccp/m9a/blob/main/agent/main.py): `agent/main.py`
- [Agent runtime](https://github.com/23swccp/m9a/blob/main/agent/agent_runtime.py): `agent/agent_runtime.py`
- [Custom registration](https://github.com/23swccp/m9a/blob/main/agent/custom/__init__.py): `agent/custom/__init__.py`

### Gameplay tasks

- [Daily & activity tasks](https://github.com/23swccp/m9a/tree/main/agent/custom/action): `agent/custom/action`
- [Combat task](https://github.com/23swccp/m9a/blob/main/agent/custom/action/combat.py): `agent/custom/action/combat.py`
- [Induction task](https://github.com/23swccp/m9a/blob/main/agent/custom/action/complete_induction.py): `agent/custom/action/complete_induction.py`
- [Silence event task](https://github.com/23swccp/m9a/blob/main/agent/custom/action/syndrome_of_silence.py): `agent/custom/action/syndrome_of_silence.py`
- [Account & codes](https://github.com/23swccp/m9a/tree/main/agent/custom/action): `agent/custom/action`
- [Special event tasks](https://github.com/23swccp/m9a/tree/main/agent/custom/action): `agent/custom/action`

### Recognition logic

- [Auto promotion](https://github.com/23swccp/m9a/blob/main/agent/custom/reco/auto_promotion.py): `agent/custom/reco/auto_promotion.py`
- [Auto trail](https://github.com/23swccp/m9a/blob/main/agent/custom/reco/auto_trail.py): `agent/custom/reco/auto_trail.py`
- [Combat recognition](https://github.com/23swccp/m9a/blob/main/agent/custom/reco/combat.py): `agent/custom/reco/combat.py`
- [General recognition](https://github.com/23swccp/m9a/blob/main/agent/custom/reco/general.py): `agent/custom/reco/general.py`
- [Silence recognition](https://github.com/23swccp/m9a/blob/main/agent/custom/reco/syndrome_of_silence.py): `agent/custom/reco/syndrome_of_silence.py`

### Runtime support

- [Resource version check](https://github.com/23swccp/m9a/blob/main/agent/utils/manifest_checker.py): `agent/utils/manifest_checker.py`
- [Resource updater](https://github.com/23swccp/m9a/blob/main/agent/utils/resource_updater.py): `agent/utils/resource_updater.py`
- [HTTP session](https://github.com/23swccp/m9a/blob/main/agent/utils/http_session.py): `agent/utils/http_session.py`
- [Parameter handling](https://github.com/23swccp/m9a/blob/main/agent/utils/params.py): `agent/utils/params.py`
- [Recognition types](https://github.com/23swccp/m9a/blob/main/agent/utils/maa_types.py): `agent/utils/maa_types.py`
- [Logging](https://github.com/23swccp/m9a/blob/main/agent/utils/logger.py): `agent/utils/logger.py`
- [Time utilities](https://github.com/23swccp/m9a/blob/main/agent/utils/time.py): `agent/utils/time.py`

### Other components

- **Maa client**
- **MaaFramework**

## Connections

- Maa client → Agent entry: launches (evidence: `README.md`)
- Agent entry → Agent runtime: calls (evidence: `agent/main.py`)
- Agent runtime → Custom registration: registers (evidence: `agent/agent_runtime.py`)
- Agent runtime → MaaFramework: starts agent (evidence: `agent/agent_runtime.py`)
- Agent runtime → Resource version check: checks versions (evidence: `agent/agent_runtime.py`)
- Agent runtime → Resource updater: updates resources (evidence: `agent/agent_runtime.py`)
- Resource version check → HTTP session: uses (evidence: `agent/utils/manifest_checker.py`)
- Resource updater → HTTP session: uses (evidence: `agent/utils/resource_updater.py`)
- Combat task → Combat recognition: uses (evidence: `agent/custom/action/combat.py`)
- Auto promotion → Auto trail: resets state (evidence: `agent/custom/reco/auto_promotion.py`)
- Silence event task → Recognition types: uses (evidence: `agent/custom/action/syndrome_of_silence.py`)
- Auto promotion → Parameter handling: parses parameters (evidence: `agent/custom/reco/auto_promotion.py`)
- Combat recognition → Recognition types: uses (evidence: `agent/custom/reco/combat.py`)
- General recognition → Recognition types: uses (evidence: `agent/custom/reco/general.py`)
- Resource updater → Time utilities: uses (evidence: `agent/utils/resource_updater.py`)
- Agent runtime → Logging: logs (evidence: `agent/agent_runtime.py`)
