@curviate/cli 0.47.0 → 0.49.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 (48) hide show
  1. package/CHANGELOG.md +231 -1
  2. package/README.md +136 -88
  3. package/dist/{account-RFJ63QYL.js → account-2BH2Q6VG.js} +41 -31
  4. package/dist/chunk-3RCW7URJ.js +41 -0
  5. package/dist/{chunk-UJOTQPL6.js → chunk-5ZGTU4VD.js} +47 -14
  6. package/dist/chunk-D2S5OCYU.js +38 -0
  7. package/dist/{chunk-HOQ7EUHJ.js → chunk-FDJMAF7D.js} +1 -0
  8. package/dist/{chunk-ERBYEC5P.js → chunk-JYKYD57J.js} +1 -1
  9. package/dist/chunk-MGB6FE4A.js +58 -0
  10. package/dist/chunk-NNV2OYEF.js +23 -0
  11. package/dist/{chunk-76SWLAZ6.js → chunk-RXWODUWA.js} +43 -1
  12. package/dist/{chunk-V3MVOVQT.js → chunk-SA2QHAXG.js} +8 -1
  13. package/dist/chunk-TEAWYLPO.js +1493 -0
  14. package/dist/{chunk-PD2I5TYC.js → chunk-V7FJWTZW.js} +3 -3
  15. package/dist/{chunk-TC4ZPUWI.js → chunk-Y7MZZRYR.js} +21 -80
  16. package/dist/{chunk-FXYK2GTO.js → chunk-Z7OQSWBD.js} +38 -33
  17. package/dist/chunk-ZYURL5VK.js +83 -0
  18. package/dist/cli.js +79 -98
  19. package/dist/{comment-MCXE7B7V.js → comment-MRDPDA33.js} +29 -24
  20. package/dist/{company-EUUN372H.js → company-2AEHSGHA.js} +57 -52
  21. package/dist/{config-K4G3VSBA.js → config-NRBKHXES.js} +13 -5
  22. package/dist/{connect-2AL7XVJO.js → connect-4XEBV5V3.js} +42 -38
  23. package/dist/core-RGU2SCBN.js +46 -0
  24. package/dist/{doctor-WPYI7X2T.js → doctor-BZ4DA7DV.js} +9 -5
  25. package/dist/document-RKHRWXNT.js +27 -0
  26. package/dist/{draft-G65DVXT7.js → draft-C5N6EOO5.js} +27 -22
  27. package/dist/enrollment-BNQOUKI7.js +472 -0
  28. package/dist/examples-NIMSIXMV.js +53 -0
  29. package/dist/{exit-codes-AW6KHDDN.js → exit-codes-TLMKTLRI.js} +1 -1
  30. package/dist/{feed-HV24WME4.js → feed-DFUU7SUJ.js} +15 -11
  31. package/dist/{group-HADXNVJW.js → group-CSD2OWOZ.js} +17 -13
  32. package/dist/{inbox-G3EE54OB.js → inbox-SNSPWI7J.js} +23 -19
  33. package/dist/{inboxes-237XOBTP.js → inboxes-RIRHPS4H.js} +18 -14
  34. package/dist/{job-LIN6RWD7.js → job-6PNXXZNF.js} +31 -27
  35. package/dist/{login-OHAHNBRW.js → login-Y7JBAHCW.js} +10 -5
  36. package/dist/{message-U2O2JQSW.js → message-2IK4MBBG.js} +10 -8
  37. package/dist/motion-7ATUXO6R.js +946 -0
  38. package/dist/{notification-3VG32LWM.js → notification-VYK5NDEB.js} +19 -15
  39. package/dist/{post-ECDK2KJL.js → post-AN6T2OJF.js} +35 -30
  40. package/dist/{profile-JOHS6SDW.js → profile-UQY64642.js} +46 -42
  41. package/dist/{recruiter-7VXEIXN3.js → recruiter-OY4RN5HH.js} +122 -119
  42. package/dist/{sales-nav-K4BMBH7R.js → sales-nav-KLODLYMW.js} +36 -30
  43. package/dist/{search-C2UYO6PI.js → search-NWP5S6CF.js} +68 -58
  44. package/dist/{setup-GYEZFDEN.js → setup-YPPFLH2N.js} +14 -9
  45. package/dist/{webhook-KCOQOH7D.js → webhook-OHKBL3YS.js} +51 -55
  46. package/package.json +2 -2
  47. package/dist/chunk-KJ24DIAJ.js +0 -60
  48. package/dist/examples-IJL3A6SZ.js +0 -18
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ ANNOTATIONS,
4
+ ENFORCED,
5
+ MAX_DOCUMENT_BYTES,
6
+ documentSchema,
7
+ parseDocument,
8
+ readFileFlag,
9
+ readStdinCapped,
10
+ renderDocument,
11
+ reportIssues,
12
+ validate
13
+ } from "./chunk-TEAWYLPO.js";
14
+ import "./chunk-FDJMAF7D.js";
15
+ import "./chunk-ZYURL5VK.js";
16
+ export {
17
+ ANNOTATIONS,
18
+ ENFORCED,
19
+ MAX_DOCUMENT_BYTES,
20
+ documentSchema,
21
+ parseDocument,
22
+ readFileFlag,
23
+ readStdinCapped,
24
+ renderDocument,
25
+ reportIssues,
26
+ validate
27
+ };
@@ -21,17 +21,22 @@ import {
21
21
  resolveEffectiveConfig,
22
22
  streamAll,
23
23
  writeNdjsonItem
24
- } from "./chunk-V3MVOVQT.js";
24
+ } from "./chunk-SA2QHAXG.js";
25
25
  import {
26
26
  createClient
27
- } from "./chunk-UJOTQPL6.js";
27
+ } from "./chunk-5ZGTU4VD.js";
28
28
  import {
29
29
  GLOBAL_FLAGS,
30
30
  READ_SINGLE_FLAGS,
31
31
  WRITE_SINGLE_FLAGS,
32
- readOnly,
32
+ readOnly
33
+ } from "./chunk-Y7MZZRYR.js";
34
+ import {
35
+ DESCRIPTIONS
36
+ } from "./chunk-D2S5OCYU.js";
37
+ import {
33
38
  resolveTextOrStdin
34
- } from "./chunk-TC4ZPUWI.js";
39
+ } from "./chunk-ZYURL5VK.js";
35
40
 
