fix: replace all Daytona references with HanzoRuntime
- Renamed all class names: Daytona → HanzoRuntime - Updated error classes: DaytonaError → HanzoRuntimeError - Changed config classes: DaytonaConfig → HanzoRuntimeConfig - Updated environment variables: DAYTONA_* → HANZO_RUNTIME_* - Fixed all import statements and file references - Updated copyright headers to Hanzo Industries Inc - Changed default API URL to https://app.hanzo.ai/api - Renamed source files to match new class names - Incremented version to 0.0.1-dev for republishing
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
# NPM Authentication
|
||||
# Get token from: https://www.npmjs.com/settings/YOUR_USERNAME/tokens
|
||||
# Choose "Automation" type to bypass 2FA
|
||||
NPM_TOKEN=npm_YOUR_TOKEN_HERE
|
||||
|
||||
# PyPI Authentication
|
||||
# Get token from: https://pypi.org/manage/account/token/
|
||||
# Use __token__ as username when prompted
|
||||
TWINE_USERNAME=__token__
|
||||
TWINE_PASSWORD=pypi-YOUR_TOKEN_HERE
|
||||
@@ -1,2 +1,5 @@
|
||||
# Expose Astro dependencies for \`pnpm\` users
|
||||
shamefully-hoist=true
|
||||
shamefully-hoist=true
|
||||
|
||||
# NPM authentication token for publishing
|
||||
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
|
||||
@@ -27,25 +27,51 @@ clean: ## Clean build artifacts
|
||||
@rm -f libs/sdk-typescript/*.tgz
|
||||
@rm -f *.tgz
|
||||
|
||||
.PHONY: publish
|
||||
publish: publish-check build publish-python publish-npm ## Build and publish all packages
|
||||
.PHONY: publish
|
||||
publish: ## Build and publish all packages
|
||||
@if [ -z "$$NPM_TOKEN" ] && [ -z "$$PYPI_TOKEN" ]; then \
|
||||
echo "Attempting to load tokens from parent shell..."; \
|
||||
zsh -i -c 'make publish-with-tokens NPM_TOKEN="$$NPM_TOKEN" PYPI_TOKEN="$$PYPI_TOKEN"'; \
|
||||
else \
|
||||
make publish-with-tokens; \
|
||||
fi
|
||||
|
||||
.PHONY: publish-with-tokens
|
||||
publish-with-tokens: publish-check build publish-python publish-npm
|
||||
|
||||
.PHONY: publish-check
|
||||
publish-check: ## Check if ready to publish
|
||||
@echo "Checking publishing prerequisites..."
|
||||
@which twine > /dev/null || (echo "Error: twine not installed. Run: pip install twine" && exit 1)
|
||||
@npm whoami > /dev/null 2>&1 || (echo "Error: Not logged in to npm. Run: npm login" && exit 1)
|
||||
@if [ -z "$$NPM_TOKEN" ]; then \
|
||||
echo "Error: NPM_TOKEN environment variable not set"; \
|
||||
exit 1; \
|
||||
fi
|
||||
@if [ -z "$$PYPI_TOKEN" ]; then \
|
||||
echo "Error: PYPI_TOKEN environment variable not set"; \
|
||||
exit 1; \
|
||||
fi
|
||||
@echo "✓ All publishing tools available"
|
||||
@echo "✓ NPM_TOKEN is set"
|
||||
@echo "✓ PYPI_TOKEN is set"
|
||||
|
||||
.PHONY: publish-python
|
||||
publish-python: ## Publish Python package to PyPI
|
||||
@echo "Publishing Python package to PyPI..."
|
||||
@cd libs/sdk-python && python -m twine upload dist/* --repository pypi || echo "Note: You may need to configure PyPI credentials"
|
||||
@if [ -z "$$PYPI_TOKEN" ]; then \
|
||||
echo "Error: PYPI_TOKEN environment variable not set"; \
|
||||
exit 1; \
|
||||
fi
|
||||
@cd libs/sdk-python && python -m twine upload dist/* \
|
||||
--repository pypi \
|
||||
--username __token__ \
|
||||
--password $$PYPI_TOKEN \
|
||||
--non-interactive
|
||||
|
||||
.PHONY: publish-npm
|
||||
publish-npm: ## Publish TypeScript package to npm
|
||||
@echo "Publishing TypeScript package to npm..."
|
||||
@cd libs/sdk-typescript && npm publish --access public --tag beta || echo "Note: You may need to provide OTP with --otp=<code>"
|
||||
@cd libs/sdk-typescript && zsh -i -c 'source ~/.zshrc && npm publish --access public --tag beta'
|
||||
|
||||
.PHONY: publish-dry-run
|
||||
publish-dry-run: build ## Dry run of publishing (no actual upload)
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
# NPM Authentication for Publishing
|
||||
|
||||
## Method 1: Using .npmrc with Auth Token
|
||||
|
||||
1. First, create an access token on npm:
|
||||
- Go to https://www.npmjs.com/settings/YOUR_USERNAME/tokens
|
||||
- Click "Generate New Token"
|
||||
- Select "Automation" type (bypasses 2FA for CI/CD)
|
||||
- Copy the token
|
||||
|
||||
2. Add the token to your `.npmrc` file:
|
||||
|
||||
```bash
|
||||
# In your home directory ~/.npmrc
|
||||
//registry.npmjs.org/:_authToken=npm_YOUR_TOKEN_HERE
|
||||
```
|
||||
|
||||
Or for project-specific:
|
||||
```bash
|
||||
# In project root .npmrc
|
||||
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
|
||||
```
|
||||
|
||||
3. If using environment variable, set it:
|
||||
```bash
|
||||
export NPM_TOKEN="npm_YOUR_TOKEN_HERE"
|
||||
```
|
||||
|
||||
## Method 2: Using npm login with --auth-type=legacy
|
||||
|
||||
For automation tokens that bypass 2FA:
|
||||
```bash
|
||||
npm set //registry.npmjs.org/:_authToken "npm_YOUR_TOKEN_HERE"
|
||||
```
|
||||
|
||||
## Method 3: For GitHub Actions / CI
|
||||
|
||||
```yaml
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '18'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- name: Publish
|
||||
run: npm publish --access public
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
```
|
||||
|
||||
## Publishing with Token
|
||||
|
||||
Once configured, you can publish without OTP:
|
||||
```bash
|
||||
npm publish --access public --tag beta
|
||||
```
|
||||
|
||||
## Security Notes
|
||||
|
||||
- Never commit tokens to git
|
||||
- Use environment variables for CI/CD
|
||||
- Automation tokens bypass 2FA, so keep them secure
|
||||
- Tokens can be revoked at https://www.npmjs.com/settings/YOUR_USERNAME/tokens
|
||||
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
|
||||
|
||||
[project]
|
||||
name = "hanzo-runtime"
|
||||
version = "0.0.0-dev"
|
||||
version = "0.0.1-dev"
|
||||
authors = [
|
||||
{ name = "Hanzo Industries Inc", email = "support@hanzo.ai" },
|
||||
]
|
||||
@@ -32,5 +32,5 @@ keywords = ["hanzo", "runtime", "sdk", "ai", "code-execution"]
|
||||
license = {text = "Apache-2.0"}
|
||||
|
||||
[tool.deptry]
|
||||
exclude = ["src/daytona/_utils/chart_data_extractor_wrapper.py", "scripts/sync_generator.py"]
|
||||
exclude = ["src/hanzo_runtime/_utils/chart_data_extractor_wrapper.py", "scripts/sync_generator.py"]
|
||||
extend_exclude = [".venv", "dist", "build", ".pytest_cache", "__pycache__"]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
set -e
|
||||
@@ -15,8 +15,8 @@ fi
|
||||
|
||||
poetry build
|
||||
|
||||
mv src/daytona src/daytona_sdk
|
||||
sed -i 's/^name = "[^"]*"/name = "daytona_sdk"/' pyproject.toml
|
||||
mv src/hanzo_runtime src/hanzo_runtime_sdk
|
||||
sed -i 's/^name = "[^"]*"/name = "hanzo_runtime_sdk"/' pyproject.toml
|
||||
poetry build
|
||||
mv src/daytona_sdk src/daytona
|
||||
sed -i 's/^name = "[^"]*"/name = "daytona"/' pyproject.toml
|
||||
mv src/hanzo_runtime_sdk src/hanzo_runtime
|
||||
sed -i 's/^name = "[^"]*"/name = "hanzo_runtime"/' pyproject.toml
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
"""
|
||||
@@ -34,8 +34,8 @@ logger = logging.getLogger(__name__)
|
||||
project_root = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(project_root))
|
||||
|
||||
SOURCE_DIR = project_root / "src" / "daytona" / "_async"
|
||||
TARGET_DIR = project_root / "src" / "daytona" / "_sync"
|
||||
SOURCE_DIR = project_root / "src" / "hanzo_runtime" / "_async"
|
||||
TARGET_DIR = project_root / "src" / "hanzo_runtime" / "_sync"
|
||||
|
||||
# Regex markers for blocks
|
||||
MARKERS = {
|
||||
@@ -59,7 +59,7 @@ ADDITIONAL_REPLACEMENTS = {
|
||||
"AsyncGit": "Git",
|
||||
"AsyncLspServer": "LspServer",
|
||||
"AsyncProcess": "Process",
|
||||
"AsyncDaytona": "Daytona",
|
||||
"AsyncHanzoRuntime": "HanzoRuntime",
|
||||
"AsyncSandbox": "Sandbox",
|
||||
# aiofiles replacement
|
||||
"aiofiles.open": "open",
|
||||
@@ -82,7 +82,7 @@ POST_REPLACEMENTS = [
|
||||
(re.compile(r"httpx\.SyncClient\b"), "httpx.Client"),
|
||||
(re.compile(r"\.aiter_bytes\b"), ".iter_bytes"),
|
||||
# Update module imports
|
||||
(re.compile(r"from daytona\._async"), "from daytona._sync"),
|
||||
(re.compile(r"from hanzo_runtime\._async"), "from hanzo_runtime._sync"),
|
||||
# Documentation cleanup
|
||||
(re.compile(r"\basynchronous methods\b"), "methods"),
|
||||
(re.compile(r"\basynchronous\b"), "synchronous"),
|
||||
@@ -160,12 +160,12 @@ def transform_docstrings(text: str) -> str:
|
||||
|
||||
# Handle async with pattern
|
||||
async_with_match = re.match(
|
||||
r"^(\s*)async\s+with\s+(?:Async)?Daytona\(\)(?:\([^)]*\))?\s+as\s+(\w+):\s*(#.*)?$", line
|
||||
r"^(\s*)async\s+with\s+(?:Async)?HanzoRuntime\(\)(?:\([^)]*\))?\s+as\s+(\w+):\s*(#.*)?$", line
|
||||
)
|
||||
if async_with_match:
|
||||
indent, var_name, comment = async_with_match.groups()
|
||||
# Transform to variable assignment
|
||||
new_line = f"{indent}{var_name} = Daytona()"
|
||||
new_line = f"{indent}{var_name} = HanzoRuntime()"
|
||||
if comment:
|
||||
new_line += f" {comment}"
|
||||
result_lines.append(new_line)
|
||||
@@ -233,11 +233,11 @@ def transform_docstrings(text: str) -> str:
|
||||
finally_content.append(lines[k])
|
||||
k += 1
|
||||
|
||||
# Check if finally only contains daytona.close()
|
||||
# Check if finally only contains hanzo_runtime.close()
|
||||
non_empty_finally = [l for l in finally_content if l.strip()]
|
||||
only_has_close = len(non_empty_finally) == 1 and (
|
||||
re.search(r"daytona\w*\.close\(\)", non_empty_finally[0])
|
||||
or re.search(r"await\s+daytona\w*\.close\(\)", non_empty_finally[0])
|
||||
re.search(r"hanzo_runtime\w*\.close\(\)", non_empty_finally[0])
|
||||
or re.search(r"await\s+hanzo_runtime\w*\.close\(\)", non_empty_finally[0])
|
||||
)
|
||||
|
||||
if only_has_close:
|
||||
@@ -274,10 +274,10 @@ def transform_docstrings(text: str) -> str:
|
||||
result_lines.append(lines[i])
|
||||
i += 1
|
||||
|
||||
# Add finally body, filtering out daytona.close()
|
||||
# Add finally body, filtering out hanzo_runtime.close()
|
||||
while i < k:
|
||||
line = lines[i]
|
||||
if not re.search(r"(?:await\s+)?daytona\w*\.close\(\)", line):
|
||||
if not re.search(r"(?:await\s+)?hanzo_runtime\w*\.close\(\)", line):
|
||||
result_lines.append(line)
|
||||
i += 1
|
||||
continue
|
||||
@@ -291,8 +291,8 @@ def transform_docstrings(text: str) -> str:
|
||||
# Process all python code blocks
|
||||
text = re.sub(r"(^[ \t]*```python\n.*?^[ \t]*```)", process_python_code_block, text, flags=re.MULTILINE | re.DOTALL)
|
||||
|
||||
# Remove any stray daytona.close() lines outside code blocks
|
||||
text = re.sub(r"^\s*(?:await\s+)?daytona\w*\.close\(\)\s*$", "", text, flags=re.MULTILINE)
|
||||
# Remove any stray hanzo_runtime.close() lines outside code blocks
|
||||
text = re.sub(r"^\s*(?:await\s+)?hanzo_runtime\w*\.close\(\)\s*$", "", text, flags=re.MULTILINE)
|
||||
|
||||
# Clean up multiple blank lines
|
||||
text = re.sub(r"\n\s*\n\s*\n", "\n\n", text)
|
||||
@@ -1177,8 +1177,8 @@ def post_process(path: Path):
|
||||
flags=re.MULTILINE,
|
||||
)
|
||||
|
||||
# 9) Remove any leftover "daytona.close()" lines
|
||||
text = re.sub(r"^\s*daytona\w*\.close\(\)\s*$", "", text, flags=re.MULTILINE)
|
||||
# 9) Remove any leftover "hanzo_runtime.close()" lines
|
||||
text = re.sub(r"^\s*hanzo_runtime\w*\.close\(\)\s*$", "", text, flags=re.MULTILINE)
|
||||
|
||||
# 10) Collapse more than two blank lines into exactly two
|
||||
text = re.sub(r"\n\s*\n\s*\n", "\n\n", text)
|
||||
|
||||
@@ -12,9 +12,9 @@ from ._async.computer_use import (
|
||||
ScreenshotOptions,
|
||||
ScreenshotRegion,
|
||||
)
|
||||
from ._async.daytona import AsyncHanzoRuntime
|
||||
from ._async.hanzo_runtime import AsyncHanzoRuntime
|
||||
from ._async.sandbox import AsyncSandbox
|
||||
from ._sync.daytona import HanzoRuntime
|
||||
from ._sync.hanzo_runtime import HanzoRuntime
|
||||
from ._sync.sandbox import Sandbox
|
||||
from .common.charts import (
|
||||
BarChart,
|
||||
@@ -26,7 +26,7 @@ from .common.charts import (
|
||||
PieChart,
|
||||
ScatterChart,
|
||||
)
|
||||
from .common.daytona import (
|
||||
from .common.hanzo_runtime import (
|
||||
CodeLanguage,
|
||||
CreateSandboxBaseParams,
|
||||
CreateSandboxFromImageParams,
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
from typing import List, Optional
|
||||
@@ -174,7 +174,7 @@ class AsyncKeyboard:
|
||||
delay (int): Delay between characters in milliseconds.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If the type operation fails.
|
||||
HanzoRuntimeError: If the type operation fails.
|
||||
|
||||
Example:
|
||||
```python
|
||||
@@ -204,7 +204,7 @@ class AsyncKeyboard:
|
||||
modifiers (List[str]): Modifier keys ('ctrl', 'alt', 'meta', 'shift').
|
||||
|
||||
Raises:
|
||||
DaytonaError: If the press operation fails.
|
||||
HanzoRuntimeError: If the press operation fails.
|
||||
|
||||
Example:
|
||||
```python
|
||||
@@ -239,7 +239,7 @@ class AsyncKeyboard:
|
||||
keys (str): The hotkey combination (e.g., 'ctrl+c', 'alt+tab', 'cmd+shift+t').
|
||||
|
||||
Raises:
|
||||
DaytonaError: If the hotkey operation fails.
|
||||
HanzoRuntimeError: If the hotkey operation fails.
|
||||
|
||||
Example:
|
||||
```python
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import io
|
||||
@@ -20,7 +20,7 @@ class AsyncFileSystem:
|
||||
"""Provides file system operations within a Sandbox.
|
||||
|
||||
This class implements a high-level interface to file system operations that can
|
||||
be performed within a Daytona Sandbox.
|
||||
be performed within a HanzoRuntime Sandbox.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
from typing import Awaitable, Callable, List, Optional
|
||||
|
||||
+77
-77
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import asyncio
|
||||
@@ -22,16 +22,16 @@ from daytona_api_client_async import VolumesApi as VolumesApi
|
||||
from environs import Env
|
||||
|
||||
from .._utils.enum import to_enum
|
||||
from .._utils.errors import DaytonaError, intercept_errors
|
||||
from .._utils.errors import HanzoRuntimeError, intercept_errors
|
||||
from .._utils.stream import process_streaming_response
|
||||
from .._utils.timeout import with_timeout
|
||||
from ..code_toolbox.sandbox_python_code_toolbox import SandboxPythonCodeToolbox
|
||||
from ..code_toolbox.sandbox_ts_code_toolbox import SandboxTsCodeToolbox
|
||||
from ..common.daytona import (
|
||||
from ..common.hanzo_runtime import (
|
||||
CodeLanguage,
|
||||
CreateSandboxFromImageParams,
|
||||
CreateSandboxFromSnapshotParams,
|
||||
DaytonaConfig,
|
||||
HanzoRuntimeConfig,
|
||||
Image,
|
||||
)
|
||||
from .sandbox import AsyncSandbox
|
||||
@@ -39,10 +39,10 @@ from .snapshot import AsyncSnapshotService
|
||||
from .volume import AsyncVolumeService
|
||||
|
||||
|
||||
class AsyncDaytona:
|
||||
"""Main class for interacting with the Daytona API.
|
||||
class AsyncHanzoRuntime:
|
||||
"""Main class for interacting with the HanzoRuntime API.
|
||||
|
||||
This class provides asynchronous methods to create, manage, and interact with Daytona Sandboxes.
|
||||
This class provides asynchronous methods to create, manage, and interact with HanzoRuntime Sandboxes.
|
||||
It can be initialized either with explicit configuration or using environment variables.
|
||||
|
||||
Attributes:
|
||||
@@ -52,22 +52,22 @@ class AsyncDaytona:
|
||||
Example:
|
||||
Using environment variables:
|
||||
```python
|
||||
async with AsyncDaytona() as daytona: # Uses DAYTONA_API_KEY, DAYTONA_API_URL
|
||||
sandbox = await daytona.create()
|
||||
async with AsyncHanzoRuntime() as hanzo_runtime: # Uses HANZO_RUNTIME_API_KEY, HANZO_RUNTIME_API_URL
|
||||
sandbox = await hanzo_runtime.create()
|
||||
```
|
||||
|
||||
Using explicit configuration:
|
||||
```python
|
||||
config = DaytonaConfig(
|
||||
config = HanzoRuntimeConfig(
|
||||
api_key="your-api-key",
|
||||
api_url="https://your-api.com",
|
||||
target="us"
|
||||
)
|
||||
try:
|
||||
daytona = AsyncDaytona(config)
|
||||
sandbox = await daytona.create()
|
||||
hanzo_runtime = AsyncHanzoRuntime(config)
|
||||
sandbox = await hanzo_runtime.create()
|
||||
finally:
|
||||
await daytona.close()
|
||||
await hanzo_runtime.close()
|
||||
```
|
||||
"""
|
||||
|
||||
@@ -77,38 +77,38 @@ class AsyncDaytona:
|
||||
_api_url: str
|
||||
_target: Optional[str] = None
|
||||
|
||||
def __init__(self, config: Optional[DaytonaConfig] = None):
|
||||
"""Initializes Daytona instance with optional configuration.
|
||||
def __init__(self, config: Optional[HanzoRuntimeConfig] = None):
|
||||
"""Initializes HanzoRuntime instance with optional configuration.
|
||||
|
||||
If no config is provided, reads from environment variables:
|
||||
- `DAYTONA_API_KEY`: Required API key for authentication
|
||||
- `DAYTONA_API_URL`: Required api URL
|
||||
- `DAYTONA_TARGET`: Optional target environment (defaults to 'us')
|
||||
- `HANZO_RUNTIME_API_KEY`: Required API key for authentication
|
||||
- `HANZO_RUNTIME_API_URL`: Required api URL
|
||||
- `HANZO_RUNTIME_TARGET`: Optional target environment (defaults to 'us')
|
||||
|
||||
Args:
|
||||
config (Optional[DaytonaConfig]): Object containing api_key, api_url, and target.
|
||||
config (Optional[HanzoRuntimeConfig]): Object containing api_key, api_url, and target.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If API key is not provided either through config or environment variables
|
||||
HanzoRuntimeError: If API key is not provided either through config or environment variables
|
||||
|
||||
Example:
|
||||
```python
|
||||
from daytona import Daytona, DaytonaConfig
|
||||
from hanzo_runtime import HanzoRuntime, HanzoRuntimeConfig
|
||||
# Using environment variables
|
||||
daytona1 = AsyncDaytona()
|
||||
await daytona1.close()
|
||||
hanzo_runtime1 = AsyncHanzoRuntime()
|
||||
await hanzo_runtime1.close()
|
||||
# Using explicit configuration
|
||||
config = DaytonaConfig(
|
||||
config = HanzoRuntimeConfig(
|
||||
api_key="your-api-key",
|
||||
api_url="https://your-api.com",
|
||||
target="us"
|
||||
)
|
||||
daytona2 = AsyncDaytona(config)
|
||||
await daytona2.close()
|
||||
hanzo_runtime2 = AsyncHanzoRuntime(config)
|
||||
await hanzo_runtime2.close()
|
||||
```
|
||||
"""
|
||||
|
||||
default_api_url = "https://app.daytona.io/api"
|
||||
default_api_url = "https://app.hanzo.ai/api"
|
||||
self.default_language = CodeLanguage.PYTHON
|
||||
api_url = None
|
||||
|
||||
@@ -136,16 +136,16 @@ class AsyncDaytona:
|
||||
env.read_env(".env", override=True)
|
||||
env.read_env(".env.local", override=True)
|
||||
|
||||
self._api_key = self._api_key or (env.str("DAYTONA_API_KEY", None) if not self._jwt_token else None)
|
||||
self._jwt_token = self._jwt_token or env.str("DAYTONA_JWT_TOKEN", None)
|
||||
self._organization_id = self._organization_id or env.str("DAYTONA_ORGANIZATION_ID", None)
|
||||
api_url = api_url or env.str("DAYTONA_API_URL", None) or env.str("DAYTONA_SERVER_URL", default_api_url)
|
||||
self._target = self._target or env.str("DAYTONA_TARGET", None)
|
||||
self._api_key = self._api_key or (env.str("HANZO_RUNTIME_API_KEY", None) if not self._jwt_token else None)
|
||||
self._jwt_token = self._jwt_token or env.str("HANZO_RUNTIME_JWT_TOKEN", None)
|
||||
self._organization_id = self._organization_id or env.str("HANZO_RUNTIME_ORGANIZATION_ID", None)
|
||||
api_url = api_url or env.str("HANZO_RUNTIME_API_URL", None) or env.str("HANZO_RUNTIME_SERVER_URL", default_api_url)
|
||||
self._target = self._target or env.str("HANZO_RUNTIME_TARGET", None)
|
||||
|
||||
if env.str("DAYTONA_SERVER_URL", None) and not env.str("DAYTONA_API_URL", None):
|
||||
if env.str("HANZO_RUNTIME_SERVER_URL", None) and not env.str("HANZO_RUNTIME_API_URL", None):
|
||||
warnings.warn(
|
||||
"Environment variable `DAYTONA_SERVER_URL` is deprecated and will be removed in future versions. "
|
||||
+ "Use `DAYTONA_API_URL` instead.",
|
||||
"Environment variable `HANZO_RUNTIME_SERVER_URL` is deprecated and will be removed in future versions. "
|
||||
+ "Use `HANZO_RUNTIME_API_URL` instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
@@ -153,18 +153,18 @@ class AsyncDaytona:
|
||||
self._api_url = api_url
|
||||
|
||||
if not self._api_key and not self._jwt_token:
|
||||
raise DaytonaError("API key or JWT token is required")
|
||||
raise HanzoRuntimeError("API key or JWT token is required")
|
||||
|
||||
# Create API configuration without api_key
|
||||
configuration = Configuration(host=self._api_url)
|
||||
self._api_client = ApiClient(configuration)
|
||||
self._api_client.default_headers["Authorization"] = f"Bearer {self._api_key or self._jwt_token}"
|
||||
self._api_client.default_headers["X-Daytona-Source"] = "python-sdk"
|
||||
self._api_client.default_headers["X-HanzoRuntime-Source"] = "python-sdk"
|
||||
|
||||
# Get SDK version dynamically
|
||||
try:
|
||||
sdk_version = None
|
||||
for pkg_name in ["daytona_sdk", "daytona"]:
|
||||
for pkg_name in ["hanzo_runtime_sdk", "hanzo_runtime"]:
|
||||
try:
|
||||
sdk_version = version(pkg_name)
|
||||
break
|
||||
@@ -177,12 +177,12 @@ class AsyncDaytona:
|
||||
except Exception:
|
||||
# Fallback version if neither package metadata is available
|
||||
sdk_version = "unknown"
|
||||
self._api_client.default_headers["X-Daytona-SDK-Version"] = sdk_version
|
||||
self._api_client.default_headers["X-HanzoRuntime-SDK-Version"] = sdk_version
|
||||
|
||||
if not self._api_key:
|
||||
if not self._organization_id:
|
||||
raise DaytonaError("Organization ID is required when using JWT token")
|
||||
self._api_client.default_headers["X-Daytona-Organization-ID"] = self._organization_id
|
||||
raise HanzoRuntimeError("Organization ID is required when using JWT token")
|
||||
self._api_client.default_headers["X-HanzoRuntime-Organization-ID"] = self._organization_id
|
||||
|
||||
# Initialize API clients with the api_client instance
|
||||
self._sandbox_api = SandboxApi(self._api_client)
|
||||
@@ -205,23 +205,23 @@ class AsyncDaytona:
|
||||
async def close(self):
|
||||
"""Close the HTTP session and clean up resources.
|
||||
|
||||
This method should be called when you're done using the AsyncDaytona instance
|
||||
This method should be called when you're done using the AsyncHanzoRuntime instance
|
||||
to properly close the underlying HTTP session and avoid resource leaks.
|
||||
|
||||
Example:
|
||||
```python
|
||||
daytona = AsyncDaytona()
|
||||
hanzo_runtime = AsyncHanzoRuntime()
|
||||
try:
|
||||
sandbox = await daytona.create()
|
||||
sandbox = await hanzo_runtime.create()
|
||||
# ... use sandbox ...
|
||||
finally:
|
||||
await daytona.close()
|
||||
await hanzo_runtime.close()
|
||||
```
|
||||
|
||||
Or better yet, use as async context manager:
|
||||
```python
|
||||
async with AsyncDaytona() as daytona:
|
||||
sandbox = await daytona.create()
|
||||
async with AsyncHanzoRuntime() as hanzo_runtime:
|
||||
sandbox = await hanzo_runtime.create()
|
||||
# ... use sandbox ...
|
||||
# Automatically closed
|
||||
```
|
||||
@@ -243,7 +243,7 @@ class AsyncDaytona:
|
||||
|
||||
Args:
|
||||
params (Optional[CreateSandboxFromSnapshotParams]): Parameters for Sandbox creation. If not provided,
|
||||
defaults to default Daytona snapshot and Python language.
|
||||
defaults to default HanzoRuntime snapshot and Python language.
|
||||
timeout (Optional[float]): Timeout (in seconds) for sandbox creation. 0 means no timeout.
|
||||
Default is 60 seconds.
|
||||
|
||||
@@ -251,13 +251,13 @@ class AsyncDaytona:
|
||||
Sandbox: The created Sandbox instance.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If timeout, auto_stop_interval or auto_archive_interval is negative;
|
||||
HanzoRuntimeError: If timeout, auto_stop_interval or auto_archive_interval is negative;
|
||||
If sandbox fails to start or times out
|
||||
|
||||
Example:
|
||||
Create a default Python Sandbox:
|
||||
```python
|
||||
sandbox = await daytona.create()
|
||||
sandbox = await hanzo_runtime.create()
|
||||
```
|
||||
|
||||
Create a custom Sandbox:
|
||||
@@ -270,7 +270,7 @@ class AsyncDaytona:
|
||||
auto_archive_interval=60,
|
||||
auto_delete_interval=120
|
||||
)
|
||||
sandbox = await daytona.create(params, timeout=40)
|
||||
sandbox = await hanzo_runtime.create(params, timeout=40)
|
||||
```
|
||||
"""
|
||||
|
||||
@@ -282,9 +282,9 @@ class AsyncDaytona:
|
||||
timeout: Optional[float] = 60,
|
||||
on_snapshot_create_logs: Callable[[str], None] = None,
|
||||
) -> AsyncSandbox:
|
||||
"""Creates Sandboxes from specified image available on some registry or declarative Daytona Image.
|
||||
"""Creates Sandboxes from specified image available on some registry or declarative HanzoRuntime Image.
|
||||
You can specify various parameters, including resources, language, image, environment variables,
|
||||
and volumes. Daytona creates snapshot from provided image and uses it to create Sandbox.
|
||||
and volumes. HanzoRuntime creates snapshot from provided image and uses it to create Sandbox.
|
||||
|
||||
Args:
|
||||
params (Optional[CreateSandboxFromImageParams]): Parameters for Sandbox creation from image.
|
||||
@@ -296,13 +296,13 @@ class AsyncDaytona:
|
||||
Sandbox: The created Sandbox instance.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If timeout, auto_stop_interval or auto_archive_interval is negative;
|
||||
HanzoRuntimeError: If timeout, auto_stop_interval or auto_archive_interval is negative;
|
||||
If sandbox fails to start or times out
|
||||
|
||||
Example:
|
||||
Create a default Python Sandbox from image:
|
||||
```python
|
||||
sandbox = await daytona.create(CreateSandboxFromImageParams(image="debian:12.9"))
|
||||
sandbox = await hanzo_runtime.create(CreateSandboxFromImageParams(image="debian:12.9"))
|
||||
```
|
||||
|
||||
Create a custom Sandbox from declarative Image definition:
|
||||
@@ -321,7 +321,7 @@ class AsyncDaytona:
|
||||
auto_archive_interval=60,
|
||||
auto_delete_interval=120
|
||||
)
|
||||
sandbox = await daytona.create(
|
||||
sandbox = await hanzo_runtime.create(
|
||||
params,
|
||||
timeout=40,
|
||||
on_snapshot_create_logs=lambda chunk: print(chunk, end=""),
|
||||
@@ -360,13 +360,13 @@ class AsyncDaytona:
|
||||
code_toolbox = self._get_code_toolbox(params.language)
|
||||
|
||||
if timeout < 0:
|
||||
raise DaytonaError("Timeout must be a non-negative number")
|
||||
raise HanzoRuntimeError("Timeout must be a non-negative number")
|
||||
|
||||
if params.auto_stop_interval is not None and params.auto_stop_interval < 0:
|
||||
raise DaytonaError("auto_stop_interval must be a non-negative integer")
|
||||
raise HanzoRuntimeError("auto_stop_interval must be a non-negative integer")
|
||||
|
||||
if params.auto_archive_interval is not None and params.auto_archive_interval < 0:
|
||||
raise DaytonaError("auto_archive_interval must be a non-negative integer")
|
||||
raise HanzoRuntimeError("auto_archive_interval must be a non-negative integer")
|
||||
|
||||
target = self._target
|
||||
|
||||
@@ -454,7 +454,7 @@ class AsyncDaytona:
|
||||
try:
|
||||
await sandbox.wait_for_sandbox_start()
|
||||
finally:
|
||||
# If not Daytona SaaS, we don't need to handle pulling image state
|
||||
# If not HanzoRuntime SaaS, we don't need to handle pulling image state
|
||||
pass
|
||||
|
||||
return sandbox
|
||||
@@ -469,14 +469,14 @@ class AsyncDaytona:
|
||||
The appropriate code toolbox instance for the specified language.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If an unsupported language is specified.
|
||||
HanzoRuntimeError: If an unsupported language is specified.
|
||||
"""
|
||||
if not language:
|
||||
return SandboxPythonCodeToolbox()
|
||||
|
||||
enum_language = to_enum(CodeLanguage, language)
|
||||
if enum_language is None:
|
||||
raise DaytonaError(f"Unsupported language: {language}")
|
||||
raise HanzoRuntimeError(f"Unsupported language: {language}")
|
||||
language = enum_language
|
||||
|
||||
match language:
|
||||
@@ -485,7 +485,7 @@ class AsyncDaytona:
|
||||
case CodeLanguage.PYTHON:
|
||||
return SandboxPythonCodeToolbox()
|
||||
case _:
|
||||
raise DaytonaError(f"Unsupported language: {language}")
|
||||
raise HanzoRuntimeError(f"Unsupported language: {language}")
|
||||
|
||||
async def delete(self, sandbox: AsyncSandbox, timeout: Optional[float] = 60) -> None:
|
||||
"""Deletes a Sandbox.
|
||||
@@ -496,13 +496,13 @@ class AsyncDaytona:
|
||||
Default is 60 seconds.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If sandbox fails to delete or times out
|
||||
HanzoRuntimeError: If sandbox fails to delete or times out
|
||||
|
||||
Example:
|
||||
```python
|
||||
sandbox = await daytona.create()
|
||||
sandbox = await hanzo_runtime.create()
|
||||
# ... use sandbox ...
|
||||
await daytona.delete(sandbox) # Clean up when done
|
||||
await hanzo_runtime.delete(sandbox) # Clean up when done
|
||||
```
|
||||
"""
|
||||
return await sandbox.delete(timeout)
|
||||
@@ -518,16 +518,16 @@ class AsyncDaytona:
|
||||
Sandbox: The Sandbox instance.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If sandbox_id is not provided.
|
||||
HanzoRuntimeError: If sandbox_id is not provided.
|
||||
|
||||
Example:
|
||||
```python
|
||||
sandbox = await daytona.get("my-sandbox-id")
|
||||
sandbox = await hanzo_runtime.get("my-sandbox-id")
|
||||
print(sandbox.status)
|
||||
```
|
||||
"""
|
||||
if not sandbox_id:
|
||||
raise DaytonaError("sandbox_id is required")
|
||||
raise HanzoRuntimeError("sandbox_id is required")
|
||||
|
||||
# Get the sandbox instance
|
||||
sandbox_instance = await self._sandbox_api.get_sandbox(sandbox_id)
|
||||
@@ -553,11 +553,11 @@ class AsyncDaytona:
|
||||
Sandbox: First Sandbox that matches the ID or labels.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If no Sandbox is found.
|
||||
HanzoRuntimeError: If no Sandbox is found.
|
||||
|
||||
Example:
|
||||
```python
|
||||
sandbox = await daytona.find_one(labels={"my-label": "my-value"})
|
||||
sandbox = await hanzo_runtime.find_one(labels={"my-label": "my-value"})
|
||||
print(f"Sandbox ID: {sandbox.id} State: {sandbox.state}")
|
||||
```
|
||||
"""
|
||||
@@ -565,7 +565,7 @@ class AsyncDaytona:
|
||||
return await self.get(sandbox_id)
|
||||
sandboxes = await self.list(labels)
|
||||
if len(sandboxes) == 0:
|
||||
raise DaytonaError(f"No sandbox found with labels {labels}")
|
||||
raise HanzoRuntimeError(f"No sandbox found with labels {labels}")
|
||||
return sandboxes[0]
|
||||
|
||||
@intercept_errors(message_prefix="Failed to list sandboxes: ")
|
||||
@@ -580,7 +580,7 @@ class AsyncDaytona:
|
||||
|
||||
Example:
|
||||
```python
|
||||
sandboxes = await daytona.list(labels={"my-label": "my-value"})
|
||||
sandboxes = await hanzo_runtime.list(labels={"my-label": "my-value"})
|
||||
for sandbox in sandboxes:
|
||||
print(f"{sandbox.id}: {sandbox.status}")
|
||||
```
|
||||
@@ -607,14 +607,14 @@ class AsyncDaytona:
|
||||
CodeLanguage: The validated language, defaults to "python" if None
|
||||
|
||||
Raises:
|
||||
DaytonaError: If the language is not supported.
|
||||
HanzoRuntimeError: If the language is not supported.
|
||||
"""
|
||||
if not language:
|
||||
return CodeLanguage.PYTHON
|
||||
|
||||
enum_language = to_enum(CodeLanguage, language)
|
||||
if enum_language is None:
|
||||
raise DaytonaError(f"Invalid code-toolbox-language: {language}")
|
||||
raise HanzoRuntimeError(f"Invalid code-toolbox-language: {language}")
|
||||
return enum_language
|
||||
|
||||
async def start(self, sandbox: AsyncSandbox, timeout: Optional[float] = 60) -> None:
|
||||
@@ -626,7 +626,7 @@ class AsyncDaytona:
|
||||
0 means no timeout. Default is 60 seconds.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If timeout is negative; If Sandbox fails to start or times out
|
||||
HanzoRuntimeError: If timeout is negative; If Sandbox fails to start or times out
|
||||
"""
|
||||
await sandbox.start(timeout)
|
||||
|
||||
@@ -639,6 +639,6 @@ class AsyncDaytona:
|
||||
0 means no timeout. Default is 60 seconds.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If timeout is negative; If Sandbox fails to stop or times out
|
||||
HanzoRuntimeError: If timeout is negative; If Sandbox fails to stop or times out
|
||||
"""
|
||||
await sandbox.stop(timeout)
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
from typing import List
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import asyncio
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import base64
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import asyncio
|
||||
@@ -12,7 +12,7 @@ from pydantic import ConfigDict, PrivateAttr
|
||||
from .._utils.errors import intercept_errors
|
||||
from .._utils.path import prefix_relative_path
|
||||
from .._utils.timeout import with_timeout
|
||||
from ..common.errors import DaytonaError
|
||||
from ..common.errors import HanzoRuntimeError
|
||||
from ..common.protocols import SandboxCodeToolbox
|
||||
from .computer_use import AsyncComputerUse
|
||||
from .filesystem import AsyncFileSystem
|
||||
@@ -22,7 +22,7 @@ from .process import AsyncProcess
|
||||
|
||||
|
||||
class AsyncSandbox(SandboxDto):
|
||||
"""Represents a Daytona Sandbox.
|
||||
"""Represents a HanzoRuntime Sandbox.
|
||||
|
||||
Attributes:
|
||||
fs (AsyncFileSystem): File system operations interface.
|
||||
@@ -31,7 +31,7 @@ class AsyncSandbox(SandboxDto):
|
||||
computer_use (AsyncComputerUse): Computer use operations interface for desktop automation.
|
||||
id (str): Unique identifier for the Sandbox.
|
||||
organization_id (str): Organization ID of the Sandbox.
|
||||
snapshot (str): Daytona snapshot used to create the Sandbox.
|
||||
snapshot (str): HanzoRuntime snapshot used to create the Sandbox.
|
||||
user (str): OS user running in the Sandbox.
|
||||
env (Dict[str, str]): Environment variables set in the Sandbox.
|
||||
labels (Dict[str, str]): Custom labels attached to the Sandbox.
|
||||
@@ -204,7 +204,7 @@ class AsyncSandbox(SandboxDto):
|
||||
timeout (Optional[float]): Maximum time to wait in seconds. 0 means no timeout. Default is 60 seconds.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If timeout is negative. If sandbox fails to start or times out.
|
||||
HanzoRuntimeError: If timeout is negative. If sandbox fails to start or times out.
|
||||
|
||||
Example:
|
||||
```python
|
||||
@@ -230,7 +230,7 @@ class AsyncSandbox(SandboxDto):
|
||||
timeout (Optional[float]): Maximum time to wait in seconds. 0 means no timeout. Default is 60 seconds.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If timeout is negative; If sandbox fails to stop or times out
|
||||
HanzoRuntimeError: If timeout is negative; If sandbox fails to stop or times out
|
||||
|
||||
Example:
|
||||
```python
|
||||
@@ -271,7 +271,7 @@ class AsyncSandbox(SandboxDto):
|
||||
timeout (Optional[float]): Maximum time to wait in seconds. 0 means no timeout. Default is 60 seconds.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If timeout is negative; If Sandbox fails to start or times out
|
||||
HanzoRuntimeError: If timeout is negative; If Sandbox fails to start or times out
|
||||
"""
|
||||
while self.state != "started":
|
||||
await self.refresh_data()
|
||||
@@ -283,7 +283,7 @@ class AsyncSandbox(SandboxDto):
|
||||
err_msg = (
|
||||
f"Sandbox {self.id} failed to start with state: {self.state}, error reason: {self.error_reason}"
|
||||
)
|
||||
raise DaytonaError(err_msg)
|
||||
raise HanzoRuntimeError(err_msg)
|
||||
|
||||
await asyncio.sleep(0.1) # Wait 100ms between checks
|
||||
|
||||
@@ -305,7 +305,7 @@ class AsyncSandbox(SandboxDto):
|
||||
timeout (Optional[float]): Maximum time to wait in seconds. 0 means no timeout. Default is 60 seconds.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If timeout is negative. If Sandbox fails to stop or times out.
|
||||
HanzoRuntimeError: If timeout is negative. If Sandbox fails to stop or times out.
|
||||
"""
|
||||
while self.state != "stopped":
|
||||
try:
|
||||
@@ -315,7 +315,7 @@ class AsyncSandbox(SandboxDto):
|
||||
err_msg = (
|
||||
f"Sandbox {self.id} failed to stop with status: {self.state}, error reason: {self.error_reason}"
|
||||
)
|
||||
raise DaytonaError(err_msg)
|
||||
raise HanzoRuntimeError(err_msg)
|
||||
except Exception as e:
|
||||
# If there's a validation error, continue waiting
|
||||
if "validation error" not in str(e):
|
||||
@@ -336,7 +336,7 @@ class AsyncSandbox(SandboxDto):
|
||||
Set to 0 to disable auto-stop. Defaults to 15.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If interval is negative
|
||||
HanzoRuntimeError: If interval is negative
|
||||
|
||||
Example:
|
||||
```python
|
||||
@@ -347,7 +347,7 @@ class AsyncSandbox(SandboxDto):
|
||||
```
|
||||
"""
|
||||
if not isinstance(interval, int) or interval < 0:
|
||||
raise DaytonaError("Auto-stop interval must be a non-negative integer")
|
||||
raise HanzoRuntimeError("Auto-stop interval must be a non-negative integer")
|
||||
|
||||
await self._sandbox_api.set_autostop_interval(self.id, interval)
|
||||
self.auto_stop_interval = interval
|
||||
@@ -363,7 +363,7 @@ class AsyncSandbox(SandboxDto):
|
||||
Set to 0 for the maximum interval. Default is 7 days.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If interval is negative
|
||||
HanzoRuntimeError: If interval is negative
|
||||
|
||||
Example:
|
||||
```python
|
||||
@@ -374,7 +374,7 @@ class AsyncSandbox(SandboxDto):
|
||||
```
|
||||
"""
|
||||
if not isinstance(interval, int) or interval < 0:
|
||||
raise DaytonaError("Auto-archive interval must be a non-negative integer")
|
||||
raise HanzoRuntimeError("Auto-archive interval must be a non-negative integer")
|
||||
await self._sandbox_api.set_auto_archive_interval(self.id, interval)
|
||||
self.auto_archive_interval = interval
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import asyncio
|
||||
@@ -12,7 +12,7 @@ from daytona_api_client_async.models.snapshot_state import SnapshotState
|
||||
from .._utils.errors import intercept_errors
|
||||
from .._utils.stream import process_streaming_response
|
||||
from .._utils.timeout import with_timeout
|
||||
from ..common.errors import DaytonaError
|
||||
from ..common.errors import HanzoRuntimeError
|
||||
from ..common.image import Image
|
||||
from ..common.snapshot import CreateSnapshotParams, Snapshot
|
||||
from .object_storage import AsyncObjectStorage
|
||||
@@ -21,7 +21,7 @@ SNAPSHOTS_FETCH_LIMIT = 200
|
||||
|
||||
|
||||
class AsyncSnapshotService:
|
||||
"""Service for managing Daytona Snapshots. Can be used to list, get, create and delete Snapshots."""
|
||||
"""Service for managing HanzoRuntime Snapshots. Can be used to list, get, create and delete Snapshots."""
|
||||
|
||||
def __init__(self, snapshots_api: SnapshotsApi, object_storage_api: ObjectStorageApi):
|
||||
self.__snapshots_api = snapshots_api
|
||||
@@ -36,7 +36,7 @@ class AsyncSnapshotService:
|
||||
|
||||
Example:
|
||||
```python
|
||||
async with AsyncDaytona() as daytona:
|
||||
async with AsyncHanzoRuntime() as daytona:
|
||||
snapshots = await daytona.snapshot.list()
|
||||
for snapshot in snapshots:
|
||||
print(f"{snapshot.name} ({snapshot.image_name})")
|
||||
@@ -56,7 +56,7 @@ class AsyncSnapshotService:
|
||||
|
||||
Example:
|
||||
```python
|
||||
async with AsyncDaytona() as daytona:
|
||||
async with AsyncHanzoRuntime() as daytona:
|
||||
snapshot = await daytona.snapshot.get("test-snapshot")
|
||||
await daytona.snapshot.delete(snapshot)
|
||||
print("Snapshot deleted")
|
||||
@@ -76,7 +76,7 @@ class AsyncSnapshotService:
|
||||
|
||||
Example:
|
||||
```python
|
||||
async with AsyncDaytona() as daytona:
|
||||
async with AsyncHanzoRuntime() as daytona:
|
||||
snapshot = await daytona.snapshot.get("test-snapshot-name")
|
||||
print(f"{snapshot.name} ({snapshot.image_name})")
|
||||
```
|
||||
@@ -182,7 +182,7 @@ class AsyncSnapshotService:
|
||||
on_logs(f"Created snapshot {created_snapshot.name} ({created_snapshot.state})")
|
||||
|
||||
if created_snapshot.state in (SnapshotState.ERROR, SnapshotState.BUILD_FAILED):
|
||||
raise DaytonaError(
|
||||
raise HanzoRuntimeError(
|
||||
f"Failed to create snapshot {created_snapshot.name}, reason: {created_snapshot.error_reason}"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import re
|
||||
@@ -11,7 +11,7 @@ from ..common.volume import Volume
|
||||
|
||||
|
||||
class AsyncVolumeService:
|
||||
"""Service for managing Daytona Volumes. Can be used to list, get, create and delete Volumes."""
|
||||
"""Service for managing HanzoRuntime Volumes. Can be used to list, get, create and delete Volumes."""
|
||||
|
||||
def __init__(self, volumes_api: VolumesApi):
|
||||
self.__volumes_api = volumes_api
|
||||
@@ -24,7 +24,7 @@ class AsyncVolumeService:
|
||||
|
||||
Example:
|
||||
```python
|
||||
async with AsyncDaytona() as daytona:
|
||||
async with AsyncHanzoRuntime() as daytona:
|
||||
volumes = await daytona.volume.list()
|
||||
for volume in volumes:
|
||||
print(f"{volume.name} ({volume.id})")
|
||||
@@ -44,7 +44,7 @@ class AsyncVolumeService:
|
||||
|
||||
Example:
|
||||
```python
|
||||
async with AsyncDaytona() as daytona:
|
||||
async with AsyncHanzoRuntime() as daytona:
|
||||
volume = await daytona.volume.get("test-volume-name", create=True)
|
||||
print(f"{volume.name} ({volume.id})")
|
||||
```
|
||||
@@ -67,7 +67,7 @@ class AsyncVolumeService:
|
||||
|
||||
Example:
|
||||
```python
|
||||
async with AsyncDaytona() as daytona:
|
||||
async with AsyncHanzoRuntime() as daytona:
|
||||
volume = await daytona.volume.create("test-volume")
|
||||
print(f"{volume.name} ({volume.id}); state: {volume.state}")
|
||||
```
|
||||
@@ -82,7 +82,7 @@ class AsyncVolumeService:
|
||||
|
||||
Example:
|
||||
```python
|
||||
async with AsyncDaytona() as daytona:
|
||||
async with AsyncHanzoRuntime() as daytona:
|
||||
volume = await daytona.volume.get("test-volume")
|
||||
await daytona.volume.delete(volume)
|
||||
print("Volume deleted")
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# DO NOT EDIT THIS FILE MANUALLY.
|
||||
@@ -178,7 +178,7 @@ class Keyboard:
|
||||
delay (int): Delay between characters in milliseconds.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If the type operation fails.
|
||||
HanzoRuntimeError: If the type operation fails.
|
||||
|
||||
Example:
|
||||
```python
|
||||
@@ -208,7 +208,7 @@ class Keyboard:
|
||||
modifiers (List[str]): Modifier keys ('ctrl', 'alt', 'meta', 'shift').
|
||||
|
||||
Raises:
|
||||
DaytonaError: If the press operation fails.
|
||||
HanzoRuntimeError: If the press operation fails.
|
||||
|
||||
Example:
|
||||
```python
|
||||
@@ -243,7 +243,7 @@ class Keyboard:
|
||||
keys (str): The hotkey combination (e.g., 'ctrl+c', 'alt+tab', 'cmd+shift+t').
|
||||
|
||||
Raises:
|
||||
DaytonaError: If the hotkey operation fails.
|
||||
HanzoRuntimeError: If the hotkey operation fails.
|
||||
|
||||
Example:
|
||||
```python
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# DO NOT EDIT THIS FILE MANUALLY.
|
||||
@@ -22,7 +22,7 @@ class FileSystem:
|
||||
"""Provides file system operations within a Sandbox.
|
||||
|
||||
This class implements a high-level interface to file system operations that can
|
||||
be performed within a Daytona Sandbox.
|
||||
be performed within a HanzoRuntime Sandbox.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# DO NOT EDIT THIS FILE MANUALLY.
|
||||
|
||||
+67
-67
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# DO NOT EDIT THIS FILE MANUALLY.
|
||||
@@ -27,16 +27,16 @@ from daytona_api_client import VolumesApi as VolumesApi
|
||||
from environs import Env
|
||||
|
||||
from .._utils.enum import to_enum
|
||||
from .._utils.errors import DaytonaError, intercept_errors
|
||||
from .._utils.errors import HanzoRuntimeError, intercept_errors
|
||||
from .._utils.stream import process_streaming_response
|
||||
from .._utils.timeout import with_timeout
|
||||
from ..code_toolbox.sandbox_python_code_toolbox import SandboxPythonCodeToolbox
|
||||
from ..code_toolbox.sandbox_ts_code_toolbox import SandboxTsCodeToolbox
|
||||
from ..common.daytona import (
|
||||
from ..common.hanzo_runtime import (
|
||||
CodeLanguage,
|
||||
CreateSandboxFromImageParams,
|
||||
CreateSandboxFromSnapshotParams,
|
||||
DaytonaConfig,
|
||||
HanzoRuntimeConfig,
|
||||
Image,
|
||||
)
|
||||
from .sandbox import Sandbox
|
||||
@@ -44,10 +44,10 @@ from .snapshot import SnapshotService
|
||||
from .volume import VolumeService
|
||||
|
||||
|
||||
class Daytona:
|
||||
"""Main class for interacting with the Daytona API.
|
||||
class HanzoRuntime:
|
||||
"""Main class for interacting with the HanzoRuntime API.
|
||||
|
||||
This class provides methods to create, manage, and interact with Daytona Sandboxes.
|
||||
This class provides methods to create, manage, and interact with HanzoRuntime Sandboxes.
|
||||
It can be initialized either with explicit configuration or using environment variables.
|
||||
|
||||
Attributes:
|
||||
@@ -57,19 +57,19 @@ class Daytona:
|
||||
Example:
|
||||
Using environment variables:
|
||||
```python
|
||||
daytona = Daytona() # Uses DAYTONA_API_KEY, DAYTONA_API_URL
|
||||
sandbox = daytona.create()
|
||||
hanzo_runtime = HanzoRuntime() # Uses HANZO_RUNTIME_API_KEY, HANZO_RUNTIME_API_URL
|
||||
sandbox = hanzo_runtime.create()
|
||||
```
|
||||
|
||||
Using explicit configuration:
|
||||
```python
|
||||
config = DaytonaConfig(
|
||||
config = HanzoRuntimeConfig(
|
||||
api_key="your-api-key",
|
||||
api_url="https://your-api.com",
|
||||
target="us"
|
||||
)
|
||||
daytona = Daytona(config)
|
||||
sandbox = daytona.create()
|
||||
hanzo_runtime = HanzoRuntime(config)
|
||||
sandbox = hanzo_runtime.create()
|
||||
```
|
||||
"""
|
||||
|
||||
@@ -79,38 +79,38 @@ class Daytona:
|
||||
_api_url: str
|
||||
_target: Optional[str] = None
|
||||
|
||||
def __init__(self, config: Optional[DaytonaConfig] = None):
|
||||
"""Initializes Daytona instance with optional configuration.
|
||||
def __init__(self, config: Optional[HanzoRuntimeConfig] = None):
|
||||
"""Initializes HanzoRuntime instance with optional configuration.
|
||||
|
||||
If no config is provided, reads from environment variables:
|
||||
- `DAYTONA_API_KEY`: Required API key for authentication
|
||||
- `DAYTONA_API_URL`: Required api URL
|
||||
- `DAYTONA_TARGET`: Optional target environment (defaults to 'us')
|
||||
- `HANZO_RUNTIME_API_KEY`: Required API key for authentication
|
||||
- `HANZO_RUNTIME_API_URL`: Required api URL
|
||||
- `HANZO_RUNTIME_TARGET`: Optional target environment (defaults to 'us')
|
||||
|
||||
Args:
|
||||
config (Optional[DaytonaConfig]): Object containing api_key, api_url, and target.
|
||||
config (Optional[HanzoRuntimeConfig]): Object containing api_key, api_url, and target.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If API key is not provided either through config or environment variables
|
||||
HanzoRuntimeError: If API key is not provided either through config or environment variables
|
||||
|
||||
Example:
|
||||
```python
|
||||
from daytona import Daytona, DaytonaConfig
|
||||
from hanzo_runtime import HanzoRuntime, HanzoRuntimeConfig
|
||||
# Using environment variables
|
||||
daytona1 = Daytona()
|
||||
hanzo_runtime1 = HanzoRuntime()
|
||||
|
||||
# Using explicit configuration
|
||||
config = DaytonaConfig(
|
||||
config = HanzoRuntimeConfig(
|
||||
api_key="your-api-key",
|
||||
api_url="https://your-api.com",
|
||||
target="us"
|
||||
)
|
||||
daytona2 = Daytona(config)
|
||||
hanzo_runtime2 = HanzoRuntime(config)
|
||||
|
||||
```
|
||||
"""
|
||||
|
||||
default_api_url = "https://app.daytona.io/api"
|
||||
default_api_url = "https://app.hanzo.ai/api"
|
||||
self.default_language = CodeLanguage.PYTHON
|
||||
api_url = None
|
||||
|
||||
@@ -138,16 +138,16 @@ class Daytona:
|
||||
env.read_env(".env", override=True)
|
||||
env.read_env(".env.local", override=True)
|
||||
|
||||
self._api_key = self._api_key or (env.str("DAYTONA_API_KEY", None) if not self._jwt_token else None)
|
||||
self._jwt_token = self._jwt_token or env.str("DAYTONA_JWT_TOKEN", None)
|
||||
self._organization_id = self._organization_id or env.str("DAYTONA_ORGANIZATION_ID", None)
|
||||
api_url = api_url or env.str("DAYTONA_API_URL", None) or env.str("DAYTONA_SERVER_URL", default_api_url)
|
||||
self._target = self._target or env.str("DAYTONA_TARGET", None)
|
||||
self._api_key = self._api_key or (env.str("HANZO_RUNTIME_API_KEY", None) if not self._jwt_token else None)
|
||||
self._jwt_token = self._jwt_token or env.str("HANZO_RUNTIME_JWT_TOKEN", None)
|
||||
self._organization_id = self._organization_id or env.str("HANZO_RUNTIME_ORGANIZATION_ID", None)
|
||||
api_url = api_url or env.str("HANZO_RUNTIME_API_URL", None) or env.str("HANZO_RUNTIME_SERVER_URL", default_api_url)
|
||||
self._target = self._target or env.str("HANZO_RUNTIME_TARGET", None)
|
||||
|
||||
if env.str("DAYTONA_SERVER_URL", None) and not env.str("DAYTONA_API_URL", None):
|
||||
if env.str("HANZO_RUNTIME_SERVER_URL", None) and not env.str("HANZO_RUNTIME_API_URL", None):
|
||||
warnings.warn(
|
||||
"Environment variable `DAYTONA_SERVER_URL` is deprecated and will be removed in future versions. "
|
||||
+ "Use `DAYTONA_API_URL` instead.",
|
||||
"Environment variable `HANZO_RUNTIME_SERVER_URL` is deprecated and will be removed in future versions. "
|
||||
+ "Use `HANZO_RUNTIME_API_URL` instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
@@ -155,18 +155,18 @@ class Daytona:
|
||||
self._api_url = api_url
|
||||
|
||||
if not self._api_key and not self._jwt_token:
|
||||
raise DaytonaError("API key or JWT token is required")
|
||||
raise HanzoRuntimeError("API key or JWT token is required")
|
||||
|
||||
# Create API configuration without api_key
|
||||
configuration = Configuration(host=self._api_url)
|
||||
self._api_client = ApiClient(configuration)
|
||||
self._api_client.default_headers["Authorization"] = f"Bearer {self._api_key or self._jwt_token}"
|
||||
self._api_client.default_headers["X-Daytona-Source"] = "python-sdk"
|
||||
self._api_client.default_headers["X-HanzoRuntime-Source"] = "python-sdk"
|
||||
|
||||
# Get SDK version dynamically
|
||||
try:
|
||||
sdk_version = None
|
||||
for pkg_name in ["daytona_sdk", "daytona"]:
|
||||
for pkg_name in ["hanzo_runtime_sdk", "hanzo_runtime"]:
|
||||
try:
|
||||
sdk_version = version(pkg_name)
|
||||
break
|
||||
@@ -179,12 +179,12 @@ class Daytona:
|
||||
except Exception:
|
||||
# Fallback version if neither package metadata is available
|
||||
sdk_version = "unknown"
|
||||
self._api_client.default_headers["X-Daytona-SDK-Version"] = sdk_version
|
||||
self._api_client.default_headers["X-HanzoRuntime-SDK-Version"] = sdk_version
|
||||
|
||||
if not self._api_key:
|
||||
if not self._organization_id:
|
||||
raise DaytonaError("Organization ID is required when using JWT token")
|
||||
self._api_client.default_headers["X-Daytona-Organization-ID"] = self._organization_id
|
||||
raise HanzoRuntimeError("Organization ID is required when using JWT token")
|
||||
self._api_client.default_headers["X-HanzoRuntime-Organization-ID"] = self._organization_id
|
||||
|
||||
# Initialize API clients with the api_client instance
|
||||
self._sandbox_api = SandboxApi(self._api_client)
|
||||
@@ -207,7 +207,7 @@ class Daytona:
|
||||
|
||||
Args:
|
||||
params (Optional[CreateSandboxFromSnapshotParams]): Parameters for Sandbox creation. If not provided,
|
||||
defaults to default Daytona snapshot and Python language.
|
||||
defaults to default HanzoRuntime snapshot and Python language.
|
||||
timeout (Optional[float]): Timeout (in seconds) for sandbox creation. 0 means no timeout.
|
||||
Default is 60 seconds.
|
||||
|
||||
@@ -215,13 +215,13 @@ class Daytona:
|
||||
Sandbox: The created Sandbox instance.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If timeout, auto_stop_interval or auto_archive_interval is negative;
|
||||
HanzoRuntimeError: If timeout, auto_stop_interval or auto_archive_interval is negative;
|
||||
If sandbox fails to start or times out
|
||||
|
||||
Example:
|
||||
Create a default Python Sandbox:
|
||||
```python
|
||||
sandbox = daytona.create()
|
||||
sandbox = hanzo_runtime.create()
|
||||
```
|
||||
|
||||
Create a custom Sandbox:
|
||||
@@ -234,7 +234,7 @@ class Daytona:
|
||||
auto_archive_interval=60,
|
||||
auto_delete_interval=120
|
||||
)
|
||||
sandbox = daytona.create(params, timeout=40)
|
||||
sandbox = hanzo_runtime.create(params, timeout=40)
|
||||
```
|
||||
"""
|
||||
|
||||
@@ -246,9 +246,9 @@ class Daytona:
|
||||
timeout: Optional[float] = 60,
|
||||
on_snapshot_create_logs: Callable[[str], None] = None,
|
||||
) -> Sandbox:
|
||||
"""Creates Sandboxes from specified image available on some registry or declarative Daytona Image.
|
||||
"""Creates Sandboxes from specified image available on some registry or declarative HanzoRuntime Image.
|
||||
You can specify various parameters, including resources, language, image, environment variables,
|
||||
and volumes. Daytona creates snapshot from provided image and uses it to create Sandbox.
|
||||
and volumes. HanzoRuntime creates snapshot from provided image and uses it to create Sandbox.
|
||||
|
||||
Args:
|
||||
params (Optional[CreateSandboxFromImageParams]): Parameters for Sandbox creation from image.
|
||||
@@ -260,13 +260,13 @@ class Daytona:
|
||||
Sandbox: The created Sandbox instance.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If timeout, auto_stop_interval or auto_archive_interval is negative;
|
||||
HanzoRuntimeError: If timeout, auto_stop_interval or auto_archive_interval is negative;
|
||||
If sandbox fails to start or times out
|
||||
|
||||
Example:
|
||||
Create a default Python Sandbox from image:
|
||||
```python
|
||||
sandbox = daytona.create(CreateSandboxFromImageParams(image="debian:12.9"))
|
||||
sandbox = hanzo_runtime.create(CreateSandboxFromImageParams(image="debian:12.9"))
|
||||
```
|
||||
|
||||
Create a custom Sandbox from declarative Image definition:
|
||||
@@ -285,7 +285,7 @@ class Daytona:
|
||||
auto_archive_interval=60,
|
||||
auto_delete_interval=120
|
||||
)
|
||||
sandbox = daytona.create(
|
||||
sandbox = hanzo_runtime.create(
|
||||
params,
|
||||
timeout=40,
|
||||
on_snapshot_create_logs=lambda chunk: print(chunk, end=""),
|
||||
@@ -324,13 +324,13 @@ class Daytona:
|
||||
code_toolbox = self._get_code_toolbox(params.language)
|
||||
|
||||
if timeout < 0:
|
||||
raise DaytonaError("Timeout must be a non-negative number")
|
||||
raise HanzoRuntimeError("Timeout must be a non-negative number")
|
||||
|
||||
if params.auto_stop_interval is not None and params.auto_stop_interval < 0:
|
||||
raise DaytonaError("auto_stop_interval must be a non-negative integer")
|
||||
raise HanzoRuntimeError("auto_stop_interval must be a non-negative integer")
|
||||
|
||||
if params.auto_archive_interval is not None and params.auto_archive_interval < 0:
|
||||
raise DaytonaError("auto_archive_interval must be a non-negative integer")
|
||||
raise HanzoRuntimeError("auto_archive_interval must be a non-negative integer")
|
||||
|
||||
target = self._target
|
||||
|
||||
@@ -418,7 +418,7 @@ class Daytona:
|
||||
try:
|
||||
sandbox.wait_for_sandbox_start()
|
||||
finally:
|
||||
# If not Daytona SaaS, we don't need to handle pulling image state
|
||||
# If not HanzoRuntime SaaS, we don't need to handle pulling image state
|
||||
pass
|
||||
|
||||
return sandbox
|
||||
@@ -433,14 +433,14 @@ class Daytona:
|
||||
The appropriate code toolbox instance for the specified language.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If an unsupported language is specified.
|
||||
HanzoRuntimeError: If an unsupported language is specified.
|
||||
"""
|
||||
if not language:
|
||||
return SandboxPythonCodeToolbox()
|
||||
|
||||
enum_language = to_enum(CodeLanguage, language)
|
||||
if enum_language is None:
|
||||
raise DaytonaError(f"Unsupported language: {language}")
|
||||
raise HanzoRuntimeError(f"Unsupported language: {language}")
|
||||
language = enum_language
|
||||
|
||||
match language:
|
||||
@@ -449,7 +449,7 @@ class Daytona:
|
||||
case CodeLanguage.PYTHON:
|
||||
return SandboxPythonCodeToolbox()
|
||||
case _:
|
||||
raise DaytonaError(f"Unsupported language: {language}")
|
||||
raise HanzoRuntimeError(f"Unsupported language: {language}")
|
||||
|
||||
def delete(self, sandbox: Sandbox, timeout: Optional[float] = 60) -> None:
|
||||
"""Deletes a Sandbox.
|
||||
@@ -460,11 +460,11 @@ class Daytona:
|
||||
Default is 60 seconds.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If sandbox fails to delete or times out
|
||||
HanzoRuntimeError: If sandbox fails to delete or times out
|
||||
|
||||
Example:
|
||||
```python
|
||||
sandbox = daytona.create()
|
||||
sandbox = hanzo_runtime.create()
|
||||
# ... use sandbox ...
|
||||
daytona.delete(sandbox) # Clean up when done
|
||||
```
|
||||
@@ -482,16 +482,16 @@ class Daytona:
|
||||
Sandbox: The Sandbox instance.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If sandbox_id is not provided.
|
||||
HanzoRuntimeError: If sandbox_id is not provided.
|
||||
|
||||
Example:
|
||||
```python
|
||||
sandbox = daytona.get("my-sandbox-id")
|
||||
sandbox = hanzo_runtime.get("my-sandbox-id")
|
||||
print(sandbox.status)
|
||||
```
|
||||
"""
|
||||
if not sandbox_id:
|
||||
raise DaytonaError("sandbox_id is required")
|
||||
raise HanzoRuntimeError("sandbox_id is required")
|
||||
|
||||
# Get the sandbox instance
|
||||
sandbox_instance = self._sandbox_api.get_sandbox(sandbox_id)
|
||||
@@ -517,11 +517,11 @@ class Daytona:
|
||||
Sandbox: First Sandbox that matches the ID or labels.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If no Sandbox is found.
|
||||
HanzoRuntimeError: If no Sandbox is found.
|
||||
|
||||
Example:
|
||||
```python
|
||||
sandbox = daytona.find_one(labels={"my-label": "my-value"})
|
||||
sandbox = hanzo_runtime.find_one(labels={"my-label": "my-value"})
|
||||
print(f"Sandbox ID: {sandbox.id} State: {sandbox.state}")
|
||||
```
|
||||
"""
|
||||
@@ -529,7 +529,7 @@ class Daytona:
|
||||
return self.get(sandbox_id)
|
||||
sandboxes = self.list(labels)
|
||||
if len(sandboxes) == 0:
|
||||
raise DaytonaError(f"No sandbox found with labels {labels}")
|
||||
raise HanzoRuntimeError(f"No sandbox found with labels {labels}")
|
||||
return sandboxes[0]
|
||||
|
||||
@intercept_errors(message_prefix="Failed to list sandboxes: ")
|
||||
@@ -544,7 +544,7 @@ class Daytona:
|
||||
|
||||
Example:
|
||||
```python
|
||||
sandboxes = daytona.list(labels={"my-label": "my-value"})
|
||||
sandboxes = hanzo_runtime.list(labels={"my-label": "my-value"})
|
||||
for sandbox in sandboxes:
|
||||
print(f"{sandbox.id}: {sandbox.status}")
|
||||
```
|
||||
@@ -571,14 +571,14 @@ class Daytona:
|
||||
CodeLanguage: The validated language, defaults to "python" if None
|
||||
|
||||
Raises:
|
||||
DaytonaError: If the language is not supported.
|
||||
HanzoRuntimeError: If the language is not supported.
|
||||
"""
|
||||
if not language:
|
||||
return CodeLanguage.PYTHON
|
||||
|
||||
enum_language = to_enum(CodeLanguage, language)
|
||||
if enum_language is None:
|
||||
raise DaytonaError(f"Invalid code-toolbox-language: {language}")
|
||||
raise HanzoRuntimeError(f"Invalid code-toolbox-language: {language}")
|
||||
return enum_language
|
||||
|
||||
def start(self, sandbox: Sandbox, timeout: Optional[float] = 60) -> None:
|
||||
@@ -590,7 +590,7 @@ class Daytona:
|
||||
0 means no timeout. Default is 60 seconds.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If timeout is negative; If Sandbox fails to start or times out
|
||||
HanzoRuntimeError: If timeout is negative; If Sandbox fails to start or times out
|
||||
"""
|
||||
sandbox.start(timeout)
|
||||
|
||||
@@ -603,6 +603,6 @@ class Daytona:
|
||||
0 means no timeout. Default is 60 seconds.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If timeout is negative; If Sandbox fails to stop or times out
|
||||
HanzoRuntimeError: If timeout is negative; If Sandbox fails to stop or times out
|
||||
"""
|
||||
sandbox.stop(timeout)
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# DO NOT EDIT THIS FILE MANUALLY.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# DO NOT EDIT THIS FILE MANUALLY.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# DO NOT EDIT THIS FILE MANUALLY.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# DO NOT EDIT THIS FILE MANUALLY.
|
||||
@@ -16,7 +16,7 @@ from pydantic import ConfigDict, PrivateAttr
|
||||
from .._utils.errors import intercept_errors
|
||||
from .._utils.path import prefix_relative_path
|
||||
from .._utils.timeout import with_timeout
|
||||
from ..common.errors import DaytonaError
|
||||
from ..common.errors import HanzoRuntimeError
|
||||
from ..common.protocols import SandboxCodeToolbox
|
||||
from .computer_use import ComputerUse
|
||||
from .filesystem import FileSystem
|
||||
@@ -26,7 +26,7 @@ from .process import Process
|
||||
|
||||
|
||||
class Sandbox(SandboxDto):
|
||||
"""Represents a Daytona Sandbox.
|
||||
"""Represents a HanzoRuntime Sandbox.
|
||||
|
||||
Attributes:
|
||||
fs (FileSystem): File system operations interface.
|
||||
@@ -35,7 +35,7 @@ class Sandbox(SandboxDto):
|
||||
computer_use (ComputerUse): Computer use operations interface for desktop automation.
|
||||
id (str): Unique identifier for the Sandbox.
|
||||
organization_id (str): Organization ID of the Sandbox.
|
||||
snapshot (str): Daytona snapshot used to create the Sandbox.
|
||||
snapshot (str): HanzoRuntime snapshot used to create the Sandbox.
|
||||
user (str): OS user running in the Sandbox.
|
||||
env (Dict[str, str]): Environment variables set in the Sandbox.
|
||||
labels (Dict[str, str]): Custom labels attached to the Sandbox.
|
||||
@@ -208,7 +208,7 @@ class Sandbox(SandboxDto):
|
||||
timeout (Optional[float]): Maximum time to wait in seconds. 0 means no timeout. Default is 60 seconds.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If timeout is negative. If sandbox fails to start or times out.
|
||||
HanzoRuntimeError: If timeout is negative. If sandbox fails to start or times out.
|
||||
|
||||
Example:
|
||||
```python
|
||||
@@ -234,7 +234,7 @@ class Sandbox(SandboxDto):
|
||||
timeout (Optional[float]): Maximum time to wait in seconds. 0 means no timeout. Default is 60 seconds.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If timeout is negative; If sandbox fails to stop or times out
|
||||
HanzoRuntimeError: If timeout is negative; If sandbox fails to stop or times out
|
||||
|
||||
Example:
|
||||
```python
|
||||
@@ -275,7 +275,7 @@ class Sandbox(SandboxDto):
|
||||
timeout (Optional[float]): Maximum time to wait in seconds. 0 means no timeout. Default is 60 seconds.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If timeout is negative; If Sandbox fails to start or times out
|
||||
HanzoRuntimeError: If timeout is negative; If Sandbox fails to start or times out
|
||||
"""
|
||||
while self.state != "started":
|
||||
self.refresh_data()
|
||||
@@ -287,7 +287,7 @@ class Sandbox(SandboxDto):
|
||||
err_msg = (
|
||||
f"Sandbox {self.id} failed to start with state: {self.state}, error reason: {self.error_reason}"
|
||||
)
|
||||
raise DaytonaError(err_msg)
|
||||
raise HanzoRuntimeError(err_msg)
|
||||
|
||||
time.sleep(0.1) # Wait 100ms between checks
|
||||
|
||||
@@ -309,7 +309,7 @@ class Sandbox(SandboxDto):
|
||||
timeout (Optional[float]): Maximum time to wait in seconds. 0 means no timeout. Default is 60 seconds.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If timeout is negative. If Sandbox fails to stop or times out.
|
||||
HanzoRuntimeError: If timeout is negative. If Sandbox fails to stop or times out.
|
||||
"""
|
||||
while self.state != "stopped":
|
||||
try:
|
||||
@@ -319,7 +319,7 @@ class Sandbox(SandboxDto):
|
||||
err_msg = (
|
||||
f"Sandbox {self.id} failed to stop with status: {self.state}, error reason: {self.error_reason}"
|
||||
)
|
||||
raise DaytonaError(err_msg)
|
||||
raise HanzoRuntimeError(err_msg)
|
||||
except Exception as e:
|
||||
# If there's a validation error, continue waiting
|
||||
if "validation error" not in str(e):
|
||||
@@ -340,7 +340,7 @@ class Sandbox(SandboxDto):
|
||||
Set to 0 to disable auto-stop. Defaults to 15.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If interval is negative
|
||||
HanzoRuntimeError: If interval is negative
|
||||
|
||||
Example:
|
||||
```python
|
||||
@@ -351,7 +351,7 @@ class Sandbox(SandboxDto):
|
||||
```
|
||||
"""
|
||||
if not isinstance(interval, int) or interval < 0:
|
||||
raise DaytonaError("Auto-stop interval must be a non-negative integer")
|
||||
raise HanzoRuntimeError("Auto-stop interval must be a non-negative integer")
|
||||
|
||||
self._sandbox_api.set_autostop_interval(self.id, interval)
|
||||
self.auto_stop_interval = interval
|
||||
@@ -367,7 +367,7 @@ class Sandbox(SandboxDto):
|
||||
Set to 0 for the maximum interval. Default is 7 days.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If interval is negative
|
||||
HanzoRuntimeError: If interval is negative
|
||||
|
||||
Example:
|
||||
```python
|
||||
@@ -378,7 +378,7 @@ class Sandbox(SandboxDto):
|
||||
```
|
||||
"""
|
||||
if not isinstance(interval, int) or interval < 0:
|
||||
raise DaytonaError("Auto-archive interval must be a non-negative integer")
|
||||
raise HanzoRuntimeError("Auto-archive interval must be a non-negative integer")
|
||||
self._sandbox_api.set_auto_archive_interval(self.id, interval)
|
||||
self.auto_archive_interval = interval
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# DO NOT EDIT THIS FILE MANUALLY.
|
||||
@@ -18,7 +18,7 @@ from daytona_api_client.models.snapshot_state import SnapshotState
|
||||
from .._utils.errors import intercept_errors
|
||||
from .._utils.stream import process_streaming_response
|
||||
from .._utils.timeout import with_timeout
|
||||
from ..common.errors import DaytonaError
|
||||
from ..common.errors import HanzoRuntimeError
|
||||
from ..common.image import Image
|
||||
from ..common.snapshot import CreateSnapshotParams, Snapshot
|
||||
from .object_storage import ObjectStorage
|
||||
@@ -27,7 +27,7 @@ SNAPSHOTS_FETCH_LIMIT = 200
|
||||
|
||||
|
||||
class SnapshotService:
|
||||
"""Service for managing Daytona Snapshots. Can be used to list, get, create and delete Snapshots."""
|
||||
"""Service for managing HanzoRuntime Snapshots. Can be used to list, get, create and delete Snapshots."""
|
||||
|
||||
def __init__(self, snapshots_api: SnapshotsApi, object_storage_api: ObjectStorageApi):
|
||||
self.__snapshots_api = snapshots_api
|
||||
@@ -42,7 +42,7 @@ class SnapshotService:
|
||||
|
||||
Example:
|
||||
```python
|
||||
daytona = Daytona()
|
||||
hanzo_runtime = HanzoRuntime()
|
||||
snapshots = daytona.snapshot.list()
|
||||
for snapshot in snapshots:
|
||||
print(f"{snapshot.name} ({snapshot.image_name})")
|
||||
@@ -62,7 +62,7 @@ class SnapshotService:
|
||||
|
||||
Example:
|
||||
```python
|
||||
daytona = Daytona()
|
||||
hanzo_runtime = HanzoRuntime()
|
||||
snapshot = daytona.snapshot.get("test-snapshot")
|
||||
daytona.snapshot.delete(snapshot)
|
||||
print("Snapshot deleted")
|
||||
@@ -82,7 +82,7 @@ class SnapshotService:
|
||||
|
||||
Example:
|
||||
```python
|
||||
daytona = Daytona()
|
||||
hanzo_runtime = HanzoRuntime()
|
||||
snapshot = daytona.snapshot.get("test-snapshot-name")
|
||||
print(f"{snapshot.name} ({snapshot.image_name})")
|
||||
```
|
||||
@@ -192,7 +192,7 @@ class SnapshotService:
|
||||
on_logs(f"Created snapshot {created_snapshot.name} ({created_snapshot.state})")
|
||||
|
||||
if created_snapshot.state in (SnapshotState.ERROR, SnapshotState.BUILD_FAILED):
|
||||
raise DaytonaError(
|
||||
raise HanzoRuntimeError(
|
||||
f"Failed to create snapshot {created_snapshot.name}, reason: {created_snapshot.error_reason}"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# DO NOT EDIT THIS FILE MANUALLY.
|
||||
@@ -15,7 +15,7 @@ from ..common.volume import Volume
|
||||
|
||||
|
||||
class VolumeService:
|
||||
"""Service for managing Daytona Volumes. Can be used to list, get, create and delete Volumes."""
|
||||
"""Service for managing HanzoRuntime Volumes. Can be used to list, get, create and delete Volumes."""
|
||||
|
||||
def __init__(self, volumes_api: VolumesApi):
|
||||
self.__volumes_api = volumes_api
|
||||
@@ -28,7 +28,7 @@ class VolumeService:
|
||||
|
||||
Example:
|
||||
```python
|
||||
daytona = Daytona()
|
||||
hanzo_runtime = HanzoRuntime()
|
||||
volumes = daytona.volume.list()
|
||||
for volume in volumes:
|
||||
print(f"{volume.name} ({volume.id})")
|
||||
@@ -48,7 +48,7 @@ class VolumeService:
|
||||
|
||||
Example:
|
||||
```python
|
||||
daytona = Daytona()
|
||||
hanzo_runtime = HanzoRuntime()
|
||||
volume = daytona.volume.get("test-volume-name", create=True)
|
||||
print(f"{volume.name} ({volume.id})")
|
||||
```
|
||||
@@ -71,7 +71,7 @@ class VolumeService:
|
||||
|
||||
Example:
|
||||
```python
|
||||
daytona = Daytona()
|
||||
hanzo_runtime = HanzoRuntime()
|
||||
volume = daytona.volume.create("test-volume")
|
||||
print(f"{volume.name} ({volume.id}); state: {volume.state}")
|
||||
```
|
||||
@@ -86,7 +86,7 @@ class VolumeService:
|
||||
|
||||
Example:
|
||||
```python
|
||||
daytona = Daytona()
|
||||
hanzo_runtime = HanzoRuntime()
|
||||
volume = daytona.volume.get("test-volume")
|
||||
daytona.volume.delete(volume)
|
||||
print("Volume deleted")
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import base64
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import warnings
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
from enum import Enum
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import functools
|
||||
@@ -9,7 +9,7 @@ from typing import Callable, NoReturn, ParamSpec, TypeVar, Union
|
||||
from daytona_api_client.exceptions import OpenApiException
|
||||
from daytona_api_client_async.exceptions import OpenApiException as OpenApiExceptionAsync
|
||||
|
||||
from ..common.errors import DaytonaError
|
||||
from ..common.errors import HanzoRuntimeError
|
||||
|
||||
P = ParamSpec("P")
|
||||
T = TypeVar("T")
|
||||
@@ -29,12 +29,12 @@ def intercept_errors(
|
||||
def process_n_raise_exception(e: Exception) -> NoReturn:
|
||||
if isinstance(e, (OpenApiException, OpenApiExceptionAsync)):
|
||||
msg = _get_open_api_exception_message(e)
|
||||
raise DaytonaError(f"{message_prefix}{msg}") from None
|
||||
raise HanzoRuntimeError(f"{message_prefix}{msg}") from None
|
||||
|
||||
if message_prefix:
|
||||
msg = f"{message_prefix}{str(e)}"
|
||||
raise DaytonaError(msg) # pylint: disable=raise-missing-from
|
||||
raise DaytonaError(str(e)) # pylint: disable=raise-missing-from
|
||||
raise HanzoRuntimeError(msg) # pylint: disable=raise-missing-from
|
||||
raise HanzoRuntimeError(str(e)) # pylint: disable=raise-missing-from
|
||||
|
||||
if inspect.iscoroutinefunction(func):
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import os
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import asyncio
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import asyncio
|
||||
@@ -7,7 +7,7 @@ import functools
|
||||
import inspect
|
||||
from typing import Any, Callable, Optional, ParamSpec, TypeVar
|
||||
|
||||
from .._utils.errors import DaytonaError
|
||||
from .._utils.errors import HanzoRuntimeError
|
||||
|
||||
P = ParamSpec("P")
|
||||
T = TypeVar("T")
|
||||
@@ -47,7 +47,7 @@ def with_timeout(
|
||||
if timeout is None or timeout == 0:
|
||||
return await func(*args, **kwargs)
|
||||
if timeout < 0:
|
||||
raise DaytonaError("Timeout must be a non-negative number or None.")
|
||||
raise HanzoRuntimeError("Timeout must be a non-negative number or None.")
|
||||
|
||||
try:
|
||||
return await asyncio.wait_for(func(*args, **kwargs), timeout)
|
||||
@@ -62,7 +62,7 @@ def with_timeout(
|
||||
if timeout is None or timeout == 0:
|
||||
return func(*args, **kwargs)
|
||||
if timeout < 0:
|
||||
raise DaytonaError("Timeout must be a non-negative number or None.")
|
||||
raise HanzoRuntimeError("Timeout must be a non-negative number or None.")
|
||||
|
||||
with concurrent.futures.ThreadPoolExecutor() as executor:
|
||||
future = executor.submit(func, *args, **kwargs)
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import base64
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import base64
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
from enum import Enum
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
from typing import Optional
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
|
||||
class DaytonaError(Exception):
|
||||
"""Base error for Daytona SDK."""
|
||||
class HanzoRuntimeError(Exception):
|
||||
"""Base error for HanzoRuntime SDK."""
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
|
||||
|
||||
+14
-14
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import warnings
|
||||
@@ -15,7 +15,7 @@ from .volume import VolumeMount
|
||||
|
||||
@dataclass
|
||||
class CodeLanguage(Enum):
|
||||
"""Programming languages supported by Daytona
|
||||
"""Programming languages supported by HanzoRuntime
|
||||
|
||||
**Enum Members**:
|
||||
- `PYTHON` ("python")
|
||||
@@ -36,29 +36,29 @@ class CodeLanguage(Enum):
|
||||
return super().__eq__(other)
|
||||
|
||||
|
||||
class DaytonaConfig(BaseModel):
|
||||
"""Configuration options for initializing the Daytona client.
|
||||
class HanzoRuntimeConfig(BaseModel):
|
||||
"""Configuration options for initializing the HanzoRuntime client.
|
||||
|
||||
Attributes:
|
||||
api_key (Optional[str]): API key for authentication with the Daytona API. If not set, it must be provided
|
||||
via the environment variable `DAYTONA_API_KEY`, or a JWT token must be provided instead.
|
||||
jwt_token (Optional[str]): JWT token for authentication with the Daytona API. If not set, it must be provided
|
||||
via the environment variable `DAYTONA_JWT_TOKEN`, or an API key must be provided instead.
|
||||
api_key (Optional[str]): API key for authentication with the HanzoRuntime API. If not set, it must be provided
|
||||
via the environment variable `HANZO_RUNTIME_API_KEY`, or a JWT token must be provided instead.
|
||||
jwt_token (Optional[str]): JWT token for authentication with the HanzoRuntime API. If not set, it must be provided
|
||||
via the environment variable `HANZO_RUNTIME_JWT_TOKEN`, or an API key must be provided instead.
|
||||
organization_id (Optional[str]): Organization ID used for JWT-based authentication. Required if a JWT token
|
||||
is provided, and must be set either here or in the environment variable `DAYTONA_ORGANIZATION_ID`.
|
||||
api_url (Optional[str]): URL of the Daytona API. Defaults to `'https://app.daytona.io/api'` if not set
|
||||
here or in the environment variable `DAYTONA_API_URL`.
|
||||
is provided, and must be set either here or in the environment variable `HANZO_RUNTIME_ORGANIZATION_ID`.
|
||||
api_url (Optional[str]): URL of the HanzoRuntime API. Defaults to `'https://app.hanzo.ai/api'` if not set
|
||||
here or in the environment variable `HANZO_RUNTIME_API_URL`.
|
||||
server_url (Optional[str]): Deprecated. Use `api_url` instead. This property will be removed
|
||||
in a future version.
|
||||
target (Optional[str]): Target runner location for the Sandbox. Defaults to `'us'` if not set here
|
||||
or in the environment variable `DAYTONA_TARGET`.
|
||||
or in the environment variable `HANZO_RUNTIME_TARGET`.
|
||||
|
||||
Example:
|
||||
```python
|
||||
config = DaytonaConfig(api_key="your-api-key")
|
||||
config = HanzoRuntimeConfig(api_key="your-api-key")
|
||||
```
|
||||
```python
|
||||
config = DaytonaConfig(jwt_token="your-jwt-token", organization_id="your-organization-id")
|
||||
config = HanzoRuntimeConfig(jwt_token="your-jwt-token", organization_id="your-organization-id")
|
||||
```
|
||||
"""
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import glob
|
||||
@@ -13,7 +13,7 @@ import toml
|
||||
from pydantic import BaseModel, PrivateAttr
|
||||
|
||||
from .._sync.object_storage import ObjectStorage
|
||||
from .errors import DaytonaError
|
||||
from .errors import HanzoRuntimeError
|
||||
|
||||
SupportedPythonSeries = Literal["3.9", "3.10", "3.11", "3.12", "3.13"]
|
||||
SUPPORTED_PYTHON_SERIES = list(get_args(SupportedPythonSeries))
|
||||
@@ -33,7 +33,7 @@ class Context(BaseModel):
|
||||
|
||||
|
||||
class Image(BaseModel):
|
||||
"""Represents an image definition for a Daytona sandbox.
|
||||
"""Represents an image definition for a HanzoRuntime sandbox.
|
||||
Do not construct this class directly. Instead use one of its static factory methods,
|
||||
such as `Image.base()`, `Image.debian_slim()`, or `Image.from_dockerfile()`.
|
||||
"""
|
||||
@@ -110,7 +110,7 @@ class Image(BaseModel):
|
||||
"""
|
||||
requirements_txt = os.path.expanduser(requirements_txt)
|
||||
if not Path(requirements_txt).exists():
|
||||
raise DaytonaError(f"Requirements file {requirements_txt} does not exist")
|
||||
raise HanzoRuntimeError(f"Requirements file {requirements_txt} does not exist")
|
||||
|
||||
extra_args = self.__format_pip_install_args(find_links, index_url, extra_index_urls, pre, extra_options)
|
||||
|
||||
@@ -161,7 +161,7 @@ class Image(BaseModel):
|
||||
"See https://packaging.python.org/en/latest/guides/writing-pyproject-toml "
|
||||
"for further file format guidelines."
|
||||
)
|
||||
raise DaytonaError(msg)
|
||||
raise HanzoRuntimeError(msg)
|
||||
|
||||
dependencies.extend(toml_data["project"]["dependencies"])
|
||||
if optional_dependencies:
|
||||
@@ -271,7 +271,7 @@ class Image(BaseModel):
|
||||
"""
|
||||
non_str_keys = [key for key, val in env_vars.items() if not isinstance(val, str)]
|
||||
if non_str_keys:
|
||||
raise DaytonaError(f"Image ENV variables must be strings. Invalid keys: {non_str_keys}")
|
||||
raise HanzoRuntimeError(f"Image ENV variables must be strings. Invalid keys: {non_str_keys}")
|
||||
|
||||
for key, val in env_vars.items():
|
||||
self._dockerfile += f"ENV {key}={shlex.quote(val)}\n"
|
||||
@@ -310,7 +310,7 @@ class Image(BaseModel):
|
||||
```
|
||||
"""
|
||||
if not isinstance(entrypoint_commands, list) or not all(isinstance(x, str) for x in entrypoint_commands):
|
||||
raise DaytonaError("entrypoint_commands must be a list of strings.")
|
||||
raise HanzoRuntimeError("entrypoint_commands must be a list of strings.")
|
||||
|
||||
args_str = self.__flatten_str_args("entrypoint", "entrypoint_commands", entrypoint_commands)
|
||||
args_str = '"' + '", "'.join(args_str) + '"' if args_str else ""
|
||||
@@ -333,7 +333,7 @@ class Image(BaseModel):
|
||||
```
|
||||
"""
|
||||
if not isinstance(cmd, list) or not all(isinstance(x, str) for x in cmd):
|
||||
raise DaytonaError("Image CMD must be a list of strings.")
|
||||
raise HanzoRuntimeError("Image CMD must be a list of strings.")
|
||||
cmd_str = self.__flatten_str_args("cmd", "cmd", cmd)
|
||||
cmd_str = '"' + '", "'.join(cmd_str) + '"' if cmd_str else ""
|
||||
self._dockerfile += f"CMD [{cmd_str}]\n"
|
||||
@@ -361,7 +361,7 @@ class Image(BaseModel):
|
||||
if context_dir:
|
||||
context_dir = os.path.expanduser(context_dir)
|
||||
if not os.path.isdir(context_dir):
|
||||
raise DaytonaError(f"Context directory {context_dir} does not exist")
|
||||
raise HanzoRuntimeError(f"Context directory {context_dir} does not exist")
|
||||
|
||||
for context_path, original_path in Image.__extract_copy_sources(
|
||||
"\n".join(dockerfile_commands), context_dir or ""
|
||||
@@ -570,7 +570,7 @@ class Image(BaseModel):
|
||||
elif is_str_list(x):
|
||||
ret.extend(x)
|
||||
else:
|
||||
raise DaytonaError(f"{function_name}: {arg_name} must only contain strings")
|
||||
raise HanzoRuntimeError(f"{function_name}: {arg_name} must only contain strings")
|
||||
return ret
|
||||
|
||||
@staticmethod
|
||||
@@ -621,26 +621,26 @@ class Image(BaseModel):
|
||||
str: The processed Python version.
|
||||
|
||||
Raises:
|
||||
DaytonaError: If the Python version is invalid.
|
||||
HanzoRuntimeError: If the Python version is invalid.
|
||||
"""
|
||||
if python_version is None:
|
||||
# If Python version is unspecified, match the local version, up to the minor component
|
||||
python_version = series_version = f"{sys.version_info.major}.{sys.version_info.minor}"
|
||||
elif not re.match(r"^3(?:\.\d{1,2}){1,2}(rc\d*)?$", python_version):
|
||||
raise DaytonaError(f"Invalid Python version: {python_version!r}")
|
||||
raise HanzoRuntimeError(f"Invalid Python version: {python_version!r}")
|
||||
else:
|
||||
components = python_version.split(".")
|
||||
if len(components) == 3 and not allow_micro_granularity:
|
||||
raise DaytonaError(
|
||||
raise HanzoRuntimeError(
|
||||
"Python version must be specified as 'major.minor' for this interface;"
|
||||
f" micro-level specification ({python_version!r}) is not valid."
|
||||
)
|
||||
series_version = f"{components[0]}.{components[1]}"
|
||||
|
||||
if series_version not in SUPPORTED_PYTHON_SERIES:
|
||||
raise DaytonaError(
|
||||
raise HanzoRuntimeError(
|
||||
f"Unsupported Python version: {python_version!r}."
|
||||
f" Daytona supports the following series: {SUPPORTED_PYTHON_SERIES!r}."
|
||||
f" HanzoRuntime supports the following series: {SUPPORTED_PYTHON_SERIES!r}."
|
||||
)
|
||||
|
||||
# If the python version is specified as a micro version, return it as is
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
from enum import Enum
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import warnings
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
from typing import Protocol
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
from typing import List, Optional, Union
|
||||
@@ -7,12 +7,12 @@ from daytona_api_client import BuildInfo, SnapshotDto
|
||||
from daytona_api_client_async import BuildInfo as AsyncBuildInfo
|
||||
from pydantic import BaseModel
|
||||
|
||||
from .daytona import Resources
|
||||
from .hanzo_runtime import Resources
|
||||
from .image import Image
|
||||
|
||||
|
||||
class Snapshot(SnapshotDto):
|
||||
"""Represents a Daytona Snapshot which is a pre-configured sandbox.
|
||||
"""Represents a HanzoRuntime Snapshot which is a pre-configured sandbox.
|
||||
|
||||
Attributes:
|
||||
id (StrictStr): Unique identifier for the Snapshot.
|
||||
@@ -48,7 +48,7 @@ class CreateSnapshotParams(BaseModel):
|
||||
name (Optional[str]): Name of the snapshot.
|
||||
image (Union[str, Image]): Image of the snapshot. If a string is provided,
|
||||
it should be available on some registry. If an Image instance is provided,
|
||||
it will be used to create a new image in Daytona.
|
||||
it will be used to create a new image in HanzoRuntime.
|
||||
resources (Optional[Resources]): Resources of the snapshot.
|
||||
entrypoint (Optional[List[str]]): Entrypoint of the snapshot.
|
||||
"""
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2025 Daytona Platforms Inc.
|
||||
# Copyright 2025 Hanzo Industries Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
from daytona_api_client import SandboxVolume as ApiVolumeMount
|
||||
@@ -11,7 +11,7 @@ class VolumeMount(ApiVolumeMount, AsyncApiVolumeMount):
|
||||
|
||||
|
||||
class Volume(VolumeDto):
|
||||
"""Represents a Daytona Volume which is a shared storage volume for Sandboxes.
|
||||
"""Represents a HanzoRuntime Volume which is a shared storage volume for Sandboxes.
|
||||
|
||||
Attributes:
|
||||
id (StrictStr): Unique identifier for the Volume.
|
||||
|
||||
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hanzo/runtime",
|
||||
"version": "0.0.0-dev",
|
||||
"version": "0.0.1-dev",
|
||||
"description": "TypeScript SDK for Hanzo Runtime",
|
||||
"main": "./src/index.js",
|
||||
"types": "./src/index.d.ts",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* Copyright 2025 Hanzo Industries Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
@@ -188,7 +188,7 @@ export class Keyboard {
|
||||
*
|
||||
* @param {string} text - The text to type
|
||||
* @param {number} [delay=0] - Delay between characters in milliseconds
|
||||
* @throws {DaytonaError} If the type operation fails
|
||||
* @throws {HanzoRuntimeError} If the type operation fails
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
@@ -218,7 +218,7 @@ export class Keyboard {
|
||||
*
|
||||
* @param {string} key - The key to press (e.g., 'Enter', 'Escape', 'Tab', 'a', 'A')
|
||||
* @param {string[]} [modifiers=[]] - Modifier keys ('ctrl', 'alt', 'meta', 'shift')
|
||||
* @throws {DaytonaError} If the press operation fails
|
||||
* @throws {HanzoRuntimeError} If the press operation fails
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
@@ -256,7 +256,7 @@ export class Keyboard {
|
||||
* Presses a hotkey combination
|
||||
*
|
||||
* @param {string} keys - The hotkey combination (e.g., 'ctrl+c', 'alt+tab', 'cmd+shift+t')
|
||||
* @throws {DaytonaError} If the hotkey operation fails
|
||||
* @throws {HanzoRuntimeError} If the hotkey operation fails
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* Copyright 2025 Hanzo Industries Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* Copyright 2025 Hanzo Industries Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* Copyright 2025 Hanzo Industries Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
@@ -18,7 +18,7 @@ import axios, { AxiosError } from 'axios'
|
||||
import * as dotenv from 'dotenv'
|
||||
import { SandboxPythonCodeToolbox } from './code-toolbox/SandboxPythonCodeToolbox'
|
||||
import { SandboxTsCodeToolbox } from './code-toolbox/SandboxTsCodeToolbox'
|
||||
import { DaytonaError, DaytonaNotFoundError } from './errors/DaytonaError'
|
||||
import { HanzoRuntimeError, HanzoRuntimeNotFoundError } from './errors/HanzoRuntimeError'
|
||||
import { Image } from './Image'
|
||||
import { Sandbox } from './Sandbox'
|
||||
import { SnapshotService } from './Snapshot'
|
||||
@@ -40,34 +40,34 @@ export interface VolumeMount extends SandboxVolume {
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration options for initializing the Daytona client.
|
||||
* Configuration options for initializing the HanzoRuntime client.
|
||||
*
|
||||
* @interface
|
||||
* @property {string} apiKey - API key for authentication with the Daytona API
|
||||
* @property {string} jwtToken - JWT token for authentication with the Daytona API. If not set, it must be provided
|
||||
* via the environment variable `DAYTONA_JWT_TOKEN`, or an API key must be provided instead.
|
||||
* @property {string} apiKey - API key for authentication with the HanzoRuntime API
|
||||
* @property {string} jwtToken - JWT token for authentication with the HanzoRuntime API. If not set, it must be provided
|
||||
* via the environment variable `HANZO_RUNTIME_JWT_TOKEN`, or an API key must be provided instead.
|
||||
* @property {string} organizationId - Organization ID used for JWT-based authentication. Required if a JWT token
|
||||
* is provided, and must be set either here or in the environment variable `DAYTONA_ORGANIZATION_ID`.
|
||||
* @property {string} apiUrl - URL of the Daytona API. Defaults to 'https://app.daytona.io/api'
|
||||
* if not set here and not set in environment variable DAYTONA_API_URL.
|
||||
* is provided, and must be set either here or in the environment variable `HANZO_RUNTIME_ORGANIZATION_ID`.
|
||||
* @property {string} apiUrl - URL of the HanzoRuntime API. Defaults to 'https://app.hanzo.ai/api'
|
||||
* if not set here and not set in environment variable HANZO_RUNTIME_API_URL.
|
||||
* @property {string} target - Target location for Sandboxes
|
||||
*
|
||||
* @example
|
||||
* const config: DaytonaConfig = {
|
||||
* const config: HanzoRuntimeConfig = {
|
||||
* apiKey: "your-api-key",
|
||||
* apiUrl: "https://your-api.com",
|
||||
* target: "us"
|
||||
* };
|
||||
* const daytona = new Daytona(config);
|
||||
* const hanzo_runtime = new HanzoRuntime(config);
|
||||
*/
|
||||
export interface DaytonaConfig {
|
||||
/** API key for authentication with the Daytona API */
|
||||
export interface HanzoRuntimeConfig {
|
||||
/** API key for authentication with the HanzoRuntime API */
|
||||
apiKey?: string
|
||||
/** JWT token for authentication with the Daytona API */
|
||||
/** JWT token for authentication with the HanzoRuntime API */
|
||||
jwtToken?: string
|
||||
/** Organization ID for authentication with the Daytona API */
|
||||
/** Organization ID for authentication with the HanzoRuntime API */
|
||||
organizationId?: string
|
||||
/** URL of the Daytona API.
|
||||
/** URL of the HanzoRuntime API.
|
||||
*/
|
||||
apiUrl?: string
|
||||
/**
|
||||
@@ -176,31 +176,31 @@ export type SandboxFilter = {
|
||||
}
|
||||
|
||||
/**
|
||||
* Main class for interacting with the Daytona API.
|
||||
* Provides methods for creating, managing, and interacting with Daytona Sandboxes.
|
||||
* Main class for interacting with the HanzoRuntime API.
|
||||
* Provides methods for creating, managing, and interacting with HanzoRuntime Sandboxes.
|
||||
* Can be initialized either with explicit configuration or using environment variables.
|
||||
*
|
||||
* @property {VolumeService} volume - Service for managing Daytona Volumes
|
||||
* @property {SnapshotService} snapshot - Service for managing Daytona Snapshots
|
||||
* @property {VolumeService} volume - Service for managing HanzoRuntime Volumes
|
||||
* @property {SnapshotService} snapshot - Service for managing HanzoRuntime Snapshots
|
||||
*
|
||||
* @example
|
||||
* // Using environment variables
|
||||
* // Uses DAYTONA_API_KEY, DAYTONA_API_URL, DAYTONA_TARGET
|
||||
* const daytona = new Daytona();
|
||||
* const sandbox = await daytona.create();
|
||||
* // Uses HANZO_RUNTIME_API_KEY, HANZO_RUNTIME_API_URL, HANZO_RUNTIME_TARGET
|
||||
* const hanzo_runtime = new HanzoRuntime();
|
||||
* const sandbox = await hanzo_runtime.create();
|
||||
*
|
||||
* @example
|
||||
* // Using explicit configuration
|
||||
* const config: DaytonaConfig = {
|
||||
* const config: HanzoRuntimeConfig = {
|
||||
* apiKey: "your-api-key",
|
||||
* apiUrl: "https://your-api.com",
|
||||
* target: "us"
|
||||
* };
|
||||
* const daytona = new Daytona(config);
|
||||
* const hanzo_runtime = new HanzoRuntime(config);
|
||||
*
|
||||
* @class
|
||||
*/
|
||||
export class Daytona {
|
||||
export class HanzoRuntime {
|
||||
private readonly sandboxApi: SandboxApi
|
||||
private readonly toolboxApi: ToolboxApi
|
||||
private readonly objectStorageApi: ObjectStorageApi
|
||||
@@ -213,12 +213,12 @@ export class Daytona {
|
||||
public readonly snapshot: SnapshotService
|
||||
|
||||
/**
|
||||
* Creates a new Daytona client instance.
|
||||
* Creates a new HanzoRuntime client instance.
|
||||
*
|
||||
* @param {DaytonaConfig} [config] - Configuration options
|
||||
* @throws {DaytonaError} - `DaytonaError` - When API key is missing
|
||||
* @param {HanzoRuntimeConfig} [config] - Configuration options
|
||||
* @throws {HanzoRuntimeError} - `HanzoRuntimeError` - When API key is missing
|
||||
*/
|
||||
constructor(config?: DaytonaConfig) {
|
||||
constructor(config?: HanzoRuntimeConfig) {
|
||||
let apiUrl: string | undefined
|
||||
if (config) {
|
||||
this.apiKey = !config?.apiKey && config?.jwtToken ? undefined : config?.apiKey
|
||||
@@ -234,16 +234,16 @@ export class Daytona {
|
||||
) {
|
||||
dotenv.config()
|
||||
dotenv.config({ path: '.env.local', override: true })
|
||||
this.apiKey = this.apiKey || (this.jwtToken ? undefined : process?.env['DAYTONA_API_KEY'])
|
||||
this.jwtToken = this.jwtToken || process?.env['DAYTONA_JWT_TOKEN']
|
||||
this.organizationId = this.organizationId || process?.env['DAYTONA_ORGANIZATION_ID']
|
||||
this.apiKey = this.apiKey || (this.jwtToken ? undefined : process?.env['HANZO_RUNTIME_API_KEY'])
|
||||
this.jwtToken = this.jwtToken || process?.env['HANZO_RUNTIME_JWT_TOKEN']
|
||||
this.organizationId = this.organizationId || process?.env['HANZO_RUNTIME_ORGANIZATION_ID']
|
||||
apiUrl =
|
||||
apiUrl || process?.env['DAYTONA_API_URL'] || process?.env['DAYTONA_SERVER_URL'] || 'https://app.daytona.io/api'
|
||||
this.target = this.target || process?.env['DAYTONA_TARGET']
|
||||
apiUrl || process?.env['HANZO_RUNTIME_API_URL'] || process?.env['HANZO_RUNTIME_SERVER_URL'] || 'https://app.hanzo.ai/api'
|
||||
this.target = this.target || process?.env['HANZO_RUNTIME_TARGET']
|
||||
|
||||
if (process?.env['DAYTONA_SERVER_URL'] && !process?.env['DAYTONA_API_URL']) {
|
||||
if (process?.env['HANZO_RUNTIME_SERVER_URL'] && !process?.env['HANZO_RUNTIME_API_URL']) {
|
||||
console.warn(
|
||||
'[Deprecation Warning] Environment variable `DAYTONA_SERVER_URL` is deprecated and will be removed in future versions. Use `DAYTONA_API_URL` instead.',
|
||||
'[Deprecation Warning] Environment variable `HANZO_RUNTIME_SERVER_URL` is deprecated and will be removed in future versions. Use `HANZO_RUNTIME_API_URL` instead.',
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -253,9 +253,9 @@ export class Daytona {
|
||||
const orgHeader: Record<string, string> = {}
|
||||
if (!this.apiKey) {
|
||||
if (!this.organizationId) {
|
||||
throw new DaytonaError('Organization ID is required when using JWT token')
|
||||
throw new HanzoRuntimeError('Organization ID is required when using JWT token')
|
||||
}
|
||||
orgHeader['X-Daytona-Organization-ID'] = this.organizationId
|
||||
orgHeader['X-HanzoRuntime-Organization-ID'] = this.organizationId
|
||||
}
|
||||
|
||||
const configuration = new Configuration({
|
||||
@@ -263,8 +263,8 @@ export class Daytona {
|
||||
baseOptions: {
|
||||
headers: {
|
||||
Authorization: `Bearer ${this.apiKey || this.jwtToken}`,
|
||||
'X-Daytona-Source': 'typescript-sdk',
|
||||
'X-Daytona-SDK-Version': packageJson.version,
|
||||
'X-HanzoRuntime-Source': 'typescript-sdk',
|
||||
'X-HanzoRuntime-SDK-Version': packageJson.version,
|
||||
...orgHeader,
|
||||
},
|
||||
},
|
||||
@@ -294,9 +294,9 @@ export class Daytona {
|
||||
|
||||
switch (error.response?.data?.statusCode) {
|
||||
case 404:
|
||||
throw new DaytonaNotFoundError(errorMessage)
|
||||
throw new HanzoRuntimeNotFoundError(errorMessage)
|
||||
default:
|
||||
throw new DaytonaError(errorMessage)
|
||||
throw new HanzoRuntimeError(errorMessage)
|
||||
}
|
||||
},
|
||||
)
|
||||
@@ -318,7 +318,7 @@ export class Daytona {
|
||||
* @returns {Promise<Sandbox>} The created Sandbox instance
|
||||
*
|
||||
* @example
|
||||
* const sandbox = await daytona.create();
|
||||
* const sandbox = await hanzo_runtime.create();
|
||||
*
|
||||
* @example
|
||||
* // Create a custom sandbox
|
||||
@@ -333,12 +333,12 @@ export class Daytona {
|
||||
* autoArchiveInterval: 60,
|
||||
* autoDeleteInterval: 120
|
||||
* };
|
||||
* const sandbox = await daytona.create(params, { timeout: 100 });
|
||||
* const sandbox = await hanzo_runtime.create(params, { timeout: 100 });
|
||||
*/
|
||||
public async create(params?: CreateSandboxFromSnapshotParams, options?: { timeout?: number }): Promise<Sandbox>
|
||||
/**
|
||||
* Creates Sandboxes from specified image available on some registry or declarative Daytona Image. You can specify various parameters,
|
||||
* including resources, language, image, environment variables, and volumes. Daytona creates snapshot from
|
||||
* Creates Sandboxes from specified image available on some registry or declarative HanzoRuntime Image. You can specify various parameters,
|
||||
* including resources, language, image, environment variables, and volumes. HanzoRuntime creates snapshot from
|
||||
* provided image and uses it to create Sandbox.
|
||||
*
|
||||
* @param {CreateSandboxFromImageParams} [params] - Parameters for Sandbox creation from image
|
||||
@@ -348,7 +348,7 @@ export class Daytona {
|
||||
* @returns {Promise<Sandbox>} The created Sandbox instance
|
||||
*
|
||||
* @example
|
||||
* const sandbox = await daytona.create({ image: 'debian:12.9' }, { timeout: 90, onSnapshotCreateLogs: console.log });
|
||||
* const sandbox = await hanzo_runtime.create({ image: 'debian:12.9' }, { timeout: 90, onSnapshotCreateLogs: console.log });
|
||||
*
|
||||
* @example
|
||||
* // Create a custom sandbox
|
||||
@@ -368,7 +368,7 @@ export class Daytona {
|
||||
* autoArchiveInterval: 60,
|
||||
* autoDeleteInterval: 120
|
||||
* };
|
||||
* const sandbox = await daytona.create(params, { timeout: 100, onSnapshotCreateLogs: console.log });
|
||||
* const sandbox = await hanzo_runtime.create(params, { timeout: 100, onSnapshotCreateLogs: console.log });
|
||||
*/
|
||||
public async create(
|
||||
params?: CreateSandboxFromImageParams,
|
||||
@@ -395,21 +395,21 @@ export class Daytona {
|
||||
}
|
||||
|
||||
if (options.timeout < 0) {
|
||||
throw new DaytonaError('Timeout must be a non-negative number')
|
||||
throw new HanzoRuntimeError('Timeout must be a non-negative number')
|
||||
}
|
||||
|
||||
if (
|
||||
params.autoStopInterval !== undefined &&
|
||||
(!Number.isInteger(params.autoStopInterval) || params.autoStopInterval < 0)
|
||||
) {
|
||||
throw new DaytonaError('autoStopInterval must be a non-negative integer')
|
||||
throw new HanzoRuntimeError('autoStopInterval must be a non-negative integer')
|
||||
}
|
||||
|
||||
if (
|
||||
params.autoArchiveInterval !== undefined &&
|
||||
(!Number.isInteger(params.autoArchiveInterval) || params.autoArchiveInterval < 0)
|
||||
) {
|
||||
throw new DaytonaError('autoArchiveInterval must be a non-negative integer')
|
||||
throw new HanzoRuntimeError('autoArchiveInterval must be a non-negative integer')
|
||||
}
|
||||
|
||||
const codeToolbox = this.getCodeToolbox(params.language as CodeLanguage)
|
||||
@@ -499,9 +499,9 @@ export class Daytona {
|
||||
|
||||
return sandbox
|
||||
} catch (error) {
|
||||
if (error instanceof DaytonaError && error.message.includes('Operation timed out')) {
|
||||
if (error instanceof HanzoRuntimeError && error.message.includes('Operation timed out')) {
|
||||
const errMsg = `Failed to create and start sandbox within ${options.timeout} seconds. Operation timed out.`
|
||||
throw new DaytonaError(errMsg)
|
||||
throw new HanzoRuntimeError(errMsg)
|
||||
}
|
||||
throw error
|
||||
}
|
||||
@@ -514,7 +514,7 @@ export class Daytona {
|
||||
* @returns {Promise<Sandbox>} The Sandbox
|
||||
*
|
||||
* @example
|
||||
* const sandbox = await daytona.get('my-sandbox-id');
|
||||
* const sandbox = await hanzo_runtime.get('my-sandbox-id');
|
||||
* console.log(`Sandbox state: ${sandbox.state}`);
|
||||
*/
|
||||
public async get(sandboxId: string): Promise<Sandbox> {
|
||||
@@ -533,7 +533,7 @@ export class Daytona {
|
||||
* @returns {Promise<Sandbox>} First Sandbox that matches the ID or labels.
|
||||
*
|
||||
* @example
|
||||
* const sandbox = await daytona.findOne({ labels: { 'my-label': 'my-value' } });
|
||||
* const sandbox = await hanzo_runtime.findOne({ labels: { 'my-label': 'my-value' } });
|
||||
* console.log(`Sandbox ID: ${sandbox.id}, State: ${sandbox.state}`);
|
||||
*/
|
||||
public async findOne(filter: SandboxFilter): Promise<Sandbox> {
|
||||
@@ -544,7 +544,7 @@ export class Daytona {
|
||||
const sandboxes = await this.list(filter.labels)
|
||||
if (sandboxes.length === 0) {
|
||||
const errMsg = `No sandbox found with labels ${JSON.stringify(filter.labels)}`
|
||||
throw new DaytonaError(errMsg)
|
||||
throw new HanzoRuntimeError(errMsg)
|
||||
}
|
||||
return sandboxes[0]
|
||||
}
|
||||
@@ -556,7 +556,7 @@ export class Daytona {
|
||||
* @returns {Promise<Sandbox[]>} Array of Sandboxes that match the labels.
|
||||
*
|
||||
* @example
|
||||
* const sandboxes = await daytona.list({ 'my-label': 'my-value' });
|
||||
* const sandboxes = await hanzo_runtime.list({ 'my-label': 'my-value' });
|
||||
* for (const sandbox of sandboxes) {
|
||||
* console.log(`${sandbox.id}: ${sandbox.state}`);
|
||||
* }
|
||||
@@ -582,9 +582,9 @@ export class Daytona {
|
||||
* @returns {Promise<void>}
|
||||
*
|
||||
* @example
|
||||
* const sandbox = await daytona.get('my-sandbox-id');
|
||||
* const sandbox = await hanzo_runtime.get('my-sandbox-id');
|
||||
* // Wait up to 60 seconds for the sandbox to start
|
||||
* await daytona.start(sandbox, 60);
|
||||
* await hanzo_runtime.start(sandbox, 60);
|
||||
*/
|
||||
public async start(sandbox: Sandbox, timeout?: number) {
|
||||
await sandbox.start(timeout)
|
||||
@@ -597,8 +597,8 @@ export class Daytona {
|
||||
* @returns {Promise<void>}
|
||||
*
|
||||
* @example
|
||||
* const sandbox = await daytona.get('my-sandbox-id');
|
||||
* await daytona.stop(sandbox);
|
||||
* const sandbox = await hanzo_runtime.get('my-sandbox-id');
|
||||
* await hanzo_runtime.stop(sandbox);
|
||||
*/
|
||||
public async stop(sandbox: Sandbox) {
|
||||
await sandbox.stop()
|
||||
@@ -612,8 +612,8 @@ export class Daytona {
|
||||
* @returns {Promise<void>}
|
||||
*
|
||||
* @example
|
||||
* const sandbox = await daytona.get('my-sandbox-id');
|
||||
* await daytona.delete(sandbox);
|
||||
* const sandbox = await hanzo_runtime.get('my-sandbox-id');
|
||||
* await hanzo_runtime.delete(sandbox);
|
||||
*/
|
||||
public async delete(sandbox: Sandbox, timeout = 60) {
|
||||
await sandbox.delete(timeout)
|
||||
@@ -625,7 +625,7 @@ export class Daytona {
|
||||
* @private
|
||||
* @param {CodeLanguage} [language] - Programming language for the toolbox
|
||||
* @returns {SandboxCodeToolbox} The appropriate code toolbox instance
|
||||
* @throws {DaytonaError} - `DaytonaError` - When an unsupported language is specified
|
||||
* @throws {HanzoRuntimeError} - `HanzoRuntimeError` - When an unsupported language is specified
|
||||
*/
|
||||
private getCodeToolbox(language?: CodeLanguage) {
|
||||
switch (language) {
|
||||
@@ -637,7 +637,7 @@ export class Daytona {
|
||||
return new SandboxPythonCodeToolbox()
|
||||
default: {
|
||||
const errMsg = `Unsupported language: ${language}, supported languages: ${Object.values(CodeLanguage).join(', ')}`
|
||||
throw new DaytonaError(errMsg)
|
||||
throw new HanzoRuntimeError(errMsg)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* Copyright 2025 Hanzo Industries Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,7 @@ import * as fg from 'fast-glob'
|
||||
import * as _path from 'path'
|
||||
import { quote, parse as parseShellQuote } from 'shell-quote'
|
||||
import expandTilde from 'expand-tilde'
|
||||
import { DaytonaError } from './errors/DaytonaError'
|
||||
import { HanzoRuntimeError } from './errors/HanzoRuntimeError'
|
||||
import { parse as parseToml } from '@iarna/toml'
|
||||
|
||||
const SUPPORTED_PYTHON_SERIES = ['3.9', '3.10', '3.11', '3.12', '3.13'] as const
|
||||
@@ -58,7 +58,7 @@ export interface PyprojectOptions extends PipInstallOptions {
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents an image definition for a Daytona sandbox.
|
||||
* Represents an image definition for a HanzoRuntime sandbox.
|
||||
* Do not construct this class directly. Instead use one of its static factory methods,
|
||||
* such as `Image.base()`, `Image.debianSlim()` or `Image.fromDockerfile()`.
|
||||
*
|
||||
@@ -148,7 +148,7 @@ export class Image {
|
||||
'No [project.dependencies] section in pyproject.toml file. ' +
|
||||
'See https://packaging.python.org/en/latest/guides/writing-pyproject-toml ' +
|
||||
'for further file format guidelines.'
|
||||
throw new DaytonaError(msg)
|
||||
throw new HanzoRuntimeError(msg)
|
||||
}
|
||||
|
||||
dependencies.push(...tomlData.project.dependencies)
|
||||
@@ -521,7 +521,7 @@ export class Image {
|
||||
if (!SUPPORTED_PYTHON_SERIES.includes(pythonVersion)) {
|
||||
throw new Error(
|
||||
`Unsupported Python version: ${pythonVersion}. ` +
|
||||
`Daytona supports the following series: ${SUPPORTED_PYTHON_SERIES.join(', ')}`,
|
||||
`HanzoRuntime supports the following series: ${SUPPORTED_PYTHON_SERIES.join(', ')}`,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* Copyright 2025 Hanzo Industries Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* Copyright 2025 Hanzo Industries Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
@@ -10,7 +10,7 @@ import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
import * as tar from 'tar'
|
||||
import { PassThrough } from 'stream'
|
||||
import { DaytonaError } from './errors/DaytonaError'
|
||||
import { HanzoRuntimeError } from './errors/HanzoRuntimeError'
|
||||
|
||||
/**
|
||||
* Configuration for the ObjectStorage class.
|
||||
@@ -65,7 +65,7 @@ export class ObjectStorage {
|
||||
async upload(path: string, organizationId: string, archiveBasePath: string): Promise<string> {
|
||||
if (!fs.existsSync(path)) {
|
||||
const errMsg = `Path does not exist: ${path}`
|
||||
throw new DaytonaError(errMsg)
|
||||
throw new HanzoRuntimeError(errMsg)
|
||||
}
|
||||
|
||||
// Compute hash for the path
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* Copyright 2025 Hanzo Industries Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* Copyright 2025 Hanzo Industries Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
@@ -17,7 +17,7 @@ import { FileSystem } from './FileSystem'
|
||||
import { Git } from './Git'
|
||||
import { CodeRunParams, Process } from './Process'
|
||||
import { LspLanguageId, LspServer } from './LspServer'
|
||||
import { DaytonaError } from './errors/DaytonaError'
|
||||
import { HanzoRuntimeError } from './errors/HanzoRuntimeError'
|
||||
import { prefixRelativePath } from './utils/Path'
|
||||
import { ComputerUse } from './ComputerUse'
|
||||
|
||||
@@ -31,7 +31,7 @@ export interface SandboxCodeToolbox {
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a Daytona Sandbox.
|
||||
* Represents a HanzoRuntime Sandbox.
|
||||
*
|
||||
* @property {FileSystem} fs - File system operations interface
|
||||
* @property {Git} git - Git operations interface
|
||||
@@ -39,7 +39,7 @@ export interface SandboxCodeToolbox {
|
||||
* @property {ComputerUse} computerUse - Computer use operations interface for desktop automation
|
||||
* @property {string} id - Unique identifier for the Sandbox
|
||||
* @property {string} organizationId - Organization ID of the Sandbox
|
||||
* @property {string} [snapshot] - Daytona snapshot used to create the Sandbox
|
||||
* @property {string} [snapshot] - HanzoRuntime snapshot used to create the Sandbox
|
||||
* @property {string} user - OS user running in the Sandbox
|
||||
* @property {Record<string, string>} env - Environment variables set in the Sandbox
|
||||
* @property {Record<string, string>} labels - Custom labels attached to the Sandbox
|
||||
@@ -185,16 +185,16 @@ export class Sandbox implements SandboxDto {
|
||||
* @param {number} [timeout] - Maximum time to wait in seconds. 0 means no timeout.
|
||||
* Defaults to 60-second timeout.
|
||||
* @returns {Promise<void>}
|
||||
* @throws {DaytonaError} - `DaytonaError` - If Sandbox fails to start or times out
|
||||
* @throws {HanzoRuntimeError} - `HanzoRuntimeError` - If Sandbox fails to start or times out
|
||||
*
|
||||
* @example
|
||||
* const sandbox = await daytona.getCurrentSandbox('my-sandbox');
|
||||
* const sandbox = await hanzo_runtime.getCurrentSandbox('my-sandbox');
|
||||
* await sandbox.start(40); // Wait up to 40 seconds
|
||||
* console.log('Sandbox started successfully');
|
||||
*/
|
||||
public async start(timeout = 60): Promise<void> {
|
||||
if (timeout < 0) {
|
||||
throw new DaytonaError('Timeout must be a non-negative number')
|
||||
throw new HanzoRuntimeError('Timeout must be a non-negative number')
|
||||
}
|
||||
const startTime = Date.now()
|
||||
const response = await this.sandboxApi.startSandbox(this.id, undefined, { timeout: timeout * 1000 })
|
||||
@@ -213,13 +213,13 @@ export class Sandbox implements SandboxDto {
|
||||
* @returns {Promise<void>}
|
||||
*
|
||||
* @example
|
||||
* const sandbox = await daytona.getCurrentSandbox('my-sandbox');
|
||||
* const sandbox = await hanzo_runtime.getCurrentSandbox('my-sandbox');
|
||||
* await sandbox.stop();
|
||||
* console.log('Sandbox stopped successfully');
|
||||
*/
|
||||
public async stop(timeout = 60): Promise<void> {
|
||||
if (timeout < 0) {
|
||||
throw new DaytonaError('Timeout must be a non-negative number')
|
||||
throw new HanzoRuntimeError('Timeout must be a non-negative number')
|
||||
}
|
||||
const startTime = Date.now()
|
||||
await this.sandboxApi.stopSandbox(this.id, undefined, { timeout: timeout * 1000 })
|
||||
@@ -246,11 +246,11 @@ export class Sandbox implements SandboxDto {
|
||||
* @param {number} [timeout] - Maximum time to wait in seconds. 0 means no timeout.
|
||||
* Defaults to 60 seconds.
|
||||
* @returns {Promise<void>}
|
||||
* @throws {DaytonaError} - `DaytonaError` - If the sandbox ends up in an error state or fails to start within the timeout period.
|
||||
* @throws {HanzoRuntimeError} - `HanzoRuntimeError` - If the sandbox ends up in an error state or fails to start within the timeout period.
|
||||
*/
|
||||
public async waitUntilStarted(timeout = 60) {
|
||||
if (timeout < 0) {
|
||||
throw new DaytonaError('Timeout must be a non-negative number')
|
||||
throw new HanzoRuntimeError('Timeout must be a non-negative number')
|
||||
}
|
||||
|
||||
const checkInterval = 100 // Wait 100 ms between checks
|
||||
@@ -266,11 +266,11 @@ export class Sandbox implements SandboxDto {
|
||||
|
||||
if (this.state === 'error') {
|
||||
const errMsg = `Sandbox ${this.id} failed to start with status: ${this.state}, error reason: ${this.errorReason}`
|
||||
throw new DaytonaError(errMsg)
|
||||
throw new HanzoRuntimeError(errMsg)
|
||||
}
|
||||
|
||||
if (timeout !== 0 && Date.now() - startTime > timeout * 1000) {
|
||||
throw new DaytonaError('Sandbox failed to become ready within the timeout period')
|
||||
throw new HanzoRuntimeError('Sandbox failed to become ready within the timeout period')
|
||||
}
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, checkInterval))
|
||||
@@ -286,11 +286,11 @@ export class Sandbox implements SandboxDto {
|
||||
* @param {number} [timeout] - Maximum time to wait in seconds. 0 means no timeout.
|
||||
* Defaults to 60 seconds.
|
||||
* @returns {Promise<void>}
|
||||
* @throws {DaytonaError} - `DaytonaError` - If the sandbox fails to stop within the timeout period.
|
||||
* @throws {HanzoRuntimeError} - `HanzoRuntimeError` - If the sandbox fails to stop within the timeout period.
|
||||
*/
|
||||
public async waitUntilStopped(timeout = 60) {
|
||||
if (timeout < 0) {
|
||||
throw new DaytonaError('Timeout must be a non-negative number')
|
||||
throw new HanzoRuntimeError('Timeout must be a non-negative number')
|
||||
}
|
||||
|
||||
const checkInterval = 100 // Wait 100 ms between checks
|
||||
@@ -306,11 +306,11 @@ export class Sandbox implements SandboxDto {
|
||||
|
||||
if (this.state === 'error') {
|
||||
const errMsg = `Sandbox failed to stop with status: ${this.state}, error reason: ${this.errorReason}`
|
||||
throw new DaytonaError(errMsg)
|
||||
throw new HanzoRuntimeError(errMsg)
|
||||
}
|
||||
|
||||
if (timeout !== 0 && Date.now() - startTime > timeout * 1000) {
|
||||
throw new DaytonaError('Sandbox failed to become stopped within the timeout period')
|
||||
throw new HanzoRuntimeError('Sandbox failed to become stopped within the timeout period')
|
||||
}
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, checkInterval))
|
||||
@@ -343,7 +343,7 @@ export class Sandbox implements SandboxDto {
|
||||
* @param {number} interval - Number of minutes of inactivity before auto-stopping.
|
||||
* Set to 0 to disable auto-stop. Default is 15 minutes.
|
||||
* @returns {Promise<void>}
|
||||
* @throws {DaytonaError} - `DaytonaError` - If interval is not a non-negative integer
|
||||
* @throws {HanzoRuntimeError} - `HanzoRuntimeError` - If interval is not a non-negative integer
|
||||
*
|
||||
* @example
|
||||
* // Auto-stop after 1 hour
|
||||
@@ -353,7 +353,7 @@ export class Sandbox implements SandboxDto {
|
||||
*/
|
||||
public async setAutostopInterval(interval: number): Promise<void> {
|
||||
if (!Number.isInteger(interval) || interval < 0) {
|
||||
throw new DaytonaError('autoStopInterval must be a non-negative integer')
|
||||
throw new HanzoRuntimeError('autoStopInterval must be a non-negative integer')
|
||||
}
|
||||
|
||||
await this.sandboxApi.setAutostopInterval(this.id, interval)
|
||||
@@ -368,7 +368,7 @@ export class Sandbox implements SandboxDto {
|
||||
* @param {number} interval - Number of minutes after which a continuously stopped Sandbox will be auto-archived.
|
||||
* Set to 0 for the maximum interval. Default is 7 days.
|
||||
* @returns {Promise<void>}
|
||||
* @throws {DaytonaError} - `DaytonaError` - If interval is not a non-negative integer
|
||||
* @throws {HanzoRuntimeError} - `HanzoRuntimeError` - If interval is not a non-negative integer
|
||||
*
|
||||
* @example
|
||||
* // Auto-archive after 1 hour
|
||||
@@ -378,7 +378,7 @@ export class Sandbox implements SandboxDto {
|
||||
*/
|
||||
public async setAutoArchiveInterval(interval: number): Promise<void> {
|
||||
if (!Number.isInteger(interval) || interval < 0) {
|
||||
throw new DaytonaError('autoArchiveInterval must be a non-negative integer')
|
||||
throw new HanzoRuntimeError('autoArchiveInterval must be a non-negative integer')
|
||||
}
|
||||
await this.sandboxApi.setAutoArchiveInterval(this.id, interval)
|
||||
this.autoArchiveInterval = interval
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* Copyright 2025 Hanzo Industries Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { ObjectStorageApi, SnapshotDto, SnapshotsApi, SnapshotState, CreateSnapshot } from '@daytonaio/api-client'
|
||||
import { DaytonaError } from './errors/DaytonaError'
|
||||
import { HanzoRuntimeError } from './errors/HanzoRuntimeError'
|
||||
import { ObjectStorage } from './ObjectStorage'
|
||||
import { Image } from './Image'
|
||||
import { Resources } from './Daytona'
|
||||
import { Resources } from './HanzoRuntime'
|
||||
import { processStreamingResponse } from './utils/Stream'
|
||||
|
||||
const SNAPSHOTS_FETCH_LIMIT = 200
|
||||
|
||||
/**
|
||||
* Represents a Daytona Snapshot which is a pre-configured sandbox.
|
||||
* Represents a HanzoRuntime Snapshot which is a pre-configured sandbox.
|
||||
*
|
||||
* @property {string} id - Unique identifier for the Snapshot.
|
||||
* @property {string} organizationId - Organization ID that owns the Snapshot.
|
||||
@@ -40,7 +40,7 @@ export type Snapshot = SnapshotDto & { __brand: 'Snapshot' }
|
||||
*
|
||||
* @property {string} name - Name of the snapshot.
|
||||
* @property {string | Image} image - Image of the snapshot. If a string is provided, it should be available on some registry.
|
||||
* If an Image instance is provided, it will be used to create a new image in Daytona.
|
||||
* If an Image instance is provided, it will be used to create a new image in HanzoRuntime.
|
||||
* @property {Resources} resources - Resources of the snapshot.
|
||||
* @property {string[]} entrypoint - Entrypoint of the snapshot.
|
||||
*/
|
||||
@@ -52,7 +52,7 @@ export type CreateSnapshotParams = {
|
||||
}
|
||||
|
||||
/**
|
||||
* Service for managing Daytona Snapshots. Can be used to list, get, create and delete Snapshots.
|
||||
* Service for managing HanzoRuntime Snapshots. Can be used to list, get, create and delete Snapshots.
|
||||
*
|
||||
* @class
|
||||
*/
|
||||
@@ -68,8 +68,8 @@ export class SnapshotService {
|
||||
* @returns {Promise<Snapshot[]>} List of all Snapshots accessible to the user
|
||||
*
|
||||
* @example
|
||||
* const daytona = new Daytona();
|
||||
* const snapshots = await daytona.snapshot.list();
|
||||
* const hanzo_runtime = new HanzoRuntime();
|
||||
* const snapshots = await hanzo_runtime.snapshot.list();
|
||||
* console.log(`Found ${snapshots.length} snapshots`);
|
||||
* snapshots.forEach(snapshot => console.log(`${snapshot.name} (${snapshot.imageName})`));
|
||||
*/
|
||||
@@ -89,8 +89,8 @@ export class SnapshotService {
|
||||
* @throws {Error} If the Snapshot does not exist or cannot be accessed
|
||||
*
|
||||
* @example
|
||||
* const daytona = new Daytona();
|
||||
* const snapshot = await daytona.snapshot.get("snapshot-name");
|
||||
* const hanzo_runtime = new HanzoRuntime();
|
||||
* const snapshot = await hanzo_runtime.snapshot.get("snapshot-name");
|
||||
* console.log(`Snapshot ${snapshot.name} is in state ${snapshot.state}`);
|
||||
*/
|
||||
async get(name: string): Promise<Snapshot> {
|
||||
@@ -106,9 +106,9 @@ export class SnapshotService {
|
||||
* @throws {Error} If the Snapshot does not exist or cannot be deleted
|
||||
*
|
||||
* @example
|
||||
* const daytona = new Daytona();
|
||||
* const snapshot = await daytona.snapshot.get("snapshot-name");
|
||||
* await daytona.snapshot.delete(snapshot);
|
||||
* const hanzo_runtime = new HanzoRuntime();
|
||||
* const snapshot = await hanzo_runtime.snapshot.get("snapshot-name");
|
||||
* await hanzo_runtime.snapshot.delete(snapshot);
|
||||
* console.log("Snapshot deleted successfully");
|
||||
*/
|
||||
async delete(snapshot: Snapshot): Promise<void> {
|
||||
@@ -126,7 +126,7 @@ export class SnapshotService {
|
||||
*
|
||||
* @example
|
||||
* const image = Image.debianSlim('3.12').pipInstall('numpy');
|
||||
* await daytona.snapshot.create({ name: 'my-snapshot', image: image }, { onLogs: console.log });
|
||||
* await hanzo_runtime.snapshot.create({ name: 'my-snapshot', image: image }, { onLogs: console.log });
|
||||
*/
|
||||
public async create(
|
||||
params: CreateSnapshotParams,
|
||||
@@ -163,7 +163,7 @@ export class SnapshotService {
|
||||
).data
|
||||
|
||||
if (!createdSnapshot) {
|
||||
throw new DaytonaError("Failed to create snapshot. Didn't receive a snapshot from the server API.")
|
||||
throw new HanzoRuntimeError("Failed to create snapshot. Didn't receive a snapshot from the server API.")
|
||||
}
|
||||
|
||||
const terminalStates: SnapshotState[] = [SnapshotState.ACTIVE, SnapshotState.ERROR, SnapshotState.BUILD_FAILED]
|
||||
@@ -218,7 +218,7 @@ export class SnapshotService {
|
||||
|
||||
if (createdSnapshot.state === SnapshotState.ERROR || createdSnapshot.state === SnapshotState.BUILD_FAILED) {
|
||||
const errMsg = `Failed to create snapshot. Name: ${createdSnapshot.name} Reason: ${createdSnapshot.errorReason}`
|
||||
throw new DaytonaError(errMsg)
|
||||
throw new HanzoRuntimeError(errMsg)
|
||||
}
|
||||
|
||||
return createdSnapshot as Snapshot
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* Copyright 2025 Hanzo Industries Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { VolumeDto, VolumesApi } from '@daytonaio/api-client'
|
||||
import { DaytonaNotFoundError } from './errors/DaytonaError'
|
||||
import { HanzoRuntimeNotFoundError } from './errors/HanzoRuntimeError'
|
||||
|
||||
/**
|
||||
* Represents a Daytona Volume which is a shared storage volume for Sandboxes.
|
||||
* Represents a HanzoRuntime Volume which is a shared storage volume for Sandboxes.
|
||||
*
|
||||
* @property {string} id - Unique identifier for the Volume
|
||||
* @property {string} name - Name of the Volume
|
||||
@@ -20,7 +20,7 @@ import { DaytonaNotFoundError } from './errors/DaytonaError'
|
||||
export type Volume = VolumeDto & { __brand: 'Volume' }
|
||||
|
||||
/**
|
||||
* Service for managing Daytona Volumes.
|
||||
* Service for managing HanzoRuntime Volumes.
|
||||
*
|
||||
* This service provides methods to list, get, create, and delete Volumes.
|
||||
*
|
||||
@@ -35,8 +35,8 @@ export class VolumeService {
|
||||
* @returns {Promise<Volume[]>} List of all Volumes accessible to the user
|
||||
*
|
||||
* @example
|
||||
* const daytona = new Daytona();
|
||||
* const volumes = await daytona.volume.list();
|
||||
* const hanzo_runtime = new HanzoRuntime();
|
||||
* const volumes = await hanzo_runtime.volume.list();
|
||||
* console.log(`Found ${volumes.length} volumes`);
|
||||
* volumes.forEach(vol => console.log(`${vol.name} (${vol.id})`));
|
||||
*/
|
||||
@@ -54,8 +54,8 @@ export class VolumeService {
|
||||
* @throws {Error} If the Volume does not exist or cannot be accessed
|
||||
*
|
||||
* @example
|
||||
* const daytona = new Daytona();
|
||||
* const volume = await daytona.volume.get("volume-name", true);
|
||||
* const hanzo_runtime = new HanzoRuntime();
|
||||
* const volume = await hanzo_runtime.volume.get("volume-name", true);
|
||||
* console.log(`Volume ${volume.name} is in state ${volume.state}`);
|
||||
*/
|
||||
async get(name: string, create = false): Promise<Volume> {
|
||||
@@ -64,7 +64,7 @@ export class VolumeService {
|
||||
return response.data as Volume
|
||||
} catch (error) {
|
||||
if (
|
||||
error instanceof DaytonaNotFoundError &&
|
||||
error instanceof HanzoRuntimeNotFoundError &&
|
||||
create &&
|
||||
error.message.match(/Volume with name ([\w-]+) not found/)
|
||||
) {
|
||||
@@ -82,8 +82,8 @@ export class VolumeService {
|
||||
* @throws {Error} If the Volume cannot be created
|
||||
*
|
||||
* @example
|
||||
* const daytona = new Daytona();
|
||||
* const volume = await daytona.volume.create("my-data-volume");
|
||||
* const hanzo_runtime = new HanzoRuntime();
|
||||
* const volume = await hanzo_runtime.volume.create("my-data-volume");
|
||||
* console.log(`Created volume ${volume.name} with ID ${volume.id}`);
|
||||
*/
|
||||
async create(name: string): Promise<Volume> {
|
||||
@@ -99,9 +99,9 @@ export class VolumeService {
|
||||
* @throws {Error} If the Volume does not exist or cannot be deleted
|
||||
*
|
||||
* @example
|
||||
* const daytona = new Daytona();
|
||||
* const volume = await daytona.volume.get("volume-name");
|
||||
* await daytona.volume.delete(volume);
|
||||
* const hanzo_runtime = new HanzoRuntime();
|
||||
* const volume = await hanzo_runtime.volume.get("volume-name");
|
||||
* await hanzo_runtime.volume.delete(volume);
|
||||
* console.log("Volume deleted successfully");
|
||||
*/
|
||||
async delete(volume: Volume): Promise<void> {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* Copyright 2025 Hanzo Industries Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* Copyright 2025 Hanzo Industries Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @module Errors
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base error for Daytona SDK.
|
||||
*/
|
||||
export class DaytonaError extends Error {}
|
||||
|
||||
export class DaytonaNotFoundError extends DaytonaError {}
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright 2025 Hanzo Industries Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @module Errors
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base error for HanzoRuntime SDK.
|
||||
*/
|
||||
export class HanzoRuntimeError extends Error {}
|
||||
|
||||
export class HanzoRuntimeNotFoundError extends HanzoRuntimeError {}
|
||||
@@ -1,24 +1,24 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* Copyright 2025 Hanzo Industries Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
export { CodeLanguage, Daytona } from './Daytona'
|
||||
export { CodeLanguage, HanzoRuntime } from './HanzoRuntime'
|
||||
export type {
|
||||
CreateSandboxBaseParams,
|
||||
CreateSandboxFromImageParams,
|
||||
CreateSandboxFromSnapshotParams,
|
||||
DaytonaConfig,
|
||||
HanzoRuntimeConfig,
|
||||
Resources,
|
||||
VolumeMount,
|
||||
} from './Daytona'
|
||||
} from './HanzoRuntime'
|
||||
export { FileSystem } from './FileSystem'
|
||||
export { Git } from './Git'
|
||||
export { LspLanguageId } from './LspServer'
|
||||
export { Process } from './Process'
|
||||
// export { LspServer } from './LspServer'
|
||||
// export type { LspLanguageId, Position } from './LspServer'
|
||||
export { DaytonaError } from './errors/DaytonaError'
|
||||
export { HanzoRuntimeError } from './errors/HanzoRuntimeError'
|
||||
export { Image } from './Image'
|
||||
export { Sandbox } from './Sandbox'
|
||||
export type { SandboxCodeToolbox } from './Sandbox'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* Copyright 2025 Hanzo Industries Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* Copyright 2025 Hanzo Industries Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* Copyright 2025 Hanzo Industries Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* Copyright 2025 Hanzo Industries Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2025 Daytona Platforms Inc.
|
||||
* Copyright 2025 Hanzo Industries Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo -e "${YELLOW}Hanzo Runtime Publishing Script${NC}"
|
||||
echo "================================"
|
||||
|
||||
# Check if tokens are provided as arguments or in environment
|
||||
if [ -n "$1" ] && [ -n "$2" ]; then
|
||||
export NPM_TOKEN="$1"
|
||||
export PYPI_TOKEN="$2"
|
||||
echo -e "${GREEN}✓ Using tokens from command line arguments${NC}"
|
||||
elif [ -z "$NPM_TOKEN" ] || [ -z "$PYPI_TOKEN" ]; then
|
||||
echo -e "${RED}Error: Tokens not found${NC}"
|
||||
echo ""
|
||||
echo "Usage:"
|
||||
echo " 1. Set environment variables:"
|
||||
echo " export NPM_TOKEN='npm_...'"
|
||||
echo " export PYPI_TOKEN='pypi-...'"
|
||||
echo " ./publish.sh"
|
||||
echo ""
|
||||
echo " 2. Or pass as arguments:"
|
||||
echo " ./publish.sh 'npm_...' 'pypi-...'"
|
||||
echo ""
|
||||
exit 1
|
||||
else
|
||||
echo -e "${GREEN}✓ Using tokens from environment${NC}"
|
||||
fi
|
||||
|
||||
# Run make publish
|
||||
echo ""
|
||||
echo "Running make publish..."
|
||||
make publish
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}✅ Publishing complete!${NC}"
|
||||
echo ""
|
||||
echo "Packages published:"
|
||||
echo " - Python: https://pypi.org/project/hanzo-runtime/"
|
||||
echo " - npm: https://www.npmjs.com/package/@hanzo/runtime"
|
||||
Reference in New Issue
Block a user