@erdoai/cli 0.197.0 → 0.198.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 (2) hide show
  1. package/dist/index.js +80 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1331,6 +1331,33 @@ var ErdoClient = class {
1331
1331
  `/v1/activity/history${qs ? `?${qs}` : ""}`
1332
1332
  );
1333
1333
  }
1334
+ // --- outbound webhook subscriptions ---
1335
+ listWebhooks() {
1336
+ return this.request("GET", "/v1/webhooks");
1337
+ }
1338
+ createWebhook(input) {
1339
+ return this.request("POST", "/v1/webhooks", input);
1340
+ }
1341
+ deleteWebhook(id) {
1342
+ return this.request("DELETE", `/v1/webhooks/${encodeURIComponent(id)}`);
1343
+ }
1344
+ listWebhookDeliveries(id, params) {
1345
+ const q = new URLSearchParams();
1346
+ if (params?.status) q.set("status", params.status);
1347
+ if (params?.limit !== void 0) q.set("limit", String(params.limit));
1348
+ if (params?.offset !== void 0) q.set("offset", String(params.offset));
1349
+ const qs = q.toString();
1350
+ return this.request(
1351
+ "GET",
1352
+ `/v1/webhooks/${encodeURIComponent(id)}/deliveries${qs ? `?${qs}` : ""}`
1353
+ );
1354
+ }
1355
+ retryWebhookDelivery(id, deliveryId) {
1356
+ return this.request(
1357
+ "POST",
1358
+ `/v1/webhooks/${encodeURIComponent(id)}/deliveries/${encodeURIComponent(deliveryId)}/retry`
1359
+ );
1360
+ }
1334
1361
  // --- knowledge review queue ---
1335
1362
  listReviewItems(params) {
1336
1363
  const q = new URLSearchParams();
@@ -6372,6 +6399,59 @@ ${events.length} event${events.length === 1 ? "" : "s"}${cursor ? `; ${cursor}`
6372
6399
  }
6373
6400
  }
6374
6401
  );
6402
+ var webhooksCmd = program.command("webhooks").description("Manage outbound webhook subscriptions and inspect deliveries");
6403
+ webhooksCmd.command("list").description("List this org's webhook subscriptions").action(async () => {
6404
+ try {
6405
+ const result = await new ErdoClient().listWebhooks();
6406
+ print(result);
6407
+ } catch (e) {
6408
+ fail(e);
6409
+ }
6410
+ });
6411
+ webhooksCmd.command("create").description("Create a webhook subscription; the signing secret is shown once").requiredOption("--url <https-url>", "public HTTPS receiver URL").requiredOption("--verbs <list>", "comma-separated exact activity ledger verbs").option("--include-managed", "also receive events from currently managed orgs").action(async (opts) => {
6412
+ try {
6413
+ const verbs = opts.verbs.split(",").map((verb) => verb.trim());
6414
+ if (verbs.some((verb) => !verb)) throw new Error("--verbs must contain one or more non-empty verbs");
6415
+ const result = await new ErdoClient().createWebhook({
6416
+ url: opts.url,
6417
+ verbs,
6418
+ include_managed: Boolean(opts.includeManaged)
6419
+ });
6420
+ print(result);
6421
+ } catch (e) {
6422
+ fail(e);
6423
+ }
6424
+ });
6425
+ webhooksCmd.command("delete <id>").description("Deactivate a webhook subscription while retaining delivery history").action(async (id) => {
6426
+ try {
6427
+ print(await new ErdoClient().deleteWebhook(id));
6428
+ } catch (e) {
6429
+ fail(e);
6430
+ }
6431
+ });
6432
+ webhooksCmd.command("deliveries <id>").description("List deliveries for a webhook subscription").option("--status <status>", "pending | delivered | failed").option("-n, --limit <n>", "max rows", (v) => Number(v)).option("--offset <n>", "pagination offset", (v) => Number(v)).action(async (id, opts) => {
6433
+ try {
6434
+ if (opts.status && !["pending", "delivered", "failed"].includes(opts.status)) {
6435
+ throw new Error("--status must be pending, delivered, or failed");
6436
+ }
6437
+ for (const [name, value] of [["limit", opts.limit], ["offset", opts.offset]]) {
6438
+ if (value !== void 0 && (!Number.isSafeInteger(value) || value < (name === "limit" ? 1 : 0))) {
6439
+ throw new Error(`--${name} must be a ${name === "limit" ? "positive" : "non-negative"} integer`);
6440
+ }
6441
+ }
6442
+ const result = await new ErdoClient().listWebhookDeliveries(id, opts);
6443
+ print(result);
6444
+ } catch (e) {
6445
+ fail(e);
6446
+ }
6447
+ });
6448
+ webhooksCmd.command("retry <id> <delivery-id>").description("Retry a failed webhook delivery").action(async (id, deliveryId) => {
6449
+ try {
6450
+ print(await new ErdoClient().retryWebhookDelivery(id, deliveryId));
6451
+ } catch (e) {
6452
+ fail(e);
6453
+ }
6454
+ });
6375
6455
  var reviewsCmd = program.command("reviews").description(
6376
6456
  "The Knowledge Review queue \u2014 knowledge patches the critic proposes, investigations, and deduplicated failure signals awaiting a human decision"
6377
6457
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erdoai/cli",
3
- "version": "0.197.0",
3
+ "version": "0.198.0",
4
4
  "description": "Erdo CLI \u2014 drive datasets, pages, and evals from the terminal or CI",
5
5
  "type": "module",
6
6
  "bin": {