@solazah/solazah-runtime 0.1.147 → 0.1.149

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.1.147",
3
+ "version": "0.1.149",
4
4
  "main": "index.cjs",
5
5
  "module": "index.js",
6
6
  "types": "types/index.d.ts",
@@ -99,6 +99,16 @@ export interface CopilotOptions extends CopilotChatOptions {
99
99
  }[];
100
100
  }
101
101
  export type CopilotRunOptions = CopilotOptions;
102
+ /** 一行 = 某个模型某一天的 token 统计。model_name 是模型 id,显示名要另去模型清单里换。 */
103
+ export interface CopilotUsageStat {
104
+ model_name: string;
105
+ stat_date: string;
106
+ requests: number;
107
+ prompt_tokens: number;
108
+ cached_tokens: number;
109
+ completion_tokens: number;
110
+ history_rewrites: number;
111
+ }
102
112
  export default class Copilot {
103
113
  ipcRenderer: IpcRenderer;
104
114
  private seq;
@@ -124,6 +134,8 @@ export default class Copilot {
124
134
  * @returns 无返回;requestId 无对应在跑运行时静默无操作。
125
135
  */
126
136
  abort: (requestId: string) => Promise<any>;
137
+ /** 最近 days 天的 token 用量,按 (模型, 日期) 聚合,新到旧。用量看板用。 */
138
+ usage(days?: number): Promise<CopilotUsageStat[]>;
127
139
  /**
128
140
  * 生成途中插一句话:排进待注入队列,模型下一个决策点领走,不中止当前回合。
129
141
  *
package/types/Plugin.d.ts CHANGED
@@ -1,11 +1,30 @@
1
1
  import { default as IpcRenderer } from './IpcRenderer';
2
+ /**
3
+ * 工具回执。只回文字就直接返回字符串;要让模型**看画面**才返回这个:
4
+ * images 是本机绝对路径,宿主读盘后附成一条带图的消息,插件不必再让模型调一次 view_image。
5
+ */
6
+ export interface PluginToolReply {
7
+ text: string;
8
+ /** 本机绝对路径,png / jpg / webp / gif,最多 4 张 */
9
+ images?: string[];
10
+ }
2
11
  export interface PluginTool {
3
12
  name: string;
4
- cb: (args: any) => Promise<string> | string;
13
+ cb: (args: any) => Promise<string | PluginToolReply> | string | PluginToolReply;
5
14
  description: string;
6
15
  schema: object | null;
7
16
  timeoutMs?: number;
8
17
  }
18
+ /**
19
+ * 宿主自身的信息,随 `plugin.info()` 一起给到插件。
20
+ *
21
+ * 有了它,插件就能对**单个能力**降级,而不必在 manifest 里声明 minHostVersion 把整个插件挡在门外:
22
+ * 老宿主上少一个特性、其余照常可用,好过装不上。声明下界只留给「核心功能就依赖新宿主」的情形。
23
+ */
24
+ export interface PluginHostInfo {
25
+ /** 桌面端版本,如 "0.1.148"。 */
26
+ version: string;
27
+ }
9
28
  export interface PluginToolOptions {
10
29
  /** 宿主等待回执的上限(毫秒),给执行耗时长的工具(如跑一段脚本)用 */
11
30
  timeoutMs?: number;
@@ -132,7 +151,9 @@ export default class Plugin {
132
151
  *
133
152
  * @returns 包含插件字段、commands 数组和 settings 键值对的对象;无法定位发起方插件时返回 undefined。
134
153
  */
135
- info: () => Promise<any>;
154
+ info: () => Promise<(Record<string, any> & {
155
+ host: PluginHostInfo;
156
+ }) | undefined>;
136
157
  /**
137
158
  * 按命令名批量注销发起方插件的运行时命令,从启动器移除。
138
159
  * 按命令名(name)和插件名(pluginName)联合匹配删除;仅删运行时命令,manifest 命令不受影响。