vessels 0.2.1 → 0.2.2

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 (2) hide show
  1. package/dist/index.js +25 -13
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -37,7 +37,10 @@ async function api(path, options = {}) {
37
37
  }
38
38
  });
39
39
  const data = await res.json();
40
- if (!res.ok) throw new Error(data.error ?? `HTTP ${res.status}`);
40
+ if (!res.ok) {
41
+ const hint = res.status === 401 ? ` Run: vessels login --email <email>` : "";
42
+ throw new Error((data.error ?? `HTTP ${res.status}`) + hint);
43
+ }
41
44
  return data;
42
45
  }
43
46
  function prompt(question) {
@@ -108,11 +111,12 @@ async function cmdKeysList() {
108
111
  console.log(`${k.prefix}\u2026 ${used}${name} [${k.id}]`);
109
112
  }
110
113
  }
111
- async function cmdKeysCreate(name) {
112
- if (!name) name = await prompt("Key name (optional): ");
114
+ async function cmdKeysCreate(args) {
115
+ const flags = parseFlags(args);
116
+ const name = flags.name || (args[0] && !args[0].startsWith("--") ? args[0] : null) || null;
113
117
  const data = await api("/api/v1/keys", {
114
118
  method: "POST",
115
- body: JSON.stringify({ name: name || null })
119
+ body: JSON.stringify({ name })
116
120
  });
117
121
  console.log(`
118
122
  API key created. Copy it now \u2014 it won't be shown again.
@@ -120,6 +124,7 @@ API key created. Copy it now \u2014 it won't be shown again.
120
124
  console.log(` ${data.key}
121
125
  `);
122
126
  if (data.name) console.log(`Name: ${data.name}`);
127
+ console.log(`VESSELS_API_KEY=${data.key}`);
123
128
  }
124
129
  async function cmdKeysRevoke(id) {
125
130
  await api(`/api/v1/keys/${id}`, { method: "DELETE" });
@@ -180,17 +185,18 @@ async function cmdWebhooksToggle(id, active) {
180
185
  console.log(`Webhook ${data.endpoint.id} ${data.endpoint.active ? "enabled" : "disabled"}.`);
181
186
  }
182
187
  async function cmdPush(args) {
183
- const flags = {};
184
- for (let i = 0; i < args.length; i++) {
185
- if (args[i].startsWith("--")) flags[args[i].slice(2)] = args[i + 1] ?? "";
186
- }
188
+ const flags = parseFlags(args);
187
189
  const apiKey = flags.key ?? process.env.VESSELS_API_KEY;
188
190
  if (!apiKey) {
189
191
  console.error("Provide an API key via --key or VESSELS_API_KEY env var");
190
192
  process.exit(1);
191
193
  }
192
- const message = flags.message ?? await prompt("Message: ");
193
- const vessel = flags.vessel ?? await prompt("Vessel ID (or press enter for default): ");
194
+ if (!flags.message) {
195
+ console.error("Usage: vessels push --vessel <id> --message <text> --key <api_key>");
196
+ process.exit(1);
197
+ }
198
+ const message = flags.message;
199
+ const vessel = flags.vessel ?? void 0;
194
200
  const res = await fetch(`${BASE_URL}/api/v1/push`, {
195
201
  method: "POST",
196
202
  headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}` },
@@ -215,7 +221,7 @@ Commands:
215
221
  vessels whoami
216
222
 
217
223
  vessels keys list
218
- vessels keys create [name]
224
+ vessels keys create [--name <name>]
219
225
  vessels keys revoke <id>
220
226
 
221
227
  vessels webhooks list
@@ -231,7 +237,7 @@ Agent/Claude Code setup (fully non-interactive):
231
237
  vessels login --email me@example.com
232
238
  # tell your agent the OTP from the email
233
239
  vessels login --email me@example.com --otp 847293
234
- vessels keys create my-project
240
+ vessels keys create --name my-project
235
241
  vessels webhooks create --url https://myapp.com/hooks/vessels
236
242
  `;
237
243
  async function main() {
@@ -244,7 +250,7 @@ async function main() {
244
250
  if (cmd === "whoami") return cmdWhoami();
245
251
  if (cmd === "keys") {
246
252
  if (sub === "list" || !sub) return cmdKeysList();
247
- if (sub === "create") return cmdKeysCreate(rest[0]);
253
+ if (sub === "create") return cmdKeysCreate(rest);
248
254
  if (sub === "revoke") {
249
255
  if (!rest[0]) {
250
256
  console.error("Usage: vessels keys revoke <id>");
@@ -252,6 +258,9 @@ async function main() {
252
258
  }
253
259
  return cmdKeysRevoke(rest[0]);
254
260
  }
261
+ console.error(`Unknown subcommand: keys ${sub}
262
+ Run: vessels help`);
263
+ process.exit(1);
255
264
  }
256
265
  if (cmd === "webhooks") {
257
266
  if (sub === "list" || !sub) return cmdWebhooksList();
@@ -277,6 +286,9 @@ async function main() {
277
286
  }
278
287
  return cmdWebhooksToggle(rest[0], false);
279
288
  }
289
+ console.error(`Unknown subcommand: webhooks ${sub}
290
+ Run: vessels help`);
291
+ process.exit(1);
280
292
  }
281
293
  if (cmd === "push") return cmdPush([sub, ...rest].filter(Boolean));
282
294
  console.error(`Unknown command: ${cmd}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vessels",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Vessels CLI — manage your agent communication layer from the terminal",
5
5
  "type": "module",
6
6
  "bin": {