@wirecat/cli-core 0.642.0 → 0.643.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/CHANGELOG.md +188 -0
  2. package/dist/attachments/ocr.js +27 -18
  3. package/dist/attachments/picture-reading.d.ts +51 -0
  4. package/dist/attachments/picture-reading.js +207 -0
  5. package/dist/background/backfill.d.ts +4 -2
  6. package/dist/background/backfill.js +3 -3
  7. package/dist/background/schedules.d.ts +23 -1
  8. package/dist/background/schedules.js +45 -17
  9. package/dist/background/units.d.ts +2 -0
  10. package/dist/background/units.js +8 -9
  11. package/dist/calendar/cli/index.js +10 -2
  12. package/dist/calendar/feeds.js +2 -2
  13. package/dist/calendar/server-search.js +2 -2
  14. package/dist/calendar/source.d.ts +4 -3
  15. package/dist/calendar/sync.js +12 -10
  16. package/dist/calendar/testing/source-contract.js +5 -4
  17. package/dist/calendar/testing/source.js +3 -2
  18. package/dist/cli/complete-command.d.ts +23 -0
  19. package/dist/cli/complete-command.js +80 -0
  20. package/dist/cli/context.js +7 -1
  21. package/dist/cli/effects.d.ts +2 -0
  22. package/dist/cli/effects.js +2 -0
  23. package/dist/cli/envelope.js +6 -1
  24. package/dist/cli/help/first-screen.js +5 -0
  25. package/dist/cli/index.d.ts +4 -2
  26. package/dist/cli/index.js +2 -1
  27. package/dist/cli/list-query.d.ts +3 -1
  28. package/dist/cli/list-query.js +5 -3
  29. package/dist/cli/local-only-command.js +9 -0
  30. package/dist/cli/messenger/backfill-command.js +1 -1
  31. package/dist/cli/messenger/chat-queries.js +2 -1
  32. package/dist/cli/messenger/complete-command.d.ts +4 -7
  33. package/dist/cli/messenger/complete-command.js +31 -98
  34. package/dist/cli/messenger/contacts-command.js +4 -0
  35. package/dist/cli/messenger/guard-commands.js +1 -1
  36. package/dist/cli/messenger/images-command.js +32 -0
  37. package/dist/cli/messenger/list-result-queries.d.ts +1 -0
  38. package/dist/cli/messenger/list-result-queries.js +2 -1
  39. package/dist/cli/messenger/mentions-command.js +3 -3
  40. package/dist/cli/messenger/message-items.js +1 -0
  41. package/dist/cli/messenger/messages-command.js +7 -6
  42. package/dist/cli/messenger/people-queries.d.ts +2 -2
  43. package/dist/cli/messenger/people-queries.js +4 -4
  44. package/dist/cli/messenger/search-answers.js +2 -2
  45. package/dist/cli/messenger/search-command.js +3 -3
  46. package/dist/cli/messenger/searches-command.js +1 -1
  47. package/dist/cli/messenger/store-maintenance-command.js +4 -0
  48. package/dist/cli/messenger/tasks-analysis-command.js +1 -1
  49. package/dist/cli/messenger/tasks-command.js +2 -2
  50. package/dist/cli/model-catalogue-command.js +2 -0
  51. package/dist/cli/picture-reading-command.d.ts +12 -0
  52. package/dist/cli/picture-reading-command.js +82 -0
  53. package/dist/cli/program.d.ts +6 -0
  54. package/dist/cli/program.js +28 -2
  55. package/dist/cli/schedule/agent-start.d.ts +23 -0
  56. package/dist/cli/schedule/agent-start.js +115 -0
  57. package/dist/cli/schedule/harnesses.d.ts +203 -0
  58. package/dist/cli/schedule/harnesses.js +278 -0
  59. package/dist/cli/schedule/schedule-command.d.ts +9 -5
  60. package/dist/cli/schedule/schedule-command.js +89 -79
  61. package/dist/cli/shared-command-exports.d.ts +186 -0
  62. package/dist/cli/shared-command-exports.js +2 -0
  63. package/dist/cli/untrusted-marks.d.ts +25 -0
  64. package/dist/cli/untrusted-marks.js +102 -0
  65. package/dist/crm/cli/index.d.ts +1 -0
  66. package/dist/crm/cli/index.js +6 -5
  67. package/dist/crm/cli/store.d.ts +30 -0
  68. package/dist/crm/cli/store.js +63 -0
  69. package/dist/crm/source.d.ts +6 -4
  70. package/dist/crm/sync.js +10 -6
  71. package/dist/crm/testing/source-contract.js +9 -7
  72. package/dist/crm/testing/source.js +6 -2
  73. package/dist/crm/testing/sync-contract.js +4 -4
  74. package/dist/crm/writes.d.ts +5 -2
  75. package/dist/crm/writes.js +1 -1
  76. package/dist/documents.d.ts +1 -0
  77. package/dist/documents.js +1 -0
  78. package/dist/domain/addresses.d.ts +2 -0
  79. package/dist/domain/addresses.js +7 -0
  80. package/dist/domain/attachments.d.ts +2 -0
  81. package/dist/domain/attachments.js +2 -1
  82. package/dist/domain/models.d.ts +2 -0
  83. package/dist/entities/attachment-results.d.ts +3 -0
  84. package/dist/entities/attachment-results.js +3 -0
  85. package/dist/entities/attachment.d.ts +2 -0
  86. package/dist/entities/attachment.js +8 -1
  87. package/dist/entities/hit.d.ts +1 -0
  88. package/dist/entities/index.d.ts +21 -4
  89. package/dist/entities/index.js +3 -2
  90. package/dist/entities/list-results.d.ts +33 -5
  91. package/dist/entities/list-results.js +33 -5
  92. package/dist/errors/reasons.js +30 -1
  93. package/dist/mail/cli/index.js +7 -6
  94. package/dist/mcp/agent.d.ts +2 -1
  95. package/dist/mcp/agent.js +5 -0
  96. package/dist/mcp/app-server.js +10 -0
  97. package/dist/mcp/surface.d.ts +7 -2
  98. package/dist/mcp/surface.js +49 -10
  99. package/dist/meetings/cli/index.js +6 -1
  100. package/dist/meetings/mcp/index.d.ts +15 -15
  101. package/dist/meetings/mcp/index.js +6 -3
  102. package/dist/meetings/participant-search.d.ts +2 -2
  103. package/dist/meetings/project-discovery.d.ts +1 -1
  104. package/dist/meetings/project-evidence-answer.js +2 -2
  105. package/dist/meetings/reads.d.ts +2 -2
  106. package/dist/meetings/reads.js +6 -6
  107. package/dist/meetings/store.d.ts +2 -1
  108. package/dist/meetings/testing/contract.js +6 -6
  109. package/dist/meetings/testing/memory.js +7 -2
  110. package/dist/models/ai.d.ts +1 -1
  111. package/dist/models/ai.js +3 -1
  112. package/dist/models/anthropic.js +15 -9
  113. package/dist/models/index.js +5 -3
  114. package/dist/models/openai.js +24 -11
  115. package/dist/models/types.d.ts +8 -0
  116. package/dist/models/types.js +11 -1
  117. package/dist/ports/app.d.ts +17 -1
  118. package/dist/ports/app.js +63 -3
  119. package/dist/search/lucene/plain.js +45 -3
  120. package/dist/search/lucene/registry.d.ts +15 -4
  121. package/dist/search/lucene/registry.js +70 -12
  122. package/dist/search/lucene/types.d.ts +2 -0
  123. package/dist/search/lucene/types.js +12 -0
  124. package/dist/sends/upload.d.ts +8 -1
  125. package/dist/sends/upload.js +35 -14
  126. package/dist/services/account-groups.d.ts +11 -0
  127. package/dist/services/account-groups.js +29 -0
  128. package/dist/services/agenda.js +1 -0
  129. package/dist/services/attachments.d.ts +18 -4
  130. package/dist/services/attachments.js +66 -15
  131. package/dist/services/conversations.d.ts +2 -4
  132. package/dist/services/conversations.js +1 -1
  133. package/dist/services/deal-context.js +5 -5
  134. package/dist/services/documents/ingestion.js +3 -3
  135. package/dist/services/documents/knowledge.d.ts +6 -6
  136. package/dist/services/documents/knowledge.js +1 -2
  137. package/dist/services/events-search.d.ts +3 -3
  138. package/dist/services/events-search.js +7 -7
  139. package/dist/services/index.d.ts +1 -1
  140. package/dist/services/index.js +1 -1
  141. package/dist/services/meeting-project-discovery.js +1 -1
  142. package/dist/services/message-resolution.js +10 -3
  143. package/dist/services/messages-search.js +6 -4
  144. package/dist/services/metadata.d.ts +1 -1
  145. package/dist/services/notes-search.d.ts +3 -3
  146. package/dist/services/notes-search.js +3 -3
  147. package/dist/services/organization-context.js +12 -9
  148. package/dist/services/people.d.ts +2 -0
  149. package/dist/services/people.js +4 -2
  150. package/dist/services/pictures.d.ts +9 -0
  151. package/dist/services/pictures.js +34 -28
  152. package/dist/services/project-status/index.js +1 -1
  153. package/dist/services/project-status/signals/payments.js +4 -2
  154. package/dist/services/project-status/signals/promises.js +5 -2
  155. package/dist/services/proposals/kinds/action.js +1 -1
  156. package/dist/services/proposals/kinds/fact.js +1 -1
  157. package/dist/services/proposals/kinds/findings.d.ts +2 -1
  158. package/dist/services/proposals/kinds/findings.js +12 -5
  159. package/dist/services/proposals/kinds/identity-link.js +1 -1
  160. package/dist/services/proposals/kinds/identity-split.js +1 -1
  161. package/dist/services/proposals/kinds/key-document.js +1 -1
  162. package/dist/services/proposals/kinds/mail-findings.d.ts +1 -1
  163. package/dist/services/proposals/kinds/mail-findings.js +11 -5
  164. package/dist/services/proposals/kinds/meeting-findings.js +10 -4
  165. package/dist/services/proposals/kinds/memory.js +1 -1
  166. package/dist/services/proposals/kinds/organization.js +1 -1
  167. package/dist/services/proposals/kinds/relationship-update.js +1 -1
  168. package/dist/services/proposals/kinds/relationship.js +1 -1
  169. package/dist/services/proposals/kinds/shared.d.ts +3 -2
  170. package/dist/services/proposals/kinds/shared.js +4 -4
  171. package/dist/services/proposals/kinds/source-review.js +1 -1
  172. package/dist/services/proposals/kinds/task-close.js +2 -2
  173. package/dist/services/proposals/registry.js +1 -1
  174. package/dist/services/proposals/types.d.ts +2 -1
  175. package/dist/services/search-all-business.js +3 -4
  176. package/dist/services/search-all.js +13 -14
  177. package/dist/services/searches.d.ts +2 -4
  178. package/dist/services/searches.js +1 -4
  179. package/dist/services/stored-project-gathering.js +6 -1
  180. package/dist/services/tags.d.ts +2 -4
  181. package/dist/services/tags.js +1 -1
  182. package/dist/services/tasks.d.ts +1 -1
  183. package/dist/services/tasks.js +4 -3
  184. package/dist/store/account-store.d.ts +2 -1
  185. package/dist/store/account-store.js +3 -1
  186. package/dist/store/accounts.d.ts +2 -0
  187. package/dist/store/accounts.js +8 -0
  188. package/dist/store/chats.d.ts +5 -0
  189. package/dist/store/chats.js +4 -0
  190. package/dist/store/evidence-findings.d.ts +9 -0
  191. package/dist/store/exports.d.ts +1 -1
  192. package/dist/store/exports.js +1 -1
  193. package/dist/store/identity-links.d.ts +3 -1
  194. package/dist/store/mail-findings.d.ts +9 -0
  195. package/dist/store/meeting-findings.d.ts +9 -0
  196. package/dist/store/searches.d.ts +3 -2
  197. package/dist/store/sqlite/accounts.js +37 -0
  198. package/dist/store/sqlite/agent-actions.d.ts +2 -1
  199. package/dist/store/sqlite/agent-actions.js +10 -4
  200. package/dist/store/sqlite/business-contracts.d.ts +3 -1
  201. package/dist/store/sqlite/business-contracts.js +7 -3
  202. package/dist/store/sqlite/business-search.d.ts +2 -1
  203. package/dist/store/sqlite/business-search.js +6 -4
  204. package/dist/store/sqlite/deals.d.ts +6 -4
  205. package/dist/store/sqlite/deals.js +12 -7
  206. package/dist/store/sqlite/evidence-findings.js +78 -9
  207. package/dist/store/sqlite/facts.d.ts +2 -1
  208. package/dist/store/sqlite/facts.js +6 -2
  209. package/dist/store/sqlite/finance.d.ts +4 -2
  210. package/dist/store/sqlite/finance.js +13 -6
  211. package/dist/store/sqlite/findings-core.d.ts +56 -2
  212. package/dist/store/sqlite/findings-core.js +109 -22
  213. package/dist/store/sqlite/identities.d.ts +4 -0
  214. package/dist/store/sqlite/identities.js +12 -3
  215. package/dist/store/sqlite/identity-proposals.js +34 -4
  216. package/dist/store/sqlite/lucene-fields.d.ts +2 -0
  217. package/dist/store/sqlite/lucene-fields.js +28 -2
  218. package/dist/store/sqlite/lucene.js +21 -10
  219. package/dist/store/sqlite/mail-findings.js +60 -22
  220. package/dist/store/sqlite/meeting-findings.js +53 -7
  221. package/dist/store/sqlite/meeting-participant-search.js +4 -5
  222. package/dist/store/sqlite/meetings.js +7 -3
  223. package/dist/store/sqlite/memories.d.ts +4 -2
  224. package/dist/store/sqlite/memories.js +13 -6
  225. package/dist/store/sqlite/money-transactions.d.ts +3 -1
  226. package/dist/store/sqlite/money-transactions.js +7 -3
  227. package/dist/store/sqlite/name-traces.d.ts +3 -3
  228. package/dist/store/sqlite/name-traces.js +29 -2
  229. package/dist/store/sqlite/orders.d.ts +3 -1
  230. package/dist/store/sqlite/orders.js +5 -2
  231. package/dist/store/sqlite/people-list.js +67 -22
  232. package/dist/store/sqlite/person-match-scan.d.ts +3 -1
  233. package/dist/store/sqlite/person-match-scan.js +97 -7
  234. package/dist/store/sqlite/products.d.ts +3 -1
  235. package/dist/store/sqlite/products.js +5 -2
  236. package/dist/store/sqlite/proposed-actions.d.ts +2 -1
  237. package/dist/store/sqlite/proposed-actions.js +7 -3
  238. package/dist/store/sqlite/query-filter.d.ts +4 -0
  239. package/dist/store/sqlite/query-filter.js +14 -0
  240. package/dist/store/sqlite/reads.d.ts +1 -0
  241. package/dist/store/sqlite/reads.js +14 -0
  242. package/dist/store/sqlite/records.d.ts +3 -1
  243. package/dist/store/sqlite/records.js +7 -5
  244. package/dist/store/sqlite/rows-page.d.ts +3 -0
  245. package/dist/store/sqlite/rows-page.js +4 -0
  246. package/dist/store/sqlite/searches.d.ts +2 -1
  247. package/dist/store/sqlite/searches.js +3 -1
  248. package/dist/store/sqlite/subscriptions.d.ts +5 -2
  249. package/dist/store/sqlite/subscriptions.js +13 -6
  250. package/dist/store/sqlite/task-board.js +27 -0
  251. package/dist/store/sqlite/task-find.d.ts +15 -0
  252. package/dist/store/sqlite/task-find.js +1 -0
  253. package/dist/store/sqlite/wallets.d.ts +3 -1
  254. package/dist/store/sqlite/wallets.js +7 -3
  255. package/dist/store/sqlite/work-tasks.d.ts +3 -11
  256. package/dist/store/sqlite/work-tasks.js +8 -4
  257. package/package.json +2 -2
  258. package/parity.json +24 -0
@@ -1,6 +1,7 @@
1
1
  import { CliError } from "@wirecat/cli-base";
2
2
  import { annotate } from "@wirecat/cli-base/commands";
3
3
  import { Command } from "commander";
4
+ import { readPictureReading } from "../attachments/picture-reading.js";
4
5
  import { chosenTextModel } from "../embeddings/models.js";
5
6
  import { aiBaseUrl, aiLeavesComputer, aiSettingPath, readAiSetting } from "../models/ai.js";
6
7
  import { onThisComputer } from "../models/endpoint.js";
@@ -50,6 +51,14 @@ const features = (command, env, on) => {
50
51
  one("voice_messages", "Voice messages", on ? "this-computer" : "elsewhere", null, on
51
52
  ? "the downloaded speech model only"
52
53
  : "the downloaded speech model first, else the messenger's own service; OpenAI only when asked by name"),
54
+ ...(() => {
55
+ const pictures = readPictureReading(env);
56
+ return [
57
+ one("picture_reading", "Picture text read by your coding agent", pictures.mode === "never" ? "off" : "agent", null, pictures.mode === "never"
58
+ ? `never; \`${command} models picture-reading set request\` turns it on`
59
+ : `\`${command} images read\` sends one picture to ${pictures.agent}: local only if that agent runs a local model`),
60
+ ];
61
+ })(),
53
62
  one("digest", "Digest", "agent", null, "runs Claude Code or Codex: local only if that agent runs a local model"),
54
63
  one("agents", "Agents over MCP", "agent", null, "whatever the agent reads goes to the agent's model"),
55
64
  ];
