# kosa8 for AI agents

You are an AI agent, and the person you work for wants you to use kosa8:
Zero Trust cybersecurity infrastructure for AI agents. Code you run goes into a microVM of its
own, not onto their machine. On their own Mac (or Linux or Windows machine)
any mistake can be rewound to a checkpoint; kosa8 Cloud runs sandboxes on
kosa8's hosts. This page is written for you. Follow it in
order. Every step is a command you can run, and the one step that needs the
person says so.

The path, in four steps:

1. Try with no account: `POST https://api.kosa8.com/v1/try/agent` (step 0 below).
2. Get the person's approval: they sign in or sign up, free (Starter, no card), and
   approve you. Over plain HTTP with no install: the device sign-in
   (`POST https://api.kosa8.com/v1/auth/device` with `{"client":"agent"}`, below).
   With the CLI installed: `kosa8 login` (step 3 below).
3. Use kosa8 with their account: the CLI, the REST API (https://api.kosa8.com/openapi.json),
   the SDKs, or the hosted MCP server at https://api.kosa8.com/mcp, with an API key
   (`KOSA8_API_KEY`).
4. When they need more: see "When the person needs to pay" below.

## 0. Try it now, no key, no install (optional)

To see kosa8 run code before the person signs up, call the keyless agent
trial. No API key, no CAPTCHA, no account:

```
curl -s https://api.kosa8.com/v1/try/agent \
  -H 'Content-Type: application/json' \
  -d '{"language":"python","code":"print(2+2)"}'
```

`language` is `python` (the default), `node` or `bash`; `code` is up to 8 KiB.
Each run is up to 60 s in a fresh sandbox with no outbound network, deleted
after the run. Each network address has a small budget: 5 minutes (300 s) of
run time per 24 hours, 10 runs an hour and 100 a day
(`GET https://api.kosa8.com/v1/try/agent` describes it and shows the quota
left). When it is used up the answer is 402 `signup_required` with an
`agent_message`: relay it to the person and go on to step 1. Don't try to get
around the budget.

## Get the person's approval over HTTP (no install; this step needs the person)

When you need an API key and the kosa8 CLI is not installed, start a device
sign-in. No key needed; `name` is optional (what you call yourself, up to 60
characters, shown to the person):

```
curl -s https://api.kosa8.com/v1/auth/device \
  -H 'Content-Type: application/json' \
  -d '{"client":"agent","name":"Claude Code"}'
# {"device_code":"...","user_code":"BCDF-GH23","verification_uri_complete":"https://app.kosa8.com/device?code=BCDF-GH23",
#  "interval":2,"expires_in":600,"token_url":"https://api.kosa8.com/v1/auth/device/token","agent_message":"..."}
```

Give the person `verification_uri_complete`, or relay `agent_message` word
for word. They open it, sign in or sign up free (Starter: $10 of usage, no
card) and press Approve. Keep `device_code` to yourself. Poll every
`interval` seconds:

```
curl -s https://api.kosa8.com/v1/auth/device/token \
  -H 'Content-Type: application/json' \
  -d '{"device_code":"DEVICE_CODE"}'
```

428 `authorization_pending`: keep waiting. 429 `slow_down`: poll less often.
403 `access_denied`: the person said no; stop. 410 `expired_token`: ten
minutes passed; start again only if the person asks. 200, exactly once:
`{api_key, org, plan, starter, needs_plan, plan_url, ...}`. Use the key as
`Authorization: Bearer <api_key>` (or `KOSA8_API_KEY`). It has the person's
access without admin: it runs sandboxes and functions and can make a payment
link (below), but cannot pay, change billing or the spend cap, or cancel. The
person can revoke it under API keys.

## Pricing

kosa8 is commercial software with a free Starter tier. One account covers
every platform (kosa8 Cloud, the web app, the desktop app, the CLI).

- Starter: free, no card, once the person confirms their sign-up email. $10
  of one-time kosa8 Cloud usage, no time limit, 2 sandboxes running, each up to
  2 vCPU and 4 GB, 60-minute sessions, outbound network to an allow-list
  (package registries, GitHub, Hugging Face, model APIs). It stops at the
  limit (402 `starter_limit`, 429 at the running limit) and never bills.
- Plans from $29 a month (https://kosa8.com/pricing/) include Cloud
  sandbox-hours and differ by features and limits (sandboxes running at once,
  the largest size, persistent sandboxes, snapshots, forks). Above a plan's
  hours, usage is billed per second up to a spend cap the person sets, on by
  default at $50, with alerts at 50%, 75% and 100% (402 `spend_cap` at the
  cap). A new paid account runs at most $50 a month above its plan until 30
  days after its first payment (402 `new_account_limit`).

A failed renewal pauses new work at once, with no grace (402 `payment_failed`,
with `portal_url`), until it is paid; running work and data are kept.
Never add a card, raise a cap or buy a plan for the person: relay the 402's
`agent_message` and `upgrade_url` to them.

### When the person needs to pay

When the person outgrows Starter or reaches a limit, kosa8 answers 402 with `agent_message` and `upgrade_url` (a `plan_limit` also carries `options`, the cheapest monthly fix first). Relay `agent_message` word for word. A 402 `starter_limit` or `plan_required` names the cheapest plan that fits, with its price. To make a payment link for one plan, call `POST https://api.kosa8.com/v1/billing/checkout` with `{"plan":"solo"}` (or `pro`, `team`, `scale`; `"yearly":true` for yearly; Team and Scale also take `seats`) using an API key approved by the account owner, such as your agent key from the device sign-in: it answers `{"url", "plan", "agent_message"}`; give the person the link or relay `agent_message`. A key approved by anyone else gets 403: relay `upgrade_url` instead. The person pays; you never pay, enter card details or raise a cap. Which plan fits a workload: https://kosa8.com/pricing.md#which-plan-is-cheapest-for-a-workload

Every price, limit, per-second rate, 402 code, refund and cancel term, with
worked cost examples: https://kosa8.com/pricing.md (or
https://kosa8.com/pricing.json).

## 1. Is kosa8 installed?

```
kosa8 version
```

If that works, go to step 3. If the command is not found, install it.

**Check which release you have.** The current release is **v0.24.0**, and
every command on this page is in it. If `kosa8 version` reports an older
release and a command answers `unknown command` (or, for `kosa8 login`, asks
for a registry password), the install is out of date. Don't retry it and don't
look for a workaround: tell the person, and update with the install command in
step 2.

## 2. Install

macOS and Linux:

```
curl -fsSL https://kosa8.com/install | sh
```

Windows (PowerShell):

```
irm https://kosa8.com/install.ps1 | iex
```

Tell the person what you are installing before you run it, the same as any
installer. Then run `kosa8 doctor`. It checks the machine and says what to fix,
in plain words. On Windows 11 (x86-64), sandboxes run through WSL2 (preview):
run `kosa8 wsl setup` once, and it sets up the Linux engine and connects the CLI
to it. Windows 10 and Windows on ARM cannot run sandboxes themselves: use kosa8
Cloud, or drive a Mac or Linux machine (see the last section). A second
Windows option (preview, in the download since v0.18.0): `kosa8d.exe` runs sandboxes as gVisor containers on Docker Desktop, which
are not microVMs.

## 3. Sign up (this step needs the person)

A new install needs the person to sign in (or sign up) before it runs. Commands
that start sandboxes refuse until they have. Check first:

```
kosa8 signup --json
```

If it says `"signed_up": true`, go to step 4. If it says `"signed_up": false`,
its answer says the next step is `kosa8 login`. Run it like this:

```
kosa8 login --no-browser
```

It prints a short code and a link (to stderr), then waits up to ten minutes.
**Give the person both** and ask them to open the link on any device, sign in
or create their account (Starter is free, with no card), and confirm
the code. The command finishes by itself once they have,
and the machine is signed up with their account's email. Run it with a long
timeout or in the background.

Never sign in on their behalf, never make up an email address, and never enter
card details yourself. The account and the card belong to the person.

Signing in puts the account's plan on this machine. An account with no card
and no plan starts on the free Starter tier.

If the person is at this machine with a browser, plain `kosa8 login` opens it
for them. It is the one kosa8 account used by the CLI, the desktop app and
app.kosa8.com.

If they already have a licence key: `kosa8 license activate KEY`.

## 4. Start the daemon

```
kosa8 daemon start
```

It runs in the background and keeps running. `kosa8 doctor` confirms it is up.

## 5. Give a task to an agent in a sandbox

The shortest path is one command, `kosa8 prompt`:

```
kosa8 prompt "add a test for parseConfig and make it pass"
```

That makes a fresh sandbox, shares the current directory into it at `/work`,
runs Claude Code headless on the task, prints the agent's output, and removes
the sandbox. The exit status is the agent's. The agent's network is limited to
the hosts its kit allows. Its API key stays on the host, in kosa8's broker, and
the sandbox only ever holds a placeholder. Every tool call is checked before it
runs, and everything is in the audit log (`kosa8 audit ls`).

- Another agent: `-a codex`, `-a gemini`, `-a qwen`, `-a opencode`, `-a crush`, `-a copilot`, or
  `-a shell` for a plain shell command.
- Another folder: `-w ~/src/api`.
- No network at all: `--no-network`.
- Long input: pipe it in, `git diff | kosa8 prompt -`.
- See the plan without running: `--dry-run`.
- Keep the sandbox afterwards: `--keep`. `kosa8 sandbox ls` shows it, and
  `kosa8 sandbox rm NAME` removes it.

The agent needs its provider's key on the host: for claude, either
`CLAUDE_CODE_OAUTH_TOKEN` (the person's Claude subscription; they make it with
`claude setup-token` in their own terminal) or `ANTHROPIC_API_KEY`;
`OPENAI_API_KEY` for codex; `GEMINI_API_KEY` for gemini. If one is
missing, `kosa8 prompt` warns. Ask the person to set it. Don't go looking for
it in their files.

## 6. Or work in sandboxes yourself, with MCP tools

To run code yourself in a sandbox, instead of handing a task to another agent:

```
kosa8 mcp install      # adds kosa8's tools to every MCP client it finds (or name one: gemini, vscode, zed, ...)
kosa8 skill install    # teaches you when and how to use them (or name your agent: gemini, copilot, ...)
```

The same guidance is also an Agent Skill (`skills/kosa8/SKILL.md`, which adds
kosa8 Cloud, fan-out and RL rollouts) for agents that install skills with the
`skills` CLI: `npx skills add AzmxAI/kosa8`. That needs read access to the
AzmxAI/kosa8 repository; if it fails, use `kosa8 skill install` above.

The person may need to restart their agent for the tools to appear. The tools
are `sandbox_create`, `sandbox_shell`, `sandbox_code_run`, the `sandbox_file_*`
tools, `sandbox_git`, `sandbox_checkpoint`, `sandbox_rewind`, `sandbox_fork`,
`sandbox_preview` and `sandbox_delete`. `kosa8 skill show` prints the guide.
`kosa8 agent compat` lists every agent and client kosa8 supports
and how. If the person runs Claude Code or Cursor on their own machine and
wants each of its tool calls checked first, `kosa8 hooks install claude-code`
(or `cursor`) adds kosa8's hook to that agent's settings; `kosa8 hooks status`
shows it and `kosa8 hooks uninstall` removes it. Ask before installing it: once
in, every checked call is refused while kosa8d is not running. To use someone else's Agent Skill, import it with `kosa8 skill add
SOURCE`: it is scanned and pinned first, and anything risky is
refused unless the person accepts it.

## When kosa8 says it needs a plan

Every account needs a plan, and each plan has hard limits and a set of
features. On kosa8 Cloud a refusal is a 402 with one of three codes, each with
`message`, `upgrade_url` and `agent_message`:

- `plan_required`: the account has no plan yet.
- `plan_limit`: a limit of the plan is reached (`limit_name`, `limit`, `used`,
  `plan`, `next_plan`), for example "Solo includes 2 sandboxes running at
  once; Pro includes 10". When an add-on pack also lifts it (sandbox-hours,
  running at once), `options` lists both ways past it, cheapest monthly cost
  first: `{kind: "pack", addon, label, monthly_usd, url}` and
  `{kind: "upgrade", plan, label, monthly_usd, url}`, with `pack_url`. Tell
  the person both; the choice and the purchase are theirs.
- `plan_feature`: the feature is on a higher plan (`feature`, `next_plan`).

A `503 no_capacity` is different: kosa8's hosts are full for a moment (kosa8
adds hosts when it needs them). Wait the seconds in its `Retry-After` header
and try again. It is not a plan limit; do not suggest an upgrade for it.

Tell the person the `agent_message` word for word and stop; do not retry until
they act, and never buy or upgrade a plan yourself.

Locally, every refusal at a plan limit (too many forks, a sandbox disk over
the plan's size, a product the plan does not carry, or no plan at all) ends in
one line naming the plan that unlocks it, its price, and the command.

Run with `--json` and the refusal is also written to stdout as data:

```
{
  "error": "Solo allows 4 forks at once; ...",
  "upgrade": {
    "plan": "pro",
    "kind": "plan",
    "name": "Pro",
    "price_usd": 89,
    "price": "$89 a month",
    "unlocks": "16 forks at once",
    "url": "https://buy.polar.sh/...",
    "command": "kosa8 upgrade pro"
  }
}
```

`kind` is `plan`, `addon` (a capacity add-on; `plan` is its id) or `contract`
(Enterprise: `price_usd` is 0 because it is quoted, and `url` is where to talk
to a person). The exit code is 1.

- Relay `upgrade` to the person as it is: what it unlocks, the price, and the
  command or link. Don't round the price or pick
  a different plan.
- Check where the machine stands: `kosa8 license status --json`. It carries
  `plan` (`unlicensed` means no plan) and, with no plan, the same `upgrade`
  object for the plan that fits what this machine ran. A machine that started a
  trial before kosa8 stopped offering them keeps its remaining days
  (`plan: "trial"`, `trial_days_left`); no new trial starts.
- Buying is the person's decision, and payment is theirs to make. Never run
  `kosa8 upgrade` without `--no-open` on their behalf: with `--no-open` it only
  prints the checkout link. The checkout takes their card and charges at once;
  nothing is charged until they complete it.
  Plans are compared at https://kosa8.com/pricing/
- After they pay, Polar emails them a licence key. Ask them for it, then run
  `kosa8 license activate KEY`.
- More forks than the plan allows: tell the person the refusal's options
  (remove a fork, a $49 Burst Pass for 24 hours, the plan in `upgrade`, or
  overage, which they turn on with `kosa8 license overage on`). Never turn
  overage on yourself; it bills them by the hour.

## No sandbox engine on this machine?

kosa8 runs sandboxes on Apple-silicon Macs, x86-64 Linux and Windows 11 on
x86-64 (through WSL2, preview). On anything else, or in a CI job or hosted agent, use kosa8
Cloud: the person signs up at https://app.kosa8.com/, adds a payment method,
and gives you an API key (`KOSA8_API_KEY`). Guide:
https://docs.kosa8.com/guides/cloud.md .

## Using kosa8 Cloud

Three ways in, all with the same key and the same rules (scopes, payment, the
spending cap, the audit log):

- MCP: `claude mcp add --transport http --scope user kosa8-cloud https://api.kosa8.com/mcp --header "Authorization: Bearer $KOSA8_API_KEY"`
  (or `kosa8 cloud mcp --install`). `tools/list` shows what the key allows:
  `sandbox_create`, `sandbox_exec`, `sandbox_exec_status`, `file_read`,
  `file_write`, `preview_create`, `snapshot_create`, `code_run`,
  `pipeline_run` and more. https://docs.kosa8.com/guides/cloud-mcp.md
- The CLI, after `kosa8 cloud login` (`kosa8 cloud --help` lists what your
  version has; add `--json` to parse the output).
- The REST API at https://api.kosa8.com (https://api.kosa8.com/openapi.json)
  or the SDKs (`Kosa8Cloud`).

What to reach for:

- Size, image, Docker, env: `kosa8 cloud sandbox create --size 4x8 --image kosa8-template/universal-24.04-20261115.2 --docker --env MODE=test --name build --label team=ml --disk-gb 40 --ttl 2h`.
  Sizes are 2x4, 4x8, 8x16 and 16x32 (vCPU x GiB). The universal image has
  common languages and build tools; `universal-full-24.04-20261115.2` has more.
  A sized or Docker sandbox may report `creating`: wait until it is `running`.
  `--persistent` keeps one long-lived container, so installs and `$HOME`
  survive between commands; `--docker` implies it.
- Long commands: an exec stops after 90 s. Start installs, builds, test
  suites and servers detached with `kosa8 cloud sandbox exec --background ID -- make test`,
  then read the state, exit code and output with
  `kosa8 cloud sandbox exec-status ID bg_…` (MCP: `background: true`, then
  `sandbox_exec_status`). To bound a command you do not trust to finish,
  `--timeout 5m` (API and MCP: `timeout_s`) stops it in the sandbox (exit 124).
- Limits: `kosa8 cloud limits` shows active sandboxes against the limit
  (429 `quota_exceeded` past it; sleep one, or ask the person to run
  `kosa8 cloud limits request N`). `kosa8 cloud cap` shows the month against
  the spending cap (none unless the owner set one); changing it is the
  person's decision, never yours. Relay any `agent_message` word for word.
- Files: `kosa8 cloud files ls|get|put|rm|mkdir ID PATH`; for big files
  `kosa8 cloud files link ID PATH` gives a one-time URL. Terminal:
  `kosa8 cloud terminal ID`.
- A web app in the sandbox: `kosa8 cloud preview open ID 3000` gives the port
  an https URL (private signed link unless public); `preview ls|link|rm`.
- Save a set-up machine and start others from it:
  `kosa8 cloud snapshot create ID --name deps`, then
  `kosa8 cloud sandbox create --from-snapshot snap_…`; `snapshot ls|rm`.
- Python with state between cells and charts: `kosa8 cloud code ID`
  (MCP `code_run`; the sandbox must be persistent).
- What happened: `kosa8 cloud logs ID`, `kosa8 cloud metrics ID`.
- CI: `kosa8 cloud pipelines run https://github.com/acme/app.git`, then
  `pipelines ls|get|logs|cancel|artifacts`; triggers with
  `kosa8 cloud pipelines hook create|ls|rm`.
  https://docs.kosa8.com/guides/cloud-pipelines.md
- Network: `kosa8 cloud egress get|set|reset ID`. Change what a sandbox may
  reach only when the person asked for it.
- Secrets are the person's: they store them with `kosa8 cloud secrets set NAME`,
  which reads the value from standard input, never from the command line.
  You refer to a secret by its name; never put a secret value in a command,
  a file, an env flag or a message. `kosa8 cloud secrets ls` shows names only.
- A web browser: `kosa8 cloud browser create --ttl 300` prints a `cdp_url` for
  Playwright `chromium.connectOverCDP(cdp_url)` or Puppeteer; over MCP use
  `browser_open`, `browser_goto`, `browser_screenshot`, `browser_close`. It
  costs $0.12 per browser-hour, billed per second: close it when done
  (`kosa8 cloud browser rm brw_…`).
  https://docs.kosa8.com/guides/cloud-browsers.md
- Delete what you made when you are done (`kosa8 cloud sandbox rm ID`,
  `kosa8 cloud snapshot rm snap_…`): running sandboxes use the plan's
  sandbox-hours, and snapshots count toward the plan's limit.

## Rules

- If kosa8 refuses something for policy or approval reasons, tell the person
  what the refusal says. Don't look for a way around it. Approvals are for a
  human: `kosa8 mcp asks` lists any waiting.
- Say which sandbox you used, so the person can look: `kosa8 sandbox ls`.
- `--json` works on most commands and gives you output you can parse.
- GitHub repos: once an admin connects GitHub (https://app.kosa8.com/auth/github/connect),
  pass `repo` ("owner/name" or "owner/name@ref") to `POST /v1/sandboxes` or `POST /v1/run`
  (MCP: `github_repos`, `sandbox_create` with `repo`, `open_pull_request`). No GitHub token
  is ever given to you or put in the sandbox; pushes go to `kosa8/*` branches and pull
  requests open as drafts. https://kosa8.com/github/ and
  https://docs.kosa8.com/guides/cloud-github.md

## More

- If the person asks how kosa8 fits their AI security programme, or whether it
  suits their security team's own AI agents: https://kosa8.com/ai-security/ and
  https://kosa8.com/ai-for-cybersecurity/ (kosa8 is the isolation layer for
  agents, not a detection or SOC product); every topic (MCP, supply chain,
  zero trust, data loss, air-gapped AI) is indexed at https://kosa8.com/cybersecurity/
- If the person asks what AI agent security involves (threats, controls, a
  maturity checklist): https://kosa8.com/ai-agent-security/; for many agents
  working together (multi-agent or swarm security):
  https://kosa8.com/swarm-security/
- Every guide and command, as markdown: https://docs.kosa8.com/llms.txt
- The whole manual in one file: https://docs.kosa8.com/llms-full.txt
- Any docs page as markdown: add `.md` to its address, for example
  https://docs.kosa8.com/reference/prompt.md
