# CLI

`ft` is Ferryseal's command line, built for people and coding agents. It covers every resource in the REST API,
prints a table in a terminal and JSON when piped, and has a built-in `--jq`. It has no dependencies (Node's standard
library only) and needs Node 22.12 or newer. Version 0.1.0.

## Install

It isn't on the npm registry yet: install the package built from the repository, with npm. Never pipe a script into
a shell.

```bash
node tools/cli/pack.mjs                                # in the repository: writes apps/cli/dist/filetransfer-cli-0.1.0.tgz
npm install -g ./apps/cli/dist/filetransfer-cli-0.1.0.tgz
ft --version
```

## Sign in

```bash
ft login --host https://api.ferryseal.com
```

It shows a short code; approve it in your browser (OAuth device flow, nothing to paste). For scripts, use a key from
Settings → API keys instead, read from a variable rather than typed on the command line:
`printf %s "$FT_API_KEY" | ft auth login --host https://api.ferryseal.com --with-key`. In CI, set `FT_HOST` and `FT_API_KEY`. `ft auth status` shows who you are; `ft auth logout` forgets the profile.

## Common commands

```bash
ft agents list --fields id,name
ft agents get agt_…
ft api GET /v1/approvals?status=pending
ft runs start agt_… --input '{"topic":"Spring launch"}' --wait
```

- Deleting needs `--force`; `--dry-run` prints the request instead of sending it.
- `ft runs start … --wait` exits 1 if the run failed; 3 if it's waiting for a person, paused or sleeping; and 0
  otherwise: done, cancelled, or still running after about 20 minutes of waiting (check its status before relying on it).
- `ft agent-context` prints, as JSON, what the CLI and your credential can do.

## Filter with --jq

```bash
ft agents list --jq '.data[] | select(.state == "live") | {id, name}'
```

The built-in jq covers paths, `select`, `map`, comparisons, object and array construction, string interpolation,
`if`/`reduce`/`try`, `sort_by`/`group_by`/`unique_by`, `to_entries`/`with_entries`, regular expressions
and formats such as `@csv` and `@json`. It only reads: no assignment, no `def`, no environment access.

## Set up Claude Code

```bash
ft install claude-code
```

It adds the MCP server to the project's `.mcp.json` and a skill for Claude Code. They reference `${FT_API_KEY}`,
never the key itself, so set `FT_API_KEY` to a key from Settings → API keys (the browser sign-in doesn't make one). `ft install codex` prints the block for Codex's config instead. Quickstarts for other clients:
[Quickstarts](https://www.ferryseal.com/docs/quickstart).

## Every command

From `ft help` (version 0.1.0):

```text
ft 0.1.0: the Ferryseal CLI

  ft login --host <api url> [--scope "agents:read …"]  sign in in your browser with a short code (no key to paste)
  ft auth login --host <api url> --key <ft_live_…>     sign in with an API key (or --with-key to read it from stdin)
  ft auth login --host <api url> --client-id <id>      sign in with OAuth (an owner registers the app with
                                                       redirect http://127.0.0.1:8765/callback; --port to change)
  ft auth status | ft auth logout
  ft send <files or folders…> [--to <email>] [--title …] [--expiry <days>] [--password …] [--limit <n>]
                                                       send files: uploads straight to storage, prints the link
                                                       (--resume <transfer id> after an interruption)
  ft sandbox create --host <api url> [--agent-name <name>] [--claim-email <person's email>]
                                                       for agents: a sandbox organization and a limited
                                                       key (7 days, no outbound until a person claims it), saved as a profile
  ft api <GET|POST|PATCH|PUT|DELETE> <path> [--field k=v] [--raw-field k=<json>] [--body <json>|@file|-] [--query k=v]
  ft <resource> list [--query k=v] [--limit n] [--all]
  ft <resource> get <id> | create [--field …] | update <id> [--field …] | delete <id> --force
  ft bulk-create <resource> --input <file.json|file.jsonl|-> [--batch <id>]   25 per request; exits 1 if any row fails
  ft runs start <agent> [--input <json>] [--wait]
  ft agent-context                                     what this CLI and your credential can do, as JSON
  ft install claude-code [--dir .]                     add the MCP server (.mcp.json) and a skill for Claude Code
  ft install codex                                     print the Codex config block (writes nothing)

  Output: a table in a terminal, JSON when piped. --json, --output table|json|toon, --fields a,b.c, --jq <program> (a built-in jq).
  --dry-run prints the request instead of sending it. --profile <name>, --host <url>. CI: FT_HOST, FT_API_KEY.
```
