testdriverai 6.1.10 → 6.2.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.
package/agent/index.js CHANGED
@@ -1776,15 +1776,24 @@ ${regression}
1776
1776
  return this.createNewSandbox();
1777
1777
  });
1778
1778
 
1779
- this.saveLastSandboxId(newSandbox.sandbox.instanceId);
1780
- let instance = await this.connectToSandboxDirect(
1781
- newSandbox.sandbox.instanceId,
1782
- true, // always persist by default
1783
- );
1784
- this.instance = instance;
1785
- await this.renderSandbox(instance, headless);
1779
+ console.log("New sandbox created:", newSandbox);
1780
+
1781
+ let data = {
1782
+ resolution: this.config.TD_RESOLUTION,
1783
+ url: newSandbox.url,
1784
+ };
1785
+
1786
+ const encodedData = Buffer.from(JSON.stringify(data)).toString('base64');
1787
+
1788
+ // Use the debugger URL instead of the VNC URL
1789
+ const urlToOpen = `${this.debuggerUrl}?data=${encodedData}`;
1790
+
1791
+ this.emitter.emit(events.showWindow, urlToOpen);
1792
+
1786
1793
  await this.newSession();
1787
1794
  await this.runLifecycle("provision");
1795
+
1796
+ console.log("provision run");
1788
1797
  }
1789
1798
 
1790
1799
  async start() {
@@ -1963,6 +1972,7 @@ Please check your network connection, TD_API_KEY, or the service status.`,
1963
1972
  async createNewSandbox() {
1964
1973
  const sandboxConfig = {
1965
1974
  type: "create",
1975
+ os: "linux",
1966
1976
  resolution: this.config.TD_RESOLUTION,
1967
1977
  ci: this.config.CI,
1968
1978
  };
@@ -1975,7 +1985,12 @@ Please check your network connection, TD_API_KEY, or the service status.`,
1975
1985
  sandboxConfig.instanceType = this.sandboxInstance;
1976
1986
  }
1977
1987
 
1988
+ console.log("sending create");
1989
+
1978
1990
  let instance = await this.sandbox.send(sandboxConfig);
1991
+
1992
+ console.log("instance created", instance);
1993
+
1979
1994
  return instance;
1980
1995
  }
1981
1996
 
