wox-plugin 0.0.1__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.
- wox_plugin-0.0.1/PKG-INFO +16 -0
- wox_plugin-0.0.1/README.md +1 -0
- wox_plugin-0.0.1/setup.cfg +4 -0
- wox_plugin-0.0.1/setup.py +23 -0
- wox_plugin-0.0.1/wox_plugin/__init__.py +55 -0
- wox_plugin-0.0.1/wox_plugin/types.py +261 -0
- wox_plugin-0.0.1/wox_plugin.egg-info/PKG-INFO +16 -0
- wox_plugin-0.0.1/wox_plugin.egg-info/SOURCES.txt +8 -0
- wox_plugin-0.0.1/wox_plugin.egg-info/dependency_links.txt +1 -0
- wox_plugin-0.0.1/wox_plugin.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: wox-plugin
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: All Python plugins for Wox should use types in this package
|
|
5
|
+
Home-page: https://github.com/Wox-launcher/Wox
|
|
6
|
+
Author: Wox-launcher
|
|
7
|
+
Author-email:
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Requires-Python: >=3.8
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name="wox-plugin",
|
|
5
|
+
version="0.0.1",
|
|
6
|
+
description="All Python plugins for Wox should use types in this package",
|
|
7
|
+
author="Wox-launcher",
|
|
8
|
+
author_email="",
|
|
9
|
+
url="https://github.com/Wox-launcher/Wox",
|
|
10
|
+
packages=find_packages(),
|
|
11
|
+
install_requires=[],
|
|
12
|
+
python_requires=">=3.8",
|
|
13
|
+
classifiers=[
|
|
14
|
+
"Development Status :: 3 - Alpha",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.8",
|
|
19
|
+
"Programming Language :: Python :: 3.9",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
],
|
|
23
|
+
)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from .types import (
|
|
2
|
+
# Basic types
|
|
3
|
+
MapString,
|
|
4
|
+
Platform,
|
|
5
|
+
|
|
6
|
+
# Context
|
|
7
|
+
Context,
|
|
8
|
+
new_context,
|
|
9
|
+
new_context_with_value,
|
|
10
|
+
|
|
11
|
+
# Selection
|
|
12
|
+
SelectionType,
|
|
13
|
+
Selection,
|
|
14
|
+
|
|
15
|
+
# Query
|
|
16
|
+
QueryType,
|
|
17
|
+
Query,
|
|
18
|
+
QueryEnv,
|
|
19
|
+
|
|
20
|
+
# Result
|
|
21
|
+
WoxImageType,
|
|
22
|
+
WoxImage,
|
|
23
|
+
new_base64_wox_image,
|
|
24
|
+
WoxPreviewType,
|
|
25
|
+
WoxPreview,
|
|
26
|
+
ResultTailType,
|
|
27
|
+
ResultTail,
|
|
28
|
+
ActionContext,
|
|
29
|
+
ResultAction,
|
|
30
|
+
Result,
|
|
31
|
+
RefreshableResult,
|
|
32
|
+
|
|
33
|
+
# Plugin API
|
|
34
|
+
ChangeQueryParam,
|
|
35
|
+
|
|
36
|
+
# AI
|
|
37
|
+
ConversationRole,
|
|
38
|
+
ChatStreamDataType,
|
|
39
|
+
Conversation,
|
|
40
|
+
ChatStreamFunc,
|
|
41
|
+
|
|
42
|
+
# Settings
|
|
43
|
+
PluginSettingDefinitionType,
|
|
44
|
+
PluginSettingValueStyle,
|
|
45
|
+
PluginSettingDefinitionValue,
|
|
46
|
+
PluginSettingDefinitionItem,
|
|
47
|
+
MetadataCommand,
|
|
48
|
+
|
|
49
|
+
# Plugin Interface
|
|
50
|
+
Plugin,
|
|
51
|
+
PublicAPI,
|
|
52
|
+
PluginInitParams,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
__version__ = "0.0.82"
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from enum import Enum
|
|
3
|
+
from typing import Dict, List, Optional, Protocol, Union, Callable, Any, TypedDict, Literal
|
|
4
|
+
import uuid
|
|
5
|
+
|
|
6
|
+
# Basic types
|
|
7
|
+
MapString = Dict[str, str]
|
|
8
|
+
Platform = Literal["windows", "darwin", "linux"]
|
|
9
|
+
|
|
10
|
+
# Context
|
|
11
|
+
class Context(TypedDict):
|
|
12
|
+
Values: Dict[str, str]
|
|
13
|
+
|
|
14
|
+
def new_context() -> Context:
|
|
15
|
+
return {"Values": {"traceId": str(uuid.uuid4())}}
|
|
16
|
+
|
|
17
|
+
def new_context_with_value(key: str, value: str) -> Context:
|
|
18
|
+
ctx = new_context()
|
|
19
|
+
ctx["Values"][key] = value
|
|
20
|
+
return ctx
|
|
21
|
+
|
|
22
|
+
# Selection
|
|
23
|
+
class SelectionType(str, Enum):
|
|
24
|
+
TEXT = "text"
|
|
25
|
+
FILE = "file"
|
|
26
|
+
|
|
27
|
+
@dataclass
|
|
28
|
+
class Selection:
|
|
29
|
+
Type: SelectionType
|
|
30
|
+
Text: Optional[str] = None
|
|
31
|
+
FilePaths: Optional[List[str]] = None
|
|
32
|
+
|
|
33
|
+
# Query Environment
|
|
34
|
+
@dataclass
|
|
35
|
+
class QueryEnv:
|
|
36
|
+
ActiveWindowTitle: str
|
|
37
|
+
|
|
38
|
+
# Query
|
|
39
|
+
class QueryType(str, Enum):
|
|
40
|
+
INPUT = "input"
|
|
41
|
+
SELECTION = "selection"
|
|
42
|
+
|
|
43
|
+
@dataclass
|
|
44
|
+
class Query:
|
|
45
|
+
Type: QueryType
|
|
46
|
+
RawQuery: str
|
|
47
|
+
TriggerKeyword: Optional[str]
|
|
48
|
+
Command: Optional[str]
|
|
49
|
+
Search: str
|
|
50
|
+
Selection: Selection
|
|
51
|
+
Env: QueryEnv
|
|
52
|
+
|
|
53
|
+
def is_global_query(self) -> bool:
|
|
54
|
+
return self.Type == QueryType.INPUT and not self.TriggerKeyword
|
|
55
|
+
|
|
56
|
+
# Result
|
|
57
|
+
class WoxImageType(str, Enum):
|
|
58
|
+
ABSOLUTE = "absolute"
|
|
59
|
+
RELATIVE = "relative"
|
|
60
|
+
BASE64 = "base64"
|
|
61
|
+
SVG = "svg"
|
|
62
|
+
URL = "url"
|
|
63
|
+
EMOJI = "emoji"
|
|
64
|
+
LOTTIE = "lottie"
|
|
65
|
+
|
|
66
|
+
@dataclass
|
|
67
|
+
class WoxImage:
|
|
68
|
+
ImageType: WoxImageType
|
|
69
|
+
ImageData: str
|
|
70
|
+
|
|
71
|
+
def new_base64_wox_image(image_data: str) -> WoxImage:
|
|
72
|
+
return WoxImage(ImageType=WoxImageType.BASE64, ImageData=image_data)
|
|
73
|
+
|
|
74
|
+
class WoxPreviewType(str, Enum):
|
|
75
|
+
MARKDOWN = "markdown"
|
|
76
|
+
TEXT = "text"
|
|
77
|
+
IMAGE = "image"
|
|
78
|
+
URL = "url"
|
|
79
|
+
FILE = "file"
|
|
80
|
+
|
|
81
|
+
@dataclass
|
|
82
|
+
class WoxPreview:
|
|
83
|
+
PreviewType: WoxPreviewType
|
|
84
|
+
PreviewData: str
|
|
85
|
+
PreviewProperties: Dict[str, str]
|
|
86
|
+
|
|
87
|
+
class ResultTailType(str, Enum):
|
|
88
|
+
TEXT = "text"
|
|
89
|
+
IMAGE = "image"
|
|
90
|
+
|
|
91
|
+
@dataclass
|
|
92
|
+
class ResultTail:
|
|
93
|
+
Type: ResultTailType
|
|
94
|
+
Text: Optional[str] = None
|
|
95
|
+
Image: Optional[WoxImage] = None
|
|
96
|
+
|
|
97
|
+
@dataclass
|
|
98
|
+
class ActionContext:
|
|
99
|
+
ContextData: str
|
|
100
|
+
|
|
101
|
+
@dataclass
|
|
102
|
+
class ResultAction:
|
|
103
|
+
Id: Optional[str]
|
|
104
|
+
Name: str
|
|
105
|
+
Icon: Optional[WoxImage]
|
|
106
|
+
IsDefault: Optional[bool]
|
|
107
|
+
PreventHideAfterAction: Optional[bool]
|
|
108
|
+
Action: Callable[[ActionContext], None]
|
|
109
|
+
Hotkey: Optional[str]
|
|
110
|
+
|
|
111
|
+
@dataclass
|
|
112
|
+
class Result:
|
|
113
|
+
Id: Optional[str]
|
|
114
|
+
Title: str
|
|
115
|
+
SubTitle: Optional[str]
|
|
116
|
+
Icon: WoxImage
|
|
117
|
+
Preview: Optional[WoxPreview]
|
|
118
|
+
Score: Optional[float]
|
|
119
|
+
Group: Optional[str]
|
|
120
|
+
GroupScore: Optional[float]
|
|
121
|
+
Tails: Optional[List[ResultTail]]
|
|
122
|
+
ContextData: Optional[str]
|
|
123
|
+
Actions: Optional[List[ResultAction]]
|
|
124
|
+
RefreshInterval: Optional[int]
|
|
125
|
+
OnRefresh: Optional[Callable[["RefreshableResult"], "RefreshableResult"]]
|
|
126
|
+
|
|
127
|
+
@dataclass
|
|
128
|
+
class RefreshableResult:
|
|
129
|
+
Title: str
|
|
130
|
+
SubTitle: str
|
|
131
|
+
Icon: WoxImage
|
|
132
|
+
Preview: WoxPreview
|
|
133
|
+
Tails: List[ResultTail]
|
|
134
|
+
ContextData: str
|
|
135
|
+
RefreshInterval: int
|
|
136
|
+
Actions: List[ResultAction]
|
|
137
|
+
|
|
138
|
+
# Plugin API
|
|
139
|
+
@dataclass
|
|
140
|
+
class ChangeQueryParam:
|
|
141
|
+
QueryType: QueryType
|
|
142
|
+
QueryText: Optional[str]
|
|
143
|
+
QuerySelection: Optional[Selection]
|
|
144
|
+
|
|
145
|
+
# AI
|
|
146
|
+
class ConversationRole(str, Enum):
|
|
147
|
+
USER = "user"
|
|
148
|
+
SYSTEM = "system"
|
|
149
|
+
|
|
150
|
+
class ChatStreamDataType(str, Enum):
|
|
151
|
+
STREAMING = "streaming"
|
|
152
|
+
FINISHED = "finished"
|
|
153
|
+
ERROR = "error"
|
|
154
|
+
|
|
155
|
+
@dataclass
|
|
156
|
+
class Conversation:
|
|
157
|
+
Role: ConversationRole
|
|
158
|
+
Text: str
|
|
159
|
+
Timestamp: int
|
|
160
|
+
|
|
161
|
+
ChatStreamFunc = Callable[[ChatStreamDataType, str], None]
|
|
162
|
+
|
|
163
|
+
# Settings
|
|
164
|
+
class PluginSettingDefinitionType(str, Enum):
|
|
165
|
+
HEAD = "head"
|
|
166
|
+
TEXTBOX = "textbox"
|
|
167
|
+
CHECKBOX = "checkbox"
|
|
168
|
+
SELECT = "select"
|
|
169
|
+
LABEL = "label"
|
|
170
|
+
NEWLINE = "newline"
|
|
171
|
+
TABLE = "table"
|
|
172
|
+
DYNAMIC = "dynamic"
|
|
173
|
+
|
|
174
|
+
@dataclass
|
|
175
|
+
class PluginSettingValueStyle:
|
|
176
|
+
PaddingLeft: int
|
|
177
|
+
PaddingTop: int
|
|
178
|
+
PaddingRight: int
|
|
179
|
+
PaddingBottom: int
|
|
180
|
+
Width: int
|
|
181
|
+
LabelWidth: int
|
|
182
|
+
|
|
183
|
+
@dataclass
|
|
184
|
+
class PluginSettingDefinitionValue:
|
|
185
|
+
def get_key(self) -> str:
|
|
186
|
+
raise NotImplementedError
|
|
187
|
+
|
|
188
|
+
def get_default_value(self) -> str:
|
|
189
|
+
raise NotImplementedError
|
|
190
|
+
|
|
191
|
+
def translate(self, translator: Callable[[Context, str], str]) -> None:
|
|
192
|
+
raise NotImplementedError
|
|
193
|
+
|
|
194
|
+
@dataclass
|
|
195
|
+
class PluginSettingDefinitionItem:
|
|
196
|
+
Type: PluginSettingDefinitionType
|
|
197
|
+
Value: PluginSettingDefinitionValue
|
|
198
|
+
DisabledInPlatforms: List[Platform]
|
|
199
|
+
IsPlatformSpecific: bool
|
|
200
|
+
|
|
201
|
+
@dataclass
|
|
202
|
+
class MetadataCommand:
|
|
203
|
+
Command: str
|
|
204
|
+
Description: str
|
|
205
|
+
|
|
206
|
+
# Plugin Interface
|
|
207
|
+
class Plugin(Protocol):
|
|
208
|
+
async def init(self, ctx: Context, init_params: "PluginInitParams") -> None:
|
|
209
|
+
...
|
|
210
|
+
|
|
211
|
+
async def query(self, ctx: Context, query: Query) -> List[Result]:
|
|
212
|
+
...
|
|
213
|
+
|
|
214
|
+
# Public API Interface
|
|
215
|
+
class PublicAPI(Protocol):
|
|
216
|
+
async def change_query(self, ctx: Context, query: ChangeQueryParam) -> None:
|
|
217
|
+
...
|
|
218
|
+
|
|
219
|
+
async def hide_app(self, ctx: Context) -> None:
|
|
220
|
+
...
|
|
221
|
+
|
|
222
|
+
async def show_app(self, ctx: Context) -> None:
|
|
223
|
+
...
|
|
224
|
+
|
|
225
|
+
async def notify(self, ctx: Context, message: str) -> None:
|
|
226
|
+
...
|
|
227
|
+
|
|
228
|
+
async def log(self, ctx: Context, level: str, msg: str) -> None:
|
|
229
|
+
...
|
|
230
|
+
|
|
231
|
+
async def get_translation(self, ctx: Context, key: str) -> str:
|
|
232
|
+
...
|
|
233
|
+
|
|
234
|
+
async def get_setting(self, ctx: Context, key: str) -> str:
|
|
235
|
+
...
|
|
236
|
+
|
|
237
|
+
async def save_setting(self, ctx: Context, key: str, value: str, is_platform_specific: bool) -> None:
|
|
238
|
+
...
|
|
239
|
+
|
|
240
|
+
async def on_setting_changed(self, ctx: Context, callback: Callable[[str, str], None]) -> None:
|
|
241
|
+
...
|
|
242
|
+
|
|
243
|
+
async def on_get_dynamic_setting(self, ctx: Context, callback: Callable[[str], PluginSettingDefinitionItem]) -> None:
|
|
244
|
+
...
|
|
245
|
+
|
|
246
|
+
async def on_deep_link(self, ctx: Context, callback: Callable[[MapString], None]) -> None:
|
|
247
|
+
...
|
|
248
|
+
|
|
249
|
+
async def on_unload(self, ctx: Context, callback: Callable[[], None]) -> None:
|
|
250
|
+
...
|
|
251
|
+
|
|
252
|
+
async def register_query_commands(self, ctx: Context, commands: List[MetadataCommand]) -> None:
|
|
253
|
+
...
|
|
254
|
+
|
|
255
|
+
async def llm_stream(self, ctx: Context, conversations: List[Conversation], callback: ChatStreamFunc) -> None:
|
|
256
|
+
...
|
|
257
|
+
|
|
258
|
+
@dataclass
|
|
259
|
+
class PluginInitParams:
|
|
260
|
+
API: PublicAPI
|
|
261
|
+
PluginDirectory: str
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: wox-plugin
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: All Python plugins for Wox should use types in this package
|
|
5
|
+
Home-page: https://github.com/Wox-launcher/Wox
|
|
6
|
+
Author: Wox-launcher
|
|
7
|
+
Author-email:
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Requires-Python: >=3.8
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
wox_plugin
|