entari-plugin-server 0.7.4__tar.gz → 0.8.0__tar.gz
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.
- {entari_plugin_server-0.7.4 → entari_plugin_server-0.8.0}/PKG-INFO +3 -3
- {entari_plugin_server-0.7.4 → entari_plugin_server-0.8.0}/pyproject.toml +3 -3
- {entari_plugin_server-0.7.4 → entari_plugin_server-0.8.0}/src/entari_plugin_server/__init__.py +35 -6
- {entari_plugin_server-0.7.4 → entari_plugin_server-0.8.0}/LICENSE +0 -0
- {entari_plugin_server-0.7.4 → entari_plugin_server-0.8.0}/README.md +0 -0
- {entari_plugin_server-0.7.4 → entari_plugin_server-0.8.0}/src/entari_plugin_server/README.md +0 -0
- {entari_plugin_server-0.7.4 → entari_plugin_server-0.8.0}/src/entari_plugin_server/_adapter.py +0 -0
- {entari_plugin_server-0.7.4 → entari_plugin_server-0.8.0}/src/entari_plugin_server/config.py +0 -0
- {entari_plugin_server-0.7.4 → entari_plugin_server-0.8.0}/src/entari_plugin_server/patch.py +0 -0
- {entari_plugin_server-0.7.4 → entari_plugin_server-0.8.0}/tests/__init__.py +0 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: entari-plugin-server
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.8.0
|
|
4
4
|
Summary: Entari plugin for running Satori Server
|
|
5
5
|
Keywords: server,adapters,satori,entari,plugin
|
|
6
6
|
Author-Email: RF-Tar-Railt <rf_tar_railt@qq.com>
|
|
7
7
|
License: MIT
|
|
8
8
|
Project-URL: homepage, https://github.com/ArcletProject/entari-plugin-server
|
|
9
9
|
Project-URL: repository, https://github.com/ArcletProject/entari-plugin-server
|
|
10
|
-
Requires-Python: >=3.
|
|
11
|
-
Requires-Dist: arclet-entari
|
|
10
|
+
Requires-Python: >=3.11
|
|
11
|
+
Requires-Dist: arclet-entari>=0.19.0rc1
|
|
12
12
|
Requires-Dist: satori-python-server<1.4.0,>=1.3.0
|
|
13
13
|
Provides-Extra: fastapi
|
|
14
14
|
Requires-Dist: fastapi>=0.116.1; extra == "fastapi"
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "entari-plugin-server"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.8.0"
|
|
4
4
|
description = "Entari plugin for running Satori Server"
|
|
5
5
|
authors = [
|
|
6
6
|
{ name = "RF-Tar-Railt", email = "rf_tar_railt@qq.com" },
|
|
7
7
|
]
|
|
8
8
|
dependencies = [
|
|
9
|
-
"arclet-entari
|
|
9
|
+
"arclet-entari>=0.19.0rc1",
|
|
10
10
|
"satori-python-server<1.4.0,>=1.3.0",
|
|
11
11
|
]
|
|
12
|
-
requires-python = ">=3.
|
|
12
|
+
requires-python = ">=3.11"
|
|
13
13
|
readme = "README.md"
|
|
14
14
|
keywords = [
|
|
15
15
|
"server",
|
{entari_plugin_server-0.7.4 → entari_plugin_server-0.8.0}/src/entari_plugin_server/__init__.py
RENAMED
|
@@ -8,10 +8,9 @@ from typing import TYPE_CHECKING, Any, Callable, Optional, Union, cast
|
|
|
8
8
|
from arclet.entari.config.models.default import BasicConfModel
|
|
9
9
|
from typing_extensions import TypeAlias
|
|
10
10
|
|
|
11
|
-
from arclet.entari import
|
|
12
|
-
from arclet.entari.plugin import PluginRole
|
|
13
|
-
from arclet.entari.config import EntariConfig
|
|
14
|
-
from arclet.entari.config import config_model_validate
|
|
11
|
+
from arclet.entari import plugin
|
|
12
|
+
from arclet.entari.plugin import PluginRole, get_plugin
|
|
13
|
+
from arclet.entari.config import EntariConfig, config_model_validate, config_model_schema
|
|
15
14
|
from arclet.entari import logger as log_m
|
|
16
15
|
|
|
17
16
|
from arclet.letoderea.utils import TCallable
|
|
@@ -29,13 +28,12 @@ DISPOSE: TypeAlias = Callable[[], None]
|
|
|
29
28
|
uvicorn.LoguruHandler = log_m.LoguruHandler
|
|
30
29
|
|
|
31
30
|
|
|
32
|
-
plg = Plugin.current()
|
|
33
31
|
plugin.declare_static()
|
|
34
32
|
plugin.metadata(
|
|
35
33
|
"server",
|
|
36
34
|
PluginRole.LIBRARY,
|
|
37
35
|
[{"name": "RF-Tar-Railt", "email": "rf_tar_railt@qq.com"}],
|
|
38
|
-
"0.
|
|
36
|
+
"0.8.0",
|
|
39
37
|
description="为 Entari 提供 Satori 服务器支持,基于此为 Entari 提供 ASGI 服务、适配器连接等功能",
|
|
40
38
|
urls={
|
|
41
39
|
"homepage": "https://github.com/ArcletProject/entari-plugin-server",
|
|
@@ -46,6 +44,7 @@ plugin.metadata(
|
|
|
46
44
|
|
|
47
45
|
|
|
48
46
|
conf = plugin.get_config(Config)
|
|
47
|
+
_plg = plugin.get_plugin()
|
|
49
48
|
|
|
50
49
|
if conf.direct_adapter:
|
|
51
50
|
server = DirectAdapterServer(conf.host, int(conf.port), conf.path, conf.version, conf.token, uvicorn_options=conf.options, stream_threshold=conf.stream_threshold, stream_chunk_size=conf.stream_chunk_size) # type: ignore
|
|
@@ -54,6 +53,8 @@ else:
|
|
|
54
53
|
|
|
55
54
|
pattern = re.compile(r"(?P<module>[\w.]+)\s*(:\s*(?P<attr>[\w.]+)\s*)?((?P<extras>\[.*\])\s*)?$")
|
|
56
55
|
|
|
56
|
+
_adapter_schemas = []
|
|
57
|
+
|
|
57
58
|
|
|
58
59
|
def _load_adapter(adapter_config: dict):
|
|
59
60
|
if "$path" not in adapter_config:
|
|
@@ -95,6 +96,13 @@ def _load_adapter(adapter_config: dict):
|
|
|
95
96
|
[],
|
|
96
97
|
bases=(config_cls, BasicConfModel),
|
|
97
98
|
)
|
|
99
|
+
_schema = config_model_schema(
|
|
100
|
+
dcls,
|
|
101
|
+
ref_root=f"/properties/plugins/properties/{_plg._config_key}/properties/adapters/items/oneOf/{len(_adapter_schemas)}/"
|
|
102
|
+
)
|
|
103
|
+
_schema["properties"]["$path"] = {"const": adapter_config["$path"]}
|
|
104
|
+
_schema["required"] = ["$path"]
|
|
105
|
+
_adapter_schemas.append(_schema)
|
|
98
106
|
dcls_instance = config_model_validate(dcls, args)
|
|
99
107
|
return ext(dcls_instance) # type: ignore
|
|
100
108
|
filtered_args = {k: v for k, v in args.items() if k in sig.parameters}
|
|
@@ -107,6 +115,13 @@ def _load_adapter(adapter_config: dict):
|
|
|
107
115
|
],
|
|
108
116
|
bases=(BasicConfModel,),
|
|
109
117
|
)
|
|
118
|
+
_schema = config_model_schema(
|
|
119
|
+
dcls,
|
|
120
|
+
ref_root=f"/properties/plugins/properties/{_plg._config_key}/properties/adapters/items/oneOf/{len(_adapter_schemas)}/"
|
|
121
|
+
)
|
|
122
|
+
_schema["properties"]["$path"] = {"const": adapter_config["$path"]}
|
|
123
|
+
_schema["required"] = ["$path"]
|
|
124
|
+
_adapter_schemas.append(_schema)
|
|
110
125
|
dcls_instance = config_model_validate(dcls, filtered_args)
|
|
111
126
|
return ext(**vars(dcls_instance))
|
|
112
127
|
elif isinstance(ext, Adapter):
|
|
@@ -117,6 +132,16 @@ def _load_adapter(adapter_config: dict):
|
|
|
117
132
|
|
|
118
133
|
adapters: list[Adapter] = [*filter(None, map(_load_adapter, conf.adapters + EntariConfig.instance.data.get("adapters", [])))]
|
|
119
134
|
|
|
135
|
+
_plg.register_schema(
|
|
136
|
+
"properties.adapters",
|
|
137
|
+
{
|
|
138
|
+
"type": "array",
|
|
139
|
+
"items": {"oneOf": _adapter_schemas} if _adapter_schemas else {"type": "object"},
|
|
140
|
+
"title": "Adapters"
|
|
141
|
+
},
|
|
142
|
+
replace=True
|
|
143
|
+
)
|
|
144
|
+
|
|
120
145
|
for adapter in adapters:
|
|
121
146
|
logger.debug(f"Applying adapter {adapter}")
|
|
122
147
|
server.apply(adapter)
|
|
@@ -148,6 +173,8 @@ def replace_asgi(app: Union[ASGIApp, asgitypes.ASGI3Application]):
|
|
|
148
173
|
Args:
|
|
149
174
|
app (Any): 新的 ASGI 应用
|
|
150
175
|
"""
|
|
176
|
+
plg = get_plugin(1)
|
|
177
|
+
|
|
151
178
|
if server.status.blocking:
|
|
152
179
|
logger.warning("Server is blocking, cannot replace ASGI app")
|
|
153
180
|
return lambda: None
|
|
@@ -186,6 +213,7 @@ def add_route(
|
|
|
186
213
|
include_in_schema (bool, optional): 是否包含在 OpenAPI 文档中,默认为 True
|
|
187
214
|
kwargs (Any): 其他参数,例如 FastAPI 的路由参数
|
|
188
215
|
"""
|
|
216
|
+
plg = get_plugin(1)
|
|
189
217
|
|
|
190
218
|
def wrapper(endpoint: TCallable, /) -> TCallable:
|
|
191
219
|
app = cast(Starlette, server.app)
|
|
@@ -217,6 +245,7 @@ def add_websocket_route(
|
|
|
217
245
|
name (str, optional): 路由名称,默认为 None
|
|
218
246
|
kwargs (Any): 其他参数,例如 FastAPI 的路由参数
|
|
219
247
|
"""
|
|
248
|
+
plg = get_plugin(1)
|
|
220
249
|
|
|
221
250
|
def wrapper(endpoint: TCallable, /) -> TCallable:
|
|
222
251
|
app = cast(Starlette, server.app)
|
|
File without changes
|
|
File without changes
|
{entari_plugin_server-0.7.4 → entari_plugin_server-0.8.0}/src/entari_plugin_server/README.md
RENAMED
|
File without changes
|
{entari_plugin_server-0.7.4 → entari_plugin_server-0.8.0}/src/entari_plugin_server/_adapter.py
RENAMED
|
File without changes
|
{entari_plugin_server-0.7.4 → entari_plugin_server-0.8.0}/src/entari_plugin_server/config.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|