@swmansion/argent 0.35.1-next.77 → 0.35.1-next.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli-cmds.mjs +1 -1
- package/dist/installer.mjs +1 -1
- package/dist/mcp-server.mjs +1 -1
- package/dist/tool-server.cjs +234 -110
- package/package.json +2 -2
package/dist/cli-cmds.mjs
CHANGED
|
@@ -38906,7 +38906,7 @@ function isCi(env = process.env) {
|
|
|
38906
38906
|
var SESSION_ID2 = randomUUID5();
|
|
38907
38907
|
function readCliVersion() {
|
|
38908
38908
|
if (true) {
|
|
38909
|
-
return "0.35.1-next.
|
|
38909
|
+
return "0.35.1-next.78";
|
|
38910
38910
|
}
|
|
38911
38911
|
return "0.0.0";
|
|
38912
38912
|
}
|
package/dist/installer.mjs
CHANGED
|
@@ -17138,7 +17138,7 @@ function isCi(env = process.env) {
|
|
|
17138
17138
|
var SESSION_ID = randomUUID4();
|
|
17139
17139
|
function readCliVersion() {
|
|
17140
17140
|
if (true) {
|
|
17141
|
-
return "0.35.1-next.
|
|
17141
|
+
return "0.35.1-next.78";
|
|
17142
17142
|
}
|
|
17143
17143
|
return "0.0.0";
|
|
17144
17144
|
}
|
package/dist/mcp-server.mjs
CHANGED
|
@@ -38473,7 +38473,7 @@ async function startMcpServer(options) {
|
|
|
38473
38473
|
const autoDescribeOn = autoDescribeEnabled();
|
|
38474
38474
|
const whatsNewOn = whatsNewEnabled();
|
|
38475
38475
|
const installedVersion = getInstalledVersion();
|
|
38476
|
-
const highlightsVersion = true ? "0.35.1-next.
|
|
38476
|
+
const highlightsVersion = true ? "0.35.1-next.78" : installedVersion;
|
|
38477
38477
|
const captureTimeoutMs = options.captureTimeoutMs ?? CAPTURE_TIMEOUT_MS;
|
|
38478
38478
|
const trees = createTreeMemory();
|
|
38479
38479
|
const screenshots = createScreenshotMemory();
|
package/dist/tool-server.cjs
CHANGED
|
@@ -52134,13 +52134,18 @@ function findExternalDevice(id) {
|
|
|
52134
52134
|
if (!record2) return void 0;
|
|
52135
52135
|
return readProviderDevices2(record2).find((device) => device.nativeId === parsed2.nativeId);
|
|
52136
52136
|
}
|
|
52137
|
+
function sameNativeId(a, b) {
|
|
52138
|
+
return a === b || SIMULATOR_UDID.test(a) && a.toUpperCase() === b.toUpperCase();
|
|
52139
|
+
}
|
|
52137
52140
|
function externalClaimForNativeId(nativeId) {
|
|
52138
52141
|
const providers = discoverProviders();
|
|
52139
52142
|
if (providers.length === 0) return void 0;
|
|
52140
52143
|
if (isExternalId(nativeId)) return void 0;
|
|
52141
52144
|
for (const record2 of providers) {
|
|
52142
52145
|
if (record2.pid !== void 0 && !isProcessAlive(record2.pid)) continue;
|
|
52143
|
-
const device = readProviderDevices2(record2).find(
|
|
52146
|
+
const device = readProviderDevices2(record2).find(
|
|
52147
|
+
(device2) => sameNativeId(device2.nativeId, nativeId)
|
|
52148
|
+
);
|
|
52144
52149
|
if (device) return device;
|
|
52145
52150
|
}
|
|
52146
52151
|
return void 0;
|
|
@@ -52239,7 +52244,7 @@ function externalSupportHint(id) {
|
|
|
52239
52244
|
const where = record2.supportUrl ? ` Report issues at ${record2.supportUrl}.` : "";
|
|
52240
52245
|
return `This device is provided by ${record2.name}.${where}`;
|
|
52241
52246
|
}
|
|
52242
|
-
var ALLOWED_ENDPOINT_SET, PROBE_TIMEOUT_MS, lastSeenCapabilities, inFlightRevocations;
|
|
52247
|
+
var ALLOWED_ENDPOINT_SET, PROBE_TIMEOUT_MS, SIMULATOR_UDID, lastSeenCapabilities, inFlightRevocations;
|
|
52243
52248
|
var init_external_devices = __esm({
|
|
52244
52249
|
"../tool-server/src/utils/external-devices.ts"() {
|
|
52245
52250
|
"use strict";
|
|
@@ -52249,6 +52254,7 @@ var init_external_devices = __esm({
|
|
|
52249
52254
|
init_src3();
|
|
52250
52255
|
ALLOWED_ENDPOINT_SET = new Set(ALLOWED_SIM_SERVER_ENDPOINTS);
|
|
52251
52256
|
PROBE_TIMEOUT_MS = 800;
|
|
52257
|
+
SIMULATOR_UDID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
52252
52258
|
lastSeenCapabilities = /* @__PURE__ */ new Map();
|
|
52253
52259
|
inFlightRevocations = /* @__PURE__ */ new Map();
|
|
52254
52260
|
}
|
|
@@ -73359,7 +73365,7 @@ function isCi(env = process.env) {
|
|
|
73359
73365
|
var SESSION_ID = (0, import_node_crypto3.randomUUID)();
|
|
73360
73366
|
function readCliVersion() {
|
|
73361
73367
|
if (true) {
|
|
73362
|
-
return "0.35.1-next.
|
|
73368
|
+
return "0.35.1-next.78";
|
|
73363
73369
|
}
|
|
73364
73370
|
return "0.0.0";
|
|
73365
73371
|
}
|
|
@@ -81767,9 +81773,17 @@ async function scanIosSimulators() {
|
|
|
81767
81773
|
return { simulators: out, timedOut: perSet.some((set2) => set2.timedOut) };
|
|
81768
81774
|
}
|
|
81769
81775
|
var runtimeKindCache = /* @__PURE__ */ new Map();
|
|
81776
|
+
var runtimeKindLookups = /* @__PURE__ */ new Map();
|
|
81770
81777
|
async function getSimulatorRuntimeKind(udid) {
|
|
81771
81778
|
const cached3 = runtimeKindCache.get(udid);
|
|
81772
81779
|
if (cached3) return cached3;
|
|
81780
|
+
const inFlight5 = runtimeKindLookups.get(udid);
|
|
81781
|
+
if (inFlight5) return inFlight5;
|
|
81782
|
+
const lookup = lookUpRuntimeKind(udid).finally(() => runtimeKindLookups.delete(udid));
|
|
81783
|
+
runtimeKindLookups.set(udid, lookup);
|
|
81784
|
+
return lookup;
|
|
81785
|
+
}
|
|
81786
|
+
async function lookUpRuntimeKind(udid) {
|
|
81773
81787
|
const kind = (await findIosSimulator(udid))?.runtimeKind;
|
|
81774
81788
|
if (kind) runtimeKindCache.set(udid, kind);
|
|
81775
81789
|
return kind;
|
|
@@ -101582,6 +101596,7 @@ init_external_devices();
|
|
|
101582
101596
|
|
|
101583
101597
|
// ../tool-server/src/utils/simulator-watcher.ts
|
|
101584
101598
|
var fs29 = __toESM(require("node:fs"));
|
|
101599
|
+
init_src2();
|
|
101585
101600
|
|
|
101586
101601
|
// ../tool-server/src/blueprints/native-devtools.ts
|
|
101587
101602
|
var net3 = __toESM(require("node:net"));
|
|
@@ -102279,14 +102294,34 @@ async function ensureAccessibilityEnabled(udid) {
|
|
|
102279
102294
|
);
|
|
102280
102295
|
}
|
|
102281
102296
|
async function setupNativeDevtoolsEnvLocal(udid, endpoint) {
|
|
102282
|
-
const tvOs = await isTvOsSimulator(udid);
|
|
102283
|
-
const bootstrapPath = await bootstrapPathFor(udid, endpoint);
|
|
102284
102297
|
const { nativeId, prefix } = await simctlTargetForUdid(udid, { granted: "native-devtools" });
|
|
102285
|
-
const
|
|
102286
|
-
"
|
|
102287
|
-
|
|
102288
|
-
|
|
102289
|
-
|
|
102298
|
+
const launchctl = (args) => execFileAsync14("xcrun", [...prefix, "spawn", nativeId, "launchctl", ...args], {
|
|
102299
|
+
encoding: "utf8",
|
|
102300
|
+
timeout: SIMCTL_SPAWN_TIMEOUT_MS,
|
|
102301
|
+
killSignal: SIMCTL_KILL_SIGNAL
|
|
102302
|
+
});
|
|
102303
|
+
await settleAllOrThrow([
|
|
102304
|
+
insertInjectionDylibs(udid, endpoint, nativeId, launchctl),
|
|
102305
|
+
setEndpointEnv(endpoint, launchctl),
|
|
102306
|
+
ensureAccessibilityEnabled(udid)
|
|
102307
|
+
]);
|
|
102308
|
+
}
|
|
102309
|
+
async function settleAllOrThrow(steps) {
|
|
102310
|
+
const results = await Promise.allSettled(steps);
|
|
102311
|
+
const failure3 = results.find((r) => r.status === "rejected");
|
|
102312
|
+
if (failure3) throw failure3.reason;
|
|
102313
|
+
}
|
|
102314
|
+
async function insertInjectionDylibs(udid, endpoint, nativeId, launchctl) {
|
|
102315
|
+
const [tvOs, bootstrapPath, result] = await Promise.all([
|
|
102316
|
+
isTvOsSimulator(udid),
|
|
102317
|
+
bootstrapPathFor(udid, endpoint),
|
|
102318
|
+
// Read launchctl inside the simulator rather than `simctl getenv`: the latter
|
|
102319
|
+
// silently truncates past 127 bytes, corrupting the colon-separated path list
|
|
102320
|
+
// and accumulating stale entries on every pass.
|
|
102321
|
+
launchctl(["getenv", "DYLD_INSERT_LIBRARIES"]).catch((e) => ({
|
|
102322
|
+
stdout: e.stdout ?? ""
|
|
102323
|
+
}))
|
|
102324
|
+
]);
|
|
102290
102325
|
const existing = (result.stdout ?? "").trim();
|
|
102291
102326
|
if (!tvOs && endpoint.transport === "unix") {
|
|
102292
102327
|
await clearAudioLeftovers(audioDir(nativeId)).catch(() => {
|
|
@@ -102295,67 +102330,30 @@ async function setupNativeDevtoolsEnvLocal(udid, endpoint) {
|
|
|
102295
102330
|
let updated = buildDyldInsertLibraries(existing, bootstrapPath);
|
|
102296
102331
|
const audioDylib = !tvOs && endpoint.transport === "unix" && audioAlwaysInserted() ? installedAudioDylib() : null;
|
|
102297
102332
|
if (audioDylib) updated = appendDyldInsertLibrary(updated, audioDylib);
|
|
102298
|
-
|
|
102299
|
-
|
|
102300
|
-
|
|
102301
|
-
|
|
102302
|
-
|
|
102303
|
-
|
|
102333
|
+
await Promise.all([
|
|
102334
|
+
updated !== existing ? launchctl(["setenv", "DYLD_INSERT_LIBRARIES", updated]) : void 0,
|
|
102335
|
+
audioDylib ? setAudioDirEnv(nativeId, launchctl) : void 0
|
|
102336
|
+
]);
|
|
102337
|
+
}
|
|
102338
|
+
function setEndpointEnv(endpoint, launchctl) {
|
|
102339
|
+
if (endpoint.transport === "unix") {
|
|
102340
|
+
return launchctl(["setenv", "NATIVE_DEVTOOLS_IOS_CDP_SOCKET", endpoint.socketPath]);
|
|
102304
102341
|
}
|
|
102305
|
-
if (endpoint.
|
|
102306
|
-
|
|
102307
|
-
|
|
102308
|
-
}
|
|
102309
|
-
await execFileAsync14(
|
|
102310
|
-
"xcrun",
|
|
102311
|
-
[
|
|
102312
|
-
...prefix,
|
|
102313
|
-
"spawn",
|
|
102314
|
-
nativeId,
|
|
102315
|
-
"launchctl",
|
|
102316
|
-
"setenv",
|
|
102317
|
-
"NATIVE_DEVTOOLS_IOS_CDP_PORT",
|
|
102318
|
-
String(endpoint.port)
|
|
102319
|
-
],
|
|
102320
|
-
{ timeout: SIMCTL_SPAWN_TIMEOUT_MS, killSignal: SIMCTL_KILL_SIGNAL }
|
|
102321
|
-
);
|
|
102322
|
-
} else {
|
|
102323
|
-
await execFileAsync14(
|
|
102324
|
-
"xcrun",
|
|
102325
|
-
[
|
|
102326
|
-
...prefix,
|
|
102327
|
-
"spawn",
|
|
102328
|
-
nativeId,
|
|
102329
|
-
"launchctl",
|
|
102330
|
-
"setenv",
|
|
102331
|
-
"NATIVE_DEVTOOLS_IOS_CDP_SOCKET",
|
|
102332
|
-
endpoint.socketPath
|
|
102333
|
-
],
|
|
102334
|
-
{ timeout: SIMCTL_SPAWN_TIMEOUT_MS, killSignal: SIMCTL_KILL_SIGNAL }
|
|
102342
|
+
if (endpoint.port === void 0) {
|
|
102343
|
+
return Promise.reject(
|
|
102344
|
+
new Error("native-devtools TCP endpoint reached host setup before its port was bound")
|
|
102335
102345
|
);
|
|
102336
102346
|
}
|
|
102337
|
-
|
|
102338
|
-
|
|
102339
|
-
|
|
102340
|
-
|
|
102341
|
-
|
|
102342
|
-
|
|
102343
|
-
|
|
102344
|
-
|
|
102345
|
-
nativeId,
|
|
102346
|
-
"launchctl",
|
|
102347
|
-
"setenv",
|
|
102348
|
-
"ARGENT_AUDIO_DIR",
|
|
102349
|
-
audioDir(nativeId)
|
|
102350
|
-
],
|
|
102351
|
-
{ timeout: SIMCTL_SPAWN_TIMEOUT_MS, killSignal: SIMCTL_KILL_SIGNAL }
|
|
102352
|
-
);
|
|
102353
|
-
} catch (err) {
|
|
102354
|
-
process.stderr.write(`[ios-host] audio setup failed for ${nativeId}: ${String(err)}
|
|
102347
|
+
return launchctl(["setenv", "NATIVE_DEVTOOLS_IOS_CDP_PORT", String(endpoint.port)]);
|
|
102348
|
+
}
|
|
102349
|
+
async function setAudioDirEnv(nativeId, launchctl) {
|
|
102350
|
+
try {
|
|
102351
|
+
fs27.mkdirSync(audioDir(nativeId), { recursive: true, mode: 448 });
|
|
102352
|
+
await launchctl(["setenv", "ARGENT_AUDIO_DIR", audioDir(nativeId)]);
|
|
102353
|
+
} catch (err) {
|
|
102354
|
+
process.stderr.write(`[ios-host] audio setup failed for ${nativeId}: ${String(err)}
|
|
102355
102355
|
`);
|
|
102356
|
-
}
|
|
102357
102356
|
}
|
|
102358
|
-
await ensureAccessibilityEnabled(udid);
|
|
102359
102357
|
}
|
|
102360
102358
|
async function bootstrapPathFor(udid, endpoint) {
|
|
102361
102359
|
if (await isTvOsSimulator(udid)) return bootstrapDylibPathTvos();
|
|
@@ -103093,6 +103091,16 @@ function nonInjectableError(bundleId) {
|
|
|
103093
103091
|
}
|
|
103094
103092
|
);
|
|
103095
103093
|
}
|
|
103094
|
+
var CONNECT_PENDING_WAIT_MS = 4e3;
|
|
103095
|
+
var CONNECT_PENDING_POLL_MS = 100;
|
|
103096
|
+
async function waitForAppConnection(api, bundleId) {
|
|
103097
|
+
const deadline = Date.now() + CONNECT_PENDING_WAIT_MS;
|
|
103098
|
+
while (!api.isConnected(bundleId)) {
|
|
103099
|
+
if (Date.now() >= deadline) return false;
|
|
103100
|
+
await new Promise((resolve24) => setTimeout(resolve24, CONNECT_PENDING_POLL_MS));
|
|
103101
|
+
}
|
|
103102
|
+
return true;
|
|
103103
|
+
}
|
|
103096
103104
|
async function precheckNativeDevtools(api, udid, bundleId) {
|
|
103097
103105
|
if (bundleId !== void 0 && !isInjectableBundleId(bundleId)) {
|
|
103098
103106
|
throw nonInjectableError(bundleId);
|
|
@@ -103127,6 +103135,7 @@ async function precheckNativeDevtools(api, udid, bundleId) {
|
|
|
103127
103135
|
if (typeof state3 !== "string") return state3;
|
|
103128
103136
|
if (state3 === "connected") return null;
|
|
103129
103137
|
if (state3 === "provider_attached") return null;
|
|
103138
|
+
if (state3 === "connecting" && await waitForAppConnection(api, bundleId)) return null;
|
|
103130
103139
|
return {
|
|
103131
103140
|
// Neither `unregistered` (a relaunch provably cannot fix it) nor
|
|
103132
103141
|
// `connecting` (a relaunch aborts the handshake and resets the age the
|
|
@@ -103153,6 +103162,9 @@ var LENT_HANDSHAKE_PROMPT_MS = 1e3;
|
|
|
103153
103162
|
var WAITING_FOR_ENABLE = "waiting for the agent to acknowledge Network.enable";
|
|
103154
103163
|
var WAITING_FOR_CAPTURE_STATE = "waiting for the agent to say whether capture is on";
|
|
103155
103164
|
var PROVIDER_CAPTURE_OFF = "the device provider has capture off for the app; argent does not turn it on, because that resets the provider's network settings: turn capture on in the provider";
|
|
103165
|
+
function simulatorNotBooted(message) {
|
|
103166
|
+
return /device is not booted|current state:\s*(shutdown|booting)/i.test(message);
|
|
103167
|
+
}
|
|
103156
103168
|
function closedBeforeRequest(bundleId, method) {
|
|
103157
103169
|
return new FailureError(
|
|
103158
103170
|
`native-devtools ${bundleId}: the connection closed before ${method} was answered`,
|
|
@@ -103286,7 +103298,8 @@ var nativeDevtoolsBlueprint = {
|
|
|
103286
103298
|
const noteInitFailure = (err) => {
|
|
103287
103299
|
if (err instanceof XcodeFirstLaunchPendingError) return;
|
|
103288
103300
|
const lastError = err instanceof Error ? err.message : String(err);
|
|
103289
|
-
const
|
|
103301
|
+
const counted = initFailure && !simulatorNotBooted(initFailure.lastError) ? initFailure.attempts : 0;
|
|
103302
|
+
const attempts = simulatorNotBooted(lastError) ? 1 : counted + 1;
|
|
103290
103303
|
const givenUp = attempts >= MAX_NATIVE_DEVTOOLS_INIT_ATTEMPTS;
|
|
103291
103304
|
initFailure = { attempts, lastError, givenUp };
|
|
103292
103305
|
if (givenUp) initRetryAt = performance.now() + NATIVE_DEVTOOLS_INIT_RETRY_COOLDOWN_MS;
|
|
@@ -104229,10 +104242,16 @@ function execSimctl(args, options = {}) {
|
|
|
104229
104242
|
// ../tool-server/src/utils/simulator-watcher.ts
|
|
104230
104243
|
var POLL_INTERVAL_MS = 1e4;
|
|
104231
104244
|
var MAX_BACKOFF_TICKS = 29;
|
|
104232
|
-
var
|
|
104233
|
-
var
|
|
104234
|
-
|
|
104235
|
-
|
|
104245
|
+
var ARM_WAIT_MS = 15e3;
|
|
104246
|
+
var NATIVE_DEVTOOLS_URN_PREFIX = `${NATIVE_DEVTOOLS_NAMESPACE}:`;
|
|
104247
|
+
var armTarget = () => Promise.resolve();
|
|
104248
|
+
var forgetTarget = () => {
|
|
104249
|
+
};
|
|
104250
|
+
function armSimulator(udid) {
|
|
104251
|
+
return armTarget(udid);
|
|
104252
|
+
}
|
|
104253
|
+
function forgetSimulatorTarget(urn) {
|
|
104254
|
+
forgetTarget(urn);
|
|
104236
104255
|
}
|
|
104237
104256
|
async function getBootedUdidsInSet(deviceSet, signal) {
|
|
104238
104257
|
const stdout = await execSimctl([...simctlPrefix(deviceSet), "list", "devices", "--json"], {
|
|
@@ -104263,27 +104282,66 @@ async function getBootedUdids(signal) {
|
|
|
104263
104282
|
return new Set(perSet.flatMap((r) => r.status === "fulfilled" ? [...r.value] : []));
|
|
104264
104283
|
}
|
|
104265
104284
|
async function initUdid(registry2, udid, trackedServices) {
|
|
104266
|
-
const
|
|
104285
|
+
const started = await runningNativeDevtools(registry2, udid);
|
|
104286
|
+
const service = started ?? await resolveNativeDevtools(registry2, udid);
|
|
104287
|
+
if (!service) return;
|
|
104288
|
+
trackedServices.set(udid, service);
|
|
104289
|
+
await started?.reverifyEnv().catch(() => {
|
|
104290
|
+
});
|
|
104291
|
+
}
|
|
104292
|
+
function simulatorNativeDevtoolsRef(udid) {
|
|
104293
|
+
return nativeDevtoolsRef({ id: udid, platform: "ios", kind: "simulator" });
|
|
104294
|
+
}
|
|
104295
|
+
async function resolveNativeDevtools(registry2, udid) {
|
|
104296
|
+
const ndRef = simulatorNativeDevtoolsRef(udid);
|
|
104267
104297
|
try {
|
|
104268
|
-
|
|
104269
|
-
trackedServices.set(udid, service);
|
|
104298
|
+
return await registry2.resolveService(ndRef.urn, ndRef.options);
|
|
104270
104299
|
} catch {
|
|
104300
|
+
return null;
|
|
104301
|
+
}
|
|
104302
|
+
}
|
|
104303
|
+
async function armNow(registry2, udid) {
|
|
104304
|
+
if (externalClaimForAnyId(udid)) return;
|
|
104305
|
+
const running = await runningNativeDevtools(registry2, udid);
|
|
104306
|
+
if (running) {
|
|
104307
|
+
await running.ensureEnvReady().catch(() => {
|
|
104308
|
+
});
|
|
104309
|
+
return;
|
|
104310
|
+
}
|
|
104311
|
+
await resolveNativeDevtools(registry2, udid);
|
|
104312
|
+
}
|
|
104313
|
+
async function runningNativeDevtools(registry2, udid) {
|
|
104314
|
+
const urn = simulatorNativeDevtoolsRef(udid).urn;
|
|
104315
|
+
try {
|
|
104316
|
+
if (registry2.getServiceState(urn) !== "RUNNING" /* RUNNING */) return null;
|
|
104317
|
+
} catch {
|
|
104318
|
+
return null;
|
|
104319
|
+
}
|
|
104320
|
+
return resolveNativeDevtools(registry2, udid);
|
|
104321
|
+
}
|
|
104322
|
+
async function armWithinCap(registry2, udid) {
|
|
104323
|
+
let timer;
|
|
104324
|
+
const cap2 = new Promise((resolve24) => {
|
|
104325
|
+
timer = setTimeout(resolve24, ARM_WAIT_MS);
|
|
104326
|
+
timer.unref();
|
|
104327
|
+
});
|
|
104328
|
+
try {
|
|
104329
|
+
await Promise.race([armNow(registry2, udid), cap2]);
|
|
104330
|
+
} finally {
|
|
104331
|
+
clearTimeout(timer);
|
|
104271
104332
|
}
|
|
104272
104333
|
}
|
|
104273
104334
|
function startSimulatorWatcher(registry2) {
|
|
104274
104335
|
const configuredUdids = process.env.ARGENT_SIMULATOR_WATCH_UDIDS;
|
|
104275
104336
|
const allowedUdids = configuredUdids === void 0 ? void 0 : new Set(configuredUdids.split(",").map((id) => id.trim().toUpperCase()));
|
|
104337
|
+
const isWatched = (udid) => !allowedUdids || allowedUdids.has(udid.toUpperCase());
|
|
104276
104338
|
const trackedServices = /* @__PURE__ */ new Map();
|
|
104339
|
+
const targetedUdids = /* @__PURE__ */ new Map();
|
|
104340
|
+
const watcherDisposals = /* @__PURE__ */ new Set();
|
|
104277
104341
|
const reportedSkips = /* @__PURE__ */ new Set();
|
|
104278
104342
|
const stopController = new AbortController();
|
|
104279
104343
|
let consecutiveTimeouts = 0;
|
|
104280
104344
|
let ticksToSkip = 0;
|
|
104281
|
-
let markArmed;
|
|
104282
|
-
const armed = new Promise((resolve24) => markArmed = resolve24);
|
|
104283
|
-
firstPollSettled = Promise.race([
|
|
104284
|
-
armed,
|
|
104285
|
-
new Promise((resolve24) => setTimeout(resolve24, FIRST_POLL_WAIT_MS).unref())
|
|
104286
|
-
]);
|
|
104287
104345
|
let firstLaunchReported = false;
|
|
104288
104346
|
function simctlWouldStartInstall() {
|
|
104289
104347
|
if (!xcodeFirstLaunchPending("simctl")) {
|
|
@@ -104292,7 +104350,6 @@ function startSimulatorWatcher(registry2) {
|
|
|
104292
104350
|
}
|
|
104293
104351
|
consecutiveTimeouts = 0;
|
|
104294
104352
|
ticksToSkip = 0;
|
|
104295
|
-
markArmed();
|
|
104296
104353
|
if (!firstLaunchReported) {
|
|
104297
104354
|
firstLaunchReported = true;
|
|
104298
104355
|
process.stderr.write(
|
|
@@ -104306,7 +104363,7 @@ function startSimulatorWatcher(registry2) {
|
|
|
104306
104363
|
const ours = /* @__PURE__ */ new Set();
|
|
104307
104364
|
const claimed = /* @__PURE__ */ new Set();
|
|
104308
104365
|
for (const udid of booted) {
|
|
104309
|
-
if (
|
|
104366
|
+
if (!isWatched(udid)) continue;
|
|
104310
104367
|
const claim2 = externalClaimForNativeId(udid);
|
|
104311
104368
|
if (!claim2) {
|
|
104312
104369
|
reportedSkips.delete(udid);
|
|
@@ -104334,7 +104391,7 @@ function startSimulatorWatcher(registry2) {
|
|
|
104334
104391
|
}
|
|
104335
104392
|
async function handBackClaimed(claimed) {
|
|
104336
104393
|
for (const udid of claimed) {
|
|
104337
|
-
const service = trackedServices.get(udid);
|
|
104394
|
+
const service = trackedServices.get(udid) ?? await runningNativeDevtools(registry2, udid);
|
|
104338
104395
|
if (!service?.armsEnv) continue;
|
|
104339
104396
|
trackedServices.delete(udid);
|
|
104340
104397
|
await service.withdrawEnv().catch((err) => {
|
|
@@ -104343,8 +104400,30 @@ function startSimulatorWatcher(registry2) {
|
|
|
104343
104400
|
`
|
|
104344
104401
|
);
|
|
104345
104402
|
});
|
|
104346
|
-
await
|
|
104347
|
-
|
|
104403
|
+
await disposeAsWatcher(udid);
|
|
104404
|
+
}
|
|
104405
|
+
}
|
|
104406
|
+
async function disposeAsWatcher(udid) {
|
|
104407
|
+
watcherDisposals.add(udid);
|
|
104408
|
+
try {
|
|
104409
|
+
await registry2.disposeService(simulatorNativeDevtoolsRef(udid).urn);
|
|
104410
|
+
} catch {
|
|
104411
|
+
} finally {
|
|
104412
|
+
watcherDisposals.delete(udid);
|
|
104413
|
+
}
|
|
104414
|
+
}
|
|
104415
|
+
function onlyTargeted(booted) {
|
|
104416
|
+
return new Set([...booted].flatMap((udid) => targetedUdids.get(udid.toUpperCase()) ?? []));
|
|
104417
|
+
}
|
|
104418
|
+
function noteTargeted(urn, _from, to) {
|
|
104419
|
+
if (!urn.startsWith(NATIVE_DEVTOOLS_URN_PREFIX)) return;
|
|
104420
|
+
const udid = urn.slice(NATIVE_DEVTOOLS_URN_PREFIX.length);
|
|
104421
|
+
const key2 = udid.toUpperCase();
|
|
104422
|
+
if (to === "RUNNING" /* RUNNING */) {
|
|
104423
|
+
if (!targetedUdids.has(key2)) targetedUdids.set(key2, udid);
|
|
104424
|
+
} else if (to === "IDLE" /* IDLE */ && !watcherDisposals.has(udid)) {
|
|
104425
|
+
if (targetedUdids.get(key2) === udid) targetedUdids.delete(key2);
|
|
104426
|
+
trackedServices.delete(udid);
|
|
104348
104427
|
}
|
|
104349
104428
|
}
|
|
104350
104429
|
async function poll(shouldBlockUntilSettled) {
|
|
@@ -104352,7 +104431,7 @@ function startSimulatorWatcher(registry2) {
|
|
|
104352
104431
|
let claimed;
|
|
104353
104432
|
try {
|
|
104354
104433
|
({ ours: booted, claimed } = withoutForeignSimulators(
|
|
104355
|
-
await getBootedUdids(stopController.signal)
|
|
104434
|
+
onlyTargeted(await getBootedUdids(stopController.signal))
|
|
104356
104435
|
));
|
|
104357
104436
|
} catch (err) {
|
|
104358
104437
|
if (err instanceof SimctlTimeoutError) {
|
|
@@ -104369,7 +104448,9 @@ function startSimulatorWatcher(registry2) {
|
|
|
104369
104448
|
}
|
|
104370
104449
|
consecutiveTimeouts = 0;
|
|
104371
104450
|
await handBackClaimed(claimed);
|
|
104372
|
-
const newUdids = [...booted].filter(
|
|
104451
|
+
const newUdids = [...booted].filter(
|
|
104452
|
+
(udid) => targetedUdids.has(udid.toUpperCase()) && !trackedServices.has(udid)
|
|
104453
|
+
);
|
|
104373
104454
|
const pendingAttempts = newUdids.map(
|
|
104374
104455
|
(udid) => initUdid(registry2, udid, trackedServices)
|
|
104375
104456
|
);
|
|
@@ -104380,15 +104461,32 @@ function startSimulatorWatcher(registry2) {
|
|
|
104380
104461
|
}));
|
|
104381
104462
|
}
|
|
104382
104463
|
}
|
|
104383
|
-
|
|
104384
|
-
if (shouldBlockUntilSettled) await attempted;
|
|
104464
|
+
if (shouldBlockUntilSettled) await Promise.all(pendingAttempts);
|
|
104385
104465
|
for (const udid of [...trackedServices.keys()]) {
|
|
104386
104466
|
if (booted.has(udid)) continue;
|
|
104387
104467
|
trackedServices.delete(udid);
|
|
104388
|
-
|
|
104389
|
-
});
|
|
104468
|
+
void disposeAsWatcher(udid);
|
|
104390
104469
|
}
|
|
104391
104470
|
}
|
|
104471
|
+
registry2.events.on("serviceStateChange", noteTargeted);
|
|
104472
|
+
const armsInFlight = /* @__PURE__ */ new Map();
|
|
104473
|
+
const armThisWatcher = (udid) => {
|
|
104474
|
+
if (!isWatched(udid)) return Promise.resolve();
|
|
104475
|
+
const key2 = udid.toUpperCase();
|
|
104476
|
+
const existing = armsInFlight.get(key2);
|
|
104477
|
+
if (existing) return existing;
|
|
104478
|
+
const spelling = targetedUdids.get(key2) ?? udid;
|
|
104479
|
+
const arming = armWithinCap(registry2, spelling).finally(() => armsInFlight.delete(key2));
|
|
104480
|
+
armsInFlight.set(key2, arming);
|
|
104481
|
+
return arming;
|
|
104482
|
+
};
|
|
104483
|
+
armTarget = armThisWatcher;
|
|
104484
|
+
const forgetThisWatcher = (urn) => {
|
|
104485
|
+
for (const [key2, udid] of targetedUdids) {
|
|
104486
|
+
if (simulatorNativeDevtoolsRef(udid).urn === urn) targetedUdids.delete(key2);
|
|
104487
|
+
}
|
|
104488
|
+
};
|
|
104489
|
+
forgetTarget = forgetThisWatcher;
|
|
104392
104490
|
const ready2 = simctlWouldStartInstall() ? Promise.resolve() : poll(true);
|
|
104393
104491
|
let inFlight5 = ready2.catch(() => {
|
|
104394
104492
|
}).finally(() => inFlight5 = null);
|
|
@@ -104404,6 +104502,10 @@ function startSimulatorWatcher(registry2) {
|
|
|
104404
104502
|
}, POLL_INTERVAL_MS);
|
|
104405
104503
|
return {
|
|
104406
104504
|
stop: () => {
|
|
104505
|
+
registry2.events.off("serviceStateChange", noteTargeted);
|
|
104506
|
+
if (armTarget === armThisWatcher) armTarget = () => Promise.resolve();
|
|
104507
|
+
if (forgetTarget === forgetThisWatcher) forgetTarget = () => {
|
|
104508
|
+
};
|
|
104407
104509
|
clearInterval(interval2);
|
|
104408
104510
|
stopController.abort();
|
|
104409
104511
|
},
|
|
@@ -104515,8 +104617,12 @@ var STDERR_DRAIN_MS = 250;
|
|
|
104515
104617
|
var STDERR_TAIL_LINES = 10;
|
|
104516
104618
|
var STDERR_MAX_LINE_CHARS = 500;
|
|
104517
104619
|
var ROUTINE_LOG_LINE = /^\[\S+\s+(?:INFO|DEBUG|TRACE)\s/;
|
|
104620
|
+
function describeExit(code, signal) {
|
|
104621
|
+
if (typeof code === "number") return `exited with code ${code}`;
|
|
104622
|
+
return signal ? `was killed by ${signal}` : "exited";
|
|
104623
|
+
}
|
|
104518
104624
|
function exitedBeforeReadyMessage(code, signal, stderrTail) {
|
|
104519
|
-
const how =
|
|
104625
|
+
const how = describeExit(code, signal);
|
|
104520
104626
|
const reason2 = stderrTail.join("\n");
|
|
104521
104627
|
return `simulator-server ${how} before becoming ready${reason2 ? `:
|
|
104522
104628
|
${reason2}` : ""}`;
|
|
@@ -104873,6 +104979,7 @@ var simulatorServerBlueprint = {
|
|
|
104873
104979
|
if (device.platform === "ios-remote") {
|
|
104874
104980
|
return withHeldTouchTeardown(device.id, await buildRemoteInstance(device));
|
|
104875
104981
|
}
|
|
104982
|
+
let arming = Promise.resolve();
|
|
104876
104983
|
if (device.platform === "ios") {
|
|
104877
104984
|
if (await isTvOsSimulator(device.id)) {
|
|
104878
104985
|
throw new UnsupportedOperationError(
|
|
@@ -104881,7 +104988,8 @@ var simulatorServerBlueprint = {
|
|
|
104881
104988
|
"this is an Apple TV (tvOS) simulator \u2014 touch, paste and rotate input are not available. Use `describe` to read focus, `tv-remote` for remote presses, and `keyboard` to type (see the argent-tv-interact skill)"
|
|
104882
104989
|
);
|
|
104883
104990
|
}
|
|
104884
|
-
|
|
104991
|
+
arming = armSimulator(device.id);
|
|
104992
|
+
await clearAutomationEnabledOrWarn(device.id);
|
|
104885
104993
|
} else if (device.platform === "android") {
|
|
104886
104994
|
await ensureDep("adb");
|
|
104887
104995
|
} else {
|
|
@@ -104891,10 +104999,14 @@ var simulatorServerBlueprint = {
|
|
|
104891
104999
|
}
|
|
104892
105000
|
const { proc, apiUrl, streamUrl, agentSocket } = await spawnWithEmulatorFallback(device);
|
|
104893
105001
|
const events = new TypedEventEmitter();
|
|
104894
|
-
|
|
104895
|
-
|
|
104896
|
-
|
|
104897
|
-
|
|
105002
|
+
let exited;
|
|
105003
|
+
const terminate = (error63) => {
|
|
105004
|
+
exited = error63;
|
|
105005
|
+
events.emit("terminated", error63);
|
|
105006
|
+
};
|
|
105007
|
+
proc.on("exit", (code, signal) => {
|
|
105008
|
+
terminate(
|
|
105009
|
+
new FailureError(`simulator-server ${describeExit(code, signal)}`, {
|
|
104898
105010
|
error_code: FAILURE_CODES.SIMULATOR_SERVER_TERMINATED,
|
|
104899
105011
|
failure_stage: "simulator_server_process_exit",
|
|
104900
105012
|
failure_area: "tool_server",
|
|
@@ -104902,9 +105014,9 @@ var simulatorServerBlueprint = {
|
|
|
104902
105014
|
})
|
|
104903
105015
|
);
|
|
104904
105016
|
});
|
|
104905
|
-
proc.on("error",
|
|
104906
|
-
|
|
104907
|
-
|
|
105017
|
+
proc.on("error", terminate);
|
|
105018
|
+
await arming;
|
|
105019
|
+
if (exited) throw exited;
|
|
104908
105020
|
const api = {
|
|
104909
105021
|
apiUrl,
|
|
104910
105022
|
streamUrl,
|
|
@@ -116913,7 +117025,7 @@ var tvControlBlueprint = {
|
|
|
116913
117025
|
const axSock = axSocketPath(udid);
|
|
116914
117026
|
const hidSock = hidSocketPath(udid);
|
|
116915
117027
|
let disposed = false;
|
|
116916
|
-
await Promise.all([ensureAutomationEnabled(udid),
|
|
117028
|
+
await Promise.all([ensureAutomationEnabled(udid), armSimulator(udid)]);
|
|
116917
117029
|
await Promise.all([reapDaemons(axSock), reapDaemons(hidSock)]);
|
|
116918
117030
|
const axTarget = () => simctlTargetForUdidSync(udid, { granted: "ax-service" });
|
|
116919
117031
|
let axProc = spawnAxDaemon(udid, axSock, axTarget());
|
|
@@ -129309,7 +129421,7 @@ var DEVICE_PORT_SPAN = 1e4;
|
|
|
129309
129421
|
var DEVICE_PORT_ATTEMPTS = 8;
|
|
129310
129422
|
var NEW_PROCESS_WAIT_MS = 3e3;
|
|
129311
129423
|
var PROCESS_POLL_INTERVAL_MS = 250;
|
|
129312
|
-
var
|
|
129424
|
+
var ARM_WAIT_MS2 = 5e3;
|
|
129313
129425
|
var ARM_PROCESS_CHECK_MS = 500;
|
|
129314
129426
|
var RECHECK_DELAYS_MS = [500, 1e3, 2e3, 4e3, 8e3];
|
|
129315
129427
|
var ENABLE_TIMEOUT_MS = 6e4;
|
|
@@ -130575,7 +130687,7 @@ function createInspector(serial, packageName, initialMetroPort) {
|
|
|
130575
130687
|
};
|
|
130576
130688
|
}
|
|
130577
130689
|
const key2 = processKey(attached.current);
|
|
130578
|
-
await waitForArmed(key2,
|
|
130690
|
+
await waitForArmed(key2, ARM_WAIT_MS2);
|
|
130579
130691
|
if (disposed) return { armed: false, reason: "capture was disposed" };
|
|
130580
130692
|
if (stopped) return { armed: false, reason: STOPPED_NOTE };
|
|
130581
130693
|
const conn = connections3.find((c) => c.armed && !c.closed && c.processKey === key2);
|
|
@@ -130666,7 +130778,7 @@ function createInspector(serial, packageName, initialMetroPort) {
|
|
|
130666
130778
|
if (err instanceof InspectorStopped) return stoppedLaunchNote(packageName);
|
|
130667
130779
|
return `native network capture could not follow this launch of ${packageName}: ${firstLine3(isOwnFailure(err) ? errorMessage3(err) : adbFailureDetail(err))}`;
|
|
130668
130780
|
}
|
|
130669
|
-
if (outcome.kind === "attached") await waitForArmed(processKey(outcome.proc),
|
|
130781
|
+
if (outcome.kind === "attached") await waitForArmed(processKey(outcome.proc), ARM_WAIT_MS2);
|
|
130670
130782
|
const reason2 = "proc" in outcome && !armedFor(processKey(outcome.proc)) ? await refreshAgentReason(outcome.proc) : void 0;
|
|
130671
130783
|
if (disposed) return void 0;
|
|
130672
130784
|
if (stopped) return stoppedLaunchNote(packageName);
|
|
@@ -138604,6 +138716,7 @@ function dispatchByPlatform(opts) {
|
|
|
138604
138716
|
if (opts.ios.requires?.length) {
|
|
138605
138717
|
await ensureDeps(opts.ios.requires);
|
|
138606
138718
|
}
|
|
138719
|
+
void armSimulator(device.id);
|
|
138607
138720
|
return opts.ios.handler(services, params, device, invokeOptions);
|
|
138608
138721
|
}
|
|
138609
138722
|
if (device.platform === "ios-remote") {
|
|
@@ -138654,6 +138767,14 @@ init_external_devices();
|
|
|
138654
138767
|
// ../tool-server/src/utils/ios-front-app.ts
|
|
138655
138768
|
var IN_FRONT_TIMEOUT_MS = 5e3;
|
|
138656
138769
|
var IN_FRONT_POLL_MS = 100;
|
|
138770
|
+
function startIosFrontAppReader(registry2, device) {
|
|
138771
|
+
void isTvOsSimulator(device.id).then((tv) => {
|
|
138772
|
+
if (tv) return;
|
|
138773
|
+
const ref = axServiceRef(device);
|
|
138774
|
+
return registry2.resolveService(ref.urn, ref.options);
|
|
138775
|
+
}).catch(() => {
|
|
138776
|
+
});
|
|
138777
|
+
}
|
|
138657
138778
|
async function awaitIosAppInFront(registry2, device, bundleId, signal) {
|
|
138658
138779
|
const deadline = Date.now() + IN_FRONT_TIMEOUT_MS;
|
|
138659
138780
|
const remaining = () => deadline - Date.now();
|
|
@@ -138686,6 +138807,7 @@ function makeIosImpl(registry2) {
|
|
|
138686
138807
|
return {
|
|
138687
138808
|
requires: ["xcrun"],
|
|
138688
138809
|
handler: async (_services, params, device, options) => {
|
|
138810
|
+
startIosFrontAppReader(registry2, device);
|
|
138689
138811
|
let nativeDevtools;
|
|
138690
138812
|
let accessibility;
|
|
138691
138813
|
if (!externalClaimForAnyId(device.id)) {
|
|
@@ -139238,6 +139360,7 @@ function makeIosImpl2(registry2) {
|
|
|
139238
139360
|
return {
|
|
139239
139361
|
requires: ["xcrun"],
|
|
139240
139362
|
handler: async (_services, params, device, options) => {
|
|
139363
|
+
startIosFrontAppReader(registry2, device);
|
|
139241
139364
|
const { udid, bundleId } = params;
|
|
139242
139365
|
let nativeDevtools;
|
|
139243
139366
|
let accessibility;
|
|
@@ -140421,7 +140544,7 @@ var execFileAsync34 = (0, import_node_util35.promisify)(import_node_child_proces
|
|
|
140421
140544
|
var iosImpl3 = {
|
|
140422
140545
|
requires: ["xcrun"],
|
|
140423
140546
|
handler: async (_services, params) => {
|
|
140424
|
-
await
|
|
140547
|
+
await armSimulator(params.udid);
|
|
140425
140548
|
try {
|
|
140426
140549
|
await execFileAsync34(
|
|
140427
140550
|
"xcrun",
|
|
@@ -140647,8 +140770,8 @@ var zodSchema17 = external_exports.object({
|
|
|
140647
140770
|
});
|
|
140648
140771
|
var openUrlTool = {
|
|
140649
140772
|
id: "open-url",
|
|
140650
|
-
// On iOS it first waits up to 15s for
|
|
140651
|
-
//
|
|
140773
|
+
// On iOS it first waits up to 15s for its simulator to be armed, so a slow
|
|
140774
|
+
// openurl can pass the MCP fetch timeout, whose replay would open the URL twice.
|
|
140652
140775
|
longRunning: true,
|
|
140653
140776
|
description: `Open a URL or deep-link scheme on the device.
|
|
140654
140777
|
Use when navigating to a web page or deep-linking into an app (prefer custom schemes or \`launch-app\` over \`https://\` Universal/App Links). On Chromium, navigates the primary page (non-page schemes like \`tel:\`/\`mailto:\` fail). On physical iOS, the receiving app becomes active for automation.<flag:harmonyos> HarmonyOS opens URIs via \`aa start -U\`.</flag:harmonyos>
|
|
@@ -158466,7 +158589,7 @@ async function startNativeProfilerIos(api, params) {
|
|
|
158466
158589
|
throw mallocNonDeviceStrategyError(captureDecision.reason);
|
|
158467
158590
|
}
|
|
158468
158591
|
const info = resolveAppForLaunch(params.device_id, params.app_process);
|
|
158469
|
-
await
|
|
158592
|
+
await armSimulator(params.device_id);
|
|
158470
158593
|
appProcess = info.CFBundleExecutable;
|
|
158471
158594
|
launchBundlePath = getAppBundlePath(params.device_id, info.CFBundleIdentifier);
|
|
158472
158595
|
try {
|
|
@@ -166918,6 +167041,7 @@ Returns \`{ stopped, unmatched?, left_running?, aborted? }\` (\`left_running\` n
|
|
|
166918
167041
|
const matchedId = scoped ? deviceIdOwningUrn(urn, DEVICE_OWNED_NAMESPACES, devices2) : void 0;
|
|
166919
167042
|
const matches2 = scoped ? matchedId !== void 0 : isDeviceServiceUrn(urn, DEVICE_OWNED_NAMESPACES);
|
|
166920
167043
|
if (matchedId !== void 0) matchedIds.add(matchedId.toLowerCase());
|
|
167044
|
+
if (matches2) forgetSimulatorTarget(urn);
|
|
166921
167045
|
if (matches2 && entry.state !== "IDLE" /* IDLE */) {
|
|
166922
167046
|
const wasLive = isLiveServiceState(entry.state);
|
|
166923
167047
|
await registry2.disposeService(urn);
|
|
@@ -167701,7 +167825,7 @@ function classifyOutcome(input2) {
|
|
|
167701
167825
|
if (!input2.startedSeen) {
|
|
167702
167826
|
return failed2(
|
|
167703
167827
|
"protocol",
|
|
167704
|
-
`The script runner exited before it started the script (${
|
|
167828
|
+
`The script runner exited before it started the script (${describeExit2(exit)}).`
|
|
167705
167829
|
);
|
|
167706
167830
|
}
|
|
167707
167831
|
if (exit.signal) {
|
|
@@ -167882,7 +168006,7 @@ function isHeapAbort(exit, heapFatalSeen) {
|
|
|
167882
168006
|
return process.platform === "win32" && exit.code !== null && WINDOWS_ABORT_CODES.has(exit.code);
|
|
167883
168007
|
}
|
|
167884
168008
|
var WINDOWS_ABORT_CODES = /* @__PURE__ */ new Set([3, 3221226505]);
|
|
167885
|
-
function
|
|
168009
|
+
function describeExit2(exit) {
|
|
167886
168010
|
if (exit.signal) return `signal ${exit.signal}`;
|
|
167887
168011
|
return `exit code ${exit.code ?? 0}`;
|
|
167888
168012
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swmansion/argent",
|
|
3
|
-
"version": "0.35.1-next.
|
|
3
|
+
"version": "0.35.1-next.78",
|
|
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": "709a5954ebd6f40571229964089eed5c847da20f"
|
|
102
102
|
}
|