argorant 0.5.1 → 0.7.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 (3) hide show
  1. package/README.md +30 -33
  2. package/bin/argorant.js +432 -162
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -122,43 +122,40 @@ needs a paid plan" apart from "something broke".
122
122
  command always wins over the stored one, `ARGORANT_API_BASE` overrides both,
123
123
  and `argorant logout` removes the file.
124
124
 
125
- ## Campaigns operator keys only
125
+ ## Campaigns and inboxes
126
126
 
127
- `argorant campaigns ...` drives live outbound campaigns end to end from the
128
- terminal (create → copy → inboxes → leads → start), in about two minutes.
129
- This group talks to a different, internal surface than everything above and
130
- only works for an `ag_live_` key that belongs to an **owner/admin** account
131
- and carries the `argorant:operator` scope — a normal customer key gets a
132
- 401/403, same as a browser session would without outbound access.
127
+ Email outreach from the terminal, with any Argorant API key. Nothing sends until you launch.
133
128
 
134
- ```sh
135
- npx argorant campaigns create --name "Q3 CFO outreach" --brand argorant \
136
- --timezone America/New_York --window 08:00-17:00 --skip-weekends
137
- npx argorant campaigns steps set "Q3 CFO outreach" --step 1 \
138
- --subject "Quick question" --body-file ./copy/step1.txt --approve
139
- npx argorant campaigns inboxes attach "Q3 CFO outreach" --count 5 --pool argorant
140
- npx argorant campaigns leads add "Q3 CFO outreach" --query "CFO" --industry fintech --country Germany
141
- npx argorant campaigns start "Q3 CFO outreach"
129
+ ```
130
+ argorant campaigns list
131
+ argorant campaigns create --name "Q4 CFO outreach" [--daily-limit 40] [--timezone Europe/Berlin] [--gap 60-120] [--start 2026-10-01]
132
+ argorant campaigns emails set <campaign> --step 1 --subject "Quick question, {{first_name}}" --body-file ./step1.txt
133
+ argorant campaigns emails set <campaign> --step 2 --body "Bumping this." --delay-days 3
134
+ argorant campaigns emails set <campaign> --file emails.json # whole sequence at once
135
+ argorant campaigns leads add <campaign> --list <list-id> # a saved list
136
+ argorant campaigns leads add <campaign> --csv leads.csv # email, first_name, last_name, company, title
137
+ argorant campaigns senders set <campaign> --emails a@x.com,b@y.com # or --all
138
+ argorant campaigns launch <campaign> [-y] # asks for confirmation
139
+ argorant campaigns update <campaign> --daily-limit 40 --window 08:00-17:00 --timezone Europe/Berlin --timezone-mode lead --gap 60-120 --tags q4
140
+ argorant campaigns leads list <campaign> [--status replied] | leads remove <campaign> <email>
141
+ argorant campaigns senders remove <campaign> <mailbox>
142
+ argorant campaigns replies <campaign>
143
+ argorant campaigns pause | stop | status | delete <campaign>
144
+
145
+ argorant inbox list [--folder replies|interested|not_interested|out_of_office|bounces|unsubscribes] [--campaign <c>] [--q text]
146
+ argorant inbox read <thread-id>
147
+ argorant inbox reply <thread-id> --body "..." [-y]
148
+ argorant inbox classify <thread-id> meeting_booked
149
+
150
+ argorant inboxes list
151
+ argorant inboxes connect-google --admin admin@yourdomain.com # lists mailboxes (or the delegation setup to do first)
152
+ argorant inboxes connect-google --admin admin@yourdomain.com --emails a@x.com,b@x.com # or --all
142
153
  ```
143
154
 
144
- | Command | What it does |
145
- | --- | --- |
146
- | `campaigns list [--brand <key>]` | Name, status, contacted, replies, reply rate |
147
- | `campaigns create --name "<n>" [--brand] [--timezone] [--window HH:MM-HH:MM] [--skip-weekends]` | New native campaign |
148
- | `campaigns steps set <campaign> --step <n> --subject "..." (--body-file <path> \| --body <text\|->) [--approve]` | Upsert one sequence step's copy. The CLI never writes copy for you. |
149
- | `campaigns inboxes attach <campaign> --count <n> [--pool <brand>]` | Attach N healthy, unattached sending inboxes (explicit fleet change; prints exactly which ones) |
150
- | `campaigns leads add <campaign> --csv <file>` | Import leads from a CSV (email + optional first_name/last_name/company/title/...) |
151
- | `campaigns leads add <campaign> --query "..." [filters]` | Enroll leads straight from a server-side search (same filters as above) |
152
- | `campaigns start <campaign>` / `pause <campaign>` | Start (auto-approves draft copy + campaign, background-schedules sends) / pause |
153
- | `campaigns status <campaign>` | Setup completeness (steps/inboxes/leads) + launch blockers |
154
-
155
- `<campaign>` accepts a raw id or an unambiguous case-insensitive name prefix;
156
- an ambiguous prefix lists every match instead of guessing.
157
-
158
- **Known gap:** `campaigns leads add --query` has no server-side row cap yet —
159
- `-n/--limit` is accepted for a familiar CLI surface but not forwarded/honored
160
- (it enrolls every valid match up to the platform's own cap). The CLI warns
161
- when you pass it. See `cli/GODMODE-PLAN.md`.
155
+ `<campaign>` accepts an id or an unambiguous case-insensitive name prefix. Every address is verified before
156
+ it is enrolled; only valid ones send unless `--include-catch-all`. Variables: `{{first_name}}`, `{{last_name}}`,
157
+ `{{company}}`, `{{title}}`; spintax `{a|b}` varies phrasing. `--query "..."` filter enrollment stays available
158
+ for operator keys.
162
159
 
163
160
  ## Releasing
164
161
 
package/bin/argorant.js CHANGED
@@ -26,6 +26,7 @@ const dim = (s) => c("2", s);
26
26
  const green = (s) => c("32", s);
27
27
  const red = (s) => c("31", s);
28
28
  const cyan = (s) => c("36", s);
29
+ const yellow = (s) => c("33", s);
29
30
 
30
31
  function die(msg, code = 1) {
31
32
  process.stderr.write(red("error: ") + msg + "\n");
@@ -351,6 +352,14 @@ async function cmdLogin(args) {
351
352
  if (!key) die("no key provided.");
352
353
  if (!/^ag_(live|test)_/.test(key)) process.stderr.write(dim("note: keys normally start with ag_live_ — continuing anyway.\n"));
353
354
  const res = await request("GET", args.base, "/api/mcp/account", { key });
355
+ if (res.status === 428 && res.json?.detail?.error === "access_key_activation_required") {
356
+ const url = res.json.detail.claim_url;
357
+ process.stdout.write(cyan("Your access key is reserved. Confirm your email to activate it:\n"));
358
+ process.stdout.write(`${url}\n\n`);
359
+ process.stdout.write(dim("After confirmation, run the same login command again.\n"));
360
+ process.exitCode = 3;
361
+ return;
362
+ }
354
363
  if (res.status === 401) die("that key was rejected (401). Double-check you copied the whole ag_live_ key.", 2);
355
364
  const acct = need(res, "login");
356
365
  saveConfig({ apiKey: key, base: args.baseExplicit && args.base !== DEFAULT_BASE ? args.base : undefined });
@@ -1060,36 +1069,34 @@ function readStdin() {
1060
1069
  });
1061
1070
  }
1062
1071
 
1063
- async function fetchCampaigns(base, key, { brand, includeCounts = true } = {}) {
1064
- const query = { include_counts: includeCounts ? "true" : "false", limit: "500" };
1065
- if (brand) query.brand = brand;
1066
- const res = await request("GET", base, "/api/sequencer/campaigns", { key, query });
1072
+ async function fetchCampaigns(base, key) {
1073
+ const res = await request("GET", base, "/api/v1/campaigns", { key, query: { limit: "500" } });
1067
1074
  const r = need(res, "campaigns list");
1068
1075
  return r.campaigns || [];
1069
1076
  }
1070
1077
 
1071
- // <campaign> accepts a raw id (uuid) or an unambiguous case-insensitive name
1072
- // prefix. Errors listing every match when the prefix is ambiguous.
1073
1078
  async function resolveCampaign(base, key, identifier) {
1074
- if (!identifier) die("campaign id or name is required.");
1075
1079
  if (UUID_RE.test(identifier)) return identifier;
1076
- const campaigns = await fetchCampaigns(base, key, { includeCounts: false });
1077
- const needle = identifier.trim().toLowerCase();
1078
- const matches = campaigns.filter((c) => String(c.name || "").toLowerCase().startsWith(needle));
1079
- if (matches.length === 1) return matches[0].id;
1080
- if (matches.length === 0) {
1080
+ const needle = String(identifier || "").toLowerCase();
1081
+ const campaigns = await fetchCampaigns(base, key);
1082
+ const exact = campaigns.filter((c) => String(c.name || "").toLowerCase() === needle);
1083
+ const matches = exact.length ? exact : campaigns.filter((c) => String(c.name || "").toLowerCase().startsWith(needle));
1084
+ if (!matches.length) {
1081
1085
  die(`no campaign matching "${identifier}". Run \`argorant campaigns list\` to see names.`);
