@startanaicompany/crm 1.0.2 → 2.0.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 (2) hide show
  1. package/index.js +330 -1
  2. package/package.json +10 -3
package/index.js CHANGED
@@ -99,7 +99,7 @@ const program = new Command();
99
99
  program
100
100
  .name('saac_crm')
101
101
  .description('AI-first CRM CLI — manage leads and API keys')
102
- .version('1.0.2')
102
+ .version('1.0.3')
103
103
  .option('--api-key <key>', 'API key (overrides SAAC_CRM_API_KEY env and config)')
104
104
  .option('--url <url>', 'API base URL (overrides config)');
105
105
 
@@ -337,6 +337,10 @@ leadsCmd
337
337
  .option('--tag <tag>', 'Filter by tag — repeatable, AND logic', (v, prev) => prev.concat([v]), [])
338
338
  .option('--api-key-id <id>', 'Filter by the API key ID that created the lead')
339
339
  .option('--self', 'Filter leads created by the current API key (shorthand for --api-key-id self)')
340
+ .option('--created-after <date>', 'Filter leads created after this ISO8601 date (e.g. 2026-01-01T00:00:00Z)')
341
+ .option('--created-before <date>', 'Filter leads created before this ISO8601 date')
342
+ .option('--updated-after <date>', 'Filter leads updated after this ISO8601 date')
343
+ .option('--updated-before <date>', 'Filter leads updated before this ISO8601 date')
340
344
  .option('--page <n>', 'Page number', '1')
341
345
  .option('--per-page <n>', 'Results per page', '20')
342
346
  .action(async (opts) => {
@@ -349,6 +353,10 @@ leadsCmd
349
353
  ...(opts.email && { email: opts.email }),
350
354
  ...(opts.company && { company: opts.company }),
351
355
  ...(apiKeyIdFilter && { api_key_id: apiKeyIdFilter }),
356
+ ...(opts.createdAfter && { created_after: opts.createdAfter }),
357
+ ...(opts.createdBefore && { created_before: opts.createdBefore }),
358
+ ...(opts.updatedAfter && { updated_after: opts.updatedAfter }),
359
+ ...(opts.updatedBefore && { updated_before: opts.updatedBefore }),
352
360
  page: opts.page,
353
361
  per_page: opts.perPage
354
362
  };
@@ -588,4 +596,325 @@ program
588
596
  }
589
597
  });
590
598
 
