@swmansion/argent 0.35.1-next.17 → 0.35.1-next.18
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/cli-cmds.mjs +1 -1
- package/dist/installer.mjs +1 -1
- package/dist/mcp-server.mjs +1 -1
- package/dist/tool-args.generated.d.ts +3 -1
- package/dist/tool-server.cjs +637 -501
- package/package.json +2 -2
package/dist/tool-server.cjs
CHANGED
|
@@ -72957,7 +72957,7 @@ function isCi(env = process.env) {
|
|
|
72957
72957
|
var SESSION_ID = (0, import_node_crypto3.randomUUID)();
|
|
72958
72958
|
function readCliVersion() {
|
|
72959
72959
|
if (true) {
|
|
72960
|
-
return "0.35.1-next.
|
|
72960
|
+
return "0.35.1-next.18";
|
|
72961
72961
|
}
|
|
72962
72962
|
return "0.0.0";
|
|
72963
72963
|
}
|
|
@@ -139261,7 +139261,91 @@ init_zod();
|
|
|
139261
139261
|
init_src2();
|
|
139262
139262
|
init_capability();
|
|
139263
139263
|
|
|
139264
|
-
// ../tool-server/src/tools/keyboard/
|
|
139264
|
+
// ../tool-server/src/tools/keyboard/platforms/ios.ts
|
|
139265
|
+
init_src2();
|
|
139266
|
+
init_capability();
|
|
139267
|
+
|
|
139268
|
+
// ../tool-server/src/tools/fill/errors.ts
|
|
139269
|
+
init_src2();
|
|
139270
|
+
init_capability();
|
|
139271
|
+
function noFocusedFieldError(stage) {
|
|
139272
|
+
return new InvalidToolInputError(
|
|
139273
|
+
"Nothing that takes text has keyboard focus, so nothing was changed. Tap the text field first, then call fill again.",
|
|
139274
|
+
{
|
|
139275
|
+
error_code: FAILURE_CODES.FILL_NO_FOCUSED_FIELD,
|
|
139276
|
+
failure_stage: stage,
|
|
139277
|
+
error_kind: "validation"
|
|
139278
|
+
}
|
|
139279
|
+
);
|
|
139280
|
+
}
|
|
139281
|
+
function notVerifiedError(stage) {
|
|
139282
|
+
return new FailureError(
|
|
139283
|
+
"fill wrote to the focused field, but reading it back did not show the requested text. The field may hold other or partial text: read it before retrying.",
|
|
139284
|
+
{
|
|
139285
|
+
error_code: FAILURE_CODES.FILL_NOT_VERIFIED,
|
|
139286
|
+
failure_stage: stage,
|
|
139287
|
+
failure_area: "tool_server",
|
|
139288
|
+
error_kind: "unknown"
|
|
139289
|
+
}
|
|
139290
|
+
);
|
|
139291
|
+
}
|
|
139292
|
+
function notChangedError(stage) {
|
|
139293
|
+
return new FailureError(
|
|
139294
|
+
"fill could not select the text of the focused field, so nothing was changed. Tap the field and retry.",
|
|
139295
|
+
{
|
|
139296
|
+
error_code: FAILURE_CODES.FILL_NOT_VERIFIED,
|
|
139297
|
+
failure_stage: stage,
|
|
139298
|
+
failure_area: "tool_server",
|
|
139299
|
+
error_kind: "unknown"
|
|
139300
|
+
}
|
|
139301
|
+
);
|
|
139302
|
+
}
|
|
139303
|
+
function notAnsweredError(stage) {
|
|
139304
|
+
return new FailureError(
|
|
139305
|
+
"The device did not finish the fill in time. The field may have changed: read it before retrying.",
|
|
139306
|
+
{
|
|
139307
|
+
error_code: FAILURE_CODES.FILL_NOT_VERIFIED,
|
|
139308
|
+
failure_stage: stage,
|
|
139309
|
+
failure_area: "tool_server",
|
|
139310
|
+
error_kind: "timeout"
|
|
139311
|
+
}
|
|
139312
|
+
);
|
|
139313
|
+
}
|
|
139314
|
+
function pageNotAnsweringError(stage, waitedMs) {
|
|
139315
|
+
return new FailureError(
|
|
139316
|
+
`The page did not answer for ${waitedMs / 1e3} s, so fill changed nothing. A JavaScript dialog (alert, confirm or prompt) may be open, or the page is busy or has crashed. Argent cannot close a dialog: ask the user to close it, then retry. A retry fills a busy page once its task ends. If no dialog is open and it still does not answer, restart the app.`,
|
|
139317
|
+
{
|
|
139318
|
+
error_code: FAILURE_CODES.FILL_NOT_VERIFIED,
|
|
139319
|
+
failure_stage: stage,
|
|
139320
|
+
failure_area: "tool_server",
|
|
139321
|
+
error_kind: "timeout"
|
|
139322
|
+
}
|
|
139323
|
+
);
|
|
139324
|
+
}
|
|
139325
|
+
function pageNotFinishedError(stage) {
|
|
139326
|
+
return new FailureError(
|
|
139327
|
+
"The page did not finish the fill in time; it may have opened a JavaScript dialog or crashed. The field may have changed, and may still change when the page resumes: read it before retrying. If the page does not answer and no dialog is open, restart the app.",
|
|
139328
|
+
{
|
|
139329
|
+
error_code: FAILURE_CODES.FILL_NOT_VERIFIED,
|
|
139330
|
+
failure_stage: stage,
|
|
139331
|
+
failure_area: "tool_server",
|
|
139332
|
+
error_kind: "timeout"
|
|
139333
|
+
}
|
|
139334
|
+
);
|
|
139335
|
+
}
|
|
139336
|
+
function unsupportedFieldError(detail, stage) {
|
|
139337
|
+
return new InvalidToolInputError(
|
|
139338
|
+
`fill cannot set this field's text: ${detail}. Nothing was changed.`,
|
|
139339
|
+
{
|
|
139340
|
+
error_code: FAILURE_CODES.FILL_UNSUPPORTED_FIELD,
|
|
139341
|
+
failure_stage: stage,
|
|
139342
|
+
error_kind: "unsupported"
|
|
139343
|
+
}
|
|
139344
|
+
);
|
|
139345
|
+
}
|
|
139346
|
+
|
|
139347
|
+
// ../tool-server/src/tools/fill/keys.ts
|
|
139348
|
+
init_src2();
|
|
139265
139349
|
init_src2();
|
|
139266
139350
|
|
|
139267
139351
|
// ../tool-server/src/tools/keyboard/key-codes.ts
|
|
@@ -139351,6 +139435,7 @@ function charToKeyPress(char) {
|
|
|
139351
139435
|
}
|
|
139352
139436
|
|
|
139353
139437
|
// ../tool-server/src/tools/keyboard/simulator-server-keys.ts
|
|
139438
|
+
init_src2();
|
|
139354
139439
|
init_capability();
|
|
139355
139440
|
var sleep10 = (ms3) => new Promise((r) => setTimeout(r, ms3));
|
|
139356
139441
|
var KEY_HOLD = { ms: 20 };
|
|
@@ -139408,6 +139493,118 @@ async function typeSimulatorServer(registry2, device, params) {
|
|
|
139408
139493
|
return { typed: params.text ?? params.key ?? "", keys: keysPressed };
|
|
139409
139494
|
}
|
|
139410
139495
|
|
|
139496
|
+
// ../tool-server/src/tools/fill/keys.ts
|
|
139497
|
+
var MAX_CLEAR_KEYS = 100;
|
|
139498
|
+
var XCTEST_DELETE = "\b";
|
|
139499
|
+
var KEY_TIMING = { holdMs: 20, settleMs: 300, typeDelayMs: 30 };
|
|
139500
|
+
var sleep11 = (ms3) => new Promise((r) => setTimeout(r, ms3));
|
|
139501
|
+
function typeableOnSimulator(text) {
|
|
139502
|
+
for (const char of text) if (!charToKeyPress(char)) return false;
|
|
139503
|
+
return true;
|
|
139504
|
+
}
|
|
139505
|
+
async function withoutTextInErrors(stage, run2) {
|
|
139506
|
+
try {
|
|
139507
|
+
return await run2();
|
|
139508
|
+
} catch (err) {
|
|
139509
|
+
const signal = getFailureSignal(err);
|
|
139510
|
+
throw new FailureError(
|
|
139511
|
+
"fill failed partway through typing: the focused field may hold part of the text. Read it before retrying.",
|
|
139512
|
+
signal ?? {
|
|
139513
|
+
error_code: FAILURE_CODES.FILL_NOT_VERIFIED,
|
|
139514
|
+
failure_stage: stage,
|
|
139515
|
+
failure_area: "tool_server",
|
|
139516
|
+
error_kind: "unknown"
|
|
139517
|
+
}
|
|
139518
|
+
);
|
|
139519
|
+
}
|
|
139520
|
+
}
|
|
139521
|
+
async function pressSimulatorBackspace(registry2, device) {
|
|
139522
|
+
const ref = simulatorServerRef(device);
|
|
139523
|
+
const api = await registry2.resolveService(ref.urn, ref.options);
|
|
139524
|
+
await api.pressKey("Down", NAMED_KEYS.backspace);
|
|
139525
|
+
await sleep11(KEY_TIMING.holdMs);
|
|
139526
|
+
await api.pressKey("Up", NAMED_KEYS.backspace);
|
|
139527
|
+
await sleep11(KEY_TIMING.settleMs);
|
|
139528
|
+
}
|
|
139529
|
+
async function typeOnSimulator(registry2, device, text) {
|
|
139530
|
+
if (!text) return;
|
|
139531
|
+
await withoutTextInErrors(
|
|
139532
|
+
"fill_keys_ios",
|
|
139533
|
+
() => typeSimulatorServer(registry2, device, {
|
|
139534
|
+
udid: device.id,
|
|
139535
|
+
text,
|
|
139536
|
+
delayMs: KEY_TIMING.typeDelayMs
|
|
139537
|
+
})
|
|
139538
|
+
);
|
|
139539
|
+
}
|
|
139540
|
+
async function fillByDeviceKeys(registry2, device, text) {
|
|
139541
|
+
const bundleId = requireCurrentIosDeviceApp(device.id);
|
|
139542
|
+
const ref = iosDeviceRunnerRef(device);
|
|
139543
|
+
const api = await registry2.resolveService(ref.urn, ref.options);
|
|
139544
|
+
const type = async (chars) => {
|
|
139545
|
+
try {
|
|
139546
|
+
return await typeText(api, bundleId, chars);
|
|
139547
|
+
} catch (err) {
|
|
139548
|
+
if (err instanceof RunnerCommandError && err.code === "TEXT_INPUT_NOT_FOCUSED") {
|
|
139549
|
+
throw noFocusedFieldError("fill_keys_ios_device_focus");
|
|
139550
|
+
}
|
|
139551
|
+
throw err;
|
|
139552
|
+
}
|
|
139553
|
+
};
|
|
139554
|
+
let reactivated = false;
|
|
139555
|
+
const cleared = await type(XCTEST_DELETE.repeat(MAX_CLEAR_KEYS));
|
|
139556
|
+
reactivated ||= cleared.reactivated;
|
|
139557
|
+
if (text) {
|
|
139558
|
+
const typed = await withoutTextInErrors("fill_keys_ios_device", () => type(text));
|
|
139559
|
+
reactivated ||= typed.reactivated;
|
|
139560
|
+
}
|
|
139561
|
+
return { reactivated };
|
|
139562
|
+
}
|
|
139563
|
+
|
|
139564
|
+
// ../tool-server/src/tools/fill/ios.ts
|
|
139565
|
+
var NEWLINE = /[\r\n]/;
|
|
139566
|
+
async function fillIos(registry2, device, text) {
|
|
139567
|
+
const ref = axServiceRef(device);
|
|
139568
|
+
const ax = await registry2.resolveService(ref.urn, ref.options);
|
|
139569
|
+
const typeable = typeableOnSimulator(text) && !NEWLINE.test(text);
|
|
139570
|
+
const first = await ax.fill(text, { typeable });
|
|
139571
|
+
if (!first.focused) throw noFocusedFieldError("fill_ios_no_focus");
|
|
139572
|
+
if (first.unsupported) {
|
|
139573
|
+
throw unsupportedFieldError(
|
|
139574
|
+
"the focused element is not a text input (a date or time input, or a picker)",
|
|
139575
|
+
"fill_ios_unsupported_field"
|
|
139576
|
+
);
|
|
139577
|
+
}
|
|
139578
|
+
if (first.singleLine) {
|
|
139579
|
+
throw unsupportedFieldError(
|
|
139580
|
+
"a single-line text field cannot hold a newline",
|
|
139581
|
+
"fill_ios_single_line"
|
|
139582
|
+
);
|
|
139583
|
+
}
|
|
139584
|
+
if (first.timedOut) throw notAnsweredError("fill_ios_timeout");
|
|
139585
|
+
if (first.untouched) throw notChangedError("fill_ios_select_failed");
|
|
139586
|
+
if (first.verified) return { verified: true };
|
|
139587
|
+
if (first.secure) {
|
|
139588
|
+
if (!typeable) {
|
|
139589
|
+
throw unsupportedFieldError(
|
|
139590
|
+
"a secure text field takes only text the keyboard can type on one line, and this text has a character it cannot",
|
|
139591
|
+
"fill_ios_secure_untypeable"
|
|
139592
|
+
);
|
|
139593
|
+
}
|
|
139594
|
+
if (!first.cleared) throw notVerifiedError("fill_ios_secure_not_cleared");
|
|
139595
|
+
await typeOnSimulator(registry2, device, text);
|
|
139596
|
+
const check3 = await ax.fill(text, { check: true });
|
|
139597
|
+
if (check3.verified) return { verified: true };
|
|
139598
|
+
throw notVerifiedError("fill_ios_not_verified");
|
|
139599
|
+
}
|
|
139600
|
+
if (first.needsBackspace) {
|
|
139601
|
+
await pressSimulatorBackspace(registry2, device);
|
|
139602
|
+
const check3 = await ax.fill(text, { check: true });
|
|
139603
|
+
if (check3.verified) return { verified: true };
|
|
139604
|
+
}
|
|
139605
|
+
throw notVerifiedError("fill_ios_not_verified");
|
|
139606
|
+
}
|
|
139607
|
+
|
|
139411
139608
|
// ../tool-server/src/tools/keyboard/ios-readback.ts
|
|
139412
139609
|
var READBACK_TIMING = {
|
|
139413
139610
|
/** Budget to reach the ax-service; past it, typing goes on unchecked. */
|
|
@@ -139532,6 +139729,13 @@ function capitalizedByIos(typed, held) {
|
|
|
139532
139729
|
// ../tool-server/src/tools/keyboard/platforms/tv.ts
|
|
139533
139730
|
init_capability();
|
|
139534
139731
|
async function typeTv(registry2, device, params) {
|
|
139732
|
+
if (params.clear) {
|
|
139733
|
+
throw new UnsupportedOperationError(
|
|
139734
|
+
"keyboard",
|
|
139735
|
+
device,
|
|
139736
|
+
"clearing a field with `clear: true` is not supported on a TV target"
|
|
139737
|
+
);
|
|
139738
|
+
}
|
|
139535
139739
|
if (params.key) {
|
|
139536
139740
|
throw new UnsupportedOperationError(
|
|
139537
139741
|
"keyboard",
|
|
@@ -139549,13 +139753,34 @@ async function typeTv(registry2, device, params) {
|
|
|
139549
139753
|
|
|
139550
139754
|
// ../tool-server/src/tools/keyboard/platforms/ios.ts
|
|
139551
139755
|
async function typeAndReadBack(registry2, device, params) {
|
|
139756
|
+
if (params.clear) {
|
|
139757
|
+
if (params.text) {
|
|
139758
|
+
for (const char of params.text) {
|
|
139759
|
+
if (!charToKeyPress(char)) {
|
|
139760
|
+
throw new InvalidToolInputError(`No keycode for character "${char}"`, {
|
|
139761
|
+
error_code: FAILURE_CODES.KEYBOARD_CHARACTER_UNSUPPORTED,
|
|
139762
|
+
failure_stage: "keyboard_char_simulator",
|
|
139763
|
+
error_kind: "unsupported"
|
|
139764
|
+
});
|
|
139765
|
+
}
|
|
139766
|
+
}
|
|
139767
|
+
}
|
|
139768
|
+
await fillIos(registry2, device, "");
|
|
139769
|
+
if (!params.text && !params.key) {
|
|
139770
|
+
return { typed: "", keys: 0, cleared: true };
|
|
139771
|
+
}
|
|
139772
|
+
}
|
|
139552
139773
|
const { result, readback } = await typeWithReadback(
|
|
139553
139774
|
registry2,
|
|
139554
139775
|
device,
|
|
139555
139776
|
params.text ?? "",
|
|
139556
139777
|
() => typeSimulatorServer(registry2, device, params)
|
|
139557
139778
|
);
|
|
139558
|
-
return
|
|
139779
|
+
return {
|
|
139780
|
+
...result,
|
|
139781
|
+
...params.clear ? { cleared: true } : {},
|
|
139782
|
+
...readback ?? {}
|
|
139783
|
+
};
|
|
139559
139784
|
}
|
|
139560
139785
|
function makeIosImpl3(registry2) {
|
|
139561
139786
|
return {
|
|
@@ -139564,7 +139789,16 @@ function makeIosImpl3(registry2) {
|
|
|
139564
139789
|
}
|
|
139565
139790
|
function makeIosRemoteImpl(registry2) {
|
|
139566
139791
|
return {
|
|
139567
|
-
handler: async (_services, params, device) =>
|
|
139792
|
+
handler: async (_services, params, device) => {
|
|
139793
|
+
if (params.clear && await isRemoteTvOsSimulator(device.id)) {
|
|
139794
|
+
throw new UnsupportedOperationError(
|
|
139795
|
+
"keyboard",
|
|
139796
|
+
device,
|
|
139797
|
+
"clearing a field with `clear: true` is not supported on a TV target"
|
|
139798
|
+
);
|
|
139799
|
+
}
|
|
139800
|
+
return typeAndReadBack(registry2, device, params);
|
|
139801
|
+
}
|
|
139568
139802
|
};
|
|
139569
139803
|
}
|
|
139570
139804
|
|
|
@@ -139603,17 +139837,28 @@ function makeIosDeviceImpl(registry2) {
|
|
|
139603
139837
|
}
|
|
139604
139838
|
);
|
|
139605
139839
|
}
|
|
139606
|
-
if (!params.text && !key2) {
|
|
139840
|
+
if (!params.text && !key2 && !params.clear) {
|
|
139607
139841
|
return {
|
|
139608
139842
|
typed: "",
|
|
139609
139843
|
keys: 0
|
|
139610
139844
|
};
|
|
139611
139845
|
}
|
|
139846
|
+
let keys = 0;
|
|
139847
|
+
let reactivated = false;
|
|
139848
|
+
if (params.clear) {
|
|
139849
|
+
const cleared = await fillByDeviceKeys(registry2, device, "");
|
|
139850
|
+
reactivated ||= cleared.reactivated;
|
|
139851
|
+
if (!params.text) {
|
|
139852
|
+
return {
|
|
139853
|
+
typed: "",
|
|
139854
|
+
keys: 0,
|
|
139855
|
+
...reactivated ? { reactivated: true } : {}
|
|
139856
|
+
};
|
|
139857
|
+
}
|
|
139858
|
+
}
|
|
139612
139859
|
const bundleId = requireCurrentIosDeviceApp(device.id);
|
|
139613
139860
|
const ref = iosDeviceRunnerRef(device);
|
|
139614
139861
|
const api = await registry2.resolveService(ref.urn, ref.options);
|
|
139615
|
-
let keys = 0;
|
|
139616
|
-
let reactivated = false;
|
|
139617
139862
|
if (params.text) {
|
|
139618
139863
|
const typed = await mapNotFocused(typeText(api, bundleId, params.text));
|
|
139619
139864
|
reactivated ||= typed.reactivated;
|
|
@@ -139645,7 +139890,30 @@ function makeIosDeviceImpl(registry2) {
|
|
|
139645
139890
|
|
|
139646
139891
|
// ../tool-server/src/tools/keyboard/platforms/android.ts
|
|
139647
139892
|
init_adb();
|
|
139648
|
-
|
|
139893
|
+
|
|
139894
|
+
// ../tool-server/src/tools/fill/android.ts
|
|
139895
|
+
async function fillAndroid(registry2, device, text) {
|
|
139896
|
+
const ref = androidDevtoolsRef(device);
|
|
139897
|
+
const helper = await registry2.resolveService(ref.urn, ref.options);
|
|
139898
|
+
const answer = await helper.setText(text);
|
|
139899
|
+
if (!answer.focused) throw noFocusedFieldError("fill_android_no_focus");
|
|
139900
|
+
if (answer.singleLine) {
|
|
139901
|
+
throw unsupportedFieldError(
|
|
139902
|
+
"a single-line text field cannot hold a newline",
|
|
139903
|
+
"fill_android_single_line"
|
|
139904
|
+
);
|
|
139905
|
+
}
|
|
139906
|
+
if (answer.timedOut) throw notAnsweredError("fill_android_timeout");
|
|
139907
|
+
if (answer.verified) return { verified: true };
|
|
139908
|
+
throw notVerifiedError("fill_android_not_verified");
|
|
139909
|
+
}
|
|
139910
|
+
|
|
139911
|
+
// ../tool-server/src/tools/keyboard/platforms/android.ts
|
|
139912
|
+
async function typeAndroidPhone(registry2, device, params) {
|
|
139913
|
+
if (params.clear) {
|
|
139914
|
+
if (params.text) assertTypeableAndroidText(params.text);
|
|
139915
|
+
await fillAndroid(registry2, device, "");
|
|
139916
|
+
}
|
|
139649
139917
|
let keysPressed = 0;
|
|
139650
139918
|
if (params.text) {
|
|
139651
139919
|
await injectAndroidText(device.id, params.text);
|
|
@@ -139656,7 +139924,11 @@ async function typeAndroidPhone(device, params) {
|
|
|
139656
139924
|
await injectAndroidNamedKey(device.id, params.key, count2);
|
|
139657
139925
|
keysPressed += count2;
|
|
139658
139926
|
}
|
|
139659
|
-
return {
|
|
139927
|
+
return {
|
|
139928
|
+
typed: params.text ?? params.key ?? "",
|
|
139929
|
+
keys: keysPressed,
|
|
139930
|
+
...params.clear ? { cleared: true } : {}
|
|
139931
|
+
};
|
|
139660
139932
|
}
|
|
139661
139933
|
function makeAndroidImpl(registry2) {
|
|
139662
139934
|
return {
|
|
@@ -139664,7 +139936,7 @@ function makeAndroidImpl(registry2) {
|
|
|
139664
139936
|
// either way), so declaring it makes a missing binary fail with
|
|
139665
139937
|
// `dispatchByPlatform`'s 424 install hint instead of from inside the probe.
|
|
139666
139938
|
requires: ["adb"],
|
|
139667
|
-
handler: async (_services, params, device) => await isAndroidTv(device.id) ? typeTv(registry2, device, params) : typeAndroidPhone(device, params)
|
|
139939
|
+
handler: async (_services, params, device) => await isAndroidTv(device.id) ? typeTv(registry2, device, params) : typeAndroidPhone(registry2, device, params)
|
|
139668
139940
|
};
|
|
139669
139941
|
}
|
|
139670
139942
|
|
|
@@ -139672,6 +139944,259 @@ function makeAndroidImpl(registry2) {
|
|
|
139672
139944
|
init_src2();
|
|
139673
139945
|
init_capability();
|
|
139674
139946
|
|
|
139947
|
+
// ../tool-server/src/tools/fill/chromium.ts
|
|
139948
|
+
init_src2();
|
|
139949
|
+
function buildChromiumFillScript(text) {
|
|
139950
|
+
return `(async () => {
|
|
139951
|
+
const text = ${JSON.stringify(text)};
|
|
139952
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
139953
|
+
try {
|
|
139954
|
+
const deepActive = (doc) => {
|
|
139955
|
+
let el = doc.activeElement;
|
|
139956
|
+
while (el && el.shadowRoot && el.shadowRoot.activeElement) el = el.shadowRoot.activeElement;
|
|
139957
|
+
return el;
|
|
139958
|
+
};
|
|
139959
|
+
let el = deepActive(document);
|
|
139960
|
+
while (el && /^(i?frame|object)$/.test(String(el.tagName).toLowerCase())) {
|
|
139961
|
+
// An <object> showing an image or a plugin has no document to descend into.
|
|
139962
|
+
if (!el.contentWindow) break;
|
|
139963
|
+
let inner = null;
|
|
139964
|
+
try { inner = el.contentDocument; } catch (e) { inner = null; }
|
|
139965
|
+
// A cross-origin or sandboxed frame hides its document.
|
|
139966
|
+
if (!inner) return { status: "unsupported", detail: "focus is in a cross-origin frame, which fill cannot reach" };
|
|
139967
|
+
el = deepActive(inner);
|
|
139968
|
+
}
|
|
139969
|
+
if (!el || el.tagName === undefined) return { status: "no_focus" };
|
|
139970
|
+
const doc = el.ownerDocument || document;
|
|
139971
|
+
const win = doc.defaultView || window;
|
|
139972
|
+
const tag = String(el.tagName).toLowerCase();
|
|
139973
|
+
if (tag === "embed") return { status: "unsupported", detail: "focus is in an <embed>, which fill cannot reach" };
|
|
139974
|
+
const type = tag === "input" ? String(el.type || "text").toLowerCase() : null;
|
|
139975
|
+
if (type !== null && /^(date|time|month|week|datetime-local)$/.test(type)) {
|
|
139976
|
+
return { status: "unsupported", detail: "a " + type + " input holds a structured value" };
|
|
139977
|
+
}
|
|
139978
|
+
const control =
|
|
139979
|
+
tag === "textarea" ||
|
|
139980
|
+
(tag === "input" && !/^(button|checkbox|radio|file|submit|reset|image|range|color|hidden)$/.test(type));
|
|
139981
|
+
if (!control) {
|
|
139982
|
+
// Focus in a closed shadow root stops at its host. An element that can
|
|
139983
|
+
// host one is focusable itself only as a tab stop, an editing host or a
|
|
139984
|
+
// box the user can scroll; one with focus that is none of these, or whose
|
|
139985
|
+
// selection is in its shadow tree, holds it in a closed shadow root. The
|
|
139986
|
+
// browser shows such a selection collapsed before the host, or in place
|
|
139987
|
+
// when the page set it there, even in an editing host's own text. In a
|
|
139988
|
+
// focused page, which :focus needs, an editing host focused itself
|
|
139989
|
+
// matches :focus-visible; one whose focus is in its shadow tree does not.
|
|
139990
|
+
const scrolls = (style) =>
|
|
139991
|
+
(/^(auto|scroll)$/.test(style.overflowY) && el.scrollHeight > el.clientHeight) ||
|
|
139992
|
+
(/^(auto|scroll)$/.test(style.overflowX) && el.scrollWidth > el.clientWidth);
|
|
139993
|
+
const inShadow = (node, offset) => {
|
|
139994
|
+
if (node == null) return false;
|
|
139995
|
+
if (node === el.parentNode && node.childNodes[offset] === el) return true;
|
|
139996
|
+
for (let root = node.getRootNode(); root.host; root = root.host.getRootNode()) if (root.host === el) return true;
|
|
139997
|
+
return false;
|
|
139998
|
+
};
|
|
139999
|
+
const selectionInShadow = () => {
|
|
140000
|
+
if (el.shadowRoot) return false;
|
|
140001
|
+
const sel = el.getRootNode().getSelection();
|
|
140002
|
+
return inShadow(sel.anchorNode, sel.anchorOffset) && inShadow(sel.focusNode, sel.focusOffset);
|
|
140003
|
+
};
|
|
140004
|
+
const focusInShadow = () => {
|
|
140005
|
+
if (el.isContentEditable !== true) return false;
|
|
140006
|
+
try {
|
|
140007
|
+
return el.matches(":focus") && !el.matches(":focus-visible");
|
|
140008
|
+
} catch (e) {
|
|
140009
|
+
// Chromium before 86 has no :focus-visible.
|
|
140010
|
+
return false;
|
|
140011
|
+
}
|
|
140012
|
+
};
|
|
140013
|
+
const closedHost =
|
|
140014
|
+
/-|^(article|aside|blockquote|div|footer|h[1-6]|header|main|nav|p|section|span)$/.test(tag) &&
|
|
140015
|
+
((!el.hasAttribute("tabindex") &&
|
|
140016
|
+
(el.isContentEditable !== true || (el.parentElement !== null && el.parentElement.isContentEditable === true)) &&
|
|
140017
|
+
!scrolls(win.getComputedStyle(el))) ||
|
|
140018
|
+
selectionInShadow() ||
|
|
140019
|
+
focusInShadow());
|
|
140020
|
+
if (closedHost) return { status: "unsupported", detail: "focus is in a closed shadow root, which fill cannot reach" };
|
|
140021
|
+
if (el.isContentEditable !== true) return { status: "no_focus" };
|
|
140022
|
+
}
|
|
140023
|
+
if (control && el.disabled === true) return { status: "unsupported", detail: "it is disabled" };
|
|
140024
|
+
if (control && el.readOnly === true) return { status: "unsupported", detail: "it is read-only" };
|
|
140025
|
+
// An <input> holds one line and drops a newline.
|
|
140026
|
+
if (tag === "input" && /[\\r\\n]/.test(text)) {
|
|
140027
|
+
return { status: "unsupported", detail: "a single-line input cannot hold a newline" };
|
|
140028
|
+
}
|
|
140029
|
+
// A textarea or an editable element stores a CR or CRLF as one LF.
|
|
140030
|
+
const want = text.replace(/\\r\\n?/g, "\\n");
|
|
140031
|
+
// Typed text stops at maxlength, which the value setter ignores.
|
|
140032
|
+
const limited = tag === "textarea" || /^(text|search|url|tel|email|password)$/.test(type);
|
|
140033
|
+
if (limited && el.maxLength >= 0 && want.length > el.maxLength) {
|
|
140034
|
+
return { status: "unsupported", detail: "the text is longer than its maxlength of " + el.maxLength };
|
|
140035
|
+
}
|
|
140036
|
+
// A number input holds only a valid number and an email input drops the
|
|
140037
|
+
// whitespace around an address, typed or set. A detached input of the
|
|
140038
|
+
// same type applies the browser's own sanitization; outside an HTML
|
|
140039
|
+
// document only the XHTML namespace makes it an input.
|
|
140040
|
+
if (type === "number" || type === "email") {
|
|
140041
|
+
const probe = doc.createElementNS("http://www.w3.org/1999/xhtml", "input");
|
|
140042
|
+
probe.type = type;
|
|
140043
|
+
probe.multiple = el.multiple === true;
|
|
140044
|
+
probe.value = text;
|
|
140045
|
+
if (probe.value !== text) {
|
|
140046
|
+
return {
|
|
140047
|
+
status: "unsupported",
|
|
140048
|
+
detail: type === "number" ? "a number input holds only a valid number" : "an email input drops the whitespace around an address",
|
|
140049
|
+
};
|
|
140050
|
+
}
|
|
140051
|
+
}
|
|
140052
|
+
if (!control) {
|
|
140053
|
+
// designMode or <body contenteditable>: the whole document is the field.
|
|
140054
|
+
let host = el;
|
|
140055
|
+
while (host.parentElement && host.parentElement.isContentEditable === true) host = host.parentElement;
|
|
140056
|
+
if (host === doc.body || host === doc.documentElement) {
|
|
140057
|
+
return { status: "unsupported", detail: "the whole document is editable" };
|
|
140058
|
+
}
|
|
140059
|
+
}
|
|
140060
|
+
const trimEnd = (s) => s.replace(/[\\u200b\\ufeff]/g, "").replace(/\\n+$/, "");
|
|
140061
|
+
const read = () =>
|
|
140062
|
+
control ? String(el.value == null ? "" : el.value) : trimEnd(String(el.innerText == null ? el.textContent || "" : el.innerText));
|
|
140063
|
+
// A number input showing text it cannot parse reads as "".
|
|
140064
|
+
const badInput = () => el.validity != null && el.validity.badInput === true;
|
|
140065
|
+
// Chrome stores an edited email address's non-ASCII domain in ASCII, by
|
|
140066
|
+
// UTS #46 transitional processing: the URL parser's, once its deviations
|
|
140067
|
+
// (\xDF, \u03C2, ZWNJ, ZWJ) are mapped.
|
|
140068
|
+
const asciiEmail = (a) => {
|
|
140069
|
+
const at = a.indexOf("@");
|
|
140070
|
+
if (at < 0 || !/[^\\x00-\\x7f]/.test(a)) return a;
|
|
140071
|
+
const host = a.slice(at + 1).replace(/[\\u00df\\u1e9e]/g, "ss").replace(/\\u03c2/g, "\\u03c3").replace(/[\\u200c\\u200d]/g, "");
|
|
140072
|
+
// A link parses its href with the URL parser even where a page's own URL
|
|
140073
|
+
// global shadows the builtin. The ".a" label keeps a numeric last label
|
|
140074
|
+
// from parsing as IPv4.
|
|
140075
|
+
const link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a");
|
|
140076
|
+
link.href = "http://" + host + ".a";
|
|
140077
|
+
// Unparsable, or not a bare host: it has a user, a port or a path.
|
|
140078
|
+
if (link.href !== "http://" + link.hostname + "/") return a;
|
|
140079
|
+
return a.slice(0, at + 1) + link.hostname.slice(0, -2);
|
|
140080
|
+
};
|
|
140081
|
+
const sameText = (got) => {
|
|
140082
|
+
if (type !== "email") return got === want;
|
|
140083
|
+
const split = (s) => (el.multiple === true ? s.split(",") : [s]);
|
|
140084
|
+
const wants = split(want);
|
|
140085
|
+
const gots = split(got);
|
|
140086
|
+
return gots.length === wants.length && gots.every((g, i) => g === wants[i] || g === asciiEmail(wants[i]));
|
|
140087
|
+
};
|
|
140088
|
+
const matches = () => (control ? sameText(read()) && !badInput() : read() === trimEnd(want));
|
|
140089
|
+
const settle = async () => {
|
|
140090
|
+
for (let i = 0; i < 10; i++) {
|
|
140091
|
+
await sleep(i === 0 ? 0 : 50);
|
|
140092
|
+
if (matches()) return true;
|
|
140093
|
+
}
|
|
140094
|
+
return false;
|
|
140095
|
+
};
|
|
140096
|
+
|
|
140097
|
+
const before = read();
|
|
140098
|
+
// The browser fires input synchronously for an edit it performed. The
|
|
140099
|
+
// window's capture phase sees it unless a page listener added there
|
|
140100
|
+
// earlier stops it.
|
|
140101
|
+
let edited = false;
|
|
140102
|
+
const onInput = () => { edited = true; };
|
|
140103
|
+
win.addEventListener("input", onInput, true);
|
|
140104
|
+
try {
|
|
140105
|
+
if (control) {
|
|
140106
|
+
try { el.select(); } catch (e) { /* no selection API */ }
|
|
140107
|
+
} else {
|
|
140108
|
+
const sel = doc.getSelection();
|
|
140109
|
+
const range = doc.createRange();
|
|
140110
|
+
range.selectNodeContents(el);
|
|
140111
|
+
sel.removeAllRanges();
|
|
140112
|
+
sel.addRange(range);
|
|
140113
|
+
}
|
|
140114
|
+
try {
|
|
140115
|
+
if (text === "") {
|
|
140116
|
+
if (read() !== "" || badInput()) doc.execCommand("delete");
|
|
140117
|
+
} else {
|
|
140118
|
+
doc.execCommand("insertText", false, text);
|
|
140119
|
+
}
|
|
140120
|
+
} catch (e) {
|
|
140121
|
+
// An SVG document has no editing commands; a control still has its setter.
|
|
140122
|
+
if (!control) throw e;
|
|
140123
|
+
}
|
|
140124
|
+
} finally {
|
|
140125
|
+
win.removeEventListener("input", onInput, true);
|
|
140126
|
+
}
|
|
140127
|
+
let verified = await settle();
|
|
140128
|
+
// An edit that did not happen fires no input and leaves the old text.
|
|
140129
|
+
// Anything else is the browser's or the page's own rewrite, which the
|
|
140130
|
+
// setter must not override, even when the rewrite equals the old text.
|
|
140131
|
+
if (!verified && control && !edited && read() === before) {
|
|
140132
|
+
const proto = tag === "textarea" ? win.HTMLTextAreaElement.prototype : win.HTMLInputElement.prototype;
|
|
140133
|
+
const setter = Object.getOwnPropertyDescriptor(proto, "value").set;
|
|
140134
|
+
setter.call(el, text);
|
|
140135
|
+
el.dispatchEvent(new win.Event("input", { bubbles: true }));
|
|
140136
|
+
el.dispatchEvent(new win.Event("change", { bubbles: true }));
|
|
140137
|
+
verified = await settle();
|
|
140138
|
+
}
|
|
140139
|
+
return { status: "ok", verified: verified };
|
|
140140
|
+
} catch (e) {
|
|
140141
|
+
return { status: "error" };
|
|
140142
|
+
}
|
|
140143
|
+
})()`;
|
|
140144
|
+
}
|
|
140145
|
+
var PAGE_ANSWER_TIMEOUT_MS = 1e4;
|
|
140146
|
+
var FILL_TIMEOUT_MS2 = 1e4;
|
|
140147
|
+
async function withTimeoutError(send, timeoutError) {
|
|
140148
|
+
try {
|
|
140149
|
+
return await send();
|
|
140150
|
+
} catch (err) {
|
|
140151
|
+
if (getFailureSignal(err)?.error_code === FAILURE_CODES.DEBUGGER_CDP_REQUEST_TIMEOUT) {
|
|
140152
|
+
throw timeoutError();
|
|
140153
|
+
}
|
|
140154
|
+
throw err;
|
|
140155
|
+
}
|
|
140156
|
+
}
|
|
140157
|
+
async function fillChromium(registry2, device, text) {
|
|
140158
|
+
const ref = chromiumCdpRef(device);
|
|
140159
|
+
const api = await withTimeoutError(
|
|
140160
|
+
() => registry2.resolveService(ref.urn, {
|
|
140161
|
+
...ref.options,
|
|
140162
|
+
answerTimeoutMs: PAGE_ANSWER_TIMEOUT_MS
|
|
140163
|
+
}),
|
|
140164
|
+
() => pageNotAnsweringError("fill_chromium_connect", PAGE_ANSWER_TIMEOUT_MS)
|
|
140165
|
+
);
|
|
140166
|
+
await withTimeoutError(
|
|
140167
|
+
() => api.cdp.send("Runtime.evaluate", { expression: "0" }, PAGE_ANSWER_TIMEOUT_MS),
|
|
140168
|
+
() => pageNotAnsweringError("fill_chromium_page_blocked", PAGE_ANSWER_TIMEOUT_MS)
|
|
140169
|
+
);
|
|
140170
|
+
const out = await withTimeoutError(
|
|
140171
|
+
() => api.cdp.send(
|
|
140172
|
+
"Runtime.evaluate",
|
|
140173
|
+
{ expression: buildChromiumFillScript(text), awaitPromise: true, returnByValue: true },
|
|
140174
|
+
FILL_TIMEOUT_MS2
|
|
140175
|
+
),
|
|
140176
|
+
() => pageNotFinishedError("fill_chromium_timeout")
|
|
140177
|
+
);
|
|
140178
|
+
const answer = out.result?.value;
|
|
140179
|
+
switch (answer?.status) {
|
|
140180
|
+
case "ok":
|
|
140181
|
+
if (answer.verified === true) {
|
|
140182
|
+
return { verified: true };
|
|
140183
|
+
}
|
|
140184
|
+
throw notVerifiedError("fill_chromium_not_verified");
|
|
140185
|
+
case "no_focus":
|
|
140186
|
+
throw noFocusedFieldError("fill_chromium_no_focus");
|
|
140187
|
+
case "unsupported":
|
|
140188
|
+
throw unsupportedFieldError(answer.detail ?? "unsupported field", "fill_chromium_field");
|
|
140189
|
+
default:
|
|
140190
|
+
throw new FailureError("fill could not run in the page; nothing is known about the field.", {
|
|
140191
|
+
error_code: FAILURE_CODES.FILL_NOT_VERIFIED,
|
|
140192
|
+
failure_stage: "fill_chromium_script",
|
|
140193
|
+
failure_area: "tool_server",
|
|
140194
|
+
error_kind: "unknown",
|
|
140195
|
+
failure_command: "cdp"
|
|
140196
|
+
});
|
|
140197
|
+
}
|
|
140198
|
+
}
|
|
140199
|
+
|
|
139675
140200
|
// ../tool-server/src/tools/keyboard/chromium-keys.ts
|
|
139676
140201
|
var CHROMIUM_NAMED_KEYS = {
|
|
139677
140202
|
"enter": { key: "Enter", code: "Enter", windowsVirtualKeyCode: 13 },
|
|
@@ -139738,7 +140263,7 @@ function charToChromiumKey(char) {
|
|
|
139738
140263
|
}
|
|
139739
140264
|
|
|
139740
140265
|
// ../tool-server/src/tools/keyboard/platforms/chromium.ts
|
|
139741
|
-
var
|
|
140266
|
+
var sleep12 = (ms3) => new Promise((r) => setTimeout(r, ms3));
|
|
139742
140267
|
async function runChromium(api, params) {
|
|
139743
140268
|
const delay3 = params.delayMs ?? 50;
|
|
139744
140269
|
let keysPressed = 0;
|
|
@@ -139766,7 +140291,7 @@ async function runChromium(api, params) {
|
|
|
139766
140291
|
windowsVirtualKeyCode: desc.windowsVirtualKeyCode
|
|
139767
140292
|
});
|
|
139768
140293
|
keysPressed++;
|
|
139769
|
-
await
|
|
140294
|
+
await sleep12(delay3);
|
|
139770
140295
|
}
|
|
139771
140296
|
}
|
|
139772
140297
|
if (params.key) {
|
|
@@ -139792,7 +140317,7 @@ async function runChromium(api, params) {
|
|
|
139792
140317
|
code: named.code,
|
|
139793
140318
|
windowsVirtualKeyCode: named.windowsVirtualKeyCode
|
|
139794
140319
|
});
|
|
139795
|
-
await
|
|
140320
|
+
await sleep12(delay3);
|
|
139796
140321
|
await api.dispatchKeyEvent({
|
|
139797
140322
|
type: "keyUp",
|
|
139798
140323
|
key: named.key,
|
|
@@ -139800,7 +140325,7 @@ async function runChromium(api, params) {
|
|
|
139800
140325
|
windowsVirtualKeyCode: named.windowsVirtualKeyCode
|
|
139801
140326
|
});
|
|
139802
140327
|
keysPressed++;
|
|
139803
|
-
if (i < count2 - 1) await
|
|
140328
|
+
if (i < count2 - 1) await sleep12(delay3);
|
|
139804
140329
|
}
|
|
139805
140330
|
}
|
|
139806
140331
|
return { typed: params.text ?? params.key ?? "", keys: keysPressed };
|
|
@@ -139808,18 +140333,44 @@ async function runChromium(api, params) {
|
|
|
139808
140333
|
function makeChromiumImpl(registry2) {
|
|
139809
140334
|
return {
|
|
139810
140335
|
handler: async (_services, params, device) => {
|
|
140336
|
+
if (params.clear) {
|
|
140337
|
+
if (params.text) {
|
|
140338
|
+
for (const char of params.text) {
|
|
140339
|
+
if (!charToChromiumKey(char)) {
|
|
140340
|
+
throw new InvalidToolInputError(`No CDP key descriptor for character "${char}"`, {
|
|
140341
|
+
error_code: FAILURE_CODES.KEYBOARD_CHARACTER_UNSUPPORTED,
|
|
140342
|
+
failure_stage: "keyboard_char_chromium",
|
|
140343
|
+
error_kind: "unsupported"
|
|
140344
|
+
});
|
|
140345
|
+
}
|
|
140346
|
+
}
|
|
140347
|
+
}
|
|
140348
|
+
await fillChromium(registry2, device, "");
|
|
140349
|
+
if (!params.text && !params.key) {
|
|
140350
|
+
return { typed: "", keys: 0, cleared: true };
|
|
140351
|
+
}
|
|
140352
|
+
}
|
|
139811
140353
|
const ref = chromiumCdpRef(device);
|
|
139812
140354
|
const chromium = await registry2.resolveService(ref.urn, ref.options);
|
|
139813
|
-
|
|
140355
|
+
const result = await runChromium(chromium, params);
|
|
140356
|
+
return params.clear ? { ...result, cleared: true } : result;
|
|
139814
140357
|
}
|
|
139815
140358
|
};
|
|
139816
140359
|
}
|
|
139817
140360
|
|
|
139818
140361
|
// ../tool-server/src/tools/keyboard/platforms/macos.ts
|
|
139819
|
-
|
|
140362
|
+
init_capability();
|
|
140363
|
+
var sleep13 = (ms3) => new Promise((r) => setTimeout(r, ms3));
|
|
139820
140364
|
function makeMacosImpl(registry2) {
|
|
139821
140365
|
return {
|
|
139822
140366
|
handler: async (_services, params, device) => {
|
|
140367
|
+
if (params.clear) {
|
|
140368
|
+
throw new UnsupportedOperationError(
|
|
140369
|
+
"keyboard",
|
|
140370
|
+
device,
|
|
140371
|
+
'clearing a field with `clear: true` is not supported on Mac apps; when a text field is focused, send `key: "command+a"` then `key: "backspace"`'
|
|
140372
|
+
);
|
|
140373
|
+
}
|
|
139823
140374
|
const app = await resolveMacosApp(registry2, device, "keyboard");
|
|
139824
140375
|
if (params.text) {
|
|
139825
140376
|
const keys = await macosTypeText(app, params.text, { delayMs: params.delayMs });
|
|
@@ -139830,7 +140381,7 @@ function makeMacosImpl(registry2) {
|
|
|
139830
140381
|
const delay3 = params.delayMs ?? 50;
|
|
139831
140382
|
for (let i = 0; i < count2; i++) {
|
|
139832
140383
|
await macosPressKey(app, params.key);
|
|
139833
|
-
if (i < count2 - 1) await
|
|
140384
|
+
if (i < count2 - 1) await sleep13(delay3);
|
|
139834
140385
|
}
|
|
139835
140386
|
return { typed: params.key, keys: count2 };
|
|
139836
140387
|
}
|
|
@@ -139839,6 +140390,9 @@ function makeMacosImpl(registry2) {
|
|
|
139839
140390
|
};
|
|
139840
140391
|
}
|
|
139841
140392
|
|
|
140393
|
+
// ../tool-server/src/tools/keyboard/platforms/vega.ts
|
|
140394
|
+
init_capability();
|
|
140395
|
+
|
|
139842
140396
|
// ../tool-server/src/utils/vega-input.ts
|
|
139843
140397
|
init_src2();
|
|
139844
140398
|
init_adb();
|
|
@@ -139935,7 +140489,14 @@ async function injectVegaText(text) {
|
|
|
139935
140489
|
}
|
|
139936
140490
|
|
|
139937
140491
|
// ../tool-server/src/tools/keyboard/platforms/vega.ts
|
|
139938
|
-
async function runVega2(params) {
|
|
140492
|
+
async function runVega2(device, params) {
|
|
140493
|
+
if (params.clear) {
|
|
140494
|
+
throw new UnsupportedOperationError(
|
|
140495
|
+
"keyboard",
|
|
140496
|
+
device,
|
|
140497
|
+
"clearing a field with `clear: true` is not supported on Vega"
|
|
140498
|
+
);
|
|
140499
|
+
}
|
|
139939
140500
|
let keysPressed = 0;
|
|
139940
140501
|
if (params.text) {
|
|
139941
140502
|
await injectVegaText(params.text);
|
|
@@ -139952,7 +140513,7 @@ async function runVega2(params) {
|
|
|
139952
140513
|
}
|
|
139953
140514
|
var vegaImpl4 = {
|
|
139954
140515
|
requires: ["adb"],
|
|
139955
|
-
handler: (_services, params) => runVega2(params)
|
|
140516
|
+
handler: (_services, params, device) => runVega2(device, params)
|
|
139956
140517
|
};
|
|
139957
140518
|
|
|
139958
140519
|
// ../tool-server/src/tools/keyboard/platforms/harmony.ts
|
|
@@ -140009,7 +140570,14 @@ function resolveHarmonyKeycode(key2) {
|
|
|
140009
140570
|
}
|
|
140010
140571
|
return code;
|
|
140011
140572
|
}
|
|
140012
|
-
async function typeHarmony(connectKey, params, signal) {
|
|
140573
|
+
async function typeHarmony(device, connectKey, params, signal) {
|
|
140574
|
+
if (params.clear) {
|
|
140575
|
+
throw new UnsupportedOperationError(
|
|
140576
|
+
"keyboard",
|
|
140577
|
+
device,
|
|
140578
|
+
"clearing a field with `clear: true` is not supported on HarmonyOS"
|
|
140579
|
+
);
|
|
140580
|
+
}
|
|
140013
140581
|
const keycode = params.key ? resolveHarmonyKeycode(params.key) : null;
|
|
140014
140582
|
if (params.text) assertTypeableHarmonyText(params.text);
|
|
140015
140583
|
if (keycode === null && !params.text) return { typed: "", keys: 0 };
|
|
@@ -140048,7 +140616,7 @@ async function typeHarmony(connectKey, params, signal) {
|
|
|
140048
140616
|
}
|
|
140049
140617
|
var harmonyImpl5 = {
|
|
140050
140618
|
requires: ["hdc"],
|
|
140051
|
-
handler: (_services, params, device, options) => typeHarmony(harmonyConnectKey(device.id), params, options?.signal)
|
|
140619
|
+
handler: (_services, params, device, options) => typeHarmony(device, harmonyConnectKey(device.id), params, options?.signal)
|
|
140052
140620
|
};
|
|
140053
140621
|
|
|
140054
140622
|
// ../tool-server/src/tools/keyboard/index.ts
|
|
@@ -140067,7 +140635,10 @@ var zodSchema27 = external_exports.object({
|
|
|
140067
140635
|
"Text to type. Cannot be combined with `key` (use two steps in `run-sequence` to type then press enter). Supports `{{secret:<NAME>}}` placeholders resolved server-side from `ARGENT_SECRET_<NAME>` / `.argent/secrets.env` (auto-screenshot is skipped; combine with submit in one `run-sequence` to keep the skip; never ask the user for plaintext)."
|
|
140068
140636
|
),
|
|
140069
140637
|
key: external_exports.string().optional().describe(
|
|
140070
|
-
"Named key. Cannot be combined with `text` (use two steps in `run-sequence`). Values: enter, escape, backspace, tab, space, arrow-up, arrow-down, arrow-left, arrow-right, f1-f12. Not supported on Apple TV / Android TV (use `tv-remote`). Physical iOS: enter/backspace only.<flag:harmonyos> HarmonyOS: enter, backspace, space, arrow-left/right.</flag:harmonyos><flag:macos-apps> Mac app: also delete (forward delete), home, end, page-up/down, and modifier shortcuts (e.g. command+a).</flag:macos-apps>"
|
|
140638
|
+
"Named key. Cannot be combined with `text` or `clear` (use two steps in `run-sequence`). Values: enter, escape, backspace, tab, space, arrow-up, arrow-down, arrow-left, arrow-right, f1-f12. Not supported on Apple TV / Android TV (use `tv-remote`). Physical iOS: enter/backspace only.<flag:harmonyos> HarmonyOS: enter, backspace, space, arrow-left/right.</flag:harmonyos><flag:macos-apps> Mac app: also delete (forward delete), home, end, page-up/down, and modifier shortcuts (e.g. command+a).</flag:macos-apps>"
|
|
140639
|
+
),
|
|
140640
|
+
clear: external_exports.boolean().optional().describe(
|
|
140641
|
+
"Clear the focused text field before typing `text` (or alone when `text` is omitted). Cannot be combined with `key`. Fails if nothing editable has focus. On physical iOS, deletes up to 100 characters before the caret, unverified, and returns no `cleared`. Not supported on <flag:macos-apps>Mac apps, </flag:macos-apps><flag:harmonyos>HarmonyOS, </flag:harmonyos>Apple TV, Android TV, or Vega."
|
|
140071
140642
|
),
|
|
140072
140643
|
repeat: external_exports.number().int().min(1).max(100).optional().describe(
|
|
140073
140644
|
'Press `key` this many times in one call, e.g. `{ key: "backspace", repeat: 12 }`. Only valid with `key`.'
|
|
@@ -140093,7 +140664,7 @@ function createKeyboardTool(registry2) {
|
|
|
140093
140664
|
id: "keyboard",
|
|
140094
140665
|
description: `Type text or press a named key on the focused field (tap or focus the field first; with no focus input is silently dropped).
|
|
140095
140666
|
Use when entering text or triggering named keys (enter, escape, backspace, arrows).
|
|
140096
|
-
Returns { typed, keys, verified?, warning?, reactivated? }. Fails if an unsupported key is passed or the input backend is unreachable (partial typing is not rolled back; re-read before retrying). On iOS simulators, typing into an empty field verifies readback (\`verified: false\` warns). React Native: after typing, the next tap outside may only close the keyboard (tap again if so); where the field submits on return, \`key: "enter"\` avoids the extra tap.`,
|
|
140667
|
+
Returns { typed, keys, cleared?, verified?, warning?, reactivated? }. Fails if an unsupported key is passed or the input backend is unreachable (partial typing is not rolled back; re-read before retrying). On iOS simulators, typing into an empty field verifies readback (\`verified: false\` warns). React Native: after typing, the next tap outside may only close the keyboard (tap again if so); where the field submits on return, \`key: "enter"\` avoids the extra tap.`,
|
|
140097
140668
|
zodSchema: zodSchema27,
|
|
140098
140669
|
alwaysLoad: true,
|
|
140099
140670
|
searchHint: "type text keyboard input named key enter escape arrow tv vega fire tv <flag:harmonyos>harmony harmonyos </flag:harmonyos>search field hid leanback",
|
|
@@ -140106,6 +140677,9 @@ Returns { typed, keys, verified?, warning?, reactivated? }. Fails if an unsuppor
|
|
|
140106
140677
|
// rejects (text+key, `{ key: "" }`), while `completedMsg` runs only after
|
|
140107
140678
|
// a success and sees neither. Both see the empty request, a no-op.
|
|
140108
140679
|
startedMsg: ({ params }) => {
|
|
140680
|
+
if (params.clear && params.key === void 0) {
|
|
140681
|
+
return params.text !== void 0 ? "Clearing field and entering text" : "Clearing field";
|
|
140682
|
+
}
|
|
140109
140683
|
if (params.text === void 0) {
|
|
140110
140684
|
return (params.repeat ?? 1) > 1 ? `Pressing a key ${params.repeat} times` : "Pressing a key";
|
|
140111
140685
|
}
|
|
@@ -140113,6 +140687,9 @@ Returns { typed, keys, verified?, warning?, reactivated? }. Fails if an unsuppor
|
|
|
140113
140687
|
return "Entering text and pressing a key";
|
|
140114
140688
|
},
|
|
140115
140689
|
completedMsg: ({ params }) => {
|
|
140690
|
+
if (params.clear) {
|
|
140691
|
+
return params.text !== void 0 ? "Cleared field and entered text" : "Cleared field";
|
|
140692
|
+
}
|
|
140116
140693
|
if (params.text !== void 0) return "Entered text";
|
|
140117
140694
|
return (params.repeat ?? 1) > 1 ? `Pressed a key ${params.repeat} times` : "Pressed a key";
|
|
140118
140695
|
},
|
|
@@ -140159,6 +140736,14 @@ Returns { typed, keys, verified?, warning?, reactivated? }. Fails if an unsuppor
|
|
|
140159
140736
|
}
|
|
140160
140737
|
);
|
|
140161
140738
|
}
|
|
140739
|
+
if (params.clear && params.key !== void 0) {
|
|
140740
|
+
throw new InvalidToolInputError(
|
|
140741
|
+
"keyboard `clear: true` cannot be combined with `key`, so nothing was changed. Pass `clear: true` alone to empty the field, or with `text` to replace its contents.",
|
|
140742
|
+
{
|
|
140743
|
+
failure_stage: "keyboard_clear_and_key_combined"
|
|
140744
|
+
}
|
|
140745
|
+
);
|
|
140746
|
+
}
|
|
140162
140747
|
if (params.repeat !== void 0 && params.key === void 0) {
|
|
140163
140748
|
throw new InvalidToolInputError(
|
|
140164
140749
|
'`repeat` only applies to `key`, not `text` or an empty request \u2014 nothing was typed. Pass a named `key` (e.g. { key: "backspace", repeat: 5 }), or omit `repeat`.',
|
|
@@ -140167,14 +140752,24 @@ Returns { typed, keys, verified?, warning?, reactivated? }. Fails if an unsuppor
|
|
|
140167
140752
|
}
|
|
140168
140753
|
);
|
|
140169
140754
|
}
|
|
140170
|
-
|
|
140755
|
+
const runDispatch = async (callParams) => {
|
|
140756
|
+
try {
|
|
140757
|
+
return await dispatch(services, callParams, options);
|
|
140758
|
+
} catch (err) {
|
|
140759
|
+
if (callParams.clear && err instanceof Error && getFailureSignal(err)?.error_code?.startsWith("FILL_")) {
|
|
140760
|
+
err.message = err.message.replace(/\bthe fill\b/g, "clearing the field").replace(/\bfill\b/g, "keyboard");
|
|
140761
|
+
}
|
|
140762
|
+
throw err;
|
|
140763
|
+
}
|
|
140764
|
+
};
|
|
140765
|
+
if (params.text === void 0) return runDispatch(params);
|
|
140171
140766
|
const { text, secrets } = resolveSecretPlaceholders(params.text, {
|
|
140172
140767
|
clientSecrets: options?.clientSecrets
|
|
140173
140768
|
});
|
|
140174
|
-
if (secrets.length === 0) return
|
|
140769
|
+
if (secrets.length === 0) return runDispatch(params);
|
|
140175
140770
|
noteTypedSecrets(params.udid, secrets);
|
|
140176
140771
|
try {
|
|
140177
|
-
const result = await
|
|
140772
|
+
const result = await runDispatch({ ...params, text });
|
|
140178
140773
|
return { ...result, typed: params.text };
|
|
140179
140774
|
} catch (err) {
|
|
140180
140775
|
throw redactSecretsFromError(err, secrets);
|
|
@@ -140200,7 +140795,7 @@ init_capability();
|
|
|
140200
140795
|
var LEFT_GUI_KEYCODE = 227;
|
|
140201
140796
|
var V_KEYCODE = charToKeyPress("v").keyCode;
|
|
140202
140797
|
var CHORD_STEP_MS = 50;
|
|
140203
|
-
var
|
|
140798
|
+
var sleep14 = (ms3) => new Promise((r) => setTimeout(r, ms3));
|
|
140204
140799
|
var typesAsText = (char) => !"\n\r ".includes(char) && !!charToKeyPress(char);
|
|
140205
140800
|
function rejectTv(device) {
|
|
140206
140801
|
throw new UnsupportedOperationError(
|
|
@@ -140226,13 +140821,13 @@ async function pasteSimulator(registry2, device, api, params) {
|
|
|
140226
140821
|
return { pasted: true, via: "keyboard" };
|
|
140227
140822
|
}
|
|
140228
140823
|
await api.pressKey("Down", LEFT_GUI_KEYCODE);
|
|
140229
|
-
await
|
|
140824
|
+
await sleep14(CHORD_STEP_MS);
|
|
140230
140825
|
await api.pressKey("Down", V_KEYCODE);
|
|
140231
|
-
await
|
|
140826
|
+
await sleep14(CHORD_STEP_MS);
|
|
140232
140827
|
await api.pressKey("Up", V_KEYCODE);
|
|
140233
|
-
await
|
|
140828
|
+
await sleep14(CHORD_STEP_MS);
|
|
140234
140829
|
await api.pressKey("Up", LEFT_GUI_KEYCODE);
|
|
140235
|
-
await
|
|
140830
|
+
await sleep14(CHORD_STEP_MS);
|
|
140236
140831
|
return { pasted: true };
|
|
140237
140832
|
}
|
|
140238
140833
|
function makeIosImpl4(registry2) {
|
|
@@ -140644,7 +141239,7 @@ async function prepareHostWindowShake(target) {
|
|
|
140644
141239
|
var execFileAsync36 = (0, import_node_util37.promisify)(import_node_child_process48.execFile);
|
|
140645
141240
|
var SHAKE_NOTIFICATION = "com.apple.UIKit.SimulatorShake";
|
|
140646
141241
|
var SHAKE_INTERVAL_MS = 400;
|
|
140647
|
-
var
|
|
141242
|
+
var sleep15 = (ms3) => new Promise((r) => setTimeout(r, ms3));
|
|
140648
141243
|
var NOTIFYUTIL_ARGV = ["notifyutil", "-p", SHAKE_NOTIFICATION];
|
|
140649
141244
|
function rejectTv2(toolId, device) {
|
|
140650
141245
|
throw new UnsupportedOperationError(
|
|
@@ -140680,7 +141275,7 @@ var iosImpl4 = {
|
|
|
140680
141275
|
const args = await simctlArgsForUdid(udid, ["spawn", udid, ...NOTIFYUTIL_ARGV]);
|
|
140681
141276
|
const shaker = await prepareHostWindowShake({ kind: "ios", udid, name: device.name });
|
|
140682
141277
|
for (let i = 0; i < count2; i++) {
|
|
140683
|
-
if (i > 0) await
|
|
141278
|
+
if (i > 0) await sleep15(SHAKE_INTERVAL_MS);
|
|
140684
141279
|
shaker.begin();
|
|
140685
141280
|
try {
|
|
140686
141281
|
await execFileAsync36("xcrun", args, { timeout: 15e3 });
|
|
@@ -140700,7 +141295,7 @@ var iosRemoteImpl6 = {
|
|
|
140700
141295
|
const count2 = params.count ?? 1;
|
|
140701
141296
|
if (await isRemoteTvOsSimulator(udid)) rejectTv2("shake", device);
|
|
140702
141297
|
for (let i = 0; i < count2; i++) {
|
|
140703
|
-
if (i > 0) await
|
|
141298
|
+
if (i > 0) await sleep15(SHAKE_INTERVAL_MS);
|
|
140704
141299
|
let result;
|
|
140705
141300
|
try {
|
|
140706
141301
|
result = await simctlSpawn(udid, { args: NOTIFYUTIL_ARGV });
|
|
@@ -140748,7 +141343,7 @@ function restingVectorFrom(stdout) {
|
|
|
140748
141343
|
return read;
|
|
140749
141344
|
}
|
|
140750
141345
|
var fmt = (v) => `${v.x.toFixed(4)}:${v.y.toFixed(4)}:${v.z.toFixed(4)}`;
|
|
140751
|
-
var
|
|
141346
|
+
var sleep16 = (ms3) => new Promise((r) => setTimeout(r, ms3));
|
|
140752
141347
|
var inFlightByDevice = /* @__PURE__ */ new Map();
|
|
140753
141348
|
function withDeviceLock(serial, fn) {
|
|
140754
141349
|
const previous = inFlightByDevice.get(serial) ?? Promise.resolve();
|
|
@@ -140813,7 +141408,7 @@ var androidImpl6 = {
|
|
|
140813
141408
|
y: rest.y,
|
|
140814
141409
|
z: rest.z
|
|
140815
141410
|
});
|
|
140816
|
-
await
|
|
141411
|
+
await sleep16(SWING_INTERVAL_MS);
|
|
140817
141412
|
}
|
|
140818
141413
|
}
|
|
140819
141414
|
} catch (err) {
|
|
@@ -141178,7 +141773,7 @@ var DISMISS_SPACING_MS = 1e3;
|
|
|
141178
141773
|
var DISMISS_TIMEOUT_MS = 5e3;
|
|
141179
141774
|
var WAKE_GRACE_READS = 2;
|
|
141180
141775
|
var abortReason2 = (signal) => signal.reason instanceof Error ? signal.reason : new Error("The fold was cancelled.");
|
|
141181
|
-
var
|
|
141776
|
+
var sleep17 = (ms3, signal) => new Promise((resolve21, reject) => {
|
|
141182
141777
|
if (signal?.aborted) return reject(abortReason2(signal));
|
|
141183
141778
|
const timer = setTimeout(resolve21, ms3);
|
|
141184
141779
|
signal?.addEventListener(
|
|
@@ -141252,7 +141847,7 @@ async function awaitSettled(serial, expected, wake, signal) {
|
|
|
141252
141847
|
let agreeing = 0;
|
|
141253
141848
|
const deadline = Date.now() + SETTLE_TIMEOUT_MS2;
|
|
141254
141849
|
while (Date.now() < deadline) {
|
|
141255
|
-
await
|
|
141850
|
+
await sleep17(POLL_MS2, signal);
|
|
141256
141851
|
const read = await readSnapshot(serial);
|
|
141257
141852
|
const same = read.state === last?.state && read.awake === last?.awake;
|
|
141258
141853
|
if (!isReady(read, expected)) agreeing = 0;
|
|
@@ -141287,7 +141882,7 @@ async function dismissFoldLockScreen(serial, signal) {
|
|
|
141287
141882
|
await shell(serial, "wm dismiss-keyguard");
|
|
141288
141883
|
}
|
|
141289
141884
|
}
|
|
141290
|
-
await
|
|
141885
|
+
await sleep17(POLL_MS2, signal);
|
|
141291
141886
|
}
|
|
141292
141887
|
return "The fold raised the lock screen and argent could not dismiss it (a PIN or password keeps it up). Unlock the device before the next action.";
|
|
141293
141888
|
}
|
|
@@ -142031,7 +142626,7 @@ Allowed tools (coords are [0,1] screen fractions; ? = optional):
|
|
|
142031
142626
|
gesture-pinch: centerX, centerY, startDistance, endDistance, endCenterX?, endCenterY?, angle?, durationMs?
|
|
142032
142627
|
gesture-rotate: centerX, centerY, startAngle, endAngle, radius (or radiusX+radiusY), durationMs?
|
|
142033
142628
|
button: button ("home"|"back"|"power"|"volumeUp"|"volumeDown"|"appSwitch"|"actionButton")<flag:harmonyos> [harmony: home/back/power]</flag:harmonyos>
|
|
142034
|
-
keyboard: text? or key? (one per step), repeat?, delayMs?
|
|
142629
|
+
keyboard: text? or key? (one per step), clear?, repeat?, delayMs?
|
|
142035
142630
|
paste: text (real paste flows only)
|
|
142036
142631
|
rotate: orientation ("Portrait"|"LandscapeLeft"|"LandscapeRight"|"PortraitUpsideDown")
|
|
142037
142632
|
shake: count?
|
|
@@ -145504,7 +146099,7 @@ function formatDescribeTree(root, opts) {
|
|
|
145504
146099
|
}
|
|
145505
146100
|
|
|
145506
146101
|
// ../tool-server/src/tools/describe/platforms/tv.ts
|
|
145507
|
-
var
|
|
146102
|
+
var sleep18 = (ms3) => new Promise((r) => setTimeout(r, ms3));
|
|
145508
146103
|
var EMPTY_RETRY_ATTEMPTS = 3;
|
|
145509
146104
|
var EMPTY_RETRY_DELAY_MS = 600;
|
|
145510
146105
|
var EMPTY_HINT2 = "No focusable elements after retrying and recycling the read path. Either the app is still loading or mid-transition (after launch-app / restart-app, or a press that opened an app), or the screen has nothing focusable (sleep, screensaver, video playback). Wait ~2-3s and call describe again; a React Native app only exposes focus once its JS bundle has loaded. If it stays empty, take a screenshot to confirm what's actually on screen.";
|
|
@@ -145536,7 +146131,7 @@ async function describeTv(registry2, device) {
|
|
|
145536
146131
|
let res = await api.describe();
|
|
145537
146132
|
if (device.platform !== "android") {
|
|
145538
146133
|
for (let attempt = 1; attempt < EMPTY_RETRY_ATTEMPTS && isEmptyFocus(res); attempt++) {
|
|
145539
|
-
await
|
|
146134
|
+
await sleep18(EMPTY_RETRY_DELAY_MS);
|
|
145540
146135
|
res = await api.describe();
|
|
145541
146136
|
}
|
|
145542
146137
|
}
|
|
@@ -146118,465 +146713,6 @@ A field is unset when it is unknown.`,
|
|
|
146118
146713
|
init_zod();
|
|
146119
146714
|
init_capability();
|
|
146120
146715
|
init_adb();
|
|
146121
|
-
|
|
146122
|
-
// ../tool-server/src/tools/fill/errors.ts
|
|
146123
|
-
init_src2();
|
|
146124
|
-
init_capability();
|
|
146125
|
-
function noFocusedFieldError(stage) {
|
|
146126
|
-
return new InvalidToolInputError(
|
|
146127
|
-
"Nothing that takes text has keyboard focus, so nothing was changed. Tap the text field first, then call fill again.",
|
|
146128
|
-
{
|
|
146129
|
-
error_code: FAILURE_CODES.FILL_NO_FOCUSED_FIELD,
|
|
146130
|
-
failure_stage: stage,
|
|
146131
|
-
error_kind: "validation"
|
|
146132
|
-
}
|
|
146133
|
-
);
|
|
146134
|
-
}
|
|
146135
|
-
function notVerifiedError(stage) {
|
|
146136
|
-
return new FailureError(
|
|
146137
|
-
"fill wrote to the focused field, but reading it back did not show the requested text. The field may hold other or partial text: read it before retrying.",
|
|
146138
|
-
{
|
|
146139
|
-
error_code: FAILURE_CODES.FILL_NOT_VERIFIED,
|
|
146140
|
-
failure_stage: stage,
|
|
146141
|
-
failure_area: "tool_server",
|
|
146142
|
-
error_kind: "unknown"
|
|
146143
|
-
}
|
|
146144
|
-
);
|
|
146145
|
-
}
|
|
146146
|
-
function notChangedError(stage) {
|
|
146147
|
-
return new FailureError(
|
|
146148
|
-
"fill could not select the text of the focused field, so nothing was changed. Tap the field and retry.",
|
|
146149
|
-
{
|
|
146150
|
-
error_code: FAILURE_CODES.FILL_NOT_VERIFIED,
|
|
146151
|
-
failure_stage: stage,
|
|
146152
|
-
failure_area: "tool_server",
|
|
146153
|
-
error_kind: "unknown"
|
|
146154
|
-
}
|
|
146155
|
-
);
|
|
146156
|
-
}
|
|
146157
|
-
function notAnsweredError(stage) {
|
|
146158
|
-
return new FailureError(
|
|
146159
|
-
"The device did not finish the fill in time. The field may have changed: read it before retrying.",
|
|
146160
|
-
{
|
|
146161
|
-
error_code: FAILURE_CODES.FILL_NOT_VERIFIED,
|
|
146162
|
-
failure_stage: stage,
|
|
146163
|
-
failure_area: "tool_server",
|
|
146164
|
-
error_kind: "timeout"
|
|
146165
|
-
}
|
|
146166
|
-
);
|
|
146167
|
-
}
|
|
146168
|
-
function pageNotAnsweringError(stage, waitedMs) {
|
|
146169
|
-
return new FailureError(
|
|
146170
|
-
`The page did not answer for ${waitedMs / 1e3} s, so fill changed nothing. A JavaScript dialog (alert, confirm or prompt) may be open, or the page is busy or has crashed. Argent cannot close a dialog: ask the user to close it, then retry. A retry fills a busy page once its task ends. If no dialog is open and it still does not answer, restart the app.`,
|
|
146171
|
-
{
|
|
146172
|
-
error_code: FAILURE_CODES.FILL_NOT_VERIFIED,
|
|
146173
|
-
failure_stage: stage,
|
|
146174
|
-
failure_area: "tool_server",
|
|
146175
|
-
error_kind: "timeout"
|
|
146176
|
-
}
|
|
146177
|
-
);
|
|
146178
|
-
}
|
|
146179
|
-
function pageNotFinishedError(stage) {
|
|
146180
|
-
return new FailureError(
|
|
146181
|
-
"The page did not finish the fill in time; it may have opened a JavaScript dialog or crashed. The field may have changed, and may still change when the page resumes: read it before retrying. If the page does not answer and no dialog is open, restart the app.",
|
|
146182
|
-
{
|
|
146183
|
-
error_code: FAILURE_CODES.FILL_NOT_VERIFIED,
|
|
146184
|
-
failure_stage: stage,
|
|
146185
|
-
failure_area: "tool_server",
|
|
146186
|
-
error_kind: "timeout"
|
|
146187
|
-
}
|
|
146188
|
-
);
|
|
146189
|
-
}
|
|
146190
|
-
function unsupportedFieldError(detail, stage) {
|
|
146191
|
-
return new InvalidToolInputError(
|
|
146192
|
-
`fill cannot set this field's text: ${detail}. Nothing was changed.`,
|
|
146193
|
-
{
|
|
146194
|
-
error_code: FAILURE_CODES.FILL_UNSUPPORTED_FIELD,
|
|
146195
|
-
failure_stage: stage,
|
|
146196
|
-
error_kind: "unsupported"
|
|
146197
|
-
}
|
|
146198
|
-
);
|
|
146199
|
-
}
|
|
146200
|
-
|
|
146201
|
-
// ../tool-server/src/tools/fill/keys.ts
|
|
146202
|
-
init_src2();
|
|
146203
|
-
init_src2();
|
|
146204
|
-
var MAX_CLEAR_KEYS = 100;
|
|
146205
|
-
var XCTEST_DELETE = "\b";
|
|
146206
|
-
var KEY_TIMING = { holdMs: 20, settleMs: 300, typeDelayMs: 30 };
|
|
146207
|
-
var sleep18 = (ms3) => new Promise((r) => setTimeout(r, ms3));
|
|
146208
|
-
function typeableOnSimulator(text) {
|
|
146209
|
-
for (const char of text) if (!charToKeyPress(char)) return false;
|
|
146210
|
-
return true;
|
|
146211
|
-
}
|
|
146212
|
-
async function withoutTextInErrors(stage, run2) {
|
|
146213
|
-
try {
|
|
146214
|
-
return await run2();
|
|
146215
|
-
} catch (err) {
|
|
146216
|
-
const signal = getFailureSignal(err);
|
|
146217
|
-
throw new FailureError(
|
|
146218
|
-
"fill failed partway through typing: the focused field may hold part of the text. Read it before retrying.",
|
|
146219
|
-
signal ?? {
|
|
146220
|
-
error_code: FAILURE_CODES.FILL_NOT_VERIFIED,
|
|
146221
|
-
failure_stage: stage,
|
|
146222
|
-
failure_area: "tool_server",
|
|
146223
|
-
error_kind: "unknown"
|
|
146224
|
-
}
|
|
146225
|
-
);
|
|
146226
|
-
}
|
|
146227
|
-
}
|
|
146228
|
-
async function pressSimulatorBackspace(registry2, device) {
|
|
146229
|
-
const ref = simulatorServerRef(device);
|
|
146230
|
-
const api = await registry2.resolveService(ref.urn, ref.options);
|
|
146231
|
-
await api.pressKey("Down", NAMED_KEYS.backspace);
|
|
146232
|
-
await sleep18(KEY_TIMING.holdMs);
|
|
146233
|
-
await api.pressKey("Up", NAMED_KEYS.backspace);
|
|
146234
|
-
await sleep18(KEY_TIMING.settleMs);
|
|
146235
|
-
}
|
|
146236
|
-
async function typeOnSimulator(registry2, device, text) {
|
|
146237
|
-
if (!text) return;
|
|
146238
|
-
await withoutTextInErrors(
|
|
146239
|
-
"fill_keys_ios",
|
|
146240
|
-
() => typeSimulatorServer(registry2, device, {
|
|
146241
|
-
udid: device.id,
|
|
146242
|
-
text,
|
|
146243
|
-
delayMs: KEY_TIMING.typeDelayMs
|
|
146244
|
-
})
|
|
146245
|
-
);
|
|
146246
|
-
}
|
|
146247
|
-
async function fillByDeviceKeys(registry2, device, text) {
|
|
146248
|
-
const bundleId = requireCurrentIosDeviceApp(device.id);
|
|
146249
|
-
const ref = iosDeviceRunnerRef(device);
|
|
146250
|
-
const api = await registry2.resolveService(ref.urn, ref.options);
|
|
146251
|
-
const type = async (chars) => {
|
|
146252
|
-
try {
|
|
146253
|
-
await typeText(api, bundleId, chars);
|
|
146254
|
-
} catch (err) {
|
|
146255
|
-
if (err instanceof RunnerCommandError && err.code === "TEXT_INPUT_NOT_FOCUSED") {
|
|
146256
|
-
throw noFocusedFieldError("fill_keys_ios_device_focus");
|
|
146257
|
-
}
|
|
146258
|
-
throw err;
|
|
146259
|
-
}
|
|
146260
|
-
};
|
|
146261
|
-
await type(XCTEST_DELETE.repeat(MAX_CLEAR_KEYS));
|
|
146262
|
-
if (text) await withoutTextInErrors("fill_keys_ios_device", () => type(text));
|
|
146263
|
-
}
|
|
146264
|
-
|
|
146265
|
-
// ../tool-server/src/tools/fill/ios.ts
|
|
146266
|
-
var NEWLINE = /[\r\n]/;
|
|
146267
|
-
async function fillIos(registry2, device, text) {
|
|
146268
|
-
const ref = axServiceRef(device);
|
|
146269
|
-
const ax = await registry2.resolveService(ref.urn, ref.options);
|
|
146270
|
-
const typeable = typeableOnSimulator(text) && !NEWLINE.test(text);
|
|
146271
|
-
const first = await ax.fill(text, { typeable });
|
|
146272
|
-
if (!first.focused) throw noFocusedFieldError("fill_ios_no_focus");
|
|
146273
|
-
if (first.unsupported) {
|
|
146274
|
-
throw unsupportedFieldError(
|
|
146275
|
-
"the focused element is not a text input (a date or time input, or a picker)",
|
|
146276
|
-
"fill_ios_unsupported_field"
|
|
146277
|
-
);
|
|
146278
|
-
}
|
|
146279
|
-
if (first.singleLine) {
|
|
146280
|
-
throw unsupportedFieldError(
|
|
146281
|
-
"a single-line text field cannot hold a newline",
|
|
146282
|
-
"fill_ios_single_line"
|
|
146283
|
-
);
|
|
146284
|
-
}
|
|
146285
|
-
if (first.timedOut) throw notAnsweredError("fill_ios_timeout");
|
|
146286
|
-
if (first.untouched) throw notChangedError("fill_ios_select_failed");
|
|
146287
|
-
if (first.verified) return { verified: true };
|
|
146288
|
-
if (first.secure) {
|
|
146289
|
-
if (!typeable) {
|
|
146290
|
-
throw unsupportedFieldError(
|
|
146291
|
-
"a secure text field takes only text the keyboard can type on one line, and this text has a character it cannot",
|
|
146292
|
-
"fill_ios_secure_untypeable"
|
|
146293
|
-
);
|
|
146294
|
-
}
|
|
146295
|
-
if (!first.cleared) throw notVerifiedError("fill_ios_secure_not_cleared");
|
|
146296
|
-
await typeOnSimulator(registry2, device, text);
|
|
146297
|
-
const check3 = await ax.fill(text, { check: true });
|
|
146298
|
-
if (check3.verified) return { verified: true };
|
|
146299
|
-
throw notVerifiedError("fill_ios_not_verified");
|
|
146300
|
-
}
|
|
146301
|
-
if (first.needsBackspace) {
|
|
146302
|
-
await pressSimulatorBackspace(registry2, device);
|
|
146303
|
-
const check3 = await ax.fill(text, { check: true });
|
|
146304
|
-
if (check3.verified) return { verified: true };
|
|
146305
|
-
}
|
|
146306
|
-
throw notVerifiedError("fill_ios_not_verified");
|
|
146307
|
-
}
|
|
146308
|
-
|
|
146309
|
-
// ../tool-server/src/tools/fill/android.ts
|
|
146310
|
-
async function fillAndroid(registry2, device, text) {
|
|
146311
|
-
const ref = androidDevtoolsRef(device);
|
|
146312
|
-
const helper = await registry2.resolveService(ref.urn, ref.options);
|
|
146313
|
-
const answer = await helper.setText(text);
|
|
146314
|
-
if (!answer.focused) throw noFocusedFieldError("fill_android_no_focus");
|
|
146315
|
-
if (answer.singleLine) {
|
|
146316
|
-
throw unsupportedFieldError(
|
|
146317
|
-
"a single-line text field cannot hold a newline",
|
|
146318
|
-
"fill_android_single_line"
|
|
146319
|
-
);
|
|
146320
|
-
}
|
|
146321
|
-
if (answer.timedOut) throw notAnsweredError("fill_android_timeout");
|
|
146322
|
-
if (answer.verified) return { verified: true };
|
|
146323
|
-
throw notVerifiedError("fill_android_not_verified");
|
|
146324
|
-
}
|
|
146325
|
-
|
|
146326
|
-
// ../tool-server/src/tools/fill/chromium.ts
|
|
146327
|
-
init_src2();
|
|
146328
|
-
function buildChromiumFillScript(text) {
|
|
146329
|
-
return `(async () => {
|
|
146330
|
-
const text = ${JSON.stringify(text)};
|
|
146331
|
-
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
146332
|
-
try {
|
|
146333
|
-
const deepActive = (doc) => {
|
|
146334
|
-
let el = doc.activeElement;
|
|
146335
|
-
while (el && el.shadowRoot && el.shadowRoot.activeElement) el = el.shadowRoot.activeElement;
|
|
146336
|
-
return el;
|
|
146337
|
-
};
|
|
146338
|
-
let el = deepActive(document);
|
|
146339
|
-
while (el && /^(i?frame|object)$/.test(String(el.tagName).toLowerCase())) {
|
|
146340
|
-
// An <object> showing an image or a plugin has no document to descend into.
|
|
146341
|
-
if (!el.contentWindow) break;
|
|
146342
|
-
let inner = null;
|
|
146343
|
-
try { inner = el.contentDocument; } catch (e) { inner = null; }
|
|
146344
|
-
// A cross-origin or sandboxed frame hides its document.
|
|
146345
|
-
if (!inner) return { status: "unsupported", detail: "focus is in a cross-origin frame, which fill cannot reach" };
|
|
146346
|
-
el = deepActive(inner);
|
|
146347
|
-
}
|
|
146348
|
-
if (!el || el.tagName === undefined) return { status: "no_focus" };
|
|
146349
|
-
const doc = el.ownerDocument || document;
|
|
146350
|
-
const win = doc.defaultView || window;
|
|
146351
|
-
const tag = String(el.tagName).toLowerCase();
|
|
146352
|
-
if (tag === "embed") return { status: "unsupported", detail: "focus is in an <embed>, which fill cannot reach" };
|
|
146353
|
-
const type = tag === "input" ? String(el.type || "text").toLowerCase() : null;
|
|
146354
|
-
if (type !== null && /^(date|time|month|week|datetime-local)$/.test(type)) {
|
|
146355
|
-
return { status: "unsupported", detail: "a " + type + " input holds a structured value" };
|
|
146356
|
-
}
|
|
146357
|
-
const control =
|
|
146358
|
-
tag === "textarea" ||
|
|
146359
|
-
(tag === "input" && !/^(button|checkbox|radio|file|submit|reset|image|range|color|hidden)$/.test(type));
|
|
146360
|
-
if (!control) {
|
|
146361
|
-
// Focus in a closed shadow root stops at its host. An element that can
|
|
146362
|
-
// host one is focusable itself only as a tab stop, an editing host or a
|
|
146363
|
-
// box the user can scroll; one with focus that is none of these, or whose
|
|
146364
|
-
// selection is in its shadow tree, holds it in a closed shadow root. The
|
|
146365
|
-
// browser shows such a selection collapsed before the host, or in place
|
|
146366
|
-
// when the page set it there, even in an editing host's own text. In a
|
|
146367
|
-
// focused page, which :focus needs, an editing host focused itself
|
|
146368
|
-
// matches :focus-visible; one whose focus is in its shadow tree does not.
|
|
146369
|
-
const scrolls = (style) =>
|
|
146370
|
-
(/^(auto|scroll)$/.test(style.overflowY) && el.scrollHeight > el.clientHeight) ||
|
|
146371
|
-
(/^(auto|scroll)$/.test(style.overflowX) && el.scrollWidth > el.clientWidth);
|
|
146372
|
-
const inShadow = (node, offset) => {
|
|
146373
|
-
if (node == null) return false;
|
|
146374
|
-
if (node === el.parentNode && node.childNodes[offset] === el) return true;
|
|
146375
|
-
for (let root = node.getRootNode(); root.host; root = root.host.getRootNode()) if (root.host === el) return true;
|
|
146376
|
-
return false;
|
|
146377
|
-
};
|
|
146378
|
-
const selectionInShadow = () => {
|
|
146379
|
-
if (el.shadowRoot) return false;
|
|
146380
|
-
const sel = el.getRootNode().getSelection();
|
|
146381
|
-
return inShadow(sel.anchorNode, sel.anchorOffset) && inShadow(sel.focusNode, sel.focusOffset);
|
|
146382
|
-
};
|
|
146383
|
-
const focusInShadow = () => {
|
|
146384
|
-
if (el.isContentEditable !== true) return false;
|
|
146385
|
-
try {
|
|
146386
|
-
return el.matches(":focus") && !el.matches(":focus-visible");
|
|
146387
|
-
} catch (e) {
|
|
146388
|
-
// Chromium before 86 has no :focus-visible.
|
|
146389
|
-
return false;
|
|
146390
|
-
}
|
|
146391
|
-
};
|
|
146392
|
-
const closedHost =
|
|
146393
|
-
/-|^(article|aside|blockquote|div|footer|h[1-6]|header|main|nav|p|section|span)$/.test(tag) &&
|
|
146394
|
-
((!el.hasAttribute("tabindex") &&
|
|
146395
|
-
(el.isContentEditable !== true || (el.parentElement !== null && el.parentElement.isContentEditable === true)) &&
|
|
146396
|
-
!scrolls(win.getComputedStyle(el))) ||
|
|
146397
|
-
selectionInShadow() ||
|
|
146398
|
-
focusInShadow());
|
|
146399
|
-
if (closedHost) return { status: "unsupported", detail: "focus is in a closed shadow root, which fill cannot reach" };
|
|
146400
|
-
if (el.isContentEditable !== true) return { status: "no_focus" };
|
|
146401
|
-
}
|
|
146402
|
-
if (control && el.disabled === true) return { status: "unsupported", detail: "it is disabled" };
|
|
146403
|
-
if (control && el.readOnly === true) return { status: "unsupported", detail: "it is read-only" };
|
|
146404
|
-
// An <input> holds one line and drops a newline.
|
|
146405
|
-
if (tag === "input" && /[\\r\\n]/.test(text)) {
|
|
146406
|
-
return { status: "unsupported", detail: "a single-line input cannot hold a newline" };
|
|
146407
|
-
}
|
|
146408
|
-
// A textarea or an editable element stores a CR or CRLF as one LF.
|
|
146409
|
-
const want = text.replace(/\\r\\n?/g, "\\n");
|
|
146410
|
-
// Typed text stops at maxlength, which the value setter ignores.
|
|
146411
|
-
const limited = tag === "textarea" || /^(text|search|url|tel|email|password)$/.test(type);
|
|
146412
|
-
if (limited && el.maxLength >= 0 && want.length > el.maxLength) {
|
|
146413
|
-
return { status: "unsupported", detail: "the text is longer than its maxlength of " + el.maxLength };
|
|
146414
|
-
}
|
|
146415
|
-
// A number input holds only a valid number and an email input drops the
|
|
146416
|
-
// whitespace around an address, typed or set. A detached input of the
|
|
146417
|
-
// same type applies the browser's own sanitization; outside an HTML
|
|
146418
|
-
// document only the XHTML namespace makes it an input.
|
|
146419
|
-
if (type === "number" || type === "email") {
|
|
146420
|
-
const probe = doc.createElementNS("http://www.w3.org/1999/xhtml", "input");
|
|
146421
|
-
probe.type = type;
|
|
146422
|
-
probe.multiple = el.multiple === true;
|
|
146423
|
-
probe.value = text;
|
|
146424
|
-
if (probe.value !== text) {
|
|
146425
|
-
return {
|
|
146426
|
-
status: "unsupported",
|
|
146427
|
-
detail: type === "number" ? "a number input holds only a valid number" : "an email input drops the whitespace around an address",
|
|
146428
|
-
};
|
|
146429
|
-
}
|
|
146430
|
-
}
|
|
146431
|
-
if (!control) {
|
|
146432
|
-
// designMode or <body contenteditable>: the whole document is the field.
|
|
146433
|
-
let host = el;
|
|
146434
|
-
while (host.parentElement && host.parentElement.isContentEditable === true) host = host.parentElement;
|
|
146435
|
-
if (host === doc.body || host === doc.documentElement) {
|
|
146436
|
-
return { status: "unsupported", detail: "the whole document is editable" };
|
|
146437
|
-
}
|
|
146438
|
-
}
|
|
146439
|
-
const trimEnd = (s) => s.replace(/[\\u200b\\ufeff]/g, "").replace(/\\n+$/, "");
|
|
146440
|
-
const read = () =>
|
|
146441
|
-
control ? String(el.value == null ? "" : el.value) : trimEnd(String(el.innerText == null ? el.textContent || "" : el.innerText));
|
|
146442
|
-
// A number input showing text it cannot parse reads as "".
|
|
146443
|
-
const badInput = () => el.validity != null && el.validity.badInput === true;
|
|
146444
|
-
// Chrome stores an edited email address's non-ASCII domain in ASCII, by
|
|
146445
|
-
// UTS #46 transitional processing: the URL parser's, once its deviations
|
|
146446
|
-
// (\xDF, \u03C2, ZWNJ, ZWJ) are mapped.
|
|
146447
|
-
const asciiEmail = (a) => {
|
|
146448
|
-
const at = a.indexOf("@");
|
|
146449
|
-
if (at < 0 || !/[^\\x00-\\x7f]/.test(a)) return a;
|
|
146450
|
-
const host = a.slice(at + 1).replace(/[\\u00df\\u1e9e]/g, "ss").replace(/\\u03c2/g, "\\u03c3").replace(/[\\u200c\\u200d]/g, "");
|
|
146451
|
-
// A link parses its href with the URL parser even where a page's own URL
|
|
146452
|
-
// global shadows the builtin. The ".a" label keeps a numeric last label
|
|
146453
|
-
// from parsing as IPv4.
|
|
146454
|
-
const link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a");
|
|
146455
|
-
link.href = "http://" + host + ".a";
|
|
146456
|
-
// Unparsable, or not a bare host: it has a user, a port or a path.
|
|
146457
|
-
if (link.href !== "http://" + link.hostname + "/") return a;
|
|
146458
|
-
return a.slice(0, at + 1) + link.hostname.slice(0, -2);
|
|
146459
|
-
};
|
|
146460
|
-
const sameText = (got) => {
|
|
146461
|
-
if (type !== "email") return got === want;
|
|
146462
|
-
const split = (s) => (el.multiple === true ? s.split(",") : [s]);
|
|
146463
|
-
const wants = split(want);
|
|
146464
|
-
const gots = split(got);
|
|
146465
|
-
return gots.length === wants.length && gots.every((g, i) => g === wants[i] || g === asciiEmail(wants[i]));
|
|
146466
|
-
};
|
|
146467
|
-
const matches = () => (control ? sameText(read()) && !badInput() : read() === trimEnd(want));
|
|
146468
|
-
const settle = async () => {
|
|
146469
|
-
for (let i = 0; i < 10; i++) {
|
|
146470
|
-
await sleep(i === 0 ? 0 : 50);
|
|
146471
|
-
if (matches()) return true;
|
|
146472
|
-
}
|
|
146473
|
-
return false;
|
|
146474
|
-
};
|
|
146475
|
-
|
|
146476
|
-
const before = read();
|
|
146477
|
-
// The browser fires input synchronously for an edit it performed. The
|
|
146478
|
-
// window's capture phase sees it unless a page listener added there
|
|
146479
|
-
// earlier stops it.
|
|
146480
|
-
let edited = false;
|
|
146481
|
-
const onInput = () => { edited = true; };
|
|
146482
|
-
win.addEventListener("input", onInput, true);
|
|
146483
|
-
try {
|
|
146484
|
-
if (control) {
|
|
146485
|
-
try { el.select(); } catch (e) { /* no selection API */ }
|
|
146486
|
-
} else {
|
|
146487
|
-
const sel = doc.getSelection();
|
|
146488
|
-
const range = doc.createRange();
|
|
146489
|
-
range.selectNodeContents(el);
|
|
146490
|
-
sel.removeAllRanges();
|
|
146491
|
-
sel.addRange(range);
|
|
146492
|
-
}
|
|
146493
|
-
try {
|
|
146494
|
-
if (text === "") {
|
|
146495
|
-
if (read() !== "" || badInput()) doc.execCommand("delete");
|
|
146496
|
-
} else {
|
|
146497
|
-
doc.execCommand("insertText", false, text);
|
|
146498
|
-
}
|
|
146499
|
-
} catch (e) {
|
|
146500
|
-
// An SVG document has no editing commands; a control still has its setter.
|
|
146501
|
-
if (!control) throw e;
|
|
146502
|
-
}
|
|
146503
|
-
} finally {
|
|
146504
|
-
win.removeEventListener("input", onInput, true);
|
|
146505
|
-
}
|
|
146506
|
-
let verified = await settle();
|
|
146507
|
-
// An edit that did not happen fires no input and leaves the old text.
|
|
146508
|
-
// Anything else is the browser's or the page's own rewrite, which the
|
|
146509
|
-
// setter must not override, even when the rewrite equals the old text.
|
|
146510
|
-
if (!verified && control && !edited && read() === before) {
|
|
146511
|
-
const proto = tag === "textarea" ? win.HTMLTextAreaElement.prototype : win.HTMLInputElement.prototype;
|
|
146512
|
-
const setter = Object.getOwnPropertyDescriptor(proto, "value").set;
|
|
146513
|
-
setter.call(el, text);
|
|
146514
|
-
el.dispatchEvent(new win.Event("input", { bubbles: true }));
|
|
146515
|
-
el.dispatchEvent(new win.Event("change", { bubbles: true }));
|
|
146516
|
-
verified = await settle();
|
|
146517
|
-
}
|
|
146518
|
-
return { status: "ok", verified: verified };
|
|
146519
|
-
} catch (e) {
|
|
146520
|
-
return { status: "error" };
|
|
146521
|
-
}
|
|
146522
|
-
})()`;
|
|
146523
|
-
}
|
|
146524
|
-
var PAGE_ANSWER_TIMEOUT_MS = 1e4;
|
|
146525
|
-
var FILL_TIMEOUT_MS2 = 1e4;
|
|
146526
|
-
async function withTimeoutError(send, timeoutError) {
|
|
146527
|
-
try {
|
|
146528
|
-
return await send();
|
|
146529
|
-
} catch (err) {
|
|
146530
|
-
if (getFailureSignal(err)?.error_code === FAILURE_CODES.DEBUGGER_CDP_REQUEST_TIMEOUT) {
|
|
146531
|
-
throw timeoutError();
|
|
146532
|
-
}
|
|
146533
|
-
throw err;
|
|
146534
|
-
}
|
|
146535
|
-
}
|
|
146536
|
-
async function fillChromium(registry2, device, text) {
|
|
146537
|
-
const ref = chromiumCdpRef(device);
|
|
146538
|
-
const api = await withTimeoutError(
|
|
146539
|
-
() => registry2.resolveService(ref.urn, {
|
|
146540
|
-
...ref.options,
|
|
146541
|
-
answerTimeoutMs: PAGE_ANSWER_TIMEOUT_MS
|
|
146542
|
-
}),
|
|
146543
|
-
() => pageNotAnsweringError("fill_chromium_connect", PAGE_ANSWER_TIMEOUT_MS)
|
|
146544
|
-
);
|
|
146545
|
-
await withTimeoutError(
|
|
146546
|
-
() => api.cdp.send("Runtime.evaluate", { expression: "0" }, PAGE_ANSWER_TIMEOUT_MS),
|
|
146547
|
-
() => pageNotAnsweringError("fill_chromium_page_blocked", PAGE_ANSWER_TIMEOUT_MS)
|
|
146548
|
-
);
|
|
146549
|
-
const out = await withTimeoutError(
|
|
146550
|
-
() => api.cdp.send(
|
|
146551
|
-
"Runtime.evaluate",
|
|
146552
|
-
{ expression: buildChromiumFillScript(text), awaitPromise: true, returnByValue: true },
|
|
146553
|
-
FILL_TIMEOUT_MS2
|
|
146554
|
-
),
|
|
146555
|
-
() => pageNotFinishedError("fill_chromium_timeout")
|
|
146556
|
-
);
|
|
146557
|
-
const answer = out.result?.value;
|
|
146558
|
-
switch (answer?.status) {
|
|
146559
|
-
case "ok":
|
|
146560
|
-
if (answer.verified === true) {
|
|
146561
|
-
return { verified: true };
|
|
146562
|
-
}
|
|
146563
|
-
throw notVerifiedError("fill_chromium_not_verified");
|
|
146564
|
-
case "no_focus":
|
|
146565
|
-
throw noFocusedFieldError("fill_chromium_no_focus");
|
|
146566
|
-
case "unsupported":
|
|
146567
|
-
throw unsupportedFieldError(answer.detail ?? "unsupported field", "fill_chromium_field");
|
|
146568
|
-
default:
|
|
146569
|
-
throw new FailureError("fill could not run in the page; nothing is known about the field.", {
|
|
146570
|
-
error_code: FAILURE_CODES.FILL_NOT_VERIFIED,
|
|
146571
|
-
failure_stage: "fill_chromium_script",
|
|
146572
|
-
failure_area: "tool_server",
|
|
146573
|
-
error_kind: "unknown",
|
|
146574
|
-
failure_command: "cdp"
|
|
146575
|
-
});
|
|
146576
|
-
}
|
|
146577
|
-
}
|
|
146578
|
-
|
|
146579
|
-
// ../tool-server/src/tools/fill/index.ts
|
|
146580
146716
|
var capability29 = {
|
|
146581
146717
|
apple: { simulator: true, device: true },
|
|
146582
146718
|
appleRemote: { simulator: true },
|