testdriverai 7.8.0-test.7 → 7.8.0-test.71

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 (98) hide show
  1. package/agent/index.js +18 -5
  2. package/agent/lib/commands.js +3 -2
  3. package/agent/lib/http.js +162 -0
  4. package/agent/lib/logger.js +15 -0
  5. package/agent/lib/sandbox.js +554 -209
  6. package/agent/lib/sdk.js +5 -22
  7. package/agent/lib/system.js +25 -65
  8. package/ai/skills/testdriver-cache/SKILL.md +221 -0
  9. package/ai/skills/testdriver-errors/SKILL.md +246 -0
  10. package/ai/skills/testdriver-events/SKILL.md +356 -0
  11. package/ai/skills/testdriver-find/SKILL.md +14 -20
  12. package/ai/skills/testdriver-mcp/SKILL.md +7 -0
  13. package/ai/skills/testdriver-provision/SKILL.md +331 -0
  14. package/ai/skills/testdriver-redraw/SKILL.md +214 -0
  15. package/ai/skills/testdriver-running-tests/SKILL.md +1 -1
  16. package/ai/skills/testdriver-screenshots/SKILL.md +184 -0
  17. package/docs/_data/examples-manifest.json +46 -46
  18. package/docs/_scripts/extract-example-urls.js +67 -72
  19. package/docs/changelog.mdx +148 -8
  20. package/docs/docs.json +46 -38
  21. package/docs/images/content/vscode/v7-chat.png +0 -0
  22. package/docs/images/content/vscode/v7-choose-agent.png +0 -0
  23. package/docs/images/content/vscode/v7-full.png +0 -0
  24. package/docs/images/content/vscode/v7-onboarding.png +0 -0
  25. package/docs/v7/cache.mdx +223 -0
  26. package/docs/v7/copilot/auto-healing.mdx +265 -0
  27. package/docs/v7/copilot/creating-tests.mdx +156 -0
  28. package/docs/v7/copilot/github.mdx +143 -0
  29. package/docs/v7/copilot/running-tests.mdx +149 -0
  30. package/docs/v7/copilot/setup.mdx +143 -0
  31. package/docs/v7/enterprise.mdx +3 -110
  32. package/docs/v7/errors.mdx +248 -0
  33. package/docs/v7/events.mdx +358 -0
  34. package/docs/v7/examples/ai.mdx +1 -1
  35. package/docs/v7/examples/assert.mdx +1 -1
  36. package/docs/v7/examples/captcha-api.mdx +1 -1
  37. package/docs/v7/examples/chrome-extension.mdx +1 -1
  38. package/docs/v7/examples/drag-and-drop.mdx +1 -1
  39. package/docs/v7/examples/element-not-found.mdx +1 -1
  40. package/docs/v7/examples/exec-output.mdx +85 -0
  41. package/docs/v7/examples/exec-pwsh.mdx +83 -0
  42. package/docs/v7/examples/focus-window.mdx +62 -0
  43. package/docs/v7/examples/hover-image.mdx +1 -1
  44. package/docs/v7/examples/hover-text.mdx +1 -1
  45. package/docs/v7/examples/installer.mdx +1 -1
  46. package/docs/v7/examples/launch-vscode-linux.mdx +1 -1
  47. package/docs/v7/examples/match-image.mdx +1 -1
  48. package/docs/v7/examples/press-keys.mdx +1 -1
  49. package/docs/v7/examples/scroll-keyboard.mdx +1 -1
  50. package/docs/v7/examples/scroll-until-image.mdx +1 -1
  51. package/docs/v7/examples/scroll-until-text.mdx +1 -1
  52. package/docs/v7/examples/scroll.mdx +1 -1
  53. package/docs/v7/examples/type.mdx +1 -1
  54. package/docs/v7/examples/windows-installer.mdx +1 -1
  55. package/docs/v7/find.mdx +14 -20
  56. package/docs/v7/{cloud.mdx → hosted.mdx} +43 -5
  57. package/docs/v7/mcp.mdx +9 -0
  58. package/docs/v7/provision.mdx +333 -0
  59. package/docs/v7/quickstart.mdx +30 -2
  60. package/docs/v7/redraw.mdx +216 -0
  61. package/docs/v7/running-tests.mdx +1 -1
  62. package/docs/v7/screenshots.mdx +186 -0
  63. package/docs/v7/self-hosted.mdx +127 -44
  64. package/docs/v7/test-results-json.mdx +258 -0
  65. package/examples/scroll-keyboard.test.mjs +1 -1
  66. package/examples/scroll.test.mjs +1 -12
  67. package/interfaces/logger.js +0 -12
  68. package/interfaces/vitest-plugin.mjs +170 -51
  69. package/lib/core/Dashcam.js +30 -23
  70. package/lib/environments.json +22 -0
  71. package/lib/github-comment.mjs +58 -40
  72. package/lib/init-project.js +5 -67
  73. package/lib/resolve-channel.js +42 -12
  74. package/lib/sentry.js +47 -23
  75. package/lib/vitest/hooks.mjs +63 -3
  76. package/{examples → manual}/drag-and-drop.test.mjs +1 -1
  77. package/manual/exec-stream-logs.test.mjs +25 -0
  78. package/mcp-server/dist/server.mjs +28 -8
  79. package/mcp-server/src/server.ts +31 -8
  80. package/package.json +4 -3
  81. package/sdk.d.ts +4 -0
  82. package/sdk.js +45 -15
  83. package/setup/aws/install-dev-runner.sh +79 -0
  84. package/setup/aws/spawn-runner.sh +165 -0
  85. package/test-sentry-span.js +35 -0
  86. package/vitest.config.mjs +22 -34
  87. package/vitest.runner.config.mjs +33 -0
  88. /package/{examples → manual}/flake-diffthreshold-001.test.mjs +0 -0
  89. /package/{examples → manual}/flake-diffthreshold-01.test.mjs +0 -0
  90. /package/{examples → manual}/flake-diffthreshold-05.test.mjs +0 -0
  91. /package/{examples → manual}/flake-noredraw-cache.test.mjs +0 -0
  92. /package/{examples → manual}/flake-noredraw-nocache.test.mjs +0 -0
  93. /package/{examples → manual}/flake-redraw-cache.test.mjs +0 -0
  94. /package/{examples → manual}/flake-redraw-nocache.test.mjs +0 -0
  95. /package/{examples → manual}/flake-rocket-match.test.mjs +0 -0
  96. /package/{examples → manual}/flake-shared.mjs +0 -0
  97. /package/{examples → manual}/no-provision.test.mjs +0 -0
  98. /package/{examples → manual}/scroll-until-text.test.mjs +0 -0
