maritime-cli 1.7.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md CHANGED
@@ -34,6 +34,58 @@ export MARITIME_TOKEN=mk_xxxxxxxxxxxxxxxxxxxxxxxx
34
34
 
35
35
  `mk_` keys do not expire. Rotate with `maritime keys list` / `maritime keys revoke <id>`.
36
36
 
37
+ ### No browser: `maritime login --device`
38
+
39
+ When the machine has no browser and no reachable localhost callback (a
40
+ headless box, a container, an AI coding agent's sandbox), sign in with a
41
+ device code. `maritime login` with no flags switches to this flow by itself
42
+ when there is no TTY, when `SSH_CONNECTION` or `CI` is set, when `--json` is
43
+ passed, or when the browser cannot be opened.
44
+
45
+ ```bash
46
+ maritime login --device --json
47
+ ```
48
+
49
+ The CLI prints one JSON line on **stderr** first, so a program can show the
50
+ code to its human:
51
+
52
+ ```json
53
+ {"ok":true,"action":"device_code","user_code":"XXXX-XXXX","verification_uri_complete":"https://maritime.sh/cli/device?code=XXXX-XXXX","expires_in":900}
54
+ ```
55
+
56
+ The human opens that URL while signed in and clicks Approve. The CLI polls
57
+ every 5 seconds, stores the token, and then prints the single result on
58
+ stdout:
59
+
60
+ ```json
61
+ { "ok": true, "action": "login", "method": "device", "user": "you@example.com" }
62
+ ```
63
+
64
+ The code expires after 15 minutes. Denial or expiry ends the command with
65
+ exit `2` and `error.code` = `access_denied` or `expired_token`. The token it
66
+ stores is the 30-day login JWT; mint an `mk_` key afterwards for anything
67
+ long-lived.
68
+
69
+ ### New account: `maritime signup`
70
+
71
+ ```bash
72
+ maritime signup -e you@example.com -p '<password>' --json
73
+ ```
74
+
75
+ Non-interactive (`--json` or no TTY) with email or password missing is a
76
+ usage error (exit `4`); the command never prompts in that case. Success
77
+ stores the token and prints:
78
+
79
+ ```json
80
+ { "ok": true, "action": "signup", "user": "you@example.com", "emailVerified": false,
81
+ "next": "Verify your email: we sent a link to you@example.com. Deploys and API keys are refused until the link is clicked. Run `maritime login --resend` to send it again." }
82
+ ```
83
+
84
+ The account is signed in but unverified: `deploy`, `start`, `restart`, key
85
+ creation and computer creation answer `403 email_not_verified` until the
86
+ human clicks the link in the email (see above). `create` and `chat` work
87
+ before that.
88
+
37
89
  ## Output contract: always pass `--json`
38
90
 
39
91
  With `--json`, every command obeys a strict contract:
@@ -50,6 +102,16 @@ The failure object is:
50
102
  { "ok": false, "error": { "code": "not_authenticated", "message": "…", "status": 401 } }
51
103
  ```
52
104
 
105
+ `error.code` is the backend's own code whenever it sent one (for example
106
+ `seat_limit` on a billing refusal), otherwise a generic code derived from the
107
+ HTTP status. `error.message` is always the backend's message verbatim.
108
+
109
+ `email_not_verified` (status 403) means the account has not clicked the link
110
+ in its verification email. Deploy, start, restart, key creation and computer
111
+ creation are refused until it does. `error.message` names the address and
112
+ the fix. A human runs `maritime login --resend` to get the link again; the
113
+ token in hand works for everything after the click.
114
+
53
115
  Always read stdout for results and branch on the exit code. Never parse human text.
54
116
 
55
117
  ### Exit codes
@@ -153,8 +215,7 @@ maritime create my-agent \
153
215
  --ram 2048 \ # RAM in MB
154
216
  --cpu 1.5 \ # vCPU cores (fractional OK)
155
217
  --idle 600 \ # auto-sleep 600s after the last request
156
- --disk 20 \ # workspace SSD in GB (clamped to the plan cap)
157
- --max-compute 120 # hard cap: sleep after 120 compute-min / billing period
218
+ --disk 20 # workspace SSD in GB
158
219
  # …or keep it resident:
159
220
  maritime create my-agent --always-on # never auto-sleep (mutually exclusive with --idle)
160
221
  ```
@@ -162,13 +223,13 @@ maritime create my-agent --always-on # never auto-sleep (mutually exclusive wi
162
223
  `--idle`/`--always-on` control how long the agent stays up after a request.
163
224
  This overrides the platform's default serverless idle cap, so an orchestrator
164
225
  that dispatches a long job and waits for a webhook won't be slept out from under
165
- the wait. `--disk` and `--max-compute` are per-agent overrides on top of the
166
- owner's account plan (disk is clamped to the plan's storage cap; the compute cap
167
- auto-sleeps the agent for the rest of the billing period when hit).
226
+ the wait. Every agent includes 2 GB RAM and 5 GB SSD; `--ram` above 2048,
227
+ `--disk` above 5, and `--always-on` are paid add-ons, so on the free plan they
228
+ come back as a `402` telling you to upgrade (see Billing refusals below).
168
229
  `status <agent> --json` echoes `memMb`, `vcpus`, `idleTtlSeconds`
