spawn/fly
A d7ff0739a2
fix: fly auth token deprecated + org picker + macaroon tokens (#1603)
* fix: fly auth token deprecated + org picker + macaroon discharge tokens

Three fixes for the fly/ TypeScript provider:

1. `fly auth token` is deprecated — newer flyctl outputs a message, not
   a token. Now tries `fly tokens create org --expiry 24h` first, with
   `fly auth token` as fallback. Uses org tokens (not deploy) since
   spawn needs to create new apps.

2. Token sanitization stripped macaroon discharge tokens at commas
   (`fm2_[^ ,]*` → `fm2_\S+`). The full composite token
   `fm2_xxx,fm2_yyy,fo1_zzz` is now preserved.

3. Org picker upgraded from numbered 1/2 input to arrow-key interactive
   selector with cursor navigation, scroll windowing, and fallback to
   numbered list when TTY is unavailable.

Also fixes: testFlyToken fallback sent `Bearer FlyV1 ...` (double prefix)
for macaroon tokens — now dispatches FlyV1 vs Bearer correctly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* docs: never run test/mock.sh locally — opens browser, CI only

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: lab <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-21 11:06:19 -08:00
..
lib fix: fly auth token deprecated + org picker + macaroon tokens (#1603) 2026-02-21 11:06:19 -08:00
claude.sh refactor: convert fly/ cloud provider from bash to TypeScript (#1601) (#1602) 2026-02-21 10:41:34 -08:00
codex.sh refactor: convert fly/ cloud provider from bash to TypeScript (#1601) (#1602) 2026-02-21 10:41:34 -08:00
kilocode.sh refactor: convert fly/ cloud provider from bash to TypeScript (#1601) (#1602) 2026-02-21 10:41:34 -08:00
main.ts refactor: convert fly/ cloud provider from bash to TypeScript (#1601) (#1602) 2026-02-21 10:41:34 -08:00
openclaw.sh refactor: convert fly/ cloud provider from bash to TypeScript (#1601) (#1602) 2026-02-21 10:41:34 -08:00
opencode.sh refactor: convert fly/ cloud provider from bash to TypeScript (#1601) (#1602) 2026-02-21 10:41:34 -08:00
README.md refactor: convert fly/ cloud provider from bash to TypeScript (#1601) (#1602) 2026-02-21 10:41:34 -08:00
zeroclaw.sh refactor: convert fly/ cloud provider from bash to TypeScript (#1601) (#1602) 2026-02-21 10:41:34 -08:00

Fly.io

Fly.io Machines via REST API and flyctl CLI. Fly.io

Architecture

The Fly.io provider is implemented in TypeScript (Bun runtime). Each .sh agent script is a thin shim that ensures bun is installed, downloads the TS sources if running via bash <(curl ...), and delegates to main.ts.

fly/
  main.ts               # Orchestrator: auth → provision → install → launch
  lib/
    fly.ts              # Core provider: API client, auth, orgs, provisioning
    agents.ts           # Agent configs (all 6) + shared install/config helpers
    oauth.ts            # OpenRouter OAuth flow (Bun.serve), key validation
    ui.ts               # Logging (ANSI), prompts (readline), browser open
  {agent}.sh            # Thin bash shim → bun run main.ts {agent}

No external dependencies — all modules use built-in Bun/Node APIs only. The fly/ directory has no package.json.

Agents

Claude Code

bash <(curl -fsSL https://openrouter.ai/labs/spawn/fly/claude.sh)

OpenClaw

bash <(curl -fsSL https://openrouter.ai/labs/spawn/fly/openclaw.sh)

ZeroClaw

bash <(curl -fsSL https://openrouter.ai/labs/spawn/fly/zeroclaw.sh)

Codex CLI

bash <(curl -fsSL https://openrouter.ai/labs/spawn/fly/codex.sh)

OpenCode

bash <(curl -fsSL https://openrouter.ai/labs/spawn/fly/opencode.sh)

Kilo Code

bash <(curl -fsSL https://openrouter.ai/labs/spawn/fly/kilocode.sh)

Non-Interactive Mode

FLY_APP_NAME=dev-mk1 \
FLY_API_TOKEN=your-token \
OPENROUTER_API_KEY=sk-or-v1-xxxxx \
  bash <(curl -fsSL https://openrouter.ai/labs/spawn/fly/claude.sh)

Environment Variables

Variable Description Default
FLY_API_TOKEN Fly.io API token (prompted or from flyctl auth)
FLY_APP_NAME App name (prompted)
FLY_REGION Deployment region iad
FLY_VM_SIZE VM size shared-cpu-1x
FLY_VM_MEMORY VM memory (MB) 1024
FLY_ORG Organization slug personal
OPENROUTER_API_KEY OpenRouter API key (OAuth or prompted)