maritime-cli 1.6.1 → 1.7.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 +24 -24
- package/dist/api.js +6 -1
- package/dist/commands/blueprint.js +4 -4
- package/dist/commands/chat.js +9 -2
- package/dist/commands/create.js +8 -13
- package/dist/commands/deploy.js +49 -17
- package/dist/commands/env.js +4 -4
- package/dist/commands/exec.js +4 -1
- package/dist/commands/guide.js +4 -4
- package/dist/commands/history.js +1 -1
- package/dist/commands/info.js +0 -1
- package/dist/commands/init.js +1 -6
- package/dist/commands/keys.js +3 -3
- package/dist/commands/list.js +0 -2
- package/dist/commands/login.js +12 -7
- package/dist/commands/logs.js +29 -20
- package/dist/commands/message.js +2 -2
- package/dist/commands/open.js +2 -1
- package/dist/commands/scale.js +5 -3
- package/dist/commands/signup.js +4 -2
- package/dist/commands/status.js +0 -1
- package/dist/commands/whoami.js +3 -2
- package/dist/context.d.ts +2 -4
- package/dist/context.js +2 -2
- package/dist/index.js +65 -23
- package/dist/interactive.js +2 -3
- package/dist/output.d.ts +19 -2
- package/dist/output.js +30 -3
- package/dist/prompt.js +4 -0
- package/dist/resolve.d.ts +0 -1
- package/dist/version-check.d.ts +12 -2
- package/dist/version-check.js +30 -8
- package/dist/websocket.d.ts +9 -0
- package/dist/websocket.js +42 -8
- package/package.json +2 -2
package/AGENTS.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Maritime CLI
|
|
1
|
+
# Maritime CLI · machine interface
|
|
2
2
|
|
|
3
3
|
This document is the contract for driving the `maritime` CLI from a program or
|
|
4
4
|
an AI agent (not a human at a keyboard). It is safe to paste into an agent's
|
|
@@ -23,7 +23,7 @@ which expires. Mint one once as a human:
|
|
|
23
23
|
```bash
|
|
24
24
|
maritime login # human, one time
|
|
25
25
|
maritime keys create --name my-agent --json
|
|
26
|
-
# → { "key": "mk_...", ... } (shown ONCE
|
|
26
|
+
# → { "key": "mk_...", ... } (shown ONCE, store it)
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
Then give the agent only the key:
|
|
@@ -34,7 +34,7 @@ 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
|
-
## Output contract
|
|
37
|
+
## Output contract: always pass `--json`
|
|
38
38
|
|
|
39
39
|
With `--json`, every command obeys a strict contract:
|
|
40
40
|
|
|
@@ -62,15 +62,15 @@ Always read stdout for results and branch on the exit code. Never parse human te
|
|
|
62
62
|
| `3` | not found (no such agent) |
|
|
63
63
|
| `4` | usage error (missing/invalid arguments) |
|
|
64
64
|
|
|
65
|
-
## The project model
|
|
65
|
+
## The project model: a directory is an agent
|
|
66
66
|
|
|
67
67
|
Like `vercel` / `railway`, you can link a directory to an agent and then run
|
|
68
68
|
commands without naming it. Two files:
|
|
69
69
|
|
|
70
|
-
- **`maritime.json
|
|
70
|
+
- **`maritime.json`**: committed config describing the agent: `name`,
|
|
71
71
|
`template` (or `framework`), persona `instructions`, env `["KEY", …]` (keys
|
|
72
|
-
only)
|
|
73
|
-
- **`.maritime/project.json
|
|
72
|
+
only). The source of truth.
|
|
73
|
+
- **`.maritime/project.json`**: machine-local link (git-ignored) pointing at
|
|
74
74
|
the agent this directory operates on.
|
|
75
75
|
|
|
76
76
|
```bash
|
|
@@ -79,7 +79,7 @@ maritime link <agent> --json # link this dir to an existing agent
|
|
|
79
79
|
maritime deploy --json # reconcile the agent to maritime.json, then ship
|
|
80
80
|
```
|
|
81
81
|
|
|
82
|
-
Once linked, the `<agent>` argument is **optional on every command
|
|
82
|
+
Once linked, the `<agent>` argument is **optional on every command**. It falls
|
|
83
83
|
back to the linked agent (resolved by walking up from the cwd):
|
|
84
84
|
|
|
85
85
|
```bash
|
|
@@ -94,7 +94,7 @@ For automation you can ignore linking entirely and pass `<agent>` on every call
|
|
|
94
94
|
explicitly: `-a/--agent` on `chat`, or the positional name on commands that take
|
|
95
95
|
a single agent.
|
|
96
96
|
|
|
97
|
-
## The interaction primitive
|
|
97
|
+
## The interaction primitive: `chat`
|
|
98
98
|
|
|
99
99
|
Send a message to a deployed agent and get its reply. Sleeping serverless
|
|
100
100
|
agents are auto-woken by the backend.
|
|
@@ -113,7 +113,7 @@ cat prompt.txt | maritime chat <agent> --json
|
|
|
113
113
|
maritime chat <agent> "and the one before that?" --conversation-id abc123 --json
|
|
114
114
|
```
|
|
115
115
|
|
|
116
|
-
`<agent>` is a name (exact match), an ID prefix, or
|
|
116
|
+
`<agent>` is a name (exact match), an ID prefix, or (omitted) the linked agent.
|
|
117
117
|
|
|
118
118
|
Success shape:
|
|
119
119
|
|
|
@@ -123,7 +123,7 @@ Success shape:
|
|
|
123
123
|
|
|
124
124
|
Without `--json`, `chat` prints only the reply text on stdout (clean for piping).
|
|
125
125
|
|
|
126
|
-
### Messaging AS an end-user
|
|
126
|
+
### Messaging AS an end-user: `message`
|
|
127
127
|
|
|
128
128
|
`chat` targets one agent; `message` routes by YOUR end-user id through the
|
|
129
129
|
agent's project front door: the same `--user` always reaches the same
|
|
@@ -136,7 +136,7 @@ maritime message <agent> --user cust_42 --wait 0 "hi" --json # ack now; reply
|
|
|
136
136
|
```
|
|
137
137
|
|
|
138
138
|
`status:"replied"` carries `.reply` inline; `"provisioning"`/`"queued"` means
|
|
139
|
-
the user's agent is still booting
|
|
139
|
+
the user's agent is still booting. Poll the message id or subscribe to the
|
|
140
140
|
`message.reply` webhook (`POST /api/v1/webhooks`).
|
|
141
141
|
|
|
142
142
|
## Sizing (optional)
|
|
@@ -146,7 +146,7 @@ framework, and the agent auto-sleeps when idle and wakes on the next `chat`.
|
|
|
146
146
|
|
|
147
147
|
For hand-tuning one agent (e.g. a reseller dialing resources per client), `create`
|
|
148
148
|
accepts optional per-agent overrides. They're hidden from `--help` but fully
|
|
149
|
-
supported; omitted flags
|
|
149
|
+
supported; omitted flags get the platform defaults.
|
|
150
150
|
|
|
151
151
|
```bash
|
|
152
152
|
maritime create my-agent \
|
|
@@ -159,19 +159,19 @@ maritime create my-agent \
|
|
|
159
159
|
maritime create my-agent --always-on # never auto-sleep (mutually exclusive with --idle)
|
|
160
160
|
```
|
|
161
161
|
|
|
162
|
-
`--idle`/`--always-on` control how long the agent stays up after a request
|
|
163
|
-
|
|
162
|
+
`--idle`/`--always-on` control how long the agent stays up after a request.
|
|
163
|
+
This overrides the platform's default serverless idle cap, so an orchestrator
|
|
164
164
|
that dispatches a long job and waits for a webhook won't be slept out from under
|
|
165
165
|
the wait. `--disk` and `--max-compute` are per-agent overrides on top of the
|
|
166
166
|
owner's account plan (disk is clamped to the plan's storage cap; the compute cap
|
|
167
167
|
auto-sleeps the agent for the rest of the billing period when hit).
|
|
168
168
|
`status <agent> --json` echoes `memMb`, `vcpus`, `idleTtlSeconds`
|
|
169
|
-
(`0` = always-on, `null` =
|
|
169
|
+
(`0` = always-on, `null` = platform default), `diskMb`, and `computeMinutesLimit`.
|
|
170
170
|
|
|
171
|
-
## Fleets
|
|
171
|
+
## Fleets: `create --count`
|
|
172
172
|
|
|
173
|
-
`maritime create <name> --count <n>` (n = 2
|
|
174
|
-
in a single call. `<name>` becomes the prefix
|
|
173
|
+
`maritime create <name> --count <n>` (n = 2-50) spins up **n identical agents**
|
|
174
|
+
in a single call. `<name>` becomes the prefix, so agents are named
|
|
175
175
|
`<name>-1` … `<name>-n`. `--count 1` (the default) is the classic single-agent
|
|
176
176
|
path, unchanged.
|
|
177
177
|
|
|
@@ -179,12 +179,12 @@ path, unchanged.
|
|
|
179
179
|
maritime create swarm --template openclaw --count 5 --idle 3600 --json
|
|
180
180
|
```
|
|
181
181
|
|
|
182
|
-
Flags supported alongside `--count > 1`: `--template`,
|
|
182
|
+
Flags supported alongside `--count > 1`: `--template`,
|
|
183
183
|
`--idle`/`--always-on`, `--repo`, and `-e/--env` (applied to every agent).
|
|
184
184
|
In the fleet path `--idle 0` means always-on (same as `--always-on`).
|
|
185
185
|
Any other `create` flag (`--branch`, `--public`, `--port`, `--framework`,
|
|
186
186
|
`--ram`, `--cpu`, `--disk`, `--max-compute`) combined with `--count > 1` is a
|
|
187
|
-
usage error (exit `4`)
|
|
187
|
+
usage error (exit `4`); nothing is silently dropped. `--count` above 50 is
|
|
188
188
|
also exit `4`; the 50-agent cap is enforced server-side too.
|
|
189
189
|
|
|
190
190
|
Success shape (`--json`, the backend response verbatim):
|
|
@@ -199,7 +199,7 @@ Success shape (`--json`, the backend response verbatim):
|
|
|
199
199
|
```
|
|
200
200
|
|
|
201
201
|
Exit codes: `0` = **all** requested agents created (`failed` empty);
|
|
202
|
-
`1` = partial or none
|
|
202
|
+
`1` = partial or none, so inspect `created`/`failed` on stdout. Billing/limit
|
|
203
203
|
rejections surface as the standard error object on stderr with exit `1`:
|
|
204
204
|
`402` → `error.code = "insufficient_balance"` (each agent bills $1/mo from the
|
|
205
205
|
wallet; n agents need n×$1 available), `403` → `error.code =
|
|
@@ -245,8 +245,8 @@ Config: `env {set,import,list,remove,reload,pull}`
|
|
|
245
245
|
Observe: `status`, `logs`
|
|
246
246
|
|
|
247
247
|
Advanced / ops (hidden from `--help`, still fully supported): `start`, `stop`,
|
|
248
|
-
`restart`, `sleep`, `
|
|
249
|
-
`triggers`, `blueprint`, `templates`. You rarely need these
|
|
248
|
+
`restart`, `sleep`, `exec <agent> <cmd...>`, `info`, `history`,
|
|
249
|
+
`triggers`, `blueprint`, `templates`. You rarely need these: lifecycle is
|
|
250
250
|
automatic (idle-sleep + auto-wake on `chat`).
|
|
251
251
|
|
|
252
252
|
Run `maritime <cmd> --help` for flags. Every command accepts the global
|
package/dist/api.js
CHANGED
|
@@ -124,7 +124,12 @@ async function parseJson(response) {
|
|
|
124
124
|
return JSON.parse(text);
|
|
125
125
|
}
|
|
126
126
|
catch {
|
|
127
|
-
|
|
127
|
+
// A non-JSON body is almost always an edge/proxy error page (502/503
|
|
128
|
+
// HTML, plain-text 500). Surface the status and a snippet so the
|
|
129
|
+
// operator sees WHAT the server said instead of a bare parse failure.
|
|
130
|
+
const snippet = text.replace(/<[^>]*>/g, ' ').replace(/\s+/g, ' ').trim().slice(0, 160);
|
|
131
|
+
throw new CliHttpError(response.status, `Non-JSON response (HTTP ${response.status}) from ${response.url}` +
|
|
132
|
+
(snippet ? `: ${snippet}` : ''));
|
|
128
133
|
}
|
|
129
134
|
}
|
|
130
135
|
async function handleResponse(response) {
|
|
@@ -4,7 +4,7 @@ import { authGet, authPost } from '../api.js';
|
|
|
4
4
|
import { resolveAgent } from '../resolve.js';
|
|
5
5
|
import { isJsonMode, outputJson, handleError, makeSpinner } from '../output.js';
|
|
6
6
|
const blueprintListCmd = new Command('list')
|
|
7
|
-
.description('List your
|
|
7
|
+
.description('List your templates')
|
|
8
8
|
.action(async () => {
|
|
9
9
|
try {
|
|
10
10
|
const blueprints = await authGet('/api/blueprints');
|
|
@@ -36,7 +36,7 @@ const blueprintListCmd = new Command('list')
|
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
const blueprintCreateCmd = new Command('create')
|
|
39
|
-
.description('Create a
|
|
39
|
+
.description('Create a template from an agent')
|
|
40
40
|
.argument('<agent>', 'Agent name or ID')
|
|
41
41
|
.option('--name <name>', 'Blueprint name')
|
|
42
42
|
.option('--visibility <vis>', 'Visibility (private, unlisted, public)', 'private')
|
|
@@ -62,7 +62,7 @@ const blueprintCreateCmd = new Command('create')
|
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
64
|
const blueprintDeployCmd = new Command('deploy')
|
|
65
|
-
.description('Deploy a new agent from a
|
|
65
|
+
.description('Deploy a new agent from a template')
|
|
66
66
|
.argument('<slug>', 'Blueprint slug or ID')
|
|
67
67
|
.option('--name <name>', 'Name for the new agent')
|
|
68
68
|
.action(async (slug, opts) => {
|
|
@@ -86,7 +86,7 @@ const blueprintDeployCmd = new Command('deploy')
|
|
|
86
86
|
});
|
|
87
87
|
export const blueprintCommand = new Command('blueprint')
|
|
88
88
|
.alias('bp')
|
|
89
|
-
.description('Manage
|
|
89
|
+
.description('Manage templates')
|
|
90
90
|
.addCommand(blueprintListCmd)
|
|
91
91
|
.addCommand(blueprintCreateCmd)
|
|
92
92
|
.addCommand(blueprintDeployCmd);
|
package/dist/commands/chat.js
CHANGED
|
@@ -7,12 +7,19 @@ import { outputResult, fail, handleError, makeSpinner } from '../output.js';
|
|
|
7
7
|
function readStdin() {
|
|
8
8
|
return new Promise((resolve) => {
|
|
9
9
|
let data = '';
|
|
10
|
+
const done = () => {
|
|
11
|
+
// Release the handle so the process can exit the moment the command
|
|
12
|
+
// finishes (a listening stdin would otherwise hold the event loop).
|
|
13
|
+
process.stdin.pause();
|
|
14
|
+
process.stdin.removeAllListeners('data');
|
|
15
|
+
resolve(data);
|
|
16
|
+
};
|
|
10
17
|
process.stdin.setEncoding('utf8');
|
|
11
18
|
process.stdin.on('data', (chunk) => {
|
|
12
19
|
data += chunk;
|
|
13
20
|
});
|
|
14
|
-
process.stdin.
|
|
15
|
-
process.stdin.
|
|
21
|
+
process.stdin.once('end', done);
|
|
22
|
+
process.stdin.once('error', done);
|
|
16
23
|
});
|
|
17
24
|
}
|
|
18
25
|
/**
|
package/dist/commands/create.js
CHANGED
|
@@ -29,7 +29,7 @@ export const createCommand = new Command('create')
|
|
|
29
29
|
.argument('[name]', 'Agent name')
|
|
30
30
|
.option('-t, --template <template>', 'Template to base the agent on (see `maritime templates`)')
|
|
31
31
|
.option('-e, --env <pairs...>', 'Environment variables (KEY=value)')
|
|
32
|
-
.option('--count <n>', 'Spin up N identical agents in one call (fleet)
|
|
32
|
+
.option('--count <n>', 'Spin up N identical agents in one call (fleet). Names become <name>-1..<name>-N')
|
|
33
33
|
.option('-r, --repo <url>', 'Deploy from a GitHub repo (must contain a Dockerfile)')
|
|
34
34
|
.option('-b, --branch <branch>', 'Git branch to deploy (with --repo)')
|
|
35
35
|
.option('--public', 'Serve a public, no-login web URL for this agent (web apps)')
|
|
@@ -40,8 +40,7 @@ export const createCommand = new Command('create')
|
|
|
40
40
|
// to hand-tune a specific agent (e.g. a reseller dialing RAM per client).
|
|
41
41
|
.addOption(new Option('-n, --name <name>', 'Agent name (alias for the positional argument)').hideHelp())
|
|
42
42
|
.addOption(new Option('--framework <framework>', 'Framework (default: custom)').hideHelp())
|
|
43
|
-
.addOption(new Option('--
|
|
44
|
-
.addOption(new Option('--ram <mb>', 'RAM in MB (per-agent override of the tier default)').hideHelp())
|
|
43
|
+
.addOption(new Option('--ram <mb>', 'RAM in MB (per-agent override of the default)').hideHelp())
|
|
45
44
|
.addOption(new Option('--cpu <cores>', 'vCPU cores, e.g. 0.5 or 2 (per-agent override)').hideHelp())
|
|
46
45
|
.addOption(new Option('--idle <seconds>', 'Auto-sleep this many seconds after the last request').hideHelp())
|
|
47
46
|
.addOption(new Option('--always-on', 'Never auto-sleep (mutually exclusive with --idle)').hideHelp())
|
|
@@ -69,7 +68,7 @@ Examples:
|
|
|
69
68
|
});
|
|
70
69
|
}
|
|
71
70
|
if (n > FLEET_CAP) {
|
|
72
|
-
fail('Fleet spin-ups are capped at 50 agents. Contact us if you need more
|
|
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 });
|
|
73
72
|
}
|
|
74
73
|
count = n;
|
|
75
74
|
}
|
|
@@ -94,7 +93,7 @@ Examples:
|
|
|
94
93
|
if (templates.length > 0) {
|
|
95
94
|
console.log(chalk.dim('\nAvailable templates:'));
|
|
96
95
|
templates.forEach((t, i) => {
|
|
97
|
-
console.log(` ${chalk.bold(String(i + 1))}. ${t.name} (${t.framework})${t.description ? '
|
|
96
|
+
console.log(` ${chalk.bold(String(i + 1))}. ${t.name} (${t.framework})${t.description ? ' · ' + t.description : ''}`);
|
|
98
97
|
});
|
|
99
98
|
console.log();
|
|
100
99
|
const choice = await promptForValue('Template number (or press Enter to skip)');
|
|
@@ -131,7 +130,7 @@ Examples:
|
|
|
131
130
|
unsupported.push('--max-compute');
|
|
132
131
|
if (unsupported.length > 0) {
|
|
133
132
|
fail(`${unsupported.join(', ')} cannot be combined with --count > 1. ` +
|
|
134
|
-
'Fleet spin-ups support --template, --
|
|
133
|
+
'Fleet spin-ups support --template, --idle/--always-on, --repo, and -e/--env.', { code: 'usage', exitCode: EXIT.USAGE });
|
|
135
134
|
}
|
|
136
135
|
if (opts.alwaysOn && opts.idle !== undefined) {
|
|
137
136
|
fail('--always-on and --idle are mutually exclusive.', { code: 'usage', exitCode: EXIT.USAGE });
|
|
@@ -139,8 +138,6 @@ Examples:
|
|
|
139
138
|
const batchBody = { namePrefix: name, count };
|
|
140
139
|
if (templateId)
|
|
141
140
|
batchBody.templateId = templateId;
|
|
142
|
-
if (opts.tier)
|
|
143
|
-
batchBody.tier = opts.tier;
|
|
144
141
|
if (opts.repo)
|
|
145
142
|
batchBody.githubRepo = opts.repo;
|
|
146
143
|
if (opts.env)
|
|
@@ -210,7 +207,7 @@ Examples:
|
|
|
210
207
|
});
|
|
211
208
|
// Exit contract: 0 = all created, 1 = partial or none.
|
|
212
209
|
if (!allCreated)
|
|
213
|
-
process.
|
|
210
|
+
process.exitCode = EXIT.ERROR;
|
|
214
211
|
return;
|
|
215
212
|
}
|
|
216
213
|
const body = { name };
|
|
@@ -218,8 +215,6 @@ Examples:
|
|
|
218
215
|
body.templateId = templateId;
|
|
219
216
|
if (opts.framework)
|
|
220
217
|
body.framework = opts.framework;
|
|
221
|
-
if (opts.tier)
|
|
222
|
-
body.tier = opts.tier;
|
|
223
218
|
if (opts.env)
|
|
224
219
|
body.initialEnvVars = parseEnvPairs(opts.env);
|
|
225
220
|
if (opts.repo)
|
|
@@ -236,7 +231,7 @@ Examples:
|
|
|
236
231
|
body.exposedPort = Number(opts.port);
|
|
237
232
|
else if (opts.public)
|
|
238
233
|
body.exposedPort = 8080;
|
|
239
|
-
// Per-agent resource overrides (serverless). Omitted fields inherit the
|
|
234
|
+
// Per-agent resource overrides (serverless). Omitted fields inherit the defaults.
|
|
240
235
|
if (opts.alwaysOn && opts.idle !== undefined) {
|
|
241
236
|
fail('--always-on and --idle are mutually exclusive.', { code: 'usage', exitCode: 4 });
|
|
242
237
|
}
|
|
@@ -289,7 +284,7 @@ Examples:
|
|
|
289
284
|
}
|
|
290
285
|
spinner.succeed(chalk.green('Created ') + chalk.bold(agent.name) + chalk.dim(` (${agent.id})`));
|
|
291
286
|
outputResult({ ok: true, action: 'create', ...agent }, () => {
|
|
292
|
-
console.log(chalk.dim(` Framework: ${agent.framework} |
|
|
287
|
+
console.log(chalk.dim(` Framework: ${agent.framework} | Status: ${agent.status}`));
|
|
293
288
|
const res = [];
|
|
294
289
|
if (agent.memMb)
|
|
295
290
|
res.push(`RAM ${agent.memMb}MB`);
|
package/dist/commands/deploy.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
-
import { authPost
|
|
3
|
+
import { authPost } from '../api.js';
|
|
4
4
|
import { resolveAgent } from '../resolve.js';
|
|
5
5
|
import { getConfig, getLinkedAgentId, writeLink } from '../context.js';
|
|
6
6
|
import { isJsonMode, outputJson, fail, handleError, makeSpinner, EXIT } from '../output.js';
|
|
7
7
|
import { connectWs } from '../websocket.js';
|
|
8
|
+
// Upper bound for `deploy --wait`. Repo builds + micro-VM ship normally
|
|
9
|
+
// finish in 1-3 minutes; 15 minutes covers cold image pulls with margin.
|
|
10
|
+
const WAIT_TIMEOUT_MS = 15 * 60 * 1000;
|
|
8
11
|
export const deployCommand = new Command('deploy')
|
|
9
12
|
.description('Deploy this directory: reconcile the agent to maritime.json, then ship it')
|
|
10
13
|
.argument('[agent]', 'Agent name or ID (defaults to the linked agent / maritime.json)')
|
|
@@ -14,8 +17,8 @@ export const deployCommand = new Command('deploy')
|
|
|
14
17
|
.option('--branch <branch>', 'Git branch')
|
|
15
18
|
.option('-w, --wait', 'Wait for deployment to complete')
|
|
16
19
|
.addHelpText('after', `
|
|
17
|
-
In a linked project, just run \`maritime deploy
|
|
18
|
-
creates the agent if needed, applies the persona
|
|
20
|
+
In a linked project, just run \`maritime deploy\`: it reads maritime.json,
|
|
21
|
+
creates the agent if needed, applies the persona, and redeploys.
|
|
19
22
|
Explicit sources still work: \`maritime deploy --source github --repo <url>\`.`)
|
|
20
23
|
.action(async (agentArg, opts) => {
|
|
21
24
|
try {
|
|
@@ -43,7 +46,7 @@ Explicit sources still work: \`maritime deploy --source github --repo <url>\`.`)
|
|
|
43
46
|
else {
|
|
44
47
|
fail('Nothing to deploy. Pass an agent, link one (`maritime link`), or add maritime.json (`maritime init`).', { code: 'no_agent', exitCode: EXIT.USAGE });
|
|
45
48
|
}
|
|
46
|
-
// ── Reconcile the agent to maritime.json (persona
|
|
49
|
+
// ── Reconcile the agent to maritime.json (persona) ────────────────
|
|
47
50
|
if (config && !explicitSource) {
|
|
48
51
|
await reconcile(agent.id, config);
|
|
49
52
|
}
|
|
@@ -71,25 +74,51 @@ Explicit sources still work: \`maritime deploy --source github --repo <url>\`.`)
|
|
|
71
74
|
});
|
|
72
75
|
return;
|
|
73
76
|
}
|
|
74
|
-
// --wait: stream deploy progress via WebSocket
|
|
77
|
+
// --wait: stream deploy progress via WebSocket. The server closes
|
|
78
|
+
// the socket on terminal status; the client-side timeout is the
|
|
79
|
+
// last-resort bound so --wait can never hang a script forever.
|
|
75
80
|
if (spinner)
|
|
76
81
|
spinner.text = `Building ${chalk.bold(agent.name)}...`;
|
|
82
|
+
let gatewayUnconfirmed = false;
|
|
77
83
|
await new Promise((resolve, reject) => {
|
|
84
|
+
let settled = false;
|
|
85
|
+
const settle = (fn) => {
|
|
86
|
+
if (settled)
|
|
87
|
+
return;
|
|
88
|
+
settled = true;
|
|
89
|
+
clearTimeout(timer);
|
|
90
|
+
fn();
|
|
91
|
+
};
|
|
92
|
+
const timer = setTimeout(() => {
|
|
93
|
+
settle(() => {
|
|
94
|
+
cleanup();
|
|
95
|
+
spinner?.fail('Timed out waiting for the deployment');
|
|
96
|
+
reject(new Error(`Timed out after ${WAIT_TIMEOUT_MS / 60000} minutes waiting for the deployment. ` +
|
|
97
|
+
'It may still complete: check `maritime status` / `maritime logs`.'));
|
|
98
|
+
});
|
|
99
|
+
}, WAIT_TIMEOUT_MS);
|
|
78
100
|
const cleanup = connectWs(`/api/deploy/${agent.id}/status`, {
|
|
79
101
|
onMessage(data) {
|
|
80
102
|
try {
|
|
81
103
|
const msg = JSON.parse(data);
|
|
82
104
|
if (msg.message && spinner)
|
|
83
105
|
spinner.text = msg.message;
|
|
106
|
+
if (msg.build_log && /did not confirm ready/i.test(msg.build_log)) {
|
|
107
|
+
gatewayUnconfirmed = true;
|
|
108
|
+
}
|
|
84
109
|
if (msg.status === 'success' || msg.status === 'completed') {
|
|
85
110
|
spinner?.succeed(chalk.green('Deployment complete: ') + chalk.bold(agent.name));
|
|
86
|
-
|
|
87
|
-
|
|
111
|
+
settle(() => {
|
|
112
|
+
cleanup();
|
|
113
|
+
resolve();
|
|
114
|
+
});
|
|
88
115
|
}
|
|
89
116
|
else if (msg.status === 'failed') {
|
|
90
117
|
spinner?.fail(chalk.red('Deployment failed: ') + (msg.message || 'unknown error'));
|
|
91
|
-
|
|
92
|
-
|
|
118
|
+
settle(() => {
|
|
119
|
+
cleanup();
|
|
120
|
+
reject(new Error('Deployment failed'));
|
|
121
|
+
});
|
|
93
122
|
}
|
|
94
123
|
}
|
|
95
124
|
catch {
|
|
@@ -98,12 +127,20 @@ Explicit sources still work: \`maritime deploy --source github --repo <url>\`.`)
|
|
|
98
127
|
}
|
|
99
128
|
},
|
|
100
129
|
onClose() {
|
|
101
|
-
resolve
|
|
130
|
+
settle(resolve);
|
|
102
131
|
},
|
|
103
132
|
maxReconnects: 3,
|
|
104
133
|
});
|
|
105
134
|
});
|
|
106
|
-
|
|
135
|
+
// Deploy success with an unconfirmed gateway means the VM booted but
|
|
136
|
+
// the app never answered on $PORT: historically that is a dead-on-
|
|
137
|
+
// arrival agent. Say so instead of reporting a clean success.
|
|
138
|
+
if (gatewayUnconfirmed && !isJsonMode()) {
|
|
139
|
+
console.log(chalk.yellow('Warning:') +
|
|
140
|
+
' the app never confirmed it was listening on $PORT. If the public URL 502s,' +
|
|
141
|
+
' check `maritime logs` for the container output (a crashed process takes the whole micro-VM down).');
|
|
142
|
+
}
|
|
143
|
+
finish({ ...deployment, gatewayUnconfirmed }, () => { });
|
|
107
144
|
}
|
|
108
145
|
catch (error) {
|
|
109
146
|
spinner?.fail('Deployment failed');
|
|
@@ -121,13 +158,11 @@ async function createFromConfig(config) {
|
|
|
121
158
|
body.templateId = config.template;
|
|
122
159
|
if (config.framework)
|
|
123
160
|
body.framework = config.framework;
|
|
124
|
-
if (config.tier)
|
|
125
|
-
body.tier = config.tier;
|
|
126
161
|
if (config.instructions)
|
|
127
162
|
body.instructions = config.instructions;
|
|
128
163
|
return authPost('/api/agents', body);
|
|
129
164
|
}
|
|
130
|
-
/** Apply persona
|
|
165
|
+
/** Apply persona from config to an existing agent (env takes effect on redeploy). */
|
|
131
166
|
async function reconcile(agentId, config) {
|
|
132
167
|
if (config.instructions) {
|
|
133
168
|
await authPost(`/api/agents/${agentId}/env`, {
|
|
@@ -136,9 +171,6 @@ async function reconcile(agentId, config) {
|
|
|
136
171
|
is_secret: false,
|
|
137
172
|
});
|
|
138
173
|
}
|
|
139
|
-
if (config.tier) {
|
|
140
|
-
await authPut(`/api/agents/${agentId}`, { tier: config.tier });
|
|
141
|
-
}
|
|
142
174
|
}
|
|
143
175
|
function finish(json, human) {
|
|
144
176
|
if (isJsonMode())
|
package/dist/commands/env.js
CHANGED
|
@@ -150,7 +150,7 @@ envCommand
|
|
|
150
150
|
console.log(chalk.yellow(' Reload skipped or failed; changes land on next boot.'));
|
|
151
151
|
});
|
|
152
152
|
if (failed.length > 0)
|
|
153
|
-
process.
|
|
153
|
+
process.exitCode = EXIT.ERROR;
|
|
154
154
|
}
|
|
155
155
|
catch (error) {
|
|
156
156
|
handleError(error);
|
|
@@ -229,7 +229,7 @@ envCommand
|
|
|
229
229
|
console.log(chalk.yellow(' Reload skipped or failed; changes land on next boot.'));
|
|
230
230
|
});
|
|
231
231
|
if (failed.length > 0)
|
|
232
|
-
process.
|
|
232
|
+
process.exitCode = EXIT.ERROR;
|
|
233
233
|
}
|
|
234
234
|
catch (error) {
|
|
235
235
|
handleError(error);
|
|
@@ -332,7 +332,7 @@ envCommand
|
|
|
332
332
|
keys.push(v.key);
|
|
333
333
|
if (v.is_secret) {
|
|
334
334
|
secretKeys.push(v.key);
|
|
335
|
-
lines.push(`${v.key}= # secret
|
|
335
|
+
lines.push(`${v.key}= # secret: value not exported; fill it in`);
|
|
336
336
|
}
|
|
337
337
|
else {
|
|
338
338
|
lines.push(`${v.key}=${v.value}`);
|
|
@@ -349,7 +349,7 @@ envCommand
|
|
|
349
349
|
outputResult({ ok: true, agentId: agent.id, file: outFile, keys, secretKeys }, () => {
|
|
350
350
|
console.log(chalk.green(`Pulled ${keys.length} var(s) → `) + chalk.bold(outFile));
|
|
351
351
|
if (secretKeys.length) {
|
|
352
|
-
console.log(chalk.dim(` ${secretKeys.length} secret value(s) masked
|
|
352
|
+
console.log(chalk.dim(` ${secretKeys.length} secret value(s) masked. Fill in: ${secretKeys.join(', ')}`));
|
|
353
353
|
}
|
|
354
354
|
});
|
|
355
355
|
}
|
package/dist/commands/exec.js
CHANGED
|
@@ -20,7 +20,10 @@ export const execCommand = new Command('exec')
|
|
|
20
20
|
process.stdout.write(result.stdout);
|
|
21
21
|
if (result.stderr)
|
|
22
22
|
process.stderr.write(result.stderr);
|
|
23
|
-
process.exit
|
|
23
|
+
// exitCode + return (NOT process.exit): letting the loop drain flushes
|
|
24
|
+
// stdout on Windows pipes and avoids the libuv teardown assertion that
|
|
25
|
+
// intermittently killed `maritime exec` right after printing.
|
|
26
|
+
process.exitCode = result.exitCode ?? 0;
|
|
24
27
|
}
|
|
25
28
|
catch (error) {
|
|
26
29
|
handleError(error);
|
package/dist/commands/guide.js
CHANGED
|
@@ -13,9 +13,9 @@ const CONTRACT = {
|
|
|
13
13
|
auth: 'Set the MARITIME_TOKEN env var to a long-lived API key (mk_…, minted via `maritime keys create`) or a login JWT. The CLI reads it before anything else; never run interactive login in automation.',
|
|
14
14
|
json: 'Pass --json on every command. Success → one JSON value on stdout, stderr empty. Failure → one JSON object {ok:false,error:{code,message,status?}} on stderr, stdout empty.',
|
|
15
15
|
exitCodes: { '0': 'ok', '1': 'error', '2': 'auth', '3': 'not_found', '4': 'usage' },
|
|
16
|
-
interaction: 'Talk to a deployed agent with `maritime chat <agent> <message>` (or pipe the message via stdin). Returns the reply text (or {response} under --json). Sleeping serverless agents auto-wake. To message AS one of YOUR end-users (sticky per-user agents via the project front door), use `maritime message <agent> --user <externalUserId> <message
|
|
17
|
-
resources: 'create accepts per-agent overrides: --ram <mb>, --cpu <cores>, --idle <seconds> | --always-on, --disk <gb>, --max-compute <minutes>. Omitted =
|
|
18
|
-
fleet: 'create --count <n> (2
|
|
16
|
+
interaction: 'Talk to a deployed agent with `maritime chat <agent> <message>` (or pipe the message via stdin). Returns the reply text (or {response} under --json). Sleeping serverless agents auto-wake. To message AS one of YOUR end-users (sticky per-user agents via the project front door), use `maritime message <agent> --user <externalUserId> <message>`; status:replied carries .reply inline; provisioning/queued means the reply arrives via the message.reply webhook.',
|
|
17
|
+
resources: 'create accepts per-agent overrides: --ram <mb>, --cpu <cores>, --idle <seconds> | --always-on, --disk <gb>, --max-compute <minutes>. Omitted = platform defaults.',
|
|
18
|
+
fleet: 'create --count <n> (2-50) spins up n identical agents named <name>-1..<name>-n in one call. Supported alongside --count: --template, --idle/--always-on, --repo, -e/--env; other create flags exit 4. --json returns {created:[{id,name,status}],failed:[{name,error}],requested,monthlyCostCents}. Exit 0 = all created, 1 = partial/none (402 insufficient wallet balance, 403 over the 50-agent cap → exit 1).',
|
|
19
19
|
project: 'A directory can be linked to an agent (like vercel/railway). `maritime init <name>` scaffolds maritime.json + AGENTS.md and links it; `maritime link <agent>` links an existing one; `maritime deploy` reconciles the agent to maritime.json. Once linked, the <agent> argument is optional on every command (resolved from .maritime/project.json, walking up from cwd).',
|
|
20
20
|
apiBase: 'Override the API base with MARITIME_API_URL (default https://api.maritime.sh).',
|
|
21
21
|
};
|
|
@@ -76,7 +76,7 @@ export const guideCommand = new Command('guide')
|
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
78
|
// Fallback if AGENTS.md wasn't shipped: print the contract essentials.
|
|
79
|
-
console.log('Maritime CLI
|
|
79
|
+
console.log('Maritime CLI · programmatic / AI-agent usage\n');
|
|
80
80
|
console.log(` Auth: ${CONTRACT.auth}`);
|
|
81
81
|
console.log(` JSON: ${CONTRACT.json}`);
|
|
82
82
|
console.log(` Chat: ${CONTRACT.interaction}`);
|
package/dist/commands/history.js
CHANGED
|
@@ -40,7 +40,7 @@ export const historyCommand = new Command('history')
|
|
|
40
40
|
const colorFn = statusColors[d.status] || chalk.white;
|
|
41
41
|
const sha = d.commitSha ? d.commitSha.slice(0, 7) : chalk.dim('n/a');
|
|
42
42
|
const started = new Date(d.startedAt).toLocaleString();
|
|
43
|
-
const completed = d.completedAt ? new Date(d.completedAt).toLocaleString() : chalk.dim('
|
|
43
|
+
const completed = d.completedAt ? new Date(d.completedAt).toLocaleString() : chalk.dim('n/a');
|
|
44
44
|
console.log(' ' +
|
|
45
45
|
chalk.dim(d.id.slice(0, 12).padEnd(14)) +
|
|
46
46
|
colorFn(d.status.padEnd(12)) +
|
package/dist/commands/info.js
CHANGED
|
@@ -31,7 +31,6 @@ export const infoCommand = new Command('info')
|
|
|
31
31
|
['ID', chalk.dim(agent.id)],
|
|
32
32
|
['Status', statusColor(agent.status)],
|
|
33
33
|
['Framework', agent.framework],
|
|
34
|
-
['Tier', agent.tier],
|
|
35
34
|
['Created', agent.createdAt ? new Date(agent.createdAt).toLocaleString() : 'n/a'],
|
|
36
35
|
];
|
|
37
36
|
if (agent.githubRepo)
|
package/dist/commands/init.js
CHANGED
|
@@ -8,7 +8,7 @@ import { promptForValue } from '../prompt.js';
|
|
|
8
8
|
import { isJsonMode, outputResult, fail, handleError, makeSpinner, EXIT } from '../output.js';
|
|
9
9
|
const AGENTS_MD = (name, instructions) => `# ${name}
|
|
10
10
|
|
|
11
|
-
${instructions || 'Describe what this agent does and how it should behave. This file is the agent\'s persona
|
|
11
|
+
${instructions || 'Describe what this agent does and how it should behave. This file is the agent\'s persona. It is loaded into the agent\'s workspace at boot.'}
|
|
12
12
|
|
|
13
13
|
## Guidelines
|
|
14
14
|
- Be concise and helpful.
|
|
@@ -20,7 +20,6 @@ export const initCommand = new Command('init')
|
|
|
20
20
|
.option('-t, --template <id>', 'Template to base the agent on (default: openclaw)')
|
|
21
21
|
.option('--framework <framework>', 'Framework for bring-your-own-code agents (instead of a template)')
|
|
22
22
|
.option('--instructions <text>', 'Plain-English persona for the agent')
|
|
23
|
-
.option('--tier <tier>', 'Tier: smart, extended, always_on')
|
|
24
23
|
.option('--no-create', 'Only write the config files; do not create the agent yet')
|
|
25
24
|
.addHelpText('after', `
|
|
26
25
|
Examples:
|
|
@@ -47,14 +46,12 @@ After init, run \`maritime deploy\` to push changes, or \`maritime chat "…"\`.
|
|
|
47
46
|
? undefined
|
|
48
47
|
: opts.template || existing.template || 'openclaw';
|
|
49
48
|
const instructions = opts.instructions ?? existing.instructions ?? '';
|
|
50
|
-
const tier = opts.tier || existing.tier;
|
|
51
49
|
const config = {
|
|
52
50
|
name,
|
|
53
51
|
...(template ? { template } : {}),
|
|
54
52
|
...(framework ? { framework } : {}),
|
|
55
53
|
...(instructions ? { instructions } : {}),
|
|
56
54
|
env: existing.env ?? [],
|
|
57
|
-
...(tier ? { tier } : {}),
|
|
58
55
|
};
|
|
59
56
|
const wroteConfig = !configExists();
|
|
60
57
|
const configPath = writeConfig(config);
|
|
@@ -76,8 +73,6 @@ After init, run \`maritime deploy\` to push changes, or \`maritime chat "…"\`.
|
|
|
76
73
|
body.templateId = template;
|
|
77
74
|
if (framework)
|
|
78
75
|
body.framework = framework;
|
|
79
|
-
if (tier)
|
|
80
|
-
body.tier = tier;
|
|
81
76
|
if (instructions)
|
|
82
77
|
body.instructions = instructions;
|
|
83
78
|
agent = await authPost('/api/agents', body);
|
package/dist/commands/keys.js
CHANGED
|
@@ -7,9 +7,9 @@ export const keysCommand = new Command('keys')
|
|
|
7
7
|
.description('Manage long-lived API keys (mk_…) for non-interactive / AI-agent access');
|
|
8
8
|
keysCommand
|
|
9
9
|
.command('create')
|
|
10
|
-
.description('Mint a new API key. Shown once
|
|
10
|
+
.description('Mint a new API key. Shown once, so save it as MARITIME_TOKEN.')
|
|
11
11
|
.option('-n, --name <name>', 'Label for the key', 'cli-agent')
|
|
12
|
-
.option('-s, --scopes <scopes>', `Comma-separated scopes (${VALID_SCOPES.join(', ')}); "manage" = all. Defaults to full access
|
|
12
|
+
.option('-s, --scopes <scopes>', `Comma-separated scopes (${VALID_SCOPES.join(', ')}); "manage" = all. Defaults to full access. Pass a narrower set to restrict the key.`, 'provision,deploy,secrets,manage')
|
|
13
13
|
.action(async (opts) => {
|
|
14
14
|
try {
|
|
15
15
|
const scopes = String(opts.scopes)
|
|
@@ -27,7 +27,7 @@ keysCommand
|
|
|
27
27
|
console.log();
|
|
28
28
|
console.log(' ' + chalk.bold(created.raw_key));
|
|
29
29
|
console.log();
|
|
30
|
-
console.log(chalk.yellow(' Save this now
|
|
30
|
+
console.log(chalk.yellow(' Save this now. It will not be shown again.'));
|
|
31
31
|
console.log(chalk.dim(' Use it non-interactively with:'));
|
|
32
32
|
console.log(chalk.dim(` export MARITIME_TOKEN=${created.raw_key}`));
|
|
33
33
|
});
|
package/dist/commands/list.js
CHANGED
|
@@ -27,7 +27,6 @@ export const listCommand = new Command('list')
|
|
|
27
27
|
chalk.dim('NAME'.padEnd(24)) +
|
|
28
28
|
chalk.dim('STATUS'.padEnd(12)) +
|
|
29
29
|
chalk.dim('FRAMEWORK'.padEnd(20)) +
|
|
30
|
-
chalk.dim('TIER'.padEnd(12)) +
|
|
31
30
|
chalk.dim('CREATED'));
|
|
32
31
|
console.log(chalk.dim(' ' + '\u2500'.repeat(80)));
|
|
33
32
|
for (const a of agents) {
|
|
@@ -39,7 +38,6 @@ export const listCommand = new Command('list')
|
|
|
39
38
|
chalk.bold(name.padEnd(24)) +
|
|
40
39
|
colorFn(a.status.padEnd(12)) +
|
|
41
40
|
fw.padEnd(20) +
|
|
42
|
-
a.tier.padEnd(12) +
|
|
43
41
|
chalk.dim(created));
|
|
44
42
|
}
|
|
45
43
|
console.log();
|