@browserstack/mcp-server 1.0.15 → 1.1.0

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.
Files changed (53) hide show
  1. package/dist/config.js +6 -2
  2. package/dist/index.js +34 -29
  3. package/dist/lib/api.js +9 -3
  4. package/dist/lib/constants.js +6 -3
  5. package/dist/lib/device-cache.js +21 -14
  6. package/dist/lib/error.js +6 -3
  7. package/dist/lib/fuzzy.js +4 -1
  8. package/dist/lib/inmemory-store.js +4 -1
  9. package/dist/lib/instrumentation.js +18 -12
  10. package/dist/lib/local.js +35 -27
  11. package/dist/lib/utils.js +15 -6
  12. package/dist/logger.js +6 -4
  13. package/dist/tools/accessibility.js +16 -13
  14. package/dist/tools/accessiblity-utils/report-fetcher.js +14 -7
  15. package/dist/tools/accessiblity-utils/report-parser.js +11 -5
  16. package/dist/tools/accessiblity-utils/scanner.js +16 -9
  17. package/dist/tools/appautomate-utils/appautomate.js +27 -17
  18. package/dist/tools/appautomate.js +35 -29
  19. package/dist/tools/applive-utils/fuzzy-search.js +6 -3
  20. package/dist/tools/applive-utils/start-session.js +20 -14
  21. package/dist/tools/applive-utils/upload-app.js +51 -12
  22. package/dist/tools/applive.js +25 -18
  23. package/dist/tools/automate-utils/fetch-screenshots.js +14 -8
  24. package/dist/tools/automate.js +21 -14
  25. package/dist/tools/bstack-sdk.js +18 -14
  26. package/dist/tools/failurelogs-utils/app-automate.js +26 -15
  27. package/dist/tools/failurelogs-utils/automate.js +23 -13
  28. package/dist/tools/getFailureLogs.js +49 -42
  29. package/dist/tools/live-utils/desktop-filter.js +11 -8
  30. package/dist/tools/live-utils/mobile-filter.js +10 -7
  31. package/dist/tools/live-utils/start-session.js +23 -17
  32. package/dist/tools/live-utils/types.js +5 -2
  33. package/dist/tools/live-utils/version-resolver.js +4 -1
  34. package/dist/tools/live.js +29 -23
  35. package/dist/tools/observability.js +19 -12
  36. package/dist/tools/sdk-utils/constants.js +9 -3
  37. package/dist/tools/sdk-utils/instructions.js +9 -4
  38. package/dist/tools/sdk-utils/types.js +2 -1
  39. package/dist/tools/testmanagement-utils/TCG-utils/api.js +38 -26
  40. package/dist/tools/testmanagement-utils/TCG-utils/config.js +10 -5
  41. package/dist/tools/testmanagement-utils/TCG-utils/helpers.js +8 -3
  42. package/dist/tools/testmanagement-utils/TCG-utils/types.js +8 -5
  43. package/dist/tools/testmanagement-utils/add-test-result.js +24 -17
  44. package/dist/tools/testmanagement-utils/create-project-folder.js +28 -21
  45. package/dist/tools/testmanagement-utils/create-testcase.js +38 -30
  46. package/dist/tools/testmanagement-utils/create-testrun.js +30 -23
  47. package/dist/tools/testmanagement-utils/list-testcases.js +22 -15
  48. package/dist/tools/testmanagement-utils/list-testruns.js +19 -12
  49. package/dist/tools/testmanagement-utils/testcase-from-file.js +22 -16
  50. package/dist/tools/testmanagement-utils/update-testrun.js +22 -15
  51. package/dist/tools/testmanagement-utils/upload-file.js +29 -22
  52. package/dist/tools/testmanagement.js +76 -61
  53. package/package.json +1 -1
@@ -1,13 +1,17 @@
1
- import { z } from "zod";
2
- import { generateBrowserStackYMLInstructions, getInstructionsForProjectConfiguration, } from "./sdk-utils/instructions.js";
3
- import { trackMCP } from "../lib/instrumentation.js";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bootstrapProjectWithSDK = bootstrapProjectWithSDK;
4
+ exports.default = addSDKTools;
5
+ const zod_1 = require("zod");
6
+ const instructions_js_1 = require("./sdk-utils/instructions.js");
7
+ const instrumentation_js_1 = require("../lib/instrumentation.js");
4
8
  /**
5
9
  * BrowserStack SDK hooks into your test framework to seamlessly run tests on BrowserStack.
6
10
  * This tool gives instructions to setup a browserstack.yml file in the project root and installs the necessary dependencies.
7
11
  */
