@solazah/solazah-runtime 0.2.62 → 0.2.64
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.
- package/package.json +1 -1
- package/types/Copilot.d.ts +19 -0
- package/types/Plugin.d.ts +24 -1
- package/types/PluginSettings.d.ts +7 -0
- package/types/PreloadApi.d.ts +68 -0
package/package.json
CHANGED
package/types/Copilot.d.ts
CHANGED
|
@@ -169,6 +169,15 @@ export interface CopilotRoundRefusal {
|
|
|
169
169
|
* 执行端能干什么。本机界面与远程对端问到的是同一份,界面据此隐藏用不了的入口、提示用不上的输入。
|
|
170
170
|
* 镜像在 solazah-plugin-copilot 的 `ExecutorCapabilities`(src/renderer/runtime/CopilotClient.ts),改字段两处一起改。
|
|
171
171
|
*/
|
|
172
|
+
/** 执行端机器上的一层文件夹。path 为 null 时是起点那一屏(主目录、盘符),parent 为 null 时没有上一级 */
|
|
173
|
+
export interface CopilotDirectoryListing {
|
|
174
|
+
path: string | null;
|
|
175
|
+
parent: string | null;
|
|
176
|
+
directories: {
|
|
177
|
+
name: string;
|
|
178
|
+
path: string;
|
|
179
|
+
}[];
|
|
180
|
+
}
|
|
172
181
|
export interface CopilotExecutorCapabilities {
|
|
173
182
|
kind: "local" | "remote" | "cloud";
|
|
174
183
|
/** 电脑控制类工具(鼠标、键盘、截屏) */
|
|
@@ -195,6 +204,16 @@ export interface CopilotUsageStat {
|
|
|
195
204
|
history_rewrites: number;
|
|
196
205
|
}
|
|
197
206
|
export default class Copilot {
|
|
207
|
+
/** 将内容交付到当前宿主工具调用所属对话。 */
|
|
208
|
+
present: (content: {
|
|
209
|
+
kind: "file" | "image" | "widget";
|
|
210
|
+
items?: {
|
|
211
|
+
path: string;
|
|
212
|
+
caption?: string;
|
|
213
|
+
}[];
|
|
214
|
+
code?: string;
|
|
215
|
+
title?: string;
|
|
216
|
+
}) => Promise<any>;
|
|
198
217
|
ipcRenderer: IpcRenderer;
|
|
199
218
|
constructor();
|
|
200
219
|
/**
|
package/types/Plugin.d.ts
CHANGED
|
@@ -21,7 +21,13 @@ export interface PluginTool {
|
|
|
21
21
|
schema: object | null;
|
|
22
22
|
timeoutMs?: number;
|
|
23
23
|
resident?: boolean;
|
|
24
|
+
requires?: PluginToolCapability[];
|
|
24
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* 工具可以声明依赖的宿主能力。「数据」类(插件设置、对话、工作空间文件、网络)每台执行端都有,不必声明。
|
|
28
|
+
* - ui:插件窗口与命令(打开命令、切到某条对话)。没有界面的执行端(solazah-cli serve)没有
|
|
29
|
+
*/
|
|
30
|
+
export type PluginToolCapability = "ui";
|
|
25
31
|
/**
|
|
26
32
|
* 宿主自身的信息,随 `plugin.info()` 一起给到插件。
|
|
27
33
|
*
|
|
@@ -41,12 +47,25 @@ export interface PluginToolOptions {
|
|
|
41
47
|
* 且在插件里**固定不变**(按需增删会让整段历史前缀失配)。
|
|
42
48
|
*/
|
|
43
49
|
resident?: boolean;
|
|
50
|
+
/** 工具要用到的宿主能力(见 PluginToolCapability)。执行端提供不了时这个工具不进模型的工具表 */
|
|
51
|
+
requires?: PluginToolCapability[];
|
|
44
52
|
}
|
|
53
|
+
/** 页面方法:工具入口里 requires ui 的工具经 `callPage` 交给本插件页面执行的那段实现 */
|
|
54
|
+
export type PluginPageHandler = (args: any) => Promise<unknown> | unknown;
|
|
45
55
|
export default class Plugin {
|
|
46
56
|
private ipcRenderer;
|
|
57
|
+
/** 调用本插件独立入口,不接受调用方提供的线程身份。 */
|
|
58
|
+
callTool: (name: string, args?: unknown) => Promise<any>;
|
|
59
|
+
/**
|
|
60
|
+
* 工具入口调用本插件页面登记的方法(见 handle),宿主按需拉起页面、等回执。
|
|
61
|
+
* 只给声明了 requires ui 的工具用:没有插件页面的执行端没有这条通道。
|
|
62
|
+
*/
|
|
63
|
+
callPage: (name: string, args?: unknown, timeoutMs?: number) => Promise<any>;
|
|
47
64
|
private readonly onSearchHandlers;
|
|
48
65
|
private readonly onActionHandlers;
|
|
49
66
|
private readonly tools;
|
|
67
|
+
/** plugin.onCall 按名字找的处理函数:入口里是 tool 注册的工具,页面里是 handle 登记的方法 */
|
|
68
|
+
private readonly callHandlers;
|
|
50
69
|
/** 用 Solazah 账号登录插件,见 PluginAccount */
|
|
51
70
|
readonly account: PluginAccount;
|
|
52
71
|
constructor(ipcRenderer?: IpcRenderer);
|
|
@@ -56,16 +75,20 @@ export default class Plugin {
|
|
|
56
75
|
schema: object | null;
|
|
57
76
|
timeoutMs: number | undefined;
|
|
58
77
|
resident: boolean | undefined;
|
|
78
|
+
requires: "ui"[] | undefined;
|
|
59
79
|
}[];
|
|
60
80
|
/**
|
|
61
|
-
* 给 Otta 注册 AI
|
|
81
|
+
* 给 Otta 注册 AI 工具。只在工具入口(src/tools/index.mjs)里调用,宿主只从入口收工具。
|
|
62
82
|
* schema 传 JSON Schema 对象(如 z.toJSONSchema(...) 的返回值),无参工具传 null;
|
|
63
83
|
* cb 收到已按 schema 拆包的参数对象(无参工具收到 {}),返回字符串给 LLM(返回对象会被 JSON.stringify);
|
|
64
84
|
* 第二个参数是调用上下文(见 PluginToolContext)。
|
|
65
85
|
* options.timeoutMs 是宿主等待回执的上限,执行耗时长的工具要显式给。
|
|
86
|
+
* options.requires 声明工具要用到的宿主能力,执行端提供不了时这个工具不进工具表。
|
|
66
87
|
* 同名重复注册为覆盖(HMR 安全)。
|
|
67
88
|
*/
|
|
68
89
|
tool: (name: string, description: string, schema: object | null, cb: (args: any, context: PluginToolContext) => Promise<string> | string, options?: PluginToolOptions) => (args: any, context: PluginToolContext) => Promise<string> | string;
|
|
90
|
+
/** 在插件页面登记一个供工具入口 callPage 调用的方法。同名重复登记为覆盖(HMR 安全)。 */
|
|
91
|
+
handle: (name: string, handler: PluginPageHandler) => void;
|
|
69
92
|
onSearch: (commandName: string, handler: any) => Promise<void>;
|
|
70
93
|
onAction: (commandName: string, action: string, handler: any) => Promise<void>;
|
|
71
94
|
/**
|
|
@@ -64,4 +64,11 @@ export default class PluginSettings {
|
|
|
64
64
|
* @returns 无返回。无法定位发起方插件时不执行任何操作。
|
|
65
65
|
*/
|
|
66
66
|
removeItem: (collection: string, id: string) => Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* 本插件的设置可能变了:助理的工具写了设置(工具跑在另一个进程里)、或从别的设备同步来了变更。
|
|
69
|
+
* 界面据此重读自己关心的数据。同一时刻只保留最后一次订阅的监听器。
|
|
70
|
+
*
|
|
71
|
+
* @param listener 变更时被调用,不带参数。
|
|
72
|
+
*/
|
|
73
|
+
onChanged: (listener: () => void) => Promise<void>;
|
|
67
74
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { default as Notifications } from './Notifications';
|
|
2
|
+
import { default as IpcRenderer } from './IpcRenderer';
|
|
3
|
+
import { default as Copilot } from './Copilot';
|
|
4
|
+
import { default as CopilotSubAgent } from './CopilotSubAgent';
|
|
5
|
+
import { default as CopilotThread } from './CopilotThread';
|
|
6
|
+
import { default as CopilotMcpServer } from './CopilotMcpServer';
|
|
7
|
+
import { default as CopilotModel } from './CopilotModel';
|
|
8
|
+
import { default as Plugin } from './Plugin';
|
|
9
|
+
import { default as PluginCommand } from './PluginCommand';
|
|
10
|
+
import { default as PluginSettings } from './PluginSettings';
|
|
11
|
+
import { default as System } from './System';
|
|
12
|
+
import { default as SystemClipboard } from './SystemClipboard';
|
|
13
|
+
import { default as SystemKeyboard } from './SystemKeyboard';
|
|
14
|
+
import { default as SystemMouse } from './SystemMouse';
|
|
15
|
+
import { default as SystemOCR } from './SystemOCR';
|
|
16
|
+
import { default as SystemSetting } from './SystemSetting';
|
|
17
|
+
import { default as SystemShell } from './SystemShell';
|
|
18
|
+
import { default as SystemBrowser } from './SystemBrowser';
|
|
19
|
+
import { default as SystemShortcut } from './SystemShortcut';
|
|
20
|
+
import { default as SystemAudio } from './SystemAudio';
|
|
21
|
+
import { default as SystemWindow } from './SystemWindow';
|
|
22
|
+
import { default as SystemRecorder } from './SystemRecorder';
|
|
23
|
+
import { default as SystemElevation } from './SystemElevation';
|
|
24
|
+
import { default as SystemNotification } from './SystemNotification';
|
|
25
|
+
import { default as Account } from './Account';
|
|
26
|
+
import { default as Workspace } from './Workspace';
|
|
27
|
+
import { default as File } from './File';
|
|
28
|
+
import { default as Http } from './Http';
|
|
29
|
+
import { default as Kb } from './Kb';
|
|
30
|
+
import { default as Mail } from './Mail';
|
|
31
|
+
import { default as Sync } from './Sync';
|
|
32
|
+
/**
|
|
33
|
+
* 宿主给插件的 API 对象,即 `window` 上的那一组:插件页面由 preload 经 contextBridge 暴露,
|
|
34
|
+
* 插件工具入口进程(src/scripts/PluginAgent.ts)直接挂在它的 window 上。两边是同一份清单。
|
|
35
|
+
*/
|
|
36
|
+
export declare function createPreloadApi(): {
|
|
37
|
+
notifications: Notifications;
|
|
38
|
+
ipcRenderer: IpcRenderer;
|
|
39
|
+
copilot: Copilot;
|
|
40
|
+
copilotSubagent: CopilotSubAgent;
|
|
41
|
+
copilotThread: CopilotThread;
|
|
42
|
+
copilotMcpServer: CopilotMcpServer;
|
|
43
|
+
copilotModel: CopilotModel;
|
|
44
|
+
plugin: Plugin;
|
|
45
|
+
pluginCommand: PluginCommand;
|
|
46
|
+
pluginSettings: PluginSettings;
|
|
47
|
+
system: System;
|
|
48
|
+
systemClipboard: SystemClipboard;
|
|
49
|
+
systemKeyboard: SystemKeyboard;
|
|
50
|
+
systemMouse: SystemMouse;
|
|
51
|
+
systemOCR: SystemOCR;
|
|
52
|
+
systemSetting: SystemSetting;
|
|
53
|
+
systemShell: SystemShell;
|
|
54
|
+
systemBrowser: SystemBrowser;
|
|
55
|
+
systemShortcut: SystemShortcut;
|
|
56
|
+
systemAudio: SystemAudio;
|
|
57
|
+
systemWindow: SystemWindow;
|
|
58
|
+
systemRecorder: SystemRecorder;
|
|
59
|
+
systemElevation: SystemElevation;
|
|
60
|
+
systemNotification: SystemNotification;
|
|
61
|
+
account: Account;
|
|
62
|
+
workspace: Workspace;
|
|
63
|
+
file: File;
|
|
64
|
+
http: Http;
|
|
65
|
+
kb: Kb;
|
|
66
|
+
mail: Mail;
|
|
67
|
+
sync: Sync;
|
|
68
|
+
};
|