App Builder passes local.envVars, which @cursor/sdk ignores
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:
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=nonein the workspace.env/ generated project scripts the agent actually runs. - Stop passing a no-op
local.envVarsso the example does not teach an invalid option.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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