@swmansion/argent 0.35.1-next.65 → 0.35.1-next.66
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/tool-server.cjs +158 -75
- package/package.json +2 -2
package/dist/tool-server.cjs
CHANGED
|
@@ -104935,8 +104935,12 @@ var CDPClient = class {
|
|
|
104935
104935
|
if (dotIdx < 0) return;
|
|
104936
104936
|
const domain2 = method.slice(0, dotIdx);
|
|
104937
104937
|
const action = method.slice(dotIdx + 1);
|
|
104938
|
-
if (action === "enable")
|
|
104939
|
-
|
|
104938
|
+
if (action === "enable") {
|
|
104939
|
+
this.enabledDomains.add(domain2);
|
|
104940
|
+
this.events.emit("domainEnabled", domain2);
|
|
104941
|
+
} else if (action === "disable") {
|
|
104942
|
+
this.enabledDomains.delete(domain2);
|
|
104943
|
+
}
|
|
104940
104944
|
}
|
|
104941
104945
|
cleanup() {
|
|
104942
104946
|
this.paused = void 0;
|
|
@@ -105105,7 +105109,7 @@ async function openBlankPage(port) {
|
|
|
105105
105109
|
}
|
|
105106
105110
|
}
|
|
105107
105111
|
async function primePageSession(cdp) {
|
|
105108
|
-
for (const domain2 of ["Page", "DOM", "Runtime", "Accessibility"]) {
|
|
105112
|
+
for (const domain2 of ["Page", "DOM", "Runtime", "Accessibility", "Log"]) {
|
|
105109
105113
|
try {
|
|
105110
105114
|
await cdp.send(`${domain2}.enable`);
|
|
105111
105115
|
} catch {
|
|
@@ -125328,6 +125332,66 @@ function describeReapedSession(entry, what) {
|
|
|
125328
125332
|
return `The ${what} for device ${entry.deviceId} was torn down ${secondsAgo}s ago \u2014 by a stop-all-simulator-servers, which reaps every service a device owns, or by another teardown that reaches the same services (a stop-simulator-server on Chromium or a Mac app, or a react-profiler-start reclaiming the session with force). One tool-server serves every agent using this Argent install and home, so this may have been another agent rather than your own call. It was not a session that never started.${salvage}`;
|
|
125329
125333
|
}
|
|
125330
125334
|
|
|
125335
|
+
// ../tool-server/src/tools/network/network-secrets.ts
|
|
125336
|
+
init_src();
|
|
125337
|
+
|
|
125338
|
+
// ../tool-server/src/utils/received-secrets.ts
|
|
125339
|
+
var MAX_VALUES2 = 256;
|
|
125340
|
+
var received = /* @__PURE__ */ new Map();
|
|
125341
|
+
function noteReceivedSecrets(secrets) {
|
|
125342
|
+
for (const [name, value] of secrets) {
|
|
125343
|
+
if (value.length === 0) continue;
|
|
125344
|
+
received.delete(value);
|
|
125345
|
+
received.set(value, name);
|
|
125346
|
+
if (received.size > MAX_VALUES2) received.delete(received.keys().next().value);
|
|
125347
|
+
}
|
|
125348
|
+
}
|
|
125349
|
+
function receivedSecrets() {
|
|
125350
|
+
return [...received].reverse().map(([value, name]) => ({ name, value }));
|
|
125351
|
+
}
|
|
125352
|
+
|
|
125353
|
+
// ../tool-server/src/tools/network/network-secrets.ts
|
|
125354
|
+
function networkSecrets(ctx) {
|
|
125355
|
+
const secrets = [];
|
|
125356
|
+
for (const [name, value] of ctx?.clientSecrets ?? []) secrets.push({ name, value });
|
|
125357
|
+
for (const source of secretSources()) {
|
|
125358
|
+
for (const [name, value] of source.values) secrets.push({ name, value });
|
|
125359
|
+
}
|
|
125360
|
+
return [...secrets, ...receivedSecrets(), ...typedSecrets()];
|
|
125361
|
+
}
|
|
125362
|
+
function networkRedactorOf(secrets) {
|
|
125363
|
+
const byValue = /* @__PURE__ */ new Map();
|
|
125364
|
+
for (const { name, value } of secrets) {
|
|
125365
|
+
if (value.length > 0 && !byValue.has(value)) byValue.set(value, name);
|
|
125366
|
+
}
|
|
125367
|
+
return secretRedactor(
|
|
125368
|
+
[...byValue].map(([value, name]) => ({ name, value })),
|
|
125369
|
+
{ wholeValues: true }
|
|
125370
|
+
);
|
|
125371
|
+
}
|
|
125372
|
+
function networkSecretRedactor(ctx) {
|
|
125373
|
+
return networkRedactorOf(networkSecrets(ctx));
|
|
125374
|
+
}
|
|
125375
|
+
function redactNetworkResult(result, redact2, keep = []) {
|
|
125376
|
+
if (redact2.names.size === 0) return result;
|
|
125377
|
+
const kept = keep.map((path77) => path77.split("."));
|
|
125378
|
+
const walk = (node2, path77) => {
|
|
125379
|
+
if (typeof node2 === "string") {
|
|
125380
|
+
return kept.some(
|
|
125381
|
+
(k) => k.length === path77.length && k.every((p, i) => p === "*" ? /^\d+$/.test(path77[i]) : p === path77[i])
|
|
125382
|
+
) ? node2 : redact2(node2);
|
|
125383
|
+
}
|
|
125384
|
+
if (Array.isArray(node2)) return node2.map((item, i) => walk(item, [...path77, String(i)]));
|
|
125385
|
+
if (node2 === null || typeof node2 !== "object") return node2;
|
|
125386
|
+
const out = {};
|
|
125387
|
+
for (const [key2, value] of Object.entries(node2)) {
|
|
125388
|
+
out[redact2(key2)] = walk(value, [...path77, key2]);
|
|
125389
|
+
}
|
|
125390
|
+
return out;
|
|
125391
|
+
};
|
|
125392
|
+
return walk(result, []);
|
|
125393
|
+
}
|
|
125394
|
+
|
|
125331
125395
|
// ../tool-server/src/blueprints/chromium-js-runtime-debugger.ts
|
|
125332
125396
|
var CHROMIUM_JS_RUNTIME_DEBUGGER_NAMESPACE = "ChromiumJsRuntimeDebugger";
|
|
125333
125397
|
function chromiumJsRuntimeDebuggerRef(device) {
|
|
@@ -125353,6 +125417,66 @@ function formatConsoleArgs(params) {
|
|
|
125353
125417
|
return `[${arg.type}]`;
|
|
125354
125418
|
}).join(" ");
|
|
125355
125419
|
}
|
|
125420
|
+
var MAX_REPLAY_KEYS = 5e4;
|
|
125421
|
+
var REPLAY_KEY_PREFIX_CHARS = 64;
|
|
125422
|
+
function replayKey(targetId, { timestamp, level, message }) {
|
|
125423
|
+
const prefix = detachedCopy(message.slice(0, REPLAY_KEY_PREFIX_CHARS));
|
|
125424
|
+
return `${targetId}|${timestamp}|${level}|${message.length}|${prefix}`;
|
|
125425
|
+
}
|
|
125426
|
+
function createReplayFilter() {
|
|
125427
|
+
const recorded = /* @__PURE__ */ new Map();
|
|
125428
|
+
const seenSinceAttach = /* @__PURE__ */ new Map();
|
|
125429
|
+
const replaying = /* @__PURE__ */ new Set();
|
|
125430
|
+
return {
|
|
125431
|
+
attached: () => {
|
|
125432
|
+
seenSinceAttach.clear();
|
|
125433
|
+
replaying.add("Runtime").add("Log");
|
|
125434
|
+
},
|
|
125435
|
+
enabled: (domain2) => {
|
|
125436
|
+
replaying.delete(domain2);
|
|
125437
|
+
},
|
|
125438
|
+
isReplay(domain2, key2) {
|
|
125439
|
+
const seen = seenSinceAttach.get(key2) ?? 0;
|
|
125440
|
+
const count2 = recorded.get(key2) ?? 0;
|
|
125441
|
+
if (replaying.has(domain2) && seen < count2) {
|
|
125442
|
+
seenSinceAttach.set(key2, seen + 1);
|
|
125443
|
+
return true;
|
|
125444
|
+
}
|
|
125445
|
+
if (count2 > 0 || recorded.size < MAX_REPLAY_KEYS) {
|
|
125446
|
+
recorded.set(key2, count2 + 1);
|
|
125447
|
+
seenSinceAttach.set(key2, seen + 1);
|
|
125448
|
+
}
|
|
125449
|
+
return false;
|
|
125450
|
+
}
|
|
125451
|
+
};
|
|
125452
|
+
}
|
|
125453
|
+
function withEntryUrl(text, { source, url: url2 }) {
|
|
125454
|
+
if (!url2 || text.includes(url2)) return text;
|
|
125455
|
+
return source === "network" ? `${url2} ${text}` : `${text} ${url2}`;
|
|
125456
|
+
}
|
|
125457
|
+
function browserLogMessage(params) {
|
|
125458
|
+
const entry = params.entry ?? {};
|
|
125459
|
+
const text = entry.text ?? "";
|
|
125460
|
+
return {
|
|
125461
|
+
args: [],
|
|
125462
|
+
level: entry.level === "verbose" ? "debug" : entry.level ?? "info",
|
|
125463
|
+
message: withEntryUrl(text, entry),
|
|
125464
|
+
timestamp: entry.timestamp ?? NaN
|
|
125465
|
+
};
|
|
125466
|
+
}
|
|
125467
|
+
function uncaughtExceptionMessage(params) {
|
|
125468
|
+
const details = params.exceptionDetails ?? {};
|
|
125469
|
+
const exception = details.exception;
|
|
125470
|
+
const thrown = exception?.description?.split("\n")[0] ?? (exception && "value" in exception ? stringifyConsoleValue(exception.value) : void 0);
|
|
125471
|
+
const text = details.text ?? "Uncaught";
|
|
125472
|
+
return {
|
|
125473
|
+
args: [],
|
|
125474
|
+
level: "error",
|
|
125475
|
+
message: thrown ? `${text} ${thrown}` : text,
|
|
125476
|
+
timestamp: params.timestamp ?? NaN,
|
|
125477
|
+
stackTrace: details.stackTrace
|
|
125478
|
+
};
|
|
125479
|
+
}
|
|
125356
125480
|
function createConsoleLogServer(consoleEvents, logWriter) {
|
|
125357
125481
|
return new Promise((resolve24, reject) => {
|
|
125358
125482
|
const server = http3.createServer();
|
|
@@ -125437,10 +125561,26 @@ var chromiumJsRuntimeDebuggerBlueprint = {
|
|
|
125437
125561
|
const logWriter = new LogFileWriter(port);
|
|
125438
125562
|
const consoleEvents = new TypedEventEmitter();
|
|
125439
125563
|
let nextLogId = 0;
|
|
125564
|
+
const replays = createReplayFilter();
|
|
125565
|
+
cdp.events.on("connected", replays.attached);
|
|
125566
|
+
cdp.events.on("domainEnabled", replays.enabled);
|
|
125567
|
+
const isReplay = (domain2, fields) => Number.isFinite(fields.timestamp) && replays.isReplay(domain2, replayKey(chromium.server.tabs.activeTargetId(), fields));
|
|
125568
|
+
const record2 = (domain2, fields, { redactSecrets: redactSecrets2 = false } = {}) => {
|
|
125569
|
+
if (isReplay(domain2, fields)) return;
|
|
125570
|
+
const message = redactSecrets2 ? networkSecretRedactor()(fields.message) : fields.message;
|
|
125571
|
+
const ts = Number.isFinite(fields.timestamp) ? fields.timestamp : Date.now();
|
|
125572
|
+
const entry = { ...fields, id: nextLogId++, message, timestamp: ts };
|
|
125573
|
+
logWriter.write({
|
|
125574
|
+
id: entry.id,
|
|
125575
|
+
timestamp: consoleTimestampToIso(ts),
|
|
125576
|
+
level: entry.level,
|
|
125577
|
+
message: entry.message,
|
|
125578
|
+
stackTrace: entry.stackTrace
|
|
125579
|
+
});
|
|
125580
|
+
consoleEvents.emit("log", entry);
|
|
125581
|
+
};
|
|
125440
125582
|
const onConsoleAPI = (params) => {
|
|
125441
|
-
|
|
125442
|
-
const entry = {
|
|
125443
|
-
id: nextLogId++,
|
|
125583
|
+
record2("Runtime", {
|
|
125444
125584
|
level: params.type,
|
|
125445
125585
|
args: params.args.map((a) => ({
|
|
125446
125586
|
type: a.type,
|
|
@@ -125448,19 +125588,19 @@ var chromiumJsRuntimeDebuggerBlueprint = {
|
|
|
125448
125588
|
description: a.description
|
|
125449
125589
|
})),
|
|
125450
125590
|
message: formatConsoleArgs(params),
|
|
125451
|
-
timestamp:
|
|
125591
|
+
timestamp: params.timestamp,
|
|
125452
125592
|
stackTrace: params.stackTrace
|
|
125453
|
-
};
|
|
125454
|
-
logWriter.write({
|
|
125455
|
-
id: entry.id,
|
|
125456
|
-
timestamp: consoleTimestampToIso(ts),
|
|
125457
|
-
level: entry.level,
|
|
125458
|
-
message: entry.message,
|
|
125459
|
-
stackTrace: entry.stackTrace
|
|
125460
125593
|
});
|
|
125461
|
-
consoleEvents.emit("log", entry);
|
|
125462
125594
|
};
|
|
125463
125595
|
cdp.events.on("consoleAPICalled", onConsoleAPI);
|
|
125596
|
+
const onBrowserEvent = (method, params) => {
|
|
125597
|
+
if (method === "Log.entryAdded") {
|
|
125598
|
+
record2("Log", browserLogMessage(params), { redactSecrets: true });
|
|
125599
|
+
} else if (method === "Runtime.exceptionThrown") {
|
|
125600
|
+
record2("Runtime", uncaughtExceptionMessage(params));
|
|
125601
|
+
}
|
|
125602
|
+
};
|
|
125603
|
+
cdp.events.on("event", onBrowserEvent);
|
|
125464
125604
|
const consoleServer = await createConsoleLogServer(consoleEvents, logWriter);
|
|
125465
125605
|
await cdp.addBinding("__argent_callback").catch(() => {
|
|
125466
125606
|
});
|
|
@@ -125487,6 +125627,9 @@ var chromiumJsRuntimeDebuggerBlueprint = {
|
|
|
125487
125627
|
api,
|
|
125488
125628
|
dispose: async () => {
|
|
125489
125629
|
cdp.events.off("consoleAPICalled", onConsoleAPI);
|
|
125630
|
+
cdp.events.off("event", onBrowserEvent);
|
|
125631
|
+
cdp.events.off("connected", replays.attached);
|
|
125632
|
+
cdp.events.off("domainEnabled", replays.enabled);
|
|
125490
125633
|
cdp.events.off("disconnected", onDisconnected);
|
|
125491
125634
|
await consoleServer.close();
|
|
125492
125635
|
const captured = logWriter.getStats().totalEntries;
|
|
@@ -125792,21 +125935,6 @@ function isLocalConnection(socket) {
|
|
|
125792
125935
|
return LOOPBACK_ADDRESSES.has(remote) || remote === socket.localAddress || isOwnAddress(remote);
|
|
125793
125936
|
}
|
|
125794
125937
|
|
|
125795
|
-
// ../tool-server/src/utils/received-secrets.ts
|
|
125796
|
-
var MAX_VALUES2 = 256;
|
|
125797
|
-
var received = /* @__PURE__ */ new Map();
|
|
125798
|
-
function noteReceivedSecrets(secrets) {
|
|
125799
|
-
for (const [name, value] of secrets) {
|
|
125800
|
-
if (value.length === 0) continue;
|
|
125801
|
-
received.delete(value);
|
|
125802
|
-
received.set(value, name);
|
|
125803
|
-
if (received.size > MAX_VALUES2) received.delete(received.keys().next().value);
|
|
125804
|
-
}
|
|
125805
|
-
}
|
|
125806
|
-
function receivedSecrets() {
|
|
125807
|
-
return [...received].reverse().map(([value, name]) => ({ name, value }));
|
|
125808
|
-
}
|
|
125809
|
-
|
|
125810
125938
|
// ../tool-server/src/http.ts
|
|
125811
125939
|
var AUTO_SUPPRESS_MS = 30 * 60 * 1e3;
|
|
125812
125940
|
var AUTH_TOKEN_ENV = "ARGENT_AUTH_TOKEN";
|
|
@@ -129451,51 +129579,6 @@ Fails if the simulator server is not running for the given UDID.`,
|
|
|
129451
129579
|
|
|
129452
129580
|
// ../tool-server/src/tools/native-devtools/native-network-logs.ts
|
|
129453
129581
|
init_zod();
|
|
129454
|
-
|
|
129455
|
-
// ../tool-server/src/tools/network/network-secrets.ts
|
|
129456
|
-
init_src();
|
|
129457
|
-
function networkSecrets(ctx) {
|
|
129458
|
-
const secrets = [];
|
|
129459
|
-
for (const [name, value] of ctx?.clientSecrets ?? []) secrets.push({ name, value });
|
|
129460
|
-
for (const source of secretSources()) {
|
|
129461
|
-
for (const [name, value] of source.values) secrets.push({ name, value });
|
|
129462
|
-
}
|
|
129463
|
-
return [...secrets, ...receivedSecrets(), ...typedSecrets()];
|
|
129464
|
-
}
|
|
129465
|
-
function networkRedactorOf(secrets) {
|
|
129466
|
-
const byValue = /* @__PURE__ */ new Map();
|
|
129467
|
-
for (const { name, value } of secrets) {
|
|
129468
|
-
if (value.length > 0 && !byValue.has(value)) byValue.set(value, name);
|
|
129469
|
-
}
|
|
129470
|
-
return secretRedactor(
|
|
129471
|
-
[...byValue].map(([value, name]) => ({ name, value })),
|
|
129472
|
-
{ wholeValues: true }
|
|
129473
|
-
);
|
|
129474
|
-
}
|
|
129475
|
-
function networkSecretRedactor(ctx) {
|
|
129476
|
-
return networkRedactorOf(networkSecrets(ctx));
|
|
129477
|
-
}
|
|
129478
|
-
function redactNetworkResult(result, redact2, keep = []) {
|
|
129479
|
-
if (redact2.names.size === 0) return result;
|
|
129480
|
-
const kept = keep.map((path77) => path77.split("."));
|
|
129481
|
-
const walk = (node2, path77) => {
|
|
129482
|
-
if (typeof node2 === "string") {
|
|
129483
|
-
return kept.some(
|
|
129484
|
-
(k) => k.length === path77.length && k.every((p, i) => p === "*" ? /^\d+$/.test(path77[i]) : p === path77[i])
|
|
129485
|
-
) ? node2 : redact2(node2);
|
|
129486
|
-
}
|
|
129487
|
-
if (Array.isArray(node2)) return node2.map((item, i) => walk(item, [...path77, String(i)]));
|
|
129488
|
-
if (node2 === null || typeof node2 !== "object") return node2;
|
|
129489
|
-
const out = {};
|
|
129490
|
-
for (const [key2, value] of Object.entries(node2)) {
|
|
129491
|
-
out[redact2(key2)] = walk(value, [...path77, key2]);
|
|
129492
|
-
}
|
|
129493
|
-
return out;
|
|
129494
|
-
};
|
|
129495
|
-
return walk(result, []);
|
|
129496
|
-
}
|
|
129497
|
-
|
|
129498
|
-
// ../tool-server/src/tools/native-devtools/native-network-logs.ts
|
|
129499
129582
|
init_src2();
|
|
129500
129583
|
init_device_info();
|
|
129501
129584
|
|
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.66",
|
|
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": "99f69a581658b01280e23a60c61c78988e4faf61"
|
|
102
102
|
}
|