libentry 1.24.7__py3-none-any.whl → 1.24.8__py3-none-any.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.
- libentry/mcp/api.py +22 -7
- libentry/mcp/client.py +5 -5
- {libentry-1.24.7.dist-info → libentry-1.24.8.dist-info}/METADATA +1 -1
- {libentry-1.24.7.dist-info → libentry-1.24.8.dist-info}/RECORD +9 -9
- {libentry-1.24.7.dist-info → libentry-1.24.8.dist-info}/LICENSE +0 -0
- {libentry-1.24.7.dist-info → libentry-1.24.8.dist-info}/WHEEL +0 -0
- {libentry-1.24.7.dist-info → libentry-1.24.8.dist-info}/entry_points.txt +0 -0
- {libentry-1.24.7.dist-info → libentry-1.24.8.dist-info}/top_level.txt +0 -0
- {libentry-1.24.7.dist-info → libentry-1.24.8.dist-info}/zip-safe +0 -0
libentry/mcp/api.py
CHANGED
@@ -15,7 +15,7 @@ __all__ = [
|
|
15
15
|
|
16
16
|
import re
|
17
17
|
from functools import partial
|
18
|
-
from typing import Callable, List, Literal, Optional, Tuple, Type, Union
|
18
|
+
from typing import Any, Callable, List, Literal, Optional, Tuple, Type, Union
|
19
19
|
|
20
20
|
from pydantic import BaseModel, ConfigDict
|
21
21
|
|
@@ -29,16 +29,28 @@ TAG_RESOURCE = "resource"
|
|
29
29
|
|
30
30
|
|
31
31
|
class HasRequestPath:
|
32
|
+
"""The object has a request path.
|
33
|
+
A request path is a snake named string starts with "/".
|
34
|
+
"""
|
35
|
+
|
36
|
+
__request_name__ = None
|
32
37
|
|
33
38
|
@classmethod
|
34
39
|
def get_request_path(cls) -> str:
|
35
|
-
name = cls.
|
36
|
-
if name
|
37
|
-
|
38
|
-
|
40
|
+
name = cls.__request_name__
|
41
|
+
if name:
|
42
|
+
if name.startswith("/"):
|
43
|
+
return name
|
44
|
+
else:
|
45
|
+
return "/" + name
|
46
|
+
else:
|
47
|
+
name = cls.__name__
|
48
|
+
if name.endswith("Request"):
|
49
|
+
name = name[:-7]
|
50
|
+
return "/" + cls._camel_to_snake(name)
|
39
51
|
|
40
52
|
@staticmethod
|
41
|
-
def
|
53
|
+
def _camel_to_snake(name: str) -> str:
|
42
54
|
s1 = re.sub(r"(.)([A-Z][a-z]+)", r"\1_\2", name)
|
43
55
|
s2 = re.sub(r"([a-z0-9])([A-Z])", r"\1_\2", s1)
|
44
56
|
return s2.lower()
|
@@ -55,7 +67,7 @@ class APIInfo(BaseModel):
|
|
55
67
|
|
56
68
|
|
57
69
|
def api(
|
58
|
-
path: Optional[Union[str, Type[HasRequestPath], HasRequestPath]] = None,
|
70
|
+
path: Optional[Union[str, Type[HasRequestPath], HasRequestPath, Any]] = None,
|
59
71
|
methods: List[Literal["GET", "POST"]] = ("GET", "POST"),
|
60
72
|
name: Optional[str] = None,
|
61
73
|
description: Optional[str] = None,
|
@@ -76,6 +88,9 @@ def api(
|
|
76
88
|
else:
|
77
89
|
_path = f"/{fn_name}"
|
78
90
|
|
91
|
+
if not isinstance(_path, str):
|
92
|
+
raise TypeError(f"\"path\" should be instance of str or HasRequestPath.")
|
93
|
+
|
79
94
|
api_info = APIInfo(
|
80
95
|
path=_path,
|
81
96
|
methods=methods,
|
libentry/mcp/client.py
CHANGED
@@ -121,7 +121,7 @@ class SubroutineMixIn(abc.ABC):
|
|
121
121
|
@abc.abstractmethod
|
122
122
|
def subroutine_request(
|
123
123
|
self,
|
124
|
-
path: Union[str, Type[HasRequestPath], HasRequestPath],
|
124
|
+
path: Union[str, Type[HasRequestPath], HasRequestPath, Any],
|
125
125
|
params: Optional[Union[JSONObject, BaseModel]] = None,
|
126
126
|
options: Optional[HTTPOptions] = None
|
127
127
|
) -> Union[SubroutineResponse, Iterable[SubroutineResponse]]:
|
@@ -129,7 +129,7 @@ class SubroutineMixIn(abc.ABC):
|
|
129
129
|
|
130
130
|
def request(
|
131
131
|
self,
|
132
|
-
path: Union[str, Type[HasRequestPath], HasRequestPath],
|
132
|
+
path: Union[str, Type[HasRequestPath], HasRequestPath, Any],
|
133
133
|
params: Optional[Union[JSONObject, BaseModel]] = None,
|
134
134
|
options: Optional[HTTPOptions] = None
|
135
135
|
) -> Union[JSONType, Iterable[JSONType]]:
|
@@ -152,7 +152,7 @@ class SubroutineMixIn(abc.ABC):
|
|
152
152
|
|
153
153
|
def get(
|
154
154
|
self,
|
155
|
-
path: Union[str, Type[HasRequestPath], HasRequestPath],
|
155
|
+
path: Union[str, Type[HasRequestPath], HasRequestPath, Any],
|
156
156
|
options: Optional[HTTPOptions] = None
|
157
157
|
) -> Union[JSONType, Iterable[JSONType]]:
|
158
158
|
if options is None:
|
@@ -163,7 +163,7 @@ class SubroutineMixIn(abc.ABC):
|
|
163
163
|
|
164
164
|
def post(
|
165
165
|
self,
|
166
|
-
path: Union[str, Type[HasRequestPath], HasRequestPath],
|
166
|
+
path: Union[str, Type[HasRequestPath], HasRequestPath, Any],
|
167
167
|
params: Optional[Union[JSONObject, BaseModel]] = None,
|
168
168
|
options: Optional[HTTPOptions] = None
|
169
169
|
) -> Union[JSONType, Iterable[JSONType]]:
|
@@ -461,7 +461,7 @@ class APIClient(SubroutineMixIn, MCPMixIn):
|
|
461
461
|
|
462
462
|
def subroutine_request(
|
463
463
|
self,
|
464
|
-
path: Union[str, Type[HasRequestPath], HasRequestPath],
|
464
|
+
path: Union[str, Type[HasRequestPath], HasRequestPath, Any],
|
465
465
|
params: Optional[Union[JSONObject, BaseModel]] = None,
|
466
466
|
options: Optional[HTTPOptions] = None
|
467
467
|
) -> Union[SubroutineResponse, Iterable[SubroutineResponse]]:
|
@@ -11,8 +11,8 @@ libentry/schema.py,sha256=40SOhCF_eytWOF47MWKCRHKHl_lCaQVetx1Af62PkiI,10439
|
|
11
11
|
libentry/test_api.py,sha256=Xw7B7sH6g1iCTV5sFzyBF3JAJzeOr9xg0AyezTNsnIk,4452
|
12
12
|
libentry/utils.py,sha256=O7P6GadtUIjq0N2IZH7PhHZDUM3NebzcqyDqytet7CM,683
|
13
13
|
libentry/mcp/__init__.py,sha256=1oLL20yLB1GL9IbFiZD8OReDqiCpFr-yetIR6x1cNkI,23
|
14
|
-
libentry/mcp/api.py,sha256=
|
15
|
-
libentry/mcp/client.py,sha256=
|
14
|
+
libentry/mcp/api.py,sha256=GDErVCz_hh_ZeMxLS8bTPyBUhCTHw3Mm-nGFMV2W2yo,3669
|
15
|
+
libentry/mcp/client.py,sha256=3HmKAsFenPlDk1lfSdXL9GJwfCSU92uQS04zvZGeJfQ,23065
|
16
16
|
libentry/mcp/service.py,sha256=qA6I9Mi-eudRYwVGhff1_aAImK424bhASlsWaHP8XNI,34971
|
17
17
|
libentry/mcp/types.py,sha256=aAoVO4jjqEvDzNneuZapmRYonLLnGsbcLoypVyRNNYg,12389
|
18
18
|
libentry/service/__init__.py,sha256=1oLL20yLB1GL9IbFiZD8OReDqiCpFr-yetIR6x1cNkI,23
|
@@ -22,10 +22,10 @@ libentry/service/list.py,sha256=ElHWhTgShGOhaxMUEwVbMXos0NQKjHsODboiQ-3AMwE,1397
|
|
22
22
|
libentry/service/running.py,sha256=FrPJoJX6wYxcHIysoatAxhW3LajCCm0Gx6l7__6sULQ,5105
|
23
23
|
libentry/service/start.py,sha256=mZT7b9rVULvzy9GTZwxWnciCHgv9dbGN2JbxM60OMn4,1270
|
24
24
|
libentry/service/stop.py,sha256=wOpwZgrEJ7QirntfvibGq-XsTC6b3ELhzRW2zezh-0s,1187
|
25
|
-
libentry-1.24.
|
26
|
-
libentry-1.24.
|
27
|
-
libentry-1.24.
|
28
|
-
libentry-1.24.
|
29
|
-
libentry-1.24.
|
30
|
-
libentry-1.24.
|
31
|
-
libentry-1.24.
|
25
|
+
libentry-1.24.8.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
26
|
+
libentry-1.24.8.dist-info/METADATA,sha256=xTdFiobksHW7BiQG0DgyOd3d46as22zSv3q2uxz5jKM,1135
|
27
|
+
libentry-1.24.8.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
28
|
+
libentry-1.24.8.dist-info/entry_points.txt,sha256=1v_nLVDsjvVJp9SWhl4ef2zZrsLTBtFWgrYFgqvQBgc,61
|
29
|
+
libentry-1.24.8.dist-info/top_level.txt,sha256=u2uF6-X5fn2Erf9PYXOg_6tntPqTpyT-yzUZrltEd6I,9
|
30
|
+
libentry-1.24.8.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
31
|
+
libentry-1.24.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|