maritime-cli 1.8.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +17 -0
  2. package/bin/maritime.js +40 -0
  3. package/install.js +118 -0
  4. package/package.json +22 -36
  5. package/AGENTS.md +0 -309
  6. package/dist/api.d.ts +0 -30
  7. package/dist/api.js +0 -240
  8. package/dist/commands/chat.d.ts +0 -2
  9. package/dist/commands/chat.js +0 -120
  10. package/dist/commands/create.d.ts +0 -2
  11. package/dist/commands/create.js +0 -310
  12. package/dist/commands/delete.d.ts +0 -2
  13. package/dist/commands/delete.js +0 -43
  14. package/dist/commands/deploy.d.ts +0 -2
  15. package/dist/commands/deploy.js +0 -180
  16. package/dist/commands/env.d.ts +0 -2
  17. package/dist/commands/env.js +0 -368
  18. package/dist/commands/exec.d.ts +0 -2
  19. package/dist/commands/exec.js +0 -31
  20. package/dist/commands/guide.d.ts +0 -2
  21. package/dist/commands/guide.js +0 -87
  22. package/dist/commands/history.d.ts +0 -2
  23. package/dist/commands/history.js +0 -56
  24. package/dist/commands/info.d.ts +0 -2
  25. package/dist/commands/info.js +0 -78
  26. package/dist/commands/init.d.ts +0 -2
  27. package/dist/commands/init.js +0 -114
  28. package/dist/commands/keys.d.ts +0 -2
  29. package/dist/commands/keys.js +0 -90
  30. package/dist/commands/link.d.ts +0 -4
  31. package/dist/commands/link.js +0 -65
  32. package/dist/commands/list.d.ts +0 -2
  33. package/dist/commands/list.js +0 -55
  34. package/dist/commands/login.d.ts +0 -2
  35. package/dist/commands/login.js +0 -209
  36. package/dist/commands/logout.d.ts +0 -2
  37. package/dist/commands/logout.js +0 -12
  38. package/dist/commands/logs.d.ts +0 -2
  39. package/dist/commands/logs.js +0 -89
  40. package/dist/commands/message.d.ts +0 -8
  41. package/dist/commands/message.js +0 -75
  42. package/dist/commands/open.d.ts +0 -2
  43. package/dist/commands/open.js +0 -25
  44. package/dist/commands/restart.d.ts +0 -2
  45. package/dist/commands/restart.js +0 -26
  46. package/dist/commands/signup.d.ts +0 -2
  47. package/dist/commands/signup.js +0 -45
  48. package/dist/commands/sleep.d.ts +0 -2
  49. package/dist/commands/sleep.js +0 -22
  50. package/dist/commands/start.d.ts +0 -2
  51. package/dist/commands/start.js +0 -27
  52. package/dist/commands/status.d.ts +0 -2
  53. package/dist/commands/status.js +0 -69
  54. package/dist/commands/stop.d.ts +0 -2
  55. package/dist/commands/stop.js +0 -26
  56. package/dist/commands/templates.d.ts +0 -2
  57. package/dist/commands/templates.js +0 -40
  58. package/dist/commands/triggers.d.ts +0 -2
  59. package/dist/commands/triggers.js +0 -89
  60. package/dist/commands/whoami.d.ts +0 -2
  61. package/dist/commands/whoami.js +0 -76
  62. package/dist/config.d.ts +0 -2
  63. package/dist/config.js +0 -14
  64. package/dist/context.d.ts +0 -39
  65. package/dist/context.js +0 -110
  66. package/dist/index.d.ts +0 -2
  67. package/dist/index.js +0 -186
  68. package/dist/interactive.d.ts +0 -1
  69. package/dist/interactive.js +0 -66
  70. package/dist/output.d.ts +0 -80
  71. package/dist/output.js +0 -176
  72. package/dist/prompt.d.ts +0 -2
  73. package/dist/prompt.js +0 -62
  74. package/dist/resolve.d.ts +0 -16
  75. package/dist/resolve.js +0 -59
  76. package/dist/version-check.d.ts +0 -20
  77. package/dist/version-check.js +0 -81
  78. package/dist/websocket.d.ts +0 -22
  79. package/dist/websocket.js +0 -89
