@wirecat/cli-core 0.707.0 → 0.709.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 (39) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/dist/cli/list-query.d.ts +5 -0
  3. package/dist/cli/list-query.js +9 -0
  4. package/dist/cli/messenger/conversation-answers.d.ts +4 -0
  5. package/dist/cli/messenger/message-answers.d.ts +4 -0
  6. package/dist/cli/messenger/message-writes.d.ts +8 -0
  7. package/dist/crm/cli/changes.d.ts +2 -0
  8. package/dist/crm/cli/changes.js +4 -2
  9. package/dist/crm/cli/index.d.ts +2 -0
  10. package/dist/crm/cli/index.js +17 -13
  11. package/dist/crm/cli/records.d.ts +2 -0
  12. package/dist/crm/cli/records.js +25 -8
  13. package/dist/crm/cli/search-all.d.ts +3 -1
  14. package/dist/crm/cli/search-all.js +5 -4
  15. package/dist/entities/contact-context.d.ts +8 -0
  16. package/dist/entities/conversation-results.d.ts +8 -0
  17. package/dist/entities/evidence.d.ts +32 -0
  18. package/dist/entities/index.d.ts +73 -88
  19. package/dist/entities/index.js +1 -0
  20. package/dist/entities/listener.d.ts +16 -0
  21. package/dist/entities/message-change.d.ts +4 -0
  22. package/dist/entities/message-context.d.ts +12 -0
  23. package/dist/entities/message-write.d.ts +16 -0
  24. package/dist/entities/message.d.ts +5 -0
  25. package/dist/entities/message.js +2 -0
  26. package/dist/entities/store-records.d.ts +4 -0
  27. package/dist/errors/reasons.js +2 -0
  28. package/dist/mail/cli/inbox.d.ts +15 -0
  29. package/dist/mail/cli/inbox.js +208 -0
  30. package/dist/mail/cli/index.d.ts +1 -0
  31. package/dist/mail/cli/index.js +1 -0
  32. package/dist/mail/cli/review.js +12 -8
  33. package/dist/mail/inbox.d.ts +108 -0
  34. package/dist/mail/inbox.js +215 -0
  35. package/dist/mail/index.d.ts +1 -0
  36. package/dist/mail/index.js +1 -0
  37. package/dist/ports/wirecat-tools.js +7 -0
  38. package/package.json +1 -1
  39. package/parity.json +23 -0
