Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: GRPC #54

Merged
merged 71 commits into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
0922723
feat: introduce grpc
neko-para Sep 22, 2023
db58ac8
fix: get the fucking protoc work
neko-para Sep 22, 2023
c584909
feat: add controller
neko-para Sep 23, 2023
6ca5510
feat: finish framework protobuf
neko-para Sep 23, 2023
f4524e6
feat: basic impl
neko-para Sep 24, 2023
eafbee7
feat: add sh ver generator
neko-para Sep 25, 2023
f310db7
feat: impl register callback logic
neko-para Sep 25, 2023
88bbddb
feat: install proto
neko-para Sep 25, 2023
d7c6f72
Merge branch 'main' into grpc
neko-para Sep 26, 2023
f50a6a1
refactor: split proto
neko-para Sep 26, 2023
d2db91e
refactor: rewrite logic
neko-para Sep 26, 2023
f79f006
fix: build err
neko-para Sep 26, 2023
259d732
Merge branch 'main' into grpc
neko-para Sep 26, 2023
de13c08
refactor: add some macro
neko-para Sep 26, 2023
965daaf
refactor: use uuid instead of uint64
neko-para Sep 26, 2023
acc6ed5
feat: impl basic controller
neko-para Sep 26, 2023
7bbf926
refactor: optimize
neko-para Sep 26, 2023
2cc7cb3
fix: miswrite
neko-para Sep 26, 2023
534646d
feat: SyncContext
neko-para Sep 26, 2023
c6b6462
feat: finish instance
neko-para Sep 26, 2023
85f97e4
fix: build err
neko-para Sep 26, 2023
f37556b
feat: update ci
neko-para Sep 26, 2023
2d4f66a
chore: add proto generated file
neko-para Sep 27, 2023
20c7d21
ci: remove update-proto calling
neko-para Sep 27, 2023
b39c1c3
fix: build error
neko-para Sep 27, 2023
807384c
ci: hack windows
neko-para Sep 27, 2023
3342e26
refactor: alter macro
neko-para Sep 27, 2023
fb8b7c2
ci: fix win link
neko-para Sep 27, 2023
d8a2ef7
ci: full link pb
neko-para Sep 27, 2023
c2681a7
refactor: move protos
neko-para Sep 27, 2023
7b68b69
feat: add device
neko-para Sep 27, 2023
f2cb957
refactor: service init
neko-para Sep 27, 2023
c20a515
fix: 修复toolkit头文件install错误
MistEO Sep 26, 2023
390d288
chore: cmakelists 小细节修正
MistEO Sep 26, 2023
e19fe09
ci: 仅使用最新正式版MaaDeps
MistEO Sep 26, 2023
04f4026
feat: add arg for custom controller
neko-para Sep 27, 2023
d5d9b1b
feat: custom controller
neko-para Sep 27, 2023
3724d67
Merge branch 'main' into grpc
neko-para Sep 28, 2023
94fc316
feat: split into dll+exe
neko-para Sep 28, 2023
89e27b5
feat: update config
neko-para Sep 28, 2023
60ddc37
feat: finish custom action and recognizer
neko-para Sep 28, 2023
56b33bb
chore: clean
neko-para Sep 28, 2023
312ae51
chore: remove generated sources
neko-para Sep 28, 2023
1968226
chore: update deps
neko-para Sep 28, 2023
beca3ac
chore: update cmake
neko-para Sep 28, 2023
8ee0b8b
fix: 调整custom部分参数顺序,修复编译错误
MistEO Sep 28, 2023
1284eca
chore: 调整custom controller 接口顺序
MistEO Sep 28, 2023
d6bef2a
fix: update custom
neko-para Sep 28, 2023
4d4ecc5
fix: onnxruntime include
neko-para Sep 28, 2023
ea8046b
chore: 移除toolkit中已废弃的实现
MistEO Sep 29, 2023
8a8fa36
Merge branch 'main' into grpc
MistEO Oct 7, 2023
85b0c89
fix: build error of onnxruntime
MistEO Oct 7, 2023
0afccf8
fix: ONNXRuntime_LIBRARY-NOTFOUND
MistEO Oct 7, 2023
acab5b0
fix: build error of MaaToolKit.vcxproj
MistEO Oct 7, 2023
9f1d78e
fix: fool problem
neko-para Oct 7, 2023
7ea412d
fix: Update MaaDeps to 2023-10-07-5 for fix build error
MistEO Oct 7, 2023
97da011
chore: rename fastdeploy
MistEO Oct 7, 2023
97943a4
chore: drop generated files
neko-para Oct 8, 2023
af00ace
fix: build err on win
neko-para Oct 8, 2023
033fd12
fix: mis deleting
neko-para Oct 8, 2023
802eeff
feat: generate proto in cmake
neko-para Oct 8, 2023
afc87c6
fix: link err
neko-para Oct 8, 2023
6043fca
fix: add pic
neko-para Oct 8, 2023
6c14e5d
format: change name
neko-para Oct 8, 2023
5c6f22f
Update .gitmodules
MistEO Oct 8, 2023
d0f8a66
feat: optimize MaaRpcCli
neko-para Oct 8, 2023
4304bd7
fix: build err
neko-para Oct 8, 2023
c45e7cc
fix: build error of smoke testing
MistEO Oct 8, 2023
5c4c040
fix: add install
neko-para Oct 8, 2023
3b5b300
chore: format
neko-para Oct 8, 2023
9579831
chore: clean some useless
neko-para Oct 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ Language: Json
ColumnLimit: 1000
IndentWidth: 4
---
Language: Proto
---
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
Expand Down
21 changes: 19 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,24 @@ jobs:
fail-fast: false