36
41
  // src/commands/draft.ts
37
42
  import { defineCommand } from "citty";
@@ -62,7 +67,7 @@ function rejectAllOnNonPaginated(all, out) {
62
67
  async function handleError(err, outOpts, out) {
63
68
  const { CurviateError } = await import("@curviate/sdk");
64
69
  if (err instanceof CurviateError) {
65
- const { getExitCode } = await import("./exit-codes-AW6KHDDN.js");
70
+ const { getExitCode } = await import("./exit-codes-TLMKTLRI.js");
66
71
  renderError(err, outOpts, out);
67
72
  process.exit(getExitCode(err));
68
73
  }
@@ -142,7 +147,7 @@ async function uploadAll(client, draftId, files, out) {
142
147
  contentType: guessContentType(f.path)
143
148
  });
144
149
  } catch (err) {
145
- out.stderr.write(`error: uploading ${basename(f.path)} to draft ${draftId} failed; the Draft exists with the files before it. Fix the cause and add the rest with \`curviate draft update ${draftId} --attach <file>\`.
150
+ out.stderr.write(`error: uploading ${basename(f.path)} to draft ${draftId} failed; the Draft exists with the files before it. Fix the cause and add the rest with \`curviate core draft update ${draftId} --attach <file>\`.
146
151
  `);
147
152
  throw err;
148
153
  }
