autoglm.js 0.0.9 → 0.0.11
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.mjs +18 -11
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -350,7 +350,7 @@ const SYSTEM_PROMPT_ZH = `今天的日期是: ${formatted_date}
|
|
|
350
350
|
- do(action="Wait", duration="x seconds")
|
|
351
351
|
等待页面加载,x为需要等待多少秒。
|
|
352
352
|
- finish(message="xxx")
|
|
353
|
-
finish是结束任务的操作,表示准确完整完成任务,message
|
|
353
|
+
finish是结束任务的操作,表示准确完整完成任务,message参数是任务完成后的总结信息,必须简洁明了地说明执行结果。
|
|
354
354
|
|
|
355
355
|
必须遵循的规则:
|
|
356
356
|
1. 在执行任何操作前,先检查当前app是否是目标app,如果不是,先执行 Launch。
|
|
@@ -1202,10 +1202,14 @@ function getActionType(node) {
|
|
|
1202
1202
|
*/
|
|
1203
1203
|
function parseAction(actionStr) {
|
|
1204
1204
|
if (actionStr.startsWith("finish(")) {
|
|
1205
|
-
const match = actionStr.match(/finish\(message=(.*)\)/);
|
|
1206
|
-
return {
|
|
1205
|
+
const match = actionStr.match(/finish\(message=(.*)\)/s);
|
|
1206
|
+
if (match) return {
|
|
1207
|
+
_metadata: "finish",
|
|
1208
|
+
message: parseQuotedString(match[1].trim())
|
|
1209
|
+
};
|
|
1210
|
+
else return {
|
|
1207
1211
|
_metadata: "finish",
|
|
1208
|
-
message:
|
|
1212
|
+
message: void 0
|
|
1209
1213
|
};
|
|
1210
1214
|
}
|
|
1211
1215
|
if (actionStr.startsWith("do(")) {
|
|
@@ -1624,6 +1628,13 @@ var ModelClient = class {
|
|
|
1624
1628
|
}
|
|
1625
1629
|
};
|
|
1626
1630
|
|
|
1631
|
+
//#endregion
|
|
1632
|
+
//#region src/utils/finishMessage.ts
|
|
1633
|
+
function getFinishMessage(result) {
|
|
1634
|
+
const actionMessage = result?.action?._metadata === "finish" ? result.action.message : void 0;
|
|
1635
|
+
return result?.message || actionMessage || result?.thinking || "Task completed";
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1627
1638
|
//#endregion
|
|
1628
1639
|
//#region src/agent/index.ts
|
|
1629
1640
|
var PhoneAgent = class {
|
|
@@ -1738,18 +1749,14 @@ var PhoneAgent = class {
|
|
|
1738
1749
|
const result = await this.actionHandler.execute(action, screenshot.width, screenshot.height);
|
|
1739
1750
|
this.context.push(MessageBuilder.createAssistantMessage(`<think>${response.thinking}</think><answer>${response.action}</answer>`));
|
|
1740
1751
|
const finished = action._metadata === "finish" || result.should_finish;
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
const message = result.message || actionMessage$1 || "Task completed";
|
|
1744
|
-
this.ctx.emit(EventType.TASK_COMPLETE, message);
|
|
1745
|
-
}
|
|
1746
|
-
const actionMessage = action._metadata === "finish" ? action.message : void 0;
|
|
1752
|
+
const message = getFinishMessage(result);
|
|
1753
|
+
if (finished) this.ctx.emit(EventType.TASK_COMPLETE, message);
|
|
1747
1754
|
return {
|
|
1748
1755
|
success: result.success,
|
|
1749
1756
|
finished,
|
|
1750
1757
|
action,
|
|
1751
1758
|
thinking: response.thinking,
|
|
1752
|
-
message
|
|
1759
|
+
message
|
|
1753
1760
|
};
|
|
1754
1761
|
} catch (error) {
|
|
1755
1762
|
return {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "autoglm.js",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.11",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "AutoGLM.js is a JavaScript library for Open-AutoGLM",
|
|
7
7
|
"author": "FliPPeDround <flippedround@qq.com>",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"unzipper": "^0.12.3"
|
|
49
49
|
},
|
|
50
50
|
"optionalDependencies": {
|
|
51
|
-
"@autoglm.js/platform-tools-darwin": "36.0.0",
|
|
52
51
|
"@autoglm.js/adb-keyboard": "0.0.1",
|
|
52
|
+
"@autoglm.js/platform-tools-darwin": "36.0.0",
|
|
53
53
|
"@autoglm.js/platform-tools-linux": "36.0.0",
|
|
54
54
|
"@autoglm.js/platform-tools-windows": "36.0.0"
|
|
55
55
|
},
|