fix(build): explicitly install shims module from anthropic and openai in stagehand route (#2350)

This commit is contained in:
Waleed
2025-12-12 19:24:47 -08:00
committed by GitHub
parent ecf5209e6f
commit 821d127c00
3 changed files with 10 additions and 5 deletions

View File

@@ -1,4 +1,3 @@
import { Stagehand } from '@browserbasehq/stagehand'
import { type NextRequest, NextResponse } from 'next/server'
import { z } from 'zod'
import { env } from '@/lib/core/config/env'
@@ -7,6 +6,8 @@ import { ensureZodObject, normalizeUrl } from '@/app/api/tools/stagehand/utils'
const logger = createLogger('StagehandAgentAPI')
type StagehandType = import('@browserbasehq/stagehand').Stagehand
const BROWSERBASE_API_KEY = env.BROWSERBASE_API_KEY
const BROWSERBASE_PROJECT_ID = env.BROWSERBASE_PROJECT_ID
@@ -89,7 +90,7 @@ function substituteVariables(text: string, variables: Record<string, string> | u
}
export async function POST(request: NextRequest) {
let stagehand: Stagehand | null = null
let stagehand: StagehandType | null = null
try {
const body = await request.json()
@@ -157,6 +158,8 @@ export async function POST(request: NextRequest) {
try {
logger.info('Initializing Stagehand with Browserbase (v3)', { provider, modelName })
const { Stagehand } = await import('@browserbasehq/stagehand')
stagehand = new Stagehand({
env: 'BROWSERBASE',
apiKey: BROWSERBASE_API_KEY,

View File

@@ -1,4 +1,3 @@
import { Stagehand } from '@browserbasehq/stagehand'
import { type NextRequest, NextResponse } from 'next/server'
import { z } from 'zod'
import { env } from '@/lib/core/config/env'
@@ -7,6 +6,8 @@ import { ensureZodObject, normalizeUrl } from '@/app/api/tools/stagehand/utils'
const logger = createLogger('StagehandExtractAPI')
type StagehandType = import('@browserbasehq/stagehand').Stagehand
const BROWSERBASE_API_KEY = env.BROWSERBASE_API_KEY
const BROWSERBASE_PROJECT_ID = env.BROWSERBASE_PROJECT_ID
@@ -21,7 +22,7 @@ const requestSchema = z.object({
})
export async function POST(request: NextRequest) {
let stagehand: Stagehand | null = null
let stagehand: StagehandType | null = null
try {
const body = await request.json()
@@ -93,6 +94,8 @@ export async function POST(request: NextRequest) {
logger.info('Initializing Stagehand with Browserbase (v3)', { provider, modelName })
const { Stagehand } = await import('@browserbasehq/stagehand')
stagehand = new Stagehand({
env: 'BROWSERBASE',
apiKey: BROWSERBASE_API_KEY,

View File

@@ -79,7 +79,6 @@ const nextConfig: NextConfig = {
'pino',
'pino-pretty',
'thread-stream',
'@browserbasehq/stagehand',
],
experimental: {
optimizeCss: true,