169
- (`0` = always-on, `null` = platform default), `diskMb`, and `computeMinutesLimit`.
230
+ (`0` = always-on, `null` = platform default) and `diskMb`.
170
231
 
171
- ## Fleets: `create --count`
232
+ ## Batches: `create --count`
172
233
 
173
234
  `maritime create <name> --count <n>` (n = 2-50) spins up **n identical agents**
174
235
  in a single call. `<name>` becomes the prefix, so agents are named
@@ -181,11 +242,11 @@ maritime create swarm --template openclaw --count 5 --idle 3600 --json
181
242
 
182
243
  Flags supported alongside `--count > 1`: `--template`,
183
244
  `--idle`/`--always-on`, `--repo`, and `-e/--env` (applied to every agent).
184
- In the fleet path `--idle 0` means always-on (same as `--always-on`).
245
+ In the batch path `--idle 0` means always-on (same as `--always-on`).
185
246
  Any other `create` flag (`--branch`, `--public`, `--port`, `--framework`,
186
- `--ram`, `--cpu`, `--disk`, `--max-compute`) combined with `--count > 1` is a
187
- usage error (exit `4`); nothing is silently dropped. `--count` above 50 is
188
- also exit `4`; the 50-agent cap is enforced server-side too.
247
+ `--ram`, `--cpu`, `--disk`) combined with `--count > 1` is a usage error
248
+ (exit `4`); nothing is silently dropped. `--count` above 50 is also exit `4`;
249
+ the 50-agent cap is enforced server-side too.
189
250
 
190
251
  Success shape (`--json`, the backend response verbatim):
191
252
 
@@ -193,25 +254,45 @@ Success shape (`--json`, the backend response verbatim):
193
254
  {
194
255
  "created": [{ "id": "…", "name": "swarm-1", "status": "deploying" }],
195
256
  "failed": [{ "name": "swarm-3", "error": "…" }],
196
- "requested": 5,
197
- "monthlyCostCents": 500
257
+ "requested": 5
198
258
  }
199
259
  ```
200
260
 
201
261
  Exit codes: `0` = **all** requested agents created (`failed` empty);
202
- `1` = partial or none, so inspect `created`/`failed` on stdout. Billing/limit
262
+ `1` = partial or none, so inspect `created`/`failed` on stdout. Limit
203
263
  rejections surface as the standard error object on stderr with exit `1`:
204
- `402` → `error.code = "insufficient_balance"` (each agent bills $1/mo from the
205
- wallet; n agents need n×$1 available), `403` → `error.code =
206
- "fleet_cap_exceeded"`.
264
+ `402` → `error.code = "seat_limit"` (your plan's agent cap; see Billing
265
+ refusals below), `403` → `error.code = "fleet_cap_exceeded"` (the 50-agent
266
+ per-call cap).
207
267
 
208
268
  ```bash
209
- # Recipe: spin up a 5-agent fleet, then fan a message out to every member
269
+ # Recipe: spin up 5 agents, then fan a message out to every one of them
210
270
  maritime create swarm --template openclaw --count 5 --idle 3600 --json \
211
271
  | jq -r '.created[].name' \
212
272
  | xargs -I{} maritime chat {} "introduce yourself" --json
