Skip to content

fix(gemini-cua): Update template to use Stagehand v3 API #66

@cursor

Description

@cursor

Problem

The Gemini CUA template is using Stagehand v2 syntax while the package version needs to be v3, causing the template to fail when invoked.

Related Linear issue: KERNEL-716

Solution

1. Update templates/typescript/gemini-cua/package.json:

{
  "name": "ts-gemini-cua",
  "module": "index.ts",
  "type": "module",
  "private": true,
  "peerDependencies": {
    "typescript": "^5"
  },
  "dependencies": {
    "@browserbasehq/stagehand": "^3.0.1",
    "@onkernel/sdk": "^0.18.0",
    "zod": "=3.25.67"
  }
}

2. Update templates/typescript/gemini-cua/index.ts:

Stagehand constructor (v2 → v3):

// Before (v2)
const stagehand = new Stagehand({
  env: "LOCAL",
  verbose: 1,
  domSettleTimeoutMs: 30_000,
  modelName: "gpt-4o",
  modelClientOptions: {
    apiKey: OPENAI_API_KEY
  },
  localBrowserLaunchOptions: {
    cdpUrl: kernelBrowser.cdp_ws_url
  }
});

// After (v3)
const stagehand = new Stagehand({
  env: "LOCAL",
  localBrowserLaunchOptions: {
    cdpUrl: kernelBrowser.cdp_ws_url,
  },
  model: "openai/gpt-4o",
  apiKey: OPENAI_API_KEY,
  verbose: 1,
  domSettleTimeout: 30_000
});

Page access (v2 → v3):

// Before (v2)
const page = stagehand.page;

// After (v3)
const page = stagehand.context.pages()[0];

Agent configuration (v2 → v3):

// Before (v2)
const agent = stagehand.agent({
  provider: "google",
  model: "gemini-2.5-computer-use-preview-10-2025",
  instructions: `You are a helpful assistant...`,
  options: {
    apiKey: GOOGLE_API_KEY,
  }
});

// After (v3)
const agent = stagehand.agent({
  cua: true,
  model: {
    modelName: "google/gemini-2.5-computer-use-preview-10-2025",
    apiKey: GOOGLE_API_KEY,
  },
  systemPrompt: `You are a helpful assistant...`,
});

Kernel SDK initialization (simplified):

// Before
const kernel = new Kernel({
  apiKey: process.env.KERNEL_API_KEY
});

// After
const kernel = new Kernel();

Reference

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions