Skip to main content

zerolaunch_plugin_protocol/
methods.rs

1/// Host-to-plugin method names (plugin/* namespace).
2pub mod plugin {
3    /// 进程级握手:插件初始化(版本协商、目录、locale 下发)。
4    pub const INITIALIZE: &str = "plugin/initialize";
5    /// 拉取插件实现的全部组件清单(ComponentDescriptor 列表)。
6    pub const GET_COMPONENTS: &str = "plugin/get_components";
7    /// 拉取指定组件的设置 schema。
8    pub const GET_SETTINGS_SCHEMA: &str = "plugin/get_settings_schema";
9    /// 拉取指定组件当前的设置值。
10    pub const GET_SETTINGS: &str = "plugin/get_settings";
11    /// 指定组件应用新的设置值。
12    pub const APPLY_SETTINGS: &str = "plugin/apply_settings";
13    /// 校验一组设置值是否合法(不实际应用)。
14    pub const VALIDATE_SETTINGS: &str = "plugin/validate_settings";
15    /// 拉取指定组件的配置动作列表。
16    pub const CONFIG_ACTIONS: &str = "plugin/config_actions";
17    /// 执行指定组件的配置动作。
18    pub const EXECUTE_CONFIG_ACTION: &str = "plugin/execute_config_action";
19    /// 插件查询(Plugin 组件)。
20    pub const QUERY: &str = "plugin/query";
21    /// 查询匹配裁决(Plugin 组件,插件级语义):宿主在路由阶段询问插件是否接管当前输入。
22    /// 响应为布尔值(true = 接管);旧插件未实现时宿主按 METHOD_NOT_FOUND 容错,
23    /// 用同一份框架关键词判定兜底。
24    pub const MATCH_QUERY: &str = "plugin/match_query";
25    /// 执行插件动作(Plugin 组件)。
26    pub const EXECUTE_ACTION: &str = "plugin/execute_action";
27    /// 插件初始化钩子(注册完成后通知,携带真实查询上下文)。
28    pub const INIT: &str = "plugin/init";
29    /// 拉取面板交互策略(PanelInteraction,插件级语义)。
30    /// 插件级语义:宿主仅对 Plugin 种类组件调用;SDK 恒返回主插件策略。
31    pub const INTERACTION_POLICY: &str = "plugin/interaction_policy";
32    /// 拉取指定组件的默认启用状态。
33    pub const GET_DEFAULT_ENABLED: &str = "plugin/get_default_enabled";
34    /// DataSource 组件:采集候选项。
35    pub const FETCH_CANDIDATES: &str = "plugin/fetch_candidates";
36    /// ActionExecutor 组件:支持的目标类型列表。
37    pub const SUPPORTED_TARGET_TYPES: &str = "plugin/supported_target_types";
38    /// ActionExecutor 组件:支持的动作列表。
39    pub const SUPPORTED_ACTIONS: &str = "plugin/supported_actions";
40    /// ActionExecutor 组件:执行动作。
41    pub const EXECUTOR_EXECUTE: &str = "plugin/executor_execute";
42    /// SearchEngine 组件:对缓存候选计算分数。
43    pub const CALCULATE_SCORES: &str = "plugin/calculate_scores";
44    /// ScoreBooster 组件:对已计算分数做增强。
45    pub const BOOSTER_BOOST: &str = "plugin/booster_boost";
46    /// ScoreBooster 组件:记录用户确认(学习用户习惯)。
47    pub const BOOSTER_RECORD: &str = "plugin/booster_record";
48    /// KeywordOptimizer 组件:拉取声明属性(input_source / priority)。
49    pub const KEYWORD_OPTIMIZER_INFO: &str = "plugin/keyword_optimizer_info";
50    /// KeywordOptimizer 组件:优化单个关键词。
51    pub const KEYWORD_OPTIMIZE: &str = "plugin/keyword_optimize";
52    /// KeywordInjector 组件:对单个候选注入关键词。
53    pub const KEYWORD_INJECT: &str = "plugin/keyword_inject";
54}
55
56/// Plugin-to-host method names (host/* namespace).
57pub mod host {
58    /// 插件侧日志写入(转发到宿主日志系统)。
59    pub const LOG: &str = "host/log";
60    /// 插件侧通知弹窗(宿主桌面通知)。
61    pub const NOTIFY: &str = "host/notify";
62    /// 打开指定路径/URL(系统关联)。
63    pub const SHELL_OPEN: &str = "host/shell.open";
64    /// 打开资源管理器文件夹。
65    pub const SHELL_OPEN_FOLDER: &str = "host/shell.open_folder";
66    /// 以提权方式执行命令。
67    pub const SHELL_EXECUTE_ELEVATION: &str = "host/shell.execute_elevation";
68    /// 执行命令(普通权限;呈现方式由载荷的 mode 决定)。
69    pub const SHELL_EXECUTE_COMMAND: &str = "host/shell.execute_command";
70    /// 激活指定进程对应的窗口。
71    pub const WINDOW_ACTIVATE_BY_PROCESS: &str = "host/window.activate_by_process";
72    /// 获取图标(返回 WebP/PNG base64 字节)。
73    pub const ICON_GET: &str = "host/icon.get";
74    /// 枚举已安装应用。
75    pub const APP_ENUMERATE: &str = "host/app.enumerate";
76    /// 解析路径(环境变量展开等)。
77    pub const PATH_RESOLVE: &str = "host/path.resolve";
78    /// 上传资源文件到插件目录。
79    pub const RESOURCE_UPLOAD: &str = "host/resource.upload";
80    /// 写入资源文件。
81    pub const RESOURCE_PUT: &str = "host/resource.put";
82    /// 读取资源文件。
83    pub const RESOURCE_GET: &str = "host/resource.get";
84    /// 删除资源文件。
85    pub const RESOURCE_DELETE: &str = "host/resource.delete";
86    /// 列出插件目录资源。
87    pub const RESOURCE_LIST: &str = "host/resource.list";
88    /// 解析参数模板。
89    pub const PARAMETER_RESOLVE: &str = "host/parameter.resolve";
90    /// 拉取宿主当前 locale。
91    pub const GET_LOCALE: &str = "host/i18n.get_locale";
92    /// 拉取宿主当前主题。
93    pub const GET_THEME: &str = "host/theme.get";
94    /// 拉取全网模型清单(聚合所有提供方)。
95    pub const MODEL_LIST: &str = "host/model.list";
96    /// 按 model_id 调用文本生成。
97    pub const MODEL_CHAT: &str = "host/model.chat";
98    /// 按 model_id 调用文本向量化。
99    pub const MODEL_EMBEDDING: &str = "host/model.embedding";
100    /// 按 model_id 计算查询向量与多个目标向量的相似度。
101    pub const MODEL_SIMILARITY: &str = "host/model.similarity";
102    /// 查询宿主平台能力集(插件据此决定是否降级)。
103    pub const PLATFORM_CAPABILITIES: &str = "host/platform.capabilities";
104    /// 更新本插件的 SDK 配置(如图标缓存等级),立即生效。
105    pub const SDK_CONFIG_UPDATE: &str = "host/sdk_config.update";
106    /// 提取图标;提取失败返回错误(与 host/icon.get 的默认图标回退不同)。
107    pub const ICON_EXTRACT: &str = "host/icon.extract";
108    /// 强制从磁盘提取图标并写回缓存(跳过缓存读取)。
109    pub const ICON_REFRESH: &str = "host/icon.refresh";
110    /// 用自定义图标文件覆盖指定图标请求的缓存条目。
111    pub const ICON_OVERRIDE_CACHE: &str = "host/icon.override_cache";
112    /// 按进程 PID 激活已存在的窗口。
113    pub const WINDOW_ACTIVATE_BY_PID: &str = "host/window.activate_by_pid";
114    /// 按窗口标题片段激活已存在的窗口。
115    pub const WINDOW_ACTIVATE_BY_TITLE: &str = "host/window.activate_by_title";
116    /// 将文本写入系统剪贴板。
117    pub const CLIPBOARD_SET_TEXT: &str = "host/clipboard.set_text";
118    /// 启动已安装应用,返回进程 PID。
119    pub const APP_LAUNCH: &str = "host/app.launch";
120    /// 查询内置应用图标资源的文件系统路径。
121    pub const APP_ICON_PATH: &str = "host/app.icon_path";
122    /// 解析 .lnk 快捷方式文件的目标路径。
123    pub const PATH_RESOLVE_LNK: &str = "host/path.resolve_lnk";
124    /// 解析目录下 desktop.ini 的本地化文件名。
125    pub const PATH_LOCALIZED_NAMES: &str = "host/path.localized_names";
126    /// 查询系统主题(未经宿主显式 light/dark 配置解析)。
127    pub const THEME_GET_SYSTEM: &str = "host/theme.get_system";
128    /// 统计参数模板中需要用户输入的参数数量。
129    pub const PARAMETER_COUNT_USER: &str = "host/parameter.count_user";
130    /// 判断参数模板是否包含系统参数。
131    pub const PARAMETER_HAS_SYSTEM: &str = "host/parameter.has_system";
132    /// 写入插件本地缓存(可再生的本地数据,不经存储后端)。
133    pub const CACHE_PUT: &str = "host/cache.put";
134    /// 读取插件本地缓存;不存在时返回 null。
135    pub const CACHE_GET: &str = "host/cache.get";
136    /// 删除插件本地缓存条目。
137    pub const CACHE_DELETE: &str = "host/cache.delete";
138    /// 按容量上限清理插件本地缓存域。
139    pub const CACHE_CLEANUP: &str = "host/cache.cleanup";
140    /// 创建一次性定时器,到期由宿主推送 `plugin/timer.fired`。
141    pub const TIMER_SET_TIMEOUT: &str = "host/timer.set_timeout";
142    /// 创建重复定时器,每次到期由宿主推送 `plugin/timer.fired`。
143    pub const TIMER_SET_INTERVAL: &str = "host/timer.set_interval";
144    /// 取消指定的本插件定时器。
145    pub const TIMER_CANCEL: &str = "host/timer.cancel";
146    /// 取消本插件的全部定时器。
147    pub const TIMER_CANCEL_ALL: &str = "host/timer.cancel_all";
148    /// 订阅按键事件,宿主推送 `plugin/hotkey.event`。
149    pub const HOTKEY_SUBSCRIBE: &str = "host/hotkey.subscribe";
150    /// 退订按键事件。
151    pub const HOTKEY_UNSUBSCRIBE: &str = "host/hotkey.unsubscribe";
152    /// 订阅安装监控事件,宿主推送 `plugin/installation.event`。
153    pub const INSTALLATION_SUBSCRIBE: &str = "host/installation.subscribe";
154    /// 退订安装监控事件。
155    pub const INSTALLATION_UNSUBSCRIBE: &str = "host/installation.unsubscribe";
156    /// 订阅窗口焦点事件,宿主推送 `plugin/focus.event`。
157    pub const FOCUS_SUBSCRIBE: &str = "host/focus.subscribe";
158    /// 退订窗口焦点事件。
159    pub const FOCUS_UNSUBSCRIBE: &str = "host/focus.unsubscribe";
160}
161
162/// Host-to-plugin push methods (fire-and-forget, no response expected).
163///
164/// 与 `plugin/*` 请求的区别:这些方法由宿主单向推送给插件进程,用于把
165/// `host/timer.*` / `host/*.subscribe` 注册的事件送达插件;插件不应答。
166pub mod event {
167    /// 定时器到期(参数:`{ id }`,id 为 host/timer.set_* 返回的定时器 ID)。
168    pub const TIMER_FIRED: &str = "plugin/timer.fired";
169    /// 按键事件(参数:`{ event }`,HotkeyEvent 序列化形态)。
170    pub const HOTKEY_EVENT: &str = "plugin/hotkey.event";
171    /// 安装监控事件(参数:`{ event }`,InstallationEvent 序列化形态)。
172    pub const INSTALLATION_EVENT: &str = "plugin/installation.event";
173    /// 窗口焦点事件(参数:`{ event }`,FocusEvent 序列化形态)。
174    pub const FOCUS_EVENT: &str = "plugin/focus.event";
175}
176
177/// Notification-only method names (fire-and-forget, no response expected).
178pub mod notify {
179    /// 插件进程就绪通知。
180    pub const PLUGIN_READY: &str = "plugin/ready";
181    /// 插件进程崩溃通知。
182    pub const PLUGIN_CRASHED: &str = "plugin/crashed";
183}