@wirecat/cli-core 0.618.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 (274) hide show
  1. package/CHANGELOG.md +339 -1
  2. package/README.md +1 -1
  3. package/THIRD_PARTY_NOTICES +3 -0
  4. package/dist/background/daily-archive-timer.d.ts +1 -1
  5. package/dist/background/deliver.d.ts +5 -2
  6. package/dist/background/deliver.js +30 -12
  7. package/dist/background/report/render.d.ts +3 -1
  8. package/dist/background/report/render.js +3 -1
  9. package/dist/calendar/cli/answers.d.ts +1 -0
  10. package/dist/calendar/cli/answers.js +6 -1
  11. package/dist/calendar/cli/index.js +2 -14
  12. package/dist/calendar/cli/people-link.d.ts +3 -0
  13. package/dist/calendar/cli/people-link.js +23 -0
  14. package/dist/calendar/index.d.ts +1 -1
  15. package/dist/calendar/index.js +1 -1
  16. package/dist/calendar/mcp/index.d.ts +12 -12
  17. package/dist/cli/base-stages-command.d.ts +22 -0
  18. package/dist/cli/base-stages-command.js +174 -0
  19. package/dist/cli/command-runs.d.ts +2 -0
  20. package/dist/cli/command-runs.js +3 -1
  21. package/dist/cli/config-command.js +6 -1
  22. package/dist/cli/context.js +1 -0
  23. package/dist/cli/group-lock.d.ts +42 -0
  24. package/dist/cli/group-lock.js +130 -0
  25. package/dist/cli/index.d.ts +7 -2
  26. package/dist/cli/index.js +7 -2
  27. package/dist/cli/messenger/backfill-command.js +27 -15
  28. package/dist/cli/messenger/contacts-command.js +10 -3
  29. package/dist/cli/messenger/context.js +1 -0
  30. package/dist/cli/messenger/doctor-command.js +3 -1
  31. package/dist/cli/messenger/models-command.js +1 -1
  32. package/dist/cli/messenger/store-maintenance-command.d.ts +22 -2
  33. package/dist/cli/messenger/store-maintenance-command.js +9 -4
  34. package/dist/cli/model-catalogue-command.d.ts +3 -1
  35. package/dist/cli/model-catalogue-command.js +46 -2
  36. package/dist/cli/profile.d.ts +8 -0
  37. package/dist/cli/profile.js +25 -0
  38. package/dist/cli/program.js +2 -0
  39. package/dist/cli/runs/search-query.d.ts +1 -1
  40. package/dist/cli/runs/search-query.js +4 -0
  41. package/dist/cli/runs/search.d.ts +5 -1
  42. package/dist/cli/runs/search.js +12 -1
  43. package/dist/cli/search-left-out.d.ts +6 -1
  44. package/dist/cli/search-left-out.js +9 -4
  45. package/dist/cli/settings.d.ts +8 -0
  46. package/dist/cli/settings.js +17 -2
  47. package/dist/cli/shared-command-exports.d.ts +16 -0
  48. package/dist/cli/store-recover.d.ts +3 -3
  49. package/dist/cli/store-recover.js +26 -26
  50. package/dist/cli/store-settings.d.ts +2 -0
  51. package/dist/cli/store-settings.js +37 -9
  52. package/dist/crm/cli/index.js +38 -6
  53. package/dist/crm/group-hint.d.ts +8 -0
  54. package/dist/crm/group-hint.js +13 -0
  55. package/dist/crm/source.d.ts +12 -1
  56. package/dist/crm/sync.d.ts +31 -2
  57. package/dist/crm/sync.js +110 -3
  58. package/dist/crm/testing/acme-scenario.d.ts +40 -0
  59. package/dist/crm/testing/acme-scenario.js +170 -0
  60. package/dist/crm/testing/index.d.ts +1 -0
  61. package/dist/crm/testing/index.js +1 -0
  62. package/dist/crm/testing/source-contract.js +12 -0
  63. package/dist/crm/testing/source.d.ts +2 -0
  64. package/dist/crm/testing/source.js +1 -0
  65. package/dist/domain/addresses.d.ts +13 -0
  66. package/dist/domain/addresses.js +63 -0
  67. package/dist/domain/categories.d.ts +3 -0
  68. package/dist/domain/categories.js +2 -0
  69. package/dist/domain/crm.d.ts +23 -0
  70. package/dist/domain/crm.js +7 -0
  71. package/dist/domain/mentions.d.ts +2 -12
  72. package/dist/domain/mentions.js +2 -19
  73. package/dist/domain/orders.d.ts +8 -1
  74. package/dist/domain/orders.js +6 -2
  75. package/dist/domain/phones.d.ts +26 -0
  76. package/dist/domain/phones.js +48 -0
  77. package/dist/domain/record-types.d.ts +1 -1
  78. package/dist/domain/record-types.js +1 -0
  79. package/dist/domain/records.d.ts +5 -0
  80. package/dist/domain/ref-summaries.d.ts +39 -0
  81. package/dist/domain/ref-summaries.js +51 -3
  82. package/dist/domain/relations.d.ts +12 -2
  83. package/dist/domain/relations.js +14 -3
  84. package/dist/domain/vcard.d.ts +2 -2
  85. package/dist/domain/vcard.js +4 -10
  86. package/dist/embeddings/models.d.ts +11 -3
  87. package/dist/embeddings/models.js +28 -4
  88. package/dist/entities/business-context.d.ts +149 -0
  89. package/dist/entities/business-context.js +192 -0
  90. package/dist/entities/contact-activity.d.ts +2 -0
  91. package/dist/entities/contact-activity.js +7 -1
  92. package/dist/entities/contact-context.d.ts +157 -0
  93. package/dist/entities/contact-context.js +2 -0
  94. package/dist/entities/deal.d.ts +10 -0
  95. package/dist/entities/deal.js +2 -0
  96. package/dist/entities/index.d.ts +23 -3
  97. package/dist/entities/index.js +5 -0
  98. package/dist/entities/mention.d.ts +4 -3
  99. package/dist/entities/mention.js +2 -1
  100. package/dist/entities/message-transfer.d.ts +4 -2
  101. package/dist/entities/message-transfer.js +2 -2
  102. package/dist/entities/model.d.ts +2 -2
  103. package/dist/entities/model.js +1 -1
  104. package/dist/entities/relationship.d.ts +4 -0
  105. package/dist/entities/relationship.js +4 -0
  106. package/dist/errors/reasons.js +37 -4
  107. package/dist/fetch/page.js +2 -1
  108. package/dist/index.d.ts +3 -2
  109. package/dist/index.js +3 -2
  110. package/dist/meetings/context-store.d.ts +2 -0
  111. package/dist/meetings/findings-rules.d.ts +4 -0
  112. package/dist/meetings/findings-rules.js +5 -2
  113. package/dist/meetings/result-items.d.ts +1 -0
  114. package/dist/meetings/result-items.js +1 -0
  115. package/dist/models/index.js +22 -5
  116. package/dist/runs/events.d.ts +11 -1
  117. package/dist/runs/events.js +3 -1
  118. package/dist/runs/log-attributes.js +4 -0
  119. package/dist/runs/log-events.js +2 -0
  120. package/dist/runs/recording.d.ts +3 -0
  121. package/dist/runs/recording.js +36 -12
  122. package/dist/runs/run.d.ts +12 -3
  123. package/dist/runs/run.js +32 -13
  124. package/dist/search/account-list.d.ts +6 -0
  125. package/dist/search/account-list.js +9 -3
  126. package/dist/search/groups.d.ts +68 -0
  127. package/dist/search/groups.js +172 -0
  128. package/dist/services/account-groups.d.ts +28 -0
  129. package/dist/services/account-groups.js +89 -0
  130. package/dist/services/archive.d.ts +7 -1
  131. package/dist/services/archive.js +19 -3
  132. package/dist/services/business-context.d.ts +113 -0
  133. package/dist/services/business-context.js +156 -0
  134. package/dist/services/communications.d.ts +50 -0
  135. package/dist/services/communications.js +140 -0
  136. package/dist/services/deal-context.d.ts +90 -0
  137. package/dist/services/deal-context.js +131 -0
  138. package/dist/services/deps.d.ts +2 -0
  139. package/dist/services/enrichment.d.ts +7 -2
  140. package/dist/services/enrichment.js +46 -5
  141. package/dist/services/events-search.js +2 -1
  142. package/dist/services/group-guard.d.ts +28 -0
  143. package/dist/services/group-guard.js +131 -0
  144. package/dist/services/index.d.ts +15 -2
  145. package/dist/services/index.js +9 -2
  146. package/dist/services/ingest.d.ts +12 -0
  147. package/dist/services/ingest.js +4 -0
  148. package/dist/services/meaning-model.d.ts +7 -0
  149. package/dist/services/meaning-model.js +20 -0
  150. package/dist/services/meeting-context.d.ts +6 -1
  151. package/dist/services/meeting-context.js +12 -5
  152. package/dist/services/message-resolution.js +2 -3
  153. package/dist/services/messages-meaning.js +4 -5
  154. package/dist/services/messages-search.d.ts +5 -1
  155. package/dist/services/messages-search.js +1 -1
  156. package/dist/services/model-downloads.d.ts +1 -1
  157. package/dist/services/model-downloads.js +6 -4
  158. package/dist/services/money-context.d.ts +73 -0
  159. package/dist/services/money-context.js +77 -0
  160. package/dist/services/notes-search.d.ts +4 -1
  161. package/dist/services/notes-search.js +19 -7
  162. package/dist/services/organization-context.d.ts +80 -0
  163. package/dist/services/organization-context.js +154 -0
  164. package/dist/services/people.d.ts +22 -6
  165. package/dist/services/people.js +38 -8
  166. package/dist/services/person-business.d.ts +43 -0
  167. package/dist/services/person-business.js +67 -0
  168. package/dist/services/person-context.d.ts +9 -1
  169. package/dist/services/person-context.js +5 -3
  170. package/dist/services/proposals/kinds/identity-link.d.ts +4 -0
  171. package/dist/services/proposals/kinds/identity-link.js +48 -0
  172. package/dist/services/proposals/kinds/orders.js +1 -1
  173. package/dist/services/proposals/registry.js +2 -0
  174. package/dist/services/search-kind.d.ts +12 -5
  175. package/dist/services/search-kind.js +49 -10
  176. package/dist/services/text-model-choice.js +1 -1
  177. package/dist/store/accounts.d.ts +18 -0
  178. package/dist/store/accounts.js +18 -3
  179. package/dist/store/damage.d.ts +43 -10
  180. package/dist/store/damage.js +119 -36
  181. package/dist/store/decisions.js +3 -1
  182. package/dist/store/evidence-findings.d.ts +14 -0
  183. package/dist/store/evidence-findings.js +2 -0
  184. package/dist/store/exports.d.ts +2 -1
  185. package/dist/store/identity-links.d.ts +92 -0
  186. package/dist/store/identity-links.js +6 -0
  187. package/dist/store/index.d.ts +11 -5
  188. package/dist/store/index.js +5 -2
  189. package/dist/store/journal.d.ts +10 -0
  190. package/dist/store/journal.js +33 -0
  191. package/dist/store/marks.d.ts +19 -1
  192. package/dist/store/marks.js +23 -1
  193. package/dist/store/people.d.ts +22 -0
  194. package/dist/store/people.js +15 -1
  195. package/dist/store/sqlite/accounts.js +2 -0
  196. package/dist/store/sqlite/base-stages.d.ts +122 -0
  197. package/dist/store/sqlite/base-stages.js +443 -0
  198. package/dist/store/sqlite/base-suggest.d.ts +13 -0
  199. package/dist/store/sqlite/base-suggest.js +62 -0
  200. package/dist/store/sqlite/business-contracts.js +10 -1
  201. package/dist/store/sqlite/crm-settings.d.ts +12 -2
  202. package/dist/store/sqlite/crm-settings.js +56 -13
  203. package/dist/store/sqlite/crm.d.ts +13 -1
  204. package/dist/store/sqlite/crm.js +20 -4
  205. package/dist/store/sqlite/deals.d.ts +33 -0
  206. package/dist/store/sqlite/deals.js +42 -4
  207. package/dist/store/sqlite/decision-requests.js +7 -3
  208. package/dist/store/sqlite/email-index.js +8 -4
  209. package/dist/store/sqlite/evidence-findings.js +29 -5
  210. package/dist/store/sqlite/findings-core.js +4 -2
  211. package/dist/store/sqlite/identity-link-rows.d.ts +50 -0
  212. package/dist/store/sqlite/identity-link-rows.js +146 -0
  213. package/dist/store/sqlite/identity-proposals.d.ts +53 -0
  214. package/dist/store/sqlite/identity-proposals.js +234 -0
  215. package/dist/store/sqlite/knowledge.js +2 -2
  216. package/dist/store/sqlite/link-kinds.d.ts +1 -0
  217. package/dist/store/sqlite/link-kinds.js +1 -0
  218. package/dist/store/sqlite/link-row.d.ts +6 -0
  219. package/dist/store/sqlite/link-row.js +35 -0
  220. package/dist/store/sqlite/link-source.d.ts +10 -0
  221. package/dist/store/sqlite/link-source.js +16 -0
  222. package/dist/store/sqlite/manifest.js +1 -0
  223. package/dist/store/sqlite/meeting-context-links.js +9 -6
  224. package/dist/store/sqlite/memories.js +9 -7
  225. package/dist/store/sqlite/mentions.d.ts +4 -1
  226. package/dist/store/sqlite/mentions.js +14 -9
  227. package/dist/store/sqlite/migrations.generated.js +8 -0
  228. package/dist/store/sqlite/notes.d.ts +1 -2
  229. package/dist/store/sqlite/notes.js +4 -29
  230. package/dist/store/sqlite/open-store.js +3 -0
  231. package/dist/store/sqlite/open.js +11 -2
  232. package/dist/store/sqlite/orders.d.ts +2 -0
  233. package/dist/store/sqlite/orders.js +9 -3
  234. package/dist/store/sqlite/organization-categories.d.ts +18 -0
  235. package/dist/store/sqlite/organization-categories.js +34 -0
  236. package/dist/store/sqlite/organizations.d.ts +5 -1
  237. package/dist/store/sqlite/organizations.js +14 -4
  238. package/dist/store/sqlite/person-links.d.ts +19 -4
  239. package/dist/store/sqlite/person-links.js +49 -11
  240. package/dist/store/sqlite/person-match-scan.d.ts +13 -0
  241. package/dist/store/sqlite/person-match-scan.js +251 -0
  242. package/dist/store/sqlite/person-matcher.d.ts +16 -0
  243. package/dist/store/sqlite/person-matcher.js +32 -0
  244. package/dist/store/sqlite/proposed-actions.js +6 -0
  245. package/dist/store/sqlite/record-matching.d.ts +2 -8
  246. package/dist/store/sqlite/record-matching.js +8 -40
  247. package/dist/store/sqlite/record-projectors-phone.js +2 -1
  248. package/dist/store/sqlite/record-relationships.d.ts +52 -0
  249. package/dist/store/sqlite/record-relationships.js +243 -0
  250. package/dist/store/sqlite/record-run.d.ts +5 -0
  251. package/dist/store/sqlite/record-run.js +62 -2
  252. package/dist/store/sqlite/record-writes.d.ts +1 -1
  253. package/dist/store/sqlite/record-writes.js +4 -2
  254. package/dist/store/sqlite/records.js +27 -2
  255. package/dist/store/sqlite/ref-accounts.d.ts +13 -0
  256. package/dist/store/sqlite/ref-accounts.js +117 -0
  257. package/dist/store/sqlite/ref-summaries.js +5 -1
  258. package/dist/store/sqlite/relation-list.d.ts +4 -1
  259. package/dist/store/sqlite/relation-list.js +18 -2
  260. package/dist/store/sqlite/relation-proposals.d.ts +6 -0
  261. package/dist/store/sqlite/relation-proposals.js +3 -0
  262. package/dist/store/sqlite/relation-roles.js +12 -6
  263. package/dist/store/sqlite/reported-relations.d.ts +11 -1
  264. package/dist/store/sqlite/reported-relations.js +59 -18
  265. package/dist/store/sqlite/schema.d.ts +32 -0
  266. package/dist/store/sqlite/schema.js +3 -0
  267. package/dist/store/sqlite/transaction.js +11 -1
  268. package/dist/store/store.d.ts +3 -0
  269. package/dist/store/store.js +5 -0
  270. package/dist/store/write-events.d.ts +18 -0
  271. package/dist/store/write-events.js +88 -0
  272. package/package.json +3 -3
  273. package/parity.json +11 -4
  274. package/schemas/records-envelope.v1.schema.json +3 -0
