@wirecat/cli-core 1.1.0 → 1.3.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 (80) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/dist/cli/account-remove.d.ts +3 -0
  3. package/dist/cli/account-remove.js +1 -1
  4. package/dist/cli/contract-templates.js +3 -0
  5. package/dist/cli/documents/index.d.ts +2 -1
  6. package/dist/cli/documents/index.js +4 -1
  7. package/dist/cli/help/first-screen.js +2 -2
  8. package/dist/cli/index.d.ts +3 -3
  9. package/dist/cli/index.js +3 -3
  10. package/dist/cli/messenger/account-command.js +0 -10
  11. package/dist/cli/messenger/accounts.d.ts +1 -1
  12. package/dist/cli/messenger/accounts.js +1 -1
  13. package/dist/cli/messenger/context.d.ts +1 -1
  14. package/dist/cli/messenger/conversation-answers.d.ts +2 -0
  15. package/dist/cli/messenger/message-answers.d.ts +2 -0
  16. package/dist/cli/messenger/message-items.js +2 -0
  17. package/dist/cli/messenger/message-writes.d.ts +4 -0
  18. package/dist/cli/messenger/search-answers.js +2 -0
  19. package/dist/cli/messenger/session-commands.d.ts +1 -1
  20. package/dist/cli/messenger/session-commands.js +1 -1
  21. package/dist/cli/oauth-session.js +6 -3
  22. package/dist/cli/program.js +2 -2
  23. package/dist/cli/settings.d.ts +3 -3
  24. package/dist/cli/shared-command-exports.d.ts +2 -0
  25. package/dist/cli/shared-command-exports.js +3 -0
  26. package/dist/cli/token-session.d.ts +1 -4
  27. package/dist/cli/token-session.js +5 -1
  28. package/dist/domain/models.d.ts +5 -0
  29. package/dist/domain/person-kinds.d.ts +1 -1
  30. package/dist/entities/contact-context.d.ts +4 -0
  31. package/dist/entities/conversation-results.d.ts +4 -0
  32. package/dist/entities/evidence.d.ts +16 -0
  33. package/dist/entities/index.d.ts +36 -0
  34. package/dist/entities/listener.d.ts +8 -0
  35. package/dist/entities/message-change.d.ts +2 -0
  36. package/dist/entities/message-context.d.ts +6 -0
  37. package/dist/entities/message-write.d.ts +8 -0
  38. package/dist/entities/message.d.ts +4 -0
  39. package/dist/entities/message.js +4 -0
  40. package/dist/entities/store-maintenance.js +1 -1
  41. package/dist/entities/store-records.d.ts +2 -0
  42. package/dist/errors/failures.d.ts +6 -0
  43. package/dist/errors/failures.js +18 -4
  44. package/dist/errors/reasons.js +16 -0
  45. package/dist/errors/store-reasons.js +1 -0
  46. package/dist/mail/cli/index.js +1 -1
  47. package/dist/mail/headers.d.ts +2 -0
  48. package/dist/mail/headers.js +2 -1
  49. package/dist/mail/read.js +1 -0
  50. package/dist/mail/sort-rules.d.ts +58 -0
  51. package/dist/mail/sort-rules.js +79 -0
  52. package/dist/mcp/tool.js +2 -2
  53. package/dist/runs/recording.js +2 -2
  54. package/dist/search/lucene/registry.js +24 -0
  55. package/dist/services/messages-search.js +1 -1
  56. package/dist/store/areas.d.ts +2 -0
  57. package/dist/store/areas.js +2 -0
  58. package/dist/store/public.d.ts +1 -1
  59. package/dist/store/public.js +1 -1
  60. package/dist/store/queries.js +9 -2
  61. package/dist/store/sqlite/email-types.d.ts +8 -0
  62. package/dist/store/sqlite/email-types.js +45 -10
  63. package/dist/store/sqlite/emails.d.ts +3 -0
  64. package/dist/store/sqlite/emails.js +14 -5
  65. package/dist/store/sqlite/lucene-fields.d.ts +6 -0
  66. package/dist/store/sqlite/lucene-fields.js +10 -0
  67. package/dist/store/sqlite/lucene.js +6 -0
  68. package/dist/store/sqlite/mail-sorting.d.ts +122 -0
  69. package/dist/store/sqlite/mail-sorting.js +482 -0
  70. package/dist/store/sqlite/manifest.js +2 -0
  71. package/dist/store/sqlite/migrations.generated.js +20 -0
  72. package/dist/store/sqlite/people-list.js +65 -16
  73. package/dist/store/sqlite/schema/mail-sorting.d.ts +384 -0
  74. package/dist/store/sqlite/schema/mail-sorting.js +31 -0
  75. package/dist/store/sqlite/schema.d.ts +17 -0
  76. package/dist/store/sqlite/schema.js +3 -0
  77. package/dist/store/sqlite/sender-bots.d.ts +10 -1
  78. package/dist/store/sqlite/sender-bots.js +47 -8
  79. package/package.json +2 -2
  80. package/parity.json +9 -3
