@solazah/solazah-runtime 0.0.163 → 0.0.164

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solazah/solazah-runtime",
3
- "version": "0.0.163",
3
+ "version": "0.0.164",
4
4
  "main": "index.cjs",
5
5
  "module": "index.js",
6
6
  "types": "types/index.d.ts",
package/types/Plugin.d.ts CHANGED
@@ -1,10 +1,9 @@
1
1
  import { default as IpcRenderer } from './IpcRenderer';
2
- import { ToolCall } from 'langchain';
3
2
  export interface PluginTool {
4
3
  name: string;
5
- cb: (call: ToolCall) => Promise<string>;
4
+ cb: (args: any) => Promise<string> | string;
6
5
  description: string;
7
- schema: string;
6
+ schema: object | null;
8
7
  }
9
8
  export default class Plugin {
10
9
  private ipcRenderer;
@@ -15,9 +14,15 @@ export default class Plugin {
15
14
  getTools: () => {
16
15
  name: string;
17
16
  description: string;
18
- schema: string;
17
+ schema: object | null;
19
18
  }[];
20
- tool: (name: string, description: string, schema: string, cb: any) => any;
19
+ /**
20
+ * 给 Otta 注册 AI 工具。
21
+ * schema 传 JSON Schema 对象(如 z.toJSONSchema(...) 的返回值),无参工具传 null;
22
+ * cb 收到已按 schema 拆包的参数对象(无参工具收到 {}),返回字符串给 LLM(返回对象会被 JSON.stringify)。
23
+ * 同名重复注册为覆盖(HMR 安全)。
24
+ */
25
+ tool: (name: string, description: string, schema: object | null, cb: (args: any) => Promise<string> | string) => (args: any) => Promise<string> | string;
21
26
  onSearch: (commandName: string, handler: any) => Promise<void>;
22
27
  onAction: (commandName: string, action: string, handler: any) => Promise<void>;
23
28
  /**
@@ -1,4 +1,11 @@
1
1
  import { default as IpcRenderer } from './IpcRenderer';
2
+ export interface OCRTextBlock {
3
+ text: string;
4
+ score: number;
5
+ chars: any;
6
+ /** 四个角点坐标,顺时针或逆时针,不是 x/y/width/height 矩形 */
7
+ box: [number, number][];
8
+ }
2
9
  export default class SystemOCR {
3
10
  private transport;
4
11
  constructor(transport?: IpcRenderer);
@@ -6,8 +13,8 @@ export default class SystemOCR {
6
13
  * 调用本地 OCR 引擎识别图片并返回文本块数组。
7
14
  *
8
15
  * @param base64String Base64 编码的图片数据。
9
- * @returns 文本块数组。
16
+ * @returns 文本块数组,每块含 text(识别文字)/score(置信度)/chars/box(四角点坐标)。
10
17
  * @throws 图片解码失败或 OCR 引擎未就绪时抛错。
11
18
  */
12
- recognize: (base64String: string) => Promise<any>;
19
+ recognize: (base64String: string) => Promise<OCRTextBlock[]>;
13
20
  }