@capsule-run/cli 0.2.2 → 0.3.0
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.
- package/README.md +38 -11
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -75,13 +75,14 @@ When you run `capsule run main.ts`, your code is compiled into a WebAssembly mod
|
|
|
75
75
|
|
|
76
76
|
### Task Configuration Options
|
|
77
77
|
|
|
78
|
-
| Parameter | Type |
|
|
79
|
-
|
|
80
|
-
| `name` | `string` |
|
|
81
|
-
| `compute` |
|
|
82
|
-
| `ram` | `string` |
|
|
83
|
-
| `timeout` | `string` or `number` |
|
|
84
|
-
| `maxRetries` |
|
|
78
|
+
| Parameter | Description | Type | Default | Example |
|
|
79
|
+
|-----------|-------------|------|---------|---------|
|
|
80
|
+
| `name` | Task identifier | `string` | *required* | `"process_data"` |
|
|
81
|
+
| `compute` | CPU level: `"LOW"`, `"MEDIUM"`, `"HIGH"` | `string` | `"MEDIUM"` | `"HIGH"` |
|
|
82
|
+
| `ram` | Memory limit | `string` | unlimited | `"512MB"`, `"2GB"` |
|
|
83
|
+
| `timeout` | Maximum execution time | `string` or `number` | unlimited | `"30s"`, `"5m"`, `30000` (ms) |
|
|
84
|
+
| `maxRetries` | Retry attempts on failure | `number` | `0` | `3` |
|
|
85
|
+
| `allowedFiles` | Folders accessible in the sandbox | `string[]` | `[]` | `["./data", "./output"]` |
|
|
85
86
|
|
|
86
87
|
### Compute Levels
|
|
87
88
|
|
|
@@ -90,6 +91,36 @@ When you run `capsule run main.ts`, your code is compiled into a WebAssembly mod
|
|
|
90
91
|
- **HIGH**: Maximum fuel for compute-intensive operations
|
|
91
92
|
- **CUSTOM**: Specify exact fuel value (e.g., `compute="1000000"`)
|
|
92
93
|
|
|
94
|
+
### File Access
|
|
95
|
+
|
|
96
|
+
The **entry point task** (main) has access to the entire project directory. Sub-tasks have **no filesystem access by default** and must declare `allowedFiles` to access specific paths.
|
|
97
|
+
|
|
98
|
+
Node.js built-ins like `fs` are not available in the WebAssembly sandbox. Instead, use the `files` API provided by the SDK:
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
import { task, files } from "@capsule-run/sdk";
|
|
102
|
+
|
|
103
|
+
export const restrictedWriter = task({
|
|
104
|
+
name: "restricted_writer",
|
|
105
|
+
allowedFiles: ["./output"]
|
|
106
|
+
}, async () => {
|
|
107
|
+
await files.writeText("./output/result.txt", "result");
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
export const main = task({ name: "main" }, async () => {
|
|
111
|
+
restrictedWriter();
|
|
112
|
+
return await files.readText("./data/input.txt");
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Available methods:
|
|
117
|
+
- `files.readText(path)` — Read file as string
|
|
118
|
+
- `files.readBytes(path)` — Read file as `Uint8Array`
|
|
119
|
+
- `files.writeText(path, content)` — Write string to file
|
|
120
|
+
- `files.writeBytes(path, data)` — Write bytes to file
|
|
121
|
+
- `files.list(path)` — List directory contents
|
|
122
|
+
- `files.exists(path)` — Check if file exists
|
|
123
|
+
|
|
93
124
|
## Compatibility
|
|
94
125
|
|
|
95
126
|
✅ **Supported:**
|
|
@@ -102,7 +133,3 @@ When you run `capsule run main.ts`, your code is compiled into a WebAssembly mod
|
|
|
102
133
|
|
|
103
134
|
- [GitHub](https://github.com/mavdol/capsule)
|
|
104
135
|
- [Issues](https://github.com/mavdol/capsule/issues)
|
|
105
|
-
|
|
106
|
-
## License
|
|
107
|
-
|
|
108
|
-
Apache-2.0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capsule-run/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
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.
|
|
33
|
-
"@capsule-run/cli-darwin-x64": "0.
|
|
34
|
-
"@capsule-run/cli-linux-x64": "0.
|
|
35
|
-
"@capsule-run/cli-win32-x64": "0.
|
|
32
|
+
"@capsule-run/cli-darwin-arm64": "0.3.0",
|
|
33
|
+
"@capsule-run/cli-darwin-x64": "0.3.0",
|
|
34
|
+
"@capsule-run/cli-linux-x64": "0.3.0",
|
|
35
|
+
"@capsule-run/cli-win32-x64": "0.3.0"
|
|
36
36
|
}
|
|
37
37
|
}
|