package/CHANGELOG.md CHANGED
@@ -5,6 +5,45 @@ Notable changes to `@wirecat/cli-core` (`@wirecat/cli-messaging` up to 0.261.0,
5
5
  minor version may break callers, and says how under "Changed — may break callers". `pnpm docs:check` checks the
6
6
  shape of this file.
7
7
 
8
+ ## 0.709.0 — 19.11.2026
9
+
10
+ ### Added
11
+
12
+ - **`mailInboxCommand`: a mail CLI's `inbox` sorts new mail with the shared AI model.** The threads that changed since
13
+ its last run go to the model chosen with `models ai` (Anthropic, OpenAI or a local Ollama), with no agent. It puts
14
+ each one under needs an answer, to read or can wait, with a one-line reason, then lists every sorted thread, those
15
+ that need an answer first. It sends each thread's subject, senders and its 3 newest emails without quoted mail or
16
+ the signature, at most 1500 characters each. Mail sent to many is not sent. `--max-messages` (40 by default) and
17
+ `--max-tokens` (60000) limit a run, and the threads left wait for the next. A model outside this computer follows
18
+ local only and `models chats`: under ask it needs `--yes`. An agent is refused (`mail.inbox-agent`), and
19
+ `--offline` lists without calling the model. A thread the owner answered leaves the list on the next run. The
20
+ verdicts are kept in the store, so a schedule can run it.
21
+ - **Mail `review` shows how `inbox` sorted each thread**, as `email.inbox` (`bucket` and `reason`, the reason marked
22
+ untrusted).
23
+ - **wordpress joins `WIRECAT_TOOLS`.** WordPress (`wordpress`, `@wirecat/wordpress-cli`) is on npm since 0.1.0, so
24
+ every CLI's first screen ("Works with") and first-run list of other WireCat tools now name it, and an upload refuses
25
+ a file from its folders (`wordpress-cli`, `WCWP_`) as it does for the other tools.
26
+
27
+ ### Fixed
28
+
29
+ - **`parity.json` has rows for `messages scheduled cancel`, `edit` and `send`** (max and tg; WhatsApp has no scheduled
30
+ messages). 0.706.0 added the commands without rows, so the parity manifest check failed for max-cli and tg-cli,
31
+ hidden only because both were listed as known broken.
32
+
33
+ ## 0.708.0 — 19.11.2026
34
+
35
+ ### Fixed
36
+
37
+ - **The shared CRM help fits every CRM.** The `create` and `update` examples set a field by its label
38
+ (`--field Source=web`), not by Bitrix24's own `UF_CRM_SOURCE`. A CRM mounted with `leads: false`, such as amoCRM, no
39
+ longer mentions leads in the descriptions of `sync`, `store status`, `store apply`, `changes`, `fields list` and
40
+ `search all`, nor shows `kind:lead` in its examples.
41
+ - A CRM CLI whose live `people list` and `organizations list` are the service's own search (a source from a manifest)
42
+ passes `liveQuery: "words"` to `addCrmCommands`: the lists then take words, and their help no longer promises
43
+ field terms and a Fields table the search cannot take.
44
+ - `people show` and `organizations show` read a word as a name when the CRM refuses it as an id with a validation
45
+ error. Attio answered HTTP 400 to `people show "Anna Example"`, and the command failed.
46
+
8
47
  ## 0.707.0 — 19.11.2026
9
48
 
10
49
  ### Added
@@ -11,6 +11,11 @@ export declare const QUERY_ARGUMENT = "field:value terms that narrow the list \u
11
11
  * `commands --json`. The registry is checked here, so a field whose example does not run fails at startup.
12
12
  */
13
13
  export declare const withQuery: (command: Command, registry: QueryRegistry) => Command;
14
+ /**
15
+ * A list the service's own search narrows by words only: no Fields section in its help. The argument keeps the name
16
+ * `query`, so its MCP tool takes the same input as a list that takes field terms.
17
+ */
18
+ export declare const withWords: (command: Command, registry: QueryRegistry, words: string) => Command;
14
19
  /**
15
20
  * A list its source answers whole and cannot narrow: the entity's fields are named, none is filterable, so any
16
21
  * term is `query.unsupported-field` rather than a filter applied to what came back.
@@ -19,6 +19,15 @@ export const withQuery = (command, registry) => {
19
19
  command.addHelpText("after", `\n${fieldsHelp({ ...query, fields: shown }, LIST_QUERY_GUIDE)}`);
20
20
  return command;
21
21
  };
22
+ /**
23
+ * A list the service's own search narrows by words only: no Fields section in its help. The argument keeps the name
24
+ * `query`, so its MCP tool takes the same input as a list that takes field terms.
25
+ */
26
+ export const withWords = (command, registry, words) => {
27
+ annotate(command, { query: defineQuery(registry), output: { entity: registry.entity } });
28
+ queryWordsAfterOptions(command).argument("[query...]", words);
29
+ return command;
30
+ };
22
31
  /**
23
32
  * A list its source answers whole and cannot narrow: the entity's fields are named, none is filterable, so any
24
33
  * term is `query.unsupported-field` rather than a filter applied to what came back.
@@ -254,6 +254,10 @@ export declare const conversationShown: (account: AccountKey, { summary, message
254
254
  fingerprint?: string | undefined;
255
255
  new_sender?: boolean | undefined;
256
256
  sender_identities?: number | undefined;
257
+ inbox?: {
258
+ bucket: "answer" | "later" | "read";
259
+ reason: string;
260
+ } | undefined;
257
261
  } | undefined;
258
262
  provider_metadata?: {
259
263
  [x: string]: unknown;
@@ -231,6 +231,10 @@ export declare const threadAnswer: ({ items, ...thread }: ThreadContext, reader:
231
231
  fingerprint?: string | undefined;
232
232
  new_sender?: boolean | undefined;
233
233
  sender_identities?: number | undefined;
234
+ inbox?: {
235
+ bucket: "answer" | "later" | "read";
236
+ reason: string;
237
+ } | undefined;
234
238
  } | undefined;
235
239
  provider_metadata?: {
236
240
  [x: string]: unknown;
@@ -235,6 +235,10 @@ export declare const writtenAnswer: ({ operationId, sendId, message, messages, s
235
235
  fingerprint?: string | undefined;
236
236
  new_sender?: boolean | undefined;
237
237
  sender_identities?: number | undefined;
238
+ inbox?: {
239
+ bucket: "answer" | "later" | "read";
240
+ reason: string;
241
+ } | undefined;
238
242
  } | undefined;
239
243
  provider_metadata?: {
240
244
  [x: string]: unknown;
@@ -460,6 +464,10 @@ export declare const writtenAnswer: ({ operationId, sendId, message, messages, s
460
464
  fingerprint?: string | undefined;
461
465
  new_sender?: boolean | undefined;
462
466
  sender_identities?: number | undefined;
467
+ inbox?: {
468
+ bucket: "answer" | "later" | "read";
469
+ reason: string;
470
+ } | undefined;
463
471
  } | undefined;
464
472
  provider_metadata?: {
465
473
  [x: string]: unknown;
@@ -18,6 +18,8 @@ export interface CrmChangeCommandOptions {
18
18
  pathOf: (command: Command) => string[];
19
19
  /** Also mount `activities list`, for a CLI that copies the CRM's activities. */
20
20
  activities?: boolean;
21
+ /** The CRM has leads; true when absent. */
22
+ leads?: boolean;
21
23
  }