@@ -0,0 +1,35 @@
1
+ const Sentry = require('@sentry/node');
2
+ const crypto = require('crypto');
3
+
4
+ Sentry.init({ dsn: 'https://test@sentry.io/123', tracesSampleRate: 1.0 });
5
+
6
+ const sessionId = 'test-session-123';
7
+ const traceId = crypto.createHash('md5').update(sessionId).digest('hex');
8
+ console.log('expected traceId:', traceId);
9
+
10
+ const sentryTraceHeader = traceId + '-' + crypto.randomBytes(8).toString('hex') + '-1';
11
+ const baggageHeader = 'sentry-trace_id=' + traceId + ',sentry-sampled=true';
12
+
13
+ // Approach: Use continueTrace + startInactiveSpan for the root, then rely on scope
14
+ // for getTraceData propagation
15
+ Sentry.continueTrace(
16
+ { sentryTrace: sentryTraceHeader, baggage: baggageHeader },
17
+ () => {
18
+ // This sets propagation context on the current scope
19
+ const rootSpan = Sentry.startInactiveSpan({ name: 'sdk.session', op: 'session', forceTransaction: true });
20
+
21
+ // After continueTrace returns, check if getTraceData still uses the right traceId
22
+ const td = Sentry.getTraceData();
23
+ console.log('after continueTrace getTraceData:', JSON.stringify(td));
24
+ console.log('traceId matches:', td['sentry-trace'] && td['sentry-trace'].startsWith(traceId));
25
+
26
+ // Simulate async: do a child span later
27
+ setTimeout(() => {
28
+ const td2 = Sentry.getTraceData();
29
+ console.log('async getTraceData:', JSON.stringify(td2));
30
+ console.log('async traceId matches:', td2['sentry-trace'] && td2['sentry-trace'].startsWith(traceId));
31
+ rootSpan.end();
32
+ process.exit(0);
33
+ }, 100);
34
+ }
35
+ );
package/vitest.config.mjs CHANGED
@@ -1,7 +1,9 @@
1
1
  import TestDriver from "testdriverai/vitest";
2
2
  import { defineConfig } from "vitest/config";
3
- import { readFileSync, existsSync } from "fs";
4
- import { resolve } from "path";
3
+ import { createRequire } from "module";
4
+
5
+ const require = createRequire(import.meta.url);
6
+ const { resolveEnv, getEnvironmentNames } = require("../shared/resolve-env");
5
7
 
6
8
  // Always include AWS setup - it will be a no-op unless TD_OS=windows
7
9
  // Note: dotenv is loaded automatically by the TestDriver SDK
