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    /// 执行命令(普通权限)。
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
104/// Notification-only method names (fire-and-forget, no response expected).
105pub mod notify {
106    /// 插件进程就绪通知。
107    pub const PLUGIN_READY: &str = "plugin/ready";
108    /// 插件进程崩溃通知。
109    pub const PLUGIN_CRASHED: &str = "plugin/crashed";
110}