dsh-multigameassistant 2.0.5 → 2.1.1
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/cordis.patch.yml +178 -4
- package/lib/analyzer.js +6 -4
- package/lib/browser.js +279 -0
- package/lib/{chunk-KHO3SRUJ.js → chunk-5PDYWE24.js} +4 -2
- package/lib/{chunk-YG4B5G7F.js → chunk-B4UT4NYH.js} +1 -0
- package/lib/{chunk-IOBYH4RN.js → chunk-FBDVN6Q2.js} +76 -1
- package/lib/{chunk-TD4YFQWE.js → chunk-MQG5FLOG.js} +629 -167
- package/lib/chunk-NM6H6WCQ.js +3753 -0
- package/lib/chunk-RESS7WVY.js +157 -0
- package/lib/{chunk-BTT2GBTQ.js → chunk-SHTX4AGU.js} +1 -3670
- package/lib/{chunk-4Q4EH73S.js → chunk-UQLHGLMP.js} +13 -9
- package/lib/{chunk-PAJOD6LV.js → chunk-VOTN4IHB.js} +384 -54
- package/lib/emulator.js +6 -4
- package/lib/feishu.js +8 -6
- package/lib/game-intel.js +90 -9
- package/lib/gateway.js +11 -6
- package/lib/guard.js +5 -3
- package/lib/intervene.js +62 -18
- package/lib/low-context.js +13 -2
- package/lib/monitor.js +90 -10
- package/lib/notify.js +6 -5
- package/lib/orchestrator.js +14 -10
- package/lib/qqbot.js +8 -6
- package/lib/runner.js +18 -5
- package/lib/scheduler.js +4 -2
- package/lib/script-registry.js +345 -216
- package/package.json +5 -4
- package/skills/pipeline-planning.md +1 -1
- package/skills/web-reading.md +2 -0
- package/web/assets/index-CL3SeTW9.css +1 -0
- package/web/assets/index-GYwpGP3f.js +244 -0
- package/web/assets/index-GYwpGP3f.js.map +1 -0
- package/web/index.html +2 -2
- package/lib/chunk-CCAB6XXZ.js +0 -34
- package/web/assets/index-BuStplKb.js +0 -242
- package/web/assets/index-BuStplKb.js.map +0 -1
- package/web/assets/index-CSB3B28L.css +0 -1
package/cordis.patch.yml
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# dsh-multigameassistant 2.
|
|
1
|
+
# dsh-multigameassistant 2.1.1
|
|
2
2
|
# dsh-multigameassistant: the app's plugins (packages/bundle/cordis.patch.yml, each @adg/<plugin> as dsh-multigameassistant/<plugin>)
|
|
3
3
|
# sharing the dsh with the person's other chats, and the app's agent preset (dsh's standard one with the app's
|
|
4
4
|
# tools and prompts, and compaction as 设置 → 对话压缩 says). No row of dsh is restated.
|
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
name: 'dsh-multigameassistant/script-registry'
|
|
26
26
|
config:
|
|
27
27
|
toolsDir: !!js "process.env.ADG_TOOLS_DIR || dshHomePath('adg/tools')"
|
|
28
|
+
# Scripts installed before ADG_TOOLS_DIR was set stay where they are until their next update.
|
|
29
|
+
formerToolsDirs: !!js "process.env.ADG_TOOLS_DIR ? [dshHomePath('adg/tools')] : []"
|
|
28
30
|
dataDir: !!js "process.env.ADG_DATA_DIR || dshHomePath('adg/data')"
|
|
29
31
|
defaults:
|
|
30
32
|
downloadMirror: !!js "process.env.ADG_GITHUB_MIRROR || ''"
|
|
@@ -68,6 +70,18 @@
|
|
|
68
70
|
config:
|
|
69
71
|
dataDir: !!js "process.env.ADG_DATA_DIR || dshHomePath('adg/data')"
|
|
70
72
|
|
|
73
|
+
# The built-in browser's `browser_*` tools: web pages the agent operates and
|
|
74
|
+
# the user watches in the browser panel. The browser itself is the desktop
|
|
75
|
+
# app's (apps/desktop/browser.mjs), which hands dsh its bridge:
|
|
76
|
+
# ADG_BROWSER_URL the bridge's loopback address
|
|
77
|
+
# ADG_BROWSER_TOKEN its token
|
|
78
|
+
# Neither set (dsh started another way, or dsh's own app): no browser tools.
|
|
79
|
+
- id: adg-browser
|
|
80
|
+
name: 'dsh-multigameassistant/browser'
|
|
81
|
+
config:
|
|
82
|
+
endpoint: !!js "process.env.ADG_BROWSER_URL || undefined"
|
|
83
|
+
token: !!js "process.env.ADG_BROWSER_TOKEN || undefined"
|
|
84
|
+
|
|
71
85
|
# M3: the chat layer — notices with buttons, replies, conversations with
|
|
72
86
|
# the agent, approval cards; the `notify` capability.
|
|
73
87
|
- id: adg-notify
|
|
@@ -154,6 +168,159 @@
|
|
|
154
168
|
disabled: !!js process.platform !== 'win32'
|
|
155
169
|
- id: tool-fs
|
|
156
170
|
name: '@deepseek-ai/dsh-tool-fs'
|
|
171
|
+
config:
|
|
172
|
+
# Set false to drop the apply_patch tool beside edit.
|
|
173
|
+
applyPatch: false
|
|
174
|
+
- id: tool-fs-search
|
|
175
|
+
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
176
|
+
config:
|
|
177
|
+
sampleOverCapGlobResults: false
|
|
178
|
+
- id: tool-jobs
|
|
179
|
+
name: '@deepseek-ai/dsh-tool-jobs'
|
|
180
|
+
- id: tool-schedule
|
|
181
|
+
name: '@deepseek-ai/dsh-tool-schedule'
|
|
182
|
+
- id: skill-filesystem
|
|
183
|
+
name: '@deepseek-ai/dsh-skill-filesystem'
|
|
184
|
+
config:
|
|
185
|
+
customSkillDirs:
|
|
186
|
+
- !!js process.getBuiltinModule('node:path').join(process.getBuiltinModule('node:path').dirname(process.getBuiltinModule('node:module').createRequire(baseUrl).resolve('@deepseek-ai/dsh-agent-preset/package.json')), 'skills')
|
|
187
|
+
- id: tool-skill
|
|
188
|
+
name: '@deepseek-ai/dsh-tool-skill'
|
|
189
|
+
- id: command-goal
|
|
190
|
+
name: '@deepseek-ai/dsh-command-goal'
|
|
191
|
+
- id: tool-goal
|
|
192
|
+
name: '@deepseek-ai/dsh-tool-goal'
|
|
193
|
+
- id: planning
|
|
194
|
+
name: cordis:group
|
|
195
|
+
group: true
|
|
196
|
+
isolate:
|
|
197
|
+
planMode: true
|
|
198
|
+
config:
|
|
199
|
+
- id: plan-mode
|
|
200
|
+
name: '@deepseek-ai/dsh-plan-mode'
|
|
201
|
+
config:
|
|
202
|
+
section: |
|
|
203
|
+
You are in plan mode. Stay in plan mode until the user approves your plan through exit_plan_mode or switches the session mode. Imperative language to implement changes means plan the implementation, not execute it. A user's conversational agreement — including an answer confirming something you asked — approves nothing and does not end plan mode; fold the confirmed decision into the plan and submit it through exit_plan_mode.
|
|
204
|
+
|
|
205
|
+
Explore first. Use non-mutating reads, searches, static analysis, and checks to ground the plan in the actual repository. Do not edit or write files, change configuration, run formatters or code generation that rewrites tracked files, commit, or otherwise carry out the plan. Prefer existing functions and patterns over new machinery.
|
|
206
|
+
|
|
207
|
+
The tool catalog stays the same across modes for request-cache stability. These plan-mode rules override any later tool description or guidance that suggests using mutation tools; those tools remain listed to keep the tool catalog unchanged. Do not use todo_write to track this planning phase: it tracks implementation after an approved plan, while the plan itself belongs in exit_plan_mode.
|
|
208
|
+
|
|
209
|
+
Resolve discoverable facts by inspection. Use ask_user_question only for user-owned choices or material ambiguity that inspection cannot answer. Do not ask the user where code lives or how current behavior works when you can find out.
|
|
210
|
+
|
|
211
|
+
Make the plan decision-complete: state the goal and success criteria; group implementation changes by subsystem; identify public API, schema, and data-flow changes; cover edge cases, failure modes, tests, acceptance criteria, and explicit assumptions. Keep it concise enough to review but detailed enough that another engineer can implement it without making design decisions.
|
|
212
|
+
|
|
213
|
+
When ready, call exit_plan_mode with the complete plan markdown, starting with a # title. Make exit_plan_mode the only and final tool call in that assistant response: it presents the plan for approval, and implementation begins only in a later step after approval. Do not paste the final plan as a plain reply or ask "should I proceed?" through prose or ask_user_question. If review rejects it, incorporate the feedback and present again. If the review channel is unavailable or aborted, stay in plan mode and ask the user to switch modes manually; do not proceed with implementation.
|
|
214
|
+
- id: compaction
|
|
215
|
+
name: cordis:group
|
|
216
|
+
group: true
|
|
217
|
+
isolate:
|
|
218
|
+
compaction: true
|
|
219
|
+
toolResultPruner: true
|
|
220
|
+
config:
|
|
221
|
+
- id: compaction-basic
|
|
222
|
+
name: '@deepseek-ai/dsh-compaction-basic'
|
|
223
|
+
config:
|
|
224
|
+
# 设置 → 对话压缩 (compaction.json in the app's data); read when the agent service starts.
|
|
225
|
+
auto: !!js "(() => { try { return JSON.parse(process.getBuiltinModule('node:fs').readFileSync((process.env.ADG_DATA_DIR || dshHomePath('adg/data')) + '/compaction.json', 'utf8')) } catch { return {} } })().auto !== false"
|
|
226
|
+
thresholdRatio: !!js "(Math.min(100, Math.max(5, Number((() => { try { return JSON.parse(process.getBuiltinModule('node:fs').readFileSync((process.env.ADG_DATA_DIR || dshHomePath('adg/data')) + '/compaction.json', 'utf8')) } catch { return {} } })().threshold) || 80)) / 100)"
|
|
227
|
+
retainRatio: !!js "Math.min(0.16, (Math.min(100, Math.max(5, Number((() => { try { return JSON.parse(process.getBuiltinModule('node:fs').readFileSync((process.env.ADG_DATA_DIR || dshHomePath('adg/data')) + '/compaction.json', 'utf8')) } catch { return {} } })().threshold) || 80)) / 100) / 2)"
|
|
228
|
+
- id: adg-low-context
|
|
229
|
+
name: 'dsh-multigameassistant/low-context'
|
|
230
|
+
config:
|
|
231
|
+
file: !!js "(process.env.ADG_DATA_DIR || dshHomePath('adg/data')) + '/compaction.json'"
|
|
232
|
+
- id: command-compact
|
|
233
|
+
name: '@deepseek-ai/dsh-command-compact'
|
|
234
|
+
- id: tool-result-pruner
|
|
235
|
+
name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
|
|
236
|
+
config:
|
|
237
|
+
thresholdChars: 8192
|
|
238
|
+
headChars: 4096
|
|
239
|
+
tailChars: 1024
|
|
240
|
+
- id: delegation
|
|
241
|
+
name: cordis:group
|
|
242
|
+
group: true
|
|
243
|
+
isolate:
|
|
244
|
+
workflowEngine: true
|
|
245
|
+
config:
|
|
246
|
+
- id: tool-subagent-control
|
|
247
|
+
name: '@deepseek-ai/dsh-tool-subagent-control'
|
|
248
|
+
config:
|
|
249
|
+
interrupt: false
|
|
250
|
+
- id: tool-subagent
|
|
251
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
252
|
+
config:
|
|
253
|
+
# Sub-agents call their tools from a program (run_code); read when the agent service starts.
|
|
254
|
+
agentPreset: !!js "(() => { try { return JSON.parse(process.getBuiltinModule('node:fs').readFileSync((process.env.ADG_DATA_DIR || dshHomePath('adg/data')) + '/compaction.json', 'utf8')) } catch { return {} } })().ptcSubagents === false ? undefined : 'mga-ptc'"
|
|
255
|
+
provider: spawn
|
|
256
|
+
toolName: subagent
|
|
257
|
+
modelSelection: true
|
|
258
|
+
modelDiscovery: true
|
|
259
|
+
- id: tool-subagent-fork
|
|
260
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
261
|
+
config:
|
|
262
|
+
provider: fork
|
|
263
|
+
toolName: subagent_fork
|
|
264
|
+
- id: workflow-ptc
|
|
265
|
+
name: '@deepseek-ai/dsh-workflow-ptc'
|
|
266
|
+
config:
|
|
267
|
+
provider: spawn
|
|
268
|
+
- id: tool-workflow
|
|
269
|
+
name: '@deepseek-ai/dsh-tool-workflow'
|
|
270
|
+
- id: tool-ask-user
|
|
271
|
+
name: '@deepseek-ai/dsh-tool-ask-user'
|
|
272
|
+
- id: tool-todo
|
|
273
|
+
name: '@deepseek-ai/dsh-tool-todo'
|
|
274
|
+
config:
|
|
275
|
+
allowParallelInProgress: true
|
|
276
|
+
- id: tool-web
|
|
277
|
+
name: '@deepseek-ai/dsh-tool-web'
|
|
278
|
+
config:
|
|
279
|
+
fetch: true
|
|
280
|
+
searchTimeoutMs: 60000
|
|
281
|
+
- id: present
|
|
282
|
+
name: '@deepseek-ai/dsh-tool-present'
|
|
283
|
+
- id: tool-office
|
|
284
|
+
name: '@deepseek-ai/dsh-tool-office'
|
|
285
|
+
- id: tool-plugin-manager
|
|
286
|
+
name: '@deepseek-ai/dsh-plugin-manager/tools'
|
|
287
|
+
disabled: !!js "!ctx.get('profileContext')"
|
|
288
|
+
- id: tool-plugin-market
|
|
289
|
+
name: '@deepseek-ai/dsh-plugin-market/tools'
|
|
290
|
+
disabled: true
|
|
291
|
+
- id: adg-agent
|
|
292
|
+
name: 'dsh-multigameassistant/agent'
|
|
293
|
+
|
|
294
|
+
# What the app's sub-agents run: dsh's ptc preset with the app's tools (设置 → 对话压缩 can turn it off).
|
|
295
|
+
- id: preset-mga-ptc
|
|
296
|
+
name: '@deepseek-ai/dsh-agent-preset'
|
|
297
|
+
config:
|
|
298
|
+
id: mga-ptc
|
|
299
|
+
name: 多游戏助手 · 子 agent
|
|
300
|
+
description: 多游戏助手的子 agent 自动用的(用代码调用工具),不用自己选
|
|
301
|
+
order: 51
|
|
302
|
+
plugins:
|
|
303
|
+
- id: persona
|
|
304
|
+
name: '@deepseek-ai/dsh-persona'
|
|
305
|
+
config:
|
|
306
|
+
prefix: You are a coding agent powered by the {{model}} model.
|
|
307
|
+
- id: agent-instructions
|
|
308
|
+
name: '@deepseek-ai/dsh-agent-instructions'
|
|
309
|
+
config:
|
|
310
|
+
maxBytes: 65536
|
|
311
|
+
- id: time-context
|
|
312
|
+
name: '@deepseek-ai/dsh-time-context'
|
|
313
|
+
- id: tool-bash
|
|
314
|
+
name: '@deepseek-ai/dsh-tool-bash'
|
|
315
|
+
disabled: !!js process.platform === 'win32'
|
|
316
|
+
- id: tool-pwsh
|
|
317
|
+
name: '@deepseek-ai/dsh-tool-pwsh'
|
|
318
|
+
disabled: !!js process.platform !== 'win32'
|
|
319
|
+
- id: tool-fs
|
|
320
|
+
name: '@deepseek-ai/dsh-tool-fs'
|
|
321
|
+
config:
|
|
322
|
+
# Set true to add the apply_patch tool beside edit.
|
|
323
|
+
applyPatch: false
|
|
157
324
|
- id: tool-fs-search
|
|
158
325
|
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
159
326
|
config:
|
|
@@ -225,14 +392,15 @@
|
|
|
225
392
|
config:
|
|
226
393
|
- id: tool-subagent-control
|
|
227
394
|
name: '@deepseek-ai/dsh-tool-subagent-control'
|
|
228
|
-
|
|
229
|
-
|
|
395
|
+
config:
|
|
396
|
+
interrupt: false
|
|
230
397
|
- id: tool-subagent
|
|
231
398
|
name: '@deepseek-ai/dsh-tool-subagent'
|
|
232
399
|
config:
|
|
233
400
|
provider: spawn
|
|
234
401
|
toolName: subagent
|
|
235
|
-
|
|
402
|
+
modelSelection: true
|
|
403
|
+
modelDiscovery: true
|
|
236
404
|
- id: tool-subagent-fork
|
|
237
405
|
name: '@deepseek-ai/dsh-tool-subagent'
|
|
238
406
|
config:
|
|
@@ -240,10 +408,12 @@
|
|
|
240
408
|
toolName: subagent_fork
|
|
241
409
|
- id: workflow-ptc
|
|
242
410
|
name: '@deepseek-ai/dsh-workflow-ptc'
|
|
411
|
+
disabled: true
|
|
243
412
|
config:
|
|
244
413
|
provider: spawn
|
|
245
414
|
- id: tool-workflow
|
|
246
415
|
name: '@deepseek-ai/dsh-tool-workflow'
|
|
416
|
+
disabled: true
|
|
247
417
|
- id: tool-ask-user
|
|
248
418
|
name: '@deepseek-ai/dsh-tool-ask-user'
|
|
249
419
|
- id: tool-todo
|
|
@@ -255,8 +425,12 @@
|
|
|
255
425
|
config:
|
|
256
426
|
fetch: true
|
|
257
427
|
searchTimeoutMs: 60000
|
|
428
|
+
- id: tool-executor-ptc
|
|
429
|
+
name: '@deepseek-ai/dsh-tool-executor-ptc'
|
|
258
430
|
- id: present
|
|
259
431
|
name: '@deepseek-ai/dsh-tool-present'
|
|
432
|
+
- id: tool-office
|
|
433
|
+
name: '@deepseek-ai/dsh-tool-office'
|
|
260
434
|
- id: tool-plugin-manager
|
|
261
435
|
name: '@deepseek-ai/dsh-plugin-manager/tools'
|
|
262
436
|
disabled: true
|
package/lib/analyzer.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import { createRequire as __adgCreateRequire } from 'node:module'; import { dirname as __adgDirname } from 'node:path'; import { fileURLToPath as __adgFileURLToPath } from 'node:url'; const require = __adgCreateRequire(import.meta.url); const __filename = __adgFileURLToPath(import.meta.url); const __dirname = __adgDirname(__filename);
|
|
2
2
|
import {
|
|
3
3
|
probeProject
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-B4UT4NYH.js";
|
|
5
5
|
import {
|
|
6
6
|
MANIFEST_FILE,
|
|
7
7
|
SKILL_FILE,
|
|
8
8
|
guideIssues,
|
|
9
9
|
parseManifest,
|
|
10
10
|
require_dist
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-5PDYWE24.js";
|
|
12
12
|
import {
|
|
13
13
|
BUILTIN_PACK_VERSION,
|
|
14
14
|
PACKS_CAPABILITY,
|
|
15
|
-
ScriptId
|
|
15
|
+
ScriptId
|
|
16
|
+
} from "./chunk-NM6H6WCQ.js";
|
|
17
|
+
import {
|
|
16
18
|
external_exports
|
|
17
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-SHTX4AGU.js";
|
|
18
20
|
import {
|
|
19
21
|
__toESM
|
|
20
22
|
} from "./chunk-2UFLGPDY.js";
|
package/lib/browser.js
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { createRequire as __adgCreateRequire } from 'node:module'; import { dirname as __adgDirname } from 'node:path'; import { fileURLToPath as __adgFileURLToPath } from 'node:url'; const require = __adgCreateRequire(import.meta.url); const __filename = __adgFileURLToPath(import.meta.url); const __dirname = __adgDirname(__filename);
|
|
2
|
+
import {
|
|
3
|
+
external_exports
|
|
4
|
+
} from "./chunk-SHTX4AGU.js";
|
|
5
|
+
import "./chunk-2UFLGPDY.js";
|
|
6
|
+
|
|
7
|
+
// packages/browser/lib/client.js
|
|
8
|
+
var CALL_TIMEOUT_MS = 6e4;
|
|
9
|
+
function browserClient(endpoint, fetchImpl = fetch) {
|
|
10
|
+
return async (method, params, signal) => {
|
|
11
|
+
let response;
|
|
12
|
+
try {
|
|
13
|
+
response = await fetchImpl(`${endpoint.url}/call`, {
|
|
14
|
+
method: "POST",
|
|
15
|
+
headers: { authorization: `Bearer ${endpoint.token}`, "content-type": "application/json" },
|
|
16
|
+
body: JSON.stringify({ method, params }),
|
|
17
|
+
signal: signal === void 0 ? AbortSignal.timeout(CALL_TIMEOUT_MS) : AbortSignal.any([signal, AbortSignal.timeout(CALL_TIMEOUT_MS)])
|
|
18
|
+
});
|
|
19
|
+
} catch (error) {
|
|
20
|
+
if (signal?.aborted === true)
|
|
21
|
+
throw error;
|
|
22
|
+
throw new Error(`\u8FDE\u4E0D\u4E0A\u5185\u7F6E\u6D4F\u89C8\u5668\uFF08\u591A\u6E38\u620F\u52A9\u624B\u7684\u684C\u9762\u7A0B\u5E8F\uFF09\uFF1A${error instanceof Error ? error.message : String(error)}`);
|
|
23
|
+
}
|
|
24
|
+
const body = await response.json().catch(() => void 0);
|
|
25
|
+
if (body?.ok === true)
|
|
26
|
+
return body.result;
|
|
27
|
+
throw new Error(body?.error ?? `\u5185\u7F6E\u6D4F\u89C8\u5668\u6CA1\u6709\u56DE\u7B54\uFF08HTTP ${response.status}\uFF09`);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// packages/browser/lib/tools.js
|
|
32
|
+
var BROWSER_TOOLS = {
|
|
33
|
+
navigate: "browser_navigate",
|
|
34
|
+
snapshot: "browser_snapshot",
|
|
35
|
+
click: "browser_click",
|
|
36
|
+
type: "browser_type",
|
|
37
|
+
press: "browser_press",
|
|
38
|
+
scroll: "browser_scroll",
|
|
39
|
+
screenshot: "browser_screenshot",
|
|
40
|
+
text: "browser_text",
|
|
41
|
+
tabs: "browser_tabs"
|
|
42
|
+
};
|
|
43
|
+
function parse(schema, args) {
|
|
44
|
+
const parsed = schema.safeParse(args);
|
|
45
|
+
if (!parsed.success)
|
|
46
|
+
throw new Error(`\u53C2\u6570\u65E0\u6548\uFF1A${parsed.error.issues.map((i) => `${i.path.join(".") || "(root)"} ${i.message}`).join("; ")}`);
|
|
47
|
+
return parsed.data;
|
|
48
|
+
}
|
|
49
|
+
function renderPage(view) {
|
|
50
|
+
return `\u6807\u7B7E\u9875 ${view.tab}\uFF1A${view.title === "" ? "\uFF08\u65E0\u6807\u9898\uFF09" : view.title}
|
|
51
|
+
${view.url}${view.loading === true ? "\n\uFF08\u8FD8\u5728\u52A0\u8F7D\uFF09" : ""}
|
|
52
|
+
|
|
53
|
+
${view.snapshot}`;
|
|
54
|
+
}
|
|
55
|
+
var REF = { type: "string", description: "\u9875\u9762\u5185\u5BB9\u91CC\u7684 [ref=\u2026]\uFF08\u5982 e12\uFF09\u3002\u53EA\u5728\u6700\u8FD1\u4E00\u6B21\u8FD4\u56DE\u7684\u9875\u9762\u5185\u5BB9\u91CC\u6709\u6548\u3002" };
|
|
56
|
+
function browserTools(deps) {
|
|
57
|
+
const sessionOf = (exec) => exec.agent?.session.id;
|
|
58
|
+
const call = (exec, method, params) => {
|
|
59
|
+
const session = sessionOf(exec);
|
|
60
|
+
return deps.call(method, { ...params, ...session === void 0 ? {} : { session } }, exec.signal);
|
|
61
|
+
};
|
|
62
|
+
const given = (o) => Object.fromEntries(Object.entries(o).filter(([, v]) => v !== void 0 && v !== null));
|
|
63
|
+
const tool = (spec) => ({
|
|
64
|
+
name: spec.name,
|
|
65
|
+
description: spec.description,
|
|
66
|
+
parameters: { type: "object", properties: spec.properties, ...spec.required === void 0 ? {} : { required: spec.required }, additionalProperties: false },
|
|
67
|
+
output: { schema: {}, render: spec.render ?? ((_args, value) => [{ type: "text", text: renderPage(value) }]) },
|
|
68
|
+
timeoutMs: 9e4,
|
|
69
|
+
// One page, one cursor: the agent's actions on it go one after another.
|
|
70
|
+
isConcurrencySafe: () => false,
|
|
71
|
+
execute: async (args, exec) => JSON.parse(JSON.stringify(await spec.execute(args, exec) ?? null)),
|
|
72
|
+
presentCall: (args) => ({ card: "generic", title: spec.title(args ?? {}), kind: spec.readOnly === true ? "read" : "other" })
|
|
73
|
+
});
|
|
74
|
+
return [
|
|
75
|
+
tool({
|
|
76
|
+
name: BROWSER_TOOLS.navigate,
|
|
77
|
+
description: "\u5728\u5185\u7F6E\u6D4F\u89C8\u5668\u91CC\u6253\u5F00\u7F51\u9875\uFF08\u7528\u6237\u80FD\u5728\u591A\u6E38\u620F\u52A9\u624B\u7684\u6D4F\u89C8\u5668\u9762\u677F\u91CC\u770B\u5230\uFF0C\u4E5F\u80FD\u63A5\u624B\uFF09\uFF0C\u6216\u8005\u540E\u9000\u3001\u524D\u8FDB\u3001\u5237\u65B0\u3002\u9002\u5408 web_fetch \u53EA\u62FF\u5230\u6807\u9898\u6216\u7A7A\u58F3\u7684\u7F51\u9875\uFF08\u524D\u7AEF\u6E32\u67D3\u7684\u5B98\u7F51\u3001\u516C\u544A\u9875\u3001\u6D3B\u52A8\u9875\uFF09\uFF0C\u8981\u70B9\u51FB\u3001\u7FFB\u9875\u3001\u5C55\u5F00\u624D\u770B\u5F97\u5230\u7684\u5185\u5BB9\uFF0C\u6216\u8005\u7528\u6237\u8BA9\u4F60\u5728\u6D4F\u89C8\u5668\u91CC\u64CD\u4F5C\uFF1B\u666E\u901A\u7684\u9759\u6001\u9875\u9762\u548C JSON \u63A5\u53E3\u7528 web_fetch \u66F4\u7701\u3002\u8BFB\u6587\u5B57\u7528 browser_text\u3002\u6BCF\u4E2A\u5BF9\u8BDD\u6709\u81EA\u5DF1\u7684\u6807\u7B7E\u9875\uFF1B\u8FD4\u56DE\u9875\u9762\u5185\u5BB9\uFF1A\u89D2\u8272\u548C\u6587\u5B57\u6309\u5C42\u7EA7\u5217\u51FA\uFF0C\u80FD\u64CD\u4F5C\u7684\u5143\u7D20\u5E26 [ref=\u2026]\uFF0C\u63A5\u7740\u7528 browser_click / browser_type \u64CD\u4F5C\u5B83\u4EEC\u3002\u5185\u7F6E\u6D4F\u89C8\u5668\u662F\u9694\u79BB\u7684\uFF1A\u4E0D\u4FDD\u5B58\u767B\u5F55\u3001\u4E0D\u80FD\u4E0B\u8F7D\u6587\u4EF6\uFF0C\u53EA\u5F00 http / https \u7F51\u9875\u3002",
|
|
78
|
+
properties: {
|
|
79
|
+
url: { type: "string", description: "\u8981\u6253\u5F00\u7684\u7F51\u5740\uFF08\u4E0D\u5199 https:// \u4E5F\u884C\uFF09\u3002" },
|
|
80
|
+
action: { type: "string", enum: ["back", "forward", "reload"], description: "\u4E0D\u7ED9 url \u65F6\uFF1A\u540E\u9000\u3001\u524D\u8FDB\u6216\u5237\u65B0\u3002" },
|
|
81
|
+
new_tab: { type: "boolean", description: "\u5728\u65B0\u6807\u7B7E\u9875\u6253\u5F00\uFF08\u539F\u6765\u7684\u7559\u7740\uFF09\u3002" }
|
|
82
|
+
},
|
|
83
|
+
title: (a) => typeof a["url"] === "string" ? `\u6253\u5F00\u7F51\u9875\uFF1A${a["url"]}` : `\u6D4F\u89C8\u5668\uFF1A${String(a["action"] ?? "")}`,
|
|
84
|
+
execute: async (args, exec) => {
|
|
85
|
+
const a = parse(external_exports.object({ url: external_exports.string().trim().min(1).nullish(), action: external_exports.enum(["back", "forward", "reload"]).nullish(), new_tab: external_exports.boolean().nullish() }), args);
|
|
86
|
+
if ((a.url ?? void 0) === void 0 && (a.action ?? void 0) === void 0)
|
|
87
|
+
throw new Error("\u8981\u7ED9 url\uFF0C\u6216 action\uFF08back / forward / reload\uFF09");
|
|
88
|
+
return call(exec, "navigate", given({ url: a.url, action: a.url === void 0 || a.url === null ? a.action : void 0, newTab: a.new_tab === true ? true : void 0 }));
|
|
89
|
+
}
|
|
90
|
+
}),
|
|
91
|
+
tool({
|
|
92
|
+
name: BROWSER_TOOLS.snapshot,
|
|
93
|
+
description: "\u91CD\u65B0\u8BFB\u4E00\u904D\u5F53\u524D\u9875\u9762\u7684\u5185\u5BB9\uFF08\u5E26 [ref=\u2026]\uFF09\u3002\u6BCF\u6B21\u64CD\u4F5C\u90FD\u5DF2\u7ECF\u8FD4\u56DE\u4E86\u9875\u9762\u5185\u5BB9\uFF0C\u4E00\u822C\u4E0D\u7528\u5355\u72EC\u8C03\u7528\uFF1B\u9875\u9762\u81EA\u5DF1\u53D8\u4E86\uFF08\u7B49\u52A0\u8F7D\u3001\u5B9A\u65F6\u5237\u65B0\uFF09\u6216\u5185\u5BB9\u88AB\u622A\u65AD\u60F3\u770B\u66F4\u591A\u65F6\u518D\u7528\u3002",
|
|
94
|
+
properties: { max_chars: { type: "integer", description: "\u6700\u591A\u8FD4\u56DE\u591A\u5C11\u5B57\uFF0C\u9ED8\u8BA4 20000\uFF0C\u6700\u591A 60000\u3002" } },
|
|
95
|
+
readOnly: true,
|
|
96
|
+
title: () => "\u8BFB\u53D6\u9875\u9762",
|
|
97
|
+
execute: async (args, exec) => {
|
|
98
|
+
const a = parse(external_exports.object({ max_chars: external_exports.number().int().min(2e3).max(6e4).nullish() }), args);
|
|
99
|
+
return call(exec, "snapshot", given({ maxChars: a.max_chars }));
|
|
100
|
+
}
|
|
101
|
+
}),
|
|
102
|
+
tool({
|
|
103
|
+
name: BROWSER_TOOLS.click,
|
|
104
|
+
description: "\u70B9\u51FB\u9875\u9762\u4E0A\u7684\u5143\u7D20\uFF1A\u7ED9 ref\uFF1B\u753B\u9762\u4E0A\u624D\u770B\u5F97\u5230\u7684\u4F4D\u7F6E\uFF08\u753B\u5E03\u3001\u5730\u56FE\uFF09\u53EF\u4EE5\u7ED9 browser_screenshot \u622A\u56FE\u4E0A\u7684 x\u3001y\u3002\u8FD4\u56DE\u70B9\u51FB\u540E\u7684\u9875\u9762\u5185\u5BB9\u3002",
|
|
105
|
+
properties: {
|
|
106
|
+
ref: REF,
|
|
107
|
+
x: { type: "number", description: "\u6CA1\u6709 ref \u65F6\uFF1A\u622A\u56FE\u4E0A\u7684\u6A2A\u5750\u6807\u3002" },
|
|
108
|
+
y: { type: "number", description: "\u6CA1\u6709 ref \u65F6\uFF1A\u622A\u56FE\u4E0A\u7684\u7EB5\u5750\u6807\u3002" },
|
|
109
|
+
double: { type: "boolean", description: "\u53CC\u51FB\u3002" }
|
|
110
|
+
},
|
|
111
|
+
title: (a) => `\u70B9\u51FB\uFF1A${String(a["ref"] ?? `${String(a["x"])},${String(a["y"])}`)}`,
|
|
112
|
+
execute: async (args, exec) => {
|
|
113
|
+
const a = parse(external_exports.object({ ref: external_exports.string().nullish(), x: external_exports.number().nullish(), y: external_exports.number().nullish(), double: external_exports.boolean().nullish() }), args);
|
|
114
|
+
return call(exec, "click", given({ ref: a.ref, x: a.x, y: a.y, double: a.double }));
|
|
115
|
+
}
|
|
116
|
+
}),
|
|
117
|
+
tool({
|
|
118
|
+
name: BROWSER_TOOLS.type,
|
|
119
|
+
description: "\u5728\u8F93\u5165\u6846\u91CC\u8F93\u5165\u6587\u5B57\uFF08\u9ED8\u8BA4\u5148\u6E05\u7A7A\u539F\u6765\u7684\u5185\u5BB9\uFF09\uFF1Bsubmit=true \u8F93\u5165\u540E\u6309\u56DE\u8F66\uFF08\u63D0\u4EA4\u641C\u7D22\u3001\u8868\u5355\uFF09\u3002\u8FD4\u56DE\u4E4B\u540E\u7684\u9875\u9762\u5185\u5BB9\u3002\u4E0D\u8981\u8F93\u5165\u7528\u6237\u7684\u5BC6\u7801\u3001\u652F\u4ED8\u4FE1\u606F\u6216\u8BC1\u4EF6\u53F7\uFF1A\u9700\u8981\u767B\u5F55\u6216\u4ED8\u6B3E\u65F6\u8BF7\u7528\u6237\u5728\u6D4F\u89C8\u5668\u9762\u677F\u91CC\u81EA\u5DF1\u64CD\u4F5C\u3002",
|
|
120
|
+
properties: {
|
|
121
|
+
ref: REF,
|
|
122
|
+
text: { type: "string", description: "\u8981\u8F93\u5165\u7684\u6587\u5B57\u3002" },
|
|
123
|
+
clear: { type: "boolean", description: "\u5148\u6E05\u7A7A\u539F\u6765\u7684\u5185\u5BB9\uFF0C\u9ED8\u8BA4 true\u3002" },
|
|
124
|
+
submit: { type: "boolean", description: "\u8F93\u5165\u540E\u6309\u56DE\u8F66\u3002" }
|
|
125
|
+
},
|
|
126
|
+
required: ["ref", "text"],
|
|
127
|
+
title: (a) => `\u8F93\u5165\uFF1A${String(a["ref"] ?? "")}`,
|
|
128
|
+
execute: async (args, exec) => {
|
|
129
|
+
const a = parse(external_exports.object({ ref: external_exports.string().min(1), text: external_exports.string().max(1e4), clear: external_exports.boolean().nullish(), submit: external_exports.boolean().nullish() }), args);
|
|
130
|
+
return call(exec, "type", given({ ref: a.ref, text: a.text, clear: a.clear, submit: a.submit }));
|
|
131
|
+
}
|
|
132
|
+
}),
|
|
133
|
+
tool({
|
|
134
|
+
name: BROWSER_TOOLS.press,
|
|
135
|
+
description: "\u6309\u952E\uFF1AEnter\u3001Escape\u3001Tab\u3001ArrowDown\u3001PageDown \u7B49\uFF0C\u6216\u7EC4\u5408\u952E\u5982 Control+A\u3001Shift+Tab\u3002\u6309\u5728\u5F53\u524D\u83B7\u5F97\u7126\u70B9\u7684\u5143\u7D20\u4E0A\u3002\u8FD4\u56DE\u4E4B\u540E\u7684\u9875\u9762\u5185\u5BB9\u3002",
|
|
136
|
+
properties: { key: { type: "string", description: "\u6309\u952E\u540D\uFF0C\u6216\u7528 + \u8FDE\u8D77\u6765\u7684\u7EC4\u5408\u952E\u3002" } },
|
|
137
|
+
required: ["key"],
|
|
138
|
+
title: (a) => `\u6309\u952E\uFF1A${String(a["key"] ?? "")}`,
|
|
139
|
+
execute: async (args, exec) => {
|
|
140
|
+
const a = parse(external_exports.object({ key: external_exports.string().min(1).max(40) }), args);
|
|
141
|
+
return call(exec, "press", { key: a.key });
|
|
142
|
+
}
|
|
143
|
+
}),
|
|
144
|
+
tool({
|
|
145
|
+
name: BROWSER_TOOLS.scroll,
|
|
146
|
+
description: "\u6EDA\u52A8\u9875\u9762\uFF1Adirection \u548C amount\uFF08\u50CF\u7D20\uFF0C\u9ED8\u8BA4 600\uFF09\uFF1B\u7ED9 ref \u4E0D\u7ED9 direction \u5C31\u628A\u90A3\u4E2A\u5143\u7D20\u6EDA\u5230\u770B\u5F97\u89C1\u7684\u5730\u65B9\uFF1B\u4E24\u4E2A\u90FD\u7ED9\u5C31\u5728\u90A3\u4E2A\u5143\u7D20\uFF08\u4F8B\u5982\u4E00\u4E2A\u53EF\u4EE5\u6EDA\u52A8\u7684\u5217\u8868\uFF09\u91CC\u6EDA\u3002\u8FD4\u56DE\u4E4B\u540E\u7684\u9875\u9762\u5185\u5BB9\u3002",
|
|
147
|
+
properties: {
|
|
148
|
+
direction: { type: "string", enum: ["up", "down", "left", "right"] },
|
|
149
|
+
amount: { type: "integer", description: "\u6EDA\u591A\u5C11\u50CF\u7D20\uFF0C\u9ED8\u8BA4 600\u3002" },
|
|
150
|
+
ref: REF
|
|
151
|
+
},
|
|
152
|
+
title: (a) => `\u6EDA\u52A8\uFF1A${String(a["direction"] ?? a["ref"] ?? "down")}`,
|
|
153
|
+
execute: async (args, exec) => {
|
|
154
|
+
const a = parse(external_exports.object({ direction: external_exports.enum(["up", "down", "left", "right"]).nullish(), amount: external_exports.number().int().min(50).max(5e3).nullish(), ref: external_exports.string().nullish() }), args);
|
|
155
|
+
return call(exec, "scroll", given({ direction: a.direction, amount: a.amount, ref: a.ref }));
|
|
156
|
+
}
|
|
157
|
+
}),
|
|
158
|
+
tool({
|
|
159
|
+
name: BROWSER_TOOLS.screenshot,
|
|
160
|
+
description: "\u7ED9\u5F53\u524D\u6807\u7B7E\u9875\u622A\u56FE\uFF08\u6A21\u578B\u8981\u80FD\u770B\u56FE\uFF09\u3002\u9875\u9762\u5185\u5BB9\u662F\u6587\u5B57\u65F6\u4E0D\u7528\u622A\u56FE\uFF1B\u753B\u9762\u3001\u56FE\u8868\u3001\u753B\u5E03\u3001\u9A8C\u8BC1\u6548\u679C\u65F6\u518D\u7528\u3002\u622A\u56FE\u7684\u5750\u6807\u53EF\u4EE5\u7ED9 browser_click \u7528\u3002",
|
|
161
|
+
properties: {},
|
|
162
|
+
readOnly: true,
|
|
163
|
+
title: () => "\u6D4F\u89C8\u5668\u622A\u56FE",
|
|
164
|
+
execute: async (_args, exec) => {
|
|
165
|
+
await deps.checkVision(exec);
|
|
166
|
+
const shot = await call(exec, "screenshot", {});
|
|
167
|
+
const image = await deps.saveImage(Buffer.from(shot.png, "base64"));
|
|
168
|
+
return { tab: shot.tab, url: shot.url, title: shot.title, width: shot.width, height: shot.height, image };
|
|
169
|
+
},
|
|
170
|
+
render: (_args, value) => {
|
|
171
|
+
const v = value;
|
|
172
|
+
return [
|
|
173
|
+
{ type: "text", text: `\u6807\u7B7E\u9875 ${v.tab}\uFF1A${v.title}
|
|
174
|
+
${v.url}
|
|
175
|
+
\u622A\u56FE ${v.width}\xD7${v.height}\uFF08\u5DE6\u4E0A\u89D2\u662F 0,0\uFF0Cbrowser_click \u7684 x\u3001y \u6309\u8FD9\u5F20\u56FE\uFF09` },
|
|
176
|
+
{ type: "image", attachment: v.image }
|
|
177
|
+
];
|
|
178
|
+
}
|
|
179
|
+
}),
|
|
180
|
+
tool({
|
|
181
|
+
name: BROWSER_TOOLS.text,
|
|
182
|
+
description: "\u53D6\u5F53\u524D\u9875\u9762\u7684\u5168\u90E8\u53EF\u89C1\u6587\u5B57\uFF08\u4E0D\u5E26\u7ED3\u6784\u548C ref\uFF09\uFF0C\u9002\u5408\u8BFB\u957F\u6587\u7AE0\u3001\u516C\u544A\u3001\u8868\u683C\u5185\u5BB9\u3002",
|
|
183
|
+
properties: { max_chars: { type: "integer", description: "\u6700\u591A\u8FD4\u56DE\u591A\u5C11\u5B57\uFF0C\u9ED8\u8BA4 20000\uFF0C\u6700\u591A 100000\u3002" } },
|
|
184
|
+
readOnly: true,
|
|
185
|
+
title: () => "\u8BFB\u53D6\u9875\u9762\u6587\u5B57",
|
|
186
|
+
execute: async (args, exec) => {
|
|
187
|
+
const a = parse(external_exports.object({ max_chars: external_exports.number().int().min(1e3).max(1e5).nullish() }), args);
|
|
188
|
+
return call(exec, "text", given({ maxChars: a.max_chars }));
|
|
189
|
+
},
|
|
190
|
+
render: (_args, value) => {
|
|
191
|
+
const v = value;
|
|
192
|
+
return [{ type: "text", text: `\u6807\u7B7E\u9875 ${v.tab}\uFF1A${v.title}
|
|
193
|
+
${v.url}
|
|
194
|
+
|
|
195
|
+
${v.text}${v.truncated === void 0 ? "" : `
|
|
196
|
+
\u2026\uFF08\u8FD8\u6709 ${v.truncated} \u5B57\uFF0C\u52A0\u5927 max_chars \u770B\u66F4\u591A\uFF09`}` }];
|
|
197
|
+
}
|
|
198
|
+
}),
|
|
199
|
+
tool({
|
|
200
|
+
name: BROWSER_TOOLS.tabs,
|
|
201
|
+
description: "\u5185\u7F6E\u6D4F\u89C8\u5668\u7684\u6807\u7B7E\u9875\uFF1Alist \u5217\u51FA\u5168\u90E8\uFF08\u6807\u51FA\u4F60\u5728\u7528\u7684\u90A3\u4E2A\uFF09\uFF1Bselect \u6362\u5230\u67D0\u4E2A\u6807\u7B7E\u9875\uFF08\u4E4B\u540E\u7684\u64CD\u4F5C\u90FD\u5728\u5B83\u4E0A\u9762\uFF0C\u4F8B\u5982\u7528\u6237\u6253\u5F00\u7684\u9875\u9762\uFF09\uFF1Bclose \u5173\u6389\u4E00\u4E2A\u3002",
|
|
202
|
+
properties: {
|
|
203
|
+
action: { type: "string", enum: ["list", "select", "close"] },
|
|
204
|
+
tab: { type: "string", description: "select / close\uFF1A\u6807\u7B7E\u9875 id\uFF08list \u53EF\u67E5\uFF09\u3002" }
|
|
205
|
+
},
|
|
206
|
+
required: ["action"],
|
|
207
|
+
title: (a) => `\u6D4F\u89C8\u5668\u6807\u7B7E\u9875\uFF1A${String(a["action"] ?? "")}`,
|
|
208
|
+
execute: async (args, exec) => {
|
|
209
|
+
const a = parse(external_exports.object({ action: external_exports.enum(["list", "select", "close"]), tab: external_exports.string().nullish() }), args);
|
|
210
|
+
if (a.action !== "list" && (a.tab ?? void 0) === void 0)
|
|
211
|
+
throw new Error(`${a.action} \u8981\u7ED9 tab`);
|
|
212
|
+
return call(exec, "tabs", given({ action: a.action, tab: a.tab }));
|
|
213
|
+
},
|
|
214
|
+
render: (_args, value) => {
|
|
215
|
+
const v = value;
|
|
216
|
+
if ("snapshot" in v)
|
|
217
|
+
return [{ type: "text", text: renderPage(v) }];
|
|
218
|
+
return [{ type: "text", text: v.tabs.length === 0 ? "\u6CA1\u6709\u6253\u5F00\u7684\u6807\u7B7E\u9875" : v.tabs.map((t) => `${t.id}${t.yours === true ? "\uFF08\u4F60\u5728\u7528\uFF09" : ""}\uFF1A${t.title === "" ? "\uFF08\u65E0\u6807\u9898\uFF09" : t.title} ${t.url}`).join("\n") }];
|
|
219
|
+
}
|
|
220
|
+
})
|
|
221
|
+
];
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// packages/browser/lib/index.js
|
|
225
|
+
var name = "adg-browser";
|
|
226
|
+
var ConfigSchema = external_exports.object({
|
|
227
|
+
/** The bridge's address (`http://127.0.0.1:<port>`); none: no browser here. */
|
|
228
|
+
endpoint: external_exports.string().url().optional(),
|
|
229
|
+
token: external_exports.string().min(1).optional()
|
|
230
|
+
});
|
|
231
|
+
function apply(ctx, config = {}, call) {
|
|
232
|
+
const spec = ConfigSchema.parse(config);
|
|
233
|
+
if (call === void 0 && (spec.endpoint === void 0 || spec.token === void 0))
|
|
234
|
+
return;
|
|
235
|
+
const browser = call ?? browserClient({ url: spec.endpoint, token: spec.token });
|
|
236
|
+
const sees = async (provider, model, signal) => {
|
|
237
|
+
const llm = ctx.get("llm");
|
|
238
|
+
if (llm === void 0)
|
|
239
|
+
return true;
|
|
240
|
+
const info = await llm.resolveModelInfo(provider, model, signal);
|
|
241
|
+
return info.inputModalities?.includes("image") === true;
|
|
242
|
+
};
|
|
243
|
+
ctx.inject(["adgGateway"], (gateway) => gateway.adgGateway.agentPart("adg-browser tools", (agent) => {
|
|
244
|
+
const tools = browserTools({
|
|
245
|
+
call: browser,
|
|
246
|
+
saveImage: async (png) => {
|
|
247
|
+
const attachments = ctx.get("attachments");
|
|
248
|
+
if (attachments === void 0)
|
|
249
|
+
throw new Error("\u6CA1\u6709\u56FE\u7247\u5B58\u50A8\u670D\u52A1\uFF0C\u65E0\u6CD5\u628A\u622A\u56FE\u4EA4\u7ED9\u6A21\u578B");
|
|
250
|
+
return { ...await attachments.saveImage({ data: png, mediaType: "image/png", name: "browser.png" }) };
|
|
251
|
+
},
|
|
252
|
+
checkVision: async (exec) => {
|
|
253
|
+
const routed = exec.agent?.session.requestHeader()?.config;
|
|
254
|
+
const provider = routed?.provider ?? exec.agent?.options.provider;
|
|
255
|
+
const model = routed?.model ?? exec.agent?.options.model;
|
|
256
|
+
if (provider === void 0 || model === void 0)
|
|
257
|
+
return;
|
|
258
|
+
if (!await sees(provider, model, exec.signal))
|
|
259
|
+
throw new Error(`\u5F53\u524D\u6A21\u578B ${model} \u4E0D\u80FD\u770B\u56FE\u7247\uFF1A\u7528 browser_snapshot \u8BFB\u9875\u9762\u5185\u5BB9\uFF0C\u6216\u6362\u4E00\u4E2A\u80FD\u770B\u56FE\u7684\u6A21\u578B`);
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
const registered = tools.map((tool) => agent.tools.register({ ...tool, execute: async (args, exec) => {
|
|
263
|
+
await ctx.get("adgGateway")?.guardTool(exec);
|
|
264
|
+
return tool.execute(args, exec);
|
|
265
|
+
} }));
|
|
266
|
+
return () => {
|
|
267
|
+
for (const dispose of registered)
|
|
268
|
+
dispose();
|
|
269
|
+
};
|
|
270
|
+
}));
|
|
271
|
+
}
|
|
272
|
+
export {
|
|
273
|
+
BROWSER_TOOLS,
|
|
274
|
+
apply,
|
|
275
|
+
browserClient,
|
|
276
|
+
browserTools,
|
|
277
|
+
name,
|
|
278
|
+
renderPage
|
|
279
|
+
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { createRequire as __adgCreateRequire } from 'node:module'; import { dirname as __adgDirname } from 'node:path'; import { fileURLToPath as __adgFileURLToPath } from 'node:url'; const require = __adgCreateRequire(import.meta.url); const __filename = __adgFileURLToPath(import.meta.url); const __dirname = __adgDirname(__filename);
|
|
2
2
|
import {
|
|
3
3
|
ScriptFamily,
|
|
4
|
-
ScriptId
|
|
4
|
+
ScriptId
|
|
5
|
+
} from "./chunk-NM6H6WCQ.js";
|
|
6
|
+
import {
|
|
5
7
|
external_exports
|
|
6
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-SHTX4AGU.js";
|
|
7
9
|
import {
|
|
8
10
|
__commonJS,
|
|
9
11
|
__require,
|