@solazah/solazah-runtime 0.2.10 → 0.2.18
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 +44 -17
- package/types/CopilotMcpServer.d.ts +10 -10
- package/types/CopilotThread.d.ts +0 -1
- package/types/index.d.ts +0 -2
- package/types/CopilotWechatBridge.d.ts +0 -86
package/package.json
CHANGED
package/types/Copilot.d.ts
CHANGED
|
@@ -20,7 +20,6 @@ export interface CopilotBaseOptions {
|
|
|
20
20
|
* - false: 显式关闭
|
|
21
21
|
* - undefined: 保持模型默认
|
|
22
22
|
* 优先级低于 reasoningEffort:provider 先看 reasoningEffort,缺省才回落到 enableThinking。
|
|
23
|
-
* quick-chat / popup 仍只传 enableThinking:false(不带 reasoningEffort)→ 关思考。
|
|
24
23
|
*/
|
|
25
24
|
enableThinking?: boolean;
|
|
26
25
|
/**
|
|
@@ -51,11 +50,17 @@ export interface CopilotChatOptions extends CopilotBaseOptions {
|
|
|
51
50
|
*/
|
|
52
51
|
onRunFinished?: () => void;
|
|
53
52
|
}
|
|
54
|
-
/**
|
|
55
|
-
|
|
53
|
+
/**
|
|
54
|
+
* 随用户一句话附上的一张图:`url` 是 data URL;`path` 是执行端这台机器上的图片文件,
|
|
55
|
+
* 由执行端读出并缩到长边 1280 再交给模型。
|
|
56
|
+
*/
|
|
57
|
+
export type CopilotInputImage = {
|
|
56
58
|
url: string;
|
|
57
59
|
mime?: string;
|
|
58
|
-
}
|
|
60
|
+
} | {
|
|
61
|
+
path: string;
|
|
62
|
+
mime?: string;
|
|
63
|
+
};
|
|
59
64
|
/** 待投递给主 agent 的一条内容:notice = 后台任务完成通知,interject = 用户在生成途中插的话。 */
|
|
60
65
|
export interface CopilotPendingInjection {
|
|
61
66
|
kind: "notice" | "interject";
|
|
@@ -67,12 +72,23 @@ export interface CopilotPendingInjection {
|
|
|
67
72
|
images?: CopilotInputImage[];
|
|
68
73
|
}
|
|
69
74
|
export interface CopilotOptions extends CopilotChatOptions {
|
|
70
|
-
|
|
75
|
+
/**
|
|
76
|
+
* quick = 精简的一问一答(智能工具栏):不带任何工具、不思考、用精简提示词。缺省是完整的 agent 轮次。
|
|
77
|
+
*/
|
|
78
|
+
mode?: "quick";
|
|
79
|
+
/**
|
|
80
|
+
* quick = 这一轮发自快捷入口(问问智能助理、快捷命令、智能工具栏):新对话记成 quick 类型,
|
|
81
|
+
* 之后在智能助理里接着聊(不带它)就转成普通对话。与 mode 各管一件事:一个管对话归到哪,一个管这一轮怎么跑。
|
|
82
|
+
*/
|
|
83
|
+
kind?: "quick";
|
|
84
|
+
/**
|
|
85
|
+
* 新对话的标题:发起方手里已有现成的(如智能工具栏的「Prompt 名:选中文字」)就带上,
|
|
86
|
+
* 不再从这句话起标题 —— 同一个 Prompt 模板开头的对话,取开头起出来条条一样。对话已有标题时不改。
|
|
87
|
+
*/
|
|
88
|
+
title?: string;
|
|
71
89
|
projectDir?: string;
|
|
72
90
|
recursionLimit?: number;
|
|
73
91
|
thread_id?: string;
|
|
74
|
-
/** 经哪个桥发起(如 wechat)。这一轮新建对话时写进对话行的 bridge。 */
|
|
75
|
-
bridge?: string;
|
|
76
92
|
run_id?: string;
|
|
77
93
|
/**
|
|
78
94
|
* 计费用的模型名(LiteLLM 的 model_name,如 deepseek-v4-pro)。
|
|
@@ -86,9 +102,11 @@ export interface CopilotOptions extends CopilotChatOptions {
|
|
|
86
102
|
*/
|
|
87
103
|
viaGateway?: boolean;
|
|
88
104
|
streamMode?: string[];
|
|
105
|
+
/**
|
|
106
|
+
* 本轮常驻的 AI 插件:它们的工具直接进模型的工具表,不必先 tool_search。
|
|
107
|
+
* 只给插件自己发起的轮次用(如电脑控制插件在后台跑自己的活),不写进对话,界面上没有这个选择。
|
|
108
|
+
*/
|
|
89
109
|
plugins?: string[];
|
|
90
|
-
tools?: any[];
|
|
91
|
-
skills?: string[];
|
|
92
110
|
chatModel?: any;
|
|
93
111
|
/** 本轮模型看得了图:主进程按模型标签定,决定要不要给 agent 装 view_image */
|
|
94
112
|
vision?: boolean;
|
|
@@ -121,6 +139,16 @@ export interface CopilotOptions extends CopilotChatOptions {
|
|
|
121
139
|
images?: CopilotInputImage[];
|
|
122
140
|
}
|
|
123
141
|
export type CopilotRunOptions = CopilotOptions;
|
|
142
|
+
/**
|
|
143
|
+
* `window.copilot.run/resume` 被拒时抛出的东西:普通对象而不是 Error,经 contextBridge 交到页面时 code 才留得住。
|
|
144
|
+
* code 是主进程给的错误码(busy、stale、COPILOT_LOGIN_REQUIRED、COPILOT_MODEL_NOT_FOUND……),message 是原话。
|
|
145
|
+
* 起跑之后的失败(含额度用完 COPILOT_QUOTA_BLOCKED)不从这里抛,走 `onRunEvent` 的 error 事件,data 同样带 code 与 message
|
|
146
|
+
*/
|
|
147
|
+
export interface CopilotRoundRefusal {
|
|
148
|
+
name: "CopilotRoundRefusal";
|
|
149
|
+
code: string;
|
|
150
|
+
message: string;
|
|
151
|
+
}
|
|
124
152
|
/** 一行 = 某个模型某一天的 token 统计。model_name 是模型 id,显示名要另去模型清单里换。 */
|
|
125
153
|
export interface CopilotUsageStat {
|
|
126
154
|
model_name: string;
|
|
@@ -133,7 +161,6 @@ export interface CopilotUsageStat {
|
|
|
133
161
|
}
|
|
134
162
|
export default class Copilot {
|
|
135
163
|
ipcRenderer: IpcRenderer;
|
|
136
|
-
private seq;
|
|
137
164
|
constructor();
|
|
138
165
|
/**
|
|
139
166
|
* 单轮补全:按 options.model(缺省用默认补全模型)一次性生成并直接返回完整文本,
|
|
@@ -146,13 +173,9 @@ export default class Copilot {
|
|
|
146
173
|
* @throws 模型不存在或 provider 不支持时抛错;流式错误后配额已退还再抛原错。
|
|
147
174
|
*/
|
|
148
175
|
completion: (input: string, options: any) => Promise<any>;
|
|
149
|
-
chat: (input: string, options: CopilotRunOptions) => Promise<AsyncIterableIterator<any>>;
|
|
150
176
|
/**
|
|
151
|
-
* 跑一轮。返回本轮的 requestId,**事件不在返回值里** —— 用 `onRunEvent`
|
|
152
|
-
*
|
|
153
|
-
* 以前返回一条只有发起方拿得到的流,于是别人开的那一轮谁也看不见:
|
|
154
|
-
* 微信桥、定时任务在后台跑的轮次,本机界面只能等落库刷出结果。
|
|
155
|
-
* 订阅必须在发起**之前**建立,否则会漏掉开头那几条。
|
|
177
|
+
* 跑一轮。返回本轮的 requestId,**事件不在返回值里** —— 用 `onRunEvent` 订阅,按 requestId 认领。
|
|
178
|
+
* 订阅必须在发起**之前**建立,否则会漏掉开头那几条。被拒时抛 {@link CopilotRoundRefusal}。
|
|
156
179
|
*/
|
|
157
180
|
run: (input: string, options: CopilotRunOptions) => Promise<string>;
|
|
158
181
|
/** 轮次事件在本进程里的全部订阅者。端口只开一条,见 onRunEvent。 */
|
|
@@ -209,5 +232,9 @@ export default class Copilot {
|
|
|
209
232
|
}) => void) => (() => void);
|
|
210
233
|
/** 续一轮。与 run 同理:返回 requestId,事件用 `onRunEvent` 订阅。 */
|
|
211
234
|
resume: (response: any, options: CopilotRunOptions) => Promise<string>;
|
|
212
|
-
|
|
235
|
+
/**
|
|
236
|
+
* 发起或续跑一轮。被拒时抛 {@link CopilotRoundRefusal} 这个普通对象:Error 经 contextBridge 交到页面只剩 message,
|
|
237
|
+
* code 属性到不了页面,而判忙、晚到这些拒绝要按码分支
|
|
238
|
+
*/
|
|
239
|
+
private startRound;
|
|
213
240
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as IpcRenderer } from './IpcRenderer';
|
|
2
|
-
/**
|
|
2
|
+
/** 装好、改好或重新启用一台 MCP server 后(设置页或对话里),主进程经 copilot.mcp.installed 推来的 payload。 */
|
|
3
3
|
export interface CopilotMcpInstalledMessage {
|
|
4
4
|
name: string;
|
|
5
5
|
displayName: string;
|
|
@@ -10,20 +10,21 @@ export default class CopilotMcpServer {
|
|
|
10
10
|
private transport;
|
|
11
11
|
constructor(transport?: IpcRenderer);
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* 列出已配置的全部 MCP server,含停用的。
|
|
14
14
|
*
|
|
15
|
-
* @returns
|
|
15
|
+
* @returns 所有 MCP server 实体数组。
|
|
16
16
|
*/
|
|
17
17
|
getServers: () => Promise<any>;
|
|
18
18
|
/**
|
|
19
|
-
* 新增一个 MCP server
|
|
19
|
+
* 新增一个 MCP server 配置;已有同名的则更新那一台。启用着的随即连一次,列出它的工具。
|
|
20
20
|
*
|
|
21
21
|
* @param data MCP server 的部分字段,name/transport/command/url 等按需传入;未填字段取实体默认值。
|
|
22
|
-
* @returns 落库后的完整 CopilotMcpServer
|
|
22
|
+
* @returns 落库后的完整 CopilotMcpServer 实体,附 toolNames(连接测试取到的工具名,为空表示连不通或没有工具)。
|
|
23
23
|
*/
|
|
24
24
|
addServer: (data: any) => Promise<any>;
|
|
25
25
|
/**
|
|
26
26
|
* 按 id 局部更新一个 MCP server 配置:只覆盖 data 中传入的字段,id/created_at/updated_at 等只读字段不会被覆盖。
|
|
27
|
+
* 改成别的 server 已在用的名字时报错。
|
|
27
28
|
*
|
|
28
29
|
* @param id 目标 MCP server 的 id。
|
|
29
30
|
* @param data 要合并进现有记录的字段(undefined 的字段会被置为 null)。
|
|
@@ -46,20 +47,19 @@ export default class CopilotMcpServer {
|
|
|
46
47
|
*/
|
|
47
48
|
toggleServer: (id: string, enabled: boolean) => Promise<any>;
|
|
48
49
|
/**
|
|
49
|
-
* 按名称测试一个已保存的 MCP server
|
|
50
|
-
* 先在库中按 name 查找;插件自带的 server(pluginName 非空)直接视为通过,不做实际连接测试。
|
|
50
|
+
* 按名称测试一个已保存的 MCP server 能否连上,连上时顺带记下它的工具定义。
|
|
51
51
|
*
|
|
52
52
|
* @param server MCP server 的名称(name 字段,非 id)。
|
|
53
|
-
* @returns true
|
|
53
|
+
* @returns true 表示连接成功;false 表示 server 不存在或连接失败。
|
|
54
54
|
*/
|
|
55
55
|
testConnect: (server: string) => Promise<any>;
|
|
56
56
|
/**
|
|
57
|
-
* 订阅"
|
|
57
|
+
* 订阅"装好、改好或重新启用了一台 MCP server"通知(设置页或对话里)。渲染层据此刷新列表、把新 server 并入
|
|
58
58
|
* 当前会话的 usedServers、弹全局 Toast。返回 unsubscribe。
|
|
59
59
|
* 底层 IpcRenderer.on 对同通道 removeAllListeners 后再绑,全局只应有一个订阅者。
|
|
60
60
|
*/
|
|
61
61
|
onMcpInstalled: (onInstalled: (msg: CopilotMcpInstalledMessage) => void) => (() => void);
|
|
62
|
-
/** 订阅"
|
|
62
|
+
/** 订阅"删除、禁用或改名了一台 MCP server"通知(设置页或对话里)。渲染层据此刷新列表、把它移出 usedServers。 */
|
|
63
63
|
onMcpRemoved: (onRemoved: (msg: {
|
|
64
64
|
name: string;
|
|
65
65
|
displayName?: string;
|
package/types/CopilotThread.d.ts
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -18,7 +18,6 @@ import { default as SystemShell } from './SystemShell';
|
|
|
18
18
|
import { default as SystemBrowser } from './SystemBrowser';
|
|
19
19
|
import { default as SystemShortcut } from './SystemShortcut';
|
|
20
20
|
import { default as SystemWindow } from './SystemWindow';
|
|
21
|
-
import { default as CopilotWechatBridge } from './CopilotWechatBridge';
|
|
22
21
|
import { default as Workspace } from './Workspace';
|
|
23
22
|
import { default as File } from './File';
|
|
24
23
|
import { default as Http } from './Http';
|
|
@@ -56,7 +55,6 @@ declare global {
|
|
|
56
55
|
systemShortcut: SystemShortcut;
|
|
57
56
|
systemWindow: SystemWindow;
|
|
58
57
|
systemNotification: SystemNotification;
|
|
59
|
-
copilotWechatBridge: CopilotWechatBridge;
|
|
60
58
|
workspace: Workspace;
|
|
61
59
|
file: File;
|
|
62
60
|
http: Http;
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { default as IpcRenderer } from './IpcRenderer';
|
|
2
|
-
export interface WechatAccount {
|
|
3
|
-
accountId: string;
|
|
4
|
-
baseUrl: string;
|
|
5
|
-
cdnBaseUrl: string;
|
|
6
|
-
token?: string;
|
|
7
|
-
configured: boolean;
|
|
8
|
-
userId?: string;
|
|
9
|
-
enabled: boolean;
|
|
10
|
-
}
|
|
11
|
-
export interface WechatLoginStartResult {
|
|
12
|
-
qrcode: string;
|
|
13
|
-
sessionKey: string;
|
|
14
|
-
message: string;
|
|
15
|
-
}
|
|
16
|
-
export interface WechatLoginResult {
|
|
17
|
-
connected: boolean;
|
|
18
|
-
alreadyConnected?: boolean;
|
|
19
|
-
accountId?: string;
|
|
20
|
-
sessionKey?: string;
|
|
21
|
-
baseUrl?: string;
|
|
22
|
-
userId?: string;
|
|
23
|
-
message: string;
|
|
24
|
-
}
|
|
25
|
-
export interface WechatChannelStatus {
|
|
26
|
-
running: boolean;
|
|
27
|
-
account: WechatAccount;
|
|
28
|
-
}
|
|
29
|
-
export default class CopilotWechatBridge {
|
|
30
|
-
private transport;
|
|
31
|
-
constructor(transport?: IpcRenderer);
|
|
32
|
-
/**
|
|
33
|
-
* 发起微信扫码登录流程,向微信 API 请求登录二维码并返回给渲染进程展示。
|
|
34
|
-
*
|
|
35
|
-
* @param params 可选参数对象。
|
|
36
|
-
* @param params.force 是否强制重新获取二维码;`false` 或省略时,若存在未过期的有效二维码则直接复用。
|
|
37
|
-
* @returns 包含二维码图片 URL、本次登录的 `sessionKey` 及提示文本的启动结果。
|
|
38
|
-
* @throws 微信 API 返回的二维码响应不完整(缺少 qrcode 或 qrcodeUrl 字段)时抛错。
|
|
39
|
-
*/
|
|
40
|
-
startLogin: (params?: {
|
|
41
|
-
force?: boolean;
|
|
42
|
-
}) => Promise<WechatLoginStartResult>;
|
|
43
|
-
/**
|
|
44
|
-
* 轮询等待用户手机微信扫码并确认登录。以 1 秒间隔轮询二维码状态,
|
|
45
|
-
* 直到用户确认、二维码过期或超时。登录确认后自动保存账号凭证到本地数据库,
|
|
46
|
-
* 若为新连接(非此前已绑定)则自动启动微信消息桥接通道。
|
|
47
|
-
*
|
|
48
|
-
* @param params 登录等待参数。
|
|
49
|
-
* @param params.sessionKey 由 `startLogin` 返回的会话标识,用于关联本次扫码流程。
|
|
50
|
-
* @param params.timeoutMs 等待超时毫秒数,默认 480_000(8 分钟),实际取值最小为 1_000。
|
|
51
|
-
* @returns 登录结果:`connected` 表示是否连接成功;`alreadyConnected` 为 `true` 表示该设备此前已绑定,
|
|
52
|
-
* 无需重新扫码即恢复连接;失败时 `message` 携带原因描述。
|
|
53
|
-
*/
|
|
54
|
-
waitForLogin: (params: {
|
|
55
|
-
sessionKey: string;
|
|
56
|
-
timeoutMs?: number;
|
|
57
|
-
}) => Promise<WechatLoginResult>;
|
|
58
|
-
/**
|
|
59
|
-
* 登出微信:先停止消息桥接通道(终止长轮询),再清除本地数据库中的账号凭证。
|
|
60
|
-
*
|
|
61
|
-
* @returns 无返回。
|
|
62
|
-
*/
|
|
63
|
-
logout: () => Promise<void>;
|
|
64
|
-
/**
|
|
65
|
-
* 查询当前微信桥接的运行状态及已登录的账号信息。
|
|
66
|
-
*
|
|
67
|
-
* @returns 包含两个字段的对象:`running` 表示消息监听循环是否正在运行;
|
|
68
|
-
* `account` 为当前账号配置详情,包含 `configured`(是否有 token)、
|
|
69
|
-
* `enabled`(是否启用)、`accountId`、`userId` 等字段。
|
|
70
|
-
*/
|
|
71
|
-
status: () => Promise<WechatChannelStatus>;
|
|
72
|
-
/**
|
|
73
|
-
* 启动微信消息桥接通道,开始长轮询监听微信消息。
|
|
74
|
-
* 仅在系统设置 `copilot.bridge.wechat.enabled` 为 `true` 且当前账号已配置并启用时才会实际启动;
|
|
75
|
-
* 任一条件不满足则主动停止已有的监听循环。
|
|
76
|
-
*
|
|
77
|
-
* @returns 无返回。
|
|
78
|
-
*/
|
|
79
|
-
channelStart: () => Promise<void>;
|
|
80
|
-
/**
|
|
81
|
-
* 停止微信消息桥接通道,终止长轮询监听循环并释放相关资源。
|
|
82
|
-
*
|
|
83
|
-
* @returns 无返回。
|
|
84
|
-
*/
|
|
85
|
-
channelStop: () => Promise<void>;
|
|
86
|
-
}
|