@wirecat/cli-core 0.619.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 (85) hide show
  1. package/CHANGELOG.md +114 -0
  2. package/dist/background/daily-archive-timer.d.ts +1 -1
  3. package/dist/calendar/cli/search-all.d.ts +1 -1
  4. package/dist/calendar/cli/search-all.js +9 -10
  5. package/dist/calendar/prepare.js +1 -0
  6. package/dist/cli/base-stages-command.d.ts +1 -1
  7. package/dist/cli/base-stages-command.js +1 -1
  8. package/dist/cli/bot/buttons.d.ts +3 -0
  9. package/dist/cli/bot/buttons.js +24 -0
  10. package/dist/cli/bot/messages.js +14 -1
  11. package/dist/cli/bot/port.d.ts +8 -0
  12. package/dist/cli/contract-templates.js +31 -2
  13. package/dist/cli/messenger/contacts-command.js +2 -1
  14. package/dist/cli/messenger/conversations-command.js +2 -1
  15. package/dist/cli/messenger/message-items.js +1 -1
  16. package/dist/cli/messenger/search-answers.d.ts +5 -5
  17. package/dist/cli/messenger/search-answers.js +9 -20
  18. package/dist/cli/messenger/search-command.d.ts +2 -2
  19. package/dist/cli/messenger/search-command.js +8 -18
  20. package/dist/cli/model-catalogue-command.js +3 -1
  21. package/dist/cli/search-harder-consents-command.d.ts +18 -0
  22. package/dist/cli/search-harder-consents-command.js +83 -0
  23. package/dist/cli/steps.js +0 -6
  24. package/dist/cli/templates-command.js +4 -4
  25. package/dist/crm/cli/index.js +2 -2
  26. package/dist/crm/cli/search-all.js +7 -6
  27. package/dist/domain/models.d.ts +2 -0
  28. package/dist/entities/contact-context.d.ts +3 -0
  29. package/dist/entities/contact-context.js +4 -0
  30. package/dist/entities/hit.d.ts +9 -2
  31. package/dist/entities/hit.js +6 -2
  32. package/dist/entities/index.d.ts +9 -1
  33. package/dist/errors/reasons.js +2 -0
  34. package/dist/meetings/hit-query.d.ts +1 -1
  35. package/dist/meetings/hit-query.js +2 -2
  36. package/dist/meetings/index.d.ts +1 -0
  37. package/dist/meetings/index.js +1 -0
  38. package/dist/meetings/store.d.ts +4 -0
  39. package/dist/meetings/store.js +2 -1
  40. package/dist/models/anthropic.js +5 -0
  41. package/dist/search/question-period.d.ts +10 -0
  42. package/dist/search/question-period.js +133 -0
  43. package/dist/sends/buttons.d.ts +2 -0
  44. package/dist/sends/buttons.js +6 -1
  45. package/dist/services/enrichment.d.ts +5 -0
  46. package/dist/services/enrichment.js +1 -1
  47. package/dist/services/index.d.ts +4 -2
  48. package/dist/services/index.js +3 -1
  49. package/dist/services/messages.d.ts +1 -4
  50. package/dist/services/messages.js +0 -2
  51. package/dist/services/metadata.d.ts +1 -1
  52. package/dist/services/person-context.d.ts +3 -1
  53. package/dist/services/person-context.js +21 -8
  54. package/dist/services/person-preparation.d.ts +5 -1
  55. package/dist/services/person-preparation.js +10 -3
  56. package/dist/services/person-timeline.d.ts +6 -1
  57. package/dist/services/person-timeline.js +10 -2
  58. package/dist/services/search-all-deprecated.d.ts +40 -0
  59. package/dist/services/search-all-deprecated.js +10 -0
  60. package/dist/services/search-all-meetings.d.ts +50 -52
  61. package/dist/services/search-all-meetings.js +265 -272
  62. package/dist/services/search-all.d.ts +34 -6
  63. package/dist/services/search-all.js +118 -24
  64. package/dist/services/search-harder.d.ts +64 -0
  65. package/dist/services/search-harder.js +194 -0
  66. package/dist/store/chats.d.ts +3 -1
  67. package/dist/store/chats.js +6 -0
  68. package/dist/store/people.d.ts +6 -2
  69. package/dist/store/sqlite/added-sources.d.ts +15 -3
  70. package/dist/store/sqlite/added-sources.js +26 -5
  71. package/dist/store/sqlite/chats.d.ts +2 -0
  72. package/dist/store/sqlite/chats.js +6 -0
  73. package/dist/store/sqlite/involvements.d.ts +1 -1
  74. package/dist/store/sqlite/involvements.js +4 -2
  75. package/dist/store/sqlite/meeting-hit-query.d.ts +5 -0
  76. package/dist/store/sqlite/meeting-hit-query.js +33 -0
  77. package/dist/store/sqlite/meeting-hit-search.js +10 -8
  78. package/dist/store/sqlite/meetings.js +1 -1
  79. package/dist/store/sqlite/notes.d.ts +7 -0
  80. package/dist/store/sqlite/notes.js +13 -5
  81. package/dist/store/sqlite/person-preparation.d.ts +7 -3
  82. package/dist/store/sqlite/person-preparation.js +20 -6
  83. package/dist/store/sqlite/relation-list.js +4 -2
  84. package/package.json +1 -1
  85. package/parity.json +26 -12
@@ -22,44 +22,35 @@ export const searchAllOnlyOf = (value, allowed = SOURCE_SEARCHED) => {
22
22
  throw new CliError("validation_error", "mail is searched by the separate memo CLI: install @wirecat/cli-memo, then `memo search mail …`");
23
23
  const unknown = chosen.find((one) => !allowed.includes(one));
24
24
  if (unknown !== undefined || chosen.length === 0)
25
- throw new CliError("validation_error", `--only takes ${allowed.join(", ")}, separated by commas; meetings when --source names a meeting account`);
25
+ throw new CliError("validation_error", `--only takes ${allowed.join(", ")}, separated by commas`);
26
26
  return [...new Set(chosen)];
27
27
  };
