@solazah/solazah-runtime 0.2.61 → 0.2.63
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 +12 -0
- 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,9 +47,13 @@ export interface PluginToolOptions {
|
|
|
41
47
|
* 且在插件里**固定不变**(按需增删会让整段历史前缀失配)。
|
|
42
48
|
*/
|
|
43
49
|
resident?: boolean;
|
|
50
|
+
/** 工具要用到的宿主能力(见 PluginToolCapability)。执行端提供不了时这个工具不进模型的工具表 */
|
|
51
|
+
requires?: PluginToolCapability[];
|
|
44
52
|
}
|
|
45
53
|
export default class Plugin {
|
|
46
54
|
private ipcRenderer;
|
|
55
|
+
/** 调用本插件独立入口,不接受调用方提供的线程身份。 */
|
|
56
|
+
callTool: (name: string, args?: unknown) => Promise<any>;
|
|
47
57
|
private readonly onSearchHandlers;
|
|
48
58
|
private readonly onActionHandlers;
|
|
49
59
|
private readonly tools;
|
|
@@ -56,6 +66,7 @@ export default class Plugin {
|
|
|
56
66
|
schema: object | null;
|
|
57
67
|
timeoutMs: number | undefined;
|
|
58
68
|
resident: boolean | undefined;
|
|
69
|
+
requires: "ui"[] | undefined;
|
|
59
70
|
}[];
|
|
60
71
|
/**
|
|
61
72
|
* 给 Otta 注册 AI 工具。
|
|
@@ -63,6 +74,7 @@ export default class Plugin {
|
|
|
63
74
|
* cb 收到已按 schema 拆包的参数对象(无参工具收到 {}),返回字符串给 LLM(返回对象会被 JSON.stringify);
|
|
64
75
|
* 第二个参数是调用上下文(见 PluginToolContext)。
|
|
65
76
|
* options.timeoutMs 是宿主等待回执的上限,执行耗时长的工具要显式给。
|
|
77
|
+
* options.requires 声明工具要用到的宿主能力,执行端提供不了时这个工具不进工具表。
|
|
66
78
|
* 同名重复注册为覆盖(HMR 安全)。
|
|
67
79
|
*/
|
|
68
80
|
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;
|
|
@@ -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
|
+
};
|