@wirecat/cli-core 0.618.0 → 0.620.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (335) hide show
  1. package/CHANGELOG.md +453 -1
  2. package/README.md +1 -1
  3. package/THIRD_PARTY_NOTICES +3 -0
  4. package/dist/background/deliver.d.ts +5 -2
  5. package/dist/background/deliver.js +30 -12
  6. package/dist/background/report/render.d.ts +3 -1
  7. package/dist/background/report/render.js +3 -1
  8. package/dist/calendar/cli/answers.d.ts +1 -0
  9. package/dist/calendar/cli/answers.js +6 -1
  10. package/dist/calendar/cli/index.js +2 -14
  11. package/dist/calendar/cli/people-link.d.ts +3 -0
  12. package/dist/calendar/cli/people-link.js +23 -0
  13. package/dist/calendar/cli/search-all.d.ts +1 -1
  14. package/dist/calendar/cli/search-all.js +9 -10
  15. package/dist/calendar/index.d.ts +1 -1
  16. package/dist/calendar/index.js +1 -1
  17. package/dist/calendar/mcp/index.d.ts +12 -12
  18. package/dist/calendar/prepare.js +1 -0
  19. package/dist/cli/base-stages-command.d.ts +22 -0
  20. package/dist/cli/base-stages-command.js +174 -0
  21. package/dist/cli/bot/buttons.d.ts +3 -0
  22. package/dist/cli/bot/buttons.js +24 -0
  23. package/dist/cli/bot/messages.js +14 -1
  24. package/dist/cli/bot/port.d.ts +8 -0
  25. package/dist/cli/command-runs.d.ts +2 -0
  26. package/dist/cli/command-runs.js +3 -1
  27. package/dist/cli/config-command.js +6 -1
  28. package/dist/cli/context.js +1 -0
  29. package/dist/cli/contract-templates.js +31 -2
  30. package/dist/cli/group-lock.d.ts +42 -0
  31. package/dist/cli/group-lock.js +130 -0
  32. package/dist/cli/index.d.ts +7 -2
  33. package/dist/cli/index.js +7 -2
  34. package/dist/cli/messenger/backfill-command.js +27 -15
  35. package/dist/cli/messenger/contacts-command.js +12 -4
  36. package/dist/cli/messenger/context.js +1 -0
  37. package/dist/cli/messenger/conversations-command.js +2 -1
  38. package/dist/cli/messenger/doctor-command.js +3 -1
  39. package/dist/cli/messenger/message-items.js +1 -1
  40. package/dist/cli/messenger/models-command.js +1 -1
  41. package/dist/cli/messenger/search-answers.d.ts +5 -5
  42. package/dist/cli/messenger/search-answers.js +9 -20
  43. package/dist/cli/messenger/search-command.d.ts +2 -2
  44. package/dist/cli/messenger/search-command.js +8 -18
  45. package/dist/cli/messenger/store-maintenance-command.d.ts +22 -2
  46. package/dist/cli/messenger/store-maintenance-command.js +9 -4
  47. package/dist/cli/model-catalogue-command.d.ts +3 -1
  48. package/dist/cli/model-catalogue-command.js +48 -2
  49. package/dist/cli/profile.d.ts +8 -0
  50. package/dist/cli/profile.js +25 -0
  51. package/dist/cli/program.js +2 -0
  52. package/dist/cli/runs/search-query.d.ts +1 -1
  53. package/dist/cli/runs/search-query.js +4 -0
  54. package/dist/cli/runs/search.d.ts +5 -1
  55. package/dist/cli/runs/search.js +12 -1
  56. package/dist/cli/search-harder-consents-command.d.ts +18 -0
  57. package/dist/cli/search-harder-consents-command.js +83 -0
  58. package/dist/cli/search-left-out.d.ts +6 -1
  59. package/dist/cli/search-left-out.js +9 -4
  60. package/dist/cli/settings.d.ts +8 -0
  61. package/dist/cli/settings.js +17 -2
  62. package/dist/cli/shared-command-exports.d.ts +16 -0
  63. package/dist/cli/steps.js +0 -6
  64. package/dist/cli/store-recover.d.ts +3 -3
  65. package/dist/cli/store-recover.js +26 -26
  66. package/dist/cli/store-settings.d.ts +2 -0
  67. package/dist/cli/store-settings.js +37 -9
  68. package/dist/cli/templates-command.js +4 -4
  69. package/dist/crm/cli/index.js +40 -8
  70. package/dist/crm/cli/search-all.js +7 -6
  71. package/dist/crm/group-hint.d.ts +8 -0
  72. package/dist/crm/group-hint.js +13 -0
  73. package/dist/crm/source.d.ts +12 -1
  74. package/dist/crm/sync.d.ts +31 -2
  75. package/dist/crm/sync.js +110 -3
  76. package/dist/crm/testing/acme-scenario.d.ts +40 -0
  77. package/dist/crm/testing/acme-scenario.js +170 -0
  78. package/dist/crm/testing/index.d.ts +1 -0
  79. package/dist/crm/testing/index.js +1 -0
  80. package/dist/crm/testing/source-contract.js +12 -0
  81. package/dist/crm/testing/source.d.ts +2 -0
  82. package/dist/crm/testing/source.js +1 -0
  83. package/dist/domain/addresses.d.ts +13 -0
  84. package/dist/domain/addresses.js +63 -0
  85. package/dist/domain/categories.d.ts +3 -0
  86. package/dist/domain/categories.js +2 -0
  87. package/dist/domain/crm.d.ts +23 -0
  88. package/dist/domain/crm.js +7 -0
  89. package/dist/domain/mentions.d.ts +2 -12
  90. package/dist/domain/mentions.js +2 -19
  91. package/dist/domain/models.d.ts +2 -0
  92. package/dist/domain/orders.d.ts +8 -1
  93. package/dist/domain/orders.js +6 -2
  94. package/dist/domain/phones.d.ts +26 -0
  95. package/dist/domain/phones.js +48 -0
  96. package/dist/domain/record-types.d.ts +1 -1
  97. package/dist/domain/record-types.js +1 -0
  98. package/dist/domain/records.d.ts +5 -0
  99. package/dist/domain/ref-summaries.d.ts +39 -0
  100. package/dist/domain/ref-summaries.js +51 -3
  101. package/dist/domain/relations.d.ts +12 -2
  102. package/dist/domain/relations.js +14 -3
  103. package/dist/domain/vcard.d.ts +2 -2
  104. package/dist/domain/vcard.js +4 -10
  105. package/dist/embeddings/models.d.ts +11 -3
  106. package/dist/embeddings/models.js +28 -4
  107. package/dist/entities/business-context.d.ts +149 -0
  108. package/dist/entities/business-context.js +192 -0
  109. package/dist/entities/contact-activity.d.ts +2 -0
  110. package/dist/entities/contact-activity.js +7 -1
  111. package/dist/entities/contact-context.d.ts +160 -0
  112. package/dist/entities/contact-context.js +6 -0
  113. package/dist/entities/deal.d.ts +10 -0
  114. package/dist/entities/deal.js +2 -0
  115. package/dist/entities/hit.d.ts +9 -2
  116. package/dist/entities/hit.js +6 -2
  117. package/dist/entities/index.d.ts +32 -4
  118. package/dist/entities/index.js +5 -0
  119. package/dist/entities/mention.d.ts +4 -3
  120. package/dist/entities/mention.js +2 -1
  121. package/dist/entities/message-transfer.d.ts +4 -2
  122. package/dist/entities/message-transfer.js +2 -2
  123. package/dist/entities/model.d.ts +2 -2
  124. package/dist/entities/model.js +1 -1
  125. package/dist/entities/relationship.d.ts +4 -0
  126. package/dist/entities/relationship.js +4 -0
  127. package/dist/errors/reasons.js +39 -4
  128. package/dist/fetch/page.js +2 -1
  129. package/dist/index.d.ts +3 -2
  130. package/dist/index.js +3 -2
  131. package/dist/meetings/context-store.d.ts +2 -0
  132. package/dist/meetings/findings-rules.d.ts +4 -0
  133. package/dist/meetings/findings-rules.js +5 -2
  134. package/dist/meetings/hit-query.d.ts +1 -1
  135. package/dist/meetings/hit-query.js +2 -2
  136. package/dist/meetings/index.d.ts +1 -0
  137. package/dist/meetings/index.js +1 -0
  138. package/dist/meetings/result-items.d.ts +1 -0
  139. package/dist/meetings/result-items.js +1 -0
  140. package/dist/meetings/store.d.ts +4 -0
  141. package/dist/meetings/store.js +2 -1
  142. package/dist/models/anthropic.js +5 -0
  143. package/dist/models/index.js +22 -5
  144. package/dist/runs/events.d.ts +11 -1
  145. package/dist/runs/events.js +3 -1
  146. package/dist/runs/log-attributes.js +4 -0
  147. package/dist/runs/log-events.js +2 -0
  148. package/dist/runs/recording.d.ts +3 -0
  149. package/dist/runs/recording.js +36 -12
  150. package/dist/runs/run.d.ts +12 -3
  151. package/dist/runs/run.js +32 -13
  152. package/dist/search/account-list.d.ts +6 -0
  153. package/dist/search/account-list.js +9 -3
  154. package/dist/search/groups.d.ts +68 -0
  155. package/dist/search/groups.js +172 -0
  156. package/dist/search/question-period.d.ts +10 -0
  157. package/dist/search/question-period.js +133 -0
  158. package/dist/sends/buttons.d.ts +2 -0
  159. package/dist/sends/buttons.js +6 -1
  160. package/dist/services/account-groups.d.ts +28 -0
  161. package/dist/services/account-groups.js +89 -0
  162. package/dist/services/archive.d.ts +7 -1
  163. package/dist/services/archive.js +19 -3
  164. package/dist/services/business-context.d.ts +113 -0
  165. package/dist/services/business-context.js +156 -0
  166. package/dist/services/communications.d.ts +50 -0
  167. package/dist/services/communications.js +140 -0
  168. package/dist/services/deal-context.d.ts +90 -0
  169. package/dist/services/deal-context.js +131 -0
  170. package/dist/services/deps.d.ts +2 -0
  171. package/dist/services/enrichment.d.ts +12 -2
  172. package/dist/services/enrichment.js +47 -6
  173. package/dist/services/events-search.js +2 -1
  174. package/dist/services/group-guard.d.ts +28 -0
  175. package/dist/services/group-guard.js +131 -0
  176. package/dist/services/index.d.ts +19 -4
  177. package/dist/services/index.js +12 -3
  178. package/dist/services/ingest.d.ts +12 -0
  179. package/dist/services/ingest.js +4 -0
  180. package/dist/services/meaning-model.d.ts +7 -0
  181. package/dist/services/meaning-model.js +20 -0
  182. package/dist/services/meeting-context.d.ts +6 -1
  183. package/dist/services/meeting-context.js +12 -5
  184. package/dist/services/message-resolution.js +2 -3
  185. package/dist/services/messages-meaning.js +4 -5
  186. package/dist/services/messages-search.d.ts +5 -1
  187. package/dist/services/messages-search.js +1 -1
  188. package/dist/services/messages.d.ts +1 -4
  189. package/dist/services/messages.js +0 -2
  190. package/dist/services/metadata.d.ts +1 -1
  191. package/dist/services/model-downloads.d.ts +1 -1
  192. package/dist/services/model-downloads.js +6 -4
  193. package/dist/services/money-context.d.ts +73 -0
  194. package/dist/services/money-context.js +77 -0
  195. package/dist/services/notes-search.d.ts +4 -1
  196. package/dist/services/notes-search.js +19 -7
  197. package/dist/services/organization-context.d.ts +80 -0
  198. package/dist/services/organization-context.js +154 -0
  199. package/dist/services/people.d.ts +22 -6
  200. package/dist/services/people.js +38 -8
  201. package/dist/services/person-business.d.ts +43 -0
  202. package/dist/services/person-business.js +67 -0
  203. package/dist/services/person-context.d.ts +11 -1
  204. package/dist/services/person-context.js +25 -10
  205. package/dist/services/person-preparation.d.ts +5 -1
  206. package/dist/services/person-preparation.js +10 -3
  207. package/dist/services/person-timeline.d.ts +6 -1
  208. package/dist/services/person-timeline.js +10 -2
  209. package/dist/services/proposals/kinds/identity-link.d.ts +4 -0
  210. package/dist/services/proposals/kinds/identity-link.js +48 -0
  211. package/dist/services/proposals/kinds/orders.js +1 -1
  212. package/dist/services/proposals/registry.js +2 -0
  213. package/dist/services/search-all-deprecated.d.ts +40 -0
  214. package/dist/services/search-all-deprecated.js +10 -0
  215. package/dist/services/search-all-meetings.d.ts +50 -52
  216. package/dist/services/search-all-meetings.js +265 -272
  217. package/dist/services/search-all.d.ts +34 -6
  218. package/dist/services/search-all.js +118 -24
  219. package/dist/services/search-harder.d.ts +64 -0
  220. package/dist/services/search-harder.js +194 -0
  221. package/dist/services/search-kind.d.ts +12 -5
  222. package/dist/services/search-kind.js +49 -10
  223. package/dist/services/text-model-choice.js +1 -1
  224. package/dist/store/accounts.d.ts +18 -0
  225. package/dist/store/accounts.js +18 -3
  226. package/dist/store/chats.d.ts +3 -1
  227. package/dist/store/chats.js +6 -0
  228. package/dist/store/damage.d.ts +43 -10
  229. package/dist/store/damage.js +119 -36
  230. package/dist/store/decisions.js +3 -1
  231. package/dist/store/evidence-findings.d.ts +14 -0
  232. package/dist/store/evidence-findings.js +2 -0
  233. package/dist/store/exports.d.ts +2 -1
  234. package/dist/store/identity-links.d.ts +92 -0
  235. package/dist/store/identity-links.js +6 -0
  236. package/dist/store/index.d.ts +11 -5
  237. package/dist/store/index.js +5 -2
  238. package/dist/store/journal.d.ts +10 -0
  239. package/dist/store/journal.js +33 -0
  240. package/dist/store/marks.d.ts +19 -1
  241. package/dist/store/marks.js +23 -1
  242. package/dist/store/people.d.ts +28 -2
  243. package/dist/store/people.js +15 -1
  244. package/dist/store/sqlite/accounts.js +2 -0
  245. package/dist/store/sqlite/added-sources.d.ts +15 -3
  246. package/dist/store/sqlite/added-sources.js +26 -5
  247. package/dist/store/sqlite/base-stages.d.ts +122 -0
  248. package/dist/store/sqlite/base-stages.js +443 -0
  249. package/dist/store/sqlite/base-suggest.d.ts +13 -0
  250. package/dist/store/sqlite/base-suggest.js +62 -0
  251. package/dist/store/sqlite/business-contracts.js +10 -1
  252. package/dist/store/sqlite/chats.d.ts +2 -0
  253. package/dist/store/sqlite/chats.js +6 -0
  254. package/dist/store/sqlite/crm-settings.d.ts +12 -2
  255. package/dist/store/sqlite/crm-settings.js +56 -13
  256. package/dist/store/sqlite/crm.d.ts +13 -1
  257. package/dist/store/sqlite/crm.js +20 -4
  258. package/dist/store/sqlite/deals.d.ts +33 -0
  259. package/dist/store/sqlite/deals.js +42 -4
  260. package/dist/store/sqlite/decision-requests.js +7 -3
  261. package/dist/store/sqlite/email-index.js +8 -4
  262. package/dist/store/sqlite/evidence-findings.js +29 -5
  263. package/dist/store/sqlite/findings-core.js +4 -2
  264. package/dist/store/sqlite/identity-link-rows.d.ts +50 -0
  265. package/dist/store/sqlite/identity-link-rows.js +146 -0
  266. package/dist/store/sqlite/identity-proposals.d.ts +53 -0
  267. package/dist/store/sqlite/identity-proposals.js +234 -0
  268. package/dist/store/sqlite/involvements.d.ts +1 -1
  269. package/dist/store/sqlite/involvements.js +4 -2
  270. package/dist/store/sqlite/knowledge.js +2 -2
  271. package/dist/store/sqlite/link-kinds.d.ts +1 -0
  272. package/dist/store/sqlite/link-kinds.js +1 -0
  273. package/dist/store/sqlite/link-row.d.ts +6 -0
  274. package/dist/store/sqlite/link-row.js +35 -0
  275. package/dist/store/sqlite/link-source.d.ts +10 -0
  276. package/dist/store/sqlite/link-source.js +16 -0
  277. package/dist/store/sqlite/manifest.js +1 -0
  278. package/dist/store/sqlite/meeting-context-links.js +9 -6
  279. package/dist/store/sqlite/meeting-hit-query.d.ts +5 -0
  280. package/dist/store/sqlite/meeting-hit-query.js +33 -0
  281. package/dist/store/sqlite/meeting-hit-search.js +10 -8
  282. package/dist/store/sqlite/meetings.js +1 -1
  283. package/dist/store/sqlite/memories.js +9 -7
  284. package/dist/store/sqlite/mentions.d.ts +4 -1
  285. package/dist/store/sqlite/mentions.js +14 -9
  286. package/dist/store/sqlite/migrations.generated.js +8 -0
  287. package/dist/store/sqlite/notes.d.ts +8 -2
  288. package/dist/store/sqlite/notes.js +17 -34
  289. package/dist/store/sqlite/open-store.js +3 -0
  290. package/dist/store/sqlite/open.js +11 -2
  291. package/dist/store/sqlite/orders.d.ts +2 -0
  292. package/dist/store/sqlite/orders.js +9 -3
  293. package/dist/store/sqlite/organization-categories.d.ts +18 -0
  294. package/dist/store/sqlite/organization-categories.js +34 -0
  295. package/dist/store/sqlite/organizations.d.ts +5 -1
  296. package/dist/store/sqlite/organizations.js +14 -4
  297. package/dist/store/sqlite/person-links.d.ts +19 -4
  298. package/dist/store/sqlite/person-links.js +49 -11
  299. package/dist/store/sqlite/person-match-scan.d.ts +13 -0
  300. package/dist/store/sqlite/person-match-scan.js +251 -0
  301. package/dist/store/sqlite/person-matcher.d.ts +16 -0
  302. package/dist/store/sqlite/person-matcher.js +32 -0
  303. package/dist/store/sqlite/person-preparation.d.ts +7 -3
  304. package/dist/store/sqlite/person-preparation.js +20 -6
  305. package/dist/store/sqlite/proposed-actions.js +6 -0
  306. package/dist/store/sqlite/record-matching.d.ts +2 -8
  307. package/dist/store/sqlite/record-matching.js +8 -40
  308. package/dist/store/sqlite/record-projectors-phone.js +2 -1
  309. package/dist/store/sqlite/record-relationships.d.ts +52 -0
  310. package/dist/store/sqlite/record-relationships.js +243 -0
  311. package/dist/store/sqlite/record-run.d.ts +5 -0
  312. package/dist/store/sqlite/record-run.js +62 -2
  313. package/dist/store/sqlite/record-writes.d.ts +1 -1
  314. package/dist/store/sqlite/record-writes.js +4 -2
  315. package/dist/store/sqlite/records.js +27 -2
  316. package/dist/store/sqlite/ref-accounts.d.ts +13 -0
  317. package/dist/store/sqlite/ref-accounts.js +117 -0
  318. package/dist/store/sqlite/ref-summaries.js +5 -1
  319. package/dist/store/sqlite/relation-list.d.ts +4 -1
  320. package/dist/store/sqlite/relation-list.js +22 -4
  321. package/dist/store/sqlite/relation-proposals.d.ts +6 -0
  322. package/dist/store/sqlite/relation-proposals.js +3 -0
  323. package/dist/store/sqlite/relation-roles.js +12 -6
  324. package/dist/store/sqlite/reported-relations.d.ts +11 -1
  325. package/dist/store/sqlite/reported-relations.js +59 -18
  326. package/dist/store/sqlite/schema.d.ts +32 -0
  327. package/dist/store/sqlite/schema.js +3 -0
  328. package/dist/store/sqlite/transaction.js +11 -1
  329. package/dist/store/store.d.ts +3 -0
  330. package/dist/store/store.js +5 -0
  331. package/dist/store/write-events.d.ts +18 -0
  332. package/dist/store/write-events.js +88 -0
  333. package/package.json +3 -3
  334. package/parity.json +37 -16
  335. package/schemas/records-envelope.v1.schema.json +3 -0
