diff --git a/public/llms-full.txt b/public/llms-full.txt index 4590b1d4..347f143b 100644 --- a/public/llms-full.txt +++ b/public/llms-full.txt @@ -358,16 +358,16 @@ Run the following code to create a Daytona Sandbox and execute commands: ```python -from daytona_sdk import Daytona, DaytonaConfig, CreateSandboxParams +from daytona_sdk import Daytona, DaytonaConfig # Initialize the Daytona client daytona = Daytona(DaytonaConfig(api_key="YOUR_API_KEY")) # Create the Sandbox instance -sandbox = daytona.create(CreateSandboxParams(language="python")) +sandbox = daytona.create() # Run code securely inside the Sandbox -response = sandbox.process.code_run('print("Sum of 3 and 4 is " + str(3 + 4))') +response = sandbox.process.code_run("python", 'print("Sum of 3 and 4 is " + str(3 + 4))') if response.exit_code != 0: print(f"Error running code: {response.exit_code} {response.result}") else: @@ -392,11 +392,10 @@ async function main() { let sandbox; try { // Create the Sandbox instance - sandbox = await daytona.create({ - language: "python", - }); + sandbox = await daytona.create(); // Run code securely inside the Sandbox const response = await sandbox.process.codeRun( + 'python', 'print("Sum of 3 and 4 is " + str(3 + 4))' ); if (response.exitCode !== 0) { @@ -610,7 +609,7 @@ if __name__ == "__main__": # Run Python code inside the Sandbox and get the output -response = sandbox.process.code_run(app_code) +response = sandbox.process.code_run("python", app_code) print(response.result) ``` @@ -658,7 +657,7 @@ if __name__ == "__main__": `; // Run Python code inside the Sandbox and get the output - const response = await sandbox.process.codeRun(appCode); + const response = await sandbox.process.codeRun('python', appCode); console.log(response.result); } @@ -965,14 +964,13 @@ Once the image is pulled, validated and has an `Active` state, it is ready to be ```bash -params = CreateSandboxParams(image="alpine/3.21", language="python") +params = CreateSandboxParams(image="alpine/3.21") sandbox = daytona.create(params) ``` ```bash const sandbox = await daytona.create({ - language: 'python', image: 'alpine/3.21', }) ``` @@ -988,9 +986,9 @@ from daytona_sdk import Daytona, CreateSandboxParams daytona = Daytona() -sandbox = daytona.create(CreateSandboxParams(image="alpine/3.21", language="python")) +sandbox = daytona.create(CreateSandboxParams(image="alpine/3.21")) -response = sandbox.process.code_run('print("Sum of 3 and 4 is " + str(3 + 4))') +response = sandbox.process.code_run("python", 'print("Sum of 3 and 4 is " + str(3 + 4))') if response.exit_code != 0: print(f"Error running code: {response.exit_code} {response.result}") else: @@ -1012,11 +1010,11 @@ async function main() { try { // Create the Sandbox instance const sandbox = await daytona.create({ - language: 'python', image: 'alpine/3.21', }) // Run the code securely inside the Sandbox const response = await sandbox.process.codeRun( + 'python', 'print("Sum of 3 and 4 is " + str(3 + 4))', ) if (response.exitCode !== 0) { @@ -1167,24 +1165,30 @@ as it won't be shown again. ```python from daytona_sdk import Daytona, DaytonaConfig - # Define the configuration +# Define the configuration + config = DaytonaConfig(api_key="your-api-key") - # Initialize the Daytona client +# Initialize the Daytona client + daytona = Daytona(config) - # Create the Sandbox instance +# Create the Sandbox instance + sandbox = daytona.create() - # Run the code securely inside the Sandbox - response = sandbox.process.code_run('print("Hello World from code!")') +# Run the code securely inside the Sandbox + + response = sandbox.process.code_run("python", 'print("Hello World from code!")') if response.exit_code != 0: print(f"Error: {response.exit_code} {response.result}") else: print(response.result) - # Clean up +# Clean up + daytona.remove(sandbox) + ``` @@ -1196,12 +1200,10 @@ as it won't be shown again. const daytona = new Daytona({ apiKey: 'your-api-key' }); // Create the Sandbox instance - const sandbox = await daytona.create({ - language: 'typescript', - }); + const sandbox = await daytona.create(); // Run the code securely inside the Sandbox - const response = await sandbox.process.codeRun('console.log("Hello World from code!")') + const response = await sandbox.process.codeRun('typescript', 'console.log("Hello World from code!")') console.log(response.result); // Clean up @@ -1278,9 +1280,7 @@ import { Daytona, LspLanguageId } from '@daytonaio/sdk' // Create sandbox const daytona = new Daytona() -const sandbox = await daytona.create({ - language: 'typescript' -}) +const sandbox = await daytona.create() // Create LSP server for TypeScript const lspServer = sandbox.createLspServer( @@ -1430,7 +1430,9 @@ Daytona SDK provides an option to run code snippets in Python and TypeScript. Yo ```python # Run Python code -response = sandbox.process.code_run(''' +response = sandbox.process.code_run( + "python", +''' def greet(name): return f"Hello, {name}!" @@ -1444,17 +1446,21 @@ print(response.result) ```typescript // Run TypeScript code -let response = await sandbox.process.codeRun(` -function greet(name: string): string { - return \`Hello, \${name}!\`; -} +let response = await sandbox.process.codeRun( + 'typescript', + ` + function greet(name: string): string { + return \`Hello, \${name}!\`; + } -console.log(greet("Daytona")); -`); + console.log(greet("Daytona")); + ` +); console.log(response.result); // Run code with argv and environment variables response = await sandbox.process.codeRun( + 'typescript', ` console.log(\`Hello, \${process.argv[2]}!\`); console.log(\`FOO: \${process.env.FOO}\`); @@ -1468,6 +1474,7 @@ console.log(response.result); // Run code with timeout response = await sandbox.process.codeRun( + 'typescript', 'setTimeout(() => console.log("Done"), 2000);', undefined, 5000 @@ -1596,7 +1603,7 @@ Daytona SDK provides best practices for process and code execution in Sandboxes. ```python try: - response = sandbox.process.code_run("invalid python code") + response = sandbox.process.code_run("python", "invalid python code") except ProcessExecutionError as e: print(f"Execution failed: {e}") print(f"Exit code: {e.exit_code}") @@ -1606,12 +1613,12 @@ except ProcessExecutionError as e: ```typescript try { - const response = await sandbox.process.codeRun("invalid typescript code"); + const response = await sandbox.process.codeRun('typescript', 'invalid typescript code'); } catch (e) { if (e instanceof ProcessExecutionError) { - console.error("Execution failed:", e); - console.error("Exit code:", e.exitCode); - console.error("Error output:", e.stderr); + console.error('Execution failed:', e); + console.error('Exit code:', e.exitCode); + console.error('Error output:', e.stderr); } } ``` @@ -1668,11 +1675,6 @@ daytona = Daytona() sandbox = daytona.create() -# Create a Sandbox with specific language - -params = CreateSandboxParams(language="python") -sandbox = daytona.create(params) - # Create a Sandbox with custom ID params = CreateSandboxParams(id="my-sandbox") @@ -1689,9 +1691,6 @@ const daytona = new Daytona(); // Create a basic Sandbox const sandbox = await daytona.create(); -// Create a Sandbox with specific language -const sandbox = await daytona.create({ language: 'typescript' }); - // Create a Sandbox with custom ID const sandbox = await daytona.create({ id: 'my-sandbox' }); ``` diff --git a/public/search.json b/public/search.json index 2271980c..8ecd0329 100644 --- a/public/search.json +++ b/public/search.json @@ -855,21 +855,13 @@ "slug": "/sandbox-management#create-a-basic-sandbox", "objectID": 107 }, - { - "title": "Create a Sandbox with specific language", - "description": "", - "tag": "Documentation", - "url": "/docs/sandbox-management#create-a-sandbox-with-specific-language", - "slug": "/sandbox-management#create-a-sandbox-with-specific-language", - "objectID": 108 - }, { "title": "Create a Sandbox with custom ID", "description": "", "tag": "Documentation", "url": "/docs/sandbox-management#create-a-sandbox-with-custom-id", "slug": "/sandbox-management#create-a-sandbox-with-custom-id", - "objectID": 109 + "objectID": 108 }, { "title": "Sandbox Information", @@ -877,7 +869,7 @@ "tag": "Documentation", "url": "/docs/sandbox-management#sandbox-information", "slug": "/sandbox-management#sandbox-information", - "objectID": 110 + "objectID": 109 }, { "title": "Get Sandbox ID", @@ -885,7 +877,7 @@ "tag": "Documentation", "url": "/docs/sandbox-management#get-sandbox-id", "slug": "/sandbox-management#get-sandbox-id", - "objectID": 111 + "objectID": 110 }, { "title": "Get the root directory of tha Sandbox user", @@ -893,7 +885,7 @@ "tag": "Documentation", "url": "/docs/sandbox-management#get-the-root-directory-of-tha-sandbox-user", "slug": "/sandbox-management#get-the-root-directory-of-tha-sandbox-user", - "objectID": 112 + "objectID": 111 }, { "title": "Get the Sandbox name, image and state", @@ -901,7 +893,7 @@ "tag": "Documentation", "url": "/docs/sandbox-management#get-the-sandbox-name-image-and-state", "slug": "/sandbox-management#get-the-sandbox-name-image-and-state", - "objectID": 113 + "objectID": 112 }, { "title": "Get the preview link for an app running on port 3000", @@ -909,7 +901,7 @@ "tag": "Documentation", "url": "/docs/sandbox-management#get-the-preview-link-for-an-app-running-on-port-3000", "slug": "/sandbox-management#get-the-preview-link-for-an-app-running-on-port-3000", - "objectID": 114 + "objectID": 113 }, { "title": "Remove Sandbox", @@ -917,7 +909,7 @@ "tag": "Documentation", "url": "/docs/sandbox-management#remove-sandbox", "slug": "/sandbox-management#remove-sandbox", - "objectID": 115 + "objectID": 114 }, { "title": "Remove Sandbox", @@ -925,7 +917,7 @@ "tag": "Documentation", "url": "/docs/sandbox-management#remove-sandbox", "slug": "/sandbox-management#remove-sandbox", - "objectID": 116 + "objectID": 115 }, { "title": "Sandbox Persistence", @@ -933,7 +925,7 @@ "tag": "Documentation", "url": "/docs/sandbox-management#sandbox-persistence", "slug": "/sandbox-management#sandbox-persistence", - "objectID": 117 + "objectID": 116 }, { "title": "Running", @@ -941,7 +933,7 @@ "tag": "Documentation", "url": "/docs/sandbox-management#running", "slug": "/sandbox-management#running", - "objectID": 118 + "objectID": 117 }, { "title": "Stopped", @@ -949,7 +941,7 @@ "tag": "Documentation", "url": "/docs/sandbox-management#stopped", "slug": "/sandbox-management#stopped", - "objectID": 119 + "objectID": 118 }, { "title": "Archived", @@ -957,7 +949,7 @@ "tag": "Documentation", "url": "/docs/sandbox-management#archived", "slug": "/sandbox-management#archived", - "objectID": 120 + "objectID": 119 }, { "title": "Performance Considerations", @@ -965,7 +957,7 @@ "tag": "Documentation", "url": "/docs/sandbox-management#performance-considerations", "slug": "/sandbox-management#performance-considerations", - "objectID": 121 + "objectID": 120 }, { "title": "CLI", @@ -973,7 +965,7 @@ "tag": "Documentation", "url": "/docs/tools/cli", "slug": "/tools/cli", - "objectID": 122 + "objectID": 121 }, { "title": "daytona version", @@ -981,7 +973,7 @@ "tag": "Documentation", "url": "/docs/tools/cli#daytona-version", "slug": "/tools/cli#daytona-version", - "objectID": 123 + "objectID": 122 }, { "title": "daytona sandbox info", @@ -989,7 +981,7 @@ "tag": "Documentation", "url": "/docs/tools/cli#daytona-sandbox-info", "slug": "/tools/cli#daytona-sandbox-info", - "objectID": 124 + "objectID": 123 }, { "title": "daytona sandbox list", @@ -997,7 +989,7 @@ "tag": "Documentation", "url": "/docs/tools/cli#daytona-sandbox-list", "slug": "/tools/cli#daytona-sandbox-list", - "objectID": 125 + "objectID": 124 }, { "title": "daytona sandbox start", @@ -1005,7 +997,7 @@ "tag": "Documentation", "url": "/docs/tools/cli#daytona-sandbox-start", "slug": "/tools/cli#daytona-sandbox-start", - "objectID": 126 + "objectID": 125 }, { "title": "daytona sandbox stop", @@ -1013,7 +1005,7 @@ "tag": "Documentation", "url": "/docs/tools/cli#daytona-sandbox-stop", "slug": "/tools/cli#daytona-sandbox-stop", - "objectID": 127 + "objectID": 126 }, { "title": "daytona sandbox", @@ -1021,7 +1013,7 @@ "tag": "Documentation", "url": "/docs/tools/cli#daytona-sandbox", "slug": "/tools/cli#daytona-sandbox", - "objectID": 128 + "objectID": 127 }, { "title": "daytona sandbox create", @@ -1029,7 +1021,7 @@ "tag": "Documentation", "url": "/docs/tools/cli#daytona-sandbox-create", "slug": "/tools/cli#daytona-sandbox-create", - "objectID": 129 + "objectID": 128 }, { "title": "daytona sandbox delete", @@ -1037,7 +1029,7 @@ "tag": "Documentation", "url": "/docs/tools/cli#daytona-sandbox-delete", "slug": "/tools/cli#daytona-sandbox-delete", - "objectID": 130 + "objectID": 129 }, { "title": "daytona image push", @@ -1045,7 +1037,7 @@ "tag": "Documentation", "url": "/docs/tools/cli#daytona-image-push", "slug": "/tools/cli#daytona-image-push", - "objectID": 131 + "objectID": 130 }, { "title": "daytona login", @@ -1053,7 +1045,7 @@ "tag": "Documentation", "url": "/docs/tools/cli#daytona-login", "slug": "/tools/cli#daytona-login", - "objectID": 132 + "objectID": 131 }, { "title": "daytona logout", @@ -1061,7 +1053,7 @@ "tag": "Documentation", "url": "/docs/tools/cli#daytona-logout", "slug": "/tools/cli#daytona-logout", - "objectID": 133 + "objectID": 132 }, { "title": "daytona image", @@ -1069,7 +1061,7 @@ "tag": "Documentation", "url": "/docs/tools/cli#daytona-image", "slug": "/tools/cli#daytona-image", - "objectID": 134 + "objectID": 133 }, { "title": "daytona image create", @@ -1077,7 +1069,7 @@ "tag": "Documentation", "url": "/docs/tools/cli#daytona-image-create", "slug": "/tools/cli#daytona-image-create", - "objectID": 135 + "objectID": 134 }, { "title": "daytona image delete", @@ -1085,7 +1077,7 @@ "tag": "Documentation", "url": "/docs/tools/cli#daytona-image-delete", "slug": "/tools/cli#daytona-image-delete", - "objectID": 136 + "objectID": 135 }, { "title": "daytona image list", @@ -1093,7 +1085,7 @@ "tag": "Documentation", "url": "/docs/tools/cli#daytona-image-list", "slug": "/tools/cli#daytona-image-list", - "objectID": 137 + "objectID": 136 }, { "title": "daytona", @@ -1101,7 +1093,7 @@ "tag": "Documentation", "url": "/docs/tools/cli#daytona", "slug": "/tools/cli#daytona", - "objectID": 138 + "objectID": 137 }, { "title": "daytona autocomplete", @@ -1109,7 +1101,7 @@ "tag": "Documentation", "url": "/docs/tools/cli#daytona-autocomplete", "slug": "/tools/cli#daytona-autocomplete", - "objectID": 139 + "objectID": 138 }, { "title": "daytona docs", @@ -1117,6 +1109,6 @@ "tag": "Documentation", "url": "/docs/tools/cli#daytona-docs", "slug": "/tools/cli#daytona-docs", - "objectID": 140 + "objectID": 139 } ] \ No newline at end of file diff --git a/src/content/docs/getting-started.mdx b/src/content/docs/getting-started.mdx index 09bf5756..b3ee169e 100644 --- a/src/content/docs/getting-started.mdx +++ b/src/content/docs/getting-started.mdx @@ -44,16 +44,16 @@ Run the following code to create a Daytona Sandbox and execute commands: ```python -from daytona_sdk import Daytona, DaytonaConfig, CreateSandboxParams +from daytona_sdk import Daytona, DaytonaConfig # Initialize the Daytona client daytona = Daytona(DaytonaConfig(api_key="YOUR_API_KEY")) # Create the Sandbox instance -sandbox = daytona.create(CreateSandboxParams(language="python")) +sandbox = daytona.create() # Run code securely inside the Sandbox -response = sandbox.process.code_run('print("Sum of 3 and 4 is " + str(3 + 4))') +response = sandbox.process.code_run("python", 'print("Sum of 3 and 4 is " + str(3 + 4))') if response.exit_code != 0: print(f"Error running code: {response.exit_code} {response.result}") else: @@ -78,11 +78,10 @@ async function main() { let sandbox; try { // Create the Sandbox instance - sandbox = await daytona.create({ - language: "python", - }); + sandbox = await daytona.create(); // Run code securely inside the Sandbox const response = await sandbox.process.codeRun( + 'python', 'print("Sum of 3 and 4 is " + str(3 + 4))' ); if (response.exitCode !== 0) { @@ -296,7 +295,7 @@ if __name__ == "__main__": # Run Python code inside the Sandbox and get the output -response = sandbox.process.code_run(app_code) +response = sandbox.process.code_run("python", app_code) print(response.result) ``` @@ -344,7 +343,7 @@ if __name__ == "__main__": `; // Run Python code inside the Sandbox and get the output - const response = await sandbox.process.codeRun(appCode); + const response = await sandbox.process.codeRun('python', appCode); console.log(response.result); } diff --git a/src/content/docs/images.mdx b/src/content/docs/images.mdx index fb9c1c6b..cebfc7c0 100644 --- a/src/content/docs/images.mdx +++ b/src/content/docs/images.mdx @@ -18,14 +18,13 @@ Once the image is pulled, validated and has an `Active` state, it is ready to be ```bash -params = CreateSandboxParams(image="alpine/3.21", language="python") +params = CreateSandboxParams(image="alpine/3.21") sandbox = daytona.create(params) ``` ```bash const sandbox = await daytona.create({ - language: 'python', image: 'alpine/3.21', }) ``` @@ -41,9 +40,9 @@ from daytona_sdk import Daytona, CreateSandboxParams daytona = Daytona() -sandbox = daytona.create(CreateSandboxParams(image="alpine/3.21", language="python")) +sandbox = daytona.create(CreateSandboxParams(image="alpine/3.21")) -response = sandbox.process.code_run('print("Sum of 3 and 4 is " + str(3 + 4))') +response = sandbox.process.code_run("python", 'print("Sum of 3 and 4 is " + str(3 + 4))') if response.exit_code != 0: print(f"Error running code: {response.exit_code} {response.result}") else: @@ -65,11 +64,11 @@ async function main() { try { // Create the Sandbox instance const sandbox = await daytona.create({ - language: 'python', image: 'alpine/3.21', }) // Run the code securely inside the Sandbox const response = await sandbox.process.codeRun( + 'python', 'print("Sum of 3 and 4 is " + str(3 + 4))', ) if (response.exitCode !== 0) { diff --git a/src/content/docs/index.mdx b/src/content/docs/index.mdx index b50a79c9..8a1ae094 100644 --- a/src/content/docs/index.mdx +++ b/src/content/docs/index.mdx @@ -58,24 +58,30 @@ as it won't be shown again. ```python from daytona_sdk import Daytona, DaytonaConfig - # Define the configuration +# Define the configuration + config = DaytonaConfig(api_key="your-api-key") - # Initialize the Daytona client +# Initialize the Daytona client + daytona = Daytona(config) - # Create the Sandbox instance +# Create the Sandbox instance + sandbox = daytona.create() - # Run the code securely inside the Sandbox - response = sandbox.process.code_run('print("Hello World from code!")') +# Run the code securely inside the Sandbox + + response = sandbox.process.code_run("python", 'print("Hello World from code!")') if response.exit_code != 0: print(f"Error: {response.exit_code} {response.result}") else: print(response.result) - # Clean up +# Clean up + daytona.remove(sandbox) + ``` @@ -87,12 +93,10 @@ as it won't be shown again. const daytona = new Daytona({ apiKey: 'your-api-key' }); // Create the Sandbox instance - const sandbox = await daytona.create({ - language: 'typescript', - }); + const sandbox = await daytona.create(); // Run the code securely inside the Sandbox - const response = await sandbox.process.codeRun('console.log("Hello World from code!")') + const response = await sandbox.process.codeRun('typescript', 'console.log("Hello World from code!")') console.log(response.result); // Clean up diff --git a/src/content/docs/language-server-protocol.mdx b/src/content/docs/language-server-protocol.mdx index 21e36dd1..8119be06 100644 --- a/src/content/docs/language-server-protocol.mdx +++ b/src/content/docs/language-server-protocol.mdx @@ -35,9 +35,7 @@ import { Daytona, LspLanguageId } from '@daytonaio/sdk' // Create sandbox const daytona = new Daytona() -const sandbox = await daytona.create({ - language: 'typescript' -}) +const sandbox = await daytona.create() // Create LSP server for TypeScript const lspServer = sandbox.createLspServer( diff --git a/src/content/docs/process-code-execution.mdx b/src/content/docs/process-code-execution.mdx index 35aa2302..958650dc 100644 --- a/src/content/docs/process-code-execution.mdx +++ b/src/content/docs/process-code-execution.mdx @@ -18,7 +18,9 @@ Daytona SDK provides an option to run code snippets in Python and TypeScript. Yo ```python # Run Python code -response = sandbox.process.code_run(''' +response = sandbox.process.code_run( + "python", +''' def greet(name): return f"Hello, {name}!" @@ -32,17 +34,21 @@ print(response.result) ```typescript // Run TypeScript code -let response = await sandbox.process.codeRun(` -function greet(name: string): string { - return \`Hello, \${name}!\`; -} +let response = await sandbox.process.codeRun( + 'typescript', + ` + function greet(name: string): string { + return \`Hello, \${name}!\`; + } -console.log(greet("Daytona")); -`); + console.log(greet("Daytona")); + ` +); console.log(response.result); // Run code with argv and environment variables response = await sandbox.process.codeRun( + 'typescript', ` console.log(\`Hello, \${process.argv[2]}!\`); console.log(\`FOO: \${process.env.FOO}\`); @@ -56,6 +62,7 @@ console.log(response.result); // Run code with timeout response = await sandbox.process.codeRun( + 'typescript', 'setTimeout(() => console.log("Done"), 2000);', undefined, 5000 @@ -184,7 +191,7 @@ Daytona SDK provides best practices for process and code execution in Sandboxes. ```python try: - response = sandbox.process.code_run("invalid python code") + response = sandbox.process.code_run("python", "invalid python code") except ProcessExecutionError as e: print(f"Execution failed: {e}") print(f"Exit code: {e.exit_code}") @@ -194,12 +201,12 @@ except ProcessExecutionError as e: ```typescript try { - const response = await sandbox.process.codeRun("invalid typescript code"); + const response = await sandbox.process.codeRun('typescript', 'invalid typescript code'); } catch (e) { if (e instanceof ProcessExecutionError) { - console.error("Execution failed:", e); - console.error("Exit code:", e.exitCode); - console.error("Error output:", e.stderr); + console.error('Execution failed:', e); + console.error('Exit code:', e.exitCode); + console.error('Error output:', e.stderr); } } ``` diff --git a/src/content/docs/sandbox-management.mdx b/src/content/docs/sandbox-management.mdx index c260fc60..4536b1b0 100644 --- a/src/content/docs/sandbox-management.mdx +++ b/src/content/docs/sandbox-management.mdx @@ -26,11 +26,6 @@ daytona = Daytona() sandbox = daytona.create() -# Create a Sandbox with specific language - -params = CreateSandboxParams(language="python") -sandbox = daytona.create(params) - # Create a Sandbox with custom ID params = CreateSandboxParams(id="my-sandbox") @@ -47,9 +42,6 @@ const daytona = new Daytona(); // Create a basic Sandbox const sandbox = await daytona.create(); -// Create a Sandbox with specific language -const sandbox = await daytona.create({ language: 'typescript' }); - // Create a Sandbox with custom ID const sandbox = await daytona.create({ id: 'my-sandbox' }); ```