@@ -1,87 +0,0 @@
1
- import { readFileSync } from 'node:fs';
2
- import { fileURLToPath } from 'node:url';
3
- import { dirname, join } from 'node:path';
4
- import { Command } from 'commander';
5
- import { isJsonMode, outputJson } from '../output.js';
6
- const __dirname = dirname(fileURLToPath(import.meta.url));
7
- /**
8
- * The machine contract an AI agent needs that isn't expressible as flags.
9
- * Kept in sync with AGENTS.md; emitted by `guide --json` so an agent can learn
10
- * the rules in one structured call.
11
- */
12
- const CONTRACT = {
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
- 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
- exitCodes: { '0': 'ok', '1': 'error', '2': 'auth', '3': 'not_found', '4': 'usage' },
16
- 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.',
17
- 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.',
18
- 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.',
19
- 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.',
20
- 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).',
21
- apiBase: 'Override the API base with MARITIME_API_URL (default https://api.maritime.sh).',
22
- };
23
- /* eslint-disable @typescript-eslint/no-explicit-any */
24
- function serializeCommand(cmd) {
25
- const args = (cmd.registeredArguments ?? cmd._args ?? []);
26
- return {
27
- name: cmd.name(),
28
- aliases: typeof cmd.aliases === 'function' ? cmd.aliases() : [],
29
- description: typeof cmd.description === 'function' ? cmd.description() : '',
30
- arguments: args.map((a) => ({
31
- name: typeof a.name === 'function' ? a.name() : a._name ?? String(a),
32
- required: Boolean(a.required),
33
- variadic: Boolean(a.variadic),
34
- })),
35
- options: (cmd.options ?? []).map((o) => ({
36
- flags: o.flags,
37
- description: o.description ?? '',
38
- })),
39
- subcommands: (cmd.commands ?? [])
40
- .filter((c) => c.name() !== 'help')
41
- .map(serializeCommand),
42
- };
43
- }
44
- /* eslint-enable @typescript-eslint/no-explicit-any */
45
- function readBundledGuide() {
46
- // dist/commands/guide.js → package root is two levels up.
47
- for (const rel of [['..', '..', 'AGENTS.md'], ['..', '..', '..', 'AGENTS.md']]) {
48
- try {
49
- return readFileSync(join(__dirname, ...rel), 'utf-8');
50
- }
51
- catch {
52
- // try next candidate
53
- }
54
- }
55
- return null;
56
- }
57
- export const guideCommand = new Command('guide')
58
- .alias('agent-guide')
59
- .description('Print the machine-readable usage guide for driving this CLI from code/an AI agent')
60
- .action((_opts, command) => {
61
- if (isJsonMode()) {
62
- // One structured call gives an agent the entire surface + the contract.
63
- const root = command.parent ?? command;
64
- const program = root;
65
- outputJson({
66
- name: typeof program.name === 'function' ? program.name() : 'maritime',
67
- contract: CONTRACT,
68
- commands: (root.commands ?? [])
69
- .filter((c) => c.name() !== 'help' && c.name() !== 'guide')
70
- .map(serializeCommand),
71
- });
72
- return;
73
- }
74
- const md = readBundledGuide();
75
- if (md) {
76
- process.stdout.write(md.endsWith('\n') ? md : md + '\n');
77
- return;
78
- }
79
- // Fallback if AGENTS.md wasn't shipped: print the contract essentials.
80
- console.log('Maritime CLI · programmatic / AI-agent usage\n');
81
- console.log(` Auth: ${CONTRACT.auth}`);
82
- console.log(` JSON: ${CONTRACT.json}`);
83
- console.log(` Chat: ${CONTRACT.interaction}`);
84
- console.log(` Limits: ${CONTRACT.resources}`);
85
- console.log(` Billing: ${CONTRACT.billing}`);
86
- console.log('\n Run `maritime guide --json` for the full structured manifest.');
87
- });
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const historyCommand: Command;
@@ -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
- });
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const infoCommand: Command;
@@ -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
- }
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const initCommand: Command;
@@ -1,114 +0,0 @@
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('--no-create', 'Only write the config files; do not create the agent yet')
24
- .addHelpText('after', `
25
- Examples:
26
- maritime init # scaffold + create, named after the folder
27
- maritime init support-bot # explicit name
28
- maritime init bot --no-create # just write ${CONFIG_FILENAME} + AGENTS.md
29
- After init, run \`maritime deploy\` to push changes, or \`maritime chat "…"\`.`)
30
- .action(async (nameArg, opts) => {
31
- try {
32
- const interactive = !isJsonMode() && process.stdin.isTTY;
33
- const existing = getConfig() ?? {};
34
- // Name: arg → existing config → folder name (prompted if interactive).
35
- let name = nameArg || existing.name || basename(process.cwd());
36
- if (interactive && !nameArg && !existing.name) {
37
- name = (await promptForValue('Agent name', undefined)) || name;
38
- }
39
- if (!name) {
40
- fail('Agent name is required.', { code: 'usage', exitCode: EXIT.USAGE });
41
- }
42
- // Template/framework: explicit flags win; else keep existing; else default
43
- // to the openclaw template so a bare `init` yields a *working* agent.
44
- const framework = opts.framework || existing.framework;
45
- const template = framework
46
- ? undefined
47
- : opts.template || existing.template || 'openclaw';
48
- const instructions = opts.instructions ?? existing.instructions ?? '';
49
- const config = {
50
- name,
51
- ...(template ? { template } : {}),
52
- ...(framework ? { framework } : {}),
53
- ...(instructions ? { instructions } : {}),
54
- env: existing.env ?? [],
55
- };
56
- const wroteConfig = !configExists();
57
- const configPath = writeConfig(config);
58
- // Scaffold an AGENTS.md persona file if there isn't one already.
59
- const agentsMdPath = join(process.cwd(), 'AGENTS.md');
60
- let wroteAgentsMd = false;
61
- if (!existsSync(agentsMdPath)) {
62
- writeFileSync(agentsMdPath, AGENTS_MD(name, instructions));
63
- wroteAgentsMd = true;
64
- }
65
- // Create + link unless --no-create.
66
- let agent = null;
67
- let linkPath = null;
68
- if (opts.create !== false) {
69
- const spinner = await makeSpinner(`Creating ${chalk.bold(name)}...`);
70
- try {
71
- const body = { name };
72
- if (template)
73
- body.templateId = template;
74
- if (framework)
75
- body.framework = framework;
76
- if (instructions)
77
- body.instructions = instructions;
78
- agent = await authPost('/api/agents', body);
79
- }
80
- catch (error) {
81
- spinner.fail('Failed to create agent');
82
- throw error;
83
- }
84
- spinner.succeed(chalk.green('Created ') + chalk.bold(agent.name) + chalk.dim(` (${agent.id})`));
85
- linkPath = writeLink({ agentId: agent.id, name: agent.name });
86
- }
87
- outputResult({
88
- ok: true,
89
- action: 'init',
90
- config: configPath,
91
- wroteConfig,
92
- wroteAgentsMd,
93
- agentId: agent?.id ?? null,
94
- agentName: agent?.name ?? name,
95
- linked: Boolean(linkPath),
96
- }, () => {
97
- console.log(chalk.dim(` ${wroteConfig ? 'wrote' : 'updated'} ${CONFIG_FILENAME}`));
98
- if (wroteAgentsMd)
99
- console.log(chalk.dim(' wrote AGENTS.md'));
100
- if (agent) {
101
- console.log(chalk.dim(' linked this directory → ') + chalk.bold(agent.name));
102
- console.log();
103
- console.log('Next: ' + chalk.bold('maritime chat "hello"') + chalk.dim(' · ') + chalk.bold('maritime deploy') + chalk.dim(' to push edits'));
104
- }
105
- else {
106
- console.log();
107
- console.log('Next: ' + chalk.bold('maritime deploy') + chalk.dim(' to create + link the agent'));
108
- }
109
- });
110
- }
111
- catch (error) {
112
- handleError(error);
113
- }
114
- });
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const keysCommand: Command;
@@ -1,90 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import { authGet, authPost, authDelete } from '../api.js';
4
- import { isJsonMode, outputJson, outputResult, handleError } from '../output.js';
5
- const VALID_SCOPES = ['provision', 'deploy', 'secrets', 'manage'];
6
- export const keysCommand = new Command('keys')
7
- .description('Manage long-lived API keys (mk_…) for non-interactive / AI-agent access');
8
- keysCommand
9
- .command('create')
10
- .description('Mint a new API key. Shown once, so save it as MARITIME_TOKEN.')
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. Pass a narrower set to restrict the key.`, 'provision,deploy,secrets,manage')
13
- .action(async (opts) => {
14
- try {
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 });
25
- outputResult(created, () => {
26
- console.log(chalk.green('Created API key ') + chalk.bold(created.name) + chalk.dim(` [${created.scopes.join(', ')}]`));
27
- console.log();
28
- console.log(' ' + chalk.bold(created.raw_key));
29
- console.log();
30
- console.log(chalk.yellow(' Save this now. It will not be shown again.'));
31
- console.log(chalk.dim(' Use it non-interactively with:'));
32
- console.log(chalk.dim(` export MARITIME_TOKEN=${created.raw_key}`));
33
- });
34
- }
35
- catch (error) {
36
- handleError(error);
37
- }
38
- });
39
- keysCommand
40
- .command('list')
41
- .alias('ls')
42
- .description('List your API keys (values are never shown again)')
43
- .action(async () => {
44
- try {
45
- const keys = await authGet('/api/v1/keys');
46
- if (isJsonMode()) {
47
- outputJson(keys);
48
- return;
49
- }
50
- if (keys.length === 0) {
51
- console.log(chalk.dim('No API keys. Run `maritime keys create` to mint one.'));
52
- return;
53
- }
54
- console.log('\n ' +
55
- chalk.dim('ID'.padEnd(14)) +
56
- chalk.dim('NAME'.padEnd(20)) +
57
- chalk.dim('PREFIX'.padEnd(15)) +
58
- chalk.dim('SCOPES'.padEnd(28)) +
59
- chalk.dim('LAST USED'));
60
- console.log(chalk.dim(' ' + '─'.repeat(86)));
61
- for (const k of keys) {
62
- const last = k.last_used_at;
63
- const lastStr = last ? new Date(last).toLocaleString() : chalk.dim('never');
64
- console.log(' ' +
65
- chalk.dim(String(k.id).slice(0, 12).padEnd(14)) +
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) +
69
- lastStr);
70
- }
71
- console.log();
72
- }
73
- catch (error) {
74
- handleError(error);
75
- }
76
- });
77
- keysCommand
78
- .command('revoke')
79
- .alias('delete')
80
- .description('Revoke an API key by ID')
81
- .argument('<id>', 'API key ID (from `maritime keys list`)')
82
- .action(async (id) => {
83
- try {
84
- await authDelete(`/api/v1/keys/${id}`);
85
- outputResult({ ok: true, action: 'revoke', id }, () => console.log(chalk.green('Revoked key ') + chalk.bold(id)));
86
- }
87
- catch (error) {
88
- handleError(error);
89
- }
90
- });
@@ -1,4 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const linkCommand: Command;
3
- /** Read the current link for display (used by whoami/status helpers if needed). */
4
- export declare function currentLink(): import("../context.js").ProjectLink | null;
@@ -1,65 +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 { 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
- }
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const listCommand: Command;
@@ -1,55 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import { authGet } from '../api.js';
4
- import { isJsonMode, outputJson, handleError } from '../output.js';
5
- function sleepPolicyOf(a) {
6
- if (a.sleepPolicy)
7
- return a.sleepPolicy;
8
- return a.idleTtlSeconds != null && a.idleTtlSeconds <= 0 ? 'always-on' : 'auto-sleep';
9
- }
10
- const statusColors = {
11
- active: chalk.green,
12
- sleeping: chalk.blue,
13
- deploying: chalk.yellow,
14
- error: chalk.red,
15
- stopped: chalk.gray,
16
- };
17
- export const listCommand = new Command('list')
18
- .alias('ls')
19
- .description('List your agents')
20
- .action(async () => {
21
- try {
22
- const agents = await authGet('/api/agents');
23
- if (isJsonMode()) {
24
- outputJson(agents);
25
- return;
26
- }
27
- if (agents.length === 0) {
28
- console.log(chalk.yellow('No agents found.') + ' Run `maritime create` to create one.');
29
- return;
30
- }
31
- console.log('\n ' +
32
- chalk.dim('NAME'.padEnd(24)) +
33
- chalk.dim('STATUS'.padEnd(12)) +
34
- chalk.dim('SLEEP'.padEnd(12)) +
35
- chalk.dim('FRAMEWORK'.padEnd(20)) +
36
- chalk.dim('CREATED'));
37
- console.log(chalk.dim(' ' + '\u2500'.repeat(88)));
38
- for (const a of agents) {
39
- const colorFn = statusColors[a.status] || chalk.white;
40
- const created = a.createdAt ? new Date(a.createdAt).toLocaleDateString() : '';
41
- const name = a.name.length > 22 ? a.name.slice(0, 21) + '\u2026' : a.name;
42
- const fw = a.framework.length > 18 ? a.framework.slice(0, 17) + '\u2026' : a.framework;
43
- console.log(' ' +
44
- chalk.bold(name.padEnd(24)) +
45
- colorFn(a.status.padEnd(12)) +
46
- sleepPolicyOf(a).padEnd(12) +
47
- fw.padEnd(20) +
48
- chalk.dim(created));
49
- }
50
- console.log();
51
- }
52
- catch (error) {
53
- handleError(error);
54
- }
55
- });
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const loginCommand: Command;