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.
- package/README.md +17 -0
- package/bin/maritime.js +40 -0
- package/install.js +118 -0
- package/package.json +22 -36
- package/AGENTS.md +0 -309
- package/dist/api.d.ts +0 -30
- package/dist/api.js +0 -240
- 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 -87
- 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 -114
- 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 -209
- 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 -45
- 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/stop.js
DELETED
|
@@ -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 stopCommand = new Command('stop')
|
|
7
|
-
.description('Stop 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(`Stopping ${chalk.bold(agent.name)}...`);
|
|
13
|
-
try {
|
|
14
|
-
await authPost(`/api/agents/${agent.id}/stop`);
|
|
15
|
-
}
|
|
16
|
-
catch (error) {
|
|
17
|
-
spinner.fail('Failed to stop agent');
|
|
18
|
-
throw error;
|
|
19
|
-
}
|
|
20
|
-
spinner.succeed(chalk.green('Stopped ') + chalk.bold(agent.name));
|
|
21
|
-
outputResult({ ok: true, action: 'stop', agentId: agent.id, name: agent.name }, () => { });
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
handleError(error);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { publicGet } from '../api.js';
|
|
4
|
-
import { isJsonMode, outputJson, handleError } from '../output.js';
|
|
5
|
-
export const templatesCommand = new Command('templates')
|
|
6
|
-
.description('List available agent templates')
|
|
7
|
-
.action(async () => {
|
|
8
|
-
try {
|
|
9
|
-
const templates = await publicGet('/api/templates');
|
|
10
|
-
if (isJsonMode()) {
|
|
11
|
-
outputJson(templates);
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
if (templates.length === 0) {
|
|
15
|
-
console.log(chalk.dim('No templates available.'));
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
console.log('\n ' +
|
|
19
|
-
chalk.dim('NAME'.padEnd(20)) +
|
|
20
|
-
chalk.dim('FRAMEWORK'.padEnd(20)) +
|
|
21
|
-
chalk.dim('DESCRIPTION'));
|
|
22
|
-
console.log(chalk.dim(' ' + '\u2500'.repeat(66)));
|
|
23
|
-
for (const t of templates) {
|
|
24
|
-
const fw = t.framework.length > 18 ? t.framework.slice(0, 17) + '\u2026' : t.framework;
|
|
25
|
-
console.log(' ' +
|
|
26
|
-
chalk.bold(t.name.padEnd(20)) +
|
|
27
|
-
fw.padEnd(20) +
|
|
28
|
-
chalk.dim(t.description || ''));
|
|
29
|
-
// Surface the demo recording so the CLI links the same clip the
|
|
30
|
-
// dashboard template card does.
|
|
31
|
-
if (t.videoUrl) {
|
|
32
|
-
console.log(' ' + ' '.repeat(20) + chalk.cyan('\u25b6 demo: ') + chalk.underline(t.videoUrl));
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
console.log();
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
handleError(error);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { authGet, authPost, authDelete } from '../api.js';
|
|
4
|
-
import { resolveAgent } from '../resolve.js';
|
|
5
|
-
import { isJsonMode, outputJson, handleError } from '../output.js';
|
|
6
|
-
const triggerListCmd = new Command('list')
|
|
7
|
-
.description('List triggers for an agent')
|
|
8
|
-
.argument('<agent>', 'Agent name or ID')
|
|
9
|
-
.action(async (agentArg) => {
|
|
10
|
-
try {
|
|
11
|
-
const agent = await resolveAgent(agentArg);
|
|
12
|
-
const triggers = await authGet(`/api/agents/${agent.id}/triggers`);
|
|
13
|
-
if (isJsonMode()) {
|
|
14
|
-
outputJson(triggers);
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
if (triggers.length === 0) {
|
|
18
|
-
console.log(chalk.dim('No triggers configured.'));
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
console.log('\n ' +
|
|
22
|
-
chalk.dim('ID'.padEnd(14)) +
|
|
23
|
-
chalk.dim('TYPE'.padEnd(14)) +
|
|
24
|
-
chalk.dim('CONFIG'));
|
|
25
|
-
console.log(chalk.dim(' ' + '\u2500'.repeat(50)));
|
|
26
|
-
for (const t of triggers) {
|
|
27
|
-
const configStr = t.config ? JSON.stringify(t.config) : '';
|
|
28
|
-
console.log(' ' +
|
|
29
|
-
chalk.dim(t.id.slice(0, 12).padEnd(14)) +
|
|
30
|
-
t.type.padEnd(14) +
|
|
31
|
-
chalk.dim(configStr.length > 40 ? configStr.slice(0, 39) + '\u2026' : configStr));
|
|
32
|
-
}
|
|
33
|
-
console.log();
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
handleError(error);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
const triggerCreateCmd = new Command('create')
|
|
40
|
-
.description('Create a trigger for an agent')
|
|
41
|
-
.argument('<agent>', 'Agent name or ID')
|
|
42
|
-
.requiredOption('--type <type>', 'Trigger type (webhook, cron, telegram, discord)')
|
|
43
|
-
.option('--cron <expression>', 'Cron expression (for cron triggers)')
|
|
44
|
-
.option('--prompt <text>', 'Message delivered to the agent on each fire (cron triggers only, max 2000 chars)')
|
|
45
|
-
.action(async (agentArg, opts) => {
|
|
46
|
-
try {
|
|
47
|
-
if (opts.prompt !== undefined && opts.type !== 'cron') {
|
|
48
|
-
handleError(new Error('--prompt applies to cron triggers only'));
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const agent = await resolveAgent(agentArg);
|
|
52
|
-
const body = { type: opts.type };
|
|
53
|
-
const config = {};
|
|
54
|
-
if (opts.cron)
|
|
55
|
-
config.cron = opts.cron;
|
|
56
|
-
if (opts.prompt)
|
|
57
|
-
config.prompt = opts.prompt;
|
|
58
|
-
if (Object.keys(config).length > 0)
|
|
59
|
-
body.config = config;
|
|
60
|
-
const trigger = await authPost(`/api/agents/${agent.id}/triggers`, body);
|
|
61
|
-
if (isJsonMode()) {
|
|
62
|
-
outputJson(trigger);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
console.log(chalk.green('Trigger created:') + ` ${trigger.id} (${trigger.type})`);
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
handleError(error);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
const triggerDeleteCmd = new Command('delete')
|
|
72
|
-
.description('Delete a trigger')
|
|
73
|
-
.argument('<agent>', 'Agent name or ID')
|
|
74
|
-
.argument('<trigger-id>', 'Trigger ID')
|
|
75
|
-
.action(async (agentArg, triggerId) => {
|
|
76
|
-
try {
|
|
77
|
-
const agent = await resolveAgent(agentArg);
|
|
78
|
-
await authDelete(`/api/agents/${agent.id}/triggers/${triggerId}`);
|
|
79
|
-
console.log(chalk.green('Trigger deleted.'));
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
handleError(error);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
export const triggersCommand = new Command('triggers')
|
|
86
|
-
.description('Manage agent triggers')
|
|
87
|
-
.addCommand(triggerListCmd)
|
|
88
|
-
.addCommand(triggerCreateCmd)
|
|
89
|
-
.addCommand(triggerDeleteCmd);
|
package/dist/commands/whoami.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { config } from '../config.js';
|
|
4
|
-
import { isJsonMode, outputResult, fail, EXIT } from '../output.js';
|
|
5
|
-
function decodeJwt(token) {
|
|
6
|
-
try {
|
|
7
|
-
const parts = token.split('.');
|
|
8
|
-
if (parts.length !== 3)
|
|
9
|
-
return null;
|
|
10
|
-
return JSON.parse(Buffer.from(parts[1], 'base64url').toString());
|
|
11
|
-
}
|
|
12
|
-
catch {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export const whoamiCommand = new Command('whoami')
|
|
17
|
-
.description('Show the current authentication (token source, user, expiry)')
|
|
18
|
-
.action(() => {
|
|
19
|
-
// Env var wins (how an AI agent / CI authenticates), then stored login.
|
|
20
|
-
const envToken = process.env.MARITIME_TOKEN;
|
|
21
|
-
const token = envToken || config.get('token');
|
|
22
|
-
if (!token) {
|
|
23
|
-
if (isJsonMode()) {
|
|
24
|
-
// Not an error per se, but exit non-zero so scripts can branch.
|
|
25
|
-
process.stdout.write(JSON.stringify({ authenticated: false }, null, 2) + '\n');
|
|
26
|
-
process.exitCode = EXIT.AUTH;
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
fail('Not logged in. Run `maritime login`, or set MARITIME_TOKEN.', {
|
|
30
|
-
code: 'not_authenticated',
|
|
31
|
-
exitCode: EXIT.AUTH,
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
const source = envToken ? 'env:MARITIME_TOKEN' : 'login';
|
|
35
|
-
// API keys (mk_…) aren't JWTs — report them as a long-lived key.
|
|
36
|
-
if (token.startsWith('mk_')) {
|
|
37
|
-
outputResult({ authenticated: true, method: 'api_key', source, expires: null }, () => {
|
|
38
|
-
console.log(chalk.bold('Method: ') + 'API key (mk_…)');
|
|
39
|
-
console.log(chalk.bold('Source: ') + source);
|
|
40
|
-
console.log(chalk.bold('Token: ') + chalk.green('valid') + chalk.dim(' (does not expire)'));
|
|
41
|
-
});
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const payload = decodeJwt(token);
|
|
45
|
-
if (!payload) {
|
|
46
|
-
fail('Could not decode token. Re-run `maritime login` or check MARITIME_TOKEN.', {
|
|
47
|
-
code: 'bad_token',
|
|
48
|
-
exitCode: EXIT.AUTH,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
const email = payload.email || null;
|
|
52
|
-
const name = payload.name || null;
|
|
53
|
-
const expMs = typeof payload.exp === 'number' ? payload.exp * 1000 : null;
|
|
54
|
-
const expired = expMs !== null && Date.now() >= expMs;
|
|
55
|
-
outputResult({
|
|
56
|
-
authenticated: !expired,
|
|
57
|
-
method: 'jwt',
|
|
58
|
-
source,
|
|
59
|
-
email,
|
|
60
|
-
name,
|
|
61
|
-
expiresAt: expMs ? new Date(expMs).toISOString() : null,
|
|
62
|
-
expired,
|
|
63
|
-
}, () => {
|
|
64
|
-
if (email)
|
|
65
|
-
console.log(chalk.bold('Email: ') + email);
|
|
66
|
-
if (name)
|
|
67
|
-
console.log(chalk.bold('Name: ') + name);
|
|
68
|
-
console.log(chalk.bold('Source: ') + source);
|
|
69
|
-
if (expMs) {
|
|
70
|
-
console.log(chalk.bold('Token: ') +
|
|
71
|
-
(expired ? chalk.red('expired') : chalk.green('valid') + chalk.dim(` (expires ${new Date(expMs).toLocaleDateString()})`)));
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
if (expired)
|
|
75
|
-
process.exitCode = EXIT.AUTH;
|
|
76
|
-
});
|
package/dist/config.d.ts
DELETED
package/dist/config.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { chmodSync } from 'node:fs';
|
|
2
|
-
import Conf from 'conf';
|
|
3
|
-
const configDir = process.env.MARITIME_CONFIG_DIR;
|
|
4
|
-
export const config = new Conf({
|
|
5
|
-
projectName: 'maritime',
|
|
6
|
-
...(configDir ? { cwd: configDir } : {}),
|
|
7
|
-
});
|
|
8
|
-
// Restrict config file permissions to owner-only (ignored on Windows)
|
|
9
|
-
try {
|
|
10
|
-
chmodSync(config.path, 0o600);
|
|
11
|
-
}
|
|
12
|
-
catch {
|
|
13
|
-
// chmodSync may fail on Windows or read-only filesystems
|
|
14
|
-
}
|
package/dist/context.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
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
|
|
9
|
-
* keys). 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
|
-
}
|
|
30
|
-
export declare function findLinkPath(start?: string): string | null;
|
|
31
|
-
export declare function getLink(): ProjectLink | null;
|
|
32
|
-
export declare function getLinkedAgentId(): string | null;
|
|
33
|
-
/** Persist the link for `dir`, and git-ignore `.maritime/` so it stays local. */
|
|
34
|
-
export declare function writeLink(link: ProjectLink, dir?: string): string;
|
|
35
|
-
export declare function findConfigPath(start?: string): string | null;
|
|
36
|
-
export declare function getConfig(): MaritimeConfig | null;
|
|
37
|
-
export declare function configExists(dir?: string): boolean;
|
|
38
|
-
export declare function writeConfig(cfg: MaritimeConfig, dir?: string): string;
|
|
39
|
-
export declare const CONFIG_FILENAME = "maritime.json";
|
package/dist/context.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
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
|
|
9
|
-
* keys). 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
|
-
import { existsSync, readFileSync, writeFileSync, mkdirSync, appendFileSync, } from 'node:fs';
|
|
16
|
-
import { dirname, join, resolve } from 'node:path';
|
|
17
|
-
const LINK_DIR = '.maritime';
|
|
18
|
-
const LINK_FILE = 'project.json';
|
|
19
|
-
const CONFIG_FILE = 'maritime.json';
|
|
20
|
-
// ---------------------------------------------------------------------------
|
|
21
|
-
// Generic upward-walk lookup
|
|
22
|
-
// ---------------------------------------------------------------------------
|
|
23
|
-
function findUp(relPath, start = process.cwd()) {
|
|
24
|
-
let dir = resolve(start);
|
|
25
|
-
// eslint-disable-next-line no-constant-condition
|
|
26
|
-
while (true) {
|
|
27
|
-
const candidate = join(dir, relPath);
|
|
28
|
-
if (existsSync(candidate))
|
|
29
|
-
return candidate;
|
|
30
|
-
const parent = dirname(dir);
|
|
31
|
-
if (parent === dir)
|
|
32
|
-
return null;
|
|
33
|
-
dir = parent;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
// ---------------------------------------------------------------------------
|
|
37
|
-
// Link (.maritime/project.json)
|
|
38
|
-
// ---------------------------------------------------------------------------
|
|
39
|
-
export function findLinkPath(start = process.cwd()) {
|
|
40
|
-
return findUp(join(LINK_DIR, LINK_FILE), start);
|
|
41
|
-
}
|
|
42
|
-
export function getLink() {
|
|
43
|
-
const p = findLinkPath();
|
|
44
|
-
if (!p)
|
|
45
|
-
return null;
|
|
46
|
-
try {
|
|
47
|
-
const parsed = JSON.parse(readFileSync(p, 'utf-8'));
|
|
48
|
-
return parsed.agentId ? parsed : null;
|
|
49
|
-
}
|
|
50
|
-
catch {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
export function getLinkedAgentId() {
|
|
55
|
-
return getLink()?.agentId ?? null;
|
|
56
|
-
}
|
|
57
|
-
/** Persist the link for `dir`, and git-ignore `.maritime/` so it stays local. */
|
|
58
|
-
export function writeLink(link, dir = process.cwd()) {
|
|
59
|
-
const linkDir = join(dir, LINK_DIR);
|
|
60
|
-
mkdirSync(linkDir, { recursive: true });
|
|
61
|
-
const p = join(linkDir, LINK_FILE);
|
|
62
|
-
writeFileSync(p, JSON.stringify(link, null, 2) + '\n');
|
|
63
|
-
ensureGitignored(LINK_DIR, dir);
|
|
64
|
-
return p;
|
|
65
|
-
}
|
|
66
|
-
// ---------------------------------------------------------------------------
|
|
67
|
-
// Config (maritime.json)
|
|
68
|
-
// ---------------------------------------------------------------------------
|
|
69
|
-
export function findConfigPath(start = process.cwd()) {
|
|
70
|
-
return findUp(CONFIG_FILE, start);
|
|
71
|
-
}
|
|
72
|
-
export function getConfig() {
|
|
73
|
-
const p = findConfigPath();
|
|
74
|
-
if (!p)
|
|
75
|
-
return null;
|
|
76
|
-
try {
|
|
77
|
-
return JSON.parse(readFileSync(p, 'utf-8'));
|
|
78
|
-
}
|
|
79
|
-
catch {
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
export function configExists(dir = process.cwd()) {
|
|
84
|
-
return existsSync(join(dir, CONFIG_FILE));
|
|
85
|
-
}
|
|
86
|
-
export function writeConfig(cfg, dir = process.cwd()) {
|
|
87
|
-
const p = join(dir, CONFIG_FILE);
|
|
88
|
-
writeFileSync(p, JSON.stringify(cfg, null, 2) + '\n');
|
|
89
|
-
return p;
|
|
90
|
-
}
|
|
91
|
-
export const CONFIG_FILENAME = CONFIG_FILE;
|
|
92
|
-
// ---------------------------------------------------------------------------
|
|
93
|
-
// Helpers
|
|
94
|
-
// ---------------------------------------------------------------------------
|
|
95
|
-
function ensureGitignored(entry, dir) {
|
|
96
|
-
const gi = join(dir, '.gitignore');
|
|
97
|
-
try {
|
|
98
|
-
const current = existsSync(gi) ? readFileSync(gi, 'utf-8') : '';
|
|
99
|
-
const present = current
|
|
100
|
-
.split('\n')
|
|
101
|
-
.some((l) => l.trim() === entry || l.trim() === `${entry}/`);
|
|
102
|
-
if (!present) {
|
|
103
|
-
const prefix = current && !current.endsWith('\n') ? '\n' : '';
|
|
104
|
-
appendFileSync(gi, `${prefix}${entry}\n`);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
catch {
|
|
108
|
-
// Best-effort; never block on .gitignore.
|
|
109
|
-
}
|
|
110
|
-
}
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { readFileSync } from 'node:fs';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { dirname, join } from 'node:path';
|
|
5
|
-
import { Command } from 'commander';
|
|
6
|
-
import chalk from 'chalk';
|
|
7
|
-
import { loginCommand } from './commands/login.js';
|
|
8
|
-
import { signupCommand } from './commands/signup.js';
|
|
9
|
-
import { logoutCommand } from './commands/logout.js';
|
|
10
|
-
import { whoamiCommand } from './commands/whoami.js';
|
|
11
|
-
import { keysCommand } from './commands/keys.js';
|
|
12
|
-
import { createCommand } from './commands/create.js';
|
|
13
|
-
import { deployCommand } from './commands/deploy.js';
|
|
14
|
-
import { listCommand } from './commands/list.js';
|
|
15
|
-
import { startCommand } from './commands/start.js';
|
|
16
|
-
import { stopCommand } from './commands/stop.js';
|
|
17
|
-
import { restartCommand } from './commands/restart.js';
|
|
18
|
-
import { deleteCommand } from './commands/delete.js';
|
|
19
|
-
import { logsCommand } from './commands/logs.js';
|
|
20
|
-
import { envCommand } from './commands/env.js';
|
|
21
|
-
import { templatesCommand } from './commands/templates.js';
|
|
22
|
-
import { statusCommand } from './commands/status.js';
|
|
23
|
-
import { openCommand } from './commands/open.js';
|
|
24
|
-
import { infoCommand } from './commands/info.js';
|
|
25
|
-
import { execCommand } from './commands/exec.js';
|
|
26
|
-
import { chatCommand } from './commands/chat.js';
|
|
27
|
-
import { messageCommand } from './commands/message.js';
|
|
28
|
-
import { historyCommand } from './commands/history.js';
|
|
29
|
-
import { triggersCommand } from './commands/triggers.js';
|
|
30
|
-
import { sleepCommand } from './commands/sleep.js';
|
|
31
|
-
import { checkForUpdates, printUpdateNotice, versionCheckSettled } from './version-check.js';
|
|
32
|
-
import { guideCommand } from './commands/guide.js';
|
|
33
|
-
import { initCommand } from './commands/init.js';
|
|
34
|
-
import { linkCommand } from './commands/link.js';
|
|
35
|
-
import { getLink } from './context.js';
|
|
36
|
-
import { ExitSignal, handleError } from './output.js';
|
|
37
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
38
|
-
const pkg = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf-8'));
|
|
39
|
-
// Daily update check (skipped in --json / non-TTY / CI; awaited in finishRun
|
|
40
|
-
// so its network work can never race process teardown).
|
|
41
|
-
checkForUpdates(pkg.version);
|
|
42
|
-
const program = new Command();
|
|
43
|
-
// Commander's default help/version/usage-error paths call process.exit()
|
|
44
|
-
// internally, which is exactly the hard-exit-with-live-handles pattern that
|
|
45
|
-
// crashes on Windows (see ExitSignal). Route them through ExitSignal too.
|
|
46
|
-
program.exitOverride((err) => {
|
|
47
|
-
throw new ExitSignal(err.exitCode ?? 0);
|
|
48
|
-
});
|
|
49
|
-
program
|
|
50
|
-
.name('maritime')
|
|
51
|
-
.description(chalk.hex('#8B5CF6')('Maritime') + ' · Deploy AI agents from your terminal')
|
|
52
|
-
.version(pkg.version)
|
|
53
|
-
.option('--json', 'Output raw JSON instead of formatted tables')
|
|
54
|
-
.option('--verbose', 'Show detailed request/response info');
|
|
55
|
-
// The lean surface: what shows in `maritime --help`. Everything a human or an
|
|
56
|
-
// AI agent needs on the happy path: authenticate, create, deploy, talk, observe.
|
|
57
|
-
const HIDDEN = { hidden: true };
|
|
58
|
-
// Auth
|
|
59
|
-
program.addCommand(loginCommand);
|
|
60
|
-
program.addCommand(logoutCommand);
|
|
61
|
-
program.addCommand(whoamiCommand);
|
|
62
|
-
program.addCommand(keysCommand);
|
|
63
|
-
// Project: link a directory to an agent (the Vercel/Railway model)
|
|
64
|
-
program.addCommand(initCommand);
|
|
65
|
-
program.addCommand(linkCommand);
|
|
66
|
-
// Agent lifecycle
|
|
67
|
-
program.addCommand(createCommand);
|
|
68
|
-
program.addCommand(deployCommand);
|
|
69
|
-
program.addCommand(listCommand);
|
|
70
|
-
program.addCommand(deleteCommand);
|
|
71
|
-
// Interaction
|
|
72
|
-
program.addCommand(chatCommand);
|
|
73
|
-
program.addCommand(messageCommand);
|
|
74
|
-
// Observability
|
|
75
|
-
program.addCommand(logsCommand);
|
|
76
|
-
program.addCommand(statusCommand);
|
|
77
|
-
program.addCommand(envCommand);
|
|
78
|
-
// Machine manifest (for agents/scripts driving the CLI)
|
|
79
|
-
program.addCommand(guideCommand);
|
|
80
|
-
// --- Hidden: still fully functional, just off the main --help to keep the
|
|
81
|
-
// surface small. Lifecycle is mostly automatic (idle-sleep + auto-wake on
|
|
82
|
-
// chat), so these are ops/debug + power-user/reseller tools, not the happy
|
|
83
|
-
// path. They still work exactly as before; `maritime <cmd> --help` shows them. ---
|
|
84
|
-
program.addCommand(signupCommand, HIDDEN);
|
|
85
|
-
program.addCommand(startCommand, HIDDEN);
|
|
86
|
-
program.addCommand(stopCommand, HIDDEN);
|
|
87
|
-
program.addCommand(restartCommand, HIDDEN);
|
|
88
|
-
program.addCommand(sleepCommand, HIDDEN);
|
|
89
|
-
program.addCommand(execCommand, HIDDEN);
|
|
90
|
-
program.addCommand(infoCommand, HIDDEN);
|
|
91
|
-
program.addCommand(historyCommand, HIDDEN);
|
|
92
|
-
program.addCommand(triggersCommand, HIDDEN);
|
|
93
|
-
program.addCommand(templatesCommand, HIDDEN);
|
|
94
|
-
program.addCommand(openCommand, HIDDEN);
|
|
95
|
-
// Make the programmatic contract discoverable from the first thing an agent
|
|
96
|
-
// runs (`maritime --help`), and point to the one-shot machine manifest.
|
|
97
|
-
program.addHelpText('after', `
|
|
98
|
-
Quickstart (a directory is an agent):
|
|
99
|
-
maritime init my-agent create + link this folder to an agent
|
|
100
|
-
maritime chat "hello" talk to the linked agent (no name needed)
|
|
101
|
-
maritime deploy push maritime.json changes (persona)
|
|
102
|
-
maritime logs · status · env · open all act on the linked agent
|
|
103
|
-
|
|
104
|
-
For scripts & AI agents:
|
|
105
|
-
Auth set MARITIME_TOKEN (mk_… key from \`maritime keys create\`)
|
|
106
|
-
Output pass --json: results on stdout, errors as JSON on stderr
|
|
107
|
-
Exit code 0 ok · 1 error · 2 auth · 3 not-found · 4 usage
|
|
108
|
-
Talk maritime chat <agent> "..." (or pipe the message via stdin)
|
|
109
|
-
Full spec maritime guide (human) · maritime guide --json (manifest)`);
|
|
110
|
-
const noArgs = process.argv.length <= 2;
|
|
111
|
-
/**
|
|
112
|
-
* Map any escaped error to an exit code WITHOUT calling process.exit().
|
|
113
|
-
* ExitSignal carries an explicit code (fail(), commander overrides); anything
|
|
114
|
-
* else goes through handleError, which prints a structured failure and
|
|
115
|
-
* throws its own ExitSignal.
|
|
116
|
-
*/
|
|
117
|
-
function settleFatal(error) {
|
|
118
|
-
if (error instanceof ExitSignal) {
|
|
119
|
-
process.exitCode = error.exitCode;
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
try {
|
|
123
|
-
handleError(error);
|
|
124
|
-
}
|
|
125
|
-
catch (signal) {
|
|
126
|
-
process.exitCode = signal instanceof ExitSignal ? signal.exitCode : 1;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* End-of-run: wait for the (bounded, at most daily) update check so no
|
|
131
|
-
* network work is in flight at teardown, print the notice, then arm an
|
|
132
|
-
* unref'd failsafe timer. Normal runs exit the moment the loop drains and
|
|
133
|
-
* never see the timer; if a stray handle (raw-mode stdin left by a prompt
|
|
134
|
-
* library, a wedged socket) keeps the loop alive, the timer force-exits
|
|
135
|
-
* after 2s. By then nothing is in flight, so even the hard exit is safe
|
|
136
|
-
* from the Windows uv_async_send-during-close assertion.
|
|
137
|
-
*/
|
|
138
|
-
async function finishRun() {
|
|
139
|
-
await versionCheckSettled();
|
|
140
|
-
printUpdateNotice(pkg.version);
|
|
141
|
-
const failsafe = setTimeout(() => process.exit(process.exitCode ?? 0), 2000);
|
|
142
|
-
failsafe.unref();
|
|
143
|
-
}
|
|
144
|
-
// In a linked directory, the bare `maritime` shows the linked agent's status
|
|
145
|
-
// (the Vercel/Railway "context-aware default"). Outside one, fall back to the
|
|
146
|
-
// interactive picker in a TTY.
|
|
147
|
-
if (noArgs && getLink()) {
|
|
148
|
-
process.argv = [process.argv[0], process.argv[1], 'status'];
|
|
149
|
-
program
|
|
150
|
-
.parseAsync()
|
|
151
|
-
.catch(settleFatal)
|
|
152
|
-
.finally(() => {
|
|
153
|
-
void finishRun();
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
else if (noArgs && process.stdin.isTTY) {
|
|
157
|
-
import('./interactive.js').then(async ({ runInteractive }) => {
|
|
158
|
-
try {
|
|
159
|
-
const args = await runInteractive();
|
|
160
|
-
// Re-parse with selected command
|
|
161
|
-
process.argv = [process.argv[0], process.argv[1], ...args];
|
|
162
|
-
await program.parseAsync();
|
|
163
|
-
}
|
|
164
|
-
catch (error) {
|
|
165
|
-
// Inquirer signals Ctrl-C with ExitPromptError: conventional 130,
|
|
166
|
-
// no error output. Everything else is a real failure.
|
|
167
|
-
if (error?.name === 'ExitPromptError') {
|
|
168
|
-
process.exitCode = 130;
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
settleFatal(error);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
finally {
|
|
175
|
-
void finishRun();
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
program
|
|
181
|
-
.parseAsync()
|
|
182
|
-
.catch(settleFatal)
|
|
183
|
-
.finally(() => {
|
|
184
|
-
void finishRun();
|
|
185
|
-
});
|
|
186
|
-
}
|
package/dist/interactive.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function runInteractive(): Promise<string[]>;
|