@wirecat/cli-core 0.641.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 (287) hide show
  1. package/CHANGELOG.md +218 -0
  2. package/dist/analysis/provider.d.ts +1 -1
  3. package/dist/analysis/provider.js +2 -1
  4. package/dist/attachments/gateway-ocr.js +13 -8
  5. package/dist/attachments/ocr.js +27 -18
  6. package/dist/attachments/picture-reading.d.ts +51 -0
  7. package/dist/attachments/picture-reading.js +207 -0
  8. package/dist/background/backfill.d.ts +4 -2
  9. package/dist/background/backfill.js +3 -3
  10. package/dist/background/schedules.d.ts +28 -2
  11. package/dist/background/schedules.js +73 -20
  12. package/dist/background/units.d.ts +2 -0
  13. package/dist/background/units.js +8 -9
  14. package/dist/calendar/cli/index.js +10 -2
  15. package/dist/calendar/feeds.js +2 -2
  16. package/dist/calendar/mcp/index.d.ts +12 -12
  17. package/dist/calendar/server-search.js +2 -2
  18. package/dist/calendar/source.d.ts +4 -3
  19. package/dist/calendar/sync.js +12 -10
  20. package/dist/calendar/testing/source-contract.js +5 -4
  21. package/dist/calendar/testing/source.js +3 -2
  22. package/dist/cli/ai-model-command.js +6 -3
  23. package/dist/cli/analysis-choice.js +20 -4
  24. package/dist/cli/complete-command.d.ts +23 -0
  25. package/dist/cli/complete-command.js +80 -0
  26. package/dist/cli/context.js +7 -1
  27. package/dist/cli/effects.d.ts +2 -0
  28. package/dist/cli/effects.js +2 -0
  29. package/dist/cli/enrichment-consents-command.js +2 -0
  30. package/dist/cli/envelope.js +6 -1
  31. package/dist/cli/help/first-screen.js +5 -0
  32. package/dist/cli/index.d.ts +4 -2
  33. package/dist/cli/index.js +2 -1
  34. package/dist/cli/list-query.d.ts +3 -1
  35. package/dist/cli/list-query.js +5 -3
  36. package/dist/cli/local-only-command.d.ts +10 -0
  37. package/dist/cli/local-only-command.js +112 -0
  38. package/dist/cli/messenger/backfill-command.js +1 -1
  39. package/dist/cli/messenger/chat-queries.js +2 -1
  40. package/dist/cli/messenger/complete-command.d.ts +4 -7
  41. package/dist/cli/messenger/complete-command.js +31 -98
  42. package/dist/cli/messenger/contacts-command.js +4 -0
  43. package/dist/cli/messenger/conversations-command.js +1 -1
  44. package/dist/cli/messenger/guard-commands.js +1 -1
  45. package/dist/cli/messenger/images-command.js +32 -0
  46. package/dist/cli/messenger/list-result-queries.d.ts +1 -0
  47. package/dist/cli/messenger/list-result-queries.js +2 -1
  48. package/dist/cli/messenger/mentions-command.js +3 -3
  49. package/dist/cli/messenger/message-items.js +1 -0
  50. package/dist/cli/messenger/messages-command.js +7 -6
  51. package/dist/cli/messenger/people-queries.d.ts +2 -2
  52. package/dist/cli/messenger/people-queries.js +4 -4
  53. package/dist/cli/messenger/replies-consents-command.js +12 -6
  54. package/dist/cli/messenger/search-answers.js +2 -2
  55. package/dist/cli/messenger/search-command.js +3 -3
  56. package/dist/cli/messenger/searches-command.js +1 -1
  57. package/dist/cli/messenger/store-maintenance-command.js +4 -0
  58. package/dist/cli/messenger/tasks-analysis-command.js +1 -1
  59. package/dist/cli/messenger/tasks-command.js +2 -2
  60. package/dist/cli/model-catalogue-command.js +4 -0
  61. package/dist/cli/picture-reading-command.d.ts +12 -0
  62. package/dist/cli/picture-reading-command.js +82 -0
  63. package/dist/cli/program.d.ts +6 -0
  64. package/dist/cli/program.js +28 -2
  65. package/dist/cli/schedule/agent-start.d.ts +23 -0
  66. package/dist/cli/schedule/agent-start.js +115 -0
  67. package/dist/cli/schedule/harnesses.d.ts +203 -0
  68. package/dist/cli/schedule/harnesses.js +278 -0
  69. package/dist/cli/schedule/schedule-command.d.ts +9 -5
  70. package/dist/cli/schedule/schedule-command.js +89 -79
  71. package/dist/cli/search-harder-consents-command.js +16 -1
  72. package/dist/cli/shared-command-exports.d.ts +186 -0
  73. package/dist/cli/shared-command-exports.js +2 -0
  74. package/dist/cli/untrusted-marks.d.ts +25 -0
  75. package/dist/cli/untrusted-marks.js +102 -0
  76. package/dist/crm/cli/index.d.ts +1 -0
  77. package/dist/crm/cli/index.js +6 -5
  78. package/dist/crm/cli/store.d.ts +30 -0
  79. package/dist/crm/cli/store.js +63 -0
  80. package/dist/crm/source.d.ts +6 -4
  81. package/dist/crm/sync.js +10 -6
  82. package/dist/crm/testing/source-contract.js +9 -7
  83. package/dist/crm/testing/source.js +6 -2
  84. package/dist/crm/testing/sync-contract.js +4 -4
  85. package/dist/crm/writes.d.ts +5 -2
  86. package/dist/crm/writes.js +1 -1
  87. package/dist/documents.d.ts +2 -1
  88. package/dist/documents.js +2 -1
  89. package/dist/domain/addresses.d.ts +2 -0
  90. package/dist/domain/addresses.js +7 -0
  91. package/dist/domain/attachments.d.ts +2 -0
  92. package/dist/domain/attachments.js +2 -1
  93. package/dist/domain/models.d.ts +2 -0
  94. package/dist/embeddings/remote.d.ts +2 -1
  95. package/dist/embeddings/remote.js +5 -3
  96. package/dist/entities/attachment-results.d.ts +3 -0
  97. package/dist/entities/attachment-results.js +3 -0
  98. package/dist/entities/attachment.d.ts +2 -0
  99. package/dist/entities/attachment.js +8 -1
  100. package/dist/entities/hit.d.ts +1 -0
  101. package/dist/entities/index.d.ts +21 -4
  102. package/dist/entities/index.js +3 -2
  103. package/dist/entities/list-results.d.ts +33 -5
  104. package/dist/entities/list-results.js +33 -5
  105. package/dist/errors/reasons.js +38 -1
  106. package/dist/mail/cli/index.js +7 -6
  107. package/dist/mcp/agent.d.ts +2 -1
  108. package/dist/mcp/agent.js +5 -0
  109. package/dist/mcp/app-server.js +10 -0
  110. package/dist/mcp/surface.d.ts +7 -2
  111. package/dist/mcp/surface.js +49 -10
  112. package/dist/meetings/cli/index.js +6 -1
  113. package/dist/meetings/mcp/index.js +6 -3
  114. package/dist/meetings/participant-search.d.ts +2 -2
  115. package/dist/meetings/project-discovery.d.ts +1 -1
  116. package/dist/meetings/project-evidence-answer.js +2 -2
  117. package/dist/meetings/reads.d.ts +2 -2
  118. package/dist/meetings/reads.js +6 -6
  119. package/dist/meetings/store.d.ts +2 -1
  120. package/dist/meetings/testing/contract.js +6 -6
  121. package/dist/meetings/testing/memory.js +7 -2
  122. package/dist/models/ai.d.ts +17 -4
  123. package/dist/models/ai.js +22 -14
  124. package/dist/models/anthropic.js +15 -9
  125. package/dist/models/endpoint.d.ts +5 -0
  126. package/dist/models/endpoint.js +13 -0
  127. package/dist/models/index.d.ts +4 -0
  128. package/dist/models/index.js +14 -4
  129. package/dist/models/local-only.d.ts +17 -0
  130. package/dist/models/local-only.js +42 -0
  131. package/dist/models/openai.js +24 -11
  132. package/dist/models/purpose.d.ts +24 -0
  133. package/dist/models/purpose.js +26 -0
  134. package/dist/models/types.d.ts +8 -0
  135. package/dist/models/types.js +11 -1
  136. package/dist/ports/app.d.ts +17 -1
  137. package/dist/ports/app.js +63 -3
  138. package/dist/replies/rendering.js +10 -10
  139. package/dist/search/lucene/plain.js +45 -3
  140. package/dist/search/lucene/registry.d.ts +15 -4
  141. package/dist/search/lucene/registry.js +70 -12
  142. package/dist/search/lucene/types.d.ts +2 -0
  143. package/dist/search/lucene/types.js +12 -0
  144. package/dist/sends/upload.d.ts +8 -1
  145. package/dist/sends/upload.js +35 -14
  146. package/dist/services/account-groups.d.ts +11 -0
  147. package/dist/services/account-groups.js +29 -0
  148. package/dist/services/agenda.js +1 -0
  149. package/dist/services/attachments.d.ts +18 -4
  150. package/dist/services/attachments.js +66 -15
  151. package/dist/services/conversations.d.ts +2 -4
  152. package/dist/services/conversations.js +1 -1
  153. package/dist/services/deal-context.js +5 -5
  154. package/dist/services/documents/ingestion.js +3 -3
  155. package/dist/services/documents/knowledge.d.ts +6 -6
  156. package/dist/services/documents/knowledge.js +1 -2
  157. package/dist/services/embeddings-maintenance.js +4 -1
  158. package/dist/services/enrichment.d.ts +1 -1
  159. package/dist/services/enrichment.js +27 -0
  160. package/dist/services/events-search.d.ts +3 -3
  161. package/dist/services/events-search.js +7 -7
  162. package/dist/services/index.d.ts +1 -1
  163. package/dist/services/index.js +1 -1
  164. package/dist/services/meeting-model.js +1 -1
  165. package/dist/services/meeting-project-discovery.js +1 -1
  166. package/dist/services/message-resolution.js +10 -3
  167. package/dist/services/messages-search.js +6 -4
  168. package/dist/services/metadata.d.ts +1 -1
  169. package/dist/services/notes-search.d.ts +3 -3
  170. package/dist/services/notes-search.js +3 -3
  171. package/dist/services/organization-context.js +12 -9
  172. package/dist/services/people.d.ts +2 -0
  173. package/dist/services/people.js +4 -2
  174. package/dist/services/pictures.d.ts +9 -0
  175. package/dist/services/pictures.js +34 -28
  176. package/dist/services/project-status/index.js +1 -1
  177. package/dist/services/project-status/signals/payments.js +4 -2
  178. package/dist/services/project-status/signals/promises.js +5 -2
  179. package/dist/services/proposals/kinds/action.js +1 -1
  180. package/dist/services/proposals/kinds/fact.js +1 -1
  181. package/dist/services/proposals/kinds/findings.d.ts +2 -1
  182. package/dist/services/proposals/kinds/findings.js +12 -5
  183. package/dist/services/proposals/kinds/identity-link.js +1 -1
  184. package/dist/services/proposals/kinds/identity-split.js +1 -1
  185. package/dist/services/proposals/kinds/key-document.js +1 -1
  186. package/dist/services/proposals/kinds/mail-findings.d.ts +1 -1
  187. package/dist/services/proposals/kinds/mail-findings.js +11 -5
  188. package/dist/services/proposals/kinds/meeting-findings.js +10 -4
  189. package/dist/services/proposals/kinds/memory.js +1 -1
  190. package/dist/services/proposals/kinds/organization.js +1 -1
  191. package/dist/services/proposals/kinds/relationship-update.js +1 -1
  192. package/dist/services/proposals/kinds/relationship.js +1 -1
  193. package/dist/services/proposals/kinds/shared.d.ts +3 -2
  194. package/dist/services/proposals/kinds/shared.js +4 -4
  195. package/dist/services/proposals/kinds/source-review.js +1 -1
  196. package/dist/services/proposals/kinds/task-close.js +2 -2
  197. package/dist/services/proposals/registry.js +1 -1
  198. package/dist/services/proposals/types.d.ts +2 -1
  199. package/dist/services/search-all-business.js +3 -4
  200. package/dist/services/search-all.js +13 -14
  201. package/dist/services/search-harder.d.ts +11 -1
  202. package/dist/services/search-harder.js +38 -5
  203. package/dist/services/searches.d.ts +2 -4
  204. package/dist/services/searches.js +1 -4
  205. package/dist/services/stored-project-gathering.js +6 -1
  206. package/dist/services/tags.d.ts +2 -4
  207. package/dist/services/tags.js +1 -1
  208. package/dist/services/tasks.d.ts +1 -1
  209. package/dist/services/tasks.js +4 -3
  210. package/dist/speech/openai.js +2 -0
  211. package/dist/speech/transcribe.d.ts +5 -2
  212. package/dist/speech/transcribe.js +14 -5
  213. package/dist/store/account-store.d.ts +2 -1
  214. package/dist/store/account-store.js +3 -1
  215. package/dist/store/accounts.d.ts +2 -0
  216. package/dist/store/accounts.js +8 -0
  217. package/dist/store/chats.d.ts +5 -0
  218. package/dist/store/chats.js +4 -0
  219. package/dist/store/evidence-findings.d.ts +9 -0
  220. package/dist/store/exports.d.ts +1 -1
  221. package/dist/store/exports.js +1 -1
  222. package/dist/store/identity-links.d.ts +3 -1
  223. package/dist/store/mail-findings.d.ts +9 -0
  224. package/dist/store/meeting-findings.d.ts +9 -0
  225. package/dist/store/searches.d.ts +3 -2
  226. package/dist/store/sqlite/accounts.js +37 -0
  227. package/dist/store/sqlite/agent-actions.d.ts +2 -1
  228. package/dist/store/sqlite/agent-actions.js +10 -4
  229. package/dist/store/sqlite/business-contracts.d.ts +3 -1
  230. package/dist/store/sqlite/business-contracts.js +7 -3
  231. package/dist/store/sqlite/business-search.d.ts +2 -1
  232. package/dist/store/sqlite/business-search.js +6 -4
  233. package/dist/store/sqlite/deals.d.ts +6 -4
  234. package/dist/store/sqlite/deals.js +12 -7
  235. package/dist/store/sqlite/evidence-findings.js +78 -9
  236. package/dist/store/sqlite/facts.d.ts +2 -1
  237. package/dist/store/sqlite/facts.js +6 -2
  238. package/dist/store/sqlite/finance.d.ts +4 -2
  239. package/dist/store/sqlite/finance.js +13 -6
  240. package/dist/store/sqlite/findings-core.d.ts +56 -2
  241. package/dist/store/sqlite/findings-core.js +109 -22
  242. package/dist/store/sqlite/identities.d.ts +4 -0
  243. package/dist/store/sqlite/identities.js +12 -3
  244. package/dist/store/sqlite/identity-proposals.js +34 -4
  245. package/dist/store/sqlite/lucene-fields.d.ts +2 -0
  246. package/dist/store/sqlite/lucene-fields.js +28 -2
  247. package/dist/store/sqlite/lucene.js +21 -10
  248. package/dist/store/sqlite/mail-findings.js +60 -22
  249. package/dist/store/sqlite/meeting-findings.js +53 -7
  250. package/dist/store/sqlite/meeting-participant-search.js +4 -5
  251. package/dist/store/sqlite/meetings.js +7 -3
  252. package/dist/store/sqlite/memories.d.ts +4 -2
  253. package/dist/store/sqlite/memories.js +13 -6
  254. package/dist/store/sqlite/money-transactions.d.ts +3 -1
  255. package/dist/store/sqlite/money-transactions.js +7 -3
  256. package/dist/store/sqlite/name-traces.d.ts +3 -3
  257. package/dist/store/sqlite/name-traces.js +29 -2
  258. package/dist/store/sqlite/orders.d.ts +3 -1
  259. package/dist/store/sqlite/orders.js +5 -2
  260. package/dist/store/sqlite/people-list.js +67 -22
  261. package/dist/store/sqlite/person-match-scan.d.ts +3 -1
  262. package/dist/store/sqlite/person-match-scan.js +97 -7
  263. package/dist/store/sqlite/products.d.ts +3 -1
  264. package/dist/store/sqlite/products.js +5 -2
  265. package/dist/store/sqlite/proposed-actions.d.ts +2 -1
  266. package/dist/store/sqlite/proposed-actions.js +7 -3
  267. package/dist/store/sqlite/query-filter.d.ts +4 -0
  268. package/dist/store/sqlite/query-filter.js +14 -0
  269. package/dist/store/sqlite/reads.d.ts +1 -0
  270. package/dist/store/sqlite/reads.js +14 -0
  271. package/dist/store/sqlite/records.d.ts +3 -1
  272. package/dist/store/sqlite/records.js +7 -5
  273. package/dist/store/sqlite/rows-page.d.ts +3 -0
  274. package/dist/store/sqlite/rows-page.js +4 -0
  275. package/dist/store/sqlite/searches.d.ts +2 -1
  276. package/dist/store/sqlite/searches.js +3 -1
  277. package/dist/store/sqlite/subscriptions.d.ts +5 -2
  278. package/dist/store/sqlite/subscriptions.js +13 -6
  279. package/dist/store/sqlite/task-board.js +27 -0
  280. package/dist/store/sqlite/task-find.d.ts +15 -0
  281. package/dist/store/sqlite/task-find.js +1 -0
  282. package/dist/store/sqlite/wallets.d.ts +3 -1
  283. package/dist/store/sqlite/wallets.js +7 -3
  284. package/dist/store/sqlite/work-tasks.d.ts +3 -11
  285. package/dist/store/sqlite/work-tasks.js +8 -4
  286. package/package.json +2 -2
  287. package/parity.json +24 -0
