@wirecat/cli-core 0.642.0 → 0.643.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 (258) hide show
  1. package/CHANGELOG.md +188 -0
  2. package/dist/attachments/ocr.js +27 -18
  3. package/dist/attachments/picture-reading.d.ts +51 -0
  4. package/dist/attachments/picture-reading.js +207 -0
  5. package/dist/background/backfill.d.ts +4 -2
  6. package/dist/background/backfill.js +3 -3
  7. package/dist/background/schedules.d.ts +23 -1
  8. package/dist/background/schedules.js +45 -17
  9. package/dist/background/units.d.ts +2 -0
  10. package/dist/background/units.js +8 -9
  11. package/dist/calendar/cli/index.js +10 -2
  12. package/dist/calendar/feeds.js +2 -2
  13. package/dist/calendar/server-search.js +2 -2
  14. package/dist/calendar/source.d.ts +4 -3
  15. package/dist/calendar/sync.js +12 -10
  16. package/dist/calendar/testing/source-contract.js +5 -4
  17. package/dist/calendar/testing/source.js +3 -2
  18. package/dist/cli/complete-command.d.ts +23 -0
  19. package/dist/cli/complete-command.js +80 -0
  20. package/dist/cli/context.js +7 -1
  21. package/dist/cli/effects.d.ts +2 -0
  22. package/dist/cli/effects.js +2 -0
  23. package/dist/cli/envelope.js +6 -1
  24. package/dist/cli/help/first-screen.js +5 -0
  25. package/dist/cli/index.d.ts +4 -2
  26. package/dist/cli/index.js +2 -1
  27. package/dist/cli/list-query.d.ts +3 -1
  28. package/dist/cli/list-query.js +5 -3
  29. package/dist/cli/local-only-command.js +9 -0
  30. package/dist/cli/messenger/backfill-command.js +1 -1
  31. package/dist/cli/messenger/chat-queries.js +2 -1
  32. package/dist/cli/messenger/complete-command.d.ts +4 -7
  33. package/dist/cli/messenger/complete-command.js +31 -98
  34. package/dist/cli/messenger/contacts-command.js +4 -0
  35. package/dist/cli/messenger/guard-commands.js +1 -1
  36. package/dist/cli/messenger/images-command.js +32 -0
  37. package/dist/cli/messenger/list-result-queries.d.ts +1 -0
  38. package/dist/cli/messenger/list-result-queries.js +2 -1
  39. package/dist/cli/messenger/mentions-command.js +3 -3
  40. package/dist/cli/messenger/message-items.js +1 -0
  41. package/dist/cli/messenger/messages-command.js +7 -6
  42. package/dist/cli/messenger/people-queries.d.ts +2 -2
  43. package/dist/cli/messenger/people-queries.js +4 -4
  44. package/dist/cli/messenger/search-answers.js +2 -2
  45. package/dist/cli/messenger/search-command.js +3 -3
  46. package/dist/cli/messenger/searches-command.js +1 -1
  47. package/dist/cli/messenger/store-maintenance-command.js +4 -0
  48. package/dist/cli/messenger/tasks-analysis-command.js +1 -1
  49. package/dist/cli/messenger/tasks-command.js +2 -2
  50. package/dist/cli/model-catalogue-command.js +2 -0
  51. package/dist/cli/picture-reading-command.d.ts +12 -0
  52. package/dist/cli/picture-reading-command.js +82 -0
  53. package/dist/cli/program.d.ts +6 -0
  54. package/dist/cli/program.js +28 -2
  55. package/dist/cli/schedule/agent-start.d.ts +23 -0
  56. package/dist/cli/schedule/agent-start.js +115 -0
  57. package/dist/cli/schedule/harnesses.d.ts +203 -0
  58. package/dist/cli/schedule/harnesses.js +278 -0
  59. package/dist/cli/schedule/schedule-command.d.ts +9 -5
  60. package/dist/cli/schedule/schedule-command.js +89 -79
  61. package/dist/cli/shared-command-exports.d.ts +186 -0
  62. package/dist/cli/shared-command-exports.js +2 -0
  63. package/dist/cli/untrusted-marks.d.ts +25 -0
  64. package/dist/cli/untrusted-marks.js +102 -0
  65. package/dist/crm/cli/index.d.ts +1 -0
  66. package/dist/crm/cli/index.js +6 -5
  67. package/dist/crm/cli/store.d.ts +30 -0
  68. package/dist/crm/cli/store.js +63 -0
  69. package/dist/crm/source.d.ts +6 -4
  70. package/dist/crm/sync.js +10 -6
  71. package/dist/crm/testing/source-contract.js +9 -7
  72. package/dist/crm/testing/source.js +6 -2
  73. package/dist/crm/testing/sync-contract.js +4 -4
  74. package/dist/crm/writes.d.ts +5 -2
  75. package/dist/crm/writes.js +1 -1
  76. package/dist/documents.d.ts +1 -0
  77. package/dist/documents.js +1 -0
  78. package/dist/domain/addresses.d.ts +2 -0
  79. package/dist/domain/addresses.js +7 -0
  80. package/dist/domain/attachments.d.ts +2 -0
  81. package/dist/domain/attachments.js +2 -1
  82. package/dist/domain/models.d.ts +2 -0
  83. package/dist/entities/attachment-results.d.ts +3 -0
  84. package/dist/entities/attachment-results.js +3 -0
  85. package/dist/entities/attachment.d.ts +2 -0
  86. package/dist/entities/attachment.js +8 -1
  87. package/dist/entities/hit.d.ts +1 -0
  88. package/dist/entities/index.d.ts +21 -4
  89. package/dist/entities/index.js +3 -2
  90. package/dist/entities/list-results.d.ts +33 -5
  91. package/dist/entities/list-results.js +33 -5
  92. package/dist/errors/reasons.js +30 -1
  93. package/dist/mail/cli/index.js +7 -6
  94. package/dist/mcp/agent.d.ts +2 -1
  95. package/dist/mcp/agent.js +5 -0
  96. package/dist/mcp/app-server.js +10 -0
  97. package/dist/mcp/surface.d.ts +7 -2
  98. package/dist/mcp/surface.js +49 -10
  99. package/dist/meetings/cli/index.js +6 -1
  100. package/dist/meetings/mcp/index.d.ts +15 -15
  101. package/dist/meetings/mcp/index.js +6 -3
  102. package/dist/meetings/participant-search.d.ts +2 -2
  103. package/dist/meetings/project-discovery.d.ts +1 -1
  104. package/dist/meetings/project-evidence-answer.js +2 -2
  105. package/dist/meetings/reads.d.ts +2 -2
  106. package/dist/meetings/reads.js +6 -6
  107. package/dist/meetings/store.d.ts +2 -1
  108. package/dist/meetings/testing/contract.js +6 -6
  109. package/dist/meetings/testing/memory.js +7 -2
  110. package/dist/models/ai.d.ts +1 -1
  111. package/dist/models/ai.js +3 -1
  112. package/dist/models/anthropic.js +15 -9
  113. package/dist/models/index.js +5 -3
  114. package/dist/models/openai.js +24 -11
  115. package/dist/models/types.d.ts +8 -0
  116. package/dist/models/types.js +11 -1
  117. package/dist/ports/app.d.ts +17 -1
  118. package/dist/ports/app.js +63 -3
  119. package/dist/search/lucene/plain.js +45 -3
  120. package/dist/search/lucene/registry.d.ts +15 -4
  121. package/dist/search/lucene/registry.js +70 -12
  122. package/dist/search/lucene/types.d.ts +2 -0
  123. package/dist/search/lucene/types.js +12 -0
  124. package/dist/sends/upload.d.ts +8 -1
  125. package/dist/sends/upload.js +35 -14
  126. package/dist/services/account-groups.d.ts +11 -0
  127. package/dist/services/account-groups.js +29 -0
  128. package/dist/services/agenda.js +1 -0
  129. package/dist/services/attachments.d.ts +18 -4
  130. package/dist/services/attachments.js +66 -15
  131. package/dist/services/conversations.d.ts +2 -4
  132. package/dist/services/conversations.js +1 -1
  133. package/dist/services/deal-context.js +5 -5
  134. package/dist/services/documents/ingestion.js +3 -3
  135. package/dist/services/documents/knowledge.d.ts +6 -6
  136. package/dist/services/documents/knowledge.js +1 -2
  137. package/dist/services/events-search.d.ts +3 -3
  138. package/dist/services/events-search.js +7 -7
  139. package/dist/services/index.d.ts +1 -1
  140. package/dist/services/index.js +1 -1
  141. package/dist/services/meeting-project-discovery.js +1 -1
  142. package/dist/services/message-resolution.js +10 -3
  143. package/dist/services/messages-search.js +6 -4
  144. package/dist/services/metadata.d.ts +1 -1
  145. package/dist/services/notes-search.d.ts +3 -3
  146. package/dist/services/notes-search.js +3 -3
  147. package/dist/services/organization-context.js +12 -9
  148. package/dist/services/people.d.ts +2 -0
  149. package/dist/services/people.js +4 -2
  150. package/dist/services/pictures.d.ts +9 -0
  151. package/dist/services/pictures.js +34 -28
  152. package/dist/services/project-status/index.js +1 -1
  153. package/dist/services/project-status/signals/payments.js +4 -2
  154. package/dist/services/project-status/signals/promises.js +5 -2
  155. package/dist/services/proposals/kinds/action.js +1 -1
  156. package/dist/services/proposals/kinds/fact.js +1 -1
  157. package/dist/services/proposals/kinds/findings.d.ts +2 -1
  158. package/dist/services/proposals/kinds/findings.js +12 -5
  159. package/dist/services/proposals/kinds/identity-link.js +1 -1
  160. package/dist/services/proposals/kinds/identity-split.js +1 -1
  161. package/dist/services/proposals/kinds/key-document.js +1 -1
  162. package/dist/services/proposals/kinds/mail-findings.d.ts +1 -1
  163. package/dist/services/proposals/kinds/mail-findings.js +11 -5
  164. package/dist/services/proposals/kinds/meeting-findings.js +10 -4
  165. package/dist/services/proposals/kinds/memory.js +1 -1
  166. package/dist/services/proposals/kinds/organization.js +1 -1
  167. package/dist/services/proposals/kinds/relationship-update.js +1 -1
  168. package/dist/services/proposals/kinds/relationship.js +1 -1
  169. package/dist/services/proposals/kinds/shared.d.ts +3 -2
  170. package/dist/services/proposals/kinds/shared.js +4 -4
  171. package/dist/services/proposals/kinds/source-review.js +1 -1
  172. package/dist/services/proposals/kinds/task-close.js +2 -2
  173. package/dist/services/proposals/registry.js +1 -1
  174. package/dist/services/proposals/types.d.ts +2 -1
  175. package/dist/services/search-all-business.js +3 -4
  176. package/dist/services/search-all.js +13 -14
  177. package/dist/services/searches.d.ts +2 -4
  178. package/dist/services/searches.js +1 -4
  179. package/dist/services/stored-project-gathering.js +6 -1
  180. package/dist/services/tags.d.ts +2 -4
  181. package/dist/services/tags.js +1 -1
  182. package/dist/services/tasks.d.ts +1 -1
  183. package/dist/services/tasks.js +4 -3
  184. package/dist/store/account-store.d.ts +2 -1
  185. package/dist/store/account-store.js +3 -1
  186. package/dist/store/accounts.d.ts +2 -0
  187. package/dist/store/accounts.js +8 -0
  188. package/dist/store/chats.d.ts +5 -0
  189. package/dist/store/chats.js +4 -0
  190. package/dist/store/evidence-findings.d.ts +9 -0
  191. package/dist/store/exports.d.ts +1 -1
  192. package/dist/store/exports.js +1 -1
  193. package/dist/store/identity-links.d.ts +3 -1
  194. package/dist/store/mail-findings.d.ts +9 -0
  195. package/dist/store/meeting-findings.d.ts +9 -0
  196. package/dist/store/searches.d.ts +3 -2
  197. package/dist/store/sqlite/accounts.js +37 -0
  198. package/dist/store/sqlite/agent-actions.d.ts +2 -1
  199. package/dist/store/sqlite/agent-actions.js +10 -4
  200. package/dist/store/sqlite/business-contracts.d.ts +3 -1
  201. package/dist/store/sqlite/business-contracts.js +7 -3
  202. package/dist/store/sqlite/business-search.d.ts +2 -1
  203. package/dist/store/sqlite/business-search.js +6 -4
  204. package/dist/store/sqlite/deals.d.ts +6 -4
  205. package/dist/store/sqlite/deals.js +12 -7
  206. package/dist/store/sqlite/evidence-findings.js +78 -9
  207. package/dist/store/sqlite/facts.d.ts +2 -1
  208. package/dist/store/sqlite/facts.js +6 -2
  209. package/dist/store/sqlite/finance.d.ts +4 -2
  210. package/dist/store/sqlite/finance.js +13 -6
  211. package/dist/store/sqlite/findings-core.d.ts +56 -2
  212. package/dist/store/sqlite/findings-core.js +109 -22
  213. package/dist/store/sqlite/identities.d.ts +4 -0
  214. package/dist/store/sqlite/identities.js +12 -3
  215. package/dist/store/sqlite/identity-proposals.js +34 -4
  216. package/dist/store/sqlite/lucene-fields.d.ts +2 -0
  217. package/dist/store/sqlite/lucene-fields.js +28 -2
  218. package/dist/store/sqlite/lucene.js +21 -10
  219. package/dist/store/sqlite/mail-findings.js +60 -22
  220. package/dist/store/sqlite/meeting-findings.js +53 -7
  221. package/dist/store/sqlite/meeting-participant-search.js +4 -5
  222. package/dist/store/sqlite/meetings.js +7 -3
  223. package/dist/store/sqlite/memories.d.ts +4 -2
  224. package/dist/store/sqlite/memories.js +13 -6
  225. package/dist/store/sqlite/money-transactions.d.ts +3 -1
  226. package/dist/store/sqlite/money-transactions.js +7 -3
  227. package/dist/store/sqlite/name-traces.d.ts +3 -3
  228. package/dist/store/sqlite/name-traces.js +29 -2
  229. package/dist/store/sqlite/orders.d.ts +3 -1
  230. package/dist/store/sqlite/orders.js +5 -2
  231. package/dist/store/sqlite/people-list.js +67 -22
  232. package/dist/store/sqlite/person-match-scan.d.ts +3 -1
  233. package/dist/store/sqlite/person-match-scan.js +97 -7
  234. package/dist/store/sqlite/products.d.ts +3 -1
  235. package/dist/store/sqlite/products.js +5 -2
  236. package/dist/store/sqlite/proposed-actions.d.ts +2 -1
  237. package/dist/store/sqlite/proposed-actions.js +7 -3
  238. package/dist/store/sqlite/query-filter.d.ts +4 -0
  239. package/dist/store/sqlite/query-filter.js +14 -0
  240. package/dist/store/sqlite/reads.d.ts +1 -0
  241. package/dist/store/sqlite/reads.js +14 -0
  242. package/dist/store/sqlite/records.d.ts +3 -1
  243. package/dist/store/sqlite/records.js +7 -5
  244. package/dist/store/sqlite/rows-page.d.ts +3 -0
  245. package/dist/store/sqlite/rows-page.js +4 -0
  246. package/dist/store/sqlite/searches.d.ts +2 -1
  247. package/dist/store/sqlite/searches.js +3 -1
  248. package/dist/store/sqlite/subscriptions.d.ts +5 -2
  249. package/dist/store/sqlite/subscriptions.js +13 -6
  250. package/dist/store/sqlite/task-board.js +27 -0
  251. package/dist/store/sqlite/task-find.d.ts +15 -0
  252. package/dist/store/sqlite/task-find.js +1 -0
  253. package/dist/store/sqlite/wallets.d.ts +3 -1
  254. package/dist/store/sqlite/wallets.js +7 -3
  255. package/dist/store/sqlite/work-tasks.d.ts +3 -11
  256. package/dist/store/sqlite/work-tasks.js +8 -4
  257. package/package.json +2 -2
  258. package/parity.json +24 -0
