Skip to content

feat: integration of daytona.io #325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

feat: integration of daytona.io #325

wants to merge 2 commits into from

Conversation

TooonyChen
Copy link
Collaborator

@TooonyChen TooonyChen commented May 6, 2025

🏷️ Ticket

#293

πŸ“ Description

This PR implements the Daytona.io integration for running AI-generated code in secure, isolated environments. Daytona provides a fast and secure sandbox solution with sub-90ms creation time, enabling seamless execution of untrusted code.

The implementation includes:

  • App configuration with proper authentication method (Bearer token)
  • Complete API endpoints for workspace management (list, create, get, delete, start, stop)
  • Command execution functionality for running code in workspaces
  • Comprehensive validation and error handling

Integration was tested with various prompts to ensure proper functionality:

# List Workspaces
docker compose exec runner python -m aci.cli fuzzy-test-function-execution \
  --function-name DAYTONA__LIST_WORKSPACES \
  --linked-account-owner-id 2463d857-cf44-464d-8db5-c687a795bf99 \
  --aci-api-key 251e318625ff383f1ec0f440e4525e5f7a36a6325b084ab0665a711f787970df \
  --prompt "List all workspaces with verbose output and filter by the labels as JSON: {\"project\":\"ai-sandbox\"}."

# Create Workspace
docker compose exec runner python -m aci.cli fuzzy-test-function-execution \
  --function-name DAYTONA__CREATE_WORKSPACE \
  --linked-account-owner-id 2463d857-cf44-464d-8db5-c687a795bf99 \
  --aci-api-key 251e318625ff383f1ec0f440e4525e5f7a36a6325b084ab0665a711f787970df \
  --prompt "Create a new workspace named 'ai-code-executor'. Add labels as a JSON object: {\"project\":\"ai-sandbox\",\"environment\":\"dev\"}. Set auto-stop to 5 minutes."

# Get Workspace
docker compose exec runner python -m aci.cli fuzzy-test-function-execution \
  --function-name DAYTONA__GET_WORKSPACE \
  --linked-account-owner-id 2463d857-cf44-464d-8db5-c687a795bf99 \
  --aci-api-key 251e318625ff383f1ec0f440e4525e5f7a36a6325b084ab0665a711f787970df \
  --prompt "Get detailed information about the workspace with ID '523aaaab-451b-43e6-bb47-42b337b6dcad'. Include verbose output to see all configuration details."

# Delete Workspace
docker compose exec runner python -m aci.cli fuzzy-test-function-execution \
  --function-name DAYTONA__DELETE_WORKSPACE \
  --linked-account-owner-id 2463d857-cf44-464d-8db5-c687a795bf99 \
  --aci-api-key 251e318625ff383f1ec0f440e4525e5f7a36a6325b084ab0665a711f787970df \
  --prompt "Delete the workspace with ID '523aaaab-451b-43e6-bb47-42b337b6dcad'. Force the deletion to ensure all resources are cleaned up immediately."

# Start Workspace
docker compose exec runner python -m aci.cli fuzzy-test-function-execution \
  --function-name DAYTONA__START_WORKSPACE \
  --linked-account-owner-id 2463d857-cf44-464d-8db5-c687a795bf99 \
  --aci-api-key 251e318625ff383f1ec0f440e4525e5f7a36a6325b084ab0665a711f787970df \
  --prompt "Start the workspace with ID '523aaaab-451b-43e6-bb47-42b337b6dcad' to initialize the environment and make it ready for use."

# Stop Workspace
docker compose exec runner python -m aci.cli fuzzy-test-function-execution \
  --function-name DAYTONA__STOP_WORKSPACE \
  --linked-account-owner-id 2463d857-cf44-464d-8db5-c687a795bf99 \
  --aci-api-key 251e318625ff383f1ec0f440e4525e5f7a36a6325b084ab0665a711f787970df \
  --prompt "Stop the workspace with ID '523aaaab-451b-43e6-bb47-42b337b6dcad' to conserve resources when it's not in use."

# Execute Command
docker compose exec runner python -m aci.cli fuzzy-test-function-execution \
  --function-name DAYTONA__EXECUTE_COMMAND \
  --linked-account-owner-id 2463d857-cf44-464d-8db5-c687a795bf99 \
  --aci-api-key 251e318625ff383f1ec0f440e4525e5f7a36a6325b084ab0665a711f787970df \
  --prompt "Execute the command 'curl ip.sb' in the workspace with ID '523aaaab-451b-43e6-bb47-42b337b6dcad'. Set the working directory to '/home/daytona/project' and add an environment variable 'DEBUG=true'. Set a timeout of 30 seconds."

πŸŽ₯ Demo (if applicable)

πŸ“Έ Screenshots (if applicable)

image

image

image

image

image

image

image

βœ… Checklist

  • [ x ] I have signed the Contributor License Agreement (CLA) and read the contributing guide (required)
  • [ x ] I have linked this PR to an issue or a ticket (required)
  • [ x ] I have updated the documentation related to my change if needed
  • [ x ] I have updated the tests accordingly (required for a bug fix or a new feature)
  • [ x ] All checks on CI passed

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced configuration and metadata for the Daytona application, highlighting secure, elastic infrastructure for running AI-generated code in isolated environments.
    • Added a suite of REST API endpoints for managing workspaces, including listing, creating, retrieving, deleting, starting, stopping, and executing commands within workspaces.
  • Chores

    • Added new JSON configuration files to define app settings and API function schemas for Daytona.

Copy link

vercel bot commented May 6, 2025

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated (UTC)
aci-dev-portal βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback May 6, 2025 9:27am

Copy link
Contributor

coderabbitai bot commented May 6, 2025

Walkthrough

