cursor / cursor/cookbook

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

Open
#61 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
4.1k
Forks
492
Avg merge
37m
Merged PRs (30d)
3

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in sdk/app-builder/src/lib/app-builder/server.ts around lines 1002–1011 and compare the create call with the SDK's LocalAgentOptions. Trace how the preview host starts Vite and how later agent-launched commands receive environment variables. Done means choosing and validating a supported way to keep local agent previews from opening a system browser, or removing the invalid option if no such channel exists.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.