@tencent-ai/cloud-agent-sdk 0.2.6 → 0.2.7-next.dbd767f.20260127
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/dist/index.cjs +694 -137
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -170
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +34 -170
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +694 -137
- package/dist/index.mjs.map +1 -1
- package/dist/tencent-ai-cloud-agent-sdk-0.2.7-next.dbd767f.20260127.tgz +0 -0
- package/package.json +4 -3
- package/dist/MockAgentProvider-4e4oOusg.cjs +0 -3
- package/dist/MockAgentProvider-D-basTXz.cjs +0 -3219
- package/dist/MockAgentProvider-D-basTXz.cjs.map +0 -1
- package/dist/MockAgentProvider-TNsV559x.mjs +0 -3202
- package/dist/MockAgentProvider-TNsV559x.mjs.map +0 -1
- package/dist/MockAgentProvider-tNdtAJCv.mjs +0 -3
- package/dist/tencent-ai-cloud-agent-sdk-0.2.6.tgz +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,633 @@
|
|
|
1
|
-
import "
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
import { ClientSideConnection, PROTOCOL_VERSION } from "@agentclientprotocol/sdk";
|
|
3
3
|
import "@connectrpc/connect";
|
|
4
4
|
import "@connectrpc/connect-web";
|
|
5
5
|
import "@bufbuild/protobuf";
|
|
6
6
|
import { Sandbox } from "e2b";
|
|
7
7
|
|
|
8
|
+
//#region ../agent-provider/src/common/_legacy/tool-schemas.ts
|
|
9
|
+
/**
|
|
10
|
+
* ACP Tool Input/Output Schema 定义
|
|
11
|
+
*
|
|
12
|
+
* 用于约束 ACP 协议中 ToolCallUpdate 的 rawInput 和 rawOutput 字段
|
|
13
|
+
* 基于 getCraftToolProvider 使用的工具定义
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* 工具输入 Schema 定义
|
|
17
|
+
* 用于验证和约束 rawInput
|
|
18
|
+
*/
|
|
19
|
+
const ToolInputSchemas = {
|
|
20
|
+
list_dir: z.object({
|
|
21
|
+
target_directory: z.string().describe("要列出内容的目录路径"),
|
|
22
|
+
ignore_globs: z.string().optional().describe("可选的 glob 模式数组,用于忽略特定文件")
|
|
23
|
+
}),
|
|
24
|
+
search_file: z.object({
|
|
25
|
+
target_directory: z.string().describe("搜索的目录绝对路径"),
|
|
26
|
+
pattern: z.string().describe("文件模式(如 \"*.js\"),支持通配符"),
|
|
27
|
+
recursive: z.boolean().describe("是否递归搜索子目录"),
|
|
28
|
+
caseSensitive: z.boolean().describe("是否区分大小写")
|
|
29
|
+
}),
|
|
30
|
+
read_file: z.object({
|
|
31
|
+
filePath: z.string().describe("要读取的文件的绝对路径"),
|
|
32
|
+
offset: z.number().optional().describe("开始读取的行号"),
|
|
33
|
+
limit: z.number().optional().describe("要读取的行数")
|
|
34
|
+
}),
|
|
35
|
+
read_lints: z.object({ paths: z.string().optional().describe("要读取 lint 错误的文件或目录路径") }),
|
|
36
|
+
rag_search: z.object({
|
|
37
|
+
queryString: z.string().describe("用户的实际问题或搜索查询"),
|
|
38
|
+
knowledgeBaseNames: z.string().describe("知识库名称,多个用逗号分隔")
|
|
39
|
+
}),
|
|
40
|
+
read_rules: z.object({ ruleNames: z.string().describe("要读取的规则关键词,用逗号分隔,格式:{ruleName}_{ruleId}") }),
|
|
41
|
+
mcp_get_tool_description: z.object({ toolRequests: z.string().describe("JSON 字符串,二维数组格式:[[\"server1\", \"tool1\"], [\"server2\", \"tool2\"]]") }),
|
|
42
|
+
mcp_call_tool: z.object({
|
|
43
|
+
serverName: z.string().describe("MCP 服务器名称"),
|
|
44
|
+
toolName: z.string().describe("要调用的工具名称"),
|
|
45
|
+
arguments: z.string().describe("目标 MCP 工具的参数,JSON 格式字符串"),
|
|
46
|
+
maxOutputLength: z.number().optional().describe("控制工具输出的最大长度,默认 200000")
|
|
47
|
+
}),
|
|
48
|
+
fetch_mcp_resource: z.object({
|
|
49
|
+
server: z.string().describe("MCP 服务器标识符"),
|
|
50
|
+
uri: z.string().describe("要读取的资源 URI"),
|
|
51
|
+
arguments: z.record(z.unknown()).optional().describe("资源模板的参数"),
|
|
52
|
+
downloadPath: z.string().optional().describe("可选的绝对路径,用于保存资源到磁盘")
|
|
53
|
+
}),
|
|
54
|
+
create_rule: z.object({
|
|
55
|
+
ruleScope: z.string().describe("规则范围,project rule 或 user rule"),
|
|
56
|
+
ruleName: z.string().describe("规则文件名,不带扩展名"),
|
|
57
|
+
ruleType: z.string().describe("规则类型,always、manual 或 requested"),
|
|
58
|
+
ruleContent: z.string().describe("规则内容,使用 Markdown 格式"),
|
|
59
|
+
ruleDescription: z.string().optional().describe("规则描述,使用 Markdown 格式")
|
|
60
|
+
}),
|
|
61
|
+
update_memory: z.object({
|
|
62
|
+
action: z.enum([
|
|
63
|
+
"create",
|
|
64
|
+
"update",
|
|
65
|
+
"delete"
|
|
66
|
+
]).optional().describe("执行的操作"),
|
|
67
|
+
existing_knowledge_id: z.string().optional().describe("更新或删除时必需,现有记忆的 ID"),
|
|
68
|
+
knowledge_to_store: z.string().optional().describe("要存储的特定记忆"),
|
|
69
|
+
title: z.string().optional().describe("记忆的标题")
|
|
70
|
+
}),
|
|
71
|
+
search_content: z.object({
|
|
72
|
+
pattern: z.string().describe("要搜索的关键字或正则表达式模式"),
|
|
73
|
+
directory: z.string().describe("要搜索的目录的绝对路径"),
|
|
74
|
+
fileTypes: z.string().optional().describe("可选的逗号分隔文件扩展名"),
|
|
75
|
+
contextBefore: z.number().optional().describe("每个匹配前显示的行数"),
|
|
76
|
+
contextAfter: z.number().optional().describe("每个匹配后显示的行数"),
|
|
77
|
+
contextAround: z.number().optional().describe("每个匹配前后显示的行数"),
|
|
78
|
+
outputMode: z.string().optional().describe("输出模式:content、files_with_matches 或 count"),
|
|
79
|
+
caseSensitive: z.boolean().optional().describe("是否区分大小写")
|
|
80
|
+
}),
|
|
81
|
+
write_to_file: z.object({
|
|
82
|
+
filePath: z.string().describe("目标文件的绝对路径"),
|
|
83
|
+
content: z.string().describe("要写入的内容")
|
|
84
|
+
}),
|
|
85
|
+
replace_in_file: z.object({
|
|
86
|
+
filePath: z.string().describe("要修改的文件的绝对路径"),
|
|
87
|
+
old_str: z.string().describe("要替换的文本"),
|
|
88
|
+
new_str: z.string().describe("替换后的文本")
|
|
89
|
+
}),
|
|
90
|
+
delete_file: z.object({
|
|
91
|
+
target_file: z.string().describe("要删除的文件的绝对路径"),
|
|
92
|
+
explanation: z.string().optional().describe("为什么使用此工具的一句话解释")
|
|
93
|
+
}),
|
|
94
|
+
execute_command: z.object({
|
|
95
|
+
command: z.string().describe("要执行的 CLI 命令"),
|
|
96
|
+
requires_approval: z.boolean().describe("命令是否需要用户批准")
|
|
97
|
+
}),
|
|
98
|
+
preview_url: z.object({ url: z.string().describe("要打开的完整、有效的 HTTP/HTTPS URL") }),
|
|
99
|
+
ask_followup_question: z.object({ questions: z.array(z.object({
|
|
100
|
+
question: z.string(),
|
|
101
|
+
header: z.string().max(12),
|
|
102
|
+
options: z.array(z.object({
|
|
103
|
+
label: z.string().max(50),
|
|
104
|
+
description: z.string()
|
|
105
|
+
})).min(2).max(4),
|
|
106
|
+
multiSelect: z.boolean().optional()
|
|
107
|
+
})).min(1).max(4) }),
|
|
108
|
+
invoke_integration: z.object({}).passthrough(),
|
|
109
|
+
call_integration: z.object({}).passthrough(),
|
|
110
|
+
search_integration_tool: z.object({}).passthrough(),
|
|
111
|
+
supabase_get_logs: z.object({}).passthrough(),
|
|
112
|
+
supabase_execute_sql: z.object({}).passthrough(),
|
|
113
|
+
supabase_apply_migration: z.object({}).passthrough(),
|
|
114
|
+
supabase_list_migration: z.object({}).passthrough(),
|
|
115
|
+
supabase_list_tables: z.object({}).passthrough(),
|
|
116
|
+
cloud_studio_fetch_log: z.object({}).passthrough(),
|
|
117
|
+
cloud_studio_execute_command: z.object({}).passthrough(),
|
|
118
|
+
cloud_studio_deploy_sandbox: z.object({}).passthrough(),
|
|
119
|
+
component_get_prompt: z.object({}).passthrough(),
|
|
120
|
+
web_fetch: z.object({
|
|
121
|
+
url: z.string().describe("要获取内容的 URL"),
|
|
122
|
+
fetchInfo: z.string().describe("用户想要获取的信息描述")
|
|
123
|
+
}),
|
|
124
|
+
use_skill: z.object({ command: z.string().describe("技能名称(不含参数),如 \"pdf\" 或 \"xlsx\"") }),
|
|
125
|
+
web_search: z.object({
|
|
126
|
+
explanation: z.string().describe("为什么使用此工具的一句话解释"),
|
|
127
|
+
searchTerm: z.string().describe("要在网络上搜索的搜索词")
|
|
128
|
+
}),
|
|
129
|
+
task: z.object({
|
|
130
|
+
subagent_name: z.string().describe("要调用的子代理名称"),
|
|
131
|
+
description: z.string().describe("任务的简短描述(3-5 个词)"),
|
|
132
|
+
prompt: z.string().describe("子代理要执行的任务"),
|
|
133
|
+
subagent_path: z.string().optional().describe("子代理定义文件的路径")
|
|
134
|
+
}),
|
|
135
|
+
codebase_search: z.object({
|
|
136
|
+
query: z.string().describe("关于你想理解的内容的完整问题"),
|
|
137
|
+
path: z.string().describe("限制搜索范围的目录路径前缀"),
|
|
138
|
+
limit: z.number().max(100).optional().describe("返回的最大结果数,默认 10")
|
|
139
|
+
}),
|
|
140
|
+
lsp: z.object({}).passthrough(),
|
|
141
|
+
spec_create: z.object({
|
|
142
|
+
name: z.string().describe("Plan 名称,用作稳定标识符/文件名"),
|
|
143
|
+
overview: z.string().describe("用一两句话精确概括本次 plan 的主要内容"),
|
|
144
|
+
relative_history: z.string().describe("准备阶段的上下文,包含用户需求、代码位置、额外上下文等")
|
|
145
|
+
}),
|
|
146
|
+
spec_update: z.object({ status: z.enum([
|
|
147
|
+
"prepare",
|
|
148
|
+
"ready",
|
|
149
|
+
"building",
|
|
150
|
+
"finished"
|
|
151
|
+
]).optional().describe("Plan 状态") })
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* 工具输出 Schema 定义
|
|
155
|
+
* 用于验证和约束 rawOutput
|
|
156
|
+
*/
|
|
157
|
+
const ToolOutputSchemas = {
|
|
158
|
+
list_dir: z.object({
|
|
159
|
+
type: z.literal("list_files_result"),
|
|
160
|
+
files: z.array(z.object({
|
|
161
|
+
filePath: z.string(),
|
|
162
|
+
size: z.string(),
|
|
163
|
+
modifyTime: z.string()
|
|
164
|
+
})),
|
|
165
|
+
root: z.string(),
|
|
166
|
+
listing: z.string().optional()
|
|
167
|
+
}),
|
|
168
|
+
search_file: z.object({
|
|
169
|
+
type: z.literal("search_file_result"),
|
|
170
|
+
path: z.string(),
|
|
171
|
+
pattern: z.string(),
|
|
172
|
+
recursive: z.boolean().optional(),
|
|
173
|
+
caseSensitive: z.boolean().optional(),
|
|
174
|
+
results: z.array(z.object({
|
|
175
|
+
filePath: z.string(),
|
|
176
|
+
size: z.string(),
|
|
177
|
+
modifyTime: z.string()
|
|
178
|
+
}))
|
|
179
|
+
}),
|
|
180
|
+
read_file: z.object({
|
|
181
|
+
type: z.literal("read_file_result"),
|
|
182
|
+
path: z.string(),
|
|
183
|
+
content: z.string(),
|
|
184
|
+
totalLineCount: z.number(),
|
|
185
|
+
hasMore: z.boolean(),
|
|
186
|
+
diagnostic: z.string().optional(),
|
|
187
|
+
hint: z.string().optional(),
|
|
188
|
+
image: z.object({
|
|
189
|
+
data: z.string(),
|
|
190
|
+
mimeType: z.string()
|
|
191
|
+
}).optional()
|
|
192
|
+
}),
|
|
193
|
+
read_lints: z.object({
|
|
194
|
+
type: z.literal("read_lints_result"),
|
|
195
|
+
diagnostics: z.array(z.string()),
|
|
196
|
+
totalCount: z.number().optional(),
|
|
197
|
+
hint: z.string().optional(),
|
|
198
|
+
isTruncated: z.boolean().optional()
|
|
199
|
+
}),
|
|
200
|
+
rag_search: z.object({
|
|
201
|
+
type: z.literal("knowledge_base_result"),
|
|
202
|
+
selectedKnowledgeBases: z.string(),
|
|
203
|
+
queryInput: z.string()
|
|
204
|
+
}),
|
|
205
|
+
read_rules: z.object({
|
|
206
|
+
type: z.literal("rule_match_result"),
|
|
207
|
+
ruleDescription: z.string(),
|
|
208
|
+
filePaths: z.array(z.string())
|
|
209
|
+
}),
|
|
210
|
+
mcp_get_tool_description: z.object({}).passthrough(),
|
|
211
|
+
mcp_call_tool: z.object({
|
|
212
|
+
type: z.literal("mcp_call_tool_result"),
|
|
213
|
+
serverName: z.string(),
|
|
214
|
+
toolName: z.string(),
|
|
215
|
+
data: z.array(z.union([
|
|
216
|
+
z.object({
|
|
217
|
+
type: z.literal("text"),
|
|
218
|
+
text: z.string()
|
|
219
|
+
}),
|
|
220
|
+
z.object({
|
|
221
|
+
type: z.literal("image"),
|
|
222
|
+
data: z.string(),
|
|
223
|
+
mimeType: z.string()
|
|
224
|
+
}),
|
|
225
|
+
z.object({
|
|
226
|
+
type: z.literal("resource"),
|
|
227
|
+
resource: z.object({
|
|
228
|
+
uri: z.string(),
|
|
229
|
+
mimeType: z.string().optional(),
|
|
230
|
+
text: z.string().optional(),
|
|
231
|
+
blob: z.string().optional()
|
|
232
|
+
})
|
|
233
|
+
})
|
|
234
|
+
])),
|
|
235
|
+
isError: z.boolean().optional(),
|
|
236
|
+
error: z.unknown().optional(),
|
|
237
|
+
hint: z.string().optional()
|
|
238
|
+
}),
|
|
239
|
+
fetch_mcp_resource: z.object({
|
|
240
|
+
type: z.literal("fetch_mcp_resource_result"),
|
|
241
|
+
server: z.string(),
|
|
242
|
+
uri: z.string(),
|
|
243
|
+
content: z.string(),
|
|
244
|
+
downloadPath: z.string().optional()
|
|
245
|
+
}),
|
|
246
|
+
create_rule: z.object({
|
|
247
|
+
type: z.literal("rule_create_result"),
|
|
248
|
+
ruleName: z.string(),
|
|
249
|
+
createState: z.enum([
|
|
250
|
+
"success",
|
|
251
|
+
"invoke",
|
|
252
|
+
"cancelled"
|
|
253
|
+
]),
|
|
254
|
+
hint: z.string().optional(),
|
|
255
|
+
filePath: z.string().optional()
|
|
256
|
+
}),
|
|
257
|
+
update_memory: z.object({
|
|
258
|
+
type: z.literal("update_memory_result"),
|
|
259
|
+
success: z.boolean(),
|
|
260
|
+
message: z.string(),
|
|
261
|
+
action: z.enum([
|
|
262
|
+
"create",
|
|
263
|
+
"update",
|
|
264
|
+
"delete"
|
|
265
|
+
]),
|
|
266
|
+
knowledge_id: z.string().optional()
|
|
267
|
+
}),
|
|
268
|
+
search_content: z.object({
|
|
269
|
+
type: z.literal("search_content_result"),
|
|
270
|
+
directory: z.string(),
|
|
271
|
+
pattern: z.string(),
|
|
272
|
+
fileTypes: z.string(),
|
|
273
|
+
matches: z.array(z.object({
|
|
274
|
+
filePath: z.string(),
|
|
275
|
+
content: z.string(),
|
|
276
|
+
startLine: z.number(),
|
|
277
|
+
endLine: z.number(),
|
|
278
|
+
size: z.string(),
|
|
279
|
+
modifyTime: z.string()
|
|
280
|
+
})),
|
|
281
|
+
totalCount: z.number(),
|
|
282
|
+
hasMore: z.boolean(),
|
|
283
|
+
offset: z.number(),
|
|
284
|
+
limit: z.number(),
|
|
285
|
+
contextBefore: z.number(),
|
|
286
|
+
contextAfter: z.number(),
|
|
287
|
+
contextAround: z.number().optional(),
|
|
288
|
+
outputMode: z.string(),
|
|
289
|
+
caseSensitive: z.boolean(),
|
|
290
|
+
hint: z.string().optional()
|
|
291
|
+
}),
|
|
292
|
+
write_to_file: z.object({
|
|
293
|
+
type: z.literal("write_to_file_result"),
|
|
294
|
+
path: z.string(),
|
|
295
|
+
addLineCount: z.number(),
|
|
296
|
+
removedLines: z.number(),
|
|
297
|
+
addedChars: z.number().optional(),
|
|
298
|
+
removedChars: z.number().optional(),
|
|
299
|
+
bytesWritten: z.number(),
|
|
300
|
+
isNewFile: z.boolean(),
|
|
301
|
+
oldContent: z.string().optional(),
|
|
302
|
+
diagnostic: z.string().optional()
|
|
303
|
+
}),
|
|
304
|
+
replace_in_file: z.object({
|
|
305
|
+
type: z.literal("replace_in_file_result"),
|
|
306
|
+
path: z.string(),
|
|
307
|
+
addLineCount: z.number().optional(),
|
|
308
|
+
removedLines: z.number().optional(),
|
|
309
|
+
addedChars: z.number().optional(),
|
|
310
|
+
removedChars: z.number().optional(),
|
|
311
|
+
matchCount: z.number().optional(),
|
|
312
|
+
hint: z.string().optional(),
|
|
313
|
+
diagnosticChange: z.object({
|
|
314
|
+
added: z.string(),
|
|
315
|
+
removed: z.string(),
|
|
316
|
+
unchanged: z.string()
|
|
317
|
+
}).optional()
|
|
318
|
+
}),
|
|
319
|
+
delete_file: z.object({
|
|
320
|
+
type: z.literal("delete_file_result"),
|
|
321
|
+
path: z.string(),
|
|
322
|
+
recursive: z.boolean(),
|
|
323
|
+
hint: z.string().optional()
|
|
324
|
+
}),
|
|
325
|
+
execute_command: z.object({
|
|
326
|
+
type: z.literal("execute_command_result"),
|
|
327
|
+
stdout: z.string(),
|
|
328
|
+
stderr: z.string(),
|
|
329
|
+
exitCode: z.number(),
|
|
330
|
+
hint: z.string().optional(),
|
|
331
|
+
serviceInfo: z.object({
|
|
332
|
+
isWatchCommand: z.boolean(),
|
|
333
|
+
isServiceOutput: z.boolean(),
|
|
334
|
+
serviceReady: z.boolean(),
|
|
335
|
+
message: z.string()
|
|
336
|
+
}).optional(),
|
|
337
|
+
use_standalone_terminal: z.boolean().optional()
|
|
338
|
+
}),
|
|
339
|
+
preview_url: z.object({
|
|
340
|
+
type: z.literal("preview_tool_result"),
|
|
341
|
+
url: z.string(),
|
|
342
|
+
message: z.string()
|
|
343
|
+
}),
|
|
344
|
+
ask_followup_question: z.object({
|
|
345
|
+
type: z.literal("multi_question_result"),
|
|
346
|
+
questions: z.array(z.object({
|
|
347
|
+
id: z.string(),
|
|
348
|
+
question: z.string(),
|
|
349
|
+
options: z.array(z.string()),
|
|
350
|
+
multiSelect: z.boolean().optional(),
|
|
351
|
+
title: z.string().optional()
|
|
352
|
+
})),
|
|
353
|
+
answers: z.record(z.union([z.string(), z.array(z.string())])),
|
|
354
|
+
message: z.string()
|
|
355
|
+
}),
|
|
356
|
+
invoke_integration: z.object({
|
|
357
|
+
type: z.literal("invoke_integration_tool_result"),
|
|
358
|
+
recommend: z.object({
|
|
359
|
+
id: z.string(),
|
|
360
|
+
type: z.string(),
|
|
361
|
+
status: z.enum(["connected", "disconnected"])
|
|
362
|
+
}),
|
|
363
|
+
message: z.string()
|
|
364
|
+
}),
|
|
365
|
+
call_integration: z.object({
|
|
366
|
+
type: z.literal("call_integration_tool_result"),
|
|
367
|
+
integrationId: z.string(),
|
|
368
|
+
toolName: z.string(),
|
|
369
|
+
data: z.object({
|
|
370
|
+
type: z.literal("text"),
|
|
371
|
+
text: z.string()
|
|
372
|
+
}),
|
|
373
|
+
isError: z.boolean().optional(),
|
|
374
|
+
error: z.unknown().optional()
|
|
375
|
+
}),
|
|
376
|
+
search_integration_tool: z.object({
|
|
377
|
+
type: z.literal("search_integration_tool_result"),
|
|
378
|
+
data: z.array(z.object({
|
|
379
|
+
integrationId: z.string(),
|
|
380
|
+
integrationName: z.string(),
|
|
381
|
+
toolName: z.string(),
|
|
382
|
+
description: z.string(),
|
|
383
|
+
inputSchema: z.record(z.unknown())
|
|
384
|
+
})),
|
|
385
|
+
hint: z.string().optional()
|
|
386
|
+
}),
|
|
387
|
+
supabase_get_logs: z.object({
|
|
388
|
+
type: z.enum([
|
|
389
|
+
"supabase_get_logs_result",
|
|
390
|
+
"supabase_execute_sql_result",
|
|
391
|
+
"supabase_apply_migration_result",
|
|
392
|
+
"supabase_list_migration_result",
|
|
393
|
+
"supabase_list_tables_result"
|
|
394
|
+
]),
|
|
395
|
+
message: z.string()
|
|
396
|
+
}),
|
|
397
|
+
supabase_execute_sql: z.object({
|
|
398
|
+
type: z.enum([
|
|
399
|
+
"supabase_get_logs_result",
|
|
400
|
+
"supabase_execute_sql_result",
|
|
401
|
+
"supabase_apply_migration_result",
|
|
402
|
+
"supabase_list_migration_result",
|
|
403
|
+
"supabase_list_tables_result"
|
|
404
|
+
]),
|
|
405
|
+
message: z.string()
|
|
406
|
+
}),
|
|
407
|
+
supabase_apply_migration: z.object({
|
|
408
|
+
type: z.enum([
|
|
409
|
+
"supabase_get_logs_result",
|
|
410
|
+
"supabase_execute_sql_result",
|
|
411
|
+
"supabase_apply_migration_result",
|
|
412
|
+
"supabase_list_migration_result",
|
|
413
|
+
"supabase_list_tables_result"
|
|
414
|
+
]),
|
|
415
|
+
message: z.string()
|
|
416
|
+
}),
|
|
417
|
+
supabase_list_migration: z.object({
|
|
418
|
+
type: z.enum([
|
|
419
|
+
"supabase_get_logs_result",
|
|
420
|
+
"supabase_execute_sql_result",
|
|
421
|
+
"supabase_apply_migration_result",
|
|
422
|
+
"supabase_list_migration_result",
|
|
423
|
+
"supabase_list_tables_result"
|
|
424
|
+
]),
|
|
425
|
+
message: z.string()
|
|
426
|
+
}),
|
|
427
|
+
supabase_list_tables: z.object({
|
|
428
|
+
type: z.enum([
|
|
429
|
+
"supabase_get_logs_result",
|
|
430
|
+
"supabase_execute_sql_result",
|
|
431
|
+
"supabase_apply_migration_result",
|
|
432
|
+
"supabase_list_migration_result",
|
|
433
|
+
"supabase_list_tables_result"
|
|
434
|
+
]),
|
|
435
|
+
message: z.string()
|
|
436
|
+
}),
|
|
437
|
+
cloud_studio_fetch_log: z.object({
|
|
438
|
+
type: z.literal("cloud_studio_fetch_log_result"),
|
|
439
|
+
success: z.boolean(),
|
|
440
|
+
logs: z.record(z.string())
|
|
441
|
+
}),
|
|
442
|
+
cloud_studio_execute_command: z.object({
|
|
443
|
+
type: z.literal("cloud_studio_execute_command_result"),
|
|
444
|
+
success: z.boolean(),
|
|
445
|
+
message: z.string()
|
|
446
|
+
}),
|
|
447
|
+
cloud_studio_deploy_sandbox: z.object({
|
|
448
|
+
type: z.literal("cloud_studio_integration_result"),
|
|
449
|
+
previewUrl: z.string().optional(),
|
|
450
|
+
steps: z.array(z.object({
|
|
451
|
+
status: z.enum([
|
|
452
|
+
"idle",
|
|
453
|
+
"success",
|
|
454
|
+
"running",
|
|
455
|
+
"error"
|
|
456
|
+
]),
|
|
457
|
+
name: z.enum([
|
|
458
|
+
"createSandbox",
|
|
459
|
+
"uploadProject",
|
|
460
|
+
"installDependencies",
|
|
461
|
+
"startService",
|
|
462
|
+
"preview"
|
|
463
|
+
]),
|
|
464
|
+
error: z.object({
|
|
465
|
+
code: z.number().optional(),
|
|
466
|
+
message: z.string().optional()
|
|
467
|
+
}).optional()
|
|
468
|
+
}))
|
|
469
|
+
}),
|
|
470
|
+
component_get_prompt: z.object({
|
|
471
|
+
type: z.literal("component_get_prompt_result"),
|
|
472
|
+
componentType: z.string(),
|
|
473
|
+
webFramework: z.string(),
|
|
474
|
+
data: z.object({
|
|
475
|
+
type: z.literal("text"),
|
|
476
|
+
text: z.string()
|
|
477
|
+
})
|
|
478
|
+
}),
|
|
479
|
+
web_fetch: z.object({
|
|
480
|
+
type: z.literal("web_fetch_tool_result"),
|
|
481
|
+
message: z.string(),
|
|
482
|
+
data: z.string(),
|
|
483
|
+
loading: z.string().optional(),
|
|
484
|
+
title: z.string().optional(),
|
|
485
|
+
favicon: z.string().optional()
|
|
486
|
+
}),
|
|
487
|
+
use_skill: z.object({
|
|
488
|
+
type: z.literal("use_skill_tool_result"),
|
|
489
|
+
commandMessage: z.string(),
|
|
490
|
+
message: z.string()
|
|
491
|
+
}),
|
|
492
|
+
web_search: z.object({
|
|
493
|
+
type: z.literal("web_search_tool_result"),
|
|
494
|
+
data: z.array(z.object({
|
|
495
|
+
passage: z.string(),
|
|
496
|
+
uri: z.string(),
|
|
497
|
+
site: z.string(),
|
|
498
|
+
title: z.string(),
|
|
499
|
+
snippets: z.array(z.string()).optional(),
|
|
500
|
+
content: z.string().optional()
|
|
501
|
+
})),
|
|
502
|
+
searchInput: z.string().optional()
|
|
503
|
+
}),
|
|
504
|
+
task: z.object({
|
|
505
|
+
type: z.literal("task_tool_result"),
|
|
506
|
+
toolInfo: z.array(z.object({
|
|
507
|
+
name: z.string(),
|
|
508
|
+
info: z.string(),
|
|
509
|
+
needApprove: z.boolean().optional(),
|
|
510
|
+
toolCallId: z.string().optional(),
|
|
511
|
+
executeStatus: z.enum([
|
|
512
|
+
"ing",
|
|
513
|
+
"completed",
|
|
514
|
+
"cancel",
|
|
515
|
+
"fail"
|
|
516
|
+
]).optional()
|
|
517
|
+
})).optional(),
|
|
518
|
+
startCallTool: z.boolean().optional(),
|
|
519
|
+
finalResult: z.string().optional(),
|
|
520
|
+
toolCallBrief: z.string().optional()
|
|
521
|
+
}),
|
|
522
|
+
codebase_search: z.object({
|
|
523
|
+
type: z.literal("codebase_search_result"),
|
|
524
|
+
query: z.string(),
|
|
525
|
+
path: z.string(),
|
|
526
|
+
content: z.string()
|
|
527
|
+
}),
|
|
528
|
+
lsp: z.object({
|
|
529
|
+
type: z.literal("lsp_tool_result"),
|
|
530
|
+
operation: z.string(),
|
|
531
|
+
result: z.string(),
|
|
532
|
+
resultCount: z.number().optional(),
|
|
533
|
+
fileCount: z.number().optional(),
|
|
534
|
+
character: z.number().optional()
|
|
535
|
+
}),
|
|
536
|
+
spec_create: z.object({
|
|
537
|
+
type: z.literal("plan_create_tool_result"),
|
|
538
|
+
message: z.string(),
|
|
539
|
+
data: z.string()
|
|
540
|
+
}),
|
|
541
|
+
spec_update: z.object({
|
|
542
|
+
type: z.literal("plan_update_tool_result"),
|
|
543
|
+
status: z.enum([
|
|
544
|
+
"prepare",
|
|
545
|
+
"ready",
|
|
546
|
+
"building",
|
|
547
|
+
"finished"
|
|
548
|
+
]),
|
|
549
|
+
data: z.string(),
|
|
550
|
+
reminder: z.string()
|
|
551
|
+
})
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
//#endregion
|
|
555
|
+
//#region ../agent-provider/src/common/_legacy/MockAgentProvider.ts
|
|
556
|
+
/**
|
|
557
|
+
* Mock 会话数据存储
|
|
558
|
+
* 每个会话都有对应的模拟历史消息
|
|
559
|
+
*/
|
|
560
|
+
const mockSessionHistories = /* @__PURE__ */ new Map();
|
|
561
|
+
mockSessionHistories.set("1", [
|
|
562
|
+
{
|
|
563
|
+
type: "user",
|
|
564
|
+
content: "帮我开发一个五子棋游戏,需要包含以下功能:\n1. 双人对战模式\n2. 悔棋功能\n3. 计时器",
|
|
565
|
+
timestamp: Date.now() - 18e5 - 6e4
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
type: "assistant",
|
|
569
|
+
content: "好的,我来帮你开发一个五子棋游戏。我会创建以下文件结构:\n\n- `index.html` - 主页面\n- `game.js` - 游戏逻辑\n- `style.css` - 样式文件\n\n让我开始创建这些文件...",
|
|
570
|
+
timestamp: Date.now() - 18e5 - 5e4
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
type: "assistant",
|
|
574
|
+
content: "我已经完成了所有文件的创建和修改。游戏支持双人对战、悔棋和计时功能。你可以直接在浏览器中打开 index.html 开始游戏。",
|
|
575
|
+
timestamp: Date.now() - 18e5
|
|
576
|
+
}
|
|
577
|
+
]);
|
|
578
|
+
mockSessionHistories.set("2", [
|
|
579
|
+
{
|
|
580
|
+
type: "user",
|
|
581
|
+
content: "登录页面的样式有问题,按钮颜色不对齐,帮我修复一下",
|
|
582
|
+
timestamp: Date.now() - 72e5 - 12e4
|
|
583
|
+
},
|
|
584
|
+
{
|
|
585
|
+
type: "assistant",
|
|
586
|
+
content: "我来检查登录页面的样式。让我先看看相关的 CSS 文件...",
|
|
587
|
+
timestamp: Date.now() - 72e5 - 1e5
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
type: "assistant",
|
|
591
|
+
content: "样式问题已修复,请查看效果。主要修改了按钮的 flex 布局和颜色变量。",
|
|
592
|
+
timestamp: Date.now() - 72e5
|
|
593
|
+
}
|
|
594
|
+
]);
|
|
595
|
+
mockSessionHistories.set("3", [
|
|
596
|
+
{
|
|
597
|
+
type: "user",
|
|
598
|
+
content: "API 接口响应太慢了,需要添加缓存和错误重试机制",
|
|
599
|
+
timestamp: Date.now() - 144e5 - 18e4
|
|
600
|
+
},
|
|
601
|
+
{
|
|
602
|
+
type: "assistant",
|
|
603
|
+
content: "好的,我来优化 API 接口。我会实现:\n1. Redis 缓存层\n2. 指数退避重试策略\n3. 请求去重",
|
|
604
|
+
timestamp: Date.now() - 144e5 - 15e4
|
|
605
|
+
},
|
|
606
|
+
{
|
|
607
|
+
type: "assistant",
|
|
608
|
+
content: "已添加缓存和错误重试机制。性能提升了约 60%。",
|
|
609
|
+
timestamp: Date.now() - 144e5
|
|
610
|
+
}
|
|
611
|
+
]);
|
|
612
|
+
mockSessionHistories.set("4", [
|
|
613
|
+
{
|
|
614
|
+
type: "user",
|
|
615
|
+
content: "帮我为核心模块添加单元测试,覆盖率要达到 80% 以上",
|
|
616
|
+
timestamp: Date.now() - 864e5 - 3e5
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
type: "assistant",
|
|
620
|
+
content: "好的,我会使用 Jest 来编写单元测试。让我先看看核心模块的代码结构...",
|
|
621
|
+
timestamp: Date.now() - 864e5 - 25e4
|
|
622
|
+
},
|
|
623
|
+
{
|
|
624
|
+
type: "assistant",
|
|
625
|
+
content: "测试覆盖率已达到 85%,超过了目标。主要测试了:\n- 用户认证逻辑\n- 数据验证\n- 错误处理",
|
|
626
|
+
timestamp: Date.now() - 864e5
|
|
627
|
+
}
|
|
628
|
+
]);
|
|
629
|
+
|
|
630
|
+
//#endregion
|
|
8
631
|
//#region ../agent-client-protocol/src/common/types.ts
|
|
9
632
|
/**
|
|
10
633
|
* Protocol Extension Types for Agent Client Protocol
|
|
@@ -81,7 +704,7 @@ function parseSSELine(line, currentEvent) {
|
|
|
81
704
|
function streamableHttp(options) {
|
|
82
705
|
const { endpoint, authToken, headers: customHeaders = {}, reconnect = {}, signal: externalSignal, fetch: customFetch = globalThis.fetch, onConnect, onDisconnect, onError, heartbeatTimeout = 6e4, postTimeout = 3e4, backpressure = {} } = options;
|
|
83
706
|
const { enabled: reconnectEnabled = true, initialDelay = 1e3, maxDelay = 3e4, maxRetries = Infinity, jitter: jitterEnabled = true } = reconnect;
|
|
84
|
-
const { highWaterMark = 100, lowWaterMark = 50 } = backpressure;
|
|
707
|
+
const { highWaterMark = 100, lowWaterMark = 50, pauseTimeout = 5e3 } = backpressure;
|
|
85
708
|
let connectionId;
|
|
86
709
|
let lastEventId;
|
|
87
710
|
let reconnectAttempts = 0;
|
|
@@ -110,6 +733,7 @@ function streamableHttp(options) {
|
|
|
110
733
|
let streamError = null;
|
|
111
734
|
let isPaused = false;
|
|
112
735
|
let resumeReading = null;
|
|
736
|
+
let backgroundSSEProcessors = /* @__PURE__ */ new Set();
|
|
113
737
|
let lastActivity = Date.now();
|
|
114
738
|
let heartbeatCheckTimer;
|
|
115
739
|
function enqueueMessage(message) {
|
|
@@ -132,7 +756,8 @@ function streamableHttp(options) {
|
|
|
132
756
|
const message = messageQueue.shift();
|
|
133
757
|
if (isPaused && messageQueue.length <= lowWaterMark) {
|
|
134
758
|
isPaused = false;
|
|
135
|
-
resumeReading
|
|
759
|
+
const resume = resumeReading;
|
|
760
|
+
if (resume) queueMicrotask(() => resume());
|
|
136
761
|
}
|
|
137
762
|
return Promise.resolve(message);
|
|
138
763
|
}
|
|
@@ -186,6 +811,7 @@ function streamableHttp(options) {
|
|
|
186
811
|
resumeReading();
|
|
187
812
|
resumeReading = null;
|
|
188
813
|
}
|
|
814
|
+
backgroundSSEProcessors.clear();
|
|
189
815
|
while (messageResolvers.length > 0) messageResolvers.shift()(null);
|
|
190
816
|
}
|
|
191
817
|
async function sendDelete() {
|
|
@@ -218,7 +844,21 @@ function streamableHttp(options) {
|
|
|
218
844
|
while (true) {
|
|
219
845
|
if (isPaused) {
|
|
220
846
|
await new Promise((resolve) => {
|
|
221
|
-
|
|
847
|
+
let resolved = false;
|
|
848
|
+
const timeoutId = setTimeout(() => {
|
|
849
|
+
if (!resolved) {
|
|
850
|
+
resolved = true;
|
|
851
|
+
console.warn("[StreamableHTTP] Backpressure pause timeout, forcing resume");
|
|
852
|
+
resolve();
|
|
853
|
+
}
|
|
854
|
+
}, pauseTimeout);
|
|
855
|
+
resumeReading = () => {
|
|
856
|
+
if (!resolved) {
|
|
857
|
+
resolved = true;
|
|
858
|
+
clearTimeout(timeoutId);
|
|
859
|
+
resolve();
|
|
860
|
+
}
|
|
861
|
+
};
|
|
222
862
|
});
|
|
223
863
|
resumeReading = null;
|
|
224
864
|
}
|
|
@@ -251,6 +891,19 @@ function streamableHttp(options) {
|
|
|
251
891
|
reader.releaseLock();
|
|
252
892
|
}
|
|
253
893
|
}
|
|
894
|
+
/**
|
|
895
|
+
* Process SSE stream in background without blocking the caller.
|
|
896
|
+
* This prevents deadlock when POST responses return SSE streams.
|
|
897
|
+
*/
|
|
898
|
+
function processSSEStreamBackground(reader) {
|
|
899
|
+
const promise = processSSEStream(reader).catch((error) => {
|
|
900
|
+
console.error("[StreamableHTTP] Background SSE processing error:", error);
|
|
901
|
+
onError?.(error instanceof Error ? error : new Error(String(error)));
|
|
902
|
+
}).finally(() => {
|
|
903
|
+
backgroundSSEProcessors.delete(promise);
|
|
904
|
+
});
|
|
905
|
+
backgroundSSEProcessors.add(promise);
|
|
906
|
+
}
|
|
254
907
|
async function startSSEConnection() {
|
|
255
908
|
let currentReader = null;
|
|
256
909
|
const triggerReconnect = () => {
|
|
@@ -286,14 +939,14 @@ function streamableHttp(options) {
|
|
|
286
939
|
stopHeartbeatCheck();
|
|
287
940
|
const endedConnectionId = connectionId;
|
|
288
941
|
connectionId = void 0;
|
|
289
|
-
if (
|
|
290
|
-
|
|
291
|
-
break;
|
|
292
|
-
}
|
|
942
|
+
if (endedConnectionId) onDisconnect?.(endedConnectionId);
|
|
943
|
+
if (!reconnectEnabled || closed) break;
|
|
293
944
|
connectionReady = new Promise((resolve, reject) => {
|
|
294
945
|
resolveConnection = resolve;
|
|
295
946
|
rejectConnection = reject;
|
|
296
947
|
});
|
|
948
|
+
const reconnectDelay = calculateDelay(1);
|
|
949
|
+
await new Promise((resolve) => setTimeout(resolve, reconnectDelay));
|
|
297
950
|
} catch (error) {
|
|
298
951
|
stopHeartbeatCheck();
|
|
299
952
|
currentReader = null;
|
|
@@ -310,14 +963,21 @@ function streamableHttp(options) {
|
|
|
310
963
|
}
|
|
311
964
|
async function sendMessage(message) {
|
|
312
965
|
if (closed) throw new Error("Connection is closed");
|
|
313
|
-
const
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
966
|
+
const maxWaitAttempts = 5;
|
|
967
|
+
let currentConnectionId;
|
|
968
|
+
for (let attempt = 0; attempt < maxWaitAttempts; attempt++) {
|
|
969
|
+
const versionBeforeWait = connectionVersion;
|
|
970
|
+
await connectionReady;
|
|
971
|
+
if (versionBeforeWait !== connectionVersion && versionBeforeWait > 0) await connectionReady;
|
|
972
|
+
currentConnectionId = connectionId;
|
|
973
|
+
if (currentConnectionId) break;
|
|
974
|
+
if (attempt < maxWaitAttempts - 1) await new Promise((resolve) => setTimeout(resolve, 100));
|
|
975
|
+
}
|
|
976
|
+
if (!currentConnectionId) throw new Error("No connection ID available after multiple attempts");
|
|
317
977
|
const headers = buildHeaders();
|
|
318
978
|
headers["Content-Type"] = "application/json";
|
|
319
979
|
headers["Accept"] = "application/json, text/event-stream";
|
|
320
|
-
headers["Acp-Connection-Id"] =
|
|
980
|
+
headers["Acp-Connection-Id"] = currentConnectionId;
|
|
321
981
|
const postController = new AbortController();
|
|
322
982
|
let timeoutId;
|
|
323
983
|
const postSignal = postTimeout > 0 ? postController.signal : combinedSignal;
|
|
@@ -340,7 +1000,7 @@ function streamableHttp(options) {
|
|
|
340
1000
|
const contentType = response.headers.get("Content-Type") || "";
|
|
341
1001
|
if (contentType.includes("text/event-stream")) {
|
|
342
1002
|
const reader = response.body?.getReader();
|
|
343
|
-
if (reader)
|
|
1003
|
+
if (reader) processSSEStreamBackground(reader);
|
|
344
1004
|
} else if (contentType.includes("application/json")) {
|
|
345
1005
|
const data = await response.json();
|
|
346
1006
|
if (data && typeof data === "object" && "jsonrpc" in data) enqueueMessage(data);
|
|
@@ -3848,9 +4508,11 @@ const SELECTED_ACCOUNT_KEY = "CODEBUDDY_IDE_SELECTED_ACCOUNT_ID";
|
|
|
3848
4508
|
* Backend Provider 实现类
|
|
3849
4509
|
*
|
|
3850
4510
|
* 职责:
|
|
3851
|
-
* - 与后端 API 通信(getAgents, getModels, getAccount 等)
|
|
3852
4511
|
* - 触发登录/登出流程
|
|
3853
4512
|
* - 获取 account 后自动同步到 accountService
|
|
4513
|
+
*
|
|
4514
|
+
* 注意:getAgents 和 getModels 方法已废弃并移除,
|
|
4515
|
+
* 请使用 IAgentAdapter 中的对应方法
|
|
3854
4516
|
*/
|
|
3855
4517
|
var BackendProvider = class {
|
|
3856
4518
|
constructor(config) {
|
|
@@ -3858,98 +4520,6 @@ var BackendProvider = class {
|
|
|
3858
4520
|
this.authToken = config.authToken;
|
|
3859
4521
|
}
|
|
3860
4522
|
/**
|
|
3861
|
-
* 获取 Agent 列表
|
|
3862
|
-
* API 端点: GET /v2/cloudagent/agentmgmt/agents
|
|
3863
|
-
*/
|
|
3864
|
-
async getAgents(request = {}) {
|
|
3865
|
-
const { MockAgentProvider } = await import("./MockAgentProvider-tNdtAJCv.mjs");
|
|
3866
|
-
const sessions = new MockAgentProvider().getAllSessions();
|
|
3867
|
-
const mockTitles = {
|
|
3868
|
-
"1": "开发五子棋游戏",
|
|
3869
|
-
"2": "修复登录页面样式",
|
|
3870
|
-
"3": "API 接口优化"
|
|
3871
|
-
};
|
|
3872
|
-
const agents = sessions.map((session, index) => ({
|
|
3873
|
-
id: session.sessionId,
|
|
3874
|
-
name: mockTitles[session.sessionId] || `Agent ${session.sessionId}`,
|
|
3875
|
-
status: "RUNNING",
|
|
3876
|
-
visibility: "PRIVATE",
|
|
3877
|
-
createdAt: new Date(session.createdAt).toISOString(),
|
|
3878
|
-
summary: `Session created at ${new Date(session.createdAt).toLocaleString()}`,
|
|
3879
|
-
source: {
|
|
3880
|
-
provider: "github",
|
|
3881
|
-
ref: "refs/heads/main",
|
|
3882
|
-
repository: session.cwd
|
|
3883
|
-
},
|
|
3884
|
-
target: {
|
|
3885
|
-
autoCreatePr: false,
|
|
3886
|
-
branchName: "feature/mock",
|
|
3887
|
-
prUrl: void 0,
|
|
3888
|
-
url: void 0
|
|
3889
|
-
}
|
|
3890
|
-
}));
|
|
3891
|
-
return {
|
|
3892
|
-
agents,
|
|
3893
|
-
pagination: {
|
|
3894
|
-
hasNext: false,
|
|
3895
|
-
hasPrev: false,
|
|
3896
|
-
page: 1,
|
|
3897
|
-
size: agents.length,
|
|
3898
|
-
total: agents.length,
|
|
3899
|
-
totalPages: 1
|
|
3900
|
-
}
|
|
3901
|
-
};
|
|
3902
|
-
}
|
|
3903
|
-
/**
|
|
3904
|
-
* 获取可用模型列表
|
|
3905
|
-
* API 端点: GET /v2/cloudagent/models (假设)
|
|
3906
|
-
*
|
|
3907
|
-
* 当前实现: 返回 Mock 数据
|
|
3908
|
-
*/
|
|
3909
|
-
async getModels(request) {
|
|
3910
|
-
const mockModels = [{
|
|
3911
|
-
id: "glm-4.7",
|
|
3912
|
-
name: "GLM-4.7",
|
|
3913
|
-
vendor: "f",
|
|
3914
|
-
maxOutputTokens: 48e3,
|
|
3915
|
-
maxInputTokens: 2e5,
|
|
3916
|
-
supportsToolCall: true,
|
|
3917
|
-
supportsImages: false,
|
|
3918
|
-
disabledMultimodal: true,
|
|
3919
|
-
maxAllowedSize: 2e5,
|
|
3920
|
-
supportsReasoning: true,
|
|
3921
|
-
onlyReasoning: true,
|
|
3922
|
-
temperature: 1,
|
|
3923
|
-
reasoning: {
|
|
3924
|
-
effort: "medium",
|
|
3925
|
-
summary: "auto"
|
|
3926
|
-
},
|
|
3927
|
-
descriptionEn: "GLM-4.7 model, Well-rounded model for everyday use",
|
|
3928
|
-
descriptionZh: "GLM-4.7 大模型,能力均衡,适合日常使用"
|
|
3929
|
-
}, {
|
|
3930
|
-
id: "glm-4.7-flash",
|
|
3931
|
-
name: "GLM-4.7 Flash",
|
|
3932
|
-
vendor: "f",
|
|
3933
|
-
maxOutputTokens: 4e4,
|
|
3934
|
-
maxInputTokens: 128e3,
|
|
3935
|
-
supportsToolCall: true,
|
|
3936
|
-
supportsImages: false,
|
|
3937
|
-
disabledMultimodal: false,
|
|
3938
|
-
maxAllowedSize: 128e3,
|
|
3939
|
-
supportsReasoning: false,
|
|
3940
|
-
onlyReasoning: false,
|
|
3941
|
-
temperature: .7,
|
|
3942
|
-
reasoning: {
|
|
3943
|
-
effort: "low",
|
|
3944
|
-
summary: "never"
|
|
3945
|
-
},
|
|
3946
|
-
descriptionEn: "GLM-4.7 Flash, Fast and efficient model",
|
|
3947
|
-
descriptionZh: "GLM-4.7 Flash,快速高效的模型"
|
|
3948
|
-
}];
|
|
3949
|
-
console.log("[BackendProvider] getModels called for repository:", request.repository);
|
|
3950
|
-
return { models: mockModels };
|
|
3951
|
-
}
|
|
3952
|
-
/**
|
|
3953
4523
|
* 获取当前账号信息
|
|
3954
4524
|
* API 端点: GET /console/accounts (返回账号列表)
|
|
3955
4525
|
*
|
|
@@ -4174,11 +4744,10 @@ function createBackendProvider(config) {
|
|
|
4174
4744
|
* Backend 请求类型常量
|
|
4175
4745
|
*/
|
|
4176
4746
|
const BACKEND_REQUEST_TYPES = {
|
|
4177
|
-
GET_AGENTS: "backend:get-agents-request",
|
|
4178
|
-
GET_MODELS: "backend:get-models",
|
|
4179
4747
|
LOGIN: "backend:login",
|
|
4180
4748
|
LOGOUT: "backend:logout",
|
|
4181
|
-
GET_ACCOUNT: "backend:get-account"
|
|
4749
|
+
GET_ACCOUNT: "backend:get-account",
|
|
4750
|
+
RELOAD_WINDOW: "backend:reload-window"
|
|
4182
4751
|
};
|
|
4183
4752
|
/**
|
|
4184
4753
|
* 生成唯一请求 ID
|
|
@@ -4189,7 +4758,7 @@ function generateRequestId() {
|
|
|
4189
4758
|
/**
|
|
4190
4759
|
* IPC Backend Provider 实现类
|
|
4191
4760
|
*
|
|
4192
|
-
* 通过 IWidgetChannel
|
|
4761
|
+
* 通过 IWidgetChannel 与后端通信
|
|
4193
4762
|
*/
|
|
4194
4763
|
var IPCBackendProvider = class {
|
|
4195
4764
|
constructor(config) {
|
|
@@ -4220,32 +4789,6 @@ var IPCBackendProvider = class {
|
|
|
4220
4789
|
return response?.data !== void 0 ? response.data : response;
|
|
4221
4790
|
}
|
|
4222
4791
|
/**
|
|
4223
|
-
* 获取 Agent 列表
|
|
4224
|
-
* 通过 IWidgetChannel 发送请求到后端
|
|
4225
|
-
*/
|
|
4226
|
-
async getAgents(request = {}) {
|
|
4227
|
-
this.log("Getting agents with request:", request);
|
|
4228
|
-
try {
|
|
4229
|
-
return await this.sendBackendRequest(BACKEND_REQUEST_TYPES.GET_AGENTS, request);
|
|
4230
|
-
} catch (error) {
|
|
4231
|
-
this.log("Get agents failed:", error);
|
|
4232
|
-
throw error;
|
|
4233
|
-
}
|
|
4234
|
-
}
|
|
4235
|
-
/**
|
|
4236
|
-
* 获取可用模型列表
|
|
4237
|
-
* 通过 IWidgetChannel 发送请求到后端
|
|
4238
|
-
*/
|
|
4239
|
-
async getModels(request) {
|
|
4240
|
-
this.log("Getting models with request:", request);
|
|
4241
|
-
try {
|
|
4242
|
-
return await this.sendBackendRequest(BACKEND_REQUEST_TYPES.GET_MODELS, request);
|
|
4243
|
-
} catch (error) {
|
|
4244
|
-
this.log("Get models failed:", error);
|
|
4245
|
-
throw error;
|
|
4246
|
-
}
|
|
4247
|
-
}
|
|
4248
|
-
/**
|
|
4249
4792
|
* 获取当前账号信息
|
|
4250
4793
|
* IDE 环境: 通过 IPC 获取账号信息,并同步到 accountService
|
|
4251
4794
|
*/
|
|
@@ -4289,6 +4832,20 @@ var IPCBackendProvider = class {
|
|
|
4289
4832
|
}
|
|
4290
4833
|
}
|
|
4291
4834
|
/**
|
|
4835
|
+
* 重新加载窗口
|
|
4836
|
+
* IDE 环境: 通过 IPC 通知 IDE 重新加载窗口(用于应用语言设置等)
|
|
4837
|
+
* @param params 可选参数,如 locale
|
|
4838
|
+
*/
|
|
4839
|
+
async reloadWindow(params) {
|
|
4840
|
+
this.log("Triggering reload window via IPC", params);
|
|
4841
|
+
try {
|
|
4842
|
+
await this.sendBackendRequest(BACKEND_REQUEST_TYPES.RELOAD_WINDOW, params);
|
|
4843
|
+
} catch (error) {
|
|
4844
|
+
this.log("Reload window request failed:", error);
|
|
4845
|
+
throw error;
|
|
4846
|
+
}
|
|
4847
|
+
}
|
|
4848
|
+
/**
|
|
4292
4849
|
* 调试日志
|
|
4293
4850
|
*/
|
|
4294
4851
|
log(...args) {
|