@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
@@ -14,6 +14,7 @@ import { wholeList } from "../messenger/chat-answers.js";
14
14
  import { messageItem } from "../messenger/message-items.js";
15
15
  import { readAll } from "../messenger/stdin.js";
16
16
  import { positiveCount } from "../paging.js";
17
+ import { parseButtons } from "./buttons.js";
17
18
  import { botContext } from "./context.js";
18
19
  import { botExamples } from "./examples.js";
19
20
  import { BOT_MESSAGES_QUERY, botMessageWindow } from "./list-queries.js";
@@ -53,6 +54,7 @@ const written = (context, botId, receipt, message) => itemOf({
53
54
  });
54
55
  /** Says what fills the copy, rather than printing an empty list. */
55
56
  const nothingKept = (context) => new CliError("not_found", `this bot has kept nothing on this machine yet — run \`${context.words} messages list <chat>\` once without --offline`);
57
+ const collectButton = (value, previous = []) => [...previous, value];
56
58
  const marks = (md, html) => {
57
59
  if (md && html)
58
60
  throw new CliError("validation_error", "--md and --html mark up the text two ways; use one");
@@ -74,6 +76,7 @@ const sendCommand = (bot) => annotate(new Command("send"), {
74
76
  .option("--silent", "deliver without a notification")
75
77
  .option("--md", "read this messenger's Markdown; see its formatting guide for supported syntax")
76
78
  .option("--html", "the text is HTML: <b>, <i>, <a href>, <code>")
79
+ .option("--button <text=data>", "an inline button, as <text>=<data>; repeat for more in one row; the data (1 to 64 bytes) goes back to the bot", collectButton)
77
80
  .addOption(ownerOnlyOption("--file <file>", "attach a file; the text becomes its caption"))
78
81
  .addOption(ownerOnlyOption("--photo <file>", "attach a .jpg, .png or .webp as a photo; the text becomes its caption"))
79
82
  .addOption(ownerOnlyOption("--as-file", "send the --file as a file to download, a video included"))
@@ -83,6 +86,7 @@ const sendCommand = (bot) => annotate(new Command("send"), {
83
86
  const context = botContext(this, bot);
84
87
  const options = this.opts();
85
88
  marks(options.md, options.html);
89
+ const buttons = parseButtons(options.button ?? []);
86
90
  const ref = context.chatRef(chat);
87
91
  const attachments = await readAttachments({
88
92
  ...(options.photo === undefined ? {} : { photo: options.photo }),
@@ -118,6 +122,7 @@ const sendCommand = (bot) => annotate(new Command("send"), {
118
122
  ...(spans.length > 0 ? { formatting: spans } : {}),
119
123
  ...(options.html ? { html: true } : {}),
120
124
  ...(attachments.length > 0 ? { attachments } : {}),
125
+ ...(buttons.length > 0 ? { buttons } : {}),
121
126
  }), (sent) => ({ messageId: sent.id }));
122
127
  seen(context, message);
123
128
  if (message.senderId)
@@ -204,16 +209,23 @@ const editCommand = (bot) => annotate(new Command("edit"), {
204
209
  effects: REMOTE_WRITE,
205
210
  examples: botExamples(bot, 'messages edit Team 101 "Doors open at 10"'),
206
211
  })
207
- .description("replace the text of a message the bot sent")
212
+ .description("replace the text of a message the bot sent; --button replaces its buttons, --no-buttons takes them off")
213
+ .summary("replace the text or buttons of a message the bot sent")
208
214
  .argument("<chat>", "a chat id, user:<id> for a person, or the title of a chat this bot has seen")
209
215
  .argument("<message>", "message id")
210
216
  .argument("<text>", "the new text")
211
217
  .option("--md", "read this messenger's Markdown; see its formatting guide for supported syntax")
212
218
  .option("--html", "the text is HTML: <b>, <i>, <a href>, <code>")
219
+ .option("--button <text=data>", "a button under the message, as <text>=<data>; replaces its buttons; repeat for more in one row", collectButton)
220
+ .option("--no-buttons", "take the buttons off the message")
213
221
  .action(async function (chat, messageId, text) {
214
222
  const context = botContext(this, bot);
215
223
  const options = this.opts();
216
224
  marks(options.md, options.html);
225
+ if (options.buttons === false && options.button?.length) {
226
+ throw new CliError("validation_error", "--button and --no-buttons set the buttons two ways; use one");
227
+ }
228
+ const buttons = options.buttons === false ? [] : options.button ? parseButtons(options.button) : undefined;
217
229
  const ref = context.chatRef(chat);
218
230
  await context.run(async (events) => {
219
231
  const adapter = await context.authenticated({ events });
@@ -227,6 +239,7 @@ const editCommand = (bot) => annotate(new Command("edit"), {
227
239
  const message = await guardedWrite(context.guard(), { operationId, chatId: ref, kind: "edit", key: "bot.messages.edit", messageId, length: plain.length }, () => edit(ref, messageId, plain, {
228
240
  ...(spans.length > 0 ? { formatting: spans } : {}),
229
241
  ...(options.html ? { html: true } : {}),
242
+ ...(buttons ? { buttons } : {}),
230
243
  }));
231
244
  const botId = await botIdOf(context, adapter);
232
245
  await context.copy.keep(botId, [message], "send", context.renderer.warn, adapter.senders?.());
@@ -19,6 +19,11 @@ import type { BotTokenStore } from "./token.js";
19
19
  * MAX's Bot API writes to a person by user id, and Telegram's chat id for a dialog is the person's id.
20
20
  */
21
21
  export type BotChatRef = string;
22
+ /** An inline button that sends `data` back to the bot when pressed; Telegram allows 1 to 64 bytes of it. */
23
+ export interface BotButton {
24
+ text: string;
25
+ data: string;
26
+ }
22
27
  /** How one bot message goes. A bot send is never repeated — neither Bot API makes a repeat safe — so it has no send id. */
23
28
  export interface BotSendOptions {
24
29
  /** A message id in the same chat. */
@@ -30,6 +35,8 @@ export interface BotSendOptions {
30
35
  /** `text` is the messenger's HTML. */
31
36
  html?: boolean;
32
37
  attachments?: Upload[];
38
+ /** Inline buttons under the message, row by row. */
39
+ buttons?: BotButton[][];
33
40
  }
34
41
  /** Sending, changing and deleting the bot's messages. */
35
42
  export interface BotMessaging {
@@ -38,6 +45,7 @@ export interface BotMessaging {
38
45
  markup?: Markup[];
39
46
  formatting?: TextSpan[];
40
47
  html?: boolean;
48
+ buttons?: BotButton[][];
41
49
  }): Promise<Message>;
42
50
  delete(chat: BotChatRef, messageIds: Id[]): Promise<void>;
43
51
  }
@@ -8,6 +8,7 @@ export interface SavedRunSettings {
8
8
  record?: boolean | undefined;
9
9
  keepRunsForDays?: number | undefined;
10
10
  keepSuccessfulRunsForDays?: number | undefined;
11
+ keepStoreRunsForDays?: number | undefined;
11
12
  runsSizeLimitMb?: number | undefined;
12
13
  /** `record_input`: left out, the typed words are kept, secrets hidden. */
13
14
  recordInput?: RecordInput | undefined;
@@ -17,6 +18,7 @@ export interface RunSettings {
17
18
  keepFailedRuns: boolean;
18
19
  keepRunsForDays: number;
19
20
  keepSuccessfulRunsForDays: number;
21
+ keepStoreRunsForDays: number;
20
22
  runsSizeLimitMb: number;
21
23
  }
22
24
  /**
@@ -3,7 +3,7 @@ import { isCliError } from "@wirecat/cli-base";
3
3
  import { metaOf } from "@wirecat/cli-base/commands";
4
4
  import { providerErrorKey } from "../runs/events.js";
5
5
  import { startRecording, wasSettled } from "../runs/recording.js";
6
- import { KEEP_RUNS_FOR_DAYS, KEEP_SUCCESSFUL_RUNS_FOR_DAYS, RUNS_SIZE_LIMIT_MB } from "../runs/run.js";
6
+ import { KEEP_RUNS_FOR_DAYS, KEEP_STORE_RUNS_FOR_DAYS, KEEP_SUCCESSFUL_RUNS_FOR_DAYS, RUNS_SIZE_LIMIT_MB, } from "../runs/run.js";
7
7
  import { keepsSuccess, runContextOf } from "../runs/run-context.js";
8
8
  import { currentAttempt, runEvent } from "../runs/scope.js";
9
9
  import { environmentOf } from "./context.js";
@@ -19,6 +19,7 @@ export const runSettings = (flag, saved = {}) => {
19
19
  keepFailedRuns: record || flag !== false,
20
20
  keepRunsForDays: saved.keepRunsForDays ?? KEEP_RUNS_FOR_DAYS,
21
21
  keepSuccessfulRunsForDays: saved.keepSuccessfulRunsForDays ?? KEEP_SUCCESSFUL_RUNS_FOR_DAYS,
22
+ keepStoreRunsForDays: saved.keepStoreRunsForDays ?? KEEP_STORE_RUNS_FOR_DAYS,
22
23
  runsSizeLimitMb: saved.runsSizeLimitMb ?? RUNS_SIZE_LIMIT_MB,
23
24
  };
24
25
  };
@@ -69,6 +70,7 @@ const tracker = (options, typed) => {
69
70
  keepFailed: settings.keepFailedRuns,
70
71
  keepDays: settings.keepRunsForDays,
71
72
  keepSuccessDays: settings.keepSuccessfulRunsForDays,
73
+ keepStoreDays: settings.keepStoreRunsForDays,
72
74
  maxBytes: settings.runsSizeLimitMb * 1024 * 1024,
73
75
  trace: false,
74
76
  format,
@@ -14,7 +14,7 @@ import { knownBeside, knownPermissionKeys, unknownPermissionIssues, } from "./pe
14
14
  import { profileFree } from "./profile.js";
15
15
  import { fromFile, NONE_NAMED } from "./settings.js";
16
16
  import { nextStep } from "./steps.js";
17
- import { changeStoreSetting, isStoreSetting, offersStoreSetting, storeSettings, storeSettingsOf, } from "./store-settings.js";
17
+ import { changeStoreSetting, isOwnerOnlyStoreSetting, isStoreSetting, offersStoreSetting, storeSettings, storeSettingsOf, } from "./store-settings.js";
18
18
  export const configCommand = (app, config, { permissionKey = config.permissions, ownerOnly = {}, } = {}) => {
19
19
  const command = new Command("config").description("the settings in force, and where each one came from");
20
20
  // Only a messenger has bots, and with them the personal and bot sections of the file. Elsewhere the options stay
@@ -91,6 +91,11 @@ export const configCommand = (app, config, { permissionKey = config.permissions,
91
91
  if (isStoreSetting(setting) && !offersStoreSetting(app, setting))
92
92
  throw new CliError("validation_error", `no setting called "${setting}" here — it belongs to the messenger CLIs; one of: ${[...config.allSettings, ...storeSettingsOf(app)].join(", ")}`);
93
93
  if (isStoreSetting(setting)) {
94
+ // A guard against a change by mistake, not a boundary: an agent can drop its markers or write the store file.
95
+ if (isOwnerOnlyStoreSetting(setting) && (environmentOf(this).agent || agentOf(env)))
96
+ throw new CliError("permission_error", `${setting} is the owner's to set, in a terminal: an agent's run is stopped from changing it by mistake`, {
97
+ setting,
98
+ });
94
99
  if (everyone || personal || bot)
95
100
  throw new CliError("validation_error", `${setting} is store-wide — --defaults, --personal and --bot do not apply`);
96
101
  const lock = envName(app, "PROFILE_LOCK");
@@ -131,6 +131,7 @@ export const baseContext = (command, resolveSettings) => {
131
131
  ...(settings.keepSuccessfulRunsForDays === undefined
132
132
  ? {}
133
133
  : { keepSuccessDays: settings.keepSuccessfulRunsForDays }),
134
+ ...(settings.keepStoreRunsForDays === undefined ? {} : { keepStoreDays: settings.keepStoreRunsForDays }),
134
135
  ...(settings.runsSizeLimitMb === undefined ? {} : { maxBytes: settings.runsSizeLimitMb * 1024 * 1024 }),
135
136
  processRun: !environment.agent,
136
137
  format,
@@ -1,6 +1,6 @@
1
1
  import { CliError } from "@wirecat/cli-base";
2
2
  import { annotate, sharedCommand } from "@wirecat/cli-base/commands";
3
- import { Command } from "commander";
3
+ import { Command, Option } from "commander";
4
4
  import { note } from "../entities/note.js";
5
5
  import { addMeetingCommands } from "../meetings/cli/index.js";
6
6
  import { commandsCommand } from "./commands-command.js";
@@ -10,6 +10,35 @@ import { doctorCommand } from "./messenger/doctor-command.js";
10
10
  import { mcpCommand } from "./messenger/mcp-command.js";
11
11
  import { searchCommand } from "./messenger/search-command.js";
12
12
  import { settingsFor } from "./settings.js";
13
+ /**
14
+ * `search all` as it was before meetings became one of its sources: cli-memo, zoom-cli and drive-cli review their
15
+ * overrides against these exact values, and a template that moves fails their start. Drop it in the cli-core release
16
+ * that cli-memo#703, zoom-cli#344 and drive-cli's update land with.
17
+ */
18
+ const frozenSearch = (search) => {
19
+ const all = search.commands.find((command) => command.name() === "all");
20
+ if (!all)
21
+ return search;
22
+ all
23
+ .summary("search stored messages, notes, calendar events and selected meeting transcripts")
24
+ .description("search messenger messages and notes in the local store, calendar events when the store holds a calendar, and " +
25
+ "a meeting account's transcripts when --source names one — best match first; not mail (the separate memo CLI " +
26
+ "searches it: memo search mail), tasks, people, memories or projects. Use it when you do not know where " +
27
+ "something was written; search messages or notes reads one kind with all its fields");
28
+ const option = (flags) => all.options.find((one) => one.flags === flags);
29
+ const only = option("--only <resources>");
30
+ const source = option("--source <accounts>");
31
+ if (only)
32
+ only.description =
33
+ "only these resources, separated by commas: messages, notes, events; meetings when --source names a meeting account";
34
+ if (source) {
35
+ source.description =
36
+ "only these accounts, separated by commas: provider:account as a hit shows it, a provider, a kind or " +
37
+ "group:<name>; each resource reads the ones of its kind, and meetings only when it names one";
38
+ all.options.splice(all.options.indexOf(source) + 1, 0, new Option("--max-meetings <n>", "how many of the meeting account's meetings to look through, newest first, or all for every one (default 100)"));
39
+ }
40
+ return search;
41
+ };
13
42
  /** Construction-only defaults for a CLI that explicitly binds an independent source or transport. */
14
43
  export const sharedCommandTemplate = (app, name) => {
15
44
  const unavailable = () => {
@@ -32,7 +61,7 @@ export const sharedCommandTemplate = (app, name) => {
32
61
  if (name === "mcp")
33
62
  return mcpCommand(messenger);
34
63
  if (name === "search")
35
- return searchCommand(messenger);
64
+ return frozenSearch(searchCommand(messenger));
36
65
  if (name === "meetings") {
37
66
  const root = new Command(app.command);
38
67
  addMeetingCommands(root, {
@@ -0,0 +1,42 @@
1
+ import type { Command } from "commander";
2
+ import { type SimpleReference } from "../domain/references.js";
3
+ import { type AppIdentity } from "../ports/app.js";
4
+ import { type MessageStore } from "../store/store.js";
5
+ /**
6
+ * Marks a command, and every command under it, as one that keeps to the run's account group: it scopes its reads
7
+ * and writes with `scopeToGroup`. Under `<PREFIX>_GROUP_LOCK` every other command is refused (WC-ACCT-13).
8
+ */
9
+ export declare const groupAware: <T extends Command>(command: T) => T;
10
+ export declare const isGroupAware: (command: Command) => boolean;
11
+ /**
12
+ * What a bare id names: a referenced thing's kind, a proposed action (`action`, as `actions confirm 17` takes it), or
13
+ * a proposal id of the review registry (`proposal`: `17070`, `17080/f1`, `link:17`, `fact:512`).
14
+ */
15
+ export type RefKind = SimpleReference | "action" | "proposal";
16
+ /**
17
+ * The kind of thing a bare id names, per argument (by its name) or option (by its long flag):
18
+ * `refKinds(show, { organization: "organization", "--note": "note" })`. An argument or a `--<kind>` option named
19
+ * after a kind needs no entry. Under the lock a bare value there is checked as `<kind>:<value>`; a command that
20
+ * declares nothing has any other argument value refused, since what it names is unknown (`1e0`, `+1`, `link:1`).
21
+ * `{}` says no argument takes an id, so free text passes.
22
+ */
23
+ export declare const refKinds: <T extends Command>(command: T, kinds: Readonly<Record<string, RefKind>>) => T;
24
+ /**
25
+ * Every reference typed into the run: each word of each argument and option value that is a reference, and each bare
26
+ * id in a position whose kind is known, as `<kind>:<id>`. `unknown` holds every other argument value of a command
27
+ * that declares no kinds.
28
+ */
29
+ export declare const referencesIn: (command: Command) => {
30
+ references: string[];
31
+ unknown: string[];
32
+ };
33
+ /**
34
+ * Under `<PREFIX>_GROUP_LOCK`, refuses a command that does not keep to a group, and a reference whose thing belongs
35
+ * only to accounts outside the group. A thing no account brought is the owner's and passes in every group, a note
36
+ * written in memo included; a person passes when one of their identities is in the group.
37
+ */
38
+ export declare const refuseOutsideGroup: (command: Command, { app, env, store }: {
39
+ app: AppIdentity;
40
+ env: NodeJS.ProcessEnv;
41
+ store?: MessageStore;
42
+ }) => Promise<void>;
@@ -0,0 +1,130 @@
1
+ import { CliError } from "@wirecat/cli-base";
2
+ import { INTERNAL_NOTES } from "../domain/providers.js";
3
+ import { looksLikeReference, SIMPLE_REFERENCES } from "../domain/references.js";
4
+ import { envName } from "../ports/app.js";
5
+ import { inGroupOf } from "../search/groups.js";
6
+ import { groupLockOf, listContextOf } from "../services/search-kind.js";
7
+ import { openStore } from "../store/store.js";
8
+ import { PROFILE_FREE } from "./profile.js";
9
+ const keepsToGroup = new WeakSet();
10
+ /**
11
+ * Marks a command, and every command under it, as one that keeps to the run's account group: it scopes its reads
12
+ * and writes with `scopeToGroup`. Under `<PREFIX>_GROUP_LOCK` every other command is refused (WC-ACCT-13).
13
+ */
14
+ export const groupAware = (command) => {
15
+ keepsToGroup.add(command);
16
+ return command;
17
+ };
18
+ export const isGroupAware = (command) => {
19
+ let top;
20
+ for (let at = command; at?.parent; at = at.parent) {
21
+ if (keepsToGroup.has(at))
22
+ return true;
23
+ top = at;
24
+ }
25
+ return top !== undefined && PROFILE_FREE.has(top.name());
26
+ };
27
+ const valuesOf = (value) => typeof value === "string" ? [value] : Array.isArray(value) ? value.flatMap(valuesOf) : [];
28
+ const declared = new WeakMap();
29
+ /**
30
+ * The kind of thing a bare id names, per argument (by its name) or option (by its long flag):
31
+ * `refKinds(show, { organization: "organization", "--note": "note" })`. An argument or a `--<kind>` option named
32
+ * after a kind needs no entry. Under the lock a bare value there is checked as `<kind>:<value>`; a command that
33
+ * declares nothing has any other argument value refused, since what it names is unknown (`1e0`, `+1`, `link:1`).
34
+ * `{}` says no argument takes an id, so free text passes.
35
+ */
36
+ export const refKinds = (command, kinds) => {
37
+ declared.set(command, kinds);
38
+ return command;
39
+ };
40
+ const isSimpleReference = (name) => SIMPLE_REFERENCES.includes(name);
41
+ const kindAt = (command, name, implicit) => declared.get(command)?.[name] ?? (isSimpleReference(implicit) ? implicit : undefined);
42
+ /**
43
+ * Every reference typed into the run: each word of each argument and option value that is a reference, and each bare
44
+ * id in a position whose kind is known, as `<kind>:<id>`. `unknown` holds every other argument value of a command
45
+ * that declares no kinds.
46
+ */
47
+ export const referencesIn = (command) => {
48
+ const references = new Set();
49
+ const unknown = [];
50
+ const typed = (value, kind, onBare) => {
51
+ for (const word of value.split(/[\s,]+/).filter(Boolean)) {
52
+ const stored = /^([1-9]\d*)(?:\/[\w-]+)?$/.exec(word)?.[1];
53
+ const proposalKind = kind === "action" || kind === "proposal";
54
+ if (looksLikeReference(word) || (proposalKind && PROPOSAL_REF.test(word)))
55
+ references.add(word);
56
+ else if (proposalKind && stored)
57
+ references.add(`action:${stored}`);
58
+ // A key-document suggestion is a link between the document and its project, so both ends are checked.
59
+ else if (kind === "proposal" && /^key:[1-9]\d*$/.test(word))
60
+ references.add(`link:${word.slice(4)}`);
61
+ // A close suggestion is its task's, which the owner made; the task's evidence is stripped where it is shown.
62
+ else if (kind === "proposal" && word.startsWith("close:"))
63
+ references.add(`task:${word.slice(6)}`);
64
+ else if (kind !== undefined && kind !== "proposal" && !word.includes(":"))
65
+ references.add(`${kind}:${word}`);
66
+ else
67
+ onBare?.();
68
+ }
69
+ };
70
+ command.registeredArguments.forEach((argument, at) => {
71
+ const name = argument.name();
72
+ const kind = kindAt(command, name, name);
73
+ for (const value of valuesOf(command.processedArgs[at] ?? command.args[at]))
74
+ typed(value, kind, () => {
75
+ // A proposal id of no kind the lock knows cannot be checked, so it is refused even where kinds are declared.
76
+ const named = `<${name}> ${value}`;
77
+ if ((!declared.has(command) || kind === "proposal") && !unknown.includes(named))
78
+ unknown.push(named);
79
+ });
80
+ });
81
+ for (const option of command.options) {
82
+ const long = option.long ?? "";
83
+ for (const value of valuesOf(command.getOptionValue(option.attributeName())))
84
+ typed(value, kindAt(command, long, long.replace(/^--/, "")));
85
+ }
86
+ return { references: [...references], unknown };
87
+ };
88
+ const PROPOSAL_REF = /^(action|link):[1-9]\d*$/;
89
+ const pathOf = (command) => {
90
+ const words = [];
91
+ for (let at = command; at?.parent; at = at.parent)
92
+ words.unshift(at.name());
93
+ return words.join(" ");
94
+ };
95
+ /**
96
+ * Under `<PREFIX>_GROUP_LOCK`, refuses a command that does not keep to a group, and a reference whose thing belongs
97
+ * only to accounts outside the group. A thing no account brought is the owner's and passes in every group, a note
98
+ * written in memo included; a person passes when one of their identities is in the group.
99
+ */
100
+ export const refuseOutsideGroup = async (command, { app, env, store }) => {
101
+ const lock = groupLockOf(app, env);
102
+ if (lock === undefined)
103
+ return;
104
+ const locked = `this process is locked to group ${lock} (${envName(app, "GROUP_LOCK")})`;
105
+ if (!isGroupAware(command))
106
+ throw new CliError("permission_error", `${locked} — \`${app.command} ${pathOf(command)}\` does not keep to a group, so it does not run`, { group: lock });
107
+ const { references, unknown } = referencesIn(command);
108
+ if (unknown.length)
109
+ throw new CliError("permission_error", `${locked} — \`${app.command} ${pathOf(command)}\` takes ${unknown.join(", ")} as an id of a kind it does not ` +
110
+ "declare, so it cannot be checked against the group", { group: lock });
111
+ if (references.length === 0)
112
+ return;
113
+ const opened = store ?? (await openStore({ env, command: app.command, version: app.version }));
114
+ try {
115
+ const context = await listContextOf(opened, { provider: "notes", account: INTERNAL_NOTES }, app, undefined, env);
116
+ const inGroup = inGroupOf(context, lock);
117
+ for (const reference of references) {
118
+ const ends = await opened.refs.ends(reference);
119
+ if (ends?.some((end) => end.length > 0 && !end.some(inGroup)))
120
+ throw new CliError("permission_error", `${locked} — ${reference} belongs to an account outside it`, {
121
+ group: lock,
122
+ reference,
123
+ });
124
+ }
125
+ }
126
+ finally {
127
+ if (!store)
128
+ await opened.close();
129
+ }
130
+ };
@@ -1,7 +1,9 @@
1
1
  export { AI_ENTRIES, AI_SETTING_KEYS, type AISettings, resolveAISettings } from "../analysis/settings.js";
2
2
  export { AGENT_INPUT_MAX_CHARS, type AgentCli, type AgentInput, readSchedule, SCHEDULE_DEFAULTS, scheduleFile, spentToday, } from "../background/schedules.js";
3
3
  export { parseDuration } from "../domain/duration.js";
4
- export { openOf, PROFILE_PLACEHOLDER, type ProfilesFor, type RefOpen, type RefSummary, refLabel, } from "../domain/ref-summaries.js";
4
+ export { openOf, PROFILE_PLACEHOLDER, type ProfilesFor, profilesOn, type RefOpen, type RefSummary, refLabel, storedProfilesFor, type WritesWith, writesWithOf, } from "../domain/ref-summaries.js";
5
+ /** The shared entities `person_context`, `organization_context`, `deal_context` and `deal_context.brief`. */
6
+ export { dealBrief as dealBriefSchema, dealContext as dealContextSchema, organizationContext as organizationContextSchema, personContext as personContextSchema, } from "../entities/business-context.js";
5
7
  export { botTemplate } from "../entities/list-results.js";
6
8
  export { syncProgress } from "../entities/store-records.js";
7
9
  export { isCliFailure, isCommanderFailure, storeDamaged } from "../errors/failures.js";
@@ -49,6 +51,7 @@ export { answerEntity } from "./answer-entity.js";
49
51
  export { type AppDoctorOptions, appDoctorReport } from "./app-doctor-command.js";
50
52
  export type { AppMcpOptions } from "./app-mcp-command.js";
51
53
  export { actorOf } from "./author.js";
54
+ export { type BaseStagesCommandOptions, baseStagesCommand } from "./base-stages-command.js";
52
55
  export type { ApiCommandInput, ApiCommands } from "./bot/api.js";
53
56
  export { apiFlagOf, apiJson, apiOptionKey, apiPlainJson, checkApiBody, checkApiParameter, parseApiJson, readApiBody, } from "./bot/api-input.js";
54
57
  export { prepareRpcApiBody, type RpcApiBody } from "./bot/api-rpc.js";
@@ -81,6 +84,7 @@ export { type AnswerOutput, answerSchema, type Body, type ItemBody, isBody, item
81
84
  export { withAbort } from "./execution.js";
82
85
  export { parseEvidenceFindingsJson, parseMailFindingsJson, parseMeetingFindingsJson, readMailFindingsJson, } from "./findings-input.js";
83
86
  export { askSetupQuestions, asksAtStart, type FirstRun, type FirstRunIo, setupAtStart, systemLanguage, } from "./first-run.js";
87
+ export { groupAware, isGroupAware, type RefKind, referencesIn, refKinds, refuseOutsideGroup } from "./group-lock.js";
84
88
  export { checkGuide, checkStep, type GuideOptions, type GuideReference, type GuideStep, loadScenarios, MEMO_SCENARIOS, type Scenario, shellProblems, } from "./guide.js";
85
89
  export { type CommandHelp, commandHelp, commandHelpMarkdown, commandHelpText, exampleReport, type NextChoice, nextUsually, } from "./help/command-help.js";
86
90
  export { commandsText } from "./help/commands-text.js";
@@ -122,7 +126,7 @@ export { MODEL_CATALOGUE_QUERY, type ModelCatalogueOptions } from "./model-catal
122
126
  export { writeNewFile } from "./new-file.js";
123
127
  export { positiveCount, window, withPaging } from "./paging.js";
124
128
  export { type CommandPermissions, type ConditionalKey, commandPathKey, commandPermissions, knownBeside, knownPermissionKeys, type PermissionKeyOf, type PermissionKeySource, refuseUnknownPermissionKeys, unknownPermissionIssues, unknownPermissionKeys, } from "./permission-keys.js";
125
- export { asFirstWord, commandWords, liftProfile, profileFree, refuseCommandName, rootOf, takesProfile, usableProfileName, } from "./profile.js";
129
+ export { asFirstWord, commandWords, liftProfile, profileFree, refuseCommandName, rootOf, runGroup, takesProfile, usableProfileName, } from "./profile.js";
126
130
  export { ProfileTokenStore, type ProfileTokenStoreOptions, type TokenStorage } from "./profile-token.js";
127
131
  export { createProgram, type ProgramDefinition, type ProgramOptions, type RunOptions, run } from "./program.js";
128
132
  export { type ProjectTextHints, projectAnswerParts, projectCutoffTime, projectEvidenceText, projectWindowOf, withSyncCommands, } from "./project-evidence.js";
@@ -130,6 +134,7 @@ export { type ProjectStatusHints, type ProjectStatusItem, projectStatusAnswer, p
130
134
  export { STATUS_ROWS, STATUS_SIGNAL_ROWS } from "./project-status-rows.js";
131
135
  export { fieldsOf, projectFields } from "./result-fields.js";
132
136
  export { backfillScheduleRun, SCHEDULE_SETTINGS, type ScheduleHost, type ScheduleLimits, scheduleLimitsOf, } from "./schedule/schedule-command.js";
137
+ export { deniedKinds, deniedKindsOf, type LeftOut, type SearchedKind } from "./search-left-out.js";
133
138
  export { type DeclaredSetting, type SettingRow, settingRows, withSettingDefaults } from "./setting-defaults.js";
134
139
  export { type Config, type Configuration, count, first, flag, fromFile, type GlobalFlags, NONE_NAMED, namedProfile, type ProfileKind, plain, type ResolveOptions, type Settings, type SettingsExtension, type SettingsExtensionContext, type Source, settingsFor, } from "./settings.js";
135
140
  export { type PermissionAnswer, readSetupAnswers, type SetupAnswers, setupPermissionCeiling } from "./setup-answers.js";
package/dist/cli/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  export { AI_ENTRIES, AI_SETTING_KEYS, resolveAISettings } from "../analysis/settings.js";
2
2
  export { AGENT_INPUT_MAX_CHARS, readSchedule, SCHEDULE_DEFAULTS, scheduleFile, spentToday, } from "../background/schedules.js";
3
3
  export { parseDuration } from "../domain/duration.js";
4
- export { openOf, PROFILE_PLACEHOLDER, refLabel, } from "../domain/ref-summaries.js";
4
+ export { openOf, PROFILE_PLACEHOLDER, profilesOn, refLabel, storedProfilesFor, writesWithOf, } from "../domain/ref-summaries.js";
5
+ /** The shared entities `person_context`, `organization_context`, `deal_context` and `deal_context.brief`. */
6
+ export { dealBrief as dealBriefSchema, dealContext as dealContextSchema, organizationContext as organizationContextSchema, personContext as personContextSchema, } from "../entities/business-context.js";
5
7
  export { botTemplate } from "../entities/list-results.js";
6
8
  export { syncProgress } from "../entities/store-records.js";
7
9
  export { isCliFailure, isCommanderFailure, storeDamaged } from "../errors/failures.js";
@@ -43,6 +45,7 @@ export { evaluateAgent, } from "./agent-evaluation.js";
43
45
  export { answerEntity } from "./answer-entity.js";
44
46
  export { appDoctorReport } from "./app-doctor-command.js";
45
47
  export { actorOf } from "./author.js";
48
+ export { baseStagesCommand } from "./base-stages-command.js";
46
49
  export { apiFlagOf, apiJson, apiOptionKey, apiPlainJson, checkApiBody, checkApiParameter, parseApiJson, readApiBody, } from "./bot/api-input.js";
47
50
  export { prepareRpcApiBody } from "./bot/api-rpc.js";
48
51
  export { botContext, botWords } from "./bot/context.js";
@@ -73,6 +76,7 @@ export { answerSchema, isBody, itemAnswer, itemOf, jsonlRecords, judgedAnswer, l
73
76
  export { withAbort } from "./execution.js";
74
77
  export { parseEvidenceFindingsJson, parseMailFindingsJson, parseMeetingFindingsJson, readMailFindingsJson, } from "./findings-input.js";
75
78
  export { askSetupQuestions, asksAtStart, setupAtStart, systemLanguage, } from "./first-run.js";
79
+ export { groupAware, isGroupAware, referencesIn, refKinds, refuseOutsideGroup } from "./group-lock.js";
76
80
  export { checkGuide, checkStep, loadScenarios, MEMO_SCENARIOS, shellProblems, } from "./guide.js";
77
81
  export { commandHelp, commandHelpMarkdown, commandHelpText, exampleReport, nextUsually, } from "./help/command-help.js";
78
82
  export { commandsText } from "./help/commands-text.js";
@@ -112,7 +116,7 @@ export { MODEL_CATALOGUE_QUERY } from "./model-catalogue-command.js";
112
116
  export { writeNewFile } from "./new-file.js";
113
117
  export { positiveCount, window, withPaging } from "./paging.js";
114
118
  export { commandPathKey, commandPermissions, knownBeside, knownPermissionKeys, refuseUnknownPermissionKeys, unknownPermissionIssues, unknownPermissionKeys, } from "./permission-keys.js";
115
- export { asFirstWord, commandWords, liftProfile, profileFree, refuseCommandName, rootOf, takesProfile, usableProfileName, } from "./profile.js";
119
+ export { asFirstWord, commandWords, liftProfile, profileFree, refuseCommandName, rootOf, runGroup, takesProfile, usableProfileName, } from "./profile.js";
116
120
  export { ProfileTokenStore } from "./profile-token.js";
117
121
  export { createProgram, run } from "./program.js";
118
122
  export { projectAnswerParts, projectCutoffTime, projectEvidenceText, projectWindowOf, withSyncCommands, } from "./project-evidence.js";
@@ -120,6 +124,7 @@ export { projectStatusAnswer, projectStatusRow, projectStatusSchema, projectStat
120
124
  export { STATUS_ROWS, STATUS_SIGNAL_ROWS } from "./project-status-rows.js";
121
125
  export { fieldsOf, projectFields } from "./result-fields.js";
122
126
  export { backfillScheduleRun, SCHEDULE_SETTINGS, scheduleLimitsOf, } from "./schedule/schedule-command.js";
127
+ export { deniedKinds, deniedKindsOf } from "./search-left-out.js";
123
128
  export { settingRows, withSettingDefaults } from "./setting-defaults.js";
124
129
  export { count, first, flag, fromFile, NONE_NAMED, namedProfile, plain, settingsFor, } from "./settings.js";
125
130
  export { readSetupAnswers, setupPermissionCeiling } from "./setup-answers.js";
@@ -34,19 +34,25 @@ const ALL_SINCE = "90d";
34
34
  /** What a background `--all` job is listed under; no chat argument is spelled like it. */
35
35
  const ALL_CHATS = "--all";
36
36
  /** Says where the history limits (history_* settings) stopped the read, so an agent does not take it for all. */
37
- const limitedLine = (result, status) => {
37
+ const limitedLines = (result, status) => {
38
38
  if ("items" in result) {
39
- const { groupTooLarge = 0, olderThanWindow = 0 } = result.limited ?? {};
40
- if (groupTooLarge + olderThanWindow === 0)
41
- return undefined;
42
- return (`the history limits (history_* settings) left ${groupTooLarge} big group(s) unread and read ${olderThanWindow} ` +
43
- `chat(s) only to the window's start — \`${status}\` lists them; \`messages sync <chat> --full-history\` reads one in full`);
39
+ const { groupTooLarge = 0, olderThanWindow = 0, muted = 0 } = result.limited ?? {};
40
+ const lines = [];
41
+ if (groupTooLarge + olderThanWindow > 0)
42
+ lines.push(`the history limits (history_* settings) left ${groupTooLarge} big group(s) unread and read ${olderThanWindow} ` +
43
+ `chat(s) only to the window's start — \`${status}\` lists them; \`messages sync <chat> --full-history\` reads one in full`);
44
+ if (muted > 0)
45
+ lines.push(`${muted} muted chat(s) not read — --with-muted or history_muted true reads them; \`messages sync <chat>\` reads one, and ` +
46
+ "`--full-history` keeps it in every --all");
47
+ return lines;
44
48
  }
45
49
  if (result.limited === "group_too_large")
46
- return "not read: a group above history_group_members_max — `--full-history` reads it and keeps it in full";
50
+ return ["not read: a group above history_group_members_max — `--full-history` reads it and keeps it in full"];
47
51
  if (result.limited === "older_than_window")
48
- return "read to the history window's start (history_dialog_days / history_group_days) — `--full-history` reads further";
49
- return undefined;
52
+ return [
53
+ "read to the history window's start (history_dialog_days / history_group_days) — `--full-history` reads further",
54
+ ];
55
+ return [];
50
56
  };
51
57
  export const syncCommand = (messenger) => {
52
58
  const fetching = messenger.fetching ?? FETCHING;
@@ -60,7 +66,8 @@ export const syncCommand = (messenger) => {
60
66
  .description("bring a chat's history in the local store up to date, newest first; run it again to continue; --all syncs every chat; " +
61
67
  'with --json, stderr carries progress lines: {"event":"progress","step":"sync","chats","chats_done","fetched"}, counts only')
62
68
  .argument("[chat]", messenger.chatArgument)
63
- .option("--all", `every chat, most recently active first — what search needs; the last ${ALL_SINCE} unless --since-time or --last`)
69
+ .option("--all", `every chat, most recently active first — what search needs; the last ${ALL_SINCE} unless --since-time or --last; ` +
70
+ "muted chats only with --with-muted or history_muted true")
64
71
  .option("--limit <n>", `at most this many messages in this run, per chat with --all; ${fetching.maxPages * fetching.page} if not given`, wholeNumber)
65
72
  .option("--page-size <n>", `how many messages one request asks for; ${fetching.page} if not given`, wholeNumber)
66
73
  .option("--pause <duration>", fetching.jitter
@@ -74,16 +81,19 @@ export const syncCommand = (messenger) => {
74
81
  .option("--catch-up-messages <n>", "skip a graph rebuild larger than this many messages", wholeNumber)
75
82
  .option("--catch-up-time <duration>", "local preparation time budget, 30s by default")
76
83
  .option("--full-history", "read and keep this chat's history in full from now on, past the history limits (history_* settings)")
84
+ .option("--with-muted", "with --all: also read the chats the owner muted, as history_muted true does")
77
85
  .option("--background", "run as a job that outlives this command; `store jobs show` follows it")
78
86
  .option("--dry-run", "only estimate how many messages, requests and minutes a full fetch would still take — from the store, no request")
79
87
  .action(async function (chat) {
80
- const { all, pause, sinceTime: since, last, background, dryRun: estimate, catchUp, catchUpChunks, catchUpMessages, catchUpTime, fullHistory: include, ...sizes } = this.opts();
88
+ const { all, pause, sinceTime: since, last, background, dryRun: estimate, catchUp, catchUpChunks, catchUpMessages, catchUpTime, fullHistory: include, withMuted, ...sizes } = this.opts();
81
89
  if ((chat === undefined) === (all !== true))
82
90
  throw new CliError("validation_error", "name a chat, or --all for every chat");
83
91
  if (all && estimate)
84
92
  throw new CliError("validation_error", "--dry-run prices one chat; not with --all");
85
93
  if (include && chat === undefined)
86
94
  throw new CliError("validation_error", "--full-history keeps one chat: name it");
95
+ if (withMuted && all !== true)
96
+ throw new CliError("validation_error", "--with-muted is for --all; a chat named is read even when muted");
87
97
  if (all && messenger.history === "store") {
88
98
  throw new CliError("validation_error", `--all walks the messenger's chat list, and ${messenger.name ?? messenger.app.command} pushes its chats ` +
89
99
  `instead — keep \`${lineOf(this, "serve")}\` running${messenger.historyOnDemand ? ", or name one chat" : ""}`);
@@ -137,6 +147,7 @@ export const syncCommand = (messenger) => {
137
147
  pageSize,
138
148
  pause,
139
149
  catchUp: prepare,
150
+ ...(withMuted ? { withMuted } : {}),
140
151
  ...(catchUpChunks === undefined ? {} : { catchUpChunks }),
141
152
  ...(catchUpMessages === undefined ? {} : { catchUpMessages }),
142
153
  ...(catchUpTime === undefined ? {} : { catchUpTime }),
@@ -167,6 +178,7 @@ export const syncCommand = (messenger) => {
167
178
  pageSize,
168
179
  pauseMs,
169
180
  ...(include ? { fullHistory: true } : {}),
181
+ ...(withMuted ? { withMuted } : {}),
170
182
  catchUp: prepare ? preparation : false,
171
183
  ...(sinceMs === undefined ? {} : { sinceMs }),
172
184
  ...(last === undefined ? {} : { last }),
@@ -218,9 +230,8 @@ export const syncCommand = (messenger) => {
218
230
  ],
219
231
  meta: window.meta,
220
232
  }));
221
- const limitedNote = limitedLine(result, lineOf(this, "store status"));
222
- if (limitedNote)
223
- context.renderer.note(limitedNote);
233
+ for (const line of limitedLines(result, lineOf(this, "store status")))
234
+ context.renderer.note(line);
224
235
  if (tasks?.held)
225
236
  context.renderer.note(`the first sync left ${tasks.held} possible task(s) in ${tasks.heldChats ?? 0} chat(s) unopened ` +
226
237
  `(config task_first_pass_per_chat) — ask the owner, then \`${lineOf(this, "tasks scan <chat>")}\``);
@@ -376,7 +387,7 @@ const findJob = (messenger, context, id) => {
376
387
  }
377
388
  return job;
378
389
  };
379
- const fetchArgv = (command, { chat, limit, pageSize, pause, since, last, catchUp, catchUpChunks, catchUpMessages, catchUpTime, }) => {
390
+ const fetchArgv = (command, { chat, limit, pageSize, pause, since, last, catchUp, withMuted, catchUpChunks, catchUpMessages, catchUpTime, }) => {
380
391
  const { timeout } = command.optsWithGlobals();
381
392
  return [
382
393
  "messages",
@@ -391,6 +402,7 @@ const fetchArgv = (command, { chat, limit, pageSize, pause, since, last, catchUp
391
402
  ...(since === undefined ? [] : ["--since-time", since]),
392
403
  ...(last === undefined ? [] : ["--last", String(last)]),
393
404
  ...(catchUp === undefined ? [] : [catchUp ? "--catch-up" : "--no-catch-up"]),
405
+ ...(withMuted ? ["--with-muted"] : []),
394
406
  ...(catchUpChunks === undefined ? [] : ["--catch-up-chunks", String(catchUpChunks)]),
395
407
  ...(catchUpMessages === undefined ? [] : ["--catch-up-messages", String(catchUpMessages)]),
396
408
  ...(catchUpTime === undefined ? [] : ["--catch-up-time", catchUpTime]),