@@ -208,7 +213,7 @@ async function runDraftGet(client, flags, out) {
208
213
  async function runDraftCreate(client, flags, out, readStdin) {
209
214
  const body = {};
210
215
  if (flags.unschedule) {
211
- out.stderr.write("error: --unschedule applies to `draft update`; a new Draft is unscheduled unless you pass --schedule-at.\n");
216
+ out.stderr.write("error: --unschedule applies to `curviate core draft update`; a new Draft is unscheduled unless you pass --schedule-at.\n");
212
217
  process.exit(2);
213
218
  }
214
219
  const account = readAccount(flags, out);
@@ -324,9 +329,9 @@ var draftListCommand = defineCommand({
324
329
  name: "list",
325
330
  description: "List Drafts, newest first. With --status published it lists publish records instead (post id, account, time; never Drafts).",
326
331
  examples: [
327
- "curviate draft list",
328
- "curviate draft list --status scheduled --account acc_YOUR_ACCOUNT_ID --order asc",
329
- "curviate draft list --status scheduled,published --from 2026-10-01T00:00:00Z --to 2026-11-01T00:00:00Z"
332
+ "curviate core draft list",
333
+ "curviate core draft list --status scheduled --account acc_YOUR_ACCOUNT_ID --order asc",
334
+ "curviate core draft list --status scheduled,published --from 2026-10-01T00:00:00Z --to 2026-11-01T00:00:00Z"
330
335
  ]
331
336
  },
332
337
  args: {
@@ -345,7 +350,7 @@ var draftGetCommand = defineCommand({
345
350
  meta: {
346
351
  name: "get",
347
352
  description: "Get one Draft, with a fresh signed link (valid 1 hour) for each attachment.",
348
- examples: ["curviate draft get drf_YOUR_DRAFT_ID"]
353
+ examples: ["curviate core draft get drf_YOUR_DRAFT_ID"]
349
354
  },
350
355
  args: {
351
356
  ...readOnly(READ_SINGLE_FLAGS),
@@ -360,9 +365,9 @@ var draftCreateCommand = defineCommand({
360
365
  name: "create",
361
366
  description: "Store a Draft. Every part is optional. With --schedule-at (and an account and text) Curviate publishes it at that time. Up to 50 Drafts and 2 GiB of media per account, and per no-account. A retry creates a second Draft.",
362
367
  examples: [
363
- 'curviate draft create "Three things we learned shipping our first agent integration."',
364
- 'curviate draft create "Launch day." --account acc_YOUR_ACCOUNT_ID --schedule-at 2026-10-12T09:00:00+02:00',
365
- 'curviate draft create "Demo." --account acc_YOUR_ACCOUNT_ID --attach screenshot.png'
368
+ 'curviate core draft create "Three things we learned shipping our first agent integration."',
369
+ 'curviate core draft create "Launch day." --account acc_YOUR_ACCOUNT_ID --schedule-at 2026-10-12T09:00:00+02:00',
370
+ 'curviate core draft create "Demo." --account acc_YOUR_ACCOUNT_ID --attach screenshot.png'
366
371
  ]
367
372
  },
368
373
  args: {
@@ -381,9 +386,9 @@ var draftUpdateCommand = defineCommand({
381
386
  name: "update",
382
387
  description: "Change a Draft: only the parts you pass change. --attach appends files; --schedule-at schedules or reschedules, --unschedule cancels. Any update to a failed Draft clears its failure. A Draft being published answers DRAFT_PUBLISHING: read it again in a few seconds.",
383
388
  examples: [
384
- 'curviate draft update drf_YOUR_DRAFT_ID --text "New wording."',
385
- "curviate draft update drf_YOUR_DRAFT_ID --schedule-at 2026-10-12T09:00:00+02:00",
386
- "curviate draft update drf_YOUR_DRAFT_ID --unschedule"
389
+ 'curviate core draft update drf_YOUR_DRAFT_ID --text "New wording."',
390
+ "curviate core draft update drf_YOUR_DRAFT_ID --schedule-at 2026-10-12T09:00:00+02:00",
391
+ "curviate core draft update drf_YOUR_DRAFT_ID --unschedule"
387
392
  ]
388
393
  },
389
394
  args: {
@@ -403,7 +408,7 @@ var draftDeleteCommand = defineCommand({
403
408
  meta: {
404
409
  name: "delete",
405
410
  description: "Delete a Draft and its stored media.",
406
- examples: ["curviate draft delete drf_YOUR_DRAFT_ID"]
411
+ examples: ["curviate core draft delete drf_YOUR_DRAFT_ID"]
407
412
  },
408
413
  args: {
409
414
  ...WRITE_SINGLE_FLAGS,
@@ -416,8 +421,8 @@ var draftDeleteCommand = defineCommand({
416
421
  var draftPublishCommand = defineCommand({
417
422
  meta: {
418
423
  name: "publish",
419
- description: "Publish a Draft now, under the same rules and safety limits as `post create`. Success deletes the Draft and prints the post id; a known failure leaves the Draft unchanged. If the error says the outcome is unknown, the post may be live: check the account's posts before retrying.",
420
- examples: ["curviate draft publish drf_YOUR_DRAFT_ID"]
424
+ description: "Publish a Draft now, under the same rules and safety limits as `curviate core post create`. Success deletes the Draft and prints the post id; a known failure leaves the Draft unchanged. If the error says the outcome is unknown, the post may be live: check the account's posts before retrying.",
425
+ examples: ["curviate core draft publish drf_YOUR_DRAFT_ID"]
421
426
  },
422
427
  args: {
423
428
  ...WRITE_SINGLE_FLAGS,
@@ -428,7 +433,7 @@ var draftPublishCommand = defineCommand({
428
433
  }
429
434
  });
430
435
  var draftCommand = defineCommand({
431
- meta: { name: "draft", description: "Drafts and scheduled posts." },
436
+ meta: { name: "draft", description: DESCRIPTIONS.draft },
432
437
  subCommands: {
433
438
  list: draftListCommand,
434
439
  get: draftGetCommand,
@@ -439,7 +444,7 @@ var draftCommand = defineCommand({
439
444
  },
440
445
  async run() {
441
446
  process.stderr.write(
442
- 'Usage: curviate draft <subcommand>\n list | get <id> | create ["<text>"] | update <id> | delete <id> | publish <id>\n'
447
+ 'Usage: curviate core draft <subcommand>\n list | get <id> | create ["<text>"] | update <id> | delete <id> | publish <id>\n'
443
448
  );
444
449
  }
445
450
  });
@@ -0,0 +1,472 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ fail,
4
+ listFlag,
5
+ outputOpts,
6
+ rootClient,
7
+ usage
8
+ } from "./chunk-MGB6FE4A.js";
9
+ import {
10
+ intFlag
11
+ } from "./chunk-NNV2OYEF.js";
12
+ import {
13
+ buildPreviewOutput
14
+ } from "./chunk-TCUYH5GO.js";
15
+ import {
16
+ pageDelayFromFlags,
17
+ readCursorFlag,
18
+ readMaxPagesFlag,
19
+ readableObject,
20
+ readablePage,
21
+ rejectPaginationModifiersWithoutAll,
22
+ renderSuccess,
23
+ streamAll,
24
+ writeNdjsonItem
25
+ } from "./chunk-SA2QHAXG.js";
26
+ import "./chunk-5ZGTU4VD.js";
27
+ import {
28
+ GLOBAL_FLAGS,
29
+ READ_SINGLE_FLAGS,
30
+ WRITE_SINGLE_FLAGS,
31
+ readOnly
32
+ } from "./chunk-Y7MZZRYR.js";
33
+ import {
34
+ DESCRIPTIONS
35
+ } from "./chunk-D2S5OCYU.js";
36
+ import "./chunk-ZYURL5VK.js";
37
+
38
+ // src/commands/enrollment.ts
39
+ import { defineCommand } from "citty";
40
+ import { setTimeout as sleep } from "timers/promises";
41
+ var POLL_MS = 2e3;
42
+ var RETRY_WAIT_MS = 10 * 60 * 1e3;
43
+ function preview(method, args, body = {}) {
44
+ process.stdout.write(JSON.stringify(buildPreviewOutput({ method, args, body })) + "\n");
45
+ }
46
+ function filters(f) {
47
+ const q = {};
48
+ const one = (flag, key) => {
49
+ const v = f[flag];
50
+ if (v === void 0) return;
51
+ if (typeof v !== "string" || v.trim() === "") usage(`--${String(flag)} was given an empty value.`);
52
+ q[key] = v;
53
+ };
54
+ one("motion", "motion_id");
55
+ one("contact", "contact_id");
56
+ one("step", "step_id");
57
+ one("done-step", "done_step");
58
+ one("outcome", "outcome");
59
+ one("variant", "variant_id");
60
+ if (f.status !== void 0) q["status"] = listFlag("status", f.status);
61
+ if (f.reason !== void 0) q["reason"] = listFlag("reason", f.reason);
62
+ if (f.relationship !== void 0) q["relationship_at_enrollment"] = listFlag("relationship", f.relationship);
63
+ if (f.version !== void 0) q["version"] = intFlag("version", f.version);
64
+ return q;
65
+ }
66
+ var paired = (code, message) => code != null && message != null ? `${code}: ${message}` : code;
67
+ function humanReasons(data) {
68
+ if (Array.isArray(data)) return data.map(humanReasons);
69
+ if (!data || typeof data !== "object") return data;
70
+ const o = { ...data };
71
+ for (const k of ["skip", "finish"]) {
72
+ if (`${k}_message` in o) {
73
+ o[`${k}_reason`] = paired(o[`${k}_reason`], o[`${k}_message`]);
74
+ delete o[`${k}_message`];
75
+ }
76
+ }
77
+ if ("reason_message" in o) {
78
+ o["reason"] = paired(o["reason"], o["reason_message"]);
79
+ delete o["reason_message"];
80
+ }
81
+ for (const k of ["items", "history"]) if (Array.isArray(o[k])) o[k] = o[k].map(humanReasons);
82
+ return o;
83
+ }
84
+ function show(result, f) {
85
+ const opts = outputOpts(f);
86
+ renderSuccess(opts.json ? result : humanReasons(result), opts, process);
87
+ }
88
+ async function runList(c, f) {
89
+ rejectPaginationModifiersWithoutAll(f, process);
90
+ const params = filters(f);
91
+ if (f.limit !== void 0) params["limit"] = intFlag("limit", f.limit, 1, 100);
92
+ const cursor = readCursorFlag(f, process);
93
+ if (cursor) params["cursor"] = cursor;
94
+ try {
95
+ if (f.all) {
96
+ const page = (p) => c.enrollments.list(p);
97
+ for await (const item of streamAll(page, params, { maxPages: readMaxPagesFlag(f, process), out: process, pageDelayMs: pageDelayFromFlags(f) })) writeNdjsonItem(process, item, f.fields);
98
+ } else {
99
+ show(readablePage(await c.enrollments.list(params)), f);
100
+ }
101
+ } catch (err) {
102
+ await fail(err, f);
103
+ }
104
+ }
105
+ async function runGet(c, f) {
106
+ try {
107
+ show(readableObject(await c.enrollments.get(String(f.id ?? ""))), f);
108
+ } catch (err) {
109
+ await fail(err, f);
110
+ }
111
+ }
112
+ var single = (method, body = () => void 0) => async (c, f) => {
113
+ const b = body(f);
114
+ if (f.preview) return preview(`enrollments.${method}`, { id: f.id }, b ?? {});
115
+ try {
116
+ const call = c.enrollments[method];
117
+ show(await call.call(c.enrollments, String(f.id ?? ""), b), f);
118
+ } catch (err) {
119
+ await fail(err, f);
120
+ }
121
+ };
122
+ var required = (flag, v, what) => {
123
+ if (v === void 0 || v.trim() === "") usage(`--${flag} is required: ${what}.`);
124
+ return v;
125
+ };
126
+ async function runRetry(c, f) {
127
+ const id = String(f.id ?? "");
128
+ const waitMs = f["wait-timeout"] === void 0 ? RETRY_WAIT_MS : intFlag("wait-timeout", f["wait-timeout"], 0, 24 * 60 * 60 * 1e3);
129
+ if (f.preview) return preview("enrollments.retry", { id });
130
+ const read = async () => {
131
+ const e = await c.enrollments.get(id);
132
+ return Array.isArray(e?.history) ? e.history : [];
133
+ };
134
+ let before;
135
+ try {
136
+ before = await read();
137
+ } catch (err) {
138
+ return fail(err, f);
139
+ }
140
+ const failed = [...before].reverse().find((h) => h.outcome === "failed");
141
+ let item;
142
+ try {
143
+ item = await c.enrollments.retry(id);
144
+ } catch (err) {
145
+ const { CurviateError } = await import("@curviate/sdk");
146
+ if (err instanceof CurviateError) return fail(err, f);
147
+ process.stderr.write(`error: the API answered the retry without a readable result. It may have been applied: check with \`curviate enrollment get ${id}\` before sending it again.
148
+ `);
149
+ process.exit(7);
150
+ }
151
+ if (!failed?.step_id) {
152
+ process.stderr.write(`The retry was accepted, but no failed Step was in the history read just before it: read the outcome with \`curviate enrollment get ${id}\`.
153
+ `);
154
+ return renderSuccess(item, outputOpts(f), process);
155
+ }
156
+ const deadline = Date.now() + waitMs;
157
+ for (; ; ) {
158
+ const now = await read().catch(() => null);
159
+ const record = now?.slice(before.length).find((h) => h.step_id === failed.step_id);
160
+ if (record) return renderSuccess({ step_id: failed.step_id, outcome: record.outcome ?? null, reason: record.reason ?? null, message: record.reason_message ?? null }, outputOpts(f), process);
161
+ const left = deadline - Date.now();
162
+ if (left <= 0) break;
163
+ await sleep(Math.min(POLL_MS, left));
164
+ }
165
+ process.stderr.write(
166
+ `error: Step ${failed.step_id} was resumed but has not run within ${waitMs} ms; it may wait for pacing or a budget. Read it later with \`curviate enrollment get ${id}\`. Do not retry it: it is already resumed.
167
+ `
168
+ );
169
+ process.exit(7);
170
+ }
171
+ var ACTIONS = ["pause", "resume", "stop", "retry", "event", "reassign"];
172
+ async function runBulk(c, f) {
173
+ const action = required("action", f.action, ACTIONS.join(", "));
174
+ if (!ACTIONS.includes(action)) usage(`--action takes one of ${ACTIONS.join(", ")}.`);
175
+ const ids = listFlag("id", f.id);
176
+ const filter = filters(f);
177
+ if (ids.length > 0 === (f.motion !== void 0)) usage("name the Enrollments either with --id (repeatable, or a comma list) or with --motion and its filters, not both.");
178
+ if (ids.length && Object.keys(filter).length) usage("the list filters apply with --motion, not with --id.");
179
+ const body = { action, ...ids.length ? { ids } : { filter } };
180
+ if (f.at !== void 0) body["at"] = f.at;
181
+ if (f.name !== void 0) body["name"] = f.name;
182
+ if (f.account !== void 0) body["account_id"] = f.account;
183
+ if (f.preview) return preview("enrollments.bulk", {}, body);
184
+ let result;
185
+ try {
186
+ result = await c.enrollments.bulk(body);
187
+ } catch (err) {
188
+ return fail(err, f);
189
+ }
190
+ const results = Array.isArray(result?.results) ? result.results : [];
191
+ if (outputOpts(f).json) renderSuccess(result, outputOpts(f), process);
192
+ else {
193
+ for (const r of results) {
194
+ const warn = (r.warnings ?? []).map((w) => ` (warning: ${w.message ?? ""})`).join("");
195
+ process.stdout.write(`${r.enrollment_id} ${r.outcome === "ok" ? "ok" : `error ${r.error?.code}: ${r.error?.message ?? ""}`}${warn}
196
+ `);
197
+ }
198
+ }
199
+ const firstError = results.find((r) => r.outcome !== "ok");
200
+ if (firstError) {
201
+ const { getExitCode } = await import("./exit-codes-TLMKTLRI.js");
202
+ process.stderr.write(`error: ${results.filter((r) => r.outcome !== "ok").length} of ${results.length} Enrollments were refused; each refusal is listed.
203
+ `);
204
+ process.exit(getExitCode(firstError.error?.code ?? "INTERNAL"));
205
+ }
206
+ }
207
+ var online = (fn) => async ({ args }) => {
208
+ const f = args;
209
+ await fn(await rootClient(f), f);
210
+ };
211
+ var ID = { type: "positional", description: "Enrollment id (enr_...)." };
212
+ var ROLE = { INSUFFICIENT_ROLE: "your role cannot operate the Enrollment's Account.", ACCOUNT_NOT_SHARED: "the Enrollment's Account is not shared with you." };
213
+ var NOT_ACTIVE = { ENROLLMENT_NOT_ACTIVE: "the Enrollment's status does not take this operation." };
214
+ var IN_FLIGHT = { STEP_IN_FLIGHT: "a Step of the Enrollment is being sent right now; read it again in a minute, then retry." };
215
+ var SEE = ["curviate enrollment get", "curviate enrollment list"];
216
+ var FILTER_ARGS = {
217
+ motion: { type: "string", description: "Only this Motion's Enrollments (mot_...)." },
218
+ contact: { type: "string", description: "Only this Contact's Enrollments (con_...)." },
219
+ status: { type: "string", description: "Comma list of pending, active, paused, finished, skipped." },
220
+ step: { type: "string", description: "Only Enrollments now at this Step id." },
221
+ version: { type: "string", description: "Only Enrollments running this Sequence version (1 or more)." },
222
+ "done-step": { type: "string", description: "Only Enrollments that ran this Step id. With --outcome: how it ended." },
223
+ outcome: { type: "string", description: "With --done-step: executed, skipped, failed, accepted, not_accepted, replied, no_reply or seen." },
224
+ reason: { type: "string", description: "Comma list of reason codes (skip, finish or Step reasons; narrowed to --done-step when given)." },
225
+ variant: { type: "string", description: "Only Enrollments given this variant id." },
226
+ relationship: { type: "string", description: "Comma list of connected, not_connected, invite_pending, unknown: the Contact's relationship to the Account when it started." }
227
+ };
228
+ var listCmd = defineCommand({
229
+ meta: {
230
+ name: "list",
231
+ description: "List Enrollments, newest first, filtered by Motion, Contact, status, current Step, or how a Step ended. Each counts once per Contact, Motion and Account.",
232
+ risk: "read",
233
+ output: ["Each reason code comes with its sentence beside it (`skip_reason` and `skip_message`, `finish_reason` and `finish_message`)."],
234
+ examples: [
235
+ "curviate enrollment list --motion mot_YOUR_MOTION_ID",
236
+ "curviate enrollment list --motion mot_YOUR_MOTION_ID --done-step opener --outcome failed",
237
+ "curviate enrollment list --motion mot_YOUR_MOTION_ID --reason already_connected,known_chat --relationship connected"
238
+ ]
239
+ },
240
+ args: { ...readOnly(GLOBAL_FLAGS), ...FILTER_ARGS },
241
+ run: online(runList)
242
+ });
243
+ var getCmd = defineCommand({
244
+ meta: {
245
+ name: "get",
246
+ description: "One Enrollment with the history of its Steps: outcome, reason and its sentence, the Account that ran it. Metadata only, never the text sent.",
247
+ risk: "read",
248
+ examples: ["curviate enrollment get enr_YOUR_ENROLLMENT_ID"]
249
+ },
250
+ args: { ...readOnly(READ_SINGLE_FLAGS), id: ID },
251
+ run: online(runGet)
252
+ });
253
+ var pauseCmd = defineCommand({
254
+ meta: {
255
+ name: "pause",
256
+ description: "Hold one Enrollment until you resume it; its waits freeze with the time they had left. Replies are still recorded.",
257
+ risk: "write",
258
+ rules: {
259
+ changes: "No Step of this Enrollment runs until it is resumed.",
260
+ visible_to: "Your Team.",
261
+ budget_rows: [],
262
+ retry: "A second pause answers ENROLLMENT_NOT_ACTIVE; nothing changes.",
263
+ undo: "`curviate enrollment resume <enrollment_id>`."
264
+ },
265
+ errors: { ...NOT_ACTIVE, ...IN_FLIGHT, MOTION_STATUS_CONFLICT: "the Motion is archived or past its end.", ...ROLE },
266
+ examples: ["curviate enrollment pause enr_YOUR_ENROLLMENT_ID"]
267
+ },
268
+ args: { ...WRITE_SINGLE_FLAGS, id: ID },
269
+ run: online(single("pause"))
270
+ });
271
+ var resumeCmd = defineCommand({
272
+ meta: {
273
+ name: "resume",
274
+ description: "Without --at: lift your own pause; the Enrollment continues where it was. With --at: jump to that Step of its Sequence version. The jump is not guarded: it re-enters the Step even when that Step already sent, so a message can go out again. To retry a failed Step use `curviate enrollment retry <enrollment_id>`, which acts only on a failure.",
275
+ risk: "high",
276
+ rules: {
277
+ changes: "The Enrollment runs again from its Account; with --at, from the named Step.",
278
+ visible_to: "The Contact, once its next Step reaches LinkedIn.",
279
+ budget_rows: [],
280
+ retry: "With --at, every call jumps again and may send again: read `curviate enrollment get <enrollment_id>` first.",
281
+ undo: "`curviate enrollment pause <enrollment_id>`; what was sent stays sent.",
282
+ blast_radius: "One Enrollment: one Contact, from one Account."
283
+ },
284
+ errors: { ...NOT_ACTIVE, ...IN_FLIGHT, MOTION_STATUS_CONFLICT: "the Motion is archived or past its end.", ...ROLE },
285
+ seeAlso: ["curviate enrollment retry", "curviate enrollment get"],
286
+ examples: ["curviate enrollment resume enr_YOUR_ENROLLMENT_ID", "curviate enrollment resume enr_YOUR_ENROLLMENT_ID --at bump"]
287
+ },
288
+ args: {
289
+ ...WRITE_SINGLE_FLAGS,
290
+ id: ID,
291
+ at: { type: "string", description: "Jump to this Step id (the out-of-office path). Not guarded: a Step that already sent sends again." }
292
+ },
293
+ run: online(single("resume", (f) => f.at === void 0 ? void 0 : { at: required("at", f.at, "a Step id") }))
294
+ });
295
+ var retryCmd = defineCommand({
296
+ meta: {
297
+ name: "retry",
298
+ description: "Retry the failed Step of one Enrollment. Acts only while that Step's latest outcome is failed, so a repeated retry never re-sends a delivered message. Then waits for the Step's next record and prints it as {outcome, reason, message}; the Step may wait for pacing or a budget.",
299
+ risk: "high",
300
+ rules: {
301
+ changes: "Resumes the Enrollment at its failed Step, which runs again when its Account may send.",
302
+ visible_to: "The Contact, if the Step reaches LinkedIn.",
303
+ budget_rows: [],
304
+ retry: "Safe: with nothing failed it answers NOTHING_TO_RETRY and sends nothing.",
305
+ undo: "`curviate enrollment pause <enrollment_id>` before the Step runs; what was sent stays sent.",
306
+ blast_radius: "One Step of one Enrollment."
307
+ },
308
+ errors: {
309
+ NOTHING_TO_RETRY: "nothing to retry: the Enrollment's latest Step outcome is not failed.",
310
+ ...IN_FLIGHT,
311
+ ...NOT_ACTIVE,
312
+ MOTION_STATUS_CONFLICT: "the Motion is archived or past its end.",
313
+ ...ROLE
314
+ },
315
+ output: ["The re-run's record, {step_id, outcome, reason, message}. Exit 7 when the wait runs out first: the Step is resumed; read it later."],
316
+ seeAlso: ["curviate enrollment get", "curviate enrollment bulk"],
317
+ examples: ["curviate enrollment retry enr_YOUR_ENROLLMENT_ID", "curviate enrollment retry enr_YOUR_ENROLLMENT_ID --wait-timeout 60000"]
318
+ },
319
+ args: {
320
+ ...WRITE_SINGLE_FLAGS,
321
+ id: ID,
322
+ "wait-timeout": { type: "string", description: "How long to wait for the re-run, in milliseconds (default 600000). --timeout stays the request timeout." }
323
+ },
324
+ run: online(runRetry)
325
+ });
326
+ var stopCmd = defineCommand({
327
+ meta: {
328
+ name: "stop",
329
+ description: "Stop a pending, active or paused Enrollment: it finishes (stopped) and runs no further Step.",
330
+ risk: "write",
331
+ rules: {
332
+ changes: "The Enrollment finishes with reason stopped.",
333
+ visible_to: "Your Team.",
334
+ budget_rows: [],
335
+ retry: "A second stop answers ENROLLMENT_NOT_ACTIVE.",
336
+ undo: "`curviate enrollment resume <enrollment_id> --at <step_id>` restarts it at a Step."
337
+ },
338
+ errors: { ...NOT_ACTIVE, ...ROLE },
339
+ examples: ["curviate enrollment stop enr_YOUR_ENROLLMENT_ID"]
340
+ },
341
+ args: { ...WRITE_SINGLE_FLAGS, id: ID },
342
+ run: online(single("stop"))
343
+ });
344
+ var EVENT_ARGS = {
345
+ ...WRITE_SINGLE_FLAGS,
346
+ id: ID,
347
+ name: { type: "positional", description: "The event name a Step of its Sequence waits for (`until event.<name>`)." }
348
+ };
349
+ var eventMeta = (name, description, example) => ({
350
+ name,
351
+ description,
352
+ risk: "write",
353
+ rules: {
354
+ changes: "Records the event; a Step waiting for it continues. Fires no webhook.",
355
+ visible_to: "Your Team; the Contact once the next Step runs.",
356
+ budget_rows: [],
357
+ retry: "A second event is recorded again; a Step already past the wait ignores it.",
358
+ undo: "Cannot be undone; pause or stop the Enrollment to keep its next Step from running."
359
+ },
360
+ errors: { ...NOT_ACTIVE, INVALID_REQUEST: "no Step of its version waits for this name; the message lists the awaited names.", ...ROLE },
361
+ examples: [example]
362
+ });
363
+ var eventCmd = defineCommand({
364
+ meta: eventMeta(
365
+ "event",
366
+ "Send a custom event to an active or paused Enrollment whose Sequence waits for it, for example once your agent wrote the researched text to the Contact's custom fields. Input only: fires no webhook.",
367
+ "curviate enrollment event enr_YOUR_ENROLLMENT_ID research_ready"
368
+ ),
369
+ args: EVENT_ARGS,
370
+ run: online(single("events", (f) => ({ name: f.name ?? "" })))
371
+ });
372
+ var signalCmd = defineCommand({
373
+ meta: eventMeta(
374
+ "signal",
375
+ "Deprecated alias of `curviate enrollment event`, accepted until 2027-01-19. Sends the same event.",
376
+ "curviate enrollment signal enr_YOUR_ENROLLMENT_ID research_ready"
377
+ ),
378
+ args: EVENT_ARGS,
379
+ async run(ctx) {
380
+ process.stderr.write("warning: `curviate enrollment signal` is deprecated; use `curviate enrollment event`. It stops working on 2027-01-19.\n");
381
+ await online(single("events", (f) => ({ name: f.name ?? "" })))(ctx);
382
+ }
383
+ });
384
+ var reassignCmd = defineCommand({
385
+ meta: {
386
+ name: "reassign",
387
+ description: "Move an Enrollment to another sending Account of its Motion; it restarts there at the first Step of its version (one you paused stays paused). Refused, nothing changed, when its Account already engaged the person, the target already holds them, or the target has a chat with them.",
388
+ risk: "high",
389
+ rules: {
390
+ changes: "The Enrollment restarts on the target Account; Steps already skipped are named in warnings.",
391
+ visible_to: "The Contact, once the target Account's first Step reaches LinkedIn.",
392
+ budget_rows: [],
393
+ retry: "A second call to the same Account answers ALREADY_ENROLLED_ON_ACCOUNT.",
394
+ undo: "Reassign it back while the target has not engaged the person yet.",
395
+ blast_radius: "One Enrollment: one Contact, from one Account."
396
+ },
397
+ errors: {
398
+ ACCOUNT_NOT_FOUND: "the target is not a sending Account of the Motion.",
399
+ ...NOT_ACTIVE,
400
+ ...IN_FLIGHT,
401
+ ACCOUNT_ALREADY_ENGAGED: "its current Account already did something the person can see.",
402
+ ALREADY_ENROLLED_ON_ACCOUNT: "the target already holds this Contact in the Motion, or is the current Account.",
403
+ KNOWN_CHAT: "the target already has a chat with the person.",
404
+ ...ROLE
405
+ },
406
+ seeAlso: ["curviate enrollment get", "curviate motion get"],
407
+ examples: ["curviate enrollment reassign enr_YOUR_ENROLLMENT_ID --account acc_YOUR_ACCOUNT_ID"]
408
+ },
409
+ args: {
410
+ ...WRITE_SINGLE_FLAGS,
411
+ id: ID,
412
+ account: { type: "string", required: true, description: "The target sending Account of the Motion (acc_...). Never defaulted." }
413
+ },
414
+ run: online(single("reassign", (f) => ({ account_id: required("account", f.account, "the target Account (acc_...)") })))
415
+ });
416
+ var bulkCmd = defineCommand({
417
+ meta: {
418
+ name: "bulk",
419
+ description: "Pause, resume, stop, retry, send an event to or reassign many Enrollments in one call, named with --id or matched by --motion and the list filters. Each is decided alone, as its own command would be; not atomic. Up to 1000 items: ids, or Enrollments the filters match. List with the same filters first to see the matches.",
420
+ risk: "high",
421
+ rules: {
422
+ changes: "Each Enrollment gets the action as its single command would.",
423
+ visible_to: "The Contacts whose next Step reaches LinkedIn.",
424
+ budget_rows: [],
425
+ retry: "A retried call is a new call: each Enrollment answers again on its own (a second stop is ENROLLMENT_NOT_ACTIVE for it).",
426
+ undo: "Per Enrollment, as its single command says; what was sent stays sent.",
427
+ blast_radius: "Up to 1000 items (Enrollments), every Contact and Account they cover."
428
+ },
429
+ errors: { ...NOT_ACTIVE, NOTHING_TO_RETRY: "retry, per Enrollment: nothing failed.", ...IN_FLIGHT, ...ROLE },
430
+ output: ["One line per Enrollment, `<enrollment_id> ok` or `<enrollment_id> error <code>: <message>`; with --json (or piped) the API's answer. Exit 0 when every one is ok, else the first refusal's exit."],
431
+ seeAlso: SEE,
432
+ examples: [
433
+ "curviate enrollment bulk --action stop --id enr_A,enr_B",
434
+ "curviate enrollment bulk --action retry --motion mot_YOUR_MOTION_ID --done-step opener --outcome failed"
435
+ ]
436
+ },
437
+ args: {
438
+ ...WRITE_SINGLE_FLAGS,
439
+ action: { type: "string", required: true, description: `One of ${ACTIONS.join(", ")}.` },
440
+ id: { type: "string", description: "An Enrollment id (enr_...); repeatable, or a comma list. Not with --motion." },
441
+ ...FILTER_ARGS,
442
+ motion: { type: "string", description: "Act on this Motion's Enrollments (mot_...) that the other filters match. Not with --id." },
443
+ at: { type: "string", description: "With --action resume: jump to this Step id (not guarded, see `curviate enrollment resume`)." },
444
+ name: { type: "string", description: "With --action event: the event name." },
445
+ account: { type: "string", description: "With --action reassign: the target sending Account (acc_...). Never defaulted." }
446
+ },
447
+ run: online(runBulk)
448
+ });
449
+ var enrollmentCommand = defineCommand({
450
+ meta: { name: "enrollment", description: DESCRIPTIONS.enrollment },
451
+ subCommands: {
452
+ list: listCmd,
453
+ get: getCmd,
454
+ pause: pauseCmd,
455
+ resume: resumeCmd,
456
+ retry: retryCmd,
457
+ stop: stopCmd,
458
+ event: eventCmd,
459
+ signal: signalCmd,
460
+ reassign: reassignCmd,
461
+ bulk: bulkCmd
462
+ },
463
+ async run() {
464
+ const { showHelp } = await import("./examples-NIMSIXMV.js");
465
+ await showHelp(enrollmentCommand, ["curviate", "enrollment"]);
466
+ }
467
+ });
468
+ export {
469
+ enrollmentCommand,
470
+ humanReasons,
471
+ runRetry
472
+ };