@matware/e2e-runner 1.3.0 → 1.3.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.
@@ -0,0 +1,339 @@
1
+ /**
2
+ * App Pool — isolated application environments for test isolation.
3
+ *
4
+ * Provides each test with its own application instance via fast VM/container
5
+ * forking. Supports multiple drivers:
6
+ *
7
+ * - "docker" — Docker-based: runs a fresh container per test (slower, ~2-5s)
8
+ * - "zeroboot" — Firecracker microVM fork via Zeroboot SDK (~0.8ms)
9
+ *
10
+ * Lifecycle:
11
+ * 1. Template creation (one-time): boot app, wait for ready, snapshot state
12
+ * 2. Fork (per-test): clone template into isolated instance with unique port
13
+ * 3. Test runs against fork's baseUrl
14
+ * 4. Fork destroyed after test completes
15
+ *
16
+ * The app pool is independent of the Chrome pool — both are selected in
17
+ * parallel by pool-manager.js for maximum throughput.
18
+ */
19
+
20
+ import { log, colors as C } from './logger.js';
21
+
22
+ // ── Port allocator ────────────────────────────────────────────────────────────
23
+
24
+ /** Tracks allocated ports to avoid collisions across concurrent forks. */
25
+ const allocatedPorts = new Set();
26
+
27
+ function allocatePort(basePort, maxForks) {
28
+ for (let offset = 0; offset < maxForks; offset++) {
29
+ const port = basePort + offset;
30
+ if (!allocatedPorts.has(port)) {
31
+ allocatedPorts.add(port);
32
+ return port;
33
+ }
34
+ }
35
+ throw new Error(`App pool: no free ports in range ${basePort}-${basePort + maxForks - 1}`);
36
+ }
37
+
38
+ function releasePort(port) {
39
+ allocatedPorts.delete(port);
40
+ }
41
+
42
+ // ── Fork registry ─────────────────────────────────────────────────────────────
43
+
44
+ /**
45
+ * Active fork tracking.
46
+ * Maps forkId → { port, driver, testName, startTime, metadata }
47
+ */
48
+ const activeForks = new Map();
49
+ let forkCounter = 0;
50
+
51
+ function generateForkId() {
52
+ return `fork-${Date.now().toString(36)}-${(++forkCounter).toString(36)}`;
53
+ }
54
+
55
+ // ── Health check ──────────────────────────────────────────────────────────────
56
+
57
+ /**
58
+ * Polls a URL until it returns 2xx or timeout is reached.
59
+ * Used to verify a forked app instance is ready to receive traffic.
60
+ */
61
+ async function waitForReady(url, timeoutMs = 10000, intervalMs = 200) {
62
+ const start = Date.now();
63
+ while (Date.now() - start < timeoutMs) {
64
+ try {
65
+ const res = await fetch(url, { signal: AbortSignal.timeout(2000) });
66
+ if (res.ok) return true;
67
+ } catch { /* not ready yet */ }
68
+ await new Promise(r => setTimeout(r, intervalMs));
69
+ }
70
+ throw new Error(`App pool: fork not ready after ${timeoutMs}ms (checked ${url})`);
71
+ }
72
+
73
+ // ── Driver: Docker ────────────────────────────────────────────────────────────
74
+
75
+ /**
76
+ * Docker driver — runs a fresh container per fork.
77
+ * Slower (~2-5s) but works everywhere Docker is available.
78
+ *
79
+ * Expects appPool config:
80
+ * image: Docker image to run (required)
81
+ * envVars: { KEY: 'value' } environment variables for the container
82
+ * readyCheck: path to poll for readiness (e.g. '/health')
83
+ * readyTimeout: ms to wait for ready (default 15000)
84
+ */
85
+ async function dockerFork(config, port) {
86
+ const { execFile } = await import('child_process');
87
+ const { promisify } = await import('util');
88
+ const execFileAsync = promisify(execFile);
89
+
90
+ const appConfig = config.appPool;
91
+ const containerName = `e2e-app-${port}`;
92
+
93
+ const args = [
94
+ 'run', '-d',
95
+ '--name', containerName,
96
+ '-p', `${port}:${appConfig.containerPort || 3000}`,
97
+ ];
98
+
99
+ // Add host.docker.internal access
100
+ args.push('--add-host', 'host.docker.internal:host-gateway');
101
+
102
+ // Environment variables
103
+ if (appConfig.envVars) {
104
+ for (const [key, value] of Object.entries(appConfig.envVars)) {
105
+ args.push('-e', `${key}=${value}`);
106
+ }
107
+ }
108
+
109
+ args.push(appConfig.image);
110
+
111
+ // Optional command override
112
+ if (appConfig.cmd) {
113
+ args.push(...(Array.isArray(appConfig.cmd) ? appConfig.cmd : appConfig.cmd.split(' ')));
114
+ }
115
+
116
+ await execFileAsync('docker', args);
117
+
118
+ return {
119
+ containerId: containerName,
120
+ cleanup: async () => {
121
+ try {
122
+ await execFileAsync('docker', ['rm', '-f', containerName]);
123
+ } catch { /* best effort */ }
124
+ },
125
+ };
126
+ }
127
+
128
+ async function dockerDestroy(metadata) {
129
+ if (metadata?.cleanup) {
130
+ await metadata.cleanup();
131
+ }
132
+ }
133
+
134
+ // ── Driver: Zeroboot ──────────────────────────────────────────────────────────
135
+
136
+ /**
137
+ * Zeroboot driver — sub-millisecond VM forks via Firecracker snapshots.
138
+ *
139
+ * NOTE: Zeroboot currently has NO networking within VMs (serial I/O only).
140
+ * This driver is a forward-looking implementation for when networking is added.
141
+ * The interface is ready — only the SDK calls need updating.
142
+ *
143
+ * Expects appPool config:
144
+ * zeroboot.apiUrl: Zeroboot API endpoint (default: http://localhost:8484)
145
+ * zeroboot.templateId: pre-created template ID (required)
146
+ * readyCheck: path to poll for readiness
147
+ * readyTimeout: ms to wait for ready (default 5000)
148
+ */
149
+
150
+ /** Placeholder for Zeroboot SDK — replace with actual import when available. */
151
+ function getZerobootClient(apiUrl) {
152
+ // When Zeroboot publishes their Node SDK:
153
+ // import { ZerobootClient } from '@anthropic-ai/zeroboot';
154
+ // return new ZerobootClient({ apiUrl });
155
+ return {
156
+ async fork(templateId, _options) {
157
+ // SDK call: creates a KVM fork from snapshot in ~0.8ms
158
+ // Returns: { forkId, port, host }
159
+ throw new Error(
160
+ 'Zeroboot SDK not installed. Install with: npm install @anthropic-ai/zeroboot\n' +
161
+ 'Zeroboot currently requires networking support (not yet available).\n' +
162
+ 'See: https://github.com/zerobootdev/zeroboot'
163
+ );
164
+ },
165
+ async destroy(_forkId) {
166
+ // SDK call: destroys the forked VM
167
+ },
168
+ async status() {
169
+ // SDK call: returns template and fork status
170
+ return { templates: [], activeForks: 0, memoryUsed: 0 };
171
+ },
172
+ };
173
+ }
174
+
175
+ async function zerobootFork(config, port) {
176
+ const appConfig = config.appPool;
177
+ const apiUrl = appConfig.zeroboot?.apiUrl || 'http://localhost:8484';
178
+ const templateId = appConfig.zeroboot?.templateId;
179
+
180
+ if (!templateId) {
181
+ throw new Error('App pool (zeroboot): zeroboot.templateId is required in appPool config');
182
+ }
183
+
184
+ const client = getZerobootClient(apiUrl);
185
+ const fork = await client.fork(templateId, { port });
186
+
187
+ return {
188
+ zerobootForkId: fork.forkId,
189
+ client,
190
+ cleanup: async () => {
191
+ try {
192
+ await client.destroy(fork.forkId);
193
+ } catch { /* best effort */ }
194
+ },
195
+ };
196
+ }
197
+
198
+ async function zerobootDestroy(metadata) {
199
+ if (metadata?.cleanup) {
200
+ await metadata.cleanup();
201
+ }
202
+ }
203
+
204
+ // ── Public API ────────────────────────────────────────────────────────────────
205
+
206
+ /**
207
+ * Forks a new isolated app instance.
208
+ *
209
+ * @param {object} config - Full e2e-runner config with appPool section
210
+ * @param {string} [testName] - Test name for logging/tracking
211
+ * @returns {{ forkId: string, baseUrl: string, port: number }}
212
+ */
213
+ export async function forkAppInstance(config, testName = '') {
214
+ const appConfig = config.appPool;
215
+ if (!appConfig?.enabled) {
216
+ throw new Error('App pool is not enabled in config');
217
+ }
218
+
219
+ const driver = appConfig.driver || 'docker';
220
+ const basePort = appConfig.forkBasePort || 4000;
221
+ const maxForks = appConfig.maxForks || 10;
222
+ const port = allocatePort(basePort, maxForks);
223
+ const forkId = generateForkId();
224
+
225
+ log('🔱', `${C.cyan}Forking app${C.reset} ${C.dim}(${driver}, port ${port}${testName ? `, ${testName}` : ''})${C.reset}`);
226
+
227
+ const startMs = Date.now();
228
+ let metadata;
229
+
230
+ try {
231
+ if (driver === 'zeroboot') {
232
+ metadata = await zerobootFork(config, port);
233
+ } else if (driver === 'docker') {
234
+ metadata = await dockerFork(config, port);
235
+ } else {
236
+ throw new Error(`App pool: unknown driver "${driver}". Use "docker" or "zeroboot".`);
237
+ }
238
+
239
+ // Determine the baseUrl for the forked instance
240
+ const host = appConfig.forkHost || 'localhost';
241
+ const protocol = appConfig.forkProtocol || 'http';
242
+ const baseUrl = `${protocol}://${host}:${port}`;
243
+
244
+ // For Docker-based apps accessed from Chrome inside Docker:
245
+ const dockerBaseUrl = `http://host.docker.internal:${port}`;
246
+
247
+ // Wait for the app to be ready
248
+ if (appConfig.readyCheck) {
249
+ const checkUrl = `${baseUrl}${appConfig.readyCheck}`;
250
+ const readyTimeout = appConfig.readyTimeout || (driver === 'zeroboot' ? 5000 : 15000);
251
+ await waitForReady(checkUrl, readyTimeout);
252
+ }
253
+
254
+ const forkTimeMs = Date.now() - startMs;
255
+ log('🔱', `${C.green}App fork ready${C.reset} ${C.dim}(${forkTimeMs}ms, ${baseUrl})${C.reset}`);
256
+
257
+ const forkInfo = {
258
+ forkId,
259
+ port,
260
+ baseUrl,
261
+ dockerBaseUrl,
262
+ driver,
263
+ testName,
264
+ startTime: new Date().toISOString(),
265
+ forkTimeMs,
266
+ metadata,
267
+ };
268
+
269
+ activeForks.set(forkId, forkInfo);
270
+ return forkInfo;
271
+ } catch (error) {
272
+ releasePort(port);
273
+ throw error;
274
+ }
275
+ }
276
+
277
+ /**
278
+ * Destroys a forked app instance and releases its port.
279
+ *
280
+ * @param {string} forkId - Fork ID returned by forkAppInstance
281
+ */
282
+ export async function destroyFork(forkId) {
283
+ const fork = activeForks.get(forkId);
284
+ if (!fork) return;
285
+
286
+ log('🔱', `${C.dim}Destroying app fork${C.reset} ${C.dim}(port ${fork.port}${fork.testName ? `, ${fork.testName}` : ''})${C.reset}`);
287
+
288
+ try {
289
+ if (fork.driver === 'zeroboot') {
290
+ await zerobootDestroy(fork.metadata);
291
+ } else if (fork.driver === 'docker') {
292
+ await dockerDestroy(fork.metadata);
293
+ }
294
+ } finally {
295
+ releasePort(fork.port);
296
+ activeForks.delete(forkId);
297
+ }
298
+ }
299
+
300
+ /**
301
+ * Returns the status of the app pool: active forks, port usage, per-fork details.
302
+ */
303
+ export function getAppPoolStatus() {
304
+ const forks = [];
305
+ for (const [id, fork] of activeForks) {
306
+ forks.push({
307
+ forkId: id,
308
+ port: fork.port,
309
+ driver: fork.driver,
310
+ baseUrl: fork.baseUrl,
311
+ testName: fork.testName,
312
+ startTime: fork.startTime,
313
+ forkTimeMs: fork.forkTimeMs,
314
+ });
315
+ }
316
+
317
+ return {
318
+ activeForks: activeForks.size,
319
+ allocatedPorts: [...allocatedPorts].sort((a, b) => a - b),
320
+ forks,
321
+ };
322
+ }
323
+
324
+ /**
325
+ * Destroys all active forks. Called during cleanup/shutdown.
326
+ */
327
+ export async function destroyAllForks() {
328
+ const ids = [...activeForks.keys()];
329
+ if (ids.length === 0) return;
330
+ log('🔱', `${C.dim}Destroying ${ids.length} app fork(s)...${C.reset}`);
331
+ await Promise.allSettled(ids.map(id => destroyFork(id)));
332
+ }
333
+
334
+ /**
335
+ * Checks if app pool is configured and enabled.
336
+ */
337
+ export function isAppPoolEnabled(config) {
338
+ return config?.appPool?.enabled === true;
339
+ }
package/src/config.js CHANGED
@@ -40,6 +40,7 @@ const DEFAULTS = {
40
40
  connectRetries: 3,
41
41
  connectRetryDelay: 2000,
42
42
  poolPort: 3333,
43
+ poolDriver: 'auto',
43
44
  maxSessions: 10,
44
45
  retries: 0,
45
46
  retryDelay: 1000,
@@ -54,6 +55,11 @@ const DEFAULTS = {
54
55
  failOnNetworkError: false,
55
56
  actionRetries: 0,
56
57
  actionRetryDelay: 500,
58
+ screencast: false,
59
+ screencastQuality: 60,
60
+ screencastMaxWidth: 800,
61
+ screencastMaxHeight: 600,
62
+ screencastEveryNthFrame: 1,
57
63
  anthropicApiKey: null,
58
64
  anthropicModel: 'claude-sonnet-4-5-20250929',
59
65
  authToken: null,
@@ -68,7 +74,28 @@ const DEFAULTS = {
68
74
  neo4jBoltPort: 7687,
69
75
  neo4jHttpPort: 7474,
70
76
  verificationStrictness: 'moderate',
77
+ verificationThreshold: 0.02,
78
+ goldenDir: null,
71
79
  networkIgnoreDomains: [],
80
+ // App pool: isolated app environments per test
81
+ appPool: {
82
+ enabled: false,
83
+ driver: 'docker', // 'docker' | 'zeroboot'
84
+ image: null, // Docker image to run (docker driver)
85
+ containerPort: 3000, // Port the app listens on inside the container
86
+ cmd: null, // Optional command override
87
+ envVars: null, // { KEY: 'value' } for the container
88
+ forkBasePort: 4000, // Host port range start for forked instances
89
+ forkHost: 'localhost', // Host for health checks from runner
90
+ forkProtocol: 'http',
91
+ maxForks: 10, // Max concurrent forks
92
+ readyCheck: null, // Path to poll for readiness (e.g. '/health')
93
+ readyTimeout: 15000, // ms to wait for fork to be ready
94
+ zeroboot: { // Zeroboot-specific config
95
+ apiUrl: 'http://localhost:8484',
96
+ templateId: null, // Pre-created template ID
97
+ },
98
+ },
72
99
  authLoginEndpoint: null,
73
100
  authCredentials: null,
74
101
  authTokenPath: 'token',
@@ -142,6 +169,12 @@ function loadEnvVars() {
142
169
  if (process.env.FAIL_ON_NETWORK_ERROR) env.failOnNetworkError = process.env.FAIL_ON_NETWORK_ERROR === 'true' || process.env.FAIL_ON_NETWORK_ERROR === '1';
143
170
  if (process.env.ACTION_RETRIES) env.actionRetries = parseInt(process.env.ACTION_RETRIES);
144
171
  if (process.env.ACTION_RETRY_DELAY) env.actionRetryDelay = parseInt(process.env.ACTION_RETRY_DELAY);
172
+ if (process.env.POOL_DRIVER) env.poolDriver = process.env.POOL_DRIVER;
173
+ if (process.env.SCREENCAST) env.screencast = process.env.SCREENCAST === 'true' || process.env.SCREENCAST === '1';
174
+ if (process.env.SCREENCAST_QUALITY) env.screencastQuality = parseInt(process.env.SCREENCAST_QUALITY);
175
+ if (process.env.SCREENCAST_MAX_WIDTH) env.screencastMaxWidth = parseInt(process.env.SCREENCAST_MAX_WIDTH);
176
+ if (process.env.SCREENCAST_MAX_HEIGHT) env.screencastMaxHeight = parseInt(process.env.SCREENCAST_MAX_HEIGHT);
177
+ if (process.env.SCREENCAST_EVERY_NTH_FRAME) env.screencastEveryNthFrame = parseInt(process.env.SCREENCAST_EVERY_NTH_FRAME);
145
178
  if (process.env.ANTHROPIC_API_KEY) env.anthropicApiKey = process.env.ANTHROPIC_API_KEY;
146
179
  if (process.env.ANTHROPIC_MODEL) env.anthropicModel = process.env.ANTHROPIC_MODEL;
147
180
  if (process.env.AUTH_TOKEN) env.authToken = process.env.AUTH_TOKEN;
@@ -158,6 +191,25 @@ function loadEnvVars() {
158
191
  if (process.env.NETWORK_IGNORE_DOMAINS) env.networkIgnoreDomains = process.env.NETWORK_IGNORE_DOMAINS.split(',').map(d => d.trim()).filter(Boolean);
159
192
  if (process.env.AUTH_LOGIN_ENDPOINT) env.authLoginEndpoint = process.env.AUTH_LOGIN_ENDPOINT;
160
193
  if (process.env.AUTH_TOKEN_PATH) env.authTokenPath = process.env.AUTH_TOKEN_PATH;
194
+ // credentials.env convention: E2E_USERNAME + E2E_PASSWORD → authCredentials
195
+ // Sends both email and username fields so the API accepts whichever it expects.
196
+ // E2E_AUTH_FIELD overrides to send a single field if desired.
197
+ if (process.env.E2E_USERNAME && process.env.E2E_PASSWORD) {
198
+ if (process.env.E2E_AUTH_FIELD) {
199
+ env.authCredentials = {
200
+ [process.env.E2E_AUTH_FIELD]: process.env.E2E_USERNAME,
201
+ password: process.env.E2E_PASSWORD,
202
+ };
203
+ } else {
204
+ env.authCredentials = {
205
+ email: process.env.E2E_USERNAME,
206
+ username: process.env.E2E_USERNAME,
207
+ password: process.env.E2E_PASSWORD,
208
+ };
209
+ }
210
+ }
211
+ if (process.env.E2E_LOGIN_ENDPOINT) env.authLoginEndpoint = process.env.E2E_LOGIN_ENDPOINT;
212
+ if (process.env.E2E_TOKEN_PATH) env.authTokenPath = process.env.E2E_TOKEN_PATH;
161
213
  if (process.env.GQL_ENDPOINT) env.gqlEndpoint = process.env.GQL_ENDPOINT;
162
214
  if (process.env.GQL_AUTH_HEADER) env.gqlAuthHeader = process.env.GQL_AUTH_HEADER;
163
215
  if (process.env.GQL_AUTH_KEY) env.gqlAuthKey = process.env.GQL_AUTH_KEY;
@@ -174,7 +226,53 @@ function loadEnvVars() {
174
226
  env.verificationStrictness = val;
175
227
  }
176
228
  }
177
-
229
+ if (process.env.VERIFICATION_THRESHOLD) env.verificationThreshold = parseFloat(process.env.VERIFICATION_THRESHOLD);
230
+ if (process.env.GOLDEN_DIR) env.goldenDir = process.env.GOLDEN_DIR;
231
+
232
+ // App pool configuration from env vars
233
+ if (process.env.APP_POOL_ENABLED) {
234
+ env.appPool = env.appPool || {};
235
+ env.appPool.enabled = process.env.APP_POOL_ENABLED === 'true' || process.env.APP_POOL_ENABLED === '1';
236
+ }
237
+ if (process.env.APP_POOL_DRIVER) {
238
+ env.appPool = env.appPool || {};
239
+ env.appPool.driver = process.env.APP_POOL_DRIVER;
240
+ }
241
+ if (process.env.APP_POOL_IMAGE) {
242
+ env.appPool = env.appPool || {};
243
+ env.appPool.image = process.env.APP_POOL_IMAGE;
244
+ }
245
+ if (process.env.APP_POOL_CONTAINER_PORT) {
246
+ env.appPool = env.appPool || {};
247
+ env.appPool.containerPort = parseInt(process.env.APP_POOL_CONTAINER_PORT);
248
+ }
249
+ if (process.env.APP_POOL_BASE_PORT) {
250
+ env.appPool = env.appPool || {};
251
+ env.appPool.forkBasePort = parseInt(process.env.APP_POOL_BASE_PORT);
252
+ }
253
+ if (process.env.APP_POOL_MAX_FORKS) {
254
+ env.appPool = env.appPool || {};
255
+ env.appPool.maxForks = parseInt(process.env.APP_POOL_MAX_FORKS);
256
+ }
257
+ if (process.env.APP_POOL_READY_CHECK) {
258
+ env.appPool = env.appPool || {};
259
+ env.appPool.readyCheck = process.env.APP_POOL_READY_CHECK;
260
+ }
261
+ if (process.env.APP_POOL_READY_TIMEOUT) {
262
+ env.appPool = env.appPool || {};
263
+ env.appPool.readyTimeout = parseInt(process.env.APP_POOL_READY_TIMEOUT);
264
+ }
265
+ if (process.env.ZEROBOOT_API_URL) {
266
+ env.appPool = env.appPool || {};
267
+ env.appPool.zeroboot = env.appPool.zeroboot || {};
268
+ env.appPool.zeroboot.apiUrl = process.env.ZEROBOOT_API_URL;
269
+ }
270
+ if (process.env.ZEROBOOT_TEMPLATE_ID) {
271
+ env.appPool = env.appPool || {};
272
+ env.appPool.zeroboot = env.appPool.zeroboot || {};
273
+ env.appPool.zeroboot.templateId = process.env.ZEROBOOT_TEMPLATE_ID;
274
+ }
275
+
178
276
  // Sync configuration from env vars
179
277
  if (process.env.E2E_SYNC_MODE) {
180
278
  const mode = process.env.E2E_SYNC_MODE.toLowerCase();
@@ -231,11 +329,10 @@ async function loadConfigFile(cwd) {
231
329
  return {};
232
330
  }
233
331
 
234
- /** Load .env file from cwd into process.env (no deps, KEY=VALUE format). */
235
- function loadDotEnv(cwd) {
236
- const envPath = path.join(cwd, '.env');
237
- if (!fs.existsSync(envPath)) return;
238
- const lines = fs.readFileSync(envPath, 'utf-8').split('\n');
332
+ /** Load a KEY=VALUE file into process.env (no deps). */
333
+ function loadEnvFile(filePath) {
334
+ if (!fs.existsSync(filePath)) return;
335
+ const lines = fs.readFileSync(filePath, 'utf-8').split('\n');
239
336
  for (const line of lines) {
240
337
  const trimmed = line.trim();
241
338
  if (!trimmed || trimmed.startsWith('#')) continue;
@@ -254,6 +351,14 @@ function loadDotEnv(cwd) {
254
351
  }
255
352
  }
256
353
 
354
+ /** Load .env and credentials.env from cwd into process.env. */
355
+ function loadDotEnv(cwd) {
356
+ loadEnvFile(path.join(cwd, '.env'));
357
+ // credentials.env — search e2e/ subdir first, then cwd root
358
+ loadEnvFile(path.join(cwd, 'e2e', 'credentials.env'));
359
+ loadEnvFile(path.join(cwd, 'credentials.env'));
360
+ }
361
+
257
362
  export async function loadConfig(cliArgs = {}, cwd = null) {
258
363
  cwd = cwd || process.cwd();
259
364
  loadDotEnv(cwd);
@@ -267,7 +372,7 @@ export async function loadConfig(cliArgs = {}, cwd = null) {
267
372
  ...cliArgs,
268
373
  };
269
374
 
270
- // Deep merge sync config (nested objects need special handling)
375
+ // Deep merge nested config objects
271
376
  if (fileConfig.sync || envConfig.sync || cliArgs.sync) {
272
377
  config.sync = deepMerge(
273
378
  DEFAULTS.sync,
@@ -276,6 +381,14 @@ export async function loadConfig(cliArgs = {}, cwd = null) {
276
381
  cliArgs.sync || {}
277
382
  );
278
383
  }
384
+ if (fileConfig.appPool || envConfig.appPool || cliArgs.appPool) {
385
+ config.appPool = deepMerge(
386
+ DEFAULTS.appPool,
387
+ fileConfig.appPool || {},
388
+ envConfig.appPool || {},
389
+ cliArgs.appPool || {}
390
+ );
391
+ }
279
392
 
280
393
  // Apply environment profile overrides
281
394
  if (config.env && config.env !== 'default' && config.environments?.[config.env]) {
@@ -300,6 +413,11 @@ export async function loadConfig(cliArgs = {}, cwd = null) {
300
413
  fs.mkdirSync(config.screenshotsDir, { recursive: true });
301
414
  }
302
415
 
416
+ // Auto-infer authLoginEndpoint from baseUrl if credentials are available but no endpoint
417
+ if (config.authCredentials && !config.authLoginEndpoint && config.baseUrl) {
418
+ config.authLoginEndpoint = config.baseUrl.replace(/\/+$/, '') + '/api/auth/login';
419
+ }
420
+
303
421
  // Stash cwd for project identity (used by db.js)
304
422
  config._cwd = cwd;
305
423
  if (!config.projectName) {