599
+ // ============================================================
600
+ // CONTACTS
601
+ // ============================================================
602
+
603
+ const contactsCmd = program
604
+ .command('contacts')
605
+ .description('Manage contacts (people separate from leads)');
606
+
607
+ contactsCmd
608
+ .command('create')
609
+ .description('Create a new contact')
610
+ .requiredOption('--first-name <name>', 'First name')
611
+ .option('--last-name <name>', 'Last name')
612
+ .option('--email <email>', 'Email address (unique)')
613
+ .option('--phone <phone>', 'Phone number')
614
+ .option('--company <company>', 'Company name')
615
+ .option('--title <title>', 'Job title')
616
+ .option('--tags <tags>', 'Comma-separated tags')
617
+ .option('--do-not-contact', 'Mark as do not contact')
618
+ .option('--notes <notes>', 'Notes')
619
+ .action(async (opts) => {
620
+ const globalOpts = program.opts();
621
+ const client = getClient(globalOpts);
622
+ try {
623
+ const body = {
624
+ first_name: opts.firstName,
625
+ last_name: opts.lastName,
626
+ email: opts.email,
627
+ phone: opts.phone,
628
+ company: opts.company,
629
+ title: opts.title,
630
+ notes: opts.notes,
631
+ do_not_contact: opts.doNotContact === true,
632
+ };
633
+ if (opts.tags) body.tags = opts.tags.split(',').map(t => t.trim());
634
+ const res = await client.post('/contacts', body);
635
+ printJSON(res.data);
636
+ } catch (err) {
637
+ handleError(err);
638
+ }
639
+ });
640
+
641
+ contactsCmd
642
+ .command('list')
643
+ .description('List contacts')
644
+ .option('--email <email>', 'Filter by email (partial match)')
645
+ .option('--company <company>', 'Filter by company (partial match)')
646
+ .option('--tag <tag>', 'Filter by tag')
647
+ .option('--page <n>', 'Page number', '1')
648
+ .option('--per-page <n>', 'Results per page', '20')
649
+ .action(async (opts) => {
650
+ const globalOpts = program.opts();
651
+ const client = getClient(globalOpts);
652
+ try {
653
+ const params = { page: opts.page, per_page: opts.perPage };
654
+ if (opts.email) params.email = opts.email;
655
+ if (opts.company) params.company = opts.company;
656
+ if (opts.tag) params.tag = opts.tag;
657
+ const res = await client.get('/contacts', { params });
658
+ printJSON(res.data);
659
+ } catch (err) {
660
+ handleError(err);
661
+ }
662
+ });
663
+
664
+ contactsCmd
665
+ .command('get <id>')
666
+ .description('Get a contact by ID')
667
+ .action(async (id) => {
668
+ const globalOpts = program.opts();
669
+ const client = getClient(globalOpts);
670
+ try {
671
+ const res = await client.get(`/contacts/${id}`);
672
+ printJSON(res.data);
673
+ } catch (err) {
674
+ handleError(err);
675
+ }
676
+ });
677
+
678
+ contactsCmd
679
+ .command('update <id>')
680
+ .description('Update a contact')
681
+ .option('--first-name <name>', 'First name')
682
+ .option('--last-name <name>', 'Last name')
683
+ .option('--email <email>', 'Email address')
684
+ .option('--phone <phone>', 'Phone number')
685
+ .option('--company <company>', 'Company name')
686
+ .option('--title <title>', 'Job title')
687
+ .option('--tags <tags>', 'Comma-separated tags')
688
+ .option('--notes <notes>', 'Notes')
689
+ .action(async (id, opts) => {
690
+ const globalOpts = program.opts();
691
+ const client = getClient(globalOpts);
692
+ try {
693
+ const body = {};
694
+ if (opts.firstName !== undefined) body.first_name = opts.firstName;
695
+ if (opts.lastName !== undefined) body.last_name = opts.lastName;
696
+ if (opts.email !== undefined) body.email = opts.email;
697
+ if (opts.phone !== undefined) body.phone = opts.phone;
698
+ if (opts.company !== undefined) body.company = opts.company;
699
+ if (opts.title !== undefined) body.title = opts.title;
700
+ if (opts.tags !== undefined) body.tags = opts.tags.split(',').map(t => t.trim());
701
+ if (opts.notes !== undefined) body.notes = opts.notes;
702
+ const res = await client.patch(`/contacts/${id}`, body);
703
+ printJSON(res.data);
704
+ } catch (err) {
705
+ handleError(err);
706
+ }
707
+ });
708
+
709
+ contactsCmd
710
+ .command('delete <id>')
711
+ .description('Soft-delete a contact')
712
+ .action(async (id) => {
713
+ const globalOpts = program.opts();
714
+ const client = getClient(globalOpts);
715
+ try {
716
+ const res = await client.delete(`/contacts/${id}`);
717
+ printJSON(res.data);
718
+ } catch (err) {
719
+ handleError(err);
720
+ }
721
+ });
722
+
723
+ contactsCmd
724
+ .command('leads <id>')
725
+ .description('List leads linked to a contact')
726
+ .action(async (id) => {
727
+ const globalOpts = program.opts();
728
+ const client = getClient(globalOpts);
729
+ try {
730
+ const res = await client.get(`/contacts/${id}/leads`);
731
+ printJSON(res.data);
732
+ } catch (err) {
733
+ handleError(err);
734
+ }
735
+ });
736
+
737
+ // ============================================================
738
+ // BOARD — sales pipeline board
739
+ // ============================================================
740
+
741
+ program
742
+ .command('board')
743
+ .description('Show sales pipeline board (leads grouped by stage)')
744
+ .action(async () => {
745
+ const globalOpts = program.opts();
746
+ const client = getClient(globalOpts);
747
+ try {
748
+ const res = await client.get('/board');
749
+ printJSON(res.data);
750
+ } catch (err) {
751
+ handleError(err);
752
+ }
753
+ });
754
+
755
+ // ============================================================
756
+ // CALLS
757
+ // ============================================================
758
+
759
+ const callsCmd = program
760
+ .command('calls')
761
+ .description('Manage call logs');
762
+
763
+ callsCmd
764
+ .command('create')
765
+ .description('Log a call')
766
+ .requiredOption('--direction <dir>', 'inbound or outbound')
767
+ .option('--lead-id <id>', 'Lead ID associated with this call')
768
+ .option('--contact-id <id>', 'Contact ID associated with this call')
769
+ .option('--outcome <outcome>', 'connected | left_voicemail | no_answer | busy | wrong_number | meeting_booked | demo_completed')
770
+ .option('--duration <seconds>', 'Duration in seconds')
771
+ .option('--notes <notes>', 'Call notes')
772
+ .option('--call-time <iso>', 'Call time (ISO8601, defaults to now)')
773
+ .action(async (opts) => {
774
+ const globalOpts = program.opts();
775
+ const client = getClient(globalOpts);
776
+ try {
777
+ const body = { direction: opts.direction };
778
+ if (opts.leadId) body.lead_id = opts.leadId;
779
+ if (opts.contactId) body.contact_id = opts.contactId;
780
+ if (opts.outcome) body.outcome = opts.outcome;
781
+ if (opts.duration) body.duration_seconds = parseInt(opts.duration);
782
+ if (opts.notes) body.notes = opts.notes;
783
+ if (opts.callTime) body.call_time = opts.callTime;
784
+ const res = await client.post('/calls', body);
785
+ printJSON(res.data);
786
+ } catch (err) {
787
+ handleError(err);
788
+ }
789
+ });
790
+
791
+ callsCmd
792
+ .command('list')
793
+ .description('List call logs')
794
+ .option('--lead-id <id>', 'Filter by lead ID')
795
+ .option('--contact-id <id>', 'Filter by contact ID')
796
+ .option('--direction <dir>', 'Filter by direction (inbound/outbound)')
797
+ .option('--outcome <outcome>', 'Filter by outcome')
798
+ .option('--page <n>', 'Page number', '1')
799
+ .option('--per-page <n>', 'Results per page', '20')
800
+ .action(async (opts) => {
801
+ const globalOpts = program.opts();
802
+ const client = getClient(globalOpts);
803
+ try {
804
+ const params = { page: opts.page, per_page: opts.perPage };
805
+ if (opts.leadId) params.lead_id = opts.leadId;
806
+ if (opts.contactId) params.contact_id = opts.contactId;
807
+ if (opts.direction) params.direction = opts.direction;
808
+ if (opts.outcome) params.outcome = opts.outcome;
809
+ const res = await client.get('/calls', { params });
810
+ printJSON(res.data);
811
+ } catch (err) {
812
+ handleError(err);
813
+ }
814
+ });
815
+
816
+ callsCmd
817
+ .command('get <id>')
818
+ .description('Get a call log by ID')
819
+ .action(async (id) => {
820
+ const globalOpts = program.opts();
821
+ const client = getClient(globalOpts);
822
+ try {
823
+ const res = await client.get(`/calls/${id}`);
824
+ printJSON(res.data);
825
+ } catch (err) {
826
+ handleError(err);
827
+ }
828
+ });
829
+
830
+ callsCmd
831
+ .command('update <id>')
832
+ .description('Update a call log')
833
+ .option('--outcome <outcome>', 'New outcome')
834
+ .option('--duration <seconds>', 'Duration in seconds')
835
+ .option('--notes <notes>', 'Call notes')
836
+ .action(async (id, opts) => {
837
+ const globalOpts = program.opts();
838
+ const client = getClient(globalOpts);
839
+ try {
840
+ const body = {};
841
+ if (opts.outcome !== undefined) body.outcome = opts.outcome;
842
+ if (opts.duration !== undefined) body.duration_seconds = parseInt(opts.duration);
843
+ if (opts.notes !== undefined) body.notes = opts.notes;
844
+ const res = await client.patch(`/calls/${id}`, body);
845
+ printJSON(res.data);
846
+ } catch (err) {
847
+ handleError(err);
848
+ }
849
+ });
850
+
851
+ callsCmd
852
+ .command('delete <id>')
853
+ .description('Soft-delete a call log')
854
+ .action(async (id) => {
855
+ const globalOpts = program.opts();
856
+ const client = getClient(globalOpts);
857
+ try {
858
+ const res = await client.delete(`/calls/${id}`);
859
+ printJSON(res.data);
860
+ } catch (err) {
861
+ handleError(err);
862
+ }
863
+ });
864
+
865
+
866
+ // ============================================================
867
+ // LEADS STAGE — pipeline stage management
868
+ // ============================================================
869
+
870
+ const leadsStageCmd = program
871
+ .command('leads-stage')
872
+ .description('Manage lead pipeline stages (sales board)');
873
+
874
+ leadsStageCmd
875
+ .command('get <lead-id>')
876
+ .description('Get the current pipeline stage of a lead')
877
+ .action(async (leadId) => {
878
+ const globalOpts = program.opts();
879
+ const client = getClient(globalOpts);
880
+ try {
881
+ const res = await client.get(`/leads/${leadId}/stage`);
882
+ printJSON(res.data);
883
+ } catch (err) {
884
+ handleError(err);
885
+ }
886
+ });
887
+
888
+ leadsStageCmd
889
+ .command('set <lead-id> <stage>')
890
+ .description('Set pipeline stage: new | qualified | proposal | negotiation | closed_won | closed_lost')
891
+ .option('--note <note>', 'Optional note about why stage changed')
892
+ .action(async (leadId, stage, opts) => {
893
+ const globalOpts = program.opts();
894
+ const client = getClient(globalOpts);
895
+ try {
896
+ const body = { stage };
897
+ if (opts.note) body.note = opts.note;
898
+ const res = await client.patch(`/leads/${leadId}/stage`, body);
899
+ printJSON(res.data);
900
+ } catch (err) {
901
+ handleError(err);
902
+ }
903
+ });
904
+
905
+ leadsStageCmd
906
+ .command('history <lead-id>')
907
+ .description('Get stage transition history for a lead')
908
+ .action(async (leadId) => {
909
+ const globalOpts = program.opts();
910
+ const client = getClient(globalOpts);
911
+ try {
912
+ const res = await client.get(`/leads/${leadId}/stage/history`);
913
+ printJSON(res.data);
914
+ } catch (err) {
915
+ handleError(err);
916
+ }
917
+ });
918
+
919
+
591
920
  program.parse(process.argv);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@startanaicompany/crm",
3
- "version": "1.0.2",
4
- "description": "AI-first CRM CLI manage leads and API keys from the terminal",
3
+ "version": "2.0.0",
4
+ "description": "AI-first CRM CLI \u2014 manage leads and API keys from the terminal",
5
5
  "main": "index.js",
6
6
  "bin": {
7
7
  "saac_crm": "./index.js"
@@ -9,7 +9,14 @@
9
9
  "scripts": {
10
10
  "test": "echo \"No tests yet\""
11
11
  },
12
- "keywords": ["crm", "ai", "leads", "api", "saac", "agent"],
12
+ "keywords": [
13
+ "crm",
14
+ "ai",
15
+ "leads",
16
+ "api",
17
+ "saac",
18
+ "agent"
19
+ ],
13
20
  "license": "MIT",
14
21
  "repository": {
15
22
  "type": "git",