@@ -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",
@@ -12,6 +12,11 @@ export declare const HARDER_MODELS: Readonly<Record<EnrichmentProvider, string>>
12
12
  /** The search lab's setup (cli-testing search-lab, "Haiku rerank"): the top 30, each cut to 400 characters. */
13
13
  export declare const HARDER_CANDIDATES = 30;
14
14
  export declare const HARDER_CHARS = 400;
15
+ /** A hosted model answers in 1 to 2 s; a model on this computer's CPU can take tens of seconds for 30 hits. */
16
+ export declare const HARDER_TIMEOUT_S: {
17
+ readonly hosted: 5;
18
+ readonly local: 60;
19
+ };
15
20
  declare const Setting: v.StrictObjectSchema<{
16
21
  readonly provider: v.PicklistSchema<readonly ["openai", "anthropic"], undefined>;
17
22
  readonly model: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 200, undefined>]>;
@@ -23,7 +28,11 @@ export type HarderSetting = v.InferOutput<typeof Setting>;
23
28
  /** The owner's consent, or `undefined`: no section means `--harder` sends nothing. */
24
29
  export declare const readHarderSetting: (env: NodeJS.ProcessEnv) => HarderSetting | undefined;
25
30
  export declare const writeHarderSetting: (env: NodeJS.ProcessEnv, setting: HarderSetting | undefined) => void;
26
- export declare const HARDER_REASON_IDS: readonly ["harder.no-consent", "harder.no-key", "harder.bad-setting", "harder.later-page", "harder.too-few", "harder.timeout", "harder.key-rejected", "harder.unreachable", "harder.rate-limited", "harder.bad-reply", "harder.error"];
31
+ /** The owner's time limit in seconds, or `undefined` for the default by where the model runs. */
32
+ export declare const readHarderTimeout: (env: NodeJS.ProcessEnv) => number | undefined;
33
+ export declare const writeHarderTimeout: (env: NodeJS.ProcessEnv, seconds: number | undefined) => void;
34
+ export declare const harderTimeoutSeconds: (env: NodeJS.ProcessEnv, endpoint: string) => number;
35
+ export declare const HARDER_REASON_IDS: readonly ["harder.no-consent", "harder.no-key", "harder.bad-setting", "harder.local-only", "harder.address-refused", "harder.later-page", "harder.too-few", "harder.timeout", "harder.key-rejected", "harder.unreachable", "harder.rate-limited", "harder.bad-reply", "harder.error"];
27
36
  export type HarderReasonId = (typeof HARDER_REASON_IDS)[number];
28
37
  /** What `--harder` did: `applied` only when the model's order replaced the plain one. */
29
38
  export interface HarderResult {
@@ -70,6 +79,7 @@ export type HarderAccess = {
70
79
  model: string;
71
80
  endpoint: string;
72
81
  custom: boolean;
82
+ timeoutMs: number;
73
83
  key?: string;
74
84
  } | {
75
85
  ready: false;
@@ -1,6 +1,8 @@
1
1
  import { CliError } from "@wirecat/cli-base";
2
2
  import * as v from "valibot";
3
+ import { modelAddressAllowed, onThisComputer } from "../models/endpoint.js";
3
4
  import { modelGateway } from "../models/index.js";
5
+ import { localOnly } from "../models/local-only.js";
4
6
  import { readSharedSection, writeSharedSection } from "../store/shared-config.js";
5
7
  import { keyLookup, keyVariable } from "./enrichment.js";
6
8
  import { costOf, enrichmentEndpoint, enrichmentSettingPath, MODEL_CHOICE, } from "./enrichment-setting.js";
@@ -16,7 +18,9 @@ export const HARDER_MODELS = {
16
18
  /** The search lab's setup (cli-testing search-lab, "Haiku rerank"): the top 30, each cut to 400 characters. */
17
19
  export const HARDER_CANDIDATES = 30;
18
20
  export const HARDER_CHARS = 400;
19
- const TIMEOUT_MS = 5_000;
21
+ /** A hosted model answers in 1 to 2 s; a model on this computer's CPU can take tens of seconds for 30 hits. */
22
+ export const HARDER_TIMEOUT_S = { hosted: 5, local: 60 };
23
+ const TIMEOUT_SECTION = "search_harder_timeout_s";
20
24
  const Setting = v.strictObject({
21
25
  ...MODEL_CHOICE,
22
26
  /** When the owner agreed that a `--harder` search sends its question and hits; the setting exists only with it. */
@@ -34,10 +38,22 @@ export const readHarderSetting = (env) => {
34
38
  return checked.output;
35
39
  };
36
40
  export const writeHarderSetting = (env, setting) => writeSharedSection(enrichmentSettingPath(env), SECTION, setting === undefined ? undefined : v.parse(Setting, setting));
41
+ // Its own key beside search_harder: an older tool reads that section strictly and would refuse a new field in it.
42
+ const Timeout = v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(600));
43
+ /** The owner's time limit in seconds, or `undefined` for the default by where the model runs. */
44
+ export const readHarderTimeout = (env) => {
45
+ const value = readSharedSection(enrichmentSettingPath(env), TIMEOUT_SECTION);
46
+ const checked = v.safeParse(Timeout, value);
47
+ return checked.success ? checked.output : undefined;
48
+ };
49
+ export const writeHarderTimeout = (env, seconds) => writeSharedSection(enrichmentSettingPath(env), TIMEOUT_SECTION, seconds === undefined ? undefined : v.parse(Timeout, seconds));
50
+ export const harderTimeoutSeconds = (env, endpoint) => readHarderTimeout(env) ?? (onThisComputer(endpoint) ? HARDER_TIMEOUT_S.local : HARDER_TIMEOUT_S.hosted);
37
51
  export const HARDER_REASON_IDS = [
38
52
  "harder.no-consent",
39
53
  "harder.no-key",
40
54
  "harder.bad-setting",
55
+ "harder.local-only",
56
+ "harder.address-refused",
41
57
  "harder.later-page",
42
58
  "harder.too-few",
43
59
  "harder.timeout",
@@ -87,7 +103,9 @@ const REASON_TEXT = {
87
103
  "harder.bad-setting": "the search_harder setting cannot be read; nothing was sent",
88
104
  "harder.later-page": "--harder reorders the first page only; nothing was sent",
89
105
  "harder.too-few": "fewer than two hits to reorder; nothing was sent",
90
- "harder.timeout": `the model did not answer within ${TIMEOUT_MS / 1000} s`,
106
+ "harder.address-refused": "the address is plain http to another computer: use https, or http only on this computer; nothing was sent",
107
+ "harder.local-only": "local only is on and the model is not on this computer; nothing was sent",
108
+ "harder.timeout": "the model did not answer within the time limit",
91
109
  "harder.key-rejected": "the provider refused the key",
92
110
  "harder.unreachable": "the provider could not be reached",
93
111
  "harder.rate-limited": "the provider's rate limit was reached",
@@ -135,6 +153,15 @@ export const harderAccess = ({ env, command, ...options }) => {
135
153
  endpoint: enrichmentEndpoint(setting),
136
154
  custom: setting.base_url !== undefined,
137
155
  };
156
+ if (!modelAddressAllowed(chosen.endpoint))
157
+ return {
158
+ ready: false,
159
+ ...chosen,
160
+ reason_id: "harder.address-refused",
161
+ reason: REASON_TEXT["harder.address-refused"],
162
+ };
163
+ if (!onThisComputer(chosen.endpoint) && localOnly(env))
164
+ return { ready: false, ...chosen, reason_id: "harder.local-only", reason: REASON_TEXT["harder.local-only"] };
138
165
  let key;
139
166
  try {
140
167
  key = keyLookup({ env, ...options }, setting)?.key;
@@ -155,17 +182,23 @@ export const harderAccess = ({ env, command, ...options }) => {
155
182
  reason_id: "harder.no-key",
156
183
  reason: `no ${setting.provider} key: \`${tool} models keys set ${setting.provider}\` or set ${keyVariable(setting.provider)}; nothing was sent`,
157
184
  };
158
- return { ready: true, ...chosen, ...(key === undefined ? {} : { key }) };
185
+ return {
186
+ ready: true,
187
+ ...chosen,
188
+ timeoutMs: options.timeoutMs ?? harderTimeoutSeconds(env, chosen.endpoint) * 1000,
189
+ ...(key === undefined ? {} : { key }),
190
+ };
159
191
  };
160
- /** One call to the model under the 5 s limit; a failure comes back as its reason, never thrown. */
192
+ /** One call to the model under the time limit; a failure comes back as its reason, never thrown. */
161
193
  const ask = async (access, options, request) => {
162
194
  const limit = new AbortController();
163
- const timer = setTimeout(() => limit.abort(), options.timeoutMs ?? TIMEOUT_MS);
195
+ const timer = setTimeout(() => limit.abort(), access.timeoutMs);
164
196
  const gateway = modelGateway({
165
197
  resolve: () => ({ provider: access.provider, model: access.model, baseUrl: access.endpoint }),
166
198
  consent: (_request, chosen) => chosen.provider === access.provider && chosen.baseUrl === access.endpoint,
167
199
  key: () => access.key,
168
200
  signal: limit.signal,
201
+ env: options.env,
169
202
  ...(options.adapters ? { adapters: options.adapters } : {}),
170
203
  ...(options.fetch ? { fetch: options.fetch } : {}),
171
204
  });
@@ -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;
@@ -1,4 +1,5 @@
1
1
  import { type QueryAst } from "@wirecat/cli-base/query";
2
+ import type { ListResult } from "@wirecat/cli-base/standards";
2
3
  import type * as v from "valibot";
3
4
  import type { Id } from "../domain/models.js";
4
5
  import { type TagType } from "../domain/tags.js";
@@ -40,10 +41,7 @@ export interface TagsService {
40
41
  query?: QueryAst;
41
42
  limit: number;
42
43
  offset: number;
43
- }): Promise<{
44
- items: TaggingItem[];
45
- has_more: boolean;
46
- }>;
44
+ }): Promise<ListResult<TaggingItem>>;
47
45
  }
48
46
  export type TaggingItem = v.InferOutput<typeof tagging>;
49
47
  export declare const TAGGING_QUERY: {
@@ -98,7 +98,7 @@ export const tagsService = (deps) => {
98
98
  ...(where ? { where } : {}),
99
99
  window: { limit: limit + 1, offset },
100
100
  });
101
- return { items: rows.slice(0, limit).map((one) => taggingOf(account, one)), has_more: rows.length > limit };
101
+ return { items: rows.slice(0, limit).map((one) => taggingOf(account, one)), hasMore: rows.length > limit };
102
102
  }),
103
103
  };