@@ -11,6 +11,7 @@ import { withoutPhone } from "../../services/people.js";
11
11
  import { CHAT_MESSAGES, CONTEXT_BYTES, CONTEXT_MESSAGES } from "../../services/person-context.js";
12
12
  import { SCOPES, TIMELINE_ITEMS } from "../../services/person-timeline.js";
13
13
  import { readSecret } from "../../terminal/prompt.js";
14
+ import { actorOf } from "../author.js";
14
15
  import { secretInputOf } from "../context.js";
15
16
  import { FETCH, LOCAL_WRITE, REMOTE_READ } from "../effects.js";
16
17
  import { itemOf, listOf, renderAnswer, snakeKeys } from "../envelope.js";
@@ -190,7 +191,8 @@ export const contactsCommand = (messenger) => {
190
191
  })
191
192
  .summary("one person's activity across their linked identities")
192
193
  .description("everything one person took part in, in every messenger linked to them — messages they wrote or were " +
193
- "mentioned in, chats, mail, meetings, tasks — newest first, from the store; never connects")
194
+ "mentioned in, chats, mail, meetings, tasks — newest first, from the store; only in this account's scope, " +
195
+ "personal or work, and scope: of the other one is refused; never connects")
194
196
  .argument("<person>", "their id, @username, or part of their name"), CONTACT_ACTIVITY_QUERY)
195
197
  .option("--limit <n>", `at most this many; ${TIMELINE_ITEMS} if not given`, positiveCount("--limit"))
196
198
  .option("--cursor <cursor>", "go on from where the last page stopped; page.next gives it, with the same filters")
@@ -256,18 +258,24 @@ export const contactsCommand = (messenger) => {
256
258
  .description("record that two people in the store are one person — the same name is never enough")
257
259
  .argument("<person>", "their id, @username, or part of their name")
258
260
  .argument("<other>", "the same in another messenger of the store, as <messenger>:<person> — max:Ana; me: it is you, as zoom:<id> me")
261
+ .option("--reason <text>", "why they are one person; an agent's link is a proposal and needs it")
259
262
  .action(async function (person, other) {
260
263
  const context = messengerContext(this, messenger);
261
- const linked = await context.withServices((services) => services.people.link(person, other));
264
+ const { reason } = this.opts();
265
+ const by = actorOf(this);
266
+ const linked = await context.withServices((services) => services.people.link(person, other, { by, reason }));
262
267
  renderAnswer(this, context, itemOf(snakeKeys(linked)));
263
- context.renderer.success(`${linked.identities.length} identities are now one person`);
268
+ if (linked.proposal === undefined)
269
+ context.renderer.success(`${linked.identities.length} identities are now one person`);
270
+ else
271
+ context.renderer.note(`proposed as ${linked.proposal}: only the owner links them`);
264
272
  });
265
273
  annotate(contacts.command("unlink"), { effects: LOCAL_WRITE, output: { entity: "linked_person" } })
266
274
  .description("undo contacts link for one identity: it is a person of its own again")
267
275
  .argument("<person>", "their id, @username, or part of their name; <messenger>:<person> for another messenger")
268
276
  .action(async function (person) {
269
277
  const context = messengerContext(this, messenger);
270
- renderAnswer(this, context, itemOf(snakeKeys(await context.withServices((services) => services.people.unlink(person)))));
278
+ renderAnswer(this, context, itemOf(snakeKeys(await context.withServices((services) => services.people.unlink(person, { by: actorOf(this) })))));
271
279
  });
272
280
  /**
273
281
  * ⚠ **The number is asked for or piped, never an argument**: argv is read by `ps` and kept by shell
@@ -423,6 +423,7 @@ export const messengerContext = (command, messenger, resolving = {}) => {
423
423
  history: base.settings.record,
424
424
  searchCatchUp: base.settings.searchCatchUp,
425
425
  ...(base.settings.historyLimits ? { historyLimits: base.settings.historyLimits } : {}),
426
+ historyMuted: base.settings.historyMuted,
426
427
  pictures: base.settings.pictureSearch,
427
428
  reranker: base.settings.searchReranker,
428
429
  guard,
@@ -4,6 +4,7 @@ import { Command, Option } from "commander";
4
4
  import { analysisConsents } from "../../analysis/consents.js";
5
5
  import { openAnalysis, providerIdentity } from "../../analysis/provider.js";
6
6
  import { runAnalysis } from "../../analysis/runner.js";
7
+ import { DEFAULT_TEXT_MODEL } from "../../embeddings/models.js";
7
8
  import { isLocal } from "../../embeddings/remote.js";
8
9
  import { renderMessages } from "../../render/messages.js";
9
10
  import { BATCH_SIZE, CONVERSATION_QUERY } from "../../services/conversations.js";
@@ -401,7 +402,7 @@ const chatOf = ({ chat }) => {
401
402
  return chat;
402
403
  };
403
404
  const withModelOptions = (command) => command
404
- .option("--model <model>", "local: a model id from `models list` (default: e5-small); remote: the provider's model")
405
+ .option("--model <model>", `local: a model id from \`models list\` (default: ${DEFAULT_TEXT_MODEL}); remote: the provider's model`)
405
406
  .addOption(new Option("--embedding-provider <provider>", "embedding provider: local or openai; flags override profile settings"))
406
407
  .option("--base-url <url>", "a server with OpenAI's /v1/embeddings: Gemini, Jina, or Ollama and LM Studio on this machine")
407
408
  .option("--dims <n>", "remote: the vector size — needed with --base-url; shortens an OpenAI model's", positiveCount("--dims"));
@@ -71,7 +71,9 @@ export const damageNotes = (store) => {
71
71
  `the deep check passed, so writes are allowed again: \`${cleared.command}\` had found the store damaged at ${cleared.at}`,
72
72
  ]
73
73
  : []),
74
- ...(damage ? [damage.what, damage.external_unaffected, ...damage.steps.map((step) => `next: ${step}`)] : []),
74
+ ...(damage
75
+ ? [damage.what_happened, damage.external_data_safe, ...damage.steps.map(({ command }) => `next: ${command}`)]
76
+ : []),
75
77
  ];
76
78
  };
77
79
  const INCLUDES = [
@@ -20,7 +20,7 @@ const attachmentItem = (attachment) => defined({
20
20
  phone: attachment.contact.phone,
21
21
  user_id: attachment.contact.userId,
22
22
  }),
23
- buttons: attachment.buttons,
23
+ buttons: attachment.buttons?.map((row) => row.map(({ data: _data, ...button }) => button)),
24
24
  });
25
25
  const quotedItem = (quoted) => quoted === null
26
26
  ? null
@@ -185,7 +185,7 @@ export const modelsCommand = (messenger) => {
185
185
  .summary("download and verify one speech, embedding or reranker model")
186
186
  .description("download and verify one speech, embedding or reranker model: tens to hundreds of MB, each size in models list")
187
187
  .argument("<model>", "a model id from models list")
188
- .option("--accept-terms", "accept the model's licence terms, for a model that has its own")
188
+ .option("--accept-terms", "no longer needed; kept so older scripts still run")
189
189
  .action(async function (id, options) {
190
190
  if (orderedModels().some((model) => model.id === id))
191
191
  return downloadAudioModel(this, messenger, id);
@@ -6,8 +6,8 @@ import type { ChatCoverage } from "../../services/chat-coverage.js";
6
6
  import type { FoundMessage, SearchFound } from "../../services/messages.js";
7
7
  import type { MeaningSkipped } from "../../services/messages-discovery.js";
8
8
  import type { FoundNote, NotesFoundOf } from "../../services/notes-search.js";
9
- import type { SearchAllItem } from "../../services/search-all.js";
10
- import type { MeetingSearchItem, SearchAllIncludingMeetingsFound } from "../../services/search-all-meetings.js";
9
+ import type { SearchAllFound, SearchAllItem } from "../../services/search-all.js";
10
+ import type { SearchAllIncludingMeetingsFound } from "../../services/search-all-deprecated.js";
11
11
  import type { StoredHistorySkip } from "../../store/store.js";
12
12
  import { type ListBody } from "../envelope.js";
13
13
  /** What a source tool's `search all` reads: never mail, which is memo's (docs/dev/TOOL-BOUNDARIES.md). */
@@ -46,11 +46,11 @@ export declare const shownOf: (shown: number, offset: number, total: SearchTotal
46
46
  /** `search messages` and `search mail`, CLI and MCP alike. */
47
47
  export declare const messagesAnswer: (command: string, found: SearchFound, { limit, page, again }: Paging, query?: string, skips?: StoredHistorySkip[]) => ListBody<MessageHitItem>;
48
48
  export declare const noteHitItem: (hit: FoundNote) => NoteHitItem;
49
- export declare const allHitItem: (item: SearchAllItem | MeetingSearchItem) => HitItem;
49
+ export declare const allHitItem: (item: SearchAllItem) => HitItem;
50
50
  /** `search notes`, CLI and MCP alike. */
51
51
  export declare const notesAnswer: (command: string, found: NotesFoundOf, { limit, page, again }: Paging, exact?: boolean) => ListBody<NoteHitItem>;
52
- /** `search all`, CLI and MCP alike. A bounded meeting scan that could not tell whether more match says so. */
53
- export declare const allAnswer: (command: string, found: SearchAllIncludingMeetingsFound, { limit, page, again }: Paging, exact?: boolean, skips?: StoredHistorySkip[],
52
+ /** `search all`, CLI and MCP alike. A meeting account whose index is still being built says so. */
53
+ export declare const allAnswer: (command: string, found: SearchAllFound | SearchAllIncludingMeetingsFound, { limit, page, again }: Paging, exact?: boolean, skips?: StoredHistorySkip[],
54
54
  /** Kinds the profile's levels kept out of the search, each with why. */
55
55
  leftOut?: readonly {
56
56
  why: string;
@@ -306,7 +306,9 @@ export const allHitItem = (item) => item.kind === "meeting"
306
306
  excerpt: item.text,
307
307
  offset_ms: item.startMs,
308
308
  scope: item.scope,
309
+ found_by: item.foundBy,
309
310
  id: String(item.id),
311
+ ...(item.match === undefined ? {} : { match: item.match, corrections: item.corrections ?? [] }),
310
312
  ...(item.cueRef === undefined
311
313
  ? {}
312
314
  : {
@@ -359,12 +361,11 @@ export const notesAnswer = (command, found, { limit, page, again }, exact = fals
359
361
  ...meaningGap(found.meaning_skipped, exact),
360
362
  meta: metaOf(found.accounts, found.skipped),
361
363
  });
362
- /** `search all`, CLI and MCP alike. A bounded meeting scan that could not tell whether more match says so. */
364
+ /** `search all`, CLI and MCP alike. A meeting account whose index is still being built says so. */
363
365
  export const allAnswer = (command, found, { limit, page, again }, exact = false, skips = [],
364
366
  /** Kinds the profile's levels kept out of the search, each with why. */
365
367
  leftOut = []) => {
366
368
  const limited = historyLimitGaps(skips);
367
- const scan = found.meetings?.complete === false ? found.meetings : undefined;
368
369
  const notes = meaningGap(found.notes?.meaningSkipped, exact);
369
370
  const messages = messageMeaningGap(found.messages?.meaningSkipped, "found_by");
370
371
  const archive = coverageGaps({ coverage: found.coverage }, found.items.length);
@@ -375,30 +376,18 @@ leftOut = []) => {
375
376
  page: page ?? 1,
376
377
  ...(again ? { args: again } : {}),
377
378
  next: [
378
- ...(scan
379
- ? [
380
- nextStep("search.meetings", {
381
- command,
382
- args: { ...again, max_meetings: "all" },
383
- values: { scanned: scan.meetingsScanned },
384
- }),
385
- ]
386
- : []),
387
379
  ...notes.next,
388
380
  ...messages.next.filter((step) => !notes.next.some((asked) => JSON.stringify(asked) === JSON.stringify(step))),
389
381
  ...archive.next,
390
382
  ...limited.next,
391
383
  ],
392
384
  missing: [
393
- ...(scan
394
- ? [
395
- {
396
- field: "items",
397
- why: `stopped after ${scan.meetingsScanned} meetings; more may match`,
398
- step: "search.meetings",
399
- },
400
- ]
401
- : []),
385
+ ...(Array.isArray(found.meetings) ? found.meetings : [])
386
+ .filter(({ indexing }) => indexing === "pending")
387
+ .map(({ provider, account }) => ({
388
+ field: "items",
389
+ why: `${provider}:${account}: meetings saved since its search index was last built are not found yet`,
390
+ })),
402
391
  ...notes.missing,
403
392
  ...messages.missing,
404
393
  ...archive.missing,
@@ -1,10 +1,10 @@
1
1
  import { Command } from "commander";
2
- import type { SearchAllIncludingMeetingsFound } from "../../services/search-all-meetings.js";
2
+ import type { SearchAllItem } from "../../services/search-all.js";
3
3
  import { type Messenger } from "./context.js";
4
4
  import { type SourceSearched } from "./search-answers.js";
5
5
  export declare const searchAllOnlyOf: (value: string, allowed?: readonly string[]) => SourceSearched[];
6
6
  /** One `search all` hit as a person reads it. */
7
- export declare const searchAllLine: (item: SearchAllIncludingMeetingsFound["items"][number]) => string;
7
+ export declare const searchAllLine: (item: SearchAllItem) => string;
8
8
  /**
9
9
  * `search all`'s scope, paging and matching options, the same in every CLI that mounts it (WC-ACCT-8): a messenger's
10
10
  * and a calendar's.
@@ -22,44 +22,35 @@ export const searchAllOnlyOf = (value, allowed = SOURCE_SEARCHED) => {
22
22
  throw new CliError("validation_error", "mail is searched by the separate memo CLI: install @wirecat/cli-memo, then `memo search mail …`");
23
23
  const unknown = chosen.find((one) => !allowed.includes(one));
24
24
  if (unknown !== undefined || chosen.length === 0)
25
- throw new CliError("validation_error", `--only takes ${allowed.join(", ")}, separated by commas; meetings when --source names a meeting account`);
25
+ throw new CliError("validation_error", `--only takes ${allowed.join(", ")}, separated by commas`);
26
26
  return [...new Set(chosen)];
27
27
  };
28
28
  /** One `search all` hit as a person reads it. */
29
29
  export const searchAllLine = (item) => item.kind === "meeting"
30
30
  ? `meeting · ${item.provider} · ${singleLine(item.title ?? "")} ${item.ref}\n ${item.timestamp ?? "time unknown"} ${singleLine(item.text).slice(0, 200)}\n`
31
31
  : `${item.kind} · ${item.provider} · ${singleLine(item.title ?? "")} ${item.ref}${item.url ? `\n ${singleLine(item.url)}` : ""}\n ${item.timestamp}${item.from?.name ? ` ${singleLine(item.from.name)}` : ""} ${singleLine(item.text)}\n`;
32
- const maxMeetingsOf = (value) => {
33
- if (value === "all")
34
- return "all";
35
- if (!/^[1-9]\d*$/.test(value))
36
- throw new CliError("validation_error", "--max-meetings takes a whole number from 1, or all");
37
- return Number(value);
38
- };
39
32
  /**
40
33
  * `search all`'s scope, paging and matching options, the same in every CLI that mounts it (WC-ACCT-8): a messenger's
41
34
  * and a calendar's.
42
35
  */
43
36
  /** `allowed`: the resources `--only` takes, a CRM CLI's with `crm`. */
44
37
  export const searchAllOptions = (command, allowed = SOURCE_SEARCHED) => command
45
- .option("--only <resources>", `only these resources, separated by commas: ${allowed.filter((one) => one !== "meetings").join(", ")}; ` +
46
- "meetings when --source names a meeting account", (value) => searchAllOnlyOf(value, allowed))
38
+ .option("--only <resources>", `only these resources, separated by commas: ${allowed.join(", ")}`, (value) => searchAllOnlyOf(value, allowed))
47
39
  .option("--source <accounts>", "only these accounts, separated by commas: provider:account as a hit shows it, a provider, a kind or " +
48
- "group:<name>; each resource reads the ones of its kind, and meetings only when it names one")
49
- .option("--max-meetings <n>", "how many of the meeting account's meetings to look through, newest first, or all for every one (default 100)", maxMeetingsOf)
40
+ "group:<name>; each resource reads the ones of its kind")
50
41
  .option("--limit <n>", "how many", positiveCount("--limit"))
51
42
  .option("--page <n>", "which page, starting at 1", positiveCount("--page"))
52
43
  .option("--exact", "bare words and quotes match their exact form only, as exact:word does")
53
44
  .option("--timezone <zone>", "the IANA timezone for calendar date boundaries");
54
45
  const allCommand = (messenger) => {
55
46
  const command = annotate(new Command("all"), { effects: REMOTE_READ, partial: true })
56
- .summary("search stored messages, notes, calendar events and selected meeting transcripts")
47
+ .summary("search stored messages, notes, calendar events and meetings")
57
48
  .description((messenger.serverSearch
58
49
  ? "search messenger messages and notes in the local store, and by default the messenger's server for " +
59
50
  "messages too (notes and events are local only; --backend archive or --offline keeps it to the local store)"
60
51
  : "search messenger messages and notes in the local store") +
61
52
  ", calendar events when the store holds a calendar" +
62
- ", and a meeting account's transcripts when --source names one — best match first; not mail (the separate memo CLI searches it: memo search mail), " +
53
+ ", and meeting transcripts, chat and summaries when it holds a meeting account — best match first; not mail (the separate memo CLI searches it: memo search mail), " +
63
54
  "tasks, people, memories or projects. Use it when you do not know where something was written; search messages " +
64
55
  "or notes reads one kind with all its fields")
65
56
  .argument("<query...>", 'strict Lucene query: words, "phrases", AND/OR/NOT, field groups and date ranges')
@@ -68,10 +59,10 @@ const allCommand = (messenger) => {
68
59
  --json: the list is items; each result's reference is ref, with its kind.`);
69
60
  return backendOptions(annotate(searchAllOptions(command), { output: { entity: "hit" } }), messenger).action(async function (words) {
70
61
  const context = messengerContext(this, messenger);
71
- const { only, source, maxMeetings, limit: typed, page, exact, timezone, } = this.opts();
62
+ const { only, source, limit: typed, page, exact, timezone, } = this.opts();
72
63
  const limit = typed ?? context.settings.limit;
73
64
  const offset = offsetOf(page, limit);
74
- const found = await context.withServices((services) => services.messages.searchAllWithMeetings({
65
+ const found = await context.withServices((services) => services.messages.searchAll({
75
66
  text: words.join(" "),
76
67
  limit,
77
68
  ...(offset === undefined ? {} : { offset }),
@@ -80,8 +71,8 @@ const allCommand = (messenger) => {
80
71
  ...backendRequest(this),
81
72
  env: context.env,
82
73
  only: only ?? SOURCE_SEARCHED,
74
+ ...(only?.includes("meetings") ? { meetingsAsked: true } : {}),
83
75
  ...(source === undefined ? {} : { source }),
84
- ...(maxMeetings === undefined ? {} : { maxMeetings }),
85
76
  }));
86
77
  noteServer(context, found.server);
87
78
  if (context.format === "pretty")
@@ -98,7 +89,6 @@ const allCommand = (messenger) => {
98
89
  query: words.join(" "),
99
90
  ...(only === undefined ? {} : { only: only.join(",") }),
100
91
  ...(source === undefined ? {} : { source }),
101
- ...(maxMeetings === undefined ? {} : { max_meetings: maxMeetings }),
102
92
  ...(exact ? { exact: true } : {}),
103
93
  ...(timezone === undefined ? {} : { timezone }),
104
94
  };
@@ -32,6 +32,7 @@ export declare const storeSummary: (env: NodeJS.ProcessEnv, { deep, command, ver
32
32
  run_id?: string;
33
33
  error: string;
34
34
  } | undefined;
35
+ journalMark?: import("../../store/marks.js").JournalMark | undefined;
35
36
  damageMarkCleared?: {
36
37
  at: string;
37
38
  command: string;
@@ -39,7 +40,16 @@ export declare const storeSummary: (env: NodeJS.ProcessEnv, { deep, command, ver
39
40
  run_id?: string;
40
41
  error: string;
41
42
  } | undefined;
42
- damage?: import("../../store/damage.js").DamageExplanation | undefined;
43
+ damage?: {
44
+ whatHappened: string;
45
+ likelyCauses: import("../../store/damage.js").DamageCause[];
46
+ impact: string[];
47
+ externalDataSafe: string;
48
+ lastOkAt: string | null;
49
+ loss: string;
50
+ steps: import("../../store/damage.js").RecoveryStep[];
51
+ what: string;
52
+ } | undefined;
43
53
  path: string;
44
54
  exists: boolean;
45
55
  schema: number;
@@ -66,6 +76,7 @@ export declare const storeSummary: (env: NodeJS.ProcessEnv, { deep, command, ver
66
76
  run_id?: string;
67
77
  error: string;
68
78
  } | undefined;
79
+ journalMark?: import("../../store/marks.js").JournalMark | undefined;
69
80
  damageMarkCleared?: {
70
81
  at: string;
71
82
  command: string;
@@ -73,7 +84,16 @@ export declare const storeSummary: (env: NodeJS.ProcessEnv, { deep, command, ver
73
84
  run_id?: string;
74
85
  error: string;
75
86
  } | undefined;
76
- damage?: import("../../store/damage.js").DamageExplanation | undefined;
87
+ damage?: {
88
+ whatHappened: string;
89
+ likelyCauses: import("../../store/damage.js").DamageCause[];
90
+ impact: string[];
91
+ externalDataSafe: string;
92
+ lastOkAt: string | null;
93
+ loss: string;
94
+ steps: import("../../store/damage.js").RecoveryStep[];
95
+ what: string;
96
+ } | undefined;
77
97
  path: string;
78
98
  exists: boolean;
79
99
  error: string;
@@ -8,9 +8,9 @@ import { RULES_VERSION } from "../../conversations/link.js";
8
8
  import { syncsOneChat } from "../../ports/traits.js";
9
9
  import { isSealed, sealFile, unsealFile } from "../../sealed.js";
10
10
  import { fileSchemaOf, SPEAKS, writableBy } from "../../store/compatibility.js";
11
- import { explainDamage } from "../../store/damage.js";
11
+ import { storeDamageReport } from "../../store/damage.js";
12
12
  import { QUICK_HEALTH_CHECKS, storeHealth } from "../../store/health.js";
13
- import { readDamageMark, readHealthMark, recordDeepCheck } from "../../store/marks.js";
13
+ import { readDamageMark, readHealthMark, readJournalMark, recordDeepCheck } from "../../store/marks.js";
14
14
  import { migrate } from "../../store/migrations.js";
15
15
  import { openCache } from "../../store/open.js";
16
16
  import { storePath } from "../../store/path.js";
@@ -79,6 +79,7 @@ export const storeSummary = async (env, { deep = false, command, version } = {})
79
79
  if (!existsSync(path))
80
80
  return { path, exists: false };
81
81
  const checked = await storeHealth(path, { deep });
82
+ const journal = readJournalMark(path);
82
83
  const recorded = deep
83
84
  ? recordDeepCheck(path, checked, {
84
85
  cli: command ?? "unknown",
@@ -100,13 +101,17 @@ export const storeSummary = async (env, { deep = false, command, version } = {})
100
101
  ? { damagedSearchIndexes: checked.searchIndexes.filter((index) => !index.ok).map((index) => index.name) }
101
102
  : {}),
102
103
  };
103
- const damage = command ? explainDamage(checked, command, mark) : null;
104
+ const damage = command
105
+ ? storeDamageReport({ health: checked, command, mark, journal, lastOkAt: lastKnownGood })
106
+ : null;
104
107
  const healthOf = {
105
108
  health,
106
109
  lastKnownGood,
107
110
  ...(mark ? { damageMark: withoutInode(mark) } : {}),
111
+ ...(journal ? { journalMark: journal } : {}),
108
112
  ...(recorded?.cleared ? { damageMarkCleared: withoutInode(recorded.cleared) } : {}),
109
- ...(damage ? { damage } : {}),
113
+ // `what` keeps memo's doctor, which reads it, compiling until it moves to `whatHappened`.
114
+ ...(damage ? { damage: { what: damage.whatHappened, ...damage } } : {}),
110
115
  };
111
116
  try {
112
117
  return await reading(path, (database) => {
@@ -13,8 +13,10 @@ export interface ModelCatalogueOptions {
13
13
  * (memo): it changes the shared store for every CLI.
14
14
  */
15
15
  enrichment?: boolean;
16
- /** Where `models consents` looks for the enrichment provider's key; the system keyring when absent. */
16
+ /** Where `models consents` and `models keys` keep the provider's key; the system keyring when absent. */
17
17
  keyring?: KeyringStore;
18
+ /** Where `models keys set` reads the key; process.stdin when absent. */
19
+ stdin?: () => NodeJS.ReadableStream | undefined;
18
20
  output: (answer: Body, command: Command) => void;
19
21
  diagnostic: (line: string) => void;
20
22
  jsonOption?: boolean;
@@ -4,16 +4,19 @@ import { annotate } from "@wirecat/cli-base/commands";
4
4
  import { defineQuery } from "@wirecat/cli-base/query";
5
5
  import { Command } from "commander";
6
6
  import { isTextModelInstalled, textModelsDirectory } from "../embeddings/embed.js";
7
+ import { embeddingKeys } from "../embeddings/keys.js";
7
8
  import { chosenTextModel, DEFAULT_TEXT_MODEL, textModel, textModels } from "../embeddings/models.js";
8
9
  import { downloadTextModel } from "../services/model-downloads.js";
9
10
  import { addCustomTextModel, useTextModel } from "../services/text-model-choice.js";
10
11
  import { install, installedBytes, isInstalled, modelsDirectory } from "../speech/install.js";
11
12
  import { DEFAULT_ORDER, orderedModels, speechModel } from "../speech/models.js";
13
+ import { readSecret } from "../terminal/prompt.js";
12
14
  import { stepLines } from "../terminal/step-lines.js";
13
15
  import { FETCH, grantsAuthority, LOCAL_READ, LOCAL_WRITE, NO_EFFECTS } from "./effects.js";
14
16
  import { enrichmentConsentsCommand } from "./enrichment-consents-command.js";
15
17
  import { itemOf, listOf } from "./envelope.js";
16
18
  import { listQuery, nativeTerms, termField, typedQuery, withQuery } from "./list-query.js";
19
+ import { harderConsentsCommand } from "./search-harder-consents-command.js";
17
20
  export const MODEL_CATALOGUE_QUERY = defineQuery({
18
21
  entity: "model",
19
22
  backend: "native",
@@ -70,7 +73,7 @@ export const modelCatalogueCommand = (app, options) => {
70
73
  .description("download and verify one speech or embedding model")
71
74
  .argument("<model>", "a model id from models list")
72
75
  .option("--offline", "refuse a download that needs the network")
73
- .option("--accept-terms", "accept the model's licence terms, for a model that has its own")
76
+ .option("--accept-terms", "no longer needed; kept so older scripts still run")
74
77
  .action(async function (id, given) {
75
78
  if (options.offline?.() || this.optsWithGlobals().offline)
76
79
  throw new CliError("permission_error", "downloading a model needs the network; --offline was requested", {
@@ -138,13 +141,56 @@ export const modelCatalogueCommand = (app, options) => {
138
141
  options.output(itemOf(textModelItem(model, env)), this);
139
142
  });
140
143
  }
141
- if (options.enrichment === true)
144
+ if (options.enrichment === true) {
142
145
  models.addCommand(enrichmentConsentsCommand(app, options));
146
+ models.addCommand(harderConsentsCommand(app, options));
147
+ models.addCommand(providerKeysCommand(app, options));
148
+ }
143
149
  if (options.jsonOption)
144
150
  for (const command of models.commands.flatMap((one) => (one.commands.length ? one.commands : [one])))
145
151
  command.option("--json", "print JSON");
146
152
  return models;
147
153
  };
154
+ const PROVIDER = /^[a-z0-9][a-z0-9.:-]*$/;
155
+ const providerOf = (given) => {
156
+ const provider = given.trim().toLowerCase();
157
+ if (!PROVIDER.test(provider))
158
+ throw new CliError("validation_error", "name the provider: openai, anthropic, or the host of a --base-url server");
159
+ return provider;
160
+ };
161
+ /** The enrichment provider's key in the tool's keyring entry `embeddings:<provider>`; never printed, never an argument. */
162
+ const providerKeysCommand = (app, options) => {
163
+ const keys = new Command("keys").description("the API key write-time enrichment and search all --harder send with each request");
164
+ const store = () => embeddingKeys(app, options.env(), options.keyring);
165
+ grantsAuthority(annotate(keys.command("set"), {
166
+ effects: LOCAL_WRITE,
167
+ output: { entity: "model_key", view: "stored" },
168
+ examples: [`${app.command} models keys set openai < key.txt`],
169
+ }))
170
+ .argument("<provider>", "openai, anthropic, or the host of a --base-url server that wants a key")
171
+ .description("store a key, typed at a hidden prompt or piped on stdin — never as an argument")
172
+ .action(async function (given) {
173
+ const provider = providerOf(given);
174
+ const input = options.stdin?.();
175
+ const secret = (await readSecret(`API key for ${provider}: `, input ? { input } : {})).trim();
176
+ if (!secret)
177
+ throw new CliError("validation_error", "no key was given — nothing was stored");
178
+ options.output(itemOf({ provider, stored: true, source: store().write(provider, secret) }), this);
179
+ });
180
+ grantsAuthority(annotate(keys.command("remove"), {
181
+ effects: LOCAL_WRITE,
182
+ output: { entity: "model_key", view: "removed" },
183
+ examples: [`${app.command} models keys remove openai`],
184
+ }))
185
+ .argument("<provider>", "openai, anthropic, or a server's host")
186
+ .description("forget the stored key; a key in the environment stays")
187
+ .action(function (given) {
188
+ const provider = providerOf(given);
189
+ const removed = store().remove(provider);
190
+ options.output(itemOf({ provider, removed: removed.length > 0, from: removed }), this);
191
+ });
192
+ return keys;
193
+ };
148
194
  const PROGRESS_EVERY_MS = 500;
149
195
  /**
150
196
  * `{"event":"progress","step":"download",…}` on stderr under --json, for a window to draw a bar by: at most every half
@@ -1,4 +1,6 @@
1
1
  import type { Command } from "commander";
2
+ import { type AppIdentity } from "../ports/app.js";
3
+ import type { RunGroup } from "../search/groups.js";
2
4
  /** How the command line names this profile: always the first word, since none is assumed. */
3
5
  export declare const asFirstWord: (profile: string) => string;
4
6
  export declare const isProfileName: (word: string) => boolean;
@@ -27,6 +29,12 @@ export declare const liftProfile: (argv: string[], words: Set<string>, valued?:
27
29
  profile?: string;
28
30
  rest: string[];
29
31
  };
32
+ /**
33
+ * The group a run reads, from the first word (`liftProfile` lifts it) or `<PREFIX>_GROUP`; `all`, the default, is
34
+ * every account, so no restriction. Under `<PREFIX>_GROUP_LOCK` any other group, `all` included, is refused, as the
35
+ * profile lock refuses another profile (WC-ACCT-5); a lock of `all` locks nothing.
36
+ */
37
+ export declare const runGroup: (app: AppIdentity, env: NodeJS.ProcessEnv, word?: string) => RunGroup | undefined;
30
38
  /** The root's options that take the next word as their value: `--timeout 30s`. */
31
39
  export declare const valuedOptions: (program: Command) => Set<string>;
32
40
  /**
@@ -1,4 +1,6 @@
1
1
  import { CliError } from "@wirecat/cli-base";
2
+ import { envName } from "../ports/app.js";
3
+ import { isGroupName } from "../search/account-list.js";
2
4
  /** How the command line names this profile: always the first word, since none is assumed. */
3
5
  export const asFirstWord = (profile) => `${profile} `;
4
6
  /**
@@ -57,6 +59,29 @@ export const liftProfile = (argv, words, valued = new Set()) => {
57
59
  return { rest: argv };
58
60
  return { profile: first, rest: [...argv.slice(0, at), ...argv.slice(at + 1)] };
59
61
  };
62
+ /**
63
+ * The group a run reads, from the first word (`liftProfile` lifts it) or `<PREFIX>_GROUP`; `all`, the default, is
64
+ * every account, so no restriction. Under `<PREFIX>_GROUP_LOCK` any other group, `all` included, is refused, as the
65
+ * profile lock refuses another profile (WC-ACCT-5); a lock of `all` locks nothing.
66
+ */
67
+ export const runGroup = (app, env, word) => {
68
+ const GROUP = envName(app, "GROUP");
69
+ const LOCK = envName(app, "GROUP_LOCK");
70
+ const lock = env[LOCK]?.trim() || undefined;
71
+ const named = word ?? (env[GROUP]?.trim() || undefined);
72
+ const from = word === undefined ? GROUP : "first word";
73
+ for (const [name, origin] of [
74
+ [named, from],
75
+ [lock, LOCK],
76
+ ])
77
+ if (name !== undefined && !isGroupName(name))
78
+ throw new CliError("validation_error", `"${name}" (${origin}) is not a group name — letters, digits, - and _, starting with a letter or a digit`);
79
+ if (lock === undefined || lock.toLowerCase() === "all")
80
+ return named === undefined || named.toLowerCase() === "all" ? undefined : { name: named, from, locked: false };
81
+ if (named !== undefined && named !== lock)
82
+ throw new CliError("permission_error", `this process is locked to group ${lock} (${LOCK}) — group "${named}" (${from}) is refused`);
83
+ return { name: lock, from: LOCK, locked: true };
84
+ };
60
85
  /** The root's options that take the next word as their value: `--timeout 30s`. */
61
86
  export const valuedOptions = (program) => new Set(program.options
62
87
  .filter((option) => option.required)
@@ -25,6 +25,7 @@ import { admittedUnderLock, changesAuthorityAt, changesAuthorityNow, isLogin, is
25
25
  import { itemOf, renderAnswer, snakeKeys } from "./envelope.js";
26
26
  import { byteCount, DEFAULT_AGENT_COOPERATIVE_MS, DEFAULT_COMMAND_MS, DEFAULT_COOPERATIVE_MS, DEFAULT_OUTPUT_BYTES, DEFAULT_SYNC_MS, execution, } from "./execution.js";
27
27
  import { setupAtStart } from "./first-run.js";
28
+ import { refuseOutsideGroup } from "./group-lock.js";
28
29
  import { installHelp } from "./help/first-screen.js";
29
30
  import { showInputFields } from "./input-fields.js";
30
31
  import { MAX_BUFFERED_INPUT, provideInputPolicy } from "./input-policy.js";
@@ -321,6 +322,7 @@ const runOnce = async (argv, definition, options) => {
321
322
  input,
322
323
  terminal: !options.streams && input.isTTY === true && process.stderr.isTTY === true,
323
324
  });
325
+ await refuseOutsideGroup(action, { app: definition.app, env: commandEnv });
324
326
  if (lock && isLogin(action) && !flags.dryRun)
325
327
  throw readOnlyRefusal(lock, "log in or out");
326
328
  if (lock && isStoreChange(action) && !flags.dryRun)
@@ -1,4 +1,4 @@
1
1
  import { type QueryWords } from "../list-query.js";
2
2
  import type { RunSearch } from "./search.js";
3
3
  export declare const RUN_SEARCH_QUERY: import("@wirecat/cli-base/query").QueryRegistry;
4
- export declare const runSearchFilter: (words: QueryWords) => Pick<RunSearch, "terms" | "status" | "errorCode" | "operation" | "profile" | "since" | "until">;
4
+ export declare const runSearchFilter: (words: QueryWords) => Pick<RunSearch, "terms" | "status" | "errorCode" | "operation" | "profile" | "kind" | "table" | "since" | "until">;
@@ -15,6 +15,8 @@ export const RUN_SEARCH_QUERY = defineQuery({
15
15
  termField("error_code", "kw", "error_code:rate_limited"),
16
16
  termField("operation", "kw", "operation:messages.download"),
17
17
  termField("profile", "kw", "profile:work"),
18
+ termField("kind", "kw", "kind:store"),
19
+ termField("table", "kw", "table:emails"),
18
20
  ],
19
21
  });
20
22
  export const runSearchFilter = (words) => {
@@ -62,5 +64,7 @@ export const runSearchFilter = (words) => {
62
64
  ...(fields.has("error_code") ? { errorCode: fields.get("error_code") } : {}),
63
65
  ...(fields.has("operation") ? { operation: fields.get("operation") } : {}),
64
66
  ...(fields.has("profile") ? { profile: fields.get("profile") } : {}),
67
+ ...(fields.has("kind") ? { kind: fields.get("kind") } : {}),
68
+ ...(fields.has("table") ? { table: fields.get("table") } : {}),
65
69
  };
66
70
  };
@@ -5,12 +5,16 @@ export interface RunSearch {
5
5
  errorCode?: string;
6
6
  operation?: string;
7
7
  profile?: string;
8
+ /** An event's `kind`: `store` for the writes a run made to the store. */
9
+ kind?: string;
10
+ /** A store event's table. */
11
+ table?: string;
8
12
  since?: string;
9
13
  until?: string;
10
14
  limit?: number;
11
15
  page?: number;
12
16
  }
13
- export declare const searchRuns: (dir: string, { query, terms, status, errorCode, operation, profile, since, until, limit, page }?: RunSearch) => {
17
+ export declare const searchRuns: (dir: string, { query, terms, status, errorCode, operation, profile, kind, table, since, until, limit, page, }?: RunSearch) => {
14
18
  items: {
15
19
  runId: string;
16
20
  command: string;