MaaFw 3.0.4__py3-none-macosx_13_0_arm64.whl → 4.0.0__py3-none-macosx_13_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of MaaFw might be problematic. Click here for more details.
- maa/__init__.py +1 -1
- maa/agent/__init__.py +12 -0
- maa/agent/agent_server.py +132 -0
- maa/agent_client.py +91 -0
- maa/bin/libMaaAdbControlUnit.dylib +0 -0
- maa/bin/libMaaAgentClient.dylib +0 -0
- maa/bin/libMaaAgentServer.dylib +0 -0
- maa/bin/libMaaDbgControlUnit.dylib +0 -0
- maa/bin/libMaaFramework.dylib +0 -0
- maa/bin/libMaaToolkit.dylib +0 -0
- maa/bin/libMaaUtils.dylib +0 -0
- maa/bin/libfastdeploy_ppocr.dylib +0 -0
- maa/bin/libonnxruntime.1.19.2.dylib +0 -0
- maa/bin/libopencv_world4.4.8.0.dylib +0 -0
- maa/buffer.py +129 -131
- maa/context.py +24 -24
- maa/controller.py +70 -70
- maa/define.py +15 -12
- maa/library.py +103 -15
- maa/notification_handler.py +3 -3
- maa/resource.py +47 -47
- maa/tasker.py +63 -61
- maa/toolkit.py +82 -78
- {MaaFw-3.0.4.dist-info → maafw-4.0.0.dist-info}/METADATA +22 -7
- maafw-4.0.0.dist-info/RECORD +33 -0
- maafw-4.0.0.dist-info/WHEEL +4 -0
- MaaFw-3.0.4.dist-info/RECORD +0 -29
- MaaFw-3.0.4.dist-info/WHEEL +0 -4
- MaaFw-3.0.4.dist-info/top_level.txt +0 -1
- {MaaFw-3.0.4.dist-info → maafw-4.0.0.dist-info/licenses}/LICENSE.md +0 -0
maa/__init__.py
CHANGED
maa/agent/__init__.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from ..library import Library
|
|
5
|
+
|
|
6
|
+
env_path = os.environ.get("MAAFW_BINARY_PATH")
|
|
7
|
+
if env_path:
|
|
8
|
+
__PATH = Path(env_path)
|
|
9
|
+
else:
|
|
10
|
+
__PATH = Path(Path(__file__).parent.parent, "bin")
|
|
11
|
+
|
|
12
|
+
Library.open(__PATH, agent_server=True)
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import ctypes
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
from ..define import *
|
|
5
|
+
from ..library import Library
|
|
6
|
+
from ..buffer import StringBuffer
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AgentServer:
|
|
10
|
+
|
|
11
|
+
@staticmethod
|
|
12
|
+
def custom_recognition(name: str):
|
|
13
|
+
|
|
14
|
+
def wrapper_recognition(recognition):
|
|
15
|
+
AgentServer.register_custom_recognition(
|
|
16
|
+
name=name, recognition=recognition()
|
|
17
|
+
)
|
|
18
|
+
return recognition
|
|
19
|
+
|
|
20
|
+
return wrapper_recognition
|
|
21
|
+
|
|
22
|
+
_custom_recognition_holder = {}
|
|
23
|
+
|
|
24
|
+
@staticmethod
|
|
25
|
+
def register_custom_recognition(
|
|
26
|
+
name: str, recognition: "CustomRecognition" # type: ignore
|
|
27
|
+
) -> bool:
|
|
28
|
+
|
|
29
|
+
AgentServer._set_api_properties()
|
|
30
|
+
|
|
31
|
+
# avoid gc
|
|
32
|
+
AgentServer._custom_recognition_holder[name] = recognition
|
|
33
|
+
|
|
34
|
+
return bool(
|
|
35
|
+
Library.agent_server().MaaAgentServerRegisterCustomRecognition(
|
|
36
|
+
name.encode(),
|
|
37
|
+
recognition.c_handle,
|
|
38
|
+
recognition.c_arg,
|
|
39
|
+
)
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
@staticmethod
|
|
43
|
+
def custom_action(name: str):
|
|
44
|
+
|
|
45
|
+
def wrapper_action(action):
|
|
46
|
+
AgentServer.register_custom_action(name=name, action=action())
|
|
47
|
+
return action
|
|
48
|
+
|
|
49
|
+
return wrapper_action
|
|
50
|
+
|
|
51
|
+
_custom_action_holder = {}
|
|
52
|
+
|
|
53
|
+
@staticmethod
|
|
54
|
+
def register_custom_action(name: str, action: "CustomAction") -> bool: # type: ignore
|
|
55
|
+
|
|
56
|
+
AgentServer._set_api_properties()
|
|
57
|
+
|
|
58
|
+
# avoid gc
|
|
59
|
+
AgentServer._custom_action_holder[name] = action
|
|
60
|
+
|
|
61
|
+
return bool(
|
|
62
|
+
Library.agent_server().MaaAgentServerRegisterCustomAction(
|
|
63
|
+
name.encode(),
|
|
64
|
+
action.c_handle,
|
|
65
|
+
action.c_arg,
|
|
66
|
+
)
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
@staticmethod
|
|
70
|
+
def start_up(identifier: str) -> bool:
|
|
71
|
+
|
|
72
|
+
AgentServer._set_api_properties()
|
|
73
|
+
|
|
74
|
+
return bool(Library.agent_server().MaaAgentServerStartUp(identifier.encode()))
|
|
75
|
+
|
|
76
|
+
@staticmethod
|
|
77
|
+
def shut_down() -> None:
|
|
78
|
+
|
|
79
|
+
AgentServer._set_api_properties()
|
|
80
|
+
|
|
81
|
+
Library.agent_server().MaaAgentServerShutDown()
|
|
82
|
+
|
|
83
|
+
@staticmethod
|
|
84
|
+
def join() -> None:
|
|
85
|
+
|
|
86
|
+
AgentServer._set_api_properties()
|
|
87
|
+
|
|
88
|
+
Library.agent_server().MaaAgentServerJoin()
|
|
89
|
+
|
|
90
|
+
@staticmethod
|
|
91
|
+
def detach(self) -> None:
|
|
92
|
+
|
|
93
|
+
AgentServer._set_api_properties()
|
|
94
|
+
|
|
95
|
+
Library.agent_server().MaaAgentServerDetach()
|
|
96
|
+
|
|
97
|
+
_api_properties_initialized: bool = False
|
|
98
|
+
|
|
99
|
+
@staticmethod
|
|
100
|
+
def _set_api_properties():
|
|
101
|
+
if AgentServer._api_properties_initialized:
|
|
102
|
+
return
|
|
103
|
+
|
|
104
|
+
AgentServer._api_properties_initialized = True
|
|
105
|
+
|
|
106
|
+
Library.agent_server().MaaAgentServerRegisterCustomRecognition.restype = MaaBool
|
|
107
|
+
Library.agent_server().MaaAgentServerRegisterCustomRecognition.argtypes = [
|
|
108
|
+
ctypes.c_char_p,
|
|
109
|
+
MaaCustomRecognitionCallback,
|
|
110
|
+
ctypes.c_void_p,
|
|
111
|
+
]
|
|
112
|
+
|
|
113
|
+
Library.agent_server().MaaAgentServerRegisterCustomAction.restype = MaaBool
|
|
114
|
+
Library.agent_server().MaaAgentServerRegisterCustomAction.argtypes = [
|
|
115
|
+
ctypes.c_char_p,
|
|
116
|
+
MaaCustomActionCallback,
|
|
117
|
+
ctypes.c_void_p,
|
|
118
|
+
]
|
|
119
|
+
|
|
120
|
+
Library.agent_server().MaaAgentServerStartUp.restype = MaaBool
|
|
121
|
+
Library.agent_server().MaaAgentServerStartUp.argtypes = [
|
|
122
|
+
ctypes.c_char_p,
|
|
123
|
+
]
|
|
124
|
+
|
|
125
|
+
Library.agent_server().MaaAgentServerShutDown.restype = None
|
|
126
|
+
Library.agent_server().MaaAgentServerShutDown.argtypes = []
|
|
127
|
+
|
|
128
|
+
Library.agent_server().MaaAgentServerJoin.restype = None
|
|
129
|
+
Library.agent_server().MaaAgentServerJoin.argtypes = []
|
|
130
|
+
|
|
131
|
+
Library.agent_server().MaaAgentServerDetach.restype = None
|
|
132
|
+
Library.agent_server().MaaAgentServerDetach.argtypes = []
|
maa/agent_client.py
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import ctypes
|
|
2
|
+
|
|
3
|
+
from .define import *
|
|
4
|
+
from .library import Library
|
|
5
|
+
from .resource import Resource
|
|
6
|
+
from .buffer import StringBuffer
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AgentClient:
|
|
10
|
+
_handle: MaaAgentClientHandle
|
|
11
|
+
|
|
12
|
+
def __init__(self):
|
|
13
|
+
self._set_api_properties()
|
|
14
|
+
|
|
15
|
+
self._handle = Library.agent_client().MaaAgentClientCreate()
|
|
16
|
+
if not self._handle:
|
|
17
|
+
raise RuntimeError("Failed to create agent client.")
|
|
18
|
+
|
|
19
|
+
def __del__(self):
|
|
20
|
+
if self._handle:
|
|
21
|
+
Library.agent_client().MaaAgentClientDestroy(self._handle)
|
|
22
|
+
|
|
23
|
+
def bind(self, resource: Resource) -> bool:
|
|
24
|
+
# avoid gc
|
|
25
|
+
self._resource = resource
|
|
26
|
+
|
|
27
|
+
return bool(
|
|
28
|
+
Library.agent_client().MaaAgentClientBindResource(
|
|
29
|
+
self._handle, resource._handle
|
|
30
|
+
)
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
def create_socket(self, identifier: str = "") -> Optional[str]:
|
|
34
|
+
id_buffer = StringBuffer()
|
|
35
|
+
id_buffer.set(identifier)
|
|
36
|
+
|
|
37
|
+
ret = bool(
|
|
38
|
+
Library.agent_client().MaaAgentClientCreateSocket(
|
|
39
|
+
self._handle, id_buffer._handle
|
|
40
|
+
)
|
|
41
|
+
)
|
|
42
|
+
if not ret:
|
|
43
|
+
return None
|
|
44
|
+
|
|
45
|
+
return id_buffer.get()
|
|
46
|
+
|
|
47
|
+
def connect(self) -> bool:
|
|
48
|
+
return bool(Library.agent_client().MaaAgentClientConnect(self._handle))
|
|
49
|
+
|
|
50
|
+
def disconnect(self) -> bool:
|
|
51
|
+
return bool(Library.agent_client().MaaAgentClientDisconnect(self._handle))
|
|
52
|
+
|
|
53
|
+
_api_properties_initialized: bool = False
|
|
54
|
+
|
|
55
|
+
@staticmethod
|
|
56
|
+
def _set_api_properties():
|
|
57
|
+
if AgentClient._api_properties_initialized:
|
|
58
|
+
return
|
|
59
|
+
|
|
60
|
+
if Library.is_agent_server():
|
|
61
|
+
raise RuntimeError("AgentClient is not available in AgentServer.")
|
|
62
|
+
|
|
63
|
+
AgentClient._api_properties_initialized = True
|
|
64
|
+
|
|
65
|
+
Library.agent_client().MaaAgentClientCreate.restype = MaaAgentClientHandle
|
|
66
|
+
Library.agent_client().MaaAgentClientCreate.argtypes = []
|
|
67
|
+
|
|
68
|
+
Library.agent_client().MaaAgentClientDestroy.restype = None
|
|
69
|
+
Library.agent_client().MaaAgentClientDestroy.argtypes = [MaaAgentClientHandle]
|
|
70
|
+
|
|
71
|
+
Library.agent_client().MaaAgentClientBindResource.restype = MaaBool
|
|
72
|
+
Library.agent_client().MaaAgentClientBindResource.argtypes = [
|
|
73
|
+
MaaAgentClientHandle,
|
|
74
|
+
MaaResourceHandle,
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
Library.agent_client().MaaAgentClientCreateSocket.restype = MaaBool
|
|
78
|
+
Library.agent_client().MaaAgentClientCreateSocket.argtypes = [
|
|
79
|
+
MaaAgentClientHandle,
|
|
80
|
+
MaaStringBufferHandle,
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
Library.agent_client().MaaAgentClientConnect.restype = MaaBool
|
|
84
|
+
Library.agent_client().MaaAgentClientConnect.argtypes = [
|
|
85
|
+
MaaAgentClientHandle,
|
|
86
|
+
]
|
|
87
|
+
|
|
88
|
+
Library.agent_client().MaaAgentClientDisconnect.restype = MaaBool
|
|
89
|
+
Library.agent_client().MaaAgentClientDisconnect.argtypes = [
|
|
90
|
+
MaaAgentClientHandle,
|
|
91
|
+
]
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
maa/bin/libMaaFramework.dylib
CHANGED
|
Binary file
|
maa/bin/libMaaToolkit.dylib
CHANGED
|
Binary file
|
maa/bin/libMaaUtils.dylib
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|