maritime-cli 1.9.0 → 2.0.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.
Files changed (82) hide show
  1. package/README.md +17 -0
  2. package/bin/maritime.js +40 -0
  3. package/install.js +118 -0
  4. package/package.json +22 -37
  5. package/AGENTS.md +0 -361
  6. package/SKILL.md +0 -181
  7. package/dist/api.d.ts +0 -30
  8. package/dist/api.js +0 -246
  9. package/dist/bundled.d.ts +0 -11
  10. package/dist/bundled.js +0 -25
  11. package/dist/commands/chat.d.ts +0 -2
  12. package/dist/commands/chat.js +0 -120
  13. package/dist/commands/create.d.ts +0 -2
  14. package/dist/commands/create.js +0 -310
  15. package/dist/commands/delete.d.ts +0 -2
  16. package/dist/commands/delete.js +0 -43
  17. package/dist/commands/deploy.d.ts +0 -2
  18. package/dist/commands/deploy.js +0 -180
  19. package/dist/commands/env.d.ts +0 -2
  20. package/dist/commands/env.js +0 -368
  21. package/dist/commands/exec.d.ts +0 -2
  22. package/dist/commands/exec.js +0 -31
  23. package/dist/commands/guide.d.ts +0 -2
  24. package/dist/commands/guide.js +0 -75
  25. package/dist/commands/history.d.ts +0 -2
  26. package/dist/commands/history.js +0 -56
  27. package/dist/commands/info.d.ts +0 -2
  28. package/dist/commands/info.js +0 -78
  29. package/dist/commands/init.d.ts +0 -2
  30. package/dist/commands/init.js +0 -143
  31. package/dist/commands/keys.d.ts +0 -2
  32. package/dist/commands/keys.js +0 -90
  33. package/dist/commands/link.d.ts +0 -4
  34. package/dist/commands/link.js +0 -65
  35. package/dist/commands/list.d.ts +0 -2
  36. package/dist/commands/list.js +0 -55
  37. package/dist/commands/login.d.ts +0 -2
  38. package/dist/commands/login.js +0 -368
  39. package/dist/commands/logout.d.ts +0 -2
  40. package/dist/commands/logout.js +0 -12
  41. package/dist/commands/logs.d.ts +0 -2
  42. package/dist/commands/logs.js +0 -89
  43. package/dist/commands/message.d.ts +0 -8
  44. package/dist/commands/message.js +0 -75
  45. package/dist/commands/open.d.ts +0 -2
  46. package/dist/commands/open.js +0 -25
  47. package/dist/commands/restart.d.ts +0 -2
  48. package/dist/commands/restart.js +0 -26
  49. package/dist/commands/signup.d.ts +0 -2
  50. package/dist/commands/signup.js +0 -72
  51. package/dist/commands/sleep.d.ts +0 -2
  52. package/dist/commands/sleep.js +0 -22
  53. package/dist/commands/start.d.ts +0 -2
  54. package/dist/commands/start.js +0 -27
  55. package/dist/commands/status.d.ts +0 -2
  56. package/dist/commands/status.js +0 -69
  57. package/dist/commands/stop.d.ts +0 -2
  58. package/dist/commands/stop.js +0 -26
  59. package/dist/commands/templates.d.ts +0 -2
  60. package/dist/commands/templates.js +0 -40
  61. package/dist/commands/triggers.d.ts +0 -2
  62. package/dist/commands/triggers.js +0 -89
  63. package/dist/commands/whoami.d.ts +0 -2
  64. package/dist/commands/whoami.js +0 -76
  65. package/dist/config.d.ts +0 -2
  66. package/dist/config.js +0 -14
  67. package/dist/context.d.ts +0 -39
  68. package/dist/context.js +0 -110
  69. package/dist/index.d.ts +0 -2
  70. package/dist/index.js +0 -186
  71. package/dist/interactive.d.ts +0 -1
  72. package/dist/interactive.js +0 -66
  73. package/dist/output.d.ts +0 -80
  74. package/dist/output.js +0 -176
  75. package/dist/prompt.d.ts +0 -2
  76. package/dist/prompt.js +0 -62
  77. package/dist/resolve.d.ts +0 -16
  78. package/dist/resolve.js +0 -59
  79. package/dist/version-check.d.ts +0 -20
  80. package/dist/version-check.js +0 -81
  81. package/dist/websocket.d.ts +0 -22
  82. package/dist/websocket.js +0 -89