213
273
  ```
214
274
 
275
+ ## Billing refusals (`402`)
276
+
277
+ Your plan sets how many agents you may have (the free plan includes 3) and
278
+ whether you can use the paid add-ons (extra RAM, extra SSD, always-on). When a
279
+ create is refused for a billing reason, the CLI exits `1` and writes the
280
+ standard error object with `error.status = 402` and the server's own
281
+ `error.code`, usually `"seat_limit"`.
282
+
283
+ **`error.message` is the server's sentence, verbatim.** It already names the
284
+ fix and carries the link, for example:
285
+
286
+ ```json
287
+ { "ok": false, "error": { "code": "seat_limit", "status": 402,
288
+ "message": "You are on the free plan, which includes 3 agents (you have 3). Delete an agent you no longer need, or upgrade to a paid plan to create more: https://maritime.sh/billing" } }
289
+ ```
290
+
291
+ Show that message to your user unchanged rather than writing your own reason:
292
+ the same code covers several distinct gates (plan agent cap, add-ons needing a
293
+ paid plan, a lapsed plan, an identity agent needing your own `INKBOX_API_KEY`)
294
+ and only the message tells them which one they hit.
295
+
215
296
  ## Environment variables
216
297
 
217
298
  Values are secret (encrypted) by default. Env changes apply on the next
@@ -246,7 +327,7 @@ Observe: `status`, `logs`
246
327
 
247
328
  Advanced / ops (hidden from `--help`, still fully supported): `start`, `stop`,
248
329
  `restart`, `sleep`, `exec <agent> <cmd...>`, `info`, `history`,
249
- `triggers`, `blueprint`, `templates`. You rarely need these: lifecycle is
330
+ `triggers`, `templates`. You rarely need these: lifecycle is
250
331
  automatic (idle-sleep + auto-wake on `chat`).
251
332
 
252
333
  Run `maritime <cmd> --help` for flags. Every command accepts the global
package/SKILL.md ADDED
@@ -0,0 +1,181 @@
1
+ ---
2
+ name: maritime
3
+ description: Deploy and operate AI agents on Maritime (maritime.sh), a cloud that gives every agent its own persistent Firecracker micro-VM that sleeps when idle and wakes in about a second. Use when asked to host, deploy, run, or manage an agent on Maritime, to give an agent a persistent computer, to provision one agent per end user from a backend, or to move a bot, worker, or scheduled job onto Maritime. Covers signup, headless login, the JSON output contract, exit codes, deploy recipes, and the email verification wall.
4
+ metadata:
5
+ author: maritime-sh
6
+ version: "1.0"
7
+ ---
8
+
9
+ # Maritime
10
+
11
+ Maritime hosts AI agents. Each agent runs in its own micro-VM with a persistent
12
+ disk at `/data`. It sleeps when idle (free while asleep), wakes in about a
13
+ second on the next message or trigger, and hosting is a flat monthly plan with
14
+ no metering. The free plan includes 3 machines, no card.
15
+
16
+ This skill is for driving Maritime as a program or an AI agent, not as a
17
+ human at a keyboard. Every command speaks JSON and every failure is
18
+ structured.
19
+
20
+ ## Rules
21
+
22
+ 1. Pass `--json` on every command. Success: one JSON value on stdout, stderr
23
+ empty. Failure: `{"ok": false, "error": {"code", "message", "status"}}` on
24
+ stderr, stdout empty. Read stdout, branch on the exit code, never scrape
25
+ human text.
26
+ 2. Exit codes: `0` ok, `1` error, `2` auth, `3` not found, `4` usage.
27
+ 3. Never guess flags. `maritime guide --json` prints the full command and flag
28
+ manifest, introspected from the installed CLI.
29
+ 4. Never paste a secret into chat. Keys go into env vars or `maritime env set`.
30
+ 5. Confirm with the user before a paid create. On the free plan a create is
31
+ free (3 machines). A refused create exits `1` with `error.status` 402 and
32
+ `error.code` `seat_limit`; show `error.message` unchanged, it names the fix.
33
+
34
+ ## Install
35
+
36
+ ```bash
37
+ npm install -g maritime-cli # Node 20.12 or later; the command is `maritime`
38
+ maritime --version # 1.9.0 or later has `login --device` and `signup` in --help
39
+ ```
40
+
41
+ If a flag below is unknown, the CLI is old: `npm install -g maritime-cli@latest`.
42
+
43
+ ## Authenticate
44
+
45
+ Try these in order and stop at the first that works.
46
+
47
+ 1. A token is already present: `MARITIME_TOKEN` in the environment, or a
48
+ saved login. Check with `maritime whoami --json` (exit `2` means no token).
49
+ 2. The user has an account and you have no browser: `maritime login --device
50
+ --json`. It prints a code on stderr as one JSON line
51
+ (`{"action":"device_code","user_code":"XXXX-XXXX","verification_uri_complete":"..."}`).
52
+ Show the user the URL and the code, then wait; the command returns when
53
+ they approve.
54
+ 3. The user has an account and a browser on this machine: `maritime login`.
55
+ 4. No account: `maritime signup -e <email> -p <password> -n <name> --json`.
56
+ Ask the user for the email and password; never invent them. Signup saves a
57
+ token and returns `emailVerified: false`.
58
+
59
+ The email verification wall: until the user clicks the link Maritime emailed
60
+ them, `create`, `deploy`, `start`, `restart`, `keys create` and computer
61
+ creation are refused with status `403` and `error.code`
62
+ `email_not_verified`. When you see it, tell the user to open the email and
63
+ click the link, offer `maritime login --resend` to send it again, then retry
64
+ the same command. Everything else (list, status, logs, templates) works
65
+ before verification.
66
+
67
+ For long-running automation mint a key once the account is verified:
68
+ `maritime keys create --name <purpose> --json` returns `raw_key` (`mk_...`,
69
+ shown once, never expires). Export it as `MARITIME_TOKEN`.
70
+
71
+ `MARITIME_API_URL` overrides the API base (default `https://api.maritime.sh`).
72
+
73
+ ## Deploy
74
+
75
+ Pick the recipe that matches what the user has.
76
+
77
+ ### A ready-made agent from a template
78
+
79
+ ```bash
80
+ maritime templates --json # ids: openclaw, hermes, zeroclaw, claude_code, codex, dsh
81
+ maritime create my-agent --template openclaw --json
82
+ maritime status my-agent --json # poll until .status is "active"
83
+ maritime chat my-agent "introduce yourself" --json | jq -r '.response'
84
+ ```
85
+
86
+ Most templates need no model key (Maritime's metered LLM proxy). `claude_code`
87
+ is the exception: it needs `ANTHROPIC_API_KEY` as a secret env var.
88
+
89
+ ### The user's own code (any framework, Dockerfile at the repo root)
90
+
91
+ ```bash
92
+ maritime create my-bot --repo https://github.com/you/agent --json
93
+ maritime status my-bot --json # builds take 1 to 3 minutes
94
+ maritime logs my-bot --json
95
+ ```
96
+
97
+ The container contract: listen on `0.0.0.0:$PORT` (injected, never hardcode
98
+ 8080), answer `GET /health` with any 2xx, answer `POST /chat` with JSON
99
+ `{"message": "..."}` within 30 seconds returning text or JSON with one of
100
+ `response`, `reply`, `message`, `text`, `output`. Persist under `/data` only.
101
+ Never use a shell-string `CMD`; launch a real program. Full contract:
102
+ https://maritime.sh/docs/frameworks/custom.md
103
+
104
+ Private GitHub repos need the Maritime GitHub App installed from the
105
+ dashboard. Pre-built public images: `POST /api/agents` with
106
+ `{"framework": "custom", "imageName": "ghcr.io/acme/img:tag"}`.
107
+
108
+ ### A public web app on its own HTTPS URL
109
+
110
+ ```bash
111
+ maritime create my-app --repo https://github.com/you/app --public --port 3000 --json
112
+ ```
113
+
114
+ It sleeps when idle and wakes on the next visit.
115
+
116
+ ### Secrets and env vars
117
+
118
+ ```bash
119
+ maritime env set my-agent OPENAI_API_KEY=sk-... --reload --json # secret by default
120
+ maritime env import my-agent ./prod.env --reload --json
121
+ ```
122
+
123
+ Without `--reload` the change applies on the next boot.
124
+
125
+ ### Schedules
126
+
127
+ Timers inside a sleeping VM do not fire. Use platform triggers:
128
+
129
+ ```bash
130
+ maritime triggers create my-agent --type cron --cron "0 9 * * *" --json
131
+ ```
132
+
133
+ ### One agent per end user, from a backend
134
+
135
+ Use the SDK instead of the CLI: `npm install maritime-sdk` or
136
+ `pip install maritime`, key in `MARITIME_API_KEY`. `provision({externalId})`
137
+ is idempotent. Docs: https://maritime.sh/docs/build.md
138
+
139
+ ### A persistent desktop for an existing agent (Computers, paid plan)
140
+
141
+ One MCP server, one Linux desktop per end user id:
142
+
143
+ ```bash
144
+ claude mcp add --transport http maritime-computers https://mcp.maritime.sh/mcp \
145
+ --header "Authorization: Bearer mk_..."
146
+ ```
147
+
148
+ Docs: https://maritime.sh/docs/computers.md
149
+
150
+ ## Verify before you finish
151
+
152
+ 1. `maritime status <agent> --json` reports `active` (or `sleeping` after
153
+ idle; both are healthy).
154
+ 2. `maritime chat <agent> "hello" --json` returns a reply, or for a custom
155
+ container `maritime logs <agent> --json` shows the server listening.
156
+ 3. Tell the user the agent name, the dashboard URL
157
+ `https://maritime.sh/agents`, and what you changed in their repo.
158
+
159
+ ## Inspect and repair
160
+
161
+ ```bash
162
+ maritime list --json
163
+ maritime info my-agent --json # env count, triggers, last deploy
164
+ maritime history my-agent --json # build and deploy attempts with buildLog
165
+ maritime exec my-agent ls /data --json | jq -r '.stdout'
166
+ maritime restart my-agent --json # also picks up new env vars
167
+ maritime delete my-agent --yes --json # --yes is required non-interactively
168
+ ```
169
+
170
+ `error.code` `agent_unavailable` on chat means the agent is not running:
171
+ `maritime start <agent>`, wait a few seconds, retry. A 404 on exec or files
172
+ usually means the agent is asleep or errored: start it, do not recreate it.
173
+
174
+ ## Reference
175
+
176
+ - Contract file: https://maritime.sh/docs/cli/llms.txt
177
+ - Setup procedure for agents: https://maritime.sh/agents.md
178
+ - Everything: https://maritime.sh/llms.txt (index) and https://maritime.sh/llms-full.txt
179
+ - REST API: https://api.maritime.sh/openapi.json (bearer `mk_` key)
180
+ - Any docs page as markdown: append `.md` to its URL, for example
181
+ https://maritime.sh/docs/quickstart.md
package/dist/api.d.ts CHANGED
@@ -2,7 +2,11 @@ type JsonRecord = Record<string, unknown>;
2
2
  export declare class CliHttpError extends Error {
3
3
  status: number;
4
4
  detail: string;
5
- constructor(status: number, detail: string);
5
+ /** Machine-readable error code from the server when present, e.g.
6
+ * 'seat_limit' when the account hit its plan's agent cap, needs a paid
7
+ * plan for an add-on, or has a lapsed plan. */
8
+ code?: string;
9
+ constructor(status: number, detail: string, code?: string);
6
10
  }
7
11
  export interface CliUser {
8
12
  id: string;
package/dist/api.js CHANGED
@@ -4,10 +4,15 @@ import { fail, EXIT } from './output.js';
4
4
  export class CliHttpError extends Error {
5
5
  status;
6
6
  detail;
7
- constructor(status, detail) {
7
+ /** Machine-readable error code from the server when present, e.g.
8
+ * 'seat_limit' when the account hit its plan's agent cap, needs a paid
9
+ * plan for an add-on, or has a lapsed plan. */
10
+ code;
11
+ constructor(status, detail, code) {
8
12
  super(detail);
9
13
  this.status = status;
10
14
  this.detail = detail;
15
+ this.code = code;
11
16
  }
12
17
  }
13
18
  function isErrorWithMessage(error) {
@@ -77,7 +82,7 @@ async function maybeRefreshToken(token) {
77
82
  }
78
83
  }
79
84
  catch {
80
- // Refresh failed silently — continue with current token
85
+ // Refresh failed silently, continue with current token
81
86
  }
82
87
  return token;
83
88
  }
@@ -138,7 +143,14 @@ async function handleResponse(response) {
138
143
  const detail = typeof payload.detail === 'string'
139
144
  ? payload.detail
140
145
  : `Request failed with status ${response.status}`;
141
- throw new CliHttpError(response.status, detail);
146
+ // `code` is Maritime's own field; `error` is the RFC 8628 shape the
147
+ // device-login endpoints answer with ({"error": "authorization_pending"}).
148
+ const code = typeof payload.code === 'string'
149
+ ? payload.code
150
+ : typeof payload.error === 'string'
151
+ ? payload.error
152
+ : undefined;
153
+ throw new CliHttpError(response.status, detail, code);
142
154
  }
143
155
  return payload;
144
156
  }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Reads a file shipped at the package root (the `files` list in package.json),
3
+ * such as AGENTS.md or SKILL.md.
4
+ *
5
+ * Works from both the built layout (dist/bundled.js, one level below the
6
+ * root) and the tsx dev layout (src/bundled.ts). Returns null when the file
7
+ * was not shipped.
8
+ *
9
+ * @param name The file name at the package root.
10
+ */
11
+ export declare function readBundledFile(name: string): string | null;
@@ -0,0 +1,25 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { dirname, join } from 'node:path';
4
+ const __dirname = dirname(fileURLToPath(import.meta.url));
5
+ /**
6
+ * Reads a file shipped at the package root (the `files` list in package.json),
7
+ * such as AGENTS.md or SKILL.md.
8
+ *
9
+ * Works from both the built layout (dist/bundled.js, one level below the
10
+ * root) and the tsx dev layout (src/bundled.ts). Returns null when the file
11
+ * was not shipped.
12
+ *
13
+ * @param name The file name at the package root.
14
+ */
15
+ export function readBundledFile(name) {
16
+ for (const rel of [['..', name], ['..', '..', name]]) {
17
+ try {
18
+ return readFileSync(join(__dirname, ...rel), 'utf-8');
19
+ }
20
+ catch {
21
+ // try the next candidate
22
+ }
23
+ }
24
+ return null;
25
+ }
@@ -3,11 +3,7 @@ import chalk from 'chalk';
3
3
  import { authGet, authPost, CliHttpError } from '../api.js';
4
4
  import { promptForValue } from '../prompt.js';
5
5
  import { isJsonMode, outputResult, fail, handleError, makeSpinner, EXIT } from '../output.js';
6
- const FLEET_CAP = 50;
7
- /** Format integer cents as a dollar string ($5 or $7.50). */
8
- function formatDollars(cents) {
9
- return cents % 100 === 0 ? `$${cents / 100}` : `$${(cents / 100).toFixed(2)}`;
10
- }
6
+ const BATCH_CAP = 50;
11
7
  function parseEnvPairs(pairs) {
12
8
  return pairs.map((pair) => {
13
9
  const eqIdx = pair.indexOf('=');
@@ -29,35 +25,34 @@ export const createCommand = new Command('create')
29
25
  .argument('[name]', 'Agent name')
30
26
  .option('-t, --template <template>', 'Template to base the agent on (see `maritime templates`)')
31
27
  .option('-e, --env <pairs...>', 'Environment variables (KEY=value)')
32
- .option('--count <n>', 'Spin up N identical agents in one call (fleet). Names become <name>-1..<name>-N')
28
+ .option('--count <n>', 'Spin up N identical agents in one call. Names become <name>-1..<name>-N')
33
29
  .option('-r, --repo <url>', 'Deploy from a GitHub repo (must contain a Dockerfile)')
34
30
  .option('-b, --branch <branch>', 'Git branch to deploy (with --repo)')
35
31
  .option('--public', 'Serve a public, no-login web URL for this agent (web apps)')
36
32
  .option('--port <n>', 'Port your app listens on (exposed publicly; default 8080)')
37
- // Advanced overrides — kept fully working but off the main --help so the
33
+ // Advanced overrides, kept fully working but off the main --help so the
38
34
  // happy path stays flag-free. By default the platform picks the applicable
39
35
  // size for the framework and auto-sleeps when idle; you only reach for these
40
36
  // to hand-tune a specific agent (e.g. a reseller dialing RAM per client).
41
37
  .addOption(new Option('-n, --name <name>', 'Agent name (alias for the positional argument)').hideHelp())
42
38
  .addOption(new Option('--framework <framework>', 'Framework (default: custom)').hideHelp())
43
- .addOption(new Option('--ram <mb>', 'RAM in MB (per-agent override of the default)').hideHelp())
39
+ .addOption(new Option('--ram <mb>', 'RAM in MB (2048 included; above that is a paid add-on)').hideHelp())
44
40
  .addOption(new Option('--cpu <cores>', 'vCPU cores, e.g. 0.5 or 2 (per-agent override)').hideHelp())
45
41
  .addOption(new Option('--idle <seconds>', 'Auto-sleep this many seconds after the last request').hideHelp())
46
- .addOption(new Option('--always-on', 'Never auto-sleep (mutually exclusive with --idle)').hideHelp())
47
- .addOption(new Option('--disk <gb>', 'Workspace SSD size in GB (per-agent override)').hideHelp())
48
- .addOption(new Option('--max-compute <minutes>', 'Hard cap: auto-sleep after N compute-minutes per billing period').hideHelp())
42
+ .addOption(new Option('--always-on', 'Never auto-sleep (a paid add-on; mutually exclusive with --idle)').hideHelp())
43
+ .addOption(new Option('--disk <gb>', 'Workspace SSD size in GB (5 included; above that is a paid add-on)').hideHelp())
49
44
  .addHelpText('after', `
50
45
  Examples:
51
46
  maritime create researcher
52
47
  maritime create acme-bot --template openclaw --json
53
48
  maritime create my-app --repo https://github.com/you/app --public # public web agent
54
49
  maritime create client-x -e OPENAI_API_KEY=sk-...
55
- maritime create swarm --template openclaw --count 5 # fleet: swarm-1..swarm-5`)
50
+ maritime create swarm --template openclaw --count 5 # swarm-1..swarm-5`)
56
51
  .action(async (nameArg, opts) => {
57
52
  try {
58
53
  let name = nameArg || opts.name;
59
54
  let templateId = opts.template;
60
- // --count: fleet spin-up. 1 (default) = the classic single-agent path.
55
+ // --count: batch spin-up. 1 (default) = the classic single-agent path.
61
56
  let count = 1;
62
57
  if (opts.count !== undefined) {
63
58
  const n = Number(opts.count);
@@ -67,8 +62,8 @@ Examples:
67
62
  exitCode: EXIT.USAGE,
68
63
  });
69
64
  }
70
- if (n > FLEET_CAP) {
71
- fail('Fleet spin-ups are capped at 50 agents. Contact us if you need more. We keep the cap to protect shared server capacity.', { code: 'usage', exitCode: EXIT.USAGE });
65
+ if (n > BATCH_CAP) {
66
+ fail('Batch creates are capped at 50 agents. Contact us if you need more. We keep the cap to protect shared server capacity.', { code: 'usage', exitCode: EXIT.USAGE });
72
67
  }
73
68
  count = n;
74
69
  }
@@ -107,10 +102,10 @@ Examples:
107
102
  // Templates fetch failed; continue without template
108
103
  }
109
104
  }
110
- // ── Fleet path (--count > 1): one POST /api/fleet/batch call ──
105
+ // ── Batch path (--count > 1): one POST /api/fleet/batch call ──
111
106
  if (count > 1) {
112
107
  // The batch endpoint only understands a subset of create's flags.
113
- // Anything it can't honor is a hard usage error — never silently dropped.
108
+ // Anything it can't honor is a hard usage error, never silently dropped.
114
109
  const unsupported = [];
115
110
  if (opts.branch !== undefined)
116
111
  unsupported.push('--branch');
@@ -126,11 +121,9 @@ Examples:
126
121
  unsupported.push('--cpu');
127
122
  if (opts.disk !== undefined)
128
123
  unsupported.push('--disk');
129
- if (opts.maxCompute !== undefined)
130
- unsupported.push('--max-compute');
131
124
  if (unsupported.length > 0) {
132
125
  fail(`${unsupported.join(', ')} cannot be combined with --count > 1. ` +
133
- 'Fleet spin-ups support --template, --idle/--always-on, --repo, and -e/--env.', { code: 'usage', exitCode: EXIT.USAGE });
126
+ 'Batch creates support --template, --idle/--always-on, --repo, and -e/--env.', { code: 'usage', exitCode: EXIT.USAGE });
134
127
  }
135
128
  if (opts.alwaysOn && opts.idle !== undefined) {
136
129
  fail('--always-on and --idle are mutually exclusive.', { code: 'usage', exitCode: EXIT.USAGE });
@@ -155,19 +148,21 @@ Examples:
155
148
  }
156
149
  batchBody.idleTtlSeconds = secs; // 0 = always-on
157
150
  }
158
- const spinner = await makeSpinner(`Creating fleet ${chalk.bold(name)} × ${count}...`);
151
+ const spinner = await makeSpinner(`Creating ${chalk.bold(name)} × ${count}...`);
159
152
  let result;
160
153
  try {
161
154
  result = await authPost('/api/fleet/batch', batchBody);
162
155
  }
163
156
  catch (error) {
164
- spinner.fail('Failed to create fleet');
157
+ spinner.fail('Failed to create agents');
165
158
  if (error instanceof CliHttpError && (error.status === 402 || error.status === 403)) {
166
- // 402 = wallet can't cover count × $1/mo; 403 = server-enforced cap.
167
- // Both are request failures, not auth failures → exit 1.
159
+ // 402 = the plan's agent cap (code seat_limit); the server's detail
160
+ // is already a complete sentence naming the fix and the billing
161
+ // link, so print it verbatim. 403 = the server-enforced batch cap.
162
+ // Both are request failures, not auth failures, so exit 1.
168
163
  fail(error.detail, {
169
164
  status: error.status,
170
- code: error.status === 402 ? 'insufficient_balance' : 'fleet_cap_exceeded',
165
+ code: error.code ?? (error.status === 402 ? 'seat_limit' : 'fleet_cap_exceeded'),
171
166
  exitCode: EXIT.ERROR,
172
167
  });
173
168
  }
@@ -199,10 +194,7 @@ Examples:
199
194
  console.log(' ' + chalk.bold(f.name.padEnd(24)) + chalk.red(f.error));
200
195
  }
201
196
  }
202
- console.log('\n ' +
203
- `${result.created.length}/${result.requested} created` +
204
- chalk.dim(' · ') +
205
- `${formatDollars(result.monthlyCostCents)}/mo`);
197
+ console.log('\n ' + `${result.created.length}/${result.requested} created`);
206
198
  console.log();
207
199
  });
