@audienti/cli 0.1.91 → 0.1.93

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/CHANGELOG.md CHANGED
@@ -4,6 +4,19 @@ All notable changes to the Audienti CLI are documented here.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.1.93] - 2026-10-03
8
+
9
+ ### Added
10
+
11
+ - `social-cookies show <scok_id> --json` includes `computer_usage`: separate measured Computer and browser-container bandwidth, running time, measurement coverage and timestamps. Missing usage stays unknown; the earlier browser estimate remains separate (#2578).
12
+
13
+ ## [0.1.92] - 2026-10-03
14
+
15
+ ### Added
16
+
17
+ - `audienti payment show` tells whether an account still needs the $5 card step or a signup code, and prints the pay page address. `audienti payment code <signup_code>` uses a code (#2551).
18
+ - A command against an account that has not paid or used a code now says so and points to `audienti payment show`.
19
+
7
20
  ## [0.1.91] - 2026-10-03
8
21
 
9
22
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@audienti/cli",
3
- "version": "0.1.91",
3
+ "version": "0.1.93",
4
4
  "description": "Agent-first command-line client for Audienti.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/api-client.js CHANGED
@@ -437,6 +437,17 @@ export class AudientiClient {
437
437
  });
438
438
  }
439
439
 
440
+ accountPayment(accountId) {
441
+ return this.requestJson(accountPath(accountId, ["admission"]));
442
+ }
443
+
444
+ redeemSignupCode(accountId, code) {
445
+ return this.requestJson(accountPath(accountId, ["admission"]), {
446
+ method: "POST",
447
+ body: { code }
448
+ });
449
+ }
450
+
440
451
  brandProfile(accountId) {
441
452
  return this.requestJson(accountPath(accountId, ["brand_profile"]));
442
453
  }
@@ -1381,6 +1392,13 @@ function errorMessage(status, body) {
1381
1392
  return "Authentication failed. Run `audienti auth token <token>` with a valid API token.";
1382
1393
  }
1383
1394
 
1395
+ if (status === 402) {
1396
+ if (body?.code === "payment_needed") {
1397
+ return "This account has not paid or used a signup code yet. Run `audienti payment show`.";
1398
+ }
1399
+ return body?.error || "Audienti stopped this account for a payment reason.";
1400
+ }
1401
+
1384
1402
  if (status === 403) {
1385
1403
  return "The API token is not allowed to access that Audienti resource.";
1386
1404
  }
@@ -1399,6 +1417,10 @@ function errorMessage(status, body) {
1399
1417
  return details ? `Audienti rejected the request: ${details}` : "Audienti rejected the request.";
1400
1418
  }
1401
1419
 
1420
+ if (status === 429 && body?.error) {
1421
+ return body.error;
1422
+ }
1423
+
1402
1424
  return `Audienti API request failed with HTTP ${status}.`;
1403
1425
  }
1404
1426
 
package/src/cli.js CHANGED
@@ -136,6 +136,8 @@ const WEBHOOKS_ROTATE_USAGE = "Usage: audienti webhooks rotate <endpoint_id> [--
136
136
  const WEBHOOKS_REMOVE_USAGE = "Usage: audienti webhooks remove <endpoint_id> [--json] [--account <acct_id>]";
137
137
  const REPLY_ALERTS_SHOW_USAGE = "Usage: audienti reply-alerts show [--json]";
138
138
  const REPLY_ALERTS_UPDATE_USAGE = "Usage: audienti reply-alerts update [--phone <number|none>] [--sms <true|false>] [--slack <true|false>] [--json]";
139
+ const PAYMENT_SHOW_USAGE = "Usage: audienti payment show [--json] [--account <acct_id>]";
140
+ const PAYMENT_CODE_USAGE = "Usage: audienti payment code <signup_code> [--json] [--account <acct_id>]";
139
141
  const BRAND_PROFILE_SHOW_USAGE = "Usage: audienti brand-profile show [--json] [--account <acct_id>]";
140
142
  const BRAND_PROFILE_UPDATE_USAGE = "Usage: audienti brand-profile update [--voice <text>] [--style <text>] [--do-not-use <text>] [--json] [--account <acct_id>]";
141
143
  const ACCOUNTS_SHOW_USAGE = "Usage: audienti accounts show [<acct_id>] [--json] [--account <acct_id>]";
