@browserstack/mcp-server 1.1.0 → 1.1.1

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