@wirecat/cli-core 0.663.0 → 0.664.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 (97) hide show
  1. package/CHANGELOG.md +125 -0
  2. package/dist/background/daily-archive-timer.d.ts +1 -1
  3. package/dist/cli/chat-sending-command.d.ts +14 -0
  4. package/dist/cli/chat-sending-command.js +64 -0
  5. package/dist/cli/context.d.ts +7 -0
  6. package/dist/cli/context.js +12 -4
  7. package/dist/cli/index.d.ts +2 -0
  8. package/dist/cli/index.js +2 -0
  9. package/dist/cli/meeting-meaning-command.d.ts +47 -0
  10. package/dist/cli/meeting-meaning-command.js +136 -0
  11. package/dist/cli/meeting-preparation-answer.d.ts +6 -0
  12. package/dist/cli/meeting-preparation-projects.d.ts +6 -0
  13. package/dist/cli/meeting-preparation-read.d.ts +6 -0
  14. package/dist/cli/meeting-tags-command.d.ts +18 -0
  15. package/dist/cli/meeting-tags-command.js +74 -0
  16. package/dist/cli/messenger/conversation-answers.d.ts +1 -1
  17. package/dist/cli/messenger/conversation-answers.js +1 -0
  18. package/dist/cli/messenger/conversations-command.js +38 -12
  19. package/dist/cli/messenger/models-command.js +7 -0
  20. package/dist/cli/messenger/records-command.d.ts +4 -1
  21. package/dist/cli/messenger/records-command.js +6 -1
  22. package/dist/cli/model-catalogue-command.js +2 -0
  23. package/dist/cli/profile-token.d.ts +15 -1
  24. package/dist/cli/profile-token.js +103 -7
  25. package/dist/cli/program.js +2 -2
  26. package/dist/domain/links.d.ts +11 -0
  27. package/dist/domain/links.js +4 -0
  28. package/dist/entities/chat-sending.d.ts +10 -0
  29. package/dist/entities/chat-sending.js +11 -0
  30. package/dist/entities/index.d.ts +43 -1
  31. package/dist/entities/index.js +6 -2
  32. package/dist/entities/meeting-preparation.d.ts +6 -0
  33. package/dist/entities/meeting.d.ts +1 -1
  34. package/dist/entities/meeting.js +1 -1
  35. package/dist/errors/reasons.js +25 -1
  36. package/dist/mcp/meeting-preparation.d.ts +6 -0
  37. package/dist/meetings/answers.d.ts +7 -0
  38. package/dist/meetings/answers.js +4 -0
  39. package/dist/meetings/index.d.ts +1 -0
  40. package/dist/meetings/index.js +1 -0
  41. package/dist/meetings/mcp/search.d.ts +6 -0
  42. package/dist/meetings/project-evidence-answer.d.ts +6 -0
  43. package/dist/meetings/tag-answers.d.ts +43 -0
  44. package/dist/meetings/tag-answers.js +41 -0
  45. package/dist/models/chat-sending.d.ts +24 -0
  46. package/dist/models/chat-sending.js +40 -0
  47. package/dist/runs/events.d.ts +1 -1
  48. package/dist/search/question-plan.d.ts +2 -0
  49. package/dist/search/question-plan.js +2 -0
  50. package/dist/search/task-similarity.d.ts +1 -0
  51. package/dist/search/task-similarity.js +1 -1
  52. package/dist/services/embeddings-search.js +19 -5
  53. package/dist/services/embeddings.d.ts +4 -0
  54. package/dist/services/index.d.ts +2 -0
  55. package/dist/services/index.js +2 -0
  56. package/dist/services/meeting-meaning.d.ts +47 -0
  57. package/dist/services/meeting-meaning.js +158 -0
  58. package/dist/services/meeting-tags.d.ts +27 -0
  59. package/dist/services/meeting-tags.js +81 -0
  60. package/dist/services/messages-discovery.js +2 -2
  61. package/dist/sftp/index.d.ts +1 -1
  62. package/dist/sftp/index.js +1 -1
  63. package/dist/sftp/session.d.ts +30 -4
  64. package/dist/sftp/session.js +195 -11
  65. package/dist/sftp/ssh2.d.ts +19 -4
  66. package/dist/sftp/ssh2.js +144 -17
  67. package/dist/speech/cloud.d.ts +47 -0
  68. package/dist/speech/cloud.js +73 -0
  69. package/dist/speech/decode.d.ts +36 -9
  70. package/dist/speech/decode.js +208 -61
  71. package/dist/speech/index.d.ts +2 -1
  72. package/dist/speech/index.js +2 -1
  73. package/dist/speech/openai.d.ts +4 -0
  74. package/dist/speech/openai.js +13 -12
  75. package/dist/sql/index.d.ts +1 -0
  76. package/dist/sql/index.js +1 -0
  77. package/dist/sql/reader.d.ts +95 -0
  78. package/dist/sql/reader.js +214 -0
  79. package/dist/store/sqlite/drizzle/bun.js +4 -4
  80. package/dist/store/sqlite/drizzle/bun.js.map +1 -1
  81. package/dist/store/sqlite/drizzle/core.js +5 -5
  82. package/dist/store/sqlite/drizzle/core.js.map +1 -1
  83. package/dist/store/sqlite/drizzle/node.js +4 -4
  84. package/dist/store/sqlite/drizzle/node.js.map +1 -1
  85. package/dist/store/sqlite/drizzle/{shared-55XJMTPA.js → shared-5XR7K42U.js} +58 -58
  86. package/dist/store/sqlite/drizzle/{shared-55XJMTPA.js.map → shared-5XR7K42U.js.map} +1 -1
  87. package/dist/store/sqlite/knowledge.d.ts +1 -1
  88. package/dist/store/sqlite/knowledge.js +8 -4
  89. package/dist/store/sqlite/labelled.d.ts +5 -0
  90. package/dist/store/sqlite/labelled.js +6 -0
  91. package/dist/store/sqlite/link-row.d.ts +1 -0
  92. package/dist/store/sqlite/link-row.js +2 -0
  93. package/dist/store/sqlite/notes.d.ts +1 -1
  94. package/dist/store/sqlite/notes.js +1 -1
  95. package/package.json +18 -3
  96. package/parity.json +20 -1
  97. package/skills/link-conversations/SKILL.md +1 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,131 @@ 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.664.0 — 14.11.2026
