Skip to content

Commit 821d127

Browse files
authored
fix(build): explicitly install shims module from anthropic and openai in stagehand route (#2350)
1 parent ecf5209 commit 821d127

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

apps/sim/app/api/tools/stagehand/agent/route.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Stagehand } from '@browserbasehq/stagehand'
21
import { type NextRequest, NextResponse } from 'next/server'
32
import { z } from 'zod'
43
import { env } from '@/lib/core/config/env'
@@ -7,6 +6,8 @@ import { ensureZodObject, normalizeUrl } from '@/app/api/tools/stagehand/utils'
76

87
const logger = createLogger('StagehandAgentAPI')
98

9+
type StagehandType = import('@browserbasehq/stagehand').Stagehand
10+
1011
const BROWSERBASE_API_KEY = env.BROWSERBASE_API_KEY
1112
const BROWSERBASE_PROJECT_ID = env.BROWSERBASE_PROJECT_ID
1213

@@ -89,7 +90,7 @@ function substituteVariables(text: string, variables: Record<string, string> | u
8990
}
9091

9192
export async function POST(request: NextRequest) {
92-
let stagehand: Stagehand | null = null
93+
let stagehand: StagehandType | null = null
9394

9495
try {
9596
const body = await request.json()
@@ -157,6 +158,8 @@ export async function POST(request: NextRequest) {
157158
try {
158159
logger.info('Initializing Stagehand with Browserbase (v3)', { provider, modelName })
159160

161+
const { Stagehand } = await import('@browserbasehq/stagehand')
162+
160163
stagehand = new Stagehand({
161164
env: 'BROWSERBASE',
162165
apiKey: BROWSERBASE_API_KEY,

apps/sim/app/api/tools/stagehand/extract/route.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Stagehand } from '@browserbasehq/stagehand'
21
import { type NextRequest, NextResponse } from 'next/server'
32
import { z } from 'zod'
43
import { env } from '@/lib/core/config/env'
@@ -7,6 +6,8 @@ import { ensureZodObject, normalizeUrl } from '@/app/api/tools/stagehand/utils'
76

87
const logger = createLogger('StagehandExtractAPI')
98

9+
type StagehandType = import('@browserbasehq/stagehand').Stagehand
10+
1011
const BROWSERBASE_API_KEY = env.BROWSERBASE_API_KEY
1112
const BROWSERBASE_PROJECT_ID = env.BROWSERBASE_PROJECT_ID
1213

@@ -21,7 +22,7 @@ const requestSchema = z.object({
2122
})
2223

2324
export async function POST(request: NextRequest) {
24-
let stagehand: Stagehand | null = null
25+
let stagehand: StagehandType | null = null
2526

2627
try {
2728
const body = await request.json()
@@ -93,6 +94,8 @@ export async function POST(request: NextRequest) {
9394

9495
logger.info('Initializing Stagehand with Browserbase (v3)', { provider, modelName })
9596

97+
const { Stagehand } = await import('@browserbasehq/stagehand')
98+
9699
stagehand = new Stagehand({
97100
env: 'BROWSERBASE',
98101
apiKey: BROWSERBASE_API_KEY,

apps/sim/next.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ const nextConfig: NextConfig = {
7979
'pino',
8080
'pino-pretty',
8181
'thread-stream',
82-
'@browserbasehq/stagehand',
8382
],
8483
experimental: {
8584
optimizeCss: true,

0 commit comments

Comments
 (0)