maritime-cli 1.1.0 → 1.3.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 +60 -14
- package/dist/commands/chat.js +28 -8
- package/dist/commands/create.js +21 -16
- package/dist/commands/delete.js +1 -1
- package/dist/commands/deploy.js +124 -59
- package/dist/commands/env.js +110 -14
- package/dist/commands/guide.js +1 -0
- package/dist/commands/info.js +1 -1
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.js +119 -0
- package/dist/commands/keys.js +25 -13
- package/dist/commands/link.d.ts +4 -0
- package/dist/commands/link.js +65 -0
- package/dist/commands/logs.js +1 -1
- package/dist/commands/open.js +1 -1
- package/dist/commands/restart.js +1 -1
- package/dist/commands/sleep.js +1 -1
- package/dist/commands/start.js +1 -1
- package/dist/commands/status.js +1 -1
- package/dist/commands/stop.js +1 -1
- package/dist/context.d.ts +41 -0
- package/dist/context.js +110 -0
- package/dist/index.js +48 -21
- package/dist/resolve.d.ts +9 -1
- package/dist/resolve.js +27 -0
- package/package.json +1 -1
package/dist/commands/env.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { readFileSync } from 'node:fs';
|
|
1
|
+
import { readFileSync, writeFileSync, existsSync } from 'node:fs';
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import { authGet, authPost, authDelete } from '../api.js';
|
|
5
5
|
import { resolveAgent } from '../resolve.js';
|
|
6
|
+
import { getLinkedAgentId } from '../context.js';
|
|
6
7
|
import { isJsonMode, outputJson, outputResult, fail, handleError, makeSpinner, EXIT } from '../output.js';
|
|
7
8
|
/** Parse a single KEY=value token (as passed on the command line). */
|
|
8
9
|
function parsePair(pair) {
|
|
@@ -72,7 +73,7 @@ Secrets are encrypted and marked secret by default; changes apply on next
|
|
|
72
73
|
boot unless you pass --reload.`);
|
|
73
74
|
// --- list -----------------------------------------------------------------
|
|
74
75
|
envCommand
|
|
75
|
-
.command('list
|
|
76
|
+
.command('list [agent]')
|
|
76
77
|
.alias('ls')
|
|
77
78
|
.description('List environment variables')
|
|
78
79
|
.action(async (agentArg) => {
|
|
@@ -100,14 +101,30 @@ envCommand
|
|
|
100
101
|
});
|
|
101
102
|
// --- set (one or many pairs) ----------------------------------------------
|
|
102
103
|
envCommand
|
|
103
|
-
.command('set
|
|
104
|
+
.command('set [agent] [pairs...]')
|
|
104
105
|
.description('Set one or more environment variables (KEY=value KEY2=value2 …)')
|
|
105
106
|
.option('--no-secret', 'Store as plain (non-secret) values')
|
|
106
107
|
.option('-r, --reload', 'Hot-reload env into the running container afterward')
|
|
107
108
|
.action(async (agentArg, rawPairs, opts) => {
|
|
108
109
|
try {
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
// A leading token without "=" is the agent name; otherwise everything is
|
|
111
|
+
// pairs and the agent comes from the linked directory.
|
|
112
|
+
const positionals = [agentArg, ...(rawPairs || [])].filter(Boolean);
|
|
113
|
+
let target;
|
|
114
|
+
let pairTokens;
|
|
115
|
+
if (positionals.length > 0 && !positionals[0].includes('=')) {
|
|
116
|
+
target = positionals[0];
|
|
117
|
+
pairTokens = positionals.slice(1);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
target = undefined;
|
|
121
|
+
pairTokens = positionals;
|
|
122
|
+
}
|
|
123
|
+
if (pairTokens.length === 0) {
|
|
124
|
+
fail('No KEY=value pairs given.', { code: 'usage', exitCode: EXIT.USAGE });
|
|
125
|
+
}
|
|
126
|
+
const pairs = pairTokens.map(parsePair);
|
|
127
|
+
const agent = await resolveAgent(target);
|
|
111
128
|
const spinner = await makeSpinner(`Setting ${pairs.length} var${pairs.length === 1 ? '' : 's'} for ${agent.name}...`);
|
|
112
129
|
const { uploaded, failed } = await uploadVars(agent.id, pairs, opts.secret);
|
|
113
130
|
let reloaded = false;
|
|
@@ -141,14 +158,26 @@ envCommand
|
|
|
141
158
|
});
|
|
142
159
|
// --- import (.env file or stdin) ------------------------------------------
|
|
143
160
|
envCommand
|
|
144
|
-
.command('import
|
|
161
|
+
.command('import [agent] [file]')
|
|
145
162
|
.description('Upload all keys from a .env file (or stdin if file is "-" / omitted)')
|
|
146
163
|
.option('--plain', 'Store as plain (non-secret) values')
|
|
147
164
|
.option('-r, --reload', 'Hot-reload env into the running container afterward')
|
|
148
165
|
.action(async (agentArg, file, opts) => {
|
|
149
166
|
try {
|
|
167
|
+
// In a linked dir the single positional is the file (agent = linked);
|
|
168
|
+
// otherwise it's `<agent> [file]`.
|
|
169
|
+
let target;
|
|
170
|
+
let srcFile;
|
|
171
|
+
if (getLinkedAgentId()) {
|
|
172
|
+
target = undefined;
|
|
173
|
+
srcFile = agentArg;
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
target = agentArg;
|
|
177
|
+
srcFile = file;
|
|
178
|
+
}
|
|
150
179
|
let text;
|
|
151
|
-
if (!
|
|
180
|
+
if (!srcFile || srcFile === '-') {
|
|
152
181
|
if (process.stdin.isTTY) {
|
|
153
182
|
fail('No input. Pass a .env file path or pipe one via stdin.', {
|
|
154
183
|
code: 'usage',
|
|
@@ -159,17 +188,17 @@ envCommand
|
|
|
159
188
|
}
|
|
160
189
|
else {
|
|
161
190
|
try {
|
|
162
|
-
text = readFileSync(
|
|
191
|
+
text = readFileSync(srcFile, 'utf8');
|
|
163
192
|
}
|
|
164
193
|
catch {
|
|
165
|
-
fail(`Cannot read file: ${
|
|
194
|
+
fail(`Cannot read file: ${srcFile}`, { code: 'usage', exitCode: EXIT.USAGE });
|
|
166
195
|
}
|
|
167
196
|
}
|
|
168
197
|
const pairs = parseDotenv(text);
|
|
169
198
|
if (pairs.length === 0) {
|
|
170
199
|
fail('No KEY=value pairs found in input.', { code: 'usage', exitCode: EXIT.USAGE });
|
|
171
200
|
}
|
|
172
|
-
const agent = await resolveAgent(
|
|
201
|
+
const agent = await resolveAgent(target);
|
|
173
202
|
const spinner = await makeSpinner(`Importing ${pairs.length} vars into ${agent.name}...`);
|
|
174
203
|
const { uploaded, failed } = await uploadVars(agent.id, pairs, !opts.plain);
|
|
175
204
|
let reloaded = false;
|
|
@@ -203,13 +232,28 @@ envCommand
|
|
|
203
232
|
});
|
|
204
233
|
// --- remove ----------------------------------------------------------------
|
|
205
234
|
envCommand
|
|
206
|
-
.command('remove
|
|
235
|
+
.command('remove [agent] [key]')
|
|
207
236
|
.alias('rm')
|
|
208
237
|
.description('Remove an environment variable')
|
|
209
238
|
.option('-r, --reload', 'Hot-reload env into the running container afterward')
|
|
210
|
-
.action(async (agentArg,
|
|
239
|
+
.action(async (agentArg, keyArg, opts) => {
|
|
211
240
|
try {
|
|
212
|
-
|
|
241
|
+
// In a linked dir the single positional is the key (agent = linked);
|
|
242
|
+
// otherwise it's `<agent> <key>`.
|
|
243
|
+
let target;
|
|
244
|
+
let key;
|
|
245
|
+
if (getLinkedAgentId()) {
|
|
246
|
+
target = undefined;
|
|
247
|
+
key = agentArg;
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
target = agentArg;
|
|
251
|
+
key = keyArg;
|
|
252
|
+
}
|
|
253
|
+
if (!key) {
|
|
254
|
+
fail('No env key given to remove.', { code: 'usage', exitCode: EXIT.USAGE });
|
|
255
|
+
}
|
|
256
|
+
const agent = await resolveAgent(target);
|
|
213
257
|
const spinner = await makeSpinner(`Removing ${key} from ${agent.name}...`);
|
|
214
258
|
await authDelete(`/api/agents/${agent.id}/env/${encodeURIComponent(key)}`);
|
|
215
259
|
let reloaded = false;
|
|
@@ -231,7 +275,7 @@ envCommand
|
|
|
231
275
|
});
|
|
232
276
|
// --- reload ----------------------------------------------------------------
|
|
233
277
|
envCommand
|
|
234
|
-
.command('reload
|
|
278
|
+
.command('reload [agent]')
|
|
235
279
|
.description('Hot-reload env vars into the running container')
|
|
236
280
|
.action(async (agentArg) => {
|
|
237
281
|
try {
|
|
@@ -245,3 +289,55 @@ envCommand
|
|
|
245
289
|
handleError(error);
|
|
246
290
|
}
|
|
247
291
|
});
|
|
292
|
+
// --- pull ------------------------------------------------------------------
|
|
293
|
+
envCommand
|
|
294
|
+
.command('pull [agent] [file]')
|
|
295
|
+
.description('Write the agent’s env to a local .env file (secret values are masked)')
|
|
296
|
+
.option('-f, --force', 'Overwrite the file if it already exists')
|
|
297
|
+
.action(async (agentArg, fileArg, opts) => {
|
|
298
|
+
try {
|
|
299
|
+
// In a linked dir the single positional is the output file (agent = linked).
|
|
300
|
+
let target;
|
|
301
|
+
let outFile;
|
|
302
|
+
if (getLinkedAgentId()) {
|
|
303
|
+
target = undefined;
|
|
304
|
+
outFile = agentArg || '.env';
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
target = agentArg;
|
|
308
|
+
outFile = fileArg || '.env';
|
|
309
|
+
}
|
|
310
|
+
const agent = await resolveAgent(target);
|
|
311
|
+
const vars = await authGet(`/api/agents/${agent.id}/env`);
|
|
312
|
+
const lines = [];
|
|
313
|
+
const keys = [];
|
|
314
|
+
const secretKeys = [];
|
|
315
|
+
for (const v of vars) {
|
|
316
|
+
keys.push(v.key);
|
|
317
|
+
if (v.is_secret) {
|
|
318
|
+
secretKeys.push(v.key);
|
|
319
|
+
lines.push(`${v.key}= # secret — value not exported; fill it in`);
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
lines.push(`${v.key}=${v.value}`);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
const text = lines.length ? lines.join('\n') + '\n' : '';
|
|
326
|
+
if (existsSync(outFile) && !opts.force) {
|
|
327
|
+
fail(`${outFile} already exists. Pass --force to overwrite.`, {
|
|
328
|
+
code: 'usage',
|
|
329
|
+
exitCode: EXIT.USAGE,
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
writeFileSync(outFile, text);
|
|
333
|
+
outputResult({ ok: true, agentId: agent.id, file: outFile, keys, secretKeys }, () => {
|
|
334
|
+
console.log(chalk.green(`Pulled ${keys.length} var(s) → `) + chalk.bold(outFile));
|
|
335
|
+
if (secretKeys.length) {
|
|
336
|
+
console.log(chalk.dim(` ${secretKeys.length} secret value(s) masked — fill in: ${secretKeys.join(', ')}`));
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
catch (error) {
|
|
341
|
+
handleError(error);
|
|
342
|
+
}
|
|
343
|
+
});
|
package/dist/commands/guide.js
CHANGED
|
@@ -15,6 +15,7 @@ const CONTRACT = {
|
|
|
15
15
|
exitCodes: { '0': 'ok', '1': 'error', '2': 'auth', '3': 'not_found', '4': 'usage' },
|
|
16
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.',
|
|
17
17
|
resources: 'create accepts per-agent overrides: --ram <mb>, --cpu <cores>, --idle <seconds> | --always-on, --disk <gb>, --max-compute <minutes>. Omitted = inherit the tier/plan.',
|
|
18
|
+
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
19
|
apiBase: 'Override the API base with MARITIME_API_URL (default https://api.maritime.sh).',
|
|
19
20
|
};
|
|
20
21
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
package/dist/commands/info.js
CHANGED
|
@@ -5,7 +5,7 @@ import { resolveAgent } from '../resolve.js';
|
|
|
5
5
|
import { isJsonMode, outputJson, handleError } from '../output.js';
|
|
6
6
|
export const infoCommand = new Command('info')
|
|
7
7
|
.description('Show full details for an agent')
|
|
8
|
-
.argument('
|
|
8
|
+
.argument('[agent]', 'Agent name or ID (defaults to the linked agent)')
|
|
9
9
|
.action(async (agentArg) => {
|
|
10
10
|
try {
|
|
11
11
|
const summary = await resolveAgent(agentArg);
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { existsSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { basename, join } from 'node:path';
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { authPost } from '../api.js';
|
|
6
|
+
import { getConfig, writeConfig, writeLink, configExists, CONFIG_FILENAME, } from '../context.js';
|
|
7
|
+
import { promptForValue } from '../prompt.js';
|
|
8
|
+
import { isJsonMode, outputResult, fail, handleError, makeSpinner, EXIT } from '../output.js';
|
|
9
|
+
const AGENTS_MD = (name, instructions) => `# ${name}
|
|
10
|
+
|
|
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
|
+
|
|
13
|
+
## Guidelines
|
|
14
|
+
- Be concise and helpful.
|
|
15
|
+
- Ask for missing information instead of guessing.
|
|
16
|
+
`;
|
|
17
|
+
export const initCommand = new Command('init')
|
|
18
|
+
.description(`Scaffold ${CONFIG_FILENAME}, create the agent, and link this directory to it`)
|
|
19
|
+
.argument('[name]', 'Agent name (defaults to the folder name)')
|
|
20
|
+
.option('-t, --template <id>', 'Template to base the agent on (default: openclaw)')
|
|
21
|
+
.option('--framework <framework>', 'Framework for bring-your-own-code agents (instead of a template)')
|
|
22
|
+
.option('--instructions <text>', 'Plain-English persona for the agent')
|
|
23
|
+
.option('--tier <tier>', 'Tier: smart, extended, always_on')
|
|
24
|
+
.option('--no-create', 'Only write the config files; do not create the agent yet')
|
|
25
|
+
.addHelpText('after', `
|
|
26
|
+
Examples:
|
|
27
|
+
maritime init # scaffold + create, named after the folder
|
|
28
|
+
maritime init support-bot # explicit name
|
|
29
|
+
maritime init bot --no-create # just write ${CONFIG_FILENAME} + AGENTS.md
|
|
30
|
+
After init, run \`maritime deploy\` to push changes, or \`maritime chat "…"\`.`)
|
|
31
|
+
.action(async (nameArg, opts) => {
|
|
32
|
+
try {
|
|
33
|
+
const interactive = !isJsonMode() && process.stdin.isTTY;
|
|
34
|
+
const existing = getConfig() ?? {};
|
|
35
|
+
// Name: arg → existing config → folder name (prompted if interactive).
|
|
36
|
+
let name = nameArg || existing.name || basename(process.cwd());
|
|
37
|
+
if (interactive && !nameArg && !existing.name) {
|
|
38
|
+
name = (await promptForValue('Agent name', undefined)) || name;
|
|
39
|
+
}
|
|
40
|
+
if (!name) {
|
|
41
|
+
fail('Agent name is required.', { code: 'usage', exitCode: EXIT.USAGE });
|
|
42
|
+
}
|
|
43
|
+
// Template/framework: explicit flags win; else keep existing; else default
|
|
44
|
+
// to the openclaw template so a bare `init` yields a *working* agent.
|
|
45
|
+
const framework = opts.framework || existing.framework;
|
|
46
|
+
const template = framework
|
|
47
|
+
? undefined
|
|
48
|
+
: opts.template || existing.template || 'openclaw';
|
|
49
|
+
const instructions = opts.instructions ?? existing.instructions ?? '';
|
|
50
|
+
const tier = opts.tier || existing.tier;
|
|
51
|
+
const config = {
|
|
52
|
+
name,
|
|
53
|
+
...(template ? { template } : {}),
|
|
54
|
+
...(framework ? { framework } : {}),
|
|
55
|
+
...(instructions ? { instructions } : {}),
|
|
56
|
+
env: existing.env ?? [],
|
|
57
|
+
...(tier ? { tier } : {}),
|
|
58
|
+
};
|
|
59
|
+
const wroteConfig = !configExists();
|
|
60
|
+
const configPath = writeConfig(config);
|
|
61
|
+
// Scaffold an AGENTS.md persona file if there isn't one already.
|
|
62
|
+
const agentsMdPath = join(process.cwd(), 'AGENTS.md');
|
|
63
|
+
let wroteAgentsMd = false;
|
|
64
|
+
if (!existsSync(agentsMdPath)) {
|
|
65
|
+
writeFileSync(agentsMdPath, AGENTS_MD(name, instructions));
|
|
66
|
+
wroteAgentsMd = true;
|
|
67
|
+
}
|
|
68
|
+
// Create + link unless --no-create.
|
|
69
|
+
let agent = null;
|
|
70
|
+
let linkPath = null;
|
|
71
|
+
if (opts.create !== false) {
|
|
72
|
+
const spinner = await makeSpinner(`Creating ${chalk.bold(name)}...`);
|
|
73
|
+
try {
|
|
74
|
+
const body = { name };
|
|
75
|
+
if (template)
|
|
76
|
+
body.templateId = template;
|
|
77
|
+
if (framework)
|
|
78
|
+
body.framework = framework;
|
|
79
|
+
if (tier)
|
|
80
|
+
body.tier = tier;
|
|
81
|
+
if (instructions)
|
|
82
|
+
body.instructions = instructions;
|
|
83
|
+
agent = await authPost('/api/agents', body);
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
spinner.fail('Failed to create agent');
|
|
87
|
+
throw error;
|
|
88
|
+
}
|
|
89
|
+
spinner.succeed(chalk.green('Created ') + chalk.bold(agent.name) + chalk.dim(` (${agent.id})`));
|
|
90
|
+
linkPath = writeLink({ agentId: agent.id, name: agent.name });
|
|
91
|
+
}
|
|
92
|
+
outputResult({
|
|
93
|
+
ok: true,
|
|
94
|
+
action: 'init',
|
|
95
|
+
config: configPath,
|
|
96
|
+
wroteConfig,
|
|
97
|
+
wroteAgentsMd,
|
|
98
|
+
agentId: agent?.id ?? null,
|
|
99
|
+
agentName: agent?.name ?? name,
|
|
100
|
+
linked: Boolean(linkPath),
|
|
101
|
+
}, () => {
|
|
102
|
+
console.log(chalk.dim(` ${wroteConfig ? 'wrote' : 'updated'} ${CONFIG_FILENAME}`));
|
|
103
|
+
if (wroteAgentsMd)
|
|
104
|
+
console.log(chalk.dim(' wrote AGENTS.md'));
|
|
105
|
+
if (agent) {
|
|
106
|
+
console.log(chalk.dim(' linked this directory → ') + chalk.bold(agent.name));
|
|
107
|
+
console.log();
|
|
108
|
+
console.log('Next: ' + chalk.bold('maritime chat "hello"') + chalk.dim(' · ') + chalk.bold('maritime deploy') + chalk.dim(' to push edits'));
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
console.log();
|
|
112
|
+
console.log('Next: ' + chalk.bold('maritime deploy') + chalk.dim(' to create + link the agent'));
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
handleError(error);
|
|
118
|
+
}
|
|
119
|
+
});
|
package/dist/commands/keys.js
CHANGED
|
@@ -2,23 +2,34 @@ import { Command } from 'commander';
|
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import { authGet, authPost, authDelete } from '../api.js';
|
|
4
4
|
import { isJsonMode, outputJson, outputResult, handleError } from '../output.js';
|
|
5
|
+
const VALID_SCOPES = ['provision', 'deploy', 'secrets', 'manage'];
|
|
5
6
|
export const keysCommand = new Command('keys')
|
|
6
7
|
.description('Manage long-lived API keys (mk_…) for non-interactive / AI-agent access');
|
|
7
8
|
keysCommand
|
|
8
9
|
.command('create')
|
|
9
10
|
.description('Mint a new API key. Shown once — save it as MARITIME_TOKEN.')
|
|
10
11
|
.option('-n, --name <name>', 'Label for the key', 'cli-agent')
|
|
12
|
+
.option('-s, --scopes <scopes>', `Comma-separated scopes (${VALID_SCOPES.join(', ')}); "manage" = all`, 'provision,deploy,secrets')
|
|
11
13
|
.action(async (opts) => {
|
|
12
14
|
try {
|
|
13
|
-
const
|
|
15
|
+
const scopes = String(opts.scopes)
|
|
16
|
+
.split(',')
|
|
17
|
+
.map((s) => s.trim())
|
|
18
|
+
.filter(Boolean);
|
|
19
|
+
const bad = scopes.filter((s) => !VALID_SCOPES.includes(s));
|
|
20
|
+
if (bad.length) {
|
|
21
|
+
handleError(new Error(`Unknown scope(s): ${bad.join(', ')}. Valid: ${VALID_SCOPES.join(', ')}`));
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const created = await authPost('/api/v1/keys', { name: opts.name, scopes });
|
|
14
25
|
outputResult(created, () => {
|
|
15
|
-
console.log(chalk.green('Created API key ') + chalk.bold(created.name));
|
|
26
|
+
console.log(chalk.green('Created API key ') + chalk.bold(created.name) + chalk.dim(` [${created.scopes.join(', ')}]`));
|
|
16
27
|
console.log();
|
|
17
|
-
console.log(' ' + chalk.bold(created.
|
|
28
|
+
console.log(' ' + chalk.bold(created.raw_key));
|
|
18
29
|
console.log();
|
|
19
30
|
console.log(chalk.yellow(' Save this now — it will not be shown again.'));
|
|
20
31
|
console.log(chalk.dim(' Use it non-interactively with:'));
|
|
21
|
-
console.log(chalk.dim(` export MARITIME_TOKEN=${created.
|
|
32
|
+
console.log(chalk.dim(` export MARITIME_TOKEN=${created.raw_key}`));
|
|
22
33
|
});
|
|
23
34
|
}
|
|
24
35
|
catch (error) {
|
|
@@ -31,7 +42,7 @@ keysCommand
|
|
|
31
42
|
.description('List your API keys (values are never shown again)')
|
|
32
43
|
.action(async () => {
|
|
33
44
|
try {
|
|
34
|
-
const keys = await authGet('/api/
|
|
45
|
+
const keys = await authGet('/api/v1/keys');
|
|
35
46
|
if (isJsonMode()) {
|
|
36
47
|
outputJson(keys);
|
|
37
48
|
return;
|
|
@@ -42,18 +53,19 @@ keysCommand
|
|
|
42
53
|
}
|
|
43
54
|
console.log('\n ' +
|
|
44
55
|
chalk.dim('ID'.padEnd(14)) +
|
|
45
|
-
chalk.dim('NAME'.padEnd(
|
|
46
|
-
chalk.dim('PREFIX'.padEnd(
|
|
56
|
+
chalk.dim('NAME'.padEnd(20)) +
|
|
57
|
+
chalk.dim('PREFIX'.padEnd(15)) +
|
|
58
|
+
chalk.dim('SCOPES'.padEnd(28)) +
|
|
47
59
|
chalk.dim('LAST USED'));
|
|
48
|
-
console.log(chalk.dim(' ' + '─'.repeat(
|
|
60
|
+
console.log(chalk.dim(' ' + '─'.repeat(86)));
|
|
49
61
|
for (const k of keys) {
|
|
50
|
-
const
|
|
51
|
-
const last = k.lastUsedAt || k.last_used_at;
|
|
62
|
+
const last = k.last_used_at;
|
|
52
63
|
const lastStr = last ? new Date(last).toLocaleString() : chalk.dim('never');
|
|
53
64
|
console.log(' ' +
|
|
54
65
|
chalk.dim(String(k.id).slice(0, 12).padEnd(14)) +
|
|
55
|
-
chalk.bold(String(k.name).slice(0,
|
|
56
|
-
(
|
|
66
|
+
chalk.bold(String(k.name).slice(0, 18).padEnd(20)) +
|
|
67
|
+
((k.key_prefix || '') + '…').padEnd(15) +
|
|
68
|
+
String((k.scopes || []).join(',')).slice(0, 26).padEnd(28) +
|
|
57
69
|
lastStr);
|
|
58
70
|
}
|
|
59
71
|
console.log();
|
|
@@ -69,7 +81,7 @@ keysCommand
|
|
|
69
81
|
.argument('<id>', 'API key ID (from `maritime keys list`)')
|
|
70
82
|
.action(async (id) => {
|
|
71
83
|
try {
|
|
72
|
-
await authDelete(`/api/
|
|
84
|
+
await authDelete(`/api/v1/keys/${id}`);
|
|
73
85
|
outputResult({ ok: true, action: 'revoke', id }, () => console.log(chalk.green('Revoked key ') + chalk.bold(id)));
|
|
74
86
|
}
|
|
75
87
|
catch (error) {
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { authGet } from '../api.js';
|
|
4
|
+
import { resolveAgent } from '../resolve.js';
|
|
5
|
+
import { writeLink, getLink } from '../context.js';
|
|
6
|
+
import { promptForValue } from '../prompt.js';
|
|
7
|
+
import { isJsonMode, outputResult, fail, handleError, EXIT } from '../output.js';
|
|
8
|
+
export const linkCommand = new Command('link')
|
|
9
|
+
.description('Link this directory to an agent, so commands target it without naming it')
|
|
10
|
+
.argument('[agent]', 'Agent name or ID (interactive picker if omitted)')
|
|
11
|
+
.addHelpText('after', `
|
|
12
|
+
Once linked, the agent argument is optional everywhere:
|
|
13
|
+
maritime link support-bot
|
|
14
|
+
maritime chat "what's open?" # talks to support-bot
|
|
15
|
+
maritime logs # support-bot's logs
|
|
16
|
+
The link lives in .maritime/ (git-ignored). Re-run to change it.`)
|
|
17
|
+
.action(async (agentArg, _opts, command) => {
|
|
18
|
+
try {
|
|
19
|
+
let agent;
|
|
20
|
+
if (agentArg) {
|
|
21
|
+
agent = await resolveAgent(agentArg);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
// Interactive: pick from the caller's agents.
|
|
25
|
+
const interactive = !isJsonMode() && process.stdin.isTTY;
|
|
26
|
+
if (!interactive) {
|
|
27
|
+
fail('Pass an agent name to link to (non-interactive).', {
|
|
28
|
+
code: 'usage',
|
|
29
|
+
exitCode: EXIT.USAGE,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const agents = await authGet('/api/agents');
|
|
33
|
+
if (agents.length === 0) {
|
|
34
|
+
fail('You have no agents yet. Create one with `maritime create <name>` or `maritime init`.', {
|
|
35
|
+
code: 'not_found',
|
|
36
|
+
exitCode: EXIT.NOT_FOUND,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
console.log(chalk.dim('\nYour agents:'));
|
|
40
|
+
agents.forEach((a, i) => {
|
|
41
|
+
console.log(` ${chalk.bold(String(i + 1))}. ${a.name} ${chalk.dim(`(${a.status})`)}`);
|
|
42
|
+
});
|
|
43
|
+
console.log();
|
|
44
|
+
const choice = await promptForValue('Link to which? (number or name)');
|
|
45
|
+
const idx = parseInt(choice, 10);
|
|
46
|
+
agent =
|
|
47
|
+
idx >= 1 && idx <= agents.length
|
|
48
|
+
? agents[idx - 1]
|
|
49
|
+
: await resolveAgent(choice);
|
|
50
|
+
}
|
|
51
|
+
const path = writeLink({ agentId: agent.id, name: agent.name });
|
|
52
|
+
outputResult({ ok: true, action: 'link', agentId: agent.id, agentName: agent.name, path }, () => {
|
|
53
|
+
console.log(chalk.green('Linked ') + chalk.dim('this directory → ') + chalk.bold(agent.name));
|
|
54
|
+
console.log(chalk.dim(` ${path}`));
|
|
55
|
+
console.log(chalk.dim(' The agent argument is now optional here: try `maritime status`.'));
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
handleError(error);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
/** Read the current link for display (used by whoami/status helpers if needed). */
|
|
63
|
+
export function currentLink() {
|
|
64
|
+
return getLink();
|
|
65
|
+
}
|
package/dist/commands/logs.js
CHANGED
|
@@ -22,7 +22,7 @@ function formatEntry(entry) {
|
|
|
22
22
|
}
|
|
23
23
|
export const logsCommand = new Command('logs')
|
|
24
24
|
.description('View logs from an agent')
|
|
25
|
-
.argument('
|
|
25
|
+
.argument('[agent]', 'Agent name or ID (defaults to the linked agent)')
|
|
26
26
|
.option('-n, --lines <num>', 'Number of lines', '50')
|
|
27
27
|
.option('--level <level>', 'Filter by level (info, warn, error, debug)')
|
|
28
28
|
.option('-f, --follow', 'Follow log output')
|
package/dist/commands/open.js
CHANGED
|
@@ -6,7 +6,7 @@ import { resolveAgent } from '../resolve.js';
|
|
|
6
6
|
const APP_URL = process.env.MARITIME_APP_URL || 'https://maritime.sh';
|
|
7
7
|
export const openCommand = new Command('open')
|
|
8
8
|
.description('Open an agent in the dashboard')
|
|
9
|
-
.argument('
|
|
9
|
+
.argument('[agent]', 'Agent name or ID (defaults to the linked agent)')
|
|
10
10
|
.action(async (agentArg) => {
|
|
11
11
|
try {
|
|
12
12
|
const agent = await resolveAgent(agentArg);
|
package/dist/commands/restart.js
CHANGED
|
@@ -5,7 +5,7 @@ import { resolveAgent } from '../resolve.js';
|
|
|
5
5
|
import { outputResult, handleError, makeSpinner } from '../output.js';
|
|
6
6
|
export const restartCommand = new Command('restart')
|
|
7
7
|
.description('Restart an agent')
|
|
8
|
-
.argument('
|
|
8
|
+
.argument('[agent]', 'Agent name or ID (defaults to the linked agent)')
|
|
9
9
|
.action(async (agentArg) => {
|
|
10
10
|
try {
|
|
11
11
|
const agent = await resolveAgent(agentArg);
|
package/dist/commands/sleep.js
CHANGED
|
@@ -6,7 +6,7 @@ import { resolveAgent } from '../resolve.js';
|
|
|
6
6
|
import { isJsonMode, outputJson, handleError } from '../output.js';
|
|
7
7
|
export const sleepCommand = new Command('sleep')
|
|
8
8
|
.description('Put an agent to sleep')
|
|
9
|
-
.argument('
|
|
9
|
+
.argument('[agent]', 'Agent name or ID (defaults to the linked agent)')
|
|
10
10
|
.action(async (agentArg) => {
|
|
11
11
|
try {
|
|
12
12
|
const agent = await resolveAgent(agentArg);
|
package/dist/commands/start.js
CHANGED
|
@@ -5,7 +5,7 @@ import { resolveAgent } from '../resolve.js';
|
|
|
5
5
|
import { outputResult, handleError, makeSpinner } from '../output.js';
|
|
6
6
|
export const startCommand = new Command('start')
|
|
7
7
|
.description('Start an agent')
|
|
8
|
-
.argument('
|
|
8
|
+
.argument('[agent]', 'Agent name or ID (defaults to the linked agent)')
|
|
9
9
|
.action(async (agentArg) => {
|
|
10
10
|
try {
|
|
11
11
|
const agent = await resolveAgent(agentArg);
|
package/dist/commands/status.js
CHANGED
|
@@ -5,7 +5,7 @@ import { resolveAgent } from '../resolve.js';
|
|
|
5
5
|
import { isJsonMode, outputJson, handleError } from '../output.js';
|
|
6
6
|
export const statusCommand = new Command('status')
|
|
7
7
|
.description('Show detailed status for an agent')
|
|
8
|
-
.argument('
|
|
8
|
+
.argument('[agent]', 'Agent name or ID (defaults to the linked agent)')
|
|
9
9
|
.action(async (agentArg) => {
|
|
10
10
|
try {
|
|
11
11
|
const summary = await resolveAgent(agentArg);
|
package/dist/commands/stop.js
CHANGED
|
@@ -5,7 +5,7 @@ import { resolveAgent } from '../resolve.js';
|
|
|
5
5
|
import { outputResult, handleError, makeSpinner } from '../output.js';
|
|
6
6
|
export const stopCommand = new Command('stop')
|
|
7
7
|
.description('Stop an agent')
|
|
8
|
-
.argument('
|
|
8
|
+
.argument('[agent]', 'Agent name or ID (defaults to the linked agent)')
|
|
9
9
|
.action(async (agentArg) => {
|
|
10
10
|
try {
|
|
11
11
|
const agent = await resolveAgent(agentArg);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project context — the Vercel/Railway "link a directory to a project" model,
|
|
3
|
+
* applied to agents.
|
|
4
|
+
*
|
|
5
|
+
* .maritime/project.json the LINK: which agent this directory operates on.
|
|
6
|
+
* Machine-local, git-ignored. Written by `link`/`init`.
|
|
7
|
+
* maritime.json the CONFIG: the source-of-truth description of the
|
|
8
|
+
* agent (name, template/framework, persona, env keys,
|
|
9
|
+
* tier). Committed to the repo; `deploy` reconciles
|
|
10
|
+
* the remote agent to it.
|
|
11
|
+
*
|
|
12
|
+
* Both are discovered by walking up from the cwd, so commands work from any
|
|
13
|
+
* subdirectory of a linked project — just like `git`.
|
|
14
|
+
*/
|
|
15
|
+
export interface ProjectLink {
|
|
16
|
+
agentId: string;
|
|
17
|
+
name?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface MaritimeConfig {
|
|
20
|
+
name?: string;
|
|
21
|
+
/** A curated template id (e.g. "openclaw"). Mutually exclusive with framework. */
|
|
22
|
+
template?: string;
|
|
23
|
+
/** Framework for bring-your-own-code agents (default "custom"). */
|
|
24
|
+
framework?: string;
|
|
25
|
+
/** Plain-English persona; becomes the agent's workspace AGENTS.md at boot. */
|
|
26
|
+
instructions?: string;
|
|
27
|
+
/** Env var KEYS this agent expects. Values are set via `env`, never committed. */
|
|
28
|
+
env?: string[];
|
|
29
|
+
/** Optional tier override (smart | extended | always_on). */
|
|
30
|
+
tier?: string;
|
|
31
|
+
}
|
|
32
|
+
export declare function findLinkPath(start?: string): string | null;
|
|
33
|
+
export declare function getLink(): ProjectLink | null;
|
|
34
|
+
export declare function getLinkedAgentId(): string | null;
|
|
35
|
+
/** Persist the link for `dir`, and git-ignore `.maritime/` so it stays local. */
|
|
36
|
+
export declare function writeLink(link: ProjectLink, dir?: string): string;
|
|
37
|
+
export declare function findConfigPath(start?: string): string | null;
|
|
38
|
+
export declare function getConfig(): MaritimeConfig | null;
|
|
39
|
+
export declare function configExists(dir?: string): boolean;
|
|
40
|
+
export declare function writeConfig(cfg: MaritimeConfig, dir?: string): string;
|
|
41
|
+
export declare const CONFIG_FILENAME = "maritime.json";
|