Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/core/lib/v3/dom/genA11yScripts.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import fs from "node:fs";
import path from "node:path";
import { pathToFileURL } from "node:url";
import path, { dirname } from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
import esbuild from "esbuild";

const __dirname = dirname(fileURLToPath(import.meta.url));
const here = __dirname;
const srcDir = path.join(here, "./a11yScripts");
const outDir = path.join(here, "./build");
Expand Down
4 changes: 3 additions & 1 deletion packages/core/lib/v3/dom/genDomScripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
* as a string constant (`v3ScriptContent`) for CDP injection (document-start).
*/
import fs from "node:fs";
import path from "node:path";
import path, { dirname } from "node:path";
import { fileURLToPath } from "node:url";
import esbuild from "esbuild";

const __dirname = dirname(fileURLToPath(import.meta.url));
const here = __dirname;
const outDir = path.join(here, "./build");
fs.mkdirSync(outDir, { recursive: true });
Expand Down
5 changes: 3 additions & 2 deletions packages/core/lib/v3/dom/genLocatorScripts.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import fs from "node:fs";
import path from "node:path";
import { pathToFileURL } from "node:url";
import path, { dirname } from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
import esbuild from "esbuild";

const __dirname = dirname(fileURLToPath(import.meta.url));
const here = __dirname;
const outDir = path.join(here, "./build");
const entry = path.join(here, "./locatorScripts/index.ts");
Expand Down
1 change: 0 additions & 1 deletion packages/core/lib/v3/llm/AnthropicClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { toJsonSchema } from "../zodCompat";
export class AnthropicClient extends LLMClient {
public type = "anthropic" as const;
private client: Anthropic;
public clientOptions: ClientOptions;

constructor({
modelName,
Expand Down
3 changes: 1 addition & 2 deletions packages/core/lib/v3/llm/CerebrasClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import { toJsonSchema } from "../zodCompat";
export class CerebrasClient extends LLMClient {
public type = "cerebras" as const;
private client: OpenAI;
public clientOptions: ClientOptions;
public hasVision = false;
public override hasVision = false;

constructor({
modelName,
Expand Down
2 changes: 0 additions & 2 deletions packages/core/lib/v3/llm/GoogleClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ const safetySettings = [
export class GoogleClient extends LLMClient {
public type = "google" as const;
private client: GoogleGenAI;
public clientOptions: ClientOptions;
public hasVision: boolean;
private logger: (message: LogLine) => void;

constructor({
Expand Down
3 changes: 1 addition & 2 deletions packages/core/lib/v3/llm/GroqClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import { toJsonSchema } from "../zodCompat";
export class GroqClient extends LLMClient {
public type = "groq" as const;
private client: OpenAI;
public clientOptions: ClientOptions;
public hasVision = false;
public override hasVision = false;

constructor({
modelName,
Expand Down
1 change: 0 additions & 1 deletion packages/core/lib/v3/llm/OpenAIClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import { toJsonSchema } from "../zodCompat";
export class OpenAIClient extends LLMClient {
public type = "openai" as const;
private client: OpenAI;
public clientOptions: ClientOptions;

constructor({
modelName,
Expand Down
5 changes: 4 additions & 1 deletion packages/core/lib/v3/tests/v3.bb.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import type { V3Options } from "../types/public/options";
import type { LogLine } from "../types/public/logs";
import dotenv from "dotenv";
import path from "path";
import path, { dirname } from "path";
import { fileURLToPath } from "url";

const __dirname = dirname(fileURLToPath(import.meta.url));

dotenv.config();

Expand Down
5 changes: 4 additions & 1 deletion packages/core/lib/v3/tests/v3.bb.playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { defineConfig } from "@playwright/test";
import dotenv from "dotenv";
import path from "path";
import path, { dirname } from "path";
import { fileURLToPath } from "url";

const __dirname = dirname(fileURLToPath(import.meta.url));

// Load environment variables before setting TEST_ENV
dotenv.config();
Expand Down
5 changes: 4 additions & 1 deletion packages/core/lib/v3/tests/v3.dynamic.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import type { V3Options } from "../types/public/options";
import type { LogLine } from "../types/public/logs";
import dotenv from "dotenv";
import path from "path";
import path, { dirname } from "path";
import { fileURLToPath } from "url";

const __dirname = dirname(fileURLToPath(import.meta.url));

dotenv.config();

Expand Down
5 changes: 4 additions & 1 deletion packages/core/lib/v3/tests/v3.local.playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { defineConfig } from "@playwright/test";
import dotenv from "dotenv";
import path from "path";
import path, { dirname } from "path";
import { fileURLToPath } from "url";

const __dirname = dirname(fileURLToPath(import.meta.url));

// Load environment variables before setting TEST_ENV
dotenv.config();
Expand Down
12 changes: 10 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
{
"name": "@browserbasehq/stagehand",
"version": "3.0.8",
"type": "module",
"description": "An AI web browsing framework focused on simplicity and extensibility.",
"main": "./dist/index.js",
"main": "./dist/index.cjs",
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: The dist/index.cjs file referenced here is not included in the files array. When published to npm, this file won't be included, breaking CommonJS support. Add "dist/index.cjs" to the files array.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/core/package.json, line 6:

<comment>The `dist/index.cjs` file referenced here is not included in the `files` array. When published to npm, this file won't be included, breaking CommonJS support. Add `"dist/index.cjs"` to the `files` array.</comment>

<file context>
@@ -1,14 +1,22 @@
+  "type": "module",
   "description": "An AI web browsing framework focused on simplicity and extensibility.",
-  "main": "./dist/index.js",
+  "main": "./dist/index.cjs",
   "module": "./dist/index.js",
   "types": "./dist/index.d.ts",
</file context>
Fix with Cubic

"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"scripts": {
"gen-version": "tsx scripts/gen-version.ts",
"build-dom-scripts": "tsx lib/v3/dom/genDomScripts.ts && tsx lib/v3/dom/genLocatorScripts.ts && tsx lib/v3/dom/genA11yScripts.ts",
"build-js": "tsup --entry.index lib/v3/index.ts --dts",
"build-js": "tsup --entry.index lib/v3/index.ts --format esm,cjs --dts --target es2022",
"typecheck": "tsc --noEmit",
"build": "pnpm run gen-version && pnpm run build-dom-scripts && pnpm run build-js && pnpm run typecheck",
"example": "node --import tsx -e \"const args=process.argv.slice(1).filter(a=>a!=='--'); const [p]=args; const n=(p||'example').replace(/^\\.\\//,'').replace(/\\.ts$/i,''); import(new URL(require('node:path').resolve('examples', n + '.ts'), 'file:'));\" --",
Expand Down
4 changes: 3 additions & 1 deletion packages/core/scripts/gen-version.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { readFileSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import { join, dirname } from "node:path";
import { fileURLToPath } from "node:url";

type PackageJson = { version: string };

const __dirname = dirname(fileURLToPath(import.meta.url));
const pkgPath = join(__dirname, "..", "package.json");
const pkg: PackageJson = JSON.parse(readFileSync(pkgPath, "utf8"));

Expand Down
6 changes: 3 additions & 3 deletions packages/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"compilerOptions": {
"module": "commonjs",
"module": "ES2022",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"target": "es6",
"target": "ES2022",
"noImplicitAny": true,
"moduleResolution": "node",
"moduleResolution": "Node",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider using "moduleResolution": "Node16" or "NodeNext" instead of "Node" for better ESM compatibility with explicit file extensions

Suggested change
"moduleResolution": "Node",
"moduleResolution": "NodeNext",

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/core/tsconfig.json
Line: 8:8

Comment:
consider using `"moduleResolution": "Node16"` or `"NodeNext"` instead of `"Node"` for better ESM compatibility with explicit file extensions

```suggestion
    "moduleResolution": "NodeNext",
```

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

"sourceMap": true,
"outDir": "./dist",
"rootDir": "../../",
Expand Down
Loading