@curviate/cli 0.49.0 → 0.50.0-next.1

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 (70) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +12 -5
  3. package/dist/{account-2BH2Q6VG.js → account-U7UJIE3H.js} +784 -116
  4. package/dist/analytics-MZU2WKON.js +27 -0
  5. package/dist/beta-consent-67IDUV3K.js +81 -0
  6. package/dist/billing-QAW75YE7.js +124 -0
  7. package/dist/{chunk-RXWODUWA.js → chunk-2W4RN5ON.js} +18 -2
  8. package/dist/{chunk-MGB6FE4A.js → chunk-3Z6PXS6N.js} +6 -6
  9. package/dist/chunk-5S3MJVI5.js +22 -0
  10. package/dist/{chunk-V7FJWTZW.js → chunk-6LBOGIVE.js} +4 -4
  11. package/dist/{chunk-Z7OQSWBD.js → chunk-6PLDAEMO.js} +85 -10
  12. package/dist/chunk-73DJ3KNE.js +54 -0
  13. package/dist/{chunk-3RCW7URJ.js → chunk-A57ZILRU.js} +1 -1
  14. package/dist/chunk-AVI7J47S.js +52 -0
  15. package/dist/{chunk-JYKYD57J.js → chunk-CKVCBGQX.js} +1 -1
  16. package/dist/chunk-EIA66ESN.js +339 -0
  17. package/dist/{chunk-YLSJ4HKU.js → chunk-ENBIMEKS.js} +26 -1
  18. package/dist/{chunk-LCGXJGPB.js → chunk-GHMRPX5H.js} +7 -1
  19. package/dist/chunk-GOICALYQ.js +28 -0
  20. package/dist/{chunk-PQWDDSV7.js → chunk-L7JH3W56.js} +1 -1
  21. package/dist/chunk-LCPPXOPN.js +528 -0
  22. package/dist/chunk-LRMPS4UQ.js +144 -0
  23. package/dist/{chunk-5ZGTU4VD.js → chunk-LULN3II2.js} +78 -5
  24. package/dist/chunk-PPGKQJKU.js +38 -0
  25. package/dist/chunk-Q3ZPRFUX.js +20 -0
  26. package/dist/{chunk-SA2QHAXG.js → chunk-QM57YDJE.js} +13 -201
  27. package/dist/{chunk-Y7MZZRYR.js → chunk-RYWWSZUH.js} +14 -2
  28. package/dist/{chunk-TEAWYLPO.js → chunk-TYNVJDYK.js} +49 -18
  29. package/dist/cli.js +34 -18
  30. package/dist/{comment-MRDPDA33.js → comment-6NRZILAS.js} +90 -11
  31. package/dist/{company-2AEHSGHA.js → company-VXE7IEPT.js} +65 -15
  32. package/dist/{config-NRBKHXES.js → config-3WP7OD35.js} +53 -4
  33. package/dist/{connect-4XEBV5V3.js → connect-FBK6UWZP.js} +63 -18
  34. package/dist/contact-HFPZ3KGL.js +32 -0
  35. package/dist/contact-groups-AI4MLGQS.js +399 -0
  36. package/dist/contact-import-54Y7EMU2.js +336 -0
  37. package/dist/core-RLMWMQEI.js +46 -0
  38. package/dist/do-not-contact-LQ5V6SPE.js +200 -0
  39. package/dist/{doctor-BZ4DA7DV.js → doctor-KKRL7TEF.js} +65 -11
  40. package/dist/{document-RKHRWXNT.js → document-GFRWPQFV.js} +1 -1
  41. package/dist/{draft-C5N6EOO5.js → draft-VSWZOCDR.js} +60 -14
  42. package/dist/{enrollment-BNQOUKI7.js → enrollment-OACCSBM5.js} +31 -19
  43. package/dist/{examples-NIMSIXMV.js → examples-JJB4DZKK.js} +2 -2
  44. package/dist/{exit-codes-TLMKTLRI.js → exit-codes-7DBETBDT.js} +1 -1
  45. package/dist/export-AQHAFVAB.js +96 -0
  46. package/dist/{feed-DFUU7SUJ.js → feed-HY4HT75U.js} +13 -10
  47. package/dist/{group-CSD2OWOZ.js → group-A3SMBFU5.js} +18 -10
  48. package/dist/{inbox-SNSPWI7J.js → inbox-YHUO2RPI.js} +31 -12
  49. package/dist/{inboxes-RIRHPS4H.js → inboxes-GKLMHPDR.js} +14 -10
  50. package/dist/incoming-NHROOOIZ.js +218 -0
  51. package/dist/{job-6PNXXZNF.js → job-QBW3PGWL.js} +65 -13
  52. package/dist/{login-Y7JBAHCW.js → login-GWIYHKYO.js} +13 -4
  53. package/dist/{message-2IK4MBBG.js → message-BFLN2VHS.js} +9 -7
  54. package/dist/{motion-7ATUXO6R.js → motion-LTWU2GPC.js} +39 -117
  55. package/dist/network-CNSBX2SR.js +235 -0
  56. package/dist/{notification-VYK5NDEB.js → notification-DCCFJPXU.js} +38 -11
  57. package/dist/notifications-AQBXBK4K.js +231 -0
  58. package/dist/{post-AN6T2OJF.js → post-PINZHSPS.js} +92 -12
  59. package/dist/{profile-UQY64642.js → profile-MJQJSNYR.js} +76 -20
  60. package/dist/{recruiter-OY4RN5HH.js → recruiter-X6GX4A2G.js} +133 -22
  61. package/dist/{sales-nav-KLODLYMW.js → sales-nav-44GYWDYE.js} +74 -19
  62. package/dist/{search-NWP5S6CF.js → search-SULIN6TB.js} +55 -23
  63. package/dist/{setup-YPPFLH2N.js → setup-ZQRHMRMB.js} +69 -17
  64. package/dist/team-TM6LRUY5.js +450 -0
  65. package/dist/tier-Z3U6AT7H.js +61 -0
  66. package/dist/unibox-BIMI2KY5.js +402 -0
  67. package/dist/{webhook-OHKBL3YS.js → webhook-EHXRTHBG.js} +257 -27
  68. package/package.json +2 -2
  69. package/dist/chunk-D2S5OCYU.js +0 -38
  70. package/dist/core-RGU2SCBN.js +0 -46
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  readlineSync
4
- } from "./chunk-YLSJ4HKU.js";
4
+ } from "./chunk-ENBIMEKS.js";
5
5
  import {
6
6
  baseUrlProblem,
7
7
  writeProfile
8
- } from "./chunk-5ZGTU4VD.js";
8
+ } from "./chunk-LULN3II2.js";
9
9
  import {
10
10
  GLOBAL_FLAGS
11
- } from "./chunk-Y7MZZRYR.js";
11
+ } from "./chunk-RYWWSZUH.js";
12
12
  import {
13
13
  DESCRIPTIONS
14
- } from "./chunk-D2S5OCYU.js";
14
+ } from "./chunk-73DJ3KNE.js";
15
15
  import {
16
16
  defaultReadStdin,
17
17
  resolveTextOrStdin
@@ -55,6 +55,15 @@ var loginCommand = defineCommand({
55
55
  meta: {
56
56
  name: "login",
57
57
  description: DESCRIPTIONS.login,
58
+ risk: "write",
59
+ rules: {
60
+ changes: "Saves the API key to a local profile; no request is made.",
61
+ visible_to: "Nobody else: the file stays on this machine.",
62
+ budget_rows: [],
63
+ retry: "Safe: the same key saved again leaves the profile the same.",
64
+ undo: "`curviate config reset --profile <name> --yes` removes the profile."
65
+ },
66
+ errors: { INVALID_REQUEST: "the key is empty or the base URL is not valid." },
58
67
  examples: [
59
68
  "curviate login",
60
69
  "curviate login --api-key - --profile work"
@@ -13,19 +13,21 @@ import {
13
13
  runMessageSend,
14
14
  sentAsNotice,
15
15
  willSendAsNotice
16
- } from "./chunk-Z7OQSWBD.js";
16
+ } from "./chunk-6PLDAEMO.js";
17
17
  import "./chunk-5I6JJJIV.js";
18
18
  import "./chunk-UWO2D4HW.js";
19
+ import "./chunk-Q3ZPRFUX.js";
19
20
  import "./chunk-UEAX6KUB.js";
20
- import "./chunk-V7FJWTZW.js";
21
+ import "./chunk-6LBOGIVE.js";
21
22
  import "./chunk-TCUYH5GO.js";
22
- import "./chunk-SA2QHAXG.js";
23
- import "./chunk-RXWODUWA.js";
24
- import "./chunk-5ZGTU4VD.js";
25
- import "./chunk-Y7MZZRYR.js";
26
- import "./chunk-D2S5OCYU.js";
23
+ import "./chunk-LRMPS4UQ.js";
24
+ import "./chunk-QM57YDJE.js";
25
+ import "./chunk-LULN3II2.js";
26
+ import "./chunk-RYWWSZUH.js";
27
+ import "./chunk-73DJ3KNE.js";
27
28
  import "./chunk-FDJMAF7D.js";
28
29
  import "./chunk-ZYURL5VK.js";
30
+ import "./chunk-2W4RN5ON.js";
29
31
  export {
30
32
  guardBareMessageForm,
31
33
  messageCommand,
@@ -1,17 +1,20 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ sendInChunks
4
+ } from "./chunk-AVI7J47S.js";
2
5
  import {
3
6
  fail,
4
7
  listFlag,
5
8
  outputOpts,
6
9
  rootClient,
7
10
  usage
8
- } from "./chunk-MGB6FE4A.js";
9
- import {
10
- intFlag
11
- } from "./chunk-NNV2OYEF.js";
11
+ } from "./chunk-3Z6PXS6N.js";
12
12
  import {
13
13
  buildPreviewOutput
14
14
  } from "./chunk-TCUYH5GO.js";
15
+ import {
16
+ intFlag
17
+ } from "./chunk-NNV2OYEF.js";
15
18
  import {
16
19
  pageDelayFromFlags,
17
20
  readCursorFlag,
@@ -19,27 +22,29 @@ import {
19
22
  readableObject,
20
23
  readablePage,
21
24
  rejectPaginationModifiersWithoutAll,
25
+ streamAll
26
+ } from "./chunk-LRMPS4UQ.js";
27
+ import {
22
28
  renderSuccess,
23
- streamAll,
24
29
  writeNdjsonItem
25
- } from "./chunk-SA2QHAXG.js";
26
- import "./chunk-5ZGTU4VD.js";
30
+ } from "./chunk-QM57YDJE.js";
31
+ import "./chunk-LULN3II2.js";
27
32
  import {
28
33
  GLOBAL_FLAGS,
29
34
  READ_SINGLE_FLAGS,
30
35
  WRITE_SINGLE_FLAGS,
31
36
  readOnly
32
- } from "./chunk-Y7MZZRYR.js";
37
+ } from "./chunk-RYWWSZUH.js";
33
38
  import {
34
39
  DESCRIPTIONS
35
- } from "./chunk-D2S5OCYU.js";
40
+ } from "./chunk-73DJ3KNE.js";
36
41
  import {
37
42
  documentSchema,
38
43
  parseDocument,
39
44
  readFileFlag,
40
45
  reportIssues,
41
46
  validate
42
- } from "./chunk-TEAWYLPO.js";
47
+ } from "./chunk-TYNVJDYK.js";
43
48
  import "./chunk-FDJMAF7D.js";
