@wirecat/cli-core 0.617.0 → 0.619.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 (306) hide show
  1. package/CHANGELOG.md +406 -1
  2. package/README.md +1 -1
  3. package/THIRD_PARTY_NOTICES +3 -0
  4. package/dist/background/backfill.d.ts +21 -0
  5. package/dist/background/backfill.js +41 -0
  6. package/dist/background/daily-archive-timer.d.ts +1 -1
  7. package/dist/background/deliver.d.ts +5 -2
  8. package/dist/background/deliver.js +30 -12
  9. package/dist/background/report/messages.js +4 -1
  10. package/dist/background/report/render.d.ts +3 -1
  11. package/dist/background/report/render.js +3 -1
  12. package/dist/background/report/view.js +4 -1
  13. package/dist/background/schedules.d.ts +17 -0
  14. package/dist/background/schedules.js +21 -8
  15. package/dist/calendar/cli/answers.d.ts +1 -0
  16. package/dist/calendar/cli/answers.js +6 -1
  17. package/dist/calendar/cli/index.js +2 -14
  18. package/dist/calendar/cli/people-link.d.ts +3 -0
  19. package/dist/calendar/cli/people-link.js +23 -0
  20. package/dist/calendar/index.d.ts +1 -1
  21. package/dist/calendar/index.js +1 -1
  22. package/dist/calendar/mcp/index.d.ts +12 -12
  23. package/dist/cli/base-stages-command.d.ts +22 -0
  24. package/dist/cli/base-stages-command.js +174 -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.d.ts +5 -0
  29. package/dist/cli/context.js +1 -0
  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 +10 -4
  33. package/dist/cli/index.js +10 -4
  34. package/dist/cli/messenger/backfill-command.js +27 -15
  35. package/dist/cli/messenger/contacts-command.js +10 -3
  36. package/dist/cli/messenger/context.js +1 -0
  37. package/dist/cli/messenger/doctor-command.js +3 -1
  38. package/dist/cli/messenger/models-command.js +1 -1
  39. package/dist/cli/messenger/serve-command.js +24 -2
  40. package/dist/cli/messenger/serve-outdated.d.ts +22 -0
  41. package/dist/cli/messenger/serve-outdated.js +100 -0
  42. package/dist/cli/messenger/store-maintenance-command.d.ts +22 -2
  43. package/dist/cli/messenger/store-maintenance-command.js +9 -4
  44. package/dist/cli/model-catalogue-command.d.ts +3 -1
  45. package/dist/cli/model-catalogue-command.js +46 -2
  46. package/dist/cli/profile.d.ts +8 -0
  47. package/dist/cli/profile.js +25 -0
  48. package/dist/cli/program.js +2 -0
  49. package/dist/cli/runs/search-query.d.ts +1 -1
  50. package/dist/cli/runs/search-query.js +4 -0
  51. package/dist/cli/runs/search.d.ts +5 -1
  52. package/dist/cli/runs/search.js +12 -1
  53. package/dist/cli/schedule/schedule-command.d.ts +9 -0
  54. package/dist/cli/schedule/schedule-command.js +13 -0
  55. package/dist/cli/search-left-out.d.ts +6 -1
  56. package/dist/cli/search-left-out.js +9 -4
  57. package/dist/cli/settings.d.ts +8 -0
  58. package/dist/cli/settings.js +17 -2
  59. package/dist/cli/shared-command-exports.d.ts +16 -0
  60. package/dist/cli/store-recover.d.ts +3 -3
  61. package/dist/cli/store-recover.js +47 -23
  62. package/dist/cli/store-settings.d.ts +2 -0
  63. package/dist/cli/store-settings.js +37 -9
  64. package/dist/crm/cli/index.js +38 -6
  65. package/dist/crm/group-hint.d.ts +8 -0
  66. package/dist/crm/group-hint.js +13 -0
  67. package/dist/crm/source.d.ts +12 -1
  68. package/dist/crm/sync.d.ts +31 -2
  69. package/dist/crm/sync.js +110 -3
  70. package/dist/crm/testing/acme-scenario.d.ts +40 -0
  71. package/dist/crm/testing/acme-scenario.js +170 -0
  72. package/dist/crm/testing/index.d.ts +1 -0
  73. package/dist/crm/testing/index.js +1 -0
  74. package/dist/crm/testing/source-contract.js +12 -0
  75. package/dist/crm/testing/source.d.ts +2 -0
  76. package/dist/crm/testing/source.js +1 -0
  77. package/dist/domain/addresses.d.ts +13 -0
  78. package/dist/domain/addresses.js +63 -0
  79. package/dist/domain/categories.d.ts +3 -0
  80. package/dist/domain/categories.js +2 -0
  81. package/dist/domain/crm.d.ts +23 -0
  82. package/dist/domain/crm.js +7 -0
  83. package/dist/domain/links.d.ts +17 -4
  84. package/dist/domain/links.js +20 -7
  85. package/dist/domain/mentions.d.ts +2 -12
  86. package/dist/domain/mentions.js +2 -19
  87. package/dist/domain/orders.d.ts +8 -1
  88. package/dist/domain/orders.js +6 -2
  89. package/dist/domain/phones.d.ts +26 -0
  90. package/dist/domain/phones.js +48 -0
  91. package/dist/domain/record-types.d.ts +1 -1
  92. package/dist/domain/record-types.js +1 -0
  93. package/dist/domain/records.d.ts +5 -0
  94. package/dist/domain/ref-summaries.d.ts +39 -0
  95. package/dist/domain/ref-summaries.js +51 -3
  96. package/dist/domain/relations.d.ts +27 -2
  97. package/dist/domain/relations.js +37 -3
  98. package/dist/domain/vcard.d.ts +2 -2
  99. package/dist/domain/vcard.js +4 -10
  100. package/dist/embeddings/models.d.ts +11 -3
  101. package/dist/embeddings/models.js +28 -4
  102. package/dist/entities/business-context.d.ts +149 -0
  103. package/dist/entities/business-context.js +192 -0
  104. package/dist/entities/contact-activity.d.ts +2 -0
  105. package/dist/entities/contact-activity.js +7 -1
  106. package/dist/entities/contact-context.d.ts +157 -0
  107. package/dist/entities/contact-context.js +2 -0
  108. package/dist/entities/deal.d.ts +10 -0
  109. package/dist/entities/deal.js +2 -0
  110. package/dist/entities/index.d.ts +23 -3
  111. package/dist/entities/index.js +5 -0
  112. package/dist/entities/mention.d.ts +4 -3
  113. package/dist/entities/mention.js +2 -1
  114. package/dist/entities/message-transfer.d.ts +4 -2
  115. package/dist/entities/message-transfer.js +2 -2
  116. package/dist/entities/model.d.ts +2 -2
  117. package/dist/entities/model.js +1 -1
  118. package/dist/entities/relationship.d.ts +4 -0
  119. package/dist/entities/relationship.js +4 -0
  120. package/dist/errors/reasons.js +44 -4
  121. package/dist/fetch/page.js +2 -1
  122. package/dist/index.d.ts +4 -3
  123. package/dist/index.js +4 -3
  124. package/dist/meetings/context-store.d.ts +2 -0
  125. package/dist/meetings/findings-rules.d.ts +4 -0
  126. package/dist/meetings/findings-rules.js +5 -2
  127. package/dist/meetings/mcp/index.d.ts +15 -15
  128. package/dist/meetings/result-items.d.ts +1 -0
  129. package/dist/meetings/result-items.js +1 -0
  130. package/dist/models/index.js +22 -5
  131. package/dist/runs/events.d.ts +11 -1
  132. package/dist/runs/events.js +3 -1
  133. package/dist/runs/log-attributes.js +4 -0
  134. package/dist/runs/log-events.js +2 -0
  135. package/dist/runs/recording.d.ts +3 -0
  136. package/dist/runs/recording.js +36 -12
  137. package/dist/runs/run.d.ts +12 -3
  138. package/dist/runs/run.js +32 -13
  139. package/dist/search/account-list.d.ts +6 -0
  140. package/dist/search/account-list.js +9 -3
  141. package/dist/search/groups.d.ts +68 -0
  142. package/dist/search/groups.js +172 -0
  143. package/dist/services/account-groups.d.ts +28 -0
  144. package/dist/services/account-groups.js +89 -0
  145. package/dist/services/archive.d.ts +7 -1
  146. package/dist/services/archive.js +19 -3
  147. package/dist/services/business-context.d.ts +113 -0
  148. package/dist/services/business-context.js +156 -0
  149. package/dist/services/communications.d.ts +50 -0
  150. package/dist/services/communications.js +140 -0
  151. package/dist/services/deal-context.d.ts +90 -0
  152. package/dist/services/deal-context.js +131 -0
  153. package/dist/services/deps.d.ts +2 -0
  154. package/dist/services/enrichment.d.ts +7 -2
  155. package/dist/services/enrichment.js +46 -5
  156. package/dist/services/events-search.js +2 -1
  157. package/dist/services/group-guard.d.ts +28 -0
  158. package/dist/services/group-guard.js +131 -0
  159. package/dist/services/index.d.ts +15 -2
  160. package/dist/services/index.js +9 -2
  161. package/dist/services/ingest.d.ts +12 -0
  162. package/dist/services/ingest.js +4 -0
  163. package/dist/services/link-scorers/chat-senders.js +39 -29
  164. package/dist/services/link-scorers/member-chats.js +4 -3
  165. package/dist/services/link-scorers/member-dialog.js +5 -7
  166. package/dist/services/link-scorers/scan.js +17 -8
  167. package/dist/services/link-scorers/shared.d.ts +6 -2
  168. package/dist/services/link-scorers/shared.js +6 -2
  169. package/dist/services/link-scorers/types.d.ts +2 -0
  170. package/dist/services/meaning-model.d.ts +7 -0
  171. package/dist/services/meaning-model.js +20 -0
  172. package/dist/services/meeting-context.d.ts +6 -1
  173. package/dist/services/meeting-context.js +12 -5
  174. package/dist/services/message-resolution.js +2 -3
  175. package/dist/services/messages-meaning.js +4 -5
  176. package/dist/services/messages-search.d.ts +5 -1
  177. package/dist/services/messages-search.js +1 -1
  178. package/dist/services/model-downloads.d.ts +1 -1
  179. package/dist/services/model-downloads.js +6 -4
  180. package/dist/services/money-context.d.ts +73 -0
  181. package/dist/services/money-context.js +77 -0
  182. package/dist/services/notes-search.d.ts +4 -1
  183. package/dist/services/notes-search.js +19 -7
  184. package/dist/services/organization-context.d.ts +80 -0
  185. package/dist/services/organization-context.js +154 -0
  186. package/dist/services/people.d.ts +22 -6
  187. package/dist/services/people.js +38 -8
  188. package/dist/services/person-business.d.ts +43 -0
  189. package/dist/services/person-business.js +67 -0
  190. package/dist/services/person-context.d.ts +9 -1
  191. package/dist/services/person-context.js +5 -3
  192. package/dist/services/proposals/kinds/identity-link.d.ts +4 -0
  193. package/dist/services/proposals/kinds/identity-link.js +48 -0
  194. package/dist/services/proposals/kinds/orders.js +1 -1
  195. package/dist/services/proposals/registry.js +2 -0
  196. package/dist/services/search-kind.d.ts +12 -5
  197. package/dist/services/search-kind.js +49 -10
  198. package/dist/services/text-model-choice.js +1 -1
  199. package/dist/store/accounts.d.ts +18 -0
  200. package/dist/store/accounts.js +18 -3
  201. package/dist/store/damage.d.ts +43 -10
  202. package/dist/store/damage.js +119 -36
  203. package/dist/store/decisions.js +3 -1
  204. package/dist/store/evidence-findings.d.ts +14 -0
  205. package/dist/store/evidence-findings.js +2 -0
  206. package/dist/store/exports.d.ts +2 -1
  207. package/dist/store/identity-links.d.ts +92 -0
  208. package/dist/store/identity-links.js +6 -0
  209. package/dist/store/index.d.ts +11 -5
  210. package/dist/store/index.js +5 -2
  211. package/dist/store/journal.d.ts +10 -0
  212. package/dist/store/journal.js +33 -0
  213. package/dist/store/marks.d.ts +19 -1
  214. package/dist/store/marks.js +23 -1
  215. package/dist/store/migrations.d.ts +1 -1
  216. package/dist/store/migrations.js +35 -12
  217. package/dist/store/people.d.ts +22 -0
  218. package/dist/store/people.js +15 -1
  219. package/dist/store/recover.d.ts +34 -0
  220. package/dist/store/recover.js +188 -6
  221. package/dist/store/refill.d.ts +28 -0
  222. package/dist/store/refill.js +120 -0
  223. package/dist/store/sqlite/accounts.js +2 -0
  224. package/dist/store/sqlite/base-stages.d.ts +122 -0
  225. package/dist/store/sqlite/base-stages.js +443 -0
  226. package/dist/store/sqlite/base-suggest.d.ts +13 -0
  227. package/dist/store/sqlite/base-suggest.js +62 -0
  228. package/dist/store/sqlite/business-contracts.js +10 -1
  229. package/dist/store/sqlite/clients.d.ts +7 -3
  230. package/dist/store/sqlite/clients.js +11 -7
  231. package/dist/store/sqlite/crm-settings.d.ts +12 -2
  232. package/dist/store/sqlite/crm-settings.js +56 -13
  233. package/dist/store/sqlite/crm.d.ts +13 -1
  234. package/dist/store/sqlite/crm.js +20 -4
  235. package/dist/store/sqlite/deals.d.ts +33 -0
  236. package/dist/store/sqlite/deals.js +42 -4
  237. package/dist/store/sqlite/decision-requests.js +7 -3
  238. package/dist/store/sqlite/email-index.js +17 -15
  239. package/dist/store/sqlite/evidence-findings.js +29 -5
  240. package/dist/store/sqlite/findings-core.js +4 -2
  241. package/dist/store/sqlite/identity-link-rows.d.ts +50 -0
  242. package/dist/store/sqlite/identity-link-rows.js +146 -0
  243. package/dist/store/sqlite/identity-proposals.d.ts +53 -0
  244. package/dist/store/sqlite/identity-proposals.js +234 -0
  245. package/dist/store/sqlite/knowledge.js +5 -3
  246. package/dist/store/sqlite/link-kinds.d.ts +1 -0
  247. package/dist/store/sqlite/link-kinds.js +1 -0
  248. package/dist/store/sqlite/link-row.d.ts +6 -0
  249. package/dist/store/sqlite/link-row.js +35 -0
  250. package/dist/store/sqlite/link-source.d.ts +10 -0
  251. package/dist/store/sqlite/link-source.js +16 -0
  252. package/dist/store/sqlite/manifest.js +1 -0
  253. package/dist/store/sqlite/meeting-context-links.js +9 -6
  254. package/dist/store/sqlite/memories.js +9 -7
  255. package/dist/store/sqlite/mentions.d.ts +4 -1
  256. package/dist/store/sqlite/mentions.js +14 -9
  257. package/dist/store/sqlite/migrations.generated.js +8 -0
  258. package/dist/store/sqlite/note-index.js +9 -7
  259. package/dist/store/sqlite/notes.d.ts +2 -3
  260. package/dist/store/sqlite/notes.js +6 -29
  261. package/dist/store/sqlite/open-store.js +3 -0
  262. package/dist/store/sqlite/open.js +11 -2
  263. package/dist/store/sqlite/orders.d.ts +2 -0
  264. package/dist/store/sqlite/orders.js +9 -3
  265. package/dist/store/sqlite/organization-categories.d.ts +18 -0
  266. package/dist/store/sqlite/organization-categories.js +34 -0
  267. package/dist/store/sqlite/organizations.d.ts +5 -1
  268. package/dist/store/sqlite/organizations.js +14 -4
  269. package/dist/store/sqlite/person-links.d.ts +19 -4
  270. package/dist/store/sqlite/person-links.js +49 -11
  271. package/dist/store/sqlite/person-match-scan.d.ts +13 -0
  272. package/dist/store/sqlite/person-match-scan.js +251 -0
  273. package/dist/store/sqlite/person-matcher.d.ts +16 -0
  274. package/dist/store/sqlite/person-matcher.js +32 -0
  275. package/dist/store/sqlite/proposed-actions.js +6 -0
  276. package/dist/store/sqlite/record-matching.d.ts +2 -8
  277. package/dist/store/sqlite/record-matching.js +8 -40
  278. package/dist/store/sqlite/record-projectors-phone.js +2 -1
  279. package/dist/store/sqlite/record-relationships.d.ts +52 -0
  280. package/dist/store/sqlite/record-relationships.js +243 -0
  281. package/dist/store/sqlite/record-run.d.ts +5 -0
  282. package/dist/store/sqlite/record-run.js +62 -2
  283. package/dist/store/sqlite/record-writes.d.ts +1 -1
  284. package/dist/store/sqlite/record-writes.js +4 -2
  285. package/dist/store/sqlite/records.js +27 -2
  286. package/dist/store/sqlite/ref-accounts.d.ts +13 -0
  287. package/dist/store/sqlite/ref-accounts.js +117 -0
  288. package/dist/store/sqlite/ref-summaries.js +5 -1
  289. package/dist/store/sqlite/relation-list.d.ts +4 -1
  290. package/dist/store/sqlite/relation-list.js +20 -2
  291. package/dist/store/sqlite/relation-proposals.d.ts +18 -1
  292. package/dist/store/sqlite/relation-proposals.js +53 -11
  293. package/dist/store/sqlite/relation-roles.js +12 -6
  294. package/dist/store/sqlite/reported-relations.d.ts +11 -1
  295. package/dist/store/sqlite/reported-relations.js +59 -18
  296. package/dist/store/sqlite/schema.d.ts +32 -0
  297. package/dist/store/sqlite/schema.js +3 -0
  298. package/dist/store/sqlite/transaction.d.ts +13 -0
  299. package/dist/store/sqlite/transaction.js +33 -15
  300. package/dist/store/store.d.ts +3 -0
  301. package/dist/store/store.js +5 -0
  302. package/dist/store/write-events.d.ts +18 -0
  303. package/dist/store/write-events.js +88 -0
  304. package/package.json +3 -3
  305. package/parity.json +11 -4
  306. package/schemas/records-envelope.v1.schema.json +3 -0