@@ -210,6 +210,8 @@ export declare const contribution: v.StrictObjectSchema<{
210
210
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
211
211
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
212
212
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
213
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
214
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
213
215
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
214
216
  readonly score: v.NumberSchema<undefined>;
215
217
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -437,6 +439,8 @@ export declare const contribution: v.StrictObjectSchema<{
437
439
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
438
440
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
439
441
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
442
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
443
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
440
444
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
441
445
  readonly score: v.NumberSchema<undefined>;
442
446
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -702,6 +706,8 @@ export declare const contribution: v.StrictObjectSchema<{
702
706
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
703
707
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
704
708
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
709
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
710
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
705
711
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
706
712
  readonly score: v.NumberSchema<undefined>;
707
713
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -929,6 +935,8 @@ export declare const contribution: v.StrictObjectSchema<{
929
935
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
930
936
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
931
937
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
938
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
939
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
932
940
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
933
941
  readonly score: v.NumberSchema<undefined>;
934
942
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -1230,6 +1238,8 @@ export declare const evidence: v.UnionSchema<[v.StrictObjectSchema<{
1230
1238
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
1231
1239
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
1232
1240
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
1241
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1242
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1233
1243
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
1234
1244
  readonly score: v.NumberSchema<undefined>;
1235
1245
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -1457,6 +1467,8 @@ export declare const evidence: v.UnionSchema<[v.StrictObjectSchema<{
1457
1467
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
1458
1468
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
1459
1469
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
1470
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1471
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1460
1472
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
1461
1473
  readonly score: v.NumberSchema<undefined>;
1462
1474
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -1722,6 +1734,8 @@ export declare const evidence: v.UnionSchema<[v.StrictObjectSchema<{
1722
1734
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
1723
1735
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
1724
1736
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
1737
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1738
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1725
1739
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
1726
1740
  readonly score: v.NumberSchema<undefined>;
1727
1741
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -1949,6 +1963,8 @@ export declare const evidence: v.UnionSchema<[v.StrictObjectSchema<{
1949
1963
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
1950
1964
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
1951
1965
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
1966
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1967
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1952
1968
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
1953
1969
  readonly score: v.NumberSchema<undefined>;
1954
1970
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -651,6 +651,8 @@ export declare const ENTITIES: {
651
651
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
652
652
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
653
653
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
654
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
655
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
654
656
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
655
657
  readonly score: v.NumberSchema<undefined>;
656
658
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -878,6 +880,8 @@ export declare const ENTITIES: {
878
880
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
879
881
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
880
882
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
883
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
884
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
881
885
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
882
886
  readonly score: v.NumberSchema<undefined>;
883
887
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -1110,6 +1114,8 @@ export declare const ENTITIES: {
1110
1114
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
1111
1115
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
1112
1116
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
1117
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1118
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1113
1119
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
1114
1120
  readonly score: v.NumberSchema<undefined>;
1115
1121
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -1481,6 +1487,8 @@ export declare const ENTITIES: {
1481
1487
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
1482
1488
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
1483
1489
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
1490
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1491
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1484
1492
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
1485
1493
  readonly score: v.NumberSchema<undefined>;
1486
1494
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -1732,6 +1740,8 @@ export declare const ENTITIES: {
1732
1740
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
1733
1741
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
1734
1742
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
1743
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1744
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1735
1745
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
1736
1746
  readonly score: v.NumberSchema<undefined>;
1737
1747
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -1959,6 +1969,8 @@ export declare const ENTITIES: {
1959
1969
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
1960
1970
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
1961
1971
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
1972
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1973
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1962
1974
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
1963
1975
  readonly score: v.NumberSchema<undefined>;
1964
1976
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -2190,6 +2202,8 @@ export declare const ENTITIES: {
2190
2202
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
2191
2203
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
2192
2204
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
2205
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
2206
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
2193
2207
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
2194
2208
  readonly score: v.NumberSchema<undefined>;
2195
2209
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -2417,6 +2431,8 @@ export declare const ENTITIES: {
2417
2431
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
2418
2432
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
2419
2433
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
2434
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
2435
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
2420
2436
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
2421
2437
  readonly score: v.NumberSchema<undefined>;
2422
2438
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -3166,6 +3182,8 @@ export declare const ENTITIES: {
3166
3182
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
3167
3183
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
3168
3184
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
3185
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
3186
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
3169
3187
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
3170
3188
  readonly score: v.NumberSchema<undefined>;
3171
3189
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -7348,6 +7366,8 @@ export declare const ENTITIES: {
7348
7366
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
7349
7367
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
7350
7368
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
7369
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
7370
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
7351
7371
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
7352
7372
  readonly score: v.NumberSchema<undefined>;
7353
7373
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -7575,6 +7595,8 @@ export declare const ENTITIES: {
7575
7595
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
7576
7596
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
7577
7597
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
7598
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
7599
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
7578
7600
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
7579
7601
  readonly score: v.NumberSchema<undefined>;
7580
7602
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -8047,6 +8069,8 @@ export declare const ENTITIES: {
8047
8069
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
8048
8070
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
8049
8071
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
8072
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
8073
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
8050
8074
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
8051
8075
  readonly score: v.NumberSchema<undefined>;
8052
8076
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -8565,6 +8589,8 @@ export declare const ENTITIES: {
8565
8589
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
8566
8590
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
8567
8591
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
8592
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
8593
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
8568
8594
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
8569
8595
  readonly score: v.NumberSchema<undefined>;
8570
8596
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -9273,6 +9299,8 @@ export declare const ENTITIES: {
9273
9299
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
9274
9300
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
9275
9301
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
9302
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
9303
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
9276
9304
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
9277
9305
  readonly score: v.NumberSchema<undefined>;
9278
9306
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -11068,6 +11096,8 @@ export declare const ENTITIES: {
11068
11096
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
11069
11097
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
11070
11098
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
11099
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
11100
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
11071
11101
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
11072
11102
  readonly score: v.NumberSchema<undefined>;
11073
11103
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -11295,6 +11325,8 @@ export declare const ENTITIES: {
11295
11325
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
11296
11326
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
11297
11327
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
11328
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
11329
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
11298
11330
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
11299
11331
  readonly score: v.NumberSchema<undefined>;
11300
11332
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -11560,6 +11592,8 @@ export declare const ENTITIES: {
11560
11592
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
11561
11593
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
11562
11594
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
11595
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
11596
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
11563
11597
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
11564
11598
  readonly score: v.NumberSchema<undefined>;
11565
11599
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -11787,6 +11821,8 @@ export declare const ENTITIES: {
11787
11821
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
11788
11822
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
11789
11823
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
11824
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
11825
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
11790
11826
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
11791
11827
  readonly score: v.NumberSchema<undefined>;
11792
11828
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -208,6 +208,8 @@ export declare const watchedMessage: v.StrictObjectSchema<{
208
208
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
209
209
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
210
210
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
211
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
212
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
211
213
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
212
214
  readonly score: v.NumberSchema<undefined>;
213
215
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -727,6 +729,8 @@ export declare const messageEvent: v.VariantSchema<"event", [v.StrictObjectSchem
727
729
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
728
730
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
729
731
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
732
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
733
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
730
734
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
731
735
  readonly score: v.NumberSchema<undefined>;
732
736
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -1353,6 +1357,8 @@ export declare const watchItem: v.UnionSchema<[v.StrictObjectSchema<{
1353
1357
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
1354
1358
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
1355
1359
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
1360
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1361
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1356
1362
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
1357
1363
  readonly score: v.NumberSchema<undefined>;
1358
1364
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -1871,6 +1877,8 @@ export declare const watchItem: v.UnionSchema<[v.StrictObjectSchema<{
1871
1877
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
1872
1878
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
1873
1879
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
1880
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1881
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1874
1882
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
1875
1883
  readonly score: v.NumberSchema<undefined>;
1876
1884
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -236,6 +236,8 @@ declare const scheduledSendEntries: {
236
236
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
237
237
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
238
238
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
239
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
240
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
239
241
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
240
242
  readonly score: v.NumberSchema<undefined>;
241
243
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -214,6 +214,8 @@ export declare const messageThread: v.StrictObjectSchema<{
214
214
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
215
215
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
216
216
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
217
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
218
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
217
219
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
218
220
  readonly score: v.NumberSchema<undefined>;
219
221
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -465,6 +467,8 @@ export declare const messageContext: v.UnionSchema<[v.StrictObjectSchema<{
465
467
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
466
468
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
467
469
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
470
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
471
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
468
472
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
469
473
  readonly score: v.NumberSchema<undefined>;
470
474
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -697,6 +701,8 @@ export declare const messageContext: v.UnionSchema<[v.StrictObjectSchema<{
697
701
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
698
702
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
699
703
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
704
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
705
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
700
706
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
701
707
  readonly score: v.NumberSchema<undefined>;
702
708
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -210,6 +210,8 @@ export declare const messageWrite: v.StrictObjectSchema<{
210
210
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
211
211
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
212
212
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
213
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
214
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
213
215
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
214
216
  readonly score: v.NumberSchema<undefined>;
215
217
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -438,6 +440,8 @@ export declare const messageWrite: v.StrictObjectSchema<{
438
440
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
439
441
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
440
442
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
443
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
444
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
441
445
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
442
446
  readonly score: v.NumberSchema<undefined>;
443
447
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -674,6 +678,8 @@ export declare const messageSend: v.UnionSchema<[v.StrictObjectSchema<{
674
678
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
675
679
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
676
680
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
681
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
682
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
677
683
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
678
684
  readonly score: v.NumberSchema<undefined>;
679
685
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -902,6 +908,8 @@ export declare const messageSend: v.UnionSchema<[v.StrictObjectSchema<{
902
908
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
903
909
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
904
910
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
911
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
912
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
905
913
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
906
914
  readonly score: v.NumberSchema<undefined>;
907
915
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -232,6 +232,10 @@ export declare const message: v.StrictObjectSchema<{
232
232
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
233
233
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
234
234
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
235
+ /** What the email is, apart from its sender: one of the mail types. @experimental */
236
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
237
+ /** How it reached the owner: direct, group or broadcast. @experimental */
238
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
235
239
  /** How much the sender's mail looks like spam, a scam or a robot (memo's score), and why; absent when unscored. */
236
240
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
237
241
  readonly score: v.NumberSchema<undefined>;
@@ -101,6 +101,10 @@ export const message = v.strictObject({
101
101
  thread: reference,
102
102
  read: v.nullable(v.boolean()),
103
103
  flagged: v.nullable(v.boolean()),
104
+ /** What the email is, apart from its sender: one of the mail types. @experimental */
105
+ mail_type: v.optional(text),
106
+ /** How it reached the owner: direct, group or broadcast. @experimental */
107
+ reach: v.optional(text),
104
108
  /** How much the sender's mail looks like spam, a scam or a robot (memo's score), and why; absent when unscored. */
105
109
  sender_score: v.optional(v.strictObject({ score: v.number(), signals: v.array(text), demoted: v.optional(v.literal(true)) })),
106
110
  /** Mail `review`: filed in the mailbox of mail sent to many. */
@@ -45,7 +45,7 @@ const perAccount = { chats: count, messages: count, emails: count, documents: co
45
45
  const contents = {
46
46
  by_provider: v.optional(v.array(v.strictObject({ provider: text, accounts: count, ...perAccount }))),
47
47
  by_chat_kind: v.optional(v.array(v.strictObject({ provider: text, kind: text, chats: count, messages: count }))),
48
- /** `name` is the one `account list` shows; the messenger's own id for the account is left out. */
48
+ /** `name` is the one `session list` shows; the messenger's own id for the account is left out. */
49
49
  by_account: v.optional(v.array(v.strictObject({ provider: text, account_id: count, name: v.nullable(text), ...perAccount }))),
50
50
  /** Calendar years in UTC. */
51
51
  by_year: v.optional(v.array(v.strictObject({ provider: text, year: count, messages: count }))),
@@ -241,6 +241,8 @@ export declare const storeExport: v.UnionSchema<[v.StrictObjectSchema<{
241
241
  readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
242
242
  readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
243
243
  readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
244
+ readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
245
+ readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
244
246
  readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
245
247
  readonly score: v.NumberSchema<undefined>;
246
248
  readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
@@ -30,6 +30,12 @@ export declare const sqliteCode: (error: unknown) => number | undefined;
30
30
  * @experimental
31
31
  */
32
32
  export declare const storeDamaged: (error: unknown, next?: string) => unknown;
33
+ /**
34
+ * Another process (a scheduled sync of another account, memo's import) held the store's write lock past the busy
35
+ * timeout: `store.busy`, not a crash. Not marked safe to retry, as the command may have written before it waited.
36
+ * @experimental
37
+ */
38
+ export declare const storeBusy: (error: unknown) => unknown;
33
39
  /** Runs `work` on store files the owner named, so a damaged one is named rather than taken for the CLI's own. */
34
40
  export declare const damagedFile: <T>(files: readonly string[], work: () => Promise<T>) => Promise<T>;
35
41
  /** Whether `error` is SQLite saying the database file is damaged. */
@@ -23,6 +23,7 @@ const USAGE_REASONS = {
23
23
  export const usageReason = (code) => USAGE_REASONS[code];
24
24
  /** What failed, never what it said: a messenger's refusal can quote the message back. */
25
25
  export const failureKey = (error) => isCliFailure(error) ? error.code : error instanceof Error ? error.name : "error";
26
+ const SQLITE_BUSY = 5;
26
27
  const SQLITE_CORRUPT = 11;
27
28
  const SQLITE_NOTADB = 26;
28
29
  const DAMAGED_TEXT = /database disk image is malformed|file is not a database|fts5: corruption/i;
@@ -35,19 +36,22 @@ export const sqliteCode = (error) => {
35
36
  const code = typeof errcode === "number" ? errcode : name === "SQLiteError" && typeof errno === "number" ? errno : null;
36
37
  return code === null ? undefined : code & 0xff;
37
38
  };
38
- /** The SQLite failure that says the database file is damaged, on the error or up to five `cause`s behind it. */
39
- const damageIn = (error) => {
39
+ /** The SQLite failure `matches` picks, on the error or up to five `cause`s behind it. */
40
+ const sqliteFailureIn = (error, matches) => {
40
41
  if (isCliFailure(error) || isCommanderFailure(error))
41
42
  return undefined;
42
43
  let at = error;
43
44
  for (let depth = 0; depth < 5 && at instanceof Error; depth += 1) {
44
- const code = sqliteCode(at);
45
- if ((code !== undefined && [SQLITE_CORRUPT, SQLITE_NOTADB].includes(code)) || DAMAGED_TEXT.test(at.message))
45
+ if (matches(at))
46
46
  return at;
47
47
  at = at.cause;
48
48
  }
49
49
  return undefined;
50
50
  };
51
+ const damageIn = (error) => sqliteFailureIn(error, (at) => {
52
+ const code = sqliteCode(at);
53
+ return (code !== undefined && [SQLITE_CORRUPT, SQLITE_NOTADB].includes(code)) || DAMAGED_TEXT.test(at.message);
54
+ });
51
55
  // The record's frames are where SQLite failed, not where the failure was renamed.
52
56
  const wrapping = (error, original) => {
53
57
  Object.defineProperty(error, "cause", { value: original, configurable: true, writable: true });
@@ -65,6 +69,16 @@ const wrapping = (error, original) => {
65
69
  export const storeDamaged = (error, next) => damageIn(error)
66
70
  ? wrapping(new CliError("configuration_error", `the store file is damaged${next ? `; \`${next}\` says what is damaged and what to do` : ""}`, { reason: "store.damaged" }), error)
67
71
  : error;
72
+ /**
73
+ * Another process (a scheduled sync of another account, memo's import) held the store's write lock past the busy
74
+ * timeout: `store.busy`, not a crash. Not marked safe to retry, as the command may have written before it waited.
75
+ * @experimental
76
+ */
77
+ export const storeBusy = (error) => sqliteFailureIn(error, (at) => sqliteCode(at) === SQLITE_BUSY)
78
+ ? wrapping(new CliError("conflict", "another process held the store for longer than this command waits; run it again", {
79
+ reason: "store.busy",
80
+ }), error)
81
+ : error;
68
82
  /** Runs `work` on store files the owner named, so a damaged one is named rather than taken for the CLI's own. */
69
83
  export const damagedFile = async (files, work) => {
70
84
  try {
@@ -668,6 +668,22 @@ const OTHERS = [
668
668
  validation("sender-bot.not-a-person", "the identity named is a sender bot's, not a person's; name a person"),
669
669
  validation("sender-bot.empty", "the person or bot named holds no identity to move"),
670
670
  validation("sender-bot.assignee", "a sender bot is no one's assignee; move it to a person first"),
671
+ validation("mail-sort.scope", "a sorting rule's scope is mail, list, subject, address or domain"),
672
+ validation("mail-sort.apply-to", "a sorting rule says whether it sorts past mail too: applyTo all or new"),
673
+ validation("mail-sort.value", "the value names no mail, list, subject, address or domain of that scope"),
674
+ validation("mail-sort.mail-type", "the mail type is not one of the known types"),
675
+ validation("mail-sort.sender", "a sorting rule makes a sender a bot or a person"),
676
+ validation("mail-sort.no-action", "a sorting rule sets a mail type, a sender or an organization"),
677
+ validation("mail-sort.owner-only", "only the owner moves or files senders, undoes and resets; a program removes its own rules"),
678
+ validation("mail-sort.sender-scope", "a sorting rule moves or files a sender at address or domain scope only"),
679
+ validation("mail-sort.sender-new", "a sender moves with its whole history, so an address rule that moves one applies to all"),
680
+ validation("mail-sort.over-addresses", "only a domain rule can beat the address rules"),
681
+ validation("mail-sort.free-mail-program", "only the owner sets a sorting rule on a free-mail or throwaway domain"),
682
+ validation("mail-sort.organization", "the organization named is not in the store"),
683
+ validation("mail-sort.confirm", "a free-mail domain rule needs the confirm of a dry run whose counts still hold; run the dry run again"),
684
+ validation("mail-sort.sender-ref", "the sender is named by an address, a person: ref or a sender-bot: ref"),
685
+ ["mail-sort.not-found", "not_found", "no mail sorting rule has that id; the rules list names them"],
686
+ ["mail-sort.email", "not_found", "no incoming email has that id"],
671
687
  validation("identity.shared-email", "more than six people share the address, so it proposes no one"),
672
688
  validation("identity-link.dedicated-review", "an identity link is staged and decided through the people review"),
673
689
  validation("identity-split.dedicated-review", "a split of a person is staged and decided through the people review"),
@@ -13,6 +13,7 @@ export const STORE = [
13
13
  "conflict",
14
14
  "another program deleted or replaced the store's journal file while it was open; store recover says what to do",
15
15
  ],
16
+ ["store.busy", "conflict", "another process held the store for longer than this command waits; run it again"],
16
17
  validation("store.file-damaged", "the named store file is damaged or not a database"),
17
18
  ["store.unopenable", "configuration_error", "the store file cannot be opened at its path; details.path names it"],
18
19
  [
@@ -123,7 +123,7 @@ const searchCommand = (mail) => {
123
123
  .option("--timezone <zone>", "the IANA timezone for calendar date boundaries")
124
124
  .addHelpText("after", `
125
125
  Fields: from: to: cc: bcc: subject: body: mailbox: (or label:) list: (a List-Id or its domain) is:unread|read|starred
126
- has:attachment, filename:, content: (the text of attachments), size>, date: — \`${mail.app.command} personal search messages 'content:invoice'\`.
126
+ type: (order, bill, promotion… — what the email is) reach:direct|group|broadcast has:attachment, filename:, content: (the text of attachments), size>, date: — \`${mail.app.command} personal search messages 'content:invoice'\`.
127
127
  chat: names a thread by its subject. Mail sent to many is in the mailbox bulk; NOT mailbox:bulk leaves it out.
128
128
  Mail from senders with signs of fraud comes after the rest of the page; --plain-order keeps it in place.
129
129
  --json: the list is items; each hit's reference is ref (msg:email/…), which messages show reads.${mail.server
@@ -37,6 +37,8 @@ export declare const authOf: (unfolded: string) => AuthVerdicts | undefined;
37
37
  */
38
38
  export declare const signedFieldsOf: (unfolded: string, from: string | undefined) => Set<string>;
39
39
  export declare const addressesOf: (value: string | undefined) => string[];
40
+ /** A List-Id as the store keeps it: the part inside angle brackets, lower case. */
41
+ export declare const listIdOf: (raw: string | undefined) => string | undefined;
40
42
  /** The header fields of one email, from its header text. */
41
43
  export declare const headersOf: (text: string) => MailHeaders;
42
44
  /** The header fields of a whole email, as `headersOf` reads them from a listing. */
@@ -95,7 +95,8 @@ const nameOf = (value) => {
95
95
  const name = before?.replace(/^"(.*)"$/, "$1").trim();
96
96
  return name ? decodeWords(name) : undefined;
97
97
  };
98
- const listIdOf = (raw) => raw === undefined ? undefined : (/<([^>]+)>/.exec(raw)?.[1] ?? raw).trim().toLowerCase() || undefined;
98
+ /** A List-Id as the store keeps it: the part inside angle brackets, lower case. */
99
+ export const listIdOf = (raw) => raw === undefined ? undefined : (/<([^>]+)>/.exec(raw)?.[1] ?? raw).trim().toLowerCase() || undefined;
99
100
  /** The header fields of one email, from its header text. */
100
101
  export const headersOf = (text) => {
101
102
  const unfolded = unfold(text);
package/dist/mail/read.js CHANGED
@@ -90,6 +90,7 @@ export const hitText = (item, level, shown = (time) => time) => {
90
90
  mail.to.length ? `to ${names(mail.to)}` : "",
91
91
  mail.cc.length ? `cc ${names(mail.cc)}` : "",
92
92
  mail.labels.join(", "),
93
+ [mail.mailType, mail.reach].filter(Boolean).join(", "),
93
94
  ]
94
95
  .filter(Boolean)
95
96
  .join(" · ")
@@ -0,0 +1,58 @@
1
+ import type { MailType } from "./mail-types.js";
2
+ /** What a sorting rule names, most specific first. @experimental */
3
+ export declare const SORT_SCOPES: readonly ["mail", "list", "subject", "address", "domain"];
4
+ /** @experimental */
5
+ export type SortScope = (typeof SORT_SCOPES)[number];
6
+ /** @experimental */
7
+ export type SortAuthor = "owner" | "program";
8
+ /** One sorting rule as the matcher reads it. @experimental */
9
+ export interface SortRuleFacts {
10
+ id: number;
11
+ scope: SortScope;
12
+ value: string;
13
+ author: SortAuthor;
14
+ /** A domain rule that beats the address rules at its domain. */
15
+ overAddresses: boolean;
16
+ /** `false`: only mail dated from `createdAt` on. */
17
+ past: boolean;
18
+ createdAt: number;
19
+ }
20
+ /** What a rule is matched against for one email. @experimental */
21
+ export interface SortedMail {
22
+ id: number;
23
+ /** Lower case. */
24
+ from: string | null;
25
+ subject: string | null;
26
+ /** As `listIdOf` keeps it. */
27
+ list: string | null;
28
+ /** The mail's own date, ms. */
29
+ at: number | null;
30
+ }
31
+ /** A subject pattern: any case, and any number stands for any other, so "Order 4411" matches "order 9". */
32
+ export declare const subjectKeyOf: (text: string) => string;
33
+ /** Rules filed by what they name, each list in the order a match takes them. @experimental */
34
+ export interface SortIndex<R extends SortRuleFacts> {
35
+ byKey: Map<string, R[]>;
36
+ subjects: R[];
37
+ size: number;
38
+ }
39
+ /** @experimental */
40
+ export declare const sortIndexOf: <R extends SortRuleFacts>(rules: readonly R[]) => SortIndex<R>;
41
+ /**
42
+ * The rule that decides this email, the first scope that has one: the mail, its List-Id or a subject pattern, its
43
+ * address, its domain. Within a scope the owner's rule beats the program's and the newest wins. A domain rule marked
44
+ * `overAddresses` beats the address rules. Addresses match whole and domains on a label boundary, so `ann@` never
45
+ * matches `joann@` and `shop.example` never matches `myshop.example`. @experimental
46
+ */
47
+ export declare const sortRuleFor: <R extends SortRuleFacts>(index: SortIndex<R>, mail: SortedMail) => R | undefined;
48
+ /** Whether a scope is more specific than another. @experimental */
49
+ export declare const narrower: (a: SortScope, b: SortScope) => boolean;
50
+ /** What a rule of this scope keeps as its value, or `undefined` when the value names nothing. @experimental */
51
+ export declare const sortValueOf: (scope: SortScope, value: string | number) => string | undefined;
52
+ /** What a rule sets on mail and on its sender. @experimental */
53
+ export interface SortAction {
54
+ mailType?: MailType;
55
+ sender?: "bot" | "person";
56
+ /** `organization:<id>`. */
57
+ organization?: string;
58
+ }