@@ -395,6 +397,7 @@ async function dispatch(argv, context) {
395
397
  if (normalizedResource === "webhooks") return webhooksCommand(action, rest, context, { accountOverride });
396
398
  if (normalizedResource === "reply-alerts") return replyAlertsCommand(action, rest, context);
397
399
  if (normalizedResource === "brand-profile") return brandProfileCommand(action, rest, context, { accountOverride });
400
+ if (normalizedResource === "payment") return paymentCommand(action, rest, context, { accountOverride });
398
401
  if (normalizedResource === "tags" && action === "list") return tagsList(rest, context, { accountOverride });
399
402
  if (normalizedResource === "tags" && action === "show") return tagsShow(rest, context, { accountOverride });
400
403
  if (normalizedResource === "tasks" && ["list", "manage"].includes(action)) return tasksList(rest, context, { accountOverride });
@@ -2636,6 +2639,57 @@ function writeReplyAlerts(alerts, context) {
2636
2639
  writeLine(context.stdout, `Slack: ${alerts?.slack_enabled ? "on" : "off"} | Connected: ${alerts?.slack_connected ? "yes" : "no"} | Channel: ${display(alerts?.slack_channel, "-")}`);
2637
2640
  }
2638
2641
 
2642
+ async function paymentCommand(action, args, context, { accountOverride } = {}) {
2643
+ if (action === "show") {
2644
+ const { values, positionals } = parseCommandArgs(args, jsonOptions());
2645
+ if (positionals.length > 0) throw new CommandError(PAYMENT_SHOW_USAGE);
2646
+
2647
+ const { client, accountId } = await requireAccountContext(context, { accountOverride });
2648
+ const payload = await client.accountPayment(accountId);
2649
+ if (values.json) return writeJson(context.stdout, payload);
2650
+
2651
+ writeAccountPayment(payload, context);
2652
+ return;
2653
+ }
2654
+
2655
+ if (action === "code") {
2656
+ const { values, positionals } = parseCommandArgs(args, jsonOptions());
2657
+ if (positionals.length !== 1) throw new CommandError(PAYMENT_CODE_USAGE);
2658
+
2659
+ const { client, accountId } = await requireAccountContext(context, { accountOverride });
2660
+ const payload = await client.redeemSignupCode(accountId, positionals[0]);
2661
+ if (values.json) return writeJson(context.stdout, payload);
2662
+
2663
+ writeLine(context.stdout, "Code accepted. No card needed.");
2664
+ writeAccountPayment(payload, context);
2665
+ return;
2666
+ }
2667
+
2668
+ throw new CommandError(`Unknown payment command "${display(action, "")}". Run \`audienti payment --help\`.`);
2669
+ }
2670
+
2671
+ function writeAccountPayment(payment, context) {
2672
+ const state = payment?.state;
2673
+ if (state === "payment_needed") {
2674
+ const price = payment?.price?.amount ? `$${payment.price.amount / 100}` : "the starting charge";
2675
+ const credits = payment?.card_usage?.unit === "usd_cents" && payment.card_usage.amount ? ` The card charge gets you $${payment.card_usage.amount / 100} of credits.` : "";
2676
+ writeLine(context.stdout, `Payment needed: pay ${price} by card or use a signup code.${credits}`);
2677
+ writeLine(context.stdout, `Card: open ${display(payment?.payment_url, "-")}`);
2678
+ writeLine(context.stdout, "Code: audienti payment code <signup_code>");
2679
+ return;
2680
+ }
2681
+
2682
+ if (state === "payment_stopped") {
2683
+ writeLine(context.stdout, "Stopped: the payment for this account was returned. Nothing runs.");
2684
+ return;
2685
+ }
2686
+
2687
+ writeLine(context.stdout, `State: ${display(state, "-")}`);
2688
+ writeLine(context.stdout, `Let in by: ${display(payment?.admitted_via, "-")}`);
2689
+ const usage = payment?.starting_usage;
2690
+ if (usage) writeLine(context.stdout, `Starting usage: ${usage.amount} ${usage.unit}`);
2691
+ }
2692
+
2639
2693
  async function brandProfileCommand(action, args, context, { accountOverride } = {}) {
2640
2694
  if (action === "show") {
2641
2695
  const { values, positionals } = parseCommandArgs(args, jsonOptions());
@@ -10142,6 +10196,8 @@ const HELP_TOPICS = new Map([
10142
10196
  " audienti hubspot show",
10143
10197
  " audienti webhooks list",
10144
10198
  " audienti brand-profile show",
10199
+ " audienti payment show",
10200
+ " audienti payment code <signup_code>",
10145
10201
  " audienti reply-alerts show",
10146
10202
  "",
10147
10203
  " Writer",
@@ -11348,6 +11404,42 @@ const HELP_TOPICS = new Map([
11348
11404
  " PATCH /api/v1/me/reply_alerts.json"
11349
11405
  ].join("\n")],
11350
11406
 
11407
+ ["payment", [
11408
+ "Usage:",
11409
+ ` ${PAYMENT_SHOW_USAGE.slice("Usage: ".length)}`,
11410
+ ` ${PAYMENT_CODE_USAGE.slice("Usage: ".length)}`,
11411
+ "",
11412
+ "Status: implemented",
11413
+ "",
11414
+ "Purpose:",
11415
+ " A new account runs after one card charge or a signup code. Show the state, or use a code.",
11416
+ " The card step needs a browser; `payment show` prints the address. Account admins only for `code`.",
11417
+ "",
11418
+ "API:",
11419
+ " GET /api/v1/accounts/:account_id/admission.json",
11420
+ " POST /api/v1/accounts/:account_id/admission.json"
11421
+ ].join("\n")],
11422
+
11423
+ ["payment show", [
11424
+ "Usage:",
11425
+ ` ${PAYMENT_SHOW_USAGE.slice("Usage: ".length)}`,
11426
+ "",
11427
+ "Status: implemented",
11428
+ "",
11429
+ "API:",
11430
+ " GET /api/v1/accounts/:account_id/admission.json"
11431
+ ].join("\n")],
11432
+
11433
+ ["payment code", [
11434
+ "Usage:",
11435
+ ` ${PAYMENT_CODE_USAGE.slice("Usage: ".length)}`,
11436
+ "",
11437
+ "Status: implemented",
11438
+ "",
11439
+ "API:",
11440
+ " POST /api/v1/accounts/:account_id/admission.json"
11441
+ ].join("\n")],
11442
+
11351
11443
  ["brand-profile", [
11352
11444
  "Usage:",
11353
11445
  ` ${BRAND_PROFILE_SHOW_USAGE.slice("Usage: ".length)}`,