@haystackeditor/cli 0.10.1 → 0.10.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.
@@ -1,243 +0,0 @@
1
- # External Sandbox Setup
2
-
3
- **Your job**: Help the user connect Haystack to their existing sandbox infrastructure instead of using Haystack's built-in sandboxes.
4
-
5
- ---
6
-
7
- ## When to Use This
8
-
9
- External sandboxes are for users who:
10
- - Have their own background agent (e.g., custom AI coding agent)
11
- - Already spin up development environments (e.g., Codespaces, Gitpod, custom VMs)
12
- - Want Haystack's review UI (browser, editor, terminal) to connect to THEIR sandbox
13
-
14
- If the user doesn't have their own sandbox infrastructure, they should use Haystack's built-in sandboxes instead.
15
-
16
- ---
17
-
18
- ## Step 1: Understand Their Setup
19
-
20
- **Ask the user:**
21
-
22
- > Do you have your own background agent or sandbox infrastructure?
23
- >
24
- > Haystack can connect to your existing sandbox instead of spinning up its own. This is useful if:
25
- > - You have a custom AI agent that makes code changes
26
- > - You use Codespaces, Gitpod, or similar cloud dev environments
27
- > - You want to share a single sandbox between your agent and Haystack's review UI
28
- >
29
- > **How does your sandbox provide access?**
30
- >
31
- > 1. **HTTP API** - Your sandbox exposes an endpoint that returns URLs (recommended)
32
- > 2. **Webhook push** - Your agent calls Haystack when the sandbox is ready
33
- > 3. **Neither yet** - I need help designing the integration
34
-
35
- **Wait for the user's response before continuing.**
36
-
37
- ---
38
-
39
- ## Step 2: Configure Based on Response
40
-
41
- ### Option 1: HTTP API (Pull)
42
-
43
- The user's sandbox exposes an endpoint that Haystack queries.
44
-
45
- **Their endpoint must return:**
46
-
47
- ```json
48
- {
49
- "devUrl": "https://sandbox.example.com:3000", // Browser preview
50
- "opencodeUrl": "https://sandbox.example.com:8080", // Code editor (OpenCode)
51
- "terminalUrl": "https://sandbox.example.com/term", // Web terminal
52
- "status": "ready" // "starting" | "ready" | "stopped" | "error"
53
- }
54
- ```
55
-
56
- **Query parameters Haystack sends:**
57
-
58
- | Param | Description |
59
- |-------|-------------|
60
- | `session_id` | Haystack session ID |
61
- | `repo` | Repository name (e.g., `owner/repo`) |
62
- | `branch` | Branch name |
63
- | `pr_number` | PR number (if applicable) |
64
-
65
- **Add to `.haystack.json`:**
66
-
67
- ```json
68
- {
69
- "sandbox": {
70
- "external": {
71
- "pullEndpoint": "https://your-api.example.com/sandbox",
72
- "authHeader": "X-API-Key"
73
- }
74
- }
75
- }
76
- ```
77
-
78
- If they need authentication, tell them:
79
- > Add your API key as a Haystack secret:
80
- > ```bash
81
- > npx @haystackeditor/cli secrets set SANDBOX_API_KEY "your-key"
82
- > ```
83
- > Then reference it in the config:
84
- > ```json
85
- > {
86
- > "sandbox": {
87
- > "external": {
88
- > "pullEndpoint": "https://your-api.example.com/sandbox",
89
- > "authHeader": "X-API-Key",
90
- > "authValue": "$SANDBOX_API_KEY"
91
- > }
92
- > }
93
- > }
94
- > ```
95
-
96
- ---
97
-
98
- ### Option 2: Webhook Push
99
-
100
- The user's agent calls Haystack when the sandbox is ready.
101
-
102
- **Webhook endpoint:**
103
-
104
- ```
105
- POST https://haystack-agent.akshaysg.workers.dev/sessions/{session_id}/external-sandbox
106
- ```
107
-
108
- **Request body:**
109
-
110
- ```json
111
- {
112
- "devUrl": "https://sandbox.example.com:3000",
113
- "opencodeUrl": "https://sandbox.example.com:8080",
114
- "terminalUrl": "https://sandbox.example.com/term",
115
- "status": "ready"
116
- }
117
- ```
118
-
119
- **Add to `.haystack.json`:**
120
-
121
- ```json
122
- {
123
- "sandbox": {
124
- "external": {
125
- "mode": "push"
126
- }
127
- }
128
- }
129
- ```
130
-
131
- **Tell the user:**
132
- > Your agent needs to POST to Haystack when the sandbox is ready.
133
- >
134
- > **Webhook URL pattern:**
135
- > ```
136
- > https://haystack-agent.akshaysg.workers.dev/sessions/{SESSION_ID}/external-sandbox
137
- > ```
138
- >
139
- > The `SESSION_ID` is passed to your agent when Haystack requests a sandbox.
140
- > Your agent should call this endpoint with the sandbox URLs when ready.
141
-
142
- ---
143
-
144
- ### Option 3: Neither (Help Design)
145
-
146
- If they don't have an existing API, help them add one.
147
-
148
- **Questions to ask:**
149
-
150
- 1. What language/framework is your agent built with?
151
- 2. Where does your agent store sandbox URLs? (DB, memory, file)
152
- 3. How does your sandbox expose services? (tunnels, direct ports, custom domain)
153
-
154
- **Provide a minimal implementation example based on their stack:**
155
-
156
- **Node.js/Express:**
157
- ```javascript
158
- app.get('/sandbox', (req, res) => {
159
- const { session_id, repo, branch, pr_number } = req.query;
160
-
161
- // Look up or create sandbox for this session
162
- const sandbox = getSandboxFor(session_id, repo, branch);
163
-
164
- res.json({
165
- devUrl: sandbox.devServerUrl,
166
- opencodeUrl: sandbox.editorUrl,
167
- terminalUrl: sandbox.terminalUrl,
168
- status: sandbox.status // "starting" | "ready" | "stopped" | "error"
169
- });
170
- });
171
- ```
172
-
173
- **Python/FastAPI:**
174
- ```python
175
- @app.get("/sandbox")
176
- async def get_sandbox(
177
- session_id: str,
178
- repo: str,
179
- branch: str,
180
- pr_number: Optional[int] = None
181
- ):
182
- sandbox = await get_or_create_sandbox(session_id, repo, branch)
183
- return {
184
- "devUrl": sandbox.dev_server_url,
185
- "opencodeUrl": sandbox.editor_url,
186
- "terminalUrl": sandbox.terminal_url,
187
- "status": sandbox.status
188
- }
189
- ```
190
-
191
- ---
192
-
193
- ## Step 3: Verify the Configuration
194
-
195
- After adding the config to `.haystack.json`, verify it works:
196
-
197
- ```bash
198
- # If using pull mode, test the endpoint directly
199
- curl "https://your-api.example.com/sandbox?session_id=test&repo=owner/repo&branch=main"
200
-
201
- # Should return:
202
- # {"devUrl": "...", "opencodeUrl": "...", "terminalUrl": "...", "status": "ready"}
203
- ```
204
-
205
- ---
206
-
207
- ## Step 4: Commit
208
-
209
- ```bash
210
- git add .haystack.json
211
- git commit -m "Configure external sandbox integration"
212
- ```
213
-
214
- Done! Haystack will now use your sandbox infrastructure instead of its built-in sandboxes.
215
-
216
- ---
217
-
218
- ## URL Requirements
219
-
220
- Your sandbox URLs must be:
221
-
222
- | URL | Purpose | Requirements |
223
- |-----|---------|--------------|
224
- | `devUrl` | Browser preview | HTTPS, iframe-embeddable, serves your dev server |
225
- | `opencodeUrl` | Code editor | HTTPS, serves OpenCode web UI on port 8080 |
226
- | `terminalUrl` | Web terminal | HTTPS, WebSocket-capable, ttyd or xterm.js |
227
-
228
- **Common Issues:**
229
-
230
- - **CORS**: Your sandbox must allow requests from `https://haystackeditor.com`
231
- - **X-Frame-Options**: Set to `ALLOWALL` or `ALLOW-FROM https://haystackeditor.com`
232
- - **Mixed content**: All URLs must be HTTPS (no HTTP)
233
-
234
- ---
235
-
236
- ## Debugging
237
-
238
- If the integration isn't working:
239
-
240
- 1. **Check the endpoint returns valid JSON** with all required fields
241
- 2. **Check status** - must be one of: `starting`, `ready`, `stopped`, `error`
242
- 3. **Check URLs are accessible** - Haystack can't access localhost or private IPs
243
- 4. **Check CORS headers** - your sandbox must allow cross-origin requests