1082
1086
  }
1083
- die(
1084
- `"${identifier}" matches ${matches.length} campaigns — be more specific:\n` +
1085
- matches.map((c) => ` ${c.id} ${c.name}`).join("\n")
1086
- );
1087
+ if (matches.length > 1) {
1088
+ die(
1089
+ `"${identifier}" matches ${matches.length} campaigns — be more specific:\n` +
1090
+ matches.map((c) => ` ${c.name} ${dim(c.id)}`).join("\n")
1091
+ );
1092
+ }
1093
+ return matches[0].id;
1087
1094
  }
1088
1095
 
1089
1096
  async function campaignsList(argv) {
1090
1097
  const key = requireKey();
1091
- const args = readFlags(argv, { "--brand": "brand" });
1092
- const campaigns = await fetchCampaigns(args.base, key, { brand: args.brand, includeCounts: true });
1098
+ const args = readFlags(argv);
1099
+ const campaigns = await fetchCampaigns(args.base, key);
1093
1100
  if (args.json) return console.log(JSON.stringify(campaigns, null, 2));
1094
1101
  if (!campaigns.length) {
1095
1102
  return console.log(dim('No campaigns yet. Create one with `argorant campaigns create --name "..."`.'));
@@ -1101,7 +1108,9 @@ async function campaignsList(argv) {
1101
1108
  console.log(`${bold(c.name || "—")} ${dim(c.id)}`);
1102
1109
  console.log(
1103
1110
  ` ${c.status}` +
1104
- dim(" · contacted ") + sent.toLocaleString() +
1111
+ dim(" · leads ") + Number(c.lead_count || 0).toLocaleString() +
1112
+ dim(" · senders ") + Number(c.inbox_count || 0).toLocaleString() +
1113
+ dim(" · sent ") + sent.toLocaleString() +
1105
1114
  dim(" · replies ") + replied.toLocaleString() +
1106
1115
  dim(" · reply rate ") + rate
1107
1116
  );
@@ -1110,45 +1119,97 @@ async function campaignsList(argv) {
1110
1119
 
1111
1120
  async function campaignsCreate(argv) {
1112
1121
  const key = requireKey();
1113
- const args = readFlags(
1114
- argv,
1115
- { "--name": "name", "--brand": "brand", "--timezone": "timezone", "--window": "window" },
1116
- { "--skip-weekends": "skipWeekends", "--no-skip-weekends": "noSkipWeekends" }
1117
- );
1122
+ const args = readFlags(argv, CAMPAIGN_SETTING_FLAGS, CAMPAIGN_SETTING_BOOLS);
1118
1123
  const name = (args.name || "").trim();
1119
1124
  if (!name) {
1125
+ die('usage: argorant campaigns create --name "<name>" [--daily-limit 100] [--per-mailbox-limit 20] [--timezone America/New_York] [--timezone-mode fixed|lead] [--window 08:00-17:00] [--no-skip-weekends] [--gap 60-120] [--no-unsubscribe] [--start YYYY-MM-DD] [--tags a,b]');
1126
+ }
1127
+ const body = settingsFromFlags(args);
1128
+ body.name = name;
1129
+ const res = await request("POST", args.base, "/api/v1/campaigns", { key, body });
1130
+ const r = need(res, "campaigns create");
1131
+ const c = r.campaign || r;
1132
+ if (args.json) return console.log(JSON.stringify(r, null, 2));
1133
+ console.log(green("✓") + ` Created campaign ${bold(c.name || name)} ${dim(c.id)}`);
1134
+ printSettings(c);
1135
+ console.log(dim(`Next: argorant campaigns emails set ${c.id} --step 1 --subject "..." --body-file ./copy.txt`));
1136
+ }
1137
+
1138
+ // emails: the whole sequence at once (--file emails.json, or - for stdin) or
1139
+ // one step merged into what is already there (--step n ...).
1140
+ async function campaignsEmails(argv) {
1141
+ const sub = argv[0];
1142
+ if (sub !== "set") {
1120
1143
  die(
1121
- 'usage: argorant campaigns create --name "<name>" [--brand <key>] [--timezone <tz>] ' +
1122
- "[--window HH:MM-HH:MM] [--skip-weekends | --no-skip-weekends]"
1144
+ 'usage: argorant campaigns emails set <campaign> --file emails.json\n' +
1145
+ ' or: argorant campaigns emails set <campaign> --step <n> --subject "..." (--body-file <path> | --body <text|->) [--delay-days <d>] [--new-thread]\n' +
1146
+ ' emails.json: [{"subject":"...","body":"...","delay_days":0},{"body":"...","delay_days":3}]'
1123
1147
  );
1124
1148
  }
1125
- // lead_source defaults to "argorant_campaign" server-side, which requires a
1126
- // source_outbound_campaign_id this command doesn't collect. CLI-created
1127
- // campaigns add leads afterwards via `campaigns leads add`, so force "manual"
1128
- // it's a plain attribute on the campaign row, independent of how leads
1129
- // actually get imported later.
1130
- const body = { name, lead_source: "manual" };
1131
- if (args.brand) body.product_key = args.brand;
1132
- if (args.timezone) body.default_timezone = args.timezone;
1133
- if (args.window) {
1134
- const m = /^(\d{1,2}:\d{2})-(\d{1,2}:\d{2})$/.exec(args.window);
1135
- if (!m) die("--window must look like 08:00-17:00");
1136
- body.sending_window_start = m[1];
1137
- body.sending_window_end = m[2];
1149
+ const key = requireKey();
1150
+ const args = readFlags(
1151
+ argv.slice(1),
1152
+ { "--file": "file", "--step": "step", "--subject": "subject", "--body": "body", "--body-file": "bodyFile", "--delay-days": "delayDays" },
1153
+ { "--new-thread": "newThread" }
1154
+ );
1155
+ const identifier = args._[0];
1156
+ if (!identifier) die("usage: argorant campaigns emails set <campaign> ...");
1157
+ const campaignId = await resolveCampaign(args.base, key, identifier);
1158
+ let emails;
1159
+ if (args.file) {
1160
+ const text = args.file === "-" ? await readStdin() : (() => { try { return fs.readFileSync(args.file, "utf8"); } catch { die(`cannot read file: ${args.file}`); } })();
1161
+ try { emails = JSON.parse(text); } catch (e) { die(`${args.file}: not valid JSON (${e.message})`); }
1162
+ if (!Array.isArray(emails) || !emails.length) die("emails.json must be a non-empty array");
1163
+ } else {
1164
+ const step = Number(args.step);
1165
+ if (!Number.isInteger(step) || step < 1) die("--step must be 1, 2, 3 …");
1166
+ let body = args.body;
1167
+ if (args.bodyFile) { try { body = fs.readFileSync(args.bodyFile, "utf8"); } catch { die(`cannot read file: ${args.bodyFile}`); } }
1168
+ else if (body === "-") body = await readStdin();
1169
+ if (!body || !body.trim()) die("give the email text with --body or --body-file");
1170
+ if (step === 1 && !(args.subject || "").trim()) die("the first email needs --subject");
1171
+ // merge into the current sequence
1172
+ const cur = need(await request("GET", args.base, `/api/v1/campaigns/${campaignId}`, { key }), "campaign");
1173
+ const existing = (cur.emails || []).map((e) => ({ subject: e.subject || "", body: e.body || "", delay_days: e.delay_days || 0, same_thread: e.same_thread !== false }));
1174
+ while (existing.length < step) existing.push({ subject: "", body: "", delay_days: 3, same_thread: true });
1175
+ existing[step - 1] = {
1176
+ subject: (args.subject || existing[step - 1].subject || "").trim(),
1177
+ body,
1178
+ delay_days: args.delayDays !== undefined ? Number(args.delayDays) : (step === 1 ? 0 : existing[step - 1].delay_days || 3),
1179
+ same_thread: !args.newThread,
1180
+ };
1181
+ emails = existing.filter((e) => e.body && e.body.trim());
1182
+ }
1183
+ const res = await request("POST", args.base, `/api/v1/campaigns/${campaignId}/emails`, { key, body: { emails } });
1184
+ const r = need(res, "campaigns emails set");
1185
+ if (args.json) return console.log(JSON.stringify(r, null, 2));
1186
+ console.log(green("✓") + ` Saved ${(r.emails || emails).length} email(s) for ${dim(campaignId)}`);
1187
+ }
1188
+
1189
+ // senders: which connected mailboxes send this campaign.
1190
+ async function campaignsSenders(argv) {
1191
+ const sub = argv[0];
1192
+ const key = requireKey();
1193
+ if (sub === "remove") {
1194
+ const args = readFlags(argv.slice(1));
1195
+ const [identifier, email] = args._;
1196
+ if (!identifier || !email) die("usage: argorant campaigns senders remove <campaign> <mailbox@domain>");
1197
+ const campaignId = await resolveCampaign(args.base, key, identifier);
1198
+ const r = need(await request("DELETE", args.base, `/api/v1/campaigns/${campaignId}/senders/${encodeURIComponent(email)}`, { key }), "campaigns senders remove");
1199
+ if (args.json) return console.log(JSON.stringify(r, null, 2));
1200
+ return console.log(green("✓") + ` Detached ${r.detached}`);
1138
1201
  }
1139
- if (args.skipWeekends) body.skip_weekends = true;
1140
- if (args.noSkipWeekends) body.skip_weekends = false;
1141
- const res = await request("POST", args.base, "/api/sequencer/campaigns", { key, body });
1142
- const r = need(res, "campaigns create");
1143
- const c = r.campaign || {};
1202
+ if (sub !== "set") die("usage: argorant campaigns senders set <campaign> --emails a@x.com,b@y.com | --all\n or: argorant campaigns senders remove <campaign> <mailbox>");
1203
+ const args = readFlags(argv.slice(1), { "--emails": "emails" }, { "--all": "all" });
1204
+ const identifier = args._[0];
1205
+ if (!identifier) die("usage: argorant campaigns senders set <campaign> --emails a@x.com,b@y.com | --all");
1206
+ const campaignId = await resolveCampaign(args.base, key, identifier);
1207
+ const emails = String(args.emails || "").split(",").map((x) => x.trim()).filter(Boolean);
1208
+ if (!emails.length && !args.all) die("give --emails <a,b,c> or --all (see: argorant inboxes list)");
1209
+ const res = await request("POST", args.base, `/api/v1/campaigns/${campaignId}/senders`, { key, body: { emails, all_connected: !!args.all } });
1210
+ const r = need(res, "campaigns senders set");
1144
1211
  if (args.json) return console.log(JSON.stringify(r, null, 2));
1145
- console.log(green("✓") + ` Created campaign ${bold(c.name)} ${dim(c.id)}`);
1146
- console.log(
1147
- dim(
1148
- ` ${c.status} · ${c.default_timezone} · ${c.sending_window_start}–${c.sending_window_end} · skip weekends: ${c.skip_weekends}`
1149
- )
1150
- );
1151
- console.log(dim(`Next: argorant campaigns steps set ${c.id} --step 1 --subject "..." --body-file ./copy.txt`));
1212
+ console.log(green("✓") + ` ${r.attached || 0} sender(s) attached` + (r.senders && r.senders.length ? dim(` ${r.senders.join(", ")}`) : ""));
1152
1213
  }
1153
1214
 
1154
1215
  async function campaignsSteps(argv) {
@@ -1258,153 +1319,307 @@ async function campaignsInboxes(argv) {
1258
1319
 
1259
1320
  async function campaignsLeads(argv) {
1260
1321
  const sub = argv[0];
1261
- if (sub !== "add") {
1262
- die(
1263
- 'usage: argorant campaigns leads add <campaign> --csv <file>\n' +
1264
- ' or: argorant campaigns leads add <campaign> --query "..." [filters] -n <n>'
1265
- );
1266
- }
1322
+ const usage =
1323
+ 'usage: argorant campaigns leads add <campaign> --list <list-id>\n' +
1324
+ ' or: argorant campaigns leads add <campaign> --csv <file> (columns: email, first_name, last_name, company, title)\n' +
1325
+ ' or: argorant campaigns leads add <campaign> --query "..." [filters] -n <n> (operator keys)';
1267
1326
  const key = requireKey();
1268
- const valueFlags = { ...CAMPAIGN_FILTER_VALUE_FLAGS, "--csv": "csv", "-n": "limit", "--limit": "limit" };
1269
- const args = readFlags(argv.slice(1), valueFlags, CAMPAIGN_FILTER_BOOL_FLAGS);
1327
+ if (sub === "list" || sub === "remove") {
1328
+ const args = readFlags(argv.slice(1), { "--status": "status", "--q": "q", "-n": "limit", "--limit": "limit", "--offset": "offset" });
1329
+ if (!args._[0]) die(`usage: argorant campaigns leads ${sub} <campaign>${sub === "remove" ? " <email>" : " [--status queued|replied|bounced] [--q text] [-n 50]"}`);
1330
+ const campaignId = await resolveCampaign(args.base, key, args._[0]);
1331
+ return sub === "list" ? campaignsLeadsList(args, campaignId, key) : campaignsLeadsRemove(args, campaignId, key);
1332
+ }
1333
+ if (sub !== "add") die(usage);
1334
+ const valueFlags = { ...CAMPAIGN_FILTER_VALUE_FLAGS, "--csv": "csv", "--file": "csv", "--list": "list", "-n": "limit", "--limit": "limit" };
1335
+ const args = readFlags(argv.slice(1), valueFlags, { ...CAMPAIGN_FILTER_BOOL_FLAGS, "--include-catch-all": "includeCatchAll" });
1270
1336
  const identifier = args._[0];
1271
- if (!identifier) {
1272
- die(
1273
- 'usage: argorant campaigns leads add <campaign> --csv <file>\n' +
1274
- ' or: argorant campaigns leads add <campaign> --query "..." [filters] -n <n>'
1275
- );
1276
- }
1337
+ if (!identifier) die(usage);
1277
1338
  const campaignId = await resolveCampaign(args.base, key, identifier);
1278
- const body = {};
1279
- if (args.csv) {
1280
- let text;
1281
- try {
1282
- text = fs.readFileSync(args.csv, "utf8");
1283
- } catch {
1284
- die(`cannot read file: ${args.csv}`);
1285
- }
1286
- if (!text.trim()) die(`file is empty: ${args.csv}`);
1287
- body.csv_text = text;
1288
- } else {
1289
- const filters = {};
1290
- for (const field of Object.values(CAMPAIGN_FILTER_VALUE_FLAGS)) if (args[field]) filters[field] = args[field];
1291
- for (const field of Object.values(CAMPAIGN_FILTER_BOOL_FLAGS)) if (args[field]) filters[field] = "true";
1292
- if (!Object.keys(filters).length) {
1293
- die(
1294
- 'provide --csv <file>, or at least one filter: --query "..." --title --country --industry ' +
1295
- "--seniority --department --state --city --company --domain --has-phone --has-linkedin --has-email"
1296
- );
1297
- }
1298
- // GAP (see GODMODE-PLAN.md): the sequencer's filter-enroll endpoint has no
1299
- // per-request row cap — it enrolls every valid match up to its own
1300
- // server-side limit (currently 50,000). -n/--limit is accepted here for a
1301
- // familiar CLI surface but is NOT forwarded/honored; warn rather than
1302
- // silently ignoring a flag the caller explicitly set.
1303
- if (args.limit) {
1304
- warn("-n/--limit is not honored by campaign lead enrollment yet (platform-side gap, see GODMODE-PLAN.md) — it enrolls every valid match.");
1339
+
1340
+ if (args.list || args.csv) {
1341
+ const body = { include_catch_all: !!args.includeCatchAll };
1342
+ if (args.list) body.list_id = parseLimit(args.list, "--list");
1343
+ else {
1344
+ let text;
1345
+ try { text = fs.readFileSync(args.csv, "utf8"); } catch { die(`cannot read file: ${args.csv}`); }
1346
+ const lines = text.split(/\r?\n/).filter((l) => l.trim());
1347
+ if (lines.length < 2) die(`file has no rows: ${args.csv}`);
1348
+ const head = lines.shift().split(",").map((h) => h.trim().toLowerCase().replace(/\s+/g, "_"));
1349
+ if (!head.includes("email")) die("the CSV needs an email column");
1350
+ body.rows = lines.map((ln) => {
1351
+ const cells = ln.split(",");
1352
+ const row = {};
1353
+ head.forEach((h, i) => { if (h) row[h] = (cells[i] || "").trim(); });
1354
+ return row;
1355
+ });
1305
1356
  }
1306
- body.filters = filters;
1357
+ const res = await request("POST", args.base, `/api/v1/campaigns/${campaignId}/leads`, { key, body });
1358
+ const r = need(res, "campaigns leads add");
1359
+ if (args.json) return console.log(JSON.stringify(r, null, 2));
1360
+ const v = r.verification_counts || {};
1361
+ console.log(green("✓") + ` Enrolled ${Number(r.inserted || 0).toLocaleString()} of ${Number(r.input_rows || 0).toLocaleString()}`);
1362
+ console.log(dim(` duplicates ${r.duplicates_skipped || 0} · not valid ${r.skipped_not_valid || 0} (invalid ${v.invalid || 0}, catch-all ${v.catch_all || 0}) · checking in background ${r.queued_for_verification || 0}`));
1363
+ return;
1307
1364
  }
1365
+
1366
+ // Filter enrollment straight from the database: operator keys.
1367
+ const filters = {};
1368
+ for (const field of Object.values(CAMPAIGN_FILTER_VALUE_FLAGS)) if (args[field]) filters[field] = args[field];
1369
+ for (const field of Object.values(CAMPAIGN_FILTER_BOOL_FLAGS)) if (args[field]) filters[field] = "true";
1370
+ if (!Object.keys(filters).length) die(usage);
1371
+ const body = { filters };
1372
+ if (args.limit) body.limit = parseLimit(args.limit, "-n");
1308
1373
  const res = await request("POST", args.base, `/api/sequencer/campaigns/${campaignId}/leads/import`, { key, body });
1309
1374
  const r = need(res, "campaigns leads add");
1310
1375
  if (args.json) return console.log(JSON.stringify(r, null, 2));
1311
- console.log(
1312
- green("✓") +
1313
- ` ${bold(r.inserted || 0)} lead(s) added` +
1314
- (r.duplicates_skipped ? dim(` (${r.duplicates_skipped} duplicate already in campaign)`) : "")
1315
- );
1316
- if (r.queued_for_verification) {
1317
- console.log(dim(` ${r.queued_for_verification} queued for verification — will join once confirmed deliverable`));
1318
- }
1319
- if (r.skipped_not_valid) console.log(dim(` ${r.skipped_not_valid} skipped (not deliverable)`));
1320
- if (r.invalid_email_rows) console.log(dim(` ${r.invalid_email_rows} row(s) had no usable email`));
1376
+ console.log(green("✓") + ` Imported ${Number(r.inserted || 0).toLocaleString()} lead(s)` + dim(` (skipped ${r.duplicates_skipped || 0} duplicates, ${r.invalid_rows || 0} invalid)`));
1321
1377
  }
1322
1378
 
1323
- async function campaignsSetStatus(argv, status, verb) {
1379
+ async function campaignsSetStatus(argv, action) {
1324
1380
  const key = requireKey();
1325
- const args = readFlags(argv, {});
1381
+ const args = readFlags(argv);
1326
1382
  const identifier = args._[0];
1327
- if (!identifier) die(`usage: argorant campaigns ${verb} <campaign>`);
1383
+ if (!identifier) die(`usage: argorant campaigns ${action} <campaign>`);
1328
1384
  const campaignId = await resolveCampaign(args.base, key, identifier);
1329
- const res = await request("PATCH", args.base, `/api/sequencer/campaigns/${campaignId}`, { key, body: { status } });
1330
- if (res.status === 400 && res.json && res.json.detail && typeof res.json.detail === "object") {
1331
- const d = res.json.detail;
1332
- const blockers = d.blockers || [];
1333
- die(
1334
- `cannot ${verb} campaign: ${d.message || "blocked"}` +
1335
- (blockers.length ? "\n" + blockers.map((b) => ` - ${b}`).join("\n") : "")
1336
- );
1385
+ if (action === "launch" && !args.yes) {
1386
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
1387
+ const ok = await new Promise((r) => rl.question(`Launch ${campaignId} and start sending real email? [y/N] `, (a) => { rl.close(); r(/^y/i.test(a)); }));
1388
+ if (!ok) return console.log(dim("aborted"));
1337
1389
  }
1338
- const r = need(res, `campaigns ${verb}`);
1390
+ const res = await request("POST", args.base, `/api/v1/campaigns/${campaignId}/${action}`, { key, body: {} });
1391
+ const r = need(res, `campaigns ${action}`);
1339
1392
  if (args.json) return console.log(JSON.stringify(r, null, 2));
1340
1393
  const c = r.campaign || {};
1341
- console.log(green("✓") + ` Campaign ${bold(c.name || campaignId)} is now ${bold(c.status || status)}`);
1394
+ console.log(green("✓") + ` ${bold(c.name || campaignId)} is now ${bold(c.status || action)}`);
1342
1395
  }
1343
1396
 
1344
1397
  async function campaignsStatus(argv) {
1345
1398
  const key = requireKey();
1346
- const args = readFlags(argv, {});
1399
+ const args = readFlags(argv);
1347
1400
  const identifier = args._[0];
1348
1401
  if (!identifier) die("usage: argorant campaigns status <campaign>");
1349
1402
  const campaignId = await resolveCampaign(args.base, key, identifier);
1350
- const res = await request("GET", args.base, `/api/sequencer/campaigns/${campaignId}`, { key });
1351
- const r = need(res, "campaigns status");
1403
+ const r = need(await request("GET", args.base, `/api/v1/campaigns/${campaignId}`, { key }), "campaign");
1404
+ if (args.json) return console.log(JSON.stringify(r, null, 2));
1352
1405
  const c = r.campaign || {};
1353
- if (args.json) return console.log(JSON.stringify(c, null, 2));
1354
- const stepsOk = Number(c.approved_step_count || 0) > 0;
1355
- const inboxesOk = Number(c.inbox_count || 0) > 0;
1356
- const leadsOk = Number(c.queued_count || 0) > 0 || Number(c.lead_count || 0) > 0;
1357
- const mark = (ok) => (ok ? green("✓") : red(""));
1358
- console.log(`${bold(c.name || "—")} ${dim(c.id)} ${dim(c.status)}`);
1359
- console.log(` ${mark(stepsOk)} steps approved ${dim(`${c.approved_step_count || 0}/${c.step_count || 0}`)}`);
1360
- console.log(` ${mark(inboxesOk)} inboxes attached ${dim(String(c.inbox_count || 0))}`);
1361
- console.log(
1362
- ` ${mark(leadsOk)} leads queued ${dim(`${c.queued_count || 0} queued / ${c.lead_count || 0} total`)}`
1363
- );
1364
- const blockers = c.launch_blockers || [];
1365
- if (blockers.length) {
1366
- console.log(bold("\nLaunch blockers:"));
1367
- for (const b of blockers) console.log(` - ${b}`);
1368
- } else {
1369
- console.log(green("\n✓ Ready to launch") + dim(` — argorant campaigns start ${c.id}`));
1406
+ console.log(`${bold(c.name || "—")} ${dim(c.id)}`);
1407
+ console.log(` status ${bold(c.status)} · leads ${Number(c.lead_count || 0).toLocaleString()} · sent ${Number(c.sent_count || 0).toLocaleString()} · replies ${Number(c.replied_count || 0).toLocaleString()} · bounced ${Number(c.bounced_count || 0).toLocaleString()}`);
1408
+ console.log(` emails ${(r.emails || []).length} · senders ${(r.senders || []).length}`);
1409
+ printSettings({ settings: r.settings });
1410
+ for (const e of r.emails || []) console.log(dim(` ${e.step}. ${e.subject || "(same thread)"}${e.step > 1 ? ` · +${e.delay_days || 0} days` : ""}`));
1411
+ if (r.launch_blockers && r.launch_blockers.length) {
1412
+ console.log(yellow(" before launch:"));
1413
+ for (const b of r.launch_blockers) console.log(yellow(` · ${b}`));
1414
+ }
1415
+ if (c.url) console.log(dim(` ${c.url}`));
1416
+ }
1417
+
1418
+ const CAMPAIGN_SETTING_FLAGS = {
1419
+ "--name": "name", "--daily-limit": "daily_limit", "--per-mailbox-limit": "per_mailbox_daily_limit", "--max-mailboxes": "max_active_mailboxes",
1420
+ "--timezone": "timezone", "--timezone-mode": "timezone_mode", "--window": "window", "--gap": "gap", "--start": "planned_start_date",
1421
+ "--days-ahead": "schedule_days_ahead", "--tags": "tags",
1422
+ };
1423
+ const CAMPAIGN_SETTING_BOOLS = { "--skip-weekends": "skip_weekends", "--no-skip-weekends": "no_skip_weekends", "--unsubscribe": "include_unsubscribe", "--no-unsubscribe": "no_unsubscribe" };
1424
+
1425
+ function settingsFromFlags(args) {
1426
+ const body = {};
1427
+ for (const key of ["name", "timezone", "timezone_mode", "planned_start_date"]) if (args[key] !== undefined) body[key] = args[key];
1428
+ for (const key of ["daily_limit", "per_mailbox_daily_limit", "max_active_mailboxes", "schedule_days_ahead"]) if (args[key] !== undefined) body[key] = parseLimit(args[key], key);
1429
+ if (args.window) {
1430
+ const m = /^(\d{1,2}:\d{2})-(\d{1,2}:\d{2})$/.exec(args.window);
1431
+ if (!m) die("--window must look like 08:00-17:00");
1432
+ body.window_start = m[1].padStart(5, "0"); body.window_end = m[2].padStart(5, "0");
1433
+ }
1434
+ if (args.gap) {
1435
+ const m = /^(\d+)(?:-(\d+))?$/.exec(args.gap);
1436
+ if (!m) die("--gap must look like 60-120 (minutes between two sends from one mailbox)");
1437
+ body.gap_minutes_min = Number(m[1]); body.gap_minutes_max = Number(m[2] || m[1]);
1438
+ }
1439
+ if (args.tags !== undefined) body.tags = String(args.tags).split(",").map((t) => t.trim()).filter(Boolean);
1440
+ if (args.skip_weekends) body.skip_weekends = true;
1441
+ if (args.no_skip_weekends) body.skip_weekends = false;
1442
+ if (args.include_unsubscribe) body.include_unsubscribe = true;
1443
+ if (args.no_unsubscribe) body.include_unsubscribe = false;
1444
+ return body;
1445
+ }
1446
+
1447
+ function printSettings(c) {
1448
+ const s = c.settings || {};
1449
+ console.log(dim(` ${s.daily_limit || "?"} a day` + (s.per_mailbox_daily_limit ? ` · ${s.per_mailbox_daily_limit} per mailbox` : "") + ` · ${s.window_start || "?"}-${s.window_end || "?"} ${s.timezone || ""}${s.timezone_mode === "lead" ? " (recipient local time)" : ""}` +
1450
+ ` · ${s.skip_weekends ? "weekdays" : "every day"} · gap ${s.gap_minutes_min || "?"}-${s.gap_minutes_max || "?"} min` + (s.planned_start_date ? ` · starts ${s.planned_start_date}` : "") + (s.include_unsubscribe === false ? " · no opt-out line" : "") + (s.tags && s.tags.length ? ` · ${s.tags.join(", ")}` : "")));
1451
+ }
1452
+
1453
+ async function campaignsUpdate(argv) {
1454
+ const key = requireKey();
1455
+ const args = readFlags(argv, CAMPAIGN_SETTING_FLAGS, CAMPAIGN_SETTING_BOOLS);
1456
+ const identifier = args._[0];
1457
+ if (!identifier) die('usage: argorant campaigns update <campaign> [--name "<n>"] [--daily-limit 40] [--per-mailbox-limit 20] [--max-mailboxes 10] [--timezone Europe/Berlin] [--timezone-mode fixed|lead] [--window 08:00-17:00] [--skip-weekends|--no-skip-weekends] [--gap 60-120] [--unsubscribe|--no-unsubscribe] [--start YYYY-MM-DD] [--tags a,b]');
1458
+ const campaignId = await resolveCampaign(args.base, key, identifier);
1459
+ const body = settingsFromFlags(args);
1460
+ if (!Object.keys(body).length) die("nothing to change (see: argorant campaigns help)");
1461
+ const r = need(await request("PATCH", args.base, `/api/v1/campaigns/${campaignId}`, { key, body }), "campaigns update");
1462
+ if (args.json) return console.log(JSON.stringify(r, null, 2));
1463
+ console.log(green("✓") + ` Updated ${(r.changed || []).join(", ")}`);
1464
+ printSettings(r.campaign || {});
1465
+ }
1466
+
1467
+ async function campaignsDelete(argv) {
1468
+ const key = requireKey();
1469
+ const args = readFlags(argv);
1470
+ const identifier = args._[0];
1471
+ if (!identifier) die("usage: argorant campaigns delete <campaign> [-y]");
1472
+ const campaignId = await resolveCampaign(args.base, key, identifier);
1473
+ if (!args.yes) {
1474
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
1475
+ const ok = await new Promise((r) => rl.question(`Delete campaign ${campaignId} with all its leads and results? [y/N] `, (a) => { rl.close(); r(/^y/i.test(a)); }));
1476
+ if (!ok) return console.log(dim("aborted"));
1477
+ }
1478
+ const r = need(await request("DELETE", args.base, `/api/v1/campaigns/${campaignId}`, { key }), "campaigns delete");
1479
+ if (args.json) return console.log(JSON.stringify(r, null, 2));
1480
+ console.log(green("✓") + ` Deleted ${campaignId}`);
1481
+ }
1482
+
1483
+ async function campaignsLeadsList(args, campaignId, key) {
1484
+ const query = { limit: args.limit || 50, offset: args.offset || 0 };
1485
+ if (args.status) query.status = args.status;
1486
+ if (args.q) query.q = args.q;
1487
+ const r = need(await request("GET", args.base, `/api/v1/campaigns/${campaignId}/leads`, { key, query }), "campaigns leads");
1488
+ if (args.json) return console.log(JSON.stringify(r, null, 2));
1489
+ console.log(dim(`${r.total} lead(s)`));
1490
+ for (const l of r.leads || []) console.log(`${l.email} ${dim([l.first_name, l.last_name].filter(Boolean).join(" ") || "")} ${l.status}${l.current_step ? dim(` step ${l.current_step}`) : ""}${l.replied_at ? green(" replied") : ""}${l.bounced_at ? red(" bounced") : ""}`);
1491
+ }
1492
+
1493
+ async function campaignsLeadsRemove(args, campaignId, key) {
1494
+ const email = args._[1];
1495
+ if (!email) die("usage: argorant campaigns leads remove <campaign> <email>");
1496
+ const r = need(await request("DELETE", args.base, `/api/v1/campaigns/${campaignId}/leads/${encodeURIComponent(email)}`, { key }), "campaigns leads remove");
1497
+ if (args.json) return console.log(JSON.stringify(r, null, 2));
1498
+ console.log(green("✓") + ` Removed ${r.removed}`);
1499
+ }
1500
+
1501
+ async function campaignsReplies(argv) {
1502
+ const key = requireKey();
1503
+ const args = readFlags(argv, { "-n": "limit", "--limit": "limit" });
1504
+ const identifier = args._[0];
1505
+ if (!identifier) die("usage: argorant campaigns replies <campaign> [-n 50]");
1506
+ const campaignId = await resolveCampaign(args.base, key, identifier);
1507
+ const r = need(await request("GET", args.base, `/api/v1/campaigns/${campaignId}/replies`, { key, query: { limit: args.limit || 50 } }), "campaigns replies");
1508
+ if (args.json) return console.log(JSON.stringify(r, null, 2));
1509
+ if (!(r.replies || []).length) return console.log(dim("No replies yet."));
1510
+ for (const e of r.replies) {
1511
+ console.log(`${bold(e.from_email || "")} ${dim([e.first_name, e.last_name].filter(Boolean).join(" "))} ${e.classification || ""} ${dim(e.created_at || "")}`);
1512
+ console.log(dim(` ${(e.subject || "").slice(0, 80)} — ${(e.body || "").replace(/\s+/g, " ").slice(0, 140)}`));
1513
+ }
1514
+ }
1515
+
1516
+ async function cmdInboxThreads(argv) {
1517
+ const sub = argv[0] || "list";
1518
+ const key = requireKey();
1519
+ if (sub === "list") {
1520
+ const args = readFlags(argv.slice(1), { "--folder": "folder", "--campaign": "campaign", "--classification": "classification", "--q": "q", "-n": "limit", "--limit": "limit" });
1521
+ const query = { folder: args.folder || "replies", limit: args.limit || 50 };
1522
+ if (args.classification) query.classification = args.classification;
1523
+ if (args.q) query.q = args.q;
1524
+ if (args.campaign) query.campaign_id = await resolveCampaign(args.base, key, args.campaign);
1525
+ const r = need(await request("GET", args.base, "/api/v1/inbox", { key, query }), "inbox");
1526
+ if (args.json) return console.log(JSON.stringify(r, null, 2));
1527
+ if (!(r.events || []).length) return console.log(dim(`No conversations in ${query.folder}.`));
1528
+ for (const e of r.events) {
1529
+ console.log(`${dim(e.id)}`);
1530
+ console.log(` ${bold(e.from_email || e.lead_email || "")} ${e.classification || ""} ${dim(e.campaign_name || "")} ${dim(e.created_at || "")}`);
1531
+ console.log(dim(` ${(e.subject || "").slice(0, 80)} — ${(e.body || e.snippet || "").replace(/\s+/g, " ").slice(0, 140)}`));
1532
+ }
1533
+ return;
1534
+ }
1535
+ if (sub === "read") {
1536
+ const args = readFlags(argv.slice(1));
1537
+ const id = args._[0]; if (!id) die("usage: argorant inbox read <thread-id>");
1538
+ const r = need(await request("GET", args.base, `/api/v1/inbox/${encodeURIComponent(id)}`, { key }), "inbox read");
1539
+ if (args.json) return console.log(JSON.stringify(r, null, 2));
1540
+ const e = r.event || {};
1541
+ console.log(`${bold(e.from_email || e.lead_email || "")} ${e.classification || ""} ${dim(e.campaign_name || "")}\n${dim(e.subject || "")}\n\n${e.body || ""}`);
1542
+ return;
1543
+ }
1544
+ if (sub === "reply") {
1545
+ const args = readFlags(argv.slice(1), { "--body": "body", "--body-file": "bodyFile" });
1546
+ const id = args._[0]; if (!id) die("usage: argorant inbox reply <thread-id> --body \"...\" | --body-file reply.txt [-y]");
1547
+ let body = args.body;
1548
+ if (args.bodyFile) { try { body = fs.readFileSync(args.bodyFile, "utf8"); } catch { die(`cannot read file: ${args.bodyFile}`); } }
1549
+ if (!body || !body.trim()) die("give the reply text with --body or --body-file");
1550
+ if (!args.yes) {
1551
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
1552
+ const ok = await new Promise((r) => rl.question(`Send this reply now? [y/N] `, (a) => { rl.close(); r(/^y/i.test(a)); }));
1553
+ if (!ok) return console.log(dim("aborted"));
1554
+ }
1555
+ const r = need(await request("POST", args.base, `/api/v1/inbox/${encodeURIComponent(id)}/reply`, { key, body: { body } }), "inbox reply");
1556
+ if (args.json) return console.log(JSON.stringify(r, null, 2));
1557
+ console.log(green("✓") + " Reply sent");
1558
+ return;
1559
+ }
1560
+ if (sub === "classify") {
1561
+ const args = readFlags(argv.slice(1));
1562
+ const [id, cl] = args._; if (!id || !cl) die("usage: argorant inbox classify <thread-id> interested|not_interested|out_of_office|meeting_booked|referral|other");
1563
+ const r = need(await request("POST", args.base, `/api/v1/inbox/${encodeURIComponent(id)}/classify`, { key, body: { classification: cl } }), "inbox classify");
1564
+ if (args.json) return console.log(JSON.stringify(r, null, 2));
1565
+ console.log(green("✓") + ` ${r.classification}`);
1566
+ return;
1370
1567
  }
1568
+ die(`unknown inbox subcommand: ${sub} (list, read, reply, classify)`);
1371
1569
  }
1372
1570
 
1373
1571
  function campaignsHelp() {
1374
1572
  const p = bold("argorant campaigns");
1375
1573
  console.log(`
1376
- ${bold("Argorant Campaigns")} — god-mode outbound campaign control ${dim("(operator keys only)")}
1574
+ ${bold("Argorant Campaigns")} — email outreach from the terminal
1377
1575
 
1378
- Drives the internal Argorant Sequencer (${dim("/api/sequencer/*")}) a live campaign
1379
- in about two minutes from the terminal. Requires an ag_live_ key belonging to
1380
- an owner/admin account with the ${bold("argorant:operator")} scope; any other key gets
1381
- a 401/403, same as it would in a browser without outbound access.
1576
+ Works with any Argorant API key. Nothing is sent until you launch.
1382
1577
 
1383
1578
  ${bold("USAGE")}
1384
- ${p} list [--brand <key>]
1385
- ${p} create --name "<name>" [--brand <key>] [--timezone <tz>] [--window HH:MM-HH:MM] [--skip-weekends]
1386
- ${p} steps set <campaign> --step <n> --subject "..." (--body-file <path> | --body <text|->) [--approve]
1387
- ${p} inboxes attach <campaign> --count <n> [--pool <brand>]
1388
- ${p} leads add <campaign> --csv <file>
1389
- ${p} leads add <campaign> --query "..." [filters]
1390
- ${p} start <campaign>
1579
+ ${p} list
1580
+ ${p} create --name "<name>" [settings]
1581
+ ${p} update <campaign> [settings] ${dim("only the flags you pass change")}
1582
+ settings: --daily-limit 40 --per-mailbox-limit 20 --max-mailboxes 10 --timezone Europe/Berlin
1583
+ --timezone-mode fixed|lead --window 08:00-17:00 --skip-weekends|--no-skip-weekends
1584
+ --gap 60-120 --unsubscribe|--no-unsubscribe --start YYYY-MM-DD --tags a,b --name "<n>"
1585
+ ${p} emails set <campaign> --file emails.json
1586
+ ${p} emails set <campaign> --step <n> --subject "..." (--body-file <path> | --body <text|->) [--delay-days <d>]
1587
+ ${p} leads add <campaign> --list <list-id> | --csv <file> [--include-catch-all]
1588
+ ${p} leads list <campaign> [--status replied] [--q text] [-n 50]
1589
+ ${p} leads remove <campaign> <email>
1590
+ ${p} senders set <campaign> --emails a@x.com,b@y.com | --all
1591
+ ${p} senders remove <campaign> <mailbox>
1592
+ ${p} replies <campaign> [-n 50]
1593
+ ${p} delete <campaign> [-y]
1594
+ ${p} launch <campaign> [-y] ${dim("asks for confirmation; sends real email")}
1391
1595
  ${p} pause <campaign>
1596
+ ${p} stop <campaign>
1392
1597
  ${p} status <campaign>
1393
1598
 
1394
- ${dim("<campaign> accepts a raw id or an unambiguous case-insensitive name prefix.")}
1395
- ${dim("The CLI never writes copy for you steps set only upserts what you give it.")}
1599
+ ${bold("argorant inboxes")} list
1600
+ ${bold("argorant inboxes")} connect-google --admin <admin@yourdomain.com> [--emails a,b | --all]
1601
+
1602
+ ${bold("argorant inbox")} list [--folder replies|interested|not_interested|out_of_office|bounces|unsubscribes|all] [--campaign <c>] [--q text]
1603
+ ${bold("argorant inbox")} read <thread-id>
1604
+ ${bold("argorant inbox")} reply <thread-id> --body "..." | --body-file reply.txt [-y]
1605
+ ${bold("argorant inbox")} classify <thread-id> interested|not_interested|out_of_office|meeting_booked|referral|other
1606
+
1607
+ ${dim("<campaign> accepts an id or an unambiguous case-insensitive name prefix.")}
1608
+ ${dim("Variables in emails: {{first_name}} {{last_name}} {{company}} {{title}}. Spintax {a|b} varies phrasing.")}
1609
+ ${dim("Every address is verified before it is enrolled; only valid ones send unless --include-catch-all.")}
1396
1610
 
1397
- ${bold("EXAMPLE — live in two minutes")}
1398
- ${p} create --name "Q3 CFO outreach" --brand argorant --timezone America/New_York --window 08:00-17:00 --skip-weekends
1399
- ${p} steps set "Q3 CFO outreach" --step 1 --subject "Quick question" --body-file ./copy/step1.txt --approve
1400
- ${p} inboxes attach "Q3 CFO outreach" --count 5 --pool argorant
1401
- ${p} leads add "Q3 CFO outreach" --query "CFO" --industry fintech --country Germany
1402
- ${p} start "Q3 CFO outreach"
1611
+ ${bold("EXAMPLE")}
1612
+ ${p} create --name "Q4 CFO outreach" --daily-limit 40
1613
+ ${p} emails set "Q4 CFO" --step 1 --subject "Quick question, {{first_name}}" --body-file ./step1.txt
1614
+ ${p} emails set "Q4 CFO" --step 2 --body "Bumping this up." --delay-days 3
1615
+ ${p} leads add "Q4 CFO" --list 1240
1616
+ ${p} senders set "Q4 CFO" --all
1617
+ ${p} launch "Q4 CFO"
1403
1618
 
1404
1619
  ${bold("OPTIONS")}
1405
1620
  --json Raw JSON output --base <url> Override API base
1406
1621
 
1407
- Docs: ${cyan("https://argorant.com/docs/cli")} · Gap notes: cli/GODMODE-PLAN.md
1622
+ Docs: ${cyan("https://argorant.com/docs/cli")}
1408
1623
  `);
1409
1624
  }
1410
1625
 
@@ -1415,18 +1630,69 @@ async function cmdCampaigns(argv) {
1415
1630
  const table = {
1416
1631
  list: campaignsList,
1417
1632
  create: campaignsCreate,
1633
+ update: campaignsUpdate,
1634
+ set: campaignsUpdate,
1635
+ delete: campaignsDelete,
1636
+ replies: campaignsReplies,
1637
+ emails: campaignsEmails,
1418
1638
  steps: campaignsSteps,
1639
+ senders: campaignsSenders,
1419
1640
  inboxes: campaignsInboxes,
1420
1641
  leads: campaignsLeads,
1421
- start: (a) => campaignsSetStatus(a, "active", "start"),
1422
- pause: (a) => campaignsSetStatus(a, "paused", "pause"),
1642
+ launch: (a) => campaignsSetStatus(a, "launch"),
1643
+ start: (a) => campaignsSetStatus(a, "launch"),
1644
+ pause: (a) => campaignsSetStatus(a, "pause"),
1645
+ stop: (a) => campaignsSetStatus(a, "stop"),
1423
1646
  status: campaignsStatus,
1647
+ get: campaignsStatus,
1424
1648
  };
1425
1649
  const fn = table[sub];
1426
1650
  if (!fn) die(`unknown campaigns subcommand: ${sub}\nRun \`argorant campaigns help\` for usage.`);
1427
1651
  await fn(rest);
1428
1652
  }
1429
1653
 
1654
+ async function cmdInboxes(argv) {
1655
+ const sub = argv[0] || "list";
1656
+ const key = requireKey();
1657
+ if (sub === "list") {
1658
+ const args = readFlags(argv.slice(1));
1659
+ const r = need(await request("GET", args.base, "/api/v1/inboxes", { key }), "inboxes list");
1660
+ if (args.json) return console.log(JSON.stringify(r, null, 2));
1661
+ const rows = r.inboxes || [];
1662
+ if (!rows.length) return console.log(dim("No mailboxes connected yet. Connect Google Workspace with `argorant inboxes connect-google --admin ...` or Microsoft 365 in the app."));
1663
+ for (const i of rows) {
1664
+ console.log(`${bold(i.email)} ${dim(i.name || "")}`);
1665
+ console.log(dim(` ${i.provider} · ${i.status}${i.health ? ` · ${i.health}` : ""} · today ${i.sent_today || 0}/${i.daily_limit || "?"}`));
1666
+ }
1667
+ return;
1668
+ }
1669
+ if (sub === "connect-google") {
1670
+ const args = readFlags(argv.slice(1), { "--admin": "admin", "--emails": "emails" }, { "--all": "all" });
1671
+ if (!args.admin) die("usage: argorant inboxes connect-google --admin admin@yourdomain.com [--emails a@x.com,b@x.com | --all]");
1672
+ const body = { admin_email: args.admin };
1673
+ if (args.all) body.emails = [];
1674
+ else if (args.emails) body.emails = String(args.emails).split(",").map((x) => x.trim()).filter(Boolean);
1675
+ const r = need(await request("POST", args.base, "/api/v1/inboxes/google-workspace", { key, body }), "inboxes connect-google");
1676
+ if (args.json) return console.log(JSON.stringify(r, null, 2));
1677
+ if (r.ok === false && r.setup) {
1678
+ console.log(yellow("Delegation is not active yet.") + ` ${r.reason || ""}`);
1679
+ console.log(`In Google Admin > Security > API controls > Domain-wide delegation add:\n Client ID: ${bold(r.setup.client_id)}\n Scopes: ${r.setup.scopes_csv || (r.setup.scopes || []).join(",")}`);
1680
+ if (r.setup.delegation_url) console.log(dim(` ${r.setup.delegation_url}`));
1681
+ console.log(dim("Then run this command again."));
1682
+ return;
1683
+ }
1684
+ if (r.mailboxes) {
1685
+ for (const m of r.mailboxes) console.log(`${m.connected ? green("✓") : " "} ${m.email} ${dim(m.name || "")}${m.alias ? dim(" alias") : ""}`);
1686
+ console.log(dim("\nconnect with: --emails a@x.com,b@x.com or --all"));
1687
+ return;
1688
+ }
1689
+ console.log(green("✓") + ` Connected ${(r.connected || []).length} mailbox(es)`);
1690
+ for (const c of r.connected || []) console.log(dim(` ${c.email} · ${c.health || "ok"}`));
1691
+ return;
1692
+ }
1693
+ die(`unknown inboxes subcommand: ${sub} (list, connect-google)`);
1694
+ }
1695
+
1430
1696
  function help() {
1431
1697
  const p = bold("argorant");
1432
1698
  console.log(`
@@ -1454,7 +1720,9 @@ ${bold("COMMANDS")}
1454
1720
  ${cyan("list status")} <id> Show a saved list's size ${dim("(free)")}
1455
1721
  ${cyan("verify")} <email> Verify one of your own emails ${dim("(verification pool)")}
1456
1722
  ${cyan("verify")} --file emails.csv -o out.csv Bulk-verify your own list ${dim("(recent re-checks free)")}
1457
- ${cyan("campaigns")} ... Live outbound campaigns from the terminal ${dim("(operator keys only — argorant campaigns help)")}
1723
+ ${cyan("campaigns")} ... Email outreach: create, write, enroll, launch ${dim("(argorant campaigns help)")}
1724
+ ${cyan("inboxes")} list | connect-google Connected mailboxes; connect a Google Workspace
1725
+ ${cyan("inbox")} list | read | reply | classify Replies across campaigns; answer in-thread
1458
1726
 
1459
1727
  ${bold("FILTERS")}
1460
1728
  --keywords <k> Comma = OR. The widest, most reliable filter - prefer it
@@ -1512,9 +1780,11 @@ async function main() {
1512
1780
  // `campaigns` has its own flag vocabulary (--step, --count, --pool, --csv, ...)
1513
1781
  // handled by readFlags — it never goes through the generic filter parser
1514
1782
  // below, which would reject those flags as unknown.
1515
- if (cmd === "campaigns") {
1783
+ if (cmd === "campaigns" || cmd === "campaign" || cmd === "inboxes" || cmd === "mailboxes" || cmd === "inbox" || cmd === "unibox") {
1516
1784
  try {
1517
- await cmdCampaigns(argv.slice(1));
1785
+ if (cmd.startsWith("campaign")) await cmdCampaigns(argv.slice(1));
1786
+ else if (cmd === "inbox" || cmd === "unibox") await cmdInboxThreads(argv.slice(1));
1787
+ else await cmdInboxes(argv.slice(1));
1518
1788
  } catch (e) {
1519
1789
  die(e && e.message ? e.message : String(e));
1520
1790
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "argorant",
3
- "version": "0.5.1",
3
+ "version": "0.7.0",
4
4
  "description": "Search, count, reveal, export, and verify B2B contacts from the Argorant database — from your terminal, scripts, or coding agent.",
5
5
  "bin": {
6
6
  "argorant": "bin/argorant.js"