wuying-agentbay-sdk 0.10.0 → 0.10.2
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 +52 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +12 -9
- package/dist/index.d.ts +12 -9
- package/dist/index.mjs +52 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -301,6 +301,7 @@ declare class ApplyMqttTokenResponse extends $dara.Model {
|
|
|
301
301
|
declare class CallMcpToolRequest extends $dara.Model {
|
|
302
302
|
args?: string;
|
|
303
303
|
authorization?: string;
|
|
304
|
+
autoGenSession?: boolean;
|
|
304
305
|
externalUserId?: string;
|
|
305
306
|
imageId?: string;
|
|
306
307
|
name?: string;
|
|
@@ -3655,15 +3656,16 @@ declare function validateExtraConfigs(extraConfigs: ExtraConfigs): void;
|
|
|
3655
3656
|
interface BoolResult extends OperationResult {
|
|
3656
3657
|
data?: boolean;
|
|
3657
3658
|
}
|
|
3659
|
+
interface UIBounds {
|
|
3660
|
+
left: number;
|
|
3661
|
+
top: number;
|
|
3662
|
+
right: number;
|
|
3663
|
+
bottom: number;
|
|
3664
|
+
}
|
|
3658
3665
|
interface UIElement$1 {
|
|
3659
3666
|
text: string;
|
|
3660
3667
|
className: string;
|
|
3661
|
-
bounds:
|
|
3662
|
-
left: number;
|
|
3663
|
-
top: number;
|
|
3664
|
-
right: number;
|
|
3665
|
-
bottom: number;
|
|
3666
|
-
};
|
|
3668
|
+
bounds: UIBounds | string;
|
|
3667
3669
|
}
|
|
3668
3670
|
interface UIElementsResult extends OperationResult {
|
|
3669
3671
|
elements: UIElement$1[];
|
|
@@ -3733,9 +3735,9 @@ declare class Mobile {
|
|
|
3733
3735
|
*/
|
|
3734
3736
|
startApp(startCmd: string, workDirectory?: string, activity?: string): Promise<ProcessResult>;
|
|
3735
3737
|
/**
|
|
3736
|
-
* Stop app by
|
|
3738
|
+
* Stop app by command.
|
|
3737
3739
|
*/
|
|
3738
|
-
|
|
3740
|
+
stopAppByCmd(stopCmd: string): Promise<BoolResult>;
|
|
3739
3741
|
/**
|
|
3740
3742
|
* Take a screenshot.
|
|
3741
3743
|
*/
|
|
@@ -4336,9 +4338,10 @@ declare class Session {
|
|
|
4336
4338
|
*
|
|
4337
4339
|
* @param toolName - Name of the MCP tool to call
|
|
4338
4340
|
* @param args - Arguments to pass to the tool
|
|
4341
|
+
* @param autoGenSession - Whether to automatically generate session if not exists (default: false)
|
|
4339
4342
|
* @returns McpToolResult containing the response data
|
|
4340
4343
|
*/
|
|
4341
|
-
callMcpTool(toolName: string, args: any): Promise<McpToolResult>;
|
|
4344
|
+
callMcpTool(toolName: string, args: any, autoGenSession?: boolean): Promise<McpToolResult>;
|
|
4342
4345
|
}
|
|
4343
4346
|
|
|
4344
4347
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -301,6 +301,7 @@ declare class ApplyMqttTokenResponse extends $dara.Model {
|
|
|
301
301
|
declare class CallMcpToolRequest extends $dara.Model {
|
|
302
302
|
args?: string;
|
|
303
303
|
authorization?: string;
|
|
304
|
+
autoGenSession?: boolean;
|
|
304
305
|
externalUserId?: string;
|
|
305
306
|
imageId?: string;
|
|
306
307
|
name?: string;
|
|
@@ -3655,15 +3656,16 @@ declare function validateExtraConfigs(extraConfigs: ExtraConfigs): void;
|
|
|
3655
3656
|
interface BoolResult extends OperationResult {
|
|
3656
3657
|
data?: boolean;
|
|
3657
3658
|
}
|
|
3659
|
+
interface UIBounds {
|
|
3660
|
+
left: number;
|
|
3661
|
+
top: number;
|
|
3662
|
+
right: number;
|
|
3663
|
+
bottom: number;
|
|
3664
|
+
}
|
|
3658
3665
|
interface UIElement$1 {
|
|
3659
3666
|
text: string;
|
|
3660
3667
|
className: string;
|
|
3661
|
-
bounds:
|
|
3662
|
-
left: number;
|
|
3663
|
-
top: number;
|
|
3664
|
-
right: number;
|
|
3665
|
-
bottom: number;
|
|
3666
|
-
};
|
|
3668
|
+
bounds: UIBounds | string;
|
|
3667
3669
|
}
|
|
3668
3670
|
interface UIElementsResult extends OperationResult {
|
|
3669
3671
|
elements: UIElement$1[];
|
|
@@ -3733,9 +3735,9 @@ declare class Mobile {
|
|
|
3733
3735
|
*/
|
|
3734
3736
|
startApp(startCmd: string, workDirectory?: string, activity?: string): Promise<ProcessResult>;
|
|
3735
3737
|
/**
|
|
3736
|
-
* Stop app by
|
|
3738
|
+
* Stop app by command.
|
|
3737
3739
|
*/
|
|
3738
|
-
|
|
3740
|
+
stopAppByCmd(stopCmd: string): Promise<BoolResult>;
|
|
3739
3741
|
/**
|
|
3740
3742
|
* Take a screenshot.
|
|
3741
3743
|
*/
|
|
@@ -4336,9 +4338,10 @@ declare class Session {
|
|
|
4336
4338
|
*
|
|
4337
4339
|
* @param toolName - Name of the MCP tool to call
|
|
4338
4340
|
* @param args - Arguments to pass to the tool
|
|
4341
|
+
* @param autoGenSession - Whether to automatically generate session if not exists (default: false)
|
|
4339
4342
|
* @returns McpToolResult containing the response data
|
|
4340
4343
|
*/
|
|
4341
|
-
callMcpTool(toolName: string, args: any): Promise<McpToolResult>;
|
|
4344
|
+
callMcpTool(toolName: string, args: any, autoGenSession?: boolean): Promise<McpToolResult>;
|
|
4342
4345
|
}
|
|
4343
4346
|
|
|
4344
4347
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -570,19 +570,10 @@ function getVersionFromPackageJson() {
|
|
|
570
570
|
}
|
|
571
571
|
__name(getVersionFromPackageJson, "getVersionFromPackageJson");
|
|
572
572
|
function isReleaseBuild() {
|
|
573
|
-
|
|
574
|
-
return false;
|
|
575
|
-
}
|
|
576
|
-
const workflow = process.env.GITHUB_WORKFLOW || "";
|
|
577
|
-
if (workflow.includes("Build and Publish to npm")) {
|
|
578
|
-
return true;
|
|
579
|
-
}
|
|
580
|
-
if (process.env.AGENTBAY_RELEASE_BUILD === "true") {
|
|
581
|
-
return true;
|
|
582
|
-
}
|
|
583
|
-
return false;
|
|
573
|
+
return __AGENTBAY_IS_RELEASE_BUILD__;
|
|
584
574
|
}
|
|
585
575
|
__name(isReleaseBuild, "isReleaseBuild");
|
|
576
|
+
var __AGENTBAY_IS_RELEASE_BUILD__ = true;
|
|
586
577
|
var VERSION = getVersionFromPackageJson();
|
|
587
578
|
var IS_RELEASE = isReleaseBuild();
|
|
588
579
|
|
|
@@ -1094,6 +1085,7 @@ var _CallMcpToolRequest = class _CallMcpToolRequest extends $dara16.Model {
|
|
|
1094
1085
|
return {
|
|
1095
1086
|
args: "Args",
|
|
1096
1087
|
authorization: "Authorization",
|
|
1088
|
+
autoGenSession: "AutoGenSession",
|
|
1097
1089
|
externalUserId: "ExternalUserId",
|
|
1098
1090
|
imageId: "ImageId",
|
|
1099
1091
|
name: "Name",
|
|
@@ -1106,6 +1098,7 @@ var _CallMcpToolRequest = class _CallMcpToolRequest extends $dara16.Model {
|
|
|
1106
1098
|
return {
|
|
1107
1099
|
args: "string",
|
|
1108
1100
|
authorization: "string",
|
|
1101
|
+
autoGenSession: "boolean",
|
|
1109
1102
|
externalUserId: "string",
|
|
1110
1103
|
imageId: "string",
|
|
1111
1104
|
name: "string",
|
|
@@ -3456,6 +3449,9 @@ var _Client = class _Client extends (OpenApi.default || OpenApi) {
|
|
|
3456
3449
|
if (!$dara84.isNull(request.authorization)) {
|
|
3457
3450
|
body["Authorization"] = request.authorization;
|
|
3458
3451
|
}
|
|
3452
|
+
if (!$dara84.isNull(request.autoGenSession)) {
|
|
3453
|
+
body["AutoGenSession"] = request.autoGenSession;
|
|
3454
|
+
}
|
|
3459
3455
|
if (!$dara84.isNull(request.externalUserId)) {
|
|
3460
3456
|
body["ExternalUserId"] = request.externalUserId;
|
|
3461
3457
|
}
|
|
@@ -9106,6 +9102,31 @@ init_esm_shims();
|
|
|
9106
9102
|
|
|
9107
9103
|
// src/mobile/mobile.ts
|
|
9108
9104
|
init_esm_shims();
|
|
9105
|
+
function parseBoundsString(boundsStr) {
|
|
9106
|
+
const parts = boundsStr.split(",");
|
|
9107
|
+
if (parts.length !== 4) {
|
|
9108
|
+
return null;
|
|
9109
|
+
}
|
|
9110
|
+
const [left, top, right, bottom] = parts.map((p) => parseInt(p.trim(), 10));
|
|
9111
|
+
if (isNaN(left) || isNaN(top) || isNaN(right) || isNaN(bottom)) {
|
|
9112
|
+
return null;
|
|
9113
|
+
}
|
|
9114
|
+
return { left, top, right, bottom };
|
|
9115
|
+
}
|
|
9116
|
+
__name(parseBoundsString, "parseBoundsString");
|
|
9117
|
+
function normalizeUIElement(element) {
|
|
9118
|
+
if (element.bounds && typeof element.bounds === "string") {
|
|
9119
|
+
const parsedBounds = parseBoundsString(element.bounds);
|
|
9120
|
+
if (parsedBounds) {
|
|
9121
|
+
element.bounds = parsedBounds;
|
|
9122
|
+
}
|
|
9123
|
+
}
|
|
9124
|
+
if (element.children && Array.isArray(element.children)) {
|
|
9125
|
+
element.children = element.children.map(normalizeUIElement);
|
|
9126
|
+
}
|
|
9127
|
+
return element;
|
|
9128
|
+
}
|
|
9129
|
+
__name(normalizeUIElement, "normalizeUIElement");
|
|
9109
9130
|
var _Mobile = class _Mobile {
|
|
9110
9131
|
constructor(session) {
|
|
9111
9132
|
this.session = session;
|
|
@@ -9223,11 +9244,12 @@ var _Mobile = class _Mobile {
|
|
|
9223
9244
|
}
|
|
9224
9245
|
try {
|
|
9225
9246
|
const elements = JSON.parse(result.data);
|
|
9247
|
+
const normalizedElements = (elements || []).map(normalizeUIElement);
|
|
9226
9248
|
return {
|
|
9227
9249
|
success: true,
|
|
9228
9250
|
requestId: result.requestId || "",
|
|
9229
9251
|
errorMessage: "",
|
|
9230
|
-
elements:
|
|
9252
|
+
elements: normalizedElements
|
|
9231
9253
|
};
|
|
9232
9254
|
} catch (parseError) {
|
|
9233
9255
|
return {
|
|
@@ -9271,11 +9293,12 @@ var _Mobile = class _Mobile {
|
|
|
9271
9293
|
}
|
|
9272
9294
|
try {
|
|
9273
9295
|
const elements = JSON.parse(result.data);
|
|
9296
|
+
const normalizedElements = (elements || []).map(normalizeUIElement);
|
|
9274
9297
|
return {
|
|
9275
9298
|
success: true,
|
|
9276
9299
|
requestId: result.requestId || "",
|
|
9277
9300
|
errorMessage: "",
|
|
9278
|
-
elements:
|
|
9301
|
+
elements: normalizedElements
|
|
9279
9302
|
};
|
|
9280
9303
|
} catch (parseError) {
|
|
9281
9304
|
return {
|
|
@@ -9391,12 +9414,12 @@ var _Mobile = class _Mobile {
|
|
|
9391
9414
|
}
|
|
9392
9415
|
}
|
|
9393
9416
|
/**
|
|
9394
|
-
* Stop app by
|
|
9417
|
+
* Stop app by command.
|
|
9395
9418
|
*/
|
|
9396
|
-
async
|
|
9397
|
-
const args = {
|
|
9419
|
+
async stopAppByCmd(stopCmd) {
|
|
9420
|
+
const args = { stop_cmd: stopCmd };
|
|
9398
9421
|
try {
|
|
9399
|
-
const result = await this.session.callMcpTool("
|
|
9422
|
+
const result = await this.session.callMcpTool("stop_app_by_cmd", args);
|
|
9400
9423
|
return {
|
|
9401
9424
|
success: result.success || false,
|
|
9402
9425
|
requestId: result.requestId || "",
|
|
@@ -10840,9 +10863,10 @@ var _Session = class _Session {
|
|
|
10840
10863
|
*
|
|
10841
10864
|
* @param toolName - Name of the MCP tool to call
|
|
10842
10865
|
* @param args - Arguments to pass to the tool
|
|
10866
|
+
* @param autoGenSession - Whether to automatically generate session if not exists (default: false)
|
|
10843
10867
|
* @returns McpToolResult containing the response data
|
|
10844
10868
|
*/
|
|
10845
|
-
async callMcpTool(toolName, args) {
|
|
10869
|
+
async callMcpTool(toolName, args, autoGenSession = false) {
|
|
10846
10870
|
try {
|
|
10847
10871
|
const argsJSON = JSON.stringify(args);
|
|
10848
10872
|
if (this.isVpcEnabled()) {
|
|
@@ -10920,7 +10944,8 @@ var _Session = class _Session {
|
|
|
10920
10944
|
authorization: `Bearer ${this.getAPIKey()}`,
|
|
10921
10945
|
sessionId: this.getSessionId(),
|
|
10922
10946
|
name: toolName,
|
|
10923
|
-
args: argsJSON
|
|
10947
|
+
args: argsJSON,
|
|
10948
|
+
autoGenSession
|
|
10924
10949
|
});
|
|
10925
10950
|
const response = await this.getClient().callMcpTool(callToolRequest);
|
|
10926
10951
|
if (!response.body?.data) {
|
|
@@ -11735,6 +11760,14 @@ var _AgentBay = class _AgentBay {
|
|
|
11735
11760
|
session.token = getResult.data.token;
|
|
11736
11761
|
session.resourceUrl = getResult.data.resourceUrl;
|
|
11737
11762
|
}
|
|
11763
|
+
const contextName = `file-transfer-context-${Date.now()}`;
|
|
11764
|
+
const contextResult = await this.context.get(contextName, true);
|
|
11765
|
+
if (contextResult.success && contextResult.context) {
|
|
11766
|
+
session.fileTransferContextId = contextResult.context.id;
|
|
11767
|
+
logInfo(`\u{1F4C1} Created file transfer context for recovered session: ${contextResult.context.id}`);
|
|
11768
|
+
} else {
|
|
11769
|
+
logError(`\u26A0\uFE0F Failed to create file transfer context for recovered session: ${contextResult.errorMessage || "Unknown error"}`);
|
|
11770
|
+
}
|
|
11738
11771
|
return {
|
|
11739
11772
|
requestId: getResult.requestId,
|
|
11740
11773
|
success: true,
|