@capsule-run/cli 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +22 -2
  2. package/package.json +5 -5
package/README.md CHANGED
@@ -42,7 +42,6 @@ Run it:
42
42
  capsule run hello.ts
43
43
  ```
44
44
 
45
- > [!TIP]
46
45
  > Use `--verbose` to display real-time task execution details.
47
46
 
48
47
  ## How It Works
@@ -71,7 +70,6 @@ export const main = task({
71
70
  });
72
71
  ```
73
72
 
74
- > [!NOTE]
75
73
  > The runtime requires a task named `"main"` as the entry point.
76
74
 
77
75
  When you run `capsule run main.ts`, your code is compiled into a WebAssembly module and executed in a dedicated sandbox.
@@ -115,6 +113,7 @@ Every task returns a structured JSON envelope containing both the result and exe
115
113
  | `timeout` | Maximum execution time | `string` or `number` | unlimited | `"30s"`, `"5m"`, `30000` (ms) |
116
114
  | `maxRetries` | Retry attempts on failure | `number` | `0` | `3` |
117
115
  | `allowedFiles` | Folders accessible in the sandbox | `string[]` | `[]` | `["./data", "./output"]` |
116
+ | `envVariables` | Environment variables accessible in the sandbox | `string[]` | `[]` | `["API_KEY"]` |
118
117
 
119
118
  ### Compute Levels
120
119
 
@@ -171,6 +170,27 @@ Available methods:
171
170
  - `files.list(path)` — List directory contents
172
171
  - `files.exists(path)` — Check if file exists
173
172
 
173
+ ### Environment Variables
174
+
175
+ Tasks can access environment variables to read configuration, API keys, or other runtime settings. Use the `env` API provided by the SDK:
176
+
177
+ ```typescript
178
+ import { task, env } from "@capsule-run/sdk";
179
+
180
+ export const main = task({
181
+ name: "main",
182
+ envVariables: ["API_KEY"]
183
+ }, () => {
184
+ const apiKey = env.get("API_KEY");
185
+ return { apiKeySet: apiKey !== undefined };
186
+ });
187
+ ```
188
+
189
+ Available methods:
190
+ - `env.get(key)` — Get a specific environment variable (returns `undefined` if not found)
191
+ - `env.has(key)` — Check if an environment variable exists
192
+ - `env.getAll()` — Get all environment variables as an object
193
+
174
194
  ## Compatibility
175
195
 
176
196
  ✅ **Supported:**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capsule-run/cli",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Secure WASM runtime to isolate and manage AI agent tasks",
5
5
  "bin": {
6
6
  "capsule": "./bin/capsule.js"
@@ -29,9 +29,9 @@
29
29
  "node": ">=18"
30
30
  },
31
31
  "optionalDependencies": {
32
- "@capsule-run/cli-darwin-arm64": "0.4.1",
33
- "@capsule-run/cli-darwin-x64": "0.4.1",
34
- "@capsule-run/cli-linux-x64": "0.4.1",
35
- "@capsule-run/cli-win32-x64": "0.4.1"
32
+ "@capsule-run/cli-darwin-arm64": "0.4.2",
33
+ "@capsule-run/cli-darwin-x64": "0.4.2",
34
+ "@capsule-run/cli-linux-x64": "0.4.2",
35
+ "@capsule-run/cli-win32-x64": "0.4.2"
36
36
  }
37
37
  }