@wirecat/cli-core 0.604.0 → 0.606.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 (141) hide show
  1. package/CHANGELOG.md +159 -0
  2. package/dist/calendar/prepare.d.ts +4 -2
  3. package/dist/calendar/prepare.js +8 -8
  4. package/dist/cli/index.d.ts +2 -2
  5. package/dist/cli/index.js +2 -1
  6. package/dist/cli/messenger/contacts-command.js +3 -2
  7. package/dist/cli/messenger/doctor-command.js +14 -7
  8. package/dist/cli/messenger/store-maintenance-command.d.ts +34 -2
  9. package/dist/cli/messenger/store-maintenance-command.js +31 -4
  10. package/dist/cli/program.js +11 -2
  11. package/dist/cli/steps.js +9 -1
  12. package/dist/cli/store-recover.d.ts +10 -2
  13. package/dist/cli/store-recover.js +18 -4
  14. package/dist/cli/store-settings.js +38 -4
  15. package/dist/crm/cli/index.js +3 -1
  16. package/dist/crm/index.d.ts +2 -2
  17. package/dist/crm/index.js +1 -1
  18. package/dist/crm/source.d.ts +35 -5
  19. package/dist/crm/sync.d.ts +15 -7
  20. package/dist/crm/sync.js +169 -11
  21. package/dist/domain/crm.d.ts +41 -2
  22. package/dist/domain/deals.d.ts +5 -2
  23. package/dist/domain/deals.js +5 -2
  24. package/dist/domain/record-types.d.ts +61 -0
  25. package/dist/domain/record-types.js +26 -0
  26. package/dist/domain/records.d.ts +3 -5
  27. package/dist/domain/records.js +10 -13
  28. package/dist/domain/relations.d.ts +125 -0
  29. package/dist/domain/relations.js +107 -0
  30. package/dist/entities/contact-activity.d.ts +4 -0
  31. package/dist/entities/contact-activity.js +1 -0
  32. package/dist/entities/contact-context.d.ts +20 -0
  33. package/dist/entities/contact-context.js +2 -0
  34. package/dist/entities/deal.d.ts +2 -2
  35. package/dist/entities/deal.js +2 -1
  36. package/dist/entities/index.d.ts +39 -13
  37. package/dist/entities/relationship.d.ts +8 -2
  38. package/dist/entities/relationship.js +8 -2
  39. package/dist/entities/task-results.d.ts +10 -10
  40. package/dist/errors/failures.d.ts +17 -1
  41. package/dist/errors/failures.js +57 -1
  42. package/dist/errors/reasons.js +28 -0
  43. package/dist/index.d.ts +2 -1
  44. package/dist/index.js +1 -0
  45. package/dist/mail/cli/review.js +20 -6
  46. package/dist/mail/index.d.ts +1 -1
  47. package/dist/mail/marks.d.ts +10 -5
  48. package/dist/mail/marks.js +16 -8
  49. package/dist/mail/review.d.ts +5 -0
  50. package/dist/mcp/tool.js +2 -1
  51. package/dist/runs/recording.js +13 -4
  52. package/dist/services/deps.js +4 -6
  53. package/dist/services/index.d.ts +1 -1
  54. package/dist/services/link-scorers/chat-senders.d.ts +3 -2
  55. package/dist/services/link-scorers/chat-senders.js +7 -4
  56. package/dist/services/link-scorers/mail-thread.js +1 -0
  57. package/dist/services/link-scorers/member-chats.js +1 -0
  58. package/dist/services/link-scorers/member-dialog.d.ts +1 -1
  59. package/dist/services/link-scorers/member-dialog.js +4 -3
  60. package/dist/services/link-scorers/scan.d.ts +5 -2
  61. package/dist/services/link-scorers/scan.js +100 -54
  62. package/dist/services/link-scorers/shared.d.ts +2 -2
  63. package/dist/services/link-scorers/shared.js +8 -4
  64. package/dist/services/link-scorers/types.d.ts +3 -0
  65. package/dist/services/metadata.d.ts +1 -1
  66. package/dist/services/person-context.d.ts +24 -7
  67. package/dist/services/person-context.js +45 -11
  68. package/dist/services/person-preparation.js +4 -5
  69. package/dist/services/project-status/index.js +2 -1
  70. package/dist/services/stored-project-gathering.js +4 -3
  71. package/dist/store/damage.d.ts +3 -1
  72. package/dist/store/damage.js +19 -12
  73. package/dist/store/document-transfer/index.js +7 -0
  74. package/dist/store/exports.d.ts +1 -0
  75. package/dist/store/exports.js +1 -0
  76. package/dist/store/index.d.ts +7 -1
  77. package/dist/store/index.js +2 -0
  78. package/dist/store/marks.d.ts +57 -0
  79. package/dist/store/marks.js +121 -0
  80. package/dist/store/project-transfer/preview.js +12 -7
  81. package/dist/store/project-transfer/request.d.ts +4 -1
  82. package/dist/store/project-transfer/schema.d.ts +9 -2
  83. package/dist/store/project-transfer/schema.js +4 -0
  84. package/dist/store/project-transfer/snapshot-model.d.ts +8 -2
  85. package/dist/store/recover.js +16 -1
  86. package/dist/store/sqlite/crm-settings.d.ts +28 -0
  87. package/dist/store/sqlite/crm-settings.js +80 -0
  88. package/dist/store/sqlite/crm.d.ts +42 -2
  89. package/dist/store/sqlite/crm.js +397 -36
  90. package/dist/store/sqlite/deals.js +3 -2
  91. package/dist/store/sqlite/finance.d.ts +8 -1
  92. package/dist/store/sqlite/finance.js +10 -3
  93. package/dist/store/sqlite/involvement-queue.js +4 -3
  94. package/dist/store/sqlite/knowledge.d.ts +7 -3
  95. package/dist/store/sqlite/knowledge.js +43 -31
  96. package/dist/store/sqlite/link-kinds.d.ts +2 -3
  97. package/dist/store/sqlite/link-kinds.js +4 -2
  98. package/dist/store/sqlite/manifest.js +5 -0
  99. package/dist/store/sqlite/memories.d.ts +1 -1
  100. package/dist/store/sqlite/memories.js +33 -7
  101. package/dist/store/sqlite/migrations.generated.js +31 -0
  102. package/dist/store/sqlite/notes.d.ts +3 -2
  103. package/dist/store/sqlite/notes.js +23 -6
  104. package/dist/store/sqlite/open-store.js +4 -1
  105. package/dist/store/sqlite/organizations.d.ts +8 -0
  106. package/dist/store/sqlite/organizations.js +14 -0
  107. package/dist/store/sqlite/own-identities.d.ts +1 -1
  108. package/dist/store/sqlite/own-identities.js +7 -5
  109. package/dist/store/sqlite/person-links.d.ts +5 -2
  110. package/dist/store/sqlite/person-links.js +24 -18
  111. package/dist/store/sqlite/person-preparation.d.ts +1 -1
  112. package/dist/store/sqlite/person-preparation.js +3 -2
  113. package/dist/store/sqlite/person-separation.d.ts +5 -0
  114. package/dist/store/sqlite/person-separation.js +26 -0
  115. package/dist/store/sqlite/project-transfer/records.js +14 -3
  116. package/dist/store/sqlite/project-transfer/snapshot.d.ts +4 -1
  117. package/dist/store/sqlite/project-transfer/snapshot.js +6 -0
  118. package/dist/store/sqlite/record-projectors.d.ts +44 -0
  119. package/dist/store/sqlite/record-projectors.js +72 -0
  120. package/dist/store/sqlite/records.js +12 -70
  121. package/dist/store/sqlite/relation-list.d.ts +43 -0
  122. package/dist/store/sqlite/relation-list.js +133 -0
  123. package/dist/store/sqlite/relation-proposals.d.ts +28 -6
  124. package/dist/store/sqlite/relation-proposals.js +134 -10
  125. package/dist/store/sqlite/relation-reads.d.ts +8 -0
  126. package/dist/store/sqlite/relation-reads.js +7 -0
  127. package/dist/store/sqlite/relation-roles.d.ts +26 -0
  128. package/dist/store/sqlite/relation-roles.js +91 -0
  129. package/dist/store/sqlite/reported-relations.d.ts +63 -0
  130. package/dist/store/sqlite/reported-relations.js +132 -0
  131. package/dist/store/sqlite/schema/link-revisions.d.ts +136 -0
  132. package/dist/store/sqlite/schema/link-revisions.js +11 -0
  133. package/dist/store/sqlite/schema/links.d.ts +360 -0
  134. package/dist/store/sqlite/schema/links.js +32 -0
  135. package/dist/store/sqlite/schema.d.ts +2 -296
  136. package/dist/store/sqlite/schema.js +2 -24
  137. package/dist/store/sqlite/transaction.js +2 -5
  138. package/dist/store/store.d.ts +3 -0
  139. package/dist/store/store.js +5 -0
  140. package/dist/store/types.d.ts +5 -0
  141. package/package.json +5 -5
@@ -272,7 +272,7 @@ export declare const ENTITIES: {
272
272
  readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
273
273
  readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
274
274
  readonly owner: v.BooleanSchema<undefined>;
275
- readonly role: v.PicklistSchema<["owner", "contact", "decision-maker"], undefined>;
275
+ readonly role: v.PicklistSchema<readonly ["owner", "contact", "decision-maker", "influencer"], undefined>;
276
276
  }, undefined>, undefined>;
277
277
  readonly author: v.StrictObjectSchema<{
278
278
  readonly type: v.PicklistSchema<["person", "bot"], undefined>;
@@ -327,7 +327,7 @@ export declare const ENTITIES: {
327
327
  readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
328
328
  readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
329
329
  readonly owner: v.BooleanSchema<undefined>;
330
- readonly role: v.PicklistSchema<["owner", "contact", "decision-maker"], undefined>;
330
+ readonly role: v.PicklistSchema<readonly ["owner", "contact", "decision-maker", "influencer"], undefined>;
331
331
  }, undefined>, undefined>;
332
332
  readonly author: v.StrictObjectSchema<{
333
333
  readonly type: v.PicklistSchema<["person", "bot"], undefined>;
@@ -2689,6 +2689,10 @@ export declare const ENTITIES: {
2689
2689
  readonly username: v.NullableSchema<v.StringSchema<undefined>, undefined>;
2690
2690
  readonly is_bot: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
2691
2691
  readonly accounts: v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
2692
+ readonly seen_in: v.ArraySchema<v.StrictObjectSchema<{
2693
+ readonly account: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
2694
+ readonly scope: v.PicklistSchema<["personal", "work"], undefined>;
2695
+ }, undefined>, undefined>;
2692
2696
  readonly method: v.StringSchema<undefined>;
2693
2697
  readonly linked_by: v.StringSchema<undefined>;
2694
2698
  readonly linked_at: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>;
@@ -2696,6 +2700,11 @@ export declare const ENTITIES: {
2696
2700
  readonly provider: v.StringSchema<undefined>;
2697
2701
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
2698
2702
  }, undefined>;
2703
+ readonly accounts: v.ArraySchema<v.StrictObjectSchema<{
2704
+ readonly provider: v.StringSchema<undefined>;
2705
+ readonly account: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
2706
+ readonly scope: v.PicklistSchema<["personal", "work"], undefined>;
2707
+ }, undefined>, undefined>;
2699
2708
  readonly shared: v.ArraySchema<v.StrictObjectSchema<{
2700
2709
  readonly provider: v.StringSchema<undefined>;
2701
2710
  readonly account: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
@@ -3465,6 +3474,10 @@ export declare const ENTITIES: {
3465
3474
  readonly username: v.NullableSchema<v.StringSchema<undefined>, undefined>;
3466
3475
  readonly is_bot: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
3467
3476
  readonly accounts: v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
3477
+ readonly seen_in: v.ArraySchema<v.StrictObjectSchema<{
3478
+ readonly account: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
3479
+ readonly scope: v.PicklistSchema<["personal", "work"], undefined>;
3480
+ }, undefined>, undefined>;
3468
3481
  readonly method: v.StringSchema<undefined>;
3469
3482
  readonly linked_by: v.StringSchema<undefined>;
3470
3483
  readonly linked_at: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>;
@@ -3472,6 +3485,11 @@ export declare const ENTITIES: {
3472
3485
  readonly provider: v.StringSchema<undefined>;
3473
3486
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
3474
3487
  }, undefined>;
3488
+ readonly accounts: v.ArraySchema<v.StrictObjectSchema<{
3489
+ readonly provider: v.StringSchema<undefined>;
3490
+ readonly account: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
3491
+ readonly scope: v.PicklistSchema<["personal", "work"], undefined>;
3492
+ }, undefined>, undefined>;
3475
3493
  readonly shared: v.ArraySchema<v.StrictObjectSchema<{
3476
3494
  readonly provider: v.StringSchema<undefined>;
3477
3495
  readonly account: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
@@ -3748,6 +3766,10 @@ export declare const ENTITIES: {
3748
3766
  readonly username: v.NullableSchema<v.StringSchema<undefined>, undefined>;
3749
3767
  readonly is_bot: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
3750
3768
  readonly accounts: v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
3769
+ readonly seen_in: v.ArraySchema<v.StrictObjectSchema<{
3770
+ readonly account: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
3771
+ readonly scope: v.PicklistSchema<["personal", "work"], undefined>;
3772
+ }, undefined>, undefined>;
3751
3773
  readonly method: v.StringSchema<undefined>;
3752
3774
  readonly linked_by: v.StringSchema<undefined>;
3753
3775
  readonly linked_at: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>;
@@ -4586,7 +4608,7 @@ export declare const ENTITIES: {
4586
4608
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
4587
4609
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
4588
4610
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
4589
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
4611
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
4590
4612
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
4591
4613
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
4592
4614
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -4601,7 +4623,7 @@ export declare const ENTITIES: {
4601
4623
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
4602
4624
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
4603
4625
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
4604
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
4626
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
4605
4627
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
4606
4628
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
4607
4629
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -4702,7 +4724,7 @@ export declare const ENTITIES: {
4702
4724
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
4703
4725
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
4704
4726
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
4705
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
4727
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
4706
4728
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
4707
4729
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
4708
4730
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -4717,7 +4739,7 @@ export declare const ENTITIES: {
4717
4739
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
4718
4740
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
4719
4741
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
4720
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
4742
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
4721
4743
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
4722
4744
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
4723
4745
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -4819,7 +4841,7 @@ export declare const ENTITIES: {
4819
4841
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
4820
4842
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
4821
4843
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
4822
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
4844
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
4823
4845
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
4824
4846
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
4825
4847
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -4834,7 +4856,7 @@ export declare const ENTITIES: {
4834
4856
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
4835
4857
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
4836
4858
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
4837
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
4859
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
4838
4860
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
4839
4861
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
4840
4862
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -4964,7 +4986,7 @@ export declare const ENTITIES: {
4964
4986
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
4965
4987
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
4966
4988
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
4967
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
4989
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
4968
4990
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
4969
4991
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
4970
4992
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -4979,7 +5001,7 @@ export declare const ENTITIES: {
4979
5001
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
4980
5002
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
4981
5003
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
4982
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
5004
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
4983
5005
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
4984
5006
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
4985
5007
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -5074,7 +5096,7 @@ export declare const ENTITIES: {
5074
5096
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
5075
5097
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
5076
5098
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
5077
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
5099
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
5078
5100
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
5079
5101
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
5080
5102
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -5089,7 +5111,7 @@ export declare const ENTITIES: {
5089
5111
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
5090
5112
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
5091
5113
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
5092
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
5114
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
5093
5115
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
5094
5116
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
5095
5117
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -6585,13 +6607,17 @@ export declare const ENTITIES: {
6585
6607
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
6586
6608
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
6587
6609
  readonly to: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
6588
- readonly kind: v.PicklistSchema<readonly ["member-of", "related-to"], undefined>;
6610
+ readonly kind: v.PicklistSchema<("customer-of" | "member-of" | "partner-of" | "related-to" | "reports-to")[], undefined>;
6589
6611
  readonly role: v.NullableSchema<v.StringSchema<undefined>, undefined>;
6590
6612
  readonly purpose: v.NullableSchema<v.StringSchema<undefined>, undefined>;
6591
6613
  readonly evidence: v.NullableSchema<v.StringSchema<undefined>, undefined>;
6592
6614
  readonly confirmed: v.BooleanSchema<undefined>;
6593
6615
  readonly provenance: v.NullableSchema<v.StringSchema<undefined>, undefined>;
6594
6616
  readonly confidence_category: v.PicklistSchema<["owner-confirmed", "weak"], undefined>;
6617
+ readonly standing: v.PicklistSchema<readonly ["confirmed", "reported", "proposed", "ended"], undefined>;
6618
+ readonly position: v.NullableSchema<v.StringSchema<undefined>, undefined>;
6619
+ readonly starts_at: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
6620
+ readonly ends_at: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
6595
6621
  readonly created_at: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>;
6596
6622
  }, undefined>;
6597
6623
  readonly recipient: v.StrictObjectSchema<{
@@ -1,10 +1,10 @@
1
1
  import * as v from "valibot";
2
- /** A link the owner or an agent drew between two people, organizations, projects or tasks. */
2
+ /** A link the owner, an agent or a source drew between people, organizations, projects, tasks and deals. */
3
3
  export declare const relationship: v.StrictObjectSchema<{
4
4
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
5
5
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
6
6
  readonly to: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
7
- readonly kind: v.PicklistSchema<readonly ["member-of", "related-to"], undefined>;
7
+ readonly kind: v.PicklistSchema<("customer-of" | "member-of" | "partner-of" | "related-to" | "reports-to")[], undefined>;
8
8
  readonly role: v.NullableSchema<v.StringSchema<undefined>, undefined>;
9
9
  /** A purpose from memo's config; `null` means `work`. */
10
10
  readonly purpose: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -13,5 +13,11 @@ export declare const relationship: v.StrictObjectSchema<{
13
13
  readonly confirmed: v.BooleanSchema<undefined>;
14
14
  readonly provenance: v.NullableSchema<v.StringSchema<undefined>, undefined>;
15
15
  readonly confidence_category: v.PicklistSchema<["owner-confirmed", "weak"], undefined>;
16
+ /** `reported`: a CRM account says so and nobody confirmed it; `ended`: it no longer holds. */
17
+ readonly standing: v.PicklistSchema<readonly ["confirmed", "reported", "proposed", "ended"], undefined>;
18
+ /** A job title beside it, never its role. */
19
+ readonly position: v.NullableSchema<v.StringSchema<undefined>, undefined>;
20
+ readonly starts_at: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
21
+ readonly ends_at: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
16
22
  readonly created_at: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>;
17
23
  }, undefined>;
@@ -1,7 +1,7 @@
1
1
  import * as v from "valibot";
2
- import { RELATION_KINDS } from "../store/sqlite/link-kinds.js";
2
+ import { RELATION_KINDS, STANDINGS } from "../domain/relations.js";
3
3
  import { id, reference, text, time } from "./fields.js";
4
- /** A link the owner or an agent drew between two people, organizations, projects or tasks. */
4
+ /** A link the owner, an agent or a source drew between people, organizations, projects, tasks and deals. */
5
5
  export const relationship = v.strictObject({
6
6
  id,
7
7
  from: reference,
@@ -15,5 +15,11 @@ export const relationship = v.strictObject({
15
15
  confirmed: v.boolean(),
16
16
  provenance: v.nullable(text),
17
17
  confidence_category: v.picklist(["owner-confirmed", "weak"]),
18
+ /** `reported`: a CRM account says so and nobody confirmed it; `ended`: it no longer holds. */
19
+ standing: v.picklist(STANDINGS),
20
+ /** A job title beside it, never its role. */
21
+ position: v.nullable(text),
22
+ starts_at: v.nullable(time),
23
+ ends_at: v.nullable(time),
18
24
  created_at: time,
19
25
  });
@@ -52,7 +52,7 @@ export declare const taskCard: v.StrictObjectSchema<{
52
52
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
53
53
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
54
54
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
55
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
55
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
56
56
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
57
57
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
58
58
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -67,7 +67,7 @@ export declare const taskCard: v.StrictObjectSchema<{
67
67
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
68
68
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
69
69
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
70
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
70
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
71
71
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
72
72
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
73
73
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -170,7 +170,7 @@ export declare const taskCreated: v.StrictObjectSchema<{
170
170
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
171
171
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
172
172
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
173
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
173
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
174
174
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
175
175
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
176
176
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -185,7 +185,7 @@ export declare const taskCreated: v.StrictObjectSchema<{
185
185
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
186
186
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
187
187
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
188
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
188
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
189
189
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
190
190
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
191
191
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -289,7 +289,7 @@ export declare const taskLinks: v.UnionSchema<[v.StrictObjectSchema<{
289
289
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
290
290
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
291
291
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
292
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
292
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
293
293
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
294
294
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
295
295
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -304,7 +304,7 @@ export declare const taskLinks: v.UnionSchema<[v.StrictObjectSchema<{
304
304
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
305
305
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
306
306
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
307
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
307
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
308
308
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
309
309
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
310
310
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -436,7 +436,7 @@ export declare const taskMerge: v.StrictObjectSchema<{
436
436
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
437
437
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
438
438
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
439
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
439
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
440
440
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
441
441
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
442
442
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -451,7 +451,7 @@ export declare const taskMerge: v.StrictObjectSchema<{
451
451
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
452
452
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
453
453
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
454
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
454
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
455
455
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
456
456
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
457
457
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -548,7 +548,7 @@ export declare const taskUnmerge: v.StrictObjectSchema<{
548
548
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
549
549
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
550
550
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
551
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
551
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
552
552
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
553
553
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
554
554
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -563,7 +563,7 @@ export declare const taskUnmerge: v.StrictObjectSchema<{
563
563
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
564
564
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
565
565
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
566
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
566
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
567
567
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
568
568
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
569
569
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -1,4 +1,4 @@
1
- import { type CliError } from "@wirecat/cli-base";
1
+ import { CliError } from "@wirecat/cli-base";
2
2
  /**
3
3
  * **By shape, not by class.** A package linked during development brings its own copy of
4
4
  * cli-base, and an error built with one copy is not an `instanceof` the other's `CliError` —
@@ -14,3 +14,19 @@ export declare const isCommanderFailure: (value: unknown) => value is Error & {
14
14
  };
15
15
  /** What failed, never what it said: a messenger's refusal can quote the message back. */
16
16
  export declare const failureKey: (error: unknown) => string;
17
+ /**
18
+ * SQLite's primary result code: node:sqlite's `errcode`, or `errno` only on bun:sqlite's `SQLiteError`. A filesystem
19
+ * error's errno shares the low byte with SQLite's codes: Windows' EIO, -4070, reads as SQLITE_NOTADB.
20
+ */
21
+ export declare const sqliteCode: (error: unknown) => number | undefined;
22
+ /**
23
+ * A damaged store file as the owner's problem, not a bug: SQLITE_CORRUPT or SQLITE_NOTADB becomes `store.damaged`.
24
+ * `next` is the command line that says what to do, such as `tg store recover`, only where that command exists.
25
+ * Only for the CLI's own store: a file the owner named goes through `damagedFile`. Any other failure is returned as
26
+ * it came.
27
+ */
28
+ export declare const storeDamaged: (error: unknown, next?: string) => unknown;
29
+ /** Runs `work` on store files the owner named, so a damaged one is named rather than taken for the CLI's own. */
30
+ export declare const damagedFile: <T>(files: readonly string[], work: () => Promise<T>) => Promise<T>;
31
+ /** Whether `error` is SQLite saying the database file is damaged. */
32
+ export declare const isStoreDamage: (error: unknown) => boolean;
@@ -1,4 +1,4 @@
1
- import { errorCodes } from "@wirecat/cli-base";
1
+ import { CliError, errorCodes } from "@wirecat/cli-base";
2
2
  /**
3
3
  * **By shape, not by class.** A package linked during development brings its own copy of
4
4
  * cli-base, and an error built with one copy is not an `instanceof` the other's `CliError` —
@@ -16,3 +16,59 @@ export const isCommanderFailure = (value) => {
16
16
  };
17
17
  /** What failed, never what it said: a messenger's refusal can quote the message back. */
18
18
  export const failureKey = (error) => isCliFailure(error) ? error.code : error instanceof Error ? error.name : "error";
19
+ const SQLITE_CORRUPT = 11;
20
+ const SQLITE_NOTADB = 26;
21
+ const DAMAGED_TEXT = /database disk image is malformed|file is not a database|fts5: corruption/i;
22
+ /**
23
+ * SQLite's primary result code: node:sqlite's `errcode`, or `errno` only on bun:sqlite's `SQLiteError`. A filesystem
24
+ * error's errno shares the low byte with SQLite's codes: Windows' EIO, -4070, reads as SQLITE_NOTADB.
25
+ */
26
+ export const sqliteCode = (error) => {
27
+ const { errcode, errno, name } = (error ?? {});
28
+ const code = typeof errcode === "number" ? errcode : name === "SQLiteError" && typeof errno === "number" ? errno : null;
29
+ return code === null ? undefined : code & 0xff;
30
+ };
31
+ /** The SQLite failure that says the database file is damaged, on the error or up to five `cause`s behind it. */
32
+ const damageIn = (error) => {
33
+ if (isCliFailure(error) || isCommanderFailure(error))
34
+ return undefined;
35
+ let at = error;
36
+ for (let depth = 0; depth < 5 && at instanceof Error; depth += 1) {
37
+ const code = sqliteCode(at);
38
+ if ((code !== undefined && [SQLITE_CORRUPT, SQLITE_NOTADB].includes(code)) || DAMAGED_TEXT.test(at.message))
39
+ return at;
40
+ at = at.cause;
41
+ }
42
+ return undefined;
43
+ };
44
+ // The record's frames are where SQLite failed, not where the failure was renamed.
45
+ const wrapping = (error, original) => {
46
+ Object.defineProperty(error, "cause", { value: original, configurable: true, writable: true });
47
+ if (original instanceof Error && original.stack)
48
+ error.stack = original.stack;
49
+ return error;
50
+ };
51
+ /**
52
+ * A damaged store file as the owner's problem, not a bug: SQLITE_CORRUPT or SQLITE_NOTADB becomes `store.damaged`.
53
+ * `next` is the command line that says what to do, such as `tg store recover`, only where that command exists.
54
+ * Only for the CLI's own store: a file the owner named goes through `damagedFile`. Any other failure is returned as
55
+ * it came.
56
+ */
57
+ export const storeDamaged = (error, next) => damageIn(error)
58
+ ? wrapping(new CliError("configuration_error", `the store file is damaged${next ? `; \`${next}\` says what is damaged and what to do` : ""}`, { reason: "store.damaged" }), error)
59
+ : error;
60
+ /** Runs `work` on store files the owner named, so a damaged one is named rather than taken for the CLI's own. */
61
+ export const damagedFile = async (files, work) => {
62
+ try {
63
+ return await work();
64
+ }
65
+ catch (error) {
66
+ if (!damageIn(error))
67
+ throw error;
68
+ throw wrapping(new CliError("validation_error", `${files.join(" or ")} is damaged or not a database`, {
69
+ reason: "store.file-damaged",
70
+ }), error);
71
+ }
72
+ };
73
+ /** Whether `error` is SQLite saying the database file is damaged. */
74
+ export const isStoreDamage = (error) => damageIn(error) !== undefined;
@@ -157,6 +157,17 @@ const OTHERS = [
157
157
  ],
158
158
  validation("store.refused", "the local store refused the document text"),
159
159
  ["store.not-writable", "permission_error", "the message store cannot be written from this process"],
160
+ [
161
+ "store.damaged",
162
+ "configuration_error",
163
+ "the store file is damaged; store recover says what is lost and recovers it",
164
+ ],
165
+ validation("store.file-damaged", "the named store file is damaged or not a database"),
166
+ [
167
+ "store.unreadable",
168
+ "configuration_error",
169
+ "the store file's header or schema is damaged, so it cannot be recovered",
170
+ ],
160
171
  validation("store.in-use", "a process or a scheduled timer has the store open; stop it, then recover the store"),
161
172
  [
162
173
  "store.sqlite3-missing",
@@ -208,6 +219,7 @@ const OTHERS = [
208
219
  validation("record.reference-not-found", "a reference in the record's fields is not in the store"),
209
220
  validation("record.relation-ambiguous", "the record names more than one target for a role that takes one"),
210
221
  validation("record.stale-revision", "the store holds a newer revision of the record"),
222
+ validation("memory.already-superseded", "the memory was already replaced by another"),
211
223
  validation("memory.evidence-required", "a memory needs its evidence"),
212
224
  validation("memory.scope-required", "a memory needs its scope"),
213
225
  validation("money.amount", "the amount is not a decimal string in the currency's scale"),
@@ -231,6 +243,13 @@ const OTHERS = [
231
243
  validation("field.unknown-kind", "fields are listed for deals, leads, people and organizations only"),
232
244
  validation("crm.write-unsupported", "the CRM does not take this write, or does not recognise a repeated one"),
233
245
  validation("crm.unlisted-held", "a list of every id would mark most of a kind deleted; nothing was, until --rescan"),
246
+ validation("crm.not-reported", "the CRM did not list users or departments; what they would say is unknown, nothing withdrawn"),
247
+ validation("crm.reference-unknown", "a CRM row names a contact, company or user the store does not hold; that link was not made"),
248
+ validation("crm.pending-dropped", "relationships waited too long for an end that never came; they were dropped"),
249
+ validation("crm.email-ambiguous", "a CRM contact's email belongs to more than one person; the owner decides"),
250
+ validation("crm.own-unknown", "no own company of the CRM account is stored, so its users are no one's employees yet"),
251
+ validation("relationship.reference-unknown", "a reported relationship names something the store does not hold"),
252
+ validation("relationship.invalid", "a reported relationship joins ends or takes a role the registry refuses"),
234
253
  validation("order.duplicate", "the shop's order with this number is already stored; change its status instead"),
235
254
  validation("order.proposed", "the shop's order with this number already waits for the owner in a findings batch"),
236
255
  validation("order.field", "a field of the order is not valid"),
@@ -240,6 +259,11 @@ const OTHERS = [
240
259
  validation("order.status", "a rejected or deleted order's status does not change"),
241
260
  ["model.not-downloaded", "not_found", "the model is not downloaded on this machine"],
242
261
  ["person.no-owner", "not_found", "no person is marked as the owner in the store"],
262
+ [
263
+ "identity.separated",
264
+ "conflict",
265
+ "the owner separated this identity from that person; only the owner links it again",
266
+ ],
243
267
  ["transcription.no-key", "authentication_error", "no OpenAI key is set for transcription"],
244
268
  validation("transcription.too-large", "the audio is over the transcription provider's size limit"),
245
269
  [
@@ -277,6 +301,10 @@ const OTHERS = [
277
301
  ["proposals.agent-decisions-off", "permission_error", "agent decisions are turned off; the owner decides"],
278
302
  ["proposal.unknown-kind", "not_found", "no registered proposal kind holds this id"],
279
303
  validation("relationship.exists", "a confirmed relationship already links them"),
304
+ validation("relationship.role-exists", "the role list holds that role already"),
305
+ validation("relationship.role-built-in", "a built-in role stays on its list"),
306
+ validation("relationship.role-in-use", "relationships still hold that role; change them first (details.count)"),
307
+ validation("relationship.role-unknown", "the role is not one the relationship takes; the message lists them"),
280
308
  validation("ranking.invalid", "the ranking is not valid"),
281
309
  validation("ref.malformed", "the reference has a known kind but not its shape"),
282
310
  validation("ref.unknown-kind", "the text names no kind of reference"),
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { bareCheck, type CheckWords, checkWords } from "./domain/checks.js";
2
2
  export type { CounterField, CounterObservation, CounterObservations, CounterState } from "./domain/counters.js";
3
3
  export { COUNTER_FIELDS, counterValue, observedCounters } from "./domain/counters.js";
4
- export { CRM_KINDS, type CrmField, type CrmItem, type CrmKind, type CrmOrganization, type CrmPerson, type CrmPipeline, type CrmRecords, type CrmStage, type CrmValue, isItemKind, } from "./domain/crm.js";
4
+ export { CRM_KINDS, type CrmDepartment, type CrmField, type CrmItem, type CrmKind, type CrmOrganization, type CrmPerson, type CrmPipeline, type CrmRecords, type CrmStage, type CrmUser, type CrmValue, isItemKind, } from "./domain/crm.js";
5
5
  export { DEAL_KINDS, DEAL_ROLES, DEAL_STATUSES, type DealKind, type DealRole, type DealStatus, STAGE_OUTCOMES, type StageOutcome, } from "./domain/deals.js";
6
6
  export { FINANCE_REVIEWS, type FinanceReview, INVOICE_DIRECTIONS, INVOICE_STATUSES, type InvoiceDirection, type InvoiceStatus, MONEY_DIRECTIONS, type MoneyDirection, } from "./domain/finance.js";
7
7
  export { type FormattedText, type HtmlFormatting, type MarkdownFormatting, type TextSpan, validateFormattedText, } from "./domain/formatting.js";
@@ -19,6 +19,7 @@ export type { RankingComponent, RankingInput, RankingMeasure, RankingOptions, Ra
19
19
  export { rankingOptions } from "./domain/rankings-options.js";
20
20
  export { type EnvelopeRecord, type EnvelopeSource, envelopeOfJsonl, type IngestError, RECORD_ENTITY_TYPES, RECORD_OPERATIONS, RECORDS_ENVELOPE_SCHEMA, RECORDS_SCHEMA_VERSION, type RecordEntityType, type RecordOperation, type RecordRelation, type RecordsEnvelope, } from "./domain/records.js";
21
21
  export { canonicalReference, formatReference, looksLikeReference, parseReference, REF_KINDS, type Reference, type RefKindName, type RefKindSpec, } from "./domain/references.js";
22
+ export { inverseOf, isUsable, ORGANIZATION_ROLES, PROJECT_ROLES, RELATION_KINDS, RELATIONS, type RelationKind, ROLE_LISTS, type RoleList, rolesOf, STANDINGS, type Standing, standingOf, usableLink, } from "./domain/relations.js";
22
23
  export { normalizeTag, TAG_TYPES, type TagType } from "./domain/tags.js";
23
24
  export { type AppErrors, DETAILS as CORE_DETAILS, failureContext, REASONS as CORE_REASONS } from "./errors/reasons.js";
24
25
  export { canonicalMeetingReference, formatMeetingReference, type MeetingReference, parseMeetingReference, } from "./meetings/index.js";
package/dist/index.js CHANGED
@@ -14,6 +14,7 @@ export { CRM_OPENS, FOLDER_PROVIDERS, isFolderProvider, isKind, KINDS, kindIn, k
14
14
  export { rankingOptions } from "./domain/rankings-options.js";
15
15
  export { envelopeOfJsonl, RECORD_ENTITY_TYPES, RECORD_OPERATIONS, RECORDS_ENVELOPE_SCHEMA, RECORDS_SCHEMA_VERSION, } from "./domain/records.js";
16
16
  export { canonicalReference, formatReference, looksLikeReference, parseReference, REF_KINDS, } from "./domain/references.js";
17
+ export { inverseOf, isUsable, ORGANIZATION_ROLES, PROJECT_ROLES, RELATION_KINDS, RELATIONS, ROLE_LISTS, rolesOf, STANDINGS, standingOf, usableLink, } from "./domain/relations.js";
17
18
  export { normalizeTag, TAG_TYPES } from "./domain/tags.js";
18
19
  export { DETAILS as CORE_DETAILS, failureContext, REASONS as CORE_REASONS } from "./errors/reasons.js";
19
20
  export { canonicalMeetingReference, formatMeetingReference, parseMeetingReference, } from "./meetings/index.js";
@@ -19,7 +19,7 @@ import { parseDuration } from "../../domain/duration.js";
19
19
  import { formatReference } from "../../domain/references.js";
20
20
  import { AGENDA_DEFAULTS } from "../../services/agenda.js";
21
21
  import { REVIEW_DAYS, reviewStart } from "../../services/inbox.js";
22
- import { readPastMark } from "../marks.js";
22
+ import { cursorOf, findingsKeyOf, readPastMark } from "../marks.js";
23
23
  import { BULK_TRIAGE_DEFAULTS } from "../newsletter.js";
24
24
  import { hitText } from "../read.js";
25
25
  import { OWED_DAYS, REVIEW_THREADS, reviewMail } from "../review.js";
@@ -146,6 +146,7 @@ const reviewAnswer = (found, mailbox, fresh, step) => {
146
146
  bulk: (message.marks?.bulk ?? false) || message.excerptOnly === true,
147
147
  ...(message.excerptOnly ? { excerpt_only: true } : {}),
148
148
  ...(message.partialExcerpt ? { partial: true } : {}),
149
+ ...(message.through ? { cursor: message.through.cursor, findings_key: message.through.findingsKey } : {}),
149
150
  list_id: message.marks?.listId ?? null,
150
151
  rule_id: message.marks?.ruleId ?? null,
151
152
  ...(message.marks
@@ -170,15 +171,27 @@ const holderReview = async (command, mail, holder, query) => {
170
171
  if (typedQuery(query).trim() || unanswered !== undefined || waiting !== undefined)
171
172
  throw new CliError("validation_error", "--holder reads past its own mark — not with a query, --unanswered or --waiting");
172
173
  const triage = mail.bulkTriage?.(command) ?? BULK_TRIAGE_DEFAULTS;
174
+ const now = Date.now();
173
175
  const { read, mailbox, marks } = await mail.read(command, async (store, mailbox) => {
174
- const read = await readPastMark(store, mailbox, holder, { triage });
176
+ const read = await readPastMark(store, mailbox, holder, { triage, now });
175
177
  const ids = [...read.emails, ...read.excerpts.map(({ email }) => email)].map((one) => one.id);
176
178
  const account = ids.length ? await store.accounts.storedAccount(mailbox) : undefined;
177
179
  const marks = account ? await store.mail.emailMarks(account.id, ids) : new Map();
178
180
  return { read, mailbox, marks };
179
181
  });
182
+ const markedThrough = read.mark?.throughId ?? 0;
183
+ const heldThrough = [...read.emails, ...read.excerpts.map(({ email }) => email)].reduce((most, { storeId }) => (storeId <= markedThrough ? Math.max(most, storeId) : most), 0);
184
+ // A held email is older than the mark, and a cursor never moves the mark back.
185
+ const through = (id) => {
186
+ const held = id <= markedThrough;
187
+ const at = held ? markedThrough : id;
188
+ return {
189
+ cursor: cursorOf(at, now),
190
+ findingsKey: findingsKeyOf(holder, at, read.mark?.resets ?? 0, held ? heldThrough : undefined),
191
+ };
192
+ };
180
193
  // An agent reads this: earlier mail and signatures stay out of its text; the fingerprint is over the stored body.
181
- const emails = [
194
+ const listed = [
182
195
  ...read.emails.map((email) => ({ ...email, text: mailOwnText(email.text) })),
183
196
  ...read.excerpts.map(({ email, excerpt, partial }) => {
184
197
  const subject = email.email?.subject;
@@ -190,6 +203,7 @@ const holderReview = async (command, mail, holder, query) => {
190
203
  };
191
204
  }),
192
205
  ];
206
+ const emails = listed.map(({ storeId, ...email }) => ({ ...email, through: through(storeId) }));
193
207
  const chats = new Map();
194
208
  for (const email of emails) {
195
209
  const chat = chats.get(email.chatId) ?? {
@@ -203,10 +217,10 @@ const holderReview = async (command, mail, holder, query) => {
203
217
  chat.messages.push(mark ? { ...email, marks: mark } : email);
204
218
  chats.set(email.chatId, chat);
205
219
  }
206
- const now = new Date().toISOString();
220
+ const until = new Date(now).toISOString();
207
221
  const found = {
208
- since: read.mark?.throughAt ? new Date(read.mark.throughAt).toISOString() : now,
209
- until: now,
222
+ since: read.mark?.throughAt ? new Date(read.mark.throughAt).toISOString() : until,
223
+ until,
210
224
  complete: !read.more,
211
225
  chats: [...chats.values()],
212
226
  skipped: [],