Skip to content

App Builder passes local.envVars, which @cursor/sdk ignores #61

Description

@rajarshidattapy

Description

When App Builder creates the session agent it tries to inject BROWSER=none into the local agent:

https://github.com/cursor/cookbook/blob/main/sdk/app-builder/src/lib/app-builder/server.ts#L1002-L1011

session.agent = await Agent.create({
  apiKey: session.apiKey,
  model: { id: process.env.CURSOR_MODEL ?? "composer-2" },
  local: {
    cwd: session.projectPath,
    envVars: {
      BROWSER: "none",
    },
  },
})

envVars is a CloudAgentOptions field. LocalAgentOptions has cwd, dirs, settingSources, sandboxOptions, customTools, store, and enableAgentRetries — not envVars. The extra property is dropped at the type boundary and never reaches the local executor.

The preview host process already sets BROWSER: "none" when it starts Vite (server.ts around the runCommand spawn). That does not cover shells the agent starts later (npm run dev, vite, a browser opener). Those child processes still see a normal BROWSER and can pop a system browser on top of the in-app iframe.

Expected

Local session agents run with BROWSER=none (or an equivalent local-supported setting) so preview stays inside the App Builder iframe.

Suggested fix

Pick one:

  • Pass the var through a supported local channel if the SDK adds one.
  • Set BROWSER=none in the workspace .env / generated project scripts the agent actually runs.
  • Stop passing a no-op local.envVars so the example does not teach an invalid option.

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