@seguelac/aca-cli 0.6.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  All notable changes to `aca-cli` are documented here. Format loosely follows [Keep a Changelog](https://keepachangelog.com/).
4
4
 
5
+ ## [0.7.0] - 2026-10-19
6
+
7
+ ### Changed
8
+ - **`aca enroll -l` runs as a server-side background job.** Sending a whole list in one request died past ~50k members (the platform kills a request at 150s). The CLI now starts an enrollment job and follows it, printing progress (a 193k list takes about 4 minutes). Ctrl-C stops watching, not the job. The final output adds a breakdown of skips: already enrolled, active in another sequence, suppressed, no email.
9
+ - `--contacts` with more than 2,500 ids uses the same background job. Smaller batches still enroll synchronously and return counts straight away.
10
+
11
+ ### Added
12
+ - `-l` takes several comma-separated lists (enrolls their union).
13
+ - `--no-wait` starts the job and prints its id without following it.
14
+ - Contact ids can be piped on stdin (comma- or whitespace-separated) when neither `-l` nor `--contacts` is given.
15
+
16
+ ## [0.6.2] - 2026-09-09
17
+
18
+ ### Added
19
+ - `linkedin_bio` and `home_page_text` are now standard contact fields (promoted from an org-scoped custom field / newly added, respectively — same underlying `crm_contacts` columns the app and MCP use). `aca contact bulk-create` accepts both; `aca contact get` already returns them since it reads the full `/v1/contacts/{id}` shape.
20
+
5
21
  ## [0.6.1] - 2026-09-02
6
22
 
7
23
  ### Fixed
package/README.md CHANGED
@@ -65,8 +65,8 @@ aca campaign leads <campaignId> --stuck --json | jq '.[] | .contact_id'
65
65
  | `aca lists add -l <listId> --contacts <ids>` | Bulk-add contacts to a list. |
66
66
  | `aca lists members -l <listId>` | List members of a list. |
67
67
  | `aca lists remove -l <listId> --contacts <ids>` | Remove contacts from a list. |
68
- | `aca enroll -c <campaignId> -l <listId>` | Enroll an entire list into a campaign. |
69
- | `aca enroll -c <campaignId> --contacts <ids>` | Enroll specific contacts. |
68
+ | `aca enroll -c <campaignId> -l <listId>` | Enroll an entire list (or several, comma-separated) as a background job and follow its progress. `--no-wait` returns the job id. |
69
+ | `aca enroll -c <campaignId> --contacts <ids>` | Enroll specific contacts (or pipe ids on stdin). Over 2,500 ids runs as a background job. |
70
70
 
71
71
  ### Inbox & replies
72
72
  | Command | What it does |
@@ -13,6 +13,8 @@ const CONTACT_FIELDS = [
13
13
  'primary_email',
14
14
  'primary_phone',
15
15
  'primary_linkedin_url',
16
+ 'linkedin_bio',
17
+ 'home_page_text',
16
18
  'company_website',
17
19
  'city',
18
20
  'state',
@@ -1,32 +1,102 @@
1
- import { invokeFn } from '../api.js';
1
+ import { invokeFn, restGet } from '../api.js';
2
2
  import { readConfig } from '../config.js';
3
3
  import { output, fail } from '../output.js';
4
- import { parseList } from '../util.js';
4
+ import { parseList, readStdinIfPiped } from '../util.js';
5
+ const BACKGROUND_THRESHOLD = 2500;
6
+ const POLL_MS = 3000;
7
+ const TERMINAL = new Set(['completed', 'failed', 'cancelled']);
8
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
9
+ async function readJob(jobId) {
10
+ const rows = await restGet(`email_enrollment_jobs?id=eq.${jobId}&select=id,status,total,processed,results,error_message,completed_at`);
11
+ if (!rows[0])
12
+ throw new Error(`Enrollment job ${jobId} not found`);
13
+ return rows[0];
14
+ }
15
+ function summarize(job) {
16
+ const r = job.results ?? {};
17
+ return {
18
+ job_id: job.id,
19
+ status: job.status,
20
+ total: job.total,
21
+ processed: job.processed,
22
+ enrolled: r.enrolled ?? 0,
23
+ skipped_already_enrolled: Math.max(0, (r.skipped ?? 0) - (r.filteredOut ?? 0) - (r.awaitingPipeline ?? 0)),
24
+ skipped_active_elsewhere: r.alreadyInAnotherSequence ?? 0,
25
+ skipped_suppressed: r.suppressed ?? 0,
26
+ skipped_no_email: r.noEmail ?? 0,
27
+ skipped_filtered_out: r.filteredOut ?? 0,
28
+ skipped_awaiting_pipeline: r.awaitingPipeline ?? 0,
29
+ skipped_missing_content: r.missingContent ?? 0,
30
+ ...(job.error_message ? { error: job.error_message } : {}),
31
+ };
32
+ }
5
33
  export function registerEnroll(program) {
6
34
  program
7
35
  .command('enroll')
8
36
  .description('Enroll leads into a campaign sequence')
9
37
  .requiredOption('-c, --campaign <sequenceId>', 'Campaign / sequence ID')
10
- .option('-l, --list <listId>', 'Enroll an entire lead list')
11
- .option('--contacts <ids>', 'Comma-separated contact IDs')
38
+ .option('-l, --list <listIds>', 'Enroll one or more lead lists (comma-separated)')
39
+ .option('--contacts <ids>', 'Comma-separated contact IDs (or pipe ids on stdin)')
12
40
  .option('-o, --organization <orgId>', 'Override active organization')
41
+ .option('--no-wait', 'Start a background enrollment and return its job id without waiting')
13
42
  .option('--json', 'Emit JSON')
14
43
  .action(async (opts) => {
15
44
  const orgId = opts.organization || readConfig().active_org_id;
16
45
  if (!orgId) {
17
46
  fail('No active organization. Run `aca org switch <id>` or pass --organization.');
18
47
  }
48
+ const listIds = parseList(opts.list);
49
+ let contactIds = parseList(opts.contacts);
50
+ if (!listIds.length && !contactIds.length) {
51
+ const piped = await readStdinIfPiped();
52
+ if (piped)
53
+ contactIds = piped.split(/[\s,]+/).filter(Boolean);
54
+ }
55
+ if (!listIds.length && !contactIds.length) {
56
+ fail('Provide either --list <id> or --contacts <id1,id2,...> (or pipe contact ids on stdin)');
57
+ }
19
58
  const body = {
20
59
  sequenceId: opts.campaign,
21
60
  organizationId: orgId,
61
+ ...(listIds.length ? { listIds } : { contactIds }),
22
62
  };
23
- if (opts.list)
24
- body.listId = opts.list;
25
- else if (opts.contacts)
26
- body.contactIds = parseList(opts.contacts);
27
- else
28
- fail('Provide either --list <id> or --contacts <id1,id2,...>');
29
- const result = await invokeFn('enroll-leads', body);
30
- output(result, { json: opts.json });
63
+ if (!listIds.length && contactIds.length <= BACKGROUND_THRESHOLD) {
64
+ output(await invokeFn('enroll-leads', body), { json: opts.json });
65
+ return;
66
+ }
67
+ const started = await invokeFn('enroll-leads', { ...body, background: true });
68
+ if (!started.jobId) {
69
+ output(started, { json: opts.json });
70
+ return;
71
+ }
72
+ if (started.existing && !opts.json) {
73
+ process.stderr.write(`An enrollment is already running for this sequence; following job ${started.jobId}\n`);
74
+ }
75
+ if (!opts.wait) {
76
+ output({ job_id: started.jobId, status: started.status, already_running: started.existing === true }, { json: opts.json });
77
+ return;
78
+ }
79
+ if (!opts.json) {
80
+ process.stderr.write(`Enrolling in the background (job ${started.jobId}). Ctrl-C stops watching, not the job.\n`);
81
+ }
82
+ let lastLine = '';
83
+ for (;;) {
84
+ const job = await readJob(started.jobId);
85
+ if (TERMINAL.has(job.status)) {
86
+ output(summarize(job), { json: opts.json });
87
+ if (job.status === 'failed')
88
+ process.exitCode = 1;
89
+ return;
90
+ }
91
+ if (!opts.json) {
92
+ const line = job.status === 'running'
93
+ ? ` …${job.processed}/${job.total} checked, ${job.results?.enrolled ?? 0} enrolled`
94
+ : ` …preparing audience (${job.total} contacts so far)`;
95
+ if (line !== lastLine)
96
+ process.stderr.write(`${line}\n`);
97
+ lastLine = line;
98
+ }
99
+ await sleep(POLL_MS);
100
+ }
31
101
  });
32
102
  }
@@ -7,6 +7,7 @@ export function registerReply(program) {
7
7
  .description('Reply to an existing CRM conversation')
8
8
  .argument('<conversationId>')
9
9
  .option('-m, --message <text>', 'Reply body (or pipe via stdin)')
10
+ .option('--html', 'Send --message/stdin as raw HTML instead of plain text (email channels only) — e.g. an <a href><img></a> snippet to embed a linked thumbnail like a Loom video preview')
10
11
  .option('--subject <text>', 'Email subject (email channels only)')
11
12
  .option('--cc <emails>', 'Comma-separated CC list (email only)')
12
13
  .option('--bcc <emails>', 'Comma-separated BCC list (email only)')
@@ -23,12 +24,16 @@ export function registerReply(program) {
23
24
  if (!conv.external_participant_id) {
24
25
  fail('Conversation is missing external_participant_id — cannot determine recipient.');
25
26
  }
27
+ if (opts.html && conv.channel !== 'email' && !conv.mailbox_id) {
28
+ fail('--html is only meaningful for email conversations — other channels send it as literal text.');
29
+ }
26
30
  const body = {
27
31
  conversation_id: conv.id,
28
32
  contact_id: conv.contact_id,
29
33
  channel: conv.channel,
30
34
  recipient_external_id: conv.external_participant_id,
31
35
  content,
36
+ content_type: opts.html ? 'html' : 'text',
32
37
  };
33
38
  if (conv.channel_account_id)
34
39
  body.channel_account_id = conv.channel_account_id;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seguelac/aca-cli",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "Command-line interface for ACA (Automated Client Acquisition) — push leads to campaigns, triage replies, manage contacts, all from your terminal.",
5
5
  "type": "module",
6
6
  "bin": {