package/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # maritime-cli
2
+
3
+ The Maritime command line client. This package downloads the `maritime`
4
+ binary for your platform from the matching GitHub release and verifies its
5
+ SHA-256 before it runs.
6
+
7
+ ```bash
8
+ npm i -g maritime-cli
9
+ maritime auth login
10
+ ```
11
+
12
+ Documentation, the command reference, and the source live in
13
+ [cli/go](https://github.com/maritime-sh/maritime/tree/main/cli/go) of the
14
+ Maritime repository.
15
+
16
+ Set `MARITIME_CLI_DOWNLOAD_BASE` to install from a mirror of the release
17
+ assets. Every command name from maritime-cli 1.x keeps working.
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env node
2
+ 'use strict'
3
+ // Runs the Maritime CLI binary that install.js placed under vendor/, passing
4
+ // every argument through and exiting with the binary's status. When the
5
+ // binary is missing, for example after an install with --ignore-scripts, it
6
+ // is downloaded first.
7
+
8
+ const { spawn } = require('node:child_process')
9
+ const fs = require('node:fs')
10
+ const { install, binaryPath } = require('../install.js')
11
+
12
+ const SIGNALS = ['SIGINT', 'SIGTERM', 'SIGHUP']
13
+ const EXIT_ON_SIGNAL = 128
14
+
15
+ async function main() {
16
+ const bin = binaryPath()
17
+ if (!fs.existsSync(bin)) {
18
+ await install()
19
+ }
20
+ const child = spawn(bin, process.argv.slice(2), { stdio: 'inherit', windowsHide: true })
21
+ for (const signal of SIGNALS) {
22
+ process.on(signal, () => child.kill(signal))
23
+ }
24
+ child.on('error', (error) => {
25
+ console.error(`maritime-cli: cannot run ${bin}: ${error.message}`)
26
+ process.exit(1)
27
+ })
28
+ child.on('exit', (code, signal) => {
29
+ if (signal) {
30
+ process.kill(process.pid, signal)
31
+ process.exit(EXIT_ON_SIGNAL)
32
+ }
33
+ process.exit(code === null ? 1 : code)
34
+ })
35
+ }
36
+
37
+ main().catch((error) => {
38
+ console.error(`maritime-cli: ${error.message}`)
39
+ process.exit(1)
40
+ })
package/install.js ADDED
@@ -0,0 +1,118 @@
1
+ 'use strict'
2
+ // Downloads the Maritime CLI binary for this platform from the GitHub
3
+ // release that matches package.json's version, verifies its SHA-256 against
4
+ // the release's checksums.txt, and unpacks it next to this file.
5
+ //
6
+ // Runs as the package's postinstall step. Running it again is safe: an
7
+ // existing binary of the right version is kept. Set
8
+ // MARITIME_CLI_DOWNLOAD_BASE to install from a mirror of the release assets.
9
+
10
+ const { createHash } = require('node:crypto')
11
+ const fs = require('node:fs')
12
+ const os = require('node:os')
13
+ const path = require('node:path')
14
+ const { execFileSync } = require('node:child_process')
15
+
16
+ const pkg = require('./package.json')
17
+ const VERSION = pkg.version
18
+ const RELEASE_TAG = `cli-v${VERSION}`
19
+ const DEFAULT_BASE = `https://github.com/maritime-sh/maritime/releases/download/${RELEASE_TAG}`
20
+ const VENDOR_DIR = path.join(__dirname, 'vendor')
21
+ const MARKER = path.join(VENDOR_DIR, 'version')
22
+ const CHECKSUMS = 'checksums.txt'
23
+ const SHA256_HEX_LENGTH = 64
24
+ const DOWNLOAD_TIMEOUT_MS = 120000
25
+
26
+ const PLATFORMS = { darwin: 'darwin', linux: 'linux', win32: 'windows' }
27
+ const ARCHES = { x64: 'amd64', arm64: 'arm64' }
28
+
29
+ /** Returns the archive name for this machine, or throws for an unsupported one. */
30
+ function archiveName() {
31
+ const goos = PLATFORMS[process.platform]
32
+ const goarch = ARCHES[process.arch]
33
+ if (!goos || !goarch) {
34
+ throw new Error(`maritime-cli has no binary for ${process.platform}/${process.arch}`)
35
+ }
36
+ const ext = goos === 'windows' ? 'zip' : 'tar.gz'
37
+ return `maritime_${VERSION}_${goos}_${goarch}.${ext}`
38
+ }
39
+
40
+ /** Returns the installed binary path for this machine. */
41
+ function binaryPath() {
42
+ return path.join(VENDOR_DIR, process.platform === 'win32' ? 'maritime.exe' : 'maritime')
43
+ }
44
+
45
+ /** Fetches url and returns its body as a Buffer. */
46
+ async function download(url) {
47
+ const controller = new AbortController()
48
+ const timer = setTimeout(() => controller.abort(), DOWNLOAD_TIMEOUT_MS)
49
+ try {
50
+ const response = await fetch(url, { redirect: 'follow', signal: controller.signal })
51
+ if (!response.ok) {
52
+ throw new Error(`${url}: HTTP ${response.status}`)
53
+ }
54
+ return Buffer.from(await response.arrayBuffer())
55
+ } finally {
56
+ clearTimeout(timer)
57
+ }
58
+ }
59
+
60
+ /** Returns the expected SHA-256 of name from the checksums file text. */
61
+ function expectedChecksum(checksums, name) {
62
+ for (const line of checksums.split('\n')) {
63
+ const [hash, file] = line.trim().split(/\s+/)
64
+ if (file === name && hash && hash.length === SHA256_HEX_LENGTH) {
65
+ return hash
66
+ }
67
+ }
68
+ throw new Error(`${CHECKSUMS} has no entry for ${name}`)
69
+ }
70
+
71
+ /** Unpacks archive (tar.gz or zip) into dir with the system tar. */
72
+ function extract(archive, dir) {
73
+ // bsdtar on macOS and Windows 10+, GNU tar on Linux; all read both formats.
74
+ execFileSync('tar', ['-xf', archive, '-C', dir], { stdio: 'inherit' })
75
+ }
76
+
77
+ async function install() {
78
+ const name = archiveName()
79
+ const bin = binaryPath()
80
+ if (fs.existsSync(bin) && fs.existsSync(MARKER) && fs.readFileSync(MARKER, 'utf8').trim() === VERSION) {
81
+ return
82
+ }
83
+ const base = (process.env.MARITIME_CLI_DOWNLOAD_BASE || DEFAULT_BASE).replace(/\/+$/, '')
84
+ const [archive, checksums] = await Promise.all([
85
+ download(`${base}/${name}`),
86
+ download(`${base}/${CHECKSUMS}`),
87
+ ])
88
+ const actual = createHash('sha256').update(archive).digest('hex')
89
+ const expected = expectedChecksum(checksums.toString('utf8'), name)
90
+ if (actual !== expected) {
91
+ throw new Error(`${name}: SHA-256 ${actual} does not match ${CHECKSUMS} (${expected})`)
92
+ }
93
+ fs.rmSync(VENDOR_DIR, { recursive: true, force: true })
94
+ fs.mkdirSync(VENDOR_DIR, { recursive: true })
95
+ const tmp = path.join(os.tmpdir(), `maritime-cli-${process.pid}-${name}`)
96
+ fs.writeFileSync(tmp, archive)
97
+ try {
98
+ extract(tmp, VENDOR_DIR)
99
+ } finally {
100
+ fs.rmSync(tmp, { force: true })
101
+ }
102
+ if (!fs.existsSync(bin)) {
103
+ throw new Error(`${name} did not contain ${path.basename(bin)}`)
104
+ }
105
+ if (process.platform !== 'win32') {
106
+ fs.chmodSync(bin, 0o755)
107
+ }
108
+ fs.writeFileSync(MARKER, `${VERSION}\n`)
109
+ }
110
+
111
+ module.exports = { install, binaryPath }
112
+
113
+ if (require.main === module) {
114
+ install().catch((error) => {
115
+ console.error(`maritime-cli: ${error.message}`)
116
+ process.exit(1)
117
+ })
118
+ }
package/package.json CHANGED
@@ -1,50 +1,35 @@
1
1
  {
2
2
  "name": "maritime-cli",
3
- "version": "1.9.0",
4
- "description": "Maritime CLI - Deploy and talk to AI agents from your terminal",
5
- "type": "module",
6
- "license": "MIT",
7
- "author": "mariagorskikh",
3
+ "version": "2.0.0",
4
+ "description": "Maritime command line client: provision, operate, and inspect AI agents on maritime.sh.",
5
+ "license": "Apache-2.0",
8
6
  "repository": {
9
7
  "type": "git",
10
- "url": "https://github.com/mariagorskikh/maritime"
8
+ "url": "https://github.com/maritime-sh/maritime.git",
9
+ "directory": "cli/npm"
11
10
  },
12
- "keywords": [
13
- "ai",
14
- "agents",
15
- "deploy",
16
- "cli",
17
- "maritime"
18
- ],
11
+ "homepage": "https://maritime.sh",
19
12
  "bin": {
20
- "maritime": "./dist/index.js"
13
+ "maritime": "bin/maritime.js"
21
14
  },
22
15
  "files": [
23
- "dist",
24
- "AGENTS.md",
25
- "SKILL.md"
16
+ "bin",
17
+ "install.js",
18
+ "README.md"
26
19
  ],
27
- "engines": {
28
- "node": ">=20.12"
29
- },
30
20
  "scripts": {
31
- "build": "tsc && chmod +x dist/index.js",
32
- "dev": "tsx src/index.ts",
33
- "prepublishOnly": "npm run build"
21
+ "postinstall": "node install.js"
34
22
  },
35
- "dependencies": {
36
- "@inquirer/prompts": "^7.0.0",
37
- "chalk": "^5.3.0",
38
- "commander": "^12.0.0",
39
- "conf": "^12.0.0",
40
- "open": "^10.0.0",
41
- "ora": "^8.0.0",
42
- "ws": "^8.16.0"
23
+ "engines": {
24
+ "node": ">=18"
43
25
  },
44
- "devDependencies": {
45
- "@types/node": "^20.0.0",
46
- "@types/ws": "^8.5.0",
47
- "tsx": "^4.0.0",
48
- "typescript": "^5.0.0"
49
- }
26
+ "os": [
27
+ "darwin",
28
+ "linux",
29
+ "win32"
30
+ ],
31
+ "cpu": [
32
+ "x64",
33
+ "arm64"
34
+ ]
50
35
  }
package/AGENTS.md DELETED
@@ -1,361 +0,0 @@
1
- # Maritime CLI · machine interface
2
-
3
- This document is the contract for driving the `maritime` CLI from a program or
4
- an AI agent (not a human at a keyboard). It is safe to paste into an agent's
5
- system prompt as a tool spec.
6
-
7
- ## Install
8
-
9
- ```bash
10
- npm i -g maritime-cli
11
- maritime --version
12
- ```
13
-
14
- ## Authentication (non-interactive)
15
-
16
- The CLI reads a bearer token from the `MARITIME_TOKEN` environment variable
17
- before anything else. An agent must set this and never run the interactive
18
- `login` flow.
19
-
20
- Prefer a **long-lived API key** (`mk_…`) over the JWT from `maritime login`,
21
- which expires. Mint one once as a human:
22
-
23
- ```bash
24
- maritime login # human, one time
25
- maritime keys create --name my-agent --json
26
- # → { "key": "mk_...", ... } (shown ONCE, store it)
27
- ```
28
-
29
- Then give the agent only the key:
30
-
31
- ```bash
32
- export MARITIME_TOKEN=mk_xxxxxxxxxxxxxxxxxxxxxxxx
33
- ```
34
-
35
- `mk_` keys do not expire. Rotate with `maritime keys list` / `maritime keys revoke <id>`.
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
-
89
- ## Output contract: always pass `--json`
90
-
91
- With `--json`, every command obeys a strict contract:
92
-
93
- | Channel | On success | On failure |
94
- |---|---|---|
95
- | **stdout** | a single JSON value, nothing else | empty |
96
- | **stderr** | empty | a single JSON error object |
97
- | **exit code** | `0` | non-zero (see below) |
98
-
99
- The failure object is:
100
-
101
- ```json
102
- { "ok": false, "error": { "code": "not_authenticated", "message": "…", "status": 401 } }
103
- ```
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
-
115
- Always read stdout for results and branch on the exit code. Never parse human text.
116
-
117
- ### Exit codes
118
-
119
- | Code | Meaning |
120
- |---|---|
121
- | `0` | success |
122
- | `1` | generic error (request failed, server error, network) |
123
- | `2` | auth error (not logged in, token expired/invalid) |
124
- | `3` | not found (no such agent) |
125
- | `4` | usage error (missing/invalid arguments) |
126
-
127
- ## The project model: a directory is an agent
128
-
129
- Like `vercel` / `railway`, you can link a directory to an agent and then run
130
- commands without naming it. Two files:
131
-
132
- - **`maritime.json`**: committed config describing the agent: `name`,
133
- `template` (or `framework`), persona `instructions`, env `["KEY", …]` (keys
134
- only). The source of truth.
135
- - **`.maritime/project.json`**: machine-local link (git-ignored) pointing at
136
- the agent this directory operates on.
137
-
138
- ```bash
139
- maritime init <name> --json # scaffold maritime.json + AGENTS.md, create + link
140
- maritime link <agent> --json # link this dir to an existing agent
141
- maritime deploy --json # reconcile the agent to maritime.json, then ship
142
- ```
143
-
144
- Once linked, the `<agent>` argument is **optional on every command**. It falls
145
- back to the linked agent (resolved by walking up from the cwd):
146
-
147
- ```bash
148
- maritime chat "what's open?" --json # talks to the linked agent
149
- maritime logs --json # linked agent's logs
150
- maritime env set FOO=bar --json # linked agent's env (KEY=value ⇒ no agent token)
151
- maritime status --json # linked agent's detail
152
- ```
153
-
154
- For automation you can ignore linking entirely and pass `<agent>` on every call
155
- (below). To target a different agent from inside a linked dir, pass it
156
- explicitly: `-a/--agent` on `chat`, or the positional name on commands that take
157
- a single agent.
158
-
159
- ## The interaction primitive: `chat`
160
-
161
- Send a message to a deployed agent and get its reply. Sleeping serverless
162
- agents are auto-woken by the backend.
163
-
164
- ```bash
165
- # explicit agent + message
166
- maritime chat <agent> "summarize today's incidents" --json
167
-
168
- # linked dir: positionals are the message, target = linked agent
169
- maritime chat "summarize today's incidents" --json
170
-
171
- # message piped via stdin (best for long / multi-line prompts)
172
- cat prompt.txt | maritime chat <agent> --json
173
-
174
- # multi-turn: thread a conversation id
175
- maritime chat <agent> "and the one before that?" --conversation-id abc123 --json
176
- ```
177
-
178
- `<agent>` is a name (exact match), an ID prefix, or (omitted) the linked agent.
179
-
180
- Success shape:
181
-
182
- ```json
183
- { "ok": true, "agentId": "…", "agentName": "…", "conversationId": null, "response": "…the agent's reply…" }
184
- ```
185
-
186
- Without `--json`, `chat` prints only the reply text on stdout (clean for piping).
187
-
188
- ### Messaging AS an end-user: `message`
189
-
190
- `chat` targets one agent; `message` routes by YOUR end-user id through the
191
- agent's project front door: the same `--user` always reaches the same
192
- dedicated agent, and an unknown id gets one assigned/spawned per the
193
- project's `newChatPolicy`.
194
-
195
- ```bash
196
- maritime message <agent> --user cust_42 "where is my order?" --json | jq -r '.reply'
197
- maritime message <agent> --user cust_42 --wait 0 "hi" --json # ack now; reply via message.reply webhook
198
- ```
199
-
200
- `status:"replied"` carries `.reply` inline; `"provisioning"`/`"queued"` means
201
- the user's agent is still booting. Poll the message id or subscribe to the
202
- `message.reply` webhook (`POST /api/v1/webhooks`).
203
-
204
- ## Sizing (optional)
205
-
206
- You don't size agents. `maritime create <name>` picks an applicable size for the
207
- framework, and the agent auto-sleeps when idle and wakes on the next `chat`.
208
-
209
- For hand-tuning one agent (e.g. a reseller dialing resources per client), `create`
210
- accepts optional per-agent overrides. They're hidden from `--help` but fully
211
- supported; omitted flags get the platform defaults.
212
-
213
- ```bash
214
- maritime create my-agent \
215
- --ram 2048 \ # RAM in MB
216
- --cpu 1.5 \ # vCPU cores (fractional OK)
217
- --idle 600 \ # auto-sleep 600s after the last request
218
- --disk 20 # workspace SSD in GB
219
- # …or keep it resident:
220
- maritime create my-agent --always-on # never auto-sleep (mutually exclusive with --idle)
221
- ```
222
-
223
- `--idle`/`--always-on` control how long the agent stays up after a request.
224
- This overrides the platform's default serverless idle cap, so an orchestrator
225
- that dispatches a long job and waits for a webhook won't be slept out from under
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).
229
- `status <agent> --json` echoes `memMb`, `vcpus`, `idleTtlSeconds`
230
- (`0` = always-on, `null` = platform default) and `diskMb`.
231
-
232
- ## Batches: `create --count`
233
-
234
- `maritime create <name> --count <n>` (n = 2-50) spins up **n identical agents**
235
- in a single call. `<name>` becomes the prefix, so agents are named
236
- `<name>-1` … `<name>-n`. `--count 1` (the default) is the classic single-agent
237
- path, unchanged.
238
-
239
- ```bash
240
- maritime create swarm --template openclaw --count 5 --idle 3600 --json
241
- ```
242
-
243
- Flags supported alongside `--count > 1`: `--template`,
244
- `--idle`/`--always-on`, `--repo`, and `-e/--env` (applied to every agent).
245
- In the batch path `--idle 0` means always-on (same as `--always-on`).
246
- Any other `create` flag (`--branch`, `--public`, `--port`, `--framework`,
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.
250
-
251
- Success shape (`--json`, the backend response verbatim):
252
-
253
- ```json
254
- {
255
- "created": [{ "id": "…", "name": "swarm-1", "status": "deploying" }],
256
- "failed": [{ "name": "swarm-3", "error": "…" }],
257
- "requested": 5
258
- }
259
- ```
260
-
261
- Exit codes: `0` = **all** requested agents created (`failed` empty);
262
- `1` = partial or none, so inspect `created`/`failed` on stdout. Limit
263
- rejections surface as the standard error object on stderr with exit `1`:
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).
267
-
268
- ```bash
269
- # Recipe: spin up 5 agents, then fan a message out to every one of them
270
- maritime create swarm --template openclaw --count 5 --idle 3600 --json \
271
- | jq -r '.created[].name' \
272
- | xargs -I{} maritime chat {} "introduce yourself" --json
273
- ```
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
-
296
- ## Environment variables
297
-
298
- Values are secret (encrypted) by default. Env changes apply on the next
299
- container boot unless you `--reload` (hot-reload into the running container).
300
-
301
- ```bash
302
- # one or many at once
303
- maritime env set <agent> OPENAI_API_KEY=sk-… LOG_LEVEL=debug --no-secret --json
304
-
305
- # bulk upload a whole .env file (or pipe one via stdin), then hot-reload
306
- maritime env import <agent> ./prod.env --reload --json
307
- cat prod.env | maritime env import <agent> - --reload --json
308
-
309
- maritime env list <agent> --json
310
- maritime env remove <agent> OPENAI_API_KEY --reload --json
311
- maritime env reload <agent> --json # hot-reload without changing values
312
- maritime env pull <agent> .env --json # write env to a local .env (secret VALUES masked)
313
- ```
314
-
315
- `import`/`set` return `{ok, uploaded:[…], failed:[{key,error}], reloaded}`.
316
- A partial failure exits `1` with the failed keys listed in `failed`. In a linked
317
- dir the agent is implied: `maritime env set FOO=bar --json`, `maritime env pull`.
318
-
319
- ## Command map
320
-
321
- Project: `init`, `link`, `deploy` (a directory ⇄ an agent)
322
- Auth / keys: `login`, `logout`, `whoami`, `keys {create,list,revoke}`
323
- Lifecycle: `create`, `list`, `deploy`, `delete`
324
- Interaction: `chat`/`send`, `message` (per-end-user front door)
325
- Config: `env {set,import,list,remove,reload,pull}`
326
- Observe: `status`, `logs`
327
-
328
- Advanced / ops (hidden from `--help`, still fully supported): `start`, `stop`,
329
- `restart`, `sleep`, `exec <agent> <cmd...>`, `info`, `history`,
330
- `triggers`, `templates`. You rarely need these: lifecycle is
331
- automatic (idle-sleep + auto-wake on `chat`).
332
-
333
- Run `maritime <cmd> --help` for flags. Every command accepts the global
334
- `--json` and `--verbose`.
335
-
336
- ## Recipes
337
-
338
- ```bash
339
- # Is an agent healthy?
340
- maritime status my-agent --json | jq -r '.status'
341
-
342
- # Create, then talk to it
343
- ID=$(maritime create researcher --template openclaw --json | jq -r '.id')
344
- maritime chat "$ID" "introduce yourself" --json | jq -r '.response'
345
-
346
- # Run a shell command inside the container
347
- maritime exec my-agent ls /data --json | jq -r '.stdout'
348
-
349
- # Tail recent error logs as JSON
350
- maritime logs my-agent --level error --json
351
- ```
352
-
353
- ## Notes for agents
354
-
355
- - `delete` refuses to run non-interactively without `--yes` (exit `4`); pass
356
- `--yes` deliberately.
357
- - `create` needs a name (positional `<name>`, or `--name`) when non-interactive (exit `4`).
358
- - Non-2xx that the backend reports inside a body (e.g. agent not running for
359
- `chat`) surfaces as `error.code = "agent_unavailable"`, exit `1`.
360
- - The API base URL can be overridden with `MARITIME_API_URL` (default
361
- `https://api.maritime.sh`).