@swmansion/argent 0.34.1-next.80 → 0.34.1-next.81
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.
|
@@ -630,25 +630,25 @@ export interface ArgentToolArgs {
|
|
|
630
630
|
hitTest?: boolean;
|
|
631
631
|
};
|
|
632
632
|
"network-capture-start": {
|
|
633
|
-
/**
|
|
633
|
+
/** Target ID from list-devices: an iOS simulator UDID, an Android serial, a Mac app ID (macos-app-<bundle id>) or a Chromium ID (chromium-cdp-<port>). */
|
|
634
634
|
udid: string;
|
|
635
|
-
/** App bundle ID on iOS or package name on Android
|
|
635
|
+
/** App bundle ID on iOS or package name on Android. On Mac apps, use the bundle ID from udid. On Chromium, udid selects the app. Use a valid placeholder such as argent.capture. */
|
|
636
636
|
bundleId: string;
|
|
637
|
-
/** The app's Metro port
|
|
637
|
+
/** The app's Metro port. Omit it to use the device's port (8081 by default). Native layers exclude requests to this port on local addresses. Chromium uses the CDP port in udid. */
|
|
638
638
|
port?: number;
|
|
639
|
-
/**
|
|
639
|
+
/** Use js for JavaScript runtime capture or native for native HTTP capture. Omit to control both layers. Chromium ignores this setting and uses its single chromium layer. */
|
|
640
640
|
layer?: "js" | "native";
|
|
641
641
|
/** Only when several devices share the Metro port: this device's logicalDeviceId, which the JS layer's reason lists. The JS layer connects to that runtime, and view-network-logs then takes it as device_id. The native layer always uses udid. */
|
|
642
642
|
logicalDeviceId?: string;
|
|
643
643
|
};
|
|
644
644
|
"network-capture-stop": {
|
|
645
|
-
/**
|
|
645
|
+
/** Target ID from list-devices: an iOS simulator UDID, an Android serial, a Mac app ID (macos-app-<bundle id>) or a Chromium ID (chromium-cdp-<port>). */
|
|
646
646
|
udid: string;
|
|
647
|
-
/** App bundle ID on iOS or package name on Android
|
|
647
|
+
/** App bundle ID on iOS or package name on Android. On Mac apps, use the bundle ID from udid. On Chromium, udid selects the app. Use a valid placeholder such as argent.capture. */
|
|
648
648
|
bundleId: string;
|
|
649
|
-
/** The app's Metro port
|
|
649
|
+
/** The app's Metro port. Omit it to use the device's port (8081 by default). Native layers exclude requests to this port on local addresses. Chromium uses the CDP port in udid. */
|
|
650
650
|
port?: number;
|
|
651
|
-
/**
|
|
651
|
+
/** Use js for JavaScript runtime capture or native for native HTTP capture. Omit to control both layers. Chromium ignores this setting and uses its single chromium layer. */
|
|
652
652
|
layer?: "js" | "native";
|
|
653
653
|
/** Only when several devices share the Metro port: this device's logicalDeviceId, which the JS layer's reason lists. The JS layer connects to that runtime, and view-network-logs then takes it as device_id. The native layer always uses udid. */
|
|
654
654
|
logicalDeviceId?: string;
|
package/dist/tool-server.cjs
CHANGED
|
@@ -51253,8 +51253,7 @@ var init_capability = __esm({
|
|
|
51253
51253
|
"reinstall-app": "argent does not install Mac apps, it starts the .app where it was built. Rebuild the app, then run restart-app (or boot-device with macosAppPath for a .app at another path)"
|
|
51254
51254
|
};
|
|
51255
51255
|
NO_CAPTURE_START_STOP_REASONS = {
|
|
51256
|
-
vega: "a Vega app's network capture has no start or stop: view-network-logs turns it on at its first call"
|
|
51257
|
-
chromium: "a Chromium app's network capture has no start or stop: argent turns it on at the first tool call on the app; read the requests with view-network-logs"
|
|
51256
|
+
vega: "a Vega app's network capture has no start or stop: view-network-logs turns it on at its first call"
|
|
51258
51257
|
};
|
|
51259
51258
|
CATALYST_NO_APPKIT_VIEWS = "a Mac Catalyst app's UIKit views are not in its AppKit view tree: use describe, which lists them with their identifiers and frames";
|
|
51260
51259
|
MACOS_CATALYST_REFUSAL_REASONS = {
|
|
@@ -101268,12 +101267,15 @@ function createNetworkManager(deps) {
|
|
|
101268
101267
|
const { cdp } = deps;
|
|
101269
101268
|
const order = [];
|
|
101270
101269
|
const byId = /* @__PURE__ */ new Map();
|
|
101270
|
+
let lastSeq = 0;
|
|
101271
|
+
let mark;
|
|
101271
101272
|
let conditions = null;
|
|
101272
101273
|
function record2(requestId) {
|
|
101273
101274
|
let rec = byId.get(requestId);
|
|
101274
101275
|
if (!rec) {
|
|
101275
101276
|
rec = { requestId, method: "", url: "", startedDateTime: "", startTs: 0 };
|
|
101276
101277
|
byId.set(requestId, rec);
|
|
101278
|
+
lastSeq++;
|
|
101277
101279
|
order.push(requestId);
|
|
101278
101280
|
if (order.length > MAX_RECORDS2) {
|
|
101279
101281
|
const evicted = order.shift();
|
|
@@ -101351,6 +101353,11 @@ function createNetworkManager(deps) {
|
|
|
101351
101353
|
return {
|
|
101352
101354
|
requests: () => order.map((id) => byId.get(id)).filter((r) => !!r),
|
|
101353
101355
|
get: (requestId) => byId.get(requestId),
|
|
101356
|
+
startCapture: () => mark = { lastSeq },
|
|
101357
|
+
stopCapture: () => {
|
|
101358
|
+
if (mark && mark.stoppedSeq === void 0) mark = { ...mark, stoppedSeq: lastSeq };
|
|
101359
|
+
return mark;
|
|
101360
|
+
},
|
|
101354
101361
|
reattach: async () => {
|
|
101355
101362
|
await cdp.send("Network.enable").catch(() => {
|
|
101356
101363
|
});
|
|
@@ -124668,16 +124675,16 @@ async function queryViewHierarchyFor(services, params, toolId, method, errorCode
|
|
|
124668
124675
|
// ../tool-server/src/tools/network/network-capture.ts
|
|
124669
124676
|
var captureSchema = external_exports.object({
|
|
124670
124677
|
udid: external_exports.string().describe(
|
|
124671
|
-
"
|
|
124678
|
+
"Target ID from list-devices: an iOS simulator UDID, an Android serial<flag:macos-apps>, a Mac app ID (macos-app-<bundle id>)</flag:macos-apps> or a Chromium ID (chromium-cdp-<port>)."
|
|
124672
124679
|
),
|
|
124673
124680
|
bundleId: external_exports.string().regex(BUNDLE_ID_PATTERN, BUNDLE_ID_MESSAGE).describe(
|
|
124674
|
-
"App bundle ID on iOS or package name on Android<flag:macos-apps
|
|
124681
|
+
"App bundle ID on iOS or package name on Android<flag:macos-apps>. On Mac apps, use the bundle ID from udid</flag:macos-apps>. On Chromium, udid selects the app. Use a valid placeholder such as argent.capture."
|
|
124675
124682
|
),
|
|
124676
124683
|
port: metroPortField.describe(
|
|
124677
|
-
"The app's Metro port
|
|
124684
|
+
"The app's Metro port. Omit it to use the device's port (8081 by default). Native layers exclude requests to this port on local addresses. Chromium uses the CDP port in udid."
|
|
124678
124685
|
),
|
|
124679
124686
|
layer: external_exports.enum(["js", "native"]).optional().describe(
|
|
124680
|
-
"
|
|
124687
|
+
"Use js for JavaScript runtime capture or native for native HTTP capture. Omit to control both layers. Chromium ignores this setting and uses its single chromium layer."
|
|
124681
124688
|
),
|
|
124682
124689
|
logicalDeviceId: external_exports.string().min(1).optional().describe(
|
|
124683
124690
|
"Only when several devices share the Metro port: this device's logicalDeviceId, which the JS layer's reason lists. The JS layer connects to that runtime, and view-network-logs then takes it as device_id. The native layer always uses udid."
|
|
@@ -124717,7 +124724,8 @@ var CAPTURE_CAPABILITY = {
|
|
|
124717
124724
|
apple: { simulator: true },
|
|
124718
124725
|
appleRemote: { simulator: true },
|
|
124719
124726
|
android: { emulator: true, device: true },
|
|
124720
|
-
macos: { app: true, catalyst: true }
|
|
124727
|
+
macos: { app: true, catalyst: true },
|
|
124728
|
+
chromium: { app: true }
|
|
124721
124729
|
};
|
|
124722
124730
|
var captureLocks = /* @__PURE__ */ new Map();
|
|
124723
124731
|
var captureSweeps = /* @__PURE__ */ new Set();
|
|
@@ -139742,7 +139750,8 @@ var JS_ANSWER_WAIT_MS = 5e3;
|
|
|
139742
139750
|
function createNetworkCaptureStartTool(registry2) {
|
|
139743
139751
|
return {
|
|
139744
139752
|
id: "network-capture-start",
|
|
139745
|
-
description: `Start network capture on iOS simulators and Android<flag:macos-apps> (also on Mac apps)</flag:macos-apps>. Use when you
|
|
139753
|
+
description: `Start network capture on iOS simulators and Android<flag:macos-apps> (also on Mac apps)</flag:macos-apps>. Use when you need to inspect requests from an upcoming action, including in an e2e test. A new start keeps existing requests. Capture can slow the app.
|
|
139754
|
+
On Chromium, Argent connects if needed and marks the start of a capture window in the network log. Recording continues while connected.
|
|
139746
139755
|
The JavaScript layer needs an app connected to Metro. Start again after its JavaScript loads, including after a reload or relaunch. Android native capture needs a debuggable build.<flag:macos-apps> For a supported React Native app launched from Xcode, use layer js and form udid as macos-app-<bundle id>. Native capture needs a supported build launched through Argent.</flag:macos-apps>
|
|
139747
139756
|
Returns { status, layers }: check armed and reason for each requested layer. A pending native layer can become ready when Argent launches or reconnects to the app. On a device whose devtools agent Argent attached to, start native capture again after a relaunch.
|
|
139748
139757
|
When every requested layer is unavailable, the call fails with NETWORK_CAPTURE_UNAVAILABLE or TOOL_DEPENDENCY_MISSING.`,
|
|
@@ -139770,6 +139779,15 @@ When every requested layer is unavailable, the call fails with NETWORK_CAPTURE_U
|
|
|
139770
139779
|
const device = resolveDevice(params.udid);
|
|
139771
139780
|
assertSupported("network-capture-start", CAPTURE_CAPABILITY, device);
|
|
139772
139781
|
const run2 = requestedLayers(params.layer);
|
|
139782
|
+
if (device.platform === "chromium") {
|
|
139783
|
+
const layer = await withCaptureLock(
|
|
139784
|
+
params.udid,
|
|
139785
|
+
params.bundleId,
|
|
139786
|
+
() => startChromiumLayer(registry2, device)
|
|
139787
|
+
);
|
|
139788
|
+
if (layer.unavailable) throw unavailableError(params, [layer]);
|
|
139789
|
+
return { status: "ok", layers: [layer] };
|
|
139790
|
+
}
|
|
139773
139791
|
const port = metroPort({ device_id: params.udid, port: params.port });
|
|
139774
139792
|
const layers = await withCaptureLock(params.udid, params.bundleId, async () => {
|
|
139775
139793
|
const app = device.platform === "macos" ? await macosAppOfCall(registry2, device, "network-capture-start", params.bundleId) : void 0;
|
|
@@ -139823,6 +139841,17 @@ async function startMacosLayer(app, device, bundleId) {
|
|
|
139823
139841
|
const { armed, reason: reason2 } = await app.startNetworkCapture();
|
|
139824
139842
|
return { layer: "macos-native", armed, ...reason2 ? { reason: reason2 } : {} };
|
|
139825
139843
|
}
|
|
139844
|
+
async function startChromiumLayer(registry2, device) {
|
|
139845
|
+
const ref = chromiumCdpRef(device);
|
|
139846
|
+
let api;
|
|
139847
|
+
try {
|
|
139848
|
+
api = await registry2.resolveService(ref.urn, ref.options);
|
|
139849
|
+
} catch (err) {
|
|
139850
|
+
return unavailable2("chromium", `argent cannot reach the app over CDP: ${errorMessage4(err)}`);
|
|
139851
|
+
}
|
|
139852
|
+
api.server.network.startCapture();
|
|
139853
|
+
return { layer: "chromium", armed: true };
|
|
139854
|
+
}
|
|
139826
139855
|
function unavailableError(params, layers) {
|
|
139827
139856
|
return new FailureError(
|
|
139828
139857
|
`Network capture cannot start for ${params.bundleId} on ${params.udid}: ` + layers.map((layer) => `${layer.layer}: ${layer.reason}`).join("; "),
|
|
@@ -140070,10 +140099,10 @@ var JS_ANSWER_WAIT_MS2 = 5e3;
|
|
|
140070
140099
|
function createNetworkCaptureStopTool(registry2) {
|
|
140071
140100
|
return {
|
|
140072
140101
|
id: "network-capture-stop",
|
|
140073
|
-
description: `Stop network capture
|
|
140074
|
-
|
|
140075
|
-
|
|
140076
|
-
Returns { status, layers }
|
|
140102
|
+
description: `Stop network capture and keep the recorded requests. Use when you have the requests you need, before profiling, or to end capture in an e2e test.
|
|
140103
|
+
On Chromium, mark the end of the capture window using the existing connection. view-network-logs still includes requests outside the window. If the reason says capture was not started, call network-capture-start before reproducing the request.
|
|
140104
|
+
On other supported targets, read the retained requests with native-network-logs or view-network-logs. Use view-network-request-details with an ID from the log. JS request IDs expire on reload. Capture stays off until network-capture-start, including after relaunch. In-flight requests can finish in the log. Stopping Android native capture marks them failed in the log without interrupting the app's requests. Only bodies read before that stop remain available.
|
|
140105
|
+
Returns { status, layers }. Check armed and reason to confirm the stop. If the stop fails to reach the JS runtime, retry once the app reconnects to Metro. total counts the retained requests, or is 0 when the stop cannot count them.`,
|
|
140077
140106
|
zodSchema: captureSchema,
|
|
140078
140107
|
capability: CAPTURE_CAPABILITY,
|
|
140079
140108
|
interaction: {
|
|
@@ -140091,6 +140120,14 @@ Returns { status, layers }: per layer the call stopped, armed (false once the la
|
|
|
140091
140120
|
assertSupported("network-capture-stop", CAPTURE_CAPABILITY, device);
|
|
140092
140121
|
const port = metroPort({ device_id: params.udid, port: params.port });
|
|
140093
140122
|
const run2 = requestedLayers(params.layer);
|
|
140123
|
+
if (device.platform === "chromium") {
|
|
140124
|
+
const layer = await withCaptureLock(
|
|
140125
|
+
params.udid,
|
|
140126
|
+
params.bundleId,
|
|
140127
|
+
() => stopChromiumLayer(registry2, device)
|
|
140128
|
+
);
|
|
140129
|
+
return { status: "ok", layers: [layer] };
|
|
140130
|
+
}
|
|
140094
140131
|
const layers = await withCaptureLock(params.udid, params.bundleId, async () => {
|
|
140095
140132
|
const app = device.platform === "macos" ? await macosAppOfCall(registry2, device, "network-capture-stop", params.bundleId) : void 0;
|
|
140096
140133
|
return runLayers([
|
|
@@ -140318,6 +140355,23 @@ async function stopMacosLayer(app, port) {
|
|
|
140318
140355
|
...reason2 ? { reason: reason2 } : {}
|
|
140319
140356
|
};
|
|
140320
140357
|
}
|
|
140358
|
+
async function stopChromiumLayer(registry2, device) {
|
|
140359
|
+
const ref = chromiumCdpRef(device);
|
|
140360
|
+
if (!isLiveService(registry2, ref.urn)) {
|
|
140361
|
+
return { layer: "chromium", armed: false, total: 0, reason: NOT_STARTED2 };
|
|
140362
|
+
}
|
|
140363
|
+
const api = await registry2.resolveService(ref.urn, ref.options);
|
|
140364
|
+
const network = api.server.network;
|
|
140365
|
+
if (!network.stopCapture()) {
|
|
140366
|
+
return { layer: "chromium", armed: false, total: 0, reason: NOT_STARTED2 };
|
|
140367
|
+
}
|
|
140368
|
+
return {
|
|
140369
|
+
layer: "chromium",
|
|
140370
|
+
armed: false,
|
|
140371
|
+
total: network.requests().length,
|
|
140372
|
+
reason: "view-network-logs keeps listing the tab's requests while argent is attached; the stop marks where the capture window ends"
|
|
140373
|
+
};
|
|
140374
|
+
}
|
|
140321
140375
|
async function stopAndroidLayer(registry2, device, bundleId, port) {
|
|
140322
140376
|
const ref = androidNetworkInspectorRef(device, bundleId, port);
|
|
140323
140377
|
if (!isLiveService(registry2, ref.urn)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swmansion/argent",
|
|
3
|
-
"version": "0.34.1-next.
|
|
3
|
+
"version": "0.34.1-next.81",
|
|
4
4
|
"mcpName": "io.github.software-mansion/argent",
|
|
5
5
|
"description": "MCP server for iOS Simulator, Android Emulator, Chromium app and Mac app control",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -98,5 +98,5 @@
|
|
|
98
98
|
"vitest": "^5.0.5",
|
|
99
99
|
"yaml": "^2.9.1"
|
|
100
100
|
},
|
|
101
|
-
"gitHead": "
|
|
101
|
+
"gitHead": "f08f0efe5a98c63bc47d4ba064c0af52432ff60d"
|
|
102
102
|
}
|
|
@@ -146,13 +146,13 @@ A warning does not reject the step. If `e2e-finish-recording` reports dropped wa
|
|
|
146
146
|
|
|
147
147
|
### Network capture
|
|
148
148
|
|
|
149
|
-
On iOS, Android, and Mac apps, record a capture start before
|
|
149
|
+
On iOS, Android, and Mac apps, record a capture start before reproducing the request. On Chromium, record `view-network-logs` before the action if you only need to inspect requests. Use start and stop steps when the test needs a capture window. The Chromium log includes requests outside that window.
|
|
150
150
|
|
|
151
|
-
1.
|
|
152
|
-
2.
|
|
153
|
-
3. If a read
|
|
151
|
+
1. Add `network-capture-start` through `e2e-add-step` after the launch and first-screen wait, if present, and before the action. A relaunch ends JS capture. A start before `launch:` makes the test a fragment.
|
|
152
|
+
2. Record a wait for the screen that shows the request result before adding `network-capture-stop`.
|
|
153
|
+
3. If a read reports that capture never started, record the start through `e2e-add-step`, then re-record the action and the read. Replay only runs the steps you recorded.
|
|
154
154
|
4. A `tool:` step keeps its recorded `bundleId` on every platform. Only `launch:` takes an id per platform. If the app id differs by platform, add a top-level `requires:` block with the recording platform (see [File shape and test type](e2e-yaml.md#file-shape-and-test-type)). Record a separate test for each other platform.
|
|
155
|
-
5.
|
|
155
|
+
5. After replay, check `armed` and `reason` for the layer the test uses in each step's `result`. A passed step can report an unarmed start or an unconfirmed stop. A Chromium stop reports `armed: false` even when `reason` says no capture window was started. Fix the reported problem and replay before relying on the capture.
|
|
156
156
|
|
|
157
157
|
### Wrong turns
|
|
158
158
|
|
|
@@ -36,7 +36,9 @@ On iOS, Android, and Mac apps, call `network-capture-start` before reproducing t
|
|
|
36
36
|
|
|
37
37
|
Use the device ID as `udid` for start and stop. If shared Metro requires a logical ID on iOS or Android, pass it as `logicalDeviceId` for start and stop, and as `device_id` when reading. Keep the Metro port consistent across calls.
|
|
38
38
|
|
|
39
|
-
On Vega, call `view-network-logs` before reproducing the request and again after a reload.
|
|
39
|
+
On Vega, call `view-network-logs` before reproducing the request and again after a reload.
|
|
40
|
+
|
|
41
|
+
On Chromium and Electron, call `view-network-logs` before reproducing the request so Argent connects to the page. Use `network-capture-start` and `network-capture-stop` to mark a capture window when needed. The log includes requests outside that window.
|
|
40
42
|
|
|
41
43
|
### React Native Mac apps
|
|
42
44
|
|