steps:
- name: Windows runner hack
shell: cmd
run: |
dir d:\a
cd ..
mkdir C:\MaaFramework
rmdir MaaFramework
mklink /j MaaFramework C:\MaaFramework
dism /Online /Disable-Feature /FeatureName:Windows-Defender /Remove /NoRestart /Quiet
cd .

- name: Windows runner hack (2)
uses: al-cheb/[email protected]
with:
minimum-size: 16GB
maximum-size: 16GB
disk-root: "D:"

- uses: actions/checkout@v3
with:
submodules: true
Expand Down Expand Up @@ -273,7 +291,6 @@ jobs:
name: MAA-nupkgs
path: "pkgs/nupkgs/*.nupkg"


release:
if: ${{ needs.meta.outputs.is_release == 'true' }}
needs: [meta, windows, ubuntu, macos, nuget_pack]
Expand All @@ -299,7 +316,7 @@ jobs:
for f in *; do
(cd $f && zip -r ../$f-${{ needs.meta.outputs.tag }}.zip .)
done

- uses: softprops/action-gh-release@v1
with:
files: assets/*.zip
Expand Down
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[submodule "MaaDeps"]
path = MaaDeps
url = https://github.com/MaaAssistantArknights/MaaDeps.git
branch = grpc
[submodule "assets/config/MaaAgentBinary"]
path = assets/config/MaaAgentBinary
url = https://github.com/MaaAssistantArknights/MaaAgentBinary.git
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ set(Boost_NO_WARN_NEW_VERSIONS 1)
option(BUILD_SAMPLE "build a demo" OFF)
option(USE_MAADEPS "use third-party libraries built by MaaDeps" ON)
option(WITH_THRIFT "build with thrift" ON)
option(WITH_GRPC "build with protobuf and grpc" ON)
option(BUILD_JAVASCRIPT "build JavaScript binding extras" OFF)

include(${PROJECT_SOURCE_DIR}/cmake/config.cmake) # Basic compile & link configuration
Expand All @@ -35,6 +36,10 @@ find_package(MaaDerpLearning REQUIRED)
if(WITH_THRIFT)
find_package(Thrift CONFIG REQUIRED)
endif(WITH_THRIFT)
if(WITH_GRPC)
find_package(protobuf REQUIRED)
find_package(gRPC CONFIG REQUIRED)
endif(WITH_GRPC)
find_package(ONNXRuntime)

add_subdirectory(3rdparty)
Expand Down
2 changes: 1 addition & 1 deletion MaaDeps
Submodule MaaDeps updated 1 files
+3 −3 vcpkg.json
20 changes: 20 additions & 0 deletions include/Interface/proto/buffer.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
syntax = "proto3";

package maarpc;

import "types.proto";

message ImageInfoResponse {
optional int32 type = 1;
optional Size size = 2;
}

service Image {
rpc create(EmptyRequest) returns (HandleResponse);
rpc destroy(HandleRequest) returns (EmptyResponse);
rpc is_empty(HandleRequest) returns (BoolResponse);
rpc clear(HandleRequest) returns (EmptyResponse);
rpc info(HandleRequest) returns (ImageInfoResponse);
rpc encoded(HandleRequest) returns (BufferResponse);
rpc set_encoded(HandleBufferRequest) returns (BoolResponse);
}
15 changes: 15 additions & 0 deletions include/Interface/proto/config.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
syntax = "proto3";

package maarpc;

import "types.proto";

service Config {
rpc init(EmptyRequest) returns (EmptyResponse);
rpc uninit(EmptyRequest) returns (EmptyResponse);

rpc get_custom(StringRequest) returns (StringResponse);
rpc set_custom(KeyValueRequest) returns (EmptyResponse);

rpc config_size(EmptyRequest) returns (SizeResponse);
}
69 changes: 69 additions & 0 deletions include/Interface/proto/controller.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
syntax = "proto3";

package maarpc;

import "types.proto";
import "custom.controller.proto";

message AdbControllerRequest {
optional string id = 1;
optional string adb_path = 2;
optional string adb_serial = 3;
optional uint32 adb_type = 4;
optional string adb_config = 5;
}

message ControllerSetOptionRequest {
optional string handle = 1;
oneof option {
int32 long_side = 101;
int32 short_side = 102;
string def_package_entry = 103;
string def_package = 104;
}
}

message ControllerPostClickRequest {
optional string handle = 1;
optional ClickParam param = 2;
}

message ControllerPostSwipeRequest {
optional string handle = 1;
optional SwipeParam param = 2;
}

message ControllerPostKeyRequest {
optional string handle = 1;
optional KeyParam param = 2;
}

message ControllerPostTouchRequest {
optional string handle = 1;
optional TouchParam param = 2;
}

service Controller {
rpc create_adb(AdbControllerRequest) returns (HandleResponse);
rpc destroy(HandleRequest) returns (EmptyResponse);

rpc create_custom(stream CustomControllerRequest)
returns (stream CustomControllerResponse);

rpc set_option(ControllerSetOptionRequest) returns (EmptyResponse);
rpc post_connection(HandleRequest) returns (IIdResponse);
rpc post_click(ControllerPostClickRequest) returns (IIdResponse);
rpc post_swipe(ControllerPostSwipeRequest) returns (IIdResponse);
rpc post_press_key(ControllerPostKeyRequest) returns (IIdResponse);
rpc post_touch_down(ControllerPostTouchRequest) returns (IIdResponse);
rpc post_touch_move(ControllerPostTouchRequest) returns (IIdResponse);
rpc post_touch_up(ControllerPostTouchRequest) returns (IIdResponse);
rpc post_screencap(HandleRequest) returns (IIdResponse);

rpc status(HandleIIdRequest) returns (StatusResponse);
rpc wait(HandleIIdRequest) returns (StatusResponse);
rpc connected(HandleRequest) returns (BoolResponse);

rpc image(HandleHandleRequest) returns (EmptyResponse);
rpc uuid(HandleRequest) returns (StringResponse);
}
41 changes: 41 additions & 0 deletions include/Interface/proto/custom.action.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
syntax = "proto3";

package maarpc;

import "types.proto";

message CustomActionInit {
optional string handle = 1;
optional string name = 2;
optional string act_id = 3;
}

message CustomActionSubmit {
optional string handle = 1;
optional string cmd_id = 2;
optional bool ok = 3;
}

message CustomActionRequest {
oneof payload {
CustomActionInit init = 1;
CustomActionSubmit submit = 2;
}
}

message CustomActionRunParam {
optional string context = 1;
optional string task = 2;
optional string param = 3;
optional Rect box = 4;
optional string detail = 5;
}

message CustomActionResponse {
optional string act_id = 1;
optional string cmd_id = 2;
oneof command {
CustomActionRunParam run = 101;
bool stop = 102; // void
}
}
40 changes: 40 additions & 0 deletions include/Interface/proto/custom.controller.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
syntax = "proto3";

package maarpc;

import "types.proto";

message CustomControllerSetOptionParam {
optional int32 key = 1;
optional string value = 2;
}

message CustomControllerRequest {
optional bool ok = 1;
oneof result {
string init = 101;

Size resolution = 201;
string uuid = 202;
}
}

message CustomControllerResponse {
oneof command {
string init = 101; // handle

bool connect = 201; // void
ClickParam click = 202;
SwipeParam swipe = 203;
KeyParam key = 204;
TouchParam touch_down = 205;
TouchParam touch_move = 206;
TouchParam touch_up = 207;
string start = 208;
string stop = 209;
bool resolution = 210; // void
string image = 211;
bool uuid = 212; // void
CustomControllerSetOptionParam set_option = 213;
}
}
44 changes: 44 additions & 0 deletions include/Interface/proto/custom.recognizer.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
syntax = "proto3";

package maarpc;

import "types.proto";

message CustomRecognizerInit {
optional string handle = 1;
optional string name = 2;
optional string reco_id = 3;
}

message CustomRecognizerAnalyzeResult {
optional bool match = 1;
optional Rect box = 2;
optional string detail = 3;
}

message CustomRecognizerSubmit {
optional string handle = 1;
optional string cmd_id = 2;
optional bool ok = 3;
oneof result { CustomRecognizerAnalyzeResult analyze = 101; }
}

message CustomRecognizerRequest {
oneof payload {
CustomRecognizerInit init = 1;
CustomRecognizerSubmit submit = 2;
}
}

message CustomRecognizerAnalyzeParam {
optional string context = 1;
optional string image_handle = 2;
optional string task = 3;
optional string param = 4;
}

message CustomRecognizerResponse {
optional string reco_id = 1;
optional string cmd_id = 2;
oneof command { CustomRecognizerAnalyzeParam analyze = 101; }
}
20 changes: 20 additions & 0 deletions include/Interface/proto/device.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
syntax = "proto3";

package maarpc;

import "types.proto";

message DeviceInfo {
optional string name = 1;
optional string adb_path = 2;
optional string adb_serial = 3;
optional int32 adb_type = 4;
optional string adb_config = 5;
}

message DeviceInfosResponse { repeated DeviceInfo info = 1; }

service Device {
rpc find(EmptyRequest) returns (DeviceInfosResponse);
rpc find_with_adb(StringRequest) returns (DeviceInfosResponse);
}
50 changes: 50 additions & 0 deletions include/Interface/proto/instance.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
syntax = "proto3";

package maarpc;

import "types.proto";
import "custom.recognizer.proto";
import "custom.action.proto";

message InstancePostTaskRequest {
optional string handle = 1;
optional string task = 2;
optional string param = 3;
}

message InstanceSetTaskParamRequest {
optional string handle = 1;
optional uint64 id = 2;
optional string param = 3;
}

service Instance {
rpc create(IdRequest) returns (HandleResponse);
rpc destroy(HandleRequest) returns (EmptyResponse);

rpc register_custom_recognizer(stream CustomRecognizerRequest)
returns (stream CustomRecognizerResponse);
rpc unregister_custom_recognizer(HandleStringRequest) returns (EmptyResponse);
rpc clear_custom_recognizer(HandleRequest) returns (EmptyResponse);

rpc register_custom_action(stream CustomActionRequest)
returns (stream CustomActionResponse);
rpc unregister_custom_action(HandleStringRequest) returns (EmptyResponse);
rpc clear_custom_action(HandleRequest) returns (EmptyResponse);

rpc bind_resource(HandleHandleRequest) returns (EmptyResponse);
rpc bind_controller(HandleHandleRequest) returns (EmptyResponse);
rpc inited(HandleRequest) returns (BoolResponse);

rpc post_task(InstancePostTaskRequest) returns (IIdResponse);
rpc set_task_param(InstanceSetTaskParamRequest) returns (EmptyResponse);

rpc status(HandleIIdRequest) returns (StatusResponse);
rpc wait(HandleIIdRequest) returns (StatusResponse);
rpc all_finished(HandleRequest) returns (BoolResponse);

rpc stop(HandleRequest) returns (EmptyResponse);

rpc resource(HandleRequest) returns (HandleRequest);
rpc controller(HandleRequest) returns (HandleRequest);
}
Loading