Skip to content

Support passing code as string in addition to file paths #23

@danbugs

Description

@danbugs

Currently the SDK only accepts file paths for workload execution. It would be useful to support passing code directly as a string.

Current behavior:

result = await sandbox.run('guest-examples/hello.js')  # File path only

Proposed enhancement:
Add support for passing code as a string, with options:

Option 1: Separate method

result = await sandbox.run_code('console.log("hello")', language='javascript')

Option 2: Auto-detect (file path vs code string)

result = await sandbox.run('console.log("hello")')  # Detects as code
result = await sandbox.run('hello.js')  # Detects as file path

Implementation notes:

  • Nanvix runtime currently requires files
  • Could create temporary files internally from code strings
  • Need to handle cleanup of temporary files
  • Should work across all language bindings (NAPI, Python)

Related to PR #20 review from @jsturtevant

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions