@seguelac/aca-cli 0.10.0 → 0.11.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,16 @@
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.11.0] - 2026-12-01
6
+
7
+ ### Added
8
+ - **Workspace memory**: `aca context` prints what ACA knows about the business (sections, Brand Kit, competitors, recent log, open work); `aca context set|unset <section>`, `aca context competitor add|rm`, and `aca log ls|add` for research, learnings and decisions. Backed by `/v1/context`.
9
+ - **Content slots**: `aca formats ls|show` (formats are the blueprints Claude writes from) and `aca slots ls|fill`, to write the posts slot autopilots order and put them in the Scheduler.
10
+ - **Agent task queue**: `aca work` (`ls`, `next --claim`, `show`, `done`, `skip`, `release`) and `aca media upload` (files to public URLs), backed by `/v1/agent`.
11
+ - **`aca carousel render`**: turns slides you wrote into branded images (template renderer, no model call) for use in slots and tasks.
12
+ - `aca lists members --offset`, ordered stably for paging past 1,000 rows.
13
+ - **`aca plusvibe`**: PlusVibe from the terminal. `ls`, `campaigns`, `create` (a campaign from an ACA email sequence), `launch`, `pause`, `archive`, `rename`, `sync`, `push` (contact ids or a lead list), `mailboxes`, `warmup` and `add-mailboxes`. Backed by the `plusvibe-campaigns`, `plusvibe-mailboxes` and `push-to-plusvibe` edge functions; with one PlusVibe workspace, `--connection` can be left out.
14
+
5
15
  ## [0.10.0] - 2026-12-01
6
16
 
7
17
  ### Added
