# Use the Capgo cloud terminal

> Instructions for AI agents. Human page: https://capgo.app/cloud-terminal/

The Capgo cloud terminal is a Linux workspace (Node.js 24, npm, npx, git, curl) you drive through the hosted Capgo MCP at https://api.capgo.app/mcp. Use it when the user has no computer or shell: build the app there and ship it through Capgo.

## 1. Start a session

Call `capgo_whoami` and `capgo_list_apps`. Create the app with `capgo_add_app` if it does not exist yet; confirm the name and app ID with the user first.

Call `capgo_start_terminal` with `appId`. Keep `data.session_id`. The working folder is `/workspace/project`.

If it fails with `terminal_not_entitled`, the organization has no plan, trial or usage credits: tell the user to start a trial or choose a plan in the Capgo console. If it fails with `terminal_time_exceeded`, the plan minutes for this billing cycle are used and there are no credits: tell the user to buy credits (Settings > Organization > Credits) or upgrade.

## 2. Build

- `capgo_terminal_run_command` runs one `sh -c` command (120 s limit, 256 KiB output) in `/workspace/project`. A `cd` does not carry over to the next call, so start with `cd <folder> &&` when the app is in a subfolder. Split long installs and builds into steps.
- `capgo_terminal_write_file` creates or replaces a text file (1 MiB limit). Paths are relative to `/workspace/project`.
- `capgo_terminal_read_file` reads a text file.
- The network reaches the npm registry, GitHub and signed Capgo upload URLs only. `sudo` is blocked.

## 3. Ship a live update

1. In the terminal, after the web build: `npx @capgo/cli@latest bundle zip <appId> --path <build folder> --for-upload --json` (for example `--path dist` for Vite). Without `--path` it zips the `webDir` from `capacitor.config`.
2. Call `capgo_prepare_bundle_upload` with the JSON fields it printed.
3. In the terminal: `curl -fsS -X PUT -H "Content-Type: application/zip" --upload-file <zip> "<signed url>"`.
4. Call `capgo_complete_bundle_upload` with `upload_token`.

If prepare returns `skipped` with reason `VERSION_EXISTS`, stop: do not upload or complete.

## 4. Ship a native build

1. In the terminal, with `<platform>` set to `ios` or `android`: `npm run build`, `[ -d <platform> ] || npx cap add <platform>` (Capacitor refuses to add a platform that exists), `npx cap sync <platform>`, then `npx @capgo/cli@latest build zip <appId> --platform <platform> --json`.
2. Call `capgo_request_build`, then `capgo_get_build_upload_url` with the `job_id`.
3. In the terminal: `curl -fsS -T <zip> "<upload url>"`.
4. Call `capgo_start_build`, then poll `capgo_get_build_status` and read `capgo_get_build_logs`.

Signing credentials are uploaded by the user, never through the terminal or the chat.

## 5. Stop

Call `capgo_stop_terminal` when done. Each plan includes terminal minutes each month (300 on Solo, 1,000 on Maker, 5,000 on Team, 20,000 on Enterprise; 60 in the trial), then $0.01 per minute from usage credits. Sessions also end after 10 idle minutes or at the plan session limit (30 to 120 minutes, `expires_at`), and the files are deleted.

## Reference

- Human page: https://capgo.app/cloud-terminal/
- Docs: https://capgo.app/docs/ai/cloud-terminal/
- Hosted MCP: https://capgo.app/docs/ai/mcp/
- Site index: https://capgo.app/llms.txt
