testdriverai 7.5.26 → 7.6.0-test.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.
@@ -9,6 +9,7 @@ import { setTestRunInfo } from "./shared-test-state.mjs";
9
9
 
10
10
  // Use createRequire to import CommonJS modules without esbuild processing
11
11
  const require = createRequire(import.meta.url);
12
+ const channelConfig = require("../channel.json");
12
13
 
13
14
  // Import Sentry for error reporting
14
15
  const Sentry = require("@sentry/node");
@@ -763,7 +764,7 @@ export default function testDriverPlugin(options = {}) {
763
764
  pluginState.apiRoot =
764
765
  options.apiRoot ||
765
766
  process.env.TD_API_ROOT ||
766
- "https://api.testdriver.ai";
767
+ channelConfig.channels[channelConfig.active];
767
768
  pluginState.ciProvider = detectCI();
768
769
  pluginState.gitInfo = getGitInfo();
769
770
 
@@ -822,7 +823,7 @@ class TestDriverReporter {
822
823
  pluginState.apiRoot =
823
824
  this.options.apiRoot ||
824
825
  process.env.TD_API_ROOT ||
825
- "https://api.testdriver.ai";
826
+ channelConfig.channels[channelConfig.active];
826
827
  logger.debug("API key from options:", !!this.options.apiKey);
827
828
  logger.debug("API key from env (at onInit):", !!process.env.TD_API_KEY);
828
829
  logger.debug("API root from options:", this.options.apiRoot);
@@ -1258,6 +1259,26 @@ function getConsoleUrl(apiRoot) {
1258
1259
  return `http://localhost:3001`;
1259
1260
  }
1260
1261
 
1262
+ // Render PR previews: map API service to Web service
1263
+ // canary-api-pr-123.onrender.com -> canary-web-pr-123.onrender.com
1264
+ // testdriver-api-i4m4-pr-123.onrender.com -> web-i4m4-pr-123.onrender.com
1265
+ const renderPrMatch = apiRoot.match(/https:\/\/([\w-]+)-api(-[\w]+)?(-pr-\d+)?\.onrender\.com/);
1266
+ if (renderPrMatch) {
1267
+ const [, prefix, suffix, prSuffix] = renderPrMatch;
1268
+ // Map API naming to Web naming:
1269
+ // canary-api -> canary-web
1270
+ // testdriver-api-i4m4 -> web-i4m4
1271
+ let webPrefix;
1272
+ if (prefix === 'testdriver' && suffix) {
1273
+ // testdriver-api-i4m4 -> web-i4m4
1274
+ webPrefix = 'web' + suffix;
1275
+ } else {
1276
+ // canary-api -> canary-web
1277
+ webPrefix = prefix + '-web';
1278
+ }
1279
+ return `https://${webPrefix}${prSuffix || ''}.onrender.com`;
1280
+ }
1281
+
1261
1282
  // Other tunnels or unknown hosts: return as-is
1262
1283
  return apiRoot;
1263
1284
  }
@@ -80,8 +80,9 @@ class Dashcam {
80
80
  * @private
81
81
  */
82
82
  _getApiRoot() {
83
+ const channelConfig = require("../../channel.json");
83
84
  return (
84
- this.client.config?.TD_API_ROOT || "https://api.testdriver.ai"
85
+ this.client.config?.TD_API_ROOT || channelConfig.channels[channelConfig.active]
85
86
  );
86
87
  }
87
88
 
@@ -91,7 +92,7 @@ class Dashcam {
91
92
  * @param {string} apiRoot - The API root URL
92
93
  * @returns {string} The corresponding console URL
93
94
  */
94
- static getConsoleUrl(apiRoot = "https://api.testdriver.ai") {
95
+ static getConsoleUrl(apiRoot = (() => { const c = require("../../channel.json"); return c.channels[c.active]; })()) {
95
96
  // Allow explicit override via env (e.g. VITE_DOMAIN from .env)
96
97
  if (process.env.VITE_DOMAIN) return process.env.VITE_DOMAIN;
97
98
 
@@ -110,6 +111,26 @@ class Dashcam {
110
111
  return "http://localhost:3001";
111
112
  }
112
113
 
114
+ // Render PR previews: map API service to Web service
115
+ // canary-api-pr-123.onrender.com -> canary-web-pr-123.onrender.com
116
+ // testdriver-api-i4m4-pr-123.onrender.com -> web-i4m4-pr-123.onrender.com
117
+ const renderPrMatch = apiRoot.match(/https:\/\/([\w-]+)-api(-[\w]+)?(-pr-\d+)?\.onrender\.com/);
118
+ if (renderPrMatch) {
119
+ const [, prefix, suffix, prSuffix] = renderPrMatch;
120
+ // Map API naming to Web naming:
121
+ // canary-api -> canary-web
122
+ // testdriver-api-i4m4 -> web-i4m4
123
+ let webPrefix;
124
+ if (prefix === 'testdriver' && suffix) {
125
+ // testdriver-api-i4m4 -> web-i4m4
126
+ webPrefix = 'web' + suffix;
127
+ } else {
128
+ // canary-api -> canary-web
129
+ webPrefix = prefix + '-web';
130
+ }
131
+ return `https://${webPrefix}${prSuffix || ''}.onrender.com`;
132
+ }
133
+
113
134
  // Cloudflare tunnels, custom domains, etc.: the web console is served
114
135
  // from the same origin as the API, so return apiRoot as-is.
115
136
  return apiRoot;
@@ -337,40 +337,80 @@ jobs:
337
337
  progress("⊘ GitHub workflow already exists");
338
338
  }
339
339
 
340
- // 6. Create VSCode MCP config
341
- const vscodeDir = path.join(targetDir, ".vscode");
342
- if (!fs.existsSync(vscodeDir)) {
343
- fs.mkdirSync(vscodeDir, { recursive: true });
344
- }
340
+ // 6. Setup MCP configuration
341
+ // When triggered from VS Code extension, create .vscode/mcp.json silently
342
+ // When triggered from CLI, use interactive add-mcp for user to select their MCP client
343
+ const isVscodeInit = process.env.TD_INIT_SOURCE === "vscode";
344
+
345
+ if (isVscodeInit) {
346
+ // VS Code extension: create .vscode/mcp.json directly
347
+ const vscodeDir = path.join(targetDir, ".vscode");
348
+ if (!fs.existsSync(vscodeDir)) {
349
+ fs.mkdirSync(vscodeDir, { recursive: true });
350
+ }
345
351
 
346
- const mcpConfigFile = path.join(vscodeDir, "mcp.json");
347
- if (!fs.existsSync(mcpConfigFile)) {
348
- const mcpConfig = {
349
- inputs: [
350
- {
351
- type: "promptString",
352
- id: "testdriver-api-key",
353
- description: "TestDriver API Key From https://console.testdriver.ai/team",
354
- password: true,
355
- },
356
- ],
357
- servers: {
358
- testdriver: {
359
- command: "npx",
360
- args: ["-p", "testdriverai", "testdriverai-mcp"],
361
- env: {
362
- TD_API_KEY: "${input:testdriver-api-key}",
352
+ const mcpConfigFile = path.join(vscodeDir, "mcp.json");
353
+ if (!fs.existsSync(mcpConfigFile)) {
354
+ const mcpConfig = {
355
+ inputs: [
356
+ {
357
+ type: "promptString",
358
+ id: "testdriver-api-key",
359
+ description: "TestDriver API Key From https://console.testdriver.ai/team",
360
+ password: true,
361
+ },
362
+ ],
363
+ servers: {
364
+ testdriver: {
365
+ command: "npx",
366
+ args: ["-p", "testdriverai", "testdriverai-mcp"],
367
+ env: {
368
+ TD_API_KEY: "${input:testdriver-api-key}",
369
+ },
363
370
  },
364
371
  },
365
- },
366
- };
367
- fs.writeFileSync(mcpConfigFile, JSON.stringify(mcpConfig, null, 2) + "\n");
368
- progress("✓ Created MCP config: .vscode/mcp.json");
372
+ };
373
+ fs.writeFileSync(mcpConfigFile, JSON.stringify(mcpConfig, null, 2) + "\n");
374
+ progress("✓ Created MCP config: .vscode/mcp.json");
375
+ } else {
376
+ progress("⊘ MCP config already exists");
377
+ }
369
378
  } else {
370
- progress("⊘ MCP config already exists");
379
+ // CLI: use add-mcp for interactive MCP client selection
380
+ progress("🔧 Setting up MCP integration...");
381
+ try {
382
+ const addMcpResult = require("child_process").spawnSync(
383
+ "npx",
384
+ [
385
+ "add-mcp",
386
+ "testdriver",
387
+ "--command",
388
+ "npx -p testdriverai testdriverai-mcp",
389
+ "--env",
390
+ "TD_API_KEY",
391
+ ],
392
+ {
393
+ cwd: targetDir,
394
+ stdio: "inherit", // Pass through stdin/stdout for interactive prompts
395
+ shell: process.platform === "win32",
396
+ }
397
+ );
398
+
399
+ if (addMcpResult.status === 0) {
400
+ progress("✓ MCP configured via add-mcp");
401
+ } else if (addMcpResult.status !== null) {
402
+ progress("⚠ MCP setup skipped or failed - you can run 'npx add-mcp testdriver' later");
403
+ }
404
+ } catch (err) {
405
+ progress("⚠ Could not run add-mcp - you can run 'npx add-mcp testdriver' later");
406
+ }
371
407
  }
372
408
 
373
409
  // 7. Create VSCode extensions recommendations
410
+ const vscodeDir = path.join(targetDir, ".vscode");
411
+ if (!fs.existsSync(vscodeDir)) {
412
+ fs.mkdirSync(vscodeDir, { recursive: true });
413
+ }
374
414
  const extensionsFile = path.join(vscodeDir, "extensions.json");
375
415
  if (!fs.existsSync(extensionsFile)) {
376
416
  const extensionsConfig = {
@@ -22,6 +22,7 @@ import TestDriverSDK from "../../sdk.js";
22
22
 
23
23
  // Use createRequire to import CommonJS modules
24
24
  const require = createRequire(import.meta.url);
25
+ const channelConfig = require("../../channel.json");
25
26
 
26
27
  /**
27
28
  * Minimum required Vitest major version
@@ -255,7 +256,7 @@ async function uploadLogsToReplay(client, dashcamUrl) {
255
256
  }
256
257
 
257
258
  // Use the SDK's configured API root (matches what the SDK uses for all other API calls)
258
- const apiRoot = client.config?.TD_API_ROOT || process.env.TD_API_ROOT || "https://api.testdriver.ai";
259
+ const apiRoot = client.config?.TD_API_ROOT || process.env.TD_API_ROOT || channelConfig.channels[channelConfig.active];
259
260
 
260
261
  console.log(`[TestDriver] Uploading logs for replay ${replayId} to ${apiRoot}...`);
261
262
 
@@ -11,9 +11,19 @@ MCP server that enables AI agents to iteratively build TestDriver tests with vis
11
11
 
12
12
  ## Installation
13
13
 
14
- ### Via npx (Recommended)
14
+ ### Quick Install (Recommended)
15
15
 
16
- No installation needed! Just configure your MCP client to use npx:
16
+ Use `add-mcp` to automatically configure TestDriver for your MCP client:
17
+
18
+ ```bash
19
+ npx add-mcp testdriver
20
+ ```
21
+
22
+ This will prompt you to select your MCP client (VS Code, Cursor, Claude Desktop, etc.) and configure it automatically.
23
+
24
+ ### Manual Configuration
25
+
26
+ If you prefer to configure manually, add the following to your MCP config file:
17
27
 
18
28
  ```json
19
29
  {
@@ -141,7 +141,7 @@ export function generateActionCode(action, args, result) {
141
141
  return `const assertResult = await testdriver.assert("${escapeString(assertion)}");\nexpect(assertResult).toBeTruthy();`;
142
142
  }
143
143
  case "exec": {
144
- const language = args.language || "js";
144
+ const language = args.language || "sh";
145
145
  const code = args.code;
146
146
  const timeout = args.timeout;
147
147
  if (code.includes("\n")) {
@@ -687,6 +687,7 @@ registerAppTool(server, "find", {
687
687
  const duration = Date.now() - startTime;
688
688
  // Store cropped image for resource serving (instead of inline data URL)
689
689
  let croppedImageResourceUri;
690
+ let screenshotResourceUri;
690
691
  const croppedImage = rawResponse.croppedImage;
691
692
  if (croppedImage) {
692
693
  const imageData = croppedImage.startsWith('data:')
@@ -696,6 +697,20 @@ registerAppTool(server, "find", {
696
697
  // Remove croppedImage from response to avoid context bloat
697
698
  delete rawResponse.croppedImage;
698
699
  }
700
+ else if (!found) {
701
+ // Element not found and no cropped image - capture a fresh screenshot
702
+ // so the user can see what's currently visible on screen
703
+ try {
704
+ const screenshotBase64 = await sdk.agent.system.captureScreenBase64(1, false, true);
705
+ if (screenshotBase64) {
706
+ screenshotResourceUri = storeImage(screenshotBase64, "screenshot");
707
+ logger.debug("find: Captured screenshot for not-found state");
708
+ }
709
+ }
710
+ catch (e) {
711
+ logger.warn("find: Failed to capture screenshot for not-found state", { error: String(e) });
712
+ }
713
+ }
699
714
  // Remove extractedText and pixelDiffImage from response to reduce context bloat
700
715
  delete rawResponse.extractedText;
701
716
  delete rawResponse.pixelDiffImage;
@@ -717,6 +732,7 @@ registerAppTool(server, "find", {
717
732
  element: elementInfo,
718
733
  ref: elementRef,
719
734
  croppedImageResourceUri,
735
+ screenshotResourceUri,
720
736
  duration,
721
737
  }, generatedCode);
722
738
  }
@@ -786,6 +802,7 @@ registerAppTool(server, "findall", {
786
802
  const duration = Date.now() - startTime;
787
803
  // Store cropped image for resource serving (instead of inline data URL)
788
804
  let croppedImageResourceUri;
805
+ let screenshotResourceUri;
789
806
  const croppedImage = rawResponse.croppedImage;
790
807
  if (croppedImage) {
791
808
  const imageData = croppedImage.startsWith('data:')
@@ -795,6 +812,20 @@ registerAppTool(server, "findall", {
795
812
  // Remove croppedImage from response to avoid context bloat
796
813
  delete rawResponse.croppedImage;
797
814
  }
815
+ else if (count === 0) {
816
+ // No elements found and no cropped image - capture a fresh screenshot
817
+ // so the user can see what's currently visible on screen
818
+ try {
819
+ const screenshotBase64 = await sdk.agent.system.captureScreenBase64(1, false, true);
820
+ if (screenshotBase64) {
821
+ screenshotResourceUri = storeImage(screenshotBase64, "screenshot");
822
+ logger.debug("findall: Captured screenshot for not-found state");
823
+ }
824
+ }
825
+ catch (e) {
826
+ logger.warn("findall: Failed to capture screenshot for not-found state", { error: String(e) });
827
+ }
828
+ }
798
829
  // Remove extractedText and pixelDiffImage from response to reduce context bloat
799
830
  delete rawResponse.extractedText;
800
831
  delete rawResponse.pixelDiffImage;
@@ -810,6 +841,7 @@ registerAppTool(server, "findall", {
810
841
  refs,
811
842
  elements: elementInfos,
812
843
  croppedImageResourceUri,
844
+ screenshotResourceUri,
813
845
  duration,
814
846
  }, generatedCode);
815
847
  }
@@ -1029,6 +1061,7 @@ registerAppTool(server, "find_and_click", {
1029
1061
  const duration = Date.now() - startTime;
1030
1062
  // Store cropped image (screenshot) for resource serving
1031
1063
  let croppedImageResourceUri;
1064
+ let screenshotResourceUri;
1032
1065
  const croppedImage = rawResponse.croppedImage;
1033
1066
  if (croppedImage) {
1034
1067
  const imageData = croppedImage.startsWith('data:')
@@ -1037,6 +1070,20 @@ registerAppTool(server, "find_and_click", {
1037
1070
  croppedImageResourceUri = storeImage(imageData, "screenshot");
1038
1071
  delete rawResponse.croppedImage;
1039
1072
  }
1073
+ else {
1074
+ // No cropped image - capture a fresh screenshot so the user can see
1075
+ // what's currently visible on screen when element was not found
1076
+ try {
1077
+ const screenshotBase64 = await sdk.agent.system.captureScreenBase64(1, false, true);
1078
+ if (screenshotBase64) {
1079
+ screenshotResourceUri = storeImage(screenshotBase64, "screenshot");
1080
+ logger.debug("find_and_click: Captured screenshot for not-found state");
1081
+ }
1082
+ }
1083
+ catch (e) {
1084
+ logger.warn("find_and_click: Failed to capture screenshot for not-found state", { error: String(e) });
1085
+ }
1086
+ }
1040
1087
  // Remove extractedText and pixelDiffImage from response to reduce context bloat
1041
1088
  delete rawResponse.extractedText;
1042
1089
  delete rawResponse.pixelDiffImage;
@@ -1045,6 +1092,7 @@ registerAppTool(server, "find_and_click", {
1045
1092
  action: "find_and_click",
1046
1093
  error: "Element not found",
1047
1094
  croppedImageResourceUri,
1095
+ screenshotResourceUri,
1048
1096
  duration
1049
1097
  });
1050
1098
  }
@@ -1372,9 +1420,9 @@ You can optionally provide a reference image URI to compare against a previous s
1372
1420
  });
1373
1421
  // Exec
1374
1422
  server.registerTool("exec", {
1375
- description: "Execute code in the sandbox (JavaScript, shell, or PowerShell)",
1423
+ description: "Execute shell or PowerShell commands in the sandbox",
1376
1424
  inputSchema: z.object({
1377
- language: z.enum(["js", "sh", "pwsh"]).default("js"),
1425
+ language: z.enum(["sh", "pwsh"]).default("sh"),
1378
1426
  code: z.string().describe("Code to execute"),
1379
1427
  timeout: z.number().default(30000).describe("Timeout in ms"),
1380
1428
  }),
@@ -161,7 +161,7 @@ export function generateActionCode(
161
161
  }
162
162
 
163
163
  case "exec": {
164
- const language = (args.language as string) || "js";
164
+ const language = (args.language as string) || "sh";
165
165
  const code = args.code as string;
166
166
  const timeout = args.timeout as number | undefined;
167
167
 
@@ -867,6 +867,7 @@ registerAppTool(
867
867
 
868
868
  // Store cropped image for resource serving (instead of inline data URL)
869
869
  let croppedImageResourceUri: string | undefined;
870
+ let screenshotResourceUri: string | undefined;
870
871
  const croppedImage = rawResponse.croppedImage;
871
872
  if (croppedImage) {
872
873
  const imageData = croppedImage.startsWith('data:')
@@ -875,6 +876,18 @@ registerAppTool(
875
876
  croppedImageResourceUri = storeImage(imageData, "cropped");
876
877
  // Remove croppedImage from response to avoid context bloat
877
878
  delete rawResponse.croppedImage;
879
+ } else if (!found) {
880
+ // Element not found and no cropped image - capture a fresh screenshot
881
+ // so the user can see what's currently visible on screen
882
+ try {
883
+ const screenshotBase64 = await sdk.agent.system.captureScreenBase64(1, false, true);
884
+ if (screenshotBase64) {
885
+ screenshotResourceUri = storeImage(screenshotBase64, "screenshot");
886
+ logger.debug("find: Captured screenshot for not-found state");
887
+ }
888
+ } catch (e) {
889
+ logger.warn("find: Failed to capture screenshot for not-found state", { error: String(e) });
890
+ }
878
891
  }
879
892
 
880
893
  // Remove extractedText and pixelDiffImage from response to reduce context bloat
@@ -904,6 +917,7 @@ registerAppTool(
904
917
  element: elementInfo,
905
918
  ref: elementRef,
906
919
  croppedImageResourceUri,
920
+ screenshotResourceUri,
907
921
  duration,
908
922
  },
909
923
  generatedCode
@@ -988,6 +1002,7 @@ registerAppTool(
988
1002
 
989
1003
  // Store cropped image for resource serving (instead of inline data URL)
990
1004
  let croppedImageResourceUri: string | undefined;
1005
+ let screenshotResourceUri: string | undefined;
991
1006
  const croppedImage = rawResponse.croppedImage;
992
1007
  if (croppedImage) {
993
1008
  const imageData = croppedImage.startsWith('data:')
@@ -996,6 +1011,18 @@ registerAppTool(
996
1011
  croppedImageResourceUri = storeImage(imageData, "cropped");
997
1012
  // Remove croppedImage from response to avoid context bloat
998
1013
  delete rawResponse.croppedImage;
1014
+ } else if (count === 0) {
1015
+ // No elements found and no cropped image - capture a fresh screenshot
1016
+ // so the user can see what's currently visible on screen
1017
+ try {
1018
+ const screenshotBase64 = await sdk.agent.system.captureScreenBase64(1, false, true);
1019
+ if (screenshotBase64) {
1020
+ screenshotResourceUri = storeImage(screenshotBase64, "screenshot");
1021
+ logger.debug("findall: Captured screenshot for not-found state");
1022
+ }
1023
+ } catch (e) {
1024
+ logger.warn("findall: Failed to capture screenshot for not-found state", { error: String(e) });
1025
+ }
999
1026
  }
1000
1027
 
1001
1028
  // Remove extractedText and pixelDiffImage from response to reduce context bloat
@@ -1019,6 +1046,7 @@ registerAppTool(
1019
1046
  refs,
1020
1047
  elements: elementInfos,
1021
1048
  croppedImageResourceUri,
1049
+ screenshotResourceUri,
1022
1050
  duration,
1023
1051
  },
1024
1052
  generatedCode
@@ -1317,6 +1345,7 @@ registerAppTool(
1317
1345
 
1318
1346
  // Store cropped image (screenshot) for resource serving
1319
1347
  let croppedImageResourceUri: string | undefined;
1348
+ let screenshotResourceUri: string | undefined;
1320
1349
  const croppedImage = rawResponse.croppedImage;
1321
1350
  if (croppedImage) {
1322
1351
  const imageData = croppedImage.startsWith('data:')
@@ -1324,6 +1353,18 @@ registerAppTool(
1324
1353
  : croppedImage;
1325
1354
  croppedImageResourceUri = storeImage(imageData, "screenshot");
1326
1355
  delete rawResponse.croppedImage;
1356
+ } else {
1357
+ // No cropped image - capture a fresh screenshot so the user can see
1358
+ // what's currently visible on screen when element was not found
1359
+ try {
1360
+ const screenshotBase64 = await sdk.agent.system.captureScreenBase64(1, false, true);
1361
+ if (screenshotBase64) {
1362
+ screenshotResourceUri = storeImage(screenshotBase64, "screenshot");
1363
+ logger.debug("find_and_click: Captured screenshot for not-found state");
1364
+ }
1365
+ } catch (e) {
1366
+ logger.warn("find_and_click: Failed to capture screenshot for not-found state", { error: String(e) });
1367
+ }
1327
1368
  }
1328
1369
 
1329
1370
  // Remove extractedText and pixelDiffImage from response to reduce context bloat
@@ -1338,6 +1379,7 @@ registerAppTool(
1338
1379
  action: "find_and_click",
1339
1380
  error: "Element not found",
1340
1381
  croppedImageResourceUri,
1382
+ screenshotResourceUri,
1341
1383
  duration
1342
1384
  }
1343
1385
  );
@@ -1760,9 +1802,9 @@ You can optionally provide a reference image URI to compare against a previous s
1760
1802
  server.registerTool(
1761
1803
  "exec",
1762
1804
  {
1763
- description: "Execute code in the sandbox (JavaScript, shell, or PowerShell)",
1805
+ description: "Execute shell or PowerShell commands in the sandbox",
1764
1806
  inputSchema: z.object({
1765
- language: z.enum(["js", "sh", "pwsh"]).default("js"),
1807
+ language: z.enum(["sh", "pwsh"]).default("sh"),
1766
1808
  code: z.string().describe("Code to execute"),
1767
1809
  timeout: z.number().default(30000).describe("Timeout in ms"),
1768
1810
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "7.5.26",
3
+ "version": "7.6.0-test.0",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "sdk.js",
6
6
  "types": "sdk.d.ts",
@@ -47,7 +47,11 @@
47
47
  "bundle": "node build.mjs",
48
48
  "test": "mocha test/*",
49
49
  "test:sdk": "vitest run",
50
- "test:sdk:windows": "TEST_PLATFORM=windows vitest run",
50
+ "test:sdk:dev": "vitest run --project dev",
51
+ "test:sdk:staging": "vitest run --project staging",
52
+ "test:sdk:canary": "vitest run --project canary",
53
+ "test:sdk:stable": "vitest run --project stable",
54
+ "test:sdk:windows": "TD_OS=windows vitest run",
51
55
  "test:sdk:mac": "TEST_PLATFORM=mac vitest run",
52
56
  "test:sdk:linux": "TEST_PLATFORM=linux vitest run",
53
57
  "test:sdk:watch": "vitest",
package/sdk.d.ts CHANGED
@@ -13,7 +13,7 @@ export type ClickAction =
13
13
  export type ScrollDirection = "up" | "down" | "left" | "right";
14
14
  export type ScrollMethod = "keyboard" | "mouse";
15
15
  export type TextMatchMethod = "ai" | "turbo";
16
- export type ExecLanguage = "js" | "pwsh" | "sh";
16
+ export type ExecLanguage = "sh" | "pwsh";
17
17
  /**
18
18
  * Preview mode for live test visualization
19
19
  * - "browser": Opens debugger in default browser (default)
@@ -218,7 +218,7 @@ export type KeyboardKey =
218
218
  | "optionright";
219
219
 
220
220
  export interface TestDriverOptions {
221
- /** API endpoint URL (default: 'https://v6.testdriver.ai') */
221
+ /** API endpoint URL (default depends on release channel: latest → 'https://api.testdriver.ai') */
222
222
  apiRoot?: string;
223
223
  /** Sandbox resolution (default: '1366x768') */
224
224
  resolution?: string;
package/sdk.js CHANGED
@@ -1402,7 +1402,7 @@ function normalizeRedrawOptions(opts) {
1402
1402
  * @typedef {'up' | 'down' | 'left' | 'right'} ScrollDirection
1403
1403
  * @typedef {'keyboard' | 'mouse'} ScrollMethod
1404
1404
  * @typedef {'ai' | 'turbo'} TextMatchMethod
1405
- * @typedef {'js' | 'pwsh'} ExecLanguage
1405
+ * @typedef {'sh' | 'pwsh'} ExecLanguage
1406
1406
  * @typedef {'\\t' | '\n' | '\r' | ' ' | '!' | '"' | '#' | '$' | '%' | '&' | "'" | '(' | ')' | '*' | '+' | ',' | '-' | '.' | '/' | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | ':' | ';' | '<' | '=' | '>' | '?' | '@' | '[' | '\\' | ']' | '^' | '_' | '`' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' | '{' | '|' | '}' | '~' | 'accept' | 'add' | 'alt' | 'altleft' | 'altright' | 'apps' | 'backspace' | 'browserback' | 'browserfavorites' | 'browserforward' | 'browserhome' | 'browserrefresh' | 'browsersearch' | 'browserstop' | 'capslock' | 'clear' | 'convert' | 'ctrl' | 'ctrlleft' | 'ctrlright' | 'decimal' | 'del' | 'delete' | 'divide' | 'down' | 'end' | 'enter' | 'esc' | 'escape' | 'execute' | 'f1' | 'f10' | 'f11' | 'f12' | 'f13' | 'f14' | 'f15' | 'f16' | 'f17' | 'f18' | 'f19' | 'f2' | 'f20' | 'f21' | 'f22' | 'f23' | 'f24' | 'f3' | 'f4' | 'f5' | 'f6' | 'f7' | 'f8' | 'f9' | 'final' | 'fn' | 'hanguel' | 'hangul' | 'hanja' | 'help' | 'home' | 'insert' | 'junja' | 'kana' | 'kanji' | 'launchapp1' | 'launchapp2' | 'launchmail' | 'launchmediaselect' | 'left' | 'modechange' | 'multiply' | 'nexttrack' | 'nonconvert' | 'num0' | 'num1' | 'num2' | 'num3' | 'num4' | 'num5' | 'num6' | 'num7' | 'num8' | 'num9' | 'numlock' | 'pagedown' | 'pageup' | 'pause' | 'pgdn' | 'pgup' | 'playpause' | 'prevtrack' | 'print' | 'printscreen' | 'prntscrn' | 'prtsc' | 'prtscr' | 'return' | 'right' | 'scrolllock' | 'select' | 'separator' | 'shift' | 'shiftleft' | 'shiftright' | 'sleep' | 'space' | 'stop' | 'subtract' | 'tab' | 'up' | 'volumedown' | 'volumemute' | 'volumeup' | 'win' | 'winleft' | 'winright' | 'yen' | 'command' | 'option' | 'optionleft' | 'optionright'} KeyboardKey
1407
1407
  */
1408
1408
 
@@ -2864,6 +2864,9 @@ CAPTCHA_SOLVER_EOF`,
2864
2864
  sandboxId: this.instance?.instanceId,
2865
2865
  });
2866
2866
 
2867
+ // Log environment info (non-blocking, skip on stable)
2868
+ this._logEnvironmentInfo();
2869
+
2867
2870
  return this.instance;
2868
2871
  }
2869
2872
 
@@ -2892,8 +2895,10 @@ CAPTCHA_SOLVER_EOF`,
2892
2895
 
2893
2896
  // Always close the sandbox WebSocket connection to clean up resources
2894
2897
  // This ensures we don't leave orphaned connections even if connect() failed
2898
+ // Must be awaited so presence.leave() completes before we return —
2899
+ // otherwise the concurrency counter on the API stays stale.
2895
2900
  if (this.sandbox && typeof this.sandbox.close === "function") {
2896
- this.sandbox.close();
2901
+ await this.sandbox.close();
2897
2902
  }
2898
2903
 
2899
2904
  // Remove all event listeners on the emitter to release references
@@ -3801,6 +3806,46 @@ CAPTCHA_SOLVER_EOF`,
3801
3806
  * Set up logging for the SDK
3802
3807
  * @private
3803
3808
  */
3809
+ /**
3810
+ * Log environment info (version, API URL, git commit) after connect.
3811
+ * Fires asynchronously so it never blocks the test.
3812
+ * Suppressed when the API reports the "stable" channel.
3813
+ * @private
3814
+ */
3815
+ _logEnvironmentInfo() {
3816
+ const apiRoot = this.config?.TD_API_ROOT || 'unknown';
3817
+ const sdkVersion = require('./package.json').version;
3818
+ const http = apiRoot.startsWith('https') ? require('https') : require('http');
3819
+
3820
+ const url = apiRoot + '/api/entrance/version';
3821
+ const req = http.get(url, { timeout: 5000 }, (res) => {
3822
+ let data = '';
3823
+ res.on('data', (chunk) => { data += chunk; });
3824
+ res.on('end', () => {
3825
+ try {
3826
+ const info = JSON.parse(data);
3827
+ if (info.channel === 'stable') return; // don't show on stable
3828
+ const commit = info.commit || 'unknown';
3829
+ const shortCommit = commit.substring(0, 7);
3830
+ const commitUrl = commit !== 'unknown'
3831
+ ? `https://github.com/testdriverai/mono/commit/${commit}`
3832
+ : null;
3833
+ const lines = [
3834
+ '',
3835
+ ` TestDriver SDK v${sdkVersion}`,
3836
+ ` API: ${apiRoot} (${info.channel || 'unknown'} v${info.version || '?'})`,
3837
+ commitUrl
3838
+ ? ` Commit: ${shortCommit} → ${commitUrl}`
3839
+ : ` Commit: ${shortCommit}`,
3840
+ '',
3841
+ ];
3842
+ console.log(lines.join('\n'));
3843
+ } catch (_) { /* ignore parse errors */ }
3844
+ });
3845
+ });
3846
+ req.on('error', () => { /* ignore network errors */ });
3847
+ }
3848
+
3804
3849
  _setupLogging() {
3805
3850
  // Track the last fatal error message to throw on exit
3806
3851
  let lastFatalError = null;