@@ -1,5 +1,5 @@
1
1
  import { createHash } from "node:crypto";
2
- import { readFile, stat } from "node:fs/promises";
2
+ import { lstat, readFile } from "node:fs/promises";
3
3
  import { setTimeout as sleep } from "node:timers/promises";
4
4
  import { CliError } from "@wirecat/cli-base";
5
5
  import { formatLocator } from "../domain/locator.js";
@@ -24,6 +24,38 @@ export const plainWords = (query) => query
24
24
  .replace(/[()"+\-~^*?\\[\]{}!|&]/g, " ")
25
25
  .replace(/\s+/g, " ")
26
26
  .trim();
27
+ /**
28
+ * A picture's bytes: the saved copy when it is a regular file small enough, else a fresh download through the
29
+ * messenger. `read` is told which file was downloaded, so its refreshed reference can be kept.
30
+ */
31
+ export const pictureBytes = async (picture, files, read) => {
32
+ if (picture.localPath) {
33
+ try {
34
+ // A link could point the read at another file; a saved copy is never one.
35
+ const found = await lstat(picture.localPath);
36
+ if (found.isFile() && found.size <= PICTURE_MAX_BYTES)
37
+ return await readFile(picture.localPath);
38
+ }
39
+ catch {
40
+ // The saved copy is gone; the messenger still has the picture.
41
+ }
42
+ }
43
+ const images = (await files()).filter(({ kind, mime }) => kind === "photo" || mime?.startsWith("image/"));
44
+ const file = images.find(({ position }) => position === picture.position) ??
45
+ (images.every(({ position }) => position === undefined) ? images[0] : undefined);
46
+ if (!file || (file.size !== undefined && file.size > PICTURE_MAX_BYTES))
47
+ return undefined;
48
+ const parts = [];
49
+ let total = 0;
50
+ for await (const part of file.bytes()) {
51
+ total += part.length;
52
+ if (total > PICTURE_MAX_BYTES)
53
+ return undefined;
54
+ parts.push(part);
55
+ }
56
+ await read(file);
57
+ return Buffer.concat(parts);
58
+ };
27
59
  export const picturesService = (deps) => {
28
60
  let opened;
29
61
  const open = async () => {
@@ -44,32 +76,6 @@ export const picturesService = (deps) => {
44
76
  return opened;
45
77
  };
46
78
  const model = imageModel(DEFAULT_IMAGE_MODEL);
47
- const bytesOf = async (picture, files, read) => {
48
- if (picture.localPath) {
49
- try {
50
- if ((await stat(picture.localPath)).size <= PICTURE_MAX_BYTES)
51
- return await readFile(picture.localPath);
52
- }
53
- catch {
54
- // The saved copy is gone; the messenger still has the picture.
55
- }
56
- }
57
- const images = (await files()).filter(({ kind, mime }) => kind === "photo" || mime?.startsWith("image/"));
58
- const file = images.find(({ position }) => position === picture.position) ??
59
- (images.every(({ position }) => position === undefined) ? images[0] : undefined);
60
- if (!file || (file.size !== undefined && file.size > PICTURE_MAX_BYTES))
61
- return undefined;
62
- const parts = [];
63
- let total = 0;
64
- for await (const part of file.bytes()) {
65
- total += part.length;
66
- if (total > PICTURE_MAX_BYTES)
67
- return undefined;
68
- parts.push(part);
69
- }
70
- await read(file);
71
- return Buffer.concat(parts);
72
- };
73
79
  return {
74
80
  /**
75
81
  * Gives the images no vector yet one, reading each through the messenger's own download and keeping nothing
@@ -120,7 +126,7 @@ export const picturesService = (deps) => {
120
126
  return downloaded.files;
121
127
  };
122
128
  try {
123
- const bytes = await bytesOf(picture, files, async (file) => {
129
+ const bytes = await pictureBytes(picture, files, async (file) => {
124
130
  const refreshed = refreshedFiles([file]);
125
131
  if (refreshed.length === 0)
126
132
  return;
@@ -61,7 +61,7 @@ const owed = (item) => {
61
61
  const keepsBooks = async (store, projects) => {
62
62
  for (const project of projects) {
63
63
  const filter = { project, review: "confirmed", limit: 1 };
64
- if ((await store.finance.invoices(filter)).length || (await store.finance.payments(filter)).length)
64
+ if ((await store.finance.invoices(filter)).items.length || (await store.finance.payments(filter)).items.length)
65
65
  return true;
66
66
  }
67
67
  return false;
@@ -42,8 +42,10 @@ export const payments = {
42
42
  read: async (context) => {
43
43
  const projects = [context.project.ref, ...context.project.children.map((child) => child.ref)];
44
44
  const rows = await Promise.all(projects.map(async (project) => [
45
- ...(await context.store.finance.payments({ project, limit: 500 })).filter(holding).map(paid),
46
- ...(await context.store.finance.invoices({ project, open: true, limit: 500 })).filter(holding).map(expected),
45
+ ...(await context.store.finance.payments({ project, limit: 500 })).items.filter(holding).map(paid),
46
+ ...(await context.store.finance.invoices({ project, open: true, limit: 500 })).items
47
+ .filter(holding)
48
+ .map(expected),
47
49
  ]));
48
50
  return rows.flat();
49
51
  },
@@ -26,7 +26,10 @@ const tasksOf = async (context) => {
26
26
  const projects = [context.project.ref, ...context.project.children.map((child) => child.ref)];
27
27
  const accounts = new Map(context.chats.map((chat) => [taskAccount(chat.account), chat.account]));
28
28
  const inboxes = [...accounts.keys()].map(inboxKey);
29
- const found = await Promise.all([...projects, ...inboxes].map((project) => context.store.tasks.find({ project, limit: 500 }).catch(orNone)));
29
+ const found = await Promise.all([...projects, ...inboxes].map((project) => context.store.tasks
30
+ .find({ project, limit: 500 })
31
+ .then(({ items }) => items)
32
+ .catch(orNone)));
30
33
  const projectRefs = new Set(projects);
31
34
  return found
32
35
  .flat()
@@ -82,7 +85,7 @@ export const promises = {
82
85
  scope: "project",
83
86
  read: async (context) => {
84
87
  const projects = [context.project.ref, ...context.project.children.map((child) => child.ref)];
85
- const facts = (await Promise.all(projects.map((project) => context.store.facts.list({ type: "promise", project }))))
88
+ const facts = (await Promise.all(projects.map(async (project) => (await context.store.facts.list({ type: "promise", project })).items)))
86
89
  .flat()
87
90
  .filter((fact) => fact.status === "proposed" || fact.status === "accepted");
88
91
  return [
@@ -27,7 +27,7 @@ export const actionKind = (store, claimed) => ({
27
27
  kind: "action",
28
28
  list: async (filter) => {
29
29
  const status = storedStatus(filter);
30
- const actions = await store.proposedActions.list({
30
+ const { items: actions } = await store.proposedActions.list({
31
31
  except: [...claimed(), MEETING_FINDINGS_KIND, EVIDENCE_FINDINGS_KIND, MAIL_FINDINGS_KIND],
32
32
  ...(status === undefined ? {} : { status }),
33
33
  ...pushed(filter),
@@ -28,7 +28,7 @@ export const factKind = (store) => ({
28
28
  prefix: "fact",
29
29
  list: async (filter) => {
30
30
  const status = filter.status ?? "proposed";
31
- const facts = await store.facts.list({
31
+ const { items: facts } = await store.facts.list({
32
32
  ...pushed(filter),
33
33
  ...(status === "all" ? {} : { status: status === "confirmed" ? "accepted" : status }),
34
34
  order: "created",
@@ -5,6 +5,7 @@ import type { ProposalKind } from "../types.js";
5
5
  export declare const FACT_SUMMARIES: Record<string, (finding: Finding) => string>;
6
6
  /**
7
7
  * An agent's batch of cited facts and tasks from stored messages, mail and documents. Confirming accepts the parts
8
- * named, or every finding not rejected before; the rest are rejected. Meeting findings have their own kind.
8
+ * named, or every finding not rejected before; the rest wait. Rejecting turns down what still waits. Meeting findings
9
+ * have their own kind.
9
10
  */
10
11
  export declare const findingsKind: (store: Pick<MessageStore, "evidenceFindings" | "proposedActions">) => ProposalKind;
@@ -10,7 +10,7 @@ export const FACT_SUMMARIES = {
10
10
  const statusOf = (batch) => batch.status === "proposed" ? "proposed" : batch.receipt?.accepted.length ? "confirmed" : "rejected";
11
11
  const rowOf = (batch, createdAt) => {
12
12
  const findings = batch.input.findings;
13
- const outcome = (id) => batch.receipt?.items.find((item) => item.id === id)?.status ?? null;
13
+ const outcome = (id) => (batch.receipt?.items ?? batch.decided).find((item) => item.id === id)?.status ?? null;
14
14
  return {
15
15
  id: batch.id,
16
16
  kind: "findings",
@@ -35,7 +35,8 @@ const rowOf = (batch, createdAt) => {
35
35
  };
36
36
  /**
37
37
  * An agent's batch of cited facts and tasks from stored messages, mail and documents. Confirming accepts the parts
38
- * named, or every finding not rejected before; the rest are rejected. Meeting findings have their own kind.
38
+ * named, or every finding not rejected before; the rest wait. Rejecting turns down what still waits. Meeting findings
39
+ * have their own kind.
39
40
  */
40
41
  export const findingsKind = (store) => {
41
42
  // The batch view carries no staging time; its stored proposal does.
@@ -56,7 +57,7 @@ export const findingsKind = (store) => {
56
57
  limit: 50,
57
58
  offset,
58
59
  });
59
- rows.push(...kept(await Promise.all(page.items.map(created)), { ...filter, limit: 50 }));
60
+ rows.push(...kept(await Promise.all(page.items.map(created)), { ...filter, limit: 50 }).items);
60
61
  if (!page.hasMore)
61
62
  break;
62
63
  }
@@ -65,7 +66,11 @@ export const findingsKind = (store) => {
65
66
  get: async (id) => created(await store.evidenceFindings.get(id)),
66
67
  decide: async (id, { confirm, by, parts, reason }) => {
67
68
  const batch = await store.evidenceFindings.get(id);
68
- const turnedDown = new Set(batch.previous.filter((one) => one.status === "rejected").map((one) => one.id));
69
+ // A finding this batch already decided keeps its outcome; a confirm with no names takes what still waits.
70
+ const turnedDown = new Set([
71
+ ...batch.previous.filter((one) => one.status === "rejected").map((one) => one.id),
72
+ ...batch.decided.map((one) => one.id),
73
+ ]);
69
74
  const accept = !confirm
70
75
  ? []
71
76
  : (parts ?? batch.input.findings.map((finding) => finding.id).filter((one) => !turnedDown.has(one)));
@@ -75,7 +80,9 @@ export const findingsKind = (store) => {
75
80
  by,
76
81
  ...(reason === undefined ? {} : { reason }),
77
82
  });
78
- const made = (reviewed.receipt?.items ?? []).flatMap((item) => item.status === "accepted" && item.reference && !item.reused ? [item.reference] : []);
83
+ const made = (reviewed.receipt?.items ?? reviewed.decided).flatMap((item) => item.status === "accepted" && item.reference && !item.reused && accept.includes(item.id)
84
+ ? [item.reference]
85
+ : []);
79
86
  return { id, kind: "findings", status: accept.length ? "confirmed" : "rejected", made };
80
87
  },
81
88
  };
@@ -27,7 +27,7 @@ export const identityLinkKind = (store) => ({
27
27
  ownerOnly: true,
28
28
  list: async (filter) => {
29
29
  const status = storedStatus(filter);
30
- const stored = await store.proposedActions.list({
30
+ const { items: stored } = await store.proposedActions.list({
31
31
  kinds: [IDENTITY_LINK_KIND],
32
32
  ...(status === undefined ? {} : { status }),
33
33
  ...pushed(filter),
@@ -44,7 +44,7 @@ export const identitySplitKind = (store) => ({
44
44
  ownerOnly: true,
45
45
  list: async (filter) => {
46
46
  const status = storedStatus(filter);
47
- const stored = await store.proposedActions.list({
47
+ const { items: stored } = await store.proposedActions.list({
48
48
  kinds: [IDENTITY_SPLIT_KIND],
49
49
  ...(status === undefined ? {} : { status }),
50
50
  ...pushed(filter),
@@ -54,7 +54,7 @@ export const keyDocumentKind = (store) => {
54
54
  stored: ["key_document"],
55
55
  list: async (filter) => {
56
56
  const status = storedStatus(filter);
57
- const stored = await store.proposedActions.list({
57
+ const { items: stored } = await store.proposedActions.list({
58
58
  kinds: ["key_document"],
59
59
  ...(status === undefined ? {} : { status }),
60
60
  ...pushed(filter),
@@ -4,6 +4,6 @@ import type { ProposalKind } from "../types.js";
4
4
  * What an agent read in new mail, one batch per mailbox and run. Only the owner decides it — mail is text a stranger
5
5
  * wrote, so an agent that read it must not also approve what it made of it: an agent's confirmation is refused
6
6
  * whatever `agent_decisions` says. Confirming accepts the parts named, or every finding not
7
- * rejected before; the rest are rejected.
7
+ * rejected before; the rest wait. Rejecting turns down what still waits.
8
8
  */
9
9
  export declare const mailFindingsKind: (store: Pick<MessageStore, "mailFindings" | "proposedActions">) => ProposalKind;
@@ -28,7 +28,7 @@ const summaryOf = (finding) => {
28
28
  };
29
29
  const rowOf = (batch, createdAt) => {
30
30
  const findings = batch.input.findings;
31
- const outcome = (id) => batch.receipt?.items.find((item) => item.id === id)?.status ?? null;
31
+ const outcome = (id) => (batch.receipt?.items ?? batch.decided).find((item) => item.id === id)?.status ?? null;
32
32
  const project = findings.flatMap((finding) => ("project" in finding && finding.project ? [finding.project] : []))[0] ?? null;
33
33
  return {
34
34
  id: batch.id,
@@ -56,7 +56,7 @@ const rowOf = (batch, createdAt) => {
56
56
  * What an agent read in new mail, one batch per mailbox and run. Only the owner decides it — mail is text a stranger
57
57
  * wrote, so an agent that read it must not also approve what it made of it: an agent's confirmation is refused
58
58
  * whatever `agent_decisions` says. Confirming accepts the parts named, or every finding not
59
- * rejected before; the rest are rejected.
59
+ * rejected before; the rest wait. Rejecting turns down what still waits.
60
60
  */
61
61
  export const mailFindingsKind = (store) => {
62
62
  const created = async (batch) => rowOf(batch, (await store.proposedActions.get(batch.id)).createdAt);
@@ -75,7 +75,7 @@ export const mailFindingsKind = (store) => {
75
75
  limit: 50,
76
76
  offset,
77
77
  });
78
- for (const row of kept(await Promise.all(page.items.map(created)), { ...filter, limit: 50 }))
78
+ for (const row of kept(await Promise.all(page.items.map(created)), { ...filter, limit: 50 }).items)
79
79
  rows.push(row);
80
80
  if (!page.hasMore)
81
81
  break;
@@ -85,12 +85,18 @@ export const mailFindingsKind = (store) => {
85
85
  get: async (id) => created(await store.mailFindings.get(id)),
86
86
  decide: async (id, { confirm, by, parts }) => {
87
87
  const batch = await store.mailFindings.get(id);
88
- const turnedDown = new Set(batch.previous.filter((one) => one.status === "rejected").map((one) => one.id));
88
+ // A finding this batch already decided keeps its outcome; a confirm with no names takes what still waits.
89
+ const turnedDown = new Set([
90
+ ...batch.previous.filter((one) => one.status === "rejected").map((one) => one.id),
91
+ ...batch.decided.map((one) => one.id),
92
+ ]);
89
93
  const accept = !confirm
90
94
  ? []
91
95
  : (parts ?? batch.input.findings.map((finding) => finding.id).filter((one) => !turnedDown.has(one)));
92
96
  const reviewed = await store.mailFindings.review(id, { fingerprint: batch.fingerprint, accept, by });
93
- const made = (reviewed.receipt?.items ?? []).flatMap((item) => item.status === "accepted" && item.reference && !item.reused ? [item.reference] : []);
97
+ const made = (reviewed.receipt?.items ?? reviewed.decided).flatMap((item) => item.status === "accepted" && item.reference && !item.reused && accept.includes(item.id)
98
+ ? [item.reference]
99
+ : []);
94
100
  return { id, kind: "mail_findings", status: accept.length ? "confirmed" : "rejected", made };
95
101
  },
96
102
  };
@@ -6,7 +6,7 @@ import { kept } from "./shared.js";
6
6
  const rowOf = (action, batch) => {
7
7
  const findings = batch.input.findings;
8
8
  const projects = [...new Set(findings.map((one) => ("project" in one ? one.project : undefined)))];
9
- const outcome = (id) => batch.receipt?.items.find((item) => item.id === id)?.status ?? null;
9
+ const outcome = (id) => (batch.receipt?.items ?? batch.decided).find((item) => item.id === id)?.status ?? null;
10
10
  const references = [...new Set(findings.flatMap((finding) => finding.evidence.map((one) => one.reference)))];
11
11
  return {
12
12
  id: action.id,
@@ -46,7 +46,7 @@ export const meetingFindingsKind = (store) => {
46
46
  parts: true,
47
47
  ownerOnly: true,
48
48
  list: async (filter) => {
49
- const actions = await store.proposedActions.list({
49
+ const { items: actions } = await store.proposedActions.list({
50
50
  kinds: [MEETING_FINDINGS_KIND],
51
51
  ...((filter.status ?? "proposed") === "proposed" ? { status: "proposed" } : {}),
52
52
  ...(filter.by === undefined ? {} : { proposedBy: filter.by }),
@@ -61,12 +61,18 @@ export const meetingFindingsKind = (store) => {
61
61
  },
62
62
  decide: async (id, { confirm, by, parts }) => {
63
63
  const { account, batch } = await batchOf(await store.proposedActions.get(id));
64
- const turnedDown = new Set(batch.previous.filter((one) => one.status === "rejected").map((one) => one.id));
64
+ // A finding this batch already decided keeps its outcome; a confirm with no names takes what still waits.
65
+ const turnedDown = new Set([
66
+ ...batch.previous.filter((one) => one.status === "rejected").map((one) => one.id),
67
+ ...batch.decided.map((one) => one.id),
68
+ ]);
65
69
  const accept = !confirm
66
70
  ? []
67
71
  : (parts ?? batch.input.findings.map((finding) => finding.id).filter((one) => !turnedDown.has(one)));
68
72
  const reviewed = await store.meetingFindings.review(account, id, { fingerprint: batch.fingerprint, accept, by });
69
- const made = (reviewed.receipt?.items ?? []).flatMap((item) => item.status === "accepted" && item.reference && !item.reused ? [item.reference] : []);
73
+ const made = (reviewed.receipt?.items ?? reviewed.decided).flatMap((item) => item.status === "accepted" && item.reference && !item.reused && accept.includes(item.id)
74
+ ? [item.reference]
75
+ : []);
70
76
  return { id, kind: "meeting_findings", status: accept.length ? "confirmed" : "rejected", made };
71
77
  },
72
78
  };
@@ -28,7 +28,7 @@ export const memoryKind = (store) => ({
28
28
  prefix: "memory",
29
29
  list: async (filter) => {
30
30
  const status = filter.status ?? "proposed";
31
- const memories = await store.memories.list({
31
+ const { items: memories } = await store.memories.list({
32
32
  ...pushed(filter),
33
33
  ...(status === "all" ? {} : { status: status === "rejected" ? "stale" : status }),
34
34
  });
@@ -29,7 +29,7 @@ export const organizationKind = (store) => ({
29
29
  stored: [ORGANIZATION_ADD_KIND, ORGANIZATION_RENAME_KIND],
30
30
  list: async (filter) => {
31
31
  const status = storedStatus(filter);
32
- const actions = await store.proposedActions.list({
32
+ const { items: actions } = await store.proposedActions.list({
33
33
  kinds: [ORGANIZATION_ADD_KIND, ORGANIZATION_RENAME_KIND],
34
34
  ...(status === undefined ? {} : { status }),
35
35
  ...pushed(filter),
@@ -29,7 +29,7 @@ export const relationshipUpdateKind = (store) => ({
29
29
  stored: [KIND],
30
30
  list: async (filter) => {
31
31
  const status = storedStatus(filter);
32
- const stored = await store.proposedActions.list({
32
+ const { items: stored } = await store.proposedActions.list({
33
33
  kinds: [KIND],
34
34
  ...(status === undefined ? {} : { status }),
35
35
  ...pushed(filter),
@@ -61,7 +61,7 @@ export const relationshipKind = (store) => {
61
61
  stored: ["relationship"],
62
62
  list: async (filter) => {
63
63
  const status = storedStatus(filter);
64
- const stored = await store.proposedActions.list({
64
+ const { items: stored } = await store.proposedActions.list({
65
65
  kinds: ["relationship"],
66
66
  ...(status === undefined ? {} : { status }),
67
67
  ...pushed(filter),
@@ -1,3 +1,4 @@
1
+ import type { ListResult } from "@wirecat/cli-base/standards";
1
2
  import type { DecidedType } from "../../../domain/record-types.js";
2
3
  import type { Proposer } from "../../../store/decisions.js";
3
4
  import type { Decision, ProposalFilter, ProposalKind, ProposalRow } from "../types.js";
@@ -9,7 +10,7 @@ export declare const proposerOfAuthor: (author: {
9
10
  kind: "agent" | "rule" | null;
10
11
  }) => Proposer;
11
12
  /** What a kind keeps of the rows it read: the filter's status and proposer, newest first, at most `limit`. */
12
- export declare const kept: (rows: ProposalRow[], filter: ProposalFilter) => ProposalRow[];
13
+ export declare const kept: (rows: ProposalRow[], filter: ProposalFilter) => ListResult<ProposalRow>;
13
14
  /** The filters every store list takes, so a page is filled by the query and not cut after it. */
14
15
  export declare const pushed: (filter: ProposalFilter) => {
15
16
  project?: string | undefined;
@@ -44,7 +45,7 @@ export declare const reviewedKind: <T>(spec: {
44
45
  type: DecidedType;
45
46
  list: (options: ReturnType<typeof pushed> & {
46
47
  review?: "proposed" | "confirmed" | "rejected";
47
- }) => Promise<T[]>;
48
+ }) => Promise<ListResult<T>>;
48
49
  get: (id: string) => Promise<T>;
49
50
  row: (entry: T) => ProposalRow;
50
51
  decide: (id: string, confirm: boolean, decision: Pick<Decision, "by" | "reason">) => Promise<string>;
@@ -19,11 +19,11 @@ const byMatches = (row, by) => {
19
19
  /** What a kind keeps of the rows it read: the filter's status and proposer, newest first, at most `limit`. */
20
20
  export const kept = (rows, filter) => {
21
21
  const status = filter.status ?? "proposed";
22
- return rows
22
+ const matching = rows
23
23
  .filter((row) => (status === "all" || row.status === status) && byMatches(row, filter.by))
24
24
  .filter((row) => filter.project === undefined || row.project === filter.project)
25
- .sort((a, b) => b.createdAt.localeCompare(a.createdAt))
26
- .slice(0, filter.limit);
25
+ .sort((a, b) => b.createdAt.localeCompare(a.createdAt));
26
+ return { items: matching.slice(0, filter.limit), hasMore: matching.length > filter.limit };
27
27
  };
28
28
  /** The filters every store list takes, so a page is filled by the query and not cut after it. */
29
29
  export const pushed = (filter) => ({
@@ -73,7 +73,7 @@ export const reviewedKind = (spec) => ({
73
73
  list: async (filter) => {
74
74
  const status = filter.status ?? "proposed";
75
75
  const entries = await spec.list({ ...pushed(filter), ...(status === "all" ? {} : { review: status }) });
76
- return kept(entries.map(spec.row), filter);
76
+ return kept(entries.items.map(spec.row), filter);
77
77
  },
78
78
  get: async (id) => spec.row(await spec.get(id)),
79
79
  decide: async (id, { confirm, by, reason }) => {
@@ -30,7 +30,7 @@ export const sourceReviewKind = (store) => ({
30
30
  ownerOnly: true,
31
31
  list: async (filter) => {
32
32
  const status = storedStatus(filter);
33
- const stored = await store.proposedActions.list({
33
+ const { items: stored } = await store.proposedActions.list({
34
34
  kinds: [SOURCE_REVIEW_KIND],
35
35
  ...(status === undefined ? {} : { status }),
36
36
  ...pushed(filter),
@@ -42,8 +42,8 @@ export const taskCloseKind = (store) => {
42
42
  ownerOnly: true,
43
43
  list: async (filter) => {
44
44
  if ((filter.status ?? "proposed") !== "proposed" && filter.status !== "all")
45
- return [];
46
- const tasks = await store.tasks.find({
45
+ return { items: [], hasMore: false };
46
+ const { items: tasks } = await store.tasks.find({
47
47
  status: "open",
48
48
  where: { sql: "t.close_suggested_as IS NOT NULL", params: [] },
49
49
  limit: filter.offset + filter.limit,
@@ -62,7 +62,7 @@ export const emptyProposalRegistry = (store) => {
62
62
  throw new CliError("validation_error", "a proposal list takes a nonnegative offset");
63
63
  const asked = filter.kinds === undefined ? kinds : kinds.filter((kind) => filter.kinds?.includes(kind.kind));
64
64
  const wide = { ...filter, offset: 0, limit: filter.offset + filter.limit + 1 };
65
- const rows = (await Promise.all(asked.map(async (kind) => (await kind.list(wide)).map((row) => marked(kind, row)))))
65
+ const rows = (await Promise.all(asked.map(async (kind) => (await kind.list(wide)).items.map((row) => marked(kind, row)))))
66
66
  .flat()
67
67
  .filter((row) => filter.via === undefined || row.evidence.includes(filter.via));
68
68
  rows.sort((a, b) => b.createdAt.localeCompare(a.createdAt) || b.id.localeCompare(a.id));
@@ -1,3 +1,4 @@
1
+ import type { ListResult } from "@wirecat/cli-base/standards";
1
2
  import type { Decider, Proposer, Refusal } from "../../store/decisions.js";
2
3
  export interface ProposalRow {
3
4
  /** `17070` for a stored proposal; `fact:512`, `memory:88`, `link:17` and `key:9` for the kinds kept elsewhere. */
@@ -71,7 +72,7 @@ export interface ProposalKind {
71
72
  /** Only the owner decides it, whatever the host's `agent_decisions` says. */
72
73
  readonly ownerOnly?: boolean;
73
74
  /** Bounded: at most `offset + limit` rows, newest first. */
74
- list(filter: ProposalFilter): Promise<ProposalRow[]>;
75
+ list(filter: ProposalFilter): Promise<ListResult<ProposalRow>>;
75
76
  get(id: string): Promise<ProposalRow>;
76
77
  /** Called only after `mayDecide` allowed it. */
77
78
  decide(id: string, decision: Decision): Promise<Decided>;
@@ -11,14 +11,13 @@ export const BUSINESS_WORDS_ONLY = "invoices, payments, orders, contracts, subsc
11
11
  const placeOf = ({ source, imported }) => source ?? (imported === undefined ? OWN_BUSINESS : { provider: imported, account: "" });
12
12
  /** The `business` lane: numbers and names folded in memory, each hit titled as its ref reads everywhere else. */
13
13
  export const searchBusiness = async (store, { words, anyWord, window, accounts, }) => {
14
- const asked = Math.min(window + 1, BUSINESS_FIND_MAX);
15
14
  const found = await store.business.find({
16
15
  words,
17
16
  anyWord,
18
- limit: asked,
17
+ limit: Math.min(window, BUSINESS_FIND_MAX),
19
18
  ...(accounts === undefined ? {} : { accounts }),
20
19
  });
21
- const page = found.slice(0, window);
20
+ const page = found.items;
22
21
  const titles = await store.refs.summaries(page.map(({ ref }) => ref));
23
22
  return {
24
23
  items: page.map((hit) => ({
@@ -32,7 +31,7 @@ export const searchBusiness = async (store, { words, anyWord, window, accounts,
32
31
  ...(hit.source === undefined ? {} : { sourceRecord: hit.source }),
33
32
  foundBy: ["title"],
34
33
  })),
35
- hasMore: found.length > window || (asked < window + 1 && found.length === asked),
34
+ hasMore: found.hasMore,
36
35
  read: accounts ?? [...(await store.business.accounts()), OWN_BUSINESS],
37
36
  };
38
37
  };
@@ -54,7 +54,7 @@ export const titleWords = (text, refused = "deals and leads are found by the wor
54
54
  const clauses = root.kind === "boolean" ? root.clauses : [{ node: root, occur: "must" }];
55
55
  const words = clauses.map(({ node, occur }) => occur !== "must_not" &&
56
56
  node.kind === "predicate" &&
57
- node.field === "text" &&
57
+ (node.field === "text" || node.field === "title") &&
58
58
  (node.operator === "term" || node.operator === "phrase")
59
59
  ? // A title holds "invoice", not the question mark of "invoice?".
60
60
  node.value.replace(/\?+$/u, "") || node.value
@@ -249,15 +249,15 @@ export const searchAll = async (store, account, asked, messenger = {}, searchMes
249
249
  ...(request.timezone === undefined ? {} : { timezone: request.timezone }),
250
250
  ...(request.env === undefined ? {} : { env: request.env }),
251
251
  });
252
- hasMore ||= found.has_more;
252
+ hasMore ||= found.hasMore;
253
253
  notes = {
254
254
  by: found.by,
255
255
  ...(found.meaning_skipped === undefined ? {} : { meaningSkipped: found.meaning_skipped }),
256
256
  };
257
- for (const hit of found.hits)
257
+ for (const hit of found.items)
258
258
  if (hit.meaning_score !== undefined)
259
259
  cosines.set(hit.ref, hit.meaning_score);
260
- lists.push(found.hits.map((hit) => ({
260
+ lists.push(found.items.map((hit) => ({
261
261
  kind: hit.kind ?? "note",
262
262
  ref: hit.ref,
263
263
  provider: hit.provider ?? "notes",
@@ -291,15 +291,15 @@ export const searchAll = async (store, account, asked, messenger = {}, searchMes
291
291
  ...(request.timezone === undefined ? {} : { timezone: request.timezone }),
292
292
  ...(request.signal === undefined ? {} : { signal: request.signal }),
293
293
  });
294
- hasMore ||= found.has_more;
294
+ hasMore ||= found.hasMore;
295
295
  events = {
296
296
  by: found.by,
297
297
  ...(found.meaning_skipped === undefined ? {} : { meaningSkipped: found.meaning_skipped }),
298
298
  };
299
- for (const hit of found.hits)
299
+ for (const hit of found.items)
300
300
  if (hit.meaning_score !== undefined)
301
301
  cosines.set(hit.ref, hit.meaning_score);
302
- lists.push(found.hits.map((hit) => ({
302
+ lists.push(found.items.map((hit) => ({
303
303
  kind: "event",
304
304
  ref: hit.ref,
305
305
  provider: hit.provider ?? "calendar",
@@ -313,10 +313,6 @@ export const searchAll = async (store, account, asked, messenger = {}, searchMes
313
313
  accounts.push(...read.map(({ provider, account }) => ({ resource, provider, account })));
314
314
  }
315
315
  else if (resource === "crm") {
316
- // `plainQuery` made `stage:won` a phrase, which would find nothing and still call the answer complete.
317
- const field = /(?:^|\s)[+-]?(stage|status|pipeline):/iu.exec(asked.text)?.[1]?.toLowerCase();
318
- if (field)
319
- throw new CliError("validation_error", `deals and leads are not searched by ${field}; list them by it with \`deals list ${field}:<value>\``);
320
316
  const { words, anyWord } = titleWords(request.text);
321
317
  const chosen = scope?.crm;
322
318
  const found = await store.deals.find({
@@ -324,11 +320,14 @@ export const searchAll = async (store, account, asked, messenger = {}, searchMes
324
320
  anyWord: anyWord || discover,
325
321
  ...(request.exact ? { exact: true } : {}),
326
322
  ...(request.crmKinds === undefined ? {} : { kinds: request.crmKinds }),
327
- limit: Math.min(depth + 1, 500),
323
+ limit: Math.min(depth, 500),
328
324
  ...(chosen === undefined ? {} : { accounts: chosen }),
329
325
  });
330
- hasMore ||= found.length > depth;
331
- lists.push(found.slice(0, depth).map((deal) => ({
326
+ hasMore ||= found.hasMore;
327
+ const titled = /(?:^|[\s(+])title:/u.test(request.text);
328
+ lists.push(found.items
329
+ .filter((deal) => !titled || deal.matched.includes("title"))
330
+ .map((deal) => ({
332
331
  kind: deal.kind,
333
332
  ref: deal.ref,
334
333
  provider: deal.account?.provider ?? "crm",
@@ -1,3 +1,4 @@
1
+ import type { ListResult } from "@wirecat/cli-base/standards";
1
2
  import type * as v from "valibot";
2
3
  import type { savedSearch } from "../entities/saved-search.js";
3
4
  import type { StoredSearch } from "../store/store.js";
@@ -19,10 +20,7 @@ export interface SearchesService {
19
20
  }): Promise<StoredSearch>;
20
21
  show(reference: string): Promise<StoredSearch>;
21
22
  list(): Promise<StoredSearch[]>;
22
- history(limit: number, offset?: number): Promise<{
23
- items: StoredSearch[];
24
- has_more: boolean;
25
- }>;
23
+ history(limit: number, offset?: number): Promise<ListResult<StoredSearch>>;
26
24
  delete(reference: string): Promise<StoredSearch>;
27
25
  clear(): Promise<{
28
26
  cleared: number;
@@ -101,10 +101,7 @@ export const searchesService = (deps) => {
101
101
  }),
102
102
  show: (reference) => inStore((store) => found(store, reference)),
103
103
  list: () => inStore((store) => store.searches.savedSearches(MESSAGE_SEARCH_COMMANDS)),
104
- history: (limit, offset = 0) => inStore(async (store) => {
105
- const rows = await store.searches.searchHistory(limit, offset, MESSAGE_SEARCH_COMMANDS);
106
- return { items: rows.slice(0, limit), has_more: rows.length > limit };
107
- }),
104
+ history: (limit, offset = 0) => inStore((store) => store.searches.searchHistory(limit, offset, MESSAGE_SEARCH_COMMANDS)),
108
105
  delete: (reference) => inStore(async (store) => store.searches.deleteSearch((await found(store, reference)).id)),
109
106
  clear: () => inStore(async (store) => ({ cleared: await store.searches.clearSearchHistory(MESSAGE_SEARCH_COMMANDS) })),
110
107
  resolve: (reference, { text: words, ...typed }) => inStore(async (store) => {
@@ -103,7 +103,12 @@ const LINKED_CHATS = 16;
103
103
  const CORE_LIMIT = 16;
104
104
  /** Pending `member-of` proposals to the project, oldest first, so a cut at a limit always drops the same ones. */
105
105
  const proposedLinksOf = async (store, project) => {
106
- const stored = await store.proposedActions.list({ kinds: ["relationship"], status: "proposed", project, limit: 500 });
106
+ const { items: stored } = await store.proposedActions.list({
107
+ kinds: ["relationship"],
108
+ status: "proposed",
109
+ project,
110
+ limit: 500,
111
+ });
107
112
  const proposals = stored
108
113
  .flatMap((action) => {
109
114
  const payload = action.payload;