Project Interface V2
Note: This document is about the creation and usage of
ProjectInterface. In this document, PI refers toProjectInterfaceand Client refers to the tool that can process PI.
Introduction
The so-called ProjectInterface is a standardized project structure declaration for MaaFramework. It currently consists of a single file, interface.json. By defining a PI, you can leverage various derivative tools of MaaFramework. Therefore, even if you intend to integrate solely using a general-purpose programming language, it is recommended to define a PI containing the basic information.
UI Support
- MFAAvalonia
- MaaPiCli
- MFW-CFA
interface.json
This file can be validated and receive hints via the schema file. When opening the project template folder with VSCode, the schema and file will be automatically associated.
Overall Structure
interface_version
numberThe interface version number, currently 2, fixed and required. Used to identify the ProjectInterface protocol version.languages
objectMulti-language support configuration. Keys are language codes, values are paths to corresponding translation files. If not specified, only Chinese is supported by default. File paths are relative to the directory containing interface.json.jsonc"languages": { "zh_cn": "interface_zh.json", "en_us": "interface_en.json" }name
stringThe unique project identifier, used as the project ID.label
stringThe project display name, shown in the user interface. Supports internationalized strings (starting with$). If not set, the value of thenamefield is displayed. Optional.jsonc{ "name": "MyProject", "label": "$project_name" // Internationalized project name }title
stringThe window title. The Client will display this content directly without additional decoration. Optional, defaults to a combination ofnameandversion. Supports internationalization (starting with$).icon
stringThe application icon file path, relative to the project root directory. If not specified, the default icon is used. Supports internationalization (starting with$).mirrorchyan_rid
stringMirrorChyan resource package identifier, used for resource management and distribution.mirrorchyan_multiplatform
booleanWhether multi-platform is supported, affecting resource package packaging and distribution strategies.github
stringThe project's GitHub repository URL, used for version update checking and issue feedback. Software Update Convention:After painful lessons from version history,we expect general-purpose UIs to only provide update functionality for this GitHub release, not separate updates for the UI itself or MaaFW. Resource authors should package their specified UI/MaaFW when releasing, ensuring that a specific resource version on the user side corresponds to a unique UI and MaaFW version, avoiding various issues caused by version mixing.version
stringThe project version number. The Client can display it to users and use it for version update checking.contact
stringContact information, displayed on the "About" page. Supports file paths, URLs, or direct text. Content supports Markdown format. Supports internationalization (starting with$).license
stringProject license information, displayed on the "About" page. Supports file paths, URLs, or direct text. Content supports Markdown format. Supports internationalization (starting with$).welcome
stringWelcome message, displayed in a popup when the user first uses the application, can also be used as an announcement. Supports file paths, URLs, or direct text. Content supports Markdown format. The system records the displayed content and will show the popup again when the content is updated. Supports internationalization (starting with$).description
stringProject description information, displayed on the "About" page. Supports file paths, URLs, or direct text. Content supports Markdown format. Supports internationalization (starting with$).controller
object[]Controller configuration, an array of objects containing preset controller information.name
stringUnique name identifier, used as the controller ID.label
stringDisplay name, shown in the user interface. Supports internationalized strings (starting with$). If not set, the value of thenamefield is displayed.description
stringDetailed controller description. Supports file paths, URLs, or direct text. Content supports Markdown format. Optional. Supports internationalization (starting with$).icon
stringController icon file path, relative to the project root directory. Optional. Supports internationalization (starting with$).type
'Adb' | 'Win32'Controller type; valid values areAdbandWin32.display_short_side
numberThe short side length of the default scaled resolution, used for screen adaptation. Optional, defaults to 720. Mutually exclusive withdisplay_long_sideanddisplay_raw.display_long_side
numberThe long side length of the default scaled resolution, used for screen adaptation. Optional. Mutually exclusive withdisplay_short_sideanddisplay_raw.display_raw
booleanWhether to use the original resolution for screenshots without scaling. Optional, defaults to false. Mutually exclusive with scaled resolution settings.adb
objectSpecific configuration for theAdbcontroller.Note: In V2 protocol, the input/screencap methods for Adb controllers are automatically detected and selected by MaaFramework, no manual configuration required.
win32
objectSpecific configuration for theWin32controller.class_regex
stringOptional. The regular expression used to search for window class names by the Win32 controller.window_regex
stringOptional. The regular expression used to search for window titles by the Win32 controller.mouse
stringOptional. The mouse control method for the Win32 controller. If not provided, the default is used. See Control Methods for details.keyboard
stringOptional. The keyboard control method for the Win32 controller. If not provided, the default is used. See Control Methods for details.screencap
stringOptional. The screenshot method for the Win32 controller. If not provided, the default is used. See Control Methods for details.
resource
object[]Resource configuration, an array of objects containing information about resource loading.name
stringUnique name identifier, used as the resource package ID.label
stringDisplay name, shown in the user interface. Supports internationalized strings (starting with$). If not set, the value of thenamefield is displayed. Optional.description
stringDetailed resource description. Supports file paths, URLs, or direct text. Content supports Markdown format. Optional.icon
stringResource icon file path, relative to the project root directory. Optional. Supports internationalization (starting with$).path
string[]An array of paths to load. If multiple paths are provided, they will be loaded sequentially; resources loaded later will override those loaded earlier. File paths are relative to the directory containing interface.json. Note: Resources include not onlypipelinebut alsoimageandmodel. Therefore, do not specify thepipelinedirectory directly.controller
string[]Optional. Specifies the list of controller types supported by this resource package. Array elements should correspond to thenamefield in thecontrollerconfiguration. If not specified, all controller types are supported.When a user selects a controller, only resource packages that support that controller will be displayed in the user interface for selection. This allows providing specially optimized resource packages for different controller types.
jsonc"resource": [ { "name": "AndroidSpecificResource", "label": "$AndroidSpecificResource", "controller": ["Android"], "path": ["resource_android"] }, { "name": "GeneralResource", "label": "$GeneralResource", "path": ["resource"] } ]
agent
objectAgent configuration, an object containing information about the subprocess (AgentServer).child_exec
stringThe subprocess path, an executable file available in the system path. For example, if the Python path exists in the environment variables (system or user), you can simply write"python". CWD is the directory containing interface.json.child_args
string[]Optional. An array of arguments for the subprocess.jsonc"agent": { "child_exec": "python", "child_args": [ "./agent/main.py", // Note: CWD is the directory containing interface.json "--test-mode" // Fixed string, passed as-is ] }identifier
stringOptional. A connection identifier used to create a communication socket. If provided, it will be used; otherwise, one is created automatically.
task
object[]Task configuration, an array of objects containing information about executable tasks.name
stringUnique task identifier, used as the task ID.label
stringTask display name, shown in the user interface. Supports internationalized strings (starting with$). If not set, the value of thenamefield is displayed. Optional.entry
stringThe task entry, which is the name of theTaskin thepipeline.default_check
booleanWhether this task is selected by default. Optional, defaults to false. The Client will use this value to determine whether to check this task by default during initialization.description
stringDetailed task description to help users understand the task's functionality. Supports file paths, URLs, or direct text. Content supports Markdown format. Optional.icon
stringTask icon file path, relative to the project root directory. Used for display in the user interface. Optional. Supports internationalization (starting with$).resource
string[]Optional. Specifies the list of resource packages supported by this task. Array elements should correspond to thenamefield in theresourceconfiguration. If not specified, this task is available in all resource packages.When a user selects a resource package, only tasks that support that resource package will be displayed in the user interface for selection. This allows providing specialized task configurations for different resource packages, such as event tasks that are only available in specific resource packages.
jsonc"task": [ { "name": "EventTask", "label": "$EventTask", "entry": "ActivityTask", "resource": ["Official"], "description": "Event task only available in the Official resource package" }, { "name": "CommonTask", "label": "$CommonTask", "entry": "CommonTask" } ]pipeline_override
pipelineOptional. Task parameters that override the loaded resources when executing the task. This structure is exactly the same as the JSON file in thepipelineand must include the task name part, for example:jsonc"pipeline_override": { "Quit": { "enabled": true } }option
string[]Optional. Task configuration options, an array containing keys from subsequentoptionobjects. The Client will prompt the user to make selections based on these.The Client can display the options in the order provided in the
optionarray.
option
record<string, object>Definition of configuration options, an object mapping containing information about each option.key Unique name identifier; tasks will reference this name.
type
stringThe option type. Optional, defaults to"select". Valid values:"select": Dropdown selection box, user selects from predefined options"input": User input field, allows manual input"switch": Toggle switch, Yes or No
label
stringOption display label, shown in the user interface. Supports internationalized strings (starting with$). Optional.description
stringDetailed option description to help users understand the option's purpose. Supports file paths, URLs, or direct text. Content supports Markdown format. Optional. Supports internationalization (starting with$).icon
stringOption icon file path, relative to the project root directory. Optional. Supports internationalization (starting with$).cases
object[]Used only whentypeis"select"or"switch". Available options, an array of objects containing information about each option.Note: When
typeis"switch", only two cases are supported, and the following rules must be followed:- If
case.nameis one of"Yes","yes","Y", or"y", that case will be recognized as the Yes option - Other
case.namevalues will be recognized as the No option - The Client will match the user's Y/N input based on the case's name
It is recommended to use
"Yes"and"No"as the names of the two cases to ensure consistency across different Clients.The Client can display the options in the order provided in the
casesarray.name
stringUnique option identifier, used as the option ID.label
stringOption display name, shown in the user interface. Supports internationalized strings (starting with$). If not set, the value of thenamefield is displayed. Optional.description
stringDetailed option description. Supports file paths, URLs, or direct text. Content supports Markdown format. Optional. Supports internationalization (starting with$).icon
stringOption icon file path, relative to the project root directory. Optional. Supports internationalization (starting with$).option
string[]Sub-option list. Optional. These sub-options are only displayed when the user selects the current option. These sub-options are also defined in the outeroptionand support unlimited nesting.pipeline_override
pipelineSame as thepipeline_overridein thetask. It takes effect when the option is activated.
- If
inputs
object[]Used only whentypeis"input". Input configuration, an array of objects defining user-inputtable fields.name
stringUnique input field identifier, used as the input field ID.label
stringInput field display name, shown in the user interface. Supports internationalized strings (starting with$). If not set, the value of thenamefield is displayed. Optional.description
stringDetailed input field description to help users understand input requirements. Supports file paths, URLs, or direct text. Content supports Markdown format. Optional. Supports internationalization (starting with$).default
stringDefault value for the input field. Optional.pipeline_type
stringThe data type of the input field in pipeline_override. Valid values:"string","int","bool". When using variable substitution in pipeline_override, type conversion is performed according to this type.verify
stringRegular expression used to validate whether user input is valid. Optional.pattern_msg
stringMessage displayed when regex validation of user input fails. Optional. Supports internationalization (starting with$).
pipeline_override
pipelineUsed when the option type is"input", as a substitution template for user input content. Supports using{name}format in strings to reference input field values. Optional.default_case
stringDefault option name, used only whentypeis"select". The Client can use this value as the initial selected value for the option. Optional.
Option Examples
Select Type Option Example
{
"option": {
"BattleStage": {
"type": "select",
"label": "$SelectBattleStage",
"description": "Select the stage to farm",
"default_case": "3-9 Dire",
"cases": [
{
"name": "3-9 Dire (Lark)",
"label": "$3-9Dire",
"description": "Farm Lark",
"icon": "lark.png",
"option": [
"UseSanityPotion",
"AfterFarmingXXX"
],
"pipeline_override": {
"EnterTheShow": {
"next": "MainChapter_3"
}
}
}
]
}
}
}Input Type Option Example
{
"option": {
"CustomStage": {
"type": "input",
"label": "Custom Stage",
"description": "Choose which stage to play",
"icon": "wrench.png",
"inputs": [
{
"name": "ChapterNumber",
"label": "$ChapterNumber",
"description": "Stage chapter number, use Arabic numerals",
"default": "4",
"pipeline_type": "string",
"verify": "^\\d+$"
},
{
"name": "Timeout",
"label": "$Timeout",
"description": "Wait timeout duration",
"default": "20000",
"pipeline_type": "int",
"verify": "^\\d+$"
}
],
"pipeline_override": {
"EnterTheShow": {
"next": "MainChapter_{ChapterNumber}",
"timeout": "{Timeout}"
}
}
}
}
}Internationalization Support
For all string fields that support internationalization, if the string starts with $, it indicates that the string is an internationalized string. The Client needs to read the actual value from the translation file before displaying it.
For example:
{
"name": "MyDemo3",
"label": "$MyDemo3",
"controller": [
{
"name": "Android",
"label": "$Android"
}
]
}Corresponding translation file (e.g., interface_en.json):
{
"MyDemo3": "My Demo 3",
"Android": "Android Device"
}Resource Override
If a later-loaded resource contains a task with the same name as one already loaded, the tasks will be merged. Generally, the top-level keys of the new task will replace those of the old task. For example:
Old Task
{
"task1": {
"enabled": false,
"recognition": "DirectHit",
"next": [ "T1", "T2" ]
}
}New Task
{
"task1": {
"enabled": true,
"action": "Click",
"next": [ "T2", "T3" ]
}
}Merged Task
{
"task1": {
"enabled": true,
"recognition": "DirectHit",
"action": "Click",
"next": [ "T2", "T3" ] // Direct replacement; inner arrays/lists are not merged.
}
}Node Notification Handling
MaaFramework sends node notifications via callback functions during task execution. The Client needs to implement the corresponding handling logic to display task execution status to users.
Callback Function Signature
The Client needs to register a callback function to receive notifications. For the function signature, refer to MaaDef.h:
typedef void(MAA_CALL* MaaEventCallback)(
void* handle,
const char* message,
const char* details_json,
void* trans_arg
);- message: Message type identifier (e.g.,
Node.Action.Starting,Node.Recognition.Succeeded, etc.) - details_json: JSON string containing specific data
Message Template Mechanism
Resource authors can configure message templates in the Pipeline using the focus field. When the Client receives a callback, it should perform placeholder replacement based on the template and display the result to users.
Pipeline Configuration Example:
{
"NodeA": {
"focus": {
"Node.Recognition.Succeeded": "{name} recognition hit, ready to start execution",
"Node.Action.Starting": "{name} starts execution, task ID: {task_id}"
}
}
}Callback Function Parameters Example:
// message parameter:
"Node.Action.Starting"
// details_json parameter (after parsing):
{
"task_id": 12345,
"action_id": 11111,
"name": "NodeA",
"focus": {
"Node.Recognition.Succeeded": "{name} recognition hit, ready to start execution",
"Node.Action.Starting": "{name} starts execution, task ID: {task_id}"
}
}Client Processing Flow
- Parse the
details_jsonparameter in the callback function - Check if the parsed object contains a
focusfield - If present, find the corresponding template string in
focusbased on themessageparameter - Replace placeholders in the template (e.g.,
{name},{task_id}) with data fromdetails_json - Display the processed text to the user
Using the example above, the final display should be: NodeA starts execution, task ID: 12345
More Message Types
For a complete list of callback messages and detailed descriptions, please refer to Callback Protocol and MaaMsg.h.
