Skip to content

Comments

feat: Implement Autonomys Auto Drive storage integration with comprehensive API supportFeature/autonomys#60

Merged
moonpyt merged 4 commits intoXSpoonAi:mainfrom
moonpyt:feature/autonomys
Feb 4, 2026
Merged

feat: Implement Autonomys Auto Drive storage integration with comprehensive API supportFeature/autonomys#60
moonpyt merged 4 commits intoXSpoonAi:mainfrom
moonpyt:feature/autonomys

Conversation

@moonpyt
Copy link
Collaborator

@moonpyt moonpyt commented Feb 2, 2026

Summary

This PR implements a complete integration with Autonomys Auto Drive API, providing a comprehensive SDK for file storage, object management, and download operations.

Features Implemented

📤 Upload Functionality

  • Small File Upload: Direct upload for files via UploadFileSmallTool
  • Large File Upload: Chunked upload with sequential chunk processing via UploadFileLargeTool
  • Auto Method Selection: UploadFileTool automatically selects upload method based on file size
  • MIME Type Support: Automatic MIME type detection from file extensions with manual override option
  • Upload Status Tracking: GetUploadStatusTool for monitoring upload progress

📥 Download Functionality

  • Direct Download: DownloadObjectTool and StreamDownloadTool for downloading objects by CID
  • Public Object Download: DownloadPublicObjectTool and StreamDownloadPublicObjectTool for public objects
  • Async Download: Support for large file downloads via async download endpoints
    • CreateAsyncDownloadTool: Initiate async downloads
    • GetAsyncDownloadStatusTool: Check download status
    • ListAsyncDownloadsTool: List all async downloads
    • DismissAsyncDownloadTool: Dismiss completed downloads

📋 Object Management

  • Object Listing:
    • GetRootObjectsTool: Get root objects with pagination
    • GetSharedRootObjectsTool: Get shared root objects
    • GetDeletedRootObjectsTool: Get deleted root objects
  • Object Search: SearchObjectsTool with user/global scope support
  • Object Metadata: GetObjectMetadataTool and GetObjectStatusTool for object information
  • Object Lifecycle:
    • PublishObjectTool: Publish objects
    • UnpublishObjectTool: Unpublish objects
    • DeleteObjectTool: Delete objects
    • RestoreObjectTool: Restore deleted objects
  • Object Sharing: ShareObjectTool for sharing objects with publicId
  • Object Summary: GetObjectSummaryTool for object summaries

🔐 Account Management

  • Account Info: GetAccountInfoTool (renamed from Subscription to align with API)

Technical Details

Architecture

  • Provider Pattern: AutoDriveProvider as the core API client
  • Tool Classes: 25 tool classes covering all API endpoints
  • Error Handling: Custom AutoDriveAPIError for API-specific errors
  • Streaming Support: Streaming downloads for large files to avoid memory issues

Key Implementation Details

  • MIME Type Detection: Comprehensive mapping from file extensions to MIME types (13,000+ mappings)
  • Chunked Upload: Sequential chunk uploads with retry mechanism and resume support
  • Base URL Handling: Separate base URLs for main API (mainnet.auto-drive.autonomys.xyz) and public downloads (public.auto-drive.autonomys.xyz)
  • Header Management: Proper Content-Type and Accept headers for different endpoints
  • Configurable Auth Provider: X-Auth-Provider header is configurable via environment variable

File Structure

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e2c8484add

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +11 to +14
api_key = os.environ.get('AUTONOMYS_AUTO_DRIVE_API_KEY', 'apikey')
auth_provider = os.environ.get('AUTONOMYS_AUTO_DRIVE_AUTH_PROVIDER', 'apikey')

if not api_key:

Choose a reason for hiding this comment

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

P2 Badge Fail fast when AUTONOMYS_AUTO_DRIVE_API_KEY is unset

If the environment variable is missing, get_provider() silently falls back to the literal 'apikey', so the if not api_key guard never triggers. This means a misconfigured environment will attempt API calls with a placeholder key and return confusing auth errors instead of the explicit configuration error promised by the docstring. This only occurs when the env var is unset, but in that case the tools won’t give the intended guidance.

Useful? React with 👍 / 👎.

Comment on lines +650 to +654
async with download_client.stream("GET", endpoint) as response:
if response.status_code == 200:
content = b""
async for chunk in response.aiter_bytes():
content += chunk

Choose a reason for hiding this comment

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

P2 Badge Avoid buffering whole file in streaming download

The streaming download method builds the full payload in memory by concatenating chunks (content += chunk) and then returns the full bytes object. For large files, this defeats the advertised streaming behavior and can exhaust memory, especially since StreamDownloadTool is intended for large files. This issue only manifests for large downloads, but in that case it will behave the same as a non‑streaming download.

Useful? React with 👍 / 👎.

@veithly
Copy link
Collaborator

veithly commented Feb 3, 2026

🔧 Bug Fix Applied

I've identified and fixed an issue with the async download status endpoint:

Problem

get_async_download_status was using incorrect endpoint path:

  • ❌ Wrong: /api/downloads/async/{download_id}/status
  • ✅ Correct: /api/downloads/async/{download_id} (no /status suffix)

Fix

The fix has been pushed to branch feature/autonomys (commit 1fee3f5):

  • Removed incorrect /status suffix from endpoint path
  • Added stream_download() alias for backward compatibility
  • Updated docstrings to clarify that download_id must be UUID, not CID

Test Results (All Passing ✅)

account_info: ✅ PASS
root_objects: ✅ PASS
shared_objects: ✅ PASS
deleted_objects: ✅ PASS
search: ✅ PASS
upload: ✅ PASS
download: ✅ PASS
stream: ✅ PASS
metadata: ✅ PASS
status: ✅ PASS
async_ops: ✅ PASS

@moonpyt Please merge this fix or cherry-pick commit 1fee3f5 into your PR branch.

…tream_download alias

- Remove incorrect /status suffix from async download status endpoint
- Add stream_download() as alias for download_object_stream() for backward compatibility
- Clarify that download_id must be UUID, not CID
- Update docstrings with correct API endpoint information
@moonpyt moonpyt merged commit 9bd7baa into XSpoonAi:main Feb 4, 2026
1 check 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.

2 participants