28
28
  /** One `search all` hit as a person reads it. */
29
29
  export const searchAllLine = (item) => item.kind === "meeting"
30
30
  ? `meeting · ${item.provider} · ${singleLine(item.title ?? "")} ${item.ref}\n ${item.timestamp ?? "time unknown"} ${singleLine(item.text).slice(0, 200)}\n`
31
31
  : `${item.kind} · ${item.provider} · ${singleLine(item.title ?? "")} ${item.ref}${item.url ? `\n ${singleLine(item.url)}` : ""}\n ${item.timestamp}${item.from?.name ? ` ${singleLine(item.from.name)}` : ""} ${singleLine(item.text)}\n`;
32
- const maxMeetingsOf = (value) => {
33
- if (value === "all")
34
- return "all";
35
- if (!/^[1-9]\d*$/.test(value))
36
- throw new CliError("validation_error", "--max-meetings takes a whole number from 1, or all");
37
- return Number(value);
38
- };
39
32
  /**
40
33
  * `search all`'s scope, paging and matching options, the same in every CLI that mounts it (WC-ACCT-8): a messenger's
41
34
  * and a calendar's.
42
35
  */
43
36
  /** `allowed`: the resources `--only` takes, a CRM CLI's with `crm`. */
44
37
  export const searchAllOptions = (command, allowed = SOURCE_SEARCHED) => command
45
- .option("--only <resources>", `only these resources, separated by commas: ${allowed.filter((one) => one !== "meetings").join(", ")}; ` +
46
- "meetings when --source names a meeting account", (value) => searchAllOnlyOf(value, allowed))
38
+ .option("--only <resources>", `only these resources, separated by commas: ${allowed.join(", ")}`, (value) => searchAllOnlyOf(value, allowed))
47
39
  .option("--source <accounts>", "only these accounts, separated by commas: provider:account as a hit shows it, a provider, a kind or " +
48
- "group:<name>; each resource reads the ones of its kind, and meetings only when it names one")
49
- .option("--max-meetings <n>", "how many of the meeting account's meetings to look through, newest first, or all for every one (default 100)", maxMeetingsOf)
40
+ "group:<name>; each resource reads the ones of its kind")
50
41
  .option("--limit <n>", "how many", positiveCount("--limit"))
51
42
  .option("--page <n>", "which page, starting at 1", positiveCount("--page"))
52
43
  .option("--exact", "bare words and quotes match their exact form only, as exact:word does")
53
44
  .option("--timezone <zone>", "the IANA timezone for calendar date boundaries");
