maritime-cli 1.5.1 → 1.6.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.
@@ -164,17 +164,22 @@ envCommand
164
164
  .option('-r, --reload', 'Hot-reload env into the running container afterward')
165
165
  .action(async (agentArg, file, opts) => {
166
166
  try {
167
- // In a linked dir the single positional is the file (agent = linked);
168
- // otherwise it's `<agent> [file]`.
167
+ // Two positionals always mean `<agent> <file>` — even in a linked dir,
168
+ // an explicit agent must win. The single-positional shorthand treats
169
+ // the arg as the file (agent = linked).
169
170
  let target;
170
171
  let srcFile;
171
- if (getLinkedAgentId()) {
172
+ if (file !== undefined) {
173
+ target = agentArg;
174
+ srcFile = file;
175
+ }
176
+ else if (getLinkedAgentId()) {
172
177
  target = undefined;
173
178
  srcFile = agentArg;
174
179
  }
175
180
  else {
176
181
  target = agentArg;
177
- srcFile = file;
182
+ srcFile = undefined;
178
183
  }
179
184
  let text;
180
185
  if (!srcFile || srcFile === '-') {
@@ -238,17 +243,22 @@ envCommand
238
243
  .option('-r, --reload', 'Hot-reload env into the running container afterward')
239
244
  .action(async (agentArg, keyArg, opts) => {
240
245
  try {
241
- // In a linked dir the single positional is the key (agent = linked);
242
- // otherwise it's `<agent> <key>`.
246
+ // Two positionals always mean `<agent> <key>` — even in a linked dir,
247
+ // an explicit agent must win. Only the single-positional shorthand
248
+ // treats the arg as the key (agent = linked).
243
249
  let target;
244
250
  let key;
245
- if (getLinkedAgentId()) {
251
+ if (keyArg !== undefined) {
252
+ target = agentArg;
253
+ key = keyArg;
254
+ }
255
+ else if (getLinkedAgentId()) {
246
256
  target = undefined;
247
257
  key = agentArg;
248
258
  }
249
259
  else {
250
260
  target = agentArg;
251
- key = keyArg;
261
+ key = undefined;
252
262
  }
253
263
  if (!key) {
254
264
  fail('No env key given to remove.', { code: 'usage', exitCode: EXIT.USAGE });
@@ -296,16 +306,22 @@ envCommand
296
306
  .option('-f, --force', 'Overwrite the file if it already exists')
297
307
  .action(async (agentArg, fileArg, opts) => {
298
308
  try {
299
- // In a linked dir the single positional is the output file (agent = linked).
309
+ // Two positionals always mean `<agent> <file>` — even in a linked dir,
310
+ // an explicit agent must win. The single-positional shorthand treats
311
+ // the arg as the output file (agent = linked).
300
312
  let target;
301
313
  let outFile;
302
- if (getLinkedAgentId()) {
314
+ if (fileArg !== undefined) {
315
+ target = agentArg;
316
+ outFile = fileArg;
317
+ }
318
+ else if (getLinkedAgentId()) {
303
319
  target = undefined;
304
320
  outFile = agentArg || '.env';
305
321
  }
306
322
  else {
307
323
  target = agentArg;
308
- outFile = fileArg || '.env';
324
+ outFile = '.env';
309
325
  }
310
326
  const agent = await resolveAgent(target);
311
327
  const vars = await authGet(`/api/agents/${agent.id}/env`);
@@ -9,7 +9,7 @@ keysCommand
9
9
  .command('create')
10
10
  .description('Mint a new API key. Shown once — save it as MARITIME_TOKEN.')
11
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')
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
13
  .action(async (opts) => {
14
14
  try {
15
15
  const scopes = String(opts.scopes)
@@ -0,0 +1,8 @@
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;
@@ -0,0 +1,75 @@
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
+ });
@@ -26,6 +26,11 @@ export const templatesCommand = new Command('templates')
26
26
  chalk.bold(t.name.padEnd(20)) +
27
27
  fw.padEnd(20) +
28
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
+ }
29
34
  }
30
35
  console.log();
31
36
  }
package/dist/index.js CHANGED
@@ -24,6 +24,7 @@ import { openCommand } from './commands/open.js';
24
24
  import { infoCommand } from './commands/info.js';
25
25
  import { execCommand } from './commands/exec.js';
26
26
  import { chatCommand } from './commands/chat.js';
27
+ import { messageCommand } from './commands/message.js';
27
28
  import { historyCommand } from './commands/history.js';
28
29
  import { triggersCommand } from './commands/triggers.js';
29
30
  import { blueprintCommand } from './commands/blueprint.js';
@@ -64,6 +65,7 @@ program.addCommand(listCommand);
64
65
  program.addCommand(deleteCommand);
65
66
  // Interaction
66
67
  program.addCommand(chatCommand);
68
+ program.addCommand(messageCommand);
67
69
  // Observability
68
70
  program.addCommand(logsCommand);
69
71
  program.addCommand(statusCommand);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maritime-cli",
3
- "version": "1.5.1",
3
+ "version": "1.6.0",
4
4
  "description": "Maritime CLI - Deploy and talk to AI agents from your terminal",
5
5
  "type": "module",
6
6
  "license": "MIT",