@wirecat/cli-core 0.618.0 → 0.620.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (335) hide show
  1. package/CHANGELOG.md +453 -1
  2. package/README.md +1 -1
  3. package/THIRD_PARTY_NOTICES +3 -0
  4. package/dist/background/deliver.d.ts +5 -2
  5. package/dist/background/deliver.js +30 -12
  6. package/dist/background/report/render.d.ts +3 -1
  7. package/dist/background/report/render.js +3 -1
  8. package/dist/calendar/cli/answers.d.ts +1 -0
  9. package/dist/calendar/cli/answers.js +6 -1
  10. package/dist/calendar/cli/index.js +2 -14
  11. package/dist/calendar/cli/people-link.d.ts +3 -0
  12. package/dist/calendar/cli/people-link.js +23 -0
  13. package/dist/calendar/cli/search-all.d.ts +1 -1
  14. package/dist/calendar/cli/search-all.js +9 -10
  15. package/dist/calendar/index.d.ts +1 -1
  16. package/dist/calendar/index.js +1 -1
  17. package/dist/calendar/mcp/index.d.ts +12 -12
  18. package/dist/calendar/prepare.js +1 -0
  19. package/dist/cli/base-stages-command.d.ts +22 -0
  20. package/dist/cli/base-stages-command.js +174 -0
  21. package/dist/cli/bot/buttons.d.ts +3 -0
  22. package/dist/cli/bot/buttons.js +24 -0
  23. package/dist/cli/bot/messages.js +14 -1
  24. package/dist/cli/bot/port.d.ts +8 -0
  25. package/dist/cli/command-runs.d.ts +2 -0
  26. package/dist/cli/command-runs.js +3 -1
  27. package/dist/cli/config-command.js +6 -1
  28. package/dist/cli/context.js +1 -0
  29. package/dist/cli/contract-templates.js +31 -2
  30. package/dist/cli/group-lock.d.ts +42 -0
  31. package/dist/cli/group-lock.js +130 -0
  32. package/dist/cli/index.d.ts +7 -2
  33. package/dist/cli/index.js +7 -2
  34. package/dist/cli/messenger/backfill-command.js +27 -15
  35. package/dist/cli/messenger/contacts-command.js +12 -4
  36. package/dist/cli/messenger/context.js +1 -0
  37. package/dist/cli/messenger/conversations-command.js +2 -1
  38. package/dist/cli/messenger/doctor-command.js +3 -1
  39. package/dist/cli/messenger/message-items.js +1 -1
  40. package/dist/cli/messenger/models-command.js +1 -1
  41. package/dist/cli/messenger/search-answers.d.ts +5 -5
  42. package/dist/cli/messenger/search-answers.js +9 -20
  43. package/dist/cli/messenger/search-command.d.ts +2 -2
  44. package/dist/cli/messenger/search-command.js +8 -18
  45. package/dist/cli/messenger/store-maintenance-command.d.ts +22 -2
  46. package/dist/cli/messenger/store-maintenance-command.js +9 -4
  47. package/dist/cli/model-catalogue-command.d.ts +3 -1
  48. package/dist/cli/model-catalogue-command.js +48 -2
  49. package/dist/cli/profile.d.ts +8 -0
  50. package/dist/cli/profile.js +25 -0
  51. package/dist/cli/program.js +2 -0
  52. package/dist/cli/runs/search-query.d.ts +1 -1
  53. package/dist/cli/runs/search-query.js +4 -0
  54. package/dist/cli/runs/search.d.ts +5 -1
  55. package/dist/cli/runs/search.js +12 -1
  56. package/dist/cli/search-harder-consents-command.d.ts +18 -0
  57. package/dist/cli/search-harder-consents-command.js +83 -0
  58. package/dist/cli/search-left-out.d.ts +6 -1
  59. package/dist/cli/search-left-out.js +9 -4
  60. package/dist/cli/settings.d.ts +8 -0
  61. package/dist/cli/settings.js +17 -2
  62. package/dist/cli/shared-command-exports.d.ts +16 -0
  63. package/dist/cli/steps.js +0 -6
  64. package/dist/cli/store-recover.d.ts +3 -3
  65. package/dist/cli/store-recover.js +26 -26
  66. package/dist/cli/store-settings.d.ts +2 -0
  67. package/dist/cli/store-settings.js +37 -9
  68. package/dist/cli/templates-command.js +4 -4
  69. package/dist/crm/cli/index.js +40 -8
  70. package/dist/crm/cli/search-all.js +7 -6
  71. package/dist/crm/group-hint.d.ts +8 -0
  72. package/dist/crm/group-hint.js +13 -0
  73. package/dist/crm/source.d.ts +12 -1
  74. package/dist/crm/sync.d.ts +31 -2
  75. package/dist/crm/sync.js +110 -3
  76. package/dist/crm/testing/acme-scenario.d.ts +40 -0
  77. package/dist/crm/testing/acme-scenario.js +170 -0
  78. package/dist/crm/testing/index.d.ts +1 -0
  79. package/dist/crm/testing/index.js +1 -0
  80. package/dist/crm/testing/source-contract.js +12 -0
  81. package/dist/crm/testing/source.d.ts +2 -0
  82. package/dist/crm/testing/source.js +1 -0
  83. package/dist/domain/addresses.d.ts +13 -0
  84. package/dist/domain/addresses.js +63 -0
  85. package/dist/domain/categories.d.ts +3 -0
  86. package/dist/domain/categories.js +2 -0
  87. package/dist/domain/crm.d.ts +23 -0
  88. package/dist/domain/crm.js +7 -0
  89. package/dist/domain/mentions.d.ts +2 -12
  90. package/dist/domain/mentions.js +2 -19
  91. package/dist/domain/models.d.ts +2 -0
  92. package/dist/domain/orders.d.ts +8 -1
  93. package/dist/domain/orders.js +6 -2
  94. package/dist/domain/phones.d.ts +26 -0
  95. package/dist/domain/phones.js +48 -0
  96. package/dist/domain/record-types.d.ts +1 -1
  97. package/dist/domain/record-types.js +1 -0
  98. package/dist/domain/records.d.ts +5 -0
  99. package/dist/domain/ref-summaries.d.ts +39 -0
  100. package/dist/domain/ref-summaries.js +51 -3
  101. package/dist/domain/relations.d.ts +12 -2
  102. package/dist/domain/relations.js +14 -3
  103. package/dist/domain/vcard.d.ts +2 -2
  104. package/dist/domain/vcard.js +4 -10
  105. package/dist/embeddings/models.d.ts +11 -3
  106. package/dist/embeddings/models.js +28 -4
  107. package/dist/entities/business-context.d.ts +149 -0
  108. package/dist/entities/business-context.js +192 -0
  109. package/dist/entities/contact-activity.d.ts +2 -0
  110. package/dist/entities/contact-activity.js +7 -1
  111. package/dist/entities/contact-context.d.ts +160 -0
  112. package/dist/entities/contact-context.js +6 -0
  113. package/dist/entities/deal.d.ts +10 -0
  114. package/dist/entities/deal.js +2 -0
  115. package/dist/entities/hit.d.ts +9 -2
  116. package/dist/entities/hit.js +6 -2
  117. package/dist/entities/index.d.ts +32 -4
  118. package/dist/entities/index.js +5 -0
  119. package/dist/entities/mention.d.ts +4 -3
  120. package/dist/entities/mention.js +2 -1
  121. package/dist/entities/message-transfer.d.ts +4 -2
  122. package/dist/entities/message-transfer.js +2 -2
  123. package/dist/entities/model.d.ts +2 -2
  124. package/dist/entities/model.js +1 -1
  125. package/dist/entities/relationship.d.ts +4 -0
  126. package/dist/entities/relationship.js +4 -0
  127. package/dist/errors/reasons.js +39 -4
  128. package/dist/fetch/page.js +2 -1
  129. package/dist/index.d.ts +3 -2
  130. package/dist/index.js +3 -2
  131. package/dist/meetings/context-store.d.ts +2 -0
  132. package/dist/meetings/findings-rules.d.ts +4 -0
  133. package/dist/meetings/findings-rules.js +5 -2
  134. package/dist/meetings/hit-query.d.ts +1 -1
  135. package/dist/meetings/hit-query.js +2 -2
  136. package/dist/meetings/index.d.ts +1 -0
  137. package/dist/meetings/index.js +1 -0
  138. package/dist/meetings/result-items.d.ts +1 -0
  139. package/dist/meetings/result-items.js +1 -0
  140. package/dist/meetings/store.d.ts +4 -0
  141. package/dist/meetings/store.js +2 -1
  142. package/dist/models/anthropic.js +5 -0
  143. package/dist/models/index.js +22 -5
  144. package/dist/runs/events.d.ts +11 -1
  145. package/dist/runs/events.js +3 -1
  146. package/dist/runs/log-attributes.js +4 -0
  147. package/dist/runs/log-events.js +2 -0
  148. package/dist/runs/recording.d.ts +3 -0
  149. package/dist/runs/recording.js +36 -12
  150. package/dist/runs/run.d.ts +12 -3
  151. package/dist/runs/run.js +32 -13
  152. package/dist/search/account-list.d.ts +6 -0
  153. package/dist/search/account-list.js +9 -3
  154. package/dist/search/groups.d.ts +68 -0
  155. package/dist/search/groups.js +172 -0
  156. package/dist/search/question-period.d.ts +10 -0
  157. package/dist/search/question-period.js +133 -0
  158. package/dist/sends/buttons.d.ts +2 -0
  159. package/dist/sends/buttons.js +6 -1
  160. package/dist/services/account-groups.d.ts +28 -0
  161. package/dist/services/account-groups.js +89 -0
  162. package/dist/services/archive.d.ts +7 -1
  163. package/dist/services/archive.js +19 -3
  164. package/dist/services/business-context.d.ts +113 -0
  165. package/dist/services/business-context.js +156 -0
  166. package/dist/services/communications.d.ts +50 -0
  167. package/dist/services/communications.js +140 -0
  168. package/dist/services/deal-context.d.ts +90 -0
  169. package/dist/services/deal-context.js +131 -0
  170. package/dist/services/deps.d.ts +2 -0
  171. package/dist/services/enrichment.d.ts +12 -2
  172. package/dist/services/enrichment.js +47 -6
  173. package/dist/services/events-search.js +2 -1
  174. package/dist/services/group-guard.d.ts +28 -0
  175. package/dist/services/group-guard.js +131 -0
  176. package/dist/services/index.d.ts +19 -4
  177. package/dist/services/index.js +12 -3
  178. package/dist/services/ingest.d.ts +12 -0
  179. package/dist/services/ingest.js +4 -0
  180. package/dist/services/meaning-model.d.ts +7 -0
  181. package/dist/services/meaning-model.js +20 -0
  182. package/dist/services/meeting-context.d.ts +6 -1
  183. package/dist/services/meeting-context.js +12 -5
  184. package/dist/services/message-resolution.js +2 -3
  185. package/dist/services/messages-meaning.js +4 -5
  186. package/dist/services/messages-search.d.ts +5 -1
  187. package/dist/services/messages-search.js +1 -1
  188. package/dist/services/messages.d.ts +1 -4
  189. package/dist/services/messages.js +0 -2
  190. package/dist/services/metadata.d.ts +1 -1
  191. package/dist/services/model-downloads.d.ts +1 -1
  192. package/dist/services/model-downloads.js +6 -4
  193. package/dist/services/money-context.d.ts +73 -0
  194. package/dist/services/money-context.js +77 -0
  195. package/dist/services/notes-search.d.ts +4 -1
  196. package/dist/services/notes-search.js +19 -7
  197. package/dist/services/organization-context.d.ts +80 -0
  198. package/dist/services/organization-context.js +154 -0
  199. package/dist/services/people.d.ts +22 -6
  200. package/dist/services/people.js +38 -8
  201. package/dist/services/person-business.d.ts +43 -0
  202. package/dist/services/person-business.js +67 -0
  203. package/dist/services/person-context.d.ts +11 -1
  204. package/dist/services/person-context.js +25 -10
  205. package/dist/services/person-preparation.d.ts +5 -1
  206. package/dist/services/person-preparation.js +10 -3
  207. package/dist/services/person-timeline.d.ts +6 -1
  208. package/dist/services/person-timeline.js +10 -2
  209. package/dist/services/proposals/kinds/identity-link.d.ts +4 -0
  210. package/dist/services/proposals/kinds/identity-link.js +48 -0
  211. package/dist/services/proposals/kinds/orders.js +1 -1
  212. package/dist/services/proposals/registry.js +2 -0
  213. package/dist/services/search-all-deprecated.d.ts +40 -0
  214. package/dist/services/search-all-deprecated.js +10 -0
  215. package/dist/services/search-all-meetings.d.ts +50 -52
  216. package/dist/services/search-all-meetings.js +265 -272
  217. package/dist/services/search-all.d.ts +34 -6
  218. package/dist/services/search-all.js +118 -24
  219. package/dist/services/search-harder.d.ts +64 -0
  220. package/dist/services/search-harder.js +194 -0
  221. package/dist/services/search-kind.d.ts +12 -5
  222. package/dist/services/search-kind.js +49 -10
  223. package/dist/services/text-model-choice.js +1 -1
  224. package/dist/store/accounts.d.ts +18 -0
  225. package/dist/store/accounts.js +18 -3
  226. package/dist/store/chats.d.ts +3 -1
  227. package/dist/store/chats.js +6 -0
  228. package/dist/store/damage.d.ts +43 -10
  229. package/dist/store/damage.js +119 -36
  230. package/dist/store/decisions.js +3 -1
  231. package/dist/store/evidence-findings.d.ts +14 -0
  232. package/dist/store/evidence-findings.js +2 -0
  233. package/dist/store/exports.d.ts +2 -1
  234. package/dist/store/identity-links.d.ts +92 -0
  235. package/dist/store/identity-links.js +6 -0
  236. package/dist/store/index.d.ts +11 -5
  237. package/dist/store/index.js +5 -2
  238. package/dist/store/journal.d.ts +10 -0
  239. package/dist/store/journal.js +33 -0
  240. package/dist/store/marks.d.ts +19 -1
  241. package/dist/store/marks.js +23 -1
  242. package/dist/store/people.d.ts +28 -2
  243. package/dist/store/people.js +15 -1
  244. package/dist/store/sqlite/accounts.js +2 -0
  245. package/dist/store/sqlite/added-sources.d.ts +15 -3
  246. package/dist/store/sqlite/added-sources.js +26 -5
  247. package/dist/store/sqlite/base-stages.d.ts +122 -0
  248. package/dist/store/sqlite/base-stages.js +443 -0
  249. package/dist/store/sqlite/base-suggest.d.ts +13 -0
  250. package/dist/store/sqlite/base-suggest.js +62 -0
  251. package/dist/store/sqlite/business-contracts.js +10 -1
  252. package/dist/store/sqlite/chats.d.ts +2 -0
  253. package/dist/store/sqlite/chats.js +6 -0
  254. package/dist/store/sqlite/crm-settings.d.ts +12 -2
  255. package/dist/store/sqlite/crm-settings.js +56 -13
  256. package/dist/store/sqlite/crm.d.ts +13 -1
  257. package/dist/store/sqlite/crm.js +20 -4
  258. package/dist/store/sqlite/deals.d.ts +33 -0
  259. package/dist/store/sqlite/deals.js +42 -4
  260. package/dist/store/sqlite/decision-requests.js +7 -3
  261. package/dist/store/sqlite/email-index.js +8 -4
  262. package/dist/store/sqlite/evidence-findings.js +29 -5
  263. package/dist/store/sqlite/findings-core.js +4 -2
  264. package/dist/store/sqlite/identity-link-rows.d.ts +50 -0
  265. package/dist/store/sqlite/identity-link-rows.js +146 -0
  266. package/dist/store/sqlite/identity-proposals.d.ts +53 -0
  267. package/dist/store/sqlite/identity-proposals.js +234 -0
  268. package/dist/store/sqlite/involvements.d.ts +1 -1
  269. package/dist/store/sqlite/involvements.js +4 -2
  270. package/dist/store/sqlite/knowledge.js +2 -2
  271. package/dist/store/sqlite/link-kinds.d.ts +1 -0
  272. package/dist/store/sqlite/link-kinds.js +1 -0
  273. package/dist/store/sqlite/link-row.d.ts +6 -0
  274. package/dist/store/sqlite/link-row.js +35 -0
  275. package/dist/store/sqlite/link-source.d.ts +10 -0
  276. package/dist/store/sqlite/link-source.js +16 -0
  277. package/dist/store/sqlite/manifest.js +1 -0
  278. package/dist/store/sqlite/meeting-context-links.js +9 -6
  279. package/dist/store/sqlite/meeting-hit-query.d.ts +5 -0
  280. package/dist/store/sqlite/meeting-hit-query.js +33 -0
  281. package/dist/store/sqlite/meeting-hit-search.js +10 -8
  282. package/dist/store/sqlite/meetings.js +1 -1
  283. package/dist/store/sqlite/memories.js +9 -7
  284. package/dist/store/sqlite/mentions.d.ts +4 -1
  285. package/dist/store/sqlite/mentions.js +14 -9
  286. package/dist/store/sqlite/migrations.generated.js +8 -0
  287. package/dist/store/sqlite/notes.d.ts +8 -2
  288. package/dist/store/sqlite/notes.js +17 -34
  289. package/dist/store/sqlite/open-store.js +3 -0
  290. package/dist/store/sqlite/open.js +11 -2
  291. package/dist/store/sqlite/orders.d.ts +2 -0
  292. package/dist/store/sqlite/orders.js +9 -3
  293. package/dist/store/sqlite/organization-categories.d.ts +18 -0
  294. package/dist/store/sqlite/organization-categories.js +34 -0
  295. package/dist/store/sqlite/organizations.d.ts +5 -1
  296. package/dist/store/sqlite/organizations.js +14 -4
  297. package/dist/store/sqlite/person-links.d.ts +19 -4
  298. package/dist/store/sqlite/person-links.js +49 -11
  299. package/dist/store/sqlite/person-match-scan.d.ts +13 -0
  300. package/dist/store/sqlite/person-match-scan.js +251 -0
  301. package/dist/store/sqlite/person-matcher.d.ts +16 -0
  302. package/dist/store/sqlite/person-matcher.js +32 -0
  303. package/dist/store/sqlite/person-preparation.d.ts +7 -3
  304. package/dist/store/sqlite/person-preparation.js +20 -6
  305. package/dist/store/sqlite/proposed-actions.js +6 -0
  306. package/dist/store/sqlite/record-matching.d.ts +2 -8
  307. package/dist/store/sqlite/record-matching.js +8 -40
  308. package/dist/store/sqlite/record-projectors-phone.js +2 -1
  309. package/dist/store/sqlite/record-relationships.d.ts +52 -0
  310. package/dist/store/sqlite/record-relationships.js +243 -0
  311. package/dist/store/sqlite/record-run.d.ts +5 -0
  312. package/dist/store/sqlite/record-run.js +62 -2
  313. package/dist/store/sqlite/record-writes.d.ts +1 -1
  314. package/dist/store/sqlite/record-writes.js +4 -2
  315. package/dist/store/sqlite/records.js +27 -2
  316. package/dist/store/sqlite/ref-accounts.d.ts +13 -0
  317. package/dist/store/sqlite/ref-accounts.js +117 -0
  318. package/dist/store/sqlite/ref-summaries.js +5 -1
  319. package/dist/store/sqlite/relation-list.d.ts +4 -1
  320. package/dist/store/sqlite/relation-list.js +22 -4
  321. package/dist/store/sqlite/relation-proposals.d.ts +6 -0
  322. package/dist/store/sqlite/relation-proposals.js +3 -0
  323. package/dist/store/sqlite/relation-roles.js +12 -6
  324. package/dist/store/sqlite/reported-relations.d.ts +11 -1
  325. package/dist/store/sqlite/reported-relations.js +59 -18
  326. package/dist/store/sqlite/schema.d.ts +32 -0
  327. package/dist/store/sqlite/schema.js +3 -0
  328. package/dist/store/sqlite/transaction.js +11 -1
  329. package/dist/store/store.d.ts +3 -0
  330. package/dist/store/store.js +5 -0
  331. package/dist/store/write-events.d.ts +18 -0
  332. package/dist/store/write-events.js +88 -0
  333. package/package.json +3 -3
  334. package/parity.json +37 -16
  335. package/schemas/records-envelope.v1.schema.json +3 -0
