@wirecat/cli-core 0.618.0 → 0.620.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 (335) hide show
  1. package/CHANGELOG.md +453 -1
  2. package/README.md +1 -1
  3. package/THIRD_PARTY_NOTICES +3 -0
  4. package/dist/background/deliver.d.ts +5 -2
  5. package/dist/background/deliver.js +30 -12
  6. package/dist/background/report/render.d.ts +3 -1
  7. package/dist/background/report/render.js +3 -1
  8. package/dist/calendar/cli/answers.d.ts +1 -0
  9. package/dist/calendar/cli/answers.js +6 -1
  10. package/dist/calendar/cli/index.js +2 -14
  11. package/dist/calendar/cli/people-link.d.ts +3 -0
  12. package/dist/calendar/cli/people-link.js +23 -0
  13. package/dist/calendar/cli/search-all.d.ts +1 -1
  14. package/dist/calendar/cli/search-all.js +9 -10
  15. package/dist/calendar/index.d.ts +1 -1
  16. package/dist/calendar/index.js +1 -1
  17. package/dist/calendar/mcp/index.d.ts +12 -12
  18. package/dist/calendar/prepare.js +1 -0
  19. package/dist/cli/base-stages-command.d.ts +22 -0
  20. package/dist/cli/base-stages-command.js +174 -0
  21. package/dist/cli/bot/buttons.d.ts +3 -0
  22. package/dist/cli/bot/buttons.js +24 -0
  23. package/dist/cli/bot/messages.js +14 -1
  24. package/dist/cli/bot/port.d.ts +8 -0
  25. package/dist/cli/command-runs.d.ts +2 -0
  26. package/dist/cli/command-runs.js +3 -1
  27. package/dist/cli/config-command.js +6 -1
  28. package/dist/cli/context.js +1 -0
  29. package/dist/cli/contract-templates.js +31 -2
  30. package/dist/cli/group-lock.d.ts +42 -0
  31. package/dist/cli/group-lock.js +130 -0
  32. package/dist/cli/index.d.ts +7 -2
  33. package/dist/cli/index.js +7 -2
  34. package/dist/cli/messenger/backfill-command.js +27 -15
  35. package/dist/cli/messenger/contacts-command.js +12 -4
  36. package/dist/cli/messenger/context.js +1 -0
  37. package/dist/cli/messenger/conversations-command.js +2 -1
  38. package/dist/cli/messenger/doctor-command.js +3 -1
  39. package/dist/cli/messenger/message-items.js +1 -1
  40. package/dist/cli/messenger/models-command.js +1 -1
  41. package/dist/cli/messenger/search-answers.d.ts +5 -5
  42. package/dist/cli/messenger/search-answers.js +9 -20
  43. package/dist/cli/messenger/search-command.d.ts +2 -2
  44. package/dist/cli/messenger/search-command.js +8 -18
  45. package/dist/cli/messenger/store-maintenance-command.d.ts +22 -2
  46. package/dist/cli/messenger/store-maintenance-command.js +9 -4
  47. package/dist/cli/model-catalogue-command.d.ts +3 -1
  48. package/dist/cli/model-catalogue-command.js +48 -2
  49. package/dist/cli/profile.d.ts +8 -0
  50. package/dist/cli/profile.js +25 -0
  51. package/dist/cli/program.js +2 -0
  52. package/dist/cli/runs/search-query.d.ts +1 -1
  53. package/dist/cli/runs/search-query.js +4 -0
  54. package/dist/cli/runs/search.d.ts +5 -1
  55. package/dist/cli/runs/search.js +12 -1
  56. package/dist/cli/search-harder-consents-command.d.ts +18 -0
  57. package/dist/cli/search-harder-consents-command.js +83 -0
  58. package/dist/cli/search-left-out.d.ts +6 -1
  59. package/dist/cli/search-left-out.js +9 -4
  60. package/dist/cli/settings.d.ts +8 -0
  61. package/dist/cli/settings.js +17 -2
  62. package/dist/cli/shared-command-exports.d.ts +16 -0
  63. package/dist/cli/steps.js +0 -6
  64. package/dist/cli/store-recover.d.ts +3 -3
  65. package/dist/cli/store-recover.js +26 -26
  66. package/dist/cli/store-settings.d.ts +2 -0
  67. package/dist/cli/store-settings.js +37 -9
  68. package/dist/cli/templates-command.js +4 -4
  69. package/dist/crm/cli/index.js +40 -8
  70. package/dist/crm/cli/search-all.js +7 -6
  71. package/dist/crm/group-hint.d.ts +8 -0
  72. package/dist/crm/group-hint.js +13 -0
  73. package/dist/crm/source.d.ts +12 -1
  74. package/dist/crm/sync.d.ts +31 -2
  75. package/dist/crm/sync.js +110 -3
  76. package/dist/crm/testing/acme-scenario.d.ts +40 -0
  77. package/dist/crm/testing/acme-scenario.js +170 -0
  78. package/dist/crm/testing/index.d.ts +1 -0
  79. package/dist/crm/testing/index.js +1 -0
  80. package/dist/crm/testing/source-contract.js +12 -0
  81. package/dist/crm/testing/source.d.ts +2 -0
  82. package/dist/crm/testing/source.js +1 -0
  83. package/dist/domain/addresses.d.ts +13 -0
  84. package/dist/domain/addresses.js +63 -0
  85. package/dist/domain/categories.d.ts +3 -0
  86. package/dist/domain/categories.js +2 -0
  87. package/dist/domain/crm.d.ts +23 -0
  88. package/dist/domain/crm.js +7 -0
  89. package/dist/domain/mentions.d.ts +2 -12
  90. package/dist/domain/mentions.js +2 -19
  91. package/dist/domain/models.d.ts +2 -0
  92. package/dist/domain/orders.d.ts +8 -1
  93. package/dist/domain/orders.js +6 -2
  94. package/dist/domain/phones.d.ts +26 -0
  95. package/dist/domain/phones.js +48 -0
  96. package/dist/domain/record-types.d.ts +1 -1
  97. package/dist/domain/record-types.js +1 -0
  98. package/dist/domain/records.d.ts +5 -0
  99. package/dist/domain/ref-summaries.d.ts +39 -0
  100. package/dist/domain/ref-summaries.js +51 -3
  101. package/dist/domain/relations.d.ts +12 -2
  102. package/dist/domain/relations.js +14 -3
  103. package/dist/domain/vcard.d.ts +2 -2
  104. package/dist/domain/vcard.js +4 -10
  105. package/dist/embeddings/models.d.ts +11 -3
  106. package/dist/embeddings/models.js +28 -4
  107. package/dist/entities/business-context.d.ts +149 -0
  108. package/dist/entities/business-context.js +192 -0
  109. package/dist/entities/contact-activity.d.ts +2 -0
  110. package/dist/entities/contact-activity.js +7 -1
  111. package/dist/entities/contact-context.d.ts +160 -0
  112. package/dist/entities/contact-context.js +6 -0
  113. package/dist/entities/deal.d.ts +10 -0
  114. package/dist/entities/deal.js +2 -0
  115. package/dist/entities/hit.d.ts +9 -2
  116. package/dist/entities/hit.js +6 -2
  117. package/dist/entities/index.d.ts +32 -4
  118. package/dist/entities/index.js +5 -0
  119. package/dist/entities/mention.d.ts +4 -3
  120. package/dist/entities/mention.js +2 -1
  121. package/dist/entities/message-transfer.d.ts +4 -2
  122. package/dist/entities/message-transfer.js +2 -2
  123. package/dist/entities/model.d.ts +2 -2
  124. package/dist/entities/model.js +1 -1
  125. package/dist/entities/relationship.d.ts +4 -0
  126. package/dist/entities/relationship.js +4 -0
  127. package/dist/errors/reasons.js +39 -4
  128. package/dist/fetch/page.js +2 -1
  129. package/dist/index.d.ts +3 -2
  130. package/dist/index.js +3 -2
  131. package/dist/meetings/context-store.d.ts +2 -0
  132. package/dist/meetings/findings-rules.d.ts +4 -0
  133. package/dist/meetings/findings-rules.js +5 -2
  134. package/dist/meetings/hit-query.d.ts +1 -1
  135. package/dist/meetings/hit-query.js +2 -2
  136. package/dist/meetings/index.d.ts +1 -0
  137. package/dist/meetings/index.js +1 -0
  138. package/dist/meetings/result-items.d.ts +1 -0
  139. package/dist/meetings/result-items.js +1 -0
  140. package/dist/meetings/store.d.ts +4 -0
  141. package/dist/meetings/store.js +2 -1
  142. package/dist/models/anthropic.js +5 -0
  143. package/dist/models/index.js +22 -5
  144. package/dist/runs/events.d.ts +11 -1
  145. package/dist/runs/events.js +3 -1
  146. package/dist/runs/log-attributes.js +4 -0
  147. package/dist/runs/log-events.js +2 -0
  148. package/dist/runs/recording.d.ts +3 -0
  149. package/dist/runs/recording.js +36 -12
  150. package/dist/runs/run.d.ts +12 -3
  151. package/dist/runs/run.js +32 -13
  152. package/dist/search/account-list.d.ts +6 -0
  153. package/dist/search/account-list.js +9 -3
  154. package/dist/search/groups.d.ts +68 -0
  155. package/dist/search/groups.js +172 -0
  156. package/dist/search/question-period.d.ts +10 -0
  157. package/dist/search/question-period.js +133 -0
  158. package/dist/sends/buttons.d.ts +2 -0
  159. package/dist/sends/buttons.js +6 -1
  160. package/dist/services/account-groups.d.ts +28 -0
  161. package/dist/services/account-groups.js +89 -0
  162. package/dist/services/archive.d.ts +7 -1
  163. package/dist/services/archive.js +19 -3
  164. package/dist/services/business-context.d.ts +113 -0
  165. package/dist/services/business-context.js +156 -0
  166. package/dist/services/communications.d.ts +50 -0
  167. package/dist/services/communications.js +140 -0
  168. package/dist/services/deal-context.d.ts +90 -0
  169. package/dist/services/deal-context.js +131 -0
  170. package/dist/services/deps.d.ts +2 -0
  171. package/dist/services/enrichment.d.ts +12 -2
  172. package/dist/services/enrichment.js +47 -6
  173. package/dist/services/events-search.js +2 -1
  174. package/dist/services/group-guard.d.ts +28 -0
  175. package/dist/services/group-guard.js +131 -0
  176. package/dist/services/index.d.ts +19 -4
  177. package/dist/services/index.js +12 -3
  178. package/dist/services/ingest.d.ts +12 -0
  179. package/dist/services/ingest.js +4 -0
  180. package/dist/services/meaning-model.d.ts +7 -0
  181. package/dist/services/meaning-model.js +20 -0
  182. package/dist/services/meeting-context.d.ts +6 -1
  183. package/dist/services/meeting-context.js +12 -5
  184. package/dist/services/message-resolution.js +2 -3
  185. package/dist/services/messages-meaning.js +4 -5
  186. package/dist/services/messages-search.d.ts +5 -1
  187. package/dist/services/messages-search.js +1 -1
  188. package/dist/services/messages.d.ts +1 -4
  189. package/dist/services/messages.js +0 -2
  190. package/dist/services/metadata.d.ts +1 -1
  191. package/dist/services/model-downloads.d.ts +1 -1
  192. package/dist/services/model-downloads.js +6 -4
  193. package/dist/services/money-context.d.ts +73 -0
  194. package/dist/services/money-context.js +77 -0
  195. package/dist/services/notes-search.d.ts +4 -1
  196. package/dist/services/notes-search.js +19 -7
  197. package/dist/services/organization-context.d.ts +80 -0
  198. package/dist/services/organization-context.js +154 -0
  199. package/dist/services/people.d.ts +22 -6
  200. package/dist/services/people.js +38 -8
  201. package/dist/services/person-business.d.ts +43 -0
  202. package/dist/services/person-business.js +67 -0
  203. package/dist/services/person-context.d.ts +11 -1
  204. package/dist/services/person-context.js +25 -10
  205. package/dist/services/person-preparation.d.ts +5 -1
  206. package/dist/services/person-preparation.js +10 -3
  207. package/dist/services/person-timeline.d.ts +6 -1
  208. package/dist/services/person-timeline.js +10 -2
  209. package/dist/services/proposals/kinds/identity-link.d.ts +4 -0
  210. package/dist/services/proposals/kinds/identity-link.js +48 -0
  211. package/dist/services/proposals/kinds/orders.js +1 -1
  212. package/dist/services/proposals/registry.js +2 -0
  213. package/dist/services/search-all-deprecated.d.ts +40 -0
  214. package/dist/services/search-all-deprecated.js +10 -0
  215. package/dist/services/search-all-meetings.d.ts +50 -52
  216. package/dist/services/search-all-meetings.js +265 -272
  217. package/dist/services/search-all.d.ts +34 -6
  218. package/dist/services/search-all.js +118 -24
  219. package/dist/services/search-harder.d.ts +64 -0
  220. package/dist/services/search-harder.js +194 -0
  221. package/dist/services/search-kind.d.ts +12 -5
  222. package/dist/services/search-kind.js +49 -10
  223. package/dist/services/text-model-choice.js +1 -1
  224. package/dist/store/accounts.d.ts +18 -0
  225. package/dist/store/accounts.js +18 -3
  226. package/dist/store/chats.d.ts +3 -1
  227. package/dist/store/chats.js +6 -0
  228. package/dist/store/damage.d.ts +43 -10
  229. package/dist/store/damage.js +119 -36
  230. package/dist/store/decisions.js +3 -1
  231. package/dist/store/evidence-findings.d.ts +14 -0
  232. package/dist/store/evidence-findings.js +2 -0
  233. package/dist/store/exports.d.ts +2 -1
  234. package/dist/store/identity-links.d.ts +92 -0
  235. package/dist/store/identity-links.js +6 -0
  236. package/dist/store/index.d.ts +11 -5
  237. package/dist/store/index.js +5 -2
  238. package/dist/store/journal.d.ts +10 -0
  239. package/dist/store/journal.js +33 -0
  240. package/dist/store/marks.d.ts +19 -1
  241. package/dist/store/marks.js +23 -1
  242. package/dist/store/people.d.ts +28 -2
  243. package/dist/store/people.js +15 -1
  244. package/dist/store/sqlite/accounts.js +2 -0
  245. package/dist/store/sqlite/added-sources.d.ts +15 -3
  246. package/dist/store/sqlite/added-sources.js +26 -5
  247. package/dist/store/sqlite/base-stages.d.ts +122 -0
  248. package/dist/store/sqlite/base-stages.js +443 -0
  249. package/dist/store/sqlite/base-suggest.d.ts +13 -0
  250. package/dist/store/sqlite/base-suggest.js +62 -0
  251. package/dist/store/sqlite/business-contracts.js +10 -1
  252. package/dist/store/sqlite/chats.d.ts +2 -0
  253. package/dist/store/sqlite/chats.js +6 -0
  254. package/dist/store/sqlite/crm-settings.d.ts +12 -2
  255. package/dist/store/sqlite/crm-settings.js +56 -13
  256. package/dist/store/sqlite/crm.d.ts +13 -1
  257. package/dist/store/sqlite/crm.js +20 -4
  258. package/dist/store/sqlite/deals.d.ts +33 -0
  259. package/dist/store/sqlite/deals.js +42 -4
  260. package/dist/store/sqlite/decision-requests.js +7 -3
  261. package/dist/store/sqlite/email-index.js +8 -4
  262. package/dist/store/sqlite/evidence-findings.js +29 -5
  263. package/dist/store/sqlite/findings-core.js +4 -2
  264. package/dist/store/sqlite/identity-link-rows.d.ts +50 -0
  265. package/dist/store/sqlite/identity-link-rows.js +146 -0
  266. package/dist/store/sqlite/identity-proposals.d.ts +53 -0
  267. package/dist/store/sqlite/identity-proposals.js +234 -0
  268. package/dist/store/sqlite/involvements.d.ts +1 -1
  269. package/dist/store/sqlite/involvements.js +4 -2
  270. package/dist/store/sqlite/knowledge.js +2 -2
  271. package/dist/store/sqlite/link-kinds.d.ts +1 -0
  272. package/dist/store/sqlite/link-kinds.js +1 -0
  273. package/dist/store/sqlite/link-row.d.ts +6 -0
  274. package/dist/store/sqlite/link-row.js +35 -0
  275. package/dist/store/sqlite/link-source.d.ts +10 -0
  276. package/dist/store/sqlite/link-source.js +16 -0
  277. package/dist/store/sqlite/manifest.js +1 -0
  278. package/dist/store/sqlite/meeting-context-links.js +9 -6
  279. package/dist/store/sqlite/meeting-hit-query.d.ts +5 -0
  280. package/dist/store/sqlite/meeting-hit-query.js +33 -0
  281. package/dist/store/sqlite/meeting-hit-search.js +10 -8
  282. package/dist/store/sqlite/meetings.js +1 -1
  283. package/dist/store/sqlite/memories.js +9 -7
  284. package/dist/store/sqlite/mentions.d.ts +4 -1
  285. package/dist/store/sqlite/mentions.js +14 -9
  286. package/dist/store/sqlite/migrations.generated.js +8 -0
  287. package/dist/store/sqlite/notes.d.ts +8 -2
  288. package/dist/store/sqlite/notes.js +17 -34
  289. package/dist/store/sqlite/open-store.js +3 -0
  290. package/dist/store/sqlite/open.js +11 -2
  291. package/dist/store/sqlite/orders.d.ts +2 -0
  292. package/dist/store/sqlite/orders.js +9 -3
  293. package/dist/store/sqlite/organization-categories.d.ts +18 -0
  294. package/dist/store/sqlite/organization-categories.js +34 -0
  295. package/dist/store/sqlite/organizations.d.ts +5 -1
  296. package/dist/store/sqlite/organizations.js +14 -4
  297. package/dist/store/sqlite/person-links.d.ts +19 -4
  298. package/dist/store/sqlite/person-links.js +49 -11
  299. package/dist/store/sqlite/person-match-scan.d.ts +13 -0
  300. package/dist/store/sqlite/person-match-scan.js +251 -0
  301. package/dist/store/sqlite/person-matcher.d.ts +16 -0
  302. package/dist/store/sqlite/person-matcher.js +32 -0
  303. package/dist/store/sqlite/person-preparation.d.ts +7 -3
  304. package/dist/store/sqlite/person-preparation.js +20 -6
  305. package/dist/store/sqlite/proposed-actions.js +6 -0
  306. package/dist/store/sqlite/record-matching.d.ts +2 -8
  307. package/dist/store/sqlite/record-matching.js +8 -40
  308. package/dist/store/sqlite/record-projectors-phone.js +2 -1
  309. package/dist/store/sqlite/record-relationships.d.ts +52 -0
  310. package/dist/store/sqlite/record-relationships.js +243 -0
  311. package/dist/store/sqlite/record-run.d.ts +5 -0
  312. package/dist/store/sqlite/record-run.js +62 -2
  313. package/dist/store/sqlite/record-writes.d.ts +1 -1
  314. package/dist/store/sqlite/record-writes.js +4 -2
  315. package/dist/store/sqlite/records.js +27 -2
  316. package/dist/store/sqlite/ref-accounts.d.ts +13 -0
  317. package/dist/store/sqlite/ref-accounts.js +117 -0
  318. package/dist/store/sqlite/ref-summaries.js +5 -1
  319. package/dist/store/sqlite/relation-list.d.ts +4 -1
  320. package/dist/store/sqlite/relation-list.js +22 -4
  321. package/dist/store/sqlite/relation-proposals.d.ts +6 -0
  322. package/dist/store/sqlite/relation-proposals.js +3 -0
  323. package/dist/store/sqlite/relation-roles.js +12 -6
  324. package/dist/store/sqlite/reported-relations.d.ts +11 -1
  325. package/dist/store/sqlite/reported-relations.js +59 -18
  326. package/dist/store/sqlite/schema.d.ts +32 -0
  327. package/dist/store/sqlite/schema.js +3 -0
  328. package/dist/store/sqlite/transaction.js +11 -1
  329. package/dist/store/store.d.ts +3 -0
  330. package/dist/store/store.js +5 -0
  331. package/dist/store/write-events.d.ts +18 -0
  332. package/dist/store/write-events.js +88 -0
  333. package/package.json +3 -3
  334. package/parity.json +37 -16
  335. package/schemas/records-envelope.v1.schema.json +3 -0
@@ -0,0 +1,131 @@
1
+ import { CliError } from "@wirecat/cli-base";
2
+ import { isUsable } from "../domain/relations.js";
3
+ import { coverageFor, edgesOf, grouped, namesOf, notRejected, organizationCategories, SECTION_LIMIT, STORE_PAGE, scopeOf, sectionOf, } from "./business-context.js";
4
+ import { communicationsOf } from "./communications.js";
5
+ import { moneyOf } from "./money-context.js";
6
+ import { openTasksOf } from "./organization-context.js";
7
+ const DAY = 86_400_000;
8
+ /**
9
+ * One answer about a deal or a lead from the store: the row, how it moved, its client, people, project, money and
10
+ * what its people said within its lifetime. Nothing is inferred from a stage's name. A CRM's copy outside
11
+ * `accounts` is not answered, and a CRM's relationships outside it are left out.
12
+ */
13
+ export const dealContext = async (store, reference, { accounts, limit = SECTION_LIMIT, now = Date.now(), deniedKinds = [] } = {}) => {
14
+ const scope = scopeOf(accounts, deniedKinds);
15
+ const kind = /^lead:/.test(reference.trim()) ? "lead" : "deal";
16
+ if (scope.denied.has(kind))
17
+ throw new CliError("permission_error", `the profile denies ${kind}s.list, so no ${kind} is answered`, {
18
+ reason: "deal.denied",
19
+ });
20
+ const row = await store.deals.get(reference);
21
+ const deal = row.deal !== null && !scope.allows(row.deal) ? { ...row, deal: null } : row;
22
+ if (!scope.has(deal.account))
23
+ throw new CliError("not_found", `${deal.ref} is a copy from an account outside the accounts asked for`, {
24
+ reason: "deal.out-of-scope",
25
+ });
26
+ const { edges, full } = await edgesOf(store, deal.ref, scope);
27
+ const people = edges.filter((edge) => edge.role.kind === "related-to" && edge.from === deal.ref && edge.to.startsWith("person:"));
28
+ const names = await namesOf(store, people.map(({ to }) => to));
29
+ const participants = grouped(people, (edge) => edge.to, names);
30
+ const owner = participants.find((one) => one.roles.some((role) => role.role === "owner" && isUsable(role.standing))) ?? null;
31
+ const organization = deal.organization;
32
+ const project = deal.project === null ? undefined : (await store.knowledge.projects()).find((one) => one.ref === deal.project);
33
+ const invoices = [];
34
+ const payments = [];
35
+ let complete = true;
36
+ const ways = [
37
+ ...(deal.project === null ? [] : [["project", { project: deal.project }, { project: deal.project }]]),
38
+ ...(organization === null
39
+ ? []
40
+ : [["counterparty", { counterparty: organization.ref }, { party: organization.ref }]]),
41
+ ];
42
+ for (const [way, invoiceFilter, paymentFilter] of ways) {
43
+ const invoiceRows = await store.finance.invoices({ ...invoiceFilter, limit: STORE_PAGE });
44
+ const paymentRows = await store.finance.payments({ ...paymentFilter, limit: STORE_PAGE });
45
+ complete &&= invoiceRows.length < STORE_PAGE && paymentRows.length < STORE_PAGE;
46
+ for (const invoice of notRejected(invoiceRows))
47
+ invoices.push([invoice, way]);
48
+ for (const payment of notRejected(paymentRows))
49
+ payments.push([payment, way]);
50
+ }
51
+ const only = ways.length === 1 ? ways[0]?.[0] : undefined;
52
+ const moneyNext = {
53
+ invoices: only === "project" && project
54
+ ? `invoices list project:${project.key}`
55
+ : only === "counterparty" && organization
56
+ ? `invoices list counterparty:"${organization.ref}"`
57
+ : null,
58
+ payments: only === "project" && project
59
+ ? `payments list project:${project.key}`
60
+ : only === "counterparty" && organization
61
+ ? `payments list party:"${organization.ref}"`
62
+ : null,
63
+ };
64
+ const since = Date.parse(deal.createdAt);
65
+ const until = deal.closedDate === null ? now : Date.parse(`${deal.closedDate}T00:00:00Z`) + DAY - 1;
66
+ const records = [];
67
+ for (const one of participants)
68
+ if (one.roles.some((role) => isUsable(role.standing))) {
69
+ const record = await store.people.personByUid(one.ref.slice("person:".length));
70
+ if (record)
71
+ records.push(record);
72
+ }
73
+ const talks = await communicationsOf(store, records, scope, { since, until, limit });
74
+ const said = talks.counts.messages + talks.counts.mail + talks.counts.meetings;
75
+ const stages = await store.deals.stages(deal.ref);
76
+ const tasks = await openTasksOf(store, project ? [{ ref: project.ref, key: project.key }] : []);
77
+ return {
78
+ deal,
79
+ stages: sectionOf(stages, limit, null, { newest: true }),
80
+ organization: organization === null
81
+ ? null
82
+ : {
83
+ ref: organization.ref,
84
+ name: organization.name,
85
+ categories: (await organizationCategories(store, scope)).get(organization.ref) ?? [],
86
+ },
87
+ participants: sectionOf(participants, limit, `relationships list about:${deal.ref} kind:related-to`, {
88
+ more: full,
89
+ }),
90
+ owner,
91
+ project: deal.project === null ? null : { ref: deal.project, name: deal.projectName },
92
+ money: moneyOf({ invoices, payments }, limit, moneyNext, complete),
93
+ window: { since: new Date(since).toISOString(), until: new Date(until).toISOString() },
94
+ communications: {
95
+ ...sectionOf(talks.items.map((touch) => ({ ...touch, standing: "proposed" })), limit, null, { more: talks.hasMore, total: Math.max(said, talks.items.length) }),
96
+ counts: talks.counts,
97
+ },
98
+ tasks: sectionOf(tasks.tasks, limit, tasks.next, { more: tasks.full }),
99
+ coverage: await coverageFor(store, talks.coverage, scope),
100
+ };
101
+ };
102
+ const BRIEF_STAGES = 5;
103
+ /** The roles a brief names: the usable ones, or, when none holds now, every one with its standing. */
104
+ const briefRoles = (one) => {
105
+ const usable = one.roles.filter((role) => isUsable(role.standing));
106
+ const shown = usable.length > 0 ? usable : one.roles;
107
+ return {
108
+ roles: shown.map((role) => role.role ?? role.kind),
109
+ standing: shown.some((role) => role.standing === "confirmed") ? "confirmed" : (shown[0]?.standing ?? "proposed"),
110
+ };
111
+ };
112
+ export const dealBrief = (context) => ({
113
+ ref: context.deal.ref,
114
+ kind: context.deal.kind,
115
+ title: context.deal.title,
116
+ pipeline: context.deal.pipelineName,
117
+ stage: context.deal.stage,
118
+ status: context.deal.status,
119
+ amount: context.deal.amount,
120
+ currency: context.deal.currency,
121
+ closeDate: context.deal.closeDate,
122
+ organization: context.organization?.name ?? context.organization?.ref ?? null,
123
+ owner: context.owner?.name ?? context.owner?.ref ?? null,
124
+ people: context.participants.items.map((one) => ({ ref: one.ref, name: one.name, ...briefRoles(one) })),
125
+ project: context.project?.name ?? context.project?.ref ?? null,
126
+ stages: context.stages.items.slice(-BRIEF_STAGES).map((change) => `${change.from ?? "∅"} → ${change.to}`),
127
+ money: { ...context.money.totals, unconfirmed: context.money.unconfirmed, complete: context.money.complete },
128
+ communications: { ...context.communications.counts, standing: "proposed" },
129
+ openTasks: context.tasks.total,
130
+ notRead: context.coverage.notRead,
131
+ });
@@ -42,6 +42,8 @@ export interface ServiceDeps {
42
42
  searchCatchUp?: boolean;
43
43
  /** How far back `messages sync` reads each kind of chat, and which groups it does not read at all. */
44
44
  historyLimits?: HistoryLimits;
45
+ /** `messages sync --all` reads muted chats too (`history_muted`); it leaves them out when unset. */
46
+ historyMuted?: boolean;
45
47
  /** This account has picture search on (`pictureSearch`): its images are embedded and searched by their pixels. */
46
48
  pictures?: boolean;
47
49
  /** Which reranker orders `--discover`'s first hits (`searchReranker`), or `off`; the default when unset. */
@@ -21,10 +21,14 @@ export interface EnrichOptions {
21
21
  key?: (provider: string) => string | undefined;
22
22
  signal?: AbortSignal;
23
23
  }
24
+ /** Why a run stopped or failed, from a fixed list, so a window can say it in its own words. */
25
+ export declare const ENRICHMENT_REASON_IDS: readonly ["enrichment.no-key", "enrichment.key-rejected", "enrichment.unreachable", "enrichment.rate-limited", "enrichment.bad-replies", "enrichment.cancelled", "enrichment.error"];
26
+ export type EnrichmentReasonId = (typeof ENRICHMENT_REASON_IDS)[number];
24
27
  export type EnrichRun = {
25
28
  status: "off";
26
29
  } | {
27
- status: "done" | "stopped";
30
+ /** `failed`: records were sent and none came back enriched. */
31
+ status: "done" | "stopped" | "failed";
28
32
  provider: string;
29
33
  model: string;
30
34
  /** Records the model answered for, with or without facts. */
@@ -34,10 +38,16 @@ export type EnrichRun = {
34
38
  left: number;
35
39
  usage: ModelUsage;
36
40
  cost_usd: number | null;
37
- /** Why a stopped run stopped, with no provider body or key in it. */
41
+ /** Why a stopped or failed run ended, with no provider body or key in it. */
38
42
  reason?: string;
43
+ reason_id?: EnrichmentReasonId;
39
44
  };
40
45
  export type KeySource = "keyring" | "file" | "env" | "given";
46
+ /** The provider's key and where it came from; it never leaves this process. */
47
+ export declare const keyLookup: (options: Pick<EnrichOptions, "env" | "app" | "keyring" | "key">, setting: Pick<EnrichmentSetting, "provider" | "base_url">) => {
48
+ key: string;
49
+ source: KeySource;
50
+ } | undefined;
41
51
  export declare const keyVariable: (provider: string) => string;
42
52
  /**
43
53
  * Sends records with no enrichment of their current text to the provider the owner consented to, in batches, and
@@ -54,6 +54,36 @@ export const parseEnrichmentReply = (text) => {
54
54
  [...row.facts.slice(0, MAX_FACTS), ...row.questions.slice(0, MAX_QUESTIONS)].filter(Boolean).join("\n"),
55
55
  ]));
56
56
  };
57
+ /** Why a run stopped or failed, from a fixed list, so a window can say it in its own words. */
58
+ export const ENRICHMENT_REASON_IDS = [
59
+ "enrichment.no-key",
60
+ "enrichment.key-rejected",
61
+ "enrichment.unreachable",
62
+ "enrichment.rate-limited",
63
+ "enrichment.bad-replies",
64
+ "enrichment.cancelled",
65
+ "enrichment.error",
66
+ ];
67
+ const REASON_TEXT = {
68
+ "enrichment.key-rejected": "the provider refused the key; nothing more was sent",
69
+ "enrichment.unreachable": "the provider could not be reached; nothing more was sent",
70
+ };
71
+ const reasonIdOf = (error) => {
72
+ // A reply that cannot be read throws a plain error: one more bad batch.
73
+ if (!(error instanceof CliError))
74
+ return "enrichment.bad-replies";
75
+ if (error.details.reason === "model.key-rejected")
76
+ return "enrichment.key-rejected";
77
+ if (error.details.reason === "model.unreachable")
78
+ return "enrichment.unreachable";
79
+ if (error.code === "rate_limited")
80
+ return "enrichment.rate-limited";
81
+ if (error.code === "cancelled")
82
+ return "enrichment.cancelled";
83
+ if (error.code === "invalid_response")
84
+ return "enrichment.bad-replies";
85
+ return "enrichment.error";
86
+ };
57
87
  const recordsData = (batch) => JSON.stringify(batch.map((record, i) => ({
58
88
  i,
59
89
  date: record.at === null ? null : new Date(record.at).toISOString().slice(0, 10),
@@ -61,7 +91,7 @@ const recordsData = (batch) => JSON.stringify(batch.map((record, i) => ({
61
91
  text: record.text.slice(0, MAX_INPUT_CHARS),
62
92
  })));
63
93
  /** The provider's key and where it came from; it never leaves this process. */
64
- const keyLookup = (options, setting) => {
94
+ export const keyLookup = (options, setting) => {
65
95
  if (options.key) {
66
96
  const key = options.key(setting.provider);
67
97
  return key === undefined ? undefined : { key, source: "given" };
@@ -107,7 +137,8 @@ export const enrichRecords = async (store, options) => {
107
137
  left: (await enrichment.pending(Number.MAX_SAFE_INTEGER, options.narrow)).length,
108
138
  usage: { input: 0, output: 0 },
109
139
  cost_usd: 0,
110
- reason: `no ${setting.provider} key: set ${setting.provider.toUpperCase()}_API_KEY, or the tool's own key; nothing was sent`,
140
+ reason: `no ${setting.provider} key: store one with \`models keys set ${setting.provider}\` or set ${keyVariable(setting.provider)}; nothing was sent`,
141
+ reason_id: "enrichment.no-key",
111
142
  };
112
143
  const gateway = modelGateway({
113
144
  resolve: () => target,
@@ -127,6 +158,7 @@ export const enrichRecords = async (store, options) => {
127
158
  let failed = 0;
128
159
  let failedBatches = 0;
129
160
  let reason;
161
+ let reasonId;
130
162
  const ask = async (batch) => {
131
163
  const answer = await gateway.complete({
132
164
  purpose: "enrichment",
@@ -173,16 +205,24 @@ export const enrichRecords = async (store, options) => {
173
205
  }
174
206
  catch (error) {
175
207
  failed += batch.length;
176
- const code = error instanceof CliError ? error.code : "invalid_response";
177
- if (code !== "invalid_response" || ++failedBatches >= MAX_FAILED_BATCHES)
178
- reason = error instanceof CliError ? error.message : "the enrichment provider failed";
208
+ const id = reasonIdOf(error);
209
+ // A refused key or an unreachable provider fails every batch the same way; only a bad reply may be one-off.
210
+ if (id !== "enrichment.bad-replies" || ++failedBatches >= MAX_FAILED_BATCHES) {
211
+ reason = REASON_TEXT[id] ?? (error instanceof CliError ? error.message : "the enrichment provider failed");
212
+ reasonId = id;
213
+ }
179
214
  }
180
215
  }
181
216
  };
182
217
  await Promise.all(Array.from({ length: Math.min(options.concurrency ?? CONCURRENCY, batches.length) }, () => worker()));
183
218
  const left = (await enrichment.pending(Number.MAX_SAFE_INTEGER, options.narrow)).length;
219
+ const none = enriched === 0 && failed > 0;
220
+ if (none && reason === undefined) {
221
+ reason = `the provider enriched none of the ${failed} records sent; they are sent again next sync`;
222
+ reasonId = "enrichment.bad-replies";
223
+ }
184
224
  return {
185
- status: reason === undefined ? "done" : "stopped",
225
+ status: none ? "failed" : reason === undefined ? "done" : "stopped",
186
226
  provider: setting.provider,
187
227
  model: setting.model,
188
228
  enriched,
@@ -191,6 +231,7 @@ export const enrichRecords = async (store, options) => {
191
231
  usage,
192
232
  cost_usd: costOf(usage, setting),
193
233
  ...(reason === undefined ? {} : { reason }),
234
+ ...(reasonId === undefined ? {} : { reason_id: reasonId }),
194
235
  };
195
236
  };
196
237
  /** cli-testing write-time-enrichment, 10,444 synthetic records, memo with e5-small, gpt-4o-mini, 2026-11-08. */
@@ -4,6 +4,7 @@ import { meaningFloor } from "../embeddings/models.js";
4
4
  import { plainQuery } from "../search/lucene/plain.js";
5
5
  import { questionLookup, questionText } from "../search/question-plan.js";
6
6
  import { excerpt } from "./excerpt.js";
7
+ import { meaningModel } from "./meaning-model.js";
7
8
  import { localModel, RRF_K, storeQuery, withLocal } from "./notes-search.js";
8
9
  import { plainQueryWords } from "./notes-title-tier.js";
9
10
  const MAX_EVENTS_OFFSET = 1000;
@@ -39,7 +40,7 @@ export const foundEvent = (hit, query, foundBy) => ({
39
40
  const CANDIDATES = 50;
40
41
  /** Events nearest in meaning to plain words, one per series, best first; only events already embedded are found. */
41
42
  const nearestEvents = async (store, words, { limit, accountIds, env, command, embedders, }) => {
42
- const { model, directory, key } = localModel(undefined, env, command);
43
+ const { model, directory, key } = localModel(await meaningModel(store, env), env, command);
43
44
  if (!(await store.calendar.embedded(key, accountIds ? { accountIds } : {})))
44
45
  throw new CliError("not_found", `no event has vectors of ${model.id} yet, so only words were matched`);
45
46
  const [vector] = await withLocal(model, directory, undefined, (embedder) => embedder.embed([words], "query"), embedders);
@@ -0,0 +1,28 @@
1
+ import type { AppIdentity } from "../ports/app.js";
2
+ import type { MessageStore } from "../store/store.js";
3
+ import type { ProposalRegistry, ProposalRow } from "./proposals/types.js";
4
+ /** What a run locked to a group may show of things that came through accounts (WC-ACCT-13). */
5
+ export interface GroupGuard {
6
+ group: string;
7
+ /** Every part of the thing is in the group; the owner's own things, and references the store lacks, pass. */
8
+ visible(ref: string): Promise<boolean>;
9
+ /** The references a locked run may show, in order, and how many it may not. */
10
+ keep(refs: readonly (string | null)[]): Promise<{
11
+ kept: (string | null)[];
12
+ out_of_scope: number;
13
+ }>;
14
+ /** A copy with every outside reference taken out of each `evidence` array, at any depth, and their count. */
15
+ strip<T>(value: T): Promise<{
16
+ value: T;
17
+ out_of_scope: number;
18
+ }>;
19
+ /** A proposal is its subject's, its object's and, when stored, its action's: all in the group. */
20
+ proposal(row: ProposalRow): Promise<boolean>;
21
+ }
22
+ /** `undefined` without `<PREFIX>_GROUP_LOCK`: an unlocked run shows everything. */
23
+ export declare const groupGuardOf: (store: MessageStore, app: AppIdentity, env: NodeJS.ProcessEnv) => Promise<GroupGuard | undefined>;
24
+ /**
25
+ * The registry a locked run decides through: a proposal outside the group is not listed, not shown and not decided,
26
+ * and the evidence of one it shows keeps only the group's references.
27
+ */
28
+ export declare const lockedRegistry: (registry: ProposalRegistry, guard: GroupGuard) => ProposalRegistry;
@@ -0,0 +1,131 @@
1
+ import { CliError } from "@wirecat/cli-base";
2
+ import { INTERNAL_NOTES } from "../domain/providers.js";
3
+ import { inGroupOf } from "../search/groups.js";
4
+ import { groupLockOf, listContextOf } from "./search-kind.js";
5
+ const refOf = (item) => typeof item === "string"
6
+ ? item
7
+ : typeof item === "object" && item !== null && "ref" in item
8
+ ? item.ref
9
+ : undefined;
10
+ /** `undefined` without `<PREFIX>_GROUP_LOCK`: an unlocked run shows everything. */
11
+ export const groupGuardOf = async (store, app, env) => {
12
+ const group = groupLockOf(app, env);
13
+ if (group === undefined)
14
+ return undefined;
15
+ const inGroup = inGroupOf(await listContextOf(store, { provider: "notes", account: INTERNAL_NOTES }, app, undefined, env), group);
16
+ const visible = async (ref) => {
17
+ const ends = await store.refs.ends(ref);
18
+ return ends === undefined || ends.every((end) => end.length === 0 || end.some(inGroup));
19
+ };
20
+ const keep = async (refs) => {
21
+ const kept = [];
22
+ for (const ref of refs)
23
+ if (ref === null || (await visible(ref)))
24
+ kept.push(ref);
25
+ return { kept, out_of_scope: refs.length - kept.length };
26
+ };
27
+ const strip = async (value) => {
28
+ let dropped = 0;
29
+ // Only plain objects and arrays are rebuilt, and only where something under them was dropped: a Date or any
30
+ // other value keeps its identity, so a strict answer schema still reads it.
31
+ const plain = (node) => {
32
+ const prototype = Object.getPrototypeOf(node);
33
+ return prototype === Object.prototype || prototype === null;
34
+ };
35
+ const walk = async (node, key) => {
36
+ if (Array.isArray(node)) {
37
+ const items = await Promise.all(node.map((one) => walk(one)));
38
+ let changed = items.some((one, at) => one !== node[at]);
39
+ let shown = items;
40
+ if (key === "evidence" || key === "sources") {
41
+ shown = [];
42
+ for (const item of items) {
43
+ const ref = refOf(item);
44
+ if (typeof ref === "string" && !(await visible(ref))) {
45
+ dropped += 1;
46
+ changed = true;
47
+ }
48
+ else
49
+ shown.push(item);
50
+ }
51
+ }
52
+ return changed ? shown : node;
53
+ }
54
+ if (typeof node !== "object" || node === null || !plain(node))
55
+ return node;
56
+ let changed = false;
57
+ const entries = await Promise.all(Object.entries(node).map(async ([name, one]) => {
58
+ const walkedOne = await walk(one, name);
59
+ if (walkedOne !== one)
60
+ changed = true;
61
+ return [name, walkedOne];
62
+ }));
63
+ return changed ? { ...node, ...Object.fromEntries(entries) } : node;
64
+ };
65
+ const walked = (await walk(value));
66
+ return { value: walked, out_of_scope: dropped };
67
+ };
68
+ const proposal = async (row) => {
69
+ const stored = /^([1-9]\d*)(\/|$)/.exec(row.id)?.[1];
70
+ const parts = [
71
+ row.subject,
72
+ ...(row.object === null ? [] : [row.object]),
73
+ ...(stored
74
+ ? [`action:${stored}`]
75
+ : row.id.startsWith("link:")
76
+ ? [row.id]
77
+ : row.id.startsWith("key:")
78
+ ? [`link:${row.id.slice(4)}`]
79
+ : []),
80
+ ];
81
+ for (const part of parts)
82
+ if (!(await visible(part)))
83
+ return false;
84
+ return true;
85
+ };
86
+ return { group, visible, keep, strip, proposal };
87
+ };
88
+ const outside = (guard, id) => new CliError("permission_error", `this process is locked to group ${guard.group} — proposal ${id} is outside it`, {
89
+ group: guard.group,
90
+ reason: "group.outside",
91
+ });
92
+ /**
93
+ * The registry a locked run decides through: a proposal outside the group is not listed, not shown and not decided,
94
+ * and the evidence of one it shows keeps only the group's references.
95
+ */
96
+ export const lockedRegistry = (registry, guard) => {
97
+ const shown = async (row) => ({
98
+ ...row,
99
+ evidence: (await guard.keep(row.evidence)).kept.filter((ref) => ref !== null),
100
+ });
101
+ return {
102
+ register: (kind) => registry.register(kind),
103
+ list: async (filter) => {
104
+ const { items, hasMore } = await registry.list(filter);
105
+ const kept = [];
106
+ for (const row of items)
107
+ if (await guard.proposal(row))
108
+ kept.push(await shown(row));
109
+ return { items: kept, hasMore };
110
+ },
111
+ get: async (id) => {
112
+ const row = await registry.get(id);
113
+ if (!(await guard.proposal(row)))
114
+ throw outside(guard, id);
115
+ return shown(row);
116
+ },
117
+ decide: async (ids, decision) => {
118
+ const allowed = [];
119
+ const refused = [];
120
+ for (const id of ids) {
121
+ const row = await registry.get(id.split("/")[0]).catch(() => undefined);
122
+ if (row && !(await guard.proposal(row)))
123
+ refused.push({ id, code: "permission_error", reason: "group.outside", message: outside(guard, id).message });
124
+ else
125
+ allowed.push(id);
126
+ }
127
+ const decided = allowed.length ? await registry.decide(allowed, decision) : { decided: [], refused: [] };
128
+ return { decided: decided.decided, refused: [...refused, ...decided.refused] };
129
+ },
130
+ };
131
+ };
@@ -65,10 +65,15 @@ export type { ArchiveService, Fetched, FetchOptions } from "./archive.js";
65
65
  export { archiveService } from "./archive.js";
66
66
  export type { AttachmentItem, AttachmentsService, AttachmentTextSet, ExtractItem, ExtractOptions, ExtractRun, ExtractStatus, } from "./attachments.js";
67
67
  export { attachmentsService } from "./attachments.js";
68
+ export type { Category, Coverage, Related, RelationRole, Section } from "./business-context.js";
69
+ export { CATEGORIES, organizationCategories, SECTION_LIMIT } from "./business-context.js";
68
70
  export type { ChatsService, MarkedRead, PageWindow } from "./chats.js";
69
71
  export { chatsService, EVENTS_DAYS } from "./chats.js";
72
+ export type { Communications, Touch } from "./communications.js";
70
73
  export type { BatchStatus, Built, ConversationsService, MessageLinks } from "./conversations.js";
71
74
  export { BATCH_SIZE, conversationsService } from "./conversations.js";
75
+ export type { DealBrief, DealContext, DealContextOptions, DealTouch } from "./deal-context.js";
76
+ export { dealBrief, dealContext } from "./deal-context.js";
72
77
  export type { ServiceDeps, ServiceMessenger } from "./deps.js";
73
78
  export { accountStore, crossAccount, OFFLINE, onlineDeps, storedDeps, storeOnlyDeps } from "./deps.js";
74
79
  export type { Embedded, EmbeddingsService, EmbedStatus, FoundConversation } from "./embeddings.js";
@@ -97,8 +102,13 @@ export { DELETE_AT_ONCE, messagesService } from "./messages.js";
97
102
  export { searchStore } from "./messages-archive-search.js";
98
103
  export type { ModerateOptions, ModerationService, ShownRules } from "./moderation.js";
99
104
  export { moderationService } from "./moderation.js";
105
+ export type { FinanceTotal, InvoiceLine, LinkedBy, MoneySection, OrderLine, PaymentLine } from "./money-context.js";
106
+ export type { DealLine, OrganizationContext, OrganizationContextOptions, ProjectLine, TaskLine, } from "./organization-context.js";
107
+ export { organizationContext } from "./organization-context.js";
100
108
  export type { ContactSync, PeopleService } from "./people.js";
101
109
  export { linkPeople, peopleService, phoneOf } from "./people.js";
110
+ export type { CanonicalContextOptions, CanonicalPersonContext, PersonBusiness } from "./person-business.js";
111
+ export { canonicalPersonContext, personBusiness } from "./person-business.js";
102
112
  export type { AccountScope, ContextEvent, ContextMessage, ContextOptions, NotReadReason, PersonContext, SharedChat, } from "./person-context.js";
103
113
  export { CONTEXT_BYTES, CONTEXT_MESSAGES, identityIn, personContext } from "./person-context.js";
104
114
  export type { PersonPreparation, WaitingDialog } from "./person-preparation.js";
@@ -155,13 +165,15 @@ export interface Services {
155
165
  export type Override = (base: Services, deps: ServiceDeps) => Partial<Services>;
156
166
  /** The shared services, with the messenger's `services` override applied — commands and MCP tools alike. */
157
167
  export declare const servicesFor: (deps: ServiceDeps) => Services;
158
- export { entriesOfList, type ListContext, type ListedEntry } from "../search/account-list.js";
168
+ export { entriesOfList, keyOf, type ListContext, type ListedEntry, sameAs, sourceOf, } from "../search/account-list.js";
169
+ export { ALL, type GroupContext, type GroupMember, type GroupMembership, type GroupReason, type GroupRequest, type GroupSuggestion, groupMembership, inGroupOf, NOT_GROUP_NAMES, OWNER_NOTES, type RunGroup, scopeToGroup, } from "../search/groups.js";
159
170
  export { plainQuery } from "../search/lucene/plain.js";
160
171
  export { FIELD_VERSION, QUERY_FIELDS, QUERY_OPERATORS, validateAst } from "../search/lucene/registry.js";
161
172
  export { QUERY_LIMITS, QUERY_VERSION } from "../search/lucene/types.js";
162
173
  export { questionLookup } from "../search/question-plan.js";
163
174
  export { type SearchTotal, TOTAL_CAP } from "../search/total.js";
164
175
  export { TASK_KINDS, TASK_ORIGINS, type TaskKind, type TaskOrigin } from "../tasks/index.js";
176
+ export { addGroupMember, type GroupMemberChange, type GroupMemberMove, type GroupStore, listAccountGroups, moveGroupMember, removeGroupMember, } from "./account-groups.js";
165
177
  export type { AdminFound, AdminQuery, AdminSelection, AdminStatisticsService } from "./admin-statistics.js";
166
178
  export { adminStatisticsService } from "./admin-statistics.js";
167
179
  export { GAP_BOUNDS, type GapPlan, type GapRepair, gapsService, type RepairOptions } from "./archive-gaps.js";
@@ -170,6 +182,7 @@ export { countersService } from "./counters.js";
170
182
  export { type DocumentTarget, openPictureEmbedderFor, type PictureOptions, removePicture, savePicture, } from "./document-pictures.js";
171
183
  export type { ModelChoice } from "./embeddings.js";
172
184
  export { calendarAccounts, type EventsFound, type EventsQuery, type FoundEvent, foundEvent, searchEvents, } from "./events-search.js";
185
+ export { type GroupGuard, groupGuardOf, lockedRegistry } from "./group-guard.js";
173
186
  export { createMeetingBatchReader } from "./meeting-batch.js";
174
187
  export { type MeetingCombinedHit, type MeetingCombinedRequest, searchMeetingsCombined, } from "./meeting-combined.js";
175
188
  export type { MeetingCommunicationCoverage, MeetingCommunicationExcerpt, MeetingCommunications, MeetingCommunicationsPort, MeetingCommunicationsRequest, } from "./meeting-communications-types.js";
@@ -198,10 +211,12 @@ export { approveAsTask, type ProposalTaskStore, proposalSource } from "./proposa
198
211
  export { type Decided, type Decision, emptyProposalRegistry, FACT_SUMMARIES, ORGANIZATION_ADD_KIND, ORGANIZATION_RENAME_KIND, type OrganizationProposal, type OrganizationRenameProposal, type ProposalFilter, type ProposalKind, type ProposalRegistry, type ProposalRow, parseProposalIds, proposalRegistry, } from "./proposals/index.js";
199
212
  export type { RetentionQuery, RetentionService } from "./retention.js";
200
213
  export { retentionService } from "./retention.js";
201
- export { RESOURCES_SEARCHED, type SearchAllFound, type SearchAllItem, type SearchAllMessenger, type SearchAllRequest, type SearchedResource, searchAll, } from "./search-all.js";
202
- export { type MeetingSearchCoverage, type MeetingSearchCursor, type MeetingSearchItem, RESOURCES_SEARCHED_WITH_MEETINGS, type ResourceWithMeetings, type SearchAllIncludingMeetingsFound, type SearchAllIncludingMeetingsRequest, type SearchAllWithMeetingsRequest, searchAllIncludingMeetings, searchAllWithMeetings, } from "./search-all-meetings.js";
214
+ export { RESOURCES_SEARCHED, type SearchAllFound, type SearchAllItem, type SearchAllMessenger, type SearchAllRecordItem, type SearchAllRequest, type SearchedResource, searchAll, } from "./search-all.js";
215
+ export { type MeetingSearchCoverage, type MeetingSearchCursor, type ResourceWithMeetings, type SearchAllIncludingMeetingsFound, type SearchAllIncludingMeetingsRequest, searchAllIncludingMeetings, } from "./search-all-deprecated.js";
216
+ export { type MeetingAccountCoverage, type MeetingSearchItem, MOST_HITS_PER_MEETING, } from "./search-all-meetings.js";
203
217
  export { CATCH_UP_BOUNDS, type CatchUpOptions, type CatchUpResult, catchUpSearch, validateCatchUp, } from "./search-catchup.js";
204
- export { accountsOfKind, listContextOf, type SearchKind } from "./search-kind.js";
218
+ export { HARDER_REASON_IDS, type HarderOptions, type HarderReasonId, type HarderResult, readHarderSetting, writeHarderSetting, } from "./search-harder.js";
219
+ export { accountsOfKind, groupLockOf, listContextOf, type SearchKind } from "./search-kind.js";
205
220
  export type { SearchRefreshed, SyncOptions } from "./search-refresh.js";
206
221
  export { SYNC_BOUNDS, SYNC_KEY } from "./search-refresh.js";
207
222
  export { type Backend, type HitSource, SERVER_BOUNDS, SERVER_SEARCH_KEY, type ServerSearched, } from "./server-search.js";
@@ -51,8 +51,10 @@ export { accountService } from "./account.js";
51
51
  export { adminService } from "./admin.js";
52
52
  export { archiveService } from "./archive.js";
53
53
  export { attachmentsService } from "./attachments.js";
54
+ export { CATEGORIES, organizationCategories, SECTION_LIMIT } from "./business-context.js";
54
55
  export { chatsService, EVENTS_DAYS } from "./chats.js";
55
56
  export { BATCH_SIZE, conversationsService } from "./conversations.js";
57
+ export { dealBrief, dealContext } from "./deal-context.js";
56
58
  export { accountStore, crossAccount, OFFLINE, onlineDeps, storedDeps, storeOnlyDeps } from "./deps.js";
57
59
  export { embeddingsService } from "./embeddings.js";
58
60
  export { ENRICH_PER_RUN, enrichmentState, enrichRecords, } from "./enrichment.js";
@@ -73,7 +75,9 @@ export { chatIdIn, storedChatId } from "./message-resolution.js";
73
75
  export { DELETE_AT_ONCE, messagesService } from "./messages.js";
74
76
  export { searchStore } from "./messages-archive-search.js";
75
77
  export { moderationService } from "./moderation.js";
78
+ export { organizationContext } from "./organization-context.js";
76
79
  export { linkPeople, peopleService, phoneOf } from "./people.js";
80
+ export { canonicalPersonContext, personBusiness } from "./person-business.js";
77
81
  export { CONTEXT_BYTES, CONTEXT_MESSAGES, identityIn, personContext } from "./person-context.js";
78
82
  export { PREPARE_BYTES, personPreparation } from "./person-preparation.js";
79
83
  export { personTimeline, SCOPES, TIMELINE_ITEMS, TIMELINE_MAX } from "./person-timeline.js";
@@ -120,18 +124,21 @@ export const servicesFor = (deps) => {
120
124
  };
121
125
  return deps.messenger.services ? { ...base, ...deps.messenger.services(base, deps) } : base;
122
126
  };
123
- export { entriesOfList } from "../search/account-list.js";
127
+ export { entriesOfList, keyOf, sameAs, sourceOf, } from "../search/account-list.js";
128
+ export { ALL, groupMembership, inGroupOf, NOT_GROUP_NAMES, OWNER_NOTES, scopeToGroup, } from "../search/groups.js";
124
129
  export { plainQuery } from "../search/lucene/plain.js";
125
130
  export { FIELD_VERSION, QUERY_FIELDS, QUERY_OPERATORS, validateAst } from "../search/lucene/registry.js";
126
131
  export { QUERY_LIMITS, QUERY_VERSION } from "../search/lucene/types.js";
127
132
  export { questionLookup } from "../search/question-plan.js";
128
133
  export { TOTAL_CAP } from "../search/total.js";
129
134
  export { TASK_KINDS, TASK_ORIGINS } from "../tasks/index.js";
135
+ export { addGroupMember, listAccountGroups, moveGroupMember, removeGroupMember, } from "./account-groups.js";
130
136
  export { adminStatisticsService } from "./admin-statistics.js";
131
137
  export { GAP_BOUNDS, gapsService } from "./archive-gaps.js";
132
138
  export { countersService } from "./counters.js";
133
139
  export { openPictureEmbedderFor, removePicture, savePicture, } from "./document-pictures.js";
134
140
  export { calendarAccounts, foundEvent, searchEvents, } from "./events-search.js";
141
+ export { groupGuardOf, lockedRegistry } from "./group-guard.js";
135
142
  export { createMeetingBatchReader } from "./meeting-batch.js";
136
143
  export { searchMeetingsCombined, } from "./meeting-combined.js";
137
144
  export { createMeetingContextService, } from "./meeting-context.js";
@@ -156,9 +163,11 @@ export { approveAsTask, proposalSource } from "./proposal-tasks.js";
156
163
  export { emptyProposalRegistry, FACT_SUMMARIES, ORGANIZATION_ADD_KIND, ORGANIZATION_RENAME_KIND, parseProposalIds, proposalRegistry, } from "./proposals/index.js";
157
164
  export { retentionService } from "./retention.js";
158
165
  export { RESOURCES_SEARCHED, searchAll, } from "./search-all.js";
159
- export { RESOURCES_SEARCHED_WITH_MEETINGS, searchAllIncludingMeetings, searchAllWithMeetings, } from "./search-all-meetings.js";
166
+ export { searchAllIncludingMeetings, } from "./search-all-deprecated.js";
167
+ export { MOST_HITS_PER_MEETING, } from "./search-all-meetings.js";
160
168
  export { CATCH_UP_BOUNDS, catchUpSearch, validateCatchUp, } from "./search-catchup.js";
161
- export { accountsOfKind, listContextOf } from "./search-kind.js";
169
+ export { HARDER_REASON_IDS, readHarderSetting, writeHarderSetting, } from "./search-harder.js";
170
+ export { accountsOfKind, groupLockOf, listContextOf } from "./search-kind.js";
162
171
  export { SYNC_BOUNDS, SYNC_KEY } from "./search-refresh.js";
163
172
  export { SERVER_BOUNDS, SERVER_SEARCH_KEY, } from "./server-search.js";
164
173
  export { createStoredMeetingProjectCandidateReader } from "./stored-meeting-project-candidates.js";
@@ -1,5 +1,6 @@
1
1
  import { type IngestError } from "../domain/records.js";
2
2
  import { type VcardIssue, type VcardOptions } from "../domain/vcard.js";
3
+ import { type RelationshipCounts } from "../store/index.js";
3
4
  import type { MessageStore } from "../store/store.js";
4
5
  export interface IngestOptions {
5
6
  /** The account the caller means; the envelope's `source.account` must be this one. */
@@ -62,6 +63,17 @@ export interface IngestReceipt {
62
63
  pointer: string;
63
64
  reason: string;
64
65
  }[];
66
+ /**
67
+ * The links this import's account reports from the records' relationships: new, held, back after a withdrawal,
68
+ * withdrawn, waiting for review, and left out because the owner rejected that very relationship. An issue with one
69
+ * is in `errors`, code `relationship.*`.
70
+ */
71
+ relationships: RelationshipCounts;
72
+ /**
73
+ * Taken, but not as the source put it: a relationship's word off its role list is kept on a link without a role, as
74
+ * `metadata.source_role` (`relationship.role-unlisted`).
75
+ */
76
+ notices: IngestError[];
65
77
  errors: IngestError[];
66
78
  /** A list stopped at 1000 entries; the counts are exact. */
67
79
  truncated: boolean;
@@ -15,6 +15,8 @@ const emptyReceipt = (dryRun, errors) => ({
15
15
  flagged: [],
16
16
  unmatched: [],
17
17
  ignored: [],
18
+ relationships: { added: 0, kept: 0, restored: 0, withdrawn: 0, proposed: 0, skippedOwnerRejected: 0 },
19
+ notices: [],
18
20
  errors,
19
21
  truncated: false,
20
22
  });
@@ -40,6 +42,8 @@ const receiptOf = (dryRun, source, run) => ({
40
42
  pointer: pointerOf("records", index, ...at),
41
43
  reason,
42
44
  })),
45
+ relationships: run.relationships,
46
+ notices: run.notices,
43
47
  errors: run.errors,
44
48
  truncated: run.truncated,
45
49
  });
@@ -0,0 +1,7 @@
1
+ import type { MessageStore } from "../store/store.js";
2
+ /**
3
+ * The model a search by meaning reads. A model the owner chose, always. With none chosen, the default, unless this
4
+ * store still holds more vectors of the previous default: so after EmbeddingGemma became the default, search keeps
5
+ * reading e5-small's vectors while the syncs embed the store again, and moves to Gemma once it has caught up.
6
+ */
7
+ export declare const meaningModel: (store: MessageStore, env?: NodeJS.ProcessEnv) => Promise<string>;