@wirecat/cli-core 0.663.0 → 0.665.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 (109) hide show
  1. package/CHANGELOG.md +141 -0
  2. package/dist/background/daily-archive-timer.d.ts +1 -1
  3. package/dist/calendar/index.d.ts +1 -1
  4. package/dist/calendar/index.js +1 -1
  5. package/dist/calendar/prepare.d.ts +2 -2
  6. package/dist/calendar/reads.d.ts +5 -5
  7. package/dist/calendar/writes.d.ts +4 -4
  8. package/dist/cli/chat-sending-command.d.ts +14 -0
  9. package/dist/cli/chat-sending-command.js +64 -0
  10. package/dist/cli/context.d.ts +7 -0
  11. package/dist/cli/context.js +12 -4
  12. package/dist/cli/index.d.ts +2 -0
  13. package/dist/cli/index.js +2 -0
  14. package/dist/cli/meeting-meaning-command.d.ts +47 -0
  15. package/dist/cli/meeting-meaning-command.js +136 -0
  16. package/dist/cli/meeting-preparation-answer.d.ts +6 -0
  17. package/dist/cli/meeting-preparation-projects.d.ts +6 -0
  18. package/dist/cli/meeting-preparation-read.d.ts +6 -0
  19. package/dist/cli/meeting-tags-command.d.ts +18 -0
  20. package/dist/cli/meeting-tags-command.js +74 -0
  21. package/dist/cli/messenger/conversation-answers.d.ts +1 -1
  22. package/dist/cli/messenger/conversation-answers.js +1 -0
  23. package/dist/cli/messenger/conversations-command.js +38 -12
  24. package/dist/cli/messenger/models-command.js +7 -0
  25. package/dist/cli/messenger/records-command.d.ts +4 -1
  26. package/dist/cli/messenger/records-command.js +6 -1
  27. package/dist/cli/model-catalogue-command.js +2 -0
  28. package/dist/cli/profile-token.d.ts +15 -1
  29. package/dist/cli/profile-token.js +103 -7
  30. package/dist/cli/program.js +2 -2
  31. package/dist/domain/links.d.ts +11 -0
  32. package/dist/domain/links.js +4 -0
  33. package/dist/entities/chat-sending.d.ts +10 -0
  34. package/dist/entities/chat-sending.js +11 -0
  35. package/dist/entities/index.d.ts +43 -1
  36. package/dist/entities/index.js +6 -2
  37. package/dist/entities/listings.d.ts +60 -0
  38. package/dist/entities/listings.js +15 -0
  39. package/dist/entities/meeting-preparation.d.ts +6 -0
  40. package/dist/entities/meeting.d.ts +1 -1
  41. package/dist/entities/meeting.js +1 -1
  42. package/dist/errors/reasons.js +25 -1
  43. package/dist/mcp/meeting-preparation.d.ts +6 -0
  44. package/dist/meetings/answers.d.ts +7 -0
  45. package/dist/meetings/answers.js +4 -0
  46. package/dist/meetings/event-store.d.ts +2 -1
  47. package/dist/meetings/event-store.js +6 -0
  48. package/dist/meetings/index.d.ts +2 -1
  49. package/dist/meetings/index.js +2 -1
  50. package/dist/meetings/mcp/search.d.ts +6 -0
  51. package/dist/meetings/project-evidence-answer.d.ts +6 -0
  52. package/dist/meetings/tag-answers.d.ts +43 -0
  53. package/dist/meetings/tag-answers.js +41 -0
  54. package/dist/models/chat-sending.d.ts +24 -0
  55. package/dist/models/chat-sending.js +40 -0
  56. package/dist/runs/events.d.ts +1 -1
  57. package/dist/search/question-plan.d.ts +5 -0
  58. package/dist/search/question-plan.js +5 -0
  59. package/dist/search/task-similarity.d.ts +1 -0
  60. package/dist/search/task-similarity.js +1 -1
  61. package/dist/services/embeddings-search.js +19 -5
  62. package/dist/services/embeddings.d.ts +4 -0
  63. package/dist/services/index.d.ts +2 -0
  64. package/dist/services/index.js +2 -0
  65. package/dist/services/listings.js +17 -2
  66. package/dist/services/meeting-meaning.d.ts +47 -0
  67. package/dist/services/meeting-meaning.js +158 -0
  68. package/dist/services/meeting-tags.d.ts +27 -0
  69. package/dist/services/meeting-tags.js +81 -0
  70. package/dist/services/messages-discovery.js +2 -2
  71. package/dist/sftp/index.d.ts +1 -1
  72. package/dist/sftp/index.js +1 -1
  73. package/dist/sftp/session.d.ts +30 -4
  74. package/dist/sftp/session.js +195 -11
  75. package/dist/sftp/ssh2.d.ts +19 -4
  76. package/dist/sftp/ssh2.js +144 -17
  77. package/dist/speech/cloud.d.ts +47 -0
  78. package/dist/speech/cloud.js +73 -0
  79. package/dist/speech/decode.d.ts +36 -9
  80. package/dist/speech/decode.js +208 -61
  81. package/dist/speech/index.d.ts +2 -1
  82. package/dist/speech/index.js +2 -1
  83. package/dist/speech/openai.d.ts +4 -0
  84. package/dist/speech/openai.js +13 -12
  85. package/dist/sql/index.d.ts +1 -0
  86. package/dist/sql/index.js +1 -0
  87. package/dist/sql/reader.d.ts +95 -0
  88. package/dist/sql/reader.js +214 -0
  89. package/dist/store/sqlite/drizzle/bun.js +4 -4
  90. package/dist/store/sqlite/drizzle/bun.js.map +1 -1
  91. package/dist/store/sqlite/drizzle/core.js +5 -5
  92. package/dist/store/sqlite/drizzle/core.js.map +1 -1
  93. package/dist/store/sqlite/drizzle/node.js +4 -4
  94. package/dist/store/sqlite/drizzle/node.js.map +1 -1
  95. package/dist/store/sqlite/drizzle/{shared-55XJMTPA.js → shared-5XR7K42U.js} +58 -58
  96. package/dist/store/sqlite/drizzle/{shared-55XJMTPA.js.map → shared-5XR7K42U.js.map} +1 -1
  97. package/dist/store/sqlite/knowledge.d.ts +1 -1
  98. package/dist/store/sqlite/knowledge.js +8 -4
  99. package/dist/store/sqlite/labelled.d.ts +5 -0
  100. package/dist/store/sqlite/labelled.js +6 -0
  101. package/dist/store/sqlite/link-row.d.ts +1 -0
  102. package/dist/store/sqlite/link-row.js +2 -0
  103. package/dist/store/sqlite/meeting-listing.d.ts +12 -0
  104. package/dist/store/sqlite/meeting-listing.js +20 -5
  105. package/dist/store/sqlite/notes.d.ts +1 -1
  106. package/dist/store/sqlite/notes.js +1 -1
  107. package/package.json +18 -3
  108. package/parity.json +20 -1
  109. package/skills/link-conversations/SKILL.md +1 -1
