shellx-cli 0.0.10 → 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/bundle/shellx.js +119 -33
- package/package.json +1 -1
package/bundle/shellx.js
CHANGED
|
@@ -138007,7 +138007,7 @@ var init_git_commit = __esm({
|
|
|
138007
138007
|
"packages/core/dist/src/generated/git-commit.js"() {
|
|
138008
138008
|
"use strict";
|
|
138009
138009
|
GIT_COMMIT_INFO = "fecca9c3";
|
|
138010
|
-
CLI_VERSION = "0.0.
|
|
138010
|
+
CLI_VERSION = "0.0.10";
|
|
138011
138011
|
}
|
|
138012
138012
|
});
|
|
138013
138013
|
|
|
@@ -150655,7 +150655,7 @@ function createContentGeneratorConfig(config, authType) {
|
|
|
150655
150655
|
return contentGeneratorConfig;
|
|
150656
150656
|
}
|
|
150657
150657
|
async function createContentGenerator(config, gcConfig, sessionId2) {
|
|
150658
|
-
const version2 = "0.0.
|
|
150658
|
+
const version2 = "0.0.11";
|
|
150659
150659
|
const userAgent2 = `GeminiCLI/${version2} (${process.platform}; ${process.arch})`;
|
|
150660
150660
|
const baseHeaders = {
|
|
150661
150661
|
"User-Agent": userAgent2
|
|
@@ -384223,7 +384223,7 @@ var require_shellx = __commonJS({
|
|
|
384223
384223
|
return combined;
|
|
384224
384224
|
}
|
|
384225
384225
|
/**
|
|
384226
|
-
* 通用重试机制
|
|
384226
|
+
* 通用重试机制 - 失败时返回 undefined 而不是抛出异常
|
|
384227
384227
|
*/
|
|
384228
384228
|
withRetry(operation_1) {
|
|
384229
384229
|
return __awaiter(this, arguments, void 0, function* (operation, options3 = {}) {
|
|
@@ -384233,7 +384233,8 @@ var require_shellx = __commonJS({
|
|
|
384233
384233
|
return yield operation();
|
|
384234
384234
|
} catch (error) {
|
|
384235
384235
|
if (attempt === retry) {
|
|
384236
|
-
|
|
384236
|
+
console.log(`\u274C [Retry] \u91CD\u8BD5 ${retry} \u6B21\u540E\u4ECD\u7136\u5931\u8D25\uFF0C\u8FD4\u56DE undefined:`, error);
|
|
384237
|
+
return void 0;
|
|
384237
384238
|
}
|
|
384238
384239
|
if (onRetry) {
|
|
384239
384240
|
onRetry(attempt, error);
|
|
@@ -384242,7 +384243,7 @@ var require_shellx = __commonJS({
|
|
|
384242
384243
|
yield new Promise((resolve23) => setTimeout(resolve23, delay4));
|
|
384243
384244
|
}
|
|
384244
384245
|
}
|
|
384245
|
-
|
|
384246
|
+
return void 0;
|
|
384246
384247
|
});
|
|
384247
384248
|
}
|
|
384248
384249
|
/**
|
|
@@ -384282,7 +384283,7 @@ var require_shellx = __commonJS({
|
|
|
384282
384283
|
click(clickData) {
|
|
384283
384284
|
return __awaiter(this, void 0, void 0, function* () {
|
|
384284
384285
|
const startTime = Date.now();
|
|
384285
|
-
|
|
384286
|
+
const result = yield this.withRetry(() => __awaiter(this, void 0, void 0, function* () {
|
|
384286
384287
|
try {
|
|
384287
384288
|
let target;
|
|
384288
384289
|
if (clickData.targetElementId) {
|
|
@@ -384329,6 +384330,14 @@ var require_shellx = __commonJS({
|
|
|
384329
384330
|
throw new Error(`\u70B9\u51FB\u64CD\u4F5C\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`);
|
|
384330
384331
|
}
|
|
384331
384332
|
}), { retry: clickData.retry, delay: 500 });
|
|
384333
|
+
if (!result) {
|
|
384334
|
+
return {
|
|
384335
|
+
success: false,
|
|
384336
|
+
error: "\u70B9\u51FB\u64CD\u4F5C\u5931\u8D25",
|
|
384337
|
+
duration: Date.now() - startTime
|
|
384338
|
+
};
|
|
384339
|
+
}
|
|
384340
|
+
return result;
|
|
384332
384341
|
});
|
|
384333
384342
|
}
|
|
384334
384343
|
/**
|
|
@@ -384337,7 +384346,7 @@ var require_shellx = __commonJS({
|
|
|
384337
384346
|
input(inputData) {
|
|
384338
384347
|
return __awaiter(this, void 0, void 0, function* () {
|
|
384339
384348
|
const startTime = Date.now();
|
|
384340
|
-
|
|
384349
|
+
const result = yield this.withRetry(() => __awaiter(this, void 0, void 0, function* () {
|
|
384341
384350
|
var _a5, _b2;
|
|
384342
384351
|
try {
|
|
384343
384352
|
let target;
|
|
@@ -384383,6 +384392,14 @@ var require_shellx = __commonJS({
|
|
|
384383
384392
|
throw new Error(`\u8F93\u5165\u64CD\u4F5C\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`);
|
|
384384
384393
|
}
|
|
384385
384394
|
}), { retry: inputData.retry, delay: 500 });
|
|
384395
|
+
if (!result) {
|
|
384396
|
+
return {
|
|
384397
|
+
success: false,
|
|
384398
|
+
error: "\u8F93\u5165\u64CD\u4F5C\u5931\u8D25",
|
|
384399
|
+
duration: Date.now() - startTime
|
|
384400
|
+
};
|
|
384401
|
+
}
|
|
384402
|
+
return result;
|
|
384386
384403
|
});
|
|
384387
384404
|
}
|
|
384388
384405
|
/**
|
|
@@ -384391,7 +384408,7 @@ var require_shellx = __commonJS({
|
|
|
384391
384408
|
swipe(swipeData) {
|
|
384392
384409
|
return __awaiter(this, void 0, void 0, function* () {
|
|
384393
384410
|
const startTime = Date.now();
|
|
384394
|
-
|
|
384411
|
+
const result = yield this.withRetry(() => __awaiter(this, void 0, void 0, function* () {
|
|
384395
384412
|
try {
|
|
384396
384413
|
const from = { x: swipeData.fromX, y: swipeData.fromY };
|
|
384397
384414
|
const to = { x: swipeData.toX, y: swipeData.toY };
|
|
@@ -384417,6 +384434,14 @@ var require_shellx = __commonJS({
|
|
|
384417
384434
|
throw new Error(`\u6ED1\u52A8\u64CD\u4F5C\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`);
|
|
384418
384435
|
}
|
|
384419
384436
|
}), { retry: swipeData.retry, delay: 500 });
|
|
384437
|
+
if (!result) {
|
|
384438
|
+
return {
|
|
384439
|
+
success: false,
|
|
384440
|
+
error: "\u6ED1\u52A8\u64CD\u4F5C\u5931\u8D25",
|
|
384441
|
+
duration: Date.now() - startTime
|
|
384442
|
+
};
|
|
384443
|
+
}
|
|
384444
|
+
return result;
|
|
384420
384445
|
});
|
|
384421
384446
|
}
|
|
384422
384447
|
/**
|
|
@@ -384425,7 +384450,7 @@ var require_shellx = __commonJS({
|
|
|
384425
384450
|
pressKey(keyData) {
|
|
384426
384451
|
return __awaiter(this, void 0, void 0, function* () {
|
|
384427
384452
|
const startTime = Date.now();
|
|
384428
|
-
|
|
384453
|
+
const result = yield this.withRetry(() => __awaiter(this, void 0, void 0, function* () {
|
|
384429
384454
|
try {
|
|
384430
384455
|
const action = {
|
|
384431
384456
|
title: `\u6309\u952E\u64CD\u4F5C: ${keyData.key}${keyData.longPress ? " (\u957F\u6309)" : ""}`,
|
|
@@ -384450,6 +384475,14 @@ var require_shellx = __commonJS({
|
|
|
384450
384475
|
throw new Error(`\u6309\u952E\u64CD\u4F5C\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`);
|
|
384451
384476
|
}
|
|
384452
384477
|
}), { retry: keyData.retry, delay: 500 });
|
|
384478
|
+
if (!result) {
|
|
384479
|
+
return {
|
|
384480
|
+
success: false,
|
|
384481
|
+
error: "\u6309\u952E\u64CD\u4F5C\u5931\u8D25",
|
|
384482
|
+
duration: Date.now() - startTime
|
|
384483
|
+
};
|
|
384484
|
+
}
|
|
384485
|
+
return result;
|
|
384453
384486
|
});
|
|
384454
384487
|
}
|
|
384455
384488
|
/**
|
|
@@ -384458,7 +384491,7 @@ var require_shellx = __commonJS({
|
|
|
384458
384491
|
wait(waitData) {
|
|
384459
384492
|
return __awaiter(this, void 0, void 0, function* () {
|
|
384460
384493
|
const startTime = Date.now();
|
|
384461
|
-
|
|
384494
|
+
const result = yield this.withRetry(() => __awaiter(this, void 0, void 0, function* () {
|
|
384462
384495
|
try {
|
|
384463
384496
|
const selector = this.convertSelector(waitData);
|
|
384464
384497
|
const timeout2 = waitData.timeout || 1e4;
|
|
@@ -384466,20 +384499,24 @@ var require_shellx = __commonJS({
|
|
|
384466
384499
|
const maxAttempts = Math.floor(timeout2 / interval);
|
|
384467
384500
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
384468
384501
|
try {
|
|
384469
|
-
const
|
|
384502
|
+
const result2 = yield this.client.findElement(selector, {
|
|
384470
384503
|
timeout: interval,
|
|
384471
384504
|
maxResults: 1,
|
|
384472
384505
|
visibleOnly: waitData.condition === "visible",
|
|
384473
384506
|
clickableOnly: waitData.condition === "clickable"
|
|
384474
384507
|
});
|
|
384475
|
-
if (
|
|
384508
|
+
if (!result2 || result2.success === false) {
|
|
384509
|
+
yield new Promise((resolve23) => setTimeout(resolve23, interval));
|
|
384510
|
+
continue;
|
|
384511
|
+
}
|
|
384512
|
+
if (result2.elements && result2.elements.length > 0) {
|
|
384476
384513
|
if (waitData.condition === "gone") {
|
|
384477
384514
|
yield new Promise((resolve23) => setTimeout(resolve23, interval));
|
|
384478
384515
|
continue;
|
|
384479
384516
|
} else {
|
|
384480
384517
|
return {
|
|
384481
384518
|
success: true,
|
|
384482
|
-
data: { element: this.convertElement(
|
|
384519
|
+
data: { element: this.convertElement(result2.elements[0]) },
|
|
384483
384520
|
duration: Date.now() - startTime
|
|
384484
384521
|
};
|
|
384485
384522
|
}
|
|
@@ -384499,6 +384536,14 @@ var require_shellx = __commonJS({
|
|
|
384499
384536
|
throw new Error(`\u7B49\u5F85\u64CD\u4F5C\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`);
|
|
384500
384537
|
}
|
|
384501
384538
|
}), { retry: waitData.retry, delay: 500 });
|
|
384539
|
+
if (!result) {
|
|
384540
|
+
return {
|
|
384541
|
+
success: false,
|
|
384542
|
+
error: "\u7B49\u5F85\u64CD\u4F5C\u5931\u8D25",
|
|
384543
|
+
duration: Date.now() - startTime
|
|
384544
|
+
};
|
|
384545
|
+
}
|
|
384546
|
+
return result;
|
|
384502
384547
|
});
|
|
384503
384548
|
}
|
|
384504
384549
|
/**
|
|
@@ -384506,10 +384551,10 @@ var require_shellx = __commonJS({
|
|
|
384506
384551
|
*/
|
|
384507
384552
|
find(findData) {
|
|
384508
384553
|
return __awaiter(this, void 0, void 0, function* () {
|
|
384509
|
-
|
|
384554
|
+
const result = yield this.withRetry(() => __awaiter(this, void 0, void 0, function* () {
|
|
384510
384555
|
try {
|
|
384511
384556
|
const selector = this.convertSelector(findData);
|
|
384512
|
-
const
|
|
384557
|
+
const result2 = yield this.client.findElement(selector, {
|
|
384513
384558
|
pressClick: findData.pressClick,
|
|
384514
384559
|
waitAfterMs: findData.waitAfterMs || 5e3,
|
|
384515
384560
|
maxResults: findData.maxResults || 1e3,
|
|
@@ -384517,17 +384562,32 @@ var require_shellx = __commonJS({
|
|
|
384517
384562
|
clickableOnly: false,
|
|
384518
384563
|
multiple: findData.multiple || false
|
|
384519
384564
|
});
|
|
384520
|
-
|
|
384565
|
+
if (!result2 || result2.success === false) {
|
|
384566
|
+
throw new Error((result2 === null || result2 === void 0 ? void 0 : result2.errorMessage) || "\u67E5\u627E\u5143\u7D20\u5931\u8D25");
|
|
384567
|
+
}
|
|
384568
|
+
if (!result2.elements) {
|
|
384569
|
+
throw new Error("\u672A\u627E\u5230\u5143\u7D20");
|
|
384570
|
+
}
|
|
384571
|
+
const elements = result2.elements.map((element) => this.convertElement(element));
|
|
384521
384572
|
return {
|
|
384522
384573
|
elements,
|
|
384523
384574
|
count: elements.length,
|
|
384524
384575
|
success: true,
|
|
384525
|
-
found:
|
|
384576
|
+
found: result2.found
|
|
384526
384577
|
};
|
|
384527
384578
|
} catch (error) {
|
|
384528
384579
|
throw new Error(`\u67E5\u627E\u64CD\u4F5C\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`);
|
|
384529
384580
|
}
|
|
384530
384581
|
}), { retry: findData.retry, delay: 500 });
|
|
384582
|
+
if (!result) {
|
|
384583
|
+
return {
|
|
384584
|
+
elements: [],
|
|
384585
|
+
count: 0,
|
|
384586
|
+
success: false,
|
|
384587
|
+
found: false
|
|
384588
|
+
};
|
|
384589
|
+
}
|
|
384590
|
+
return result;
|
|
384531
384591
|
});
|
|
384532
384592
|
}
|
|
384533
384593
|
/**
|
|
@@ -384535,18 +384595,27 @@ var require_shellx = __commonJS({
|
|
|
384535
384595
|
*/
|
|
384536
384596
|
executeCommand(commandData) {
|
|
384537
384597
|
return __awaiter(this, void 0, void 0, function* () {
|
|
384538
|
-
|
|
384598
|
+
const result = yield this.withRetry(() => __awaiter(this, void 0, void 0, function* () {
|
|
384539
384599
|
try {
|
|
384540
|
-
const
|
|
384600
|
+
const result2 = yield this.executeShellCommand(commandData.cmd, {
|
|
384541
384601
|
title: `\u6267\u884C\u547D\u4EE4: ${commandData.cmd}`,
|
|
384542
384602
|
timeout: commandData.timeout,
|
|
384543
384603
|
waitAfterMs: commandData.wait
|
|
384544
384604
|
});
|
|
384545
|
-
return
|
|
384605
|
+
return result2;
|
|
384546
384606
|
} catch (error) {
|
|
384547
384607
|
throw new Error(`\u547D\u4EE4\u6267\u884C\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`);
|
|
384548
384608
|
}
|
|
384549
384609
|
}), { retry: commandData.retry, delay: 1e3 });
|
|
384610
|
+
if (!result) {
|
|
384611
|
+
return {
|
|
384612
|
+
success: false,
|
|
384613
|
+
output: "",
|
|
384614
|
+
error: "\u547D\u4EE4\u6267\u884C\u5931\u8D25",
|
|
384615
|
+
duration: 0
|
|
384616
|
+
};
|
|
384617
|
+
}
|
|
384618
|
+
return result;
|
|
384550
384619
|
});
|
|
384551
384620
|
}
|
|
384552
384621
|
executeCode(agentCode, timeout2) {
|
|
@@ -384572,7 +384641,7 @@ var require_shellx = __commonJS({
|
|
|
384572
384641
|
getAppInfo(appInfoData) {
|
|
384573
384642
|
return __awaiter(this, void 0, void 0, function* () {
|
|
384574
384643
|
const startTime = Date.now();
|
|
384575
|
-
|
|
384644
|
+
const result = yield this.withRetry(() => __awaiter(this, void 0, void 0, function* () {
|
|
384576
384645
|
try {
|
|
384577
384646
|
const action = {
|
|
384578
384647
|
title: `\u83B7\u53D6\u5E94\u7528\u4FE1\u606F: ${appInfoData.package}`,
|
|
@@ -384591,6 +384660,14 @@ var require_shellx = __commonJS({
|
|
|
384591
384660
|
throw new Error(`\u83B7\u53D6\u5E94\u7528\u4FE1\u606F\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`);
|
|
384592
384661
|
}
|
|
384593
384662
|
}), { retry: appInfoData.retry, delay: 500 });
|
|
384663
|
+
if (!result) {
|
|
384664
|
+
return {
|
|
384665
|
+
success: false,
|
|
384666
|
+
error: "\u83B7\u53D6\u5E94\u7528\u4FE1\u606F\u5931\u8D25",
|
|
384667
|
+
duration: Date.now() - startTime
|
|
384668
|
+
};
|
|
384669
|
+
}
|
|
384670
|
+
return result;
|
|
384594
384671
|
});
|
|
384595
384672
|
}
|
|
384596
384673
|
/**
|
|
@@ -384599,7 +384676,7 @@ var require_shellx = __commonJS({
|
|
|
384599
384676
|
takeScreenshot() {
|
|
384600
384677
|
return __awaiter(this, arguments, void 0, function* (screenshotData = {}) {
|
|
384601
384678
|
const startTime = Date.now();
|
|
384602
|
-
|
|
384679
|
+
const result = yield this.withRetry(() => __awaiter(this, void 0, void 0, function* () {
|
|
384603
384680
|
try {
|
|
384604
384681
|
const options3 = {
|
|
384605
384682
|
format: screenshotData.format || "png",
|
|
@@ -384615,6 +384692,9 @@ var require_shellx = __commonJS({
|
|
|
384615
384692
|
};
|
|
384616
384693
|
}
|
|
384617
384694
|
const screenshot = yield this.client.screenShot(options3);
|
|
384695
|
+
if (!screenshot || screenshot.success === false) {
|
|
384696
|
+
throw new Error((screenshot === null || screenshot === void 0 ? void 0 : screenshot.errorMessage) || "\u622A\u56FE\u5931\u8D25");
|
|
384697
|
+
}
|
|
384618
384698
|
return {
|
|
384619
384699
|
success: true,
|
|
384620
384700
|
data: screenshot,
|
|
@@ -384624,6 +384704,14 @@ var require_shellx = __commonJS({
|
|
|
384624
384704
|
throw new Error(`\u622A\u56FE\u64CD\u4F5C\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`);
|
|
384625
384705
|
}
|
|
384626
384706
|
}), { retry: screenshotData.retry, delay: 500 });
|
|
384707
|
+
if (!result) {
|
|
384708
|
+
return {
|
|
384709
|
+
success: false,
|
|
384710
|
+
error: "\u622A\u56FE\u64CD\u4F5C\u5931\u8D25",
|
|
384711
|
+
duration: Date.now() - startTime
|
|
384712
|
+
};
|
|
384713
|
+
}
|
|
384714
|
+
return result;
|
|
384627
384715
|
});
|
|
384628
384716
|
}
|
|
384629
384717
|
/**
|
|
@@ -384667,9 +384755,10 @@ var require_shellx = __commonJS({
|
|
|
384667
384755
|
}
|
|
384668
384756
|
results.push(result);
|
|
384669
384757
|
if (!result.success) {
|
|
384670
|
-
|
|
384758
|
+
console.warn(`\u26A0\uFE0F [Actions] \u7B2C ${index + 1} \u4E2A\u64CD\u4F5C\u5931\u8D25: ${result.error}`);
|
|
384759
|
+
} else {
|
|
384760
|
+
console.log(`\u2705 [Actions] \u7B2C ${index + 1} \u4E2A\u64CD\u4F5C\u6267\u884C\u6210\u529F`);
|
|
384671
384761
|
}
|
|
384672
|
-
console.log(`\u2705 [Actions] \u7B2C ${index + 1} \u4E2A\u64CD\u4F5C\u6267\u884C\u6210\u529F`);
|
|
384673
384762
|
} catch (error) {
|
|
384674
384763
|
const errorResult = {
|
|
384675
384764
|
success: false,
|
|
@@ -384678,7 +384767,6 @@ var require_shellx = __commonJS({
|
|
|
384678
384767
|
};
|
|
384679
384768
|
results.push(errorResult);
|
|
384680
384769
|
console.error(`\u274C [Actions] \u7B2C ${index + 1} \u4E2A\u64CD\u4F5C\u6267\u884C\u5931\u8D25:`, error);
|
|
384681
|
-
throw error;
|
|
384682
384770
|
}
|
|
384683
384771
|
}
|
|
384684
384772
|
return results;
|
|
@@ -385551,11 +385639,7 @@ var require_dist6 = __commonJS({
|
|
|
385551
385639
|
if (shouldResolve) {
|
|
385552
385640
|
clearTimeout(task.timer);
|
|
385553
385641
|
this.pendingTasks.delete(taskId);
|
|
385554
|
-
|
|
385555
|
-
task.reject(new Error(responseData.errorMessage || "Task failed"));
|
|
385556
|
-
} else {
|
|
385557
|
-
task.resolve(responseData);
|
|
385558
|
-
}
|
|
385642
|
+
task.resolve(responseData);
|
|
385559
385643
|
break;
|
|
385560
385644
|
}
|
|
385561
385645
|
}
|
|
@@ -385567,7 +385651,8 @@ var require_dist6 = __commonJS({
|
|
|
385567
385651
|
if (taskType) {
|
|
385568
385652
|
const timer = setTimeout(() => {
|
|
385569
385653
|
this.pendingTasks.delete(taskId);
|
|
385570
|
-
|
|
385654
|
+
console.log(`\u23F0 [ShellX] \u4EFB\u52A1\u8D85\u65F6: ${taskType}, \u8FD4\u56DE undefined`);
|
|
385655
|
+
resolve23(void 0);
|
|
385571
385656
|
}, timeout2 ? timeout2 : this.config.timeout);
|
|
385572
385657
|
this.pendingTasks.set(taskId, {
|
|
385573
385658
|
resolve: resolve23,
|
|
@@ -385587,7 +385672,8 @@ var require_dist6 = __commonJS({
|
|
|
385587
385672
|
if (taskType) {
|
|
385588
385673
|
this.pendingTasks.delete(taskId);
|
|
385589
385674
|
}
|
|
385590
|
-
|
|
385675
|
+
console.log(`\u274C [ShellX] \u53D1\u9001\u6D88\u606F\u5931\u8D25\uFF0C\u8FD4\u56DE undefined:`, error);
|
|
385676
|
+
resolve23(void 0);
|
|
385591
385677
|
}
|
|
385592
385678
|
} else {
|
|
385593
385679
|
console.log("\u23F3 [ShellX] \u8FDE\u63A5\u672A\u5C31\u7EEA\uFF0C\u6D88\u606F\u5DF2\u52A0\u5165\u961F\u5217");
|
|
@@ -434704,7 +434790,7 @@ async function getPackageJson() {
|
|
|
434704
434790
|
// packages/cli/src/utils/version.ts
|
|
434705
434791
|
async function getCliVersion() {
|
|
434706
434792
|
const pkgJson = await getPackageJson();
|
|
434707
|
-
return "0.0.
|
|
434793
|
+
return "0.0.11";
|
|
434708
434794
|
}
|
|
434709
434795
|
|
|
434710
434796
|
// packages/cli/src/ui/commands/aboutCommand.ts
|