22
24
  /** `changes list`: what happened in the copy in a window, newest first; `--format report` is the morning digest. */
23
25
  export declare const addCrmChangeCommands: (program: Command, options: CrmChangeCommandOptions) => void;
@@ -124,11 +124,13 @@ const digestState = (schedule) => `crm:digest:${schedule}`;
124
124
  /** `changes list`: what happened in the copy in a window, newest first; `--format report` is the morning digest. */
125
125
  export const addCrmChangeCommands = (program, options) => {
126
126
  const { within, example, now, ownerOf, pathOf } = options;
127
+ const deals = options.leads === false ? "deals" : "deals and leads";
127
128
  if (options.activities)
128
129
  addCrmActivityCommands(program, { within, example, now, ownerOf, pathOf });
129
- const group = annotate(program.command("changes"), { effects: NO_EFFECTS }).description("what changed in the CRM's deals, leads, activities and contacts, as the syncs copied it");
130
+ const group = annotate(program.command("changes"), { effects: NO_EFFECTS }).description(`what changed in the CRM's ${options.leads === false ? "deals" : "deals, leads"}, activities and contacts, ` +
131
+ "as the syncs copied it");
130
132
  example(withQuery(answerEntity(annotate(group.command("list"), { effects: LOCAL_READ }), "crm_change", crmChange)
131
- .description("deals and leads made, moved, won, lost and given another owner, activities added and done, and contacts " +
133
+ .description(`${deals} made, moved, won, lost and given another owner, activities added and done, and contacts ` +
132
134
  "added, newest first; the last day unless at: says otherwise")
133
135
  .option("--limit <n>", `changes per page, 1–${MOST}`, integer(MOST), 50)
134
136
  .option("--cursor <cursor>", "the next page, as the last answer's page.next gave it")
@@ -54,6 +54,8 @@ export interface CrmCommandOptions {
54
54
  * `source.list`/`get`, `user` mounts `users` list/show over `source.users`. None when absent.
55
55
  */
56
56
  live?: readonly CrmLiveRecord[];
57
+ /** `words` for a source whose live lists are the service's own search: their help takes words, not field terms. */
58
+ liveQuery?: "fields" | "words";
57
59
  activities?: boolean;
58
60
  files?: boolean;
59
61
  now?: () => number;
@@ -57,7 +57,7 @@ export const LEADS_QUERY = { entity: "lead", backend: "native", fields: DEAL_FIE
57
57
  export const PIPELINES_QUERY = {
58
58
  entity: "pipeline",
59
59
  backend: "native",
60
- fields: [termField("kind", "enum", "kind:lead", { values: DEAL_KINDS })],
60
+ fields: [termField("kind", "enum", "kind:deal", { values: DEAL_KINDS })],
61
61
  };
62
62
  export const STAGES_QUERY = {
63
63
  entity: "stage",
@@ -211,14 +211,16 @@ const addCrmCommandsDefinition = (program, options) => {
211
211
  renderAnswer(command, outputFor(command), body, view);
212
212
  });
213
213
  const example = (command, ...lines) => annotate(command, { examples: lines.map((line) => `${options.app.command} work ${line}`) });
214
+ const hasLeads = options.leads !== false;
215
+ const dealsAndLeads = hasLeads ? "deals and leads" : "deals";
214
216
  example(answerEntity(annotate(program.command("sync"), { effects: FETCH, offline: false, cooperative: true, partial: true }), "crm_sync", crmSync)
215
- .description("bring the CRM's copy in the local store up to date: pipelines, companies, contacts, deals and leads that " +
217
+ .description(`bring the CRM's copy in the local store up to date: pipelines, companies, contacts, ${dealsAndLeads} that ` +
216
218
  "changed since the last sync, or everything with --rescan; a run stops before its deadline or " +
217
219
  "--max-pages and the next one goes on from there")
218
220
  // WireCat Desktop takes a summary of 300 characters at most; the settings' part is help only.
219
- .addHelpText("after", "\nWith the activities setting on, it also copies the activities and tasks on the deals and leads it keeps. " +
220
- "Then each deal or lead that moved into a stage the stage-tasks setting names opens a local task, once " +
221
- "per move."), "sync", "sync --rescan", "sync --max-pages 20")
221
+ .addHelpText("after", `\nWith the activities setting on, it also copies the activities and tasks on the ${dealsAndLeads} it keeps. ` +
222
+ `Then each ${hasLeads ? "deal or lead" : "deal"} that moved into a stage the stage-tasks setting names ` +
223
+ "opens a local task, once per move."), "sync", "sync --rescan", "sync --max-pages 20")
222
224
  .option("--rescan", "list everything again, every id too, dropping a round in progress")
223
225
  .option("--max-pages <pages>", "at most this many requests to the CRM in this run", integer(100_000))
224
226
  .action(async (opts, command) => {
@@ -291,7 +293,7 @@ const addCrmCommandsDefinition = (program, options) => {
291
293
  await within(command, async (run) => {
292
294
  const status = await crmStatus(run.store, run.account, { profile: run.profile, now: now() });
293
295
  if (await viewerOf(run))
294
- outputFor(command).renderer.note("stored counts the whole copy, more than the deals and leads you may read");
296
+ outputFor(command).renderer.note(`stored counts the whole copy, more than the ${dealsAndLeads} you may read`);
295
297
  return listOf(pathOf(command).join(" "), {
296
298
  items: status.items,
297
299
  limit: status.limit,
@@ -300,7 +302,8 @@ const addCrmCommandsDefinition = (program, options) => {
300
302
  });
301
303
  });
302
304
  });
303
- example(answerEntity(annotate(store.command("apply"), { effects: LOCAL_WRITE }), "crm_contacts_removed", crmContactsApplied).description("apply scope mine to the contacts already stored: remove those no deal or lead of the chosen users and no " +
305
+ example(answerEntity(annotate(store.command("apply"), { effects: LOCAL_WRITE }), "crm_contacts_removed", crmContactsApplied).description(`apply scope mine to the contacts already stored: remove those no ${hasLeads ? "deal or lead" : "deal"} ` +
306
+ "of the chosen users and no " +
304
307
  "kept company names, and the people they leave empty; counts only unless --yes, under scope all too. A " +
305
308
  "sync that narrows the scope, or sync --rescan under mine, does this itself"), "store apply", "store apply --yes")
306
309
  .option("--yes", "remove the contacts it counts; otherwise only count them")
@@ -499,7 +502,7 @@ const addCrmCommandsDefinition = (program, options) => {
499
502
  const run = (command, work) => within(command, (opened) => work(contextOf(opened, command)));
500
503
  const create = write("create", "create", `make a ${kind} in the CRM, then store the CRM's copy of it`);
501
504
  if (create)
502
- example(fields(create), `${plural} create --title "Example kitchen" --amount 15000 --currency EUR`, `${plural} create --title "Example office" --pipeline Sales --stage "Quote sent" --field UF_CRM_SOURCE=web`).action(async (opts, command) => {
505
+ example(fields(create), `${plural} create --title "Example kitchen" --amount 15000 --currency EUR`, `${plural} create --title "Example office" --pipeline Sales --stage "Quote sent" --field Source=web`).action(async (opts, command) => {
503
506
  await run(command, async (context) => {
504
507
  const done = await createCrmItem(context, kind, inputOf(opts), idOf(opts));
505
508
  return answered(done.operationId, done.item);
@@ -507,7 +510,7 @@ const addCrmCommandsDefinition = (program, options) => {
507
510
  });
508
511
  const update = write("update", "update", `change a ${kind} in the CRM; what is left out keeps its value; the CRM's copy is stored again`);
509
512
  if (update)
510
- example(fields(reference(update)), `${plural} update ${kind}:12 --amount 18000`, `${plural} update ${kind}:12 --field UF_CRM_SOURCE=`).action(async (ref, opts, command) => {
513
+ example(fields(reference(update)), `${plural} update ${kind}:12 --amount 18000`, `${plural} update ${kind}:12 --field Source=`).action(async (ref, opts, command) => {
511
514
  await run(command, async (context) => {
512
515
  const done = await updateCrmItem(context, kind, ref, inputOf(opts), idOf(opts));
513
516
  return answered(done.operationId, done.item);
@@ -555,7 +558,7 @@ const addCrmCommandsDefinition = (program, options) => {
555
558
  if (options.leads !== false)
556
559
  items("lead");
557
560
  const pipelines = annotate(program.command("pipelines"), { effects: NO_EFFECTS }).description("the CRM's pipelines and their stages, as last synced");
558
- example(withQuery(annotate(pipelines.command("list"), { effects: LOCAL_READ, output: { entity: "pipeline" } }).description("pipelines copied from the CRM, with their stages in order and how many are open in each"), PIPELINES_QUERY), "pipelines list --json", "pipelines list kind:lead").action(async (words, _opts, command) => {
561
+ example(withQuery(annotate(pipelines.command("list"), { effects: LOCAL_READ, output: { entity: "pipeline" } }).description("pipelines copied from the CRM, with their stages in order and how many are open in each"), PIPELINES_QUERY), "pipelines list --json", ...(hasLeads ? ["pipelines list kind:lead"] : [])).action(async (words, _opts, command) => {
559
562
  const terms = queryTerms(words, PIPELINES_QUERY, "pipelines list");
560
563
  await within(command, async (run) => {
561
564
  const found = await run.store.deals.pipelines({
@@ -594,7 +597,7 @@ const addCrmCommandsDefinition = (program, options) => {
594
597
  }, (body) => pipelineView(body, outputFor(command).color));
595
598
  });
596
599
  const stages = annotate(program.command("stages"), { effects: NO_EFFECTS }).description("the stages of the CRM's pipelines, as last synced");
597
- example(withQuery(annotate(stages.command("list"), { effects: LOCAL_READ, output: { entity: "stage" } }).description("every stage of the CRM's pipelines in order, with its outcome and how many are open in it"), STAGES_QUERY), "stages list --json", "stages list kind:lead").action(async (words, _opts, command) => {
600
+ example(withQuery(annotate(stages.command("list"), { effects: LOCAL_READ, output: { entity: "stage" } }).description("every stage of the CRM's pipelines in order, with its outcome and how many are open in it"), STAGES_QUERY), "stages list --json", ...(hasLeads ? ["stages list kind:lead"] : [])).action(async (words, _opts, command) => {
598
601
  const terms = queryTerms(words, STAGES_QUERY, "stages list");
599
602
  await within(command, async (run) => {
600
603
  const kind = terms.has("kind") ? terms.get("kind") : undefined;
@@ -639,6 +642,7 @@ const addCrmCommandsDefinition = (program, options) => {
639
642
  open: options.open,
640
643
  app: options.app,
641
644
  live: options.live ?? [],
645
+ ...(options.liveQuery ? { liveQuery: options.liveQuery } : {}),
642
646
  ...(writes ? { writes } : {}),
643
647
  now,
644
648
  });
@@ -646,7 +650,7 @@ const addCrmCommandsDefinition = (program, options) => {
646
650
  if (options.files)
647
651
  addCrmFileCommands(program, { ...options, within, example, now });
648
652
  const fieldKinds = Object.keys(FIELD_KINDS).filter((word) => word !== "leads" || options.leads !== false);
649
- const fields = annotate(program.command("fields"), { effects: NO_EFFECTS }).description("the CRM's own fields on deals, leads, people and organizations, as last synced");
653
+ const fields = annotate(program.command("fields"), { effects: NO_EFFECTS }).description(`the CRM's own fields on ${hasLeads ? "deals, leads" : "deals"}, people and organizations, as last synced`);
650
654
  example(withQuery(answerEntity(annotate(fields.command("list"), { effects: LOCAL_READ }), "crm_field", crmField)
651
655
  .description("the CRM's custom fields of one kind, in its order, with a list field's options")
652
656
  .argument("<kind>", fieldKinds.join(", "))
@@ -676,7 +680,7 @@ const addCrmCommandsDefinition = (program, options) => {
676
680
  });
677
681
  const search = program.commands.find((one) => one.name() === "search") ??
678
682
  annotate(program.command("search"), { effects: NO_EFFECTS }).description("search what the local store holds");
679
- addCrmSearchAll(search, { within, app: options.app, example, viewerOf });
683
+ addCrmSearchAll(search, { within, app: options.app, example, viewerOf, leads: hasLeads });
680
684
  };
681
685
  // honoursDryRun: a host program other than `run` would otherwise let a write through under --dry-run.
682
686
  export const addCrmCommands = honoursDryRun(sharedCommand(addCrmCommandsDefinition));
@@ -87,6 +87,8 @@ export interface CrmRecordCommandOptions {
87
87
  }) => Promise<CrmRun>;
88
88
  app: AppIdentity;
89
89
  live: readonly CrmLiveRecord[];
90
+ /** `words`: the live lists are the service's own search (a source from a manifest), which takes no field terms. */
91
+ liveQuery?: "fields" | "words";
90
92
  writes?: CrmWriteCapabilities;
91
93
  now: () => number;
92
94
  }
@@ -1,4 +1,4 @@
1
- import { CliError } from "@wirecat/cli-base";
1
+ import { CliError, isCliError } from "@wirecat/cli-base";
2
2
  import { annotate } from "@wirecat/cli-base/commands";
3
3
  import { defineQuery, queryFieldsOf } from "@wirecat/cli-base/query";
4
4
  import { isoTime } from "@wirecat/cli-base/standards";
@@ -7,7 +7,7 @@ import * as v from "valibot";
7
7
  import { answerEntity } from "../../cli/answer-entity.js";
8
8
  import { REMOTE_READ, REMOTE_WRITE } from "../../cli/effects.js";
9
9
  import { itemOf, listOf } from "../../cli/envelope.js";
10
- import { commandPath, listQuery, nativeTerms, searchText, typedQuery, withQuery } from "../../cli/list-query.js";
10
+ import { commandPath, listQuery, nativeTerms, searchText, typedQuery, withQuery, withWords, } from "../../cli/list-query.js";
11
11
  import { terminalAsker } from "../../cli/messenger/ask.js";
12
12
  import { foldName } from "../../resolve.js";
13
13
  import { foreignContacts, foreignContactsPathFor } from "../foreign-contacts.js";
@@ -197,18 +197,24 @@ export const addCrmRecordCommands = (program, options) => {
197
197
  const stored = await run.store.crm.fields(run.account, kind);
198
198
  return stored.length ? stored : ((await run.source().fields?.(kind)) ?? []);
199
199
  };
200
+ const words = options.liveQuery === "words";
200
201
  const records = (noun) => {
201
202
  const group = annotate(program.command(noun.noun), { effects: REMOTE_READ }).description(`the CRM's ${noun.what}, read live: the copy holds only your own`);
202
- example(withQuery(answerEntity(annotate(group.command("list"), { effects: REMOTE_READ, offline: false }), noun.entity, noun.schema), noun.query)
203
+ const query = words
204
+ ? { ...noun.query, fields: noun.query.fields.filter(({ name }) => name === "name") }
205
+ : noun.query;
206
+ const list = answerEntity(annotate(group.command("list"), { effects: REMOTE_READ, offline: false }), noun.entity, noun.schema);
207
+ example((words
208
+ ? withWords(list, query, `words the CRM's own search looks for in ${noun.what}`)
209
+ : withQuery(list, query).addHelpText("after", CUSTOM_HELP))
203
210
  .description(`${noun.what} in the CRM, newest first; another client is found here, never in the copy`)
204
211
  .option("--limit <n>", `${noun.what} per page, 1–${MOST}`, integer(MOST), 50)
205
212
  .option("--page <n>", "which page, starting at 1", integer(1_000_000), 1)
206
- .addOption(csvFormatOption())
207
- .addHelpText("after", CUSTOM_HELP), `${noun.noun} list`, `${noun.noun} list name:anna* --json`, `${noun.noun} list --format csv > ${noun.noun}.csv`).action(async (words, opts, command) => {
213
+ .addOption(csvFormatOption()), `${noun.noun} list`, words ? `${noun.noun} list anna --json` : `${noun.noun} list name:anna* --json`, `${noun.noun} list --format csv > ${noun.noun}.csv`).action(async (words, opts, command) => {
208
214
  const csv = opts.format === "csv";
209
215
  const path = commandPath(command);
210
216
  const text = typedQuery(words);
211
- const names = customNames(text, noun.query, path, "name");
217
+ const names = customNames(text, query, path, "name");
212
218
  const columns = command.optsWithGlobals().fields;
213
219
  const wanted = csv && columns === undefined ? "all" : wantedCodes(columns);
214
220
  const read = async (run) => {
@@ -216,7 +222,7 @@ export const addCrmRecordCommands = (program, options) => {
216
222
  const fields = names.length || wanted !== undefined || csv ? await liveFields(run, noun.kind) : [];
217
223
  const chosen = filterableFields(fields, names);
218
224
  selectedCodes(fields, wanted);
219
- const terms = nativeTerms(listQuery(text, withCustomFields(noun.query, chosen), path, { defaultField: "name" }), path);
225
+ const terms = nativeTerms(listQuery(text, withCustomFields(query, chosen), path, { defaultField: "name" }), path);
220
226
  const custom = customConditions(terms, chosen);
221
227
  const name = searchText(terms.get("name"));
222
228
  terms.delete("name");
@@ -264,9 +270,20 @@ export const addCrmRecordCommands = (program, options) => {
264
270
  users(program, options);
265
271
  };
266
272
  /** By the CRM's id first; else the one record whose whole name is the given one, folded. */
273
+ /** A service whose ids have a fixed shape refuses a word as one (Attio answers 400): the word is then a name. */
274
+ const byIdOrNone = async (run, noun, id) => {
275
+ try {
276
+ return await sourceWith(run, "get", noun.what).get(noun.kind, id);
277
+ }
278
+ catch (error) {
279
+ if (isCliError(error) && error.code === "validation_error")
280
+ return null;
281
+ throw error;
282
+ }
283
+ };
267
284
  const recordNamed = async (run, noun, given) => {
268
285
  const id = given.trim();
269
- const byId = RECORD_ID.test(id) ? await sourceWith(run, "get", noun.what).get(noun.kind, id) : null;
286
+ const byId = RECORD_ID.test(id) ? await byIdOrNone(run, noun, id) : null;
270
287
  if (byId)
271
288
  return byId;
272
289
  const want = foldName(id);
@@ -6,10 +6,12 @@ import type { CrmRun, CrmWithin } from "./index.js";
6
6
  * `search all` in a CRM CLI: the shared search over the store, its own deals and leads beside the messages, notes and
7
7
  * events other WireCat tools stored. A locked profile reads only its own account's deals.
8
8
  */
9
- export declare const addCrmSearchAll: (searches: Command, { within, app, example, viewerOf, }: {
9
+ export declare const addCrmSearchAll: (searches: Command, { within, app, example, viewerOf, leads, }: {
10
10
  within: CrmWithin;
11
11
  app: AppIdentity;
12
12
  example: (command: Command, ...lines: string[]) => Command;
13
13
  /** This profile's rule over its own account's copy, as the other reads of the copy take it. */
14
14
  viewerOf: (run: CrmRun) => Promise<CopyViewer | undefined>;
15
+ /** The CRM has leads. */
16
+ leads?: boolean;
15
17
  }) => void;
@@ -20,13 +20,14 @@ const DEFAULT_LIMIT = 20;
20
20
  * `search all` in a CRM CLI: the shared search over the store, its own deals and leads beside the messages, notes and
21
21
  * events other WireCat tools stored. A locked profile reads only its own account's deals.
22
22
  */
23
- export const addCrmSearchAll = (searches, { within, app, example, viewerOf, }) => {
23
+ export const addCrmSearchAll = (searches, { within, app, example, viewerOf, leads = true, }) => {
24
+ const deals = leads ? "deals and leads" : "deals";
24
25
  const all = annotate(new Command("all"), { effects: LOCAL_READ, partial: true, output: { entity: "hit" } })
25
- .summary("search stored deals and leads, messages, notes, calendar events and meetings")
26
- .description("search the CRM's deals and leads by the words of their title, company, contacts and activities, and the " +
26
+ .summary(`search stored ${deals}, messages, notes, calendar events and meetings`)
27
+ .description(`search the CRM's ${deals} by the words of their title, company, contacts and activities, and the ` +
27
28
  "messages, notes, calendar events and meetings other WireCat tools stored — best match first. Use it when " +
28
29
  "you do not know where something was written")
29
- .argument("<query...>", 'words and "phrases"; deals and leads match the words of their title, company, contacts and activities')
30
+ .argument("<query...>", `words and "phrases"; ${deals} match the words of their title, company, contacts and activities`)
30
31
  .addHelpText("after", SAVE_HELP);
31
32
  searches.addCommand(searchAllOptions(all, SEARCHED));
32
33
  example(all, "search all Example LLC", "search all website --only crm --json");
@@ -512,6 +512,10 @@ export declare const contactMessages: v.StrictObjectSchema<{
512
512
  readonly fingerprint: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
513
513
  readonly new_sender: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
514
514
  readonly sender_identities: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
515
+ readonly inbox: v.OptionalSchema<v.StrictObjectSchema<{
516
+ readonly bucket: v.PicklistSchema<["answer", "read", "later"], undefined>;
517
+ readonly reason: v.StringSchema<undefined>;
518
+ }, undefined>, undefined>;
515
519
  readonly reply_to: v.ArraySchema<v.StrictObjectSchema<{
516
520
  readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
517
521
  readonly address: v.StringSchema<undefined>;
@@ -1308,6 +1312,10 @@ export declare const contactContext: v.UnionSchema<[v.StrictObjectSchema<{
1308
1312
  readonly fingerprint: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
1309
1313
  readonly new_sender: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
1310
1314
  readonly sender_identities: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
1315
+ readonly inbox: v.OptionalSchema<v.StrictObjectSchema<{
1316
+ readonly bucket: v.PicklistSchema<["answer", "read", "later"], undefined>;
1317
+ readonly reason: v.StringSchema<undefined>;
1318
+ }, undefined>, undefined>;
1311
1319
  readonly reply_to: v.ArraySchema<v.StrictObjectSchema<{
1312
1320
  readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
1313
1321
  readonly address: v.StringSchema<undefined>;
@@ -230,6 +230,10 @@ export declare const conversationDetails: v.UnionSchema<[v.StrictObjectSchema<{
230
230
  readonly fingerprint: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
231
231
  readonly new_sender: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
232
232
  readonly sender_identities: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
233
+ readonly inbox: v.OptionalSchema<v.StrictObjectSchema<{
234
+ readonly bucket: v.PicklistSchema<["answer", "read", "later"], undefined>;
235
+ readonly reason: v.StringSchema<undefined>;
236
+ }, undefined>, undefined>;
233
237
  }, undefined>, undefined>;
234
238
  readonly provider_metadata: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
235
239
  }, undefined>, undefined>;
@@ -453,6 +457,10 @@ export declare const conversationDetails: v.UnionSchema<[v.StrictObjectSchema<{
453
457
  readonly fingerprint: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
454
458
  readonly new_sender: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
455
459
  readonly sender_identities: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
460
+ readonly inbox: v.OptionalSchema<v.StrictObjectSchema<{
461
+ readonly bucket: v.PicklistSchema<["answer", "read", "later"], undefined>;
462
+ readonly reason: v.StringSchema<undefined>;
463
+ }, undefined>, undefined>;
456
464
  }, undefined>, undefined>;
457
465
  readonly provider_metadata: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
458
466
  }, undefined>], undefined>;
@@ -221,6 +221,10 @@ export declare const contribution: v.StrictObjectSchema<{
221
221
  readonly fingerprint: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
222
222
  readonly new_sender: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
223
223
  readonly sender_identities: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
224
+ readonly inbox: v.OptionalSchema<v.StrictObjectSchema<{
225
+ readonly bucket: v.PicklistSchema<["answer", "read", "later"], undefined>;
226
+ readonly reason: v.StringSchema<undefined>;
227
+ }, undefined>, undefined>;
224
228
  }, undefined>, undefined>;
225
229
  readonly provider_metadata: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
226
230
  }, undefined>, "entries" | "~run" | "~standard" | "~types"> & {
@@ -444,6 +448,10 @@ export declare const contribution: v.StrictObjectSchema<{
444
448
  readonly fingerprint: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
445
449
  readonly new_sender: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
446
450
  readonly sender_identities: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
451
+ readonly inbox: v.OptionalSchema<v.StrictObjectSchema<{
452
+ readonly bucket: v.PicklistSchema<["answer", "read", "later"], undefined>;
453
+ readonly reason: v.StringSchema<undefined>;
454
+ }, undefined>, undefined>;
447
455
  }, undefined>, undefined>;
448
456
  readonly provider_metadata: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
449
457
  }, "chat_title" | "ref" | "sender_name" | "text" | "timestamp">;
@@ -705,6 +713,10 @@ export declare const contribution: v.StrictObjectSchema<{
705
713
  readonly fingerprint: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
706
714
  readonly new_sender: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
707
715
  readonly sender_identities: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
716
+ readonly inbox: v.OptionalSchema<v.StrictObjectSchema<{
717
+ readonly bucket: v.PicklistSchema<["answer", "read", "later"], undefined>;
718
+ readonly reason: v.StringSchema<undefined>;
719
+ }, undefined>, undefined>;
708
720
  }, undefined>, undefined>;
709
721
  readonly provider_metadata: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
710
722
  }, undefined>, "entries" | "~run" | "~standard" | "~types"> & {
@@ -928,6 +940,10 @@ export declare const contribution: v.StrictObjectSchema<{
928
940
  readonly fingerprint: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
929
941
  readonly new_sender: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
930
942
  readonly sender_identities: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
943
+ readonly inbox: v.OptionalSchema<v.StrictObjectSchema<{
944
+ readonly bucket: v.PicklistSchema<["answer", "read", "later"], undefined>;
945
+ readonly reason: v.StringSchema<undefined>;
946
+ }, undefined>, undefined>;
931
947
  }, undefined>, undefined>;
932
948
  readonly provider_metadata: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
933
949
  }, "chat_title" | "ref" | "sender_name" | "text" | "timestamp">;
@@ -1225,6 +1241,10 @@ export declare const evidence: v.UnionSchema<[v.StrictObjectSchema<{
1225
1241
  readonly fingerprint: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
1226
1242
  readonly new_sender: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
1227
1243
  readonly sender_identities: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
1244
+ readonly inbox: v.OptionalSchema<v.StrictObjectSchema<{
1245
+ readonly bucket: v.PicklistSchema<["answer", "read", "later"], undefined>;
1246
+ readonly reason: v.StringSchema<undefined>;
1247
+ }, undefined>, undefined>;
1228
1248
  }, undefined>, undefined>;
1229
1249
  readonly provider_metadata: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
1230
1250
  }, undefined>, "entries" | "~run" | "~standard" | "~types"> & {
@@ -1448,6 +1468,10 @@ export declare const evidence: v.UnionSchema<[v.StrictObjectSchema<{
1448
1468
  readonly fingerprint: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
1449
1469
  readonly new_sender: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
1450
1470
  readonly sender_identities: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
1471
+ readonly inbox: v.OptionalSchema<v.StrictObjectSchema<{
1472
+ readonly bucket: v.PicklistSchema<["answer", "read", "later"], undefined>;
1473
+ readonly reason: v.StringSchema<undefined>;
1474
+ }, undefined>, undefined>;
1451
1475
  }, undefined>, undefined>;
1452
1476
  readonly provider_metadata: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
1453
1477
  }, "chat_title" | "ref" | "sender_name" | "text" | "timestamp">;
@@ -1709,6 +1733,10 @@ export declare const evidence: v.UnionSchema<[v.StrictObjectSchema<{
1709
1733
  readonly fingerprint: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
1710
1734
  readonly new_sender: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
1711
1735
  readonly sender_identities: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
1736
+ readonly inbox: v.OptionalSchema<v.StrictObjectSchema<{
1737
+ readonly bucket: v.PicklistSchema<["answer", "read", "later"], undefined>;
1738
+ readonly reason: v.StringSchema<undefined>;
1739
+ }, undefined>, undefined>;
1712
1740
  }, undefined>, undefined>;
1713
1741
  readonly provider_metadata: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
1714
1742
  }, undefined>, "entries" | "~run" | "~standard" | "~types"> & {
@@ -1932,6 +1960,10 @@ export declare const evidence: v.UnionSchema<[v.StrictObjectSchema<{
1932
1960
  readonly fingerprint: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
1933
1961
  readonly new_sender: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
1934
1962
  readonly sender_identities: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
1963
+ readonly inbox: v.OptionalSchema<v.StrictObjectSchema<{
1964
+ readonly bucket: v.PicklistSchema<["answer", "read", "later"], undefined>;
1965
+ readonly reason: v.StringSchema<undefined>;
1966
+ }, undefined>, undefined>;
1935
1967
  }, undefined>, undefined>;
1936
1968
  readonly provider_metadata: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
1937
1969
  }, "chat_title" | "ref" | "sender_name" | "text" | "timestamp">;