@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
@@ -473,6 +473,7 @@ export const pollVotes = sqliteTable("poll_votes", {
473
473
  unique().on(table.chatId, table.messageExternalId, table.identityId),
474
474
  index("poll_votes_by_identity_id").on(table.identityId),
475
475
  ]);
476
+ export { linkRevisions } from "./schema/link-revisions.js";
476
477
  /**
477
478
  * One row per field a chat changed, written by a trigger on `chats` in the changing statement's transaction. No foreign
478
479
  * keys: an older build purges chats without knowing this table, and a trigger drops a purged chat's rows instead.
@@ -1781,30 +1782,7 @@ export const canonicalAutoTagClaims = sqliteTable("canonical_auto_tag_claims", {
1781
1782
  primaryKey({ columns: [table.chatId, table.tagId] }),
1782
1783
  index("canonical_auto_tag_claims_by_tag_id").on(table.tagId),
1783
1784
  ]);
1784
- export const links = sqliteTable("links", {
1785
- id: integer("id").primaryKey(),
1786
- fromType: text("from_type").notNull(),
1787
- fromId: integer("from_id").notNull(),
1788
- toType: text("to_type"),
1789
- toId: integer("to_id"),
1790
- kind: text("kind").notNull(),
1791
- anchor: text("anchor"),
1792
- source: text("source").notNull(),
1793
- targetText: text("target_text"),
1794
- targetFolded: text("target_folded"),
1795
- role: text("role"),
1796
- evidence: text("evidence"),
1797
- metadata: text("metadata"),
1798
- confirmed: integer("confirmed").notNull().default(1),
1799
- createdAt: integer("created_at").notNull(),
1800
- author: text("author"),
1801
- updatedAt: integer("updated_at").notNull(),
1802
- purpose: text("purpose"),
1803
- }, (table) => [
1804
- index("links_unresolved").on(table.targetFolded).where(sql `to_id IS NULL`),
1805
- index("links_by_from_type_from_id").on(table.fromType, table.fromId),
1806
- index("links_by_to_type_to_id").on(table.toType, table.toId),
1807
- ]);
1785
+ export { links } from "./schema/links.js";
1808
1786
  /**
1809
1787
  * Every run of `search messages` and `stats messages show`, with the parameters as the caller gave them — never
1810
1788
  * a message or a result. A row with a name is a saved search; an identical unnamed run counts on its row.
@@ -1,13 +1,10 @@
1
+ import { sqliteCode } from "../../errors/failures.js";
1
2
  import { drainInvolvementQueue } from "./involvement-queue.js";
2
3
  import { drainMentions } from "./mention-drain.js";
3
4
  import { drainStems, stemmerCache } from "./stems.js";
4
5
  const SQLITE_BUSY = 5;
5
6
  const pause = new Int32Array(new SharedArrayBuffer(4));
6
- export const isBusy = (error) => {
7
- const { errcode, errno } = (error ?? {});
8
- const code = errcode ?? errno;
9
- return typeof code === "number" && (code & 0xff) === SQLITE_BUSY;
10
- };
7
+ export const isBusy = (error) => sqliteCode(error) === SQLITE_BUSY;
11
8
  /**
12
9
  * Takes the write lock, waiting as long as the connection's `busy_timeout`. SQLite's own wait sleeps 1 ms, then up to
13
10
  * 100 ms between tries, so a process that commits and begins again at once is never seen free and the waiter fails
@@ -41,6 +41,7 @@ import { type StoreOptions } from "./sqlite/open-store.js";
41
41
  import { type OrdersStore } from "./sqlite/orders.js";
42
42
  import { type ProposedActionsStore } from "./sqlite/proposed-actions.js";
43
43
  import { type RecordStore } from "./sqlite/records.js";
44
+ import { type RelationsStore } from "./sqlite/reported-relations.js";
44
45
  import { type StoreTaskStore } from "./sqlite/tasks.js";
45
46
  import { type SyncStore } from "./sync.js";
46
47
  import { type TagsStore } from "./tags.js";
@@ -112,6 +113,8 @@ export interface MessageStore {
112
113
  readonly deals: DealsStore;
113
114
  /** A CRM account's pipelines, deals, leads, contacts and companies, written as the CRM has them. */
114
115
  readonly crm: CrmCopies;
116
+ /** Relationships a source account reports, written as a diff that never overrides the owner's. */
117
+ readonly relations: RelationsStore;
115
118
  /** The one-time keys behind the buttons of a message that asks the owner to decide a batch. */
116
119
  readonly decisionRequests: DecisionRequestStore;
117
120
  /** What each import said, by the source's identity; `ingest` (services) is the way in. */
@@ -45,6 +45,7 @@ import { projectAnnotationStoreOver } from "./sqlite/project-transfer/store.js";
45
45
  import { proposedActionsStoreOver } from "./sqlite/proposed-actions.js";
46
46
  import { recordStoreOver } from "./sqlite/records.js";
47
47
  import { refSummariesOf } from "./sqlite/ref-summaries.js";
48
+ import { relationsStoreOver } from "./sqlite/reported-relations.js";
48
49
  import * as stems from "./sqlite/stems.js";
49
50
  import { taskStoreOver } from "./sqlite/tasks.js";
50
51
  import { syncStoreOver } from "./sync.js";
@@ -123,6 +124,7 @@ const storeOver = (context) => {
123
124
  const orders = once(() => ordersStoreOver(context));
124
125
  const deals = once(() => dealsStoreOver(context));
125
126
  const crm = once(() => crmCopiesOver(context, accountPeopleOver(context)));
127
+ const relations = once(() => relationsStoreOver(context));
126
128
  const decisionRequests = once(() => decisionRequestStoreOver(context));
127
129
  const records = once(() => recordStoreOver(context));
128
130
  const memories = once(() => memoriesStoreOver(context));
@@ -240,6 +242,9 @@ const storeOver = (context) => {
240
242
  get crm() {
241
243
  return crm();
242
244
  },
245
+ get relations() {
246
+ return relations();
247
+ },
243
248
  get decisionRequests() {
244
249
  return decisionRequests();
245
250
  },
@@ -53,6 +53,11 @@ export interface LinkedIdentity extends IdentityRef {
53
53
  isBot: boolean | null;
54
54
  /** The accounts in this store that have seen it. */
55
55
  accounts: Id[];
56
+ /** The same accounts with their scope: a person joined by email may be seen by personal and work accounts. */
57
+ seenIn: {
58
+ account: Id;
59
+ scope: StoredAccount["scope"];
60
+ }[];
56
61
  method: string;
57
62
  linkedBy: string;
58
63
  linkedAt: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wirecat/cli-core",
3
- "version": "0.604.0",
3
+ "version": "0.606.0",
4
4
  "description": "The messenger-neutral half of a messaging CLI: domain model, message locators, rendering, name resolution, the SQLite seam, the command skeleton and shared read commands, the send guard, run records and the message store",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Viacheslav Ptsarev",
@@ -15,8 +15,8 @@
15
15
  "type": "module",
16
16
  "wirecat": {
17
17
  "store": {
18
- "speaks": 55,
19
- "minCompatible": 34
18
+ "speaks": 56,
19
+ "minCompatible": 56
20
20
  }
21
21
  },
22
22
  "engines": {
@@ -276,7 +276,7 @@
276
276
  "@types/node": "^22.20.5",
277
277
  "@types/pngjs": "6.0.5",
278
278
  "@vitest/coverage-v8": "^5.0.5",
279
- "@wirecat/cli-base": "0.80.7",
279
+ "@wirecat/cli-base": "0.82.0",
280
280
  "@wirecat/cli-core-legacy-tags": "npm:@wirecat/cli-core@0.414.0",
281
281
  "commander": "15.0.0",
282
282
  "cspell": "10.4.0",
@@ -296,7 +296,7 @@
296
296
  },
297
297
  "peerDependencies": {
298
298
  "@napi-rs/canvas": ">=0.1.69 <2",
299
- "@wirecat/cli-base": ">=0.80.7 <0.81.0",
299
+ "@wirecat/cli-base": ">=0.80.7 <0.83.0",
300
300
  "commander": ">=15"
301
301
  },
302
302
  "bin": {