@subcon/e2b-cli 0.1.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 +199 -0
- package/dist/index.js +155 -0
- package/package.json +44 -0
package/README.md
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# CLI Agent: Subconscious + E2B
|
|
2
|
+
|
|
3
|
+
A developer-first autonomous agent that reasons and executes code in a secure cloud sandbox. This agent uses **Subconscious** for long-horizon reasoning and **E2B** for isolated code execution.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
┌─┐┬ ┬┌┐ ┌─┐┌─┐┌┐┌┌─┐┌─┐┬┌─┐┬ ┬┌─┐
|
|
7
|
+
└─┐│ │├┴┐│ │ ││││└─┐│ ││ ││ │└─┐
|
|
8
|
+
└─┘└─┘└─┘└─┘└─┘┘└┘└─┘└─┘┴└─┘└─┘└─┘ + E2B Sandbox
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## What it does
|
|
12
|
+
|
|
13
|
+
- **Long-horizon reasoning**: Subconscious handles complex multi-step tasks with planning and self-correction
|
|
14
|
+
- **Secure execution**: All code runs in isolated E2B cloud sandboxes
|
|
15
|
+
- **File I/O**: Upload local files, download generated outputs (charts, reports, data)
|
|
16
|
+
- **Multi-language**: Python, JavaScript, TypeScript, Go, Rust, C++, Ruby, Java, Bash
|
|
17
|
+
- **Data science ready**: numpy, pandas, matplotlib pre-installed
|
|
18
|
+
- **Command history**: Arrow keys navigate previous commands
|
|
19
|
+
- **Zero-config tunneling**: Works out of the box - no external dependencies
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Install dependencies
|
|
25
|
+
bun install
|
|
26
|
+
|
|
27
|
+
# Set your API keys
|
|
28
|
+
export SUBCONSCIOUS_API_KEY=your_key_here # Get at https://subconscious.dev/platform
|
|
29
|
+
export E2B_API_KEY=your_key_here # Get at https://e2b.dev
|
|
30
|
+
|
|
31
|
+
# Run the agent
|
|
32
|
+
bun run agent
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Example Usage
|
|
36
|
+
|
|
37
|
+
### Try it with the included demo file
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
▸ Task › Analyze file: ./demo_data.csv and create a summary of hours worked per employee
|
|
41
|
+
▸ Context ›
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Simple task (no files)
|
|
45
|
+
```
|
|
46
|
+
▸ Task › Calculate the first 50 Fibonacci numbers and identify which ones are prime
|
|
47
|
+
▸ Context ›
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Generate a chart
|
|
51
|
+
```
|
|
52
|
+
▸ Task › Analyze file: ./demo_data.csv and create a bar chart of total billable hours by department. Save to output: ./chart.png
|
|
53
|
+
▸ Context › Use pandas and matplotlib
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Full analysis with multiple outputs
|
|
57
|
+
```
|
|
58
|
+
▸ Task › Analyze file: ./demo_data.csv and do the following:
|
|
59
|
+
1. Create a chart of hours by employee. Save to output: ./hours_chart.png
|
|
60
|
+
2. Write a markdown report with key insights. Save to output: ./analysis.md
|
|
61
|
+
▸ Context › Use pandas and matplotlib
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## File Handling
|
|
65
|
+
|
|
66
|
+
The agent supports file upload and download:
|
|
67
|
+
|
|
68
|
+
| Syntax | Description | Example |
|
|
69
|
+
|--------|-------------|---------|
|
|
70
|
+
| `file: ./path` | Upload a file to the sandbox | `Analyze file: ./data.csv` |
|
|
71
|
+
| `'/path/to/file'` | Quoted path (drag-and-drop) | `Analyze '/Users/me/data.csv'` |
|
|
72
|
+
| `files: ./dir/*.csv` | Upload multiple files (glob) | `Process files: ./reports/*.csv` |
|
|
73
|
+
| `output: ./path` | Download output when done | `Save chart to output: ./chart.png` |
|
|
74
|
+
|
|
75
|
+
> **Tip**: You can drag and drop files into the terminal and the quoted path will be automatically recognized and uploaded to the sandbox.
|
|
76
|
+
|
|
77
|
+
**Supported output formats:**
|
|
78
|
+
|
|
79
|
+
- Images: `.png`, `.jpg`, `.gif`, `.webp`, `.svg`
|
|
80
|
+
- Documents: `.md`, `.txt`, `.html`, `.pdf`
|
|
81
|
+
- Data: `.json`, `.csv`, `.xml`
|
|
82
|
+
- Archives: `.zip`, `.tar`, `.gz`
|
|
83
|
+
|
|
84
|
+
### How it works
|
|
85
|
+
|
|
86
|
+
1. Input files are uploaded to `/home/user/input/` in the sandbox
|
|
87
|
+
2. Output files are saved to `/home/user/output/` in the sandbox
|
|
88
|
+
3. When the agent completes, outputs are automatically downloaded to your specified local paths
|
|
89
|
+
|
|
90
|
+
## Supported Languages
|
|
91
|
+
|
|
92
|
+
| Language | Runtime | Notes |
|
|
93
|
+
|----------|---------|-------|
|
|
94
|
+
| Python | `python3` | numpy, pandas, matplotlib pre-installed |
|
|
95
|
+
| JavaScript | `node` | Node.js runtime |
|
|
96
|
+
| TypeScript | `ts-node` | Via npx |
|
|
97
|
+
| Bash | `bash` | Shell scripts |
|
|
98
|
+
| Go | `go run` | Single file execution |
|
|
99
|
+
| Rust | `rustc` | Compiled before execution |
|
|
100
|
+
| C++ | `g++` | Compiled with -O2 |
|
|
101
|
+
| C | `gcc` | Compiled with -O2 |
|
|
102
|
+
| Ruby | `ruby` | Standard runtime |
|
|
103
|
+
| Java | `javac` + `java` | Compiled and run |
|
|
104
|
+
|
|
105
|
+
## Architecture
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
109
|
+
│ CLI Agent │
|
|
110
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
111
|
+
│ User Input -> File Parser -> Subconscious API -> Display │
|
|
112
|
+
│ | | │
|
|
113
|
+
│ Upload Files Stream Reasoning │
|
|
114
|
+
│ | | │
|
|
115
|
+
│ E2B Sandbox <--- Tool Calls (execute_code) │
|
|
116
|
+
│ | │
|
|
117
|
+
│ Download Outputs -> Local Filesystem │
|
|
118
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Source Structure
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
src/
|
|
125
|
+
cli/
|
|
126
|
+
run.ts # Interactive CLI with command history
|
|
127
|
+
fileParser.ts # Parses file:/output: references
|
|
128
|
+
e2b/
|
|
129
|
+
sandbox.ts # E2B sandbox wrapper with multi-language support
|
|
130
|
+
tools/
|
|
131
|
+
e2bServer.ts # HTTP server exposing execute_code tool
|
|
132
|
+
tunnel.ts # Tunnel management (localtunnel)
|
|
133
|
+
types/
|
|
134
|
+
agent.ts # TypeScript definitions
|
|
135
|
+
config.ts # Configuration loading
|
|
136
|
+
index.ts # Entry point
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Configuration
|
|
140
|
+
|
|
141
|
+
### Environment Variables
|
|
142
|
+
|
|
143
|
+
| Variable | Required | Description |
|
|
144
|
+
|----------|----------|-------------|
|
|
145
|
+
| `SUBCONSCIOUS_API_KEY` | Yes | Your Subconscious API key |
|
|
146
|
+
| `E2B_API_KEY` | Yes | Your E2B API key |
|
|
147
|
+
| `TUNNEL_URL` | No | Use existing tunnel instead of auto-start |
|
|
148
|
+
| `VERBOSE` | No | Enable verbose logging (`true`/`false`) |
|
|
149
|
+
|
|
150
|
+
### Config file (optional)
|
|
151
|
+
|
|
152
|
+
Create `agent.config.json` to customize:
|
|
153
|
+
|
|
154
|
+
```json
|
|
155
|
+
{
|
|
156
|
+
"tunnel": {
|
|
157
|
+
"enabled": true,
|
|
158
|
+
"autoStart": true,
|
|
159
|
+
"port": 3001
|
|
160
|
+
},
|
|
161
|
+
"tools": {
|
|
162
|
+
"port": 3001,
|
|
163
|
+
"host": "localhost"
|
|
164
|
+
},
|
|
165
|
+
"environment": {
|
|
166
|
+
"filterSensitive": true,
|
|
167
|
+
"sensitivePatterns": ["KEY", "SECRET", "TOKEN", "PASSWORD"]
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Troubleshooting
|
|
173
|
+
|
|
174
|
+
### Tunnel not starting
|
|
175
|
+
|
|
176
|
+
The agent uses `localtunnel` which is installed automatically with `bun install`. If you're having issues:
|
|
177
|
+
|
|
178
|
+
1. **Check your network** - localtunnel requires outbound internet access
|
|
179
|
+
2. **Use an existing tunnel** - Set `TUNNEL_URL` environment variable to bypass auto-start
|
|
180
|
+
|
|
181
|
+
### Output files not appearing
|
|
182
|
+
|
|
183
|
+
1. Make sure you use the `output:` prefix in your task
|
|
184
|
+
2. Check that the agent says `[file] Downloaded:` at the end
|
|
185
|
+
3. Verify the path is accessible (not a protected system directory)
|
|
186
|
+
|
|
187
|
+
### Sandbox timeout or slow startup
|
|
188
|
+
|
|
189
|
+
The first run may take 30-60 seconds as E2B provisions the sandbox and installs packages. Subsequent runs are faster.
|
|
190
|
+
|
|
191
|
+
## Links
|
|
192
|
+
|
|
193
|
+
- [Subconscious](https://subconscious.dev) - Long-horizon AI reasoning
|
|
194
|
+
- [E2B](https://e2b.dev) - Secure code sandboxes
|
|
195
|
+
- [localtunnel](https://github.com/localtunnel/localtunnel) - Tunnel service
|
|
196
|
+
|
|
197
|
+
## License
|
|
198
|
+
|
|
199
|
+
Apache-2.0
|