feat(sdk-ts): env overrides for extension asset paths - #2676
Conversation
|
| Name | Type |
|---|---|
| @browserbasehq/stagehand | Patch |
| @browserbasehq/stagehand-integrations | Patch |
| @browserbasehq/stagehand-integrations-example-eve-facade | Patch |
| @browserbasehq/stagehand-integrations-example-mastra-facade | Patch |
| @browserbasehq/stagehand-integrations-example-vercel-ai-facade | Patch |
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Architecture diagram
sequenceDiagram
participant Caller as Host Code
participant Assets as extensionAssets.ts
participant Env as process.env
participant FS as File System
Note over Caller,FS: NEW: Resolve extension asset paths with env overrides
Caller->>Assets: get extension asset path (archive or directory)
Assets->>Env: Check corresponding STAGEHAND_EXTENSION_*_PATH
alt Env var set (e.g., bundler inlined, import.meta.url broken)
Env-->>Assets: real path
Assets-->>Caller: return env override path
else Env var not set
Env-->>Assets: undefined
Assets->>Assets: derive from import.meta.url (packageRoot)
Assets-->>Caller: return derived path (default)
end
Note over Caller,FS: Same logic for both ARCHIVE and DIRECTORY constants
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
d2be814 to
cc7b8ba
Compare
There was a problem hiding this comment.
All reported issues were addressed across 1 file (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Confidence score: 4/5
- In
packages/sdk-ts/src/extensionAssets.ts, the new environment-override logic (including thenonEmptyempty/whitespace-as-unset edge case) is untested, so a subtle regression in override precedence or value parsing could slip through and cause incorrect extension asset resolution at runtime — add focused unit tests for unset, empty, whitespace-only, and valid env values plus precedence behavior.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/sdk-ts/src/extensionAssets.ts">
<violation number="1" location="packages/sdk-ts/src/extensionAssets.ts:9">
P2: The new env-override behavior (including the `nonEmpty` edge-case handling that treats empty/whitespace-only values as unset, which was a dedicated fix commit) has no unit-test coverage. The existing 186 tests pass but none import `extensionAssets` or set these env vars, so the override path, the trim fallback, and the module-load-time env read can regress silently. Consider adding focused tests covering: env set → uses override, env unset → derived path, env empty/whitespace-only → derived path, and env with surrounding whitespace → trimmed value.</violation>
</file>
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
Eve example for the Stagehand facade tool surface, using Eve-native authored tools (`defineTool`) instead of an MCP connection. - **Tools:** `run` / `snapshot` / `screenshot` — the shared facade contract; descriptions, schemas, and system prompt imported from `@browserbasehq/stagehand-integrations/facade`, never restated. - **Transport:** none — tools run in-process in the Eve world. Browser session is a module-level singleton with keep-alive + reconnect-by-session-id (`browser.sessionId`). - **Run:** `packages/integrations/eve/README.md`. `pnpm dev` / `pnpm start` route through a wrapper that forwards the SDK extension asset paths (needs #2676's env overrides, merged into this branch). Verified: contract test in CI; Browserbase smoke passed (agent cited snapshot ID `[0-19]`, heading "Example Domain"); local `eve dev` browser flow verified end-to-end. Stacked on #2665. --------- Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> Co-authored-by: Shrey Pandya <shrey@browserbase.com>
f10d2ad to
5c092e4
Compare
16b037c to
c614548
Compare
Small targeted change:
STAGEHAND_EXTENSION_ARCHIVE_PATH/STAGEHAND_EXTENSION_DIRECTORY_PATHenv overrides for the two derived asset constants.Why: bundlers that inline the SDK re-anchor
import.meta.url, breaking the derived paths. Hit twice in the Eve integration:eve build(nitro bundle missing the zip → 'Failed to upload the Stagehand extension') and noweve dev(authored-module bundle → CDPExtensions.loadUnpackedfails with 'File path cannot be resolved' for local browsers). The env override is the standard escape hatch; the Eve example sets them from a tiny wrapper that resolves the real installed paths outside any bundle.Gate: build, typecheck, 186/186 unit tests.
Summary by cubic
Adds env overrides for extension asset paths in
@browserbasehq/stagehandso bundled builds can point to real assets. Trims whitespace so empty override values are ignored.STAGEHAND_EXTENSION_ARCHIVE_PATHandSTAGEHAND_EXTENSION_DIRECTORY_PATHviaprocess.env, falling back toimport.meta.url-derived paths when unset or blank.Written for commit c614548. Summary will update on new commits.