Skip to main content

Run and synchronise workspaces

Workspace transfer and repository authority are separate:
  • Workspace source is the exact local checkout or linked worktree transferred into the sandbox.
  • Repository authority is the server-verified GitHub repository against which brokered provider credentials and repository-scoped policy may be used.
You can upload and test a workspace without GitHub authorisation. Pushing a branch, creating a pull request, or using repository-scoped capabilities requires a verified repository binding.

aient sandbox run

Create a sandbox, optionally transfer a workspace or upload, run one command, and delete the sandbox:
With --environment, --workspace defaults to the current directory. With --workspace, the remote directory defaults to /workspace/repo, and the command runs there unless --workdir overrides it. Use exact argv after --:
Use --shell when shell syntax is required. Aient CLI 0.11.26 and later use Bash for --shell and --stdin; arguments after -- remain literal:
Or read the shell body from standard input:
Collect files or directories after the command with --download REMOTE=LOCAL. See downloading command results for recovery when a transfer fails.

Workspace and authority flags

Repository candidates are inferred from sanitised origin and upstream remotes when possible. Embedded remote credentials are not transmitted or displayed. If exactly one authorised repository matches, Aient binds it automatically. If none match, ordinary offload may continue without GitHub access. Use --repository when candidates are ambiguous. Changing a local remote cannot grant repository access. Every provider operation is re-authorised against the authenticated organisation, active GitHub App installation, and current repository permissions.

Run a specific commit

From Aient CLI 0.11.37, sandbox run and sandbox exec --workspace accept --workspace-commit with a full lowercase SHA-1 commit ID:
The sandbox receives that committed tree without staged, unstaged or untracked local edits. Selected submodules use the Gitlinks recorded in the commit, even when their local checkouts differ. Your local worktree stays unchanged. This mode requires /workspace/repo and cannot be combined with --include, --exclude, --reset-remote-dir or --preserve-node-modules. Use --preserve-remote-dir if you need to retain explicitly selected remote directories. If a selected submodule needs missing objects from a private HTTPS repository, initialise it with your normal Git configuration first, or configure an SSH submodule URL override. This acquisition does not use global Git credential helpers, global URL rewrites or GIT_SSH_COMMAND; a normal SSH agent works for trusted module URLs.

Git SSH trust bootstrap

By default, sandbox run selects SSH hosts only from the chosen repository’s origin, upstream, and root .gitmodules. It copies matching public records already present in the host user’s standard known_hosts files and atomically merges them into the sandbox user’s ~/.ssh/known_hosts. Existing unrelated sandbox entries are preserved. This never copies private keys, SSH configuration, an SSH agent/socket, credentials, or the complete host trust file. When github.com is selected, the sandbox user’s Git configuration also rewrites the common GitHub SSH URL forms to HTTPS, where an authorised repository-capability-bearing command can use Aient’s request-local scoped credential. Other SSH hosts receive trust only; they still need their own sandbox-available authentication. If local trust is absent or the sandbox runtime cannot install it, Aient prints a warning and continues creating the sandbox. Use --ssh-known-hosts=none when repository policy requires the image-provided trust state to remain unchanged.

Selected nested repositories

The default workspace policy rejects initialized submodules instead of silently transferring or omitting their checked-out bytes. If the command does not consume child repository content, use the explicit Gitlink-only policy:
If the command consumes a nested repository, select only that dependency:
The same flags work with sandbox sync:
Selected mode publishes one atomic /workspace/repo containing the exact root Git state and only the explicitly selected child snapshots. Every unselected Gitlink remains an empty ordinary boundary, even when its local checkout is initialized or dirty; those bytes are not transferred, preserved, or treated as implicit input. Each selected child must be an ordinary initialized repository, clean and at the exact final parent-index Gitlink OID, with complete local history and no replacement refs. To select a nested descendant, repeat --submodule for the complete ancestor closure, using canonical paths from the top-level repository. Aient does not recursively discover descendants. The first selected protocol generation accepts at most 64 selected repositories and 512 Gitlink boundaries across the selected tree. --submodule without --submodules=selected, selected mode without a path, unsafe or duplicate paths, incomplete ancestry, and a custom remote root all fail before publication. Selected mode is fixed to /workspace/repo. A retained sandbox whose reader predates selected-submodule support returns workspace_layout_selected_submodules_unavailable; recreate or upgrade it rather than retrying with a broader transfer policy.

Command and lifecycle flags

--upload PATH uploads a non-Git file or directory instead of synchronising Git state. It excludes .git and node_modules by default. Do not combine --upload and --workspace. --env and --metadata are non-secret inputs. Metadata is ordinary control-plane state: never put tokens, credentials, or sensitive values in it. It cannot override server-owned organisation, actor, environment, or repository identity. Environment and GitHub credentials are injected only into an authorised sandbox process. Raw credentials are not returned as OAuth, profile, operation-result, metadata, or workspace-revision fields, and generic file APIs do not project mounted secrets. The CLI does not retain normal command output. An authorised child can nevertheless deliberately print or copy a mounted secret; stdout and stderr are returned verbatim to the connected caller, child-created files can contain those bytes, and either may be captured by its terminal or agent transcript. Avoid env, printenv, shell tracing, or echoing GH_TOKEN.
Use sandbox run --detach --keep when a command must outlive the initiating client. Keep its execution ID so you can inspect, attach to, wait for, or cancel that same command. See Executions, output, and files.

aient sandbox sync

Synchronise exact local Git state into an existing sandbox:
The default remote workspace is /workspace/repo. For an environment-bound customer sandbox, repeat the original environment and repository selectors:
Use the logical sandbox name, not a physical runtime sessionId. Aient CLI 0.11.22 reuses shared Git history for eligible native V3 workspaces during sandbox sync and sandbox exec --workspace. A workspace-backed command starts only after activation succeeds.
The synchronised state includes the selected worktree’s exact HEAD, index, tracked changes, and selected explicit extra files. Include and exclude globs use repository-relative / separators and support *, **, and ?. Excludes filter only the explicit non-Git layer and cannot remove tracked Git state. With one or more --include patterns, they subtract from those selected paths. With no --include, exclude-only mode starts from the complete ignored and untracked inventory, then subtracts every matching path. This broad mode has no implicit cache or secret exclusions, so explicitly exclude .env files, credentials, private keys, dependency caches, and other unwanted local content. Raw --upload and files put --exclude have their own file-transfer filters. Git activation atomically replaces the destination directory. --remote-dir must therefore name a replaceable child on the workspace filesystem, such as /workspace/repo or /workspace/alternate-repo, never the mounted /workspace root itself. Raw upload may target /workspace because it does not use Git-directory activation.

Re-sync at the same commit

From Aient CLI 0.11.31, a sync does nothing when the local capture and remote workspace are unchanged. If the remote workspace has changed, the sync replaces it with the selected local state. If the CLI cannot check for changes, it performs a full sync. Save remote edits you need before synchronising.

Keep installed pnpm dependencies

Use --preserve-node-modules to keep existing pnpm dependency directories across a sync:
The flag is available from Aient CLI 0.11.31 on sandbox sync and sandbox exec --workspace. It selects existing node_modules directories at the repository root and in pnpm-workspace.yaml packages, outside submodules. It does not install or update dependencies; run your package installation command when manifests or the lockfile change. Preservation requires ordinary remote directories and a server that supports explicit path ownership. The CLI reports directories skipped because they overlap untracked files selected for upload; resolve that overlap before retrying if you need to keep those dependencies.

Atomic activation and the workspace fence

Aient constructs and verifies a candidate before activating it as /workspace/repo. V3 is selected from an explicitly advertised capability and publishes an immutable full-snapshot or retained-delta candidate. CLI 0.11.31 can recover a failed Git-cache transfer by synchronising directly; it still waits for verified activation before starting your command. Activation replaces the live child on the same filesystem while holding the exclusive workspace fence; the /workspace mount point itself is not replaced. sandbox exec, sandbox shell, and workspace reads hold the shared fence. A sync waits before activation rather than replacing the live tree under an admitted command. Direct file operations currently fail with a busy response instead of waiting. Do not start a second workspace mutation while a sync is active. Wait for the real terminal prefix:
When an explicit non-Git layer is present, the CLI prints a second Synchronized N explicit path(s) ... line. Partial transfer progress is not completion. If another program invokes the CLI, it must preserve the child process’s complete lifecycle result—including a running session handle, final exit status, and terminal output. Completion of an outer wrapper is not evidence that the CLI child has exited. Workspace archive uploads treat --timeout as an inactivity budget. The budget resets while source bytes continue to flow and when the server begins its response, so a healthy large transfer may exceed five minutes in total. A stalled upload or response still fails with a deadline-classified error. For a slow connection, increase the allowed inactivity gap:
--verbose prints safe request correlation and detailed progress; it does not print credentials. An interrupted upload does not resume from its last reported byte. See interrupted sync recovery for automatic retries and what to do when a sync stops.

Experimental selected-file live sync

Aient CLI 0.11.23 adds two experimental modes for watching selected local files in an existing sandbox. Use them when you want to send source edits without publishing a complete Git workspace on every save. Start with a running sandbox whose workspace has already been synchronised. For --live-stream, use a compatible native V3 sandbox with an attested workspace and customer shell permission. Pass the actual remote worktree path, with existing parent directories for every selected file:
Repeat --live-path to select up to 128 existing regular files, each at most 32 MiB. Paths are relative to the local repository. The usual Git and explicit extra-file selection rules apply; Git control paths, credentials, symlink sources, and submodules are rejected. The initial upload overwrites the selected remote files. Later saves replace each file atomically, including ordinary editor saves that replace the local file. Identical captured content is skipped. Each acknowledgement confirms that file’s byte count and SHA-256; it does not confirm application readiness or browser hot reload. The stream holds a shared workspace fence, so full workspace activation and exclusive file uploads remain blocked until it shuts down. Press Ctrl-C to request shutdown. If the CLI prints termination UNVERIFIED, the remote helper and fence may still be active. Starting another watcher does not recover that session and overwrites the selected files again. The reported session and process IDs are diagnostic information, not permission to terminate a process. To send selected files through the files API instead, replace --live-stream with --live. This mode requires an attested existing workspace and customer files permission. Both modes require explicit --remote-dir and --live-path; choose only one mode. Live sync does not transfer Git metadata, protect concurrent edits, propagate deletions or renames, select newly created files, or transfer mode changes. It provides neither an atomic update across multiple files nor reconnect recovery. Errors stop the watcher. Ending the watcher leaves the sandbox running, subject to its existing lifetime limits.

Live sync through supervised execution

Aient CLI 0.11.26 adds an experimental exec transport for a compatible existing customer workspace. Start the watcher before starting a long-running application: setup needs an exclusive workspace fence. After setup, writes share the fence with ordinary application execution.
Use the environment and repository that own the sandbox, and set --remote-dir to its actual worktree path. Each selected file must already exist remotely as a regular file with one hard link, with existing ordinary parent directories. This transport limits each captured file to 64 KiB and preserves the remote file mode. Unsupported runtimes and operator profiles reject this transport; there is no automatic transport fallback. An exact path, byte count, SHA-256 acknowledgement, and successful command completion confirm each write. If the CLI reports write UNCONFIRMED, remote bytes may have changed. The watcher stops without retrying; inspect and reconcile the selected files before restarting. Each write command has a 30-second limit, and the sandbox’s existing expiry still applies. The overwrite and recovery limits above also apply here: delivery does not confirm application readiness or browser hot reload. Use Agent checkout sync for a one-shot update to an Agent-owned checkout.

Recover from an interrupted workspace sync

From Aient CLI 0.11.31, a failed Git-cache sync can continue through a direct workspace transfer. The CLI reports the fallback on stderr and retains the cache operation until the direct sync succeeds. If both fail, it reports both errors. Cancellation, authorisation failures and a replaced sandbox still stop the operation. While the server reports that workspace preparation is busy, the CLI follows its retry hint for up to 15 minutes across preparation, upload, finalisation and activation. No new flag is required. A command starts only after the workspace is active. Aient CLI 0.11.28 automatically retries supported transient network failures and incomplete responses during workspace transfers. Use the existing sandbox sync, workspace-backed sandbox run, or sandbox exec --workspace command; no new flag is required. Retries keep the originally captured files and obtain fresh authorisation for the same target and operation. Candidate uploads replay the captured archive. Numbered Git-cache uploads replay only the affected part, so a lost response does not restart the whole pack. Retries are bounded. Cancellation and authorisation failures stop the transfer. Partially streamed downloads and other mutations are not automatically replayed after an ambiguous failure. Selected-file Agent sync and experimental live sync keep their existing recovery limits. From Aient CLI 0.11.38, workspace operations in ~/.aient/workspace-operations are temporary. When a sync, run or exec --workspace operation ends, the CLI removes its local record and captured files. Cleanup can fail or time out; from 0.11.40, that prints a warning without changing the command result. A synced workspace stays synced, and sandbox run still runs its command and follows its normal sandbox cleanup policy. An operation that did not activate first gets one best-effort discard on the sandbox, bounded to 10 seconds and sent even after Ctrl-C; if that discard fails, the CLI prints one line and the sandbox expires the operation. A failed sync never starts the command, and sandbox run deletes its sandbox after a failed sync unless you pass --keep. When a sync starts, the CLI prints:
If a sync fails or is interrupted, rerun the same command. The rerun syncs the worktree as it is now, including edits made since the interrupted attempt; nothing is resumed. A killed CLI or failed cleanup can leave a record behind. The next sync or sandbox workspace list removes eligible records whose owning processes have stopped. Records from older versions without ownership locks are kept; remove them manually only after those older CLIs have stopped. In 0.11.42, deleting large leftovers no longer holds the shared store lock, so other workspace commands can continue. On filesystems that cannot store extended attributes, the CLI cannot mark its directories and leaves abandoned copies in place. It names each retained directory and tells you to remove it manually once no Aient command is running. workspace list shows the store without authentication or network access:
While a record is still present, you can check its operation on the sandbox, or release an uncommitted publication:
Discard does not remove an activated or activation-pending workspace. On a transport failure, the CLI keeps the local record so you can retry; it removes it after the server proves that the exact operation was discarded, was already absent, or its sandbox has been deleted.