@@ -1,6 +1,56 @@
1
1
  import { singleLine } from "@wirecat/cli-base";
2
2
  import { providerNamed } from "./providers.js";
3
3
  export const PROFILE_PLACEHOLDER = "<profile>";
4
+ const unregistered = (provider) => `no CLI has registered ${provider} in this store yet; run its CLI once`;
5
+ export const profilesOn = (profiles, app, key) => Object.entries(profiles[app] ?? {})
6
+ .filter(([, saved]) => saved.provider === key.provider && saved.account === key.account)
7
+ .map(([name]) => name);
8
+ /** From the store's record, so it answers for any CLI that registered its provider, not only the messengers. */
9
+ export const storedProfilesFor = (profiles) => (provider, account) => {
10
+ const tool = providerNamed(provider)?.command;
11
+ if (tool === undefined)
12
+ return { why: unregistered(provider), profiles: [] };
13
+ if (account === null)
14
+ return { why: `${provider} names no account here`, profiles: [] };
15
+ const named = profilesOn(profiles, tool, { provider, account });
16
+ if (named.length === 1)
17
+ return { profile: named[0] };
18
+ return {
19
+ why: named.length === 0
20
+ ? `no ${tool} profile has run on ${provider}:${account} here; run \`${tool} <profile>\` with it once`
21
+ : `${named.length} ${tool} profiles are on ${provider}:${account}: ${named.join(", ")}; the owner chooses one`,
22
+ profiles: named,
23
+ };
24
+ };
25
+ const keyText = (key) => `${key.provider}:${key.account}`;
26
+ /**
27
+ * `null` for the owner's own row: memo itself writes it. `allowed` is the caller's profile or group lock: a profile it
28
+ * forbids is never named, and the one profile it leaves is the answer.
29
+ */
30
+ export const writesWithOf = (account, profilesFor, { allowed } = {}) => {
31
+ if (account === null)
32
+ return null;
33
+ const tool = providerNamed(account.provider)?.command ?? null;
34
+ if (tool === null)
35
+ return { tool, account, profile: null, profiles: [], why: unregistered(account.provider) };
36
+ const asked = profilesFor(account.provider, account.account);
37
+ const named = "profile" in asked ? [asked.profile] : asked.profiles;
38
+ const kept = allowed ? named.filter((profile) => allowed(tool, profile)) : named;
39
+ if (kept.length === 1 && ("profile" in asked || allowed))
40
+ return { tool, account, profile: kept[0], profiles: kept, why: null };
41
+ if (kept.length === named.length && !("profile" in asked))
42
+ return { tool, account, profile: null, profiles: asked.profiles, why: asked.why };
43
+ return {
44
+ tool,
45
+ account,
46
+ profile: null,
47
+ profiles: kept,
48
+ why: kept.length === 0
49
+ ? `no ${tool} profile on ${keyText(account)} is allowed in this run`
50
+ : `${kept.length} ${tool} profiles allowed in this run are on ${keyText(account)}: ${kept.join(", ")}; ` +
51
+ "the owner chooses one",
52
+ };
53
+ };
4
54
  /** A title from someone else's text, as one line: a newline in it would break every row it is printed in. */
