Skip to content

Feature/v0.4.2/environment variables - #53

Merged
mavdol merged 19 commits into
mainfrom
feature/v0.4.2/environment-variables
Jan 26, 2026
Merged

mavdol merged 19 commits into
mainfrom
feature/v0.4.2/environment-variables

Conversation

@mavdol

@mavdol mavdol commented Jan 25, 2026

Copy link
Copy Markdown
Member

Environment variables

This PR introduces improvements to the developer experience:

1. Environment variables option

We now have an environment variable option env_variables. By default, sandboxes don't have access to your .env file. With this option, you can select variables from your .env and make them available inside your sandbox.

from capsule import task
import os

@task(name="main", env_variables=["API_KEY"])
def main() -> dict:
    api_key = os.environ.get("API_KEY")
    return {"api_key": api_key}

2. env API for TypeScript

fs isn't available in the sandbox for TypeScript. So we provide an env API to read environment variables declared in the options.

import { task, env } from "@capsule-run/sdk";

export const main = task({
    name: "main",
    envVariables: ["API_KEY"]
}, () => {
    const apiKey = env.get("API_KEY");
    return { apiKeySet: apiKey !== undefined, environment };
});

Available methods:

  • env.get(key) — Get a specific environment variable (returns undefined if not found)
  • env.has(key) — Check if an environment variable exists
  • env.getAll() — Get all environment variables as an object

@mavdol
mavdol merged commit 9d1be2a into main Jan 26, 2026
2 checks passed
@mavdol
mavdol deleted the feature/v0.4.2/environment-variables branch January 26, 2026 13:56
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