vessels 0.2.0 → 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.
- package/dist/index.js +27 -13
- 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)
|
|
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(
|
|
112
|
-
|
|
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
|
|
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" });
|
|
@@ -147,6 +152,8 @@ async function cmdWebhooksCreate(args) {
|
|
|
147
152
|
let events;
|
|
148
153
|
if (flags.events) {
|
|
149
154
|
events = flags.events.split(/[,\s]+/).filter(Boolean);
|
|
155
|
+
} else if (flags.url) {
|
|
156
|
+
events = ["interaction.response", "message.user"];
|
|
150
157
|
} else {
|
|
151
158
|
console.log("Events (comma-separated, or press enter for both): interaction.response, message.user");
|
|
152
159
|
const eventsInput = await prompt("Events: ");
|
|
@@ -178,17 +185,18 @@ async function cmdWebhooksToggle(id, active) {
|
|
|
178
185
|
console.log(`Webhook ${data.endpoint.id} ${data.endpoint.active ? "enabled" : "disabled"}.`);
|
|
179
186
|
}
|
|
180
187
|
async function cmdPush(args) {
|
|
181
|
-
const flags =
|
|
182
|
-
for (let i = 0; i < args.length; i++) {
|
|
183
|
-
if (args[i].startsWith("--")) flags[args[i].slice(2)] = args[i + 1] ?? "";
|
|
184
|
-
}
|
|
188
|
+
const flags = parseFlags(args);
|
|
185
189
|
const apiKey = flags.key ?? process.env.VESSELS_API_KEY;
|
|
186
190
|
if (!apiKey) {
|
|
187
191
|
console.error("Provide an API key via --key or VESSELS_API_KEY env var");
|
|
188
192
|
process.exit(1);
|
|
189
193
|
}
|
|
190
|
-
|
|
191
|
-
|
|
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;
|
|
192
200
|
const res = await fetch(`${BASE_URL}/api/v1/push`, {
|
|
193
201
|
method: "POST",
|
|
194
202
|
headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}` },
|
|
@@ -213,7 +221,7 @@ Commands:
|
|
|
213
221
|
vessels whoami
|
|
214
222
|
|
|
215
223
|
vessels keys list
|
|
216
|
-
vessels keys create [name]
|
|
224
|
+
vessels keys create [--name <name>]
|
|
217
225
|
vessels keys revoke <id>
|
|
218
226
|
|
|
219
227
|
vessels webhooks list
|
|
@@ -229,7 +237,7 @@ Agent/Claude Code setup (fully non-interactive):
|
|
|
229
237
|
vessels login --email me@example.com
|
|
230
238
|
# tell your agent the OTP from the email
|
|
231
239
|
vessels login --email me@example.com --otp 847293
|
|
232
|
-
vessels keys create my-project
|
|
240
|
+
vessels keys create --name my-project
|
|
233
241
|
vessels webhooks create --url https://myapp.com/hooks/vessels
|
|
234
242
|
`;
|
|
235
243
|
async function main() {
|
|
@@ -242,7 +250,7 @@ async function main() {
|
|
|
242
250
|
if (cmd === "whoami") return cmdWhoami();
|
|
243
251
|
if (cmd === "keys") {
|
|
244
252
|
if (sub === "list" || !sub) return cmdKeysList();
|
|
245
|
-
if (sub === "create") return cmdKeysCreate(rest
|
|
253
|
+
if (sub === "create") return cmdKeysCreate(rest);
|
|
246
254
|
if (sub === "revoke") {
|
|
247
255
|
if (!rest[0]) {
|
|
248
256
|
console.error("Usage: vessels keys revoke <id>");
|
|
@@ -250,6 +258,9 @@ async function main() {
|
|
|
250
258
|
}
|
|
251
259
|
return cmdKeysRevoke(rest[0]);
|
|
252
260
|
}
|
|
261
|
+
console.error(`Unknown subcommand: keys ${sub}
|
|
262
|
+
Run: vessels help`);
|
|
263
|
+
process.exit(1);
|
|
253
264
|
}
|
|
254
265
|
if (cmd === "webhooks") {
|
|
255
266
|
if (sub === "list" || !sub) return cmdWebhooksList();
|
|
@@ -275,6 +286,9 @@ async function main() {
|
|
|
275
286
|
}
|
|
276
287
|
return cmdWebhooksToggle(rest[0], false);
|
|
277
288
|
}
|
|
289
|
+
console.error(`Unknown subcommand: webhooks ${sub}
|
|
290
|
+
Run: vessels help`);
|
|
291
|
+
process.exit(1);
|
|
278
292
|
}
|
|
279
293
|
if (cmd === "push") return cmdPush([sub, ...rest].filter(Boolean));
|
|
280
294
|
console.error(`Unknown command: ${cmd}
|