5
55
  export const oneLine = (text) => singleLine(text.replace(/\s+/g, " ").trim());
6
56
  /** Mail is a message and a chat to the provider registry: `opens` is keyed by the reference kind. */
@@ -28,9 +78,7 @@ export const openOf = (summary, ports) => {
28
78
  return {
29
79
  argv: null,
30
80
  profiles: [],
31
- why: summary.provider === null
32
- ? `nothing here opens a ${kind}`
33
- : `no CLI has registered ${summary.provider} in this store yet; run its CLI once`,
81
+ why: summary.provider === null ? `nothing here opens a ${kind}` : unregistered(summary.provider),
34
82
  };
35
83
  };
36
84
  const WORDS = {
@@ -1,6 +1,8 @@
1
1
  /** What a person is to an organization; who reports to whom is `reports-to`, and a job title is never a role. */
2
2
  export declare const ORGANIZATION_ROLES: readonly ["employee", "contractor", "founder", "owner", "manager", "adviser", "contact"];
3
3
  export declare const PROJECT_ROLES: readonly ["owner", "manager", "contributor", "client-contact", "approver"];
4
+ /** A contract party's part; a party the list cannot name has none, never a catch-all `other`. */
5
+ export declare const CONTRACT_ROLES: readonly ["customer", "supplier", "signatory", "guarantor"];
4
6
  /** How much the owner deals with a person on a project himself, not how active the person is; absent is unknown. */
5
7
  export declare const ENGAGEMENT_LEVELS: readonly ["none", "low", "medium", "high"];
6
8
  export type Engagement = (typeof ENGAGEMENT_LEVELS)[number];
@@ -12,7 +14,7 @@ export declare const engagementRank: (level: Engagement | null | undefined) => n
12
14
  export declare const byEngagement: <T extends {
13
15
  engagement?: Engagement | null;
14
16
  }>(items: readonly T[]) => T[];
15
- type End = "person" | "organization" | "project" | "task" | "chat" | "email_thread" | "deal" | "lead";
17
+ type End = "person" | "organization" | "project" | "task" | "chat" | "email_thread" | "deal" | "lead" | "contract";
16
18
  interface RelationSpec {
17
19
  from: readonly End[];
18
20
  to: readonly End[];
@@ -57,12 +59,13 @@ export declare const RELATIONS: {
57
59
  readonly symmetric: true;
58
60
  };
59
61
  readonly "related-to": {
60
- readonly from: readonly ["person", "organization", "project", "task", "deal", "lead"];
62
+ readonly from: readonly ["person", "organization", "project", "task", "deal", "lead", "contract"];
61
63
  readonly to: readonly ["person", "organization", "project", "task"];
62
64
  readonly roles: {
63
65
  readonly from: {
64
66
  readonly deal: readonly ["owner", "contact", "decision-maker", "influencer"];
65
67
  readonly lead: readonly ["owner", "contact", "decision-maker", "influencer"];
68
+ readonly contract: readonly ["customer", "supplier", "signatory", "guarantor"];
66
69
  };
67
70
  };
68
71
  };
@@ -81,6 +84,7 @@ export declare const ROLE_LISTS: {
81
84
  readonly organization: readonly ["employee", "contractor", "founder", "owner", "manager", "adviser", "contact"];
82
85
  readonly project: readonly ["owner", "manager", "contributor", "client-contact", "approver"];
83
86
  readonly deal: readonly ["owner", "contact", "decision-maker", "influencer"];
87
+ readonly contract: readonly ["customer", "supplier", "signatory", "guarantor"];
84
88
  };
85
89
  export type RoleList = keyof typeof ROLE_LISTS;
86
90
  /** Which list a relationship's role comes from, or `undefined` where a role is free text. */
@@ -124,6 +128,12 @@ export interface RelationshipColumns {
124
128
  engagement?: Engagement;
125
129
  /** The source's link this owner link overrides (`metadata.overrides`). */
126
130
  overrides?: number;
131
+ /** The source's own words for it, off the role list (`metadata.source_role`), never its role. */
132
+ sourceRoles?: string[];
133
+ /** The source account that reported it, `<provider>:<account>`. */
134
+ account?: string;
135
+ /** How a source made the relationship when it stated none, such as `department-head`. */
136
+ derived?: string;
127
137
  }
128
138
  /** The owner's confirmation outlives a source that stopped reporting it; only its own end date ends it. */
129
139
  export declare const standingOf: (link: StandingFields, now: number) => Standing;
@@ -11,6 +11,8 @@ export const ORGANIZATION_ROLES = [
11
11
  "contact",
12
12
  ];
13
13
  export const PROJECT_ROLES = ["owner", "manager", "contributor", "client-contact", "approver"];
14
+ /** A contract party's part; a party the list cannot name has none, never a catch-all `other`. */
15
+ export const CONTRACT_ROLES = ["customer", "supplier", "signatory", "guarantor"];
14
16
  /** How much the owner deals with a person on a project himself, not how active the person is; absent is unknown. */
15
17
  export const ENGAGEMENT_LEVELS = ["none", "low", "medium", "high"];
16
18
  export const isEngagement = (value) => typeof value === "string" && ENGAGEMENT_LEVELS.includes(value);
@@ -48,9 +50,9 @@ export const RELATIONS = {
48
50
  "customer-of": { from: ["person", "organization"], to: ["organization"], inverse: "supplier of" },
49
51
  "partner-of": { from: ["organization"], to: ["organization"], symmetric: true },
50
52
  "related-to": {
51
- from: ["person", "organization", "project", "task", "deal", "lead"],
53
+ from: ["person", "organization", "project", "task", "deal", "lead", "contract"],
52
54
  to: ["person", "organization", "project", "task"],
53
- roles: { from: { deal: DEAL_ROLES, lead: DEAL_ROLES } },
55
+ roles: { from: { deal: DEAL_ROLES, lead: DEAL_ROLES, contract: CONTRACT_ROLES } },
54
56
  },
55
57
  };
56
58
  export const RELATION_KINDS = Object.keys(RELATIONS);
@@ -58,12 +60,16 @@ const specOf = (kind) => Object.hasOwn(RELATIONS, kind) ? RELATIONS[kind] : unde
58
60
  export const isRelationKind = (kind) => specOf(kind) !== undefined;
59
61
  /** A chat or a mail thread is only ever a project's member: its reference names one account. */
60
62
  const memberOnly = (type) => type === "chat" || type === "email_thread";
63
+ /** A contract's parties are the people and organizations that signed it. */
64
+ const partyOnly = (from, to) => from === "contract" && to !== "person" && to !== "organization";
61
65
  export const checkEnds = (kind, from, to) => {
62
66
  const spec = specOf(kind);
63
67
  if (!spec)
64
68
  throw new CliError("validation_error", `a relationship's kind is one of ${RELATION_KINDS.join(", ")}`);
65
69
  if (memberOnly(from) && (kind !== "member-of" || to !== "project"))
66
70
  throw new CliError("validation_error", `a ${from === "chat" ? "chat" : "mail thread"} is related only as member-of a project`);
71
+ if (partyOnly(from, to))
72
+ throw new CliError("validation_error", "a contract is related only to a person or an organization");
67
73
  if (!spec.from.includes(from) || !spec.to.includes(to))
68
74
  throw new CliError("validation_error", `${kind} joins ${spec.from.join(", ")} to ${spec.to.join(", ")}, not ${from} to ${to}`);
69
75
  return spec;
@@ -79,7 +85,12 @@ export const rolesOf = (kind, from, to) => {
79
85
  return spec?.roles?.from?.[from] ?? spec?.roles?.to?.[to];
80
86
  };
81
87
  /** The role lists the owner may add to; each is a list the registry gives some relationship's ends. */
82
- export const ROLE_LISTS = { organization: ORGANIZATION_ROLES, project: PROJECT_ROLES, deal: DEAL_ROLES };
88
+ export const ROLE_LISTS = {
89
+ organization: ORGANIZATION_ROLES,
90
+ project: PROJECT_ROLES,
91
+ deal: DEAL_ROLES,
92
+ contract: CONTRACT_ROLES,
93
+ };
83
94
  /** Which list a relationship's role comes from, or `undefined` where a role is free text. */
84
95
  export const roleListOf = (kind, from, to) => {
85
96
  const roles = rolesOf(kind, from, to);
@@ -1,4 +1,4 @@
1
- import type { PhoneCountry } from "./phones.js";
1
+ import { type PhoneCountry } from "./phones.js";
2
2
  import type { RecordsEnvelope } from "./records.js";
3
3
  export interface VcardOptions {
4
4
  provider: string;
@@ -19,7 +19,7 @@ export declare const isVcard: (text: string) => boolean;
19
19
  * addresses, and one organization per `ORG` name the person is a member of. Nothing is guessed: a national number
20
20
  * is read only in `region`, and a card says nothing about a person it does not hold.
21
21
  */
22
- export declare const envelopeOfVcard: (text: string, { provider, account, batchId, region }: VcardOptions) => {
22
+ export declare const envelopeOfVcard: (text: string, { provider, account, batchId, region: given }: VcardOptions) => {
23
23
  envelope: RecordsEnvelope;
24
24
  issues: VcardIssue[];
25
25
  };
@@ -1,5 +1,5 @@
1
1
  import { createHash } from "node:crypto";
2
- import { typedPhone } from "./mentions.js";
2
+ import { e164Of } from "./phones.js";
3
3
  import { WORD_BODY } from "./record-types.js";
4
4
  const MAX_ID = 512;
5
5
  const AS_WORD = new RegExp(`^${WORD_BODY}$`);
@@ -108,14 +108,7 @@ const components = (value) => {
108
108
  };
109
109
  const textOf = (property, report) => components(decoded(property, report)).join(";").trim();
110
110
  /** E.164, or `undefined` when the number has no country of its own and none is given. */
111
- const e164 = (typed, region) => {
112
- const text = typed.replace(/^tel:/i, "").replace(/;.*$/, "").trim();
113
- const international = /^(\+|00)/.test(text);
114
- if (!international && region === undefined)
115
- return undefined;
116
- const value = typedPhone(text, region === undefined ? {} : { phoneCountries: [region] })?.value;
117
- return value?.startsWith("+") ? value : undefined;
118
- };
111
+ const e164 = (typed, region) => e164Of(typed.replace(/^tel:/i, "").replace(/;.*$/, "").trim(), region) ?? undefined;
119
112
  const foldedName = (name) => name.normalize("NFKC").toLowerCase().replace(/\s+/g, " ").trim();
120
113
  const hashed = (prefix, parts) => `${prefix}${createHash("sha256").update(parts.join("\n")).digest("hex").slice(0, 32)}`;
121
114
  const organizationId = (name) => {
@@ -174,7 +167,8 @@ const cardsOf = (text) => {
174
167
  * addresses, and one organization per `ORG` name the person is a member of. Nothing is guessed: a national number
175
168
  * is read only in `region`, and a card says nothing about a person it does not hold.
176
169
  */
177
- export const envelopeOfVcard = (text, { provider, account, batchId, region }) => {
170
+ export const envelopeOfVcard = (text, { provider, account, batchId, region: given }) => {
171
+ const region = given?.toLowerCase();
178
172
  const { cards, issues } = cardsOf(text);
179
173
  const people = [];
180
174
  const organizations = new Map();
@@ -15,8 +15,10 @@ export interface TextModel {
15
15
  custom?: boolean;
16
16
  languages: string;
17
17
  licence: string;
18
- /** A licence the user accepts before the model is downloaded, or nothing for an open one. */
18
+ /** The page of a licence with conditions of its own, or nothing for an open one. */
19
19
  terms?: string;
20
+ /** What the licence asks a copy to carry, written beside the model's files as NOTICE. */
21
+ notice?: string;
20
22
  dims: number;
21
23
  /** What the model was trained on; a longer text is cut. */
22
24
  maxTokens: number;
@@ -35,7 +37,9 @@ export interface TextModel {
35
37
  externalData?: string;
36
38
  }
37
39
  export declare const TEXT_MODELS: TextModel[];
38
- export declare const DEFAULT_TEXT_MODEL = "e5-small";
40
+ export declare const DEFAULT_TEXT_MODEL = "embeddinggemma";
41
+ /** The default until 8 Nov 2026: a machine that has it and not EmbeddingGemma keeps embedding and searching with it. */
42
+ export declare const PREVIOUS_DEFAULT_TEXT_MODEL = "e5-small";
39
43
  /** A model the owner adds: the same shape as a built-in one, so it is downloaded, checked and loaded the same way. */
40
44
  export declare const CustomTextModelShape: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
41
45
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "is not a model id: a-z, 0-9, . _ -">]>;
@@ -203,7 +207,11 @@ export declare const writeTextModelsSection: (section: TextModelsSection, env?:
203
207
  /** The models this version ships, then the owner's own. */
204
208
  export declare const textModels: (env?: NodeJS.ProcessEnv) => TextModel[];
205
209
  export declare const textModel: (id: string, env?: NodeJS.ProcessEnv) => TextModel;
206
- /** The model every embed and every search by meaning uses when none is named: the owner's `models use`, or e5-small. */
210
+ /**
211
+ * The model every embed and every search by meaning uses when none is named: the owner's `models set`, else
212
+ * EmbeddingGemma. A machine with only e5-small downloaded, the default before, keeps using it, so its search by meaning
213
+ * never stops for a model it lacks; once EmbeddingGemma is downloaded the next syncs embed with it.
214
+ */
207
215
  export declare const chosenTextModel: (env?: NodeJS.ProcessEnv) => {
208
216
  id: string;
209
217
  from: "chosen" | "default";
@@ -1,5 +1,8 @@
1
+ import { existsSync } from "node:fs";
2
+ import { join } from "node:path";
1
3
  import { CliError } from "@wirecat/cli-base";
2
4
  import * as v from "valibot";
5
+ import { filesPresent, sharedModelsDirectory } from "../speech/install.js";
3
6
  import { storePath } from "../store/path.js";
4
7
  import { readSharedSection, sharedConfigPath, writeSharedSection } from "../store/shared-config.js";
5
8
  const huggingFace = (repository, commit) => (name) => `https://huggingface.co/${repository}/resolve/${commit}/${name}`;
@@ -48,9 +51,14 @@ export const TEXT_MODELS = [
48
51
  languages: "over 100 languages — the best of the two on chat, about seven times slower",
49
52
  licence: "Gemma Terms of Use",
50
53
  terms: "https://ai.google.dev/gemma/terms",
54
+ // Gemma Terms of Use §3.1: every copy carries this notice and the use restrictions of §3.2.
55
+ notice: "Gemma is provided under and subject to the Gemma Terms of Use found at ai.google.dev/gemma/terms. Its use is " +
56
+ "restricted by the Gemma Prohibited Use Policy: https://ai.google.dev/gemma/prohibited_use_policy",
51
57
  dims: 768,
52
58
  maxTokens: 2048,
53
- chunksPerSecond: 2,
59
+ // 2026-11-08, 1,200-character chunks, 8 threads on the Ryzen AI 9 HX 470: 8.3 chunks/s against e5-small's 52.7, so
60
+ // 5 on the scale e5-small's 31 sets. It was 2, which held a memo sync to 39 chunks.
61
+ chunksPerSecond: 5,
54
62
  pooling: "sentence_embedding",
55
63
  prefix: { query: "task: search result | query: ", passage: "title: none | text: " },
56
64
  onnx: "onnx/model_q4.onnx",
@@ -117,7 +125,9 @@ export const TEXT_MODELS = [
117
125
  ],
118
126
  },
119
127
  ];
120
- export const DEFAULT_TEXT_MODEL = "e5-small";
128
+ export const DEFAULT_TEXT_MODEL = "embeddinggemma";
129
+ /** The default until 8 Nov 2026: a machine that has it and not EmbeddingGemma keeps embedding and searching with it. */
130
+ export const PREVIOUS_DEFAULT_TEXT_MODEL = "e5-small";
121
131
  const SECTION = "text_models";
122
132
  const slug = v.pipe(v.string(), v.regex(/^[a-z0-9][a-z0-9._-]{0,62}$/, "is not a model id: a-z, 0-9, . _ -"));
123
133
  const words = v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(300));
@@ -188,10 +198,24 @@ export const textModel = (id, env = process.env) => {
188
198
  }
189
199
  return found;
190
200
  };
191
- /** The model every embed and every search by meaning uses when none is named: the owner's `models use`, or e5-small. */
201
+ const downloaded = (id, env) => {
202
+ const model = TEXT_MODELS.find((one) => one.id === id);
203
+ const directory = sharedModelsDirectory("text", env);
204
+ return model !== undefined && filesPresent(model.files.map((file) => [file, join(directory, model.id, file.name)]));
205
+ };
206
+ /**
207
+ * The model every embed and every search by meaning uses when none is named: the owner's `models set`, else
208
+ * EmbeddingGemma. A machine with only e5-small downloaded, the default before, keeps using it, so its search by meaning
209
+ * never stops for a model it lacks; once EmbeddingGemma is downloaded the next syncs embed with it.
210
+ */
192
211
  export const chosenTextModel = (env = process.env) => {
193
212
  const use = readTextModelsSection(env).use;
194
- return use === undefined ? { id: DEFAULT_TEXT_MODEL, from: "default" } : { id: use, from: "chosen" };
213
+ if (use !== undefined)
214
+ return { id: use, from: "chosen" };
215
+ // The previous default's folder, not its files: a CLI may run it under its own pinned files.
216
+ const kept = !downloaded(DEFAULT_TEXT_MODEL, env) &&
217
+ existsSync(join(sharedModelsDirectory("text", env), PREVIOUS_DEFAULT_TEXT_MODEL));
218
+ return { id: kept ? PREVIOUS_DEFAULT_TEXT_MODEL : DEFAULT_TEXT_MODEL, from: "default" };
195
219
  };
196
220
  const mmarco = huggingFace("cross-encoder/mmarco-mMiniLMv2-L12-H384-v1", "1427fd652930e4ba29e8149678df786c240d8825");
197
221
  const bge = huggingFace("onnx-community/bge-reranker-v2-m3-ONNX", "6f5ff65298512715a1e669753bc754d2bc8f367b");
@@ -0,0 +1,149 @@
1
+ import * as v from "valibot";
2
+ /** What a person is in the owner's business: organizations, reporting lines, deals and projects, with standing. */
3
+ export declare const personBusiness: v.StrictObjectSchema<{
4
+ readonly organizations: v.StrictObjectSchema<{
5
+ readonly items: v.ArraySchema<v.StrictObjectSchema<{
6
+ readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
7
+ readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
8
+ readonly roles: v.ArraySchema<v.StrictObjectSchema<{
9
+ /** `link:<id>`; absent for a proposal. */
10
+ readonly link: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
11
+ /** A `relationship` proposal waiting for the owner: its id, with `standing: proposed`. */
12
+ readonly proposal: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
13
+ readonly kind: v.PicklistSchema<("customer-of" | "member-of" | "partner-of" | "related-to" | "reports-to")[], undefined>;
14
+ readonly role: v.NullableSchema<v.StringSchema<undefined>, undefined>;
15
+ /** `reported`: a CRM account says so and nobody confirmed it; `ended`: it no longer holds. */
16
+ readonly standing: v.PicklistSchema<readonly ["confirmed", "reported", "proposed", "ended"], undefined>;
17
+ /** The source account that reported it, `<provider>:<account>`. */
18
+ readonly account: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
19
+ /** A job title the source gave; never a role. */
20
+ readonly position: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
21
+ /** How a source made it when it stated none, such as `department-head`. */
22
+ readonly derived: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
23
+ readonly starts_at: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
24
+ readonly ends_at: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
25
+ }, undefined>, undefined>;
26
+ readonly categories: v.ArraySchema<v.PicklistSchema<readonly ["client", "supplier", "partner", "employer"], undefined>, undefined>;
27
+ }, undefined>, undefined>;
28
+ readonly total: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
29
+ readonly has_more: v.BooleanSchema<undefined>;
30
+ readonly next: v.NullableSchema<v.StringSchema<undefined>, undefined>;
31
+ }, undefined>;
32
+ readonly reports_to: v.StrictObjectSchema<{
33
+ readonly items: v.ArraySchema<v.StrictObjectSchema<{
34
+ readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
35
+ readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
36
+ readonly roles: v.ArraySchema<v.StrictObjectSchema<{
37
+ /** `link:<id>`; absent for a proposal. */
38
+ readonly link: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
39
+ /** A `relationship` proposal waiting for the owner: its id, with `standing: proposed`. */
40
+ readonly proposal: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
41
+ readonly kind: v.PicklistSchema<("customer-of" | "member-of" | "partner-of" | "related-to" | "reports-to")[], undefined>;
42
+ readonly role: v.NullableSchema<v.StringSchema<undefined>, undefined>;
43
+ /** `reported`: a CRM account says so and nobody confirmed it; `ended`: it no longer holds. */
44
+ readonly standing: v.PicklistSchema<readonly ["confirmed", "reported", "proposed", "ended"], undefined>;
45
+ /** The source account that reported it, `<provider>:<account>`. */
46
+ readonly account: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
47
+ /** A job title the source gave; never a role. */
48
+ readonly position: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
49
+ /** How a source made it when it stated none, such as `department-head`. */
50
+ readonly derived: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
51
+ readonly starts_at: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
52
+ readonly ends_at: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
53
+ }, undefined>, undefined>;
54
+ }, undefined>, undefined>;
55
+ readonly total: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
56
+ readonly has_more: v.BooleanSchema<undefined>;
57
+ readonly next: v.NullableSchema<v.StringSchema<undefined>, undefined>;
58
+ }, undefined>;
59
+ readonly direct_reports: v.StrictObjectSchema<{
60
+ readonly items: v.ArraySchema<v.StrictObjectSchema<{
61
+ readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
62
+ readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
63
+ readonly roles: v.ArraySchema<v.StrictObjectSchema<{
64
+ /** `link:<id>`; absent for a proposal. */
65
+ readonly link: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
66
+ /** A `relationship` proposal waiting for the owner: its id, with `standing: proposed`. */
67
+ readonly proposal: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
68
+ readonly kind: v.PicklistSchema<("customer-of" | "member-of" | "partner-of" | "related-to" | "reports-to")[], undefined>;
69
+ readonly role: v.NullableSchema<v.StringSchema<undefined>, undefined>;
70
+ /** `reported`: a CRM account says so and nobody confirmed it; `ended`: it no longer holds. */
71
+ readonly standing: v.PicklistSchema<readonly ["confirmed", "reported", "proposed", "ended"], undefined>;
72
+ /** The source account that reported it, `<provider>:<account>`. */
73
+ readonly account: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
74
+ /** A job title the source gave; never a role. */
75
+ readonly position: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
76
+ /** How a source made it when it stated none, such as `department-head`. */
77
+ readonly derived: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
78
+ readonly starts_at: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
79
+ readonly ends_at: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
80
+ }, undefined>, undefined>;
81
+ }, undefined>, undefined>;
82
+ readonly total: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
83
+ readonly has_more: v.BooleanSchema<undefined>;
84
+ readonly next: v.NullableSchema<v.StringSchema<undefined>, undefined>;
85
+ }, undefined>;
86
+ readonly deals: v.StrictObjectSchema<{
87
+ readonly items: v.ArraySchema<v.StrictObjectSchema<{
88
+ readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
89
+ readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
90
+ readonly roles: v.ArraySchema<v.StrictObjectSchema<{
91
+ /** `link:<id>`; absent for a proposal. */
92
+ readonly link: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
93
+ /** A `relationship` proposal waiting for the owner: its id, with `standing: proposed`. */
94
+ readonly proposal: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
95
+ readonly kind: v.PicklistSchema<("customer-of" | "member-of" | "partner-of" | "related-to" | "reports-to")[], undefined>;
96
+ readonly role: v.NullableSchema<v.StringSchema<undefined>, undefined>;
97
+ /** `reported`: a CRM account says so and nobody confirmed it; `ended`: it no longer holds. */
98
+ readonly standing: v.PicklistSchema<readonly ["confirmed", "reported", "proposed", "ended"], undefined>;
99
+ /** The source account that reported it, `<provider>:<account>`. */
100
+ readonly account: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
101
+ /** A job title the source gave; never a role. */
102
+ readonly position: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
103
+ /** How a source made it when it stated none, such as `department-head`. */
104
+ readonly derived: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
105
+ readonly starts_at: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
106
+ readonly ends_at: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
107
+ }, undefined>, undefined>;
108
+ }, undefined>, undefined>;
109
+ readonly total: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
110
+ readonly has_more: v.BooleanSchema<undefined>;
111
+ readonly next: v.NullableSchema<v.StringSchema<undefined>, undefined>;
112
+ }, undefined>;
113
+ readonly projects: v.StrictObjectSchema<{
114
+ readonly items: v.ArraySchema<v.StrictObjectSchema<{
115
+ readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
116
+ readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
117
+ readonly roles: v.ArraySchema<v.StrictObjectSchema<{
118
+ /** `link:<id>`; absent for a proposal. */
119
+ readonly link: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
120
+ /** A `relationship` proposal waiting for the owner: its id, with `standing: proposed`. */
121
+ readonly proposal: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
122
+ readonly kind: v.PicklistSchema<("customer-of" | "member-of" | "partner-of" | "related-to" | "reports-to")[], undefined>;
123
+ readonly role: v.NullableSchema<v.StringSchema<undefined>, undefined>;
124
+ /** `reported`: a CRM account says so and nobody confirmed it; `ended`: it no longer holds. */
125
+ readonly standing: v.PicklistSchema<readonly ["confirmed", "reported", "proposed", "ended"], undefined>;
126
+ /** The source account that reported it, `<provider>:<account>`. */
127
+ readonly account: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
128
+ /** A job title the source gave; never a role. */
129
+ readonly position: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
130
+ /** How a source made it when it stated none, such as `department-head`. */
131
+ readonly derived: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
132
+ readonly starts_at: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
133
+ readonly ends_at: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
134
+ }, undefined>, undefined>;
135
+ }, undefined>, undefined>;
136
+ readonly total: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
137
+ readonly has_more: v.BooleanSchema<undefined>;
138
+ readonly next: v.NullableSchema<v.StringSchema<undefined>, undefined>;
139
+ }, undefined>;
140
+ readonly categories: v.ArraySchema<v.PicklistSchema<readonly ["client", "supplier", "partner", "employer"], undefined>, undefined>;
141
+ }, undefined>;
142
+ /** Any canonical person's context: every account in scope read, their business, and what was not read. */
143
+ export declare const personContext: v.GenericSchema;
144
+ /** One organization: people, customers, suppliers, partners, projects, open deals, money and how much is said. */
145
+ export declare const organizationContext: v.GenericSchema;
146
+ /** One deal or lead: the row, its stages, client, people, project, money and what its people said in its time. */
147
+ export declare const dealContext: v.GenericSchema;
148
+ /** A deal context's compact form, for a model's context. */
149
+ export declare const dealBrief: v.GenericSchema;