@beeos-ai/device-agent 0.15.0 → 0.16.0
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/README.md +35 -0
- package/dist/adapters/agent-gateway-client.d.ts +6 -68
- package/dist/adapters/agent-gateway-client.js +7 -67
- package/dist/adapters/agent-gateway-client.js.map +1 -1
- package/dist/adapters/device-compat.d.ts +1 -2
- package/dist/adapters/device-compat.js +2 -52
- package/dist/adapters/device-compat.js.map +1 -1
- package/dist/agent-runtime/action-guard.js +92 -17
- package/dist/agent-runtime/action-guard.js.map +1 -1
- package/dist/agent-runtime/adapters/base.d.ts +13 -9
- package/dist/agent-runtime/adapters/base.js.map +1 -1
- package/dist/agent-runtime/adapters/general-flash.d.ts +3 -3
- package/dist/agent-runtime/adapters/general-flash.js +2 -2
- package/dist/agent-runtime/adapters/general-flash.js.map +1 -1
- package/dist/agent-runtime/adapters/native-tools.d.ts +56 -0
- package/dist/agent-runtime/adapters/native-tools.js +416 -0
- package/dist/agent-runtime/adapters/native-tools.js.map +1 -0
- package/dist/agent-runtime/adapters/openai.d.ts +1 -2
- package/dist/agent-runtime/adapters/openai.js +5 -5
- package/dist/agent-runtime/adapters/openai.js.map +1 -1
- package/dist/agent-runtime/adapters/pro.d.ts +7 -37
- package/dist/agent-runtime/adapters/pro.js +7 -249
- package/dist/agent-runtime/adapters/pro.js.map +1 -1
- package/dist/agent-runtime/advanced/app-card.js +9 -2
- package/dist/agent-runtime/advanced/app-card.js.map +1 -1
- package/dist/agent-runtime/advanced/subgoal-verifier.d.ts +1 -0
- package/dist/agent-runtime/advanced/subgoal-verifier.js +30 -36
- package/dist/agent-runtime/advanced/subgoal-verifier.js.map +1 -1
- package/dist/agent-runtime/advanced/task-state.js +4 -9
- package/dist/agent-runtime/advanced/task-state.js.map +1 -1
- package/dist/agent-runtime/agent-runner.d.ts +2 -11
- package/dist/agent-runtime/agent-runner.js +69 -34
- package/dist/agent-runtime/agent-runner.js.map +1 -1
- package/dist/agent-runtime/core.d.ts +24 -46
- package/dist/agent-runtime/core.js +161 -228
- package/dist/agent-runtime/core.js.map +1 -1
- package/dist/agent-runtime/execution-checks.d.ts +40 -0
- package/dist/agent-runtime/execution-checks.js +133 -0
- package/dist/agent-runtime/execution-checks.js.map +1 -0
- package/dist/agent-runtime/execution-mode.d.ts +1 -8
- package/dist/agent-runtime/execution-mode.js +10 -30
- package/dist/agent-runtime/execution-mode.js.map +1 -1
- package/dist/agent-runtime/feedback.d.ts +4 -28
- package/dist/agent-runtime/feedback.js +4 -26
- package/dist/agent-runtime/feedback.js.map +1 -1
- package/dist/agent-runtime/form-prerequisites.d.ts +3 -0
- package/dist/agent-runtime/form-prerequisites.js +52 -0
- package/dist/agent-runtime/form-prerequisites.js.map +1 -0
- package/dist/agent-runtime/index.d.ts +2 -8
- package/dist/agent-runtime/index.js +2 -8
- package/dist/agent-runtime/index.js.map +1 -1
- package/dist/agent-runtime/{modes/orchestrator → knowledge}/app-guide.d.ts +1 -1
- package/dist/agent-runtime/{modes/orchestrator → knowledge}/app-guide.js +1 -1
- package/dist/agent-runtime/knowledge/app-guide.js.map +1 -0
- package/dist/agent-runtime/models/base.d.ts +3 -1
- package/dist/agent-runtime/models/client.js +30 -9
- package/dist/agent-runtime/models/client.js.map +1 -1
- package/dist/agent-runtime/models/reasoning.d.ts +10 -0
- package/dist/agent-runtime/models/reasoning.js +29 -0
- package/dist/agent-runtime/models/reasoning.js.map +1 -0
- package/dist/agent-runtime/models/runtime-registry.d.ts +2 -1
- package/dist/agent-runtime/models/runtime-registry.js +4 -2
- package/dist/agent-runtime/models/runtime-registry.js.map +1 -1
- package/dist/agent-runtime/models/vlm/autoglm.js +6 -2
- package/dist/agent-runtime/models/vlm/autoglm.js.map +1 -1
- package/dist/agent-runtime/models/vlm/base.js +1 -12
- package/dist/agent-runtime/models/vlm/base.js.map +1 -1
- package/dist/agent-runtime/models/vlm/index.d.ts +0 -4
- package/dist/agent-runtime/models/vlm/index.js +0 -4
- package/dist/agent-runtime/models/vlm/index.js.map +1 -1
- package/dist/agent-runtime/modes/hybrid/index.d.ts +2 -12
- package/dist/agent-runtime/modes/hybrid/index.js +10 -27
- package/dist/agent-runtime/modes/hybrid/index.js.map +1 -1
- package/dist/agent-runtime/modes/hybrid/planner/base.d.ts +4 -44
- package/dist/agent-runtime/modes/hybrid/planner/base.js +3 -21
- package/dist/agent-runtime/modes/hybrid/planner/base.js.map +1 -1
- package/dist/agent-runtime/modes/hybrid/planner/llm-planner.d.ts +1 -1
- package/dist/agent-runtime/modes/hybrid/planner/llm-planner.js +9 -6
- package/dist/agent-runtime/modes/hybrid/planner/llm-planner.js.map +1 -1
- package/dist/agent-runtime/modes/hybrid/planner/prompts.d.ts +1 -17
- package/dist/agent-runtime/modes/hybrid/planner/prompts.js +65 -160
- package/dist/agent-runtime/modes/hybrid/planner/prompts.js.map +1 -1
- package/dist/agent-runtime/plan-executor.d.ts +13 -14
- package/dist/agent-runtime/plan-executor.js +236 -122
- package/dist/agent-runtime/plan-executor.js.map +1 -1
- package/dist/agent-runtime/pro-memory.js +1 -1
- package/dist/agent-runtime/pro-memory.js.map +1 -1
- package/dist/agent-runtime/pro-operator.js +8 -2
- package/dist/agent-runtime/pro-operator.js.map +1 -1
- package/dist/agent-runtime/pro-perception.d.ts +1 -0
- package/dist/agent-runtime/pro-perception.js +4 -2
- package/dist/agent-runtime/pro-perception.js.map +1 -1
- package/dist/agent-runtime/pro-target-check.d.ts +2 -2
- package/dist/agent-runtime/pro-target-check.js +102 -17
- package/dist/agent-runtime/pro-target-check.js.map +1 -1
- package/dist/agent-runtime/prompts/operator.d.ts +2 -0
- package/dist/agent-runtime/prompts/operator.js +69 -0
- package/dist/agent-runtime/prompts/operator.js.map +1 -0
- package/dist/agent-runtime/prompts/verification.d.ts +2 -0
- package/dist/agent-runtime/prompts/verification.js +52 -0
- package/dist/agent-runtime/prompts/verification.js.map +1 -0
- package/dist/agent-runtime/skills/replay.d.ts +4 -14
- package/dist/agent-runtime/skills/replay.js +46 -27
- package/dist/agent-runtime/skills/replay.js.map +1 -1
- package/dist/agent-runtime/tool-batch.d.ts +10 -0
- package/dist/agent-runtime/tool-batch.js +51 -0
- package/dist/agent-runtime/tool-batch.js.map +1 -0
- package/dist/agent-runtime/visual-state.d.ts +2 -0
- package/dist/agent-runtime/visual-state.js +24 -0
- package/dist/agent-runtime/visual-state.js.map +1 -0
- package/dist/agent-runtime/vlm.d.ts +1 -1
- package/dist/agent-runtime/vlm.js +1 -1
- package/dist/api.js +3 -1
- package/dist/api.js.map +1 -1
- package/dist/app/agent-host.js +6 -2
- package/dist/app/agent-host.js.map +1 -1
- package/dist/app/multi-device-host.js +4 -5
- package/dist/app/multi-device-host.js.map +1 -1
- package/dist/app/session-manager.d.ts +3 -45
- package/dist/app/session-manager.js +8 -9
- package/dist/app/session-manager.js.map +1 -1
- package/dist/bootstrap.js +25 -84
- package/dist/bootstrap.js.map +1 -1
- package/dist/config/loader.js +12 -1
- package/dist/config/loader.js.map +1 -1
- package/dist/config/schema.d.ts +7 -2
- package/dist/config/schema.js +8 -5
- package/dist/config/schema.js.map +1 -1
- package/dist/core/abortable-read.d.ts +1 -0
- package/dist/core/abortable-read.js +24 -0
- package/dist/core/abortable-read.js.map +1 -0
- package/dist/device/ui-xml.d.ts +4 -0
- package/dist/device/ui-xml.js +35 -13
- package/dist/device/ui-xml.js.map +1 -1
- package/dist/fleet/adapters/process/node-process-manager.d.ts +2 -1
- package/dist/fleet/adapters/process/node-process-manager.js +11 -19
- package/dist/fleet/adapters/process/node-process-manager.js.map +1 -1
- package/dist/inbound/acp/handlers/models.js +11 -8
- package/dist/inbound/acp/handlers/models.js.map +1 -1
- package/dist/inbound/acp/handlers/session.d.ts +1 -4
- package/dist/inbound/acp/handlers/session.js +3 -6
- package/dist/inbound/acp/handlers/session.js.map +1 -1
- package/dist/inbound/bma/agent.d.ts +47 -0
- package/dist/inbound/bma/agent.js +130 -0
- package/dist/inbound/bma/agent.js.map +1 -0
- package/dist/inbound/bma/command.d.ts +15 -0
- package/dist/inbound/bma/command.js +98 -0
- package/dist/inbound/bma/command.js.map +1 -0
- package/dist/inbound/bma/model-proxy.d.ts +22 -0
- package/dist/inbound/bma/model-proxy.js +130 -0
- package/dist/inbound/bma/model-proxy.js.map +1 -0
- package/dist/inbound/cli/main.js +12 -2
- package/dist/inbound/cli/main.js.map +1 -1
- package/dist/inbound/cli/run-artifacts.js +16 -7
- package/dist/inbound/cli/run-artifacts.js.map +1 -1
- package/dist/inbound/cli/run-command.d.ts +7 -0
- package/dist/inbound/cli/run-command.js +37 -29
- package/dist/inbound/cli/run-command.js.map +1 -1
- package/dist/index.d.ts +1 -10
- package/dist/index.js +1 -6
- package/dist/index.js.map +1 -1
- package/dist/mcp-client/autospawn.d.ts +7 -9
- package/dist/mcp-client/autospawn.js +16 -12
- package/dist/mcp-client/autospawn.js.map +1 -1
- package/dist/mcp-client/client.d.ts +6 -3
- package/dist/mcp-client/client.js +31 -13
- package/dist/mcp-client/client.js.map +1 -1
- package/dist/mcp-client/runtime.d.ts +5 -2
- package/dist/plugins/agent-sync/index.d.ts +32 -17
- package/dist/plugins/agent-sync/index.js +223 -232
- package/dist/plugins/agent-sync/index.js.map +1 -1
- package/dist/plugins/message-bus/inbound.d.ts +0 -32
- package/dist/plugins/message-bus/inbound.js +3 -0
- package/dist/plugins/message-bus/inbound.js.map +1 -1
- package/dist/plugins/message-bus/ms-channel-notifier.d.ts +1 -0
- package/dist/plugins/message-bus/ms-channel-notifier.js +16 -8
- package/dist/plugins/message-bus/ms-channel-notifier.js.map +1 -1
- package/dist/plugins/native-chat/deadline.d.ts +2 -0
- package/dist/plugins/native-chat/deadline.js +16 -0
- package/dist/plugins/native-chat/deadline.js.map +1 -0
- package/dist/plugins/native-chat/index.d.ts +46 -0
- package/dist/plugins/native-chat/index.js +331 -0
- package/dist/plugins/native-chat/index.js.map +1 -0
- package/dist/plugins/native-chat/reply-stream.d.ts +50 -0
- package/dist/plugins/native-chat/reply-stream.js +81 -0
- package/dist/plugins/native-chat/reply-stream.js.map +1 -0
- package/dist/plugins/native-chat/session-notifier.d.ts +16 -0
- package/dist/plugins/native-chat/session-notifier.js +130 -0
- package/dist/plugins/native-chat/session-notifier.js.map +1 -0
- package/dist/ports/agent-core.d.ts +2 -0
- package/dist/ports/agent-host.d.ts +2 -0
- package/dist/ports/agent-host.js +0 -21
- package/dist/ports/agent-host.js.map +1 -1
- package/dist/ports/device.d.ts +0 -1
- package/dist/ports/device.js +0 -1
- package/dist/ports/device.js.map +1 -1
- package/dist/runtime-authority/device-prompt.gen.d.ts +54 -0
- package/dist/runtime-authority/device-prompt.gen.js +19 -0
- package/dist/runtime-authority/device-prompt.gen.js.map +1 -0
- package/dist/types.d.ts +10 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -1
- package/package.json +5 -3
- package/dist/adapters/device-desktop.d.ts +0 -49
- package/dist/adapters/device-desktop.js +0 -132
- package/dist/adapters/device-desktop.js.map +0 -1
- package/dist/agent-runtime/factory.d.ts +0 -24
- package/dist/agent-runtime/factory.js +0 -25
- package/dist/agent-runtime/factory.js.map +0 -1
- package/dist/agent-runtime/models/vlm/guiowl.d.ts +0 -1
- package/dist/agent-runtime/models/vlm/guiowl.js +0 -249
- package/dist/agent-runtime/models/vlm/guiowl.js.map +0 -1
- package/dist/agent-runtime/models/vlm/maiui.d.ts +0 -1
- package/dist/agent-runtime/models/vlm/maiui.js +0 -142
- package/dist/agent-runtime/models/vlm/maiui.js.map +0 -1
- package/dist/agent-runtime/models/vlm/qwen38.d.ts +0 -1
- package/dist/agent-runtime/models/vlm/qwen38.js +0 -241
- package/dist/agent-runtime/models/vlm/qwen38.js.map +0 -1
- package/dist/agent-runtime/models/vlm/qwenvl.d.ts +0 -1
- package/dist/agent-runtime/models/vlm/qwenvl.js +0 -202
- package/dist/agent-runtime/models/vlm/qwenvl.js.map +0 -1
- package/dist/agent-runtime/modes/orchestrator/app-guide.js.map +0 -1
- package/dist/agent-runtime/modes/orchestrator/index.d.ts +0 -41
- package/dist/agent-runtime/modes/orchestrator/index.js +0 -218
- package/dist/agent-runtime/modes/orchestrator/index.js.map +0 -1
- package/dist/agent-runtime/modes/orchestrator/prompt.d.ts +0 -7
- package/dist/agent-runtime/modes/orchestrator/prompt.js +0 -53
- package/dist/agent-runtime/modes/orchestrator/prompt.js.map +0 -1
- package/dist/agent-runtime/reflection.d.ts +0 -100
- package/dist/agent-runtime/reflection.js +0 -241
- package/dist/agent-runtime/reflection.js.map +0 -1
- package/dist/agent-runtime/reflectors/action-reflector.d.ts +0 -97
- package/dist/agent-runtime/reflectors/action-reflector.js +0 -234
- package/dist/agent-runtime/reflectors/action-reflector.js.map +0 -1
- package/dist/agent-runtime/reflectors/policy.d.ts +0 -56
- package/dist/agent-runtime/reflectors/policy.js +0 -111
- package/dist/agent-runtime/reflectors/policy.js.map +0 -1
- package/dist/agent-runtime/reflectors/trajectory-reflector.d.ts +0 -93
- package/dist/agent-runtime/reflectors/trajectory-reflector.js +0 -224
- package/dist/agent-runtime/reflectors/trajectory-reflector.js.map +0 -1
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
import { invalidModelOutput, ModelAdapter, registerAdapter } from "./base.js";
|
|
2
|
-
import { parseToolCall } from "./shared/tool-call.js";
|
|
3
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
4
|
-
// GUI-Owl / GUI-Plus adapter
|
|
5
|
-
//
|
|
6
|
-
// Shared format used by:
|
|
7
|
-
// - mPLUG/GUI-Owl-7B/32B/1.5 (open-source, https://github.com/X-PLUG/MobileAgent)
|
|
8
|
-
// - Alibaba Tongyi gui-plus-* (DashScope, e.g. gui-plus-2026-02-26)
|
|
9
|
-
//
|
|
10
|
-
// Protocol (mirrors ClawGUI prompts_guiowl.py exactly):
|
|
11
|
-
// - system prompt contains a full <tools></tools> XML schema for `mobile_use`
|
|
12
|
-
// - model output: "Action: <short desc>\n<tool_call>{"name":"mobile_use","arguments":{...}}</tool_call>"
|
|
13
|
-
// - coordinates are 0–999 (resolution declared in the schema as 1000x1000)
|
|
14
|
-
// - only ONE user message is ever sent per turn; action history is injected as
|
|
15
|
-
// "Previous actions: Step1: ... Step2: ..." text, no assistant messages accumulated
|
|
16
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
17
|
-
const SCREEN_W = 1000;
|
|
18
|
-
const SCREEN_H = 1000;
|
|
19
|
-
function buildToolSchema(w, h) {
|
|
20
|
-
const schema = {
|
|
21
|
-
type: "function",
|
|
22
|
-
function: {
|
|
23
|
-
name_for_human: "mobile_use",
|
|
24
|
-
name: "mobile_use",
|
|
25
|
-
description: "Use a touchscreen to interact with a mobile device, and take screenshots.\n" +
|
|
26
|
-
"* This is an interface to a mobile device with touchscreen. " +
|
|
27
|
-
"You can perform actions like clicking, typing, swiping, etc.\n" +
|
|
28
|
-
"* Some applications may take time to start or process actions, " +
|
|
29
|
-
"so you may need to wait and take successive screenshots to see the results of your actions.\n" +
|
|
30
|
-
`* The screen's resolution is ${w}x${h}.\n` +
|
|
31
|
-
"* Make sure to click any buttons, links, icons, etc with the cursor tip " +
|
|
32
|
-
"in the center of the element. Don't click boxes on their edges unless asked.",
|
|
33
|
-
parameters: {
|
|
34
|
-
properties: {
|
|
35
|
-
action: {
|
|
36
|
-
description: "The action to perform. The available actions are:\n" +
|
|
37
|
-
"* `key`: Perform a key event on the mobile device.\n" +
|
|
38
|
-
" - This supports adb's `keyevent` syntax.\n" +
|
|
39
|
-
' - Examples: "volume_up", "volume_down", "power", "camera", "clear".\n' +
|
|
40
|
-
"* `click`: Click the point on the screen with coordinate (x, y).\n" +
|
|
41
|
-
"* `long_press`: Press the point on the screen with coordinate (x, y) for specified seconds.\n" +
|
|
42
|
-
"* `swipe`: Swipe from the starting point with coordinate (x, y) to the end point with coordinates2 (x2, y2).\n" +
|
|
43
|
-
"* `type`: Input the specified text into the activated input box.\n" +
|
|
44
|
-
"* `system_button`: Press the system button.\n" +
|
|
45
|
-
"* `open`: Open an app on the device.\n" +
|
|
46
|
-
"* `wait`: Wait specified seconds for the change to happen.\n" +
|
|
47
|
-
"* `answer`: Terminate the current task and output the answer.\n" +
|
|
48
|
-
"* `interact`: Resolve the blocking window by interacting with the user.\n" +
|
|
49
|
-
"* `terminate`: Terminate the current task and report its completion status.",
|
|
50
|
-
enum: [
|
|
51
|
-
"key", "click", "long_press", "swipe", "type",
|
|
52
|
-
"system_button", "open", "wait", "answer", "interact", "terminate",
|
|
53
|
-
],
|
|
54
|
-
type: "string",
|
|
55
|
-
},
|
|
56
|
-
coordinate: {
|
|
57
|
-
description: "(x, y): The x (pixels from the left edge) and y (pixels from the top edge). " +
|
|
58
|
-
"Required only by `action=click`, `action=long_press`, and `action=swipe`.",
|
|
59
|
-
type: "array",
|
|
60
|
-
},
|
|
61
|
-
coordinate2: {
|
|
62
|
-
description: "(x, y): swipe endpoint. Required only by `action=swipe`.",
|
|
63
|
-
type: "array",
|
|
64
|
-
},
|
|
65
|
-
text: {
|
|
66
|
-
description: "Required only by `action=key`, `action=type`, `action=open`, `action=answer`, and `action=interact`.",
|
|
67
|
-
type: "string",
|
|
68
|
-
},
|
|
69
|
-
time: {
|
|
70
|
-
description: "Seconds. Required only by `action=long_press` and `action=wait`.",
|
|
71
|
-
type: "number",
|
|
72
|
-
},
|
|
73
|
-
button: {
|
|
74
|
-
description: "Back = return to previous screen; Home = desktop; Menu = app background menu; Enter = press enter. " +
|
|
75
|
-
"Required only by `action=system_button`.",
|
|
76
|
-
enum: ["Back", "Home", "Menu", "Enter"],
|
|
77
|
-
type: "string",
|
|
78
|
-
},
|
|
79
|
-
status: {
|
|
80
|
-
description: "Task status. Required only by `action=terminate`.",
|
|
81
|
-
type: "string",
|
|
82
|
-
enum: ["success", "failure"],
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
required: ["action"],
|
|
86
|
-
type: "object",
|
|
87
|
-
},
|
|
88
|
-
args_format: "Format the arguments as a JSON object.",
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
return JSON.stringify(schema);
|
|
92
|
-
}
|
|
93
|
-
function systemPromptEn(w, h) {
|
|
94
|
-
return `# Tools
|
|
95
|
-
|
|
96
|
-
You may call one or more functions to assist with the user query.
|
|
97
|
-
|
|
98
|
-
You are provided with function signatures within <tools></tools> XML tags:
|
|
99
|
-
<tools>
|
|
100
|
-
${buildToolSchema(w, h)}
|
|
101
|
-
</tools>
|
|
102
|
-
|
|
103
|
-
For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:
|
|
104
|
-
<tool_call>
|
|
105
|
-
{"name": <function-name>, "arguments": <args-json-object>}
|
|
106
|
-
</tool_call>
|
|
107
|
-
|
|
108
|
-
# Response format
|
|
109
|
-
|
|
110
|
-
Response format for every step:
|
|
111
|
-
1) Action: a short imperative describing what to do in the UI.
|
|
112
|
-
2) A single <tool_call>...</tool_call> block containing only the JSON: {"name": <function-name>, "arguments": <args-json-object>}.
|
|
113
|
-
|
|
114
|
-
Rules:
|
|
115
|
-
- Output exactly in the order: Action, <tool_call>.
|
|
116
|
-
- Be brief: one line for Action.
|
|
117
|
-
- Do not output anything else outside those two parts.
|
|
118
|
-
- If finishing, use mobile_use with action=terminate in the tool call.`;
|
|
119
|
-
}
|
|
120
|
-
function systemPromptCn(w, h) {
|
|
121
|
-
return `# 工具
|
|
122
|
-
|
|
123
|
-
你可以调用一个或多个函数来完成用户的请求。
|
|
124
|
-
|
|
125
|
-
可用的函数定义在 <tools></tools> XML 标签内:
|
|
126
|
-
<tools>
|
|
127
|
-
${buildToolSchema(w, h)}
|
|
128
|
-
</tools>
|
|
129
|
-
|
|
130
|
-
每次调用函数时,请在 <tool_call></tool_call> XML 标签内返回一个包含函数名和参数的 JSON 对象:
|
|
131
|
-
<tool_call>
|
|
132
|
-
{"name": <函数名>, "arguments": <参数JSON对象>}
|
|
133
|
-
</tool_call>
|
|
134
|
-
|
|
135
|
-
# 回复格式
|
|
136
|
-
|
|
137
|
-
每一步的回复格式:
|
|
138
|
-
1) Action: 一句简短的祈使句,描述在UI上要执行的操作。
|
|
139
|
-
2) 一个 <tool_call>...</tool_call> 代码块,只包含 JSON:{"name": <函数名>, "arguments": <参数JSON对象>}。
|
|
140
|
-
|
|
141
|
-
规则:
|
|
142
|
-
- 严格按照 Action、<tool_call> 的顺序输出。
|
|
143
|
-
- 保持简洁:Action 只需一句话。
|
|
144
|
-
- 不要输出这两部分以外的任何内容。
|
|
145
|
-
- 如果任务完成,在 tool_call 中使用 mobile_use 的 action=terminate。`;
|
|
146
|
-
}
|
|
147
|
-
function buildUserQuery(task, history, lang, opts) {
|
|
148
|
-
const isEn = lang !== "cn";
|
|
149
|
-
const ctxHint = !opts.hasScreenshot && opts.hasXml
|
|
150
|
-
? (isEn
|
|
151
|
-
? "according to the UI hierarchy (XML) below, the instruction, and previous actions"
|
|
152
|
-
: "根据下方 UI 结构(XML)、指令和之前的操作")
|
|
153
|
-
: opts.hasScreenshot && opts.hasXml
|
|
154
|
-
? (isEn
|
|
155
|
-
? "according to the UI screenshot, the UI hierarchy (XML) below, the instruction, and previous actions"
|
|
156
|
-
: "根据 UI 截图、下方 UI 结构(XML)、指令和之前的操作")
|
|
157
|
-
: (isEn
|
|
158
|
-
? "according to the UI screenshot, the instruction, and previous actions"
|
|
159
|
-
: "根据UI截图、指令和之前的操作");
|
|
160
|
-
if (history.length === 0) {
|
|
161
|
-
return isEn
|
|
162
|
-
? `Please generate the next move ${ctxHint}.\n\nInstruction: ${task}`
|
|
163
|
-
: `请${ctxHint},生成下一步操作。\n\n指令: ${task}`;
|
|
164
|
-
}
|
|
165
|
-
const prev = history.map((d, i) => `Step${i + 1}: ${d} Tool response: None`).join("\n");
|
|
166
|
-
return isEn
|
|
167
|
-
? `Please generate the next move ${ctxHint}.\n\nInstruction: ${task}\n\nPrevious actions: \n${prev}`
|
|
168
|
-
: `请${ctxHint},生成下一步操作。\n\n指令: ${task}\n\n之前的操作: \n${prev}`;
|
|
169
|
-
}
|
|
170
|
-
class GUIOwlAdapter extends ModelAdapter {
|
|
171
|
-
name = "guiowl";
|
|
172
|
-
observationProfile = {
|
|
173
|
-
defaultMode: "vision",
|
|
174
|
-
supportedModes: ["vision", "xml", "hybrid"],
|
|
175
|
-
};
|
|
176
|
-
// Matches GUI-Owl-{7B,32B,1.5} open-source AND Alibaba DashScope gui-plus-*
|
|
177
|
-
patterns = [/guiowl/, /gui[-_]?owl/, /owl.*gui/, /gui[-_]?plus/];
|
|
178
|
-
actionHistory = [];
|
|
179
|
-
buildMessages(task, screenInfo, _context, isFirst, lang) {
|
|
180
|
-
if (isFirst)
|
|
181
|
-
this.actionHistory = [];
|
|
182
|
-
const sys = lang === "cn" ? systemPromptCn(SCREEN_W, SCREEN_H) : systemPromptEn(SCREEN_W, SCREEN_H);
|
|
183
|
-
const hasShot = !!screenInfo.imageRef;
|
|
184
|
-
const hasXml = !!screenInfo.uiXml;
|
|
185
|
-
let userText = buildUserQuery(task, this.actionHistory, lang, { hasScreenshot: hasShot, hasXml });
|
|
186
|
-
if (hasXml && screenInfo.uiXml) {
|
|
187
|
-
userText += lang !== "cn"
|
|
188
|
-
? `\n\n** UI Hierarchy (XML) **\n${screenInfo.uiXml}`
|
|
189
|
-
: `\n\n** UI 结构 (XML) **\n${screenInfo.uiXml}`;
|
|
190
|
-
}
|
|
191
|
-
const userContent = [
|
|
192
|
-
{ type: "text", text: userText },
|
|
193
|
-
];
|
|
194
|
-
if (screenInfo.imageRef) {
|
|
195
|
-
userContent.push({
|
|
196
|
-
type: "image_url",
|
|
197
|
-
image_url: { url: screenInfo.imageRef.url },
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
return [
|
|
201
|
-
{ role: "system", content: sys },
|
|
202
|
-
{ role: "user", content: userContent },
|
|
203
|
-
];
|
|
204
|
-
}
|
|
205
|
-
parseResponse(raw) {
|
|
206
|
-
// Extract the "Action: ..." line as thinking/description for history
|
|
207
|
-
const actionLineMatch = raw.match(/^\s*Action:\s*(.+?)$/m);
|
|
208
|
-
const description = actionLineMatch ? actionLineMatch[1].trim().replace(/^"|"$/g, "") : "";
|
|
209
|
-
const parsed = parseToolCall(raw, description)
|
|
210
|
-
?? invalidModelOutput(this.name, "expected a valid <tool_call> JSON action");
|
|
211
|
-
// Coordinates come back 0-999; handler treats "0-1000" the same bucket.
|
|
212
|
-
parsed.coordSystem = "0-1000";
|
|
213
|
-
return parsed;
|
|
214
|
-
}
|
|
215
|
-
updateContext(_context, _response, parsed) {
|
|
216
|
-
if (!parsed.shouldFinish) {
|
|
217
|
-
const desc = (parsed.thinking || actionSummary(parsed)).slice(0, 200);
|
|
218
|
-
if (desc)
|
|
219
|
-
this.actionHistory.push(desc);
|
|
220
|
-
}
|
|
221
|
-
// GUI-Owl / GUI-Plus rebuild messages from scratch each turn (no accumulation)
|
|
222
|
-
return [];
|
|
223
|
-
}
|
|
224
|
-
clearHistory() {
|
|
225
|
-
this.actionHistory = [];
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
registerAdapter(() => new GUIOwlAdapter());
|
|
229
|
-
function actionSummary(parsed) {
|
|
230
|
-
const { actionType: t, params: p } = parsed;
|
|
231
|
-
if (t === "tap")
|
|
232
|
-
return `click(${p.x},${p.y})`;
|
|
233
|
-
if (t === "double_tap")
|
|
234
|
-
return `double_tap(${p.x},${p.y})`;
|
|
235
|
-
if (t === "long_press")
|
|
236
|
-
return `long_press(${p.x},${p.y})`;
|
|
237
|
-
if (t === "type")
|
|
238
|
-
return `type("${String(p.text).slice(0, 40)}")`;
|
|
239
|
-
if (t === "swipe")
|
|
240
|
-
return `swipe(${p.start_x},${p.start_y}→${p.end_x},${p.end_y})`;
|
|
241
|
-
if (t === "open_app")
|
|
242
|
-
return `open(${p.app_name})`;
|
|
243
|
-
if (t === "press_back")
|
|
244
|
-
return "system_button(Back)";
|
|
245
|
-
if (t === "press_home")
|
|
246
|
-
return "system_button(Home)";
|
|
247
|
-
return t;
|
|
248
|
-
}
|
|
249
|
-
//# sourceMappingURL=guiowl.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IAAI,CAAC,KAAK,KAAK;QAAE,OAAO,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;IAC/C,IAAI,CAAC,KAAK,YAAY;QAAE,OAAO,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;IAC3D,IAAI,CAAC,KAAK,YAAY;QAAE,OAAO,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;IAC3D,IAAI,CAAC,KAAK,MAAM;QAAE,OAAO,SAAS,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC;IAClE,IAAI,CAAC,KAAK,OAAO;QAAE,OAAO,SAAS,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC;IACnF,IAAI,CAAC,KAAK,UAAU;QAAE,OAAO,QAAQ,CAAC,CAAC,QAAQ,GAAG,CAAC;IACnD,IAAI,CAAC,KAAK,YAAY;QAAE,OAAO,qBAAqB,CAAC;IACrD,IAAI,CAAC,KAAK,YAAY;QAAE,OAAO,qBAAqB,CAAC;IACrD,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { invalidModelOutput, ModelAdapter, registerAdapter } from "./base.js";
|
|
2
|
-
import { parseToolCall } from "./shared/tool-call.js";
|
|
3
|
-
// MAIUI adapter
|
|
4
|
-
// Aligned with ClawGUI prompts_maiui.py (MAI_MOBILE_SYS_PROMPT_CN / MAI_MOBILE_SYS_PROMPT_EN)
|
|
5
|
-
//
|
|
6
|
-
// Message structure (mirrors ClawGUI exactly):
|
|
7
|
-
// First turn : [system(string), user([text:task]), user([image])]
|
|
8
|
-
// Subsequent : [...context, assistant(rawContent), user([image])]
|
|
9
|
-
// Max 3 images in context window (pruned in updateContext).
|
|
10
|
-
//
|
|
11
|
-
// Output format expected:
|
|
12
|
-
// <thinking>...</thinking>
|
|
13
|
-
// <tool_call>{"name": "mobile_use", "arguments": {...}}</tool_call>
|
|
14
|
-
const MAX_IMAGES = 3;
|
|
15
|
-
const SYSTEM_PROMPT_CN = `你是一个 GUI 智能体。你将获得一个任务、你的动作历史以及截图。你需要执行下一个动作来完成任务。
|
|
16
|
-
|
|
17
|
-
## 输出格式
|
|
18
|
-
对于每个函数调用,在 <thinking> </thinking> 标签中返回思考过程,并在 <tool_call></tool_call> XML 标签中返回包含函数名和参数的 json 对象:
|
|
19
|
-
\`\`\`
|
|
20
|
-
<thinking>
|
|
21
|
-
...
|
|
22
|
-
</thinking>
|
|
23
|
-
<tool_call>
|
|
24
|
-
{"name": "mobile_use", "arguments": <args-json-object>}
|
|
25
|
-
</tool_call>
|
|
26
|
-
\`\`\`
|
|
27
|
-
|
|
28
|
-
## 动作空间
|
|
29
|
-
|
|
30
|
-
{"action": "click", "coordinate": [x, y]}
|
|
31
|
-
{"action": "long_press", "coordinate": [x, y]}
|
|
32
|
-
{"action": "type", "text": ""}
|
|
33
|
-
{"action": "swipe", "direction": "up 或 down 或 left 或 right", "coordinate": [x, y]} # "coordinate" 是可选的。如果要滑动特定 UI 元素,请使用 "coordinate"。
|
|
34
|
-
{"action": "open", "text": "app_name"}
|
|
35
|
-
{"action": "drag", "start_coordinate": [x1, y1], "end_coordinate": [x2, y2]}
|
|
36
|
-
{"action": "system_button", "button": "button_name"} # 选项: back, home, menu, enter
|
|
37
|
-
{"action": "wait"}
|
|
38
|
-
{"action": "terminate", "status": "success 或 fail"}
|
|
39
|
-
{"action": "answer", "text": "xxx"} # 在 text 部分使用转义字符 \\'、\\" 和 \\n 以确保我们可以按正常 python 字符串格式解析内容。
|
|
40
|
-
|
|
41
|
-
## 注意事项
|
|
42
|
-
- 写一个小计划,然后在 <thinking></thinking> 部分用一句话总结你的下一个动作(及其目标元素)。
|
|
43
|
-
- 你可以使用 \`open\` 动作直接打开应用,这是打开应用最快的方式。
|
|
44
|
-
- 你必须严格遵循动作空间,并在 <thinking> </thinking> 和 <tool_call></tool_call> XML 标签中返回正确的 json 对象。
|
|
45
|
-
`;
|
|
46
|
-
const SYSTEM_PROMPT_EN = `You are a GUI agent. You are given a task and your action history, with screenshots. You need to perform the next action to complete the task.
|
|
47
|
-
|
|
48
|
-
## Output Format
|
|
49
|
-
For each function call, return the thinking process in <thinking> </thinking> tags, and a json object with function name and arguments within <tool_call></tool_call> XML tags:
|
|
50
|
-
\`\`\`
|
|
51
|
-
<thinking>
|
|
52
|
-
...
|
|
53
|
-
</thinking>
|
|
54
|
-
<tool_call>
|
|
55
|
-
{"name": "mobile_use", "arguments": <args-json-object>}
|
|
56
|
-
</tool_call>
|
|
57
|
-
\`\`\`
|
|
58
|
-
|
|
59
|
-
## Action Space
|
|
60
|
-
|
|
61
|
-
{"action": "click", "coordinate": [x, y]}
|
|
62
|
-
{"action": "long_press", "coordinate": [x, y]}
|
|
63
|
-
{"action": "type", "text": ""}
|
|
64
|
-
{"action": "swipe", "direction": "up or down or left or right", "coordinate": [x, y]} # "coordinate" is optional. Use the "coordinate" if you want to swipe a specific UI element.
|
|
65
|
-
{"action": "open", "text": "app_name"}
|
|
66
|
-
{"action": "drag", "start_coordinate": [x1, y1], "end_coordinate": [x2, y2]}
|
|
67
|
-
{"action": "system_button", "button": "button_name"} # Options: back, home, menu, enter
|
|
68
|
-
{"action": "wait"}
|
|
69
|
-
{"action": "terminate", "status": "success or fail"}
|
|
70
|
-
{"action": "answer", "text": "xxx"} # Use escape characters \\'、\\" and \\n in text part to ensure we can parse the text in normal python string format.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
## Note
|
|
74
|
-
- Write a small plan and finally summarize your next action (with its target element) in one sentence in <thinking></thinking> part.
|
|
75
|
-
- You can use the \`open\` action to open the app directly, because it is the fastest way to open the app.
|
|
76
|
-
- You must follow the Action Space strictly, and return the correct json object within <thinking> </thinking> and <tool_call></tool_call> XML tags.
|
|
77
|
-
`;
|
|
78
|
-
class MAIUIAdapter extends ModelAdapter {
|
|
79
|
-
name = "maiui";
|
|
80
|
-
patterns = [/maiui/, /mai[-_]?ui/, /mai_ui/];
|
|
81
|
-
buildMessages(task, screenInfo, context, isFirst, lang) {
|
|
82
|
-
const systemPrompt = lang === "cn" ? SYSTEM_PROMPT_CN : SYSTEM_PROMPT_EN;
|
|
83
|
-
if (isFirst) {
|
|
84
|
-
// First turn: [system(string), user([text:task]), user([image])]
|
|
85
|
-
const msgs = [
|
|
86
|
-
{ role: "system", content: systemPrompt },
|
|
87
|
-
{ role: "user", content: [{ type: "text", text: task }] },
|
|
88
|
-
];
|
|
89
|
-
if (screenInfo.imageRef) {
|
|
90
|
-
msgs.push({
|
|
91
|
-
role: "user",
|
|
92
|
-
content: [{ type: "image_url", image_url: { url: screenInfo.imageRef.url } }],
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
return msgs;
|
|
96
|
-
}
|
|
97
|
-
// Subsequent turns: [...accumulated context, user([image])]
|
|
98
|
-
const userContent = [];
|
|
99
|
-
if (screenInfo.imageRef) {
|
|
100
|
-
userContent.push({ type: "image_url", image_url: { url: screenInfo.imageRef.url } });
|
|
101
|
-
}
|
|
102
|
-
return [...context, { role: "user", content: userContent }];
|
|
103
|
-
}
|
|
104
|
-
parseResponse(raw) {
|
|
105
|
-
const thinking = extractThinking(raw);
|
|
106
|
-
const cleaned = raw.replace(/<thinking>[\s\S]*?<\/thinking>/gi, "").trim();
|
|
107
|
-
const toolBlock = cleaned.includes("<tool_call>") ? cleaned : `<tool_call>${cleaned}</tool_call>`;
|
|
108
|
-
return parseToolCall(toolBlock, thinking)
|
|
109
|
-
?? invalidModelOutput(this.name, "expected a valid <tool_call> JSON action");
|
|
110
|
-
}
|
|
111
|
-
updateContext(context, response, _parsed) {
|
|
112
|
-
context.push({ role: "assistant", content: response.rawContent });
|
|
113
|
-
return pruneImages(context, MAX_IMAGES);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
registerAdapter(() => new MAIUIAdapter());
|
|
117
|
-
// ── Helpers ──────────────────────────────────────────────────────────────────
|
|
118
|
-
function extractThinking(raw) {
|
|
119
|
-
const m = raw.match(/<thinking>([\s\S]*?)<\/thinking>/i);
|
|
120
|
-
return m ? m[1].trim() : "";
|
|
121
|
-
}
|
|
122
|
-
function pruneImages(context, keepCount) {
|
|
123
|
-
let imageCount = 0;
|
|
124
|
-
for (let i = context.length - 1; i >= 0; i--) {
|
|
125
|
-
const msg = context[i];
|
|
126
|
-
if (Array.isArray(msg.content)) {
|
|
127
|
-
const parts = msg.content;
|
|
128
|
-
const hasImage = parts.some((p) => p.type === "image_url");
|
|
129
|
-
if (hasImage) {
|
|
130
|
-
imageCount++;
|
|
131
|
-
if (imageCount > keepCount) {
|
|
132
|
-
context[i] = {
|
|
133
|
-
...msg,
|
|
134
|
-
content: parts.filter((p) => p.type !== "image_url"),
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return context;
|
|
141
|
-
}
|
|
142
|
-
//# sourceMappingURL=maiui.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"maiui.js","sourceRoot":"","sources":["../../../../src/agent-runtime/models/vlm/maiui.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,gBAAgB;AAChB,8FAA8F;AAC9F,EAAE;AACF,+CAA+C;AAC/C,qEAAqE;AACrE,qEAAqE;AACrE,8DAA8D;AAC9D,EAAE;AACF,0BAA0B;AAC1B,6BAA6B;AAC7B,sEAAsE;AAEtE,MAAM,UAAU,GAAG,CAAC,CAAC;AAErB,MAAM,gBAAgB,G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,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7C,MAAM,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QACvB,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/B,MAAM,KAAK,GAAG,GAAG,CAAC,OAAkC,CAAC;YACrD,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC;YAC3D,IAAI,QAAQ,EAAE,CAAC;gBACb,UAAU,EAAE,CAAC;gBACb,IAAI,UAAU,GAAG,SAAS,EAAE,CAAC;oBAC3B,OAAO,CAAC,CAAC,CAAC,GAAG;wBACX,GAAG,GAAG;wBACN,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC;qBACrD,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
import { invalidModelOutput, ModelAdapter, registerAdapter } from "./base.js";
|
|
2
|
-
import { parseToolCall } from "./shared/tool-call.js";
|
|
3
|
-
const POINT_SCHEMA = {
|
|
4
|
-
type: "array",
|
|
5
|
-
items: { type: "integer", minimum: 0, maximum: 999 },
|
|
6
|
-
minItems: 2,
|
|
7
|
-
maxItems: 2,
|
|
8
|
-
};
|
|
9
|
-
const ALLOWED_ACTIONS = [
|
|
10
|
-
"click",
|
|
11
|
-
"tap",
|
|
12
|
-
"left_click",
|
|
13
|
-
"double_tap",
|
|
14
|
-
"double_click",
|
|
15
|
-
"doubleclick",
|
|
16
|
-
"long_press",
|
|
17
|
-
"swipe",
|
|
18
|
-
"drag",
|
|
19
|
-
"scroll",
|
|
20
|
-
"type",
|
|
21
|
-
"input_text",
|
|
22
|
-
"system_button",
|
|
23
|
-
"keyboard_enter",
|
|
24
|
-
"back",
|
|
25
|
-
"navigate_back",
|
|
26
|
-
"home",
|
|
27
|
-
"navigate_home",
|
|
28
|
-
"open_app",
|
|
29
|
-
"launch_app",
|
|
30
|
-
"wait",
|
|
31
|
-
"answer",
|
|
32
|
-
"terminate",
|
|
33
|
-
];
|
|
34
|
-
const MOBILE_USE_TOOL = {
|
|
35
|
-
type: "function",
|
|
36
|
-
function: {
|
|
37
|
-
name: "mobile_use",
|
|
38
|
-
description: "Execute exactly one atomic action on the current Android device.",
|
|
39
|
-
parameters: {
|
|
40
|
-
type: "object",
|
|
41
|
-
additionalProperties: false,
|
|
42
|
-
properties: {
|
|
43
|
-
action: {
|
|
44
|
-
type: "string",
|
|
45
|
-
enum: [
|
|
46
|
-
"click",
|
|
47
|
-
"double_tap",
|
|
48
|
-
"long_press",
|
|
49
|
-
"swipe",
|
|
50
|
-
"drag",
|
|
51
|
-
"scroll",
|
|
52
|
-
"type",
|
|
53
|
-
"system_button",
|
|
54
|
-
"open_app",
|
|
55
|
-
"wait",
|
|
56
|
-
"answer",
|
|
57
|
-
"terminate",
|
|
58
|
-
],
|
|
59
|
-
},
|
|
60
|
-
coordinate: {
|
|
61
|
-
...POINT_SCHEMA,
|
|
62
|
-
description: "Required for click, double_tap and long_press; may anchor scroll.",
|
|
63
|
-
},
|
|
64
|
-
coordinate2: { ...POINT_SCHEMA, description: "Required swipe or drag end point." },
|
|
65
|
-
start_coordinate: { ...POINT_SCHEMA, description: "Alternative swipe or drag start point." },
|
|
66
|
-
end_coordinate: { ...POINT_SCHEMA, description: "Alternative swipe or drag end point." },
|
|
67
|
-
text: { type: "string", description: "Required for type and answer." },
|
|
68
|
-
app_name: { type: "string", description: "Required for open_app." },
|
|
69
|
-
button: { type: "string", enum: ["Back", "Home", "Menu", "Enter"] },
|
|
70
|
-
direction: { type: "string", enum: ["up", "down", "left", "right"] },
|
|
71
|
-
amount: { type: "number", minimum: 0.1, maximum: 5 },
|
|
72
|
-
time: { type: "number", minimum: 0, maximum: 30 },
|
|
73
|
-
status: {
|
|
74
|
-
type: "string",
|
|
75
|
-
enum: ["success", "failure"],
|
|
76
|
-
description: "Required for terminate.",
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
required: ["action"],
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
const SYSTEM_PROMPT_EN = `You control an Android phone using the mobile_use tool.
|
|
84
|
-
Inspect the latest screenshot or UI hierarchy and call mobile_use exactly once per turn.
|
|
85
|
-
Coordinates are normalized integers from 0 to 999, with (0,0) at the top-left.
|
|
86
|
-
Use only the actions declared by the tool. Never emit desktop actions such as left_click.
|
|
87
|
-
Before repeating an action, verify from the latest observation whether the previous action worked.
|
|
88
|
-
Use answer when the user requested information. Use terminate when the task is complete or cannot be completed safely.`;
|
|
89
|
-
const SYSTEM_PROMPT_CN = `你通过 mobile_use 工具控制 Android 手机。
|
|
90
|
-
每一轮检查最新截图或 UI 结构,并且只调用一次 mobile_use。
|
|
91
|
-
坐标是 0 到 999 的归一化整数,左上角为 (0,0)。
|
|
92
|
-
只能使用工具声明的动作,不要输出 left_click 等桌面动作。
|
|
93
|
-
重复动作前,先根据最新观察确认上一步是否生效。
|
|
94
|
-
用户要求获取信息时使用 answer;任务完成或无法安全完成时使用 terminate。`;
|
|
95
|
-
class Qwen38Adapter extends ModelAdapter {
|
|
96
|
-
name = "qwen38";
|
|
97
|
-
patterns = [/(?:^|[\/_-])qwen3\.8(?:$|[\/_-])/];
|
|
98
|
-
observationProfile = {
|
|
99
|
-
defaultMode: "vision",
|
|
100
|
-
supportedModes: ["vision", "xml", "hybrid"],
|
|
101
|
-
};
|
|
102
|
-
requestProfile = {
|
|
103
|
-
tools: [MOBILE_USE_TOOL],
|
|
104
|
-
toolChoice: "required",
|
|
105
|
-
parallelToolCalls: false,
|
|
106
|
-
};
|
|
107
|
-
actionHistory = [];
|
|
108
|
-
buildMessages(task, screenInfo, _context, isFirst, lang) {
|
|
109
|
-
if (isFirst)
|
|
110
|
-
this.actionHistory = [];
|
|
111
|
-
const content = [{
|
|
112
|
-
type: "text",
|
|
113
|
-
text: buildUserPrompt(task, screenInfo, this.actionHistory, lang),
|
|
114
|
-
}];
|
|
115
|
-
if (screenInfo.imageRef) {
|
|
116
|
-
content.push({ type: "image_url", image_url: { url: screenInfo.imageRef.url } });
|
|
117
|
-
}
|
|
118
|
-
return [
|
|
119
|
-
{ role: "system", content: lang === "cn" ? SYSTEM_PROMPT_CN : SYSTEM_PROMPT_EN },
|
|
120
|
-
{ role: "user", content },
|
|
121
|
-
];
|
|
122
|
-
}
|
|
123
|
-
parseResponse(raw) {
|
|
124
|
-
const marker = raw.indexOf("<tool_call>");
|
|
125
|
-
const thinking = (marker >= 0 ? raw.slice(0, marker) : raw).trim();
|
|
126
|
-
const parsed = parseToolCall(raw, thinking, {
|
|
127
|
-
expectedToolName: "mobile_use",
|
|
128
|
-
allowedActions: ALLOWED_ACTIONS,
|
|
129
|
-
})
|
|
130
|
-
?? invalidModelOutput(this.name, "expected one valid mobile_use tool call");
|
|
131
|
-
validateAction(parsed);
|
|
132
|
-
return parsed;
|
|
133
|
-
}
|
|
134
|
-
updateContext(_context, _response, parsed) {
|
|
135
|
-
if (!parsed.shouldFinish)
|
|
136
|
-
this.actionHistory.push(actionSummary(parsed));
|
|
137
|
-
return [];
|
|
138
|
-
}
|
|
139
|
-
clearHistory() {
|
|
140
|
-
this.actionHistory = [];
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
registerAdapter(() => new Qwen38Adapter());
|
|
144
|
-
function buildUserPrompt(task, screenInfo, history, lang) {
|
|
145
|
-
const lines = lang === "cn"
|
|
146
|
-
? [`任务:${task}`, `当前应用:${screenInfo.currentApp || "未知"}`]
|
|
147
|
-
: [`Task: ${task}`, `Current app: ${screenInfo.currentApp || "unknown"}`];
|
|
148
|
-
if (history.length > 0) {
|
|
149
|
-
lines.push(lang === "cn" ? "已执行动作:" : "Actions already executed:");
|
|
150
|
-
history.forEach((action, index) => lines.push(`${index + 1}. ${action}`));
|
|
151
|
-
}
|
|
152
|
-
if (screenInfo.uiXml) {
|
|
153
|
-
lines.push(lang === "cn" ? "UI 结构:" : "UI hierarchy:", screenInfo.uiXml);
|
|
154
|
-
}
|
|
155
|
-
return lines.join("\n");
|
|
156
|
-
}
|
|
157
|
-
function validateAction(parsed) {
|
|
158
|
-
const p = parsed.params;
|
|
159
|
-
const point = (x, y, label) => {
|
|
160
|
-
if (!isCoordinate(x) || !isCoordinate(y)) {
|
|
161
|
-
invalidModelOutput("qwen38", `${label} coordinates must be integers in [0, 999]`);
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
switch (parsed.actionType) {
|
|
165
|
-
case "tap":
|
|
166
|
-
case "double_tap":
|
|
167
|
-
point(p.x, p.y, parsed.actionType);
|
|
168
|
-
break;
|
|
169
|
-
case "long_press":
|
|
170
|
-
point(p.x, p.y, parsed.actionType);
|
|
171
|
-
if (typeof p.duration_ms !== "number"
|
|
172
|
-
|| !Number.isFinite(p.duration_ms)
|
|
173
|
-
|| p.duration_ms < 0
|
|
174
|
-
|| p.duration_ms > 30_000) {
|
|
175
|
-
invalidModelOutput("qwen38", "long_press time must be in [0, 30]");
|
|
176
|
-
}
|
|
177
|
-
break;
|
|
178
|
-
case "swipe":
|
|
179
|
-
point(p.start_x, p.start_y, "swipe start");
|
|
180
|
-
point(p.end_x, p.end_y, "swipe end");
|
|
181
|
-
break;
|
|
182
|
-
case "scroll":
|
|
183
|
-
point(p.x, p.y, "scroll");
|
|
184
|
-
if (!["up", "down", "left", "right"].includes(String(p.direction))) {
|
|
185
|
-
invalidModelOutput("qwen38", "scroll direction is invalid");
|
|
186
|
-
}
|
|
187
|
-
if (typeof p.amount !== "number"
|
|
188
|
-
|| !Number.isFinite(p.amount)
|
|
189
|
-
|| p.amount < 0.1
|
|
190
|
-
|| p.amount > 5) {
|
|
191
|
-
invalidModelOutput("qwen38", "scroll amount must be in [0.1, 5]");
|
|
192
|
-
}
|
|
193
|
-
break;
|
|
194
|
-
case "type":
|
|
195
|
-
if (typeof p.text !== "string" || p.text.length === 0) {
|
|
196
|
-
invalidModelOutput("qwen38", "type requires non-empty text");
|
|
197
|
-
}
|
|
198
|
-
break;
|
|
199
|
-
case "open_app":
|
|
200
|
-
if (typeof p.app_name !== "string" || p.app_name.trim().length === 0) {
|
|
201
|
-
invalidModelOutput("qwen38", "open_app requires app_name");
|
|
202
|
-
}
|
|
203
|
-
break;
|
|
204
|
-
case "wait": {
|
|
205
|
-
const seconds = p.duration_seconds;
|
|
206
|
-
if (typeof seconds !== "number" || !Number.isFinite(seconds) || seconds < 0 || seconds > 30) {
|
|
207
|
-
invalidModelOutput("qwen38", "wait time must be in [0, 30]");
|
|
208
|
-
}
|
|
209
|
-
break;
|
|
210
|
-
}
|
|
211
|
-
case "press_back":
|
|
212
|
-
case "press_home":
|
|
213
|
-
case "press_key":
|
|
214
|
-
case "finish":
|
|
215
|
-
case "fail":
|
|
216
|
-
break;
|
|
217
|
-
default:
|
|
218
|
-
invalidModelOutput("qwen38", `unsupported action: ${parsed.actionType}`);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
function isCoordinate(value) {
|
|
222
|
-
return typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= 999;
|
|
223
|
-
}
|
|
224
|
-
function actionSummary(parsed) {
|
|
225
|
-
const p = parsed.params;
|
|
226
|
-
if (parsed.actionType === "tap")
|
|
227
|
-
return `click(${p.x},${p.y})`;
|
|
228
|
-
if (parsed.actionType === "double_tap")
|
|
229
|
-
return `double_tap(${p.x},${p.y})`;
|
|
230
|
-
if (parsed.actionType === "long_press")
|
|
231
|
-
return `long_press(${p.x},${p.y})`;
|
|
232
|
-
if (parsed.actionType === "swipe") {
|
|
233
|
-
return `swipe(${p.start_x},${p.start_y}->${p.end_x},${p.end_y})`;
|
|
234
|
-
}
|
|
235
|
-
if (parsed.actionType === "type")
|
|
236
|
-
return `type(${JSON.stringify(String(p.text).slice(0, 80))})`;
|
|
237
|
-
if (parsed.actionType === "open_app")
|
|
238
|
-
return `open_app(${p.app_name})`;
|
|
239
|
-
return parsed.actionType;
|
|
240
|
-
}
|
|
241
|
-
//# sourceMappingURL=qwen38.js.map
|