Skip to content

feat(cli): support Authenticated Fetch with saved contexts - #3329

Open
shrey150 wants to merge 2 commits into
mainfrom
shrey/authenticated-fetch-cli
Open

shrey150 wants to merge 2 commits into
mainfrom
shrey/authenticated-fetch-cli

Conversation

@shrey150

@shrey150 shrey150 commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

browse cloud fetch can now reuse a saved Browserbase login with --context-id <id|name>. Context names resolve through the existing local aliases; requests without the flag keep their current behavior. Raw, Markdown, JSON extraction, and file output all remain available.

Uses Browserbase SDK 2.23.0, updates CLI help and the bundled Browse skill, and includes a minor changeset. The SDK's exact release is included in the workspace's release-age exceptions so the new dependency can install.

Validation:

  • CLI build, type check, changed-file formatting and ESLint pass.
  • All 511 CLI tests pass, including context UUIDs, aliases, typo handling, default omission, and output formats/files.
  • Live smoke against the public The Internet login demo: anonymous raw/Markdown/JSON requests returned the login page; requests using the saved context returned protected content. Tested a UUID and saved aliases. Temporary session/context cleaned up.

Public feature reference: Authenticated Fetch.

@changeset-bot

changeset-bot Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7505305

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
browse Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@socket-security

socket-security Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​browserbasehq/​sdk@​2.23.09710010098100

View full report

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 9 files

Architecture diagram
sequenceDiagram
    participant User as CLI User
    participant FetchCmd as Fetch Command
    participant CtxResolver as resolveContextRefOrFail
    participant AliasStore as Local Alias Store
    participant BBClient as Browserbase Client
    participant BBFetch as Browserbase Fetch API

    Note over User,BBFetch: Authenticated Fetch Flow

    User->>FetchCmd: browse cloud fetch <url> --context-id <id|name>
    
    alt No --context-id flag
        FetchCmd->>BBClient: createBrowserbaseClient()
        FetchCmd->>BBClient: fetchAPI.create({url, format})
        BBClient->>BBFetch: POST /v1/fetch
        BBFetch-->>FetchCmd: FetchResponse
    else --context-id provided
        FetchCmd->>CtxResolver: resolveContextRefOrFail(ref)
        
        alt ref is a UUID
            CtxResolver->>CtxResolver: Validate UUID format
            CtxResolver-->>FetchCmd: Return UUID as-is
        else ref is a saved alias
            CtxResolver->>AliasStore: Lookup saved context alias
            AliasStore-->>CtxResolver: Context ID
        else ref is unknown (typo)
            CtxResolver->>AliasStore: Check for close matches
            Altos-->>CtxResolver: No match found
            CtxResolver-->>FetchCmd: Error: "No saved context named..."
            FetchCmd-->>User: CLI error with suggestion
            Note over User,FetchCmd: Request aborted before API call
        end

        CtxResolver-->>FetchCmd: Resolved contextId
        
        FetchCmd->>BBClient: createBrowserbaseClient()
        FetchCmd->>BBClient: fetchAPI.create({url, contextId, format})
        BBClient->>BBFetch: POST /v1/fetch
        Note over BBFetch: Fetch API uses saved context cookies
        BBFetch-->>BBClient: FetchResponse with authenticated content
    end

    BBClient-->>FetchCmd: Result
    FetchCmd->>User: Output (raw/markdown/json/file)
Loading

Tip: Get a Slack DM when cubic finishes reviewing your PRs. Connect Slack

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread packages/cli/tests/cli-cloud-contract.test.ts Outdated

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant