@dealmachine/cli 0.3.0 → 0.5.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 (102) hide show
  1. package/README.md +103 -12
  2. package/dist/agents/dealmachine-playbook.md +91 -39
  3. package/dist/commands/account.d.ts +3 -1
  4. package/dist/commands/account.d.ts.map +1 -1
  5. package/dist/commands/account.js +8 -2
  6. package/dist/commands/account.js.map +1 -1
  7. package/dist/commands/activity.js.map +1 -1
  8. package/dist/commands/addresses.js.map +1 -1
  9. package/dist/commands/agents.d.ts +7 -0
  10. package/dist/commands/agents.d.ts.map +1 -1
  11. package/dist/commands/agents.js +123 -7
  12. package/dist/commands/agents.js.map +1 -1
  13. package/dist/commands/comps.js.map +1 -1
  14. package/dist/commands/config.js.map +1 -1
  15. package/dist/commands/dev.js.map +1 -1
  16. package/dist/commands/driving.d.ts +13 -0
  17. package/dist/commands/driving.d.ts.map +1 -0
  18. package/dist/commands/driving.js +68 -0
  19. package/dist/commands/driving.js.map +1 -0
  20. package/dist/commands/enrich.d.ts +1 -0
  21. package/dist/commands/enrich.d.ts.map +1 -1
  22. package/dist/commands/enrich.js +9 -1
  23. package/dist/commands/enrich.js.map +1 -1
  24. package/dist/commands/exports.js.map +1 -1
  25. package/dist/commands/fields.js.map +1 -1
  26. package/dist/commands/filters.d.ts.map +1 -1
  27. package/dist/commands/filters.js +9 -2
  28. package/dist/commands/filters.js.map +1 -1
  29. package/dist/commands/lists.d.ts +5 -0
  30. package/dist/commands/lists.d.ts.map +1 -1
  31. package/dist/commands/lists.js +30 -7
  32. package/dist/commands/lists.js.map +1 -1
  33. package/dist/commands/locations.d.ts.map +1 -1
  34. package/dist/commands/locations.js +11 -6
  35. package/dist/commands/locations.js.map +1 -1
  36. package/dist/commands/login.js.map +1 -1
  37. package/dist/commands/logout.js.map +1 -1
  38. package/dist/commands/mail.d.ts +17 -0
  39. package/dist/commands/mail.d.ts.map +1 -1
  40. package/dist/commands/mail.js +180 -0
  41. package/dist/commands/mail.js.map +1 -1
  42. package/dist/commands/onboarding.js.map +1 -1
  43. package/dist/commands/people.d.ts +3 -1
  44. package/dist/commands/people.d.ts.map +1 -1
  45. package/dist/commands/people.js +27 -1
  46. package/dist/commands/people.js.map +1 -1
  47. package/dist/commands/phones.d.ts.map +1 -1
  48. package/dist/commands/phones.js.map +1 -1
  49. package/dist/commands/properties.d.ts +3 -1
  50. package/dist/commands/properties.d.ts.map +1 -1
  51. package/dist/commands/properties.js +27 -1
  52. package/dist/commands/properties.js.map +1 -1
  53. package/dist/commands/prospects.d.ts +133 -0
  54. package/dist/commands/prospects.d.ts.map +1 -0
  55. package/dist/commands/prospects.js +662 -0
  56. package/dist/commands/prospects.js.map +1 -0
  57. package/dist/commands/subscription.js.map +1 -1
  58. package/dist/commands/tags.d.ts +36 -0
  59. package/dist/commands/tags.d.ts.map +1 -0
  60. package/dist/commands/tags.js +132 -0
  61. package/dist/commands/tags.js.map +1 -0
  62. package/dist/commands/tasks.js.map +1 -1
  63. package/dist/commands/usage.js.map +1 -1
  64. package/dist/commands/webhooks.d.ts +59 -0
  65. package/dist/commands/webhooks.d.ts.map +1 -0
  66. package/dist/commands/webhooks.js +272 -0
  67. package/dist/commands/webhooks.js.map +1 -0
  68. package/dist/commands/whoami.js.map +1 -1
  69. package/dist/index.d.ts +2 -1
  70. package/dist/index.d.ts.map +1 -1
  71. package/dist/index.js +530 -507
  72. package/dist/index.js.map +1 -1
  73. package/dist/lib/api.d.ts.map +1 -1
  74. package/dist/lib/api.js +2 -0
  75. package/dist/lib/api.js.map +1 -1
  76. package/dist/lib/client.d.ts +1 -0
  77. package/dist/lib/client.d.ts.map +1 -1
  78. package/dist/lib/client.js +23 -0
  79. package/dist/lib/client.js.map +1 -1
  80. package/dist/lib/config.js.map +1 -1
  81. package/dist/lib/confirm.d.ts +11 -0
  82. package/dist/lib/confirm.d.ts.map +1 -0
  83. package/dist/lib/confirm.js +27 -0
  84. package/dist/lib/confirm.js.map +1 -0
  85. package/dist/lib/creditSafety.d.ts +17 -0
  86. package/dist/lib/creditSafety.d.ts.map +1 -0
  87. package/dist/lib/creditSafety.js +29 -0
  88. package/dist/lib/creditSafety.js.map +1 -0
  89. package/dist/lib/output.js.map +1 -1
  90. package/dist/lib/searchProtocol.js.map +1 -1
  91. package/dist/version.d.ts +2 -2
  92. package/dist/version.js +1 -1
  93. package/dist/version.js.map +1 -1
  94. package/package.json +29 -6
  95. package/dist/commands/crm.d.ts +0 -122
  96. package/dist/commands/crm.d.ts.map +0 -1
  97. package/dist/commands/crm.js +0 -519
  98. package/dist/commands/crm.js.map +0 -1
  99. package/dist/commands/dialer.d.ts +0 -79
  100. package/dist/commands/dialer.d.ts.map +0 -1
  101. package/dist/commands/dialer.js +0 -389
  102. package/dist/commands/dialer.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env node
2
+ import { realpathSync } from 'node:fs';
3
+ import { fileURLToPath } from 'node:url';
2
4
  import { Command } from 'commander';
3
5
  import { CLI_VERSION } from './version.js';
4
6
  import { login } from './commands/login.js';
@@ -7,7 +9,7 @@ import { whoami } from './commands/whoami.js';
7
9
  import { configGet, configSet, configPath } from './commands/config.js';
8
10
  import { account } from './commands/account.js';
9
11
  import { usage } from './commands/usage.js';
10
- import { agentsGuide, agentsPlaybook } from './commands/agents.js';
12
+ import { agentsGuide, agentsInstallClaudeCode, agentsPermissions, agentsPlaybook, } from './commands/agents.js';
11
13
  import { checkout, plans, signup } from './commands/onboarding.js';
12
14
  import { propertiesSearch, propertiesCount, propertiesGet, propertiesIds, propertiesExport, } from './commands/properties.js';
13
15
  import { peopleSearch, peopleCount, peopleGet, peopleIds, peopleExport, } from './commands/people.js';
@@ -24,10 +26,12 @@ import { exportsList, exportsGet } from './commands/exports.js';
24
26
  import { subscriptionStatus } from './commands/subscription.js';
25
27
  import { listsList, listsCreate, listsGet, listsUpdate, listsDelete, listsBuild, listsImport, listsItems, listsAdd, listsRemove, listsExport, } from './commands/lists.js';
26
28
  import { tasksList, tasksGet, tasksCreate, tasksUpdate, tasksDelete } from './commands/tasks.js';
27
- import { crmPipelines, crmOpportunitiesList, crmOpportunitiesGet, crmOpportunitiesCreate, crmOpportunitiesUpdate, crmOpportunitiesDelete, crmOpportunitiesMove, crmTasksList, crmTasksCreate, crmTasksUpdate, crmNotesList, crmNotesCreate, crmNotesUpdate, crmRecordsList, crmRecordsLink, crmRecordsUnlink, crmLabelsList, crmLabelsCreate, crmLabelsUpdate, crmLabelsDelete, crmOpportunityLabelsAdd, crmOpportunityLabelsRemove, crmSubscribersList, crmSubscribersAdd, crmSubscribersRemove, crmActivity, } from './commands/crm.js';
28
- import { dialerCallsList, dialerCallsGet, dialerCallsStats, dialerNotesList, dialerNotesCreate, dialerNotesDelete, dialerQueuesList, dialerQueuesCreate, dialerQueuesDelete, dialerQueueItemsList, dialerQueueItemsAdd, dialerQueueItemsUpdate, dialerQueueItemsRemove, dialerDispositions, dialerSuppressionList, dialerSuppressionCheck, dialerSuppressionAdd, } from './commands/dialer.js';
29
- import { mailCampaignsList, mailCampaignsCreate, mailCampaignsGet, mailCampaignsUpdate, mailCampaignsDelete, mailCampaignsSend, mailCampaignsPause, mailCampaignsResume, mailCampaignsRecipients, mailCampaignsAnalytics, mailCampaignsCostEstimate, mailDesignsList, mailDesignsCreate, mailDesignsGet, mailDesignsUpdate, mailDesignsDelete, mailReturnAddressesList, mailReturnAddressesCreate, mailReturnAddressesGet, mailReturnAddressesUpdate, mailReturnAddressesDelete, mailReturnAddressesSetDefault, mailWalletBalance, mailWalletAddFunds, mailWalletTransactions, mailWalletPricing, mailSettingsGet, mailSettingsUpdate, mailAnalyticsSummary, mailAnalyticsTimeseries, } from './commands/mail.js';
30
- const program = new Command();
29
+ import { drivingList, drivingGet } from './commands/driving.js';
30
+ import { mailCampaignsList, mailCampaignsCreate, mailCampaignsGet, mailCampaignsUpdate, mailCampaignsDelete, mailCampaignsSend, mailCampaignsPause, mailCampaignsResume, mailCampaignsRecipients, mailCampaignsAnalytics, mailCampaignsCostEstimate, mailCampaignsAddProperties, mailCampaignsEstimateAdd, mailCampaignsEnd, mailDesignsList, mailDesignsCreate, mailDesignsGet, mailDesignsUpdate, mailDesignsDelete, mailReturnAddressesList, mailReturnAddressesCreate, mailReturnAddressesGet, mailReturnAddressesUpdate, mailReturnAddressesDelete, mailReturnAddressesSetDefault, mailWalletBalance, mailWalletAddFunds, mailWalletTransactions, mailWalletPricing, mailSettingsGet, mailSettingsUpdate, mailAnalyticsSummary, mailAnalyticsTimeseries, } from './commands/mail.js';
31
+ import { prospectsList, prospectsGet, prospectsGetByRecord, prospectsAdd, prospectsArchive, prospectsRemove, prospectsReactivate, prospectsOpportunity, prospectsFavorite, prospectsCheck, prospectsCounts, prospectsActivity, prospectNotesList, prospectNotesGet, prospectNotesAdd, prospectNotesEdit, prospectNotesRemove, prospectFilesList, prospectFilesUpload, prospectFilesDownload, prospectFilesRemove, prospectPhotosList, prospectPhotosAdd, prospectPhotosRemove, prospectTagsList, prospectTagsSet, prospectTagsAdd, prospectTagsRemove, } from './commands/prospects.js';
32
+ import { tagsList, tagsGet, tagsCreate, tagsUpdate, tagsDelete, tagsReorder, } from './commands/tags.js';
33
+ import { webhooksList, webhooksGet, webhooksCreate, webhooksUpdate, webhooksDelete, webhooksTest, webhooksRotateSecret, webhooksDeliveries, webhooksDeliveryGet, webhooksRedeliver, webhooksEvents, } from './commands/webhooks.js';
34
+ export const program = new Command();
31
35
  program
32
36
  .name('dm')
33
37
  .description('DealMachine CLI - Property intelligence from the command line')
@@ -39,7 +43,6 @@ Examples:
39
43
  dm properties search -f query.json Search properties from a file
40
44
  dm enrich address "123 Main St" Enrich a single address
41
45
  dm lists search --json List all lists as JSON
42
- dm crm opportunities list --json List CRM opportunities
43
46
 
44
47
  Tip: Every subcommand supports --help with examples.
45
48
  Use --json on any command for machine-readable output.
@@ -48,6 +51,7 @@ Tip: Every subcommand supports --help with examples.
48
51
  Agents:
49
52
  dm agents guide Print concise agent usage guidance
50
53
  dm agents playbook Print the full DealMachine Playbook
54
+ dm agents install claude-code Install the Playbook as a Claude Code skill
51
55
 
52
56
  Agent defaults: use --json and --quiet, fetch filters and fields before searches,
53
57
  and count before credit-consuming commands.`);
@@ -63,9 +67,11 @@ Examples:
63
67
  dm agents Print concise agent usage guidance
64
68
  dm agents guide --json Print agent guidance as JSON
65
69
  dm agents playbook Print the full DealMachine Playbook
70
+ dm agents install claude-code Install the Playbook for Claude Code
71
+ dm agents permissions Print a safe Claude Code allowlist
66
72
  dm agents skill Alias for dm agents playbook`)
67
73
  .action(async (options) => {
68
- await agentsGuide(options);
74
+ await agentsGuide({ ...options, json: options.json || agentsCmd.opts().json });
69
75
  });
70
76
  agentsCmd
71
77
  .command('guide')
@@ -76,7 +82,7 @@ Examples:
76
82
  dm agents guide Print concise agent usage guidance
77
83
  dm agents guide --json Print agent guidance as JSON`)
78
84
  .action(async (options) => {
79
- await agentsGuide(options);
85
+ await agentsGuide({ ...options, json: options.json || agentsCmd.opts().json });
80
86
  });
81
87
  agentsCmd
82
88
  .command('playbook')
@@ -89,7 +95,45 @@ Examples:
89
95
  dm agents playbook --json Print the Playbook as JSON
90
96
  dm agents skill Alias for dm agents playbook`)
91
97
  .action(async (options) => {
92
- await agentsPlaybook(options);
98
+ await agentsPlaybook({ ...options, json: options.json || agentsCmd.opts().json });
99
+ });
100
+ agentsCmd
101
+ .command('install <agent>')
102
+ .description('Install the bundled Playbook for a supported coding agent')
103
+ .option('--project', 'Install in the current project instead of the personal Claude config')
104
+ .option('--force', 'Replace a different existing DealMachine skill')
105
+ .option('--json', 'Output as JSON')
106
+ .addHelpText('after', `
107
+ Supported agents:
108
+ claude-code
109
+
110
+ Examples:
111
+ dm agents install claude-code
112
+ dm agents install claude-code --project
113
+ dm agents install claude-code --force --json`)
114
+ .action(async (agent, options) => {
115
+ const normalizedOptions = { ...options, json: options.json || agentsCmd.opts().json };
116
+ if (agent !== 'claude-code') {
117
+ const message = `Unsupported agent "${agent}". Supported agents: claude-code`;
118
+ if (normalizedOptions.json)
119
+ console.log(JSON.stringify({ error: message }, null, 2));
120
+ else
121
+ console.error(message);
122
+ process.exitCode = 1;
123
+ return;
124
+ }
125
+ await agentsInstallClaudeCode(normalizedOptions);
126
+ });
127
+ agentsCmd
128
+ .command('permissions')
129
+ .description('Print the recommended Claude Code allowlist for free DealMachine commands')
130
+ .option('--json', 'Output as JSON')
131
+ .addHelpText('after', `
132
+ Examples:
133
+ dm agents permissions
134
+ dm agents permissions --json`)
135
+ .action(async (options) => {
136
+ await agentsPermissions({ ...options, json: options.json || agentsCmd.opts().json });
93
137
  });
94
138
  // ============================================================================
95
139
  // Auth commands
@@ -223,7 +267,7 @@ Examples:
223
267
  dm account Show account details
224
268
  dm account --json Show account details as JSON`)
225
269
  .action(async (options) => {
226
- await account();
270
+ await account(options);
227
271
  });
228
272
  program
229
273
  .command('usage')
@@ -295,8 +339,7 @@ locationsCmd
295
339
  .addHelpText('after', `
296
340
  Examples:
297
341
  dm locations autocomplete "1200 Barton Springs" --state TX
298
- dm locations autocomplete "saint louis 63101" --scope location --json
299
- dm loc autocomplete "Harris County" --limit 5`)
342
+ dm loc autocomplete "46 Joyce St" --limit 5 --json`)
300
343
  .action(async (query, options) => {
301
344
  await locationsAutocomplete({ query, ...options });
302
345
  });
@@ -377,12 +420,15 @@ propertiesCmd
377
420
  .option('--exclude-lists <ids>', 'Comma-separated list IDs to exclude')
378
421
  .option('--exclude-previously-exported', 'Exclude records already exported by this organization')
379
422
  .option('--bigquery-data-environment <n>', 'Query Builder data environment: 1 production, 2 staging, 3 development')
423
+ .option('--estimate-cost', 'Return counts and estimated credits without consuming credits')
424
+ .option('--yes', 'Confirm the estimated credit spend for non-interactive execution')
380
425
  .option('--json', 'Output as JSON')
381
426
  .addHelpText('after', `
382
427
  Examples:
383
428
  dm properties search --body '{"locations":[{"type":"zip_code","code":"78704"}]}'
384
- dm properties search -f search-query.json
385
- dm properties search -f query.json --json
429
+ dm properties search -f search-query.json --estimate-cost
430
+ dm properties search -f query.json --json Estimate automatically
431
+ dm properties search -f query.json --json --yes Run after approval
386
432
  cat query.json | dm properties search --json`)
387
433
  .action(async (options) => {
388
434
  await propertiesSearch(options);
@@ -448,6 +494,7 @@ propertiesCmd
448
494
  .option('--mobile-only', 'Only include wireless phone numbers')
449
495
  .option('--landline-only', 'Only include landline phone numbers')
450
496
  .option('--scrub-dnc', 'Exclude contacts on the Do Not Call registry')
497
+ .option('--active-phones-only', 'Only include phone numbers with active reported phone activity (inactive/unknown excluded)')
451
498
  .option('--json', 'Output as JSON')
452
499
  .addHelpText('after', `
453
500
  Examples:
@@ -512,12 +559,14 @@ listsCmd
512
559
  .option('--ids <csv>', 'Comma-separated record IDs to pre-populate (max 250)')
513
560
  .option('--body <json>', 'Request body as JSON (filters/locations)')
514
561
  .option('-f, --file <path>', 'Read request body from a JSON file')
562
+ .option('--no-prospects', 'File the records without adding them as prospects (default adds them)')
515
563
  .option('--json', 'Output as JSON')
516
564
  .addHelpText('after', `
517
565
  Examples:
518
566
  dm lists create --name "Austin Leads"
519
567
  dm lists create --name "TX Owners" --source-type properties --json
520
- dm lists create --name "Import" --ids 100,200,300`)
568
+ dm lists create --name "Import" --ids 100,200,300
569
+ dm lists create --name "Mailing only" --ids 100,200 --no-prospects`)
521
570
  .action(async (options) => {
522
571
  await listsCreate(options);
523
572
  });
@@ -566,6 +615,7 @@ listsCmd
566
615
  .description('Build a list from search filters')
567
616
  .option('--body <json>', 'Request body as JSON (filters/locations)')
568
617
  .option('-f, --file <path>', 'Read request body from a JSON file')
618
+ .option('--no-prospects', 'File the records without adding them as prospects (default adds them)')
569
619
  .option('--json', 'Output as JSON')
570
620
  .addHelpText('after', `
571
621
  Examples:
@@ -583,6 +633,7 @@ listsCmd
583
633
  .option('--source-type <type>', 'Source type: properties or people')
584
634
  .option('--body <json>', 'Request body as JSON')
585
635
  .option('-f, --file <path>', 'Read request body from a JSON file')
636
+ .option('--no-prospects', 'File the records without adding them as prospects (default adds them)')
586
637
  .option('--json', 'Output as JSON')
587
638
  .addHelpText('after', `
588
639
  Examples:
@@ -611,6 +662,7 @@ listsCmd
611
662
  .description('Add items to a list')
612
663
  .requiredOption('--ids <csv>', 'Comma-separated list of IDs to add')
613
664
  .option('--id-type <type>', 'ID type: internal_property_id or internal_person_id')
665
+ .option('--no-prospects', 'File the records without adding them as prospects (default adds them)')
614
666
  .option('--json', 'Output as JSON')
615
667
  .addHelpText('after', `
616
668
  Examples:
@@ -655,7 +707,13 @@ Examples:
655
707
  // ============================================================================
656
708
  // People commands
657
709
  // ============================================================================
658
- const peopleCmd = program.command('people').description('Search and look up people');
710
+ const peopleCmd = program
711
+ .command('people')
712
+ .description('Search and look up people')
713
+ .addHelpText('after', `
714
+ Looking up one specific person by name, email, or phone?
715
+ Use dm enrich name, dm enrich email, or dm enrich phone.
716
+ People Search is for filtered audiences and does not have a name filter.`);
659
717
  peopleCmd
660
718
  .command('search')
661
719
  .description('Search people with filters and locations')
@@ -665,11 +723,17 @@ peopleCmd
665
723
  .option('--exclude-lists <ids>', 'Comma-separated list IDs to exclude')
666
724
  .option('--exclude-previously-exported', 'Exclude records already exported by this organization')
667
725
  .option('--bigquery-data-environment <n>', 'Query Builder data environment: 1 production, 2 staging, 3 development')
726
+ .option('--estimate-cost', 'Return counts and estimated credits without consuming credits')
727
+ .option('--yes', 'Confirm the estimated credit spend for non-interactive execution')
668
728
  .option('--json', 'Output as JSON')
669
729
  .addHelpText('after', `
670
730
  Examples:
671
- dm people search -f people-query.json --json
672
- dm people search --body '{"locations":[{"type":"zip_code","code":"78704"}]}'`)
731
+ dm people search -f people-query.json --estimate-cost
732
+ dm people search -f people-query.json --json Estimate automatically
733
+ dm people search -f people-query.json --json --yes Run after approval
734
+
735
+ Specific person by name:
736
+ dm enrich name "Jane Smith" --state TX --estimate-cost`)
673
737
  .action(async (options) => {
674
738
  await peopleSearch(options);
675
739
  });
@@ -736,6 +800,7 @@ peopleCmd
736
800
  .option('--mobile-only', 'Only include wireless phone numbers')
737
801
  .option('--landline-only', 'Only include landline phone numbers')
738
802
  .option('--scrub-dnc', 'Exclude contacts on the Do Not Call registry')
803
+ .option('--active-phones-only', 'Only include phone numbers with active reported phone activity (inactive/unknown excluded)')
739
804
  .option('--json', 'Output as JSON')
740
805
  .addHelpText('after', `
741
806
  Examples:
@@ -850,15 +915,17 @@ enrichCmd
850
915
  .option('--city <place-id>', 'Narrow by city place ID from dm locations search')
851
916
  .option('--include-properties', 'Include associated properties')
852
917
  .option('--estimate-cost', 'Return match count and estimated credits without consuming credits')
918
+ .option('--yes', 'Confirm the estimated credit spend for non-interactive execution')
853
919
  .option('--page <n>', 'Page number')
854
920
  .option('--per-page <n>', 'Results per page')
855
921
  .option('--fields <csv>', 'Comma-separated field IDs from dm fields')
856
922
  .option('--json', 'Output as JSON')
857
923
  .addHelpText('after', `
858
924
  Examples:
859
- dm enrich name "David Oster" --city 53584 --json
925
+ dm enrich name "David Oster" --city 53584 --json Estimate automatically
860
926
  dm enrich name "David Oster" --state TX --estimate-cost
861
- dm enrich name "Jane Smith" --zip 78704 --include-properties
927
+ dm enrich name "Jane Smith" --zip 78704 --json --yes Run after approval
928
+ dm enrich name "Jane Smith" --zip 78704 --include-properties --yes
862
929
  dm enrich name -f names.csv --state TX`)
863
930
  .action(async (name, options) => {
864
931
  await enrichName(name, options);
@@ -951,8 +1018,7 @@ addressesCmd
951
1018
  .addHelpText('after', `
952
1019
  Examples:
953
1020
  dm addresses autocomplete "1200 Barton Springs" --state TX
954
- dm addresses autocomplete "saint louis 63101" --scope location --json
955
- dm addresses autocomplete "Harris County" --limit 5`)
1021
+ dm addresses autocomplete "46 Joyce St" --limit 5 --json`)
956
1022
  .action(async (query, options) => {
957
1023
  await addressesAutocomplete({ query, ...options });
958
1024
  });
@@ -1053,605 +1119,497 @@ Examples:
1053
1119
  await tasksDelete(id, options);
1054
1120
  });
1055
1121
  // ============================================================================
1056
- // CRM commands
1122
+ // Driving commands
1057
1123
  // ============================================================================
1058
- const crmCmd = program
1059
- .command('crm')
1060
- .description('Manage CRM pipelines, opportunities, tasks, notes, records, and labels');
1061
- crmCmd
1062
- .command('pipelines')
1063
- .description('List pipelines with stages and opportunity counts')
1124
+ const drivingCmd = program.command('driving').description('Read recorded drive history');
1125
+ drivingCmd
1126
+ .command('list')
1127
+ .alias('ls')
1128
+ .description('List recorded drives')
1129
+ .option('--driver-user-id <id>', 'Only drives by this user')
1130
+ .option('--mode <mode>', 'free_drive, route_plan, or area_drive')
1131
+ .option('--started-after <date>', 'Inclusive start date or timestamp')
1132
+ .option('--started-before <date>', 'Inclusive end date or timestamp')
1133
+ .option('-p, --page <n>', 'Page number')
1134
+ .option('--per-page <n>', 'Results per page (max 100)')
1064
1135
  .option('--json', 'Output as JSON')
1065
1136
  .addHelpText('after', `
1066
1137
  Examples:
1067
- dm crm pipelines --json`)
1138
+ dm driving list
1139
+ dm driving list --mode free_drive --started-after 2026-08-01 --json`)
1068
1140
  .action(async (options) => {
1069
- await crmPipelines(options);
1141
+ await drivingList(options);
1070
1142
  });
1071
- const crmOppCmd = crmCmd
1072
- .command('opportunities')
1073
- .alias('opp')
1074
- .description('Manage CRM opportunities');
1075
- crmOppCmd
1143
+ drivingCmd
1144
+ .command('get <id>')
1145
+ .description('Show a drive with visits, events, and prospects added')
1146
+ .option('--json', 'Output as JSON')
1147
+ .addHelpText('after', `
1148
+ Examples:
1149
+ dm driving get drive_session_501
1150
+ dm driving get drive_route_7 --json`)
1151
+ .action(async (id, options) => {
1152
+ await drivingGet(id, options);
1153
+ });
1154
+ // ============================================================================
1155
+ // Prospects commands
1156
+ // ============================================================================
1157
+ const prospectsCmd = program
1158
+ .command('prospects')
1159
+ .description('Work prospects: add, list, archive, notes, files, photos, tags, activity');
1160
+ prospectsCmd
1076
1161
  .command('list')
1077
1162
  .alias('ls')
1078
- .description('List/search opportunities')
1079
- .option('--pipeline-id <id>', 'Filter by pipeline ID')
1080
- .option('--stage-id <id>', 'Filter by stage ID')
1081
- .option('--search <term>', 'Search by name')
1082
- .option('--priority <level>', 'Filter by priority: low, medium, high, urgent')
1163
+ .description('List prospects')
1164
+ .option('--record-type <type>', 'property (default) or person')
1165
+ .option('--lifecycle <lifecycle>', 'active (default), opportunity, or archived')
1166
+ .option('--source <source>', 'Filter by source, e.g. driving, import, api, cli, or mcp')
1167
+ .option('--favorites', 'Only starred prospects')
1168
+ .option('--list <listId>', 'Only members of this list')
1169
+ .option('--tag <tagId>', 'Only prospects with this tag, e.g. tag_31')
1170
+ .option('--search <term>', 'Address words for properties; name or city for people')
1171
+ .option('--sort <order>', 'newest (default) or oldest')
1083
1172
  .option('-p, --page <n>', 'Page number')
1084
- .option('--per-page <n>', 'Results per page')
1173
+ .option('--per-page <n>', 'Results per page (max 100)')
1085
1174
  .option('--json', 'Output as JSON')
1086
1175
  .addHelpText('after', `
1087
1176
  Examples:
1088
- dm crm opportunities list --json
1089
- dm crm opp list --pipeline-id pipe_123 --priority high
1090
- dm crm opp ls --search "Main St" --per-page 50`)
1177
+ dm prospects list
1178
+ dm prospects list --source driving
1179
+ dm prospects list --lifecycle opportunity --tag tag_31
1180
+ dm prospects list --record-type person --search "austin" --json`)
1091
1181
  .action(async (options) => {
1092
- await crmOpportunitiesList(options);
1182
+ await prospectsList(options);
1093
1183
  });
1094
- crmOppCmd
1184
+ prospectsCmd
1095
1185
  .command('get <id>')
1096
- .description('Get opportunity details')
1186
+ .description('Show one prospect')
1097
1187
  .option('--json', 'Output as JSON')
1098
- .addHelpText('after', `
1099
- Examples:
1100
- dm crm opp get opp_abc123 --json`)
1101
1188
  .action(async (id, options) => {
1102
- await crmOpportunitiesGet(id, options);
1189
+ await prospectsGet(id, options);
1103
1190
  });
1104
- crmOppCmd
1105
- .command('create')
1106
- .description('Create an opportunity')
1107
- .option('--body <json>', 'Request body as JSON string')
1191
+ prospectsCmd
1192
+ .command('get-by-record <recordId>')
1193
+ .description('Find a prospect by its property, person, or company record ID')
1194
+ .option('--record-type <type>', 'property (default), person, or company')
1195
+ .option('--json', 'Output as JSON')
1196
+ .action(async (recordId, options) => {
1197
+ await prospectsGetByRecord({ ...options, recordId });
1198
+ });
1199
+ prospectsCmd
1200
+ .command('add')
1201
+ .description('Track records as prospects (up to 1,000)')
1202
+ .option('--ids <csv>', 'Comma-separated record IDs, e.g. prop_123,prop_456')
1203
+ .option('--record-type <type>', 'property (default), person, or company')
1204
+ .option('--favorite', 'Also star them')
1205
+ .option('--body <json>', 'Request body as JSON')
1108
1206
  .option('-f, --file <path>', 'Read request body from a JSON file')
1109
1207
  .option('--json', 'Output as JSON')
1110
1208
  .addHelpText('after', `
1111
1209
  Examples:
1112
- dm crm opp create --body '{"name":"123 Main St","pipeline_id":"pipe_123","stage_id":"stage_456"}' --json
1113
- dm crm opp create -f opportunity.json`)
1210
+ dm prospects add --ids prop_12345,prop_67890
1211
+ dm prospects add --ids person_777 --record-type person --favorite`)
1114
1212
  .action(async (options) => {
1115
- await crmOpportunitiesCreate(options);
1213
+ await prospectsAdd(options);
1116
1214
  });
1117
- crmOppCmd
1118
- .command('update <id>')
1119
- .description('Update an opportunity')
1120
- .option('--body <json>', 'Request body as JSON string')
1121
- .option('-f, --file <path>', 'Read request body from a JSON file')
1215
+ prospectsCmd
1216
+ .command('archive [id]')
1217
+ .description('Archive a prospect, or the prospects for up to 1,000 records with --ids (ends their mail and keeps their lists)')
1218
+ .option('--ids <csv>', 'Comma-separated record IDs to archive in bulk, e.g. prop_123,prop_456')
1219
+ .option('--record-type <type>', 'With --ids: property (default), person, or company')
1220
+ .option('--no-cascade', 'Skip optional archive cleanup; mail always ends and deals stay open')
1122
1221
  .option('--json', 'Output as JSON')
1123
1222
  .addHelpText('after', `
1124
1223
  Examples:
1125
- dm crm opp update opp_abc123 --body '{"priority":"high"}' --json`)
1224
+ dm prospects archive prospect_8812
1225
+ dm prospects archive --ids prop_12345,prop_67890
1226
+ dm prospects archive --ids person_777,person_778 --record-type person`)
1126
1227
  .action(async (id, options) => {
1127
- await crmOpportunitiesUpdate(id, options);
1228
+ await prospectsArchive(id, {
1229
+ json: options.json,
1230
+ noCascade: options.cascade === false,
1231
+ ids: options.ids,
1232
+ recordType: options.recordType,
1233
+ });
1128
1234
  });
1129
- crmOppCmd
1130
- .command('delete <id>')
1131
- .description('Delete an opportunity')
1132
- .option('--dry-run', 'Preview what would be deleted without making changes')
1235
+ prospectsCmd
1236
+ .command('remove <id>')
1237
+ .alias('rm')
1238
+ .description('Archive a prospect through the remove endpoint')
1239
+ .option('--no-cascade', 'Skip optional archive cleanup; mail always ends and deals stay open')
1133
1240
  .option('--json', 'Output as JSON')
1134
- .addHelpText('after', `
1135
- Examples:
1136
- dm crm opp delete opp_abc123
1137
- dm crm opp delete opp_abc123 --dry-run Preview deletion`)
1138
1241
  .action(async (id, options) => {
1139
- if (options.dryRun) {
1140
- console.log(`Would delete opportunity ${id}.`);
1141
- console.log('No changes made (--dry-run).');
1142
- return;
1143
- }
1144
- await crmOpportunitiesDelete(id, options);
1242
+ await prospectsRemove(id, { json: options.json, noCascade: options.cascade === false });
1145
1243
  });
1146
- crmOppCmd
1147
- .command('move <id>')
1148
- .description('Move opportunity to a different stage')
1149
- .option('--body <json>', 'Request body as JSON string (stage_id required)')
1150
- .option('-f, --file <path>', 'Read request body from a JSON file')
1244
+ prospectsCmd
1245
+ .command('reactivate [id]')
1246
+ .description('Return an archived prospect to active, or many by record ID with --ids')
1247
+ .option('--ids <csv>', 'Comma-separated record IDs to restore in bulk, e.g. prop_123,prop_456')
1248
+ .option('--record-type <type>', 'With --ids: property (default), person, or company')
1151
1249
  .option('--json', 'Output as JSON')
1152
- .addHelpText('after', `
1153
- Examples:
1154
- dm crm opp move opp_abc123 --body '{"stage_id":"stage_789"}' --json`)
1155
1250
  .action(async (id, options) => {
1156
- await crmOpportunitiesMove(id, options);
1251
+ await prospectsReactivate(id, {
1252
+ json: options.json,
1253
+ ids: options.ids,
1254
+ recordType: options.recordType,
1255
+ });
1157
1256
  });
1158
- const crmTaskCmd = crmCmd.command('tasks').description('Manage CRM tasks');
1159
- crmTaskCmd
1160
- .command('list <opportunityId>')
1161
- .alias('ls')
1162
- .description('List tasks for an opportunity')
1163
- .option('-p, --page <n>', 'Page number')
1164
- .option('--per-page <n>', 'Results per page')
1257
+ prospectsCmd
1258
+ .command('opportunity <id>')
1259
+ .description('Mark a prospect as an opportunity')
1165
1260
  .option('--json', 'Output as JSON')
1166
- .addHelpText('after', `
1167
- Examples:
1168
- dm crm tasks list opp_abc123 --json`)
1169
- .action(async (opportunityId, options) => {
1170
- await crmTasksList(opportunityId, options);
1261
+ .action(async (id, options) => {
1262
+ await prospectsOpportunity(id, options);
1171
1263
  });
1172
- crmTaskCmd
1173
- .command('create <opportunityId>')
1174
- .description('Create a task on an opportunity')
1175
- .option('--body <json>', 'Request body as JSON string')
1176
- .option('-f, --file <path>', 'Read request body from a JSON file')
1264
+ prospectsCmd
1265
+ .command('favorite <id>')
1266
+ .description('Star a prospect (or --off to unstar)')
1267
+ .option('--off', 'Remove the star')
1177
1268
  .option('--json', 'Output as JSON')
1178
- .addHelpText('after', `
1179
- Examples:
1180
- dm crm tasks create opp_abc123 --body '{"title":"Call owner"}' --json`)
1181
- .action(async (opportunityId, options) => {
1182
- await crmTasksCreate(opportunityId, options);
1269
+ .action(async (id, options) => {
1270
+ await prospectsFavorite(id, options);
1183
1271
  });
1184
- crmTaskCmd
1185
- .command('update <opportunityId> <taskId>')
1186
- .description('Update a task')
1187
- .option('--body <json>', 'Request body as JSON string')
1188
- .option('-f, --file <path>', 'Read request body from a JSON file')
1272
+ prospectsCmd
1273
+ .command('check')
1274
+ .description('See which records are prospects')
1275
+ .requiredOption('--ids <csv>', 'Comma-separated record IDs (max 500)')
1276
+ .option('--record-type <type>', 'property (default), person, or company')
1189
1277
  .option('--json', 'Output as JSON')
1190
- .addHelpText('after', `
1191
- Examples:
1192
- dm crm tasks update opp_abc123 task_456 --body '{"status":"completed"}' --json`)
1193
- .action(async (opportunityId, taskId, options) => {
1194
- await crmTasksUpdate(opportunityId, taskId, options);
1278
+ .action(async (options) => {
1279
+ await prospectsCheck(options);
1195
1280
  });
1196
- const crmNoteCmd = crmCmd.command('notes').description('Manage CRM notes');
1197
- crmNoteCmd
1198
- .command('list <opportunityId>')
1199
- .alias('ls')
1200
- .description('List notes for an opportunity')
1201
- .option('-p, --page <n>', 'Page number')
1202
- .option('--per-page <n>', 'Results per page')
1281
+ prospectsCmd
1282
+ .command('counts')
1283
+ .description('Prospect counts by lifecycle and record type')
1284
+ .option('--list <listId>', 'Count only members of this list')
1203
1285
  .option('--json', 'Output as JSON')
1204
- .addHelpText('after', `
1205
- Examples:
1206
- dm crm notes list opp_abc123 --json`)
1207
- .action(async (opportunityId, options) => {
1208
- await crmNotesList(opportunityId, options);
1286
+ .action(async (options) => {
1287
+ await prospectsCounts(options);
1209
1288
  });
1210
- crmNoteCmd
1211
- .command('create <opportunityId>')
1212
- .description('Create a note on an opportunity')
1213
- .option('--body <json>', 'Request body as JSON string')
1214
- .option('-f, --file <path>', 'Read request body from a JSON file')
1289
+ prospectsCmd
1290
+ .command('activity <id>')
1291
+ .description('Show the prospect activity feed')
1292
+ .option('--category <category>', 'record, note, tag, list, communication, crm, driving, enrichment')
1293
+ .option('--since <iso>', 'Only activity after this ISO 8601 time')
1294
+ .option('-p, --page <n>', 'Page number')
1295
+ .option('--per-page <n>', 'Results per page (max 100)')
1215
1296
  .option('--json', 'Output as JSON')
1216
- .addHelpText('after', `
1217
- Examples:
1218
- dm crm notes create opp_abc123 --body '{"content":"Spoke with owner, interested in selling."}' --json`)
1219
- .action(async (opportunityId, options) => {
1220
- await crmNotesCreate(opportunityId, options);
1297
+ .action(async (id, options) => {
1298
+ await prospectsActivity(id, options);
1221
1299
  });
1222
- crmNoteCmd
1223
- .command('update <opportunityId> <noteId>')
1224
- .description('Update a note')
1225
- .option('--body <json>', 'Request body as JSON string')
1226
- .option('-f, --file <path>', 'Read request body from a JSON file')
1300
+ const prospectNotesCmd = prospectsCmd.command('notes').description('Notes on a prospect');
1301
+ prospectNotesCmd
1302
+ .command('list <id>')
1303
+ .description('List notes')
1304
+ .option('-p, --page <n>', 'Page number')
1305
+ .option('--per-page <n>', 'Results per page')
1227
1306
  .option('--json', 'Output as JSON')
1228
- .addHelpText('after', `
1229
- Examples:
1230
- dm crm notes update opp_abc123 note_456 --body '{"content":"Updated note."}' --json`)
1231
- .action(async (opportunityId, noteId, options) => {
1232
- await crmNotesUpdate(opportunityId, noteId, options);
1307
+ .action(async (id, options) => {
1308
+ await prospectNotesList(id, options);
1233
1309
  });
1234
- const crmRecordCmd = crmCmd
1235
- .command('records')
1236
- .description('Manage linked records on opportunities');
1237
- crmRecordCmd
1238
- .command('list <opportunityId>')
1239
- .alias('ls')
1240
- .description('List records linked to an opportunity')
1310
+ prospectNotesCmd
1311
+ .command('get <id> <noteId>')
1312
+ .description('Show one note')
1241
1313
  .option('--json', 'Output as JSON')
1242
- .addHelpText('after', `
1243
- Examples:
1244
- dm crm records list opp_abc123 --json`)
1245
- .action(async (opportunityId, options) => {
1246
- await crmRecordsList(opportunityId, options);
1314
+ .action(async (id, noteId, options) => {
1315
+ await prospectNotesGet(id, noteId, options);
1247
1316
  });
1248
- crmRecordCmd
1249
- .command('link <opportunityId>')
1250
- .description('Link a record to an opportunity')
1251
- .option('--body <json>', 'Request body as JSON string')
1317
+ prospectNotesCmd
1318
+ .command('add <id> [text]')
1319
+ .description('Add a note')
1320
+ .option('--body <json>', 'Request body as JSON ({"body": "..."})')
1252
1321
  .option('-f, --file <path>', 'Read request body from a JSON file')
1253
1322
  .option('--json', 'Output as JSON')
1254
- .addHelpText('after', `
1255
- Examples:
1256
- dm crm records link opp_abc123 --body '{"record_id":"prop_456","record_type":"property"}' --json`)
1257
- .action(async (opportunityId, options) => {
1258
- await crmRecordsLink(opportunityId, options);
1323
+ .addHelpText('after', `\nExamples:\n dm prospects notes add prospect_8812 "Owner wants an offer by Friday"`)
1324
+ .action(async (id, text, options) => {
1325
+ await prospectNotesAdd(id, text, options);
1259
1326
  });
1260
- crmRecordCmd
1261
- .command('unlink <opportunityId> <recordId>')
1262
- .description('Unlink a record from an opportunity')
1263
- .option('--dry-run', 'Preview what would be unlinked without making changes')
1327
+ prospectNotesCmd
1328
+ .command('edit <id> <noteId> <text>')
1329
+ .description('Edit a note')
1264
1330
  .option('--json', 'Output as JSON')
1265
- .addHelpText('after', `
1266
- Examples:
1267
- dm crm records unlink opp_abc123 rec_456
1268
- dm crm records unlink opp_abc123 rec_456 --dry-run`)
1269
- .action(async (opportunityId, recordId, options) => {
1270
- if (options.dryRun) {
1271
- console.log(`Would unlink record ${recordId} from opportunity ${opportunityId}.`);
1272
- console.log('No changes made (--dry-run).');
1273
- return;
1274
- }
1275
- await crmRecordsUnlink(opportunityId, recordId, options);
1331
+ .action(async (id, noteId, text, options) => {
1332
+ await prospectNotesEdit(id, noteId, text, options);
1276
1333
  });
1277
- const crmLabelCmd = crmCmd.command('labels').description('Manage CRM labels');
1278
- crmLabelCmd
1279
- .command('list')
1280
- .alias('ls')
1281
- .description('List all CRM labels')
1334
+ prospectNotesCmd
1335
+ .command('remove <id> <noteId>')
1336
+ .alias('rm')
1337
+ .description('Delete a note')
1282
1338
  .option('--json', 'Output as JSON')
1283
- .addHelpText('after', `
1284
- Examples:
1285
- dm crm labels list --json`)
1286
- .action(async (options) => {
1287
- await crmLabelsList(options);
1339
+ .action(async (id, noteId, options) => {
1340
+ await prospectNotesRemove(id, noteId, options);
1288
1341
  });
1289
- crmLabelCmd
1290
- .command('create')
1291
- .description('Create a label')
1292
- .option('--body <json>', 'Request body as JSON string')
1293
- .option('-f, --file <path>', 'Read request body from a JSON file')
1342
+ const prospectFilesCmd = prospectsCmd.command('files').description('Files on a prospect');
1343
+ prospectFilesCmd
1344
+ .command('list <id>')
1345
+ .description('List files')
1294
1346
  .option('--json', 'Output as JSON')
1295
- .addHelpText('after', `
1296
- Examples:
1297
- dm crm labels create --body '{"name":"Hot Lead","color":"red"}' --json`)
1298
- .action(async (options) => {
1299
- await crmLabelsCreate(options);
1300
- });
1301
- crmLabelCmd
1302
- .command('update <id>')
1303
- .description('Update a label')
1304
- .option('--body <json>', 'Request body as JSON string')
1305
- .option('-f, --file <path>', 'Read request body from a JSON file')
1347
+ .action(async (id, options) => {
1348
+ await prospectFilesList(id, options);
1349
+ });
1350
+ prospectFilesCmd
1351
+ .command('upload <id> <path>')
1352
+ .description('Attach a local file (up to 25 MB)')
1353
+ .option('--content-type <mime>', 'MIME type, e.g. application/pdf')
1354
+ .option('--name <fileName>', 'Name to show instead of the local file name')
1355
+ .option('--json', 'Output as JSON')
1356
+ .addHelpText('after', `\nExamples:\n dm prospects files upload prospect_8812 ./inspection.pdf --content-type application/pdf`)
1357
+ .action(async (id, path, options) => {
1358
+ await prospectFilesUpload(id, path, options);
1359
+ });
1360
+ prospectFilesCmd
1361
+ .command('download <id> <fileId>')
1362
+ .description('Download a file')
1363
+ .option('-o, --out <path>', 'Where to save it')
1364
+ .option('--json', 'Print the signed URL instead of downloading')
1365
+ .action(async (id, fileId, options) => {
1366
+ await prospectFilesDownload(id, fileId, options);
1367
+ });
1368
+ prospectFilesCmd
1369
+ .command('remove <id> <fileId>')
1370
+ .alias('rm')
1371
+ .description('Delete a file')
1372
+ .option('--json', 'Output as JSON')
1373
+ .action(async (id, fileId, options) => {
1374
+ await prospectFilesRemove(id, fileId, options);
1375
+ });
1376
+ const prospectPhotosCmd = prospectsCmd
1377
+ .command('photos')
1378
+ .description('Property photos on a prospect');
1379
+ prospectPhotosCmd
1380
+ .command('list <id>')
1381
+ .description('List photos')
1306
1382
  .option('--json', 'Output as JSON')
1307
- .addHelpText('after', `
1308
- Examples:
1309
- dm crm labels update label_abc123 --body '{"name":"Warm Lead"}' --json`)
1310
1383
  .action(async (id, options) => {
1311
- await crmLabelsUpdate(id, options);
1384
+ await prospectPhotosList(id, options);
1312
1385
  });
1313
- crmLabelCmd
1314
- .command('delete <id>')
1315
- .description('Delete a label')
1316
- .option('--dry-run', 'Preview what would be deleted without making changes')
1386
+ prospectPhotosCmd
1387
+ .command('add <id>')
1388
+ .description('Add a photo from a local file (under 700 KB) or a public https URL')
1389
+ .option('--file <path>', 'Local JPEG, PNG, or WebP')
1390
+ .option('--url <url>', 'Public https image URL (up to 10 MB)')
1391
+ .option('--type <type>', 'street_view, property_front, property_side, property_back, condition, damage, other')
1392
+ .option('--caption <text>', 'Caption')
1317
1393
  .option('--json', 'Output as JSON')
1318
- .addHelpText('after', `
1319
- Examples:
1320
- dm crm labels delete label_abc123
1321
- dm crm labels delete label_abc123 --dry-run`)
1322
1394
  .action(async (id, options) => {
1323
- if (options.dryRun) {
1324
- console.log(`Would delete label ${id}.`);
1325
- console.log('No changes made (--dry-run).');
1326
- return;
1327
- }
1328
- await crmLabelsDelete(id, options);
1329
- });
1330
- // ── Opportunity Labels (add/remove on opportunities) ──
1331
- const crmOppLabelCmd = crmOppCmd.command('labels').description('Manage labels on an opportunity');
1332
- crmOppLabelCmd
1333
- .command('add <opportunityId>')
1334
- .description('Add a label to an opportunity')
1335
- .option('--label-id <id>', 'Label ID to add')
1336
- .option('--body <json>', 'Request body as JSON string')
1337
- .option('-f, --file <path>', 'Read request body from a JSON file')
1338
- .option('--json', 'Output as JSON')
1339
- .addHelpText('after', `
1340
- Examples:
1341
- dm crm opp labels add opp_abc123 --label-id label_456
1342
- dm crm opp labels add opp_abc123 --body '{"label_id":"label_456"}' --json`)
1343
- .action(async (opportunityId, options) => {
1344
- await crmOpportunityLabelsAdd(opportunityId, options);
1395
+ await prospectPhotosAdd(id, options);
1345
1396
  });
1346
- crmOppLabelCmd
1347
- .command('remove <opportunityId> <labelId>')
1348
- .description('Remove a label from an opportunity')
1397
+ prospectPhotosCmd
1398
+ .command('remove <id> <photoId>')
1399
+ .alias('rm')
1400
+ .description('Delete a photo')
1349
1401
  .option('--json', 'Output as JSON')
1350
- .addHelpText('after', `
1351
- Examples:
1352
- dm crm opp labels remove opp_abc123 label_456`)
1353
- .action(async (opportunityId, labelId, options) => {
1354
- await crmOpportunityLabelsRemove(opportunityId, labelId, options);
1402
+ .action(async (id, photoId, options) => {
1403
+ await prospectPhotosRemove(id, photoId, options);
1355
1404
  });
1356
- // ── Opportunity Subscribers ──
1357
- const crmSubCmd = crmOppCmd
1358
- .command('subscribers')
1359
- .alias('subs')
1360
- .description('Manage opportunity subscribers');
1361
- crmSubCmd
1362
- .command('list <opportunityId>')
1363
- .alias('ls')
1364
- .description('List subscribers of an opportunity')
1405
+ const prospectTagsCmd = prospectsCmd.command('tags').description('Tags on a prospect');
1406
+ prospectTagsCmd
1407
+ .command('list <id>')
1408
+ .description('Show the catalog with what is assigned')
1365
1409
  .option('--json', 'Output as JSON')
1366
- .addHelpText('after', `
1367
- Examples:
1368
- dm crm opp subscribers list opp_abc123 --json
1369
- dm crm opp subs ls opp_abc123`)
1370
- .action(async (opportunityId, options) => {
1371
- await crmSubscribersList(opportunityId, options);
1410
+ .action(async (id, options) => {
1411
+ await prospectTagsList(id, options);
1372
1412
  });
1373
- crmSubCmd
1374
- .command('add <opportunityId>')
1375
- .description('Subscribe a user to an opportunity')
1376
- .option('--user-id <id>', 'User ID to subscribe')
1377
- .option('--body <json>', 'Request body as JSON string')
1378
- .option('-f, --file <path>', 'Read request body from a JSON file')
1413
+ prospectTagsCmd
1414
+ .command('set <id>')
1415
+ .description('Replace the prospect tags with exactly these')
1416
+ .requiredOption('--ids <csv>', 'Comma-separated tag IDs (empty string clears)')
1379
1417
  .option('--json', 'Output as JSON')
1380
- .addHelpText('after', `
1381
- Examples:
1382
- dm crm opp subscribers add opp_abc123 --user-id 42
1383
- dm crm opp subs add opp_abc123 --body '{"user_id":42}' --json`)
1384
- .action(async (opportunityId, options) => {
1385
- await crmSubscribersAdd(opportunityId, options);
1418
+ .action(async (id, options) => {
1419
+ await prospectTagsSet(id, options);
1386
1420
  });
1387
- crmSubCmd
1388
- .command('remove <opportunityId>')
1389
- .description('Unsubscribe a user from an opportunity')
1390
- .requiredOption('--user-id <id>', 'User ID to unsubscribe')
1421
+ prospectTagsCmd
1422
+ .command('add <id> <tagId>')
1423
+ .description('Add one tag')
1391
1424
  .option('--json', 'Output as JSON')
1392
- .addHelpText('after', `
1393
- Examples:
1394
- dm crm opp subscribers remove opp_abc123 --user-id 42`)
1395
- .action(async (opportunityId, options) => {
1396
- await crmSubscribersRemove(opportunityId, options);
1425
+ .action(async (id, tagId, options) => {
1426
+ await prospectTagsAdd(id, tagId, options);
1397
1427
  });
1398
- crmCmd
1399
- .command('activity <opportunityId>')
1400
- .description('View activity feed for an opportunity')
1401
- .option('--cursor <cursor>', 'Cursor for pagination')
1402
- .option('--limit <n>', 'Items per page')
1403
- .option('--category <cat>', 'Filter by category')
1428
+ prospectTagsCmd
1429
+ .command('remove <id> <tagId>')
1430
+ .alias('rm')
1431
+ .description('Remove one tag')
1404
1432
  .option('--json', 'Output as JSON')
1405
- .addHelpText('after', `
1406
- Examples:
1407
- dm crm activity opp_abc123 --json
1408
- dm crm activity opp_abc123 --category notes --limit 20`)
1409
- .action(async (opportunityId, options) => {
1410
- await crmActivity(opportunityId, options);
1433
+ .action(async (id, tagId, options) => {
1434
+ await prospectTagsRemove(id, tagId, options);
1411
1435
  });
1412
1436
  // ============================================================================
1413
- // Dialer commands
1437
+ // Tags commands (catalog)
1414
1438
  // ============================================================================
1415
- const dialerCmd = program
1416
- .command('dialer')
1417
- .description('Manage dialer queues, calls, dispositions, and suppression');
1418
- // ── Calls ──
1419
- const dialerCallsCmd = dialerCmd.command('calls').description('View call history and stats');
1420
- dialerCallsCmd
1439
+ const tagsCmd = program.command('tags').description('Manage the prospect tag catalog');
1440
+ tagsCmd
1421
1441
  .command('list')
1422
1442
  .alias('ls')
1423
- .description('List call history')
1424
- .option('--status <status>', 'Filter by status: initiating, ringing, answered, completed, failed, busy, no_answer, cancelled')
1425
- .option('--search <term>', 'Search by contact name or phone number')
1426
- .option('--date-from <date>', 'Filter from date (ISO 8601)')
1427
- .option('--date-to <date>', 'Filter to date (ISO 8601)')
1428
- .option('-p, --page <n>', 'Page number')
1429
- .option('--per-page <n>', 'Results per page')
1443
+ .description('List built-in and workspace tags')
1444
+ .option('--include-inactive', 'Show archived tags too')
1430
1445
  .option('--json', 'Output as JSON')
1431
- .addHelpText('after', `
1432
- Examples:
1433
- dm dialer calls list --json
1434
- dm dialer calls list --status completed --date-from 2025-01-01
1435
- dm dialer calls list --search "5125551234" --per-page 50`)
1436
1446
  .action(async (options) => {
1437
- await dialerCallsList(options);
1447
+ await tagsList(options);
1438
1448
  });
1439
- dialerCallsCmd
1440
- .command('get <uuid>')
1441
- .description('Get call details by UUID')
1449
+ tagsCmd
1450
+ .command('get <id>')
1451
+ .description('Show one tag')
1442
1452
  .option('--json', 'Output as JSON')
1443
- .addHelpText('after', `
1444
- Examples:
1445
- dm dialer calls get call_uuid_123 --json`)
1446
- .action(async (uuid, options) => {
1447
- await dialerCallsGet(uuid, options);
1453
+ .action(async (id, options) => {
1454
+ await tagsGet(id, options);
1448
1455
  });
1449
- dialerCallsCmd
1450
- .command('stats')
1451
- .description('Get call statistics')
1452
- .option('--date-from <date>', 'Filter from date (ISO 8601)')
1453
- .option('--date-to <date>', 'Filter to date (ISO 8601)')
1456
+ tagsCmd
1457
+ .command('create')
1458
+ .description('Create a workspace tag')
1459
+ .requiredOption('--name <name>', 'Tag name (unique in the workspace)')
1460
+ .option('--description <text>', 'What the tag means')
1461
+ .option('--color <variant>', 'default, secondary, info, warning, or destructive')
1462
+ .option('--order <n>', 'Sort order (lower first)')
1454
1463
  .option('--json', 'Output as JSON')
1455
- .addHelpText('after', `
1456
- Examples:
1457
- dm dialer calls stats --json
1458
- dm dialer calls stats --date-from 2025-01-01 --date-to 2025-01-31`)
1464
+ .addHelpText('after', `\nExamples:\n dm tags create --name Probate --color info`)
1459
1465
  .action(async (options) => {
1460
- await dialerCallsStats(options);
1466
+ await tagsCreate(options);
1461
1467
  });
1462
- // ── Call Notes ──
1463
- const dialerNotesCmd = dialerCmd.command('notes').description('Manage call notes');
1464
- dialerNotesCmd
1465
- .command('list <callUuid>')
1466
- .alias('ls')
1467
- .description('List notes for a call')
1468
+ tagsCmd
1469
+ .command('update <id>')
1470
+ .description('Change a workspace tag')
1471
+ .option('--name <name>', 'New name')
1472
+ .option('--description <text>', 'New description')
1473
+ .option('--color <variant>', 'default, secondary, info, warning, or destructive')
1474
+ .option('--order <n>', 'Sort order')
1475
+ .option('--archive', 'Hide the tag without removing it from prospects')
1476
+ .option('--restore', 'Show an archived tag again')
1468
1477
  .option('--json', 'Output as JSON')
1469
- .addHelpText('after', `
1470
- Examples:
1471
- dm dialer notes list call_uuid_123 --json`)
1472
- .action(async (callUuid, options) => {
1473
- await dialerNotesList(callUuid, options);
1478
+ .action(async (id, options) => {
1479
+ await tagsUpdate(id, options);
1474
1480
  });
1475
- dialerNotesCmd
1476
- .command('create <callUuid>')
1477
- .description('Add a note to a call')
1478
- .option('--body <json>', 'Request body as JSON string')
1479
- .option('-f, --file <path>', 'Read request body from a JSON file')
1481
+ tagsCmd
1482
+ .command('delete <id>')
1483
+ .description('Delete a workspace tag')
1484
+ .option('--force', 'Remove it from every prospect first')
1480
1485
  .option('--json', 'Output as JSON')
1481
- .addHelpText('after', `
1482
- Examples:
1483
- dm dialer notes create call_uuid_123 --body '{"content":"Left voicemail."}' --json`)
1484
- .action(async (callUuid, options) => {
1485
- await dialerNotesCreate(callUuid, options);
1486
+ .action(async (id, options) => {
1487
+ await tagsDelete(id, options);
1486
1488
  });
1487
- dialerNotesCmd
1488
- .command('delete <callUuid> <noteId>')
1489
- .description('Delete a call note')
1490
- .option('--dry-run', 'Preview what would be deleted without making changes')
1489
+ tagsCmd
1490
+ .command('reorder')
1491
+ .description('Set the display order of workspace tags')
1492
+ .requiredOption('--ids <csv>', 'Comma-separated tag IDs in the order you want')
1491
1493
  .option('--json', 'Output as JSON')
1492
- .addHelpText('after', `
1493
- Examples:
1494
- dm dialer notes delete call_uuid_123 note_456
1495
- dm dialer notes delete call_uuid_123 note_456 --dry-run`)
1496
- .action(async (callUuid, noteId, options) => {
1497
- if (options.dryRun) {
1498
- console.log(`Would delete note ${noteId} from call ${callUuid}.`);
1499
- console.log('No changes made (--dry-run).');
1500
- return;
1501
- }
1502
- await dialerNotesDelete(callUuid, noteId, options);
1494
+ .action(async (options) => {
1495
+ await tagsReorder(options);
1503
1496
  });
1504
- // ── Queues ──
1505
- const dialerQueuesCmd = dialerCmd.command('queues').description('Manage dialer queues');
1506
- dialerQueuesCmd
1497
+ // ============================================================================
1498
+ // Webhooks commands
1499
+ // ============================================================================
1500
+ const webhooksCmd = program
1501
+ .command('webhooks')
1502
+ .description('Receive prospect and list events at your own URLs');
1503
+ webhooksCmd
1507
1504
  .command('list')
1508
1505
  .alias('ls')
1509
- .description('List all dialer queues')
1506
+ .description('List webhooks with their health')
1507
+ .option('--include-zapier', 'Also show subscriptions the Zapier app created')
1510
1508
  .option('--json', 'Output as JSON')
1511
- .addHelpText('after', `
1512
- Examples:
1513
- dm dialer queues list --json`)
1514
1509
  .action(async (options) => {
1515
- await dialerQueuesList(options);
1510
+ await webhooksList(options);
1516
1511
  });
1517
- dialerQueuesCmd
1512
+ webhooksCmd
1513
+ .command('get <id>')
1514
+ .description('Show one webhook')
1515
+ .option('--json', 'Output as JSON')
1516
+ .action(async (id, options) => {
1517
+ await webhooksGet(id, options);
1518
+ });
1519
+ webhooksCmd
1518
1520
  .command('create')
1519
- .description('Create a new queue')
1520
- .option('--body <json>', 'Request body as JSON string')
1521
- .option('-f, --file <path>', 'Read request body from a JSON file')
1521
+ .description('Register a URL (the signing secret is shown once)')
1522
+ .requiredOption('--url <url>', 'Public https URL that accepts POST requests')
1523
+ .requiredOption('--events <csv>', 'Event types, e.g. prospect.added,prospect.tags_changed (or prospect.* or *)')
1524
+ .option('--description <text>', 'What this webhook is for')
1525
+ .option('--batch-max <n>', 'Most events per request (1 to 100, default 50)')
1526
+ .option('--include-contacts', 'Include phone numbers and emails on person prospects')
1522
1527
  .option('--json', 'Output as JSON')
1523
1528
  .addHelpText('after', `
1524
1529
  Examples:
1525
- dm dialer queues create --body '{"name":"Morning Calls"}' --json`)
1530
+ dm webhooks create --url https://example.com/hooks/dm --events prospect.added
1531
+ dm webhooks create --url https://example.com/hooks/dm --events "prospect.*" --batch-max 10`)
1526
1532
  .action(async (options) => {
1527
- await dialerQueuesCreate(options);
1533
+ await webhooksCreate(options);
1528
1534
  });
1529
- dialerQueuesCmd
1530
- .command('delete <id>')
1531
- .description('Delete a queue')
1532
- .option('--dry-run', 'Preview what would be deleted without making changes')
1535
+ webhooksCmd
1536
+ .command('update <id>')
1537
+ .description('Change a webhook or turn it on or off')
1538
+ .option('--url <url>', 'New URL')
1539
+ .option('--events <csv>', 'New event types')
1540
+ .option('--description <text>', 'New description')
1541
+ .option('--batch-max <n>', 'Most events per request')
1542
+ .option('--include-contacts', 'Include contact data')
1543
+ .option('--no-include-contacts', 'Stop including contact data')
1544
+ .option('--enable', 'Turn on (also clears a failure lockout)')
1545
+ .option('--disable', 'Turn off')
1533
1546
  .option('--json', 'Output as JSON')
1534
- .addHelpText('after', `
1535
- Examples:
1536
- dm dialer queues delete queue_abc123
1537
- dm dialer queues delete queue_abc123 --dry-run`)
1538
1547
  .action(async (id, options) => {
1539
- if (options.dryRun) {
1540
- console.log(`Would delete queue ${id} and all its items.`);
1541
- console.log('No changes made (--dry-run).');
1542
- return;
1543
- }
1544
- await dialerQueuesDelete(id, options);
1545
- });
1546
- // ── Queue Items ──
1547
- const dialerItemsCmd = dialerCmd.command('items').description('Manage queue items');
1548
- dialerItemsCmd
1549
- .command('list <queueId>')
1550
- .alias('ls')
1551
- .description('List items in a queue')
1552
- .option('--status <status>', 'Filter by status: pending, in_progress, completed, skipped, deferred')
1553
- .option('-p, --page <n>', 'Page number')
1554
- .option('--per-page <n>', 'Results per page')
1555
- .option('--json', 'Output as JSON')
1556
- .addHelpText('after', `
1557
- Examples:
1558
- dm dialer items list queue_abc123 --json
1559
- dm dialer items list queue_abc123 --status pending --per-page 50`)
1560
- .action(async (queueId, options) => {
1561
- await dialerQueueItemsList(queueId, options);
1548
+ await webhooksUpdate(id, {
1549
+ ...options,
1550
+ includeContacts: options.includeContacts === true ? true : undefined,
1551
+ noIncludeContacts: options.includeContacts === false ? true : undefined,
1552
+ });
1562
1553
  });
1563
- dialerItemsCmd
1564
- .command('add <queueId>')
1565
- .description('Add items to a queue')
1566
- .option('--body <json>', 'Request body as JSON string')
1567
- .option('-f, --file <path>', 'Read request body from a JSON file')
1554
+ webhooksCmd
1555
+ .command('delete <id>')
1556
+ .description('Delete a webhook and its delivery log')
1568
1557
  .option('--json', 'Output as JSON')
1569
- .addHelpText('after', `
1570
- Examples:
1571
- dm dialer items add queue_abc123 --body '{"phone_numbers":["5125551234"]}' --json`)
1572
- .action(async (queueId, options) => {
1573
- await dialerQueueItemsAdd(queueId, options);
1558
+ .action(async (id, options) => {
1559
+ await webhooksDelete(id, options);
1574
1560
  });
1575
- dialerItemsCmd
1576
- .command('update <queueId> <itemId>')
1577
- .description('Update a queue item')
1578
- .option('--body <json>', 'Request body as JSON string')
1579
- .option('-f, --file <path>', 'Read request body from a JSON file')
1561
+ webhooksCmd
1562
+ .command('test <id>')
1563
+ .description('Send a signed ping event now and show the response')
1580
1564
  .option('--json', 'Output as JSON')
1581
- .addHelpText('after', `
1582
- Examples:
1583
- dm dialer items update queue_abc123 item_456 --body '{"status":"skipped"}' --json`)
1584
- .action(async (queueId, itemId, options) => {
1585
- await dialerQueueItemsUpdate(queueId, itemId, options);
1565
+ .action(async (id, options) => {
1566
+ await webhooksTest(id, options);
1586
1567
  });
1587
- dialerItemsCmd
1588
- .command('remove <queueId> <itemId>')
1589
- .description('Remove an item from a queue')
1590
- .option('--dry-run', 'Preview what would be removed without making changes')
1568
+ webhooksCmd
1569
+ .command('rotate-secret <id>')
1570
+ .description('Issue a new signing secret (the old one works for 24 hours)')
1591
1571
  .option('--json', 'Output as JSON')
1592
- .addHelpText('after', `
1593
- Examples:
1594
- dm dialer items remove queue_abc123 item_456
1595
- dm dialer items remove queue_abc123 item_456 --dry-run`)
1596
- .action(async (queueId, itemId, options) => {
1597
- if (options.dryRun) {
1598
- console.log(`Would remove item ${itemId} from queue ${queueId}.`);
1599
- console.log('No changes made (--dry-run).');
1600
- return;
1601
- }
1602
- await dialerQueueItemsRemove(queueId, itemId, options);
1603
- });
1604
- // ── Dispositions ──
1605
- dialerCmd
1606
- .command('dispositions')
1607
- .description('List call dispositions')
1572
+ .action(async (id, options) => {
1573
+ await webhooksRotateSecret(id, options);
1574
+ });
1575
+ webhooksCmd
1576
+ .command('deliveries <id>')
1577
+ .description('Show the delivery log')
1578
+ .option('--status <status>', 'pending, processing, delivered, failed, abandoned, or skipped')
1579
+ .option('--event-type <type>', 'Only this event type')
1580
+ .option('--since <iso>', 'Only deliveries after this ISO 8601 time')
1581
+ .option('-p, --page <n>', 'Page number')
1582
+ .option('--per-page <n>', 'Results per page (max 100)')
1608
1583
  .option('--json', 'Output as JSON')
1609
- .addHelpText('after', `
1610
- Examples:
1611
- dm dialer dispositions --json`)
1612
- .action(async (options) => {
1613
- await dialerDispositions(options);
1584
+ .action(async (id, options) => {
1585
+ await webhooksDeliveries(id, options);
1614
1586
  });
1615
- // ── Suppression ──
1616
- const dialerSuppCmd = dialerCmd
1617
- .command('suppression')
1618
- .description('Manage suppression list (Do Not Call)');
1619
- dialerSuppCmd
1620
- .command('list')
1621
- .alias('ls')
1622
- .description('List suppressed phone numbers')
1623
- .option('--search <term>', 'Search by phone number')
1624
- .option('-p, --page <n>', 'Page number')
1625
- .option('--per-page <n>', 'Results per page')
1587
+ webhooksCmd
1588
+ .command('delivery <id> <deliveryId>')
1589
+ .description('Show one delivery attempt')
1626
1590
  .option('--json', 'Output as JSON')
1627
- .addHelpText('after', `
1628
- Examples:
1629
- dm dialer suppression list --json
1630
- dm dialer suppression list --search "512" --per-page 100`)
1631
- .action(async (options) => {
1632
- await dialerSuppressionList(options);
1591
+ .action(async (id, deliveryId, options) => {
1592
+ await webhooksDeliveryGet(id, deliveryId, options);
1633
1593
  });
1634
- dialerSuppCmd
1635
- .command('check <phoneNumber>')
1636
- .description('Check if a phone number is suppressed')
1594
+ webhooksCmd
1595
+ .command('redeliver <id> [deliveryId]')
1596
+ .description('Send a delivery again, or every delivery since a time')
1597
+ .option('--since <iso>', 'Resend everything created after this ISO 8601 time')
1637
1598
  .option('--json', 'Output as JSON')
1638
1599
  .addHelpText('after', `
1639
1600
  Examples:
1640
- dm dialer suppression check 5125551234 --json`)
1641
- .action(async (phoneNumber, options) => {
1642
- await dialerSuppressionCheck(phoneNumber, options);
1601
+ dm webhooks redeliver whk_12 dlv_9001
1602
+ dm webhooks redeliver whk_12 --since 2026-08-26T00:00:00Z`)
1603
+ .action(async (id, deliveryId, options) => {
1604
+ await webhooksRedeliver(id, deliveryId, options);
1643
1605
  });
1644
- dialerSuppCmd
1645
- .command('add')
1646
- .description('Add a phone number to the suppression list')
1647
- .option('--body <json>', 'Request body as JSON string')
1648
- .option('-f, --file <path>', 'Read request body from a JSON file')
1606
+ webhooksCmd
1607
+ .command('events')
1608
+ .description('List event types, or print an example body')
1609
+ .option('--example <type>', 'Print the full example request body for one event type')
1649
1610
  .option('--json', 'Output as JSON')
1650
- .addHelpText('after', `
1651
- Examples:
1652
- dm dialer suppression add --body '{"phone_number":"5125551234","reason":"Do not contact"}' --json`)
1653
1611
  .action(async (options) => {
1654
- await dialerSuppressionAdd(options);
1612
+ await webhooksEvents(options);
1655
1613
  });
1656
1614
  // ============================================================================
1657
1615
  // Mail commands
@@ -1668,7 +1626,8 @@ mailCampaignsCmd
1668
1626
  .command('list')
1669
1627
  .alias('ls')
1670
1628
  .description('List mail campaigns')
1671
- .option('--status <status>', 'Filter by status: draft, active, paused, completed, cancelled')
1629
+ .option('--status <status>', 'Filter by status: draft, ready, active, paused, ended (completed and cancelled still work)')
1630
+ .option('--accepting-properties', 'Only campaigns that properties can be added to now')
1672
1631
  .option('--search <term>', 'Search by campaign name')
1673
1632
  .option('-p, --page <n>', 'Page number')
1674
1633
  .option('--per-page <n>', 'Results per page')
@@ -1677,7 +1636,10 @@ mailCampaignsCmd
1677
1636
  Examples:
1678
1637
  dm mail campaigns list --json
1679
1638
  dm mail camp ls --status active
1680
- dm mail campaigns list --search "Austin" --per-page 50`)
1639
+ dm mail campaigns list --accepting-properties --json
1640
+ dm mail campaigns list --search "Austin" --per-page 50
1641
+
1642
+ Statuses: draft, ready, active, paused, ended. Completed and Cancelled campaigns show as ended.`)
1681
1643
  .action(async (options) => {
1682
1644
  await mailCampaignsList(options);
1683
1645
  });
@@ -1692,7 +1654,11 @@ Examples:
1692
1654
  dm mail campaigns create -f campaign.json --json
1693
1655
  dm mail campaigns create --body '{"name":"Austin Owners","property_ids":[123],"address_to":"owner","steps":[{"design_prompt":"Professional postcard"}]}'
1694
1656
 
1695
- Note: Set "launch": true in body to send immediately, or leave as draft.`)
1657
+ Note: Set "launch": true in body to send immediately, or leave as draft.
1658
+ Set "accepts_properties": true to keep adding properties after the campaign starts.
1659
+ Leave out property_ids, contact_ids and list_ids to save a Ready campaign with no properties
1660
+ and no charge; it always accepts properties. Add properties later with:
1661
+ dm mail campaigns add-properties <id>`)
1696
1662
  .action(async (options) => {
1697
1663
  await mailCampaignsCreate(options);
1698
1664
  });
@@ -1722,7 +1688,7 @@ Note: Only draft campaigns can be updated.`)
1722
1688
  });
1723
1689
  mailCampaignsCmd
1724
1690
  .command('delete <id>')
1725
- .description('Cancel a campaign')
1691
+ .description('Cancel a campaign (same as end, without the confirmation)')
1726
1692
  .option('--dry-run', 'Preview what would be cancelled without making changes')
1727
1693
  .option('--json', 'Output as JSON')
1728
1694
  .addHelpText('after', `
@@ -1759,7 +1725,7 @@ Note: Verify wallet balance first with: dm mail wallet balance`)
1759
1725
  });
1760
1726
  mailCampaignsCmd
1761
1727
  .command('pause <id>')
1762
- .description('Pause an active campaign')
1728
+ .description('Pause an active or ready campaign')
1763
1729
  .option('--json', 'Output as JSON')
1764
1730
  .addHelpText('after', `
1765
1731
  Examples:
@@ -1810,6 +1776,50 @@ Examples:
1810
1776
  .action(async (id, options) => {
1811
1777
  await mailCampaignsCostEstimate(id, options);
1812
1778
  });
1779
+ mailCampaignsCmd
1780
+ .command('add-properties <id>')
1781
+ .description('Add properties to a Ready, Active or Paused campaign; each starts at step 1')
1782
+ .requiredOption('--property-ids <ids...>', 'Property IDs, space or comma separated (up to 5,000)')
1783
+ .requiredOption('--recipient <recipient>', 'Who receives the mail: owner or resident')
1784
+ .option('--yes', 'Skip the confirmation (required for agents, scripts and --json)')
1785
+ .option('--json', 'Output as JSON')
1786
+ .addHelpText('after', `
1787
+ Examples:
1788
+ dm mail campaigns add-properties camp_abc123 --property-ids 101 102 --recipient owner
1789
+ dm mail campaigns add-properties camp_abc123 --property-ids 101,102 --recipient resident --yes --json
1790
+
1791
+ Shows the charge due today and later, then asks before adding. Without --yes, agents and
1792
+ scripts get the estimate only and nothing is added. Pieces going out today are charged now;
1793
+ later pieces are charged as they go out. Skipped properties are listed with a reason.`)
1794
+ .action(async (id, options) => {
1795
+ await mailCampaignsAddProperties(id, options);
1796
+ });
1797
+ mailCampaignsCmd
1798
+ .command('estimate-add <id>')
1799
+ .description('Estimate the cost of adding properties to a campaign')
1800
+ .requiredOption('--count <n>', 'Number of properties to add (1 to 5,000)')
1801
+ .option('--json', 'Output as JSON')
1802
+ .addHelpText('after', `
1803
+ Examples:
1804
+ dm mail campaigns estimate-add camp_abc123 --count 25 --json`)
1805
+ .action(async (id, options) => {
1806
+ await mailCampaignsEstimateAdd(id, options);
1807
+ });
1808
+ mailCampaignsCmd
1809
+ .command('end <id>')
1810
+ .description('End a campaign permanently')
1811
+ .option('--yes', 'Skip the confirmation (required for agents, scripts and --json)')
1812
+ .option('--json', 'Output as JSON')
1813
+ .addHelpText('after', `
1814
+ Examples:
1815
+ dm mail campaigns end camp_abc123
1816
+ dm mail campaigns end camp_abc123 --yes --json
1817
+
1818
+ Ending is permanent. Unsent mail stops and the campaign cannot be paused, resumed or added to.
1819
+ Mail already printed still delivers. To reuse its steps, create a new campaign.`)
1820
+ .action(async (id, options) => {
1821
+ await mailCampaignsEnd(id, options);
1822
+ });
1813
1823
  // ── Designs ──
1814
1824
  const mailDesignsCmd = mailCmd.command('designs').description('Manage postcard designs');
1815
1825
  mailDesignsCmd
@@ -2118,5 +2128,18 @@ devLicenseCmd
2118
2128
  // ============================================================================
2119
2129
  // Parse and execute
2120
2130
  // ============================================================================
2121
- program.parse();
2131
+ function isMainModule() {
2132
+ if (!process.argv[1])
2133
+ return false;
2134
+ try {
2135
+ return realpathSync(process.argv[1]) === fileURLToPath(import.meta.url);
2136
+ }
2137
+ catch {
2138
+ // Importing the program must not depend on the caller's entry file existing.
2139
+ return false;
2140
+ }
2141
+ }
2142
+ if (isMainModule()) {
2143
+ program.parse();
2144
+ }
2122
2145
  //# sourceMappingURL=index.js.map