@ait-co/devtools 0.1.39 → 0.1.40

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/mcp/cli.js CHANGED
@@ -1332,8 +1332,14 @@ async function takeScreenshot(connection) {
1332
1332
  * The JS probe injected via `Runtime.evaluate`. It reads:
1333
1333
  * 1. `env(safe-area-inset-*)` via a temporary element with padding set to
1334
1334
  * those CSS env vars, then `getComputedStyle`.
1335
- * 2. `SafeAreaInsets.get()` if the native SDK object is available.
1336
- * 3. nav bar geometry (first `.ait-navbar` element height, if present).
1335
+ * 2. `window.__sdk.SafeAreaInsets.get()` (1st priority) or
1336
+ * `window.__sdk.getSafeAreaInsets()` (2nd priority) both surfaces
1337
+ * confirmed live on iPhone 15 Pro relay. `window.__sdk` is only present
1338
+ * in dogfood (__DEBUG_BUILD__) bundles; outside those it is undefined.
1339
+ * If both paths fail the result carries `sdkInsetsError` explaining why.
1340
+ * 3. nav bar geometry: the SDK does not expose navBar height as a standalone
1341
+ * API — `.ait-navbar` DOM height is read as a cross-check, and
1342
+ * `navBarHeightSource` records where it came from.
1337
1343
  * 4. `innerWidth`, `innerHeight`, `devicePixelRatio`, `navigator.userAgent`.
1338
1344
  *
1339
1345
  * Returns a plain JSON-serialisable object so `returnByValue: true` works.
@@ -1360,25 +1366,42 @@ const SAFE_AREA_PROBE_EXPRESSION = `
1360
1366
  };
1361
1367
  document.documentElement.removeChild(el);
1362
1368
  var sdkInsets = null;
1369
+ var sdkInsetsError = undefined;
1363
1370
  try {
1364
- if (typeof SafeAreaInsets !== 'undefined' && SafeAreaInsets && typeof SafeAreaInsets.get === 'function') {
1365
- sdkInsets = SafeAreaInsets.get();
1371
+ var sdk = window.__sdk;
1372
+ if (sdk && sdk.SafeAreaInsets && typeof sdk.SafeAreaInsets.get === 'function') {
1373
+ sdkInsets = sdk.SafeAreaInsets.get();
1374
+ } else if (sdk && typeof sdk.getSafeAreaInsets === 'function') {
1375
+ sdkInsets = sdk.getSafeAreaInsets();
1376
+ } else if (!sdk) {
1377
+ sdkInsetsError = 'window.__sdk not available (non-dogfood bundle)';
1378
+ } else {
1379
+ sdkInsetsError = 'neither SafeAreaInsets.get nor getSafeAreaInsets found on window.__sdk';
1366
1380
  }
1367
- } catch(_) {}
1381
+ } catch(e) {
1382
+ sdkInsetsError = String(e && e.message || e);
1383
+ }
1368
1384
  var navBarHeight = null;
1385
+ var navBarHeightSource = 'not-exposed-by-sdk';
1369
1386
  try {
1370
1387
  var nb = document.querySelector('.ait-navbar');
1371
- if (nb) navBarHeight = nb.getBoundingClientRect().height;
1388
+ if (nb) {
1389
+ navBarHeight = nb.getBoundingClientRect().height;
1390
+ navBarHeightSource = 'dom-.ait-navbar';
1391
+ }
1372
1392
  } catch(_) {}
1373
- return JSON.stringify({
1393
+ var result = {
1374
1394
  cssEnv: cssEnv,
1375
1395
  sdkInsets: sdkInsets,
1376
1396
  navBarHeight: navBarHeight,
1397
+ navBarHeightSource: navBarHeightSource,
1377
1398
  innerWidth: window.innerWidth,
1378
1399
  innerHeight: window.innerHeight,
1379
1400
  devicePixelRatio: window.devicePixelRatio,
1380
1401
  userAgent: navigator.userAgent
1381
- });
1402
+ };
1403
+ if (sdkInsetsError !== undefined) result.sdkInsetsError = sdkInsetsError;
1404
+ return JSON.stringify(result);
1382
1405
  })()
1383
1406
  `.trim();
1384
1407
  /**
@@ -1410,19 +1433,30 @@ function normalizeSafeAreaResult(rawValue) {
1410
1433
  left: typeof r.left === "number" ? r.left : 0
1411
1434
  };
1412
1435
  }
1436
+ const cssEnv = requireInsets("cssEnv") ?? {
1437
+ top: 0,
1438
+ right: 0,
1439
+ bottom: 0,
1440
+ left: 0
1441
+ };
1442
+ const sdkInsets = requireInsets("sdkInsets");
1443
+ const sdkInsetsError = typeof obj.sdkInsetsError === "string" ? obj.sdkInsetsError : void 0;
1444
+ const navBarHeight = typeof obj.navBarHeight === "number" ? obj.navBarHeight : null;
1445
+ const navBarHeightSource = typeof obj.navBarHeightSource === "string" ? obj.navBarHeightSource : "not-exposed-by-sdk";
1446
+ const innerWidth = typeof obj.innerWidth === "number" ? obj.innerWidth : 0;
1447
+ const innerHeight = typeof obj.innerHeight === "number" ? obj.innerHeight : 0;
1448
+ const devicePixelRatio = typeof obj.devicePixelRatio === "number" ? obj.devicePixelRatio : 1;
1449
+ const userAgent = typeof obj.userAgent === "string" ? obj.userAgent : "";
1413
1450
  return {
1414
- cssEnv: requireInsets("cssEnv") ?? {
1415
- top: 0,
1416
- right: 0,
1417
- bottom: 0,
1418
- left: 0
1419
- },
1420
- sdkInsets: requireInsets("sdkInsets"),
1421
- navBarHeight: typeof obj.navBarHeight === "number" ? obj.navBarHeight : null,
1422
- innerWidth: typeof obj.innerWidth === "number" ? obj.innerWidth : 0,
1423
- innerHeight: typeof obj.innerHeight === "number" ? obj.innerHeight : 0,
1424
- devicePixelRatio: typeof obj.devicePixelRatio === "number" ? obj.devicePixelRatio : 1,
1425
- userAgent: typeof obj.userAgent === "string" ? obj.userAgent : ""
1451
+ cssEnv,
1452
+ sdkInsets,
1453
+ ...sdkInsetsError !== void 0 ? { sdkInsetsError } : {},
1454
+ navBarHeight,
1455
+ navBarHeightSource,
1456
+ innerWidth,
1457
+ innerHeight,
1458
+ devicePixelRatio,
1459
+ userAgent
1426
1460
  };
1427
1461
  }
1428
1462
  /**
@@ -1827,7 +1861,7 @@ function createDebugServer(deps) {
1827
1861
  const { connection, aitSource, getTunnelStatus, waitForAttachTimeoutMs = 9e4, qrHttpServer } = deps;
1828
1862
  const server = new Server({
1829
1863
  name: "ait-debug",
1830
- version: "0.1.39"
1864
+ version: "0.1.40"
1831
1865
  }, { capabilities: { tools: { listChanged: true } } });
1832
1866
  server.setRequestHandler(ListToolsRequestSchema, () => {
1833
1867
  return { tools: connection.listTargets().length > 0 ? DEBUG_TOOL_DEFINITIONS.map((tool) => ({ ...tool })) : DEBUG_TOOL_DEFINITIONS.filter((tool) => BOOTSTRAP_TOOL_NAMES.has(tool.name)).map((tool) => ({ ...tool })) };
@@ -2378,7 +2412,7 @@ function createDevServer(deps = {}) {
2378
2412
  const aitSource = deps.aitSource ?? new HttpAitSource({ stateEndpoint });
2379
2413
  const server = new Server({
2380
2414
  name: "ait-devtools",
2381
- version: "0.1.39"
2415
+ version: "0.1.40"
2382
2416
  }, { capabilities: { tools: {} } });
2383
2417
  server.setRequestHandler(ListToolsRequestSchema, () => ({ tools: DEV_TOOL_DEFINITIONS.map((tool) => ({ ...tool })) }));
2384
2418
  server.setRequestHandler(CallToolRequestSchema, async (request) => {