@@ -12,8 +14,8 @@ const setupFiles = [
12
14
 
13
15
  const sharedTestConfig = {
14
16
  retry: 0,
15
- testTimeout: 900000,
16
- hookTimeout: 900000,
17
+ testTimeout: 480000,
18
+ hookTimeout: 480000,
17
19
  maxConcurrency: 100,
18
20
  disableConsoleIntercept: false,
19
21
  silent: false,
@@ -25,45 +27,31 @@ const sharedTestConfig = {
25
27
  include: ["examples/**/*.test.mjs"],
26
28
  };
27
29
 
28
- // ── Parse a simple KEY=VALUE .env file ──────────────────────────────
29
- function parseEnvFile(filePath) {
30
- if (!existsSync(filePath)) return {};
31
- const env = {};
32
- for (const line of readFileSync(filePath, "utf-8").split("\n")) {
33
- const trimmed = line.trim();
34
- if (!trimmed || trimmed.startsWith("#")) continue;
35
- const idx = trimmed.indexOf("=");
36
- if (idx === -1) continue;
37
- env[trimmed.slice(0, idx)] = trimmed.slice(idx + 1);
38
- }
39
- return env;
40
- }
41
-
42
- // ── Load base .env + per-environment overlay ────────────────────────
43
- const monoRoot = resolve(import.meta.dirname, "..");
44
- const baseEnv = parseEnvFile(resolve(monoRoot, ".env"));
45
-
46
- const environments = ["dev", "test", "canary", "stable"];
30
+ // ── Resolve env vars via shared/resolve-env.js ──────────────────────
31
+ // Uses: environments.json (URLs) + envs/{env}.env (overlay) + fixtures (API keys)
32
+ // TD_PLAN selects which plan's API key to use (default: enterprise)
33
+ const plan = process.env.TD_PLAN || "enterprise";
34
+ const defaultEnv = process.env.TD_CHANNEL || "dev";
35
+ const environments = getEnvironmentNames();
47
36
 
48
- function envForProject(envName) {
49
- const overlay = parseEnvFile(resolve(monoRoot, "envs", `${envName}.env`));
50
- return { ...baseEnv, ...overlay };
51
- }
37
+ // Apply default env to the main process so the reporter/plugin picks it up
38
+ // (vitest's test.env only propagates to worker processes, not the main process)
39
+ const defaultResolved = resolveEnv(defaultEnv, plan);
40
+ Object.assign(process.env, defaultResolved);
52
41
 
53
- // ── If TD_ENV is set (e.g. from CLI), only run that environment ─────
54
- // Usage: TD_ENV=dev vitest run
55
- // TD_ENV=canary vitest run examples/assert.test.mjs
56
- // vitest run --project dev
57
- // vitest run --project canary --project stable
42
+ // ── Usage ───────────────────────────────────────────────────────────
43
+ // TD_PLAN=enterprise vitest run --project dev
44
+ // TD_PLAN=free vitest run --project test examples/assert.test.mjs
45
+ // vitest run --project canary --project stable
58
46
  export default defineConfig({
59
47
  test: {
60
48
  ...sharedTestConfig,
61
- env: envForProject(process.env.TD_ENV || "dev"),
49
+ env: defaultResolved,
62
50
  projects: environments.map((envName) => ({
63
51
  extends: true,
64
52
  test: {
65
53
  name: envName,
66
- env: envForProject(envName),
54
+ env: resolveEnv(envName, plan),
67
55
  },
68
56
  })),
69
57
  },
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Vitest config for runner/packer tests.
3
+ * Lives under sdk/ so vitest resolves from sdk/node_modules,
4
+ * but uses shared/resolve-env.js for environment variable loading.
5
+ */
6
+ import { defineConfig } from "vitest/config";
7
+ import { createRequire } from "module";
8
+ import { dirname, resolve } from "path";
9
+ import { fileURLToPath } from "url";
10
+
11
+ const __dirname = dirname(fileURLToPath(import.meta.url));
12
+ const monoRoot = resolve(__dirname, "..");
13
+
14
+ const require = createRequire(import.meta.url);
15
+ const { resolveEnv } = require("../shared/resolve-env");
16
+
17
+ const plan = process.env.TD_PLAN || "enterprise";
18
+ const env = process.env.TD_CHANNEL || "dev";
19
+ const resolved = resolveEnv(env, plan);
20
+
21
+ // Apply to the main process so test code sees the vars immediately
22
+ Object.assign(process.env, resolved);
23
+
24
+ export default defineConfig({
25
+ test: {
26
+ root: monoRoot,
27
+ testTimeout: 900_000, // 15 min per test
28
+ hookTimeout: 2_400_000, // 40 min for beforeAll (AMI build + spawn)
29
+ reporters: ["default"],
30
+ include: ["runner/packer/test/**/*.test.mjs"],
31
+ env: resolved,
32
+ },
33
+ });
File without changes
File without changes
File without changes