44
49
  import {
45
50
  isStdinToken
@@ -108,63 +113,10 @@ function compilerLines(file, text, entries, prefix = "") {
108
113
  return [...entries.errors.map((e) => line("error", e)), ...entries.warnings.map((w) => line("warning", w))];
109
114
  }
110
115
 
111
- // src/lib/chunks.ts
112
- async function sendInChunks(ids, size, send, f) {
113
- const total = Math.ceil(ids.length / size);
114
- const done = [];
115
- for (let k = 0; k < total; k++) {
116
- const chunk = ids.slice(k * size, (k + 1) * size);
117
- try {
118
- done.push(await send(chunk));
119
- } catch (err) {
120
- const { CurviateError } = await import("@curviate/sdk");
121
- const progress = {
122
- chunks: { sent: k, total },
123
- items: { accepted: k * size, total: ids.length },
124
- failed_chunk: { index: k + 1, first_row: k * size + 1, last_row: k * size + chunk.length }
125
- };
126
- if (!(err instanceof CurviateError)) {
127
- process.stderr.write(`Chunk ${k + 1} of ${total} failed; ${k * size} of ${ids.length} ids were sent before it. Nothing after it was sent.
128
- `);
129
- return fail(err, f);
130
- }
131
- const { getExitCode } = await import("./exit-codes-TLMKTLRI.js");
132
- const e = err.toJSON();
133
- if (outputOpts(f).json) process.stdout.write(JSON.stringify({ error: e, progress }) + "\n");
134
- process.stderr.write(
135
- `error [${e.code}] ${e.message}
136
- Chunk ${k + 1} of ${total} failed (ids ${progress.failed_chunk.first_row} to ${progress.failed_chunk.last_row}); ${progress.items.accepted} of ${ids.length} ids were sent before it. Nothing after it was sent.
137
- `
138
- );
139
- process.exit(getExitCode(err));
140
- }
141
- }
142
- return done;
143
- }
144
-
145
116
  // src/templates/connect-and-converse.json
146
117
  var connect_and_converse_default = {
147
118
  name: "Connect and converse",
148
- contact_list_ids: [],
149
- account_ids: [],
150
- schedule: {
151
- timezone: null,
152
- days: [
153
- "mon",
154
- "tue",
155
- "wed",
156
- "thu",
157
- "fri"
158
- ],
159
- hours: {
160
- start: "09:00",
161
- end: "18:00"
162
- }
163
- },
164
- settings: {
165
- new_enrollments_per_account_per_day: 20,
166
- stop_on_engagement: false
167
- },
119
+ description: "Visit, like a recent post, invite without a note, then two messages after acceptance.",
168
120
  sequence: {
169
121
  $schema: "https://docs.curviate.com/schemas/sequence/v1.json",
170
122
  on_reply: "replied",
@@ -273,26 +225,7 @@ var connect_and_converse_default = {
273
225
  // src/templates/engage-then-connect.json
274
226
  var engage_then_connect_default = {
275
227
  name: "Engage then connect",
276
- contact_list_ids: [],
277
- account_ids: [],
278
- schedule: {
279
- timezone: null,
280
- days: [
281
- "mon",
282
- "tue",
283
- "wed",
284
- "thu",
285
- "fri"
286
- ],
287
- hours: {
288
- start: "09:00",
289
- end: "18:00"
290
- }
291
- },
292
- settings: {
293
- new_enrollments_per_account_per_day: 20,
294
- stop_on_engagement: false
295
- },
228
+ description: "React and comment on a recent post, then invite and two messages.",
296
229
  sequence: {
297
230
  on_reply: "replied",
298
231
  steps: [
@@ -316,7 +249,7 @@ var engage_then_connect_default = {
316
249
  text: "{{comment}}",
317
250
  fallback: "skip"
318
251
  },
319
- note: "The agent writes one comment per Contact; no product mention."
252
+ note: "Your AI writes one comment per Contact; no product mention."
320
253
  },
321
254
  {
322
255
  id: "w_invite",
@@ -385,26 +318,7 @@ var engage_then_connect_default = {
385
318
  // src/templates/nurture-connections.json
386
319
  var nurture_connections_default = {
387
320
  name: "Nurture connections",
388
- contact_list_ids: [],
389
- account_ids: [],
390
- schedule: {
391
- timezone: null,
392
- days: [
393
- "mon",
394
- "tue",
395
- "wed",
396
- "thu",
397
- "fri"
398
- ],
399
- hours: {
400
- start: "09:00",
401
- end: "18:00"
402
- }
403
- },
404
- settings: {
405
- assign: "already_connected",
406
- stop_on_engagement: false
407
- },
321
+ description: "Message existing Connections twice; people not connected are tagged and skipped.",
408
322
  sequence: {
409
323
  on_reply: "replied",
410
324
  steps: [
@@ -538,6 +452,12 @@ async function runList(c, f) {
538
452
  if (bad.length) usage(`--status takes a comma list of ${STATUSES.join(", ")}.`);
539
453
  params["status"] = status;
540
454
  }
455
+ const accounts = f.accounts ?? f.account;
456
+ if (accounts !== void 0) params["account_id"] = listFlag("accounts", accounts);
457
+ if (f.sort !== void 0) {
458
+ if (!["updated", "activity"].includes(f.sort)) usage("--sort takes updated or activity.");
459
+ params["sort"] = f.sort;
460
+ }
541
461
  if (f.limit !== void 0) params["limit"] = intFlag("limit", f.limit, 1, 100);
542
462
  const cursor = readCursorFlag(f, process);
543
463
  if (cursor) params["cursor"] = cursor;
@@ -632,8 +552,8 @@ async function runLint(f) {
632
552
  async function runInit(f) {
633
553
  const tpl = Object.prototype.hasOwnProperty.call(TEMPLATES, f.template ?? "") ? TEMPLATES[f.template] : void 0;
634
554
  if (!tpl) usage(`--template takes one of ${Object.keys(TEMPLATES).join(", ")}.`);
635
- const doc = structuredClone(tpl);
636
- doc.schedule.timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
555
+ const { name, sequence } = tpl;
556
+ const doc = { name, sequence: structuredClone(sequence) };
637
557
  const text = JSON.stringify(doc, null, 2) + "\n";
638
558
  if (f.output === void 0) return void process.stdout.write(text);
639
559
  try {
@@ -659,12 +579,14 @@ var SEE_LIFECYCLE = ["curviate motion get", "curviate enrollment list"];
659
579
  var listCmd = defineCommand({
660
580
  meta: {
661
581
  name: "list",
662
- description: "List your Team's Motions, most recently updated first. Items carry no Sequence: read one with `curviate motion get <motion_id>`.",
582
+ description: "List your Team's Motions, most recently updated first (--sort activity: latest activity first, `last_activity_at`). Items carry no Sequence: read one with `curviate motion get <motion_id>`. A cursor belongs to its sort.",
663
583
  risk: "read",
664
- examples: ["curviate motion list", "curviate motion list --status active,paused"]
584
+ examples: ["curviate motion list", "curviate motion list --status active,paused", "curviate motion list --accounts acc_A,acc_B --sort activity"]
665
585
  },
666
586
  args: {
667
587
  ...readOnly(GLOBAL_FLAGS),
588
+ accounts: { type: "string", description: "Only Motions sending from one of these Accounts: a comma list of ids (acc_...). --account a,b is accepted as the same filter." },
589
+ sort: { type: "string", description: "updated (default) or activity." },
668
590
  status: { type: "string", description: `Comma list of ${STATUSES.join(", ")}. Default: all but archived.` }
669
591
  },
670
592
  run: online(runList)
@@ -698,7 +620,7 @@ var MOTION_DOC = `{
698
620
  var createCmd = defineCommand({
699
621
  meta: {
700
622
  name: "create",
701
- description: "Create a Motion from a Motion file, always as a draft: nothing runs until `curviate motion start`. The file is checked before anything is sent, its Sequence as `curviate motion lint` checks it.",
623
+ description: "Create a Motion from a Motion file, always as a draft: nothing runs until `curviate motion start`. The file is checked before anything is sent, its Sequence as `curviate motion lint` checks it. Needs Automate.",
702
624
  risk: "write",
703
625
  rules: {
704
626
  changes: "Creates a draft Motion. No Contact is enrolled and nothing reaches LinkedIn until it is started.",
@@ -726,7 +648,7 @@ EOF`
726
648
  var updateCmd = defineCommand({
727
649
  meta: {
728
650
  name: "update",
729
- description: "Change a Motion from a Motion file: objects (schedule, settings) merge by key, arrays and the Sequence replace whole, null clears. After start, a structural Sequence change makes a new version; running Enrollments keep theirs. With --if-revision the save is refused when someone saved the Sequence since.",
651
+ description: "Change a Motion from a Motion file: objects (schedule, settings) merge by key, arrays and the Sequence replace whole, null clears. After start, a structural Sequence change makes a new version; running Enrollments keep theirs. With --if-revision the save is refused when someone saved the Sequence since. Needs Automate.",
730
652
  risk: "write",
731
653
  rules: {
732
654
  changes: "Changes the Motion. A running Motion picks the change up at each Enrollment's next Step.",
@@ -764,7 +686,7 @@ var lifecycleCmd = (name, meta) => defineCommand({
764
686
  run: online(lifecycle(name))
765
687
  });
766
688
  var startCmd = lifecycleCmd("start", {
767
- description: "Start a draft: scheduled when its start time is ahead, else active. Freezes Sequence version 1. A Motion missing what it needs is refused with every gap listed.",
689
+ description: "Start a draft: scheduled when its start time is ahead, else active. Freezes Sequence version 1. A Motion missing what it needs is refused with every gap listed. Needs Automate.",
768
690
  risk: "high",
769
691
  rules: {
770
692
  changes: "The Motion starts enrolling its Contacts and running its Steps from its sending Accounts, paced on its schedule.",
@@ -774,7 +696,7 @@ var startCmd = lifecycleCmd("start", {
774
696
  undo: "`curviate motion pause <motion_id>` stops new Steps; what was sent stays sent.",
775
697
  blast_radius: "Every Contact of its Contact lists, from every sending Account, each Step spending that Account's budgets (`curviate account get <account_id>`)."
776
698
  },
777
- errors: { MOTION_NOT_STARTABLE: "a gap stops it (Contact list, sending Account, timezone, Sequence); each is listed.", MOTION_STATUS_CONFLICT: "only a draft starts.", ...ROLE_ERRORS, TIER_REQUIRED: "Motions need the Automate plan." },
699
+ errors: { MOTION_NOT_STARTABLE: "a gap stops it (Contact list, sending Account, Sequence); each is listed.", MOTION_STATUS_CONFLICT: "only a draft starts.", ...ROLE_ERRORS, TIER_REQUIRED: "Motions need the Automate plan." },
778
700
  seeAlso: ["curviate motion preview", "curviate motion pause"]
779
701
  });
780
702
  var pauseCmd = lifecycleCmd("pause", {
@@ -791,7 +713,7 @@ var pauseCmd = lifecycleCmd("pause", {
791
713
  seeAlso: SEE_LIFECYCLE
792
714
  });
793
715
  var resumeCmd = lifecycleCmd("resume", {
794
- description: "Resume a paused Motion. Runs the start checks again.",
716
+ description: "Resume a paused Motion. Runs the start checks again. Needs Automate.",
795
717
  risk: "high",
796
718
  rules: {
797
719
  changes: "The Motion's Steps run again from its sending Accounts.",
@@ -850,7 +772,7 @@ var previewCmd = defineCommand({
850
772
  var membershipCmd = (kind) => defineCommand({
851
773
  meta: {
852
774
  name: kind,
853
- description: kind === "add" ? "Enroll Contacts directly, on an Account of the Motion (--account) or one Curviate assigns. Every exclusion and filter applies; each Contact's outcome says what happened. Sent in requests of up to 1000 ids, in order." : "Take Contacts out of the Motion: their open Enrollments end (removed). Sent in requests of up to 1000 ids, in order.",
775
+ description: kind === "add" ? "Enroll Contacts directly, on an Account of the Motion (--account) or one Curviate assigns. Every exclusion and filter applies; each Contact's outcome says what happened. Sent in requests of up to 1000 ids, in order. Needs Automate." : "Take Contacts out of the Motion: their open Enrollments end (removed). Sent in requests of up to 1000 ids, in order.",
854
776
  risk: "high",
855
777
  rules: kind === "add" ? {
856
778
  changes: "Each queued Contact becomes a pending Enrollment; a running Motion reaches it on its schedule.",
@@ -900,7 +822,7 @@ var lintCmd = defineCommand({
900
822
  var initCmd = defineCommand({
901
823
  meta: {
902
824
  name: "init",
903
- description: `Write a Motion file from a template (${Object.keys(TEMPLATES).join(", ")}), its schedule in this machine's timezone. Fill contact_list_ids and account_ids, then create it.`,
825
+ description: `Write a Motion file from a template (${Object.keys(TEMPLATES).join(", ")}). Fill contact_list_ids and account_ids, then create it.`,
904
826
  risk: "read",
905
827
  rules: OFFLINE,
906
828
  output: ["The Motion file on stdout, or in the --output file."],
@@ -933,7 +855,7 @@ var motionCommand = defineCommand({
933
855
  init: initCmd
934
856
  },
935
857
  async run() {
936
- const { showHelp } = await import("./examples-NIMSIXMV.js");
858
+ const { showHelp } = await import("./examples-JJB4DZKK.js");
937
859
  await showHelp(motionCommand, ["curviate", "motion"]);
938
860
  }
939
861
  });
@@ -0,0 +1,235 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ print,
4
+ table
5
+ } from "./chunk-5S3MJVI5.js";
6
+ import {
7
+ formatRows,
8
+ writeExport
9
+ } from "./chunk-PPGKQJKU.js";
10
+ import {
11
+ fail,
12
+ listFlag,
13
+ outputOpts,
14
+ rootClient,
15
+ usage
16
+ } from "./chunk-3Z6PXS6N.js";
17
+ import {
18
+ buildPreviewOutput
19
+ } from "./chunk-TCUYH5GO.js";
20
+ import {
21
+ intFlag
22
+ } from "./chunk-NNV2OYEF.js";
23
+ import {
24
+ pageDelayFromFlags,
25
+ readCursorFlag,
26
+ readMaxPagesFlag,
27
+ readablePage,
28
+ rejectPaginationModifiersWithoutAll,
29
+ streamAll
30
+ } from "./chunk-LRMPS4UQ.js";
31
+ import {
32
+ renderSuccess,
33
+ writeNdjsonItem
34
+ } from "./chunk-QM57YDJE.js";
35
+ import "./chunk-LULN3II2.js";
36
+ import {
37
+ GLOBAL_FLAGS,
38
+ WRITE_SINGLE_FLAGS,
39
+ readOnly
40
+ } from "./chunk-RYWWSZUH.js";
41
+ import {
42
+ DESCRIPTIONS
43
+ } from "./chunk-73DJ3KNE.js";
44
+ import "./chunk-ZYURL5VK.js";
45
+
46
+ // src/commands/network.ts
47
+ import { defineCommand } from "citty";
48
+ var CONNECTION_FIELDS = [
49
+ "account_id",
50
+ "member_id",
51
+ "public_identifier",
52
+ "public_profile_url",
53
+ "first_name",
54
+ "last_name",
55
+ "headline",
56
+ "job_title",
57
+ "company",
58
+ "location",
59
+ "profile_picture_url",
60
+ "connected_at",
61
+ "first_seen_at",
62
+ "removed_at",
63
+ "observed_at"
64
+ ];
65
+ function listParams(f) {
66
+ const q = {};
67
+ if (f.accounts !== void 0) q["account_id"] = listFlag("accounts", f.accounts);
68
+ if (f.query !== void 0) q["q"] = f.query;
69
+ if (f["include-removed"]) q["include_removed"] = true;
70
+ return q;
71
+ }
72
+ async function runList(c, f) {
73
+ rejectPaginationModifiersWithoutAll(f, process);
74
+ const params = listParams(f);
75
+ if (f.limit !== void 0) params["limit"] = intFlag("limit", f.limit, 1, 1e3);
76
+ const cursor = readCursorFlag(f, process);
77
+ if (cursor) params["cursor"] = cursor;
78
+ try {
79
+ if (f.all) {
80
+ const page2 = (p) => c.network.connections.list(p);
81
+ for await (const item of streamAll(page2, params, { maxPages: readMaxPagesFlag(f, process), out: process, pageDelayMs: pageDelayFromFlags(f) })) writeNdjsonItem(process, item, f.fields);
82
+ return;
83
+ }
84
+ const page = readablePage(await c.network.connections.list(params));
85
+ if (outputOpts(f).json) return renderSuccess(page, outputOpts(f), process);
86
+ print(table(["NAME", "HEADLINE", "ACCOUNT", "CONNECTED"], page.items.map((i) => [[i["first_name"], i["last_name"]].filter(Boolean).join(" "), i["headline"], i["account_id"], i["connected_at"] ?? i["first_seen_at"]])));
87
+ coverageNote(page["coverage"]);
88
+ if (page["cursor"]) print(`next page: --cursor ${String(page["cursor"])}`);
89
+ } catch (err) {
90
+ await fail(err, f);
91
+ }
92
+ }
93
+ function coverageNote(coverage) {
94
+ const cov = coverage;
95
+ if (cov?.complete === false) process.stderr.write(`warning: ${cov.accounts_incomplete ?? "some"} Account(s) in scope have not finished their first sync; the list is incomplete. See \`curviate network status\`.
96
+ `);
97
+ }
98
+ async function runStatus(c, f) {
99
+ const params = {};
100
+ if (f.accounts !== void 0) params["account_id"] = listFlag("accounts", f.accounts);
101
+ try {
102
+ const res = await c.network.syncStatus(params);
103
+ if (outputOpts(f).json) return renderSuccess(res, outputOpts(f), process);
104
+ const win = (w) => {
105
+ const r = w;
106
+ return r ? `${r["start"]}-${r["end"]} ${r["effective_timezone"] ?? "no zone"} (${r["zone_state"]})` : null;
107
+ };
108
+ print(table(
109
+ ["ACCOUNT", "STATE", "PAUSED", "STORED", "LAST FULL SYNC", "NEXT READ", "RESYNC FROM", "READ WINDOW"],
110
+ (res.items ?? []).map((i) => [i["account_id"], i["state"], i["paused_reason"], i["connections_stored"], i["last_full_sync_at"], i["next_run_at"], i["next_manual_resync_at"], win(i["read_window"])])
111
+ ));
112
+ } catch (err) {
113
+ await fail(err, f);
114
+ }
115
+ }
116
+ async function runExport(c, f) {
117
+ if (f.json) usage("export commands take no --json: pass --format json.");
118
+ const format = f.format ?? "ndjson";
119
+ if (!["csv", "json", "ndjson"].includes(format)) usage("--format takes csv, json or ndjson.");
120
+ const fields = f.fields === void 0 ? CONNECTION_FIELDS : listFlag("fields", f.fields);
121
+ const rows = [];
122
+ let first = true;
123
+ try {
124
+ for (let cursor; first || cursor; first = false) {
125
+ const page = readablePage(await c.network.connections.list({ ...listParams(f), limit: 1e3, ...cursor ? { cursor } : {} }));
126
+ if (first) coverageNote(page["coverage"]);
127
+ rows.push(...page.items);
128
+ cursor = page["cursor"];
129
+ }
130
+ await writeExport(f.output, formatRows(rows, fields, format));
131
+ } catch (err) {
132
+ await fail(err, f);
133
+ }
134
+ process.stderr.write(`${rows.length} Connections exported.
135
+ `);
136
+ }
137
+ async function runResync(c, f) {
138
+ if (f.accountId === void 0 === !f.all) usage("name one Account (`curviate network resync <account_id>`) or pass --all for every Account you may operate, not both.");
139
+ const body = f.accountId === void 0 ? {} : { account_id: f.accountId };
140
+ if (f.preview) return print(JSON.stringify(buildPreviewOutput({ method: "network.resync", args: {}, body })));
141
+ try {
142
+ renderSuccess(await c.network.resync(body), outputOpts(f), process);
143
+ } catch (err) {
144
+ await fail(err, f);
145
+ }
146
+ }
147
+ var online = (fn) => async ({ args }) => {
148
+ const f = args;
149
+ await fn(await rootClient(f), f);
150
+ };
151
+ var FILTERS = {
152
+ accounts: { type: "string", description: "Only these Accounts: a comma list of ids (acc_...). Never filled from your profile's default Account." },
153
+ query: { type: "string", description: "Name or headline contains this text (3 to 100 characters)." },
154
+ "include-removed": { type: "boolean", description: "Also list Connections that have left (removed_at set)." }
155
+ };
156
+ var listCmd = defineCommand({
157
+ meta: {
158
+ name: "list",
159
+ description: "List the stored Connections of the Accounts you may operate, newest first: one item per Account and person. Read from Curviate's store: no LinkedIn call, no budget. An empty list with incomplete coverage means not synced yet, never no Connections.",
160
+ risk: "read",
161
+ output: ["A table of name, headline, Account and connection time; --json (or piped) prints the API page with `coverage`."],
162
+ seeAlso: ["curviate network status", "curviate network export"],
163
+ examples: ["curviate network list", "curviate network list --query founder --accounts acc_YOUR_ACCOUNT_ID"]
164
+ },
165
+ args: { ...readOnly(GLOBAL_FLAGS), ...FILTERS },
166
+ run: online(runList)
167
+ });
168
+ var statusCmd = defineCommand({
169
+ meta: {
170
+ name: "status",
171
+ description: "How far each Account's Connection sync is: state, why it is paused, Connections stored, the last full sync, the next read, when a manual resync is allowed again, and the read window.",
172
+ risk: "read",
173
+ examples: ["curviate network status", "curviate network status --accounts acc_YOUR_ACCOUNT_ID"]
174
+ },
175
+ args: { ...readOnly(WRITE_SINGLE_FLAGS), accounts: FILTERS.accounts },
176
+ run: online(runStatus)
177
+ });
178
+ var exportCmd = defineCommand({
179
+ meta: {
180
+ name: "export",
181
+ description: "Export the stored Connections, every page, with the list filters. Writes ndjson (default), json or csv to stdout or a file (mode 0600). A count goes to stderr, and a warning when an Account in scope has not finished its first sync (exit 0).",
182
+ risk: "read",
183
+ output: ["Data only on stdout or the --output file; the count and warnings on stderr. CSV is UTF-8 with a BOM; a cell starting with = + - @ or ' gets a leading '."],
184
+ examples: ["curviate network export --format csv -o connections.csv", "curviate network export --accounts acc_YOUR_ACCOUNT_ID --fields first_name,last_name,public_profile_url"]
185
+ },
186
+ args: {
187
+ "api-key": GLOBAL_FLAGS["api-key"],
188
+ profile: GLOBAL_FLAGS.profile,
189
+ team: GLOBAL_FLAGS.team,
190
+ "base-url": GLOBAL_FLAGS["base-url"],
191
+ timeout: GLOBAL_FLAGS.timeout,
192
+ ...FILTERS,
193
+ format: { type: "string", description: "csv, json or ndjson (default ndjson)." },
194
+ output: { type: "string", alias: "o", description: "File to write (mode 0600; replaced only when the export completes), or - for stdout (default)." },
195
+ fields: { type: "string", description: `Columns, comma-separated, in order (default: ${CONNECTION_FIELDS.join(", ")}).` },
196
+ json: { type: "boolean", description: "Not taken by exports: pass --format json." }
197
+ },
198
+ run: online(runExport)
199
+ });
200
+ var resyncCmd = defineCommand({
201
+ meta: {
202
+ name: "resync",
203
+ description: "Start a fresh walk of an Account's Connections now, or of every Account you may operate with --all. Once per Account per day; pages are read inside the Account's read window. Answers queued, cooldown, in_progress or paused per Account: answers, not errors. Needs Automate.",
204
+ risk: "high",
205
+ rules: {
206
+ changes: "Opens a sync walk; Curviate reads the Account's Connections from LinkedIn over the next hours.",
207
+ visible_to: "Nobody: reads only.",
208
+ budget_rows: ["connections_sync"],
209
+ retry: "A second call within the same day answers cooldown; nothing new starts.",
210
+ undo: "Cannot be stopped once queued; the walk ends on its own.",
211
+ blast_radius: "One Account, or with --all every Account you may operate."
212
+ },
213
+ errors: { ACCOUNT_NOT_FOUND: "the Account is not in your Team.", INSUFFICIENT_ROLE: "your role cannot operate the Account.", ACCOUNT_NOT_SHARED: "the Account is not shared with you.", TIER_REQUIRED: "your plan does not include Network." },
214
+ seeAlso: ["curviate network status"],
215
+ examples: ["curviate network resync --all", "curviate network resync acc_YOUR_ACCOUNT_ID"]
216
+ },
217
+ args: {
218
+ ...WRITE_SINGLE_FLAGS,
219
+ accountId: { type: "positional", required: false, description: "The Account to resync (acc_...). Omit it with --all." },
220
+ all: { type: "boolean", description: "Resync every Account you may operate." }
221
+ },
222
+ run: online(runResync)
223
+ });
224
+ var networkCommand = defineCommand({
225
+ meta: { name: "network", description: DESCRIPTIONS.network },
226
+ subCommands: { list: listCmd, status: statusCmd, export: exportCmd, resync: resyncCmd },
227
+ async run() {
228
+ const { showHelp } = await import("./examples-JJB4DZKK.js");
229
+ await showHelp(networkCommand, ["curviate", "network"]);
230
+ }
231
+ });
232
+ export {
233
+ CONNECTION_FIELDS,
234
+ networkCommand
235
+ };