104
104
  };
@@ -65,7 +65,7 @@ export interface TaskListRequest {
65
65
  }
66
66
  export interface TaskList {
67
67
  items: TaskItem[];
68
- has_more: boolean;
68
+ hasMore: boolean;
69
69
  previews?: TaskView[];
70
70
  }
71
71
  /**
@@ -4,7 +4,7 @@ import { isLocator, parseLocator } from "../domain/locator.js";
4
4
  import { formatReference } from "../domain/references.js";
5
5
  import { task as taskEntity } from "../entities/task.js";
6
6
  import { certaintyOf, TASK_RELATION_KINDS, } from "../store/index.js";
7
- import { queryFilter } from "../store/store.js";
7
+ import { foldedWords, queryFilter } from "../store/store.js";
8
8
  import { createTaskService, isClosedState, TASK_KINDS, TASK_STATES, } from "../tasks/index.js";
9
9
  import { storedChatId } from "./message-resolution.js";
10
10
  import { categorize, taskCategoryOf } from "./task-categories.js";
@@ -17,6 +17,7 @@ export const TASK_QUERY = {
17
17
  backend: "sql",
18
18
  fields: queryFieldsOf(taskEntity, {
19
19
  exclude: ["ref", "description", "project", "account", "priority", "parent", "claimed_until", "close_suggestion"],
20
+ text: ["title"],
20
21
  relations: {
21
22
  close: {
22
23
  type: "enum",
@@ -81,7 +82,7 @@ const taskColumns = (groups, tags) => ({
81
82
  key: { type: "kw", sql: "t.key" },
82
83
  category: { type: "kw", sql: "t.category" },
83
84
  tag: { where: (node) => tags.get(node.value) ?? { sql: "0", params: [] } },
84
- title: { type: "kw", sql: "t.title_folded", folded: true },
85
+ title: foldedWords("t.title_folded"),
85
86
  kind: { type: "enum", sql: "t.type" },
86
87
  state: { type: "enum", sql: "t.status" },
87
88
  origin: { type: "enum", sql: "t.source" },
@@ -235,7 +236,7 @@ export const tasksService = (deps, categories) => {
235
236
  const shown = rows.slice(0, limit);
236
237
  return {
237
238
  items: shown.map((row) => taskItem(account, row)),
238
- has_more: rows.length > limit,
239
+ hasMore: rows.length > limit,
239
240
  ...(previews ? { previews: await Promise.all(shown.map(({ task }) => taskView(store, account, task))) } : {}),
240
241
  };
241
242
  }),
@@ -2,6 +2,7 @@ import { setTimeout as wait } from "node:timers/promises";
2
2
  import { backoffMs, CliError, DEFAULT_RETRY } from "@wirecat/cli-base";
3
3
  import { providerWaitMs } from "@wirecat/cli-base/http";
4
4
  import { OPENAI_URL } from "../embeddings/remote.js";
5
+ import { refuseModelAddress } from "../models/local-only.js";
5
6
  import { filesPresent, modelsDirectory, vadPath } from "./install.js";
6
7
  import { OPENAI_TRANSCRIBE_MODEL, VAD } from "./models.js";
7
8
  import { SAMPLE_RATE, toModelRate } from "./recognize.js";
@@ -161,6 +162,7 @@ const checkKeywords = (keywords = []) => {
161
162
  * dialogue by `start`. `gpt-transcribe` gives no timestamps of its own, so the times are the detector's.
162
163
  */
163
164
  export const transcribeOpenAI = async (audio, options) => {
165
+ refuseModelAddress(options.env ?? process.env, options.baseUrl ?? OPENAI_URL, "audio");
164
166
  if (!options.apiKey)
165
167
  throw new CliError("authentication_error", "no OpenAI key — `models keys set openai`, or OPENAI_API_KEY", {
166
168
  reason: "transcription.no-key",