@@ -0,0 +1,90 @@
1
+ import type { DealKind } from "../domain/deals.js";
2
+ import { type Standing } from "../domain/relations.js";
3
+ import type { AccountKey, Deal, MessageStore, StageChange } from "../store/index.js";
4
+ import { type Category, type Coverage, type Related, type Section } from "./business-context.js";
5
+ import { type Communications, type Touch } from "./communications.js";
6
+ import { type MoneySection } from "./money-context.js";
7
+ import { type TaskLine } from "./organization-context.js";
8
+ /** Met or written to within the deal's lifetime by one of its people: an overlap of people, not a link. */
9
+ export type DealTouch = Touch & {
10
+ standing: Extract<Standing, "proposed">;
11
+ };
12
+ export interface DealContext {
13
+ /** The row as stored: its status is the CRM's or the owner's, and a stage named won is not a payment. */
14
+ deal: Deal;
15
+ /** The newest stages it entered, oldest of them first; `total` counts every one. */
16
+ stages: Section<StageChange>;
17
+ organization: {
18
+ ref: string;
19
+ name: string | null;
20
+ categories: Category[];
21
+ } | null;
22
+ /** Its people, each once with every role and the standing of each. */
23
+ participants: Section<Related>;
24
+ /** The participant whose usable role is `owner`, the CRM's "responsible". */
25
+ owner: Related | null;
26
+ project: {
27
+ ref: string;
28
+ name: string | null;
29
+ } | null;
30
+ /** Its project's invoices and payments and its organization's, each saying how it was reached. */
31
+ money: MoneySection;
32
+ /** From its creation to the day it closed, or now. */
33
+ window: {
34
+ since: string;
35
+ until: string;
36
+ };
37
+ communications: Section<DealTouch> & {
38
+ counts: Communications["counts"];
39
+ };
40
+ tasks: Section<TaskLine>;
41
+ coverage: Coverage;
42
+ }
43
+ export interface DealContextOptions {
44
+ /** The accounts read: a CRM's copy and relationships, and its people's messages, mail and events. */
45
+ accounts?: AccountKey[];
46
+ limit?: number;
47
+ /** ms: the end of an open deal's window; the clock when absent. */
48
+ now?: number;
49
+ /** The kinds the profile denies: a deal or lead of one is not answered. */
50
+ deniedKinds?: readonly DealKind[];
51
+ }
52
+ /**
53
+ * One answer about a deal or a lead from the store: the row, how it moved, its client, people, project, money and
54
+ * what its people said within its lifetime. Nothing is inferred from a stage's name. A CRM's copy outside
55
+ * `accounts` is not answered, and a CRM's relationships outside it are left out.
56
+ */
57
+ export declare const dealContext: (store: MessageStore, reference: string, { accounts, limit, now, deniedKinds }?: DealContextOptions) => Promise<DealContext>;
58
+ /** The compact form for a model's context: names, roles and standings, totals and counts, no row detail. */
59
+ export interface DealBrief {
60
+ ref: string;
61
+ kind: Deal["kind"];
62
+ title: string;
63
+ pipeline: string;
64
+ stage: string;
65
+ status: Deal["status"];
66
+ amount: string | null;
67
+ currency: string | null;
68
+ closeDate: string | null;
69
+ organization: string | null;
70
+ owner: string | null;
71
+ people: {
72
+ ref: string;
73
+ name: string | null;
74
+ roles: string[];
75
+ standing: Standing;
76
+ }[];
77
+ project: string | null;
78
+ /** The newest stage changes, `from → to`. */
79
+ stages: string[];
80
+ money: MoneySection["totals"] & {
81
+ unconfirmed: number;
82
+ complete: boolean;
83
+ };
84
+ communications: Communications["counts"] & {
85
+ standing: "proposed";
86
+ };
87
+ openTasks: number;
88
+ notRead: Coverage["notRead"];
89
+ }
90
+ export declare const dealBrief: (context: DealContext) => DealBrief;
@@ -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,8 +38,9 @@ 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";
41
46
  export declare const keyVariable: (provider: string) => string;