package/README.md CHANGED
@@ -126,6 +126,39 @@ Schedule, approve and track posts on every channel (Instagram, Facebook, TikTok,
126
126
 
127
127
  A post that would fail on a platform (Instagram with no picture, X over 280 characters) is refused with the reason, unless you save it with `--draft`.
128
128
 
129
+ ### Agent work: memory, slots and tasks
130
+ What your own Claude reads before it works for the business, and the work waiting for it. Nothing here calls a model.
131
+
132
+ | Command | What it does |
133
+ |---|---|
134
+ | `aca context` | What ACA knows: business, offers, positioning, goal, writing rules, channels, Brand Kit, competitors, recent log, open work. `--json`. |
135
+ | `aca context set offers --file offers.md` | Write a section (`business_overview`, `offers`, `positioning`, `current_goal`, `writing_rules`, `channels`, or a custom slug with `--title`). |
136
+ | `aca context competitor add clay.com --notes "…"` / `rm <domain>` | Competitors in memory. |
137
+ | `aca log ls --kind learning` / `aca log add decision "…"` | The research, learnings and decisions log. |
138
+ | `aca formats ls` / `show <id>` | Formats: the prompts and render settings Claude writes posts from. |
139
+ | `aca slots ls --json` / `aca slots fill <id> --caption-file post.md --image <url>` | Posts slot autopilots ordered, and filling one into the Scheduler. |
140
+ | `aca work` / `aca work next --claim` | The task queue: slots to fill, replies to draft. Claimed tasks are yours for 30 minutes. |
141
+ | `aca work done <id> --file result.json` / `skip <id> --reason "…"` / `release <id>` | Finish, skip or hand back a task. |
142
+ | `aca media upload a.png b.mp4` | Upload files and print their public URLs. |
143
+ | `aca carousel render --file slides.json --theme noir` | Render slides you wrote into branded images. |
144
+
145
+ ### PlusVibe
146
+ Run PlusVibe from ACA once it's connected in Settings > Integrations. Every command takes `--connection <id>`, needed only when the organization has several PlusVibe workspaces.
147
+
148
+ | Command | What it does |
149
+ |---|---|
150
+ | `aca plusvibe ls` | PlusVibe connections, with reply sync and the last alert. |
151
+ | `aca plusvibe campaigns` | Campaigns with leads, sent, replied, positive and bounced. |
152
+ | `aca plusvibe create -s <sequenceId>` | Build a campaign from an ACA email sequence (paused). `-n`, `--accounts <ids>`, `--launch`, `--preview`. |
153
+ | `aca plusvibe launch <id>` / `pause <id>` / `archive <id>` / `rename <id> -n "…"` | Campaign status and name. |
154
+ | `aca plusvibe sync <id>` | Re-send the steps from the ACA sequence the campaign was built from. |
155
+ | `aca plusvibe push -c <campaignId> -l <listId>` | Add a lead list (or `--contacts <ids>`) to a campaign, max 1000. `--skip-existing`. |
156
+ | `aca plusvibe mailboxes --days 14` | Sending accounts with warmup inbox/spam rates and sending stats. |
157
+ | `aca plusvibe warmup on <accountIds>` | Turn warmup on or off. |
158
+ | `aca plusvibe add-mailboxes -m <mailboxIds> --warmup` | Send ACA mailboxes' SMTP/IMAP logins to PlusVibe as sending accounts. |
159
+
160
+ Replies to PlusVibe campaigns land in the ACA inbox; `aca reply` answers them through PlusVibe.
161
+
129
162
  ### Config & completion
130
163
  | Command | What it does |
131
164
  |---|---|
@@ -0,0 +1,54 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { invokeFn } from '../api.js';
3
+ import { readConfig } from '../config.js';
4
+ import { output, fail } from '../output.js';
5
+ const THEMES = ['creator', 'editorial', 'noir', 'halftone', 'brutalist', 'spotlight'];
6
+ export function registerCarousel(program) {
7
+ const carousel = program.command('carousel').description('Template carousels: render slides you wrote into branded images');
8
+ carousel
9
+ .command('render')
10
+ .description('Render slides (JSON file: [{ "heading": "…", "body": "…" }, …]) and print each slide URL in order')
11
+ .requiredOption('--file <path>', 'Slides JSON: an array, or { "slides": [...] }')
12
+ .option('--theme <theme>', `Theme: ${THEMES.join(', ')} (a format's carousel.carousel_template)`, 'creator')
13
+ .option('--aspect <ratio>', 'portrait (4:5), square or story', 'portrait')
14
+ .option('--brand-voice <id>', "Use this brand voice's colors")
15
+ .option('--author <name>', 'Author name on the slides')
16
+ .option('--handle <handle>', 'Author handle on the slides')
17
+ .option('--organization <id>', 'Org (default: the active one)')
18
+ .option('--json', 'Emit JSON')
19
+ .action(async (opts) => {
20
+ const organization_id = opts.organization || readConfig().active_org_id;
21
+ if (!organization_id)
22
+ fail('No active organization. Run `aca org switch <id>` or pass --organization.');
23
+ let parsed;
24
+ try {
25
+ parsed = JSON.parse(readFileSync(opts.file, 'utf8'));
26
+ }
27
+ catch {
28
+ fail(`${opts.file} is not a readable JSON file`);
29
+ }
30
+ const slides = (Array.isArray(parsed) ? parsed : parsed?.slides);
31
+ if (!Array.isArray(slides) || !slides.length)
32
+ fail('The file needs an array of slides: [{ "heading": "…", "body": "…" }]');
33
+ if (slides.length > 20)
34
+ fail('At most 20 slides');
35
+ const result = await invokeFn('render-carousel-standalone', {
36
+ organization_id,
37
+ slides,
38
+ template: opts.theme,
39
+ aspect_ratio: opts.aspect,
40
+ brand_voice_id: opts.brandVoice,
41
+ author_name: opts.author,
42
+ author_handle: opts.handle,
43
+ });
44
+ if (!result.success)
45
+ fail(result.error || 'Render failed');
46
+ const urls = result.slides.sort((a, b) => a.slide_number - b.slide_number).map((s) => s.url);
47
+ if (urls.length < slides.length)
48
+ console.error(`warning: ${slides.length - urls.length} slide(s) failed to upload`);
49
+ if (opts.json)
50
+ return output({ images: urls }, { json: true });
51
+ for (const u of urls)
52
+ console.log(u);
53
+ });
54
+ }
@@ -0,0 +1,126 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { fnRequest } from '../api.js';
3
+ import { output, fail } from '../output.js';
4
+ import { parseList, readStdinIfPiped } from '../util.js';
5
+ const FN = 'api-context';
6
+ const TYPED = ['business_overview', 'offers', 'positioning', 'current_goal', 'writing_rules', 'channels'];
7
+ const logRow = (e) => ({
8
+ when: e.created_at.slice(0, 16).replace('T', ' '),
9
+ kind: e.kind,
10
+ summary: e.summary.replace(/\s+/g, ' ').slice(0, 90),
11
+ tags: e.tags.join(','),
12
+ by: e.created_by_label ?? '',
13
+ });
14
+ async function readContent(opts) {
15
+ if (opts.content !== undefined)
16
+ return opts.content;
17
+ if (opts.file)
18
+ return readFileSync(opts.file, 'utf8');
19
+ const piped = await readStdinIfPiped();
20
+ if (piped === null || piped === undefined)
21
+ fail('Give the text: --content, --file, or pipe it in');
22
+ return piped;
23
+ }
24
+ export function registerContext(program) {
25
+ const context = program
26
+ .command('context')
27
+ .description('Workspace memory: what the AI knows about this business (read it first)')
28
+ .option('--json', 'Emit the full digest as JSON (what agents read)')
29
+ .action(async (opts) => {
30
+ const d = await fnRequest('GET', FN);
31
+ if (opts.json)
32
+ return output(d, { json: true });
33
+ console.log(`# ${d.organization.name ?? d.organization.id}\n`);
34
+ for (const s of [...d.sections, ...d.custom_sections]) {
35
+ console.log(`## ${s.title} (${s.slug})${s.content ? '' : ' · empty'}`);
36
+ if (s.content)
37
+ console.log(`${s.content}\n`);
38
+ }
39
+ if (d.competitors.length)
40
+ console.log(`Competitors: ${d.competitors.map((c) => c.domain).join(', ')}`);
41
+ for (const [kind, items] of Object.entries(d.brand_kit)) {
42
+ if (items.length)
43
+ console.log(`${kind}: ${items.map((i) => `${i.name}${i.default ? ' (default)' : ''}`).join(', ')}`);
44
+ }
45
+ const work = Object.entries(d.open_work).map(([k, n]) => `${n} ${k}`).join(', ');
46
+ if (work)
47
+ console.log(`Open work: ${work}`);
48
+ if (d.missing_sections.length)
49
+ console.log(`Empty: ${d.missing_sections.join(', ')} (fill with \`aca context set\` or /aca:setup)`);
50
+ if (d.recent_log.length) {
51
+ console.log('\nRecent log:');
52
+ output(d.recent_log.slice(0, 10).map(logRow));
53
+ }
54
+ });
55
+ context
56
+ .command('set')
57
+ .description(`Write a section: ${TYPED.join(', ')}, or any custom slug with --title`)
58
+ .argument('<section>')
59
+ .option('--content <text>', 'The section text (or --file, or pipe it in)')
60
+ .option('--file <path>', 'Read the text from a file')
61
+ .option('--title <text>', 'Title, for a custom section')
62
+ .option('--json', 'Emit JSON')
63
+ .action(async (section, opts) => {
64
+ const content = await readContent(opts);
65
+ const op = TYPED.includes(section) ? { section, content } : { custom_section: section, content, ...(opts.title ? { title: opts.title } : {}) };
66
+ output(await fnRequest('PATCH', FN, {}, { ops: [op] }), { json: opts.json });
67
+ });
68
+ context
69
+ .command('unset')
70
+ .description('Remove a custom section (typed sections: `aca context set <slug> --content ""`)')
71
+ .argument('<slug>')
72
+ .action(async (slug) => {
73
+ output(await fnRequest('PATCH', FN, {}, { ops: [{ remove_custom_section: slug }] }));
74
+ });
75
+ const competitor = context.command('competitor').description('Competitors in workspace memory');
76
+ competitor
77
+ .command('add')
78
+ .argument('<domain>')
79
+ .option('--name <name>')
80
+ .option('--notes <text>', 'What they claim, how we answer it')
81
+ .action(async (domain, opts) => {
82
+ output(await fnRequest('PATCH', FN, {}, { ops: [{ add_competitors: [{ domain, name: opts.name, notes: opts.notes }] }] }));
83
+ });
84
+ competitor
85
+ .command('rm')
86
+ .argument('<domain>')
87
+ .action(async (domain) => {
88
+ output(await fnRequest('PATCH', FN, {}, { ops: [{ remove_competitor: domain }] }));
89
+ });
90
+ const log = program.command('log').description('Workspace log: research, learnings and decisions');
91
+ log
92
+ .command('ls')
93
+ .description('Newest first')
94
+ .option('--kind <kind>', 'research, learning or decision')
95
+ .option('--query <words>', 'Words that must all appear')
96
+ .option('--tag <tag>')
97
+ .option('--since <days|date>', 'e.g. 30, or 2026-11-01')
98
+ .option('--limit <n>', 'Max entries (max 100)', '20')
99
+ .option('--json', 'Emit JSON')
100
+ .action(async (opts) => {
101
+ const data = await fnRequest('GET', FN, { resource: 'log', kind: opts.kind, query: opts.query, tag: opts.tag, since: opts.since, limit: opts.limit });
102
+ if (opts.json)
103
+ return output(data, { json: true });
104
+ output(data.entries.map(logRow));
105
+ });
106
+ log
107
+ .command('add')
108
+ .description('Add an entry (summary as argument, --file, or piped)')
109
+ .argument('<kind>', 'research, learning or decision')
110
+ .argument('[summary]')
111
+ .option('--file <path>', 'Read the summary from a file')
112
+ .option('--tags <list>', 'Comma-separated slugs, e.g. reply,linkedin')
113
+ .option('--ref <key=id>', 'An id it is about, e.g. campaign_id=... (repeatable)', (v, prev = []) => [...prev, v])
114
+ .option('--json', 'Emit JSON')
115
+ .action(async (kind, summary, opts) => {
116
+ const text = summary ?? (await readContent({ file: opts.file }));
117
+ const refs = {};
118
+ for (const r of opts.ref ?? []) {
119
+ const i = r.indexOf('=');
120
+ if (i < 1)
121
+ fail(`--ref needs key=id, got "${r}"`);
122
+ refs[r.slice(0, i)] = r.slice(i + 1);
123
+ }
124
+ output(await fnRequest('POST', FN, { resource: 'log' }, { kind, summary: text, tags: opts.tags ? parseList(opts.tags) : undefined, refs }), { json: opts.json });
125
+ });
126
+ }
@@ -42,10 +42,11 @@ export function registerLists(program) {
42
42
  .command('members')
43
43
  .description('List members of a lead list')
44
44
  .requiredOption('-l, --list <listId>', 'Lead list ID')
45
- .option('--limit <n>', 'Max rows', '50')
45
+ .option('--limit <n>', 'Max rows (the API caps a page at 1000)', '50')
46
+ .option('--offset <n>', 'Rows to skip, for paging past 1000', '0')
46
47
  .option('--json', 'Emit JSON')
47
48
  .action(async (opts) => {
48
- const rows = await restGet(`lead_list_members?list_id=eq.${opts.list}&select=contact_id,added_at,crm_contacts(id,display_name,primary_email,primary_linkedin_url,company)&order=added_at.desc&limit=${opts.limit}`);
49
+ const rows = await restGet(`lead_list_members?list_id=eq.${opts.list}&select=contact_id,added_at,crm_contacts(id,display_name,primary_email,primary_linkedin_url,company)&order=added_at.desc,contact_id.asc&limit=${opts.limit}&offset=${opts.offset}`);
49
50
  output(rows, { json: opts.json });
50
51
  });
51
52
  lists
@@ -0,0 +1,175 @@
1
+ import { invokeFn } from '../api.js';
2
+ import { output, fail } from '../output.js';
3
+ const csv = (v) => (v ? v.split(',').map((s) => s.trim()).filter(Boolean) : undefined);
4
+ const pct = (v) => (typeof v === 'number' ? `${Math.round(v * 10) / 10}%` : '');
5
+ function common(cmd) {
6
+ return cmd
7
+ .option('--connection <id>', 'PlusVibe connection id (needed only with several; see `aca plusvibe ls`)')
8
+ .option('--json', 'Emit JSON');
9
+ }
10
+ export function registerPlusVibe(program) {
11
+ const pv = program.command('plusvibe').description('PlusVibe: campaigns, lead pushes, sending accounts');
12
+ common(pv.command('ls').description('List PlusVibe connections in the active organization (one per workspace)')).action(async (opts) => {
13
+ const { connections: list } = await invokeFn('plusvibe-campaigns', { action: 'connections' });
14
+ if (opts.json)
15
+ return output(list, { json: true });
16
+ output(list.map((c) => ({
17
+ id: c.id,
18
+ workspace: c.workspaceName ?? c.workspaceId ?? '(none, reconnect)',
19
+ reply_sync: c.replySync ? 'on' : 'off',
20
+ last_webhook: c.lastWebhookAt ? new Date(c.lastWebhookAt).toLocaleString() : '',
21
+ alert: c.error || c.lastAlert?.alert || '',
22
+ })));
23
+ });
24
+ common(pv.command('campaigns').description('List PlusVibe campaigns with stats')).action(async (opts) => {
25
+ const connectionId = opts.connection;
26
+ const res = await invokeFn('plusvibe-campaigns', { action: 'list', connectionId });
27
+ if (opts.json)
28
+ return output(res.campaigns, { json: true });
29
+ output(res.campaigns.map((c) => ({
30
+ id: c.id,
31
+ name: c.name,
32
+ status: c.status,
33
+ leads: c.stats?.leads ?? '',
34
+ sent: c.stats?.sent ?? '',
35
+ replied: c.stats?.replied ?? '',
36
+ positive: c.stats?.positive ?? '',
37
+ bounced: c.stats?.bounced ?? '',
38
+ sequence: c.linkedSequence?.name ?? '',
39
+ })));
40
+ });
41
+ common(pv
42
+ .command('create')
43
+ .description('Create a PlusVibe campaign from an ACA email sequence (paused unless --launch)')
44
+ .requiredOption('-s, --sequence <id>', 'ACA email sequence id')
45
+ .option('-n, --name <name>', 'Campaign name (defaults to the sequence name)')
46
+ .option('--accounts <ids>', 'PlusVibe sending account ids, comma-separated (see `aca plusvibe mailboxes`)')
47
+ .option('--launch', 'Launch right away')
48
+ .option('--preview', 'Only show the translated steps and warnings; create nothing')).action(async (opts) => {
49
+ const connectionId = opts.connection;
50
+ if (opts.preview) {
51
+ const res = await invokeFn('plusvibe-campaigns', { action: 'preview_sequence', connectionId, sequenceId: opts.sequence });
52
+ return output(res, { json: true });
53
+ }
54
+ const res = await invokeFn('plusvibe-campaigns', { action: 'create_from_sequence', connectionId, sequenceId: opts.sequence, name: opts.name, emailAccountIds: csv(opts.accounts), launch: !!opts.launch });
55
+ if (opts.json)
56
+ return output(res, { json: true });
57
+ console.log(`Created "${res.name}" (${res.campaignId}), ${res.steps} step(s), ${res.launched ? 'launched' : 'paused'}.`);
58
+ if (res.launchError)
59
+ console.log(`Launch failed: ${res.launchError}`);
60
+ for (const w of res.warnings ?? [])
61
+ console.log(` note: ${w}`);
62
+ });
63
+ for (const [name, description] of [
64
+ ['launch', 'Launch a PlusVibe campaign'],
65
+ ['pause', 'Pause a PlusVibe campaign'],
66
+ ['archive', 'Archive a PlusVibe campaign'],
67
+ ['sync', 'Re-sync a campaign\'s steps from the ACA sequence it was built from'],
68
+ ]) {
69
+ common(pv.command(name).description(description).argument('<campaignId>')).action(async (campaignId, opts) => {
70
+ const connectionId = opts.connection;
71
+ const res = await invokeFn('plusvibe-campaigns', {
72
+ action: name === 'sync' ? 'sync_sequence' : name,
73
+ connectionId,
74
+ campaignId,
75
+ });
76
+ if (opts.json)
77
+ return output(res, { json: true });
78
+ console.log(name === 'sync' ? `Synced ${res.steps ?? ''} step(s).` : `Campaign ${campaignId}: ${name} done.`);
79
+ for (const w of res.warnings ?? [])
80
+ console.log(` note: ${w}`);
81
+ });
82
+ }
83
+ common(pv.command('rename').description('Rename a PlusVibe campaign').argument('<campaignId>').requiredOption('-n, --name <name>', 'New name')).action(async (campaignId, opts) => {
84
+ const connectionId = opts.connection;
85
+ const res = await invokeFn('plusvibe-campaigns', { action: 'rename', connectionId, campaignId, name: opts.name });
86
+ if (opts.json)
87
+ return output(res, { json: true });
88
+ console.log(`Renamed to "${opts.name}".`);
89
+ });
90
+ common(pv
91
+ .command('push')
92
+ .description('Add ACA contacts to a PlusVibe campaign (max 1000 per call)')
93
+ .requiredOption('-c, --campaign <id>', 'PlusVibe campaign id (see `aca plusvibe campaigns`)')
94
+ .option('--contacts <ids>', 'ACA contact ids, comma-separated')
95
+ .option('-l, --list <id>', 'ACA lead list id (every member)')
96
+ .option('--skip-existing', 'Skip leads already anywhere in the PlusVibe workspace')).action(async (opts) => {
97
+ const contactIds = csv(opts.contacts);
98
+ if (!contactIds?.length && !opts.list)
99
+ fail('Pass --contacts <ids> or --list <id>.');
100
+ const connectionId = opts.connection;
101
+ const res = await invokeFn('push-to-plusvibe', {
102
+ connectionId,
103
+ campaignId: opts.campaign,
104
+ contactIds,
105
+ listId: opts.list,
106
+ skipIfInWorkspace: !!opts.skipExisting,
107
+ });
108
+ if (opts.json)
109
+ return output(res, { json: true });
110
+ output({
111
+ pushed: res.pushed,
112
+ already_in_campaign: res.alreadyInCampaign,
113
+ duplicates: res.duplicates,
114
+ invalid: res.invalid,
115
+ skipped_by_plusvibe: res.skipped,
116
+ not_sendable_in_aca: res.notSendable ?? 0,
117
+ remaining_in_plan: res.remainingInPlan ?? '',
118
+ });
119
+ });
120
+ common(pv.command('mailboxes').description('PlusVibe sending accounts with warmup and sending stats').option('--days <n>', 'Stats window, 1-90', '14')).action(async (opts) => {
121
+ const connectionId = opts.connection;
122
+ const res = await invokeFn('plusvibe-mailboxes', { action: 'list', connectionId, days: Number(opts.days) || 14 });
123
+ if (opts.json)
124
+ return output(res.accounts, { json: true });
125
+ output(res.accounts.map((a) => ({
126
+ id: a.id,
127
+ email: a.email,
128
+ status: a.status ?? '',
129
+ warmup: a.warmupStatus ?? '',
130
+ inbox: pct(a.warmup?.inboxPercent),
131
+ spam: pct(a.warmup?.spamPercent),
132
+ sent: a.sending?.sent ?? '',
133
+ reply: pct(a.sending?.replyRate),
134
+ bounce: pct(a.sending?.bounceRate),
135
+ aca: a.acaMailbox ? 'yes' : '',
136
+ })));
137
+ });
138
+ common(pv
139
+ .command('warmup')
140
+ .description('Turn PlusVibe warmup on or off')
141
+ .argument('<state>', 'on or off')
142
+ .argument('<accountIds>', 'PlusVibe account ids, comma-separated')).action(async (state, accountIds, opts) => {
143
+ if (state !== 'on' && state !== 'off')
144
+ fail('State must be on or off.');
145
+ const connectionId = opts.connection;
146
+ const res = await invokeFn('plusvibe-mailboxes', { action: 'warmup', connectionId, accountIds: csv(accountIds), enable: state === 'on' });
147
+ if (opts.json)
148
+ return output(res, { json: true });
149
+ console.log(`Warmup ${state} for ${res.updated} account(s).`);
150
+ });
151
+ common(pv
152
+ .command('add-mailboxes')
153
+ .description('Send ACA mailboxes (their SMTP/IMAP logins) to PlusVibe as sending accounts')
154
+ .requiredOption('-m, --mailboxes <ids>', 'ACA mailbox ids, comma-separated')
155
+ .option('--warmup', 'Turn on PlusVibe warmup with ramp-up')
156
+ .option('--warmup-limit <n>', 'Warmup emails per day to start with', '20')
157
+ .option('--daily-limit <n>', 'Campaign daily limit (defaults to the ACA mailbox limit)')).action(async (opts) => {
158
+ const connectionId = opts.connection;
159
+ const res = await invokeFn('plusvibe-mailboxes', {
160
+ action: 'push',
161
+ connectionId,
162
+ mailboxIds: csv(opts.mailboxes),
163
+ enableWarmup: !!opts.warmup,
164
+ warmupDailyLimit: Number(opts.warmupLimit) || undefined,
165
+ dailyLimit: Number(opts.dailyLimit) || undefined,
166
+ });
167
+ if (opts.json)
168
+ return output(res, { json: true });
169
+ console.log(`Sent ${res.submitted} mailbox(es) to PlusVibe. PlusVibe adds them in the background and emails the results to the account owner.`);
170
+ for (const s of res.skipped)
171
+ console.log(` skipped ${s.email}: ${s.reason}`);
172
+ if (res.notFound)
173
+ console.log(` ${res.notFound} id(s) not found in this organization`);
174
+ });
175
+ }
@@ -3,7 +3,7 @@ import { fnRequest } from '../api.js';
3
3
  import { output, fail } from '../output.js';
4
4
  import { parseList, readStdinIfPiped } from '../util.js';
5
5
  const FN = 'api-scheduler';
6
- const collect = (value, previous = []) => [...previous, value];
6
+ export const collect = (value, previous = []) => [...previous, value];
7
7
  function row(p) {
8
8
  const s = p.stats;
9
9
  return {
@@ -18,7 +18,7 @@ function row(p) {
18
18
  error: p.error ? p.error.slice(0, 60) : '',
19
19
  };
20
20
  }
21
- async function readCaption(opts) {
21
+ export async function readCaption(opts) {
22
22
  if (opts.caption !== undefined)
23
23
  return opts.caption;
24
24
  if (opts.captionFile)
@@ -26,7 +26,7 @@ async function readCaption(opts) {
26
26
  const piped = await readStdinIfPiped();
27
27
  return piped ?? undefined;
28
28
  }
29
- function readCaptionsFor(values) {
29
+ export function readCaptionsFor(values) {
30
30
  if (!values?.length)
31
31
  return undefined;
32
32
  const out = {};
@@ -134,7 +134,7 @@ export function registerScheduler(program) {
134
134
  .description('Posts on the calendar (default: last 7 days and next 30)')
135
135
  .option('--from <datetime>', 'Window start')
136
136
  .option('--to <datetime>', 'Window end (at most 120 days after --from)')
137
- .option('--status <list>', 'draft,scheduled,publishing,published,failed')
137
+ .option('--status <list>', 'open,draft,scheduled,publishing,published,failed,skipped')
138
138
  .option('--platform <name>', 'instagram, linkedin, facebook, tiktok, twitter…')
139
139
  .option('--limit <n>', 'Max posts (max 200)', '50')
140
140
  .option('--json', 'Emit JSON')
@@ -0,0 +1,104 @@
1
+ import { fnRequest } from '../api.js';
2
+ import { output, fail } from '../output.js';
3
+ import { collect, readCaption, readCaptionsFor } from './scheduler.js';
4
+ const FN = 'api-scheduler';
5
+ export function registerFormats(program) {
6
+ const formats = program.command('formats').description('Formats: the prompt, kind, look and Brand Kit Claude writes with');
7
+ formats
8
+ .command('ls')
9
+ .description('List formats')
10
+ .option('--kind <kind>', 'text, image, carousel, video, article')
11
+ .option('--search <text>', 'Part of the name')
12
+ .option('--limit <n>', 'Max formats (max 200)', '50')
13
+ .option('--json', 'Emit JSON')
14
+ .action(async (opts) => {
15
+ const data = await fnRequest('GET', FN, { resource: 'formats', kind: opts.kind, search: opts.search, limit: opts.limit });
16
+ if (opts.json)
17
+ return output(data, { json: true });
18
+ output(data.formats.map((f) => ({ id: f.id, kind: f.kind, name: f.name, prompt: (f.prompt_preview ?? '').replace(/\s+/g, ' ').slice(0, 60) })));
19
+ if (data.total > data.formats.length)
20
+ console.log(`(${data.formats.length} of ${data.total}; raise --limit)`);
21
+ });
22
+ formats
23
+ .command('show')
24
+ .description('One format: full prompt, render settings, reference photos and resolved Brand Kit (JSON)')
25
+ .argument('<id>')
26
+ .action(async (id) => {
27
+ output(await fnRequest('GET', FN, { resource: 'formats', id }), { json: true });
28
+ });
29
+ }
30
+ export function registerSlots(program) {
31
+ const slots = program.command('slots').description('Open slots: posts autopilots ordered for Claude to write');
32
+ slots
33
+ .command('ls')
34
+ .description('Open slots, soonest first (--json gives format, idea and Brand Kit for each)')
35
+ .option('--autopilot <id>', "Only this autopilot's slots")
36
+ .option('--before <datetime>', 'Only slots due before this time')
37
+ .option('--limit <n>', 'Max slots (max 50)', '10')
38
+ .option('--json', 'Emit JSON (everything needed to write each post)')
39
+ .action(async (opts) => {
40
+ let before;
41
+ if (opts.before) {
42
+ const at = new Date(opts.before);
43
+ if (!Number.isFinite(at.getTime()))
44
+ fail(`--before is not a date: ${opts.before}`);
45
+ before = at.toISOString();
46
+ }
47
+ const data = await fnRequest('GET', FN, { resource: 'slots', autopilot_id: opts.autopilot, before, limit: opts.limit });
48
+ if (opts.json)
49
+ return output(data, { json: true });
50
+ output(data.slots.map((s) => ({
51
+ id: s.id,
52
+ when: s.scheduled_for.slice(0, 16).replace('T', ' '),
53
+ format: `${s.format.name ?? '?'} (${s.format.kind ?? '?'})`,
54
+ idea: (s.idea.title ?? '').slice(0, 50),
55
+ platforms: [...new Set(s.accounts.map((a) => a.platform))].join(','),
56
+ lands_as: s.autopilot?.lands_as ?? '',
57
+ })));
58
+ if (data.truncated)
59
+ console.log(`(${data.slots.length} of ${data.total}; raise --limit)`);
60
+ });
61
+ slots
62
+ .command('fill')
63
+ .description('Fill an open slot with the post you wrote')
64
+ .argument('<id>')
65
+ .option('--caption <text>', 'Caption for every platform (or --caption-file, or pipe it in)')
66
+ .option('--caption-file <path>', 'Read the caption from a file')
67
+ .option('--for <platform=text>', 'Caption for one platform (repeatable)', collect)
68
+ .option('--image <url>', 'Picture URL, https (repeatable, in order: carousel slides)', collect)
69
+ .option('--video <url>', 'One video URL, https')
70
+ .option('--first-comment <text>', 'Posted as the first comment (LinkedIn, Facebook, Instagram)')
71
+ .option('--story', 'Post Instagram/Facebook as a Story')
72
+ .option('--draft', 'Land as a draft to review, whatever the autopilot says')
73
+ .option('--scheduled', 'Go out at the slot time, whatever the autopilot says')
74
+ .option('--json', 'Emit JSON')
75
+ .action(async (id, opts) => {
76
+ const body = {};
77
+ const caption = await readCaption(opts);
78
+ if (caption !== undefined)
79
+ body.caption = caption;
80
+ const captions = readCaptionsFor(opts.for);
81
+ if (captions)
82
+ body.captions = captions;
83
+ if (body.caption === undefined && !captions)
84
+ fail('Give the post: --caption, --caption-file, --for or pipe it in');
85
+ if (opts.image?.length)
86
+ body.images = opts.image;
87
+ if (opts.video)
88
+ body.video = opts.video;
89
+ if (opts.firstComment !== undefined)
90
+ body.first_comment = opts.firstComment;
91
+ if (opts.story)
92
+ body.format = 'story';
93
+ if (opts.draft)
94
+ body.status = 'draft';
95
+ if (opts.scheduled)
96
+ body.status = 'scheduled';
97
+ const result = await fnRequest('POST', FN, { resource: 'slots', id, action: 'fill' }, body);
98
+ if (opts.json)
99
+ return output(result, { json: true });
100
+ console.log(`${result.post.id} ${result.post.status} ${result.post.scheduled_for.slice(0, 16).replace('T', ' ')}`);
101
+ for (const i of result.issues ?? [])
102
+ console.log(`fix before approving: ${i.message}`);
103
+ });
104
+ }
@@ -0,0 +1,166 @@
1
+ import { readFileSync, statSync } from 'node:fs';
2
+ import { basename } from 'node:path';
3
+ import { fnRequest } from '../api.js';
4
+ import { output, fail } from '../output.js';
5
+ const FN = 'api-agent-tasks';
6
+ function ago(iso) {
7
+ const mins = Math.round((Date.now() - new Date(iso).getTime()) / 60_000);
8
+ if (Math.abs(mins) < 60)
9
+ return mins >= 0 ? `${mins} min ago` : `in ${-mins} min`;
10
+ const hours = Math.round(mins / 60);
11
+ if (Math.abs(hours) < 48)
12
+ return hours >= 0 ? `${hours} h ago` : `in ${-hours} h`;
13
+ const days = Math.round(hours / 24);
14
+ return days >= 0 ? `${days} d ago` : `in ${-days} d`;
15
+ }
16
+ async function readJson(file) {
17
+ let text;
18
+ if (!file || file === '-') {
19
+ if (process.stdin.isTTY)
20
+ fail('Give the result: --file result.json (or pipe the JSON in)');
21
+ const chunks = [];
22
+ for await (const c of process.stdin)
23
+ chunks.push(c);
24
+ text = Buffer.concat(chunks).toString('utf8');
25
+ }
26
+ else {
27
+ try {
28
+ text = readFileSync(file, 'utf8');
29
+ }
30
+ catch {
31
+ fail(`Cannot read ${file}`);
32
+ }
33
+ }
34
+ try {
35
+ return JSON.parse(text);
36
+ }
37
+ catch {
38
+ fail(`${file && file !== '-' ? file : 'stdin'} is not valid JSON`);
39
+ }
40
+ }
41
+ export function registerWork(program) {
42
+ const work = program.command('work').description('The agent work queue: tasks waiting for your agent (fill slots…)');
43
+ work
44
+ .command('ls', { isDefault: true })
45
+ .description('Open and claimed tasks, due first')
46
+ .option('--kind <kinds>', 'Only these kinds, comma-separated (fill_slot, draft_reply, …)')
47
+ .option('--status <status>', 'open,claimed (default), done, skipped, cancelled or all')
48
+ .option('--limit <n>', 'Max tasks (max 200)', '50')
49
+ .option('--json', 'Emit JSON')
50
+ .action(async (opts) => {
51
+ const data = await fnRequest('GET', FN, {
52
+ resource: 'tasks', kind: opts.kind, status: opts.status, limit: opts.limit,
53
+ });
54
+ if (opts.json)
55
+ return output(data, { json: true });
56
+ output(data.tasks.map((t) => ({
57
+ id: t.id,
58
+ kind: t.kind,
59
+ due: t.due_at ? `${ago(t.due_at)}${t.overdue ? ' (overdue)' : ''}` : '',
60
+ status: t.status === 'claimed' && t.claim ? `claimed by ${t.claim.by}` : t.status,
61
+ title: t.title.slice(0, 60),
62
+ })));
63
+ if (data.total > data.tasks.length)
64
+ console.log(`(${data.tasks.length} of ${data.total}; raise --limit)`);
65
+ console.log(data.last_claim ? `Last claim: ${data.last_claim.by}, ${ago(data.last_claim.at)}` : 'No runner has claimed a task yet.');
66
+ });
67
+ work
68
+ .command('next')
69
+ .description('The next tasks with everything needed to do each (JSON). --claim takes them for 30 minutes')
70
+ .option('--kind <kinds>', 'Only these kinds, comma-separated')
71
+ .option('--limit <n>', 'Max tasks (max 20)', '3')
72
+ .option('--claim', 'Claim them so no other runner takes them (30-minute lease)')
73
+ .option('--due-before <datetime>', 'Only tasks due before this time')
74
+ .action(async (opts) => {
75
+ let due_before;
76
+ if (opts.dueBefore) {
77
+ const at = new Date(opts.dueBefore);
78
+ if (!Number.isFinite(at.getTime()))
79
+ fail(`--due-before is not a date: ${opts.dueBefore}`);
80
+ due_before = at.toISOString();
81
+ }
82
+ const data = await fnRequest('POST', FN, { resource: 'tasks', action: 'next' }, {
83
+ kinds: opts.kind ? opts.kind.split(',').map((k) => k.trim()).filter(Boolean) : undefined,
84
+ limit: Number(opts.limit),
85
+ claim: !!opts.claim,
86
+ due_before,
87
+ });
88
+ output(data, { json: true });
89
+ });
90
+ work
91
+ .command('show')
92
+ .description('One task with its context (JSON)')
93
+ .argument('<id>')
94
+ .action(async (id) => {
95
+ output(await fnRequest('GET', FN, { resource: 'tasks', id }), { json: true });
96
+ });
97
+ work
98
+ .command('done')
99
+ .description('Complete a task with its result. fill_slot: { "caption": "…", "images": ["https://…"] }')
100
+ .argument('<id>')
101
+ .option('--file <path>', 'Result JSON file (or - / pipe it in)')
102
+ .option('--json', 'Emit JSON')
103
+ .action(async (id, opts) => {
104
+ const result = await readJson(opts.file);
105
+ const data = await fnRequest('POST', FN, { resource: 'tasks', id, action: 'complete' }, { result });
106
+ if (opts.json)
107
+ return output(data, { json: true });
108
+ console.log(`${data.task.id} done${data.post_id ? ` post ${data.post_id} (${data.post_status})` : ''}`);
109
+ for (const i of data.issues ?? [])
110
+ console.log(`fix before approving: ${i.message}`);
111
+ });
112
+ work
113
+ .command('skip')
114
+ .description("Skip a task you won't do, with the reason (fill_slot: the slot is skipped, its idea goes back)")
115
+ .argument('<id>')
116
+ .requiredOption('--reason <text>', 'Why it is not worth doing')
117
+ .action(async (id, opts) => {
118
+ const data = await fnRequest('POST', FN, { resource: 'tasks', id, action: 'skip' }, { reason: opts.reason });
119
+ console.log(`${data.task.id} ${data.task.status}`);
120
+ });
121
+ work
122
+ .command('release')
123
+ .description('Give a claimed task back to the queue')
124
+ .argument('<id>')
125
+ .action(async (id) => {
126
+ const data = await fnRequest('POST', FN, { resource: 'tasks', id, action: 'release' }, {});
127
+ console.log(`${data.task.id} ${data.task.status}`);
128
+ });
129
+ }
130
+ const TYPES = {
131
+ png: 'image/png', jpg: 'image/jpeg', jpeg: 'image/jpeg', webp: 'image/webp', gif: 'image/gif', pdf: 'application/pdf',
132
+ mp4: 'video/mp4', mov: 'video/quicktime', webm: 'video/webm',
133
+ };
134
+ export function registerMedia(program) {
135
+ const media = program.command('media').description('Media for posts (pictures, carousel slides, videos)');
136
+ media
137
+ .command('upload')
138
+ .description('Upload files and print their public URLs (25 MB per image, 200 MB per video)')
139
+ .argument('<files...>')
140
+ .option('--json', 'Emit JSON')
141
+ .action(async (files, opts) => {
142
+ const uploaded = [];
143
+ for (const file of files) {
144
+ let size;
145
+ try {
146
+ size = statSync(file).size;
147
+ }
148
+ catch {
149
+ fail(`Cannot read ${file}`);
150
+ }
151
+ const ext = (file.match(/\.([a-z0-9]+)$/i)?.[1] ?? '').toLowerCase();
152
+ const contentType = TYPES[ext];
153
+ if (!contentType)
154
+ fail(`${file}: unsupported type. Upload png, jpg, webp, gif, pdf, mp4, mov or webm.`);
155
+ const target = await fnRequest('POST', FN, { resource: 'media' }, { filename: basename(file), size: size, content_type: contentType });
156
+ const res = await fetch(target.upload_url, { method: 'PUT', headers: target.headers, body: readFileSync(file) });
157
+ if (!res.ok)
158
+ fail(`${file}: upload failed (${res.status}) ${(await res.text()).slice(0, 200)}`);
159
+ uploaded.push({ file, url: target.public_url });
160
+ }
161
+ if (opts.json)
162
+ return output(uploaded, { json: true });
163
+ for (const u of uploaded)
164
+ console.log(u.url);
165
+ });
166
+ }
package/dist/index.js CHANGED
@@ -18,6 +18,11 @@ import { registerSignals } from './commands/signals.js';
18
18
  import { registerAutopilot } from './commands/autopilot.js';
19
19
  import { registerMessaging } from './commands/messaging.js';
20
20
  import { registerScheduler } from './commands/scheduler.js';
21
+ import { registerPlusVibe } from './commands/plusvibe.js';
22
+ import { registerFormats, registerSlots } from './commands/slots.js';
23
+ import { registerMedia, registerWork } from './commands/work.js';
24
+ import { registerCarousel } from './commands/carousel.js';
25
+ import { registerContext } from './commands/context.js';
21
26
  import { registerCreative } from './commands/creative.js';
22
27
  import { registerConfig } from './commands/config.js';
23
28
  import { registerCompletion } from './commands/completion.js';
@@ -45,6 +50,13 @@ registerSignals(program);
45
50
  registerAutopilot(program);
46
51
  registerMessaging(program);
47
52
  registerScheduler(program);
53
+ registerPlusVibe(program);
54
+ registerFormats(program);
55
+ registerSlots(program);
56
+ registerWork(program);
57
+ registerMedia(program);
58
+ registerCarousel(program);
59
+ registerContext(program);
48
60
  registerCreative(program);
49
61
  registerConfig(program);
50
62
  registerCompletion(program);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seguelac/aca-cli",
3
- "version": "0.10.0",
3
+ "version": "0.11.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": {