208
200
  // Exit contract: 0 = all created, 1 = partial or none.
@@ -217,8 +209,14 @@ Examples:
217
209
  body.framework = opts.framework;
218
210
  if (opts.env)
219
211
  body.initialEnvVars = parseEnvPairs(opts.env);
220
- if (opts.repo)
212
+ if (opts.repo) {
221
213
  body.githubRepo = opts.repo;
214
+ // Source builds need a chance to identify their runtime before boot.
215
+ // This preserves an explicit framework or template, while allowing an
216
+ // OpenClaw repository to receive its required gateway credential.
217
+ if (!templateId && !opts.framework)
218
+ body.framework = 'auto';
219
+ }
222
220
  if (opts.branch)
223
221
  body.branch = opts.branch;
224
222
  if (opts.public) {
@@ -266,13 +264,6 @@ Examples:
266
264
  }
267
265
  body.diskGb = gb;
268
266
  }
269
- if (opts.maxCompute !== undefined) {
270
- const mins = Number(opts.maxCompute);
271
- if (!Number.isFinite(mins) || mins <= 0) {
272
- fail('--max-compute must be a positive number of minutes.', { code: 'usage', exitCode: 4 });
273
- }
274
- body.computeMinutesLimit = mins;
275
- }
276
267
  const spinner = await makeSpinner(`Creating agent ${chalk.bold(name)}...`);
277
268
  let agent;
278
269
  try {
@@ -280,6 +271,18 @@ Examples:
280
271
  }
281
272
  catch (error) {
282
273
  spinner.fail('Failed to create agent');
274
+ if (error instanceof CliHttpError && error.status === 402) {
275
+ // Billing gate, not a crash. The server's detail is already a
276
+ // complete user-ready sentence naming the fix (e.g. the free plan
277
+ // includes 3 agents: delete one or upgrade) and carrying
278
+ // https://maritime.sh/billing, so print it verbatim rather than
279
+ // guessing at a reason here.
280
+ fail(error.detail, {
281
+ status: 402,
282
+ code: error.code ?? 'payment_required',
283
+ exitCode: EXIT.ERROR,
284
+ });
285
+ }
283
286
  throw error;
284
287
  }
285
288
  spinner.succeed(chalk.green('Created ') + chalk.bold(agent.name) + chalk.dim(` (${agent.id})`));
@@ -295,8 +298,6 @@ Examples:
295
298
  }
296
299
  if (agent.diskMb)
297
300
  res.push(`disk ${(agent.diskMb / 1024).toFixed(1)}GB`);
298
- if (agent.computeMinutesLimit)
299
- res.push(`cap ${agent.computeMinutesLimit}min`);
300
301
  if (res.length)
301
302
  console.log(chalk.dim(` Resources: ${res.join(' | ')}`));
302
303
  if (agent.publicUrl)