Skip to content

Conversation

@hopxai
Copy link
Contributor

@hopxai hopxai commented Nov 17, 2025

Hi team πŸ‘‹

Thank you for adding support for Hopx.ai to cased/sandboxes β€” we really appreciate you integrating our platform.

This PR is our way of sending some love back from the HopX.AI side. It modernizes the Hopx provider and brings it fully in line with the current SandboxProvider expectations.

At a glance, this PR:
β€’ Upgrades to the HopX SDK v0.3.0
Uses the latest hopx-ai SDK instead of raw API wiring, with public signatures kept stable and SDK behavior used as the source of truth.
β€’ Aligns with the SandboxProvider interface
Fixes upload_file / download_file method signatures to match the base class and adds internal binary auto-detection, so callers don’t need to care about text vs binary.
β€’ Improves provider architecture & state handling
Maps all Hopx sandbox statuses to the SandboxState enum and populates connection_info (including public_host and agent_url) for more standardized downstream use.
β€’ Adds first-class preview URL support
Introduces helpers for preview URLs on arbitrary ports plus a convenience method for the agent URL, following the HopX public URL format.
β€’ Cleans up the code surface
Removes old SDK fallbacks and defensive hasattr() checks, relying on the SDK’s error semantics instead, while reducing code size and increasing clarity.

On the quality side:
β€’ All tests passing: 30/30 for tests/test_hopx_provider.py
β€’ Coverage: ~80% on sandboxes/providers/hopx.py, focused on interface compliance, status mapping, binary detection, connection info, and preview URLs
β€’ Breaking changes: None β€” binary handling is now automatic and transparent for existing callers.

If anything in the implementation, naming, or structure doesn’t match how you’d like providers to look in this repo, we’re happy to adjust this PR to fit your preferred style.

Thank you again for adding Hopx.ai to your platform.
Here’s some love back from us πŸ’™

Hugs,
The HopX.AI team

Full commit contents below

feat(hopx): upgrade to SDK v0.3.0 with interface compliance

Modernize Hopx provider to use latest hopx-ai SDK with complete SandboxProvider interface compliance and architectural improvements.

Interface Compliance

Fixed method signatures to match SandboxProvider base class:

  • upload_file(sandbox_id, local_path, sandbox_path) - Corrected parameter names
  • download_file(sandbox_id, sandbox_path, local_path) - Fixed parameter order

Binary files now auto-detected internally:

  • Upload: By file extension (.png, .pdf, .zip, etc.)
  • Download: By content type (bytes vs string)
  • Transparent to callers (no API changes)

Architecture Improvements

Status Mapping
Map all Hopx sandbox statuses to SandboxState enum:

  • running β†’ RUNNING
  • stopped β†’ STOPPED
  • paused β†’ STOPPED
  • creating β†’ CREATING

Connection Info
Populate connection_info field with public_host and agent_url for standardized access.

Error Handling
Simplified desktop feature detection - let SDK errors propagate naturally instead of defensive checks.

New Features

Preview URL Support:

  • get_preview_url(sandbox_id, port) - Get public URL for services on any port
  • get_agent_url(sandbox_id) - Convenience method for agent URL (port 7777)
  • URL format: https://{port}-{sandbox_id}.{region}.vms.hopx.dev/

Code Quality

Removed:

  • Unnecessary SDK fallback code
  • Defensive hasattr() checks
  • Binary parameter from public signatures

Added:

  • Automatic binary file detection
  • Complete status-to-state mapping
  • Connection info population
  • Preview URL tests

Net: Fewer lines while adding functionality.

Dependency Updates

  • hopx-ai: 0.1.19 β†’ 0.3.0
  • Added missing "hopx" pytest marker

Testing

All tests passing: 30/30 (100%)

pytest tests/test_hopx_provider.py -v
30 passed, 3 warnings in 19.45s

Code coverage: 80%

sandboxes/providers/hopx.py: 80.00% coverage
  Statements: 271 total, 225 covered
  Branches: 74 total, 57 covered

Coverage by feature:

  • Interface compliance: Tested (upload/download signatures verified)
  • Binary auto-detection: Tested (PNG upload/download)
  • Status mapping: Tested (all sandbox states)
  • Connection info: Tested (populated correctly)
  • Preview URLs: Tested (custom ports, agent URL, error cases)
  • Desktop features: Tested (VNC, screenshots, graceful degradation)