@@ -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),
@@ -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";
@@ -201,7 +214,7 @@ export { retentionService } from "./retention.js";
201
214
  export { RESOURCES_SEARCHED, type SearchAllFound, type SearchAllItem, type SearchAllMessenger, type SearchAllRequest, type SearchedResource, searchAll, } from "./search-all.js";
202
215
  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";
203
216
  export { CATCH_UP_BOUNDS, type CatchUpOptions, type CatchUpResult, catchUpSearch, validateCatchUp, } from "./search-catchup.js";
204
- export { accountsOfKind, listContextOf, type SearchKind } from "./search-kind.js";
217
+ export { accountsOfKind, groupLockOf, listContextOf, type SearchKind } from "./search-kind.js";
205
218
  export type { SearchRefreshed, SyncOptions } from "./search-refresh.js";
206
219
  export { SYNC_BOUNDS, SYNC_KEY } from "./search-refresh.js";
207
220
  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";
@@ -158,7 +165,7 @@ export { retentionService } from "./retention.js";
158
165
  export { RESOURCES_SEARCHED, searchAll, } from "./search-all.js";
159
166
  export { RESOURCES_SEARCHED_WITH_MEETINGS, searchAllIncludingMeetings, searchAllWithMeetings, } from "./search-all-meetings.js";
160
167
  export { CATCH_UP_BOUNDS, catchUpSearch, validateCatchUp, } from "./search-catchup.js";
161
- export { accountsOfKind, listContextOf } from "./search-kind.js";
168
+ export { accountsOfKind, groupLockOf, listContextOf } from "./search-kind.js";
162
169
  export { SYNC_BOUNDS, SYNC_KEY } from "./search-refresh.js";
163
170
  export { SERVER_BOUNDS, SERVER_SEARCH_KEY, } from "./server-search.js";
164
171
  export { createStoredMeetingProjectCandidateReader } from "./stored-meeting-project-candidates.js";