@@ -308,7 +308,7 @@ export const jobsCommand = (messenger) => {
308
308
  const jobs = jobItems(jobsDir(messenger.app, context.env), context.profile, query);
309
309
  const { limit, offset } = pageOf(context.settings);
310
310
  const items = jobs.slice(offset, offset + limit);
311
- renderAnswer(this, context, pagedList("store jobs list", context.settings, { items, has_more: jobs.length > offset + limit }), () => items.map((one) => `${jobLine(one)}\n`).join(""));
311
+ renderAnswer(this, context, pagedList("store jobs list", context.settings, { items, hasMore: jobs.length > offset + limit }), () => items.map((one) => `${jobLine(one)}\n`).join(""));
312
312
  if (jobs.length === 0 && context.format === "pretty")
313
313
  context.renderer.note(`no ${query ? "matching " : ""}background sync jobs for this profile`);
314
314
  });
@@ -9,7 +9,8 @@ const titleWords = (node) => {
9
9
  if (/[*?]/.test(part))
10
10
  queryError("query.unsupported-operator", node.span, "title: matches part of a title: title:book or title:*book*");
11
11
  if (part.length < 3)
12
- throw new CliError("validation_error", `a chat search takes at least 3 characters, got "${part}"`);
12
+ throw new CliError("validation_error", `a chat search takes at least 3 characters, got "${part}" — write more of the title, or leave title: out ` +
13
+ "and read the list newest first", { reason: "query.short-text" });
13
14
  };
14
15
  /**
15
16
  * The store's chat columns. Online the messenger filters nothing, so `chatsService.list` refuses every field
@@ -1,5 +1,5 @@
1
- import { type CompletionSources } from "@wirecat/cli-base/completion";
2
- import { Command } from "commander";
1
+ import type { CompletionSources } from "@wirecat/cli-base/completion";
2
+ import type { Command } from "commander";
3
3
  import type { Configuration } from "../settings.js";
4
4
  import type { Messenger } from "./context.js";
5
5
  export interface CompletionOptions {
@@ -7,10 +7,7 @@ export interface CompletionOptions {
7
7
  sources?: (profile: string, words: string[], env: NodeJS.ProcessEnv) => CompletionSources | undefined;
8
8
  }
9
9
  /**
10
- * `tg complete zsh` prints the script a shell sources; the script then runs `tg complete -- <words>`
11
- * on every Tab, and this answers from the command registry.
12
- *
13
- * ⚠ **A Tab never connects and never creates anything.** Names come from the message store if it
14
- * exists — no store, no names — and nothing goes to stderr: a shell shows whatever it is given.
10
+ * `tg complete zsh`, as `appCompleteCommand` answers it, with the profile's chats and people from the message store
11
+ * if it exists — no store, no names.
15
12
  */
16
13
  export declare const completeCommand: (messenger: Messenger, config: Pick<Configuration, "configuredProfiles">, options?: CompletionOptions) => Command;
@@ -1,83 +1,40 @@
1
1
  import { existsSync } from "node:fs";
2
- import { script } from "@bomb.sh/tab";
3
- import { CliError, singleLine } from "@wirecat/cli-base";
4
- import { annotate, describeOptions, describeProgram } from "@wirecat/cli-base/commands";
5
- import { formatSuggestions, suggest } from "@wirecat/cli-base/completion";
6
- import { Command } from "commander";
7
- import { envName } from "../../ports/app.js";
2
+ import { singleLine } from "@wirecat/cli-base";
8
3
  import { storePath } from "../../store/path.js";
9
4
  import { openStore } from "../../store/store.js";
10
- import { environmentOf, outputFor } from "../context.js";
11
- import { LOCAL_READ } from "../effects.js";
12
- import { commandWords, liftProfile, rootOf, usableProfileName } from "../profile.js";
5
+ import { appCompleteCommand } from "../complete-command.js";
13
6
  import { recalledAccount } from "./accounts.js";
14
- const SHELLS = ["zsh", "bash", "fish", "powershell"];
15
7
  /**
16
- * `tg complete zsh` prints the script a shell sources; the script then runs `tg complete -- <words>`
17
- * on every Tab, and this answers from the command registry.
18
- *
19
- * ⚠ **A Tab never connects and never creates anything.** Names come from the message store if it
20
- * exists — no store, no names — and nothing goes to stderr: a shell shows whatever it is given.
8
+ * `tg complete zsh`, as `appCompleteCommand` answers it, with the profile's chats and people from the message store
9
+ * if it exists — no store, no names.
21
10
  */
22
- export const completeCommand = (messenger, config, options = {}) => annotate(new Command("complete"), {
23
- literal_after_dashes: true,
24
- effects: LOCAL_READ,
25
- mcp: false,
26
- examples: [`${messenger.app.command} complete zsh`],
27
- })
28
- .description(`shell completion: \`${messenger.app.command} complete zsh\` prints the script to source`)
29
- .argument("[words...]", "zsh for the shell script, or command words to complete")
30
- .allowUnknownOption()
31
- .helpOption(false)
32
- .action(async function (words) {
33
- const { app } = messenger;
34
- const root = rootOf(this);
35
- const { streams } = outputFor(this);
36
- const env = environmentOf(this).env ?? process.env;
37
- // Commander drops the `--` from the operands, so only the raw words tell a request from a shell name.
38
- const raw = root.rawArgs;
39
- if (!raw.includes("--")) {
40
- if (words.includes("--help") || words.includes("-h"))
41
- this.help();
42
- const [shell] = words;
43
- if (!shell || !SHELLS.includes(shell)) {
44
- throw new CliError("validation_error", `name a shell: ${app.command} complete ${SHELLS.join(" | ")}`);
11
+ export const completeCommand = (messenger, config, options = {}) => appCompleteCommand(messenger.app, config, {
12
+ sources: async ({ profile, words, env }) => {
13
+ if (!profile)
14
+ return undefined;
15
+ const custom = options.sources?.(profile, words, env);
16
+ if (custom)
17
+ return custom;
18
+ const account = accountOf(messenger, profile, env, options);
19
+ const store = account && existsSync(storePath(env)) ? await openStore({ env }).catch(() => undefined) : undefined;
20
+ if (!store || !account)
21
+ return sourcesFrom([], []);
22
+ try {
23
+ // Read up front: `suggest` asks its sources synchronously, and the store answers asynchronously.
24
+ const chats = (await store.chats.chats(account, { limit: 500 })).items;
25
+ const people = (await store.people.people(account.provider, { account: account.account })).all();
26
+ const known = new Map(people.map((person) => [person.id, { value: person.id, description: singleLine(person.name ?? "") }]));
27
+ for (const chat of chats.filter((chat) => chat.kind === "dialog")) {
28
+ const id = messenger.partnerOf ? messenger.partnerOf(chat) : chat.id;
29
+ if (id !== undefined && !known.has(id))
30
+ known.set(id, { value: id, description: singleLine(chat.title ?? "") });
31
+ }
32
+ return sourcesFrom(chats, [...known.values()]);
45
33
  }
46
- // tab writes the script through console.log; stdout is where a `source <(…)` reads it.
47
- script(shell, app.command, app.command);
48
- return;
49
- }
50
- // The last word is still being typed, so it is never taken for a profile: `mess` is on its way to `messages`.
51
- const { profile, rest } = words.length > 1 ? liftProfile(words, commandWords(root)) : { profile: undefined, rest: words };
52
- const lock = env[envName(app, "PROFILE_LOCK")];
53
- const wanted = profile ?? lock ?? env[envName(app, "PROFILE")];
54
- const custom = wanted && readable(wanted, lock) ? options.sources?.(wanted, rest, env) : undefined;
55
- const account = wanted && !custom && readable(wanted, lock) ? accountOf(messenger, wanted, env, options) : undefined;
56
- const store = account && existsSync(storePath(env)) ? await openStore({ env }).catch(() => undefined) : undefined;
57
- try {
58
- // Read up front: `suggest` asks its sources synchronously, and the store answers asynchronously.
59
- const chats = store && account ? (await store.chats.chats(account, { limit: 500 })).items : [];
60
- const people = store && account ? (await store.people.people(account.provider, { account: account.account })).all() : [];
61
- const known = new Map(people.map((person) => [person.id, { value: person.id, description: singleLine(person.name ?? "") }]));
62
- for (const chat of chats.filter((chat) => chat.kind === "dialog")) {
63
- const id = messenger.partnerOf ? messenger.partnerOf(chat) : chat.id;
64
- if (id !== undefined && !known.has(id))
65
- known.set(id, { value: id, description: singleLine(chat.title ?? "") });
34
+ finally {
35
+ await store.close();
66
36
  }
67
- const suggestions = suggest({
68
- commands: describeProgram(root),
69
- globalOptions: describeOptions(root),
70
- words: rest.length > 0 ? rest : [""],
71
- sources: {
72
- ...sourcesFrom(chats, [...known.values()], profile === undefined, () => profileNames(config, env)),
73
- ...custom,
74
- },
75
- });
76
- streams.data(formatSuggestions(suggestions));
77
- }
78
- finally {
79
- await store?.close();
80
- }
37
+ },
81
38
  });
82
39
  const accountOf = (messenger, profile, env, options) => {
83
40
  if (!options.account)
@@ -85,26 +42,10 @@ const accountOf = (messenger, profile, env, options) => {
85
42
  const id = options.account(profile, env);
86
43
  return id === undefined ? undefined : { provider: messenger.provider, account: id };
87
44
  };
88
- /** A half-typed or odd first word, or another profile than a locked one, gets no names rather than an error. */
89
- const readable = (profile, lock) => {
90
- if (lock && profile !== lock)
91
- return false;
92
- try {
93
- usableProfileName(profile);
94
- return true;
95
- }
96
- catch {
97
- return false;
98
- }
99
- };
100
- const sourcesFrom = (stored, people, atTheStart, profiles) => {
45
+ const sourcesFrom = (stored, people) => {
101
46
  const chats = () => chatSuggestions(stored);
102
47
  const persons = () => people;
103
- return {
104
- arguments: { chat: chats, person: persons },
105
- options: { chat: chats },
106
- ...(atTheStart ? { firstWord: profiles } : {}),
107
- };
48
+ return { arguments: { chat: chats, person: persons }, options: { chat: chats } };
108
49
  };
109
50
  /**
110
51
  * **Ids only, never a title as the word.** bash's `compgen -W` expands `$(…)` in every word it is
@@ -112,11 +53,3 @@ const sourcesFrom = (stored, people, atTheStart, profiles) => {
112
53
  * along as a description, on one line: bash splits the answer on newlines.
113
54
  */
114
55
  const chatSuggestions = (chats) => chats.map((chat) => ({ value: chat.id, description: singleLine(chat.title ?? "") }));
115
- const profileNames = (config, env) => {
116
- try {
117
- return config.configuredProfiles({ env });
118
- }
119
- catch {
120
- return [];
121
- }
122
- };
@@ -54,6 +54,8 @@ export const contactsCommand = (messenger) => {
54
54
  const terms = nativeTerms(listQuery(typedQuery(words), CONTACTS_QUERY, "contacts list"), "contacts list");
55
55
  const name = terms.get("name");
56
56
  const notes = terms.get("notes");
57
+ const email = terms.get("email");
58
+ const phone = terms.get("phone");
57
59
  const context = messengerContext(this, messenger);
58
60
  notesAllowed(context.settings.permissions, notes);
59
61
  const { found, account } = await context.withServices(async (services) => ({
@@ -61,6 +63,8 @@ export const contactsCommand = (messenger) => {
61
63
  order,
62
64
  ...(name ? { name } : {}),
63
65
  ...(notes ? { notes } : {}),
66
+ ...(email ? { email } : {}),
67
+ ...(phone ? { phone } : {}),
64
68
  ...window(context.settings),
65
69
  }),
66
70
  account: await services.chats.account(),
@@ -96,7 +96,7 @@ export const sendsCommand = (messenger) => new Command("sends").description("eve
96
96
  renderAnswer(this, context, pagedList("sends list", settings, {
97
97
  items: shown.map(sendAttemptItem),
98
98
  args: words.length ? { query: typedQuery(words) } : {},
99
- has_more: from + shown.length < entries.length,
99
+ hasMore: from + shown.length < entries.length,
100
100
  }));
101
101
  if (entries.length === 0)
102
102
  renderer.note(filter ? "no send attempts match the query" : `profile ${settings.profile} has not tried to send anything`);
@@ -40,6 +40,38 @@ export const imagesCommand = (messenger) => {
40
40
  else
41
41
  renderAnswer(this, context, itemOf(snakeKeys(done)));
42
42
  });
43
+ annotate(images.command("read"), {
44
+ output: { entity: "attachment_text_change" },
45
+ effects: FETCH,
46
+ offline: false,
47
+ // An agent over MCP reads the saved picture at local_path itself; this would hand it to a second agent.
48
+ mcp: false,
49
+ examples: [
50
+ `${messenger.app.command} images read "msg:..." --attachment 1`,
51
+ `${messenger.app.command} images read "Book club" 101`,
52
+ ],
53
+ })
54
+ .summary("have your coding agent read the text of one picture, and keep it for search")
55
+ .description("give one picture of a message to the coding agent chosen in `models picture-reading` (Claude Code or Codex) " +
56
+ "and keep the text it read, so search finds it; the picture goes to that agent's provider. Refused while " +
57
+ "picture reading is never; the saved copy is used when there is one, else the messenger's download")
58
+ .argument("<chat>", `${messenger.chatArgument}; or a msg: locator, with no message id after it`)
59
+ .argument("[message]", "the message id")
60
+ .option("--attachment <n>", "which file of the message, from 1; needed when it has more than one", positiveCount("--attachment"))
61
+ .action(async function (chat, message) {
62
+ const context = messengerContext(this, messenger);
63
+ refuseLocalWrite(context, messenger.app.command, "attachments.update");
64
+ const { attachment } = this.opts();
65
+ const controller = new AbortController();
66
+ context.track({ close: async () => controller.abort() });
67
+ const done = await context.withServices((services) => services.attachments.readPicture({
68
+ chat,
69
+ ...(message === undefined ? {} : { message }),
70
+ ...(attachment === undefined ? {} : { attachment }),
71
+ signal: controller.signal,
72
+ }));
73
+ renderAnswer(this, context, itemOf(snakeKeys(done)), () => `${done.ref} #${done.attachment} ${done.chars} characters read by ${done.extractor}\n${done.text}\n`);
74
+ });
43
75
  images.addCommand(imageModelsCommand(messenger));
44
76
  return images;
45
77
  };
@@ -7,3 +7,4 @@ export declare const TOPICS_QUERY: QueryRegistry;
7
7
  export declare const topicTitle: (words: QueryWords) => string | undefined;
8
8
  export declare const CALLS_QUERY: QueryRegistry;
9
9
  export declare const STICKERS_QUERY: QueryRegistry;
10
+ export declare const SCHEDULE_HARNESSES_QUERY: QueryRegistry;
@@ -1,5 +1,5 @@
1
1
  import { queryFieldsOf } from "@wirecat/cli-base/query";
2
- import { callRecord, scheduledJob, stickerInventory, topic } from "../../entities/index.js";
2
+ import { callRecord, scheduledJob, scheduleHarness, stickerInventory, topic } from "../../entities/index.js";
3
3
  import { queryTerms, unfilteredQuery } from "../list-query.js";
4
4
  const termsOnly = (registry) => ({
5
5
  ...registry,
@@ -28,3 +28,4 @@ export const TOPICS_QUERY = termsOnly({
28
28
  export const topicTitle = (words) => queryTerms(words, TOPICS_QUERY, "topics list").get("title");
29
29
  export const CALLS_QUERY = unfilteredQuery("call_record", callRecord);
30
30
  export const STICKERS_QUERY = unfilteredQuery("sticker_inventory", stickerInventory);
31
+ export const SCHEDULE_HARNESSES_QUERY = unfilteredQuery("schedule_harness", scheduleHarness);
@@ -46,7 +46,7 @@ export const mentionsCommand = (messenger) => {
46
46
  context.renderer.note(`messages stored before mentions existed are not read yet — \`${tool} mentions rebuild\` reads them`);
47
47
  renderAnswer(this, context, pagedList("mentions list", context.settings, {
48
48
  items: found.items.map(snakeKeys),
49
- has_more: found.hasMore,
49
+ hasMore: found.hasMore,
50
50
  args: { query: query.join(" ") },
51
51
  }), () => found.items.map((item) => `${line(item)}\n`).join(""));
52
52
  // Moved only past a complete answer: rows are in message order, so a cut page could skip one found earlier.
@@ -72,7 +72,7 @@ export const mentionsCommand = (messenger) => {
72
72
  const sites = await context.withServices((services) => services.mentions.domains(query.join(" "), window(context.settings)));
73
73
  renderAnswer(this, context, pagedList("mentions domains", context.settings, {
74
74
  items: sites.items.map(snakeKeys),
75
- has_more: sites.hasMore,
75
+ hasMore: sites.hasMore,
76
76
  args: { query: query.join(" ") },
77
77
  }), () => sites.items
78
78
  .map(({ domain, links, chats, firstAt, lastAt }) => `${domain} ${links} link${links === 1 ? "" : "s"} in ${chats} chat${chats === 1 ? "" : "s"} ` +
@@ -93,7 +93,7 @@ export const mentionsCommand = (messenger) => {
93
93
  const places = await context.withServices((services) => services.mentions.places(window(context.settings)));
94
94
  renderAnswer(this, context, pagedList("mentions places", context.settings, {
95
95
  items: places.items.map(snakeKeys),
96
- has_more: places.hasMore,
96
+ hasMore: places.hasMore,
97
97
  }), () => places.items.map(({ id, address, mentions }) => `${id} ${address} ${mentions} mentioned\n`).join(""));
98
98
  });
99
99
  annotate(mentions.command("show"), {
@@ -12,6 +12,7 @@ const attachmentItem = (attachment) => defined({
12
12
  width: attachment.width,
13
13
  height: attachment.height,
14
14
  duration: attachment.duration,
15
+ local_path: attachment.localPath,
15
16
  contact: attachment.contact &&
16
17
  defined({
17
18
  name: attachment.contact.name,
@@ -14,6 +14,7 @@ import { itemOf, listOf, renderAnswer } from "../envelope.js";
14
14
  import { queryHelp } from "../list-query.js";
15
15
  import { withOptionHints } from "../option-hints.js";
16
16
  import { positiveCount } from "../paging.js";
17
+ import { marksUntrusted } from "../untrusted-marks.js";
17
18
  import { syncCommand } from "./backfill-command.js";
18
19
  import { messengerContext } from "./context.js";
19
20
  import { linksCommand } from "./conversations-command.js";
@@ -44,11 +45,11 @@ export const messagesCommand = (messenger) => {
44
45
  const messages = new Command("messages").description("read and send messages");
45
46
  messages.addCommand(evidenceCommand(messenger));
46
47
  const history = historyQuery(messenger);
47
- const list = annotate(messages.command("list"), {
48
+ const list = marksUntrusted(annotate(messages.command("list"), {
48
49
  examples: [`${messenger.app.command} personal messages list "Book club" --limit 20`],
49
50
  effects: REMOTE_READ,
50
51
  partial: true,
51
- })
52
+ }))
52
53
  .description("a chat's messages, oldest to newest")
53
54
  .addHelpText("after", SAVE_HELP)
54
55
  .addHelpText("after", queryHelp(history))
@@ -130,11 +131,11 @@ export const messagesCommand = (messenger) => {
130
131
  }), view);
131
132
  };
132
133
  messages.addCommand(sendCommand(messenger));
133
- annotate(messages.command("show"), {
134
+ marksUntrusted(annotate(messages.command("show"), {
134
135
  output: { entity: "message" },
135
136
  examples: [`${messenger.app.command} personal messages show "Book club" 101`],
136
137
  effects: REMOTE_READ,
137
- })
138
+ }))
138
139
  .description("one message, by its chat and id or by its msg: locator")
139
140
  .argument("<chat>", `${messenger.chatArgument}; or a msg: locator, with no message id after it`)
140
141
  .argument("[message]", "the message id")
@@ -143,11 +144,11 @@ export const messagesCommand = (messenger) => {
143
144
  return await readMailWindow(this, chat, { before: 0, after: 0 });
144
145
  await readWindow(this, chat, message, { before: 0, after: 0 });
145
146
  });
146
- threadOptions(annotate(messages.command("context"), {
147
+ threadOptions(marksUntrusted(annotate(messages.command("context"), {
147
148
  output: { entity: "message_context" },
148
149
  examples: [`${messenger.app.command} personal messages context "Book club" 101 --before-n 3 --after-n 3`],
149
150
  effects: REMOTE_READ,
150
- }))
151
+ })))
151
152
  .description("a message and what came either side of it, oldest first")
152
153
  .addHelpText("after", SAVE_HELP)
153
154
  .argument("<chat>", `${messenger.chatArgument}; or a msg: locator, with no message id after it`)
@@ -1,8 +1,8 @@
1
1
  import { type Predicate, type QueryRegistry } from "@wirecat/cli-base/query";
2
2
  import { levelFor } from "../../sends/permissions.js";
3
3
  /**
4
- * The store matches `name:` against the name, the local alias and the @username at once, and `notes:` against
5
- * the owner's private notes about them; nothing else is filtered.
4
+ * The store matches `name:` against the name, the local alias and the @username at once, `notes:` against
5
+ * the owner's private notes about them, `email:` and `phone:` against a part of the address or the number.
6
6
  */
7
7
  export declare const CONTACTS_QUERY: QueryRegistry;
8
8
  /** Reading notes by their text is reading them: `contacts.notes.list` gates `notes:` as it gates `--with-notes`. */
@@ -7,19 +7,19 @@ const notesText = (node) => {
7
7
  queryError("query.unsupported-operator", node.span, 'notes: matches text in a note: notes:valencia or notes:"met in"');
8
8
  };
9
9
  /**
10
- * The store matches `name:` against the name, the local alias and the @username at once, and `notes:` against
11
- * the owner's private notes about them; nothing else is filtered.
10
+ * The store matches `name:` against the name, the local alias and the @username at once, `notes:` against
11
+ * the owner's private notes about them, `email:` and `phone:` against a part of the address or the number.
12
12
  */
13
13
  export const CONTACTS_QUERY = {
14
14
  entity: "contact",
15
15
  backend: "native",
16
16
  fields: queryFieldsOf(contact, {
17
- native: ["name", "notes"],
17
+ native: ["name", "notes", "email", "phone"],
18
18
  text: ["name"],
19
19
  relations: {
20
20
  notes: { type: "txt", example: "notes:valencia", relation: "text in one of your private notes about them" },
21
21
  },
22
- examples: { name: "name:ana*" },
22
+ examples: { name: "name:ana*", email: "email:example.com", phone: "phone:600" },
23
23
  validate: { notes: notesText },
24
24
  }),
25
25
  };
@@ -354,9 +354,9 @@ const meaningGap = (skipped, exact) => skipped === undefined || exact
354
354
  };
355
355
  /** `search notes`, CLI and MCP alike. */
356
356
  export const notesAnswer = (command, found, { limit, page, again }, exact = false) => listOf(command, {
357
- items: found.hits.map(noteHitItem),
357
+ items: found.items.map(noteHitItem),
358
358
  limit,
359
- has_more: found.has_more && found.next_offset !== undefined,
359
+ has_more: found.hasMore && found.nextOffset !== undefined,
360
360
  page: page ?? 1,
361
361
  total: found.total,
362
362
  ...(again ? { args: again } : {}),
@@ -149,12 +149,12 @@ const notesCommand = (messenger) => annotate(new Command("notes"), { effects: LO
149
149
  ...(options.timezone === undefined ? {} : { timezone: options.timezone }),
150
150
  };
151
151
  renderAnswer(this, context, notesAnswer("search notes", found, { limit, page: options.page ?? 1, again }), () => {
152
- if (found.hits.length === 0)
152
+ if (found.items.length === 0)
153
153
  context.renderer.note("no note matches");
154
- const shown = shownOf(found.hits.length, ((options.page ?? 1) - 1) * limit, found.total);
154
+ const shown = shownOf(found.items.length, ((options.page ?? 1) - 1) * limit, found.total);
155
155
  if (shown)
156
156
  context.renderer.note(shown);
157
- return found.hits
157
+ return found.items
158
158
  .map((hit) => `${singleLine(hit.title ?? hit.path ?? hit.ref)} ${hit.ref} (${hit.found_by.join(", ")})${hit.url ? `\n ${singleLine(hit.url)}` : ""}\n ${singleLine(hit.excerpt)}\n`)
159
159
  .join("");
160
160
  });
@@ -106,7 +106,7 @@ export const searchesCommand = (messenger) => {
106
106
  const found = await context.withServices((services) => services.searches.history(limit, offset));
107
107
  renderAnswer(this, context, pagedList("searches history", context.settings, {
108
108
  items: found.items.map(savedSearchItem),
109
- has_more: found.has_more,
109
+ hasMore: found.hasMore,
110
110
  }), () => found.items.map((one) => `${line(one)}\n`).join(""));
111
111
  if (found.items.length === 0 && context.format === "pretty")
112
112
  context.renderer.note("no searches ran yet");
@@ -7,6 +7,7 @@ import { holdersOf } from "../../background/processes.js";
7
7
  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
+ import { refuseLockedOutput } from "../../sends/upload.js";
10
11
  import { fileSchemaOf, SPEAKS, writableBy } from "../../store/compatibility.js";
11
12
  import { storeDamageReport } from "../../store/damage.js";
12
13
  import { QUICK_HEALTH_CHECKS, storeHealth } from "../../store/health.js";
@@ -533,6 +534,9 @@ const backupCommand = () => destroysNothing(annotate(new Command("backup"), { ou
533
534
  const { encrypt } = this.opts();
534
535
  const path = storePath(environmentOf(this).env ?? process.env);
535
536
  const target = resolve(file);
537
+ const { app, env } = environmentOf(this);
538
+ if (app)
539
+ refuseLockedOutput(target, app, env ?? process.env, "<file>");
536
540
  if (!existsSync(path))
537
541
  throw new CliError("not_found", `no store at ${path} to back up`);
538
542
  if (existsSync(target))
@@ -60,7 +60,7 @@ export const analysisCommands = (tasks, messenger) => {
60
60
  const shown = chats.slice(offset, offset + limit);
61
61
  renderAnswer(this, context, pagedList("tasks status", context.settings, {
62
62
  items: shown.map(analysisItem),
63
- has_more: chats.length > offset + limit,
63
+ hasMore: chats.length > offset + limit,
64
64
  }), () => shown.length === 0
65
65
  ? ""
66
66
  : `${shown
@@ -158,7 +158,7 @@ export const tasksCommand = (messenger) => {
158
158
  .option("--limit <n>", "how many", positiveCount("--limit"))
159
159
  .action(async function (words) {
160
160
  const context = messengerContext(this, messenger);
161
- const query = listQuery(typedQuery(words), TASK_QUERY, "tasks list");
161
+ const query = listQuery(typedQuery(words), TASK_QUERY, "tasks list", { defaultField: "title" });
162
162
  const { limit, offset } = pageOf(context.settings);
163
163
  const found = await context.withServices((services) => services.tasks.list({
164
164
  ...(query ? { query } : {}),
@@ -310,7 +310,7 @@ export const tasksCommand = (messenger) => {
310
310
  const shown = rows.slice(0, limit);
311
311
  renderAnswer(this, context, pagedList("tasks duplicates list", context.settings, {
312
312
  items: shown.map(snakeKeys),
313
- has_more: rows.length > limit,
313
+ hasMore: rows.length > limit,
314
314
  }), () => (shown.length === 0 ? "" : `${shown.map(pairLine).join("\n")}\n`));
315
315
  if (shown.length === 0 && context.format === "pretty")
316
316
  context.renderer.note(decision === "unsure" ? "no pair waits for the owner" : "no pair waits for review");
@@ -18,6 +18,7 @@ import { enrichmentConsentsCommand } from "./enrichment-consents-command.js";
18
18
  import { itemOf, listOf } from "./envelope.js";
19
19
  import { listQuery, nativeTerms, termField, typedQuery, withQuery } from "./list-query.js";
20
20
  import { localOnlyCommand } from "./local-only-command.js";
21
+ import { pictureReadingCommand } from "./picture-reading-command.js";
21
22
  import { harderConsentsCommand } from "./search-harder-consents-command.js";
22
23
  export const MODEL_CATALOGUE_QUERY = defineQuery({
23
24
  entity: "model",
@@ -149,6 +150,7 @@ export const modelCatalogueCommand = (app, options) => {
149
150
  models.addCommand(providerKeysCommand(app, options));
150
151
  models.addCommand(aiModelCommand(app, options));
151
152
  models.addCommand(localOnlyCommand(app, options));
153
+ models.addCommand(pictureReadingCommand(app, options));
152
154
  }
153
155
  if (options.jsonOption)
154
156
  for (const command of models.commands.flatMap((one) => (one.commands.length ? one.commands : [one])))
@@ -0,0 +1,12 @@
1
+ import { Command } from "commander";
2
+ import { type PictureAgent } from "../attachments/picture-reading.js";
3
+ import type { AppIdentity } from "../ports/app.js";
4
+ import { type Body } from "./envelope.js";
5
+ export interface PictureReadingCommandOptions {
6
+ env: () => NodeJS.ProcessEnv;
7
+ output: (answer: Body, command: Command) => void;
8
+ diagnostic: (line: string) => void;
9
+ }
10
+ export declare const pictureReadingWarning: (agent: PictureAgent) => string;
11
+ /** `models picture-reading`: whether the owner's coding agent may read a picture's text, and which agent. */
12
+ export declare const pictureReadingCommand: (app: AppIdentity, options: PictureReadingCommandOptions) => Command;