@@ -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
+ };
@@ -11,7 +11,7 @@ export declare const readinessGaps: ({ meaning, model, readiness, refreshed, cov
11
11
  missing: Missing[];
12
12
  };
13
13
  /** `search conversations` and `conversations related`, CLI and MCP alike. */
14
- export declare const foundConversations: (command: string, found: Readiness & Pick<FoundConversations, "hits" | "accounts">, limit: number, messenger: Syncing, chat?: string, meta?: Partial<Meta>) => import("../envelope.js").ListBody<unknown>;
14
+ export declare const foundConversations: (command: string, found: Readiness & Pick<FoundConversations, "hits" | "accounts" | "words">, limit: number, messenger: Syncing, chat?: string, meta?: Partial<Meta>) => import("../envelope.js").ListBody<unknown>;
15
15
  /** `conversations status`: each built chat with the model it was measured by; group chats never built are missing. */
16
16
  export declare const readinessList: ({ model, chats, unbuiltGroups, }: {
17
17
  model: string;
@@ -61,6 +61,7 @@ export const foundConversations = (command, found, limit, messenger, chat, meta
61
61
  meta: {
62
62
  ...meta,
63
63
  ...(found.accounts ? { accounts: found.accounts.map((one) => `${one.provider}:${one.account}`) } : {}),
64
+ ...(found.words ? { words: found.words } : {}),
64
65
  },
65
66
  });
66
67
  /** `conversations status`: each built chat with the model it was measured by; group chats never built are missing. */
@@ -6,12 +6,16 @@ import { openAnalysis, providerIdentity } from "../../analysis/provider.js";
6
6
  import { runAnalysis } from "../../analysis/runner.js";
7
7
  import { DEFAULT_TEXT_MODEL } from "../../embeddings/models.js";
8
8
  import { isLocal } from "../../embeddings/remote.js";
9
+ import { chatSendingAllowed, chatSendingAskRefusal } from "../../models/chat-sending.js";
9
10
  import { renderMessages } from "../../render/messages.js";
11
+ import { typedCommand } from "../../runs/scope.js";
12
+ import { searchTimeLimit } from "../../search/lucene/types.js";
10
13
  import { BATCH_SIZE, CONVERSATION_QUERY } from "../../services/conversations.js";
11
14
  import { REFRESH_BOUNDS, } from "../../services/embeddings.js";
12
15
  import { servicesFor, storedDeps } from "../../services/index.js";
13
16
  import { dateWindow } from "../../services/moment.js";
14
17
  import { analysisChoice } from "../analysis-choice.js";
18
+ import { environmentOf } from "../context.js";
15
19
  import { destroysNothing, LOCAL_READ, LOCAL_WRITE, REMOTE_READ, REMOTE_WRITE, reachesOtherService, refuseUnderReadOnly, } from "../effects.js";
16
20
  import { embeddingChoice, refuseRemoteQuery } from "../embedding-choice.js";
17
21
  import { itemOf, listOf, renderAnswer, snakeKeys } from "../envelope.js";
@@ -36,7 +40,9 @@ const conversationBuildCommand = (messenger) => boundOptions(reachesOtherService
36
40
  .description("find a chat's conversations in what the store holds, replacing the last build; without --chat, every " +
37
41
  "chat that changed since its build and every group never built; never asks the messenger")
38
42
  .option("--chat <chat>", messenger.chatArgument)
39
- .option("--analyze", "link batches using the configured analysis provider; requires --chat and remembers consent for this chat/provider")
43
+ .option("--analyze", "link batches using the configured analysis provider; requires --chat. A model outside this computer follows " +
44
+ "the `models chats` setting: under ask, a yes is remembered for this chat and provider")
45
+ .option("--yes", "send this chat's text to the analysis model outside this computer, when `models chats` is ask")
40
46
  .addOption(new Option("--analysis-provider <provider>", "analysis: agent, openai or anthropic"))
41
47
  .option("--model <model>", "analysis model; overrides models.analysis.model")
42
48
  .option("--base-url <url>", "analysis API endpoint; overrides models.analysis.base_url")
@@ -44,6 +50,7 @@ const conversationBuildCommand = (messenger) => boundOptions(reachesOtherService
44
50
  .option("--max-tokens <n>", "analysis input/output reservation cap per run; default 100000", positiveCount("--max-tokens")), { chunks: false }).action(async function () {
45
51
  const options = this.optsWithGlobals();
46
52
  const { chat, maxChats } = options;
53
+ const { yes } = this.opts();
47
54
  const context = messengerContext(this, messenger);
48
55
  if (options.analyze) {
49
56
  if (!chat)
@@ -51,8 +58,14 @@ const conversationBuildCommand = (messenger) => boundOptions(reachesOtherService
51
58
  refuseLocalWrite(context, messenger.app.command, LINKS_KEY);
52
59
  refuseLocalWrite(context, messenger.app.command, "conversations.links.rebuild");
53
60
  const target = analysisChoice(options, messenger.app, context.settings, context.env, context.keyring);
54
- if (!isLocal(target.baseUrl))
55
- refuseUnderReadOnly(this, `send chat text to ${new URL(target.baseUrl).host}`);
61
+ const outside = !isLocal(target.baseUrl);
62
+ const host = new URL(target.baseUrl).host;
63
+ const tool = typedCommand(messenger.app.command, "");
64
+ if (outside)
65
+ refuseUnderReadOnly(this, `send chat text to ${host}`);
66
+ // A model on this computer keeps the text here: it needs no yes, as embeddings on this computer need none.
67
+ const needsYes = () => outside && !chatSendingAllowed(context.env, host, tool);
68
+ const asks = needsYes();
56
69
  const controller = new AbortController();
57
70
  context.track({ close: async () => controller.abort() });
58
71
  const maxTokens = options.maxTokens ?? 100_000;
@@ -66,12 +79,12 @@ const conversationBuildCommand = (messenger) => boundOptions(reachesOtherService
66
79
  const status = await services.conversations.batchStatus(chat, size);
67
80
  const consents = analysisConsents(store, account);
68
81
  const identity = providerIdentity(target);
69
- if (status.messages && !(await consents.has(status.chat, identity))) {
82
+ if (asks && status.messages && !(await consents.has(status.chat, identity))) {
70
83
  const what = `${status.messages} messages, ${status.characters} characters (about ${status.tokensEstimate} message tokens, plus prompt and batch context), go to ${target.model} at ${target.baseUrl}; this run reserves at most ${maxTokens} input/output tokens. Consent is remembered for this chat and provider until revoked`;
71
- if (!options.yes) {
84
+ if (!yes) {
72
85
  const answer = await askOwner(this, `${what}. Allow analysis? [y/N] `);
73
86
  if (answer === null)
74
- throw new CliError("confirmation_required", `${what} — add --yes`);
87
+ throw chatSendingAskRefusal(what, tool);
75
88
  if (!/^y(es)?$/i.test(answer.trim()))
76
89
  throw new CliError("cancelled", "cancelled — nothing was sent");
77
90
  }
@@ -80,7 +93,8 @@ const conversationBuildCommand = (messenger) => boundOptions(reachesOtherService
80
93
  await services.conversations.build(chat);
81
94
  const request = openAnalysis(target, controller.signal, context.env);
82
95
  return runAnalysis(services.conversations, chat, async (...args) => {
83
- if (!(await consents.has(status.chat, identity)))
96
+ // Read again per batch: a revoked consent or a stricter setting stops the run before the next send.
97
+ if (needsYes() && !(await consents.has(status.chat, identity)))
84
98
  throw new CliError("permission_error", "analysis consent was revoked; no further batch was sent");
85
99
  return request(...args);
86
100
  }, {
@@ -291,10 +305,12 @@ export const conversationsCommand = (messenger) => {
291
305
  .option("--chat <chat>", messenger.chatArgument))
292
306
  .option("--threads <n>", "local: threads in all (default: min(8, cores))", positiveCount("--threads"))
293
307
  .option("--concurrency <n>", "remote: requests at once (default: 4)", positiveCount("--concurrency"))
294
- .option("--max-tokens <n>", "remote: stop before a run that could send more tokens than this", positiveCount("--max-tokens"));
308
+ .option("--max-tokens <n>", "remote: stop before a run that could send more tokens than this", positiveCount("--max-tokens"))
309
+ .option("--yes", "remote: send the chunks to the model outside this computer, when `models chats` is ask");
295
310
  boundOptions(embed, { oneChatUnbounded: true });
296
311
  embed.action(async function () {
297
312
  const options = this.optsWithGlobals();
313
+ const { yes } = this.opts();
298
314
  const context = messengerContext(this, messenger);
299
315
  refuseLocalWrite(context, messenger.app.command, EMBED_KEY);
300
316
  const model = choiceOf(options, messenger, context);
@@ -316,8 +332,14 @@ export const conversationsCommand = (messenger) => {
316
332
  context.renderer.note(`${status.left} of ${status.chunks} chunks to embed with ${status.model}` +
317
333
  (status.estimateSeconds === null ? "" : `, ${minutes(status.estimateSeconds)} on one session`));
318
334
  if (typeof model !== "string" && status.left > 0 && !isLocal(model.remote.baseUrl)) {
319
- refuseUnderReadOnly(this, `send chat text to ${new URL(model.remote.baseUrl).host}`);
320
- await consent(this, status, model.remote.baseUrl, options);
335
+ const host = new URL(model.remote.baseUrl).host;
336
+ refuseUnderReadOnly(this, `send chat text to ${host}`);
337
+ const tool = typedCommand(messenger.app.command, "");
338
+ const allowed = chatSendingAllowed(context.env, host, tool);
339
+ await consent(this, status, model.remote.baseUrl, tool, {
340
+ yes: allowed || yes === true,
341
+ ...(options.maxTokens === undefined ? {} : { maxTokens: options.maxTokens }),
342
+ });
321
343
  }
322
344
  return services.embeddings.embed(chat, {
323
345
  model,
@@ -470,7 +492,7 @@ const choiceOf = (options, messenger, context, extra) => embeddingChoice(options
470
492
  * The messages leave the machine: say where, how much and what it may cost, and wait for a yes — `--yes`
471
493
  * in machine mode (E11). Every run asks again.
472
494
  */
473
- const consent = async (command, status, baseUrl, { yes, maxTokens }) => {
495
+ const consent = async (command, status, baseUrl, tool, { yes, maxTokens }) => {
474
496
  if (maxTokens !== undefined && status.tokensAtMost > maxTokens) {
475
497
  throw new CliError("validation_error", `this run could send up to ${status.tokensAtMost} tokens, above --max-tokens ${maxTokens} — nothing was sent`);
476
498
  }
@@ -483,7 +505,7 @@ const consent = async (command, status, baseUrl, { yes, maxTokens }) => {
483
505
  return;
484
506
  const answer = await askOwner(command, `${what}. Send them? [y/N] `);
485
507
  if (answer === null)
486
- throw new CliError("confirmation_required", `${what} — add --yes to send them`);
508
+ throw chatSendingAskRefusal(what, tool);
487
509
  if (!/^y(es)?$/i.test(answer.trim()))
488
510
  throw new CliError("cancelled", "cancelled — nothing was sent");
489
511
  };
@@ -575,10 +597,12 @@ export const conversationsSearchCommand = (messenger) => syncOptions(boundOption
575
597
  ...(since === undefined ? {} : { sinceTime: since }),
576
598
  ...(options.timezone === undefined ? {} : { zone: options.timezone }),
577
599
  });
600
+ const timeLimitMs = searchTimeLimit(environmentOf(this).deadline?.());
578
601
  const { found, refreshed } = await context.withServices(async (services) => {
579
602
  const syncing = syncRequest(this, context);
580
603
  const found = await services.embeddings.search(query, {
581
604
  ...syncing,
605
+ ...(timeLimitMs === undefined ? {} : { timeLimitMs }),
582
606
  ...(options.catchUp
583
607
  ? {
584
608
  refresh: {
@@ -602,6 +626,8 @@ export const conversationsSearchCommand = (messenger) => syncOptions(boundOption
602
626
  if (refreshed)
603
627
  for (const note of leftNotes(refreshed, rootOf(this)))
604
628
  context.renderer.note(note);
629
+ if (found.words === "out-of-time")
630
+ context.renderer.note("the word half ran out of time, so these are by meaning alone; --timeout gives it longer");
605
631
  renderAnswer(this, context, foundConversations("search conversations", found, limit, messenger, chat, window.meta), () => found.hits.map((hit) => `${hitLine(hit)}\n`).join(""));
606
632
  if (found.hits.length === 0 && context.format === "pretty")
607
633
  context.renderer.note(found.meaning === "unavailable"
@@ -7,12 +7,14 @@ import { embeddingKeys } from "../../embeddings/keys.js";
7
7
  import { DEFAULT_RERANK_MODEL, DEFAULT_TEXT_MODEL, RERANK_MODELS, textModels, } from "../../embeddings/models.js";
8
8
  import { model as modelEntity } from "../../entities/model.js";
9
9
  import { DEFAULT_IMAGE_MODEL, IMAGE_MODELS, imageModelsDirectory, isImageModelInstalled, } from "../../images/picture/models.js";
10
+ import { typedCommand } from "../../runs/scope.js";
10
11
  import { downloadImageModel, downloadRerankModel, downloadTextModel } from "../../services/model-downloads.js";
11
12
  import { addCustomTextModel, useTextModel } from "../../services/text-model-choice.js";
12
13
  import { install, installedBytes, isInstalled, megabytes, modelPath, modelsDirectory, vadPath, } from "../../speech/install.js";
13
14
  import { orderedModels, speechModel, VAD } from "../../speech/models.js";
14
15
  import { choose } from "../../speech/transcribe.js";
15
16
  import { readSecret } from "../../terminal/prompt.js";
17
+ import { chatSendingCommand } from "../chat-sending-command.js";
16
18
  import { baseContext, environmentOf } from "../context.js";
17
19
  import { FETCH, grantsAuthority, LOCAL_READ, LOCAL_WRITE, reachesOtherService } from "../effects.js";
18
20
  import { itemOf, listOf, renderAnswer } from "../envelope.js";
@@ -143,6 +145,11 @@ export const modelsCommand = (messenger) => {
143
145
  const tool = `${messenger.app.command} personal`;
144
146
  const models = new Command("models").description("models that run on this machine");
145
147
  models.addCommand(modelKeysCommand(messenger, tool));
148
+ models.addCommand(chatSendingCommand(messenger.app, {
149
+ env: (command) => baseContext(command, messenger.resolveSettings).env,
150
+ output: (answer, command) => renderAnswer(command, baseContext(command, messenger.resolveSettings), answer),
151
+ tool: () => typedCommand(messenger.app.command, ""),
152
+ }));
146
153
  withQuery(annotate(models.command("list"), {
147
154
  effects: LOCAL_READ,
148
155
  examples: [`${tool} models list`, `${tool} models list kind:audio`],
@@ -6,7 +6,10 @@ export declare const mediaCommand: (messenger: Messenger) => Command;
6
6
  export declare const stickersCommand: (messenger: Messenger) => Command;
7
7
  /** `calls list` — the account's call history, newest first. */
8
8
  export declare const callsCommand: (messenger: Messenger) => Command;
9
- /** `chats delete` and `chats clear` — for this account only; at the default level they ask first. */
9
+ /**
10
+ * `chats delete` and `chats clear` — for this account only; at the default level they ask first. No MCP server offers
11
+ * them: over MCP an ask level goes ahead, and a whole chat gone cannot be undone (owner ruling, 2026-11-14).
12
+ */
10
13
  export declare const chatDeletionCommands: (messenger: Messenger) => Command[];
11
14
  /** `chats mute` and `unmute` — the owner's own notifications for one chat; nobody in it is told. */
12
15
  export declare const muteCommands: (messenger: Messenger) => Command[];
@@ -90,11 +90,15 @@ export const callsCommand = (messenger) => {
90
90
  });
91
91
  return calls;
92
92
  };
93
- /** `chats delete` and `chats clear` — for this account only; at the default level they ask first. */
93
+ /**
94
+ * `chats delete` and `chats clear` — for this account only; at the default level they ask first. No MCP server offers
95
+ * them: over MCP an ask level goes ahead, and a whole chat gone cannot be undone (owner ruling, 2026-11-14).
96
+ */
94
97
  export const chatDeletionCommands = (messenger) => [
95
98
  annotate(new Command("delete"), {
96
99
  output: { entity: "chat_removal" },
97
100
  effects: REMOTE_WRITE,
101
+ mcp: false,
98
102
  examples: [`${messenger.app.command} personal chats delete "Book club"`],
99
103
  })
100
104
  .description("delete a chat from this account; the others in it keep it and its messages")
@@ -107,6 +111,7 @@ export const chatDeletionCommands = (messenger) => [
107
111
  annotate(new Command("clear"), {
108
112
  output: { entity: "chat_removal" },
109
113
  effects: REMOTE_WRITE,
114
+ mcp: false,
110
115
  examples: [`${messenger.app.command} personal chats clear "Book club"`],
111
116
  })
112
117
  .description("delete every message in a chat for this account; the others in it keep theirs")
@@ -13,6 +13,7 @@ import { DEFAULT_ORDER, orderedModels, speechModel } from "../speech/models.js";
13
13
  import { readSecret } from "../terminal/prompt.js";
14
14
  import { stepLines } from "../terminal/step-lines.js";
15
15
  import { aiModelCommand } from "./ai-model-command.js";
16
+ import { chatSendingCommand } from "./chat-sending-command.js";
16
17
  import { FETCH, grantsAuthority, LOCAL_READ, LOCAL_WRITE, NO_EFFECTS } from "./effects.js";
17
18
  import { enrichmentConsentsCommand } from "./enrichment-consents-command.js";
18
19
  import { itemOf, listOf } from "./envelope.js";
@@ -150,6 +151,7 @@ export const modelCatalogueCommand = (app, options) => {
150
151
  models.addCommand(providerKeysCommand(app, options));
151
152
  models.addCommand(aiModelCommand(app, options));
152
153
  models.addCommand(localOnlyCommand(app, options));
154
+ models.addCommand(chatSendingCommand(app, options));
153
155
  models.addCommand(pictureReadingCommand(app, options));
154
156
  }
155
157
  if (options.jsonOption)
@@ -13,15 +13,29 @@ export interface ProfileTokenStoreOptions {
13
13
  * `token:<profile>` under the app's own service, then a 0600 file (WC-SECR-4). A run with moved folders reads the
14
14
  * owner's entry and never replaces or deletes it: it writes a temporary `<app>:<config folder>` entry instead
15
15
  * (WC-SECR-24, cli-base `Credentials`).
16
+ *
17
+ * A profile that needs a second secret (a database password and an SSH password) keeps it in the same entry, by
18
+ * name: `writeSecret(profile, "ssh", …)`. The entry then holds the token and the named secrets as one value, as an
19
+ * OAuth entry holds its tokens and client secret; the keyring gets no second entry. `<PREFIX>_TOKEN_<NAME>` overrides
20
+ * one for CI, as `<PREFIX>_TOKEN` does the token.
16
21
  */
17
22
  export declare class ProfileTokenStore {
18
23
  #private;
19
24
  readonly variable: string;
20
25
  constructor({ app, env, keyring, warn }: ProfileTokenStoreOptions);
21
26
  read(profile: string): StoredCredential | undefined;
22
- /** `file` also forgets the keyring copy, so a later read cannot find the token the owner asked to keep elsewhere. */
27
+ /** The token; the profile's named secrets stay as they were. */
23
28
  write(profile: string, token: string, storage?: TokenStorage): CredentialSource;
29
+ /** The token and every named secret: the whole entry, as `session end` wants. */
24
30
  remove(profile: string): CredentialSource[];
31
+ /** A named secret: `<PREFIX>_TOKEN_<NAME>`, then the profile's entry. */
32
+ readSecret(profile: string, name: string): StoredCredential | undefined;
33
+ /** A named secret, kept in the profile's one entry beside its token; where the entry is now when not given. */
34
+ writeSecret(profile: string, name: string, secret: string, storage?: TokenStorage): CredentialSource;
35
+ /** Forgets one named secret; the token and the others stay. An entry left empty is removed. */
36
+ removeSecret(profile: string, name: string): CredentialSource[];
37
+ /** The variable that overrides a named secret: `PBX_TOKEN_SSH` for `ssh`. */
38
+ secretVariable(name: string): string;
25
39
  /** The profile's token, or the one "not signed in" refusal every token CLI gives, naming the command to fix it. */
26
40
  need(profile: string): string;
27
41
  /** For `appMcpCommand`'s `signedIn`: a keyring that cannot be read counts as not signed in. */
@@ -1,16 +1,60 @@
1
1
  import { CliError, Credentials, isMovedRun, resolvePaths, } from "@wirecat/cli-base";
2
2
  import { envName } from "../ports/app.js";
3
+ /**
4
+ * What one profile's entry holds when it keeps more than its token: the token and named secrets, as one JSON value
5
+ * after a prefix no typed password starts with. A plain value is the token alone, as every entry written before.
6
+ */
7
+ const ENVELOPE = "wirecat-secrets:v1:";
8
+ const SECRET_NAME = /^[a-z][a-z0-9-]{0,31}$/;
9
+ const checkName = (name) => {
10
+ if (!SECRET_NAME.test(name) || name === "token")
11
+ throw new CliError("validation_error", "a secret's name is a-z, 0-9 and -, up to 32 characters, and not token", {
12
+ reason: "input.invalid",
13
+ });
14
+ };
15
+ const unpack = (value) => {
16
+ if (value === undefined)
17
+ return { secrets: {} };
18
+ if (!value.startsWith(ENVELOPE))
19
+ return { token: value, secrets: {} };
20
+ try {
21
+ const parsed = JSON.parse(value.slice(ENVELOPE.length));
22
+ const secrets = parsed.secrets && typeof parsed.secrets === "object" ? parsed.secrets : {};
23
+ return {
24
+ ...(typeof parsed.token === "string" ? { token: parsed.token } : {}),
25
+ secrets: Object.fromEntries(Object.entries(secrets).filter((entry) => typeof entry[1] === "string")),
26
+ };
27
+ }
28
+ catch {
29
+ throw new CliError("configuration_error", "this profile's stored secrets cannot be read; run session start again", {
30
+ reason: "session.unreadable",
31
+ });
32
+ }
33
+ };
34
+ /** The token alone stays a plain value, so an entry with nothing else in it reads as before. */
35
+ const pack = (held) => {
36
+ if (Object.keys(held.secrets).length === 0)
37
+ return held.token;
38
+ return `${ENVELOPE}${JSON.stringify({ ...(held.token === undefined ? {} : { token: held.token }), secrets: held.secrets })}`;
39
+ };
3
40
  /**
4
41
  * One API token per profile for a CLI that is not a messenger: `<PREFIX>_TOKEN`, then the keyring entry
5
42
  * `token:<profile>` under the app's own service, then a 0600 file (WC-SECR-4). A run with moved folders reads the
6
43
  * owner's entry and never replaces or deletes it: it writes a temporary `<app>:<config folder>` entry instead
7
44
  * (WC-SECR-24, cli-base `Credentials`).
45
+ *
46
+ * A profile that needs a second secret (a database password and an SSH password) keeps it in the same entry, by
47
+ * name: `writeSecret(profile, "ssh", …)`. The entry then holds the token and the named secrets as one value, as an
48
+ * OAuth entry holds its tokens and client secret; the keyring gets no second entry. `<PREFIX>_TOKEN_<NAME>` overrides
49
+ * one for CI, as `<PREFIX>_TOKEN` does the token.
8
50
  */
9
51
  export class ProfileTokenStore {
10
52
  variable;
11
53
  #app;
12
54
  #options;
13
55
  #credentials;
56
+ /** The same entry without the environment variable, for the value a write merges into. */
57
+ #stored;
14
58
  constructor({ app, env = process.env, keyring, warn }) {
15
59
  const where = { appName: app.appName, prefix: app.envPrefix, env };
16
60
  this.#app = app;
@@ -25,15 +69,70 @@ export class ProfileTokenStore {
25
69
  warn: warn ?? ((message) => process.stderr.write(`${message}\n`)),
26
70
  };
27
71
  this.#credentials = new Credentials(this.#options);
72
+ const { envVar: _, ...stored } = this.#options;
73
+ this.#stored = new Credentials(stored);
28
74
  }
29
75
  read(profile) {
30
- return this.#credentials.read(accountOf(profile));
76
+ const found = this.#credentials.read(accountOf(profile));
77
+ if (!found || found.source === "environment")
78
+ return found;
79
+ const { token } = unpack(found.secret);
80
+ return token === undefined ? undefined : { secret: token, source: found.source };
31
81
  }
32
- /** `file` also forgets the keyring copy, so a later read cannot find the token the owner asked to keep elsewhere. */
82
+ /** The token; the profile's named secrets stay as they were. */
33
83
  write(profile, token, storage = "keyring") {
84
+ const held = this.#held(profile);
85
+ return this.#put(profile, { ...held, token }, storage);
86
+ }
87
+ /** The token and every named secret: the whole entry, as `session end` wants. */
88
+ remove(profile) {
89
+ return this.#credentials.remove(accountOf(profile));
90
+ }
91
+ /** A named secret: `<PREFIX>_TOKEN_<NAME>`, then the profile's entry. */
92
+ readSecret(profile, name) {
93
+ checkName(name);
94
+ const variable = this.secretVariable(name);
95
+ const given = this.#options.env?.[variable];
96
+ if (given)
97
+ return { secret: given, source: "environment" };
98
+ const found = this.#stored.read(accountOf(profile));
99
+ const secret = found ? unpack(found.secret).secrets[name] : undefined;
100
+ return found && secret !== undefined ? { secret, source: found.source } : undefined;
101
+ }
102
+ /** A named secret, kept in the profile's one entry beside its token; where the entry is now when not given. */
103
+ writeSecret(profile, name, secret, storage) {
104
+ checkName(name);
105
+ const found = this.#stored.read(accountOf(profile));
106
+ const held = unpack(found?.secret);
107
+ const where = storage ?? (found?.source === "file" ? "file" : "keyring");
108
+ return this.#put(profile, { ...held, secrets: { ...held.secrets, [name]: secret } }, where);
109
+ }
110
+ /** Forgets one named secret; the token and the others stay. An entry left empty is removed. */
111
+ removeSecret(profile, name) {
112
+ checkName(name);
113
+ const held = this.#held(profile);
114
+ if (!(name in held.secrets))
115
+ return [];
116
+ const { [name]: _, ...secrets } = held.secrets;
117
+ const left = { ...held, secrets };
118
+ if (pack(left) === undefined)
119
+ return this.remove(profile);
120
+ const found = this.#stored.read(accountOf(profile));
121
+ return [this.#put(profile, left, found?.source === "file" ? "file" : "keyring")];
122
+ }
123
+ /** The variable that overrides a named secret: `PBX_TOKEN_SSH` for `ssh`. */
124
+ secretVariable(name) {
125
+ return `${this.variable}_${name.toUpperCase().replaceAll("-", "_")}`;
126
+ }
127
+ #held(profile) {
128
+ return unpack(this.#stored.read(accountOf(profile))?.secret);
129
+ }
130
+ /** `file` also forgets the keyring copy, so a later read cannot find the secret the owner asked to keep elsewhere. */
131
+ #put(profile, held, storage) {
132
+ const value = pack(held);
34
133
  if (storage === "keyring")
35
- return this.#credentials.write(accountOf(profile), token, { signIn: true });
36
- const kept = new Credentials({ ...this.#options, storage: "file" }).write(accountOf(profile), token);
134
+ return this.#stored.write(accountOf(profile), value, { signIn: true });
135
+ const kept = new Credentials({ ...this.#options, storage: "file" }).write(accountOf(profile), value);
37
136
  try {
38
137
  new Credentials({ ...this.#options, storage: "keyring" }).remove(accountOf(profile));
39
138
  }
@@ -42,9 +141,6 @@ export class ProfileTokenStore {
42
141
  }
43
142
  return kept;
44
143
  }
45
- remove(profile) {
46
- return this.#credentials.remove(accountOf(profile));
47
- }
48
144
  /** The profile's token, or the one "not signed in" refusal every token CLI gives, naming the command to fix it. */
49
145
  need(profile) {
50
146
  const stored = this.read(profile);
@@ -22,7 +22,7 @@ import { commandPathOf } from "./command-contract.js";
22
22
  import { enterCommandServer } from "./command-server.js";
23
23
  import { exitCodeSet } from "./command-server-request.js";
24
24
  import { entityRows } from "./compact.js";
25
- import { outputFor, provide } from "./context.js";
25
+ import { outputFieldsOf, outputFor, provide } from "./context.js";
26
26
  import { refuseByCommandPermissions, refuseOfflineCommand, refuseWriteBeforeConnecting } from "./early-refusal.js";
27
27
  import { admittedUnderLock, changesAuthorityAt, changesAuthorityNow, fetchesOnlyAt, fileOptionOf, isLogin, isStoreChange, judgedEffects, judgedTargets, storeChangeRefusal, } from "./effects.js";
28
28
  import { itemOf, renderAnswer, snakeKeys } from "./envelope.js";
@@ -316,7 +316,7 @@ const runOnce = async (argv, definition, options) => {
316
316
  checkJson(action, requested, !flags.jsonl && (options.tty ?? process.stdout.isTTY) === true);
317
317
  control.configure({
318
318
  // Beside `--format csv`, `--json=a,b` names the table's columns: a CSV is no JSON to pick fields from.
319
- ...(flags.fields === undefined || action.getOptionValue("format") === "csv" ? {} : { fields: flags.fields }),
319
+ ...(action.getOptionValue("format") === "csv" ? {} : outputFieldsOf(action)),
320
320
  maxOutputBytes: flags.maxOutputBytes === undefined
321
321
  ? machine || (options.tty ?? process.stdout.isTTY) !== true
322
322
  ? DEFAULT_OUTPUT_BYTES
@@ -43,6 +43,17 @@ export type DeepLinkTarget = {
43
43
  | {
44
44
  type: "project";
45
45
  id: string;
46
+ }
47
+ /**
48
+ * A call or meeting by the provider's own ids, as a message link names its message: the provider (`asterisk`,
49
+ * `zoom`), the account as the provider knows it, and the meeting's id there. Built only from this target, never from
50
+ * a store reference: `meeting:<account>/<meeting>` names store rows.
51
+ */
52
+ | {
53
+ type: "meeting";
54
+ provider: string;
55
+ account: string;
56
+ meeting: string;
46
57
  };
47
58
  export type LinkForm = "web" | "app";
48
59
  export interface LinkConfig {
@@ -26,6 +26,8 @@ const partsOf = (target) => {
26
26
  return ["digest", target.date];
27
27
  case "sync":
28
28
  return target.account === undefined ? ["sync", target.tool] : ["sync", target.tool, target.account];
29
+ case "meeting":
30
+ return ["meeting", target.provider, target.account, target.meeting];
29
31
  }
30
32
  };
31
33
  /** The path after the version, `msg/max/1001/-2002/3003`: each part percent-encoded, so no id can add a part. */
@@ -56,6 +58,8 @@ const targetOfParts = (parts) => {
56
58
  return rest.length === 1 || rest.length === 2
57
59
  ? { type: "sync", tool: a, ...(rest.length === 2 ? { account: b } : {}) }
58
60
  : null;
61
+ case "meeting":
62
+ return rest.length === 3 ? { type: "meeting", provider: a, account: b, meeting: c } : null;
59
63
  default:
60
64
  return null;
61
65
  }
@@ -0,0 +1,10 @@
1
+ import * as v from "valibot";
2
+ /** `models chats`: whether chat text may go to a model outside this computer. */
3
+ export declare const chatSending: v.StrictObjectSchema<{
4
+ readonly mode: v.PicklistSchema<["allowed", "ask", "denied"], undefined>;
5
+ readonly meaning: v.StringSchema<undefined>;
6
+ /** When the owner last set it; `null` while it is the default, ask. */
7
+ readonly since: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
8
+ /** `set` only: whether this run changed it. */
9
+ readonly changed: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
10
+ }, undefined>;