@swmansion/argent 0.34.1-next.1 → 0.34.1-next.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/bin/argent-android-devtools-0.4.0.apk +0 -0
- package/bin/darwin/argent-macos-helper +0 -0
- package/bin/darwin/ax-service +0 -0
- package/bin/darwin/tvos-ax-service +0 -0
- package/bin/darwin/tvos-hid-daemon +0 -0
- package/bin/network-inspector/network-inspector.jar +0 -0
- package/bin/tcp/ax-service +0 -0
- package/dist/cli-cmds.mjs +60 -23
- package/dist/client.js +13 -10
- package/dist/installer-help.js +4 -0
- package/dist/installer-help.js.map +1 -1
- package/dist/installer.mjs +186 -156
- package/dist/mcp-server.mjs +16 -12
- package/dist/tool-server.cjs +881 -495
- package/dylibs/libArgentInjectionBootstrap.dylib +0 -0
- package/dylibs/libKeyboardPatch.dylib +0 -0
- package/dylibs/libNativeDevtoolsIos.dylib +0 -0
- package/dylibs/macos/libArgentInjectionBootstrap.dylib +0 -0
- package/dylibs/macos/libNativeDevtoolsMacos.dylib +0 -0
- package/dylibs/tcp/libArgentInjectionBootstrap.dylib +0 -0
- package/dylibs/tcp/libKeyboardPatch.dylib +0 -0
- package/dylibs/tcp/libNativeDevtoolsIos.dylib +0 -0
- package/dylibs/tvos/libArgentInjectionBootstrap.dylib +0 -0
- package/dylibs/tvos/libKeyboardPatch.dylib +0 -0
- package/dylibs/tvos/libNativeDevtoolsIos.dylib +0 -0
- package/package.json +1 -1
- package/rules/argent.md +6 -23
package/dist/tool-server.cjs
CHANGED
|
@@ -895,14 +895,6 @@ var init_config_schema = __esm({
|
|
|
895
895
|
// drained/reset, not just the file rewritten.
|
|
896
896
|
manageCommand: "argent telemetry"
|
|
897
897
|
},
|
|
898
|
-
{
|
|
899
|
-
key: "allowlist.enabled",
|
|
900
|
-
description: "Whether `argent update` re-applies editor auto-approve allowlist rules. Unset (the default) keeps the current behavior: update refreshes the rules for editors that already have argent configured. Set to `false` to keep update from touching editor allowlists. `false` in either scope wins, so a committed project opt-out holds for every teammate.",
|
|
901
|
-
scopes: ["project", "global"],
|
|
902
|
-
parse: asBoolean,
|
|
903
|
-
merge: "prioritize-restrictive",
|
|
904
|
-
example: "false"
|
|
905
|
-
},
|
|
906
898
|
{
|
|
907
899
|
key: "lens.agent",
|
|
908
900
|
description: "Coding-agent id remembered by `argent lens` to skip the picker.",
|
|
@@ -1595,6 +1587,10 @@ var init_failure_codes = __esm({
|
|
|
1595
1587
|
AX_DAEMON_READY_TIMEOUT: "AX_DAEMON_READY_TIMEOUT",
|
|
1596
1588
|
AX_DAEMON_EXITED_BEFORE_READY: "AX_DAEMON_EXITED_BEFORE_READY",
|
|
1597
1589
|
AX_DAEMON_PROCESS_ERROR: "AX_DAEMON_PROCESS_ERROR",
|
|
1590
|
+
// The daemon died on a fault signal (SIGSEGV, SIGABRT, ...), before or after
|
|
1591
|
+
// it connected. Kept apart from the two codes above so a crash is not read
|
|
1592
|
+
// as an ordinary exit.
|
|
1593
|
+
AX_DAEMON_CRASHED: "AX_DAEMON_CRASHED",
|
|
1598
1594
|
AX_FACTORY_OPTIONS_MISSING: "AX_FACTORY_OPTIONS_MISSING",
|
|
1599
1595
|
AX_WRONG_PLATFORM: "AX_WRONG_PLATFORM",
|
|
1600
1596
|
AX_DEVICE_ID_INVALID: "AX_DEVICE_ID_INVALID",
|
|
@@ -79843,10 +79839,10 @@ async function probeAlive(device) {
|
|
|
79843
79839
|
async function listExternalDevices(options = {}) {
|
|
79844
79840
|
const providers = discoverProviders();
|
|
79845
79841
|
if (providers.length === 0) return [];
|
|
79846
|
-
const
|
|
79847
|
-
if (options.probe === false) return
|
|
79848
|
-
const alive = await Promise.all(
|
|
79849
|
-
return
|
|
79842
|
+
const devices2 = providers.flatMap((record2) => readProviderDevices2(record2));
|
|
79843
|
+
if (options.probe === false) return devices2;
|
|
79844
|
+
const alive = await Promise.all(devices2.map((device) => probeAlive(device).catch(() => false)));
|
|
79845
|
+
return devices2.filter((_, index) => alive[index]);
|
|
79850
79846
|
}
|
|
79851
79847
|
function findExternalDevice(id) {
|
|
79852
79848
|
const parsed = parseExternalId(id);
|
|
@@ -84116,7 +84112,7 @@ async function removeAdbReverse(serial, devicePort) {
|
|
|
84116
84112
|
}
|
|
84117
84113
|
}
|
|
84118
84114
|
function parseAdbDevices(stdout) {
|
|
84119
|
-
const
|
|
84115
|
+
const devices2 = [];
|
|
84120
84116
|
const lines = stdout.split("\n");
|
|
84121
84117
|
for (const raw of lines) {
|
|
84122
84118
|
const line = raw.trim();
|
|
@@ -84125,9 +84121,9 @@ function parseAdbDevices(stdout) {
|
|
|
84125
84121
|
if (!match) continue;
|
|
84126
84122
|
const state3 = match[2];
|
|
84127
84123
|
if (!ADB_DEVICE_STATES.has(state3)) continue;
|
|
84128
|
-
|
|
84124
|
+
devices2.push({ serial: match[1], state: state3 });
|
|
84129
84125
|
}
|
|
84130
|
-
return
|
|
84126
|
+
return devices2;
|
|
84131
84127
|
}
|
|
84132
84128
|
function consolePortFromAdbSerial(serial) {
|
|
84133
84129
|
const emu = serial.match(/^emulator-(\d+)$/);
|
|
@@ -100671,7 +100667,8 @@ var ALLOWED = {
|
|
|
100671
100667
|
install_mode: INSTALL_MODE
|
|
100672
100668
|
},
|
|
100673
100669
|
"installation:allowlist_decision": {
|
|
100674
|
-
is_enabled: bool
|
|
100670
|
+
is_enabled: bool,
|
|
100671
|
+
decided_by: oneOf(["flag", "default", "prompt"])
|
|
100675
100672
|
},
|
|
100676
100673
|
"installation:stale_config_cleanup": {
|
|
100677
100674
|
removed_count: COUNT,
|
|
@@ -101281,7 +101278,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
|
|
|
101281
101278
|
var SESSION_ID = (0, import_node_crypto3.randomUUID)();
|
|
101282
101279
|
function readCliVersion() {
|
|
101283
101280
|
if (true) {
|
|
101284
|
-
return "0.34.1-next.
|
|
101281
|
+
return "0.34.1-next.11";
|
|
101285
101282
|
}
|
|
101286
101283
|
return "0.0.0";
|
|
101287
101284
|
}
|
|
@@ -103827,7 +103824,7 @@ async function setContainsUdid(deviceSet, udid) {
|
|
|
103827
103824
|
);
|
|
103828
103825
|
const data = JSON.parse(stdout);
|
|
103829
103826
|
return Object.values(data.devices ?? {}).some(
|
|
103830
|
-
(
|
|
103827
|
+
(devices2) => devices2.some((d) => d.udid === udid)
|
|
103831
103828
|
);
|
|
103832
103829
|
} catch {
|
|
103833
103830
|
return false;
|
|
@@ -103926,10 +103923,10 @@ async function listDeviceSetSimulators(deviceSet) {
|
|
|
103926
103923
|
const data = JSON.parse(stdout);
|
|
103927
103924
|
const out = [];
|
|
103928
103925
|
const deviceTypes = [];
|
|
103929
|
-
for (const [runtimeId,
|
|
103926
|
+
for (const [runtimeId, devices2] of Object.entries(data.devices)) {
|
|
103930
103927
|
const runtimeKind = simulatorRuntimeKind(runtimeId);
|
|
103931
103928
|
if (!runtimeKind) continue;
|
|
103932
|
-
for (const d of
|
|
103929
|
+
for (const d of devices2) {
|
|
103933
103930
|
if (!d.isAvailable) continue;
|
|
103934
103931
|
out.push({
|
|
103935
103932
|
udid: d.udid,
|
|
@@ -104180,8 +104177,8 @@ async function getRemoteSimulatorRuntimeKind(udid, options) {
|
|
|
104180
104177
|
const cached3 = remoteRuntimeKindCache.get(id);
|
|
104181
104178
|
if (cached3) return cached3;
|
|
104182
104179
|
try {
|
|
104183
|
-
const { devices } = await simctlListDevices(options);
|
|
104184
|
-
for (const [runtime, entries] of Object.entries(
|
|
104180
|
+
const { devices: devices2 } = await simctlListDevices(options);
|
|
104181
|
+
for (const [runtime, entries] of Object.entries(devices2)) {
|
|
104185
104182
|
if (!entries.some((d) => d.udid === id)) continue;
|
|
104186
104183
|
const kind = simulatorRuntimeKind(runtime);
|
|
104187
104184
|
if (kind) remoteRuntimeKindCache.set(id, kind);
|
|
@@ -104695,7 +104692,112 @@ function startListener(endpoint, onConnection) {
|
|
|
104695
104692
|
}
|
|
104696
104693
|
});
|
|
104697
104694
|
}
|
|
104698
|
-
|
|
104695
|
+
var DARWIN_SIGNALS = {
|
|
104696
|
+
1: "SIGHUP",
|
|
104697
|
+
2: "SIGINT",
|
|
104698
|
+
3: "SIGQUIT",
|
|
104699
|
+
4: "SIGILL",
|
|
104700
|
+
5: "SIGTRAP",
|
|
104701
|
+
6: "SIGABRT",
|
|
104702
|
+
7: "SIGEMT",
|
|
104703
|
+
8: "SIGFPE",
|
|
104704
|
+
9: "SIGKILL",
|
|
104705
|
+
10: "SIGBUS",
|
|
104706
|
+
11: "SIGSEGV",
|
|
104707
|
+
12: "SIGSYS",
|
|
104708
|
+
13: "SIGPIPE",
|
|
104709
|
+
14: "SIGALRM",
|
|
104710
|
+
15: "SIGTERM"
|
|
104711
|
+
};
|
|
104712
|
+
var FAULT_SIGNALS = /* @__PURE__ */ new Set([
|
|
104713
|
+
"SIGILL",
|
|
104714
|
+
"SIGTRAP",
|
|
104715
|
+
"SIGABRT",
|
|
104716
|
+
"SIGEMT",
|
|
104717
|
+
"SIGFPE",
|
|
104718
|
+
"SIGBUS",
|
|
104719
|
+
"SIGSEGV",
|
|
104720
|
+
"SIGSYS"
|
|
104721
|
+
]);
|
|
104722
|
+
var SIMCTL_CHILD_SIGNAL = /Child process terminated with signal (\d+)/;
|
|
104723
|
+
var STDERR_DRAIN_MS = 250;
|
|
104724
|
+
var STDERR_TAIL_CHARS = 4e3;
|
|
104725
|
+
var DAEMON_EXIT_GRACE_MS = 1e3;
|
|
104726
|
+
function readAxDaemonExit(code, signal, stderr) {
|
|
104727
|
+
if (signal) return { code, signal };
|
|
104728
|
+
const reported = SIMCTL_CHILD_SIGNAL.exec(stderr);
|
|
104729
|
+
if (!reported) return { code };
|
|
104730
|
+
const number4 = Number(reported[1]);
|
|
104731
|
+
return { code, signal: DARWIN_SIGNALS[number4] ?? `signal ${number4}` };
|
|
104732
|
+
}
|
|
104733
|
+
var AxDaemonCrashError = class extends FailureError {
|
|
104734
|
+
signalName;
|
|
104735
|
+
constructor(message, signal, signalName) {
|
|
104736
|
+
super(message, signal);
|
|
104737
|
+
this.name = "AxDaemonCrashError";
|
|
104738
|
+
this.signalName = signalName;
|
|
104739
|
+
}
|
|
104740
|
+
};
|
|
104741
|
+
function findInCauses(err, pick2) {
|
|
104742
|
+
let current = err;
|
|
104743
|
+
for (let depth = 0; current instanceof Error && depth < 8; depth++) {
|
|
104744
|
+
const found = pick2(current);
|
|
104745
|
+
if (found !== void 0) return found;
|
|
104746
|
+
current = current.cause;
|
|
104747
|
+
}
|
|
104748
|
+
return void 0;
|
|
104749
|
+
}
|
|
104750
|
+
function axDaemonCrashSignal(err) {
|
|
104751
|
+
return findInCauses(
|
|
104752
|
+
err,
|
|
104753
|
+
(error63) => error63 instanceof AxDaemonCrashError ? error63.signalName : void 0
|
|
104754
|
+
);
|
|
104755
|
+
}
|
|
104756
|
+
var startFailureDegraded = /* @__PURE__ */ new WeakMap();
|
|
104757
|
+
function axStartFailureDegraded(err) {
|
|
104758
|
+
return findInCauses(err, (error63) => startFailureDegraded.get(error63));
|
|
104759
|
+
}
|
|
104760
|
+
function axDaemonExitError(exit, phase) {
|
|
104761
|
+
const suffix = phase === "connecting" ? " before connecting" : "";
|
|
104762
|
+
const signal = {
|
|
104763
|
+
error_code: phase === "connecting" ? FAILURE_CODES.AX_DAEMON_EXITED_BEFORE_READY : FAILURE_CODES.AX_DAEMON_PROCESS_ERROR,
|
|
104764
|
+
failure_stage: phase === "connecting" ? "ax_service_spawn_ready" : "ax_service_process_exit",
|
|
104765
|
+
failure_area: "tool_server",
|
|
104766
|
+
error_kind: "subprocess",
|
|
104767
|
+
...subprocessFailureMetadata(exit, "ax_service")
|
|
104768
|
+
};
|
|
104769
|
+
if (exit.signal === void 0) {
|
|
104770
|
+
return new FailureError(`ax-service exited with code ${exit.code}${suffix}`, signal);
|
|
104771
|
+
}
|
|
104772
|
+
if (!FAULT_SIGNALS.has(exit.signal)) {
|
|
104773
|
+
return new FailureError(`ax-service was killed by ${exit.signal}${suffix}`, signal);
|
|
104774
|
+
}
|
|
104775
|
+
return new AxDaemonCrashError(
|
|
104776
|
+
`ax-service crashed with ${exit.signal}${suffix}`,
|
|
104777
|
+
{ ...signal, error_code: FAILURE_CODES.AX_DAEMON_CRASHED },
|
|
104778
|
+
exit.signal
|
|
104779
|
+
);
|
|
104780
|
+
}
|
|
104781
|
+
function watchDaemonExit(proc, onExit) {
|
|
104782
|
+
return new Promise((resolve19) => {
|
|
104783
|
+
let stderrTail = "";
|
|
104784
|
+
proc.stderr?.on("data", (chunk) => {
|
|
104785
|
+
stderrTail = (stderrTail + chunk.toString()).slice(-STDERR_TAIL_CHARS);
|
|
104786
|
+
});
|
|
104787
|
+
proc.once("exit", (code, signal) => {
|
|
104788
|
+
onExit();
|
|
104789
|
+
const settle3 = () => resolve19(readAxDaemonExit(code, signal, stderrTail));
|
|
104790
|
+
const stderr = proc.stderr;
|
|
104791
|
+
if (signal || !stderr || stderr.readableEnded) return settle3();
|
|
104792
|
+
const timer = setTimeout(settle3, STDERR_DRAIN_MS);
|
|
104793
|
+
stderr.once("end", () => {
|
|
104794
|
+
clearTimeout(timer);
|
|
104795
|
+
settle3();
|
|
104796
|
+
});
|
|
104797
|
+
});
|
|
104798
|
+
});
|
|
104799
|
+
}
|
|
104800
|
+
function waitForDaemonConnection(server, proc, exited, timeoutMs) {
|
|
104699
104801
|
return new Promise((resolve19, reject) => {
|
|
104700
104802
|
let settled = false;
|
|
104701
104803
|
const onConnection = (socket) => {
|
|
@@ -104704,19 +104806,12 @@ function waitForDaemonConnection(server, proc, timeoutMs) {
|
|
|
104704
104806
|
cleanup();
|
|
104705
104807
|
resolve19(socket);
|
|
104706
104808
|
};
|
|
104707
|
-
|
|
104809
|
+
void exited.then((exit) => {
|
|
104708
104810
|
if (settled) return;
|
|
104709
104811
|
settled = true;
|
|
104710
104812
|
cleanup();
|
|
104711
|
-
reject(
|
|
104712
|
-
|
|
104713
|
-
error_code: FAILURE_CODES.AX_DAEMON_EXITED_BEFORE_READY,
|
|
104714
|
-
failure_stage: "ax_service_spawn_ready",
|
|
104715
|
-
failure_area: "tool_server",
|
|
104716
|
-
error_kind: "subprocess"
|
|
104717
|
-
})
|
|
104718
|
-
);
|
|
104719
|
-
};
|
|
104813
|
+
reject(axDaemonExitError(exit, "connecting"));
|
|
104814
|
+
});
|
|
104720
104815
|
const onError = (err) => {
|
|
104721
104816
|
if (settled) return;
|
|
104722
104817
|
settled = true;
|
|
@@ -104750,11 +104845,9 @@ function waitForDaemonConnection(server, proc, timeoutMs) {
|
|
|
104750
104845
|
const cleanup = () => {
|
|
104751
104846
|
clearTimeout(timer);
|
|
104752
104847
|
server.off("connection", onConnection);
|
|
104753
|
-
proc.off("exit", onExit);
|
|
104754
104848
|
proc.off("error", onError);
|
|
104755
104849
|
};
|
|
104756
104850
|
server.on("connection", onConnection);
|
|
104757
|
-
proc.on("exit", onExit);
|
|
104758
104851
|
proc.on("error", onError);
|
|
104759
104852
|
});
|
|
104760
104853
|
}
|
|
@@ -104809,6 +104902,10 @@ var axServiceBlueprint = {
|
|
|
104809
104902
|
let nextRpcId = 1;
|
|
104810
104903
|
let daemonSocket = null;
|
|
104811
104904
|
let disposed = false;
|
|
104905
|
+
let exitSeen = false;
|
|
104906
|
+
let awaitingVerdict = false;
|
|
104907
|
+
let disconnectTimer;
|
|
104908
|
+
const exitGraceMs = host.kind === "local" ? DAEMON_EXIT_GRACE_MS : 0;
|
|
104812
104909
|
const failPending = (err) => {
|
|
104813
104910
|
for (const { reject, timer } of pendingRpc.values()) {
|
|
104814
104911
|
clearTimeout(timer);
|
|
@@ -104816,7 +104913,18 @@ var axServiceBlueprint = {
|
|
|
104816
104913
|
}
|
|
104817
104914
|
pendingRpc.clear();
|
|
104818
104915
|
};
|
|
104916
|
+
const terminate = (err) => {
|
|
104917
|
+
if (disposed) return;
|
|
104918
|
+
clearTimeout(disconnectTimer);
|
|
104919
|
+
awaitingVerdict = false;
|
|
104920
|
+
failPending(err);
|
|
104921
|
+
events.emit("terminated", err);
|
|
104922
|
+
};
|
|
104819
104923
|
const { entitlementBypassActive } = await host.bootstrapAx(udid);
|
|
104924
|
+
const startFailed = (err) => {
|
|
104925
|
+
if (err instanceof Error) startFailureDegraded.set(err, !entitlementBypassActive);
|
|
104926
|
+
return err;
|
|
104927
|
+
};
|
|
104820
104928
|
const server = await startListener(endpoint, (socket) => {
|
|
104821
104929
|
if (daemonSocket && !daemonSocket.destroyed) {
|
|
104822
104930
|
daemonSocket.destroy();
|
|
@@ -104849,57 +104957,29 @@ var axServiceBlueprint = {
|
|
|
104849
104957
|
}
|
|
104850
104958
|
});
|
|
104851
104959
|
socket.on("close", () => {
|
|
104852
|
-
if (daemonSocket
|
|
104853
|
-
|
|
104854
|
-
|
|
104855
|
-
|
|
104856
|
-
|
|
104857
|
-
|
|
104858
|
-
|
|
104859
|
-
|
|
104860
|
-
|
|
104861
|
-
|
|
104862
|
-
|
|
104863
|
-
}
|
|
104864
|
-
|
|
104960
|
+
if (daemonSocket !== socket) return;
|
|
104961
|
+
daemonSocket = null;
|
|
104962
|
+
if (disposed) return;
|
|
104963
|
+
awaitingVerdict = true;
|
|
104964
|
+
if (exitSeen) return;
|
|
104965
|
+
const disconnected = () => terminate(
|
|
104966
|
+
new FailureError("ax-service daemon disconnected", {
|
|
104967
|
+
error_code: FAILURE_CODES.AX_DAEMON_PROCESS_ERROR,
|
|
104968
|
+
failure_stage: "ax_service_socket_close",
|
|
104969
|
+
failure_area: "tool_server",
|
|
104970
|
+
error_kind: "subprocess"
|
|
104971
|
+
})
|
|
104972
|
+
);
|
|
104973
|
+
if (exitGraceMs === 0) disconnected();
|
|
104974
|
+
else disconnectTimer = setTimeout(disconnected, exitGraceMs);
|
|
104865
104975
|
});
|
|
104866
104976
|
socket.on("error", () => {
|
|
104867
104977
|
});
|
|
104978
|
+
}).catch((err) => {
|
|
104979
|
+
throw startFailed(err);
|
|
104868
104980
|
});
|
|
104869
|
-
|
|
104870
|
-
|
|
104871
|
-
}
|
|
104872
|
-
const proc = host.spawnAxDaemon(udid, endpoint);
|
|
104873
|
-
proc.on("exit", (code) => {
|
|
104874
|
-
if (disposed) return;
|
|
104875
|
-
const err = new FailureError(`ax-service exited with code ${code}`, {
|
|
104876
|
-
error_code: FAILURE_CODES.AX_DAEMON_PROCESS_ERROR,
|
|
104877
|
-
failure_stage: "ax_service_process_exit",
|
|
104878
|
-
failure_area: "tool_server",
|
|
104879
|
-
error_kind: "subprocess"
|
|
104880
|
-
});
|
|
104881
|
-
failPending(err);
|
|
104882
|
-
events.emit("terminated", err);
|
|
104883
|
-
});
|
|
104884
|
-
proc.on("error", (err) => {
|
|
104885
|
-
if (disposed) return;
|
|
104886
|
-
const error63 = new FailureError(
|
|
104887
|
-
err instanceof Error ? err.message : String(err),
|
|
104888
|
-
{
|
|
104889
|
-
error_code: FAILURE_CODES.AX_DAEMON_PROCESS_ERROR,
|
|
104890
|
-
failure_stage: "ax_service_spawn_process",
|
|
104891
|
-
failure_area: "tool_server",
|
|
104892
|
-
error_kind: "subprocess"
|
|
104893
|
-
},
|
|
104894
|
-
{ cause: err instanceof Error ? err : new Error(String(err)) }
|
|
104895
|
-
);
|
|
104896
|
-
failPending(error63);
|
|
104897
|
-
events.emit("terminated", error63);
|
|
104898
|
-
});
|
|
104899
|
-
try {
|
|
104900
|
-
daemonSocket = await waitForDaemonConnection(server, proc, 1e4);
|
|
104901
|
-
} catch (err) {
|
|
104902
|
-
if (!proc.killed) proc.kill("SIGTERM");
|
|
104981
|
+
let proxyStarted = false;
|
|
104982
|
+
const abandonStart = async () => {
|
|
104903
104983
|
server.close();
|
|
104904
104984
|
if (endpoint.transport === "unix") {
|
|
104905
104985
|
try {
|
|
@@ -104907,14 +104987,51 @@ var axServiceBlueprint = {
|
|
|
104907
104987
|
} catch {
|
|
104908
104988
|
}
|
|
104909
104989
|
}
|
|
104910
|
-
if (endpoint.transport === "tcp") {
|
|
104990
|
+
if (endpoint.transport === "tcp" && proxyStarted) {
|
|
104911
104991
|
await host.stopProxy(udid, endpoint.port);
|
|
104912
104992
|
}
|
|
104913
|
-
|
|
104993
|
+
};
|
|
104994
|
+
let proc;
|
|
104995
|
+
try {
|
|
104996
|
+
if (endpoint.transport === "tcp") {
|
|
104997
|
+
await host.startProxy(udid, endpoint.port);
|
|
104998
|
+
proxyStarted = true;
|
|
104999
|
+
}
|
|
105000
|
+
proc = host.spawnAxDaemon(udid, endpoint);
|
|
105001
|
+
} catch (err) {
|
|
105002
|
+
await abandonStart();
|
|
105003
|
+
throw startFailed(err);
|
|
105004
|
+
}
|
|
105005
|
+
const exited = watchDaemonExit(proc, () => {
|
|
105006
|
+
exitSeen = true;
|
|
105007
|
+
clearTimeout(disconnectTimer);
|
|
105008
|
+
});
|
|
105009
|
+
proc.on("error", (err) => {
|
|
105010
|
+
terminate(
|
|
105011
|
+
new FailureError(
|
|
105012
|
+
err instanceof Error ? err.message : String(err),
|
|
105013
|
+
{
|
|
105014
|
+
error_code: FAILURE_CODES.AX_DAEMON_PROCESS_ERROR,
|
|
105015
|
+
failure_stage: "ax_service_spawn_process",
|
|
105016
|
+
failure_area: "tool_server",
|
|
105017
|
+
error_kind: "subprocess"
|
|
105018
|
+
},
|
|
105019
|
+
{ cause: err instanceof Error ? err : new Error(String(err)) }
|
|
105020
|
+
)
|
|
105021
|
+
);
|
|
105022
|
+
});
|
|
105023
|
+
try {
|
|
105024
|
+
daemonSocket = await waitForDaemonConnection(server, proc, exited, 1e4);
|
|
105025
|
+
} catch (err) {
|
|
105026
|
+
if (!proc.killed) proc.kill("SIGTERM");
|
|
105027
|
+
await abandonStart();
|
|
105028
|
+
throw startFailed(err);
|
|
104914
105029
|
}
|
|
105030
|
+
void exited.then((exit) => terminate(axDaemonExitError(exit, "connected")));
|
|
104915
105031
|
function query(command, timeoutMs = 5e3, params) {
|
|
104916
105032
|
return new Promise((resolve19, reject) => {
|
|
104917
|
-
|
|
105033
|
+
const socket = daemonSocket && !daemonSocket.destroyed ? daemonSocket : null;
|
|
105034
|
+
if (!socket && !awaitingVerdict) {
|
|
104918
105035
|
reject(
|
|
104919
105036
|
new FailureError("ax-service not connected", {
|
|
104920
105037
|
error_code: FAILURE_CODES.AX_QUERY_FAILED,
|
|
@@ -104940,7 +105057,7 @@ var axServiceBlueprint = {
|
|
|
104940
105057
|
}
|
|
104941
105058
|
}, timeoutMs);
|
|
104942
105059
|
pendingRpc.set(id, { resolve: resolve19, reject, timer });
|
|
104943
|
-
|
|
105060
|
+
socket?.write(
|
|
104944
105061
|
JSON.stringify(params === void 0 ? { id, command } : { id, command, params }) + "\n"
|
|
104945
105062
|
);
|
|
104946
105063
|
});
|
|
@@ -105058,6 +105175,8 @@ var axServiceBlueprint = {
|
|
|
105058
105175
|
api,
|
|
105059
105176
|
dispose: async () => {
|
|
105060
105177
|
disposed = true;
|
|
105178
|
+
clearTimeout(disconnectTimer);
|
|
105179
|
+
awaitingVerdict = false;
|
|
105061
105180
|
failPending(new Error("ax-service disposed"));
|
|
105062
105181
|
if (daemonSocket && !daemonSocket.destroyed) {
|
|
105063
105182
|
daemonSocket.destroy();
|
|
@@ -123120,6 +123239,203 @@ function disposeWhenTransportDies(session, onDispose) {
|
|
|
123120
123239
|
void session.closed.then(dispose, dispose);
|
|
123121
123240
|
}
|
|
123122
123241
|
|
|
123242
|
+
// ../tool-server/src/tools/screen-recording/mjpeg-stream.ts
|
|
123243
|
+
var import_http = __toESM(require("http"));
|
|
123244
|
+
init_src2();
|
|
123245
|
+
var MAX_BUFFER_BYTES = 64 * 1024 * 1024;
|
|
123246
|
+
function delimiterFromContentType(contentType) {
|
|
123247
|
+
const match = /boundary=([^;\s]+)/i.exec(contentType ?? "");
|
|
123248
|
+
const boundary = match?.[1]?.replace(/^"|"$/g, "") ?? "NextFrame";
|
|
123249
|
+
return Buffer.from(`--${boundary}`);
|
|
123250
|
+
}
|
|
123251
|
+
function streamFailure(message, stage, kind = "network", cause) {
|
|
123252
|
+
return new FailureError(
|
|
123253
|
+
message,
|
|
123254
|
+
{
|
|
123255
|
+
error_code: FAILURE_CODES.SCREEN_RECORDING_STREAM_UNAVAILABLE,
|
|
123256
|
+
failure_stage: stage,
|
|
123257
|
+
failure_area: "tool_server",
|
|
123258
|
+
error_kind: kind,
|
|
123259
|
+
failure_command: "simulator_server"
|
|
123260
|
+
},
|
|
123261
|
+
cause instanceof Error ? { cause } : void 0
|
|
123262
|
+
);
|
|
123263
|
+
}
|
|
123264
|
+
function openMjpegStream(url2, connectTimeoutMs = 1e4) {
|
|
123265
|
+
return new Promise((resolve19, reject) => {
|
|
123266
|
+
let settled = false;
|
|
123267
|
+
const request3 = import_http.default.get(url2, (res) => {
|
|
123268
|
+
request3.setTimeout(0);
|
|
123269
|
+
res.socket?.setTimeout(0);
|
|
123270
|
+
if (res.statusCode !== 200) {
|
|
123271
|
+
res.resume();
|
|
123272
|
+
settled = true;
|
|
123273
|
+
reject(
|
|
123274
|
+
streamFailure(
|
|
123275
|
+
`simulator-server's frame stream returned HTTP ${res.statusCode ?? "?"} at ${url2}.`,
|
|
123276
|
+
"screen_recording_stream_connect"
|
|
123277
|
+
)
|
|
123278
|
+
);
|
|
123279
|
+
return;
|
|
123280
|
+
}
|
|
123281
|
+
const delimiter = delimiterFromContentType(res.headers["content-type"]);
|
|
123282
|
+
let buffer = Buffer.alloc(0);
|
|
123283
|
+
const state3 = {
|
|
123284
|
+
latest: null,
|
|
123285
|
+
frameCount: 0,
|
|
123286
|
+
error: null
|
|
123287
|
+
};
|
|
123288
|
+
let firstFrameResolve = null;
|
|
123289
|
+
let firstFrameReject = null;
|
|
123290
|
+
res.on("data", (chunk) => {
|
|
123291
|
+
buffer = buffer.length === 0 ? chunk : Buffer.concat([buffer, chunk]);
|
|
123292
|
+
for (; ; ) {
|
|
123293
|
+
const partStart = buffer.indexOf(delimiter);
|
|
123294
|
+
if (partStart < 0) break;
|
|
123295
|
+
const headerEnd = buffer.indexOf("\r\n\r\n", partStart);
|
|
123296
|
+
if (headerEnd < 0) break;
|
|
123297
|
+
const frameStart = headerEnd + 4;
|
|
123298
|
+
const frameEnd = buffer.indexOf(delimiter, frameStart);
|
|
123299
|
+
if (frameEnd < 0) break;
|
|
123300
|
+
if (frameEnd > frameStart) {
|
|
123301
|
+
const frame2 = Buffer.from(buffer.subarray(frameStart, frameEnd));
|
|
123302
|
+
state3.latest = frame2;
|
|
123303
|
+
state3.frameCount++;
|
|
123304
|
+
if (firstFrameResolve) {
|
|
123305
|
+
firstFrameResolve(frame2);
|
|
123306
|
+
firstFrameResolve = null;
|
|
123307
|
+
firstFrameReject = null;
|
|
123308
|
+
}
|
|
123309
|
+
}
|
|
123310
|
+
buffer = buffer.subarray(frameEnd);
|
|
123311
|
+
}
|
|
123312
|
+
if (buffer.length > MAX_BUFFER_BYTES) buffer = Buffer.alloc(0);
|
|
123313
|
+
});
|
|
123314
|
+
const fail = (err) => {
|
|
123315
|
+
state3.error = err;
|
|
123316
|
+
if (firstFrameReject) {
|
|
123317
|
+
const reject2 = firstFrameReject;
|
|
123318
|
+
firstFrameResolve = null;
|
|
123319
|
+
firstFrameReject = null;
|
|
123320
|
+
reject2(
|
|
123321
|
+
streamFailure(
|
|
123322
|
+
`simulator-server's frame stream dropped before the first frame arrived: ${err.message}`,
|
|
123323
|
+
"screen_recording_stream_first_frame",
|
|
123324
|
+
"network",
|
|
123325
|
+
err
|
|
123326
|
+
)
|
|
123327
|
+
);
|
|
123328
|
+
}
|
|
123329
|
+
};
|
|
123330
|
+
res.on("error", fail);
|
|
123331
|
+
res.on("aborted", () => fail(new Error("frame stream aborted")));
|
|
123332
|
+
settled = true;
|
|
123333
|
+
resolve19({
|
|
123334
|
+
get latest() {
|
|
123335
|
+
return state3.latest;
|
|
123336
|
+
},
|
|
123337
|
+
get frameCount() {
|
|
123338
|
+
return state3.frameCount;
|
|
123339
|
+
},
|
|
123340
|
+
get error() {
|
|
123341
|
+
return state3.error;
|
|
123342
|
+
},
|
|
123343
|
+
waitForFirstFrame(timeoutMs) {
|
|
123344
|
+
if (state3.latest) return Promise.resolve(state3.latest);
|
|
123345
|
+
if (state3.error) {
|
|
123346
|
+
return Promise.reject(
|
|
123347
|
+
streamFailure(
|
|
123348
|
+
`simulator-server's frame stream dropped before any frame arrived: ${state3.error.message}`,
|
|
123349
|
+
"screen_recording_stream_first_frame",
|
|
123350
|
+
"network",
|
|
123351
|
+
state3.error
|
|
123352
|
+
)
|
|
123353
|
+
);
|
|
123354
|
+
}
|
|
123355
|
+
return new Promise((resolveFrame, rejectFrame) => {
|
|
123356
|
+
const timer = setTimeout(() => {
|
|
123357
|
+
firstFrameResolve = null;
|
|
123358
|
+
firstFrameReject = null;
|
|
123359
|
+
rejectFrame(
|
|
123360
|
+
streamFailure(
|
|
123361
|
+
`No frame arrived from simulator-server within ${timeoutMs} ms. Is the device booted and its screen on?`,
|
|
123362
|
+
"screen_recording_stream_first_frame",
|
|
123363
|
+
"timeout"
|
|
123364
|
+
)
|
|
123365
|
+
);
|
|
123366
|
+
}, timeoutMs);
|
|
123367
|
+
firstFrameResolve = (frame2) => {
|
|
123368
|
+
clearTimeout(timer);
|
|
123369
|
+
firstFrameReject = null;
|
|
123370
|
+
resolveFrame(frame2);
|
|
123371
|
+
};
|
|
123372
|
+
firstFrameReject = (err) => {
|
|
123373
|
+
clearTimeout(timer);
|
|
123374
|
+
firstFrameResolve = null;
|
|
123375
|
+
rejectFrame(err);
|
|
123376
|
+
};
|
|
123377
|
+
});
|
|
123378
|
+
},
|
|
123379
|
+
close() {
|
|
123380
|
+
firstFrameResolve = null;
|
|
123381
|
+
firstFrameReject = null;
|
|
123382
|
+
res.destroy();
|
|
123383
|
+
request3.destroy();
|
|
123384
|
+
}
|
|
123385
|
+
});
|
|
123386
|
+
});
|
|
123387
|
+
request3.setTimeout(connectTimeoutMs, () => {
|
|
123388
|
+
request3.destroy(
|
|
123389
|
+
streamFailure(
|
|
123390
|
+
`Connecting to simulator-server's frame stream at ${url2} timed out after ${connectTimeoutMs} ms.`,
|
|
123391
|
+
"screen_recording_stream_connect",
|
|
123392
|
+
"timeout"
|
|
123393
|
+
)
|
|
123394
|
+
);
|
|
123395
|
+
});
|
|
123396
|
+
request3.on("error", (err) => {
|
|
123397
|
+
if (settled) return;
|
|
123398
|
+
settled = true;
|
|
123399
|
+
reject(
|
|
123400
|
+
err instanceof FailureError ? err : streamFailure(
|
|
123401
|
+
`Could not open simulator-server's frame stream at ${url2}: ${err.message}`,
|
|
123402
|
+
"screen_recording_stream_connect",
|
|
123403
|
+
"network",
|
|
123404
|
+
err
|
|
123405
|
+
)
|
|
123406
|
+
);
|
|
123407
|
+
});
|
|
123408
|
+
});
|
|
123409
|
+
}
|
|
123410
|
+
function readJpegDimensions(jpeg) {
|
|
123411
|
+
let offset = 2;
|
|
123412
|
+
while (offset + 9 < jpeg.length) {
|
|
123413
|
+
if (jpeg[offset] !== 255) {
|
|
123414
|
+
offset++;
|
|
123415
|
+
continue;
|
|
123416
|
+
}
|
|
123417
|
+
const marker = jpeg[offset + 1];
|
|
123418
|
+
if (marker === 255) {
|
|
123419
|
+
offset++;
|
|
123420
|
+
continue;
|
|
123421
|
+
}
|
|
123422
|
+
if (marker === 216 || marker === 1 || marker >= 208 && marker <= 215) {
|
|
123423
|
+
offset += 2;
|
|
123424
|
+
continue;
|
|
123425
|
+
}
|
|
123426
|
+
if (marker === 192 || marker === 193 || marker === 194) {
|
|
123427
|
+
const height = jpeg.readUInt16BE(offset + 5);
|
|
123428
|
+
const width = jpeg.readUInt16BE(offset + 7);
|
|
123429
|
+
if (width > 0 && height > 0) return { width, height };
|
|
123430
|
+
return null;
|
|
123431
|
+
}
|
|
123432
|
+
const segmentLength = jpeg.readUInt16BE(offset + 2);
|
|
123433
|
+
if (segmentLength < 2) return null;
|
|
123434
|
+
offset += 2 + segmentLength;
|
|
123435
|
+
}
|
|
123436
|
+
return null;
|
|
123437
|
+
}
|
|
123438
|
+
|
|
123123
123439
|
// ../tool-server/src/utils/simulator-client.ts
|
|
123124
123440
|
init_wrapper();
|
|
123125
123441
|
init_src2();
|
|
@@ -123212,6 +123528,9 @@ function registerCaptureOnDemandSender(deviceId, endpoint, send) {
|
|
|
123212
123528
|
if (entry.onDemand) entry.send(false);
|
|
123213
123529
|
};
|
|
123214
123530
|
}
|
|
123531
|
+
function simulatorServerDeviceIds() {
|
|
123532
|
+
return [...servers.keys()];
|
|
123533
|
+
}
|
|
123215
123534
|
function captureOnDemandDropped(deviceId, endpoint) {
|
|
123216
123535
|
const server = servers.get(deviceId);
|
|
123217
123536
|
if (server?.endpoint === endpoint) server.onDemand = false;
|
|
@@ -124677,8 +124996,8 @@ async function getBootedUdidsInSet(deviceSet, signal) {
|
|
|
124677
124996
|
});
|
|
124678
124997
|
const data = JSON.parse(stdout);
|
|
124679
124998
|
const udids = /* @__PURE__ */ new Set();
|
|
124680
|
-
for (const
|
|
124681
|
-
for (const device of
|
|
124999
|
+
for (const devices2 of Object.values(data.devices)) {
|
|
125000
|
+
for (const device of devices2) {
|
|
124682
125001
|
if (device.state === "Booted") {
|
|
124683
125002
|
udids.add(device.udid);
|
|
124684
125003
|
rememberDeviceSet(device.udid, deviceSet);
|
|
@@ -124859,7 +125178,7 @@ var getPaths = () => {
|
|
|
124859
125178
|
return { BINARY_PATH, RUN_DIR };
|
|
124860
125179
|
};
|
|
124861
125180
|
var READY_TIMEOUT_MS = 3e4;
|
|
124862
|
-
var
|
|
125181
|
+
var STDERR_DRAIN_MS2 = 250;
|
|
124863
125182
|
var STDERR_TAIL_LINES = 10;
|
|
124864
125183
|
var STDERR_MAX_LINE_CHARS = 500;
|
|
124865
125184
|
var ROUTINE_LOG_LINE = /^\[\S+\s+(?:INFO|DEBUG|TRACE)\s/;
|
|
@@ -124962,6 +125281,31 @@ function subcommandForDevice(device) {
|
|
|
124962
125281
|
}
|
|
124963
125282
|
return device.kind === "device" ? "android_device" : "android";
|
|
124964
125283
|
}
|
|
125284
|
+
var EMULATOR_NOT_DISCOVERED = /not found among running emulators|Failed to find any running emulator/;
|
|
125285
|
+
var FIRST_FRAME_TIMEOUT_MS = 5e3;
|
|
125286
|
+
async function waitForFirstFrame(streamUrl) {
|
|
125287
|
+
if (!streamUrl) return;
|
|
125288
|
+
const stream = await openMjpegStream(streamUrl, FIRST_FRAME_TIMEOUT_MS).catch(() => null);
|
|
125289
|
+
if (!stream) return;
|
|
125290
|
+
await stream.waitForFirstFrame(FIRST_FRAME_TIMEOUT_MS).catch(() => {
|
|
125291
|
+
}).finally(() => stream.close());
|
|
125292
|
+
}
|
|
125293
|
+
async function spawnWithEmulatorFallback(device) {
|
|
125294
|
+
const subcommand = subcommandForDevice(device);
|
|
125295
|
+
try {
|
|
125296
|
+
return await spawnSimulatorServerProcess(device.id, subcommand);
|
|
125297
|
+
} catch (err) {
|
|
125298
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
125299
|
+
if (subcommand !== "android" || !EMULATOR_NOT_DISCOVERED.test(message)) throw err;
|
|
125300
|
+
process.stderr.write(
|
|
125301
|
+
`[sim ${device.id}] emulator not found through gRPC discovery; falling back to the adb screen-sharing controller
|
|
125302
|
+
`
|
|
125303
|
+
);
|
|
125304
|
+
const server = await spawnSimulatorServerProcess(device.id, "android_device");
|
|
125305
|
+
await waitForFirstFrame(server.streamUrl);
|
|
125306
|
+
return server;
|
|
125307
|
+
}
|
|
125308
|
+
}
|
|
124965
125309
|
async function spawnSimulatorServerProcess(udid, subcommand) {
|
|
124966
125310
|
if (!SAFE_SIMULATOR_DEVICE_ID.test(udid)) {
|
|
124967
125311
|
throw new Error(`Refusing to start simulator-server for unsafe device id "${udid}".`);
|
|
@@ -125055,7 +125399,7 @@ async function spawnSimulatorServerProcess(udid, subcommand) {
|
|
|
125055
125399
|
};
|
|
125056
125400
|
const stderr = proc.stderr;
|
|
125057
125401
|
if (settled || !stderr || stderr.readableEnded) return fail();
|
|
125058
|
-
const drainTimer = setTimeout(fail,
|
|
125402
|
+
const drainTimer = setTimeout(fail, STDERR_DRAIN_MS2);
|
|
125059
125403
|
stderr.once("end", () => {
|
|
125060
125404
|
clearTimeout(drainTimer);
|
|
125061
125405
|
fail();
|
|
@@ -125174,10 +125518,7 @@ var simulatorServerBlueprint = {
|
|
|
125174
125518
|
`${SIMULATOR_SERVER_NAMESPACE}.factory does not support platform "${device.platform}". Use the platform-specific service blueprint instead.`
|
|
125175
125519
|
);
|
|
125176
125520
|
}
|
|
125177
|
-
const { proc, apiUrl, streamUrl } = await
|
|
125178
|
-
device.id,
|
|
125179
|
-
subcommandForDevice(device)
|
|
125180
|
-
);
|
|
125521
|
+
const { proc, apiUrl, streamUrl } = await spawnWithEmulatorFallback(device);
|
|
125181
125522
|
const events = new TypedEventEmitter();
|
|
125182
125523
|
proc.on("exit", (code) => {
|
|
125183
125524
|
events.emit(
|
|
@@ -125778,9 +126119,9 @@ async function listIosPhysicalDevices() {
|
|
|
125778
126119
|
return [];
|
|
125779
126120
|
}
|
|
125780
126121
|
const payload = json2;
|
|
125781
|
-
const
|
|
126122
|
+
const devices2 = payload?.result?.devices ?? [];
|
|
125782
126123
|
const out = [];
|
|
125783
|
-
for (const d of
|
|
126124
|
+
for (const d of devices2) {
|
|
125784
126125
|
const hardwareProperties = d.hardwareProperties ?? {};
|
|
125785
126126
|
const udid = hardwareProperties.udid ?? d.identifier;
|
|
125786
126127
|
if (!udid) {
|
|
@@ -128412,7 +128753,7 @@ async function listVvdImages() {
|
|
|
128412
128753
|
var VEGA_DISCOVERY_LIST_TIMEOUT_MS = 6e3;
|
|
128413
128754
|
var VEGA_DISCOVERY_INFO_TIMEOUT_MS = 4e3;
|
|
128414
128755
|
function parseVegaDeviceList(stdout) {
|
|
128415
|
-
const
|
|
128756
|
+
const devices2 = [];
|
|
128416
128757
|
for (const raw of stdout.split("\n")) {
|
|
128417
128758
|
const line = raw.trim();
|
|
128418
128759
|
const sep11 = line.indexOf(" : ");
|
|
@@ -128423,12 +128764,12 @@ function parseVegaDeviceList(stdout) {
|
|
|
128423
128764
|
const parts2 = rhs.split(/\s+-\s+/);
|
|
128424
128765
|
const serial = parts2[parts2.length - 1]?.trim();
|
|
128425
128766
|
if (!serial) continue;
|
|
128426
|
-
|
|
128767
|
+
devices2.push({ serial, type });
|
|
128427
128768
|
}
|
|
128428
|
-
return
|
|
128769
|
+
return devices2;
|
|
128429
128770
|
}
|
|
128430
|
-
function filterVvdShadowsFromAndroid(
|
|
128431
|
-
return
|
|
128771
|
+
function filterVvdShadowsFromAndroid(androidDevices2, vvdAdbSerials) {
|
|
128772
|
+
return androidDevices2.filter((d) => !vvdAdbSerials.has(d.serial));
|
|
128432
128773
|
}
|
|
128433
128774
|
async function readVegaInfo() {
|
|
128434
128775
|
try {
|
|
@@ -128563,10 +128904,10 @@ async function listRemoteIosSimulators() {
|
|
|
128563
128904
|
try {
|
|
128564
128905
|
const result = await simctlListDevices();
|
|
128565
128906
|
const out = [];
|
|
128566
|
-
for (const [runtime,
|
|
128907
|
+
for (const [runtime, devices2] of Object.entries(result.devices)) {
|
|
128567
128908
|
const runtimeKind = simulatorRuntimeKind(runtime);
|
|
128568
128909
|
if (!runtimeKind) continue;
|
|
128569
|
-
for (const d of
|
|
128910
|
+
for (const d of devices2) {
|
|
128570
128911
|
if (d.isAvailable === false) continue;
|
|
128571
128912
|
out.push({
|
|
128572
128913
|
platform: "ios-remote",
|
|
@@ -128603,12 +128944,12 @@ function sortIosRemote(a, b) {
|
|
|
128603
128944
|
const bBooted = b.state === "Booted" ? 0 : 1;
|
|
128604
128945
|
return aBooted - bBooted;
|
|
128605
128946
|
}
|
|
128606
|
-
async function resolveVvdShadowAdbSerials(
|
|
128947
|
+
async function resolveVvdShadowAdbSerials(androidDevices2, vega) {
|
|
128607
128948
|
if (!vega.some((d) => d.kind === "vvd" && d.state === "running")) return /* @__PURE__ */ new Set();
|
|
128608
128949
|
const vvdPorts = await listRunningVvdConsolePorts();
|
|
128609
128950
|
if (vvdPorts.size === 0) return /* @__PURE__ */ new Set();
|
|
128610
128951
|
const shadows = /* @__PURE__ */ new Set();
|
|
128611
|
-
for (const d of
|
|
128952
|
+
for (const d of androidDevices2) {
|
|
128612
128953
|
const port = consolePortFromAdbSerial(d.serial);
|
|
128613
128954
|
if (port !== null && vvdPorts.has(port)) shadows.add(d.serial);
|
|
128614
128955
|
}
|
|
@@ -128810,7 +129151,7 @@ Chromium apps are discovered by probing CDP debugging ports (default 9222; exten
|
|
|
128810
129151
|
osVersion: h.osVersion
|
|
128811
129152
|
}))
|
|
128812
129153
|
];
|
|
128813
|
-
const
|
|
129154
|
+
const devices2 = [
|
|
128814
129155
|
...iosTagged,
|
|
128815
129156
|
...iosPhysicalTagged,
|
|
128816
129157
|
...iosRemote,
|
|
@@ -128821,7 +129162,7 @@ Chromium apps are discovered by probing CDP debugging ports (default 9222; exten
|
|
|
128821
129162
|
...harmonyTagged,
|
|
128822
129163
|
...external.map(toListedExternal)
|
|
128823
129164
|
];
|
|
128824
|
-
|
|
129165
|
+
devices2.sort((a, b) => readinessRank(a) - readinessRank(b));
|
|
128825
129166
|
const avdsTagged = avds.map(
|
|
128826
129167
|
(a) => foldableAvds.has(a.name) ? { ...a, foldable: true } : a
|
|
128827
129168
|
);
|
|
@@ -128833,7 +129174,7 @@ Chromium apps are discovered by probing CDP debugging ports (default 9222; exten
|
|
|
128833
129174
|
...adbPrefix ? [adbServerHint(adbPrefix)] : []
|
|
128834
129175
|
];
|
|
128835
129176
|
return {
|
|
128836
|
-
devices,
|
|
129177
|
+
devices: devices2,
|
|
128837
129178
|
avds: avdsTagged,
|
|
128838
129179
|
...hints.length > 0 ? { hint: hints.join("\n\n") } : {}
|
|
128839
129180
|
};
|
|
@@ -129596,7 +129937,8 @@ var DEGRADED_STANDING_HINT = "This simulator was not booted through argent, so s
|
|
|
129596
129937
|
function externalCaveat(deviceId, body) {
|
|
129597
129938
|
return `${externalSupportHint(deviceId) ?? "This device is supplied by an external provider."} ${body}`;
|
|
129598
129939
|
}
|
|
129599
|
-
var
|
|
129940
|
+
var EXTERNAL_BLIND_TAIL = ", and argent cannot reboot this device to apply the pre-boot accessibility settings. Restart it from that application, or take a screenshot to see the screen.";
|
|
129941
|
+
var EXTERNAL_BLIND_BODY = `The accessibility read returned no elements${EXTERNAL_BLIND_TAIL}`;
|
|
129600
129942
|
var EXTERNAL_STANDING_BODY = "System dialogs and native modals may not appear in this tree; everything else reads normally. Argent cannot reboot this device to apply the full accessibility settings \u2014 restart it from that application if something you expect is missing.";
|
|
129601
129943
|
function isStandingCaveat(hint) {
|
|
129602
129944
|
return hint === DEGRADED_STANDING_HINT || Boolean(hint?.endsWith(EXTERNAL_STANDING_BODY));
|
|
@@ -129604,10 +129946,21 @@ function isStandingCaveat(hint) {
|
|
|
129604
129946
|
function isBlindCaveat(hint) {
|
|
129605
129947
|
return hint === DEGRADED_BLIND_HINT || Boolean(hint?.endsWith(EXTERNAL_BLIND_BODY));
|
|
129606
129948
|
}
|
|
129949
|
+
function startFailure(err) {
|
|
129950
|
+
return `The accessibility service failed to start (${errMsg(err)})`;
|
|
129951
|
+
}
|
|
129952
|
+
var DEGRADED_START_FAILED_TAIL = ", and this simulator was not booted through argent, so the pre-boot accessibility settings were never applied. Call boot-device with force=true to reboot it with those settings \u2014 this restarts the simulator. If it fails to start again after that reboot, do not reboot again: the boot was not the cause.";
|
|
129953
|
+
function axCrashHint(signal) {
|
|
129954
|
+
return `The accessibility service (ax-service) crashed with ${signal}, so the accessibility tree could not be read. Every describe starts the service again. If this hint repeats, the crash is in the service on this host: rebooting the simulator (boot-device with force=true) or restarting the tool-server will not fix it, because both start the same binary again. While it crashes, system dialogs and SpringBoard chrome cannot be read through describe. describe continues on the app's native view hierarchy where that is available, and \`screenshot\` shows the rest.`;
|
|
129955
|
+
}
|
|
129956
|
+
var NATIVE_FALLBACK_LEAD = "The native fallback has no tree for this read, for a reason of its own, unrelated to the crash:";
|
|
129607
129957
|
var bootCaveatToldDevices = /* @__PURE__ */ new Set();
|
|
129958
|
+
var readFacts = /* @__PURE__ */ new WeakMap();
|
|
129608
129959
|
function withBootCaveatOncePerDevice(deviceId, data) {
|
|
129609
129960
|
if (!isStandingCaveat(data.hint)) {
|
|
129610
|
-
|
|
129961
|
+
const facts = readFacts.get(data);
|
|
129962
|
+
const stillDegraded = facts?.daemonGone ? facts.degraded !== false : isBlindCaveat(data.hint);
|
|
129963
|
+
if (!stillDegraded) bootCaveatToldDevices.delete(deviceId);
|
|
129611
129964
|
return data;
|
|
129612
129965
|
}
|
|
129613
129966
|
if (!bootCaveatToldDevices.has(deviceId)) {
|
|
@@ -129636,6 +129989,12 @@ function lendsNativeDevtools(deviceId) {
|
|
|
129636
129989
|
}
|
|
129637
129990
|
var iosRequires = ["xcrun"];
|
|
129638
129991
|
async function describeIos(registry2, device, params, options = {}) {
|
|
129992
|
+
const facts = {};
|
|
129993
|
+
const data = await readIos(registry2, device, params, options, facts);
|
|
129994
|
+
readFacts.set(data, facts);
|
|
129995
|
+
return data;
|
|
129996
|
+
}
|
|
129997
|
+
async function readIos(registry2, device, params, options, facts) {
|
|
129639
129998
|
const isTvOs = options.isTvOs ?? await isTvOsSimulator(device.id);
|
|
129640
129999
|
if (isTvOs) {
|
|
129641
130000
|
return { tree: emptyTree(), source: "ax-service", hint: TVOS_HINT };
|
|
@@ -129644,38 +130003,59 @@ async function describeIos(registry2, device, params, options = {}) {
|
|
|
129644
130003
|
let degraded;
|
|
129645
130004
|
let resolverHint;
|
|
129646
130005
|
let readFailureHint;
|
|
130006
|
+
let startFailureHint;
|
|
130007
|
+
let crashSignal;
|
|
129647
130008
|
let axApi;
|
|
129648
130009
|
try {
|
|
129649
130010
|
const axRef = axServiceRef(device);
|
|
129650
130011
|
axApi = await registry2.resolveService(axRef.urn, axRef.options);
|
|
129651
130012
|
degraded = axApi.degraded;
|
|
130013
|
+
facts.degraded = degraded;
|
|
129652
130014
|
} catch (err) {
|
|
129653
130015
|
if (isFirstLaunchRefusal(err)) throw err;
|
|
129654
130016
|
resolverHint = tcpArtifactHint(err);
|
|
129655
|
-
|
|
130017
|
+
crashSignal = axDaemonCrashSignal(err);
|
|
130018
|
+
facts.degraded = axStartFailureDegraded(err);
|
|
130019
|
+
const explained = resolverHint !== void 0 || crashSignal !== void 0;
|
|
130020
|
+
degraded = !explained && facts.degraded !== false;
|
|
130021
|
+
if (!explained) {
|
|
130022
|
+
facts.daemonGone = true;
|
|
130023
|
+
startFailureHint = !degraded ? `${startFailure(err)}.` : isExternalId(device.id) ? externalCaveat(device.id, `${startFailure(err)}${EXTERNAL_BLIND_TAIL}`) : `${startFailure(err)}${DEGRADED_START_FAILED_TAIL}`;
|
|
130024
|
+
}
|
|
129656
130025
|
}
|
|
129657
130026
|
if (axApi) {
|
|
129658
130027
|
try {
|
|
129659
130028
|
tree = adaptAXDescribeToDescribeResult(await axApi.describe());
|
|
129660
130029
|
} catch (err) {
|
|
129661
|
-
|
|
130030
|
+
crashSignal = axDaemonCrashSignal(err);
|
|
130031
|
+
if (crashSignal === void 0) {
|
|
130032
|
+
readFailureHint = `The accessibility read failed (${errMsg(err)}).`;
|
|
130033
|
+
}
|
|
129662
130034
|
}
|
|
129663
130035
|
}
|
|
129664
|
-
const
|
|
130036
|
+
const crashHint = crashSignal === void 0 ? void 0 : axCrashHint(crashSignal);
|
|
130037
|
+
if (crashHint !== void 0) facts.daemonGone = true;
|
|
130038
|
+
const degradedHint = !degraded || crashHint !== void 0 || startFailureHint !== void 0 ? void 0 : tree.children.length === 0 ? DEGRADED_BLIND_HINT : DEGRADED_STANDING_HINT;
|
|
129665
130039
|
const deviceDegradedHint = degradedHint !== void 0 && isExternalId(device.id) ? externalCaveat(
|
|
129666
130040
|
device.id,
|
|
129667
130041
|
degradedHint === DEGRADED_BLIND_HINT ? EXTERNAL_BLIND_BODY : EXTERNAL_STANDING_BODY
|
|
129668
130042
|
) : degradedHint;
|
|
129669
|
-
const hint = resolverHint ?? (readFailureHint ? deviceDegradedHint ? `${deviceDegradedHint}. ${readFailureHint}` : readFailureHint : deviceDegradedHint);
|
|
130043
|
+
const hint = resolverHint ?? crashHint ?? startFailureHint ?? (readFailureHint ? deviceDegradedHint ? `${deviceDegradedHint}. ${readFailureHint}` : readFailureHint : deviceDegradedHint);
|
|
129670
130044
|
if (tree.children.length > 0) {
|
|
129671
130045
|
return { tree, source: "ax-service", hint };
|
|
129672
130046
|
}
|
|
130047
|
+
const daemonGoneHint = crashHint ?? (degraded ? void 0 : startFailureHint);
|
|
129673
130048
|
if (params.bundleId && !isInjectableBundleId(params.bundleId)) {
|
|
129674
|
-
return {
|
|
130049
|
+
return {
|
|
130050
|
+
tree,
|
|
130051
|
+
source: "ax-service",
|
|
130052
|
+
hint: daemonGoneHint ? `${daemonGoneHint} ${NON_INJECTABLE_HINT}` : hint ?? NON_INJECTABLE_HINT
|
|
130053
|
+
};
|
|
129675
130054
|
}
|
|
129676
130055
|
if (isExternalId(device.id) && !lendsNativeDevtools(device.id)) {
|
|
130056
|
+
const provider = externalSupportHint(device.id) ?? "This device is supplied by an external provider.";
|
|
129677
130057
|
return {
|
|
129678
|
-
hint:
|
|
130058
|
+
hint: daemonGoneHint ? `${daemonGoneHint} ${provider} The native view-hierarchy fallback is unavailable on it. Take a screenshot to see the screen.` : hint ?? `${provider} The native view-hierarchy fallback is unavailable on it, so an empty tree here means the accessibility tree itself was empty. Take a screenshot to see the screen.`,
|
|
129679
130059
|
source: "ax-service",
|
|
129680
130060
|
tree
|
|
129681
130061
|
};
|
|
@@ -129695,7 +130075,7 @@ async function describeIos(registry2, device, params, options = {}) {
|
|
|
129695
130075
|
});
|
|
129696
130076
|
if (state3 !== "connected") {
|
|
129697
130077
|
const diagnosis = buildAppStateMessage(target.bundleId, state3);
|
|
129698
|
-
const merged = hint ? `${hint} ${diagnosis}` : diagnosis;
|
|
130078
|
+
const merged = crashHint ? `${crashHint} ${NATIVE_FALLBACK_LEAD} ${diagnosis}` : hint ? `${hint} ${diagnosis}` : diagnosis;
|
|
129699
130079
|
return state3 === "unregistered" || state3 === "connecting" ? { tree, source: "ax-service", hint: merged } : { tree, source: "ax-service", should_restart: true, hint: merged };
|
|
129700
130080
|
}
|
|
129701
130081
|
const rawResult = await nativeApi.queryViewHierarchy(
|
|
@@ -131644,16 +132024,16 @@ function createPreviewRouter(registry2) {
|
|
|
131644
132024
|
const KNOWN_DEVICES_TTL_MS = 5e3;
|
|
131645
132025
|
let knownDevices = null;
|
|
131646
132026
|
let knownDevicesInFlight = null;
|
|
131647
|
-
function deviceIdSet(
|
|
132027
|
+
function deviceIdSet(devices2) {
|
|
131648
132028
|
const ids = /* @__PURE__ */ new Set();
|
|
131649
|
-
for (const d of
|
|
132029
|
+
for (const d of devices2) {
|
|
131650
132030
|
const id = d.platform === "ios" ? d.udid : d.serial;
|
|
131651
132031
|
if (typeof id === "string") ids.add(id);
|
|
131652
132032
|
}
|
|
131653
132033
|
return ids;
|
|
131654
132034
|
}
|
|
131655
|
-
function rememberDevices(
|
|
131656
|
-
knownDevices = { ids: deviceIdSet(
|
|
132035
|
+
function rememberDevices(devices2) {
|
|
132036
|
+
knownDevices = { ids: deviceIdSet(devices2), at: Date.now() };
|
|
131657
132037
|
}
|
|
131658
132038
|
async function knownDeviceIds() {
|
|
131659
132039
|
if (knownDevices && Date.now() - knownDevices.at < KNOWN_DEVICES_TTL_MS) {
|
|
@@ -133562,6 +133942,159 @@ async function resolveTvApi(registry2, udid) {
|
|
|
133562
133942
|
init_adb();
|
|
133563
133943
|
init_capability();
|
|
133564
133944
|
|
|
133945
|
+
// ../tool-server/src/utils/secrets.ts
|
|
133946
|
+
init_src2();
|
|
133947
|
+
init_capability();
|
|
133948
|
+
init_src();
|
|
133949
|
+
var SECRET_PLACEHOLDER_MARKER = "{{secret:";
|
|
133950
|
+
function resolveSecretPlaceholders(text, options = {}) {
|
|
133951
|
+
const secrets = [];
|
|
133952
|
+
let sources;
|
|
133953
|
+
const resolved = text.replace(SECRET_PLACEHOLDER_RE, (_placeholder, rawName) => {
|
|
133954
|
+
sources ??= [
|
|
133955
|
+
...options.clientSecrets ? [clientSecretSource(options.clientSecrets)] : [],
|
|
133956
|
+
...secretSources(options)
|
|
133957
|
+
];
|
|
133958
|
+
const { name, value } = lookupPlaceholderSecret(rawName, sources);
|
|
133959
|
+
if (value === void 0) {
|
|
133960
|
+
const names = secretNames(sources);
|
|
133961
|
+
const where = options.clientSecrets ? `the required secret ${name} was not provided: the argent client forwards its secrets to this tool-server and has no value for it, and no source on the machine running the tool-server defines it either` : `no source on the machine running the tool-server defines ${name}`;
|
|
133962
|
+
throw new InvalidToolInputError(
|
|
133963
|
+
`Unknown secret "${rawName}" \u2014 ${where}. Available secrets: ${names.length ? names.join(", ") : "(none)"}.
|
|
133964
|
+
Sources consulted, first match wins:
|
|
133965
|
+
${describeSecretSources(sources)}
|
|
133966
|
+
` + (options.clientSecrets ? clientSecretPlacementAdvice(name) : secretPlacementAdvice(name, options)),
|
|
133967
|
+
{
|
|
133968
|
+
error_code: FAILURE_CODES.SECRET_PLACEHOLDER_UNKNOWN,
|
|
133969
|
+
failure_stage: "secret_placeholder_resolution",
|
|
133970
|
+
error_kind: "validation"
|
|
133971
|
+
}
|
|
133972
|
+
);
|
|
133973
|
+
}
|
|
133974
|
+
if (!secrets.some((s) => s.name === name)) secrets.push({ name, value });
|
|
133975
|
+
return value;
|
|
133976
|
+
});
|
|
133977
|
+
return { text: resolved, secrets };
|
|
133978
|
+
}
|
|
133979
|
+
function scrubSecretValues(text, secrets) {
|
|
133980
|
+
return scrubSecretChunk(text, secrets, true).emit;
|
|
133981
|
+
}
|
|
133982
|
+
function scrubSecretChunk(text, secrets, final) {
|
|
133983
|
+
const ordered = orderedSecrets(secrets);
|
|
133984
|
+
if (ordered.length === 0) return { emit: text, held: 0 };
|
|
133985
|
+
const longestValue = ordered[0].value.length;
|
|
133986
|
+
const names = new Set(ordered.map((secret) => secret.name));
|
|
133987
|
+
const longestName = Math.max(...ordered.map((secret) => secret.name.length));
|
|
133988
|
+
let out = "";
|
|
133989
|
+
let copied = 0;
|
|
133990
|
+
let at = 0;
|
|
133991
|
+
while (at < text.length) {
|
|
133992
|
+
const marker = markerLengthAt(text, at, names, longestName);
|
|
133993
|
+
if (marker > 0 && !valueLeavesMarker(text, at, at + marker, ordered)) {
|
|
133994
|
+
at += marker;
|
|
133995
|
+
continue;
|
|
133996
|
+
}
|
|
133997
|
+
if (!final && text.length - at < longestValue && beginsAValue(text, at, ordered)) break;
|
|
133998
|
+
const hit = ordered.find((secret) => text.startsWith(secret.value, at));
|
|
133999
|
+
if (hit) {
|
|
134000
|
+
out += `${text.slice(copied, at)}${SECRET_PLACEHOLDER_MARKER}${hit.name}}}`;
|
|
134001
|
+
at += hit.value.length;
|
|
134002
|
+
copied = at;
|
|
134003
|
+
continue;
|
|
134004
|
+
}
|
|
134005
|
+
at += 1;
|
|
134006
|
+
}
|
|
134007
|
+
return {
|
|
134008
|
+
emit: copied === 0 ? text.slice(0, at) : out + text.slice(copied, at),
|
|
134009
|
+
held: text.length - at
|
|
134010
|
+
};
|
|
134011
|
+
}
|
|
134012
|
+
function valueLeavesMarker(text, from2, end, ordered) {
|
|
134013
|
+
for (let at = from2; at < end; at++) {
|
|
134014
|
+
for (const { value } of ordered) {
|
|
134015
|
+
if (at + value.length >= end && text.startsWith(value, at)) return true;
|
|
134016
|
+
}
|
|
134017
|
+
}
|
|
134018
|
+
return false;
|
|
134019
|
+
}
|
|
134020
|
+
function beginsAValue(text, at, ordered) {
|
|
134021
|
+
const rest = text.slice(at);
|
|
134022
|
+
return ordered.some(({ value }) => value.length > rest.length && value.startsWith(rest));
|
|
134023
|
+
}
|
|
134024
|
+
function orderedSecrets(secrets) {
|
|
134025
|
+
return secrets.filter(({ value }) => value.length > 0).sort((a, b) => b.value.length - a.value.length);
|
|
134026
|
+
}
|
|
134027
|
+
function markerLengthAt(text, at, names, longestName) {
|
|
134028
|
+
if (!text.startsWith(SECRET_PLACEHOLDER_MARKER, at)) return 0;
|
|
134029
|
+
const from2 = at + SECRET_PLACEHOLDER_MARKER.length;
|
|
134030
|
+
const window2 = text.slice(from2, from2 + longestName + 2);
|
|
134031
|
+
const end = window2.indexOf("}}");
|
|
134032
|
+
return end >= 0 && names.has(window2.slice(0, end)) ? SECRET_PLACEHOLDER_MARKER.length + end + 2 : 0;
|
|
134033
|
+
}
|
|
134034
|
+
function redactSecretsFromError(err, secrets) {
|
|
134035
|
+
const forms = secrets.flatMap((secret) => {
|
|
134036
|
+
const quoted = secret.value.replaceAll("'", "'\\''");
|
|
134037
|
+
return quoted === secret.value ? [secret] : [secret, { name: secret.name, value: quoted }];
|
|
134038
|
+
});
|
|
134039
|
+
const scrub = (s) => scrubSecretValues(s, forms);
|
|
134040
|
+
if (err instanceof Error) {
|
|
134041
|
+
err.message = scrub(err.message);
|
|
134042
|
+
if (err.stack) err.stack = scrub(err.stack);
|
|
134043
|
+
return err;
|
|
134044
|
+
}
|
|
134045
|
+
if (typeof err === "string") return scrub(err);
|
|
134046
|
+
return err;
|
|
134047
|
+
}
|
|
134048
|
+
|
|
134049
|
+
// ../tool-server/src/utils/typed-secrets.ts
|
|
134050
|
+
var MAX_VALUES = 256;
|
|
134051
|
+
var devices = /* @__PURE__ */ new Map();
|
|
134052
|
+
function deviceKey(deviceId) {
|
|
134053
|
+
return deviceId.toLowerCase();
|
|
134054
|
+
}
|
|
134055
|
+
function noteTypedSecrets(deviceId, secrets) {
|
|
134056
|
+
if (secrets.length === 0) return;
|
|
134057
|
+
const key2 = deviceKey(deviceId);
|
|
134058
|
+
const values = devices.get(key2) ?? /* @__PURE__ */ new Map();
|
|
134059
|
+
devices.set(key2, values);
|
|
134060
|
+
for (const { name, value } of secrets) {
|
|
134061
|
+
if (value.length === 0) continue;
|
|
134062
|
+
values.delete(value);
|
|
134063
|
+
values.set(value, `${SECRET_PLACEHOLDER_MARKER}${name}}}`);
|
|
134064
|
+
if (values.size > MAX_VALUES) values.delete(values.keys().next().value);
|
|
134065
|
+
}
|
|
134066
|
+
}
|
|
134067
|
+
function secretTypedOn(deviceId) {
|
|
134068
|
+
return devices.has(deviceKey(deviceId));
|
|
134069
|
+
}
|
|
134070
|
+
var WITHHELD_INPUT_TEXT = "[text withheld: a secret was typed on this device]";
|
|
134071
|
+
function redactTypedSecrets(deviceId, text) {
|
|
134072
|
+
const values = devices.get(deviceKey(deviceId));
|
|
134073
|
+
if (!values || values.size === 0) return text;
|
|
134074
|
+
const longestFirst = [...values].sort((a, b) => b[0].length - a[0].length);
|
|
134075
|
+
let out = "";
|
|
134076
|
+
for (let at = 0; at < text.length; ) {
|
|
134077
|
+
const hit = longestFirst.find(([value]) => text.startsWith(value, at));
|
|
134078
|
+
out += hit ? hit[1] : text[at];
|
|
134079
|
+
at += hit ? hit[0].length : 1;
|
|
134080
|
+
}
|
|
134081
|
+
return out;
|
|
134082
|
+
}
|
|
134083
|
+
function twinOf(tree, quotable, node2) {
|
|
134084
|
+
if (tree === node2) return quotable;
|
|
134085
|
+
for (let i = 0; i < tree.children.length; i++) {
|
|
134086
|
+
const twin = quotable.children[i];
|
|
134087
|
+
const found = twin && twinOf(tree.children[i], twin, node2);
|
|
134088
|
+
if (found) return found;
|
|
134089
|
+
}
|
|
134090
|
+
return void 0;
|
|
134091
|
+
}
|
|
134092
|
+
function quotedText(data, deviceId, node2, read) {
|
|
134093
|
+
if (!data.quotableTree) return redactTypedSecrets(deviceId, read(node2));
|
|
134094
|
+
const twin = twinOf(data.tree, data.quotableTree, node2);
|
|
134095
|
+
return twin ? read(twin) : WITHHELD_INPUT_TEXT;
|
|
134096
|
+
}
|
|
134097
|
+
|
|
133565
134098
|
// ../tool-server/src/utils/poll-describe-tree.ts
|
|
133566
134099
|
init_src2();
|
|
133567
134100
|
async function pollDescribeTree(args) {
|
|
@@ -142799,7 +143332,8 @@ function includesWordsCI(haystack, needle) {
|
|
|
142799
143332
|
function flattenHoisting(node2, project, out, scrollClip = null) {
|
|
142800
143333
|
const view = project(node2);
|
|
142801
143334
|
if (view.skip) return "";
|
|
142802
|
-
if (scrollClip && view.rect && rectFullyOutside(view.rect, scrollClip))
|
|
143335
|
+
if (scrollClip && view.rect && view.rect.w > 0 && view.rect.h > 0 && rectFullyOutside(view.rect, scrollClip))
|
|
143336
|
+
return "";
|
|
142803
143337
|
const childClip = view.scrolls && view.rect ? intersectClip(view.rect, scrollClip) : scrollClip;
|
|
142804
143338
|
const childText = [];
|
|
142805
143339
|
for (const child of view.children) {
|
|
@@ -142807,7 +143341,11 @@ function flattenHoisting(node2, project, out, scrollClip = null) {
|
|
|
142807
143341
|
if (t) childText.push(t);
|
|
142808
143342
|
}
|
|
142809
143343
|
const descendantText2 = childText.join(" ");
|
|
142810
|
-
const
|
|
143344
|
+
const ownParts = view.ownTextParts ?? [view.ownText];
|
|
143345
|
+
const subtree = [
|
|
143346
|
+
...ownParts.filter((part) => part && !includesWordsCI(descendantText2, part)),
|
|
143347
|
+
descendantText2
|
|
143348
|
+
].filter(Boolean).join(" ");
|
|
142811
143349
|
if (view.leaf) {
|
|
142812
143350
|
if (subtree && subtree !== view.ownText) view.leaf.subtreeText = subtree;
|
|
142813
143351
|
out.push(view.leaf);
|
|
@@ -143392,7 +143930,8 @@ function timeoutNote(params, lastTree, fetchError, lastData) {
|
|
|
143392
143930
|
case "text": {
|
|
143393
143931
|
const first = textCheckTarget(matches2, void 0, isMacos(params));
|
|
143394
143932
|
const wanted = params.textMatch === "equals" ? "equal" : "contain";
|
|
143395
|
-
|
|
143933
|
+
const shown = first ? redactTypedSecrets(params.udid, macFieldText(first, isMacos(params)) ?? assertText(first)) : void 0;
|
|
143934
|
+
base = shown !== void 0 ? `element matched but its text was "${shown}" (wanted to ${wanted} "${params.expectedText}")` : "no element matched the selector before timeout";
|
|
143396
143935
|
break;
|
|
143397
143936
|
}
|
|
143398
143937
|
case "hidden":
|
|
@@ -143576,7 +144115,7 @@ init_device_info();
|
|
|
143576
144115
|
|
|
143577
144116
|
// ../tool-server/src/blueprints/chromium-js-runtime-debugger.ts
|
|
143578
144117
|
init_wrapper();
|
|
143579
|
-
var
|
|
144118
|
+
var http3 = __toESM(require("node:http"));
|
|
143580
144119
|
init_src2();
|
|
143581
144120
|
|
|
143582
144121
|
// ../tool-server/src/utils/debugger/source-maps.ts
|
|
@@ -143910,7 +144449,7 @@ function formatConsoleArgs(params) {
|
|
|
143910
144449
|
}
|
|
143911
144450
|
function createConsoleLogServer(consoleEvents, logWriter) {
|
|
143912
144451
|
return new Promise((resolve19, reject) => {
|
|
143913
|
-
const server =
|
|
144452
|
+
const server = http3.createServer();
|
|
143914
144453
|
const wss = new import_websocket_server.default({ server });
|
|
143915
144454
|
wss.on("connection", (ws) => {
|
|
143916
144455
|
for (const entry of logWriter.readAll()) {
|
|
@@ -145449,8 +145988,14 @@ function findAndroidNativeRecord(id) {
|
|
|
145449
145988
|
function liveAndroidNetworkCaptures(deviceId) {
|
|
145450
145989
|
return [...liveInspectors.get(deviceKeyOf(deviceId)) ?? []].filter((handle) => handle.isLive()).map((handle) => handle.packageName).sort();
|
|
145451
145990
|
}
|
|
145991
|
+
function liveAndroidNetworkCaptureSerials() {
|
|
145992
|
+
return liveCaptureSerials(() => true);
|
|
145993
|
+
}
|
|
145452
145994
|
function liveAndroidNetworkCaptureDevices(packageName) {
|
|
145453
|
-
|
|
145995
|
+
return liveCaptureSerials((handle) => handle.packageName === packageName);
|
|
145996
|
+
}
|
|
145997
|
+
function liveCaptureSerials(matches2) {
|
|
145998
|
+
const serials = allHandles().filter((handle) => matches2(handle) && handle.isLive()).map((handle) => handle.serial);
|
|
145454
145999
|
return [...new Set(serials)].sort();
|
|
145455
146000
|
}
|
|
145456
146001
|
async function attachAndroidNetworkInspectorToLaunch(deviceId, packageName) {
|
|
@@ -147621,7 +148166,7 @@ init_external_devices();
|
|
|
147621
148166
|
var import_node_crypto13 = require("node:crypto");
|
|
147622
148167
|
init_src2();
|
|
147623
148168
|
init_device_info();
|
|
147624
|
-
function
|
|
148169
|
+
function deviceKey2(target) {
|
|
147625
148170
|
const logicalId = target.reactNative?.logicalDeviceId;
|
|
147626
148171
|
if (logicalId) return logicalId;
|
|
147627
148172
|
try {
|
|
@@ -147650,13 +148195,13 @@ function describeDevice(target) {
|
|
|
147650
148195
|
function macosAppTargets(pool, bundleId, port) {
|
|
147651
148196
|
const own2 = pool.filter((t) => macosAppBundleIdOf(t)?.toLowerCase() === bundleId.toLowerCase());
|
|
147652
148197
|
if (own2.length) return own2;
|
|
147653
|
-
const
|
|
148198
|
+
const devices2 = /* @__PURE__ */ new Map();
|
|
147654
148199
|
for (const t of pool) {
|
|
147655
|
-
const key2 =
|
|
147656
|
-
if (key2 && !
|
|
148200
|
+
const key2 = deviceKey2(t);
|
|
148201
|
+
if (key2 && !devices2.has(key2)) devices2.set(key2, describeDevice(t));
|
|
147657
148202
|
}
|
|
147658
148203
|
throw new FailureError(
|
|
147659
|
-
`No JS runtime of the Mac app ${bundleId} is connected to Metro on port ${port}. Metro lists: ${[...
|
|
148204
|
+
`No JS runtime of the Mac app ${bundleId} is connected to Metro on port ${port}. Metro lists: ${[...devices2.values()].join(", ")}. If the app does not run, start it (launch-app), wait a few seconds for the bundle to load, then retry. Otherwise the app must be a Debug build of react-native-macos 0.76 or later that loads its bundle from this Metro; a Release build has no JS debugger. If the app uses another Metro, pass that port.`,
|
|
147660
148205
|
{
|
|
147661
148206
|
error_code: FAILURE_CODES.DEBUGGER_TARGET_DEVICE_MISMATCH,
|
|
147662
148207
|
failure_stage: "debugger_select_target",
|
|
@@ -147684,7 +148229,7 @@ function selectTarget(targets, port, options) {
|
|
|
147684
148229
|
} else {
|
|
147685
148230
|
const distinctDevices = /* @__PURE__ */ new Map();
|
|
147686
148231
|
for (const t of pool) {
|
|
147687
|
-
const key2 =
|
|
148232
|
+
const key2 = deviceKey2(t);
|
|
147688
148233
|
if (key2 && !distinctDevices.has(key2)) distinctDevices.set(key2, describeDevice(t));
|
|
147689
148234
|
}
|
|
147690
148235
|
if (distinctDevices.size > 1) {
|
|
@@ -148001,7 +148546,7 @@ var DISABLE_LOGBOX_SCRIPT = `(function() {
|
|
|
148001
148546
|
|
|
148002
148547
|
// ../tool-server/src/blueprints/js-runtime-debugger.ts
|
|
148003
148548
|
init_wrapper();
|
|
148004
|
-
var
|
|
148549
|
+
var http4 = __toESM(require("node:http"));
|
|
148005
148550
|
var JS_RUNTIME_DEBUGGER_NAMESPACE = "JsRuntimeDebugger";
|
|
148006
148551
|
function stringifyConsoleValue2(value) {
|
|
148007
148552
|
if (typeof value === "object" && value !== null) {
|
|
@@ -148022,7 +148567,7 @@ function formatConsoleArgs2(params) {
|
|
|
148022
148567
|
}
|
|
148023
148568
|
function createConsoleLogServer2(consoleEvents, logWriter) {
|
|
148024
148569
|
return new Promise((resolve19, reject) => {
|
|
148025
|
-
const server =
|
|
148570
|
+
const server = http4.createServer();
|
|
148026
148571
|
const wss = new import_websocket_server.default({ server });
|
|
148027
148572
|
wss.on("connection", (ws) => {
|
|
148028
148573
|
for (const entry of logWriter.readAll()) {
|
|
@@ -150977,8 +151522,8 @@ async function awaitFirstRealFrame(serial, timeoutMs) {
|
|
|
150977
151522
|
}
|
|
150978
151523
|
async function findSerialByAvdName(avdName, deadline) {
|
|
150979
151524
|
while (Date.now() < deadline) {
|
|
150980
|
-
const
|
|
150981
|
-
const match =
|
|
151525
|
+
const devices2 = await listAndroidDevices().catch(() => []);
|
|
151526
|
+
const match = devices2.find((d) => d.isEmulator && d.avdName === avdName);
|
|
150982
151527
|
if (match) return match.serial;
|
|
150983
151528
|
await new Promise((r) => setTimeout(r, BOOT_POLL_INTERVALS_MS.serialByAvd));
|
|
150984
151529
|
}
|
|
@@ -151016,8 +151561,8 @@ async function awaitOwnEmulatorSettled(avdName, deadline) {
|
|
|
151016
151561
|
while (Date.now() < deadline) {
|
|
151017
151562
|
if (healthy) return healthy;
|
|
151018
151563
|
if ((await listEmulatorPidsForAvd(avdName)).length === 0) return null;
|
|
151019
|
-
listing ??= listAndroidDevices().then((
|
|
151020
|
-
if (
|
|
151564
|
+
listing ??= listAndroidDevices().then((devices2) => {
|
|
151565
|
+
if (devices2.some((d) => isRunningAvd(d, avdName))) healthy = devices2;
|
|
151021
151566
|
}).catch(() => {
|
|
151022
151567
|
}).finally(() => {
|
|
151023
151568
|
listing = null;
|
|
@@ -151028,9 +151573,9 @@ async function awaitOwnEmulatorSettled(avdName, deadline) {
|
|
|
151028
151573
|
}
|
|
151029
151574
|
return healthy;
|
|
151030
151575
|
}
|
|
151031
|
-
async function dropUnreachableSerials(
|
|
151576
|
+
async function dropUnreachableSerials(devices2, serialsBefore) {
|
|
151032
151577
|
await Promise.all(
|
|
151033
|
-
|
|
151578
|
+
devices2.filter((d) => d.isEmulator && !(d.state === "device" && d.avdName !== null)).map(async (d) => {
|
|
151034
151579
|
if ((await readEmulatorConsoleAvdName(d.serial)).status === "unreachable") {
|
|
151035
151580
|
serialsBefore.delete(d.serial);
|
|
151036
151581
|
}
|
|
@@ -151188,8 +151733,8 @@ async function bootIosRemote(id, registry2, force) {
|
|
|
151188
151733
|
let simState;
|
|
151189
151734
|
try {
|
|
151190
151735
|
const list = await simctlListDevices();
|
|
151191
|
-
outer: for (const
|
|
151192
|
-
for (const d of
|
|
151736
|
+
outer: for (const devices2 of Object.values(list.devices)) {
|
|
151737
|
+
for (const d of devices2) {
|
|
151193
151738
|
if (d.udid === udid) {
|
|
151194
151739
|
simState = d.state;
|
|
151195
151740
|
break outer;
|
|
@@ -156092,110 +156637,6 @@ init_zod();
|
|
|
156092
156637
|
init_src2();
|
|
156093
156638
|
init_capability();
|
|
156094
156639
|
|
|
156095
|
-
// ../tool-server/src/utils/secrets.ts
|
|
156096
|
-
init_src2();
|
|
156097
|
-
init_capability();
|
|
156098
|
-
init_src();
|
|
156099
|
-
var SECRET_PLACEHOLDER_MARKER = "{{secret:";
|
|
156100
|
-
function resolveSecretPlaceholders(text, options = {}) {
|
|
156101
|
-
const secrets = [];
|
|
156102
|
-
let sources;
|
|
156103
|
-
const resolved = text.replace(SECRET_PLACEHOLDER_RE, (_placeholder, rawName) => {
|
|
156104
|
-
sources ??= [
|
|
156105
|
-
...options.clientSecrets ? [clientSecretSource(options.clientSecrets)] : [],
|
|
156106
|
-
...secretSources(options)
|
|
156107
|
-
];
|
|
156108
|
-
const { name, value } = lookupPlaceholderSecret(rawName, sources);
|
|
156109
|
-
if (value === void 0) {
|
|
156110
|
-
const names = secretNames(sources);
|
|
156111
|
-
const where = options.clientSecrets ? `the required secret ${name} was not provided: the argent client forwards its secrets to this tool-server and has no value for it, and no source on the machine running the tool-server defines it either` : `no source on the machine running the tool-server defines ${name}`;
|
|
156112
|
-
throw new InvalidToolInputError(
|
|
156113
|
-
`Unknown secret "${rawName}" \u2014 ${where}. Available secrets: ${names.length ? names.join(", ") : "(none)"}.
|
|
156114
|
-
Sources consulted, first match wins:
|
|
156115
|
-
${describeSecretSources(sources)}
|
|
156116
|
-
` + (options.clientSecrets ? clientSecretPlacementAdvice(name) : secretPlacementAdvice(name, options)),
|
|
156117
|
-
{
|
|
156118
|
-
error_code: FAILURE_CODES.SECRET_PLACEHOLDER_UNKNOWN,
|
|
156119
|
-
failure_stage: "secret_placeholder_resolution",
|
|
156120
|
-
error_kind: "validation"
|
|
156121
|
-
}
|
|
156122
|
-
);
|
|
156123
|
-
}
|
|
156124
|
-
if (!secrets.some((s) => s.name === name)) secrets.push({ name, value });
|
|
156125
|
-
return value;
|
|
156126
|
-
});
|
|
156127
|
-
return { text: resolved, secrets };
|
|
156128
|
-
}
|
|
156129
|
-
function scrubSecretValues(text, secrets) {
|
|
156130
|
-
return scrubSecretChunk(text, secrets, true).emit;
|
|
156131
|
-
}
|
|
156132
|
-
function scrubSecretChunk(text, secrets, final) {
|
|
156133
|
-
const ordered = orderedSecrets(secrets);
|
|
156134
|
-
if (ordered.length === 0) return { emit: text, held: 0 };
|
|
156135
|
-
const longestValue = ordered[0].value.length;
|
|
156136
|
-
const names = new Set(ordered.map((secret) => secret.name));
|
|
156137
|
-
const longestName = Math.max(...ordered.map((secret) => secret.name.length));
|
|
156138
|
-
let out = "";
|
|
156139
|
-
let copied = 0;
|
|
156140
|
-
let at = 0;
|
|
156141
|
-
while (at < text.length) {
|
|
156142
|
-
const marker = markerLengthAt(text, at, names, longestName);
|
|
156143
|
-
if (marker > 0 && !valueLeavesMarker(text, at, at + marker, ordered)) {
|
|
156144
|
-
at += marker;
|
|
156145
|
-
continue;
|
|
156146
|
-
}
|
|
156147
|
-
if (!final && text.length - at < longestValue && beginsAValue(text, at, ordered)) break;
|
|
156148
|
-
const hit = ordered.find((secret) => text.startsWith(secret.value, at));
|
|
156149
|
-
if (hit) {
|
|
156150
|
-
out += `${text.slice(copied, at)}${SECRET_PLACEHOLDER_MARKER}${hit.name}}}`;
|
|
156151
|
-
at += hit.value.length;
|
|
156152
|
-
copied = at;
|
|
156153
|
-
continue;
|
|
156154
|
-
}
|
|
156155
|
-
at += 1;
|
|
156156
|
-
}
|
|
156157
|
-
return {
|
|
156158
|
-
emit: copied === 0 ? text.slice(0, at) : out + text.slice(copied, at),
|
|
156159
|
-
held: text.length - at
|
|
156160
|
-
};
|
|
156161
|
-
}
|
|
156162
|
-
function valueLeavesMarker(text, from2, end, ordered) {
|
|
156163
|
-
for (let at = from2; at < end; at++) {
|
|
156164
|
-
for (const { value } of ordered) {
|
|
156165
|
-
if (at + value.length >= end && text.startsWith(value, at)) return true;
|
|
156166
|
-
}
|
|
156167
|
-
}
|
|
156168
|
-
return false;
|
|
156169
|
-
}
|
|
156170
|
-
function beginsAValue(text, at, ordered) {
|
|
156171
|
-
const rest = text.slice(at);
|
|
156172
|
-
return ordered.some(({ value }) => value.length > rest.length && value.startsWith(rest));
|
|
156173
|
-
}
|
|
156174
|
-
function orderedSecrets(secrets) {
|
|
156175
|
-
return secrets.filter(({ value }) => value.length > 0).sort((a, b) => b.value.length - a.value.length);
|
|
156176
|
-
}
|
|
156177
|
-
function markerLengthAt(text, at, names, longestName) {
|
|
156178
|
-
if (!text.startsWith(SECRET_PLACEHOLDER_MARKER, at)) return 0;
|
|
156179
|
-
const from2 = at + SECRET_PLACEHOLDER_MARKER.length;
|
|
156180
|
-
const window2 = text.slice(from2, from2 + longestName + 2);
|
|
156181
|
-
const end = window2.indexOf("}}");
|
|
156182
|
-
return end >= 0 && names.has(window2.slice(0, end)) ? SECRET_PLACEHOLDER_MARKER.length + end + 2 : 0;
|
|
156183
|
-
}
|
|
156184
|
-
function redactSecretsFromError(err, secrets) {
|
|
156185
|
-
const forms = secrets.flatMap((secret) => {
|
|
156186
|
-
const quoted = secret.value.replaceAll("'", "'\\''");
|
|
156187
|
-
return quoted === secret.value ? [secret] : [secret, { name: secret.name, value: quoted }];
|
|
156188
|
-
});
|
|
156189
|
-
const scrub = (s) => scrubSecretValues(s, forms);
|
|
156190
|
-
if (err instanceof Error) {
|
|
156191
|
-
err.message = scrub(err.message);
|
|
156192
|
-
if (err.stack) err.stack = scrub(err.stack);
|
|
156193
|
-
return err;
|
|
156194
|
-
}
|
|
156195
|
-
if (typeof err === "string") return scrub(err);
|
|
156196
|
-
return err;
|
|
156197
|
-
}
|
|
156198
|
-
|
|
156199
156640
|
// ../tool-server/src/tools/keyboard/simulator-server-keys.ts
|
|
156200
156641
|
init_src2();
|
|
156201
156642
|
|
|
@@ -156939,6 +157380,7 @@ React Native: after typing, the next tap outside the field may only close the ke
|
|
|
156939
157380
|
clientSecrets: options?.clientSecrets
|
|
156940
157381
|
});
|
|
156941
157382
|
if (secrets.length === 0) return dispatch(services, params, options);
|
|
157383
|
+
noteTypedSecrets(params.udid, secrets);
|
|
156942
157384
|
try {
|
|
156943
157385
|
const result = await dispatch(services, { ...params, text }, options);
|
|
156944
157386
|
return { ...result, typed: params.text };
|
|
@@ -157131,6 +157573,7 @@ Tap the field first so it has focus. Returns { pasted: true }, plus via: "keyboa
|
|
|
157131
157573
|
});
|
|
157132
157574
|
return serializedPerDevice(params.udid, async () => {
|
|
157133
157575
|
if (secrets.length === 0) return dispatch(services, params, options);
|
|
157576
|
+
noteTypedSecrets(params.udid, secrets);
|
|
157134
157577
|
try {
|
|
157135
157578
|
return await dispatch(services, { ...params, text, hasSecrets: true }, options);
|
|
157136
157579
|
} catch (err) {
|
|
@@ -162080,6 +162523,7 @@ Fails with FILL_NO_FOCUSED_FIELD when nothing editable has focus, FILL_NOT_VERIF
|
|
|
162080
162523
|
const { text, secrets } = resolveSecretPlaceholders(params.text, {
|
|
162081
162524
|
clientSecrets: options?.clientSecrets
|
|
162082
162525
|
});
|
|
162526
|
+
noteTypedSecrets(params.udid, secrets);
|
|
162083
162527
|
try {
|
|
162084
162528
|
return await dispatch(services, { udid: params.udid, text }, options);
|
|
162085
162529
|
} catch (err) {
|
|
@@ -162259,7 +162703,12 @@ init_adb();
|
|
|
162259
162703
|
var execFileAsync35 = (0, import_node_util35.promisify)(import_node_child_process46.execFile);
|
|
162260
162704
|
var LOG_READ_TIMEOUT_MS = 5e3;
|
|
162261
162705
|
var RETRY_DELAY_MS = 300;
|
|
162262
|
-
|
|
162706
|
+
var OTHER_TRANSPORTS_GRACE_MS = 500;
|
|
162707
|
+
var NOT_FOUND = { found: [], unresolved: [] };
|
|
162708
|
+
async function findRuntimeDevices(cdp, {
|
|
162709
|
+
awaitSerials = [],
|
|
162710
|
+
waitSerials = []
|
|
162711
|
+
} = {}) {
|
|
162263
162712
|
const marker = `argent-device-probe:${(0, import_node_crypto15.randomUUID)()}`;
|
|
162264
162713
|
const logged = await cdp.evaluate(
|
|
162265
162714
|
`(function () {
|
|
@@ -162268,30 +162717,88 @@ async function findRuntimeDevice(cdp) {
|
|
|
162268
162717
|
return true;
|
|
162269
162718
|
})()`
|
|
162270
162719
|
).catch(() => false);
|
|
162271
|
-
if (logged !== true) return
|
|
162720
|
+
if (logged !== true) return NOT_FOUND;
|
|
162272
162721
|
const checks = [
|
|
162273
|
-
async () =>
|
|
162274
|
-
async () =>
|
|
162722
|
+
async () => androidDevices(await androidSerials(), marker, awaitSerials, waitSerials),
|
|
162723
|
+
async () => {
|
|
162724
|
+
const udids = await bootedSimulators();
|
|
162725
|
+
const udid = await firstFound(udids.map((udid2) => () => simulatorLogHolds(udid2, marker)));
|
|
162726
|
+
return udid === void 0 ? void 0 : { found: [udid], unresolved: [] };
|
|
162727
|
+
}
|
|
162275
162728
|
];
|
|
162276
162729
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
162277
162730
|
if (attempt > 0) await new Promise((r) => setTimeout(r, RETRY_DELAY_MS));
|
|
162278
162731
|
const found = await firstFound(checks);
|
|
162279
162732
|
if (found !== void 0) return found;
|
|
162280
162733
|
}
|
|
162281
|
-
return
|
|
162734
|
+
return NOT_FOUND;
|
|
162282
162735
|
}
|
|
162283
162736
|
function firstFound(checks) {
|
|
162284
162737
|
return new Promise((resolve19) => {
|
|
162285
162738
|
let left = checks.length;
|
|
162286
162739
|
if (left === 0) resolve19(void 0);
|
|
162287
162740
|
for (const check3 of checks) {
|
|
162288
|
-
void check3().then((
|
|
162289
|
-
if (
|
|
162741
|
+
void check3().then((value) => {
|
|
162742
|
+
if (value !== void 0) resolve19(value);
|
|
162290
162743
|
else if (--left === 0) resolve19(void 0);
|
|
162291
162744
|
});
|
|
162292
162745
|
}
|
|
162293
162746
|
});
|
|
162294
162747
|
}
|
|
162748
|
+
async function androidDevices(serials, marker, awaitSerials, waitSerials) {
|
|
162749
|
+
const listed = [...new Set(serials)];
|
|
162750
|
+
const awaited = listed.filter(
|
|
162751
|
+
(serial) => awaitSerials.includes(serial) || waitSerials.includes(serial)
|
|
162752
|
+
);
|
|
162753
|
+
const answers = /* @__PURE__ */ new Map();
|
|
162754
|
+
await new Promise((resolve19) => {
|
|
162755
|
+
let graceOver = false;
|
|
162756
|
+
let grace;
|
|
162757
|
+
const settle3 = () => {
|
|
162758
|
+
const held = heldSerials(answers);
|
|
162759
|
+
const waitingOn = listed.filter(
|
|
162760
|
+
(serial) => !answers.has(serial) && (!graceOver || awaited.includes(serial)) && !held.some((found2) => anotherDevice(serial, found2))
|
|
162761
|
+
);
|
|
162762
|
+
if (waitingOn.length === 0) {
|
|
162763
|
+
clearTimeout(grace);
|
|
162764
|
+
resolve19();
|
|
162765
|
+
}
|
|
162766
|
+
};
|
|
162767
|
+
settle3();
|
|
162768
|
+
for (const serial of listed) {
|
|
162769
|
+
void logcatHolds(serial, marker).then((read) => {
|
|
162770
|
+
answers.set(serial, read);
|
|
162771
|
+
if (read === "held") {
|
|
162772
|
+
grace ??= setTimeout(() => {
|
|
162773
|
+
graceOver = true;
|
|
162774
|
+
settle3();
|
|
162775
|
+
}, OTHER_TRANSPORTS_GRACE_MS);
|
|
162776
|
+
}
|
|
162777
|
+
settle3();
|
|
162778
|
+
});
|
|
162779
|
+
}
|
|
162780
|
+
});
|
|
162781
|
+
const found = heldSerials(answers);
|
|
162782
|
+
if (found.length === 0) return void 0;
|
|
162783
|
+
const unresolved = [...new Set(awaitSerials)].filter(
|
|
162784
|
+
(serial) => (!listed.includes(serial) || answers.get(serial) === "failed") && !found.some((device) => anotherDevice(serial, device))
|
|
162785
|
+
);
|
|
162786
|
+
return { found, unresolved };
|
|
162787
|
+
}
|
|
162788
|
+
function heldSerials(answers) {
|
|
162789
|
+
return [...answers].filter(([, read]) => read === "held").map(([serial]) => serial);
|
|
162790
|
+
}
|
|
162791
|
+
function anotherDevice(a, b) {
|
|
162792
|
+
if (a === b) return false;
|
|
162793
|
+
const portA = consolePortFromAdbSerial(a);
|
|
162794
|
+
const portB = consolePortFromAdbSerial(b);
|
|
162795
|
+
if (portA !== null && portB !== null) return portA !== portB;
|
|
162796
|
+
if (isUsbSerial(a) && isUsbSerial(b)) return true;
|
|
162797
|
+
return portA !== null && isUsbSerial(b) || portB !== null && isUsbSerial(a);
|
|
162798
|
+
}
|
|
162799
|
+
function isUsbSerial(serial) {
|
|
162800
|
+
return !serial.startsWith("emulator-") && !serial.includes(":") && !serial.includes("._");
|
|
162801
|
+
}
|
|
162295
162802
|
async function androidSerials() {
|
|
162296
162803
|
try {
|
|
162297
162804
|
const { stdout } = await runAdb(["devices"], { timeoutMs: ADB_DEVICES_TIMEOUT_MS });
|
|
@@ -162310,9 +162817,9 @@ async function logcatHolds(serial, marker) {
|
|
|
162310
162817
|
["-s", serial, "logcat", "-d", "-s", "ReactNativeJS", "-e", marker],
|
|
162311
162818
|
{ timeoutMs: LOG_READ_TIMEOUT_MS }
|
|
162312
162819
|
);
|
|
162313
|
-
return stdout.includes(marker) ?
|
|
162820
|
+
return stdout.includes(marker) ? "held" : "absent";
|
|
162314
162821
|
} catch {
|
|
162315
|
-
return
|
|
162822
|
+
return "failed";
|
|
162316
162823
|
}
|
|
162317
162824
|
}
|
|
162318
162825
|
async function simulatorLogHolds(udid, marker) {
|
|
@@ -162341,6 +162848,9 @@ async function simulatorLogHolds(udid, marker) {
|
|
|
162341
162848
|
}
|
|
162342
162849
|
}
|
|
162343
162850
|
|
|
162851
|
+
// ../tool-server/src/tools/profiler/react/react-profiler-start.ts
|
|
162852
|
+
init_external_devices();
|
|
162853
|
+
|
|
162344
162854
|
// ../tool-server/src/utils/react-profiler/devtools-bootstrap.ts
|
|
162345
162855
|
function bootstrapFailureMessage(bootstrap) {
|
|
162346
162856
|
switch (bootstrap.reason) {
|
|
@@ -162362,17 +162872,47 @@ function bootstrapFailureMessage(bootstrap) {
|
|
|
162362
162872
|
|
|
162363
162873
|
// ../tool-server/src/utils/profiler-shared/network-capture-warning.ts
|
|
162364
162874
|
var CAPTURE_COST = "It can slow the app, so the timings in this profile can differ from a run without it.";
|
|
162365
|
-
function nativeNetworkCaptureWarning(deviceId, runtimeApp) {
|
|
162366
|
-
let packages;
|
|
162875
|
+
function nativeNetworkCaptureWarning(deviceId, runtimeApp, runtimeDevices = { found: [], unresolved: [] }) {
|
|
162367
162876
|
try {
|
|
162368
|
-
|
|
162877
|
+
if (runtimeDevices.found.length > 0) {
|
|
162878
|
+
return foundDeviceWarning(runtimeDevices, runtimeApp);
|
|
162879
|
+
}
|
|
162880
|
+
const packages = liveAndroidNetworkCaptures(deviceId);
|
|
162369
162881
|
if (packages.length === 0) return logicalDeviceWarning(deviceId, runtimeApp);
|
|
162882
|
+
const apps = packages.join(", ");
|
|
162883
|
+
const one = packages.length === 1;
|
|
162884
|
+
return `Native network capture is on for ${apps} on this device: Argent attaches its in-app agent to the processes of ${one ? "that app" : "these apps"}. ${CAPTURE_COST} To profile without it, stop this profile, call native-network-logs with stop: true for ${one ? "that app" : "each of these apps"}, then restart-app and profile again.`;
|
|
162370
162885
|
} catch {
|
|
162371
162886
|
return void 0;
|
|
162372
162887
|
}
|
|
162373
|
-
|
|
162374
|
-
|
|
162375
|
-
|
|
162888
|
+
}
|
|
162889
|
+
function foundDeviceWarning({ found, unresolved }, runtimeApp) {
|
|
162890
|
+
const captures = found.map((device) => ({ device, packages: liveAndroidNetworkCaptures(device) })).filter(({ packages }) => packages.length > 0);
|
|
162891
|
+
const appId = runtimeApp?.platform === "android" ? runtimeApp.appId : void 0;
|
|
162892
|
+
const maybe = appId ? unresolved.filter((serial) => liveAndroidNetworkCaptures(serial).includes(appId)) : [];
|
|
162893
|
+
const first = captures[0];
|
|
162894
|
+
if (!first && (!appId || maybe.length === 0)) return void 0;
|
|
162895
|
+
const sentences = [];
|
|
162896
|
+
if (first) {
|
|
162897
|
+
const apps = [...new Set(captures.flatMap(({ packages }) => packages))].sort();
|
|
162898
|
+
const where = captures.length === 1 ? `${first.device}, the device this profile runs on` : `${captures.map(({ device }) => device).join(" and ")}, adb serials of the device this profile runs on`;
|
|
162899
|
+
sentences.push(
|
|
162900
|
+
`Native network capture is on for ${apps.join(", ")} on ${where}: Argent attaches its in-app agent to the processes of ${apps.length === 1 ? "that app" : "these apps"}.`
|
|
162901
|
+
);
|
|
162902
|
+
}
|
|
162903
|
+
if (appId && maybe.length > 0) {
|
|
162904
|
+
const one = maybe.length === 1;
|
|
162905
|
+
sentences.push(
|
|
162906
|
+
`Native network capture is ${first ? "also " : ""}on for ${appId} on ${maybe.join(", ")}, ${one ? "which" : "each of which"} may also be the device this profile runs on: ${one ? "its logcat" : "their logcats"} could not be read to tell. Argent attaches its in-app agent to the processes of that app there.`
|
|
162907
|
+
);
|
|
162908
|
+
}
|
|
162909
|
+
const stops = [
|
|
162910
|
+
...captures.flatMap(({ device, packages }) => packages.map((app) => ({ app, device }))),
|
|
162911
|
+
...appId ? maybe.map((device) => ({ app: appId, device })) : []
|
|
162912
|
+
];
|
|
162913
|
+
const stop = first && captures.length === 1 && maybe.length === 0 ? `with udid ${first.device} and stop: true for ${first.packages.length === 1 ? "that app" : "each of these apps"}` : `with stop: true for ${stops.map(({ app, device }) => `${app} with udid ${device}`).join(", ")}`;
|
|
162914
|
+
const restart = first?.device ?? found[0];
|
|
162915
|
+
return `${sentences.join(" ")} ${CAPTURE_COST} To profile without it, stop this profile, call native-network-logs ${stop}, then restart-app on ${restart} and profile again.`;
|
|
162376
162916
|
}
|
|
162377
162917
|
function logicalDeviceWarning(deviceId, runtimeApp) {
|
|
162378
162918
|
const appId = runtimeApp?.appId;
|
|
@@ -162429,6 +162969,25 @@ function failedTakeoverText({ session_id, reason: reason2 }) {
|
|
|
162429
162969
|
const run2 = session_id ? `session ${session_id}` : "a recording with no owner record";
|
|
162430
162970
|
return `Before it failed, this start stopped ${run2} (reason: ${reason2}), and nothing is recording now.`;
|
|
162431
162971
|
}
|
|
162972
|
+
function findProfiledDevices(cdp) {
|
|
162973
|
+
return findRuntimeDevices(cdp, {
|
|
162974
|
+
awaitSerials: idsOf(liveAndroidNetworkCaptureSerials),
|
|
162975
|
+
waitSerials: idsOf(simulatorServerDeviceIds).map(externalNativeId)
|
|
162976
|
+
});
|
|
162977
|
+
}
|
|
162978
|
+
function trackedIds(found) {
|
|
162979
|
+
const driven = idsOf(simulatorServerDeviceIds).filter(
|
|
162980
|
+
(id) => found.includes(externalNativeId(id))
|
|
162981
|
+
);
|
|
162982
|
+
return [.../* @__PURE__ */ new Set([...found, ...driven])];
|
|
162983
|
+
}
|
|
162984
|
+
function idsOf(lookup) {
|
|
162985
|
+
try {
|
|
162986
|
+
return lookup();
|
|
162987
|
+
} catch {
|
|
162988
|
+
return [];
|
|
162989
|
+
}
|
|
162990
|
+
}
|
|
162432
162991
|
function safeGetState(registry2, urn) {
|
|
162433
162992
|
try {
|
|
162434
162993
|
return registry2.getServiceState(urn);
|
|
@@ -162629,7 +163188,7 @@ Fails if the Hermes runtime is not reachable or the Metro CDP connection cannot
|
|
|
162629
163188
|
}
|
|
162630
163189
|
await cdp.send("Profiler.stop").catch(ignore);
|
|
162631
163190
|
api.profilingActive = false;
|
|
162632
|
-
const
|
|
163191
|
+
const runtimeDevices = isLogicalKeyedDevice(api.deviceId) ? await findProfiledDevices(cdp) : { found: [], unresolved: [] };
|
|
162633
163192
|
const sessionId = crypto6.randomUUID();
|
|
162634
163193
|
const ownerPayload = {
|
|
162635
163194
|
sessionId,
|
|
@@ -162712,8 +163271,8 @@ Fails if the Hermes runtime is not reachable or the Metro CDP connection cannot
|
|
|
162712
163271
|
api.sessionId = sessionId;
|
|
162713
163272
|
api.ownerToolServerPid = process.pid;
|
|
162714
163273
|
trackProfilingRun(api.deviceId, api);
|
|
162715
|
-
|
|
162716
|
-
const warning = nativeNetworkCaptureWarning(deviceId
|
|
163274
|
+
for (const device of trackedIds(runtimeDevices.found)) trackProfilingRun(device, api);
|
|
163275
|
+
const warning = nativeNetworkCaptureWarning(api.deviceId, api.runtimeApp, runtimeDevices);
|
|
162717
163276
|
return {
|
|
162718
163277
|
started_at: new Date(startedAtEpochMs).toISOString(),
|
|
162719
163278
|
startedAtEpochMs,
|
|
@@ -162721,7 +163280,7 @@ Fails if the Hermes runtime is not reachable or the Metro CDP connection cannot
|
|
|
162721
163280
|
detected_architecture: api.detectedArchitecture,
|
|
162722
163281
|
...tookOver ? { took_over: tookOver } : {},
|
|
162723
163282
|
...warning ? { warning } : {},
|
|
162724
|
-
...isLogicalKeyedDevice(api.deviceId) &&
|
|
163283
|
+
...isLogicalKeyedDevice(api.deviceId) && runtimeDevices.found.length === 0 ? { [RESULT_NOTE_KEY]: UNKNOWN_DEVICE_NOTE } : {}
|
|
162725
163284
|
};
|
|
162726
163285
|
}
|
|
162727
163286
|
};
|
|
@@ -171154,203 +171713,6 @@ var import_fs18 = require("fs");
|
|
|
171154
171713
|
var import_child_process9 = require("child_process");
|
|
171155
171714
|
init_src2();
|
|
171156
171715
|
|
|
171157
|
-
// ../tool-server/src/tools/screen-recording/mjpeg-stream.ts
|
|
171158
|
-
var import_http = __toESM(require("http"));
|
|
171159
|
-
init_src2();
|
|
171160
|
-
var MAX_BUFFER_BYTES = 64 * 1024 * 1024;
|
|
171161
|
-
function delimiterFromContentType(contentType) {
|
|
171162
|
-
const match = /boundary=([^;\s]+)/i.exec(contentType ?? "");
|
|
171163
|
-
const boundary = match?.[1]?.replace(/^"|"$/g, "") ?? "NextFrame";
|
|
171164
|
-
return Buffer.from(`--${boundary}`);
|
|
171165
|
-
}
|
|
171166
|
-
function streamFailure(message, stage, kind = "network", cause) {
|
|
171167
|
-
return new FailureError(
|
|
171168
|
-
message,
|
|
171169
|
-
{
|
|
171170
|
-
error_code: FAILURE_CODES.SCREEN_RECORDING_STREAM_UNAVAILABLE,
|
|
171171
|
-
failure_stage: stage,
|
|
171172
|
-
failure_area: "tool_server",
|
|
171173
|
-
error_kind: kind,
|
|
171174
|
-
failure_command: "simulator_server"
|
|
171175
|
-
},
|
|
171176
|
-
cause instanceof Error ? { cause } : void 0
|
|
171177
|
-
);
|
|
171178
|
-
}
|
|
171179
|
-
function openMjpegStream(url2, connectTimeoutMs = 1e4) {
|
|
171180
|
-
return new Promise((resolve19, reject) => {
|
|
171181
|
-
let settled = false;
|
|
171182
|
-
const request3 = import_http.default.get(url2, (res) => {
|
|
171183
|
-
request3.setTimeout(0);
|
|
171184
|
-
res.socket?.setTimeout(0);
|
|
171185
|
-
if (res.statusCode !== 200) {
|
|
171186
|
-
res.resume();
|
|
171187
|
-
settled = true;
|
|
171188
|
-
reject(
|
|
171189
|
-
streamFailure(
|
|
171190
|
-
`simulator-server's frame stream returned HTTP ${res.statusCode ?? "?"} at ${url2}.`,
|
|
171191
|
-
"screen_recording_stream_connect"
|
|
171192
|
-
)
|
|
171193
|
-
);
|
|
171194
|
-
return;
|
|
171195
|
-
}
|
|
171196
|
-
const delimiter = delimiterFromContentType(res.headers["content-type"]);
|
|
171197
|
-
let buffer = Buffer.alloc(0);
|
|
171198
|
-
const state3 = {
|
|
171199
|
-
latest: null,
|
|
171200
|
-
frameCount: 0,
|
|
171201
|
-
error: null
|
|
171202
|
-
};
|
|
171203
|
-
let firstFrameResolve = null;
|
|
171204
|
-
let firstFrameReject = null;
|
|
171205
|
-
res.on("data", (chunk) => {
|
|
171206
|
-
buffer = buffer.length === 0 ? chunk : Buffer.concat([buffer, chunk]);
|
|
171207
|
-
for (; ; ) {
|
|
171208
|
-
const partStart = buffer.indexOf(delimiter);
|
|
171209
|
-
if (partStart < 0) break;
|
|
171210
|
-
const headerEnd = buffer.indexOf("\r\n\r\n", partStart);
|
|
171211
|
-
if (headerEnd < 0) break;
|
|
171212
|
-
const frameStart = headerEnd + 4;
|
|
171213
|
-
const frameEnd = buffer.indexOf(delimiter, frameStart);
|
|
171214
|
-
if (frameEnd < 0) break;
|
|
171215
|
-
if (frameEnd > frameStart) {
|
|
171216
|
-
const frame2 = Buffer.from(buffer.subarray(frameStart, frameEnd));
|
|
171217
|
-
state3.latest = frame2;
|
|
171218
|
-
state3.frameCount++;
|
|
171219
|
-
if (firstFrameResolve) {
|
|
171220
|
-
firstFrameResolve(frame2);
|
|
171221
|
-
firstFrameResolve = null;
|
|
171222
|
-
firstFrameReject = null;
|
|
171223
|
-
}
|
|
171224
|
-
}
|
|
171225
|
-
buffer = buffer.subarray(frameEnd);
|
|
171226
|
-
}
|
|
171227
|
-
if (buffer.length > MAX_BUFFER_BYTES) buffer = Buffer.alloc(0);
|
|
171228
|
-
});
|
|
171229
|
-
const fail = (err) => {
|
|
171230
|
-
state3.error = err;
|
|
171231
|
-
if (firstFrameReject) {
|
|
171232
|
-
const reject2 = firstFrameReject;
|
|
171233
|
-
firstFrameResolve = null;
|
|
171234
|
-
firstFrameReject = null;
|
|
171235
|
-
reject2(
|
|
171236
|
-
streamFailure(
|
|
171237
|
-
`simulator-server's frame stream dropped before the first frame arrived: ${err.message}`,
|
|
171238
|
-
"screen_recording_stream_first_frame",
|
|
171239
|
-
"network",
|
|
171240
|
-
err
|
|
171241
|
-
)
|
|
171242
|
-
);
|
|
171243
|
-
}
|
|
171244
|
-
};
|
|
171245
|
-
res.on("error", fail);
|
|
171246
|
-
res.on("aborted", () => fail(new Error("frame stream aborted")));
|
|
171247
|
-
settled = true;
|
|
171248
|
-
resolve19({
|
|
171249
|
-
get latest() {
|
|
171250
|
-
return state3.latest;
|
|
171251
|
-
},
|
|
171252
|
-
get frameCount() {
|
|
171253
|
-
return state3.frameCount;
|
|
171254
|
-
},
|
|
171255
|
-
get error() {
|
|
171256
|
-
return state3.error;
|
|
171257
|
-
},
|
|
171258
|
-
waitForFirstFrame(timeoutMs) {
|
|
171259
|
-
if (state3.latest) return Promise.resolve(state3.latest);
|
|
171260
|
-
if (state3.error) {
|
|
171261
|
-
return Promise.reject(
|
|
171262
|
-
streamFailure(
|
|
171263
|
-
`simulator-server's frame stream dropped before any frame arrived: ${state3.error.message}`,
|
|
171264
|
-
"screen_recording_stream_first_frame",
|
|
171265
|
-
"network",
|
|
171266
|
-
state3.error
|
|
171267
|
-
)
|
|
171268
|
-
);
|
|
171269
|
-
}
|
|
171270
|
-
return new Promise((resolveFrame, rejectFrame) => {
|
|
171271
|
-
const timer = setTimeout(() => {
|
|
171272
|
-
firstFrameResolve = null;
|
|
171273
|
-
firstFrameReject = null;
|
|
171274
|
-
rejectFrame(
|
|
171275
|
-
streamFailure(
|
|
171276
|
-
`No frame arrived from simulator-server within ${timeoutMs} ms. Is the device booted and its screen on?`,
|
|
171277
|
-
"screen_recording_stream_first_frame",
|
|
171278
|
-
"timeout"
|
|
171279
|
-
)
|
|
171280
|
-
);
|
|
171281
|
-
}, timeoutMs);
|
|
171282
|
-
firstFrameResolve = (frame2) => {
|
|
171283
|
-
clearTimeout(timer);
|
|
171284
|
-
firstFrameReject = null;
|
|
171285
|
-
resolveFrame(frame2);
|
|
171286
|
-
};
|
|
171287
|
-
firstFrameReject = (err) => {
|
|
171288
|
-
clearTimeout(timer);
|
|
171289
|
-
firstFrameResolve = null;
|
|
171290
|
-
rejectFrame(err);
|
|
171291
|
-
};
|
|
171292
|
-
});
|
|
171293
|
-
},
|
|
171294
|
-
close() {
|
|
171295
|
-
firstFrameResolve = null;
|
|
171296
|
-
firstFrameReject = null;
|
|
171297
|
-
res.destroy();
|
|
171298
|
-
request3.destroy();
|
|
171299
|
-
}
|
|
171300
|
-
});
|
|
171301
|
-
});
|
|
171302
|
-
request3.setTimeout(connectTimeoutMs, () => {
|
|
171303
|
-
request3.destroy(
|
|
171304
|
-
streamFailure(
|
|
171305
|
-
`Connecting to simulator-server's frame stream at ${url2} timed out after ${connectTimeoutMs} ms.`,
|
|
171306
|
-
"screen_recording_stream_connect",
|
|
171307
|
-
"timeout"
|
|
171308
|
-
)
|
|
171309
|
-
);
|
|
171310
|
-
});
|
|
171311
|
-
request3.on("error", (err) => {
|
|
171312
|
-
if (settled) return;
|
|
171313
|
-
settled = true;
|
|
171314
|
-
reject(
|
|
171315
|
-
err instanceof FailureError ? err : streamFailure(
|
|
171316
|
-
`Could not open simulator-server's frame stream at ${url2}: ${err.message}`,
|
|
171317
|
-
"screen_recording_stream_connect",
|
|
171318
|
-
"network",
|
|
171319
|
-
err
|
|
171320
|
-
)
|
|
171321
|
-
);
|
|
171322
|
-
});
|
|
171323
|
-
});
|
|
171324
|
-
}
|
|
171325
|
-
function readJpegDimensions(jpeg) {
|
|
171326
|
-
let offset = 2;
|
|
171327
|
-
while (offset + 9 < jpeg.length) {
|
|
171328
|
-
if (jpeg[offset] !== 255) {
|
|
171329
|
-
offset++;
|
|
171330
|
-
continue;
|
|
171331
|
-
}
|
|
171332
|
-
const marker = jpeg[offset + 1];
|
|
171333
|
-
if (marker === 255) {
|
|
171334
|
-
offset++;
|
|
171335
|
-
continue;
|
|
171336
|
-
}
|
|
171337
|
-
if (marker === 216 || marker === 1 || marker >= 208 && marker <= 215) {
|
|
171338
|
-
offset += 2;
|
|
171339
|
-
continue;
|
|
171340
|
-
}
|
|
171341
|
-
if (marker === 192 || marker === 193 || marker === 194) {
|
|
171342
|
-
const height = jpeg.readUInt16BE(offset + 5);
|
|
171343
|
-
const width = jpeg.readUInt16BE(offset + 7);
|
|
171344
|
-
if (width > 0 && height > 0) return { width, height };
|
|
171345
|
-
return null;
|
|
171346
|
-
}
|
|
171347
|
-
const segmentLength = jpeg.readUInt16BE(offset + 2);
|
|
171348
|
-
if (segmentLength < 2) return null;
|
|
171349
|
-
offset += 2 + segmentLength;
|
|
171350
|
-
}
|
|
171351
|
-
return null;
|
|
171352
|
-
}
|
|
171353
|
-
|
|
171354
171716
|
// ../tool-server/src/tools/screen-recording/session-guards.ts
|
|
171355
171717
|
var import_fs16 = require("fs");
|
|
171356
171718
|
init_src2();
|
|
@@ -171571,7 +171933,7 @@ var MAX_CATCHUP_FRAMES = 5;
|
|
|
171571
171933
|
var MAX_BUFFERED_BYTES = 32 * 1024 * 1024;
|
|
171572
171934
|
var STATIC_GRACE_MS = 1e3;
|
|
171573
171935
|
var STREAM_CONNECT_TIMEOUT_MS = 1e4;
|
|
171574
|
-
var
|
|
171936
|
+
var FIRST_FRAME_TIMEOUT_MS2 = 1e4;
|
|
171575
171937
|
var PANEL_POLL_MS = 1e3;
|
|
171576
171938
|
var PANEL_FIRST_FRAME_TIMEOUT_MS = 5e3;
|
|
171577
171939
|
var START_FAILFAST_GRACE_MS = 800;
|
|
@@ -171783,7 +172145,7 @@ async function startCaptureLocked(api, params) {
|
|
|
171783
172145
|
let watermarkSkipped = null;
|
|
171784
172146
|
let child;
|
|
171785
172147
|
try {
|
|
171786
|
-
const firstFrame = await stream.waitForFirstFrame(
|
|
172148
|
+
const firstFrame = await stream.waitForFirstFrame(FIRST_FRAME_TIMEOUT_MS2);
|
|
171787
172149
|
const canvas = readJpegDimensions(firstFrame);
|
|
171788
172150
|
let graph = null;
|
|
171789
172151
|
if (params.watermark && canvas) {
|
|
@@ -174755,8 +175117,8 @@ Fails if the input has an unknown key (e.g. \`udids\` instead of \`devices\`); o
|
|
|
174755
175117
|
// "all" only holds for the unscoped sweep; a scoped call touches just the
|
|
174756
175118
|
// ids it was given.
|
|
174757
175119
|
startedMsg: ({ params }) => {
|
|
174758
|
-
const
|
|
174759
|
-
return
|
|
175120
|
+
const devices2 = params?.devices;
|
|
175121
|
+
return devices2 ? `Stopping simulator servers for ${devices2.length} ${devices2.length === 1 ? "device" : "devices"}` : "Stopping all simulator servers";
|
|
174760
175122
|
},
|
|
174761
175123
|
completedMsg: ({ result }) => {
|
|
174762
175124
|
const n = result.stopped.length;
|
|
@@ -174780,8 +175142,8 @@ Fails if the input has an unknown key (e.g. \`udids\` instead of \`devices\`); o
|
|
|
174780
175142
|
},
|
|
174781
175143
|
services: () => ({}),
|
|
174782
175144
|
async execute(_services, params, ctx) {
|
|
174783
|
-
const
|
|
174784
|
-
const scoped =
|
|
175145
|
+
const devices2 = params.devices;
|
|
175146
|
+
const scoped = devices2 !== void 0;
|
|
174785
175147
|
const snapshot = registry2.getSnapshot();
|
|
174786
175148
|
const stopped = [];
|
|
174787
175149
|
const matchedIds = /* @__PURE__ */ new Set();
|
|
@@ -174792,7 +175154,7 @@ Fails if the input has an unknown key (e.g. \`udids\` instead of \`devices\`); o
|
|
|
174792
175154
|
aborted2 = true;
|
|
174793
175155
|
break;
|
|
174794
175156
|
}
|
|
174795
|
-
const matchedId = scoped ? deviceIdOwningUrn(urn, DEVICE_OWNED_NAMESPACES,
|
|
175157
|
+
const matchedId = scoped ? deviceIdOwningUrn(urn, DEVICE_OWNED_NAMESPACES, devices2) : void 0;
|
|
174796
175158
|
const matches2 = scoped ? matchedId !== void 0 : isDeviceServiceUrn(urn, DEVICE_OWNED_NAMESPACES);
|
|
174797
175159
|
if (matchedId !== void 0) matchedIds.add(matchedId.toLowerCase());
|
|
174798
175160
|
if (matches2 && entry.state !== "IDLE" /* IDLE */) {
|
|
@@ -174806,7 +175168,7 @@ Fails if the input has an unknown key (e.g. \`udids\` instead of \`devices\`); o
|
|
|
174806
175168
|
if (aborted2) return { stopped, aborted: true };
|
|
174807
175169
|
if (!scoped) return { stopped };
|
|
174808
175170
|
const seen = /* @__PURE__ */ new Set();
|
|
174809
|
-
const unmatched =
|
|
175171
|
+
const unmatched = devices2.filter((id) => {
|
|
174810
175172
|
const key2 = id.toLowerCase();
|
|
174811
175173
|
if (matchedIds.has(key2) || seen.has(key2)) return false;
|
|
174812
175174
|
seen.add(key2);
|
|
@@ -177121,7 +177483,7 @@ function serializeFlow(flow) {
|
|
|
177121
177483
|
steps: flow.steps.map(toYamlStep)
|
|
177122
177484
|
};
|
|
177123
177485
|
if (flow.executionPrerequisite) doc.executionPrerequisite = flow.executionPrerequisite;
|
|
177124
|
-
return (0, import_yaml.stringify)(doc, { blockQuote: false });
|
|
177486
|
+
return (0, import_yaml.stringify)(doc, { blockQuote: false, doubleQuotedMinMultiLineLength: Infinity });
|
|
177125
177487
|
}
|
|
177126
177488
|
function validateFlow(flow) {
|
|
177127
177489
|
assertNoOutputReferences(flow.steps);
|
|
@@ -177625,14 +177987,14 @@ function isBooted(d, platform) {
|
|
|
177625
177987
|
return false;
|
|
177626
177988
|
}
|
|
177627
177989
|
}
|
|
177628
|
-
function connectedIosDeviceHint(
|
|
177990
|
+
function connectedIosDeviceHint(devices2, platform) {
|
|
177629
177991
|
if (platform && platform !== "ios") return "";
|
|
177630
|
-
const ids =
|
|
177992
|
+
const ids = devices2.filter((d) => d.platform === "ios" && d.kind === "device" && d.state === "connected").map((d) => d.udid).filter((id) => Boolean(id));
|
|
177631
177993
|
if (ids.length === 0) return "";
|
|
177632
177994
|
return ` A physical iPhone is connected (${ids.join(", ")}); hardware is never picked automatically, pass device <udid> (--device on the CLI) to run on it.`;
|
|
177633
177995
|
}
|
|
177634
|
-
function macosAppHint(
|
|
177635
|
-
if (platform || !
|
|
177996
|
+
function macosAppHint(devices2, platform) {
|
|
177997
|
+
if (platform || !devices2.some((d) => d.platform === "macos")) return "";
|
|
177636
177998
|
return " A Mac app is picked only with --platform macos or --device.";
|
|
177637
177999
|
}
|
|
177638
178000
|
function macosFlagHint(platform) {
|
|
@@ -177719,9 +178081,9 @@ async function assertDeviceMeetsRequires(device, requires, subject2 = "This e2e
|
|
|
177719
178081
|
);
|
|
177720
178082
|
}
|
|
177721
178083
|
}
|
|
177722
|
-
function unknownRuntimeKindError(requires,
|
|
178084
|
+
function unknownRuntimeKindError(requires, devices2, subject2 = "This e2e test", remedy = "") {
|
|
177723
178085
|
return requirementsError(
|
|
177724
|
-
`${subject2} declares ${describeRequires(requires)}, but the runtime kind of ${
|
|
178086
|
+
`${subject2} declares ${describeRequires(requires)}, but the runtime kind of ${devices2.join(", ")} could not be determined.${remedy}`,
|
|
177725
178087
|
FAILURE_CODES.FLOW_DEVICE_RESOLUTION
|
|
177726
178088
|
);
|
|
177727
178089
|
}
|
|
@@ -177739,8 +178101,8 @@ async function resolveFlowDevice(registry2, ctx, opts) {
|
|
|
177739
178101
|
if (macosRefusal) throw deviceResolutionError(`Cannot run on ${device.id}: ${macosRefusal}`);
|
|
177740
178102
|
return device;
|
|
177741
178103
|
}
|
|
177742
|
-
const { devices } = await invokeSubTool(registry2, ctx, "list-devices", {});
|
|
177743
|
-
const booted =
|
|
178104
|
+
const { devices: devices2 } = await invokeSubTool(registry2, ctx, "list-devices", {});
|
|
178105
|
+
const booted = devices2.filter((d) => isBooted(d, opts.platform));
|
|
177744
178106
|
const scoped = opts.platform ? booted.filter((d) => d.platform === opts.platform) : booted;
|
|
177745
178107
|
const requires = opts.requires;
|
|
177746
178108
|
const candidates = requires ? scoped.filter((d) => platformMeets(d.platform, requires)) : scoped;
|
|
@@ -177782,8 +178144,8 @@ async function resolveFlowDevice(registry2, ctx, opts) {
|
|
|
177782
178144
|
if (eligible.length === 0) {
|
|
177783
178145
|
const what = opts.platform ? `No booted ${opts.platform} device found.` : "No booted device found.";
|
|
177784
178146
|
throw deviceResolutionError(
|
|
177785
|
-
`${what} Pass a device id or platform explicitly.${connectedIosDeviceHint(
|
|
177786
|
-
|
|
178147
|
+
`${what} Pass a device id or platform explicitly.${connectedIosDeviceHint(devices2, opts.platform)}${macosAppHint(devices2, opts.platform)}${macosFlagHint(opts.platform)}`,
|
|
178148
|
+
devices2
|
|
177787
178149
|
);
|
|
177788
178150
|
}
|
|
177789
178151
|
throw deviceResolutionError(
|
|
@@ -177904,6 +178266,7 @@ function asViewNode(v) {
|
|
|
177904
178266
|
className: nonEmptyString(r.className),
|
|
177905
178267
|
identifier: nonEmptyString(r.identifier),
|
|
177906
178268
|
label: nonEmptyString(r.label),
|
|
178269
|
+
value: nonEmptyString(r.value),
|
|
177907
178270
|
frame: asRect2(r.frame),
|
|
177908
178271
|
windowFrame: asRect2(r.windowFrame),
|
|
177909
178272
|
screenFrame: asRect2(r.screenFrame),
|
|
@@ -177913,10 +178276,11 @@ function asViewNode(v) {
|
|
|
177913
178276
|
children
|
|
177914
178277
|
};
|
|
177915
178278
|
}
|
|
178279
|
+
var IOS_TEXT_INPUT_ROLE = "AXTextField";
|
|
177916
178280
|
function roleFromClassName(cn) {
|
|
177917
178281
|
if (!cn) return "AXGroup";
|
|
177918
178282
|
if (/Button/i.test(cn)) return "AXButton";
|
|
177919
|
-
if (/(TextField|TextView|SearchField)/i.test(cn)) return
|
|
178283
|
+
if (/(TextField|TextView|SearchField)/i.test(cn)) return IOS_TEXT_INPUT_ROLE;
|
|
177920
178284
|
if (/(Label|Text)/i.test(cn)) return "AXStaticText";
|
|
177921
178285
|
if (/Image/i.test(cn)) return "AXImage";
|
|
177922
178286
|
if (/(Slider|Stepper|Switch|ProgressView)/i.test(cn)) return "AXAdjustable";
|
|
@@ -177939,9 +178303,12 @@ function normalizeFrame4(rect, screenW, screenH) {
|
|
|
177939
178303
|
height: roundNormalized3(height)
|
|
177940
178304
|
};
|
|
177941
178305
|
}
|
|
177942
|
-
function projectIosNode(node2, screenW, screenH) {
|
|
178306
|
+
function projectIosNode(node2, screenW, screenH, quotedLabel) {
|
|
177943
178307
|
const skip = node2.hidden === true || node2.alpha !== void 0 && node2.alpha < 0.01;
|
|
177944
178308
|
const role = roleFromClassName(node2.className);
|
|
178309
|
+
const held = role === IOS_TEXT_INPUT_ROLE && node2.value !== node2.label ? node2.value : void 0;
|
|
178310
|
+
const value = quotedLabel && held !== void 0 ? WITHHELD_INPUT_TEXT : held;
|
|
178311
|
+
const label = quotedLabel && node2.label !== void 0 ? quotedLabel(node2.label) : node2.label;
|
|
177945
178312
|
const win = node2.screenFrame ?? node2.windowFrame;
|
|
177946
178313
|
const rect = win ? { x: win.x, y: win.y, w: win.width, h: win.height } : null;
|
|
177947
178314
|
let leaf = null;
|
|
@@ -177954,27 +178321,34 @@ function projectIosNode(node2, screenW, screenH) {
|
|
|
177954
178321
|
role,
|
|
177955
178322
|
frame: frame2,
|
|
177956
178323
|
children: [],
|
|
177957
|
-
label
|
|
178324
|
+
label,
|
|
178325
|
+
value,
|
|
177958
178326
|
identifier: node2.identifier,
|
|
177959
178327
|
focused: node2.firstResponder || void 0
|
|
177960
178328
|
};
|
|
177961
178329
|
}
|
|
177962
178330
|
}
|
|
178331
|
+
const ownTextParts = frame2 ? [label, value].filter((text) => Boolean(text)) : [];
|
|
177963
178332
|
return {
|
|
177964
178333
|
skip,
|
|
177965
178334
|
children: node2.children ?? [],
|
|
177966
178335
|
// Text hoists only from on-screen nodes (frame is null when the view is
|
|
177967
178336
|
// scrolled off or zero-area) — otherwise a text assert against an ancestor
|
|
177968
178337
|
// would pass on content the screen doesn't show. A label makes a node
|
|
177969
|
-
// leaf-eligible, so
|
|
177970
|
-
|
|
178338
|
+
// leaf-eligible, and so does the text input role a value needs, so `frame`
|
|
178339
|
+
// was computed for any node with text. Mirrors what `nodeText` reads off
|
|
178340
|
+
// the leaf: the label plus a distinct value.
|
|
178341
|
+
ownText: ownTextParts.join(" "),
|
|
178342
|
+
// Apart as well: the view under an empty field that draws its placeholder
|
|
178343
|
+
// repeats the value and not the label, and a floating label the reverse.
|
|
178344
|
+
ownTextParts,
|
|
177971
178345
|
leaf,
|
|
177972
178346
|
shield: Boolean(node2.identifier),
|
|
177973
178347
|
rect,
|
|
177974
178348
|
scrolls: role === "AXScrollArea"
|
|
177975
178349
|
};
|
|
177976
178350
|
}
|
|
177977
|
-
function adaptFullHierarchy(raw) {
|
|
178351
|
+
function adaptFullHierarchy(raw, quotedLabel) {
|
|
177978
178352
|
const payload = typeof raw === "object" && raw !== null ? raw : {};
|
|
177979
178353
|
const reportedScreen = typeof payload.screen === "object" && payload.screen !== null ? payload.screen : void 0;
|
|
177980
178354
|
const windows = Array.isArray(payload.windows) ? payload.windows.map(asViewNode).filter((n) => n !== null) : [];
|
|
@@ -177996,7 +178370,7 @@ function adaptFullHierarchy(raw) {
|
|
|
177996
178370
|
const children = [];
|
|
177997
178371
|
if (screenW > 0 && screenH > 0) {
|
|
177998
178372
|
for (const win of windows) {
|
|
177999
|
-
flattenHoisting(win, (n) => projectIosNode(n, screenW, screenH), children);
|
|
178373
|
+
flattenHoisting(win, (n) => projectIosNode(n, screenW, screenH, quotedLabel), children);
|
|
178000
178374
|
}
|
|
178001
178375
|
}
|
|
178002
178376
|
const tree = parseDescribeResult({
|
|
@@ -178017,6 +178391,9 @@ var FULL_HIERARCHY_FIELDS = [
|
|
|
178017
178391
|
"className",
|
|
178018
178392
|
"identifier",
|
|
178019
178393
|
"label",
|
|
178394
|
+
// A text input's text; an injected framework that omits it leaves a filled
|
|
178395
|
+
// field reading as empty.
|
|
178396
|
+
"value",
|
|
178020
178397
|
"frame",
|
|
178021
178398
|
"windowFrame",
|
|
178022
178399
|
"screenFrame",
|
|
@@ -178179,8 +178556,10 @@ async function queryFullHierarchyTree(registry2, device, target) {
|
|
|
178179
178556
|
);
|
|
178180
178557
|
}
|
|
178181
178558
|
const { tree, screen, uiOrientation } = adaptFullHierarchy(rawResult);
|
|
178559
|
+
const quotableTree = secretTypedOn(device.id) ? adaptFullHierarchy(rawResult, (label) => redactTypedSecrets(device.id, label)).tree : void 0;
|
|
178182
178560
|
return {
|
|
178183
178561
|
tree,
|
|
178562
|
+
...quotableTree ? { quotableTree } : {},
|
|
178184
178563
|
source: "native-devtools",
|
|
178185
178564
|
...screen ? { screen } : {},
|
|
178186
178565
|
...uiOrientation ? { uiOrientation } : {}
|
|
@@ -179289,6 +179668,7 @@ async function runType(env, step) {
|
|
|
179289
179668
|
async function waitForCondition(env, step, timeoutMs) {
|
|
179290
179669
|
const deadline = Date.now() + timeoutMs;
|
|
179291
179670
|
let lastMatches = [];
|
|
179671
|
+
let lastData;
|
|
179292
179672
|
let fetchError;
|
|
179293
179673
|
let everMatched = false;
|
|
179294
179674
|
let lastTrustedReadAt;
|
|
@@ -179300,6 +179680,7 @@ async function waitForCondition(env, step, timeoutMs) {
|
|
|
179300
179680
|
try {
|
|
179301
179681
|
const data = await readFlowTree(env);
|
|
179302
179682
|
lastMatches = flowFindAll(data.tree, step.selector, data.uiOrientation);
|
|
179683
|
+
lastData = data;
|
|
179303
179684
|
fetchError = void 0;
|
|
179304
179685
|
everMatched ||= lastMatches.length > 0;
|
|
179305
179686
|
const blind = isBlindRead(data, everMatched, step.condition);
|
|
@@ -179367,7 +179748,10 @@ async function waitForCondition(env, step, timeoutMs) {
|
|
|
179367
179748
|
// The read `lastMatches` came from is the last one that answered, and
|
|
179368
179749
|
// only a read that answers writes the orientation.
|
|
179369
179750
|
readingOrientation(env),
|
|
179370
|
-
env.device.platform === "macos"
|
|
179751
|
+
env.device.platform === "macos",
|
|
179752
|
+
// The text of an element is the only part of a reason that comes off
|
|
179753
|
+
// the screen, where a field shows a typed secret.
|
|
179754
|
+
(node2, read) => lastData ? quotedText(lastData, env.device.id, node2, read) : read(node2)
|
|
179371
179755
|
) + blipNote
|
|
179372
179756
|
};
|
|
179373
179757
|
}
|
|
@@ -179587,7 +179971,7 @@ async function waitForIdle(env, step) {
|
|
|
179587
179971
|
warning: `the screen never held still for ${MIN_STILL_INTERVALS} consecutive ${IDLE_POLL_MS}ms intervals${stableFor > 0 ? ` spanning ${stableFor}ms` : ""} within ${timeoutMs}ms, and was moving again on the last one, so this step went ahead without waiting it out. Either something on it never stops (a video, a looping animation, a carousel, live-updating text) or the screen never finished loading. Look at what is moving, and make sure the next action is gated on a stable element rather than on stillness.` + blipNote
|
|
179588
179972
|
};
|
|
179589
179973
|
}
|
|
179590
|
-
function assertReason(condition, selector, expectedText, textMatch, matches2, orientation, macos) {
|
|
179974
|
+
function assertReason(condition, selector, expectedText, textMatch, matches2, orientation, macos, quoted) {
|
|
179591
179975
|
const sel = describeSelector(selector);
|
|
179592
179976
|
switch (condition) {
|
|
179593
179977
|
case "exists":
|
|
@@ -179600,9 +179984,8 @@ function assertReason(condition, selector, expectedText, textMatch, matches2, or
|
|
|
179600
179984
|
const first = textCheckTarget(matches2, orientation, macos);
|
|
179601
179985
|
if (!first) return `no element matched selector ${sel}`;
|
|
179602
179986
|
const wanted = describeTextExpectation(expectedText, textMatch, "infinitive");
|
|
179603
|
-
const
|
|
179604
|
-
const
|
|
179605
|
-
const own2 = field ?? nodeText(first);
|
|
179987
|
+
const shown = quoted(first, (node2) => macFieldText(node2, macos) ?? assertText(node2));
|
|
179988
|
+
const own2 = quoted(first, (node2) => macFieldText(node2, macos) ?? nodeText(node2));
|
|
179606
179989
|
const ownNote = own2 && own2 !== shown ? ` (own text "${own2}")` : "";
|
|
179607
179990
|
return `element matched ${sel} but its text was "${shown}"${ownNote} (wanted to ${wanted})`;
|
|
179608
179991
|
}
|
|
@@ -180428,6 +180811,9 @@ function innermostTreeReason(message) {
|
|
|
180428
180811
|
const unwrapped = /helper is unavailable:\s*(.+)/s.exec(message)?.[1] ?? message;
|
|
180429
180812
|
return unwrapped.replace(/^\[[^\]]+\]\s*/, "").trim();
|
|
180430
180813
|
}
|
|
180814
|
+
function withoutTypedText(node2, { source }) {
|
|
180815
|
+
return source === "native-devtools" && node2.role === IOS_TEXT_INPUT_ROLE ? { ...node2, value: void 0 } : node2;
|
|
180816
|
+
}
|
|
180431
180817
|
async function captureTapSelector(registry2, session, udid, point) {
|
|
180432
180818
|
try {
|
|
180433
180819
|
const device = resolveDevice(udid);
|
|
@@ -180440,7 +180826,7 @@ async function captureTapSelector(registry2, session, udid, point) {
|
|
|
180440
180826
|
const { tree, uiOrientation } = data;
|
|
180441
180827
|
const node2 = nodeAtPoint(tree, point);
|
|
180442
180828
|
if (!node2) return { warning: "no element found under the tap; kept coordinates (brittle)" };
|
|
180443
|
-
const selector = deriveSelector(node2);
|
|
180829
|
+
const selector = deriveSelector(withoutTypedText(node2, data));
|
|
180444
180830
|
if (!selector)
|
|
180445
180831
|
return { warning: "tapped element has no stable text/id; kept coordinates (brittle)" };
|
|
180446
180832
|
const resolved = selectorToFrame(tree, selector, uiOrientation);
|