@@ -241,17 +241,31 @@ const createCommands = (
241
241
  switch (direction) {
242
242
  case "up":
243
243
  if (method === "mouse") {
244
- await sandbox.send({ type: "scroll", amount, direction });
244
+ await sandbox.send({
245
+ os: "linux",
246
+ type: "scroll",
247
+ amount,
248
+ direction,
249
+ });
245
250
  } else {
246
- await sandbox.send({ type: "press", keys: ["pageup"] });
251
+ await sandbox.send({ os: "linux", type: "press", keys: ["pageup"] });
247
252
  }
248
253
  await redraw.wait(2500);
249
254
  break;
250
255
  case "down":
251
256
  if (method === "mouse") {
252
- await sandbox.send({ type: "scroll", amount, direction });
257
+ await sandbox.send({
258
+ os: "linux",
259
+ type: "scroll",
260
+ amount,
261
+ direction,
262
+ });
253
263
  } else {
254
- await sandbox.send({ type: "press", keys: ["pagedown"] });
264
+ await sandbox.send({
265
+ os: "linux",
266
+ type: "press",
267
+ keys: ["pagedown"],
268
+ });
255
269
  }
256
270
  await redraw.wait(2500);
257
271
  break;
@@ -298,7 +312,7 @@ const createCommands = (
298
312
  x = parseInt(x);
299
313
  y = parseInt(y);
300
314
 
301
- await sandbox.send({ type: "moveMouse", x, y });
315
+ await sandbox.send({ os: "linux", type: "moveMouse", x, y });
302
316
 
303
317
  emitter.emit(events.mouseMove, { x, y });
304
318
 
@@ -306,17 +320,21 @@ const createCommands = (
306
320
 
307
321
  if (action !== "hover") {
308
322
  if (action === "click" || action === "left-click") {
309
- await sandbox.send({ type: "leftClick" });
323
+ await sandbox.send({ os: "linux", type: "leftClick" });
310
324
  } else if (action === "right-click") {
311
- await sandbox.send({ type: "rightClick" });
325
+ await sandbox.send({ os: "linux", type: "rightClick" });
312
326
  } else if (action === "middle-click") {
313
- await sandbox.send({ type: "middleClick" });
327
+ await sandbox.send({ os: "linux", type: "middleClick" });
314
328
  } else if (action === "double-click") {
315
- await sandbox.send({ type: "doubleClick" });
329
+ await sandbox.send({ os: "linux", type: "doubleClick" });
316
330
  } else if (action === "drag-start") {
317
- await sandbox.send({ type: "mousePress", button: "left" });
331
+ await sandbox.send({ os: "linux", type: "mousePress", button: "left" });
318
332
  } else if (action === "drag-end") {
319
- await sandbox.send({ type: "mouseRelease", button: "left" });
333
+ await sandbox.send({
334
+ os: "linux",
335
+ type: "mouseRelease",
336
+ button: "left",
337
+ });
320
338
  }
321
339
 
322
340
  emitter.emit(events.mouseClick, { x, y, button, click, double });
@@ -333,7 +351,7 @@ const createCommands = (
333
351
  x = parseInt(x);
334
352
  y = parseInt(y);
335
353
 
336
- await sandbox.send({ type: "moveMouse", x, y });
354
+ await sandbox.send({ os: "linux", type: "moveMouse", x, y });
337
355
 
338
356
  await redraw.wait(2500);
339
357
 
@@ -438,12 +456,13 @@ const createCommands = (
438
456
  return true;
439
457
  },
440
458
  // type a string
459
+ os: "linux",
441
460
  type: async (string, delay = 250) => {
442
461
  await redraw.start();
443
462
 
444
463
  string = string.toString();
445
464
 
446
- await sandbox.send({ type: "write", text: string, delay });
465
+ await sandbox.send({ os: "linux", type: "write", text: string, delay });
447
466
  await redraw.wait(5000);
448
467
  return;
449
468
  },
@@ -453,7 +472,7 @@ const createCommands = (
453
472
  await redraw.start();
454
473
 
455
474
  // finally, press the keys
456
- await sandbox.send({ type: "press", keys: inputKeys });
475
+ await sandbox.send({ os: "linux", type: "press", keys: inputKeys });
457
476
 
458
477
  await redraw.wait(5000);
459
478
 
@@ -592,11 +611,15 @@ const createCommands = (
592
611
 
593
612
  if (method === "keyboard") {
594
613
  try {
595
- await sandbox.send({ type: "press", keys: ["f", "ctrl"] });
614
+ await sandbox.send({
615
+ os: "linux",
616
+ type: "press",
617
+ keys: ["f", "ctrl"],
618
+ });
596
619
  await delay(1000);
597
- await sandbox.send({ type: "write", text });
620
+ await sandbox.send({ os: "linux", type: "write", text });
598
621
  await redraw.wait(5000);
599
- await sandbox.send({ type: "press", keys: ["escape"] });
622
+ await sandbox.send({ os: "linux", type: "press", keys: ["escape"] });
600
623
  } catch {
601
624
  throw new MatchError(
602
625
  "Could not find element using browser text search",
@@ -727,6 +750,7 @@ const createCommands = (
727
750
  await redraw.start();
728
751
 
729
752
  await sandbox.send({
753
+ os: "linux",
730
754
  type: "commands.focus-application",
731
755
  name,
732
756
  });
@@ -745,22 +769,25 @@ const createCommands = (
745
769
 
746
770
  return response;
747
771
  },
748
- exec: async (language, code, timeout, silent = false) => {
772
+ exec: async (language = "pwsh", code, timeout, silent = false) => {
749
773
  emitter.emit(events.log.narration, theme.dim(`calling exec...`), true);
750
774
 
751
775
  emitter.emit(events.log.log, code);
752
776
 
753
777
  let plat = system.platform();
754
778
 
755
- if (language == "pwsh") {
779
+ if (language == "pwsh" || language == "sh") {
756
780
  let result = null;
757
781
 
758
782
  result = await sandbox.send({
783
+ os: "linux",
759
784
  type: "commands.run",
760
785
  command: code,
761
786
  timeout,
762
787
  });
763
788
 
789
+ console.log("Exec result:", result);
790
+
764
791
  if (result.out && result.out.returncode !== 0) {
765
792
  throw new MatchError(
766
793
  `Command failed with exit code ${result.out.returncode}: ${result.out.stderr}`,
@@ -69,6 +69,7 @@ const createRedraw = (emitter, system, sandbox) => {
69
69
  async function updateNetwork() {
70
70
  if (sandbox && sandbox.instanceSocketConnected) {
71
71
  let network = await sandbox.send({
72
+ os: "linux",
72
73
  type: "system.network",
73
74
  });
74
75
  parseNetworkStats(
@@ -51,6 +51,7 @@ const createSandbox = (emitter, analytics) => {
51
51
  async auth(apiKey) {
52
52
  let reply = await this.send({
53
53
  type: "authenticate",
54
+ os: "linux",
54
55
  apiKey,
55
56
  });
56
57
 
@@ -64,6 +65,7 @@ const createSandbox = (emitter, analytics) => {
64
65
  async connect(sandboxId, persist = false) {
65
66
  let reply = await this.send({
66
67
  type: "connect",
68
+ os: "linux",
67
69
  persist,
68
70
  sandboxId,
69
71
  });
@@ -7,7 +7,10 @@ const { events } = require("../events.js");
7
7
 
8
8
  const createSystem = (emitter, sandbox, config) => {
9
9
  const screenshot = async (options) => {
10
- let { base64 } = await sandbox.send({ type: "system.screenshot" });
10
+ let { base64 } = await sandbox.send({
11
+ os: "linux",
12
+ type: "system.screenshot",
13
+ });
11
14
 
12
15
  if (!base64) {
13
16
  console.error("Failed to take screenshot");
@@ -110,6 +113,7 @@ const createSystem = (emitter, sandbox, config) => {
110
113
  const activeWin = async () => {
111
114
  // Get Mouse Position from command line
112
115
  let result = await sandbox.send({
116
+ os: "linux",
113
117
  type: "system.get-active-window",
114
118
  });
115
119
 
@@ -119,6 +123,7 @@ const createSystem = (emitter, sandbox, config) => {
119
123
  const getMousePosition = async () => {
120
124
  // Get Mouse Position from command line
121
125
  let result = await sandbox.send({
126
+ os: "linux",
122
127
  type: "system.get-mouse-position",
123
128
  });
124
129
 
@@ -340,7 +340,7 @@
340
340
  let parsedData;
341
341
  if (data) {
342
342
  try {
343
- parsedData = JSON.parse(decodeURIComponent(data));
343
+ parsedData = JSON.parse(atob(data));
344
344
  console.log("Data from URL:", parsedData);
345
345
  // You can use parsedData here if needed
346
346
  } catch (error) {
@@ -42,6 +42,7 @@ class BaseCommand extends Command {
42
42
  message = JSON.stringify(message);
43
43
  }
44
44
  this.agent.sandbox.send({
45
+ os: "linux",
45
46
  type: "output",
46
47
  output: Buffer.from(message).toString("base64"),
47
48
  });
@@ -29,6 +29,7 @@ class CustomTransport extends Transport {
29
29
  }
30
30
 
31
31
  this.sandbox.send({
32
+ os: "linux",
32
33
  type: "output",
33
34
  output: Buffer.from(message).toString("base64"),
34
35
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "6.1.10",
3
+ "version": "6.2.1",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "index.js",
6
6
  "bin": {
package/schema.json CHANGED
@@ -697,7 +697,8 @@
697
697
  "type": "string",
698
698
  "enum": [
699
699
  "js",
700
- "pwsh"
700
+ "pwsh",
701
+ "sh"
701
702
  ]
702
703
  },
703
704
  "code": {
@@ -0,0 +1,20 @@
1
+ version: 5.1.1
2
+ session: 67f00511acbd9ccac373edf7
3
+ steps:
4
+ - prompt: launch chrome
5
+ commands:
6
+ - command: exec
7
+ lang: sh
8
+ code: |
9
+ google-chrome \
10
+ --start-maximized \
11
+ --disable-infobars \
12
+ --disable-fre \
13
+ --no-default-browser-check \
14
+ --no-first-run \
15
+ --guest \
16
+ "${TD_WEBSITE}" \
17
+ >/dev/null 2>&1 &
18
+ - command: wait-for-text
19
+ text: ${TD_WEBSITE}
20
+ timeout: 60000