This change introduces two new JSON configuration files for the Daytona application. The first file defines the app's metadata, security scheme, and categories. The second file specifies detailed REST API function declarations for workspace management and command execution, including endpoint paths, methods, parameter schemas, and visibility settings.

Changes

File(s) Change Summary
backend/apps/daytona/app.json Added Daytona app metadata, security settings (API key via Authorization header), categories, and visibility.
backend/apps/daytona/functions.json Introduced REST API function declarations for workspace management and command execution with detailed schemas.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant DaytonaAPI

    Client->>DaytonaAPI: GET /api/workspace (List Workspaces)
    DaytonaAPI-->>Client: List of workspaces

    Client->>DaytonaAPI: POST /api/workspace (Create Workspace)
    DaytonaAPI-->>Client: Workspace creation response

    Client->>DaytonaAPI: GET /api/workspace/{workspaceId} (Get Workspace)
    DaytonaAPI-->>Client: Workspace details

    Client->>DaytonaAPI: DELETE /api/workspace/{workspaceId}?force=... (Delete Workspace)
    DaytonaAPI-->>Client: Deletion confirmation

    Client->>DaytonaAPI: POST /api/workspace/{workspaceId}/start (Start Workspace)
    DaytonaAPI-->>Client: Start confirmation

    Client->>DaytonaAPI: POST /api/workspace/{workspaceId}/stop (Stop Workspace)
    DaytonaAPI-->>Client: Stop confirmation

    Client->>DaytonaAPI: POST /api/toolbox/{workspaceId}/toolbox/process/execute (Execute Command)
    DaytonaAPI-->>Client: Command execution result
Loading

Possibly related issues

Poem

In Daytona’s fields, new configs bloom,
Workspaces spin up, dispelling the gloom.
Commands now run at a rabbit’s pace,
Secure and swift in their digital space.
πŸ‡ JSONs align, APIs in tuneβ€”
Daytona is ready, none too soon!


πŸ“œ Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between df952a0 and b75a2c0.

πŸ“’ Files selected for processing (2)
  • backend/apps/daytona/app.json (1 hunks)
  • backend/apps/daytona/functions.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • backend/apps/daytona/app.json
  • backend/apps/daytona/functions.json

πŸͺ§ Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

πŸ”­ Outside diff range comments (1)
backend/apps/daytona/functions.json (1)

1-413: ⚠️ Potential issue

Define response schemas for each endpoint.
All functions currently only specify request parameters but no response models or status codes. Without response schemas, clients cannot validate or parse API responses.

Add a "responses" section to each function entry detailing expected HTTP status codes and corresponding JSON schemas.

🧹 Nitpick comments (3)
backend/apps/daytona/functions.json (3)

25-29: Consider using an array for label filtering.
The "labels" query parameter in DAYTONA__LIST_WORKSPACES is defined as a single string. If you intend to filter by multiple labels, an array of strings (e.g., ["tag1","tag2"]) may be more appropriate.

You can change the schema to:

 "labels": {
-  "type": "string",
+  "type": "array",
+  "items": { "type": "string" },
   "description": "Filter workspaces by labels"
 }

34-46: Refactor repeated header parameter definitions.
The "X-Daytona-Organization-ID" header parameter is duplicated in every endpoint's "parameters.header" block. To reduce duplication, consider defining it once (e.g., via a shared $ref or global parameter) and referencing it in each function schema.


9-13: Centralize server_url configuration.
Each function specifies "server_url": "https://app.daytona.io". If supported, you may factor this out to a global setting to avoid repetition and simplify maintenance.

πŸ“œ Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between cecb9e0 and df952a0.

πŸ“’ Files selected for processing (2)
  • backend/apps/daytona/app.json (1 hunks)
  • backend/apps/daytona/functions.json (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Compose Tests
  • GitHub Check: Format, Lint, and Test
  • GitHub Check: Format & Lint
πŸ”‡ Additional comments (3)
backend/apps/daytona/app.json (1)

2-6:

❓ Verification inconclusive

Verify naming and version conventions across apps.
The "name" field is set to "DAYTONA" (uppercase) and "version" to "aipolabs_0.0.1". Please confirm these values align with existing application configuration patterns (e.g., lowercase names and a consistent semantic versioning scheme without vendor prefixes).

Run the following script to list the name and version fields in all app.json files:


🏁 Script executed:

#!/bin/bash
# List name and version fields in all app.json for consistency checks.
fd -g "app.json" backend/apps | while read -r file; do
  echo "$file:"
  jq -r '"  name: \(.name), version: \(.version)"' "$file"
done

Length of output: 16187


Naming and version conventions check

  • name: DAYTONA aligns with existing uppercase names (ACCREDIBLE, ACTIVE_CAMPAIGN, etc.).
  • version: aipolabs_0.0.1 matches other Aipolabs-owned connectors (AGENTMAIL, AIDBASE, ASANA, etc.), while third-party apps use plain semver (e.g., 1.0.0) or date-based versions.

Please confirm whether we should continue using the aipolabs_ prefix for all Aipolabs apps or standardize on a pure semantic versioning scheme across the board.

backend/apps/daytona/functions.json (2)

1-13: Confirm authentication enforcement for endpoints.
Function definitions omit explicit Authorization header parameters, relying on app.json for security schemes. Ensure your framework automatically attaches the API key from security_schemes; otherwise, add an Authorization: Bearer header parameter to each function.

Please verify whether functions.json supports implicit security from app.json or requires explicit header definitions.


343-346: Verify the execute endpoint path.
The path is set to /api/toolbox/{workspaceId}/toolbox/process/execute, which repeats "toolbox". Confirm this is correct and not a typo. Otherwise, adjust to /api/toolbox/{workspaceId}/process/execute or /api/workspace/{workspaceId}/toolbox/process/execute as intended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant