@solazah/solazah-runtime 0.2.63 → 0.2.65
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/Plugin.d.ts +12 -1
package/package.json
CHANGED
package/types/Plugin.d.ts
CHANGED
|
@@ -50,13 +50,22 @@ export interface PluginToolOptions {
|
|
|
50
50
|
/** 工具要用到的宿主能力(见 PluginToolCapability)。执行端提供不了时这个工具不进模型的工具表 */
|
|
51
51
|
requires?: PluginToolCapability[];
|
|
52
52
|
}
|
|
53
|
+
/** 页面方法:工具入口里 requires ui 的工具经 `callPage` 交给本插件页面执行的那段实现 */
|
|
54
|
+
export type PluginPageHandler = (args: any) => Promise<unknown> | unknown;
|
|
53
55
|
export default class Plugin {
|
|
54
56
|
private ipcRenderer;
|
|
55
57
|
/** 调用本插件独立入口,不接受调用方提供的线程身份。 */
|
|
56
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>;
|
|
57
64
|
private readonly onSearchHandlers;
|
|
58
65
|
private readonly onActionHandlers;
|
|
59
66
|
private readonly tools;
|
|
67
|
+
/** plugin.onCall 按名字找的处理函数:入口里是 tool 注册的工具,页面里是 handle 登记的方法 */
|
|
68
|
+
private readonly callHandlers;
|
|
60
69
|
/** 用 Solazah 账号登录插件,见 PluginAccount */
|
|
61
70
|
readonly account: PluginAccount;
|
|
62
71
|
constructor(ipcRenderer?: IpcRenderer);
|
|
@@ -69,7 +78,7 @@ export default class Plugin {
|
|
|
69
78
|
requires: "ui"[] | undefined;
|
|
70
79
|
}[];
|
|
71
80
|
/**
|
|
72
|
-
* 给 Otta 注册 AI
|
|
81
|
+
* 给 Otta 注册 AI 工具。只在工具入口(src/tools/index.mjs)里调用,宿主只从入口收工具。
|
|
73
82
|
* schema 传 JSON Schema 对象(如 z.toJSONSchema(...) 的返回值),无参工具传 null;
|
|
74
83
|
* cb 收到已按 schema 拆包的参数对象(无参工具收到 {}),返回字符串给 LLM(返回对象会被 JSON.stringify);
|
|
75
84
|
* 第二个参数是调用上下文(见 PluginToolContext)。
|
|
@@ -78,6 +87,8 @@ export default class Plugin {
|
|
|
78
87
|
* 同名重复注册为覆盖(HMR 安全)。
|
|
79
88
|
*/
|
|
80
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;
|
|
81
92
|
onSearch: (commandName: string, handler: any) => Promise<void>;
|
|
82
93
|
onAction: (commandName: string, action: string, handler: any) => Promise<void>;
|
|
83
94
|
/**
|