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.
- package/README.md +17 -0
- package/bin/maritime.js +40 -0
- package/install.js +118 -0
- package/package.json +22 -37
- package/AGENTS.md +0 -361
- package/SKILL.md +0 -181
- package/dist/api.d.ts +0 -30
- package/dist/api.js +0 -246
- package/dist/bundled.d.ts +0 -11
- package/dist/bundled.js +0 -25
- package/dist/commands/chat.d.ts +0 -2
- package/dist/commands/chat.js +0 -120
- package/dist/commands/create.d.ts +0 -2
- package/dist/commands/create.js +0 -310
- package/dist/commands/delete.d.ts +0 -2
- package/dist/commands/delete.js +0 -43
- package/dist/commands/deploy.d.ts +0 -2
- package/dist/commands/deploy.js +0 -180
- package/dist/commands/env.d.ts +0 -2
- package/dist/commands/env.js +0 -368
- package/dist/commands/exec.d.ts +0 -2
- package/dist/commands/exec.js +0 -31
- package/dist/commands/guide.d.ts +0 -2
- package/dist/commands/guide.js +0 -75
- package/dist/commands/history.d.ts +0 -2
- package/dist/commands/history.js +0 -56
- package/dist/commands/info.d.ts +0 -2
- package/dist/commands/info.js +0 -78
- package/dist/commands/init.d.ts +0 -2
- package/dist/commands/init.js +0 -143
- package/dist/commands/keys.d.ts +0 -2
- package/dist/commands/keys.js +0 -90
- package/dist/commands/link.d.ts +0 -4
- package/dist/commands/link.js +0 -65
- package/dist/commands/list.d.ts +0 -2
- package/dist/commands/list.js +0 -55
- package/dist/commands/login.d.ts +0 -2
- package/dist/commands/login.js +0 -368
- package/dist/commands/logout.d.ts +0 -2
- package/dist/commands/logout.js +0 -12
- package/dist/commands/logs.d.ts +0 -2
- package/dist/commands/logs.js +0 -89
- package/dist/commands/message.d.ts +0 -8
- package/dist/commands/message.js +0 -75
- package/dist/commands/open.d.ts +0 -2
- package/dist/commands/open.js +0 -25
- package/dist/commands/restart.d.ts +0 -2
- package/dist/commands/restart.js +0 -26
- package/dist/commands/signup.d.ts +0 -2
- package/dist/commands/signup.js +0 -72
- package/dist/commands/sleep.d.ts +0 -2
- package/dist/commands/sleep.js +0 -22
- package/dist/commands/start.d.ts +0 -2
- package/dist/commands/start.js +0 -27
- package/dist/commands/status.d.ts +0 -2
- package/dist/commands/status.js +0 -69
- package/dist/commands/stop.d.ts +0 -2
- package/dist/commands/stop.js +0 -26
- package/dist/commands/templates.d.ts +0 -2
- package/dist/commands/templates.js +0 -40
- package/dist/commands/triggers.d.ts +0 -2
- package/dist/commands/triggers.js +0 -89
- package/dist/commands/whoami.d.ts +0 -2
- package/dist/commands/whoami.js +0 -76
- package/dist/config.d.ts +0 -2
- package/dist/config.js +0 -14
- package/dist/context.d.ts +0 -39
- package/dist/context.js +0 -110
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -186
- package/dist/interactive.d.ts +0 -1
- package/dist/interactive.js +0 -66
- package/dist/output.d.ts +0 -80
- package/dist/output.js +0 -176
- package/dist/prompt.d.ts +0 -2
- package/dist/prompt.js +0 -62
- package/dist/resolve.d.ts +0 -16
- package/dist/resolve.js +0 -59
- package/dist/version-check.d.ts +0 -20
- package/dist/version-check.js +0 -81
- package/dist/websocket.d.ts +0 -22
- package/dist/websocket.js +0 -89
package/dist/commands/env.js
DELETED
|
@@ -1,368 +0,0 @@
|
|
|
1
|
-
import { readFileSync, writeFileSync, existsSync } from 'node:fs';
|
|
2
|
-
import { Command } from 'commander';
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
import { authGet, authPost, authDelete } from '../api.js';
|
|
5
|
-
import { resolveAgent } from '../resolve.js';
|
|
6
|
-
import { getLinkedAgentId } from '../context.js';
|
|
7
|
-
import { isJsonMode, outputJson, outputResult, fail, handleError, makeSpinner, EXIT } from '../output.js';
|
|
8
|
-
/** Parse a single KEY=value token (as passed on the command line). */
|
|
9
|
-
function parsePair(pair) {
|
|
10
|
-
const eqIdx = pair.indexOf('=');
|
|
11
|
-
if (eqIdx <= 0) {
|
|
12
|
-
fail(`Invalid format: "${pair}". Use KEY=value.`, { code: 'usage', exitCode: EXIT.USAGE });
|
|
13
|
-
}
|
|
14
|
-
return { key: pair.slice(0, eqIdx), value: pair.slice(eqIdx + 1) };
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Parse a dotenv-style document into key/value pairs. Supports blank lines,
|
|
18
|
-
* `#` comments, an optional `export ` prefix, and single/double-quoted values.
|
|
19
|
-
*/
|
|
20
|
-
function parseDotenv(text) {
|
|
21
|
-
const pairs = [];
|
|
22
|
-
for (const rawLine of text.split('\n')) {
|
|
23
|
-
let line = rawLine.trim();
|
|
24
|
-
if (!line || line.startsWith('#'))
|
|
25
|
-
continue;
|
|
26
|
-
if (line.startsWith('export '))
|
|
27
|
-
line = line.slice('export '.length).trim();
|
|
28
|
-
const eqIdx = line.indexOf('=');
|
|
29
|
-
if (eqIdx <= 0)
|
|
30
|
-
continue; // skip malformed lines rather than abort the batch
|
|
31
|
-
const key = line.slice(0, eqIdx).trim();
|
|
32
|
-
let value = line.slice(eqIdx + 1).trim();
|
|
33
|
-
// Strip matching surrounding quotes; unescape \n only inside double quotes.
|
|
34
|
-
if ((value.startsWith('"') && value.endsWith('"')) ||
|
|
35
|
-
(value.startsWith("'") && value.endsWith("'"))) {
|
|
36
|
-
const quote = value[0];
|
|
37
|
-
value = value.slice(1, -1);
|
|
38
|
-
if (quote === '"')
|
|
39
|
-
value = value.replace(/\\n/g, '\n');
|
|
40
|
-
}
|
|
41
|
-
if (key)
|
|
42
|
-
pairs.push({ key, value });
|
|
43
|
-
}
|
|
44
|
-
return pairs;
|
|
45
|
-
}
|
|
46
|
-
/** Upload a batch of vars sequentially; collect per-key outcomes. */
|
|
47
|
-
async function uploadVars(agentId, pairs, isSecret) {
|
|
48
|
-
const uploaded = [];
|
|
49
|
-
const failed = [];
|
|
50
|
-
// The backend warns when a deploy is mid-flight: that boot reads env at
|
|
51
|
-
// container start and may miss these values. One warning covers the batch.
|
|
52
|
-
let warning = null;
|
|
53
|
-
for (const { key, value } of pairs) {
|
|
54
|
-
try {
|
|
55
|
-
const resp = await authPost(`/api/agents/${agentId}/env`, { key, value, is_secret: isSecret });
|
|
56
|
-
if (resp?.warning)
|
|
57
|
-
warning = resp.warning;
|
|
58
|
-
uploaded.push(key);
|
|
59
|
-
}
|
|
60
|
-
catch (error) {
|
|
61
|
-
failed.push({ key, error: error instanceof Error ? error.message : String(error) });
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return { uploaded, failed, warning };
|
|
65
|
-
}
|
|
66
|
-
/** Hot-reload env into the running container (falls back to restart server-side). */
|
|
67
|
-
async function reloadEnv(agentId) {
|
|
68
|
-
await authPost(`/api/agents/${agentId}/reload-env`);
|
|
69
|
-
}
|
|
70
|
-
export const envCommand = new Command('env')
|
|
71
|
-
.description('Manage environment variables')
|
|
72
|
-
.addHelpText('after', `
|
|
73
|
-
Examples:
|
|
74
|
-
maritime env set my-agent OPENAI_API_KEY=sk-… --json
|
|
75
|
-
maritime env import my-agent ./prod.env --reload --json
|
|
76
|
-
maritime env reload my-agent --json
|
|
77
|
-
Secrets are encrypted and marked secret by default; changes apply on next
|
|
78
|
-
boot unless you pass --reload.`);
|
|
79
|
-
// --- list -----------------------------------------------------------------
|
|
80
|
-
envCommand
|
|
81
|
-
.command('list [agent]')
|
|
82
|
-
.alias('ls')
|
|
83
|
-
.description('List environment variables')
|
|
84
|
-
.action(async (agentArg) => {
|
|
85
|
-
try {
|
|
86
|
-
const agent = await resolveAgent(agentArg);
|
|
87
|
-
const vars = await authGet(`/api/agents/${agent.id}/env`);
|
|
88
|
-
if (isJsonMode()) {
|
|
89
|
-
outputJson(vars);
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
if (vars.length === 0) {
|
|
93
|
-
console.log(chalk.dim(`\nNo environment variables set for ${chalk.bold(agent.name)}.`));
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
console.log(chalk.dim(`\nEnvironment variables for ${chalk.bold(agent.name)}:\n`));
|
|
97
|
-
for (const v of vars) {
|
|
98
|
-
const display = v.is_secret ? chalk.dim('••••••••') : v.value;
|
|
99
|
-
console.log(` ${chalk.bold(v.key.padEnd(24))} = ${display}`);
|
|
100
|
-
}
|
|
101
|
-
console.log();
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
handleError(error);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
// --- set (one or many pairs) ----------------------------------------------
|
|
108
|
-
envCommand
|
|
109
|
-
.command('set [agent] [pairs...]')
|
|
110
|
-
.description('Set one or more environment variables (KEY=value KEY2=value2 …)')
|
|
111
|
-
.option('--no-secret', 'Store as plain (non-secret) values')
|
|
112
|
-
.option('-r, --reload', 'Hot-reload env into the running container afterward')
|
|
113
|
-
.action(async (agentArg, rawPairs, opts) => {
|
|
114
|
-
try {
|
|
115
|
-
// A leading token without "=" is the agent name; otherwise everything is
|
|
116
|
-
// pairs and the agent comes from the linked directory.
|
|
117
|
-
const positionals = [agentArg, ...(rawPairs || [])].filter(Boolean);
|
|
118
|
-
let target;
|
|
119
|
-
let pairTokens;
|
|
120
|
-
if (positionals.length > 0 && !positionals[0].includes('=')) {
|
|
121
|
-
target = positionals[0];
|
|
122
|
-
pairTokens = positionals.slice(1);
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
target = undefined;
|
|
126
|
-
pairTokens = positionals;
|
|
127
|
-
}
|
|
128
|
-
if (pairTokens.length === 0) {
|
|
129
|
-
fail('No KEY=value pairs given.', { code: 'usage', exitCode: EXIT.USAGE });
|
|
130
|
-
}
|
|
131
|
-
const pairs = pairTokens.map(parsePair);
|
|
132
|
-
const agent = await resolveAgent(target);
|
|
133
|
-
const spinner = await makeSpinner(`Setting ${pairs.length} var${pairs.length === 1 ? '' : 's'} for ${agent.name}...`);
|
|
134
|
-
const { uploaded, failed, warning } = await uploadVars(agent.id, pairs, opts.secret);
|
|
135
|
-
let reloaded = false;
|
|
136
|
-
if (opts.reload && uploaded.length > 0) {
|
|
137
|
-
try {
|
|
138
|
-
await reloadEnv(agent.id);
|
|
139
|
-
reloaded = true;
|
|
140
|
-
}
|
|
141
|
-
catch {
|
|
142
|
-
// Surface reload failure but don't undo the writes.
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
if (failed.length > 0)
|
|
146
|
-
spinner.fail(`Set ${uploaded.length}, failed ${failed.length}`);
|
|
147
|
-
else
|
|
148
|
-
spinner.succeed(`Set ${uploaded.length} var${uploaded.length === 1 ? '' : 's'} for ${chalk.bold(agent.name)}`);
|
|
149
|
-
outputResult({ ok: failed.length === 0, agentId: agent.id, uploaded, failed, reloaded, warning }, () => {
|
|
150
|
-
for (const f of failed)
|
|
151
|
-
console.error(chalk.red(` ${f.key}: ${f.error}`));
|
|
152
|
-
if (warning)
|
|
153
|
-
console.log(chalk.yellow(` ${warning}`));
|
|
154
|
-
if (reloaded)
|
|
155
|
-
console.log(chalk.dim(' Reloaded into running container.'));
|
|
156
|
-
else if (opts.reload)
|
|
157
|
-
console.log(chalk.yellow(' Reload skipped or failed; changes land on next boot.'));
|
|
158
|
-
});
|
|
159
|
-
if (failed.length > 0)
|
|
160
|
-
process.exitCode = EXIT.ERROR;
|
|
161
|
-
}
|
|
162
|
-
catch (error) {
|
|
163
|
-
handleError(error);
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
// --- import (.env file or stdin) ------------------------------------------
|
|
167
|
-
envCommand
|
|
168
|
-
.command('import [agent] [file]')
|
|
169
|
-
.description('Upload all keys from a .env file (or stdin if file is "-" / omitted)')
|
|
170
|
-
.option('--plain', 'Store as plain (non-secret) values')
|
|
171
|
-
.option('-r, --reload', 'Hot-reload env into the running container afterward')
|
|
172
|
-
.action(async (agentArg, file, opts) => {
|
|
173
|
-
try {
|
|
174
|
-
// Two positionals always mean `<agent> <file>` — even in a linked dir,
|
|
175
|
-
// an explicit agent must win. The single-positional shorthand treats
|
|
176
|
-
// the arg as the file (agent = linked).
|
|
177
|
-
let target;
|
|
178
|
-
let srcFile;
|
|
179
|
-
if (file !== undefined) {
|
|
180
|
-
target = agentArg;
|
|
181
|
-
srcFile = file;
|
|
182
|
-
}
|
|
183
|
-
else if (getLinkedAgentId()) {
|
|
184
|
-
target = undefined;
|
|
185
|
-
srcFile = agentArg;
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
target = agentArg;
|
|
189
|
-
srcFile = undefined;
|
|
190
|
-
}
|
|
191
|
-
let text;
|
|
192
|
-
if (!srcFile || srcFile === '-') {
|
|
193
|
-
if (process.stdin.isTTY) {
|
|
194
|
-
fail('No input. Pass a .env file path or pipe one via stdin.', {
|
|
195
|
-
code: 'usage',
|
|
196
|
-
exitCode: EXIT.USAGE,
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
text = readFileSync(0, 'utf8'); // fd 0 = stdin
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
try {
|
|
203
|
-
text = readFileSync(srcFile, 'utf8');
|
|
204
|
-
}
|
|
205
|
-
catch {
|
|
206
|
-
fail(`Cannot read file: ${srcFile}`, { code: 'usage', exitCode: EXIT.USAGE });
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
const pairs = parseDotenv(text);
|
|
210
|
-
if (pairs.length === 0) {
|
|
211
|
-
fail('No KEY=value pairs found in input.', { code: 'usage', exitCode: EXIT.USAGE });
|
|
212
|
-
}
|
|
213
|
-
const agent = await resolveAgent(target);
|
|
214
|
-
const spinner = await makeSpinner(`Importing ${pairs.length} vars into ${agent.name}...`);
|
|
215
|
-
const { uploaded, failed, warning } = await uploadVars(agent.id, pairs, !opts.plain);
|
|
216
|
-
let reloaded = false;
|
|
217
|
-
if (opts.reload && uploaded.length > 0) {
|
|
218
|
-
try {
|
|
219
|
-
await reloadEnv(agent.id);
|
|
220
|
-
reloaded = true;
|
|
221
|
-
}
|
|
222
|
-
catch {
|
|
223
|
-
/* keep writes; report below */
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
if (failed.length > 0)
|
|
227
|
-
spinner.fail(`Imported ${uploaded.length}, failed ${failed.length}`);
|
|
228
|
-
else
|
|
229
|
-
spinner.succeed(`Imported ${uploaded.length} vars into ${chalk.bold(agent.name)}`);
|
|
230
|
-
outputResult({ ok: failed.length === 0, agentId: agent.id, uploaded, failed, reloaded, warning }, () => {
|
|
231
|
-
for (const f of failed)
|
|
232
|
-
console.error(chalk.red(` ${f.key}: ${f.error}`));
|
|
233
|
-
if (warning)
|
|
234
|
-
console.log(chalk.yellow(` ${warning}`));
|
|
235
|
-
if (reloaded)
|
|
236
|
-
console.log(chalk.dim(' Reloaded into running container.'));
|
|
237
|
-
else if (opts.reload)
|
|
238
|
-
console.log(chalk.yellow(' Reload skipped or failed; changes land on next boot.'));
|
|
239
|
-
});
|
|
240
|
-
if (failed.length > 0)
|
|
241
|
-
process.exitCode = EXIT.ERROR;
|
|
242
|
-
}
|
|
243
|
-
catch (error) {
|
|
244
|
-
handleError(error);
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
// --- remove ----------------------------------------------------------------
|
|
248
|
-
envCommand
|
|
249
|
-
.command('remove [agent] [key]')
|
|
250
|
-
.alias('rm')
|
|
251
|
-
.description('Remove an environment variable')
|
|
252
|
-
.option('-r, --reload', 'Hot-reload env into the running container afterward')
|
|
253
|
-
.action(async (agentArg, keyArg, opts) => {
|
|
254
|
-
try {
|
|
255
|
-
// Two positionals always mean `<agent> <key>` — even in a linked dir,
|
|
256
|
-
// an explicit agent must win. Only the single-positional shorthand
|
|
257
|
-
// treats the arg as the key (agent = linked).
|
|
258
|
-
let target;
|
|
259
|
-
let key;
|
|
260
|
-
if (keyArg !== undefined) {
|
|
261
|
-
target = agentArg;
|
|
262
|
-
key = keyArg;
|
|
263
|
-
}
|
|
264
|
-
else if (getLinkedAgentId()) {
|
|
265
|
-
target = undefined;
|
|
266
|
-
key = agentArg;
|
|
267
|
-
}
|
|
268
|
-
else {
|
|
269
|
-
target = agentArg;
|
|
270
|
-
key = undefined;
|
|
271
|
-
}
|
|
272
|
-
if (!key) {
|
|
273
|
-
fail('No env key given to remove.', { code: 'usage', exitCode: EXIT.USAGE });
|
|
274
|
-
}
|
|
275
|
-
const agent = await resolveAgent(target);
|
|
276
|
-
const spinner = await makeSpinner(`Removing ${key} from ${agent.name}...`);
|
|
277
|
-
await authDelete(`/api/agents/${agent.id}/env/${encodeURIComponent(key)}`);
|
|
278
|
-
let reloaded = false;
|
|
279
|
-
if (opts.reload) {
|
|
280
|
-
try {
|
|
281
|
-
await reloadEnv(agent.id);
|
|
282
|
-
reloaded = true;
|
|
283
|
-
}
|
|
284
|
-
catch {
|
|
285
|
-
/* ignore */
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
spinner.succeed(`Removed ${chalk.bold(key)} from ${chalk.bold(agent.name)}`);
|
|
289
|
-
outputResult({ ok: true, agentId: agent.id, removed: key, reloaded }, () => { });
|
|
290
|
-
}
|
|
291
|
-
catch (error) {
|
|
292
|
-
handleError(error);
|
|
293
|
-
}
|
|
294
|
-
});
|
|
295
|
-
// --- reload ----------------------------------------------------------------
|
|
296
|
-
envCommand
|
|
297
|
-
.command('reload [agent]')
|
|
298
|
-
.description('Hot-reload env vars into the running container')
|
|
299
|
-
.action(async (agentArg) => {
|
|
300
|
-
try {
|
|
301
|
-
const agent = await resolveAgent(agentArg);
|
|
302
|
-
const spinner = await makeSpinner(`Reloading env for ${agent.name}...`);
|
|
303
|
-
await reloadEnv(agent.id);
|
|
304
|
-
spinner.succeed(`Reloaded env for ${chalk.bold(agent.name)}`);
|
|
305
|
-
outputResult({ ok: true, agentId: agent.id, reloaded: true }, () => { });
|
|
306
|
-
}
|
|
307
|
-
catch (error) {
|
|
308
|
-
handleError(error);
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
// --- pull ------------------------------------------------------------------
|
|
312
|
-
envCommand
|
|
313
|
-
.command('pull [agent] [file]')
|
|
314
|
-
.description('Write the agent’s env to a local .env file (secret values are masked)')
|
|
315
|
-
.option('-f, --force', 'Overwrite the file if it already exists')
|
|
316
|
-
.action(async (agentArg, fileArg, opts) => {
|
|
317
|
-
try {
|
|
318
|
-
// Two positionals always mean `<agent> <file>` — even in a linked dir,
|
|
319
|
-
// an explicit agent must win. The single-positional shorthand treats
|
|
320
|
-
// the arg as the output file (agent = linked).
|
|
321
|
-
let target;
|
|
322
|
-
let outFile;
|
|
323
|
-
if (fileArg !== undefined) {
|
|
324
|
-
target = agentArg;
|
|
325
|
-
outFile = fileArg;
|
|
326
|
-
}
|
|
327
|
-
else if (getLinkedAgentId()) {
|
|
328
|
-
target = undefined;
|
|
329
|
-
outFile = agentArg || '.env';
|
|
330
|
-
}
|
|
331
|
-
else {
|
|
332
|
-
target = agentArg;
|
|
333
|
-
outFile = '.env';
|
|
334
|
-
}
|
|
335
|
-
const agent = await resolveAgent(target);
|
|
336
|
-
const vars = await authGet(`/api/agents/${agent.id}/env`);
|
|
337
|
-
const lines = [];
|
|
338
|
-
const keys = [];
|
|
339
|
-
const secretKeys = [];
|
|
340
|
-
for (const v of vars) {
|
|
341
|
-
keys.push(v.key);
|
|
342
|
-
if (v.is_secret) {
|
|
343
|
-
secretKeys.push(v.key);
|
|
344
|
-
lines.push(`${v.key}= # secret: value not exported; fill it in`);
|
|
345
|
-
}
|
|
346
|
-
else {
|
|
347
|
-
lines.push(`${v.key}=${v.value}`);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
const text = lines.length ? lines.join('\n') + '\n' : '';
|
|
351
|
-
if (existsSync(outFile) && !opts.force) {
|
|
352
|
-
fail(`${outFile} already exists. Pass --force to overwrite.`, {
|
|
353
|
-
code: 'usage',
|
|
354
|
-
exitCode: EXIT.USAGE,
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
writeFileSync(outFile, text);
|
|
358
|
-
outputResult({ ok: true, agentId: agent.id, file: outFile, keys, secretKeys }, () => {
|
|
359
|
-
console.log(chalk.green(`Pulled ${keys.length} var(s) → `) + chalk.bold(outFile));
|
|
360
|
-
if (secretKeys.length) {
|
|
361
|
-
console.log(chalk.dim(` ${secretKeys.length} secret value(s) masked. Fill in: ${secretKeys.join(', ')}`));
|
|
362
|
-
}
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
|
-
catch (error) {
|
|
366
|
-
handleError(error);
|
|
367
|
-
}
|
|
368
|
-
});
|
package/dist/commands/exec.d.ts
DELETED
package/dist/commands/exec.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { authPost } from '../api.js';
|
|
3
|
-
import { resolveAgent } from '../resolve.js';
|
|
4
|
-
import { isJsonMode, outputJson, handleError } from '../output.js';
|
|
5
|
-
export const execCommand = new Command('exec')
|
|
6
|
-
.description('Execute a command in an agent container')
|
|
7
|
-
.argument('<agent>', 'Agent name or ID')
|
|
8
|
-
.argument('<cmd...>', 'Command to run')
|
|
9
|
-
.action(async (agentArg, cmd) => {
|
|
10
|
-
try {
|
|
11
|
-
const agent = await resolveAgent(agentArg);
|
|
12
|
-
const result = await authPost(`/api/agents/${agent.id}/exec`, {
|
|
13
|
-
command: cmd,
|
|
14
|
-
});
|
|
15
|
-
if (isJsonMode()) {
|
|
16
|
-
outputJson(result);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
if (result.stdout)
|
|
20
|
-
process.stdout.write(result.stdout);
|
|
21
|
-
if (result.stderr)
|
|
22
|
-
process.stderr.write(result.stderr);
|
|
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;
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
handleError(error);
|
|
30
|
-
}
|
|
31
|
-
});
|
package/dist/commands/guide.d.ts
DELETED
package/dist/commands/guide.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { readBundledFile } from '../bundled.js';
|
|
3
|
-
import { isJsonMode, outputJson } from '../output.js';
|
|
4
|
-
/**
|
|
5
|
-
* The machine contract an AI agent needs that isn't expressible as flags.
|
|
6
|
-
* Kept in sync with AGENTS.md; emitted by `guide --json` so an agent can learn
|
|
7
|
-
* the rules in one structured call.
|
|
8
|
-
*/
|
|
9
|
-
const CONTRACT = {
|
|
10
|
-
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.',
|
|
11
|
-
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.',
|
|
12
|
-
exitCodes: { '0': 'ok', '1': 'error', '2': 'auth', '3': 'not_found', '4': 'usage' },
|
|
13
|
-
billing: 'A plan sets how many machines you may have (the free plan includes 3). A machine is one micro-VM: an agent is a machine and so is a Computer, and both draw on the same count. When a create is refused for a billing reason the CLI exits 1 with error.status 402 and error.code from the server, usually seat_limit. error.message is the server sentence verbatim: it already names the fix (delete an agent, upgrade, renew a lapsed plan, or add your own INKBOX_API_KEY) and carries https://maritime.sh/billing. Surface it to your user unchanged instead of writing your own reason.',
|
|
14
|
-
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.',
|
|
15
|
-
resources: 'create accepts per-agent overrides: --ram <mb>, --cpu <cores>, --idle <seconds> | --always-on, --disk <gb>. Omitted = platform defaults. Above the included 2 GB RAM / 5 GB SSD, and for --always-on, these are paid add-ons that need a plan; the 402 below says so.',
|
|
16
|
-
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}. Exit 0 = all created, 1 = partial/none. A 402 means a billing gate closed (error.code seat_limit): error.message is the complete server sentence naming the fix and the https://maritime.sh/billing link, so show it as-is. 403 over the 50-agent cap also exits 1.',
|
|
17
|
-
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).',
|
|
18
|
-
apiBase: 'Override the API base with MARITIME_API_URL (default https://api.maritime.sh).',
|
|
19
|
-
};
|
|
20
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
21
|
-
function serializeCommand(cmd) {
|
|
22
|
-
const args = (cmd.registeredArguments ?? cmd._args ?? []);
|
|
23
|
-
return {
|
|
24
|
-
name: cmd.name(),
|
|
25
|
-
aliases: typeof cmd.aliases === 'function' ? cmd.aliases() : [],
|
|
26
|
-
description: typeof cmd.description === 'function' ? cmd.description() : '',
|
|
27
|
-
arguments: args.map((a) => ({
|
|
28
|
-
name: typeof a.name === 'function' ? a.name() : a._name ?? String(a),
|
|
29
|
-
required: Boolean(a.required),
|
|
30
|
-
variadic: Boolean(a.variadic),
|
|
31
|
-
})),
|
|
32
|
-
options: (cmd.options ?? []).map((o) => ({
|
|
33
|
-
flags: o.flags,
|
|
34
|
-
description: o.description ?? '',
|
|
35
|
-
})),
|
|
36
|
-
subcommands: (cmd.commands ?? [])
|
|
37
|
-
.filter((c) => c.name() !== 'help')
|
|
38
|
-
.map(serializeCommand),
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
42
|
-
function readBundledGuide() {
|
|
43
|
-
return readBundledFile('AGENTS.md');
|
|
44
|
-
}
|
|
45
|
-
export const guideCommand = new Command('guide')
|
|
46
|
-
.alias('agent-guide')
|
|
47
|
-
.description('Print the machine-readable usage guide for driving this CLI from code/an AI agent')
|
|
48
|
-
.action((_opts, command) => {
|
|
49
|
-
if (isJsonMode()) {
|
|
50
|
-
// One structured call gives an agent the entire surface + the contract.
|
|
51
|
-
const root = command.parent ?? command;
|
|
52
|
-
const program = root;
|
|
53
|
-
outputJson({
|
|
54
|
-
name: typeof program.name === 'function' ? program.name() : 'maritime',
|
|
55
|
-
contract: CONTRACT,
|
|
56
|
-
commands: (root.commands ?? [])
|
|
57
|
-
.filter((c) => c.name() !== 'help' && c.name() !== 'guide')
|
|
58
|
-
.map(serializeCommand),
|
|
59
|
-
});
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
const md = readBundledGuide();
|
|
63
|
-
if (md) {
|
|
64
|
-
process.stdout.write(md.endsWith('\n') ? md : md + '\n');
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
// Fallback if AGENTS.md wasn't shipped: print the contract essentials.
|
|
68
|
-
console.log('Maritime CLI · programmatic / AI-agent usage\n');
|
|
69
|
-
console.log(` Auth: ${CONTRACT.auth}`);
|
|
70
|
-
console.log(` JSON: ${CONTRACT.json}`);
|
|
71
|
-
console.log(` Chat: ${CONTRACT.interaction}`);
|
|
72
|
-
console.log(` Limits: ${CONTRACT.resources}`);
|
|
73
|
-
console.log(` Billing: ${CONTRACT.billing}`);
|
|
74
|
-
console.log('\n Run `maritime guide --json` for the full structured manifest.');
|
|
75
|
-
});
|
package/dist/commands/history.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { authGet } from '../api.js';
|
|
4
|
-
import { resolveAgent } from '../resolve.js';
|
|
5
|
-
import { isJsonMode, outputJson, handleError } from '../output.js';
|
|
6
|
-
const statusColors = {
|
|
7
|
-
success: chalk.green,
|
|
8
|
-
completed: chalk.green,
|
|
9
|
-
failed: chalk.red,
|
|
10
|
-
pending: chalk.yellow,
|
|
11
|
-
running: chalk.yellow,
|
|
12
|
-
deploying: chalk.yellow,
|
|
13
|
-
};
|
|
14
|
-
export const historyCommand = new Command('history')
|
|
15
|
-
.description('Show deployment history for an agent')
|
|
16
|
-
.argument('<agent>', 'Agent name or ID')
|
|
17
|
-
.option('-n, --limit <num>', 'Number of deployments to show', '10')
|
|
18
|
-
.action(async (agentArg, opts) => {
|
|
19
|
-
try {
|
|
20
|
-
const agent = await resolveAgent(agentArg);
|
|
21
|
-
const deployments = await authGet(`/api/deploy/agent/${agent.id}`);
|
|
22
|
-
const limit = parseInt(opts.limit, 10) || 10;
|
|
23
|
-
const shown = deployments.slice(0, limit);
|
|
24
|
-
if (isJsonMode()) {
|
|
25
|
-
outputJson(shown);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
if (shown.length === 0) {
|
|
29
|
-
console.log(chalk.dim('No deployments found.'));
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
console.log('\n ' +
|
|
33
|
-
chalk.dim('ID'.padEnd(14)) +
|
|
34
|
-
chalk.dim('STATUS'.padEnd(12)) +
|
|
35
|
-
chalk.dim('SHA'.padEnd(10)) +
|
|
36
|
-
chalk.dim('STARTED'.padEnd(22)) +
|
|
37
|
-
chalk.dim('COMPLETED'));
|
|
38
|
-
console.log(chalk.dim(' ' + '\u2500'.repeat(72)));
|
|
39
|
-
for (const d of shown) {
|
|
40
|
-
const colorFn = statusColors[d.status] || chalk.white;
|
|
41
|
-
const sha = d.commitSha ? d.commitSha.slice(0, 7) : chalk.dim('n/a');
|
|
42
|
-
const started = new Date(d.startedAt).toLocaleString();
|
|
43
|
-
const completed = d.completedAt ? new Date(d.completedAt).toLocaleString() : chalk.dim('n/a');
|
|
44
|
-
console.log(' ' +
|
|
45
|
-
chalk.dim(d.id.slice(0, 12).padEnd(14)) +
|
|
46
|
-
colorFn(d.status.padEnd(12)) +
|
|
47
|
-
String(sha).padEnd(10) +
|
|
48
|
-
started.padEnd(22) +
|
|
49
|
-
completed);
|
|
50
|
-
}
|
|
51
|
-
console.log();
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
handleError(error);
|
|
55
|
-
}
|
|
56
|
-
});
|
package/dist/commands/info.d.ts
DELETED
package/dist/commands/info.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { authGet } from '../api.js';
|
|
4
|
-
import { resolveAgent } from '../resolve.js';
|
|
5
|
-
import { isJsonMode, outputJson, handleError } from '../output.js';
|
|
6
|
-
export const infoCommand = new Command('info')
|
|
7
|
-
.description('Show full details for an agent')
|
|
8
|
-
.argument('[agent]', 'Agent name or ID (defaults to the linked agent)')
|
|
9
|
-
.action(async (agentArg) => {
|
|
10
|
-
try {
|
|
11
|
-
const summary = await resolveAgent(agentArg);
|
|
12
|
-
const id = summary.id;
|
|
13
|
-
// Fetch all data in parallel
|
|
14
|
-
const [agent, envVars, triggers, deployments] = await Promise.all([
|
|
15
|
-
authGet(`/api/agents/${id}`),
|
|
16
|
-
authGet(`/api/agents/${id}/env`).catch(() => []),
|
|
17
|
-
authGet(`/api/agents/${id}/triggers`).catch(() => []),
|
|
18
|
-
authGet(`/api/deploy/agent/${id}`).catch(() => []),
|
|
19
|
-
]);
|
|
20
|
-
if (isJsonMode()) {
|
|
21
|
-
outputJson({ agent, envVars: envVars.length, triggers, lastDeploy: deployments[0] ?? null });
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
console.log();
|
|
25
|
-
console.log(chalk.bold(agent.name));
|
|
26
|
-
if (agent.description)
|
|
27
|
-
console.log(chalk.dim(agent.description));
|
|
28
|
-
console.log(chalk.dim('─'.repeat(50)));
|
|
29
|
-
// Core info
|
|
30
|
-
const rows = [
|
|
31
|
-
['ID', chalk.dim(agent.id)],
|
|
32
|
-
['Status', statusColor(agent.status)],
|
|
33
|
-
[
|
|
34
|
-
'Sleep',
|
|
35
|
-
agent.sleepPolicy ??
|
|
36
|
-
(agent.idleTtlSeconds != null && agent.idleTtlSeconds <= 0 ? 'always-on' : 'auto-sleep'),
|
|
37
|
-
],
|
|
38
|
-
['Framework', agent.framework],
|
|
39
|
-
['Created', agent.createdAt ? new Date(agent.createdAt).toLocaleString() : 'n/a'],
|
|
40
|
-
];
|
|
41
|
-
if (agent.githubRepo)
|
|
42
|
-
rows.push(['Repo', agent.githubRepo]);
|
|
43
|
-
if (agent.imageName)
|
|
44
|
-
rows.push(['Image', agent.imageName]);
|
|
45
|
-
if (agent.invocationCount !== undefined)
|
|
46
|
-
rows.push(['Invocations', String(agent.invocationCount)]);
|
|
47
|
-
rows.push(['Env vars', String(envVars.length)]);
|
|
48
|
-
rows.push(['Triggers', String(triggers.length)]);
|
|
49
|
-
for (const [label, value] of rows) {
|
|
50
|
-
console.log(` ${(label + ':').padEnd(16)} ${value}`);
|
|
51
|
-
}
|
|
52
|
-
// Last deployment
|
|
53
|
-
const last = deployments[0];
|
|
54
|
-
if (last) {
|
|
55
|
-
console.log();
|
|
56
|
-
console.log(chalk.bold(' Last deployment'));
|
|
57
|
-
console.log(` ${'Status:'.padEnd(16)} ${last.status}`);
|
|
58
|
-
console.log(` ${'Started:'.padEnd(16)} ${new Date(last.startedAt).toLocaleString()}`);
|
|
59
|
-
if (last.completedAt) {
|
|
60
|
-
console.log(` ${'Completed:'.padEnd(16)} ${new Date(last.completedAt).toLocaleString()}`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
console.log();
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
handleError(error);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
function statusColor(status) {
|
|
70
|
-
switch (status) {
|
|
71
|
-
case 'active': return chalk.green(status);
|
|
72
|
-
case 'sleeping': return chalk.blue(status);
|
|
73
|
-
case 'deploying': return chalk.yellow(status);
|
|
74
|
-
case 'error': return chalk.red(status);
|
|
75
|
-
case 'stopped': return chalk.gray(status);
|
|
76
|
-
default: return status;
|
|
77
|
-
}
|
|
78
|
-
}
|
package/dist/commands/init.d.ts
DELETED