8
- export async function bootstrapProjectWithSDK({ detectedBrowserAutomationFramework, detectedTestingFramework, detectedLanguage, desiredPlatforms, }) {
9
- const instructions = generateBrowserStackYMLInstructions(desiredPlatforms);
10
- const instructionsForProjectConfiguration = getInstructionsForProjectConfiguration(detectedBrowserAutomationFramework, detectedTestingFramework, detectedLanguage);
12
+ async function bootstrapProjectWithSDK({ detectedBrowserAutomationFramework, detectedTestingFramework, detectedLanguage, desiredPlatforms, }) {
13
+ const instructions = (0, instructions_js_1.generateBrowserStackYMLInstructions)(desiredPlatforms);
14
+ const instructionsForProjectConfiguration = (0, instructions_js_1.getInstructionsForProjectConfiguration)(detectedBrowserAutomationFramework, detectedTestingFramework, detectedLanguage);
11
15
  return {
12
16
  content: [
13
17
  {
@@ -18,23 +22,23 @@ export async function bootstrapProjectWithSDK({ detectedBrowserAutomationFramewo
18
22
  ],
19
23
  };
20
24
  }
21
- export default function addSDKTools(server) {
25
+ function addSDKTools(server) {
22
26
  server.tool("runTestsOnBrowserStack", "Use this tool to get instructions for running tests on BrowserStack.", {
23
- detectedBrowserAutomationFramework: z
27
+ detectedBrowserAutomationFramework: zod_1.z
24
28
  .string()
25
29
  .describe("The automation framework configured in the project. Example: 'playwright', 'selenium'"),
26
- detectedTestingFramework: z
30
+ detectedTestingFramework: zod_1.z
27
31
  .string()
28
32
  .describe("The testing framework used in the project. Example: 'jest', 'pytest'"),
29
- detectedLanguage: z
33
+ detectedLanguage: zod_1.z
30
34
  .string()
31
35
  .describe("The programming language used in the project. Example: 'nodejs', 'python'"),
32
- desiredPlatforms: z
33
- .array(z.enum(["windows", "macos", "android", "ios"]))
36
+ desiredPlatforms: zod_1.z
37
+ .array(zod_1.z.enum(["windows", "macos", "android", "ios"]))
34
38
  .describe("The platforms the user wants to test on. Always ask this to the user, do not try to infer this."),
35
39
  }, async (args) => {
36
40
  try {
37
- trackMCP("runTestsOnBrowserStack", server.server.getClientVersion());
41
+ (0, instrumentation_js_1.trackMCP)("runTestsOnBrowserStack", server.server.getClientVersion());
38
42
  return await bootstrapProjectWithSDK({
39
43
  detectedBrowserAutomationFramework: args.detectedBrowserAutomationFramework,
40
44
  detectedTestingFramework: args.detectedTestingFramework,
@@ -43,7 +47,7 @@ export default function addSDKTools(server) {
43
47
  });
44
48
  }
45
49
  catch (error) {
46
- trackMCP("runTestsOnBrowserStack", server.server.getClientVersion(), error);
50
+ (0, instrumentation_js_1.trackMCP)("runTestsOnBrowserStack", server.server.getClientVersion(), error);
47
51
  return {
48
52
  content: [
49
53
  {
@@ -1,8 +1,19 @@
1
- import config from "../../config.js";
2
- import { assertOkResponse, filterLinesByKeywords } from "../../lib/utils.js";
3
- const auth = Buffer.from(`${config.browserstackUsername}:${config.browserstackAccessKey}`).toString("base64");
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.retrieveDeviceLogs = retrieveDeviceLogs;
7
+ exports.retrieveAppiumLogs = retrieveAppiumLogs;
8
+ exports.retrieveCrashLogs = retrieveCrashLogs;
9
+ exports.filterDeviceFailures = filterDeviceFailures;
10
+ exports.filterAppiumFailures = filterAppiumFailures;
11
+ exports.filterCrashFailures = filterCrashFailures;
12
+ const config_js_1 = __importDefault(require("../../config.js"));
13
+ const utils_js_1 = require("../../lib/utils.js");
14
+ const auth = Buffer.from(`${config_js_1.default.browserstackUsername}:${config_js_1.default.browserstackAccessKey}`).toString("base64");
4
15
  // DEVICE LOGS
5
- export async function retrieveDeviceLogs(sessionId, buildId) {
16
+ async function retrieveDeviceLogs(sessionId, buildId) {
6
17
  const url = `https://api.browserstack.com/app-automate/builds/${buildId}/sessions/${sessionId}/deviceLogs`;
7
18
  const response = await fetch(url, {
8
19
  headers: {
@@ -10,12 +21,12 @@ export async function retrieveDeviceLogs(sessionId, buildId) {
10
21
  Authorization: `Basic ${auth}`,
11
22
  },
12
23
  });
13
- await assertOkResponse(response, "device logs");
24
+ await (0, utils_js_1.assertOkResponse)(response, "device logs");
14
25
  const logText = await response.text();
15
26
  return filterDeviceFailures(logText);
16
27
  }
17
28
  // APPIUM LOGS
18
- export async function retrieveAppiumLogs(sessionId, buildId) {
29
+ async function retrieveAppiumLogs(sessionId, buildId) {
19
30
  const url = `https://api.browserstack.com/app-automate/builds/${buildId}/sessions/${sessionId}/appiumlogs`;
20
31
  const response = await fetch(url, {
21
32
  headers: {
@@ -23,12 +34,12 @@ export async function retrieveAppiumLogs(sessionId, buildId) {
23
34
  Authorization: `Basic ${auth}`,
24
35
  },
25
36
  });
26
- await assertOkResponse(response, "Appium logs");
37
+ await (0, utils_js_1.assertOkResponse)(response, "Appium logs");
27
38
  const logText = await response.text();
28
39
  return filterAppiumFailures(logText);
29
40
  }
30
41
  // CRASH LOGS
31
- export async function retrieveCrashLogs(sessionId, buildId) {
42
+ async function retrieveCrashLogs(sessionId, buildId) {
32
43
  const url = `https://api.browserstack.com/app-automate/builds/${buildId}/sessions/${sessionId}/crashlogs`;
33
44
  const response = await fetch(url, {
34
45
  headers: {
@@ -36,12 +47,12 @@ export async function retrieveCrashLogs(sessionId, buildId) {
36
47
  Authorization: `Basic ${auth}`,
37
48
  },
38
49
  });
39
- await assertOkResponse(response, "crash logs");
50
+ await (0, utils_js_1.assertOkResponse)(response, "crash logs");
40
51
  const logText = await response.text();
41
52
  return filterCrashFailures(logText);
42
53
  }
43
54
  // FILTER HELPERS
44
- export function filterDeviceFailures(logText) {
55
+ function filterDeviceFailures(logText) {
45
56
  const keywords = [
46
57
  "error",
47
58
  "exception",
@@ -55,9 +66,9 @@ export function filterDeviceFailures(logText) {
55
66
  "java.lang.",
56
67
  "unable to",
57
68
  ];
58
- return filterLinesByKeywords(logText, keywords);
69
+ return (0, utils_js_1.filterLinesByKeywords)(logText, keywords);
59
70
  }
60
- export function filterAppiumFailures(logText) {
71
+ function filterAppiumFailures(logText) {
61
72
  const keywords = [
62
73
  "error",
63
74
  "fail",
@@ -70,9 +81,9 @@ export function filterAppiumFailures(logText) {
70
81
  "command failed",
71
82
  "invalid selector",
72
83
  ];
73
- return filterLinesByKeywords(logText, keywords);
84
+ return (0, utils_js_1.filterLinesByKeywords)(logText, keywords);
74
85
  }
75
- export function filterCrashFailures(logText) {
86
+ function filterCrashFailures(logText) {
76
87
  const keywords = [
77
88
  "fatal exception",
78
89
  "crash",
@@ -84,5 +95,5 @@ export function filterCrashFailures(logText) {
84
95
  "abort message",
85
96
  "application has stopped unexpectedly",
86
97
  ];
87
- return filterLinesByKeywords(logText, keywords);
98
+ return (0, utils_js_1.filterLinesByKeywords)(logText, keywords);
88
99
  }
@@ -1,8 +1,18 @@
1
- import config from "../../config.js";
2
- import { assertOkResponse, filterLinesByKeywords } from "../../lib/utils.js";
3
- const auth = Buffer.from(`${config.browserstackUsername}:${config.browserstackAccessKey}`).toString("base64");
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.retrieveNetworkFailures = retrieveNetworkFailures;
7
+ exports.retrieveSessionFailures = retrieveSessionFailures;
8
+ exports.retrieveConsoleFailures = retrieveConsoleFailures;
9
+ exports.filterSessionFailures = filterSessionFailures;
10
+ exports.filterConsoleFailures = filterConsoleFailures;
11
+ const config_js_1 = __importDefault(require("../../config.js"));
12
+ const utils_js_1 = require("../../lib/utils.js");
13
+ const auth = Buffer.from(`${config_js_1.default.browserstackUsername}:${config_js_1.default.browserstackAccessKey}`).toString("base64");
4
14
  // NETWORK LOGS
5
- export async function retrieveNetworkFailures(sessionId) {
15
+ async function retrieveNetworkFailures(sessionId) {
6
16
  const url = `https://api.browserstack.com/automate/sessions/${sessionId}/networklogs`;
7
17
  const response = await fetch(url, {
8
18
  method: "GET",
@@ -11,7 +21,7 @@ export async function retrieveNetworkFailures(sessionId) {
11
21
  Authorization: `Basic ${auth}`,
12
22
  },
13
23
  });
14
- await assertOkResponse(response, "network logs");
24
+ await (0, utils_js_1.assertOkResponse)(response, "network logs");
15
25
  const networklogs = await response.json();
16
26
  // Filter for failure logs
17
27
  const failureEntries = networklogs.log.entries.filter((entry) => {
@@ -37,7 +47,7 @@ export async function retrieveNetworkFailures(sessionId) {
37
47
  }));
38
48
  }
39
49
  // SESSION LOGS
40
- export async function retrieveSessionFailures(sessionId) {
50
+ async function retrieveSessionFailures(sessionId) {
41
51
  const url = `https://api.browserstack.com/automate/sessions/${sessionId}/logs`;
42
52
  const response = await fetch(url, {
43
53
  headers: {
@@ -45,12 +55,12 @@ export async function retrieveSessionFailures(sessionId) {
45
55
  Authorization: `Basic ${auth}`,
46
56
  },
47
57
  });
48
- await assertOkResponse(response, "session logs");
58
+ await (0, utils_js_1.assertOkResponse)(response, "session logs");
49
59
  const logText = await response.text();
50
60
  return filterSessionFailures(logText);
51
61
  }
52
62
  // CONSOLE LOGS
53
- export async function retrieveConsoleFailures(sessionId) {
63
+ async function retrieveConsoleFailures(sessionId) {
54
64
  const url = `https://api.browserstack.com/automate/sessions/${sessionId}/consolelogs`;
55
65
  const response = await fetch(url, {
56
66
  headers: {
@@ -58,12 +68,12 @@ export async function retrieveConsoleFailures(sessionId) {
58
68
  Authorization: `Basic ${auth}`,
59
69
  },
60
70
  });
61
- await assertOkResponse(response, "console logs");
71
+ await (0, utils_js_1.assertOkResponse)(response, "console logs");
62
72
  const logText = await response.text();
63
73
  return filterConsoleFailures(logText);
64
74
  }
65
75
  // FILTER: session logs
66
- export function filterSessionFailures(logText) {
76
+ function filterSessionFailures(logText) {
67
77
  const keywords = [
68
78
  "error",
69
79
  "fail",
@@ -77,10 +87,10 @@ export function filterSessionFailures(logText) {
77
87
  "console.error",
78
88
  "stderr",
79
89
  ];
80
- return filterLinesByKeywords(logText, keywords);
90
+ return (0, utils_js_1.filterLinesByKeywords)(logText, keywords);
81
91
  }
82
92
  // FILTER: console logs
83
- export function filterConsoleFailures(logText) {
93
+ function filterConsoleFailures(logText) {
84
94
  const keywords = [
85
95
  "failed to load resource",
86
96
  "uncaught",
@@ -93,5 +103,5 @@ export function filterConsoleFailures(logText) {
93
103
  "undefined",
94
104
  "error:",
95
105
  ];
96
- return filterLinesByKeywords(logText, keywords);
106
+ return (0, utils_js_1.filterLinesByKeywords)(logText, keywords);
97
107
  }
@@ -1,36 +1,43 @@
1
- import { z } from "zod";
2
- import logger from "../logger.js";
3
- import { retrieveNetworkFailures, retrieveSessionFailures, retrieveConsoleFailures, } from "./failurelogs-utils/automate.js";
4
- import { retrieveDeviceLogs, retrieveAppiumLogs, retrieveCrashLogs, } from "./failurelogs-utils/app-automate.js";
5
- import { trackMCP } from "../lib/instrumentation.js";
6
- import { AppAutomateLogType, AutomateLogType, SessionType, } from "../lib/constants.js";
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getFailureLogs = getFailureLogs;
7
+ exports.default = registerGetFailureLogs;
8
+ const zod_1 = require("zod");
9
+ const logger_js_1 = __importDefault(require("../logger.js"));
10
+ const automate_js_1 = require("./failurelogs-utils/automate.js");
11
+ const app_automate_js_1 = require("./failurelogs-utils/app-automate.js");
12
+ const instrumentation_js_1 = require("../lib/instrumentation.js");
13
+ const constants_js_1 = require("../lib/constants.js");
7
14
  // Main log fetcher function
8
- export async function getFailureLogs(args) {
15
+ async function getFailureLogs(args) {
9
16
  const results = [];
10
17
  const errors = [];
11
18
  let validLogTypes = [];
12
19
  if (!args.sessionId) {
13
20
  throw new Error("Session ID is required");
14
21
  }
15
- if (args.sessionType === SessionType.AppAutomate && !args.buildId) {
22
+ if (args.sessionType === constants_js_1.SessionType.AppAutomate && !args.buildId) {
16
23
  throw new Error("Build ID is required for app-automate sessions");
17
24
  }
18
25
  // Validate log types and collect errors
19
26
  validLogTypes = args.logTypes.filter((logType) => {
20
- const isAutomate = Object.values(AutomateLogType).includes(logType);
21
- const isAppAutomate = Object.values(AppAutomateLogType).includes(logType);
27
+ const isAutomate = Object.values(constants_js_1.AutomateLogType).includes(logType);
28
+ const isAppAutomate = Object.values(constants_js_1.AppAutomateLogType).includes(logType);
22
29
  if (!isAutomate && !isAppAutomate) {
23
30
  errors.push(`Invalid log type '${logType}'. Valid log types are: ${[
24
- ...Object.values(AutomateLogType),
25
- ...Object.values(AppAutomateLogType),
31
+ ...Object.values(constants_js_1.AutomateLogType),
32
+ ...Object.values(constants_js_1.AppAutomateLogType),
26
33
  ].join(", ")}`);
27
34
  return false;
28
35
  }
29
- if (args.sessionType === SessionType.Automate && !isAutomate) {
36
+ if (args.sessionType === constants_js_1.SessionType.Automate && !isAutomate) {
30
37
  errors.push(`Log type '${logType}' is only available for app-automate sessions.`);
31
38
  return false;
32
39
  }
33
- if (args.sessionType === SessionType.AppAutomate && !isAppAutomate) {
40
+ if (args.sessionType === constants_js_1.SessionType.AppAutomate && !isAppAutomate) {
34
41
  errors.push(`Log type '${logType}' is only available for automate sessions.`);
35
42
  return false;
36
43
  }
@@ -51,8 +58,8 @@ export async function getFailureLogs(args) {
51
58
  try {
52
59
  for (const logType of validLogTypes) {
53
60
  switch (logType) {
54
- case AutomateLogType.NetworkLogs: {
55
- const logs = await retrieveNetworkFailures(args.sessionId);
61
+ case constants_js_1.AutomateLogType.NetworkLogs: {
62
+ const logs = await (0, automate_js_1.retrieveNetworkFailures)(args.sessionId);
56
63
  results.push({
57
64
  type: "text",
58
65
  text: logs.length > 0
@@ -61,8 +68,8 @@ export async function getFailureLogs(args) {
61
68
  });
62
69
  break;
63
70
  }
64
- case AutomateLogType.SessionLogs: {
65
- const logs = await retrieveSessionFailures(args.sessionId);
71
+ case constants_js_1.AutomateLogType.SessionLogs: {
72
+ const logs = await (0, automate_js_1.retrieveSessionFailures)(args.sessionId);
66
73
  results.push({
67
74
  type: "text",
68
75
  text: logs.length > 0
@@ -71,8 +78,8 @@ export async function getFailureLogs(args) {
71
78
  });
72
79
  break;
73
80
  }
74
- case AutomateLogType.ConsoleLogs: {
75
- const logs = await retrieveConsoleFailures(args.sessionId);
81
+ case constants_js_1.AutomateLogType.ConsoleLogs: {
82
+ const logs = await (0, automate_js_1.retrieveConsoleFailures)(args.sessionId);
76
83
  results.push({
77
84
  type: "text",
78
85
  text: logs.length > 0
@@ -81,8 +88,8 @@ export async function getFailureLogs(args) {
81
88
  });
82
89
  break;
83
90
  }
84
- case AppAutomateLogType.DeviceLogs: {
85
- const logs = await retrieveDeviceLogs(args.sessionId, args.buildId);
91
+ case constants_js_1.AppAutomateLogType.DeviceLogs: {
92
+ const logs = await (0, app_automate_js_1.retrieveDeviceLogs)(args.sessionId, args.buildId);
86
93
  results.push({
87
94
  type: "text",
88
95
  text: logs.length > 0
@@ -91,8 +98,8 @@ export async function getFailureLogs(args) {
91
98
  });
92
99
  break;
93
100
  }
94
- case AppAutomateLogType.AppiumLogs: {
95
- const logs = await retrieveAppiumLogs(args.sessionId, args.buildId);
101
+ case constants_js_1.AppAutomateLogType.AppiumLogs: {
102
+ const logs = await (0, app_automate_js_1.retrieveAppiumLogs)(args.sessionId, args.buildId);
96
103
  results.push({
97
104
  type: "text",
98
105
  text: logs.length > 0
@@ -101,8 +108,8 @@ export async function getFailureLogs(args) {
101
108
  });
102
109
  break;
103
110
  }
104
- case AppAutomateLogType.CrashLogs: {
105
- const logs = await retrieveCrashLogs(args.sessionId, args.buildId);
111
+ case constants_js_1.AppAutomateLogType.CrashLogs: {
112
+ const logs = await (0, app_automate_js_1.retrieveCrashLogs)(args.sessionId, args.buildId);
106
113
  results.push({
107
114
  type: "text",
108
115
  text: logs.length > 0
@@ -127,37 +134,37 @@ export async function getFailureLogs(args) {
127
134
  return { content: results };
128
135
  }
129
136
  // Register tool with the MCP server
130
- export default function registerGetFailureLogs(server) {
137
+ function registerGetFailureLogs(server) {
131
138
  server.tool("getFailureLogs", "Fetch various types of logs from a BrowserStack session. Supports both automate and app-automate sessions.", {
132
- sessionType: z
133
- .enum([SessionType.Automate, SessionType.AppAutomate])
139
+ sessionType: zod_1.z
140
+ .enum([constants_js_1.SessionType.Automate, constants_js_1.SessionType.AppAutomate])
134
141
  .describe("Type of BrowserStack session. Must be explicitly provided by the user."),
135
- sessionId: z
142
+ sessionId: zod_1.z
136
143
  .string()
137
144
  .describe("The BrowserStack session ID. Must be explicitly provided by the user."),
138
- buildId: z
145
+ buildId: zod_1.z
139
146
  .string()
140
147
  .optional()
141
148
  .describe("Required only when sessionType is 'app-automate'. If sessionType is 'app-automate', always ask the user to provide the build ID before proceeding."),
142
- logTypes: z
143
- .array(z.enum([
144
- AutomateLogType.NetworkLogs,
145
- AutomateLogType.SessionLogs,
146
- AutomateLogType.ConsoleLogs,
147
- AppAutomateLogType.DeviceLogs,
148
- AppAutomateLogType.AppiumLogs,
149
- AppAutomateLogType.CrashLogs,
149
+ logTypes: zod_1.z
150
+ .array(zod_1.z.enum([
151
+ constants_js_1.AutomateLogType.NetworkLogs,
152
+ constants_js_1.AutomateLogType.SessionLogs,
153
+ constants_js_1.AutomateLogType.ConsoleLogs,
154
+ constants_js_1.AppAutomateLogType.DeviceLogs,
155
+ constants_js_1.AppAutomateLogType.AppiumLogs,
156
+ constants_js_1.AppAutomateLogType.CrashLogs,
150
157
  ]))
151
158
  .describe("The types of logs to fetch."),
152
159
  }, async (args) => {
153
160
  try {
154
- trackMCP("getFailureLogs", server.server.getClientVersion());
161
+ (0, instrumentation_js_1.trackMCP)("getFailureLogs", server.server.getClientVersion());
155
162
  return await getFailureLogs(args);
156
163
  }
157
164
  catch (error) {
158
165
  const message = error instanceof Error ? error.message : String(error);
159
- trackMCP("getFailureLogs", server.server.getClientVersion(), error);
160
- logger.error("Failed to fetch logs: %s", message);
166
+ (0, instrumentation_js_1.trackMCP)("getFailureLogs", server.server.getClientVersion(), error);
167
+ logger_js_1.default.error("Failed to fetch logs: %s", message);
161
168
  return {
162
169
  content: [
163
170
  {
@@ -1,8 +1,11 @@
1
- import { getDevicesAndBrowsers, BrowserStackProducts, } from "../../lib/device-cache.js";
2
- import { resolveVersion } from "./version-resolver.js";
3
- import { customFuzzySearch } from "../../lib/fuzzy.js";
4
- export async function filterDesktop(args) {
5
- const data = await getDevicesAndBrowsers(BrowserStackProducts.LIVE);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.filterDesktop = filterDesktop;
4
+ const device_cache_js_1 = require("../../lib/device-cache.js");
5
+ const version_resolver_js_1 = require("./version-resolver.js");
6
+ const fuzzy_js_1 = require("../../lib/fuzzy.js");
7
+ async function filterDesktop(args) {
8
+ const data = await (0, device_cache_js_1.getDevicesAndBrowsers)(device_cache_js_1.BrowserStackProducts.LIVE);
6
9
  const allEntries = getAllDesktopEntries(data);
7
10
  // Filter OS
8
11
  const osList = filterByOS(allEntries, args.os);
@@ -15,7 +18,7 @@ export async function filterDesktop(args) {
15
18
  const entriesForOS = filterByOSVersion(browserList, chosenOS);
16
19
  // Resolve browser version
17
20
  const browserVersions = entriesForOS.map((e) => e.browser_version);
18
- const chosenBrowserVersion = resolveVersion(args.browserVersion, browserVersions);
21
+ const chosenBrowserVersion = (0, version_resolver_js_1.resolveVersion)(args.browserVersion, browserVersions);
19
22
  // Find final entry
20
23
  const finalEntry = entriesForOS.find((e) => e.browser_version === chosenBrowserVersion);
21
24
  if (!finalEntry) {
@@ -54,7 +57,7 @@ function resolveOSVersion(os, requestedVersion, availableVersions) {
54
57
  }
55
58
  else {
56
59
  // For Windows, use semantic versioning
57
- return resolveVersion(requestedVersion, availableVersions);
60
+ return (0, version_resolver_js_1.resolveVersion)(requestedVersion, availableVersions);
58
61
  }
59
62
  }
60
63
  function resolveMacOSVersion(requested, available) {
@@ -66,7 +69,7 @@ function resolveMacOSVersion(requested, available) {
66
69
  }
67
70
  else {
68
71
  // Try fuzzy matching
69
- const fuzzy = customFuzzySearch(available.map((v) => ({ os_version: v })), ["os_version"], requested, 1);
72
+ const fuzzy = (0, fuzzy_js_1.customFuzzySearch)(available.map((v) => ({ os_version: v })), ["os_version"], requested, 1);
70
73
  const matched = fuzzy.length ? fuzzy[0].os_version : requested;
71
74
  // Fallback if not valid
72
75
  return available.includes(matched) ? matched : available[0];
@@ -1,6 +1,9 @@
1
- import { getDevicesAndBrowsers, BrowserStackProducts, } from "../../lib/device-cache.js";
2
- import { resolveVersion } from "./version-resolver.js";
3
- import { customFuzzySearch } from "../../lib/fuzzy.js";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.filterMobile = filterMobile;
4
+ const device_cache_js_1 = require("../../lib/device-cache.js");
5
+ const version_resolver_js_1 = require("./version-resolver.js");
6
+ const fuzzy_js_1 = require("../../lib/fuzzy.js");
4
7
  // Extract all mobile entries from the data
5
8
  function getAllMobileEntries(data) {
6
9
  return data.mobile.flatMap((grp) => grp.devices.map((d) => ({
@@ -19,7 +22,7 @@ function filterByOS(entries, os) {
19
22
  }
20
23
  // Find matching device with exact match validation
21
24
  function findMatchingDevice(entries, deviceName, os) {
22
- const matches = customFuzzySearch(entries, ["display_name"], deviceName, 5);
25
+ const matches = (0, fuzzy_js_1.customFuzzySearch)(entries, ["display_name"], deviceName, 5);
23
26
  if (!matches.length)
24
27
  throw new Error(`No devices matching "${deviceName}" on ${os}.`);
25
28
  const exact = matches.find((m) => m.display_name.toLowerCase() === deviceName.toLowerCase());
@@ -35,7 +38,7 @@ function findMatchingDevice(entries, deviceName, os) {
35
38
  // Find the appropriate OS version
36
39
  function findOSVersion(entries, requestedVersion) {
37
40
  const versions = entries.map((d) => d.os_version);
38
- const chosenVersion = resolveVersion(requestedVersion, versions);
41
+ const chosenVersion = (0, version_resolver_js_1.resolveVersion)(requestedVersion, versions);
39
42
  const result = entries.filter((d) => d.os_version === chosenVersion);
40
43
  if (!result.length)
41
44
  throw new Error(`No entry for OS version "${requestedVersion}".`);
@@ -50,8 +53,8 @@ function createVersionNote(requestedVersion, actualVersion) {
50
53
  }
51
54
  return "";
52
55
  }
53
- export async function filterMobile(args) {
54
- const data = await getDevicesAndBrowsers(BrowserStackProducts.LIVE);
56
+ async function filterMobile(args) {
57
+ const data = await (0, device_cache_js_1.getDevicesAndBrowsers)(device_cache_js_1.BrowserStackProducts.LIVE);
55
58
  const allEntries = getAllMobileEntries(data);
56
59
  const osCandidates = filterByOS(allEntries, args.os);
57
60
  const deviceCandidates = findMatchingDevice(osCandidates, args.device, args.os);
@@ -1,31 +1,37 @@
1
- import logger from "../../logger.js";
2
- import childProcess from "child_process";
3
- import { filterDesktop } from "./desktop-filter.js";
4
- import { filterMobile } from "./mobile-filter.js";
5
- import { PlatformType, } from "./types.js";
6
- import { isLocalURL, ensureLocalBinarySetup, killExistingBrowserStackLocalProcesses, } from "../../lib/local.js";
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.startBrowserSession = startBrowserSession;
7
+ const logger_js_1 = __importDefault(require("../../logger.js"));
8
+ const child_process_1 = __importDefault(require("child_process"));
9
+ const desktop_filter_js_1 = require("./desktop-filter.js");
10
+ const mobile_filter_js_1 = require("./mobile-filter.js");
11
+ const types_js_1 = require("./types.js");
12
+ const local_js_1 = require("../../lib/local.js");
7
13
  /**
8
14
  * Prepares local tunnel setup based on URL type
9
15
  */
10
16
  async function prepareLocalTunnel(url) {
11
- const isLocal = isLocalURL(url);
17
+ const isLocal = (0, local_js_1.isLocalURL)(url);
12
18
  if (isLocal) {
13
- await ensureLocalBinarySetup();
19
+ await (0, local_js_1.ensureLocalBinarySetup)();
14
20
  }
15
21
  else {
16
- await killExistingBrowserStackLocalProcesses();
22
+ await (0, local_js_1.killExistingBrowserStackLocalProcesses)();
17
23
  }
18
24
  return isLocal;
19
25
  }
20
26
  /**
21
27
  * Entrypoint: detects platformType & delegates.
22
28
  */
23
- export async function startBrowserSession(args) {
24
- const entry = args.platformType === PlatformType.DESKTOP
25
- ? await filterDesktop(args)
26
- : await filterMobile(args);
29
+ async function startBrowserSession(args) {
30
+ const entry = args.platformType === types_js_1.PlatformType.DESKTOP
31
+ ? await (0, desktop_filter_js_1.filterDesktop)(args)
32
+ : await (0, mobile_filter_js_1.filterMobile)(args);
27
33
  const isLocal = await prepareLocalTunnel(args.url);
28
- const url = args.platformType === PlatformType.DESKTOP
34
+ const url = args.platformType === types_js_1.PlatformType.DESKTOP
29
35
  ? buildDesktopUrl(args, entry, isLocal)
30
36
  : buildMobileUrl(args, entry, isLocal);
31
37
  openBrowser(url);
@@ -75,14 +81,14 @@ function openBrowser(launchUrl) {
75
81
  ? ["cmd", "/c", "start", launchUrl]
76
82
  : ["xdg-open", launchUrl];
77
83
  // nosemgrep:javascript.lang.security.detect-child-process.detect-child-process
78
- const child = childProcess.spawn(command[0], command.slice(1), {
84
+ const child = child_process_1.default.spawn(command[0], command.slice(1), {
79
85
  stdio: "ignore",
80
86
  detached: true,
81
87
  });
82
- child.on("error", (err) => logger.error(`Failed to open browser: ${err}. URL: ${launchUrl}`));
88
+ child.on("error", (err) => logger_js_1.default.error(`Failed to open browser: ${err}. URL: ${launchUrl}`));
83
89
  child.unref();
84
90
  }
85
91
  catch (err) {
86
- logger.error(`Failed to launch browser: ${err}. URL: ${launchUrl}`);
92
+ logger_js_1.default.error(`Failed to launch browser: ${err}. URL: ${launchUrl}`);
87
93
  }
88
94
  }
@@ -1,5 +1,8 @@
1
- export var PlatformType;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PlatformType = void 0;
4
+ var PlatformType;
2
5
  (function (PlatformType) {
3
6
  PlatformType["DESKTOP"] = "desktop";
4
7
  PlatformType["MOBILE"] = "mobile";
5
- })(PlatformType || (PlatformType = {}));
8
+ })(PlatformType || (exports.PlatformType = PlatformType = {}));
@@ -1,9 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveVersion = resolveVersion;
1
4
  /**
2
5
  * If req === "latest" or "oldest", returns max/min numeric (or lex)
3
6
  * Else if exact match, returns that
4
7
  * Else picks the numerically closest (or first)
5
8
  */
6
- export function resolveVersion(requested, available) {
9
+ function resolveVersion(requested, available) {
7
10
  // strip duplicates & sort
8
11
  const uniq = Array.from(new Set(available));
9
12
  // pick min/max