9
+
10
+ ### Added
11
+
12
+ - **Tags on calls and other meetings, from a search: `addMeetingTagsCommand`** in `@wirecat/cli-core/cli` mounts
13
+ `tags add|remove|list` for a host whose meetings are its records, such as pbx and beeline.
14
+ `tags add complaint --matching "refund OR complaint"` labels every meeting of the account where `search meetings`
15
+ finds the query; `--meeting <id>` (repeatable) labels by id. A rerun after new calls are transcribed labels only
16
+ those, and `changed` in the `meeting_tag_change` answer says which. `tags list tag:complaint` answers
17
+ `meeting_tagging` items with the call's title marked untrusted. The labels are the store's ordinary taggings, so
18
+ `search meetings --tag complaint` and memo's `tags list` see them. The service is `meetingTags` in
19
+ `@wirecat/cli-core/services`. A mark stays when a new transcript of the call no longer says the words.
20
+ - cli-core's command lint now also checks a calls host's program: `stats calls show`, `search meetings` and the
21
+ meeting `tags`, with cli-base's `calls`, `--matching` and `--tag`.
22
+ - **Search by meaning for any host of stored meetings, from cli-core.** `addMeetingCombinedSearchCommand` in
23
+ `@wirecat/cli-core/cli` mounts `search meetings`: words by default, and words and meaning ranked together with
24
+ `--model <model>`, which first splits new transcripts and builds the missing vectors. A hit says how it was found
25
+ (`by`), its similarity (`score`) and the passage meaning matched, and marks `excerpt`, the passage and the title
26
+ untrusted. `addMeetingEmbeddingCommand` mounts `meetings embed`: a preview, and `--yes` splits every transcript and builds one batch of the missing
27
+ vectors; a rerun builds the next.
28
+ Without `--model` it uses the `models` command's default local text model, so the transcripts stay on this
29
+ computer; `--base-url` sends passages to a remote service only when given, and `--offline` refuses it. Both run over
30
+ `meetingMeaning(store, accountId)` in `@wirecat/cli-core/services`. These moved from zoom-cli, which can mount them
31
+ in place of its own copies; pbx and beeline mount them for calls.
32
+ - `meeting_hit` takes the optional `by`, `score` and `passage` of a search by meaning.
33
+ - **A profile can keep a second secret, in its one keyring entry.** `ProfileTokenStore` takes named secrets beside
34
+ the token: `writeSecret(profile, "ssh", secret)`, `readSecret(profile, "ssh")` and `removeSecret(profile, "ssh")`,
35
+ so a CLI can keep a database password and an SSH or SFTP password for one profile. They live in the same
36
+ `token:<profile>` entry as one value, as an OAuth entry holds its tokens and client secret: the keyring gets no
37
+ second entry (WC-SECR-4). An entry with only the token stays the plain value it was, so every entry written before
38
+ reads as before. `<PREFIX>_TOKEN_<NAME>` (`secretVariable(name)`) overrides one for CI, as `<PREFIX>_TOKEN` does the
39
+ token. Changing the token keeps the named secrets and the other way round; `remove` still forgets the whole entry,
40
+ as `session end` wants. A run with moved folders writes them to its temporary entry and never touches the owner's
41
+ (WC-SECR-24).
42
+ - **A link can open a call or meeting in WireCat Desktop.** `linkFor({ type: "meeting", provider, account, meeting })`
43
+ builds `wirecat://open/v1/meeting/<provider>/<account>/<meeting>` (or the web form) from the provider's own ids, as
44
+ a message link does: `asterisk`, the account as the provider knows it, and the call's id there. It is built only
45
+ from that target: `meeting:<account>/<meeting>` stays a store reference and never becomes a link.
46
+ `test/fixtures/links-v1.json` has the cases under `target_only`, since no ref names them, and two refused paths.
47
+ - **`readStream` on the SFTP client reads a file of any size in pieces.** It gives the file in order, 64 KiB at a
48
+ time with about a megabyte read ahead, so a Master.csv of gigabytes or a recording for ffmpeg is never held whole.
49
+ `maxBytes` is optional. A connection that breaks halfway is opened again and the read goes on where it stopped,
50
+ once the bytes just before that point read the same; a file replaced meanwhile is refused (`sftp.file-changed`).
51
+ Host-key pinning and the read-only rules are the same as for `readFile`. Each attempt is an `sftp.stream` event.
52
+ See [SFTP](docs/sftp.md#read).
53
+ - **`openSshTunnel` reaches a database that listens only on its own server** (a FreePBX CDR database) with no
54
+ `ssh -L` by hand. It signs in with the pinned host key, only forwards (no shell, no command, no SFTP), and opens no
55
+ port on this computer: `connect(host, port)` answers a stream shaped as a socket, which `pg` and `mysql2` take as
56
+ their `stream`. `close()` ends it at the end of the run. Its events are `ssh.connect` and `ssh.forward`
57
+ (`transport: "ssh"`), with no forwarded address. See
58
+ [SFTP, "A tunnel to a database behind the server"](docs/sftp.md#a-tunnel-to-a-database-behind-the-server).
59
+ - **`@wirecat/cli-core/sql`: a read-only MySQL, MariaDB and PostgreSQL reader for a host's own table.**
60
+ `openSqlReader` opens a read-only session with TLS checked and connect and query timeouts, keeps a time without a
61
+ zone as its text, reads in pages by the last row's key (or by offset), checks every name as an identifier and
62
+ sends every value as a parameter, takes a tunnel's stream as `socket`, and maps driver errors to reasons without
63
+ their text (`db.refused`, `db.no-table`, `db.no-select`, `db.read-only`…; `sqlFailure` for a host's own code).
64
+ `mysql2` and `pg` are optional peers, loaded on first use. It is the generic half of pbx's CDR reader; the
65
+ schema mapping stays in pbx. See [SQL](docs/sql.md).
66
+ - **Recordings that ffmpeg reads keep their channels.** `decodeChannels` gives a stereo WAV, GSM, AAC or M4A call
67
+ two channels, one speaker each, as it already did for MP3, Ogg and FLAC. A mono file stays one channel, and a file
68
+ of more channels is mixed down to two. Each channel still stops at an hour of audio, and ffmpeg's output is split
69
+ into channels as it arrives, so the interleaved samples are never held whole. `decodeChannelsFile(path, { maxBytes })`
70
+ hands a WAV or GSM file to ffmpeg by its path, so a recording of gigabytes is not read into memory first;
71
+ `runFfmpegFile(path)` is the step under it, and `mixDown` averages channels into one.
72
+ - **`cloudSpeech` lets a host send a profile's recordings to an OpenAI-compatible speech-to-text, when that profile
73
+ asks.** It is `null` unless the profile's own settings say `transcribeWith: "openai"`. The audio goes to OpenAI, or
74
+ to the address the shared AI model is set to (`models ai set openai --base-url … --secret-stdin`), with the key
75
+ kept for that address. The model is the profile's `transcribeModel` (`gpt-transcribe` when not set). The host's
76
+ `notify` gets one line naming the host before the first audio leaves the computer. It refuses in a read-only
77
+ process, with local only on, and without a key (`transcription.no-key`, naming the command that sets it). Long
78
+ audio goes in pieces of at most ten minutes, under the provider's 25 MB limit. See
79
+ [MEETING-PROVIDERS.md, "Decoding a recording, and cloud speech"](docs/dev/MEETING-PROVIDERS.md#decoding-a-recording-and-cloud-speech).
80
+ - `transcribeOpenAI` takes `label` and `keyHint`, so a compatible service's errors name that service and the command
81
+ that sets its key, not OpenAI. A compatible server on this computer needs no key.
82
+ - **`models chats show|set allowed|ask|denied`: one setting for chat text sent to a model outside this
83
+ computer.** It decides what `conversations embed` and `conversations links rebuild --analyze` do with a model that
84
+ is not on this computer. `allowed` sends without a yes, in a terminal and over MCP. `ask`, the default, needs a yes
85
+ as before. `denied` refuses. The setting is shared by every WireCat tool. Messenger CLIs mount it under `models`,
86
+ and so does the model catalogue for the tool that turns on enrichment. Only the owner makes it less strict: `set`
87
+ is no MCP tool, and an agent's run is refused unless it passes `--from-app`.
88
+ - **`conversations embed` and `conversations links rebuild` take their own `--yes`**, so an agent can pass `yes`
89
+ over MCP under `ask`. Before, they read only the root program's `--yes`, which a tool call cannot pass, so an
90
+ agent got `confirmation_required … add --yes` and could not go on.
91
+
92
+ ### Changed — may break callers
93
+
94
+ - **`SftpClient` has `readStream`.** A fake typed as `SftpClient` in a host's tests adds it.
95
+ - **No MCP server offers `chats delete` or `chats clear`.** Over MCP an `ask` level goes ahead without a question, so
96
+ an agent could delete a whole chat or its history from the account. Both stay on the command line, where `ask` still
97
+ asks first.
98
+ - **`Ffmpeg` (the seam of `decodeChannels` and `decodeAudio`) may answer `Pcm[]`, one per channel,** and `runFfmpeg`
99
+ now does. A seam that still answers one `Pcm` works, and `decodeChannels` then says `mixed: true`. `mixed` is no
100
+ longer true for every file ffmpeg read.
101
+ - **`decodeAudio` mixes every channel into one,** where it gave the first channel of a stereo MP3, Ogg or FLAC. A
102
+ stereo voice message or audio file now keeps both sides in its one text.
103
+ - **Under `models chats denied`, `conversations embed` and `--analyze` to a model outside this computer refuse even
104
+ with `--yes`** and even with a consent remembered for the chat: `permission_error`, reason `chat-sending.denied`.
105
+ The message names the owner's command, `<cli> models chats set ask`. Without the setting nothing changes.
106
+ - **`--analyze` with a model on this computer no longer asks for consent or remembers one**, the same as
107
+ `conversations embed` with a local model. A caller that expected `confirmation_required` there now gets the
108
+ analysis.
109
+ - **The refusal under `ask` without a yes** now has reason `chat-sending.ask`, and its message says an agent may
110
+ pass yes or ask the owner to run `<cli> models chats set allowed`.
111
+
112
+ ### Fixed
113
+
114
+ - **`knowledge.labelled` with an account lists only that account's meetings, and never a deleted meeting.** With
115
+ `null`, as memo calls it, it still lists every account's meetings, now without the deleted ones.
116
+ - cli-base 0.101.0, whose vocabulary has `calls`, `--matching` and `--tag`; the peer range moves to it.
117
+ - **A command's own `--fields` is no longer read as `--json`'s field list.** A generated Google API command such as
118
+ `gcal <profile> api calendar-events-list --fields 'items(id)' --json` failed with "--json takes comma-separated field
119
+ paths", because the command's `--fields` (Google's partial-response mask) stood in for the root's. Only
120
+ `--json=a,b` now picks the answer's fields, in `outputFor`, `baseContext` and the program's own output.
121
+ - **A project's status no longer crashes on a link whose chat was deleted.** `knowledge.relations` leaves out a link
122
+ whose start or end no longer exists, such as a `member-of` link from a chat the store has since removed. Before,
123
+ it returned the link with `from: null`, and `projectStatus` failed on it, so memo's `review agenda` and the morning
124
+ digest stopped with `command.crashed`.
125
+ - `search conversations` no longer fails on a long sentence over a large store: when the word half runs out of time,
126
+ the meaning half still answers, and the answer says so (`meta.words: "out-of-time"`, a note in pretty output).
127
+ Stop words (`что`, `какие`, `what`, `the`…) no longer go into the word half, unless the query holds nothing else.
128
+ - `search conversations` follows an explicit `--timeout`, as `search messages` does: the word half gets the longer
129
+ time limit.
130
+ - `search messages --discover` finds a name written as one word when the question spells it with a hyphen
131
+ (`Альфа-банк` finds `АльфаБанк`).
132
+
8
133
  ## 0.663.0 — 14.11.2026
9
134
 
10
135
  ### Added
@@ -24,12 +24,12 @@ export interface DailyArchiveTimerInput {
24
24
  }
25
25
  export declare const dailyArchiveTimer: (input: DailyArchiveTimerInput) => DailyArchiveTimer;
26
26
  export declare const manageDailyArchiveTimer: (plan: DailyArchiveTimer, action: "install" | "start" | "stop" | "status" | "uninstall", system: Pick<ServerSystem, "platform" | "run">, env: NodeJS.ProcessEnv, signal?: AbortSignal) => Promise<{
27
- action?: undefined;
28
27
  name: string;
29
28
  installed: boolean;
30
29
  active: boolean;
31
30
  servicePath: string;
32
31
  timerPath: string;
32
+ action?: undefined;
33
33
  } | {
34
34
  active?: undefined;
35
35
  name: string;
@@ -0,0 +1,14 @@
1
+ import { Command } from "commander";
2
+ import type { AppIdentity } from "../ports/app.js";
3
+ import { type Body } from "./envelope.js";
4
+ export interface ChatSendingCommandOptions {
5
+ env: (command: Command) => NodeJS.ProcessEnv;
6
+ output: (answer: Body, command: Command) => void;
7
+ /** The command line as the owner types it, such as `tg personal`; the app's command when absent. */
8
+ tool?: (command: Command) => string;
9
+ }
10
+ /**
11
+ * `models chats`: whether `conversations embed` and `conversations links rebuild --analyze` may send chat text
12
+ * to a model outside this computer. One setting for every WireCat tool; a model on this computer is not affected.
13
+ */
14
+ export declare const chatSendingCommand: (app: AppIdentity, options: ChatSendingCommandOptions) => Command;
@@ -0,0 +1,64 @@
1
+ import { CliError } from "@wirecat/cli-base";
2
+ import { annotate } from "@wirecat/cli-base/commands";
3
+ import { Command } from "commander";
4
+ import { CHAT_SENDING_MODES, chatSendingMode, loosens, readChatSending, writeChatSending, } from "../models/chat-sending.js";
5
+ import { agentOf } from "../runs/run-context.js";
6
+ import { environmentOf } from "./context.js";
7
+ import { grantsAuthority, LOCAL_READ, LOCAL_WRITE } from "./effects.js";
8
+ import { itemOf } from "./envelope.js";
9
+ const MEANING = {
10
+ allowed: "chat text goes to a model outside this computer without a yes, in a terminal and over MCP",
11
+ ask: "each send to a model outside this computer needs a yes: --yes, which an agent may pass",
12
+ denied: "chat text never goes to a model outside this computer, even with --yes",
13
+ };
14
+ const view = (env) => {
15
+ const mode = chatSendingMode(env);
16
+ return { mode, meaning: MEANING[mode], since: readChatSending(env)?.at ?? null };
17
+ };
18
+ /**
19
+ * `models chats`: whether `conversations embed` and `conversations links rebuild --analyze` may send chat text
20
+ * to a model outside this computer. One setting for every WireCat tool; a model on this computer is not affected.
21
+ */
22
+ export const chatSendingCommand = (app, options) => {
23
+ const tool = (command) => options.tool?.(command) ?? app.command;
24
+ const sending = annotate(new Command("chats"), { effects: LOCAL_READ }).description("whether chat text may go to a model off this computer: allowed, ask or denied");
25
+ annotate(sending.command("show"), {
26
+ effects: LOCAL_READ,
27
+ output: { entity: "chat_sending" },
28
+ examples: [`${app.command} models chats show`],
29
+ })
30
+ .description("whether chat text may go to a model outside this computer, and since when")
31
+ .action(function () {
32
+ options.output(itemOf(view(options.env(this))), this);
33
+ });
34
+ grantsAuthority(annotate(sending.command("set"), {
35
+ effects: LOCAL_WRITE,
36
+ mcp: false,
37
+ output: { entity: "chat_sending" },
38
+ examples: [
39
+ `${app.command} models chats set allowed`,
40
+ `${app.command} models chats set ask`,
41
+ `${app.command} models chats set denied`,
42
+ ],
43
+ }))
44
+ .summary("allowed, ask (the default) or denied; only you make it less strict")
45
+ .description("allowed: no yes needed; ask: --yes needed, an agent may pass it; denied: refused even with --yes. " +
46
+ "Only you make it less strict")
47
+ .argument("<mode>", "allowed, ask or denied")
48
+ .option("--from-app", "you did this in WireCat Desktop")
49
+ .action(function (given) {
50
+ if (!CHAT_SENDING_MODES.includes(given))
51
+ throw new CliError("validation_error", "say allowed, ask or denied");
52
+ const mode = given;
53
+ const env = options.env(this);
54
+ const before = chatSendingMode(env);
55
+ if (loosens(before, mode) &&
56
+ (environmentOf(this).agent || agentOf(env)) &&
57
+ !this.opts().fromApp)
58
+ throw new CliError("permission_error", `only the owner makes \`models chats\` less strict, not an agent: ask the owner to run \`${tool(this)} models chats set ${mode}\``, { reason: "chat-sending.owner-only" });
59
+ if (before !== mode)
60
+ writeChatSending(env, mode);
61
+ options.output(itemOf({ ...view(env), changed: before !== mode }), this);
62
+ });
63
+ return sending;
64
+ };
@@ -138,6 +138,13 @@ export declare const withAgentLevels: <F extends {
138
138
  * output goes and a test that captures it sees it. `readSecret(prompt, { ...secretInputOf(this), echo: true })`.
139
139
  */
140
140
  export declare const secretInputOf: (command: Command) => Pick<SecretInput, "input" | "output">;
141
+ /**
142
+ * `--json=a,b` sets the root's `fields`. A command may declare a `--fields` of its own (Google's partial-response
143
+ * mask), which `optsWithGlobals` would put in its place.
144
+ */
145
+ export declare const outputFieldsOf: (command: Command) => {
146
+ fields?: string;
147
+ };
141
148
  /** Whether the run asked for one line per item (WC-OUT-24). */
142
149
  export declare const compactOf: (command: Command) => boolean;
143
150
  /** For the commands that print but never need settings or a connection. */
@@ -60,13 +60,23 @@ const detailOf = ({ brief, full }) => {
60
60
  return brief ? { hitDetail: "brief" } : full ? { hitDetail: "full" } : {};
61
61
  };
62
62
  const COMPACT_KEY = new Option(COMPACT_FLAG).attributeName();
63
+ /**
64
+ * `--json=a,b` sets the root's `fields`. A command may declare a `--fields` of its own (Google's partial-response
65
+ * mask), which `optsWithGlobals` would put in its place.
66
+ */
67
+ export const outputFieldsOf = (command) => {
68
+ const fields = rootOf(command).getOptionValue("fields");
69
+ return typeof fields === "string" ? { fields } : {};
70
+ };
63
71
  /** Whether the run asked for one line per item (WC-OUT-24). */
64
72
  export const compactOf = (command) => command.optsWithGlobals()[COMPACT_KEY] === true;
65
73
  /** For the commands that print but never need settings or a connection. */
66
74
  export const outputFor = (command) => {
67
75
  const { streams, tty, env, agent } = environmentOf(command);
76
+ const { fields: _own, ...flags } = command.optsWithGlobals();
68
77
  return resolveOutput({
69
- ...command.optsWithGlobals(),
78
+ ...flags,
79
+ ...outputFieldsOf(command),
70
80
  ...detailOf(command.optsWithGlobals()),
71
81
  compact: compactOf(command),
72
82
  ...(agent ? { capture: agent.result } : {}),
@@ -85,9 +95,7 @@ export const baseContext = (command, resolveSettings) => {
85
95
  env,
86
96
  compact: compactOf(command),
87
97
  ...detailOf(command.optsWithGlobals()),
88
- ...(command.optsWithGlobals().fields
89
- ? { fields: command.optsWithGlobals().fields }
90
- : {}),
98
+ ...outputFieldsOf(command),
91
99
  ...(environment.agent ? { capture: environment.agent.result } : {}),
92
100
  ...(environment.streams ? { streams: environment.streams } : {}),
93
101
  ...(environment.tty === undefined ? {} : { tty: environment.tty }),
@@ -106,11 +106,13 @@ export { answerLocally, type ShownTime, wallClock } from "./local-times.js";
106
106
  export { MCP_HTTP_DEFAULT_PORT, type McpServerOptions, type McpServerTarget, mcpServerCommand, } from "./mcp-server-command.js";
107
107
  export { formatMeetingBatch, prepareMeetingBatch } from "./meeting-batch.js";
108
108
  export { meetingEvidenceItem, meetingPersonContextItem } from "./meeting-evidence-answer.js";
109
+ export { addMeetingCombinedSearchCommand, addMeetingEmbeddingCommand, type MeetingCombinedSearchDeps, type MeetingEmbeddingCommandDeps, type MeetingSearchRun, } from "./meeting-meaning-command.js";
109
110
  export { meetingPreparationAnswer } from "./meeting-preparation-answer.js";
110
111
  export { type MeetingPreparationReader, meetingPreparationInput, readMeetingPreparation, } from "./meeting-preparation-read.js";
111
112
  export { readMeetingProjectCandidates } from "./meeting-project-candidates-read.js";
112
113
  export { meetingResultItem } from "./meeting-results.js";
113
114
  export { type MeetingSeriesInventoryReader, readMeetingSeriesInventory } from "./meeting-series-inventory-read.js";
115
+ export { addMeetingTagsCommand, type MeetingTagsCommandDeps } from "./meeting-tags-command.js";
114
116
  export { accountFileFor, profilesHere, rememberAccount } from "./messenger/accounts.js";
115
117
  export { terminalAsker } from "./messenger/ask.js";
116
118
  export type { CompletionOptions } from "./messenger/complete-command.js";
package/dist/cli/index.js CHANGED
@@ -97,11 +97,13 @@ export { answerLocally, wallClock } from "./local-times.js";
97
97
  export { MCP_HTTP_DEFAULT_PORT, mcpServerCommand, } from "./mcp-server-command.js";
98
98
  export { formatMeetingBatch, prepareMeetingBatch } from "./meeting-batch.js";
99
99
  export { meetingEvidenceItem, meetingPersonContextItem } from "./meeting-evidence-answer.js";
100
+ export { addMeetingCombinedSearchCommand, addMeetingEmbeddingCommand, } from "./meeting-meaning-command.js";
100
101
  export { meetingPreparationAnswer } from "./meeting-preparation-answer.js";
101
102
  export { meetingPreparationInput, readMeetingPreparation, } from "./meeting-preparation-read.js";
102
103
  export { readMeetingProjectCandidates } from "./meeting-project-candidates-read.js";
103
104
  export { meetingResultItem } from "./meeting-results.js";
104
105
  export { readMeetingSeriesInventory } from "./meeting-series-inventory-read.js";
106
+ export { addMeetingTagsCommand } from "./meeting-tags-command.js";
105
107
  export { accountFileFor, profilesHere, rememberAccount } from "./messenger/accounts.js";
106
108
  export { terminalAsker } from "./messenger/ask.js";
107
109
  export { connectFor, messengerContext, } from "./messenger/context.js";
@@ -0,0 +1,47 @@
1
+ import { type Command } from "commander";
2
+ import { type MeetingHitSearch, type MeetingSearchFlags } from "../meetings/cli/index.js";
3
+ import type { MeetingMeaning } from "../services/meeting-meaning.js";
4
+ import { type Body } from "./envelope.js";
5
+ interface MeaningFlags {
6
+ model?: string;
7
+ baseUrl?: string;
8
+ dims?: number;
9
+ maxChunks?: number;
10
+ maxRows?: number;
11
+ maxTextBytes?: number;
12
+ }
13
+ type SearchFlags = MeetingSearchFlags & MeaningFlags;
14
+ export interface MeetingCombinedSearchDeps {
15
+ words: () => Promise<MeetingHitSearch>;
16
+ meaning: () => Promise<MeetingMeaning>;
17
+ signal: () => AbortSignal | undefined;
18
+ /** The page without `--limit`: `pagingOf` from `@wirecat/cli-core/cli`, which reads the profile's limit. */
19
+ pagingOf: (command: Command) => {
20
+ limit: number;
21
+ };
22
+ output: (body: Body, command: Command) => void;
23
+ /** One to three examples that run as written, with the host's command and a profile. */
24
+ examples: string[];
25
+ }
26
+ export type MeetingSearchRun = (query: string, options: SearchFlags, command: Command) => Promise<Body>;
27
+ /**
28
+ * `search meetings` by words, and by words and meaning ranked together with `--model`, for any host of stored
29
+ * meetings. Returns the run, so a host's saved searches replay it.
30
+ */
31
+ export declare const addMeetingCombinedSearchCommand: (program: Command, deps: MeetingCombinedSearchDeps) => MeetingSearchRun;
32
+ export interface MeetingEmbeddingCommandDeps {
33
+ meaning: () => Promise<MeetingMeaning>;
34
+ /** The local model used without `--model`: the `models` command's default text model. */
35
+ defaultModel: () => string;
36
+ signal: () => AbortSignal | undefined;
37
+ output: (body: Body, command: Command) => void;
38
+ /** Where a write's answer goes when the host keeps a receipt of it; `output` otherwise. */
39
+ receipt?: (body: Body, command: Command) => Promise<void>;
40
+ examples: string[];
41
+ }
42
+ /**
43
+ * `meetings embed`: previews the vectors a search by meaning needs, and `--yes` splits every transcript and embeds one
44
+ * batch of the passages without a vector; run it again for the next batch.
45
+ */
46
+ export declare const addMeetingEmbeddingCommand: (program: Command, deps: MeetingEmbeddingCommandDeps) => void;
47
+ export {};
@@ -0,0 +1,136 @@
1
+ import { CliError } from "@wirecat/cli-base";
2
+ import { annotate, overrideSharedContract } from "@wirecat/cli-base/commands";
3
+ import { InvalidArgumentError } from "commander";
4
+ import { createMeetingSearchCommand, meetingHitSearchRequest, meetingSearchArguments, meetingSearchMeta, } from "../meetings/cli/index.js";
5
+ import { meetingHitsList } from "../meetings/index.js";
6
+ import { FETCH } from "./effects.js";
7
+ import { itemOf, listOf } from "./envelope.js";
8
+ const count = (value) => {
9
+ if (!/^[1-9]\d*$/.test(value) || !Number.isSafeInteger(Number(value)))
10
+ throw new InvalidArgumentError("expected a positive integer");
11
+ return Number(value);
12
+ };
13
+ const FLAG = {
14
+ maxReadBytes: "--max-read-bytes",
15
+ baseUrl: "--base-url",
16
+ dims: "--dims",
17
+ maxChunks: "--max-chunks",
18
+ maxRows: "--max-rows",
19
+ maxTextBytes: "--max-text-bytes",
20
+ };
21
+ const refuse = (options, keys, mode) => {
22
+ const given = keys.filter((key) => options[key] !== undefined).map((key) => FLAG[key]);
23
+ if (given.length)
24
+ throw new CliError("validation_error", `${given.join(", ")} do not apply ${mode}`);
25
+ };
26
+ // The root `--offline`: a remote `--base-url` would send the passages out.
27
+ const offline = (command) => command.optsWithGlobals().offline === true;
28
+ /** Combined hits as the list answer: each cites a line, says how it was found, and keeps its passage. */
29
+ const combinedList = (found, limit, args) => listOf("search meetings", {
30
+ items: found.items.map((hit) => ({
31
+ ref: hit.ref,
32
+ meeting: hit.ref.split("/").slice(0, 2).join("/"),
33
+ scope: hit.scope,
34
+ excerpt: hit.text,
35
+ offset_ms: hit.startMs,
36
+ by: hit.by,
37
+ score: hit.score,
38
+ ...(hit.passage ? { passage: hit.passage } : {}),
39
+ ...(hit.match ? { match: hit.match } : {}),
40
+ ...(hit.corrections ? { corrections: hit.corrections } : {}),
41
+ source: {
42
+ ref: hit.ref,
43
+ title: hit.source.title,
44
+ started_at: hit.source.startedAt === null ? null : new Date(hit.source.startedAt).toISOString(),
45
+ url: hit.source.url,
46
+ },
47
+ untrusted: ["excerpt", "passage.first", "passage.last", "source.title"],
48
+ })),
49
+ limit,
50
+ has_more: found.hasMore,
51
+ paging: "cursor",
52
+ ...(found.nextCursor ? { cursor: found.nextCursor } : {}),
53
+ args,
54
+ missing: [
55
+ ...(found.coverage.meaningScanComplete
56
+ ? []
57
+ : [{ field: "items", why: `meaning compared only ${found.coverage.scanned} passages; raise --max-chunks` }]),
58
+ ...(found.words.refused ? [{ field: "items", why: `found by meaning only: ${found.words.refused}` }] : []),
59
+ ],
60
+ });
61
+ const MEANING_REASON = "search meetings also ranks by meaning with --model, over vectors built on this computer";
62
+ const withMeaningOptions = (command) => overrideSharedContract(command, MEANING_REASON, (one) => {
63
+ one
64
+ .description("find words in stored meetings, and by meaning with --model")
65
+ .option("--model <model>", "rank words and meaning together with this embedding model, building missing vectors first; local stays here")
66
+ .option("--base-url <url>", "remote embedding service for --model; the passages are sent there")
67
+ .option("--dims <n>", "vector size the remote service returns, in dimensions", count)
68
+ .option("--max-chunks <n>", "by meaning: most stored passages to compare (default 10000)", count)
69
+ .option("--max-rows <n>", "by meaning: most transcript lines to read, 1 through 100000", count)
70
+ .option("--max-text-bytes <bytes>", "by meaning: most transcript text to read (default 4 MiB)", count);
71
+ });
72
+ /**
73
+ * `search meetings` by words, and by words and meaning ranked together with `--model`, for any host of stored
74
+ * meetings. Returns the run, so a host's saved searches replay it.
75
+ */
76
+ export const addMeetingCombinedSearchCommand = (program, deps) => {
77
+ const execute = async (query, options, command) => {
78
+ const request = meetingHitSearchRequest(query, options, deps.pagingOf(command).limit, deps.signal());
79
+ if (options.model !== undefined) {
80
+ refuse(options, ["maxReadBytes"], "to a search by meaning");
81
+ const { limit, after, maxReadBytes: _bytes, signal, ...selection } = request;
82
+ if (options.baseUrl !== undefined && offline(command))
83
+ throw new CliError("configuration_error", "remote embeddings require network access; remove --offline");
84
+ const meaning = {
85
+ model: options.model,
86
+ baseUrl: options.baseUrl,
87
+ dims: options.dims,
88
+ limit,
89
+ maxChunks: options.maxChunks,
90
+ after,
91
+ selection,
92
+ maxRows: options.maxRows,
93
+ maxTextBytes: options.maxTextBytes,
94
+ buildMissing: true,
95
+ signal,
96
+ };
97
+ return combinedList(await (await deps.meaning()).search(query, meaning), limit, meetingSearchArguments(query, options));
98
+ }
99
+ refuse(options, ["baseUrl", "dims", "maxChunks", "maxRows", "maxTextBytes"], "without --model");
100
+ return meetingHitsList(await (await deps.words())(query, request), request.limit, "search meetings", meetingSearchArguments(query, options), meetingSearchMeta(options));
101
+ };
102
+ const command = withMeaningOptions(createMeetingSearchCommand(program)).action(async (query, options, self) => deps.output(await execute(query, options, self), self));
103
+ overrideSharedContract(command, "a search by meaning may build missing vectors, so it writes to the store", (one) => annotate(one, { origin: "handwritten", effects: FETCH, examples: deps.examples }));
104
+ return execute;
105
+ };
106
+ /**
107
+ * `meetings embed`: previews the vectors a search by meaning needs, and `--yes` splits every transcript and embeds one
108
+ * batch of the passages without a vector; run it again for the next batch.
109
+ */
110
+ export const addMeetingEmbeddingCommand = (program, deps) => {
111
+ const meetings = program.commands.find((command) => command.name() === "meetings");
112
+ if (!meetings)
113
+ throw new CliError("configuration_error", "meeting command group is unavailable");
114
+ annotate(meetings
115
+ .command("embed")
116
+ .description("preview building the vectors search by meaning reads; --yes builds one batch, rerun for the next")
117
+ .option("--model <model>", "embedding model: a local one (default: the models command's default text model)")
118
+ .option("--base-url <url>", "remote embedding service; the passages are sent there. OpenAI reads OPENAI_API_KEY")
119
+ .option("--dims <n>", "vector size the remote service returns, in dimensions", count)
120
+ .option("--limit <n>", "how many passages in one batch, 1 through 1000 (default 100)", count)
121
+ .option("--max-rows <n>", "most transcript lines to read, 1 through 100000", count)
122
+ .option("--max-text-bytes <bytes>", "most transcript text to read, in bytes (default 4 MiB)", count)
123
+ .option("--yes", "split transcripts and build their vectors; otherwise only preview")
124
+ .action(async (flags, command) => {
125
+ if (flags.baseUrl !== undefined && flags.model === undefined)
126
+ throw new CliError("validation_error", "a remote --base-url needs its own --model");
127
+ if (flags.baseUrl !== undefined && offline(command))
128
+ throw new CliError("configuration_error", "remote embeddings require network access; remove --offline");
129
+ const options = { ...flags, model: flags.model ?? deps.defaultModel(), signal: deps.signal() };
130
+ const body = itemOf(await (await deps.meaning()).generate(options));
131
+ if (options.yes && deps.receipt)
132
+ await deps.receipt(body, command);
133
+ else
134
+ deps.output(body, command);
135
+ }), { origin: "handwritten", effects: FETCH, examples: deps.examples });
136
+ };
@@ -317,6 +317,12 @@ export declare const meetingPreparationAnswer: (packet: MeetingPreparation) => i
317
317
  from: string;
318
318
  to: string[];
319
319
  }[] | undefined;
320
+ by?: ("meaning" | "words")[] | undefined;
321
+ score?: number | null | undefined;
322
+ passage?: {
323
+ first: string;
324
+ last: string;
325
+ } | undefined;
320
326
  source?: {
321
327
  ref: string;
322
328
  title: string | null;
@@ -37,6 +37,12 @@ export declare const mapPreparationProjectEvidence: (section: NonNullable<Meetin
37
37
  from: string;
38
38
  to: string[];
39
39
  }[] | undefined;
40
+ by?: ("meaning" | "words")[] | undefined;
41
+ score?: number | null | undefined;
42
+ passage?: {
43
+ first: string;
44
+ last: string;
45
+ } | undefined;
40
46
  source?: {
41
47
  ref: string;
42
48
  title: string | null;
@@ -346,6 +346,12 @@ export declare const readMeetingPreparation: (read: MeetingPreparationReader, in
346
346
  from: string;
347
347
  to: string[];
348
348
  }[] | undefined;
349
+ by?: ("meaning" | "words")[] | undefined;
350
+ score?: number | null | undefined;
351
+ passage?: {
352
+ first: string;
353
+ last: string;
354
+ } | undefined;
349
355
  source?: {
350
356
  ref: string;
351
357
  title: string | null;
@@ -0,0 +1,18 @@
1
+ import { type Command } from "commander";
2
+ import type { MeetingTags } from "../services/meeting-tags.js";
3
+ import { type Body } from "./envelope.js";
4
+ export interface MeetingTagsCommandDeps {
5
+ /** The tags of the profile's own meetings account; opened when the command runs. */
6
+ read: () => Promise<MeetingTags>;
7
+ signal?: () => AbortSignal | undefined;
8
+ /** Prints the answer; cli-core's renderer when not given. A host that closes its store first passes its own. */
9
+ output?: (body: Body, command: Command) => void;
10
+ /** One to three examples per command that run as written, with the host's command and a profile. */
11
+ examples: Record<"add" | "remove" | "list", string[]>;
12
+ }
13
+ /**
14
+ * `tags add|remove|list` for a host whose things to label are its meetings, such as pbx's phone calls. A host of
15
+ * chats mounts the messenger's `tags` instead. `--matching` takes `search meetings`'s query, so "search, then tag" is
16
+ * one command, and a rerun after new calls are transcribed marks only those.
17
+ */
18
+ export declare const addMeetingTagsCommand: (program: Command, deps: MeetingTagsCommandDeps) => void;
@@ -0,0 +1,74 @@
1
+ import { CliError } from "@wirecat/cli-base";
2
+ import { annotate } from "@wirecat/cli-base/commands";
3
+ import { InvalidArgumentError } from "commander";
4
+ import { meetingTagChangeItem, meetingTaggingItem } from "../meetings/index.js";
5
+ import { outputFor } from "./context.js";
6
+ import { LOCAL_READ, LOCAL_WRITE, NO_EFFECTS } from "./effects.js";
7
+ import { itemOf, listOf, renderAnswer } from "./envelope.js";
8
+ import { queryTerms, termField, withQuery } from "./list-query.js";
9
+ const MEETING_TAG_QUERY = {
10
+ entity: "meeting_tagging",
11
+ backend: "native",
12
+ fields: [termField("tag", "kw", "tag:complaint")],
13
+ };
14
+ const positive = (value) => {
15
+ if (!/^[1-9]\d*$/.test(value) || !Number.isSafeInteger(Number(value)))
16
+ throw new InvalidArgumentError("expected a positive integer");
17
+ return Number(value);
18
+ };
19
+ const ids = (value, previous = []) => [...previous, positive(value)];
20
+ const targetOf = ({ meeting, matching }) => {
21
+ if ((meeting === undefined) === (matching === undefined))
22
+ throw new CliError("validation_error", "name the meetings: --meeting <id> (repeat for more) or --matching <query>");
23
+ return matching === undefined ? { meetings: meeting ?? [] } : { matching };
24
+ };
25
+ const groupOf = (program) => program.commands.find((command) => command.name() === "tags") ??
26
+ annotate(program.command("tags"), { effects: NO_EFFECTS }).description("your labels on stored meetings, kept in the local store and never sent");
27
+ /**
28
+ * `tags add|remove|list` for a host whose things to label are its meetings, such as pbx's phone calls. A host of
29
+ * chats mounts the messenger's `tags` instead. `--matching` takes `search meetings`'s query, so "search, then tag" is
30
+ * one command, and a rerun after new calls are transcribed marks only those.
31
+ */
32
+ export const addMeetingTagsCommand = (program, deps) => {
33
+ const tags = groupOf(program);
34
+ const print = (body, command) => deps.output ? deps.output(body, command) : renderAnswer(command, outputFor(command), body);
35
+ for (const operation of ["add", "remove"])
36
+ annotate(tags.command(operation), {
37
+ effects: LOCAL_WRITE,
38
+ output: { entity: "meeting_tag_change" },
39
+ examples: deps.examples[operation],
40
+ })
41
+ .summary(operation === "add" ? "put tags on stored meetings" : "take tags off stored meetings")
42
+ .description(operation === "add"
43
+ ? "put tags on stored meetings: by id, or every meeting where a search finds its words"
44
+ : "take tags off stored meetings: by id, or every meeting where a search finds its words")
45
+ .argument("<tag...>", "one or more tags: 1–32 letters a–z, digits and hyphens; upper case is lowered")
46
+ .option("--meeting <id>", "a meeting, by its store id; repeat for more", ids)
47
+ .option("--matching <query>", "every meeting where search meetings finds this query: words, phrases, OR, -word, from:, date>=30d")
48
+ .action(async (given, flags, command) => {
49
+ const target = targetOf(flags);
50
+ const done = await (await deps.read())[operation](target, given, deps.signal?.());
51
+ print(itemOf(meetingTagChangeItem(done)), command);
52
+ });
53
+ withQuery(annotate(tags.command("list"), { effects: LOCAL_READ, examples: deps.examples.list })
54
+ .summary("tagged meetings of this account, with their tags")
55
+ .description("the stored meetings of this account that carry a tag, each with all its tags"), MEETING_TAG_QUERY)
56
+ .option("--limit <n>", "meetings per page, 1–500 (default 100)", positive, 100)
57
+ .option("--page <n>", "page number", positive, 1)
58
+ .action(async (words, flags, command) => {
59
+ if (flags.limit > 500)
60
+ throw new CliError("validation_error", "--limit is at most 500");
61
+ const tag = queryTerms(words, MEETING_TAG_QUERY, "tags list").get("tag");
62
+ const found = await (await deps.read()).list({
63
+ ...(tag === undefined ? {} : { tag }),
64
+ limit: flags.limit,
65
+ offset: (flags.page - 1) * flags.limit,
66
+ });
67
+ print(listOf("tags list", {
68
+ items: found.items.map(meetingTaggingItem),
69
+ limit: flags.limit,
70
+ page: flags.page,
71
+ has_more: found.hasMore,
72
+ }), command);
73
+ });
74
+ };