Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Getting code into a sandbox and results out: files, folders and change lists

Starting a sandbox is the easy part. The first real question in any agent integration is how to get the code in, and how to get the result out. Copying a repository one file at a time is slow and fiddly. Copying it all, including .env and node_modules , is wasteful and sometimes dangerous. And at the end you usually want one thing: which files did the agent change? Sandscale's API has a tool for…

Starting a sandbox is straightforward. The primary challenge lies in getting the code into the sandbox and retrieving the results. Simply copying a repository file by file is inefficient and potentially risky. The entire repository, including .env and node_modules, is unnecessary and can be unsafe. The Sandscale API provides tools for these tasks.

This article explains each step using the TypeScript SDK, curl, and the Sandboxes API reference. For single files, such as a script or configuration file, write them directly in REST with base64-encoded content. The SDK handles encoding and accepts strings or bytes. For a complete folder, send everything in a single gzip tar archive via POST /instances/{id}/project.

The server responds with details about the unpack process, including skipped files and reasons. To retrieve results, GET /instances/{id}/files?path=... reads a single file, or lists a directory if the path is a directory. The SDK's listFiles returns entries with path, name, isDir, and size, while readFile returns the bytes. To determine which files changed, use GET /instances/{id}/project/changes after the agent has finished.

This returns the files changed since the project was uploaded. After reading the changed files, stop the sandbox.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

Parsing Telegram Trading Signals: The Edge Cases That Break Copiers

If you have ever tried to turn Telegram trading signals into orders, you know the first version takes an evening. A regex finds BUY or SELL, a symbol, an entry, a stop loss and a take profit.

  • Telegram trading signals can be complex due to edge cases like multiple take profit levels
  • Comprehensive log in TPcopier provides transparency and helps resolve trade discrepancies

More from Monday 23 November →