54
45
  const allCommand = (messenger) => {
55
46
  const command = annotate(new Command("all"), { effects: REMOTE_READ, partial: true })
56
- .summary("search stored messages, notes, calendar events and selected meeting transcripts")
47
+ .summary("search stored messages, notes, calendar events and meetings")
57
48
  .description((messenger.serverSearch
58
49
  ? "search messenger messages and notes in the local store, and by default the messenger's server for " +
59
50
  "messages too (notes and events are local only; --backend archive or --offline keeps it to the local store)"
60
51
  : "search messenger messages and notes in the local store") +
61
52
  ", calendar events when the store holds a calendar" +
62
- ", and a meeting account's transcripts when --source names one — best match first; not mail (the separate memo CLI searches it: memo search mail), " +
53
+ ", and meeting transcripts, chat and summaries when it holds a meeting account — best match first; not mail (the separate memo CLI searches it: memo search mail), " +
63
54
  "tasks, people, memories or projects. Use it when you do not know where something was written; search messages " +
64
55
  "or notes reads one kind with all its fields")
65
56
  .argument("<query...>", 'strict Lucene query: words, "phrases", AND/OR/NOT, field groups and date ranges')
@@ -68,10 +59,10 @@ const allCommand = (messenger) => {
68
59
  --json: the list is items; each result's reference is ref, with its kind.`);
69
60
  return backendOptions(annotate(searchAllOptions(command), { output: { entity: "hit" } }), messenger).action(async function (words) {
70
61
  const context = messengerContext(this, messenger);
71
- const { only, source, maxMeetings, limit: typed, page, exact, timezone, } = this.opts();
62
+ const { only, source, limit: typed, page, exact, timezone, } = this.opts();
72
63
  const limit = typed ?? context.settings.limit;
73
64
  const offset = offsetOf(page, limit);
74
- const found = await context.withServices((services) => services.messages.searchAllWithMeetings({
65
+ const found = await context.withServices((services) => services.messages.searchAll({
75
66
  text: words.join(" "),
76
67
  limit,
77
68
  ...(offset === undefined ? {} : { offset }),
@@ -80,8 +71,8 @@ const allCommand = (messenger) => {
80
71
  ...backendRequest(this),
81
72
  env: context.env,
82
73
  only: only ?? SOURCE_SEARCHED,
74
+ ...(only?.includes("meetings") ? { meetingsAsked: true } : {}),
83
75
  ...(source === undefined ? {} : { source }),
84
- ...(maxMeetings === undefined ? {} : { maxMeetings }),
85
76
  }));
86
77
  noteServer(context, found.server);
87
78
  if (context.format === "pretty")
@@ -98,7 +89,6 @@ const allCommand = (messenger) => {
98
89
  query: words.join(" "),
99
90
  ...(only === undefined ? {} : { only: only.join(",") }),
100
91
  ...(source === undefined ? {} : { source }),
101
- ...(maxMeetings === undefined ? {} : { max_meetings: maxMeetings }),
102
92
  ...(exact ? { exact: true } : {}),
103
93
  ...(timezone === undefined ? {} : { timezone }),
104
94
  };
@@ -16,6 +16,7 @@ import { FETCH, grantsAuthority, LOCAL_READ, LOCAL_WRITE, NO_EFFECTS } from "./e
16
16
  import { enrichmentConsentsCommand } from "./enrichment-consents-command.js";
17
17
  import { itemOf, listOf } from "./envelope.js";
18
18
  import { listQuery, nativeTerms, termField, typedQuery, withQuery } from "./list-query.js";
19
+ import { harderConsentsCommand } from "./search-harder-consents-command.js";
19
20
  export const MODEL_CATALOGUE_QUERY = defineQuery({
20
21
  entity: "model",
21
22
  backend: "native",
@@ -142,6 +143,7 @@ export const modelCatalogueCommand = (app, options) => {
142
143
  }
143
144
  if (options.enrichment === true) {
144
145
  models.addCommand(enrichmentConsentsCommand(app, options));
146
+ models.addCommand(harderConsentsCommand(app, options));
145
147
  models.addCommand(providerKeysCommand(app, options));
146
148
  }
147
149
  if (options.jsonOption)
@@ -158,7 +160,7 @@ const providerOf = (given) => {
158
160
  };
159
161
  /** The enrichment provider's key in the tool's keyring entry `embeddings:<provider>`; never printed, never an argument. */
160
162
  const providerKeysCommand = (app, options) => {
161
- const keys = new Command("keys").description("the API key write-time enrichment sends with each request");
163
+ const keys = new Command("keys").description("the API key write-time enrichment and search all --harder send with each request");
162
164
  const store = () => embeddingKeys(app, options.env(), options.keyring);
163
165
  grantsAuthority(annotate(keys.command("set"), {
164
166
  effects: LOCAL_WRITE,
@@ -0,0 +1,18 @@
1
+ import { type KeyringStore } from "@wirecat/cli-base";
2
+ import { Command } from "commander";
3
+ import type { AppIdentity } from "../ports/app.js";
4
+ import { type Body } from "./envelope.js";
5
+ export interface HarderConsentsOptions {
6
+ env: () => NodeJS.ProcessEnv;
7
+ /** Where the key is looked for; the system keyring when absent. Tests pass memoryKeyring(). */
8
+ keyring?: KeyringStore;
9
+ output: (answer: Body, command: Command) => void;
10
+ diagnostic: (line: string) => void;
11
+ }
12
+ /** What the owner agrees to; a window can write the same text from the answer's fields. */
13
+ export declare const harderConsentWording: (command: string, model: string) => string;
14
+ /**
15
+ * The owner's consent that `search all --harder` may send a question and its hits to a hosted model. Off until
16
+ * `set … --yes`; with it, still only a search that asks with --harder sends anything.
17
+ */
18
+ export declare const harderConsentsCommand: (app: AppIdentity, options: HarderConsentsOptions) => Command;
@@ -0,0 +1,83 @@
1
+ import { CliError } from "@wirecat/cli-base";
2
+ import { annotate } from "@wirecat/cli-base/commands";
3
+ import { Command } from "commander";
4
+ import { agentOf } from "../runs/run-context.js";
5
+ import { keyLookup, keyVariable } from "../services/enrichment.js";
6
+ import { DEFAULT_HARDER_MODEL, HARDER_CANDIDATES, HARDER_CHARS, HARDER_ENDPOINT, HARDER_PROVIDER, readHarderSetting, writeHarderSetting, } from "../services/search-harder.js";
7
+ import { grantsAuthority, LOCAL_READ, LOCAL_WRITE } from "./effects.js";
8
+ import { itemOf } from "./envelope.js";
9
+ /** What the owner agrees to; a window can write the same text from the answer's fields. */
10
+ export const harderConsentWording = (command, model) => `\`${command} search all --harder\` sends the question and its first ${HARDER_CANDIDATES} hits (each one's title, ` +
11
+ `date and up to ${HARDER_CHARS} characters of its text) to ${HARDER_PROVIDER} (${new URL(HARDER_ENDPOINT).host}), ` +
12
+ `model ${model}, which puts the hits that answer it first. Only a search with --harder sends anything; one costs ` +
13
+ `about $0.0004 with claude-haiku-5-5 and adds 1 to 2 seconds. \`${command} models search-consents revoke\` turns it off.`;
14
+ const state = (app, options, model) => {
15
+ const env = options.env();
16
+ const setting = readHarderSetting(env);
17
+ const found = keyLookup({ env, app, ...(options.keyring ? { keyring: options.keyring } : {}) }, { provider: HARDER_PROVIDER });
18
+ const chosen = model ?? setting?.model ?? DEFAULT_HARDER_MODEL;
19
+ return {
20
+ on: setting !== undefined,
21
+ provider: HARDER_PROVIDER,
22
+ model: chosen,
23
+ endpoint: HARDER_ENDPOINT,
24
+ consented_at: setting?.consented_at ?? null,
25
+ candidates: HARDER_CANDIDATES,
26
+ chars_per_hit: HARDER_CHARS,
27
+ key: { present: found !== undefined, source: found?.source ?? null, env_var: keyVariable(HARDER_PROVIDER) },
28
+ consent: harderConsentWording(app.command, chosen),
29
+ off_command: `${app.command} models search-consents revoke`,
30
+ };
31
+ };
32
+ /**
33
+ * The owner's consent that `search all --harder` may send a question and its hits to a hosted model. Off until
34
+ * `set … --yes`; with it, still only a search that asks with --harder sends anything.
35
+ */
36
+ export const harderConsentsCommand = (app, options) => {
37
+ const consents = annotate(new Command("search-consents"), { effects: LOCAL_READ }).description("consent that search all --harder sends the question and its first hits to a hosted model; off by default");
38
+ annotate(consents.command("show"), { effects: LOCAL_READ, examples: [`${app.command} models search-consents show`] })
39
+ .description("whether search all --harder may call the model, which one, and whether its key is found")
40
+ .action(function () {
41
+ options.output(itemOf(state(app, options)), this);
42
+ });
43
+ grantsAuthority(annotate(consents.command("set"), {
44
+ effects: LOCAL_WRITE,
45
+ examples: [`${app.command} models search-consents set anthropic --yes`],
46
+ }))
47
+ .description("allow search all --harder to call the model; without --yes, say what it sends and change nothing")
48
+ .argument("<provider>", "the provider that receives the question and hits: anthropic")
49
+ .option("--model <model>", "the provider's model name", DEFAULT_HARDER_MODEL)
50
+ .option("--yes", "agree that a --harder search sends its question and hits, and allow it")
51
+ .action(function (provider, given) {
52
+ if (provider !== HARDER_PROVIDER)
53
+ throw new CliError("validation_error", `search all --harder calls ${HARDER_PROVIDER} only, not ${provider}`);
54
+ const env = options.env();
55
+ // An agent that turned this on would decide for the owner that his records may leave the machine.
56
+ if (agentOf(env) && given.yes)
57
+ throw new CliError("permission_error", "only the owner allows search all --harder, not an agent", {
58
+ reason: "search-harder.owner-only",
59
+ });
60
+ if (!given.yes) {
61
+ const now = state(app, options, given.model);
62
+ options.diagnostic(`${now.consent}\nNothing changed — add --yes to allow it.`);
63
+ options.output(itemOf({ ...now, changed: false }), this);
64
+ return;
65
+ }
66
+ writeHarderSetting(env, { provider: HARDER_PROVIDER, model: given.model, consented_at: new Date().toISOString() });
67
+ options.diagnostic(`search all --harder may now call ${HARDER_PROVIDER} ${given.model}`);
68
+ options.output(itemOf({ ...state(app, options), changed: true }), this);
69
+ });
70
+ grantsAuthority(annotate(consents.command("revoke"), {
71
+ effects: LOCAL_WRITE,
72
+ examples: [`${app.command} models search-consents revoke`],
73
+ }))
74
+ .description("stop search all --harder from calling the model; it gives the plain order again")
75
+ .action(function () {
76
+ const env = options.env();
77
+ const was = readHarderSetting(env);
78
+ writeHarderSetting(env, undefined);
79
+ options.diagnostic(`search all --harder sends nothing now${was ? ` (was ${was.provider} ${was.model})` : ""}`);
80
+ options.output(itemOf({ ...state(app, options), changed: was !== undefined }), this);
81
+ });
82
+ return consents;
83
+ };
package/dist/cli/steps.js CHANGED
@@ -225,12 +225,6 @@ export const STEPS = defineSteps([
225
225
  args: [],
226
226
  why: "the store file is damaged; this says what is lost and the commands that recover it",
227
227
  },
228
- {
229
- id: "search.meetings",
230
- command: "*",
231
- args: [{ name: "max_meetings", required: true }],
232
- why: "stopped after {scanned} meetings; more may match",
233
- },
234
228
  ]);
235
229
  /** A step from its registered definition; an argument left undefined is left out, as the command line would. */
236
230
  export const nextStep = (id, input) => {
@@ -154,7 +154,7 @@ export const templatesCommand = (app, options) => {
154
154
  .argument("<key>", "the template, such as report/morning-digest")
155
155
  .addOption(channelOption())
156
156
  .addOption(localeOption())
157
- .option("--file <file>", "take the new template from this file instead of opening an editor")
157
+ .option("--file <file>", "take the new template from this file instead of opening an editor; - reads stdin")
158
158
  .addOption(new Option("--undo", "put back the body your last change replaced; twice is back where you were").conflicts("file"))
159
159
  .action(async function (key, given) {
160
160
  const env = options.env();
@@ -175,7 +175,7 @@ export const templatesCommand = (app, options) => {
175
175
  body = previous;
176
176
  }
177
177
  else if (given.file !== undefined) {
178
- body = readFileSync(given.file, "utf8");
178
+ body = readFileSync(given.file === "-" ? 0 : given.file, "utf8");
179
179
  }
180
180
  else {
181
181
  draft = join(mkdtempSync(join(tmpdir(), "wirecat-template-")), `${key.replace("/", "-")}.${channel}.${address.language}.liquid`);
@@ -225,12 +225,12 @@ export const templatesCommand = (app, options) => {
225
225
  .argument("<key>", "the template, such as report/morning-digest")
226
226
  .addOption(channelOption())
227
227
  .addOption(localeOption())
228
- .option("--file <file>", "preview this draft instead of the template that applies")
228
+ .option("--file <file>", "preview this draft instead of the template that applies; - reads stdin")
229
229
  .action(async function (key, given) {
230
230
  const env = options.env();
231
231
  const { address, kind, channel } = await addressOf(key, given, env);
232
232
  const stored = given.file === undefined ? await withStore(env, (store) => store.templates.get(address)?.body) : undefined;
233
- const body = given.file === undefined ? stored : readFileSync(given.file, "utf8");
233
+ const body = given.file === undefined ? stored : readFileSync(given.file === "-" ? 0 : given.file, "utf8");
234
234
  const { against, view } = previewView(stateOf(app, env), kind, address.language, Date.now());
235
235
  const rendering = await renderReport(view, channel, body === undefined ? {} : { template: body });
236
236
  const problems = body === undefined ? [] : (await checkTemplate(view, channel, body)).problems;
@@ -295,7 +295,7 @@ const addCrmCommandsDefinition = (program, options) => {
295
295
  });
296
296
  example(annotate(group.command("show"), { effects: LOCAL_READ, output: { entity: kind } })
297
297
  .description(`one ${kind} with its pipeline, stage, status, amount and the people on it`)
298
- .argument("<ref>", `${kind}:<id>, as a list shows it`), `${plural} show ${kind}:12`).action(async (reference, _opts, command) => {
298
+ .argument(`<${kind}>`, `${kind}:<id>, as a list shows it`), `${plural} show ${kind}:12`).action(async (reference, _opts, command) => {
299
299
  await within(command, async (run) => {
300
300
  const found = await ownCopy(run, kind, reference);
301
301
  return itemOf({ ...dealKeys(found), untrusted: DEAL_UNTRUSTED });
@@ -344,7 +344,7 @@ const addCrmCommandsDefinition = (program, options) => {
344
344
  command.option("--operation-id <id>", "the operation_id a write that ended in outcome_unknown named: the CRM answers the repeat from its record");
345
345
  return command;
346
346
  };
347
- const reference = (command) => command.argument("<ref>", `${kind}:<id>, as a list shows it`);
347
+ const reference = (command) => command.argument(`<${kind}>`, `${kind}:<id>, as a list shows it`);
348
348
  const fields = (command) => command
349
349
  .option("--title <title>", `the ${kind}'s title`)
350
350
  .option("--pipeline <pipeline>", "pipeline:<id>, or a name only one of the CRM's pipelines has")
@@ -11,7 +11,7 @@ import { commandAt, rootOf } from "../../cli/steps.js";
11
11
  import { DEAL_KINDS } from "../../domain/deals.js";
12
12
  import { SAVE_HELP } from "../../meetings/index.js";
13
13
  import { meaningLane } from "../../services/messages-meaning.js";
14
- import { searchAllWithMeetings } from "../../services/search-all-meetings.js";
14
+ import { searchAll } from "../../services/search-all.js";
15
15
  /** What a CRM CLI's `search all` reads: its deals and leads first, then what the other tools stored. */
16
16
  const SEARCHED = ["crm", ...SOURCE_SEARCHED];
17
17
  const DEFAULT_LIMIT = 20;
@@ -21,9 +21,10 @@ const DEFAULT_LIMIT = 20;
21
21
  */
22
22
  export const addCrmSearchAll = (searches, { within, app, example, }) => {
23
23
  const all = annotate(new Command("all"), { effects: LOCAL_READ, partial: true, output: { entity: "hit" } })
24
- .summary("search stored deals and leads, messages, notes and calendar events")
25
- .description("search the CRM's deals and leads by the words of their title, and messages, notes and calendar events other " +
26
- "WireCat tools stored — best match first. Use it when you do not know where something was written")
24
+ .summary("search stored deals and leads, messages, notes, calendar events and meetings")
25
+ .description("search the CRM's deals and leads by the words of their title, and messages, notes, calendar events and " +
26
+ "meetings other WireCat tools stored — best match first. Use it when you do not know where something was " +
27
+ "written")
27
28
  .argument("<query...>", 'words and "phrases"; deals and leads match the words of their title')
28
29
  .addHelpText("after", SAVE_HELP);
29
30
  searches.addCommand(searchAllOptions(all, SEARCHED));
@@ -46,7 +47,7 @@ export const addCrmSearchAll = (searches, { within, app, example, }) => {
46
47
  const limit = opts.limit ?? DEFAULT_LIMIT;
47
48
  const offset = offsetOf(opts.page, limit);
48
49
  const env = run.env ?? process.env;
49
- const found = await searchAllWithMeetings(run.store, run.account, {
50
+ const found = await searchAll(run.store, run.account, {
50
51
  text: words.join(" "),
51
52
  limit,
52
53
  ...(offset === undefined ? {} : { offset }),
@@ -54,9 +55,9 @@ export const addCrmSearchAll = (searches, { within, app, example, }) => {
54
55
  ...(opts.timezone === undefined ? {} : { timezone: opts.timezone }),
55
56
  env,
56
57
  only,
58
+ ...(opts.only?.includes("meetings") ? { meetingsAsked: true } : {}),
57
59
  ...(crmKinds.length < DEAL_KINDS.length ? { crmKinds } : {}),
58
60
  ...(opts.source === undefined ? {} : { source: opts.source }),
59
- ...(opts.maxMeetings === undefined ? {} : { maxMeetings: opts.maxMeetings }),
60
61
  ...(run.locked ? { scope: { crm: [run.account] } } : {}),
61
62
  }, { app, hintCommand: commandAt(rootOf(leaf), "models download") ? app.command : null }, undefined, meaningLane({ env, messenger: { app }, store: async () => run.store }));
62
63
  const note = (text) => outputFor(leaf).renderer.note(text);
@@ -219,6 +219,8 @@ export interface Button {
219
219
  kind: ButtonKind;
220
220
  text: string;
221
221
  url?: string;
222
+ /** What a `callback` button sends the bot, where the adapter can read it; used to refuse owner-only buttons, never printed. */
223
+ data?: string;
222
224
  }
223
225
  /** Where one attachment's bytes can be fetched. */
224
226
  export interface AttachmentLink {
@@ -1847,18 +1847,21 @@ export declare const contactPreparation: v.StrictObjectSchema<{
1847
1847
  readonly cut_by: v.NullableSchema<v.PicklistSchema<["limit", "bytes"], undefined>, undefined>;
1848
1848
  readonly selection: v.LiteralSchema<"open, assigned to them in any role", undefined>;
1849
1849
  readonly accounts: v.ArraySchema<v.StringSchema<undefined>, undefined>;
1850
+ readonly scopes: v.ArraySchema<v.PicklistSchema<["personal", "work"], undefined>, undefined>;
1850
1851
  }, undefined>;
1851
1852
  readonly facts: v.StrictObjectSchema<{
1852
1853
  readonly included: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
1853
1854
  readonly has_more: v.BooleanSchema<undefined>;
1854
1855
  readonly cut_by: v.NullableSchema<v.PicklistSchema<["limit", "bytes"], undefined>, undefined>;
1855
1856
  readonly selection: v.LiteralSchema<"accepted, about them or a project they are a member of", undefined>;
1857
+ readonly scopes: v.ArraySchema<v.PicklistSchema<["personal", "work"], undefined>, undefined>;
1856
1858
  }, undefined>;
1857
1859
  readonly notes: v.StrictObjectSchema<{
1858
1860
  readonly included: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
1859
1861
  readonly has_more: v.BooleanSchema<undefined>;
1860
1862
  readonly cut_by: v.NullableSchema<v.PicklistSchema<["limit", "bytes"], undefined>, undefined>;
1861
1863
  readonly selection: v.LiteralSchema<"written by you, about them", undefined>;
1864
+ readonly scopes: v.ArraySchema<v.PicklistSchema<["personal", "work"], undefined>, undefined>;
1862
1865
  readonly withheld: v.OptionalSchema<v.LiteralSchema<"contacts.notes.list", undefined>, undefined>;
1863
1866
  }, undefined>;
1864
1867
  readonly meetings: v.StrictObjectSchema<{
@@ -139,6 +139,7 @@ export const meetingCue = v.strictObject({
139
139
  text,
140
140
  revision: v.picklist(["current", "superseded"]),
141
141
  });
142
+ const scopes = v.array(v.picklist(["personal", "work"]));
142
143
  export const contactPreparation = v.strictObject({
143
144
  ...context.entries,
144
145
  prepare: v.strictObject({
@@ -183,14 +184,17 @@ export const contactPreparation = v.strictObject({
183
184
  ...coverage.entries,
184
185
  selection: v.literal("open, assigned to them in any role"),
185
186
  accounts: v.array(text),
187
+ scopes,
186
188
  }),
187
189
  facts: v.strictObject({
188
190
  ...coverage.entries,
189
191
  selection: v.literal("accepted, about them or a project they are a member of"),
192
+ scopes,
190
193
  }),
191
194
  notes: v.strictObject({
192
195
  ...coverage.entries,
193
196
  selection: v.literal("written by you, about them"),
197
+ scopes,
194
198
  withheld: v.optional(v.literal("contacts.notes.list")),
195
199
  }),
196
200
  meetings: v.strictObject({
@@ -23,8 +23,8 @@ export declare const hit: v.StrictObjectSchema<{
23
23
  readonly found_by: v.OptionalSchema<v.ArraySchema<v.PicklistSchema<["title", "words", "meaning"], undefined>, undefined>, undefined>;
24
24
  /** How far into the meeting the passage is. */
25
25
  readonly offset_ms: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>, undefined>;
26
- /** A meeting passage's place: its transcript, chat or summary. */
27
- readonly scope: v.OptionalSchema<v.PicklistSchema<["transcript", "chat", "summary"], undefined>, undefined>;
26
+ /** A meeting hit's place: its title, transcript, chat or summary. */
27
+ readonly scope: v.OptionalSchema<v.PicklistSchema<["title", "transcript", "chat", "summary"], undefined>, undefined>;
28
28
  /** A meeting transcript hit's cue, which `meetings passage` opens with the lines around it. */
29
29
  readonly cue_ref: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
30
30
  /** A meeting transcript hit's transcript language (`ru`, `en`…), `null` when unknown. */
@@ -32,6 +32,13 @@ export declare const hit: v.StrictObjectSchema<{
32
32
  /** A meeting transcript hit's line, from 1, of `lines_total` lines in its transcript. */
33
33
  readonly line: v.OptionalSchema<v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, v.MinValueAction<number, 1, undefined>]>, undefined>;
34
34
  readonly lines_total: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
35
+ /** `corrected`: a meeting hit found only through a spelling speech recognition may have garbled. */
36
+ readonly match: v.OptionalSchema<v.PicklistSchema<["corrected"], undefined>, undefined>;
37
+ /** For a `corrected` hit, the stored words each such query word matched. */
38
+ readonly corrections: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
39
+ readonly from: v.StringSchema<undefined>;
40
+ readonly to: v.ArraySchema<v.StringSchema<undefined>, undefined>;
41
+ }, undefined>, undefined>, undefined>;
35
42
  /** A meeting passage's stored line, so two passages of one meeting stay apart; `search meetings` gives the same. */
36
43
  readonly id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
37
44
  /** A business hit's: `proposed` waits for the owner; a product or a wallet has no review and is `confirmed`. */
@@ -26,8 +26,8 @@ export const hit = v.strictObject({
26
26
  found_by: v.optional(v.array(v.picklist(["title", "words", "meaning"]))),
27
27
  /** How far into the meeting the passage is. */
28
28
  offset_ms: v.optional(v.nullable(count)),
29
- /** A meeting passage's place: its transcript, chat or summary. */
30
- scope: v.optional(v.picklist(["transcript", "chat", "summary"])),
29
+ /** A meeting hit's place: its title, transcript, chat or summary. */
30
+ scope: v.optional(v.picklist(["title", "transcript", "chat", "summary"])),
31
31
  /** A meeting transcript hit's cue, which `meetings passage` opens with the lines around it. */
32
32
  cue_ref: v.optional(reference),
33
33
  /** A meeting transcript hit's transcript language (`ru`, `en`…), `null` when unknown. */
@@ -35,6 +35,10 @@ export const hit = v.strictObject({
35
35
  /** A meeting transcript hit's line, from 1, of `lines_total` lines in its transcript. */
36
36
  line: v.optional(v.pipe(count, v.minValue(1))),
37
37
  lines_total: v.optional(count),
38
+ /** `corrected`: a meeting hit found only through a spelling speech recognition may have garbled. */
39
+ match: v.optional(v.picklist(["corrected"])),
40
+ /** For a `corrected` hit, the stored words each such query word matched. */
41
+ corrections: v.optional(v.array(v.strictObject({ from: text, to: v.array(text) }))),
38
42
  /** A meeting passage's stored line, so two passages of one meeting stay apart; `search meetings` gives the same. */
39
43
  id: v.optional(v.pipe(v.string(), v.minLength(1))),
40
44
  /** A business hit's: `proposed` waits for the owner; a product or a wallet has no review and is `confirmed`. */
@@ -3721,18 +3721,21 @@ export declare const ENTITIES: {
3721
3721
  readonly cut_by: v.NullableSchema<v.PicklistSchema<["limit", "bytes"], undefined>, undefined>;
3722
3722
  readonly selection: v.LiteralSchema<"open, assigned to them in any role", undefined>;
3723
3723
  readonly accounts: v.ArraySchema<v.StringSchema<undefined>, undefined>;
3724
+ readonly scopes: v.ArraySchema<v.PicklistSchema<["personal", "work"], undefined>, undefined>;
3724
3725
  }, undefined>;
3725
3726
  readonly facts: v.StrictObjectSchema<{
3726
3727
  readonly included: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
3727
3728
  readonly has_more: v.BooleanSchema<undefined>;
3728
3729
  readonly cut_by: v.NullableSchema<v.PicklistSchema<["limit", "bytes"], undefined>, undefined>;
3729
3730
  readonly selection: v.LiteralSchema<"accepted, about them or a project they are a member of", undefined>;
3731
+ readonly scopes: v.ArraySchema<v.PicklistSchema<["personal", "work"], undefined>, undefined>;
3730
3732
  }, undefined>;
3731
3733
  readonly notes: v.StrictObjectSchema<{
3732
3734
  readonly included: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
3733
3735
  readonly has_more: v.BooleanSchema<undefined>;
3734
3736
  readonly cut_by: v.NullableSchema<v.PicklistSchema<["limit", "bytes"], undefined>, undefined>;
3735
3737
  readonly selection: v.LiteralSchema<"written by you, about them", undefined>;
3738
+ readonly scopes: v.ArraySchema<v.PicklistSchema<["personal", "work"], undefined>, undefined>;
3736
3739
  readonly withheld: v.OptionalSchema<v.LiteralSchema<"contacts.notes.list", undefined>, undefined>;
3737
3740
  }, undefined>;
3738
3741
  readonly meetings: v.StrictObjectSchema<{
@@ -4314,11 +4317,16 @@ export declare const ENTITIES: {
4314
4317
  readonly sender_ref: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>, undefined>;
4315
4318
  readonly found_by: v.OptionalSchema<v.ArraySchema<v.PicklistSchema<["title", "words", "meaning"], undefined>, undefined>, undefined>;
4316
4319
  readonly offset_ms: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>, undefined>;
4317
- readonly scope: v.OptionalSchema<v.PicklistSchema<["transcript", "chat", "summary"], undefined>, undefined>;
4320
+ readonly scope: v.OptionalSchema<v.PicklistSchema<["title", "transcript", "chat", "summary"], undefined>, undefined>;
4318
4321
  readonly cue_ref: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
4319
4322
  readonly language: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
4320
4323
  readonly line: v.OptionalSchema<v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, v.MinValueAction<number, 1, undefined>]>, undefined>;
4321
4324
  readonly lines_total: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
4325
+ readonly match: v.OptionalSchema<v.PicklistSchema<["corrected"], undefined>, undefined>;
4326
+ readonly corrections: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
4327
+ readonly from: v.StringSchema<undefined>;
4328
+ readonly to: v.ArraySchema<v.StringSchema<undefined>, undefined>;
4329
+ }, undefined>, undefined>, undefined>;
4322
4330
  readonly id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
4323
4331
  readonly review: v.OptionalSchema<v.PicklistSchema<["proposed", "confirmed"], undefined>, undefined>;
4324
4332
  readonly source_record: v.OptionalSchema<v.StrictObjectSchema<{
@@ -59,6 +59,7 @@ const PROVIDER_API = [
59
59
  const OTHERS = [
60
60
  ["query.time-limit", "timeout", "the search took longer than its time limit; the query itself is valid"],
61
61
  ["enrichment.owner-only", "permission_error", "only the owner turns enrichment on, not an agent"],
62
+ ["search-harder.owner-only", "permission_error", "only the owner allows search all --harder, not an agent"],
62
63
  ["model.offline", "permission_error", "downloading a model needs the network; --offline was requested"],
63
64
  ["model.key-rejected", "invalid_response", "the model provider refused the API key (401 or 403)"],
64
65
  ["model.unreachable", "invalid_response", "the model provider could not be reached over the network"],
@@ -395,6 +396,7 @@ const OTHERS = [
395
396
  validation("output.unknown-field", "the answer has no field by that name"),
396
397
  validation("name.taken", "the name is already used"),
397
398
  validation("period.ambiguous", "the period can be read more than one way"),
399
+ ["press.owner-hand-only", "permission_error", "this button decides something for the owner; only a hand presses it"],
398
400
  validation("proposal.wrong-state", "the proposal is not in a state that allows this"),
399
401
  validation("proposal.reason-required", "an agent deciding for the owner, or proposing a link, gives a reason"),
400
402
  validation("decision.request-invalid", "a decision request needs its batch, message, owner and distinct known actions"),
@@ -11,7 +11,7 @@ export declare const MEETING_FIELD_NAMES: ReadonlySet<string>;
11
11
  * joined to the words with AND and given once, in the query or as an option. Text the language refuses is left as
12
12
  * typed, for the caller's own error or for a search by meaning.
13
13
  */
14
- export declare const liftMeetingFields: (query: string, request: MeetingHitSearchRequest, now?: number) => {
14
+ export declare const liftMeetingFields: (query: string, request: MeetingHitSearchRequest, now?: number, timezone?: string) => {
15
15
  query: string;
16
16
  request: MeetingHitSearchRequest;
17
17
  };
@@ -71,7 +71,7 @@ export const MEETING_FIELD_NAMES = new Set(MEETING_FIELDS.fields.map(({ name })
71
71
  * joined to the words with AND and given once, in the query or as an option. Text the language refuses is left as
72
72
  * typed, for the caller's own error or for a search by meaning.
73
73
  */
74
- export const liftMeetingFields = (query, request, now) => {
74
+ export const liftMeetingFields = (query, request, now, timezone) => {
75
75
  let ast;
76
76
  try {
77
77
  ast = validateQuery(parseLucene(query, { defaultField: "text", proximity: true, ...context }), MEETING_FIELDS, context);
@@ -103,7 +103,7 @@ export const liftMeetingFields = (query, request, now) => {
103
103
  if (node.field === "date") {
104
104
  once("since", "--since-time");
105
105
  once("until", "--until-time");
106
- const range = dateRange(node.value, node.operator === "range" ? (node.upper ?? "*") : node.value, node.lower_inclusive !== false, node.upper_inclusive !== false, timezoneOf(), node.span, now);
106
+ const range = dateRange(node.value, node.operator === "range" ? (node.upper ?? "*") : node.value, node.lower_inclusive !== false, node.upper_inclusive !== false, timezoneOf(timezone), node.span, now);
107
107
  if (range.lower !== undefined)
108
108
  next.since = range.lower + (range.lower_inclusive ? 0 : 1);
109
109
  if (range.upper !== undefined)
@@ -53,6 +53,7 @@ export { validateMeetingSeriesInventoryCursor } from "./series-inventory-validat
53
53
  export type { MeetingSource, SourceParticipant } from "./source.js";
54
54
  export { aggregateMeetingCounts, aggregateMeetingStats, MEETING_COUNTS_GROUPINGS, type MeetingCounts, type MeetingCountsGrouping, type MeetingCountsInput, type MeetingCountsMeeting, type MeetingCountsRow, type MeetingSpeakerStats, type MeetingStats, type MeetingStatsInput, type MeetingStatsRow, type MeetingStatsSelection, type MeetingStatsStore, type MeetingWeekStats, NO_SERIES, } from "./stats.js";
55
55
  export type { ChatInput, ContractCase, EventCandidateFilter, IdentityInput, MeetingDetails, MeetingFilter, MeetingHitSource, MeetingInput, MeetingSave, MeetingStore, NewRecord, ParticipantInput, SearchHit, TranscriptInput, TranscriptLanguageFill, TranscriptRowInput, } from "./store.js";
56
+ export { READ_BUDGET_EXCEEDED } from "./store.js";
56
57
  export { meetingTimestamp } from "./timestamp.js";
57
58
  export type { MeetingTranscriptReceiptStore, MeetingTranscriptStore, TranscriptAppend, TranscriptAppendReceipt, UnlinkedTranscriptInput, } from "./transcript-store.js";
58
59
  export { parseTranscriptText, TranscriptTextError, type TranscriptTextHeader } from "./transcript-text.js";
@@ -39,6 +39,7 @@ export { validateMeetingSeriesHistory, } from "./series-history.js";
39
39
  export { createMeetingSeriesInventoryReader } from "./series-inventory.js";
40
40
  export { validateMeetingSeriesInventoryCursor } from "./series-inventory-validation.js";
41
41
  export { aggregateMeetingCounts, aggregateMeetingStats, MEETING_COUNTS_GROUPINGS, NO_SERIES, } from "./stats.js";
42
+ export { READ_BUDGET_EXCEEDED } from "./store.js";
42
43
  export { meetingTimestamp } from "./timestamp.js";
43
44
  export { parseTranscriptText, TranscriptTextError } from "./transcript-text.js";
44
45
  export { transcribeMeeting, } from "./transcription.js";
@@ -79,6 +79,8 @@ export interface MeetingHitSource {
79
79
  /** A stored source-document permalink, never a meeting join or signed download URL. */
80
80
  url: string | null;
81
81
  }
82
+ /** `searchHits`' refusal of a page whose stored text passes `maxReadBytes`; a reader may ask for fewer rows. */
83
+ export declare const READ_BUDGET_EXCEEDED = "Meeting search exceeds its stored text byte budget";
82
84
  export interface SearchHit {
83
85
  source?: MeetingHitSource;
84
86
  /** A retained cue reference for transcript hits, or the parent meeting for other sources. */
@@ -102,6 +104,8 @@ export interface SearchHit {
102
104
  from: string;
103
105
  to: string[];
104
106
  }[];
107
+ /** The words of `text` the query's positive terms matched, as the text spells them. */
108
+ matchedWords?: string[];
105
109
  }
106
110
  export interface ContractCase {
107
111
  name: string;
@@ -1 +1,2 @@
1
- export {};
1
+ /** `searchHits`' refusal of a page whose stored text passes `maxReadBytes`; a reader may ask for fewer rows. */
2
+ export const READ_BUDGET_EXCEEDED = "Meeting search exceeds its stored text byte budget";
@@ -5,6 +5,11 @@ import { messagesFor, systemFor } from "./types.js";
5
5
  // API version 2026-10-21 refuses temperature, top_p and top_k on every model.
6
6
  const options = v.strictObject({
7
7
  stop_sequences: v.optional(v.array(v.string())),
8
+ thinking: v.optional(v.strictObject({ type: v.picklist(["disabled", "adaptive"]) })),
9
+ output_config: v.optional(v.strictObject({
10
+ effort: v.optional(v.picklist(["low", "medium", "high"])),
11
+ format: v.optional(v.strictObject({ type: v.literal("json_schema"), schema: v.record(v.string(), v.unknown()) })),
12
+ })),
8
13
  });
9
14
  export const anthropic = {
10
15
  images: true,
@@ -0,0 +1,10 @@
1
+ /** The time a question asks about, as epoch ms: `from` is the start of its first local day, `to` of the day after it. */
2
+ export interface Period {
3
+ from: number;
4
+ to: number;
5
+ }
6
+ /**
7
+ * The period a question names — a date, a month, "last week", «в прошлом месяце» — from the first day any phrase names
8
+ * to the last; undefined when it names none. Read as `zone`'s calendar on `now`.
9
+ */
10
+ export declare const questionPeriod: (text: string, now: number, zone: string) => Period | undefined;