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,209 +0,0 @@
1
- import http from 'node:http';
2
- import crypto from 'node:crypto';
3
- import { Command } from 'commander';
4
- import chalk from 'chalk';
5
- import open from 'open';
6
- import { config } from '../config.js';
7
- import { CliHttpError, getApiUrl, postJson } from '../api.js';
8
- import { EXIT, fail, handleError, makeSpinner, outputResult } from '../output.js';
9
- import { promptForPassword, promptForValue } from '../prompt.js';
10
- const APP_URL = process.env.MARITIME_APP_URL || 'https://maritime.sh';
11
- const TIMEOUT_MS = 120_000;
12
- function decodeJwt(token) {
13
- const parts = token.split('.');
14
- if (parts.length !== 3)
15
- return null;
16
- try {
17
- return JSON.parse(Buffer.from(parts[1], 'base64url').toString());
18
- }
19
- catch {
20
- return null;
21
- }
22
- }
23
- function persistToken(token, payload) {
24
- config.set('token', token);
25
- config.set('user', payload.email ?? '');
26
- config.set('userId', payload.sub ?? payload.id ?? '');
27
- config.set('apiUrl', getApiUrl());
28
- }
29
- function browserLogin() {
30
- return new Promise((resolve, reject) => {
31
- const state = crypto.randomBytes(16).toString('hex');
32
- const server = http.createServer((req, res) => {
33
- const url = new URL(req.url || '/', `http://localhost`);
34
- if (url.pathname !== '/callback') {
35
- res.writeHead(404);
36
- res.end();
37
- return;
38
- }
39
- const token = url.searchParams.get('token');
40
- const returnedState = url.searchParams.get('state');
41
- if (returnedState !== state || !token) {
42
- res.writeHead(400, { 'Content-Type': 'text/html' });
43
- res.end('<html><body><h2>Authentication failed.</h2><p>State mismatch or missing token. Please try again.</p></body></html>');
44
- cleanup(new Error('State mismatch or missing token'));
45
- return;
46
- }
47
- res.writeHead(200, { 'Content-Type': 'text/html' });
48
- res.end('<html><body><h2>Authenticated!</h2><p>You can close this tab and return to the terminal.</p></body></html>');
49
- cleanup(null, token);
50
- });
51
- const timer = setTimeout(() => {
52
- cleanup(new Error('Login timed out. Try `maritime login --token <token>` (get one at ' + APP_URL + '/cli/auth) instead.'));
53
- }, TIMEOUT_MS);
54
- function cleanup(err, token) {
55
- clearTimeout(timer);
56
- server.close();
57
- if (err)
58
- reject(err);
59
- else
60
- resolve(token);
61
- }
62
- server.listen(0, '127.0.0.1', () => {
63
- const addr = server.address();
64
- if (!addr || typeof addr === 'string') {
65
- cleanup(new Error('Failed to start local server'));
66
- return;
67
- }
68
- const port = addr.port;
69
- const loginUrl = `${APP_URL}/cli/auth?port=${port}&state=${state}`;
70
- open(loginUrl).catch(() => {
71
- // If open fails, print URL for manual use
72
- console.log(chalk.yellow('\nCould not open browser. Visit this URL manually:'));
73
- console.log(chalk.bold(loginUrl) + '\n');
74
- });
75
- });
76
- });
77
- }
78
- /**
79
- * Asks the server to send the email verification link again.
80
- *
81
- * The server always answers ok, also for an address with no account or an
82
- * address that is already verified, so "Sent" does not confirm an account.
83
- *
84
- * @param emailFlag The value of `-e`. When absent, the email of the stored login is used.
85
- */
86
- async function resendVerification(emailFlag) {
87
- const email = (emailFlag ?? config.get('user') ?? '').trim();
88
- if (!email) {
89
- fail('No email to send to. Run `maritime login --resend -e <email>`.', {
90
- code: 'email_required',
91
- exitCode: EXIT.USAGE,
92
- });
93
- }
94
- try {
95
- await postJson('/api/auth/resend-verification', { email });
96
- }
97
- catch (error) {
98
- handleError(error);
99
- }
100
- outputResult({ ok: true, action: 'resend_verification', email }, `Sent. Check ${email}.`);
101
- }
102
- export const loginCommand = new Command('login')
103
- .description('Authenticate with Maritime')
104
- .option('-e, --email <email>', 'Email address (for non-interactive login)')
105
- .option('-p, --password <password>', 'Password (for non-interactive login)')
106
- .option('-t, --token <token>', `Paste a token from ${APP_URL}/cli/auth (works for SSO / headless / CI)`)
107
- .option('--resend', 'Send the email verification link again (uses -e, else the logged-in email)')
108
- .action(async (opts) => {
109
- if (opts.resend) {
110
- await resendVerification(opts.email);
111
- return;
112
- }
113
- // 1. Token paste — the universal path. Works for any account, including
114
- // OAuth-only (Google/GitHub) users who have no password to type.
115
- // Generate one at <app>/cli/auth.
116
- if (opts.token) {
117
- const token = String(opts.token).trim();
118
- const payload = decodeJwt(token);
119
- if (!payload) {
120
- console.log(chalk.red('Error:') + ' that does not look like a valid token.');
121
- console.log(chalk.dim(` Copy a fresh one from ${APP_URL}/cli/auth`));
122
- process.exitCode = 1;
123
- return;
124
- }
125
- if (payload.exp && Date.now() >= payload.exp * 1000) {
126
- console.log(chalk.red('Error:') + ' that token has expired.');
127
- console.log(chalk.dim(` Generate a new one at ${APP_URL}/cli/auth`));
128
- process.exitCode = 1;
129
- return;
130
- }
131
- persistToken(token, payload);
132
- console.log(chalk.green('Authenticated as ') + chalk.bold(payload.email || 'your account'));
133
- return;
134
- }
135
- // 2. Email/password (non-interactive). OAuth-only accounts have no
136
- // password — they get pointed at the browser / token flow below.
137
- if (opts.email || opts.password) {
138
- if (opts.password) {
139
- console.log(chalk.yellow('Warning:') +
140
- ' Passing --password on the command line may expose it in shell history.' +
141
- '\n Prefer `maritime login` (browser) or `maritime login --token` for CI.');
142
- }
143
- const email = await promptForValue('Email', opts.email);
144
- const password = await promptForPassword(opts.password);
145
- if (!email || !password) {
146
- console.log(chalk.red('Error:') + ' email and password are required');
147
- process.exitCode = 1;
148
- return;
149
- }
150
- const spinner = await makeSpinner('Authenticating...');
151
- try {
152
- const auth = await postJson('/api/auth/cli-login', {
153
- email,
154
- password,
155
- });
156
- config.set('token', auth.token);
157
- config.set('user', auth.user.email);
158
- config.set('userId', auth.user.id);
159
- config.set('apiUrl', getApiUrl());
160
- spinner.succeed(chalk.green('Authenticated as ') + chalk.bold(auth.user.email));
161
- }
162
- catch (error) {
163
- spinner.fail('Authentication failed');
164
- if (error instanceof CliHttpError) {
165
- // OAuth-only accounts (no password) — guide the user to a path that
166
- // actually works for them instead of the raw "oauth_only:google".
167
- if (error.detail.startsWith('oauth_only:')) {
168
- const providers = error.detail
169
- .slice('oauth_only:'.length)
170
- .split(',')
171
- .join(', ');
172
- console.log(chalk.red('Error:') +
173
- ` this account signs in with ${chalk.bold(providers)}. There's no password to use here.`);
174
- console.log('\nAuthenticate one of these ways instead:');
175
- console.log(' ' + chalk.bold('maritime login') + chalk.dim(' open the browser and approve'));
176
- console.log(' ' + chalk.bold('maritime login --token <token>') + chalk.dim(` paste a token from ${APP_URL}/cli/auth`));
177
- process.exitCode = 2;
178
- return;
179
- }
180
- console.log(chalk.red('Error:') + ` ${error.detail}`);
181
- process.exitCode = error.status === 401 ? 2 : 1;
182
- return;
183
- }
184
- throw error;
185
- }
186
- return;
187
- }
188
- // 3. Default: browser-based login.
189
- const spinner = await makeSpinner('Opening browser for authentication...');
190
- try {
191
- const token = await browserLogin();
192
- const payload = decodeJwt(token);
193
- if (!payload) {
194
- throw new Error('Received a malformed token from the browser.');
195
- }
196
- persistToken(token, payload);
197
- spinner.succeed(chalk.green('Authenticated as ') + chalk.bold(payload.email || 'your account'));
198
- }
199
- catch (error) {
200
- spinner.fail('Authentication failed');
201
- if (error instanceof Error) {
202
- console.log(chalk.red('Error:') + ` ${error.message}`);
203
- }
204
- console.log(chalk.dim('\nOn a headless / SSH box? Run ') +
205
- chalk.bold('maritime login --token <token>') +
206
- chalk.dim(` with a token from ${APP_URL}/cli/auth`));
207
- process.exitCode = 1;
208
- }
209
- });
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const logoutCommand: Command;
@@ -1,12 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import { config } from '../config.js';
4
- export const logoutCommand = new Command('logout')
5
- .description('Log out of Maritime')
6
- .action(() => {
7
- config.delete('token');
8
- config.delete('user');
9
- config.delete('userId');
10
- config.delete('apiUrl');
11
- console.log(chalk.green('Logged out.'));
12
- });
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const logsCommand: Command;
@@ -1,89 +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, fail, EXIT } from '../output.js';
6
- import { connectWs } from '../websocket.js';
7
- const VALID_LEVELS = ['info', 'warn', 'error', 'debug'];
8
- const levelColors = {
9
- info: chalk.blue,
10
- warn: chalk.yellow,
11
- error: chalk.red,
12
- debug: chalk.gray,
13
- };
14
- function formatEntry(entry) {
15
- const ts = entry.timestamp
16
- ? chalk.dim(new Date(entry.timestamp).toLocaleTimeString())
17
- : chalk.dim('--:--:--');
18
- const level = entry.level || 'info';
19
- const colorFn = levelColors[level] || chalk.white;
20
- const levelStr = colorFn(level.toUpperCase().padEnd(5));
21
- return `${ts} ${levelStr} ${entry.message}`;
22
- }
23
- export const logsCommand = new Command('logs')
24
- .description('View logs from an agent')
25
- .argument('[agent]', 'Agent name or ID (defaults to the linked agent)')
26
- .option('-n, --lines <num>', 'Number of lines', '50')
27
- .option('--level <level>', 'Filter by level (info, warn, error, debug)')
28
- .option('-f, --follow', 'Follow log output')
29
- .action(async (agentArg, opts) => {
30
- // Validate --level
31
- if (opts.level && !VALID_LEVELS.includes(opts.level)) {
32
- fail('--level must be one of info, warn, error, debug', {
33
- code: 'usage',
34
- exitCode: EXIT.USAGE,
35
- });
36
- }
37
- // Validate --lines
38
- const lines = parseInt(opts.lines, 10);
39
- if (isNaN(lines) || lines <= 0) {
40
- fail('--lines must be a positive integer', {
41
- code: 'usage',
42
- exitCode: EXIT.USAGE,
43
- });
44
- }
45
- const agent = await resolveAgent(agentArg);
46
- let path = `/api/agents/${agent.id}/logs?limit=${lines}`;
47
- if (opts.level)
48
- path += `&level=${opts.level}`;
49
- try {
50
- const entries = await authGet(path);
51
- if (isJsonMode() && !opts.follow) {
52
- outputJson(entries);
53
- return;
54
- }
55
- if (entries.length === 0 && !opts.follow) {
56
- console.log(chalk.dim('No logs found.'));
57
- return;
58
- }
59
- for (const entry of entries) {
60
- console.log(formatEntry(entry));
61
- }
62
- // --follow: stream logs via WebSocket. Await the stream's end so the
63
- // action only resolves when following is done: the command finishes
64
- // through the normal exit path (loop drains, no hard process.exit
65
- // from inside a socket callback).
66
- if (opts.follow) {
67
- await new Promise((resolve) => {
68
- connectWs(`/api/agents/${agent.id}/logs`, {
69
- onMessage(data) {
70
- try {
71
- const entry = JSON.parse(data);
72
- console.log(formatEntry(entry));
73
- }
74
- catch {
75
- // Plain text message
76
- console.log(data);
77
- }
78
- },
79
- onClose() {
80
- resolve();
81
- },
82
- });
83
- });
84
- }
85
- }
86
- catch (error) {
87
- handleError(error);
88
- }
89
- });
@@ -1,8 +0,0 @@
1
- import { Command } from 'commander';
2
- /**
3
- * The project front door: send a message AS one of your end-users. Unlike
4
- * `chat` (which talks to one specific agent), this routes by --user: the same
5
- * external user id always reaches the same dedicated agent, and an unknown id
6
- * gets an agent assigned/spawned per the project's newChatPolicy.
7
- */
8
- export declare const messageCommand: Command;
@@ -1,75 +0,0 @@
1
- import { Command } from 'commander';
2
- import { authGet, authPost } from '../api.js';
3
- import { resolveAgent } from '../resolve.js';
4
- import { outputResult, fail, handleError, makeSpinner } from '../output.js';
5
- /**
6
- * The project front door: send a message AS one of your end-users. Unlike
7
- * `chat` (which talks to one specific agent), this routes by --user: the same
8
- * external user id always reaches the same dedicated agent, and an unknown id
9
- * gets an agent assigned/spawned per the project's newChatPolicy.
10
- */
11
- export const messageCommand = new Command('message')
12
- .description("Send an end-user's message through an agent's project front door")
13
- .argument('[agent]', 'Any agent in the project (names the project; optional when linked)')
14
- .argument('[message...]', 'Message to send')
15
- .requiredOption('-u, --user <externalUserId>', "YOUR end-user's id (sticky: same id → same agent)")
16
- .option('-w, --wait <seconds>', 'Seconds to wait for the reply inline (0-60)', '30')
17
- .option('--display-name <name>', 'Human-readable label stored on the binding')
18
- .addHelpText('after', `
19
- Examples:
20
- maritime message support-bot --user cust_42 "where is my order?"
21
- maritime message --user cust_42 "hi" # linked directory
22
- maritime message support-bot --user cust_42 --wait 0 "hi" --json # ack + poll later
23
-
24
- A 200 with status=replied carries the reply inline. status=provisioning/queued
25
- means the user's agent is still being set up. The reply arrives via the
26
- message.reply webhook (maritime guide: webhooks) or GET the message by id.`)
27
- .action(async (agentPos, messageParts, opts) => {
28
- try {
29
- const message = (messageParts || []).join(' ').trim();
30
- if (!message) {
31
- fail('No message provided.', { code: 'usage', exitCode: 4 });
32
- }
33
- const wait = Math.max(0, Math.min(60, Number(opts.wait) || 0));
34
- const agent = await resolveAgent(agentPos);
35
- // The summary omits projectId — fetch the full record for it.
36
- const full = await authGet(`/api/agents/${agent.id}`);
37
- if (!full.projectId) {
38
- fail(`Agent ${agent.name} has no project. Recreate it or use \`maritime chat\`.`, {
39
- code: 'no_project',
40
- });
41
- }
42
- const spinner = await makeSpinner(`Routing to ${opts.user}'s agent...`);
43
- let state;
44
- try {
45
- state = await authPost(`/api/v1/projects/${full.projectId}/messages`, {
46
- externalUserId: opts.user,
47
- message,
48
- wait,
49
- displayName: opts.displayName,
50
- });
51
- }
52
- catch (error) {
53
- spinner.fail('Message failed');
54
- throw error;
55
- }
56
- spinner.stop();
57
- if (state.status === 'failed') {
58
- fail(state.error || 'Delivery failed', { code: 'delivery_failed' });
59
- }
60
- outputResult({ ok: true, ...state }, () => {
61
- if (state.status === 'replied') {
62
- const reply = state.reply ?? '';
63
- process.stdout.write(reply + (reply.endsWith('\n') ? '' : '\n'));
64
- }
65
- else {
66
- process.stdout.write(`${state.status}: ${state.externalUserId}'s agent is getting ready ` +
67
- `(message ${state.messageId}). The reply will arrive via the ` +
68
- `message.reply webhook.\n`);
69
- }
70
- });
71
- }
72
- catch (error) {
73
- handleError(error);
74
- }
75
- });
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const openCommand: Command;
@@ -1,25 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import open from 'open';
4
- import { CliHttpError } from '../api.js';
5
- import { resolveAgent } from '../resolve.js';
6
- const APP_URL = process.env.MARITIME_APP_URL || 'https://maritime.sh';
7
- export const openCommand = new Command('open')
8
- .description('Open an agent in the dashboard')
9
- .argument('[agent]', 'Agent name or ID (defaults to the linked agent)')
10
- .action(async (agentArg) => {
11
- try {
12
- const agent = await resolveAgent(agentArg);
13
- const url = `${APP_URL}/dashboard/agents/${agent.id}`;
14
- console.log(chalk.dim(`Opening ${url}`));
15
- await open(url);
16
- }
17
- catch (error) {
18
- if (error instanceof CliHttpError) {
19
- console.log(chalk.red('Error:') + ` ${error.detail}`);
20
- process.exitCode = 1;
21
- return;
22
- }
23
- throw error;
24
- }
25
- });
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const restartCommand: Command;
@@ -1,26 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import { authPost } from '../api.js';
4
- import { resolveAgent } from '../resolve.js';
5
- import { outputResult, handleError, makeSpinner } from '../output.js';
6
- export const restartCommand = new Command('restart')
7
- .description('Restart an agent')
8
- .argument('[agent]', 'Agent name or ID (defaults to the linked agent)')
9
- .action(async (agentArg) => {
10
- try {
11
- const agent = await resolveAgent(agentArg);
12
- const spinner = await makeSpinner(`Restarting ${chalk.bold(agent.name)}...`);
13
- try {
14
- await authPost(`/api/agents/${agent.id}/restart`);
15
- }
16
- catch (error) {
17
- spinner.fail('Failed to restart agent');
18
- throw error;
19
- }
20
- spinner.succeed(chalk.green('Restarted ') + chalk.bold(agent.name));
21
- outputResult({ ok: true, action: 'restart', agentId: agent.id, name: agent.name }, () => { });
22
- }
23
- catch (error) {
24
- handleError(error);
25
- }
26
- });
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const signupCommand: Command;
@@ -1,45 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import { config } from '../config.js';
4
- import { CliHttpError, postJson } from '../api.js';
5
- import { makeSpinner } from '../output.js';
6
- import { promptForPassword, promptForValue } from '../prompt.js';
7
- export const signupCommand = new Command('signup')
8
- .description('Create a Maritime account with email and password')
9
- .option('-e, --email <email>', 'Email address')
10
- .option('-p, --password <password>', 'Password')
11
- .option('-n, --name <name>', 'Display name')
12
- .action(async (opts) => {
13
- const email = await promptForValue('Email', opts.email);
14
- const password = await promptForPassword(opts.password);
15
- const name = await promptForValue('Name (optional)', opts.name);
16
- if (!email || !password) {
17
- console.log(chalk.red('Error:') + ' email and password are required');
18
- process.exitCode = 1;
19
- return;
20
- }
21
- const spinner = await makeSpinner('Creating account...');
22
- try {
23
- const auth = await postJson('/api/auth/cli-signup', {
24
- email,
25
- password,
26
- name: name || undefined,
27
- });
28
- config.set('token', auth.token);
29
- config.set('user', auth.user.email);
30
- config.set('userId', auth.user.id);
31
- config.set('apiUrl', process.env.MARITIME_API_URL || 'https://api.maritime.sh');
32
- spinner.succeed(chalk.green('Authenticated as ') + chalk.bold(auth.user.email));
33
- console.log(chalk.dim('\nToken saved.'));
34
- console.log(`Verify your email to deploy: we sent a link to ${auth.user.email}.`);
35
- }
36
- catch (error) {
37
- spinner.fail('Signup failed');
38
- if (error instanceof CliHttpError) {
39
- console.log(chalk.red('Error:') + ` ${error.detail}`);
40
- process.exitCode = error.status >= 500 ? 1 : 2;
41
- return;
42
- }
43
- throw error;
44
- }
45
- });
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const sleepCommand: Command;
@@ -1,22 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import { authPost } from '../api.js';
4
- import { resolveAgent } from '../resolve.js';
5
- import { isJsonMode, outputJson, handleError, makeSpinner } from '../output.js';
6
- export const sleepCommand = new Command('sleep')
7
- .description('Put an agent to sleep')
8
- .argument('[agent]', 'Agent name or ID (defaults to the linked agent)')
9
- .action(async (agentArg) => {
10
- try {
11
- const agent = await resolveAgent(agentArg);
12
- const spinner = await makeSpinner(`Sleeping ${chalk.bold(agent.name)}...`);
13
- const result = await authPost(`/api/agents/${agent.id}/sleep`);
14
- spinner.succeed(chalk.green('Agent is now sleeping: ') + chalk.bold(agent.name));
15
- if (isJsonMode()) {
16
- outputJson(result);
17
- }
18
- }
19
- catch (error) {
20
- handleError(error);
21
- }
22
- });
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const startCommand: Command;
@@ -1,27 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import { authPost } from '../api.js';
4
- import { resolveAgent } from '../resolve.js';
5
- import { outputResult, handleError, makeSpinner } from '../output.js';
6
- export const startCommand = new Command('start')
7
- .description('Start an agent')
8
- .argument('[agent]', 'Agent name or ID (defaults to the linked agent)')
9
- .action(async (agentArg) => {
10
- try {
11
- const agent = await resolveAgent(agentArg);
12
- const spinner = await makeSpinner(`Starting ${chalk.bold(agent.name)}...`);
13
- try {
14
- await authPost(`/api/agents/${agent.id}/start`);
15
- }
16
- catch (error) {
17
- spinner.fail('Failed to start agent');
18
- throw error;
19
- }
20
- spinner.succeed(chalk.green('Started ') + chalk.bold(agent.name));
21
- // Spinner already printed the human line; only --json needs output here.
22
- outputResult({ ok: true, action: 'start', agentId: agent.id, name: agent.name }, () => { });
23
- }
24
- catch (error) {
25
- handleError(error);
26
- }
27
- });
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const statusCommand: Command;
@@ -1,69 +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 statusCommand = new Command('status')
7
- .description('Show detailed status 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 agent = await authGet(`/api/agents/${summary.id}`);
13
- if (isJsonMode()) {
14
- outputJson(agent);
15
- return;
16
- }
17
- console.log();
18
- console.log(chalk.bold(agent.name));
19
- console.log(chalk.dim('─'.repeat(40)));
20
- console.log(` ${'Status:'.padEnd(16)} ${statusColor(agent.status)}`);
21
- console.log(` ${'Framework:'.padEnd(16)} ${agent.framework}`);
22
- const resParts = [];
23
- if (agent.memMb)
24
- resParts.push(`${agent.memMb}MB`);
25
- if (agent.vcpus)
26
- resParts.push(`${agent.vcpus} vCPU`);
27
- if (agent.diskMb)
28
- resParts.push(`${(agent.diskMb / 1024).toFixed(1)}GB disk`);
29
- if (resParts.length)
30
- console.log(` ${'Resources:'.padEnd(16)} ${resParts.join(' / ')} ${chalk.dim('(override)')}`);
31
- if (agent.idleTtlSeconds != null) {
32
- const idle = agent.idleTtlSeconds <= 0 ? 'always-on' : `${agent.idleTtlSeconds}s after request`;
33
- console.log(` ${'Idle:'.padEnd(16)} ${idle}`);
34
- }
35
- console.log(` ${'ID:'.padEnd(16)} ${chalk.dim(agent.id)}`);
36
- if (agent.invocationCount !== undefined) {
37
- console.log(` ${'Invocations:'.padEnd(16)} ${agent.invocationCount}`);
38
- }
39
- if (agent.createdAt) {
40
- console.log(` ${'Created:'.padEnd(16)} ${new Date(agent.createdAt).toLocaleString()}`);
41
- }
42
- if (agent.updatedAt) {
43
- console.log(` ${'Updated:'.padEnd(16)} ${new Date(agent.updatedAt).toLocaleString()}`);
44
- }
45
- if (agent.containerId) {
46
- console.log(` ${'Container:'.padEnd(16)} ${chalk.dim(agent.containerId.slice(0, 12))}`);
47
- }
48
- console.log();
49
- }
50
- catch (error) {
51
- handleError(error);
52
- }
53
- });
54
- function statusColor(status) {
55
- switch (status) {
56
- case 'active':
57
- return chalk.green(status);
58
- case 'sleeping':
59
- return chalk.blue(status);
60
- case 'deploying':
61
- return chalk.yellow(status);
62
- case 'error':
63
- return chalk.red(status);
64
- case 'stopped':
65
- return chalk.gray(status);
66
- default:
67
- return status;
68
- }
69
- }
@@ -1,2 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const stopCommand: Command;