@dxos/test-utils 0.16.0 → 0.17.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.
@@ -272,13 +272,18 @@ var webKitLaunchEnv = (workspaceRoot) => {
272
272
  /**
273
273
  * WebKit keeps OPFS under the browser's data directory, and an ephemeral context has none, so every
274
274
  * `navigator.storage` call there fails and no app backed by OPFS boots. A persistent context has one.
275
- * Its temporary directory is per context, which keeps the isolation a fresh context gives.
275
+ * Its temporary directory is per context, which keeps the isolation a fresh context gives. On macOS
276
+ * WebKit puts OPFS under the home directory instead, shared by every context and kept across runs,
277
+ * so the home directory is pointed at the context's directory too.
276
278
  */
277
279
  var createContext = async (browser) => {
278
280
  const browserType = browser.browserType();
279
281
  if (browserType.name() !== "webkit" || !webkitWorkarounds()) return { context: await browser.newContext() };
280
282
  const userDataDir = mkdtempSync(join(tmpdir(), "dxos-webkit-"));
281
- const context = await browserType.launchPersistentContext(userDataDir, { env: webKitLaunchEnv(findWorkspaceRoot(process.cwd())) });
283
+ const context = await browserType.launchPersistentContext(userDataDir, { env: {
284
+ ...webKitLaunchEnv(findWorkspaceRoot(process.cwd())),
285
+ ...process.platform === "darwin" ? { CFFIXED_USER_HOME: userDataDir } : {}
286
+ } });
282
287
  context.once("close", () => rmSync(userDataDir, {
283
288
  recursive: true,
284
289
  force: true
@@ -335,6 +340,19 @@ var setupPage = async (browser, options = {}) => {
335
340
  throw err;
336
341
  }
337
342
  };
343
+ /**
344
+ * Opens `url` once and waits for `ready`, so Storybook's on-demand compile of the story (about 50 s on a
345
+ * 4 vCPU runner) is paid outside every test's own budget. Call from `test.beforeAll` after raising its
346
+ * timeout with `test.setTimeout`.
347
+ */
348
+ var warmStory = async (browser, url, ready) => {
349
+ const { page, close } = await setupPage(browser, { url });
350
+ try {
351
+ await ready(page);
352
+ } finally {
353
+ await close();
354
+ }
355
+ };
338
356
  var storybookUrl = (storyId, port = 9009) => `http://localhost:${port}/iframe.html?id=${storyId}&viewMode=story`;
339
357
  /**
340
358
  * Playwright `webServer` for a Storybook-backed suite. Readiness is probed by `url` rather than
@@ -343,10 +361,11 @@ var storybookUrl = (storyId, port = 9009) => `http://localhost:${port}/iframe.ht
343
361
  */
344
362
  var storybookWebServer = (port) => ({
345
363
  command: `pnpm storybook dev --ci --quiet --port=${port} --config-dir=.storybook`,
364
+ cwd: "../..",
346
365
  url: `http://localhost:${port}`,
347
366
  reuseExistingServer: false
348
367
  });
349
368
  //#endregion
350
- export { e2ePreset, setupPage, storybookUrl, storybookWebServer };
369
+ export { e2ePreset, setupPage, storybookUrl, storybookWebServer, warmStory };
351
370
 
352
371
  //# sourceMappingURL=playwright.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"playwright.mjs","names":[],"sources":["../../src/errno-shim.ts","../../src/lock.ts","../../src/playwright.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport { execFileSync } from 'node:child_process';\nimport { createHash } from 'node:crypto';\nimport { existsSync, mkdirSync, renameSync } from 'node:fs';\nimport { join } from 'node:path';\n\n/**\n * Shared object preloaded into Linux WebKit that restores errno around every signal handler installed with `sigaction`:\n * WebKit's thread-suspend handler returns from `sigsuspend` with errno set to EINTR on the thread it interrupted, which\n * fails an errno-checked parse in progress there (ICE candidates, SDP ports, GLib `getauxval`).\n * Freestanding, for glibc on x86_64 and aarch64, whose `struct sigaction` share this layout.\n *\n * Delete this file once Playwright ships a WebKit that restores errno itself — see `webkit-workarounds.md`.\n */\nexport const ERRNO_SHIM_SOURCE = `#define SA_SIGINFO_FLAG 4\n#define SIGNAL_COUNT 65\n#define RTLD_NEXT_HANDLE ((void *)-1L)\n\nstruct glibc_sigaction {\n void *handler;\n unsigned long mask[16];\n int flags;\n void (*restorer)(void);\n};\n\ntypedef int (*sigaction_fn)(int, const struct glibc_sigaction *, struct glibc_sigaction *);\n\nextern void *dlsym(void *handle, const char *name);\nextern int *__errno_location(void);\n\nstatic sigaction_fn next_sigaction;\n\n/* The handler the process installed for each signal, and whether it asked for siginfo. */\nstatic void *volatile handlers[SIGNAL_COUNT];\nstatic volatile int takes_siginfo[SIGNAL_COUNT];\n\n/* Resolved at load, so a signal handler never has to call dlsym; a constructor that ran earlier resolves it lazily. */\n__attribute__((constructor)) static void resolve_next_sigaction(void) {\n if (!next_sigaction) {\n next_sigaction = (sigaction_fn)dlsym(RTLD_NEXT_HANDLE, \"sigaction\");\n }\n}\n\n/* Passes all three arguments, which a one-argument handler ignores on x86_64 and aarch64. */\nstatic void trampoline(int signal, void *info, void *context) {\n int *error = __errno_location();\n int saved = *error;\n ((void (*)(int, void *, void *))handlers[signal])(signal, info, context);\n *error = saved;\n}\n\n/* Reports the process's own handler where the kernel holds the trampoline. */\nstatic void unwrap(struct glibc_sigaction *action, void *handler, int siginfo) {\n if (action && action->handler == (void *)trampoline) {\n action->handler = handler;\n action->flags = (action->flags & ~SA_SIGINFO_FLAG) | siginfo;\n }\n}\n\nint sigaction(int signal, const struct glibc_sigaction *action, struct glibc_sigaction *previous) {\n resolve_next_sigaction();\n if (signal <= 0 || signal >= SIGNAL_COUNT) {\n return next_sigaction(signal, action, previous);\n }\n\n void *old_handler = handlers[signal];\n int old_siginfo = takes_siginfo[signal];\n /* A trampoline read back through glibc's internal sigaction, as signal() returns it, keeps the recorded handler. */\n if (action && action->handler == (void *)trampoline) {\n struct glibc_sigaction restored = *action;\n restored.flags |= SA_SIGINFO_FLAG;\n int result = next_sigaction(signal, &restored, previous);\n if (result == 0) {\n unwrap(previous, old_handler, old_siginfo);\n }\n return result;\n }\n if (!action || action->handler == (void *)0 || action->handler == (void *)1) {\n int result = next_sigaction(signal, action, previous);\n if (result == 0) {\n unwrap(previous, old_handler, old_siginfo);\n }\n return result;\n }\n\n handlers[signal] = action->handler;\n takes_siginfo[signal] = action->flags & SA_SIGINFO_FLAG;\n struct glibc_sigaction wrapped = *action;\n wrapped.handler = (void *)trampoline;\n wrapped.flags |= SA_SIGINFO_FLAG;\n int result = next_sigaction(signal, &wrapped, previous);\n if (result != 0) {\n handlers[signal] = old_handler;\n takes_siginfo[signal] = old_siginfo;\n return result;\n }\n unwrap(previous, old_handler, old_siginfo);\n return result;\n}\n`;\n\n/** Whether {@link ERRNO_SHIM_SOURCE} fits this process's platform and architecture. */\nexport const errnoShimSupported = (): boolean =>\n process.platform === 'linux' && (process.arch === 'x64' || process.arch === 'arm64');\n\n/**\n * Compiles {@link ERRNO_SHIM_SOURCE} into `cacheDir` once per source, compiler invocation and architecture,\n * and returns its path.\n */\nexport const buildErrnoShim = (cacheDir: string): string => {\n const hash = createHash('sha256')\n .update(JSON.stringify([ERRNO_SHIM_SOURCE, compiler(), COMPILE_ARGS, LINK_ARGS]))\n .digest('hex')\n .slice(0, 16);\n const output = join(cacheDir, `errno-shim-${process.arch}-${hash}.so`);\n if (existsSync(output)) {\n return output;\n }\n\n mkdirSync(cacheDir, { recursive: true });\n // Renamed into place, so a concurrent Playwright worker never preloads a partly written file.\n const partial = `${output}.${process.pid}`;\n try {\n compileSharedObject(ERRNO_SHIM_SOURCE, partial);\n } catch (err) {\n const detail = err instanceof Error ? err.message : String(err);\n throw new Error(`Linux WebKit e2e needs a C compiler (\\`cc\\`, or \\`CC\\`) to build its errno shim: ${detail}`);\n }\n renameSync(partial, output);\n return output;\n};\n\nconst COMPILE_ARGS = ['-shared', '-fPIC', '-O2', '-x', 'c', '-o'];\nconst LINK_ARGS = ['-ldl'];\n\nconst compiler = (): string => process.env.CC || 'cc';\n\nexport const compileSharedObject = (source: string, output: string): void => {\n execFileSync(compiler(), [...COMPILE_ARGS, output, '-', ...LINK_ARGS], {\n input: source,\n stdio: ['pipe', 'ignore', 'pipe'],\n });\n};\n","//\n// Copyright 2022 DXOS.org\n//\n\nimport { trigger } from '@dxos/async';\n\n// Copied from @dxos/async.\nexport class Lock {\n private _lastPromise = Promise.resolve();\n\n async executeSynchronized<T>(fun: () => Promise<T>): Promise<T> {\n const prevPromise = this._lastPromise;\n const [getPromise, resolve] = trigger();\n this._lastPromise = getPromise();\n\n await prevPromise;\n try {\n const value = await fun();\n return value;\n } finally {\n resolve();\n }\n }\n}\n","//\n// Copyright 2023 DXOS.org\n//\n\n/* eslint-disable no-console */\n\nimport {\n type Browser,\n type BrowserContext,\n type Page,\n type PlaywrightTestConfig,\n type ReporterDescription,\n devices,\n} from '@playwright/test';\nimport { existsSync, mkdtempSync, readFileSync, rmSync } from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { dirname, join, resolve } from 'node:path';\nimport pkgUp from 'pkg-up';\n\nimport { buildErrnoShim, errnoShimSupported } from './errno-shim.ts';\nimport { Lock } from './lock.ts';\n\n/** Values that turn a boolean `DX_E2E_*` knob off; anything else, including unset, leaves it on. */\nconst DISABLED = new Set(['0', 'false']);\n\n/** All three work around bugs in Playwright's WebKit; `webkit-workarounds.md` says how to retest and retire them. */\nconst webkitWorkarounds = (): boolean => !DISABLED.has(process.env.DX_E2E_WEBKIT_WORKAROUNDS ?? '');\n\nconst findWorkspaceRoot = (startDir: string): string => {\n let dir = resolve(startDir);\n while (dir !== '/') {\n try {\n // Check for pnpm-workspace.yaml first (modern pnpm approach)\n const workspaceYamlPath = join(dir, 'pnpm-workspace.yaml');\n if (existsSync(workspaceYamlPath)) {\n return dir;\n }\n\n // Check for package.json with workspaces field (legacy approach)\n const pkgPath = join(dir, 'package.json');\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));\n if (pkg.workspaces) {\n return dir;\n }\n } catch {}\n const parent = dirname(dir);\n if (parent === dir) {\n break;\n }\n dir = parent;\n }\n\n throw new Error('Could not find pnpm workspace root');\n};\n\nexport const e2ePreset = (testDir: string): PlaywrightTestConfig => {\n const packageJson = pkgUp.sync({ cwd: testDir });\n const packageDir = packageJson!.split('/').slice(0, -1).join('/');\n const packageDirName = packageDir.split('/').pop();\n if (!packageDirName) {\n throw new Error('packageDirName not found');\n }\n\n const workspaceRoot = findWorkspaceRoot(packageDir);\n const testResultOuputDir = join(workspaceRoot, 'test-results/playwright/output', packageDirName);\n const reporterOutputFile = join(workspaceRoot, 'test-results/playwright/report', `${packageDirName}.json`);\n\n const browser = process.env.PLAYWRIGHT_BROWSER || (process.env.CI ? 'all' : 'chromium');\n const runsWebKit = browser === 'all' || browser === 'webkit';\n // In the Claude Code cloud sandbox chromium needs a pinned executable, the egress proxy passed via\n // ARGS (Playwright's `proxy:` option drops its bypass list for non-default contexts), and a TLS 1.2\n // cap (see the cloud-sandbox skill). Gated so real dev/CI runs are never silently downgraded.\n const sandboxProxy = process.env.CLAUDE_CODE_REMOTE ? process.env.HTTPS_PROXY : undefined;\n const sandboxChromium = sandboxProxy\n ? {\n launchOptions: {\n executablePath: '/opt/pw-browsers/chromium',\n args: [\n '--no-sandbox',\n `--proxy-server=${sandboxProxy}`,\n '--proxy-bypass-list=127.0.0.1;localhost',\n '--ssl-version-max=tls1.2',\n ],\n },\n }\n : {};\n const projects = [\n {\n name: 'chromium',\n use: { ...devices['Desktop Chrome'], ...sandboxChromium },\n },\n {\n name: 'firefox',\n use: { ...devices['Desktop Firefox'] },\n },\n ...(runsWebKit\n ? [\n {\n name: 'webkit',\n use: {\n ...devices['Desktop Safari'],\n launchOptions: { env: webKitLaunchEnv(workspaceRoot) },\n },\n },\n ]\n : []),\n ].filter((project) => {\n return browser === 'all' || project.name === browser;\n });\n\n return {\n testDir,\n outputDir: testResultOuputDir,\n // Playwright's default is 30s, which equals the action bound below — leaving a test no budget beyond\n // a single slow action. Storybook-backed suites also pay an on-demand story compile in the first\n // test's `beforeEach`, which alone exceeded 30s. Individual configs may still raise this.\n timeout: 60_000,\n // Run tests in files in parallel.\n fullyParallel: true,\n // Fail the build on CI if you accidentally left test.only in the source code.\n forbidOnly: !!process.env.CI,\n // No retries anywhere: retrying hides flakes behind a 3x time cost, making shard timings unusable\n // for sizing the suite. A flake now fails loudly and gets skipped with a TODO instead.\n retries: 0,\n // 4 workers starved shared setup into false \"not stable\"/\"detached\" failures, so 2 is the\n // compromise. `|| 2`, not `??`: an env var set to the empty string (common in Actions) would\n // otherwise coerce to 0 workers.\n workers: Number(process.env.PLAYWRIGHT_WORKERS) || 2,\n // Reporter to use. See https://playwright.dev/docs/test-reporters.\n reporter: [\n ...(process.env.CI\n ? ([\n ['list'],\n [\n 'json',\n {\n outputFile: reporterOutputFile,\n },\n ],\n ['junit', { outputFile: reporterOutputFile.replace(/\\.json$/, '.xml') }],\n ] satisfies ReporterDescription[])\n : ([['list']] satisfies ReporterDescription[])),\n ],\n use: {\n trace: 'retain-on-failure',\n // Playwright's default is no limit, so a stuck locator would absorb the whole per-test budget and\n // report a bare `Test timeout` naming nothing.\n actionTimeout: 30_000,\n },\n projects,\n };\n};\n\n/** `process.env` without unset keys, the shape Playwright's launch `env` takes. */\nconst definedEnv = (): Record<string, string> => {\n const env: Record<string, string> = {};\n for (const [key, value] of Object.entries(process.env)) {\n if (value !== undefined) {\n env[key] = value;\n }\n }\n return env;\n};\n\n/**\n * Environment for a WebKit launch. Replaces the browser's whole environment rather than extending it,\n * so it carries `process.env` alongside the two crash workarounds.\n */\nconst webKitLaunchEnv = (workspaceRoot: string): Record<string, string> => {\n // x86_64 Linux WebKit: every captured boot crash faulted in the wasm in-place interpreter (IPInt) with a corrupted\n // locals base or wasm PC.\n const disableWasmIPInt = webkitWorkarounds() && process.platform === 'linux' && process.arch === 'x64';\n const errnoShim =\n webkitWorkarounds() && errnoShimSupported()\n ? buildErrnoShim(join(workspaceRoot, 'node_modules/.cache/dxos-test-utils'))\n : undefined;\n return {\n ...(disableWasmIPInt ? { JSC_useWasmIPInt: 'false' } : {}),\n ...definedEnv(),\n ...(errnoShim ? { LD_PRELOAD: [errnoShim, process.env.LD_PRELOAD].filter(Boolean).join(':') } : {}),\n };\n};\n\n/**\n * WebKit keeps OPFS under the browser's data directory, and an ephemeral context has none, so every\n * `navigator.storage` call there fails and no app backed by OPFS boots. A persistent context has one.\n * Its temporary directory is per context, which keeps the isolation a fresh context gives.\n */\nconst createContext = async (browser: Browser): Promise<{ context: BrowserContext; page?: Page }> => {\n const browserType = browser.browserType();\n if (browserType.name() !== 'webkit' || !webkitWorkarounds()) {\n return { context: await browser.newContext() };\n }\n\n const userDataDir = mkdtempSync(join(tmpdir(), 'dxos-webkit-'));\n const context = await browserType.launchPersistentContext(userDataDir, {\n env: webKitLaunchEnv(findWorkspaceRoot(process.cwd())),\n });\n context.once('close', () => rmSync(userDataDir, { recursive: true, force: true }));\n // A persistent context opens with a page; taking it leaves no blank page behind.\n return { context, page: context.pages()[0] };\n};\n\nexport type SetupOptions = {\n url?: string;\n bridgeLogs?: boolean;\n viewportSize?: Parameters<Page['setViewportSize']>[0];\n};\n\n/**\n * Opens a page, creating a context for it unless handed one to borrow.\n * `close()` disposes whatever this created: the context when it made one, otherwise just the page.\n */\nexport const setupPage = async (browser: Browser | BrowserContext, options: SetupOptions = {}) => {\n const { url, bridgeLogs, viewportSize } = options;\n\n const created = 'newContext' in browser ? await createContext(browser) : undefined;\n const context = created?.context ?? (browser as BrowserContext);\n const ownsContext = created !== undefined;\n let page: Page | undefined;\n\n // Playwright opens a trace chunk on every live context at test start, so a context left behind by a\n // closed page is re-serialized into every later trace in that worker.\n const close = async (): Promise<void> => {\n await (ownsContext ? context.close() : page?.close());\n };\n\n try {\n page = created?.page ?? (await context.newPage());\n\n if (viewportSize) {\n await page.setViewportSize(viewportSize);\n }\n\n // TODO(wittjosiah): Remove?\n if (bridgeLogs) {\n const lock = new Lock();\n\n page.on('pageerror', async (error) => {\n await lock.executeSynchronized(async () => {\n // eslint-disable-next-line no-console\n console.log(error);\n });\n });\n\n page.on('console', async (msg) => {\n try {\n const argsPromise = Promise.all(msg.args().map((x) => x.jsonValue()));\n await lock.executeSynchronized(async () => {\n const args = await argsPromise;\n\n if (args.length > 0) {\n console.log(...args);\n } else {\n console.log(msg);\n }\n });\n } catch (err) {\n console.error('Failed to parse message', err);\n }\n });\n }\n\n if (url) {\n await page.goto(url);\n }\n\n return { context, page, close };\n } catch (err) {\n // The caller never received `close`, so this is the only chance to dispose what got created. The\n // setup error is the one worth reporting, so a failure to clean up does not displace it.\n await close().catch(() => {});\n throw err;\n }\n};\n\nexport const storybookUrl = (storyId: string, port = 9009) =>\n `http://localhost:${port}/iframe.html?id=${storyId}&viewMode=story`;\n\n/**\n * Playwright `webServer` for a Storybook-backed suite. Readiness is probed by `url` rather than\n * `port` because a `port` probe is a bare TCP check, which `storybook dev` satisfies by binding the\n * socket before it can serve — tests starting in that gap get ERR_CONNECTION_REFUSED.\n */\nexport const storybookWebServer = (port: number) => ({\n command: `pnpm storybook dev --ci --quiet --port=${port} --config-dir=.storybook`,\n url: `http://localhost:${port}`,\n reuseExistingServer: false,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,IAAa,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwFjC,IAAa,2BACX,QAAQ,aAAa,YAAY,QAAQ,SAAS,SAAS,QAAQ,SAAS;;;;;AAM9E,IAAa,kBAAkB,aAA6B;CAC1D,MAAM,OAAO,WAAW,QAAQ,CAAA,CAC7B,OAAO,KAAK,UAAU;EAAC;EAAmB,SAAS;EAAG;EAAc;CAAS,CAAC,CAAC,CAAA,CAC/E,OAAO,KAAK,CAAA,CACZ,MAAM,GAAG,EAAE;CACd,MAAM,SAAS,KAAK,UAAU,cAAc,QAAQ,KAAK,GAAG,KAAK,IAAI;CACrE,IAAI,WAAW,MAAM,GACnB,OAAO;CAGT,UAAU,UAAU,EAAE,WAAW,KAAK,CAAC;CAEvC,MAAM,UAAU,GAAG,OAAO,GAAG,QAAQ;CACrC,IAAI;EACF,oBAAoB,mBAAmB,OAAO;CAChD,SAAS,KAAK;EACZ,MAAM,SAAS,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;EAC9D,MAAM,IAAI,MAAM,oFAAoF,QAAQ;CAC9G;CACA,WAAW,SAAS,MAAM;CAC1B,OAA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B"}
1
+ {"version":3,"file":"playwright.mjs","names":[],"sources":["../../src/errno-shim.ts","../../src/lock.ts","../../src/playwright.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport { execFileSync } from 'node:child_process';\nimport { createHash } from 'node:crypto';\nimport { existsSync, mkdirSync, renameSync } from 'node:fs';\nimport { join } from 'node:path';\n\n/**\n * Shared object preloaded into Linux WebKit that restores errno around every signal handler installed with `sigaction`:\n * WebKit's thread-suspend handler returns from `sigsuspend` with errno set to EINTR on the thread it interrupted, which\n * fails an errno-checked parse in progress there (ICE candidates, SDP ports, GLib `getauxval`).\n * Freestanding, for glibc on x86_64 and aarch64, whose `struct sigaction` share this layout.\n *\n * Delete this file once Playwright ships a WebKit that restores errno itself — see `webkit-workarounds.md`.\n */\nexport const ERRNO_SHIM_SOURCE = `#define SA_SIGINFO_FLAG 4\n#define SIGNAL_COUNT 65\n#define RTLD_NEXT_HANDLE ((void *)-1L)\n\nstruct glibc_sigaction {\n void *handler;\n unsigned long mask[16];\n int flags;\n void (*restorer)(void);\n};\n\ntypedef int (*sigaction_fn)(int, const struct glibc_sigaction *, struct glibc_sigaction *);\n\nextern void *dlsym(void *handle, const char *name);\nextern int *__errno_location(void);\n\nstatic sigaction_fn next_sigaction;\n\n/* The handler the process installed for each signal, and whether it asked for siginfo. */\nstatic void *volatile handlers[SIGNAL_COUNT];\nstatic volatile int takes_siginfo[SIGNAL_COUNT];\n\n/* Resolved at load, so a signal handler never has to call dlsym; a constructor that ran earlier resolves it lazily. */\n__attribute__((constructor)) static void resolve_next_sigaction(void) {\n if (!next_sigaction) {\n next_sigaction = (sigaction_fn)dlsym(RTLD_NEXT_HANDLE, \"sigaction\");\n }\n}\n\n/* Passes all three arguments, which a one-argument handler ignores on x86_64 and aarch64. */\nstatic void trampoline(int signal, void *info, void *context) {\n int *error = __errno_location();\n int saved = *error;\n ((void (*)(int, void *, void *))handlers[signal])(signal, info, context);\n *error = saved;\n}\n\n/* Reports the process's own handler where the kernel holds the trampoline. */\nstatic void unwrap(struct glibc_sigaction *action, void *handler, int siginfo) {\n if (action && action->handler == (void *)trampoline) {\n action->handler = handler;\n action->flags = (action->flags & ~SA_SIGINFO_FLAG) | siginfo;\n }\n}\n\nint sigaction(int signal, const struct glibc_sigaction *action, struct glibc_sigaction *previous) {\n resolve_next_sigaction();\n if (signal <= 0 || signal >= SIGNAL_COUNT) {\n return next_sigaction(signal, action, previous);\n }\n\n void *old_handler = handlers[signal];\n int old_siginfo = takes_siginfo[signal];\n /* A trampoline read back through glibc's internal sigaction, as signal() returns it, keeps the recorded handler. */\n if (action && action->handler == (void *)trampoline) {\n struct glibc_sigaction restored = *action;\n restored.flags |= SA_SIGINFO_FLAG;\n int result = next_sigaction(signal, &restored, previous);\n if (result == 0) {\n unwrap(previous, old_handler, old_siginfo);\n }\n return result;\n }\n if (!action || action->handler == (void *)0 || action->handler == (void *)1) {\n int result = next_sigaction(signal, action, previous);\n if (result == 0) {\n unwrap(previous, old_handler, old_siginfo);\n }\n return result;\n }\n\n handlers[signal] = action->handler;\n takes_siginfo[signal] = action->flags & SA_SIGINFO_FLAG;\n struct glibc_sigaction wrapped = *action;\n wrapped.handler = (void *)trampoline;\n wrapped.flags |= SA_SIGINFO_FLAG;\n int result = next_sigaction(signal, &wrapped, previous);\n if (result != 0) {\n handlers[signal] = old_handler;\n takes_siginfo[signal] = old_siginfo;\n return result;\n }\n unwrap(previous, old_handler, old_siginfo);\n return result;\n}\n`;\n\n/** Whether {@link ERRNO_SHIM_SOURCE} fits this process's platform and architecture. */\nexport const errnoShimSupported = (): boolean =>\n process.platform === 'linux' && (process.arch === 'x64' || process.arch === 'arm64');\n\n/**\n * Compiles {@link ERRNO_SHIM_SOURCE} into `cacheDir` once per source, compiler invocation and architecture,\n * and returns its path.\n */\nexport const buildErrnoShim = (cacheDir: string): string => {\n const hash = createHash('sha256')\n .update(JSON.stringify([ERRNO_SHIM_SOURCE, compiler(), COMPILE_ARGS, LINK_ARGS]))\n .digest('hex')\n .slice(0, 16);\n const output = join(cacheDir, `errno-shim-${process.arch}-${hash}.so`);\n if (existsSync(output)) {\n return output;\n }\n\n mkdirSync(cacheDir, { recursive: true });\n // Renamed into place, so a concurrent Playwright worker never preloads a partly written file.\n const partial = `${output}.${process.pid}`;\n try {\n compileSharedObject(ERRNO_SHIM_SOURCE, partial);\n } catch (err) {\n const detail = err instanceof Error ? err.message : String(err);\n throw new Error(`Linux WebKit e2e needs a C compiler (\\`cc\\`, or \\`CC\\`) to build its errno shim: ${detail}`);\n }\n renameSync(partial, output);\n return output;\n};\n\nconst COMPILE_ARGS = ['-shared', '-fPIC', '-O2', '-x', 'c', '-o'];\nconst LINK_ARGS = ['-ldl'];\n\nconst compiler = (): string => process.env.CC || 'cc';\n\nexport const compileSharedObject = (source: string, output: string): void => {\n execFileSync(compiler(), [...COMPILE_ARGS, output, '-', ...LINK_ARGS], {\n input: source,\n stdio: ['pipe', 'ignore', 'pipe'],\n });\n};\n","//\n// Copyright 2022 DXOS.org\n//\n\nimport { trigger } from '@dxos/async';\n\n// Copied from @dxos/async.\nexport class Lock {\n private _lastPromise = Promise.resolve();\n\n async executeSynchronized<T>(fun: () => Promise<T>): Promise<T> {\n const prevPromise = this._lastPromise;\n const [getPromise, resolve] = trigger();\n this._lastPromise = getPromise();\n\n await prevPromise;\n try {\n const value = await fun();\n return value;\n } finally {\n resolve();\n }\n }\n}\n","//\n// Copyright 2023 DXOS.org\n//\n\n/* eslint-disable no-console */\n\nimport {\n type Browser,\n type BrowserContext,\n type Page,\n type PlaywrightTestConfig,\n type ReporterDescription,\n devices,\n} from '@playwright/test';\nimport { existsSync, mkdtempSync, readFileSync, rmSync } from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { dirname, join, resolve } from 'node:path';\nimport pkgUp from 'pkg-up';\n\nimport { buildErrnoShim, errnoShimSupported } from './errno-shim.ts';\nimport { Lock } from './lock.ts';\n\n/** Values that turn a boolean `DX_E2E_*` knob off; anything else, including unset, leaves it on. */\nconst DISABLED = new Set(['0', 'false']);\n\n/** All three work around bugs in Playwright's WebKit; `webkit-workarounds.md` says how to retest and retire them. */\nconst webkitWorkarounds = (): boolean => !DISABLED.has(process.env.DX_E2E_WEBKIT_WORKAROUNDS ?? '');\n\nconst findWorkspaceRoot = (startDir: string): string => {\n let dir = resolve(startDir);\n while (dir !== '/') {\n try {\n // Check for pnpm-workspace.yaml first (modern pnpm approach)\n const workspaceYamlPath = join(dir, 'pnpm-workspace.yaml');\n if (existsSync(workspaceYamlPath)) {\n return dir;\n }\n\n // Check for package.json with workspaces field (legacy approach)\n const pkgPath = join(dir, 'package.json');\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));\n if (pkg.workspaces) {\n return dir;\n }\n } catch {}\n const parent = dirname(dir);\n if (parent === dir) {\n break;\n }\n dir = parent;\n }\n\n throw new Error('Could not find pnpm workspace root');\n};\n\nexport const e2ePreset = (testDir: string): PlaywrightTestConfig => {\n const packageJson = pkgUp.sync({ cwd: testDir });\n const packageDir = packageJson!.split('/').slice(0, -1).join('/');\n const packageDirName = packageDir.split('/').pop();\n if (!packageDirName) {\n throw new Error('packageDirName not found');\n }\n\n const workspaceRoot = findWorkspaceRoot(packageDir);\n const testResultOuputDir = join(workspaceRoot, 'test-results/playwright/output', packageDirName);\n const reporterOutputFile = join(workspaceRoot, 'test-results/playwright/report', `${packageDirName}.json`);\n\n const browser = process.env.PLAYWRIGHT_BROWSER || (process.env.CI ? 'all' : 'chromium');\n const runsWebKit = browser === 'all' || browser === 'webkit';\n // In the Claude Code cloud sandbox chromium needs a pinned executable, the egress proxy passed via\n // ARGS (Playwright's `proxy:` option drops its bypass list for non-default contexts), and a TLS 1.2\n // cap (see the cloud-sandbox skill). Gated so real dev/CI runs are never silently downgraded.\n const sandboxProxy = process.env.CLAUDE_CODE_REMOTE ? process.env.HTTPS_PROXY : undefined;\n const sandboxChromium = sandboxProxy\n ? {\n launchOptions: {\n executablePath: '/opt/pw-browsers/chromium',\n args: [\n '--no-sandbox',\n `--proxy-server=${sandboxProxy}`,\n '--proxy-bypass-list=127.0.0.1;localhost',\n '--ssl-version-max=tls1.2',\n ],\n },\n }\n : {};\n const projects = [\n {\n name: 'chromium',\n use: { ...devices['Desktop Chrome'], ...sandboxChromium },\n },\n {\n name: 'firefox',\n use: { ...devices['Desktop Firefox'] },\n },\n ...(runsWebKit\n ? [\n {\n name: 'webkit',\n use: {\n ...devices['Desktop Safari'],\n launchOptions: { env: webKitLaunchEnv(workspaceRoot) },\n },\n },\n ]\n : []),\n ].filter((project) => {\n return browser === 'all' || project.name === browser;\n });\n\n return {\n testDir,\n outputDir: testResultOuputDir,\n // Playwright's default is 30s, which equals the action bound below — leaving a test no budget beyond\n // a single slow action. Storybook-backed suites also pay an on-demand story compile in the first\n // test's `beforeEach`, which alone exceeded 30s. Individual configs may still raise this.\n timeout: 60_000,\n // Run tests in files in parallel.\n fullyParallel: true,\n // Fail the build on CI if you accidentally left test.only in the source code.\n forbidOnly: !!process.env.CI,\n // No retries anywhere: retrying hides flakes behind a 3x time cost, making shard timings unusable\n // for sizing the suite. A flake now fails loudly and gets skipped with a TODO instead.\n retries: 0,\n // 4 workers starved shared setup into false \"not stable\"/\"detached\" failures, so 2 is the\n // compromise. `|| 2`, not `??`: an env var set to the empty string (common in Actions) would\n // otherwise coerce to 0 workers.\n workers: Number(process.env.PLAYWRIGHT_WORKERS) || 2,\n // Reporter to use. See https://playwright.dev/docs/test-reporters.\n reporter: [\n ...(process.env.CI\n ? ([\n ['list'],\n [\n 'json',\n {\n outputFile: reporterOutputFile,\n },\n ],\n ['junit', { outputFile: reporterOutputFile.replace(/\\.json$/, '.xml') }],\n ] satisfies ReporterDescription[])\n : ([['list']] satisfies ReporterDescription[])),\n ],\n use: {\n trace: 'retain-on-failure',\n // Playwright's default is no limit, so a stuck locator would absorb the whole per-test budget and\n // report a bare `Test timeout` naming nothing.\n actionTimeout: 30_000,\n },\n projects,\n };\n};\n\n/** `process.env` without unset keys, the shape Playwright's launch `env` takes. */\nconst definedEnv = (): Record<string, string> => {\n const env: Record<string, string> = {};\n for (const [key, value] of Object.entries(process.env)) {\n if (value !== undefined) {\n env[key] = value;\n }\n }\n return env;\n};\n\n/**\n * Environment for a WebKit launch. Replaces the browser's whole environment rather than extending it,\n * so it carries `process.env` alongside the two crash workarounds.\n */\nconst webKitLaunchEnv = (workspaceRoot: string): Record<string, string> => {\n // x86_64 Linux WebKit: every captured boot crash faulted in the wasm in-place interpreter (IPInt) with a corrupted\n // locals base or wasm PC.\n const disableWasmIPInt = webkitWorkarounds() && process.platform === 'linux' && process.arch === 'x64';\n const errnoShim =\n webkitWorkarounds() && errnoShimSupported()\n ? buildErrnoShim(join(workspaceRoot, 'node_modules/.cache/dxos-test-utils'))\n : undefined;\n return {\n ...(disableWasmIPInt ? { JSC_useWasmIPInt: 'false' } : {}),\n ...definedEnv(),\n ...(errnoShim ? { LD_PRELOAD: [errnoShim, process.env.LD_PRELOAD].filter(Boolean).join(':') } : {}),\n };\n};\n\n/**\n * WebKit keeps OPFS under the browser's data directory, and an ephemeral context has none, so every\n * `navigator.storage` call there fails and no app backed by OPFS boots. A persistent context has one.\n * Its temporary directory is per context, which keeps the isolation a fresh context gives. On macOS\n * WebKit puts OPFS under the home directory instead, shared by every context and kept across runs,\n * so the home directory is pointed at the context's directory too.\n */\nconst createContext = async (browser: Browser): Promise<{ context: BrowserContext; page?: Page }> => {\n const browserType = browser.browserType();\n if (browserType.name() !== 'webkit' || !webkitWorkarounds()) {\n return { context: await browser.newContext() };\n }\n\n const userDataDir = mkdtempSync(join(tmpdir(), 'dxos-webkit-'));\n const context = await browserType.launchPersistentContext(userDataDir, {\n env: {\n ...webKitLaunchEnv(findWorkspaceRoot(process.cwd())),\n ...(process.platform === 'darwin' ? { CFFIXED_USER_HOME: userDataDir } : {}),\n },\n });\n context.once('close', () => rmSync(userDataDir, { recursive: true, force: true }));\n // A persistent context opens with a page; taking it leaves no blank page behind.\n return { context, page: context.pages()[0] };\n};\n\nexport type SetupOptions = {\n url?: string;\n bridgeLogs?: boolean;\n viewportSize?: Parameters<Page['setViewportSize']>[0];\n};\n\n/**\n * Opens a page, creating a context for it unless handed one to borrow.\n * `close()` disposes whatever this created: the context when it made one, otherwise just the page.\n */\nexport const setupPage = async (browser: Browser | BrowserContext, options: SetupOptions = {}) => {\n const { url, bridgeLogs, viewportSize } = options;\n\n const created = 'newContext' in browser ? await createContext(browser) : undefined;\n const context = created?.context ?? (browser as BrowserContext);\n const ownsContext = created !== undefined;\n let page: Page | undefined;\n\n // Playwright opens a trace chunk on every live context at test start, so a context left behind by a\n // closed page is re-serialized into every later trace in that worker.\n const close = async (): Promise<void> => {\n await (ownsContext ? context.close() : page?.close());\n };\n\n try {\n page = created?.page ?? (await context.newPage());\n\n if (viewportSize) {\n await page.setViewportSize(viewportSize);\n }\n\n // TODO(wittjosiah): Remove?\n if (bridgeLogs) {\n const lock = new Lock();\n\n page.on('pageerror', async (error) => {\n await lock.executeSynchronized(async () => {\n // eslint-disable-next-line no-console\n console.log(error);\n });\n });\n\n page.on('console', async (msg) => {\n try {\n const argsPromise = Promise.all(msg.args().map((x) => x.jsonValue()));\n await lock.executeSynchronized(async () => {\n const args = await argsPromise;\n\n if (args.length > 0) {\n console.log(...args);\n } else {\n console.log(msg);\n }\n });\n } catch (err) {\n console.error('Failed to parse message', err);\n }\n });\n }\n\n if (url) {\n await page.goto(url);\n }\n\n return { context, page, close };\n } catch (err) {\n // The caller never received `close`, so this is the only chance to dispose what got created. The\n // setup error is the one worth reporting, so a failure to clean up does not displace it.\n await close().catch(() => {});\n throw err;\n }\n};\n\n/**\n * Opens `url` once and waits for `ready`, so Storybook's on-demand compile of the story (about 50 s on a\n * 4 vCPU runner) is paid outside every test's own budget. Call from `test.beforeAll` after raising its\n * timeout with `test.setTimeout`.\n */\nexport const warmStory = async (\n browser: Browser,\n url: string,\n ready: (page: Page) => Promise<unknown>,\n): Promise<void> => {\n const { page, close } = await setupPage(browser, { url });\n try {\n await ready(page);\n } finally {\n await close();\n }\n};\n\nexport const storybookUrl = (storyId: string, port = 9009) =>\n `http://localhost:${port}/iframe.html?id=${storyId}&viewMode=story`;\n\n/**\n * Playwright `webServer` for a Storybook-backed suite. Readiness is probed by `url` rather than\n * `port` because a `port` probe is a bare TCP check, which `storybook dev` satisfies by binding the\n * socket before it can serve — tests starting in that gap get ERR_CONNECTION_REFUSED.\n */\nexport const storybookWebServer = (port: number) => ({\n command: `pnpm storybook dev --ci --quiet --port=${port} --config-dir=.storybook`,\n // Playwright starts the server beside the config (`<package>/src/playwright`); `.storybook` is at the package root.\n cwd: '../..',\n url: `http://localhost:${port}`,\n reuseExistingServer: false,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,IAAa,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwFjC,IAAa,2BACX,QAAQ,aAAa,YAAY,QAAQ,SAAS,SAAS,QAAQ,SAAS;;;;;AAM9E,IAAa,kBAAkB,aAA6B;CAC1D,MAAM,OAAO,WAAW,QAAQ,CAAC,CAC9B,OAAO,KAAK,UAAU;EAAC;EAAmB,SAAS;EAAG;EAAc;CAAS,CAAC,CAAC,CAAC,CAChF,OAAO,KAAK,CAAC,CACb,MAAM,GAAG,EAAE;CACd,MAAM,SAAS,KAAK,UAAU,cAAc,QAAQ,KAAK,GAAG,KAAK,IAAI;CACrE,IAAI,WAAW,MAAM,GACnB,OAAO;CAGT,UAAU,UAAU,EAAE,WAAW,KAAK,CAAC;CAEvC,MAAM,UAAU,GAAG,OAAO,GAAG,QAAQ;CACrC,IAAI;EACF,oBAAoB,mBAAmB,OAAO;CAChD,SAAS,KAAK;EACZ,MAAM,SAAS,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;EAC9D,MAAM,IAAI,MAAM,oFAAoF,QAAQ;CAC9G;CACA,WAAW,SAAS,MAAM;CAC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,UAAU,SAAS,EAAE,IAAI,CAAC;CACxD,IAAI;EACF,MAAM,MAAM,IAAI;CAClB,UAAU;EACR,MAAM,MAAM;CACd;AACF;AAEA,IAAa,gBAAgB,SAAiB,OAAO,SACnD,oBAAoB,KAAK,kBAAkB,QAAQ;;;;;;AAOrD,IAAa,sBAAsB,UAAkB;CACnD,SAAS,0CAA0C,KAAK;CAExD,KAAK;CACL,KAAK,oBAAoB;CACzB,qBAAqB;AACvB"}
@@ -17,6 +17,14 @@ export type ClaudeAgentOptions = {
17
17
  model: string;
18
18
  /** Tools the agent may use without a prompt. Anything else is denied outright. */
19
19
  allowedTools: string[];
20
+ /** Plugin directories to load; with `--bare` no installed plugin loads, so these are the only ones. */
21
+ pluginDirs?: string[];
22
+ /**
23
+ * `--bare` (the default) also cuts the toolset to Bash, Edit and Read, so a plugin's skills cannot
24
+ * load. When false, the agent runs with the full toolset against an empty config directory, which
25
+ * isolates it from the developer's settings, plugins, CLAUDE.md and memory instead.
26
+ */
27
+ bare?: boolean;
20
28
  /** Ceiling for one turn, in ms. */
21
29
  timeout?: number;
22
30
  };
@@ -95,7 +103,7 @@ export declare class ClaudeAgent {
95
103
  * Nothing is sent yet — the CLI sits waiting on stdin — so a caller can scaffold whatever the
96
104
  * first turn will act on before spending a token on it.
97
105
  */
98
- static start({ cwd, mcpServers, apiKey, model, allowedTools, timeout, }: ClaudeAgentOptions): ClaudeAgent;
106
+ static start({ cwd, mcpServers, apiKey, model, allowedTools, pluginDirs, bare, timeout, }: ClaudeAgentOptions): ClaudeAgent;
99
107
  /**
100
108
  * Sends one user message and resolves when that turn's `result` event arrives.
101
109
  *
@@ -1 +1 @@
1
- {"version":3,"file":"claude-agent.d.ts","sourceRoot":"","sources":["../../../src/claude-agent.ts"],"names":[],"mappings":"AAOA;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,yFAAyF;IACzF,GAAG,EAAE,MAAM,CAAC;IACZ,qGAAqG;IACrG,UAAU,EAAE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AG,WAAW,CA4DlC;IAED;;;;;;;OAOG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA8ClC;IAED;;;;;OAKG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAiB3B;CA4BF"}
@@ -14,6 +14,12 @@ export declare const setupPage: (browser: Browser | BrowserContext, options?: Se
14
14
  page: Page;
15
15
  close: () => Promise<void>;
16
16
  }>;
17
+ /**
18
+ * Opens `url` once and waits for `ready`, so Storybook's on-demand compile of the story (about 50 s on a
19
+ * 4 vCPU runner) is paid outside every test's own budget. Call from `test.beforeAll` after raising its
20
+ * timeout with `test.setTimeout`.
21
+ */
22
+ export declare const warmStory: (browser: Browser, url: string, ready: (page: Page) => Promise<unknown>) => Promise<void>;
17
23
  export declare const storybookUrl: (storyId: string, port?: number) => string;
18
24
  /**
19
25
  * Playwright `webServer` for a Storybook-backed suite. Readiness is probed by `url` rather than
@@ -22,6 +28,7 @@ export declare const storybookUrl: (storyId: string, port?: number) => string;
22
28
  */
23
29
  export declare const storybookWebServer: (port: number) => {
24
30
  command: string;
31
+ cwd: string;
25
32
  url: string;
26
33
  reuseExistingServer: boolean;
27
34
  };
@@ -1 +1 @@
1
- {"version":3,"file":"playwright.d.ts","sourceRoot":"","sources":["../../../src/playwright.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,IAAI,EACT,KAAK,oBAAoB,EAG1B,MAAM,kBAAkB,CAAC;AA0C1B,eAAO,MAAM,SAAS,YAAa,MAAM,KAAG,oBAgG3C,CAAC;AAoDF,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,UAAU,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACvD,CAAC;AAEF;;;GAGG;A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