Skip to content
This repository was archived by the owner on May 26, 2025. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const sandbox = await daytona.create({
})

// Run the code securely inside the sandbox
const response = await sandbox.process.code_run('console.log("Hello World!")')
const response = await sandbox.process.code_run("typescript", 'console.log("Hello World!")')
console.log(response.result)
```

Expand All @@ -52,7 +52,7 @@ daytona = Daytona()
sandbox = daytona.create()

# Run the code securely inside the sandbox
response = sandbox.process.code_run('print("Hello World!")')
response = sandbox.process.code_run("python", 'print("Hello World!")')
print(response.result)
```

Expand Down
23 changes: 2 additions & 21 deletions docs/python-sdk/daytona.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,11 @@ def create(params: Optional[CreateSandboxParams] = None,
```

Creates Sandboxes with default or custom configurations. You can specify various parameters,
including language, image, resources, environment variables, and volumes for the Sandbox.
including image, resources, environment variables, and volumes for the Sandbox.

**Arguments**:

- `params` _Optional[CreateSandboxParams]_ - Parameters for Sandbox creation. If not provided,
defaults to Python language.
- `params` _Optional[CreateSandboxParams]_ - Parameters for Sandbox creation.
- `timeout` _Optional[float]_ - Timeout (in seconds) for sandbox creation. 0 means no timeout.
Default is 60 seconds.

Expand All @@ -114,7 +113,6 @@ sandbox = daytona.create()
Create a custom Sandbox:
```python
params = CreateSandboxParams(
language="python",
name="my-sandbox",
image="debian:12.9",
env_vars={"DEBUG": "true"},
Expand Down Expand Up @@ -265,20 +263,6 @@ Stops a Sandbox and waits for it to be stopped.
- `DaytonaError` - If timeout is negative; If Sandbox fails to stop or times out


## CodeLanguage

```python
@dataclass
class CodeLanguage(Enum)
```

Programming languages supported by Daytona

**Enum Members**:
- `PYTHON` ("python")
- `TYPESCRIPT` ("typescript")
- `JAVASCRIPT` ("javascript")

## DaytonaConfig

```python
Expand Down Expand Up @@ -339,7 +323,6 @@ resources = SandboxResources(
gpu=1
)
params = CreateSandboxParams(
language="python",
resources=resources
)
```
Expand All @@ -354,7 +337,6 @@ Parameters for creating a new Sandbox.

**Attributes**:

- `language` _Optional[CodeLanguage]_ - Programming language for the Sandbox ("python", "javascript", "typescript").
Defaults to "python".
- `id` _Optional[str]_ - Custom identifier for the Sandbox. If not provided, a random ID will be generated.
- `name` _Optional[str]_ - Display name for the Sandbox. Defaults to Sandbox ID if not provided.
Expand All @@ -375,7 +357,6 @@ Parameters for creating a new Sandbox.

```python
params = CreateSandboxParams(
language="python",
name="my-sandbox",
env_vars={"DEBUG": "true"},
resources=SandboxResources(cpu=2, memory=4),
Expand Down
38 changes: 27 additions & 11 deletions docs/python-sdk/process.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,19 @@ Handles process and code execution within a Sandbox.

**Attributes**:

- `code_toolbox` _SandboxPythonCodeToolbox_ - Language-specific code execution toolbox.
- `toolbox_api` _ToolboxApi_ - API client for Sandbox operations.
- `instance` _SandboxInstance_ - The Sandbox instance this process belongs to.

#### Process.\_\_init\_\_

```python
def __init__(code_toolbox: SandboxPythonCodeToolbox, toolbox_api: ToolboxApi,
instance: SandboxInstance)
def __init__(toolbox_api: ToolboxApi, instance: SandboxInstance)
```

Initialize a new Process instance.

**Arguments**:

- `code_toolbox` _SandboxPythonCodeToolbox_ - Language-specific code execution toolbox.
- `toolbox_api` _ToolboxApi_ - API client for Sandbox operations.
- `instance` _SandboxInstance_ - The Sandbox instance this process belongs to.

Expand Down Expand Up @@ -77,7 +74,8 @@ result = sandbox.process.exec("sleep 10", timeout=5)
#### Process.code\_run

```python
def code_run(code: str,
def code_run(language: Literal["python", "typescript", "javascript"],
code: str,
params: Optional[CodeRunParams] = None,
timeout: Optional[int] = None) -> ExecuteResponse
```
Expand All @@ -86,6 +84,7 @@ Executes code in the Sandbox using the appropriate language runtime.

**Arguments**:

- `language` _Literal["python", "typescript", "javascript"]_ - Programming language to use.
- `code` _str_ - Code to execute.
- `params` _Optional[CodeRunParams]_ - Parameters for code execution.
- `timeout` _Optional[int]_ - Maximum time in seconds to wait for the code
Expand All @@ -105,11 +104,14 @@ Executes code in the Sandbox using the appropriate language runtime.

```python
# Run Python code
response = sandbox.process.code_run('''
x = 10
y = 20
print(f"Sum: {x + y}")
''')
response = sandbox.process.code_run(
language="python",
code='''
x = 10
y = 20
print(f"Sum: {x + y}")
'''
)
print(response.artifacts.stdout) # Prints: Sum: 30
```

Expand All @@ -132,7 +134,7 @@ print(response.artifacts.stdout) # Prints: Sum: 30
plt.show()
'''

response = sandbox.process.code_run(code)
response = sandbox.process.code_run("python", code)
chart = response.artifacts.charts[0]

print(f"Type: {chart.type}")
Expand Down Expand Up @@ -413,3 +415,17 @@ Parameters for code execution.
- `argv` _Optional[List[str]]_ - Command line arguments
- `env` _Optional[Dict[str, str]]_ - Environment variables

## CodeLanguage

```python
@dataclass
class CodeLanguage(str, Enum)
```

Programming languages supported by Daytona

**Enum Members**:
- `PYTHON` ("python")
- `TYPESCRIPT` ("typescript")
- `JAVASCRIPT` ("javascript")

4 changes: 1 addition & 3 deletions docs/python-sdk/sandbox.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Represents a Daytona Sandbox.

- `id` _str_ - Unique identifier for the Sandbox.
- `instance` _SandboxInstance_ - The underlying Sandbox instance.
- `code_toolbox` _SandboxCodeToolbox_ - Language-specific toolbox implementation.
- `fs` _FileSystem_ - File system operations interface.
- `git` _Git_ - Git operations interface.
- `process` _Process_ - Process execution interface.
Expand All @@ -23,7 +22,7 @@ Represents a Daytona Sandbox.

```python
def __init__(id: str, instance: SandboxInstance, sandbox_api: SandboxApi,
toolbox_api: ToolboxApi, code_toolbox: SandboxCodeToolbox)
toolbox_api: ToolboxApi)
```

Initialize a new Sandbox instance.
Expand All @@ -34,7 +33,6 @@ Initialize a new Sandbox instance.
- `instance` _SandboxInstance_ - The underlying Sandbox instance.
- `sandbox_api` _SandboxApi_ - API client for Sandbox operations.
- `toolbox_api` _ToolboxApi_ - API client for toolbox operations.
- `code_toolbox` _SandboxCodeToolbox_ - Language-specific toolbox implementation.

#### Sandbox.info

Expand Down
15 changes: 1 addition & 14 deletions docs/typescript-sdk/daytona.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ create(params?: CreateSandboxParams, timeout?: number): Promise<Sandbox>
```

Creates Sandboxes with default or custom configurations. You can specify various parameters,
including language, image, resources, environment variables, and volumes for the Sandbox.
including image, resources, environment variables, and volumes for the Sandbox.

**Parameters**:

Expand All @@ -85,7 +85,6 @@ const sandbox = await daytona.create();
```ts
// Create a custom sandbox
const params: CreateSandboxParams = {
language: 'typescript',
image: 'node:18',
envVars: {
NODE_ENV: 'development',
Expand Down Expand Up @@ -282,16 +281,6 @@ await daytona.stop(sandbox);
***


## CodeLanguage

Supported programming languages for code execution

**Enum Members**:

- `JAVASCRIPT` ("javascript")
- `PYTHON` ("python")
- `TYPESCRIPT` ("typescript")

## CreateSandboxParams

Parameters for creating a new Sandbox.
Expand All @@ -304,7 +293,6 @@ Parameters for creating a new Sandbox.
- `id?` _string_ - Optional Sandbox ID. If not provided, a random ID will be generated
- `image?` _string_ - Optional Docker image to use for the Sandbox
- `labels?` _Record\<string, string\>_ - Sandbox labels
- `language?` _string_ - Programming language for direct code execution
- `public?` _boolean_ - Is the Sandbox port preview public
- `resources?` _SandboxResources_ - Resource allocation for the Sandbox
- `target?` _string_ - Target location for the Sandbox
Expand All @@ -319,7 +307,6 @@ Parameters for creating a new Sandbox.

```ts
const params: CreateSandboxParams = {
language: 'typescript',
envVars: { NODE_ENV: 'development' },
resources: {
cpu: 2,
Expand Down
42 changes: 30 additions & 12 deletions docs/typescript-sdk/process.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,11 @@ Handles process and code execution within a Sandbox.
#### new Process()

```ts
new Process(
codeToolbox: SandboxCodeToolbox,
toolboxApi: ToolboxApi,
instance: SandboxInstance): Process
new Process(toolboxApi: ToolboxApi, instance: SandboxInstance): Process
```

**Parameters**:

- `codeToolbox` _SandboxCodeToolbox_
- `toolboxApi` _ToolboxApi_
- `instance` _SandboxInstance_

Expand All @@ -59,6 +55,7 @@ new Process(

```ts
codeRun(
language: "python" | "typescript" | "javascript",
code: string,
params?: CodeRunParams,
timeout?: number): Promise<ExecuteResponse>
Expand All @@ -68,6 +65,7 @@ Executes code in the Sandbox using the appropriate language runtime.

**Parameters**:

- `language` _Programming language for the code._ - `"python"` | `"typescript"` | `"javascript"`
- `code` _string_ - Code to execute
- `params?` _CodeRunParams_ - Parameters for code execution
- `timeout?` _number_ - Maximum time in seconds to wait for execution to complete
Expand All @@ -84,17 +82,22 @@ Executes code in the Sandbox using the appropriate language runtime.

```ts
// Run TypeScript code
const response = await process.codeRun(`
const x = 10;
const y = 20;
console.log(\`Sum: \${x + y}\`);
`);
const response = await sandbox.process.codeRun(
'typescript',
`
const x = 10;
const y = 20;
console.log(\`Sum: \${x + y}\`);
`
);
console.log(response.artifacts.stdout); // Prints: Sum: 30
```

```ts
// Run Python code with matplotlib
const response = await process.codeRun(`
const response = await sandbox.process.codeRun(
'python',
`
import matplotlib.pyplot as plt
import numpy as np

Expand All @@ -108,7 +111,8 @@ plt.xlabel('X-axis (seconds)')
plt.ylabel('Y-axis (amplitude)')
plt.grid(True)
plt.show()
`);
`
);

if (response.artifacts?.charts) {
const chart = response.artifacts.charts[0];
Expand Down Expand Up @@ -427,3 +431,17 @@ sessions.forEach(session => {
});
});
```

***


## CodeLanguage

Supported programming languages for code execution

**Enum Members**:

- `JAVASCRIPT` ("javascript")
- `PYTHON` ("python")
- `TYPESCRIPT` ("typescript")

31 changes: 1 addition & 30 deletions docs/typescript-sdk/sandbox.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ new Sandbox(
id: string,
instance: SandboxInstance,
sandboxApi: WorkspaceApi,
toolboxApi: ToolboxApi,
codeToolbox: SandboxCodeToolbox): Sandbox
toolboxApi: ToolboxApi): Sandbox
```

Creates a new Sandbox instance
Expand All @@ -42,7 +41,6 @@ Creates a new Sandbox instance
- `instance` _SandboxInstance_ - The underlying Sandbox instance
- `sandboxApi` _WorkspaceApi_ - API client for Sandbox operations
- `toolboxApi` _ToolboxApi_ - API client for toolbox operations
- `codeToolbox` _SandboxCodeToolbox_ - Language-specific toolbox implementation


**Returns**:
Expand Down Expand Up @@ -421,33 +419,6 @@ or encounters an error.
**Throws**:

- `DaytonaError` - If the sandbox fails to stop within the timeout period.
## SandboxCodeToolbox

Interface defining methods that a code toolbox must implement

### Methods

#### getRunCommand()

```ts
getRunCommand(code: string, params?: CodeRunParams): string
```

Generates a command to run the provided code

**Parameters**:

- `code` _string_
- `params?` _CodeRunParams_


**Returns**:

- `string`

***


## SandboxInfo

Structured information about a Sandbox
Expand Down
Loading