@seguelac/aca-cli 0.4.0 → 0.6.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 +18 -0
- package/README.md +7 -0
- package/dist/commands/sequence.js +65 -0
- package/dist/index.js +3 -1
- package/dist/session.js +26 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
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.6.0] - 2026-09-02
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
- **API token auth was broken for every command that reads via PostgREST** (`org ls/switch/current`, `inbox`, `contact get`, `campaign`, `autopilot`, `leads`, `lists`, `signals`, `reply` lookups): `aca login --token` sent the raw `aca_` token straight to `/rest/v1/*`, which PostgREST rejects outright (`Expected 3 parts in JWT; got 1`) since it isn't a signed JWT — this affected every Google sign-in user, i.e. the CLI's own recommended login path.
|
|
9
|
+
- `getAccessToken()` now exchanges the `aca_` token for a short-lived real Supabase session via a new `cli-token-exchange` edge function, and caches it until it's near expiry. Everything downstream (PostgREST and edge-function calls alike) now gets a token it actually accepts.
|
|
10
|
+
- The 0.5.0 note that `aca sequence ls` couldn't exist because "listing goes through PostgREST, which only accepts JWTs" no longer applies — that limitation is what this fixes.
|
|
11
|
+
|
|
12
|
+
## [0.5.0] - 2026-08-07
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
- **`aca sequence duplicate <id>`**: copy an email sequence — steps, settings, mailbox pool, tracking domain and enrollment filter — optionally with its audience. `--with-lists` attaches the same lead lists (and their auto-enroll setup); `--with-leads` re-enrols the leads currently in the source. `--name` overrides the default `"<source> (copy)"`.
|
|
16
|
+
- The copy is always created as a **draft**, so duplicating never starts sending.
|
|
17
|
+
- `--with-leads` runs the full enrollment path, so unsubscribed/bounced leads and leads already active in another sequence are skipped — the command reports each bucket. It pages the source (1000 leads per request) and prints progress; ~15s per page, so a 13k-lead sequence takes a few minutes. Every page is durable, so interrupting it leaves correct data behind.
|
|
18
|
+
- Backed by a new `duplicate-email-sequence` edge function and a `sourceSequenceId` mode on `enroll-leads`, both shared with the app UI and the `duplicate_email_sequence` MCP tool.
|
|
19
|
+
|
|
20
|
+
### Note
|
|
21
|
+
There was intentionally no `aca sequence ls` — listing went through PostgREST, which only accepted JWTs, not the `aca_` API tokens this CLI recommends. Fixed in 0.6.0.
|
|
22
|
+
|
|
5
23
|
## [0.4.0] - 2026-07-18
|
|
6
24
|
|
|
7
25
|
### Added
|
package/README.md
CHANGED
|
@@ -83,6 +83,13 @@ aca campaign leads <campaignId> --stuck --json | jq '.[] | .contact_id'
|
|
|
83
83
|
| `aca campaign status <id>` | Aggregate progress counts (pending, replied, failed, etc.). |
|
|
84
84
|
| `aca campaign leads <id> --stuck` | List stuck leads (status: failed or sender_disconnected). |
|
|
85
85
|
|
|
86
|
+
### Email sequences
|
|
87
|
+
| Command | What it does |
|
|
88
|
+
|---|---|
|
|
89
|
+
| `aca sequence duplicate <id>` | Copy a sequence (steps, settings, mailbox pool, tracking domain). Always lands as a **draft**. |
|
|
90
|
+
| `aca sequence duplicate <id> --with-lists` | ...and attach the same lead lists (auto-enroll + enrollment filter travel with them). |
|
|
91
|
+
| `aca sequence duplicate <id> --with-leads` | ...and re-enrol the leads currently in the source. Unsubscribed/bounced leads, and leads already active in another sequence, are skipped and reported. Pages through the source, so a large audience takes a few minutes. |
|
|
92
|
+
|
|
86
93
|
### Contacts
|
|
87
94
|
| Command | What it does |
|
|
88
95
|
|---|---|
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { invokeFn } from '../api.js';
|
|
2
|
+
import { output } from '../output.js';
|
|
3
|
+
export function registerSequence(program) {
|
|
4
|
+
const sequence = program.command('sequence').description('Duplicate email sequences');
|
|
5
|
+
sequence
|
|
6
|
+
.command('duplicate')
|
|
7
|
+
.description('Copy a sequence — steps and settings, optionally its audience')
|
|
8
|
+
.argument('<sequenceId>')
|
|
9
|
+
.option('-n, --name <name>', 'Name for the copy (default: "<source> (copy)")')
|
|
10
|
+
.option('--with-lists', 'Attach the same lead lists (carries auto-enroll + enrollment filter)')
|
|
11
|
+
.option('--with-leads', 'Enroll the leads currently in the source sequence')
|
|
12
|
+
.option('--json', 'Emit JSON')
|
|
13
|
+
.action(async (sequenceId, opts) => {
|
|
14
|
+
const dup = await invokeFn('duplicate-email-sequence', {
|
|
15
|
+
sequenceId,
|
|
16
|
+
name: opts.name,
|
|
17
|
+
copyLeadLists: opts.withLists === true,
|
|
18
|
+
});
|
|
19
|
+
let totals = null;
|
|
20
|
+
if (opts.withLeads) {
|
|
21
|
+
const running = {
|
|
22
|
+
enrolled: 0,
|
|
23
|
+
suppressed: 0,
|
|
24
|
+
alreadyInAnotherSequence: 0,
|
|
25
|
+
noEmail: 0,
|
|
26
|
+
leadsWithoutContact: 0,
|
|
27
|
+
};
|
|
28
|
+
totals = running;
|
|
29
|
+
let offset = 0;
|
|
30
|
+
for (;;) {
|
|
31
|
+
const page = await invokeFn('enroll-leads', {
|
|
32
|
+
sequenceId: dup.sequence.id,
|
|
33
|
+
sourceSequenceId: sequenceId,
|
|
34
|
+
sourceOffset: offset,
|
|
35
|
+
});
|
|
36
|
+
running.enrolled += page.enrolled ?? 0;
|
|
37
|
+
running.suppressed += page.suppressed ?? 0;
|
|
38
|
+
running.alreadyInAnotherSequence += page.alreadyInAnotherSequence ?? 0;
|
|
39
|
+
running.noEmail += page.noEmail ?? 0;
|
|
40
|
+
running.leadsWithoutContact += page.leadsWithoutContact ?? 0;
|
|
41
|
+
if (!page.sourceCursor || page.sourceCursor.done)
|
|
42
|
+
break;
|
|
43
|
+
offset = page.sourceCursor.offset;
|
|
44
|
+
if (!opts.json) {
|
|
45
|
+
process.stderr.write(` …${offset} leads scanned, ${running.enrolled} enrolled\n`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const result = {
|
|
50
|
+
id: dup.sequence.id,
|
|
51
|
+
name: dup.sequence.name,
|
|
52
|
+
status: dup.sequence.status,
|
|
53
|
+
...(totals
|
|
54
|
+
? {
|
|
55
|
+
enrolled: totals.enrolled,
|
|
56
|
+
skipped_suppressed: totals.suppressed,
|
|
57
|
+
skipped_active_elsewhere: totals.alreadyInAnotherSequence,
|
|
58
|
+
skipped_no_email: totals.noEmail,
|
|
59
|
+
skipped_no_crm_contact: totals.leadsWithoutContact,
|
|
60
|
+
}
|
|
61
|
+
: {}),
|
|
62
|
+
};
|
|
63
|
+
output(result, { json: opts.json });
|
|
64
|
+
});
|
|
65
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -8,13 +8,14 @@ import { registerLeads } from './commands/leads.js';
|
|
|
8
8
|
import { registerInbox } from './commands/inbox.js';
|
|
9
9
|
import { registerReply } from './commands/reply.js';
|
|
10
10
|
import { registerCampaign } from './commands/campaign.js';
|
|
11
|
+
import { registerSequence } from './commands/sequence.js';
|
|
11
12
|
import { registerContact } from './commands/contact.js';
|
|
12
13
|
import { registerSignals } from './commands/signals.js';
|
|
13
14
|
import { registerAutopilot } from './commands/autopilot.js';
|
|
14
15
|
import { registerConfig } from './commands/config.js';
|
|
15
16
|
import { registerCompletion } from './commands/completion.js';
|
|
16
17
|
import { maybeCheckForUpdate } from './update-check.js';
|
|
17
|
-
const VERSION = '0.
|
|
18
|
+
const VERSION = '0.5.0';
|
|
18
19
|
const program = new Command();
|
|
19
20
|
program
|
|
20
21
|
.name('aca')
|
|
@@ -28,6 +29,7 @@ registerLeads(program);
|
|
|
28
29
|
registerInbox(program);
|
|
29
30
|
registerReply(program);
|
|
30
31
|
registerCampaign(program);
|
|
32
|
+
registerSequence(program);
|
|
31
33
|
registerContact(program);
|
|
32
34
|
registerSignals(program);
|
|
33
35
|
registerAutopilot(program);
|
package/dist/session.js
CHANGED
|
@@ -89,13 +89,38 @@ async function refreshJwt(session) {
|
|
|
89
89
|
writeSession(next);
|
|
90
90
|
return next;
|
|
91
91
|
}
|
|
92
|
+
async function exchangeApiToken(apiToken) {
|
|
93
|
+
const res = await fetch(`${SUPABASE_URL}/functions/v1/cli-token-exchange`, {
|
|
94
|
+
method: 'POST',
|
|
95
|
+
headers: { apikey: SUPABASE_ANON_KEY, Authorization: `Bearer ${apiToken}` },
|
|
96
|
+
});
|
|
97
|
+
if (!res.ok) {
|
|
98
|
+
const body = await res.text();
|
|
99
|
+
throw new Error(`Token exchange failed (${res.status}): ${body}`);
|
|
100
|
+
}
|
|
101
|
+
const data = (await res.json());
|
|
102
|
+
if (!data.access_token) {
|
|
103
|
+
throw new Error('Token exchange returned no access token');
|
|
104
|
+
}
|
|
105
|
+
return { access_token: data.access_token, expires_in: data.expires_in ?? 3600 };
|
|
106
|
+
}
|
|
92
107
|
export async function getAccessToken() {
|
|
93
108
|
const session = readSession();
|
|
94
109
|
if (!session?.access_token) {
|
|
95
110
|
throw new Error('Not logged in. Run `aca login` first.');
|
|
96
111
|
}
|
|
97
112
|
if (session.auth_method === 'api_token') {
|
|
98
|
-
|
|
113
|
+
const now = Math.floor(Date.now() / 1000);
|
|
114
|
+
if (session.derived_access_token && session.derived_expires_at && session.derived_expires_at - now > 60) {
|
|
115
|
+
return session.derived_access_token;
|
|
116
|
+
}
|
|
117
|
+
const derived = await exchangeApiToken(session.access_token);
|
|
118
|
+
writeSession({
|
|
119
|
+
...session,
|
|
120
|
+
derived_access_token: derived.access_token,
|
|
121
|
+
derived_expires_at: Math.floor(Date.now() / 1000) + derived.expires_in,
|
|
122
|
+
});
|
|
123
|
+
return derived.access_token;
|
|
99
124
|
}
|
|
100
125
|
const now = Math.floor(Date.now() / 1000);
|
|
101
126
|
if (session.expires_at && session.expires_at - now < 60) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seguelac/aca-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.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": {
|