Test categories:

  • Core functionality: 6 tests
  • File operations: 6 tests
  • Command execution: 4 tests
  • Sandbox management: 5 tests
  • Advanced features: 9 tests (desktop, rich outputs, streaming, preview URLs)

Missing coverage:

  • Error paths and edge cases only (20% uncovered)
  • Import errors, API fallbacks, rare exception handlers

Breaking Changes

None. Binary parameter removed from signatures, but auto-detection provides same functionality transparently.

Migration

No action required. Changes are backward compatible.

Modernize Hopx provider to use latest hopx-ai SDK with complete SandboxProvider
interface compliance and architectural improvements.

## Interface Compliance

**Fixed method signatures to match SandboxProvider base class:**

- `upload_file(sandbox_id, local_path, sandbox_path)` - Corrected parameter names
- `download_file(sandbox_id, sandbox_path, local_path)` - Fixed parameter order

Binary files now auto-detected internally:
- Upload: By file extension (.png, .pdf, .zip, etc.)
- Download: By content type (bytes vs string)
- Transparent to callers (no API changes)

## Architecture Improvements

**Status Mapping**
Map all Hopx sandbox statuses to SandboxState enum:
- running β†’ RUNNING
- stopped β†’ STOPPED
- paused β†’ STOPPED
- creating β†’ CREATING

**Connection Info**
Populate connection_info field with public_host and agent_url for standardized access.

**Error Handling**
Simplified desktop feature detection - let SDK errors propagate naturally instead of defensive checks.

## New Features

**Preview URL Support:**
- `get_preview_url(sandbox_id, port)` - Get public URL for services on any port
- `get_agent_url(sandbox_id)` - Convenience method for agent URL (port 7777)
- URL format: `https://{port}-{sandbox_id}.{region}.vms.hopx.dev/`

## Code Quality

Removed:
- Unnecessary SDK fallback code
- Defensive hasattr() checks
- Binary parameter from public signatures

Added:
- Automatic binary file detection
- Complete status-to-state mapping
- Connection info population
- Preview URL tests

Net: Fewer lines while adding functionality.

## Dependency Updates

- hopx-ai: 0.1.19 β†’ 0.3.0
- Added missing "hopx" pytest marker

## Testing

**All tests passing: 30/30 (100%)**

```
pytest tests/test_hopx_provider.py -v
30 passed, 3 warnings in 19.45s
```

**Code coverage: 80%**

```
sandboxes/providers/hopx.py: 80.00% coverage
  Statements: 271 total, 225 covered
  Branches: 74 total, 57 covered
```

**Coverage by feature:**
- Interface compliance: Tested (upload/download signatures verified)
- Binary auto-detection: Tested (PNG upload/download)
- Status mapping: Tested (all sandbox states)
- Connection info: Tested (populated correctly)
- Preview URLs: Tested (custom ports, agent URL, error cases)
- Desktop features: Tested (VNC, screenshots, graceful degradation)

**Test categories:**
- Core functionality: 6 tests
- File operations: 6 tests
- Command execution: 4 tests
- Sandbox management: 5 tests
- Advanced features: 9 tests (desktop, rich outputs, streaming, preview URLs)

**Missing coverage:**
- Error paths and edge cases only (20% uncovered)
- Import errors, API fallbacks, rare exception handlers

## Breaking Changes

None. Binary parameter removed from signatures, but auto-detection provides same functionality transparently.

## Migration

No action required. Changes are backward compatible.
@dobralin
Copy link

@tnm @nibzard can you take a look?

@tnm
Copy link
Contributor

tnm commented Nov 17, 2025

Awesome! I'll defer to @nibzard for a first pass if he would be so kind! πŸ™‡

@nibzard
Copy link
Collaborator

nibzard commented Nov 18, 2025

LGTM @tnm, besides those linting complaints. Really appreciate you taking the time to improve it. @dobralin

@hopxai
Copy link
Contributor Author

hopxai commented Nov 18, 2025

πŸ™ updated to address linting complaints

@tnm tnm merged commit 80613ae into cased:main Nov 18, 2025
4 checks passed
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.

4 participants