@@ -53,13 +53,16 @@ export const validEvidence = (raw, rules) => {
53
53
  .map((item) => {
54
54
  if (!item || typeof item !== "object")
55
55
  return invalid("finding evidence is a reference and fingerprint");
56
- findingFields(item, ["reference", "fingerprint"], rules.singular);
56
+ findingFields(item, rules.quotes ? ["reference", "fingerprint", "quote"] : ["reference", "fingerprint"], rules.singular);
57
57
  if (typeof item.reference !== "string" || typeof item.fingerprint !== "string")
58
58
  return invalid("evidence requires a reference and fingerprint");
59
59
  const reference = rules.reference(item.reference);
60
60
  if (!/^[a-f0-9]{64}$/.test(item.fingerprint))
61
61
  return invalid(`finding evidence requires exact ${rules.cited} references and fingerprints`);
62
- return { reference, fingerprint: item.fingerprint };
62
+ // Absent, not empty: a finding without a quote keeps the fingerprint it had before quotes existed.
63
+ if (item.quote === undefined)
64
+ return { reference, fingerprint: item.fingerprint };
65
+ return { reference, fingerprint: item.fingerprint, quote: findingText(item.quote, rules.quotes ?? 0) };
63
66
  })
64
67
  .sort((a, b) => a.reference.localeCompare(b.reference));
65
68
  if (new Set(evidence.map((item) => item.reference)).size !== evidence.length)
@@ -11,7 +11,7 @@ export declare const MEETING_FIELD_NAMES: ReadonlySet<string>;
11
11
  * joined to the words with AND and given once, in the query or as an option. Text the language refuses is left as
12
12
  * typed, for the caller's own error or for a search by meaning.
13
13
  */
14
- export declare const liftMeetingFields: (query: string, request: MeetingHitSearchRequest, now?: number) => {
14
+ export declare const liftMeetingFields: (query: string, request: MeetingHitSearchRequest, now?: number, timezone?: string) => {
15
15
  query: string;
16
16
  request: MeetingHitSearchRequest;
17
17
  };
@@ -71,7 +71,7 @@ export const MEETING_FIELD_NAMES = new Set(MEETING_FIELDS.fields.map(({ name })
71
71
  * joined to the words with AND and given once, in the query or as an option. Text the language refuses is left as
72
72
  * typed, for the caller's own error or for a search by meaning.
73
73
  */
74
- export const liftMeetingFields = (query, request, now) => {
74
+ export const liftMeetingFields = (query, request, now, timezone) => {
75
75
  let ast;
76
76
  try {
77
77
  ast = validateQuery(parseLucene(query, { defaultField: "text", proximity: true, ...context }), MEETING_FIELDS, context);
@@ -103,7 +103,7 @@ export const liftMeetingFields = (query, request, now) => {
103
103
  if (node.field === "date") {
104
104
  once("since", "--since-time");
105
105
  once("until", "--until-time");
106
- const range = dateRange(node.value, node.operator === "range" ? (node.upper ?? "*") : node.value, node.lower_inclusive !== false, node.upper_inclusive !== false, timezoneOf(), node.span, now);
106
+ const range = dateRange(node.value, node.operator === "range" ? (node.upper ?? "*") : node.value, node.lower_inclusive !== false, node.upper_inclusive !== false, timezoneOf(timezone), node.span, now);
107
107
  if (range.lower !== undefined)
108
108
  next.since = range.lower + (range.lower_inclusive ? 0 : 1);
109
109
  if (range.upper !== undefined)
@@ -53,6 +53,7 @@ export { validateMeetingSeriesInventoryCursor } from "./series-inventory-validat
53
53
  export type { MeetingSource, SourceParticipant } from "./source.js";
54
54
  export { aggregateMeetingCounts, aggregateMeetingStats, MEETING_COUNTS_GROUPINGS, type MeetingCounts, type MeetingCountsGrouping, type MeetingCountsInput, type MeetingCountsMeeting, type MeetingCountsRow, type MeetingSpeakerStats, type MeetingStats, type MeetingStatsInput, type MeetingStatsRow, type MeetingStatsSelection, type MeetingStatsStore, type MeetingWeekStats, NO_SERIES, } from "./stats.js";
55
55
  export type { ChatInput, ContractCase, EventCandidateFilter, IdentityInput, MeetingDetails, MeetingFilter, MeetingHitSource, MeetingInput, MeetingSave, MeetingStore, NewRecord, ParticipantInput, SearchHit, TranscriptInput, TranscriptLanguageFill, TranscriptRowInput, } from "./store.js";
56
+ export { READ_BUDGET_EXCEEDED } from "./store.js";
56
57
  export { meetingTimestamp } from "./timestamp.js";
57
58
  export type { MeetingTranscriptReceiptStore, MeetingTranscriptStore, TranscriptAppend, TranscriptAppendReceipt, UnlinkedTranscriptInput, } from "./transcript-store.js";
58
59
  export { parseTranscriptText, TranscriptTextError, type TranscriptTextHeader } from "./transcript-text.js";
@@ -39,6 +39,7 @@ export { validateMeetingSeriesHistory, } from "./series-history.js";
39
39
  export { createMeetingSeriesInventoryReader } from "./series-inventory.js";
40
40
  export { validateMeetingSeriesInventoryCursor } from "./series-inventory-validation.js";
41
41
  export { aggregateMeetingCounts, aggregateMeetingStats, MEETING_COUNTS_GROUPINGS, NO_SERIES, } from "./stats.js";
42
+ export { READ_BUDGET_EXCEEDED } from "./store.js";
42
43
  export { meetingTimestamp } from "./timestamp.js";
43
44
  export { parseTranscriptText, TranscriptTextError } from "./transcript-text.js";
44
45
  export { transcribeMeeting, } from "./transcription.js";
@@ -51,6 +51,7 @@ export declare const MEETING_RESULT_ENTITIES: {
51
51
  readonly person_uid: v.StringSchema<undefined>;
52
52
  readonly previous_person_uid: v.NullableSchema<v.StringSchema<undefined>, undefined>;
53
53
  readonly changed: v.BooleanSchema<undefined>;
54
+ readonly proposal: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
54
55
  }, undefined>], undefined>, undefined>;
55
56
  }, undefined>;
56
57
  readonly meeting_transcription: v.UnionSchema<[v.StrictObjectSchema<{
@@ -41,6 +41,7 @@ const personResult = v.strictObject({
41
41
  person_uid: text,
42
42
  previous_person_uid: nullableText,
43
43
  changed: flag,
44
+ proposal: v.optional(text),
44
45
  });
45
46
  const meetingChange = v.strictObject({
46
47
  scope,
@@ -79,6 +79,8 @@ export interface MeetingHitSource {
79
79
  /** A stored source-document permalink, never a meeting join or signed download URL. */
80
80
  url: string | null;
81
81
  }
82
+ /** `searchHits`' refusal of a page whose stored text passes `maxReadBytes`; a reader may ask for fewer rows. */
83
+ export declare const READ_BUDGET_EXCEEDED = "Meeting search exceeds its stored text byte budget";
82
84
  export interface SearchHit {
83
85
  source?: MeetingHitSource;
84
86
  /** A retained cue reference for transcript hits, or the parent meeting for other sources. */
@@ -102,6 +104,8 @@ export interface SearchHit {
102
104
  from: string;
103
105
  to: string[];
104
106
  }[];
107
+ /** The words of `text` the query's positive terms matched, as the text spells them. */
108
+ matchedWords?: string[];
105
109
  }
106
110
  export interface ContractCase {
107
111
  name: string;
@@ -1 +1,2 @@
1
- export {};
1
+ /** `searchHits`' refusal of a page whose stored text passes `maxReadBytes`; a reader may ask for fewer rows. */
2
+ export const READ_BUDGET_EXCEEDED = "Meeting search exceeds its stored text byte budget";
@@ -5,6 +5,11 @@ import { messagesFor, systemFor } from "./types.js";
5
5
  // API version 2026-10-21 refuses temperature, top_p and top_k on every model.
6
6
  const options = v.strictObject({
7
7
  stop_sequences: v.optional(v.array(v.string())),
8
+ thinking: v.optional(v.strictObject({ type: v.picklist(["disabled", "adaptive"]) })),
9
+ output_config: v.optional(v.strictObject({
10
+ effort: v.optional(v.picklist(["low", "medium", "high"])),
11
+ format: v.optional(v.strictObject({ type: v.literal("json_schema"), schema: v.record(v.string(), v.unknown()) })),
12
+ })),
8
13
  });
9
14
  export const anthropic = {
10
15
  images: true,
@@ -36,14 +36,25 @@ export const modelGateway = (deps) => ({
36
36
  throw new CliError("cancelled", "model request cancelled");
37
37
  const fetcher = deps.fetch ?? fetch;
38
38
  let limited = false;
39
+ let unreachable = false;
40
+ let refused = false;
39
41
  const cancellable = async (input, init) => {
40
42
  const signal = init?.signal ?? (input instanceof Request ? input.signal : undefined);
41
- const response = await fetcher(input, {
42
- ...init,
43
- signal: deps.signal ? AbortSignal.any([deps.signal, ...(signal ? [signal] : [])]) : signal,
44
- });
43
+ let response;
44
+ try {
45
+ response = await fetcher(input, {
46
+ ...init,
47
+ signal: deps.signal ? AbortSignal.any([deps.signal, ...(signal ? [signal] : [])]) : signal,
48
+ });
49
+ }
50
+ catch (error) {
51
+ unreachable = true;
52
+ throw error;
53
+ }
45
54
  if (response.status === 429)
46
55
  limited = true;
56
+ if (response.status === 401 || response.status === 403)
57
+ refused = true;
47
58
  return response;
48
59
  };
49
60
  try {
@@ -57,7 +68,13 @@ export const modelGateway = (deps) => ({
57
68
  catch {
58
69
  if (limited)
59
70
  throw new CliError("rate_limited", `${request.purpose} provider rate limit reached; no result was stored`);
60
- throw new CliError("invalid_response", `${request.purpose} provider failed or returned an incomplete response; no result was stored`);
71
+ // The message stays one for every failure; the reason tells a refused key and a network failure apart.
72
+ const reason = refused
73
+ ? "model.key-rejected"
74
+ : unreachable && !deps.signal?.aborted
75
+ ? "model.unreachable"
76
+ : undefined;
77
+ throw new CliError("invalid_response", `${request.purpose} provider failed or returned an incomplete response; no result was stored`, reason === undefined ? undefined : { reason });
61
78
  }
62
79
  },
63
80
  });
@@ -63,7 +63,17 @@ export interface CacheEvent {
63
63
  /** How old the kept answer was. */
64
64
  ageMs?: number;
65
65
  }
66
- export type DiagnosticEvent = RequestEvent | CacheEvent | WarningEvent;
66
+ /** Rows one committed write transaction changed in one table: a count, never a row. */
67
+ export interface StoreEvent {
68
+ event: "store";
69
+ /** Always `store.write`; typed wide so an object spread into a request event still narrows by `event`. */
70
+ operation: string;
71
+ kind: "store";
72
+ table: string;
73
+ op: "insert" | "update" | "delete";
74
+ n: number;
75
+ }
76
+ export type DiagnosticEvent = RequestEvent | CacheEvent | WarningEvent | StoreEvent;
67
77
  export type EventSink = (event: DiagnosticEvent) => void;
68
78
  /** A sentence for a person, and the warning event it stands for when there is one: a log record keeps only the event. */
69
79
  export type Warn = (message: string, warning?: WarningEvent) => void;
@@ -9,6 +9,8 @@ export const providerErrorKey = (value) => typeof value === "string" && /^[A-Za-
9
9
  * ```
10
10
  */
11
11
  export const renderEvent = (event) => {
12
+ if (event.event === "store")
13
+ return `${MARK.store} ${event.operation.padEnd(16)} ${event.table} ${event.op} ${event.n}`;
12
14
  if (event.event === "warning") {
13
15
  const counts = Object.entries(event.counts ?? {}).map(([field, count]) => `${count} ${field}`);
14
16
  return [`${MARK.warning} ${(event.operation ?? "").padEnd(16)} ${event.code}`, ...counts, event.detail]
@@ -53,6 +55,6 @@ export const renderEvent = (event) => {
53
55
  }
54
56
  return `${MARK[event.event]} ${event.operation.padEnd(16)} ${parts.join(" ")}`.trimEnd();
55
57
  };
56
- const MARK = { request: "→", response: "←", cache: "•", warning: "!" };
58
+ const MARK = { request: "→", response: "←", cache: "•", warning: "!", store: "+" };
57
59
  const age = (ms) => (ms < 1000 ? `${ms}ms` : `${Math.round(ms / 1000)}s`);
58
60
  const size = (bytes) => (bytes < 1000 ? `${bytes} B` : `${(bytes / 1000).toFixed(1)} kB`);
@@ -24,6 +24,10 @@ const diagnostic = {
24
24
  detail: true,
25
25
  reason: true,
26
26
  ageMs: true,
27
+ kind: true,
28
+ table: true,
29
+ op: true,
30
+ n: true,
27
31
  };
28
32
  const send = {
29
33
  profile: true,
@@ -9,6 +9,7 @@ export const CORE_LOG_EVENTS = defineLogEvents([
9
9
  meaning: "a read was answered from what was kept, without asking the messenger",
10
10
  keys: ["operation", "reason"],
11
11
  },
12
+ { id: "store.write", meaning: "a committed write changed rows of one store table", keys: ["table", "op", "n"] },
12
13
  { id: "command.crashed", meaning: "a command failed on a bug; where, never what", keys: ["error_class", "frames"] },
13
14
  {
14
15
  id: "events.dropped",
@@ -32,4 +33,5 @@ export const DIAGNOSTIC_LOG_EVENTS = {
32
33
  response: "provider.response",
33
34
  warning: "client.warning",
34
35
  cache: "cache.answered",
36
+ store: "store.write",
35
37
  };
@@ -19,6 +19,7 @@ export interface RecordingOptions {
19
19
  runsDir?: string;
20
20
  keepDays?: number;
21
21
  keepSuccessDays?: number;
22
+ keepStoreDays?: number;
22
23
  maxBytes?: number;
23
24
  now?: () => Date;
24
25
  /** The caller's trace; otherwise the enclosing run's, otherwise `TRACEPARENT` from `env`. */
@@ -56,6 +57,8 @@ export declare const wasSettled: (error: unknown) => boolean;
56
57
  /** A run of a loop that never ends must not fill the disk: past these, events are counted by operation instead. */
57
58
  export declare const EVENTS_AT_MOST = 2000;
58
59
  export declare const EVENT_BYTES_AT_MOST: number;
60
+ /** Past this many, store events are summed by table and change and written as one each when the run ends. */
61
+ export declare const STORE_EVENTS_AT_MOST = 100;
59
62
  /**
60
63
  * Where a crash happened, not what it said: the class and up to ten frames as `function file:line`,
61
64
  * paths cut to the package's own (`framesOf`). **Never `message`** in an event — it can hold whatever the
@@ -3,7 +3,7 @@ import { isCliFailure, storeDamaged } from "../errors/failures.js";
3
3
  import { markStoreDamaged } from "../store/marks.js";
4
4
  import { storePath } from "../store/path.js";
5
5
  import { endpointTemplate, errorDetailOf, framesOf } from "./error-detail.js";
6
- import { providerErrorKey, renderEvent } from "./events.js";
6
+ import { providerErrorKey, renderEvent, } from "./events.js";
7
7
  import { DIAGNOSTIC_LOG_EVENTS } from "./log-events.js";
8
8
  import { logAttributes } from "./log-keys.js";
9
9
  import { newRunId, runsDirFor, startRun } from "./run.js";
@@ -62,6 +62,7 @@ export const startRecording = (options) => {
62
62
  },
63
63
  ...(options.keepDays === undefined ? {} : { keepDays: options.keepDays }),
64
64
  ...(options.keepSuccessDays === undefined ? {} : { keepSuccessDays: options.keepSuccessDays }),
65
+ ...(options.keepStoreDays === undefined ? {} : { keepStoreDays: options.keepStoreDays }),
65
66
  ...(options.maxBytes === undefined ? {} : { maxBytes: options.maxBytes }),
66
67
  now,
67
68
  ...extra,
@@ -71,6 +72,7 @@ export const startRecording = (options) => {
71
72
  const held = !run && options.keepFailed ? [] : undefined;
72
73
  const counted = { wire: 0, operation: 0 };
73
74
  let refused;
75
+ let wroteStore = false;
74
76
  const cap = capped();
75
77
  const requests = () => (counted.wire > 0 ? counted.wire : counted.operation);
76
78
  const events = (event) => {
@@ -78,6 +80,8 @@ export const startRecording = (options) => {
78
80
  counted[event.level === "wire" ? "wire" : "operation"] += 1;
79
81
  if (event.event === "response" && event.outcome === "error")
80
82
  refused = event;
83
+ if (event.event === "store")
84
+ wroteStore = true;
81
85
  if (options.trace)
82
86
  streams.diagnostic(options.format === "pretty" ? renderEvent(event) : JSON.stringify(logAttributes(event)));
83
87
  if (run)
@@ -99,13 +103,14 @@ export const startRecording = (options) => {
99
103
  events,
100
104
  succeed: async (answer) => {
101
105
  const partial = partialOutcome(answer);
102
- const kept = run ?? (partial && held ? keep(open({ startedAt })) : undefined);
106
+ const kept = run ?? ((partial || wroteStore) && held ? keep(open({ startedAt })) : undefined);
103
107
  if (kept)
104
108
  cap.close(kept);
105
109
  await kept?.finish(partial ? "partial" : "success", {
106
110
  requests: requests(),
107
111
  ...cap.dropped(),
108
112
  ...(partial ? { partial } : {}),
113
+ ...(!run && !partial && wroteStore ? { keptBecauseStore: true } : {}),
109
114
  });
110
115
  },
111
116
  fail: async (thrown) => {
@@ -142,26 +147,45 @@ const HELD_AT_MOST = 500;
142
147
  /** A run of a loop that never ends must not fill the disk: past these, events are counted by operation instead. */
143
148
  export const EVENTS_AT_MOST = 2000;
144
149
  export const EVENT_BYTES_AT_MOST = 1024 * 1024;
150
+ /** Past this many, store events are summed by table and change and written as one each when the run ends. */
151
+ export const STORE_EVENTS_AT_MOST = 100;
145
152
  const capped = () => {
146
153
  let lines = 0;
147
154
  let bytes = 0;
148
155
  let dropped = 0;
156
+ let stores = 0;
149
157
  const byOperation = {};
158
+ const summed = new Map();
159
+ const write = (run, event) => {
160
+ // The record's own envelope (time, ids of the run, resource) is about 200 bytes on top of its attributes.
161
+ const size = JSON.stringify(logAttributes(event)).length + 200;
162
+ if (lines >= EVENTS_AT_MOST || bytes + size > EVENT_BYTES_AT_MOST) {
163
+ dropped += 1;
164
+ const operation = "operation" in event && event.operation ? event.operation : event.event;
165
+ byOperation[operation] = (byOperation[operation] ?? 0) + 1;
166
+ return;
167
+ }
168
+ lines += 1;
169
+ bytes += size;
170
+ logEvent(run, event);
171
+ };
150
172
  return {
151
173
  log: (run, event) => {
152
- // The record's own envelope (time, ids of the run, resource) is about 200 bytes on top of its attributes.
153
- const size = JSON.stringify(logAttributes(event)).length + 200;
154
- if (lines >= EVENTS_AT_MOST || bytes + size > EVENT_BYTES_AT_MOST) {
155
- dropped += 1;
156
- const operation = "operation" in event && event.operation ? event.operation : event.event;
157
- byOperation[operation] = (byOperation[operation] ?? 0) + 1;
174
+ if (event.event === "store" && ++stores > STORE_EVENTS_AT_MOST) {
175
+ const key = `${event.table} ${event.op}`;
176
+ const sum = summed.get(key);
177
+ if (sum)
178
+ sum.n += event.n;
179
+ else
180
+ summed.set(key, { ...event });
158
181
  return;
159
182
  }
160
- lines += 1;
161
- bytes += size;
162
- logEvent(run, event);
183
+ write(run, event);
163
184
  },
164
185
  close: (run) => {
186
+ for (const sum of summed.values())
187
+ write(run, sum);
188
+ summed.clear();
165
189
  if (dropped > 0)
166
190
  run.logger.warn({ event: "events.dropped", dropped, counts: byOperation });
167
191
  },
@@ -178,7 +202,7 @@ const logEvent = (run, event) => {
178
202
  };
179
203
  if (event.event === "warning")
180
204
  run.logger.warn(record);
181
- else if (event.event !== "cache" && event.outcome === "error")
205
+ else if ((event.event === "request" || event.event === "response") && event.outcome === "error")
182
206
  run.logger.error(record);
183
207
  else
184
208
  run.logger.info(record);
@@ -43,10 +43,14 @@ export interface RunMetadata {
43
43
  providerError?: string;
44
44
  /** Written only because it failed: recording was not asked for. */
45
45
  keptBecauseFailed?: boolean;
46
+ /** Written only because it wrote the store, so its counts say what to fetch again after a damage. */
47
+ keptBecauseStore?: boolean;
46
48
  /** Every operation its events named, so a search by operation need not open them. */
47
49
  operations?: string[];
48
50
  /** Every `errorCode` and warning `code` its events carried, for the same reason. */
49
51
  codes?: string[];
52
+ /** Every table its store events wrote, for the same reason. */
53
+ tables?: string[];
50
54
  /** The caller's trace: the MCP client's, or the schedule's or job's that started it. */
51
55
  traceId?: string;
52
56
  /** The whole command with the program's name, `max messages list`; `command` stays the run's short name. */
@@ -77,6 +81,8 @@ export interface StartRunOptions {
77
81
  keepDays?: number;
78
82
  /** Successful runs older than this are removed sooner than the failures `keepDays` keeps. */
79
83
  keepSuccessDays?: number;
84
+ /** A successful run that wrote the store is kept this long, whatever `keepSuccessDays` says. */
85
+ keepStoreDays?: number;
80
86
  /** The runs folder's size limit in bytes: past it, the oldest successful runs go first, then the oldest days. */
81
87
  maxBytes?: number;
82
88
  /**
@@ -106,6 +112,7 @@ export interface Run {
106
112
  }
107
113
  export declare const KEEP_RUNS_FOR_DAYS = 30;
108
114
  export declare const KEEP_SUCCESSFUL_RUNS_FOR_DAYS = 7;
115
+ export declare const KEEP_STORE_RUNS_FOR_DAYS = 3;
109
116
  export declare const RUNS_SIZE_LIMIT_MB = 200;
110
117
  /** `<state dir>/runs` — never the cache directory: a cache is deleted to fix a cache, and a run cannot be rebuilt. */
111
118
  export declare const runsDirFor: (app: AppIdentity, env?: NodeJS.ProcessEnv) => string;
@@ -161,15 +168,17 @@ export declare const findRun: (runsDir: string, id: string) => {
161
168
  export declare const readEvents: (dir: string) => Record<string, unknown>[];
162
169
  /**
163
170
  * Removes every day older than `keepDays`, then the successful runs of every day older than `keepSuccessDays`, and
164
- * answers how many days went. Then, once a day, the folder is measured against `maxBytes`: successful runs go first,
165
- * oldest day first, then whole days, until it fits.
171
+ * answers how many days went. A success that wrote the store is kept for `keepStoreDays` instead when that is longer,
172
+ * and one kept only because it wrote the store goes after `keepStoreDays`. Then, once a day, the folder is measured
173
+ * against `maxBytes`: successful runs go first, oldest day first, then whole days, until it fits.
166
174
  *
167
175
  * A day at a time, by the directory name and the day's index, so no run has to be opened to decide — and a directory
168
176
  * that is not a date is left alone rather than guessed at.
169
177
  */
170
- export declare const pruneRuns: (runsDir: string, { keepDays, keepSuccessDays, maxBytes, now, }: {
178
+ export declare const pruneRuns: (runsDir: string, { keepDays, keepSuccessDays, keepStoreDays, maxBytes, now, }: {
171
179
  keepDays: number;
172
180
  keepSuccessDays?: number;
181
+ keepStoreDays?: number;
173
182
  maxBytes?: number;
174
183
  now: Date;
175
184
  }) => number;
package/dist/runs/run.js CHANGED
@@ -7,6 +7,7 @@ import { LOG_ATTRIBUTES } from "./log-attributes.js";
7
7
  import { fromLogAttributes, logAttributes, snakeLogger } from "./log-keys.js";
8
8
  export const KEEP_RUNS_FOR_DAYS = 30;
9
9
  export const KEEP_SUCCESSFUL_RUNS_FOR_DAYS = 7;
10
+ export const KEEP_STORE_RUNS_FOR_DAYS = 3;
10
11
  export const RUNS_SIZE_LIMIT_MB = 200;
11
12
  /** `<state dir>/runs` — never the cache directory: a cache is deleted to fix a cache, and a run cannot be rebuilt. */
12
13
  export const runsDirFor = (app, env = process.env) => join(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "runs");
@@ -35,6 +36,7 @@ export const startRun = (options) => {
35
36
  pruneRuns(options.runsDir, {
36
37
  keepDays: options.keepDays ?? KEEP_RUNS_FOR_DAYS,
37
38
  keepSuccessDays: options.keepSuccessDays ?? KEEP_SUCCESSFUL_RUNS_FOR_DAYS,
39
+ keepStoreDays: options.keepStoreDays ?? KEEP_STORE_RUNS_FOR_DAYS,
38
40
  maxBytes: options.maxBytes ?? RUNS_SIZE_LIMIT_MB * 1024 * 1024,
39
41
  now: startedAt,
40
42
  });
@@ -79,10 +81,13 @@ export const startRun = (options) => {
79
81
  let finished = false;
80
82
  const operations = new Set();
81
83
  const codes = new Set();
84
+ const tables = new Set();
82
85
  const noted = (level) => (event, message) => {
83
- const { operation, errorCode, error_code, code } = event;
86
+ const { operation, errorCode, error_code, code, kind, table } = event;
84
87
  if (typeof operation === "string")
85
88
  operations.add(operation);
89
+ if (kind === "store" && typeof table === "string")
90
+ tables.add(table);
86
91
  for (const value of [errorCode, error_code, code])
87
92
  if (typeof value === "string")
88
93
  codes.add(value);
@@ -109,6 +114,7 @@ export const startRun = (options) => {
109
114
  durationMs: completedAt.getTime() - startedAt.getTime(),
110
115
  operations: [...operations].sort(),
111
116
  codes: [...codes].sort(),
117
+ ...(tables.size > 0 ? { tables: [...tables].sort() } : {}),
112
118
  };
113
119
  if (file || status !== "success") {
114
120
  opened();
@@ -285,20 +291,30 @@ const eventOf = (line) => {
285
291
  };
286
292
  /**
287
293
  * Removes every day older than `keepDays`, then the successful runs of every day older than `keepSuccessDays`, and
288
- * answers how many days went. Then, once a day, the folder is measured against `maxBytes`: successful runs go first,
289
- * oldest day first, then whole days, until it fits.
294
+ * answers how many days went. A success that wrote the store is kept for `keepStoreDays` instead when that is longer,
295
+ * and one kept only because it wrote the store goes after `keepStoreDays`. Then, once a day, the folder is measured
296
+ * against `maxBytes`: successful runs go first, oldest day first, then whole days, until it fits.
290
297
  *
291
298
  * A day at a time, by the directory name and the day's index, so no run has to be opened to decide — and a directory
292
299
  * that is not a date is left alone rather than guessed at.
293
300
  */
294
- export const pruneRuns = (runsDir, { keepDays, keepSuccessDays = keepDays, maxBytes, now, }) => {
301
+ export const pruneRuns = (runsDir, { keepDays, keepSuccessDays = keepDays, keepStoreDays = KEEP_STORE_RUNS_FOR_DAYS, maxBytes, now, }) => {
295
302
  const cutoff = day(new Date(now.getTime() - keepDays * DAY_MS));
296
- const successCutoff = day(new Date(now.getTime() - Math.min(keepSuccessDays, keepDays) * DAY_MS));
303
+ const before = (days) => day(new Date(now.getTime() - Math.min(days, keepDays) * DAY_MS));
304
+ const successCutoff = before(keepSuccessDays);
305
+ const storeCutoff = before(keepStoreDays);
306
+ const keptFor = (metadata) => metadata.keptBecauseStore
307
+ ? keepStoreDays
308
+ : metadata.operations?.includes(STORE_WRITE)
309
+ ? Math.max(keepSuccessDays, keepStoreDays)
310
+ : keepSuccessDays;
297
311
  let removed = 0;
298
312
  for (const date of days(runsDir)) {
299
313
  if (date >= cutoff) {
314
+ if (date < storeCutoff)
315
+ dropSuccesses(join(runsDir, date), STORE_RUNS_DROPPED, (metadata) => keptFor(metadata) <= keepStoreDays);
300
316
  if (date < successCutoff)
301
- dropSuccesses(join(runsDir, date));
317
+ dropSuccesses(join(runsDir, date), SUCCESSES_DROPPED, (metadata) => keptFor(metadata) <= keepSuccessDays);
302
318
  continue;
303
319
  }
304
320
  try {
@@ -314,20 +330,23 @@ export const pruneRuns = (runsDir, { keepDays, keepSuccessDays = keepDays, maxBy
314
330
  return removed;
315
331
  };
316
332
  const DAY_MS = 24 * 60 * 60 * 1000;
333
+ const STORE_WRITE = "store.write";
317
334
  const SUCCESSES_DROPPED = ".successes-dropped";
335
+ const STORE_RUNS_DROPPED = ".store-runs-dropped";
318
336
  const SIZE_CHECKED = ".size-checked";
319
- /** A day's successful runs, out of its index and off the disk; once per day, marked by a file beside them. */
320
- const dropSuccesses = (dayDir) => {
321
- const marker = join(dayDir, SUCCESSES_DROPPED);
337
+ /** A day's successful runs that `drops`, out of its index and off the disk; once per day and marker. */
338
+ const dropSuccesses = (dayDir, marker = SUCCESSES_DROPPED, drops = () => true) => {
339
+ const done = join(dayDir, marker);
322
340
  try {
323
- statSync(marker);
341
+ statSync(done);
324
342
  return;
325
343
  }
326
344
  catch { }
345
+ const dropped = (metadata) => metadata?.status === "success" && drops(metadata);
327
346
  try {
328
347
  const kept = [];
329
348
  for (const [id, metadata] of indexedRuns(dayDir)) {
330
- if (metadata.status === "success")
349
+ if (dropped(metadata))
331
350
  rmSync(join(dayDir, id), { recursive: true, force: true });
332
351
  else
333
352
  kept.push(JSON.stringify(runFileOf(metadata)));
@@ -335,11 +354,11 @@ const dropSuccesses = (dayDir) => {
335
354
  for (const entry of safeReaddir(dayDir)) {
336
355
  if (entry === INDEX || entry.startsWith("."))
337
356
  continue;
338
- if (readRun(join(dayDir, entry))?.status === "success")
357
+ if (dropped(readRun(join(dayDir, entry))))
339
358
  rmSync(join(dayDir, entry), { recursive: true, force: true });
340
359
  }
341
360
  writeSecurely(join(dayDir, INDEX), kept.map((line) => `${line}\n`).join(""), 0o600);
342
- writeFileSync(marker, "", { mode: 0o600 });
361
+ writeFileSync(done, "", { mode: 0o600 });
343
362
  }
344
363
  catch {
345
364
  // Tried again at the next run's start.
@@ -9,6 +9,7 @@ export declare const ACCOUNT_GROUPS_SETTING = "account_groups";
9
9
  export type AccountGroups = Record<string, string[]>;
10
10
  /** A bare `all` or `telegram` keeps meaning what it always did; a comma or a `:` makes it a list. */
11
11
  export declare const isAccountList: (value: string) => boolean;
12
+ export declare const isGroupName: (name: string) => boolean;
12
13
  export declare const groupName: (name: string) => string;
13
14
  /** What `config set account_groups.<name>` saves: the entries as written, so each app resolves its own profiles. */
14
15
  export declare const groupMembers: (value: string) => string[];
@@ -23,6 +24,8 @@ export interface ListContext {
23
24
  provider: Provider;
24
25
  command?: string;
25
26
  };
27
+ /** Under a group lock, the only accounts (by `keyOf`) a list may name; every other one resolves to nothing. */
28
+ only?: ReadonlySet<string>;
26
29
  }
27
30
  /**
28
31
  * An account as `--source` and a hit name it: a notes folder is `notes:<its id>`, never the store's ulid. The kind is
@@ -40,6 +43,9 @@ export interface ListedEntry {
40
43
  entry: string;
41
44
  accounts: ListedAccount[];
42
45
  }
46
+ export declare const keyOf: ({ provider, account }: AccountKey) => string;
47
+ export declare const sourceOf: ({ provider, account }: AccountKey) => string;
48
+ export declare const sameAs: (key: AccountKey) => (one: AccountKey) => boolean;
43
49
  /**
44
50
  * What `--source group:work,tg:tg3,max:Alice,email,notes:4` names, entry by entry, a group's members in its
45
51
  * place. An entry is a group, `provider:account` — the account's id, a profile of any app that recorded it, or
@@ -17,7 +17,8 @@ const itemsOf = (value) => {
17
17
  fail(`"${value}" has an empty entry — separate accounts with one comma`);
18
18
  return items;
19
19
  };
20
- export const groupName = (name) => GROUP_NAME.test(name) ? name : fail(`a group name is letters, digits, - and _ — not "${name}"`);
20
+ export const isGroupName = (name) => GROUP_NAME.test(name);
21
+ export const groupName = (name) => isGroupName(name) ? name : fail(`a group name is letters, digits, - and _ — not "${name}"`);
21
22
  /** What `config set account_groups.<name>` saves: the entries as written, so each app resolves its own profiles. */
22
23
  export const groupMembers = (value) => itemsOf(value).map((item) => item.toLowerCase().startsWith("group:")
23
24
  ? fail(`a group lists accounts, not other groups — "${item}"`)
@@ -145,7 +146,9 @@ const accountsOfWord = (word, held, context) => {
145
146
  return storedAs(held, { provider, account: "" });
146
147
  return held.filter((one) => one.provider === provider);
147
148
  };
148
- const keyOf = ({ provider, account }) => `${provider}\u0000${account}`;
149
+ export const keyOf = ({ provider, account }) => `${provider}\u0000${account}`;
150
+ export const sourceOf = ({ provider, account }) => `${provider}:${account}`;
151
+ export const sameAs = (key) => (one) => one.provider === key.provider && one.account === key.account;
149
152
  /**
150
153
  * What `--source group:work,tg:tg3,max:Alice,email,notes:4` names, entry by entry, a group's members in its
151
154
  * place. An entry is a group, `provider:account` — the account's id, a profile of any app that recorded it, or
@@ -188,9 +191,12 @@ export const entriesOfList = (value, context) => {
188
191
  };
189
192
  for (const item of itemsOf(value))
190
193
  entry(item);
194
+ const { only } = context;
191
195
  return entries.map(({ entry, accounts }) => ({
192
196
  entry,
193
- accounts: accounts.map(({ provider, account, kind, kinds }) => ({
197
+ accounts: accounts
198
+ .filter((one) => only === undefined || only.has(keyOf(one)))
199
+ .map(({ provider, account, kind, kinds }) => ({
194
200
  provider,
195
201
  account,
196
202
  kind,