Skip to content

v0.7.2

Choose a tag to compare

@mavdol mavdol released this 30 Mar 21:12
· 34 commits to main since this release
9fa976b

Dynamic Directory Aliases (--mount) & Adapter Sessions

Core Improvements

Added --mount flag (CLI) and mounts parameter (SDK) to mount a host directory into the sandbox under an alias.

# Mount a session workspace and expose it as "workspace" inside the task
capsule run main.py --mount restricted-folder/sessions/abc123_workspace::workspace

# Multiple directories
capsule run main.py \
  --mount restricted-folder/sessions/abc123_workspace::workspace \
  --mount restricted-folder/sessions/bce456_workspace::workspace:ro
from capsule import run

result = await run(
    file="main.py",
    mounts=["restricted-folder/sessions/abc123_workspace::workspace"],
)

Python & TypeScript Adapter Sessions

A new sandboxed session system is now available.

from capsule_adapter import Session

async with Session() as s:
    await s.run("x = 1")
    result = await s.run("x += 1; x")
    print(result)  # 2

You can also import files within a session:

async with Session() as s:
    # Import a single file
    await s.import_file("./notes.txt", "notes.txt")

    result = await s.run("""
with open("workspace/notes.txt") as f:
    content = f.read()
content
""")

    # Delete the file
    await s.delete_file("./notes.txt")

SDK

Added more built-ins to the TypeScript SDK.