@@ -106,7 +106,7 @@ agentkit sandbox get
106106
107107Options:
108108
109- - ` --session-id ` : optional. Sandbox session ID to look up. If omitted, the CLI
109+ - ` --session-id ` / ` --sid ` : optional. Sandbox session ID to look up. If omitted, the CLI
110110 returns all records from ` .agentkit/sandbox/sessions.json ` after syncing the
111111 current tool.
112112- ` --tool-id ` : optional. Defaults to ` AGENTKIT_SANDBOX_TOOL_ID ` . If neither is
@@ -134,6 +134,123 @@ command exits with status `1` and returns structured JSON:
134134}
135135```
136136
137+ ### File
138+
139+ Upload, download, and list files in an existing sandbox session. File commands
140+ only operate on existing sessions; they do not create a session when
141+ ` --session-id ` is missing.
142+
143+ Common options:
144+
145+ - ` --session-id ` / ` --sid ` : required. Sandbox session ID to operate on.
146+ - ` --tool-id ` : optional. Defaults to ` AGENTKIT_SANDBOX_TOOL_ID ` . If neither is
147+ set, the CLI resolves an existing tool by ` --tool-type ` .
148+ - ` --tool-type ` : optional. ` CodeEnv ` or ` SkillEnv ` ; defaults to ` CodeEnv ` .
149+ - ` --workspace ` : optional absolute sandbox path used as the root for relative
150+ sandbox paths.
151+
152+ Path rules:
153+
154+ - Local paths are normal local filesystem paths.
155+ - Sandbox paths may be absolute, or relative to ` --workspace ` .
156+ - Relative sandbox paths require ` --workspace ` .
157+ - Absolute sandbox paths must stay inside ` --workspace ` when both are provided.
158+
159+ #### Upload
160+
161+ Upload local files:
162+
163+ ``` bash
164+ agentkit sandbox file upload \
165+ --session-id 123456789 \
166+ --dst-dir /tmp/files \
167+ ./a.txt ./b.txt
168+ ```
169+
170+ Upload a local directory:
171+
172+ ``` bash
173+ agentkit sandbox file upload \
174+ --session-id 123456789 \
175+ --workspace /home/gem \
176+ --src-dir ./project \
177+ --dst-dir uploads/project
178+ ```
179+
180+ Upload options:
181+
182+ - ` FILE... ` : local regular files to upload.
183+ - ` --src-dir ` : local directory to upload recursively. Uploads the directory
184+ contents; it does not add the directory name as a top-level path.
185+ - ` --dst-dir ` : required sandbox destination directory. Created if missing.
186+
187+ Use exactly one source form: ` FILE... ` or ` --src-dir ` . Multiple ` FILE ` values
188+ must not share the same base name because they are extracted into ` --dst-dir ` .
189+
190+ #### Download
191+
192+ Download sandbox files:
193+
194+ ``` bash
195+ agentkit sandbox file download \
196+ --session-id 123456789 \
197+ --workspace /home/gem \
198+ --dst-dir ./downloads \
199+ uploads/a.txt uploads/b.txt
200+ ```
201+
202+ Download a sandbox directory:
203+
204+ ``` bash
205+ agentkit sandbox file download \
206+ --session-id 123456789 \
207+ --src-dir /tmp/project \
208+ --dst-dir ./project-copy
209+ ```
210+
211+ Download options:
212+
213+ - ` FILE... ` : sandbox regular files to download.
214+ - ` --src-dir ` : sandbox directory to download recursively. Downloads the
215+ directory contents; it does not add the directory name as a top-level path.
216+ - ` --dst-dir ` : required local directory. Created if missing.
217+ - ` --overwrite ` : overwrite existing local files while extracting.
218+
219+ Use exactly one source form: ` FILE... ` or ` --src-dir ` . Multiple ` FILE ` values
220+ must not share the same base name because they are extracted into ` --dst-dir ` .
221+ Downloaded archive members must be relative regular files or directories; links,
222+ absolute paths, and ` .. ` traversal are rejected.
223+
224+ #### List
225+
226+ List a sandbox path:
227+
228+ ``` bash
229+ agentkit sandbox file list \
230+ --session-id 123456789 \
231+ /tmp/project
232+ ```
233+
234+ List arguments and options:
235+
236+ - ` PATH ` : required sandbox path to list. Relative paths require ` --workspace ` .
237+ - ` --recursive/--no-recursive ` : list recursively. Defaults to no recursive.
238+ - ` --show-hidden/--hide-hidden ` : include hidden files. Defaults to hide hidden.
239+ - ` --max-depth ` : maximum recursive listing depth. Must be non-negative.
240+ - ` --include-size/--no-include-size ` : include file size metadata; defaults to
241+ include size.
242+ - ` --include-permissions ` : include file permission metadata.
243+ - ` --sort-by ` : ` name ` , ` size ` , ` modified ` , or ` type ` ; defaults to ` name ` .
244+ - ` --sort-desc ` : sort in descending order.
245+
246+ Implementation notes:
247+
248+ - Uploads and downloads use temporary tar archives so directories and multiple
249+ files are transferred through the sandbox file API as a single payload.
250+ - Remote temporary archives are cleaned up after download. Cleanup is
251+ best-effort: if cleanup fails, the CLI prints a warning and preserves the
252+ original download or extraction result.
253+
137254### Shell
138255
139256Execute a command in a sandbox shell.
@@ -143,11 +260,17 @@ agentkit sandbox shell \
143260 --session-id 123456789 \
144261 --command ' echo $TEST_VAR' \
145262 --shell-id shell-example
263+
264+ agentkit sandbox shell \
265+ --session-id 123456789 \
266+ --command ' ls -la /home/gem/project' \
267+ --src-dir ./README.md ./requirements.txt \
268+ --dst-dir project
146269```
147270
148271Options:
149272
150- - ` --session-id ` : optional. Sandbox session ID used as the local session key.
273+ - ` --session-id ` / ` --sid ` : optional. Sandbox session ID used as the local session key.
151274 If omitted, a UUID is generated and the command creates a sandbox session
152275 through the same idempotent session ensure flow as ` sandbox exec ` .
153276- ` --tool-id ` : optional. Defaults to ` AGENTKIT_SANDBOX_TOOL_ID ` . If neither is
@@ -158,6 +281,13 @@ Options:
158281- ` --command ` : required. Command to execute in the sandbox.
159282- ` --exec-dir ` : optional execution directory.
160283- ` --shell-id ` : optional shell terminal ID for re-entering an existing shell.
284+ - ` --workspace ` : optional sandbox workspace root; defaults to ` /home/gem ` .
285+ - ` --src-dir ` : optional local file or directory to upload before executing the
286+ shell command. Additional file or directory paths can follow this option,
287+ separated by spaces.
288+ - ` --dst-dir ` : optional sandbox destination directory for ` --src-dir ` . This is
289+ a relative path appended under ` --workspace ` ; when omitted, sources are
290+ uploaded into ` --workspace ` .
161291
162292The command posts to ` <endpoint>/v1/shell/exec ` with:
163293
@@ -172,18 +302,56 @@ The command posts to `<endpoint>/v1/shell/exec` with:
172302The response is returned as JSON. If the service returns ` data.session_id ` , the
173303CLI renames it to ` data.shell_id ` .
174304
305+ When ` --src-dir ` is provided, ` shell ` uses the same upload flow as
306+ ` sandbox exec ` : archive local sources, upload the archive to the session,
307+ extract it under ` --workspace ` plus ` --dst-dir ` , then execute ` --command ` .
308+
309+ ### Web
310+
311+ Return a browser URL for a sandbox session.
312+
313+ ``` bash
314+ agentkit sandbox web --session-id 123456789
315+ agentkit sandbox web --session-id 123456789 --tool-id t-example
316+ ```
317+
318+ Options:
319+
320+ - ` --session-id ` / ` --sid ` : required. Sandbox session ID to open in a browser.
321+ - ` --tool-id ` : optional. Defaults to ` AGENTKIT_SANDBOX_TOOL_ID ` . The
322+ underscore alias ` --tool_id ` is also accepted.
323+
324+ The command resolves the tool using the same existing-tool resolution flow as
325+ the other session-scoped sandbox commands, syncs remote sessions for that tool,
326+ then reads the session endpoint and appends ` /vnc/index.html ` with fixed
327+ browser parameters: ` autoconnect=true ` , ` resize=scale ` , and ` reconnect=1 ` .
328+ When the endpoint includes ` faasInstanceName ` and ` Authorization ` , the command
329+ also derives the VNC ` path ` query parameter from those values. The URL is opened
330+ with the system default browser, and the response is JSON:
331+
332+ ``` json
333+ {
334+ "url" : " https://example.com/vnc/index.html?autoconnect=true&resize=scale&reconnect=1&faasInstanceName=vefaas-example&Authorization=...&path=websockify%3FfaasInstanceName%3Dvefaas-example%26Authorization%3D..." ,
335+ "tool_id" : " t-example" ,
336+ "session_id" : " 123456789"
337+ }
338+ ```
339+
175340### Exec
176341
177342Open a streaming WebSocket exec session to the sandbox. By default, this connects
178343without running an initial command.
179344
180345``` bash
181346agentkit sandbox exec --session-id 123456789
347+ agentkit sandbox exec --session-id 123456789 --src-dir ./workspace
348+ agentkit sandbox exec --session-id 123456789 --src-dir ./main.py --dst-dir project
349+ agentkit sandbox exec --session-id 123456789 --src-dir ./README.md ./requirements.txt --dst-dir tmp
182350```
183351
184352Options:
185353
186- - ` --session-id ` : optional. Sandbox session ID used as the local
354+ - ` --session-id ` / ` --sid ` : optional. Sandbox session ID used as the local
187355 session key. If omitted, a UUID is generated and the command creates a
188356 sandbox session through the same idempotent session ensure flow.
189357- ` --tool-id ` : optional. Defaults to ` AGENTKIT_SANDBOX_TOOL_ID ` . If neither is
@@ -196,6 +364,13 @@ Options:
196364 ` --command codex ` to start the remote Codex TUI.
197365- ` --shell-id ` : optional. Existing shell terminal ID to connect to. When this is
198366 set and ` --command ` is omitted, no initial command is sent.
367+ - ` --workspace ` : optional sandbox workspace root; defaults to ` /home/gem ` .
368+ - ` --src-dir ` : optional local file or directory to upload before opening the
369+ exec session. Additional file or directory paths can follow this option,
370+ separated by spaces.
371+ - ` --dst-dir ` : optional sandbox destination directory for ` --src-dir ` . This is
372+ a relative path appended under ` --workspace ` ; when omitted, sources are
373+ uploaded into ` --workspace ` .
199374- ` --model-name ` : optional. When creating a sandbox session, injects the value
200375 as ` OPENCODE_MODEL ` , ` CODEX_MODEL ` , and ` ANTHROPIC_MODEL ` .
201376- ` --model-api-key ` : optional. When creating a sandbox session, injects the
@@ -206,6 +381,12 @@ The command connects to `<endpoint>/v1/shell/ws`, streams remote output to local
206381stdout, forwards local stdin as terminal input, sends terminal resize events, and
207382responds to WebSocket ` ping ` messages with ` pong ` .
208383
384+ When ` --src-dir ` is provided, the command first reuses the sandbox file upload
385+ flow to archive the local file or directory, upload it to the session, and
386+ extract it into the directory resolved from ` --workspace ` and ` --dst-dir ` . The
387+ WebSocket exec connection is opened only after the upload and extraction
388+ complete.
389+
209390When the remote terminal returns a shell session ID, the CLI prints it and
210391stores it in the ` terminal_shell_id ` list in ` .agentkit/sandbox/sessions.json `
211392while the connection is active. Multiple live WebSocket connections under the
@@ -251,6 +432,11 @@ When `--tool-id` and `AGENTKIT_SANDBOX_TOOL_ID` are both omitted,
251432
252433Cached and listed tools are reused only when their status is ` Ready ` ; tools in
253434states such as ` Creating ` , ` Error ` , ` Deleting ` , or ` Deleted ` are ignored.
435+ When a tool ID is provided explicitly, read from ` AGENTKIT_SANDBOX_TOOL_ID ` ,
436+ reused from an existing session record, or loaded from
437+ ` .agentkit/sandbox/tools.json ` , the CLI calls ` GetTool ` before using it. If the
438+ tool does not exist or its current status is not ` Ready ` , the command exits
439+ with that error instead of creating a session against an unusable tool.
254440
255441Resolved tool records are stored in:
256442
@@ -279,7 +465,7 @@ Example:
279465
280466## Module Layout
281467
282- - ` cli.py ` : registers the ` create ` , ` get ` , ` exec ` , and ` shell ` sandbox subcommands.
468+ - ` cli.py ` : registers the ` create ` , ` get ` , ` exec ` , ` shell ` , and ` file ` sandbox subcommands.
283469- ` ../cli.py ` : registers the ` sandbox ` command group.
284470- ` session_create.py ` : shared session creation and idempotent ensure helpers.
285471- ` session_sync.py ` : shared remote session list/sync helpers.
@@ -288,4 +474,5 @@ Example:
288474- ` cli_get.py ` : get command implementation.
289475- ` cli_shell.py ` : shell command implementation.
290476- ` cli_exec.py ` : streaming exec command implementation.
477+ - ` cli_file.py ` : file upload, download, and list command implementation.
291478- ` utils.py ` : shared store, URL, JSON, and error helpers.
0 commit comments