Commit b33340f
authored
fix(sandbox): use Daytona code execution API (#175)
## Why
Production research PDF generation still returned `Sandbox returned
invalid artifact metadata` after moving binary output out of stdout.
Live sandbox diagnostics showed the deeper cause: the document renderer
never executed. The custom `runCode` transport base64-encoded source
into environment chunks and reconstructed it through a shell pipeline,
but Daytona process execution did not inject those chunks, so Node
received an empty program and exited successfully with no output.
## What changed
- replace the custom base64/environment/shell reconstruction with
Daytona`s native `/process/code-run` API
- map command and code environment variables to Daytona`s documented
`envs` wire field
- preserve cwd explicitly for JavaScript and Python code execution
- preserve Python module semantics by compiling the original source
after changing cwd
- retain bounded input validation, timeout behavior, audit records,
usage metering, and provider error mapping
- remove the chunking constants and transport helpers entirely
- document the native code-execution boundary
## Architecture / migration effects
- No database or migration changes
- No new dependency or deployment configuration
- Generated code is now sent as code over Daytona`s dedicated API
instead of being disguised as shell environment data
## Verification
- `pnpm lint`
- `pnpm typecheck`
- `pnpm turbo build --force`
- `pnpm deadcode` (passes; four existing Knip configuration hints
remain)
- `pnpm architecture:check`
- `pnpm turbo skills:build`
- Live Daytona: 90,126-character JavaScript program executed with env
and cwd intact
- Live Daytona: Python executed with env, cwd, and `from __future__`
semantics intact
- Live Daytona: full Markdown PDF renderer returned the artifact marker
and created a valid 7,143-byte PDF file
Local verification used Node 26.4.0 while the repository pins Node
24.18.0; pnpm emitted the existing engine warning, and all checks
passed.1 parent 5a8bc61 commit b33340f
3 files changed
Lines changed: 71 additions & 34 deletions
File tree
- apps/agent-worker/src/durable-objects
- packages/agent-core
- src/tools/code
Lines changed: 45 additions & 32 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
| |||
56 | 55 | | |
57 | 56 | | |
58 | 57 | | |
59 | | - | |
60 | | - | |
61 | 58 | | |
62 | 59 | | |
63 | 60 | | |
| |||
149 | 146 | | |
150 | 147 | | |
151 | 148 | | |
152 | | - | |
153 | | - | |
154 | | - | |
| 149 | + | |
| 150 | + | |
155 | 151 | | |
156 | | - | |
| 152 | + | |
| 153 | + | |
157 | 154 | | |
158 | 155 | | |
159 | 156 | | |
| |||
164 | 161 | | |
165 | 162 | | |
166 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
167 | 196 | | |
168 | 197 | | |
169 | 198 | | |
| |||
211 | 240 | | |
212 | 241 | | |
213 | 242 | | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
238 | 251 | | |
239 | | - | |
| 252 | + | |
240 | 253 | | |
241 | 254 | | |
242 | 255 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
202 | 210 | | |
203 | 211 | | |
204 | 212 | | |
| |||
360 | 368 | | |
361 | 369 | | |
362 | 370 | | |
363 | | - | |
| 371 | + | |
364 | 372 | | |
365 | 373 | | |
366 | 374 | | |
| |||
369 | 377 | | |
370 | 378 | | |
371 | 379 | | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
372 | 394 | | |
373 | 395 | | |
374 | 396 | | |
| |||
0 commit comments