MaaFw 4.3.2__py3-none-macosx_13_0_x86_64.whl → 5.1.4__py3-none-macosx_13_0_x86_64.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/agent/agent_server.py +108 -3
- maa/agent_client.py +114 -1
- maa/bin/libMaaAdbControlUnit.dylib +0 -0
- maa/bin/libMaaAgentClient.dylib +0 -0
- maa/bin/libMaaAgentServer.dylib +0 -0
- maa/bin/libMaaCustomControlUnit.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 → libopencv_world4.4.11.0.dylib} +0 -0
- maa/bin/plugins/libMaaPluginDemo.dylib +0 -0
- maa/context.py +417 -10
- maa/controller.py +472 -34
- maa/custom_action.py +3 -0
- maa/custom_recognition.py +17 -9
- maa/define.py +205 -11
- maa/event_sink.py +73 -0
- maa/library.py +10 -14
- maa/pipeline.py +433 -0
- maa/resource.py +356 -18
- maa/tasker.py +473 -84
- maa/toolkit.py +22 -91
- {maafw-4.3.2.dist-info → maafw-5.1.4.dist-info}/METADATA +65 -36
- maafw-5.1.4.dist-info/RECORD +32 -0
- {maafw-4.3.2.dist-info → maafw-5.1.4.dist-info}/WHEEL +1 -1
- maa/bin/libMaaDbgControlUnit.dylib +0 -0
- maa/notification_handler.py +0 -197
- maafw-4.3.2.dist-info/RECORD +0 -30
- {maafw-4.3.2.dist-info → maafw-5.1.4.dist-info}/licenses/LICENSE.md +0 -0
maa/agent/agent_server.py
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import ctypes
|
|
2
|
-
import sys
|
|
3
2
|
|
|
4
3
|
from ..define import *
|
|
5
4
|
from ..library import Library
|
|
6
|
-
from ..
|
|
5
|
+
from ..event_sink import EventSink
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
class AgentServer:
|
|
@@ -88,12 +87,94 @@ class AgentServer:
|
|
|
88
87
|
Library.agent_server().MaaAgentServerJoin()
|
|
89
88
|
|
|
90
89
|
@staticmethod
|
|
91
|
-
def detach(
|
|
90
|
+
def detach() -> None:
|
|
92
91
|
|
|
93
92
|
AgentServer._set_api_properties()
|
|
94
93
|
|
|
95
94
|
Library.agent_server().MaaAgentServerDetach()
|
|
96
95
|
|
|
96
|
+
_sink_holder: Dict[int, "EventSink"] = {}
|
|
97
|
+
|
|
98
|
+
@staticmethod
|
|
99
|
+
def resource_sink():
|
|
100
|
+
def wrapper_sink(sink):
|
|
101
|
+
AgentServer.add_resource_sink(sink=sink())
|
|
102
|
+
return sink
|
|
103
|
+
|
|
104
|
+
return wrapper_sink
|
|
105
|
+
|
|
106
|
+
@staticmethod
|
|
107
|
+
def add_resource_sink(sink: "ResourceEventSink") -> None:
|
|
108
|
+
sink_id = int(
|
|
109
|
+
Library.agent_server().MaaAgentServerAddResourceSink(
|
|
110
|
+
*EventSink._gen_c_param(sink)
|
|
111
|
+
)
|
|
112
|
+
)
|
|
113
|
+
if sink_id == MaaInvalidId:
|
|
114
|
+
return None
|
|
115
|
+
|
|
116
|
+
AgentServer._sink_holder[sink_id] = sink
|
|
117
|
+
|
|
118
|
+
@staticmethod
|
|
119
|
+
def controller_sink():
|
|
120
|
+
def wrapper_sink(sink):
|
|
121
|
+
AgentServer.add_controller_sink(sink=sink())
|
|
122
|
+
return sink
|
|
123
|
+
|
|
124
|
+
return wrapper_sink
|
|
125
|
+
|
|
126
|
+
@staticmethod
|
|
127
|
+
def add_controller_sink(sink: "ControllerEventSink") -> None:
|
|
128
|
+
sink_id = int(
|
|
129
|
+
Library.agent_server().MaaAgentServerAddControllerSink(
|
|
130
|
+
*EventSink._gen_c_param(sink)
|
|
131
|
+
)
|
|
132
|
+
)
|
|
133
|
+
if sink_id == MaaInvalidId:
|
|
134
|
+
return None
|
|
135
|
+
|
|
136
|
+
AgentServer._sink_holder[sink_id] = sink
|
|
137
|
+
|
|
138
|
+
@staticmethod
|
|
139
|
+
def tasker_sink():
|
|
140
|
+
def wrapper_sink(sink):
|
|
141
|
+
AgentServer.add_tasker_sink(sink=sink())
|
|
142
|
+
return sink
|
|
143
|
+
|
|
144
|
+
return wrapper_sink
|
|
145
|
+
|
|
146
|
+
@staticmethod
|
|
147
|
+
def add_tasker_sink(sink: "TaskerEventSink") -> None:
|
|
148
|
+
sink_id = int(
|
|
149
|
+
Library.agent_server().MaaAgentServerAddTaskerSink(
|
|
150
|
+
*EventSink._gen_c_param(sink)
|
|
151
|
+
)
|
|
152
|
+
)
|
|
153
|
+
if sink_id == MaaInvalidId:
|
|
154
|
+
return None
|
|
155
|
+
|
|
156
|
+
AgentServer._sink_holder[sink_id] = sink
|
|
157
|
+
|
|
158
|
+
@staticmethod
|
|
159
|
+
def context_sink():
|
|
160
|
+
def wrapper_sink(sink):
|
|
161
|
+
AgentServer.add_context_sink(sink=sink())
|
|
162
|
+
return sink
|
|
163
|
+
|
|
164
|
+
return wrapper_sink
|
|
165
|
+
|
|
166
|
+
@staticmethod
|
|
167
|
+
def add_context_sink(sink: "ContextEventSink") -> None:
|
|
168
|
+
sink_id = int(
|
|
169
|
+
Library.agent_server().MaaAgentServerAddContextSink(
|
|
170
|
+
*EventSink._gen_c_param(sink)
|
|
171
|
+
)
|
|
172
|
+
)
|
|
173
|
+
if sink_id == MaaInvalidId:
|
|
174
|
+
return None
|
|
175
|
+
|
|
176
|
+
AgentServer._sink_holder[sink_id] = sink
|
|
177
|
+
|
|
97
178
|
_api_properties_initialized: bool = False
|
|
98
179
|
|
|
99
180
|
@staticmethod
|
|
@@ -130,3 +211,27 @@ class AgentServer:
|
|
|
130
211
|
|
|
131
212
|
Library.agent_server().MaaAgentServerDetach.restype = None
|
|
132
213
|
Library.agent_server().MaaAgentServerDetach.argtypes = []
|
|
214
|
+
|
|
215
|
+
Library.agent_server().MaaAgentServerAddResourceSink.restype = MaaSinkId
|
|
216
|
+
Library.agent_server().MaaAgentServerAddResourceSink.argtypes = [
|
|
217
|
+
MaaEventCallback,
|
|
218
|
+
ctypes.c_void_p,
|
|
219
|
+
]
|
|
220
|
+
|
|
221
|
+
Library.agent_server().MaaAgentServerAddControllerSink.restype = MaaSinkId
|
|
222
|
+
Library.agent_server().MaaAgentServerAddControllerSink.argtypes = [
|
|
223
|
+
MaaEventCallback,
|
|
224
|
+
ctypes.c_void_p,
|
|
225
|
+
]
|
|
226
|
+
|
|
227
|
+
Library.agent_server().MaaAgentServerAddTaskerSink.restype = MaaSinkId
|
|
228
|
+
Library.agent_server().MaaAgentServerAddTaskerSink.argtypes = [
|
|
229
|
+
MaaEventCallback,
|
|
230
|
+
ctypes.c_void_p,
|
|
231
|
+
]
|
|
232
|
+
|
|
233
|
+
Library.agent_server().MaaAgentServerAddContextSink.restype = MaaSinkId
|
|
234
|
+
Library.agent_server().MaaAgentServerAddContextSink.argtypes = [
|
|
235
|
+
MaaEventCallback,
|
|
236
|
+
ctypes.c_void_p,
|
|
237
|
+
]
|
maa/agent_client.py
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import ctypes
|
|
2
|
+
from typing import List
|
|
2
3
|
|
|
3
4
|
from .define import *
|
|
4
5
|
from .library import Library
|
|
5
6
|
from .resource import Resource
|
|
6
|
-
from .
|
|
7
|
+
from .controller import Controller
|
|
8
|
+
from .tasker import Tasker
|
|
9
|
+
from .buffer import StringBuffer, StringListBuffer
|
|
7
10
|
|
|
8
11
|
|
|
9
12
|
class AgentClient:
|
|
@@ -47,6 +50,30 @@ class AgentClient:
|
|
|
47
50
|
)
|
|
48
51
|
)
|
|
49
52
|
|
|
53
|
+
def register_sink(
|
|
54
|
+
self, resource: Resource, controller: Controller, tasker: Tasker
|
|
55
|
+
) -> bool:
|
|
56
|
+
# avoid gc
|
|
57
|
+
self._sinks = [resource, controller, tasker]
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
bool(
|
|
61
|
+
Library.agent_client().MaaAgentClientRegisterResourceSink(
|
|
62
|
+
self._handle, resource._handle
|
|
63
|
+
)
|
|
64
|
+
)
|
|
65
|
+
and bool(
|
|
66
|
+
Library.agent_client().MaaAgentClientRegisterControllerSink(
|
|
67
|
+
self._handle, controller._handle
|
|
68
|
+
)
|
|
69
|
+
)
|
|
70
|
+
and bool(
|
|
71
|
+
Library.agent_client().MaaAgentClientRegisterTaskerSink(
|
|
72
|
+
self._handle, tasker._handle
|
|
73
|
+
)
|
|
74
|
+
)
|
|
75
|
+
)
|
|
76
|
+
|
|
50
77
|
def connect(self) -> bool:
|
|
51
78
|
return bool(Library.agent_client().MaaAgentClientConnect(self._handle))
|
|
52
79
|
|
|
@@ -57,6 +84,51 @@ class AgentClient:
|
|
|
57
84
|
def connected(self) -> bool:
|
|
58
85
|
return bool(Library.agent_client().MaaAgentClientConnected(self._handle))
|
|
59
86
|
|
|
87
|
+
@property
|
|
88
|
+
def alive(self) -> bool:
|
|
89
|
+
return bool(Library.agent_client().MaaAgentClientAlive(self._handle))
|
|
90
|
+
|
|
91
|
+
def set_timeout(self, milliseconds: int) -> bool:
|
|
92
|
+
return bool(
|
|
93
|
+
Library.agent_client().MaaAgentClientSetTimeout(
|
|
94
|
+
self._handle, ctypes.c_int64(milliseconds)
|
|
95
|
+
)
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
@property
|
|
99
|
+
def custom_recognition_list(self) -> List[str]:
|
|
100
|
+
"""获取已注册的自定义识别器列表 / Get registered custom recognizer list
|
|
101
|
+
|
|
102
|
+
Returns:
|
|
103
|
+
list[str]: 自定义识别器名列表 / List of custom recognizer names
|
|
104
|
+
|
|
105
|
+
Raises:
|
|
106
|
+
RuntimeError: 如果获取失败
|
|
107
|
+
"""
|
|
108
|
+
buffer = StringListBuffer()
|
|
109
|
+
if not Library.agent_client().MaaAgentClientGetCustomRecognitionList(
|
|
110
|
+
self._handle, buffer._handle
|
|
111
|
+
):
|
|
112
|
+
raise RuntimeError("Failed to get custom recognition list.")
|
|
113
|
+
return buffer.get()
|
|
114
|
+
|
|
115
|
+
@property
|
|
116
|
+
def custom_action_list(self) -> List[str]:
|
|
117
|
+
"""获取已注册的自定义操作列表 / Get registered custom action list
|
|
118
|
+
|
|
119
|
+
Returns:
|
|
120
|
+
list[str]: 自定义操作名列表 / List of custom action names
|
|
121
|
+
|
|
122
|
+
Raises:
|
|
123
|
+
RuntimeError: 如果获取失败
|
|
124
|
+
"""
|
|
125
|
+
buffer = StringListBuffer()
|
|
126
|
+
if not Library.agent_client().MaaAgentClientGetCustomActionList(
|
|
127
|
+
self._handle, buffer._handle
|
|
128
|
+
):
|
|
129
|
+
raise RuntimeError("Failed to get custom action list.")
|
|
130
|
+
return buffer.get()
|
|
131
|
+
|
|
60
132
|
_api_properties_initialized: bool = False
|
|
61
133
|
|
|
62
134
|
@staticmethod
|
|
@@ -89,6 +161,24 @@ class AgentClient:
|
|
|
89
161
|
MaaResourceHandle,
|
|
90
162
|
]
|
|
91
163
|
|
|
164
|
+
Library.agent_client().MaaAgentClientRegisterResourceSink.restype = MaaBool
|
|
165
|
+
Library.agent_client().MaaAgentClientRegisterResourceSink.argtypes = [
|
|
166
|
+
MaaAgentClientHandle,
|
|
167
|
+
MaaResourceHandle,
|
|
168
|
+
]
|
|
169
|
+
|
|
170
|
+
Library.agent_client().MaaAgentClientRegisterControllerSink.restype = MaaBool
|
|
171
|
+
Library.agent_client().MaaAgentClientRegisterControllerSink.argtypes = [
|
|
172
|
+
MaaAgentClientHandle,
|
|
173
|
+
MaaControllerHandle,
|
|
174
|
+
]
|
|
175
|
+
|
|
176
|
+
Library.agent_client().MaaAgentClientRegisterTaskerSink.restype = MaaBool
|
|
177
|
+
Library.agent_client().MaaAgentClientRegisterTaskerSink.argtypes = [
|
|
178
|
+
MaaAgentClientHandle,
|
|
179
|
+
MaaTaskerHandle,
|
|
180
|
+
]
|
|
181
|
+
|
|
92
182
|
Library.agent_client().MaaAgentClientConnect.restype = MaaBool
|
|
93
183
|
Library.agent_client().MaaAgentClientConnect.argtypes = [
|
|
94
184
|
MaaAgentClientHandle,
|
|
@@ -103,3 +193,26 @@ class AgentClient:
|
|
|
103
193
|
Library.agent_client().MaaAgentClientConnected.argtypes = [
|
|
104
194
|
MaaAgentClientHandle,
|
|
105
195
|
]
|
|
196
|
+
|
|
197
|
+
Library.agent_client().MaaAgentClientAlive.restype = MaaBool
|
|
198
|
+
Library.agent_client().MaaAgentClientAlive.argtypes = [
|
|
199
|
+
MaaAgentClientHandle,
|
|
200
|
+
]
|
|
201
|
+
|
|
202
|
+
Library.agent_client().MaaAgentClientSetTimeout.restype = MaaBool
|
|
203
|
+
Library.agent_client().MaaAgentClientSetTimeout.argtypes = [
|
|
204
|
+
MaaAgentClientHandle,
|
|
205
|
+
ctypes.c_int64,
|
|
206
|
+
]
|
|
207
|
+
|
|
208
|
+
Library.agent_client().MaaAgentClientGetCustomRecognitionList.restype = MaaBool
|
|
209
|
+
Library.agent_client().MaaAgentClientGetCustomRecognitionList.argtypes = [
|
|
210
|
+
MaaAgentClientHandle,
|
|
211
|
+
MaaStringListBufferHandle,
|
|
212
|
+
]
|
|
213
|
+
|
|
214
|
+
Library.agent_client().MaaAgentClientGetCustomActionList.restype = MaaBool
|
|
215
|
+
Library.agent_client().MaaAgentClientGetCustomActionList.argtypes = [
|
|
216
|
+
MaaAgentClientHandle,
|
|
217
|
+
MaaStringListBufferHandle,
|
|
218
|
+
]
|
|
Binary file
|
maa/bin/libMaaAgentClient.dylib
CHANGED
|
Binary file
|
maa/bin/libMaaAgentServer.dylib
CHANGED
|
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
|
|
Binary file
|