@wirecat/cli-core 0.659.0 → 0.661.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 (89) hide show
  1. package/CHANGELOG.md +119 -0
  2. package/dist/attachments/markup.js +2 -11
  3. package/dist/calendar/mcp/index.d.ts +12 -12
  4. package/dist/calendar/mcp/index.js +23 -17
  5. package/dist/cli/ask-before-write.d.ts +8 -0
  6. package/dist/cli/ask-before-write.js +28 -0
  7. package/dist/cli/bot/api-http.d.ts +43 -0
  8. package/dist/cli/bot/api-http.js +160 -0
  9. package/dist/cli/index.d.ts +2 -0
  10. package/dist/cli/index.js +2 -0
  11. package/dist/cli/messenger/rankings-command.js +2 -1
  12. package/dist/cli/messenger/serve-command.js +7 -2
  13. package/dist/cli/messenger/tasks-command.d.ts +7 -2
  14. package/dist/cli/messenger/tasks-command.js +6 -3
  15. package/dist/cli/schedule/schedule-command.js +3 -0
  16. package/dist/domain/html-entities.d.ts +5 -0
  17. package/dist/domain/html-entities.js +56 -0
  18. package/dist/domain/locator.js +12 -4
  19. package/dist/domain/providers.js +1 -1
  20. package/dist/domain/references.js +11 -3
  21. package/dist/entities/index.d.ts +33 -93
  22. package/dist/entities/listings.d.ts +4 -4
  23. package/dist/entities/listings.js +2 -2
  24. package/dist/errors/reasons.js +12 -0
  25. package/dist/index.d.ts +1 -1
  26. package/dist/index.js +1 -1
  27. package/dist/mail/headers.js +3 -3
  28. package/dist/mail/parse.js +9 -8
  29. package/dist/mail/resume.d.ts +4 -1
  30. package/dist/mail/resume.js +11 -2
  31. package/dist/mail/retry.d.ts +2 -1
  32. package/dist/mail/retry.js +6 -4
  33. package/dist/mail/sender-scores.js +1 -6
  34. package/dist/mail/stored.d.ts +4 -1
  35. package/dist/mail/stored.js +6 -1
  36. package/dist/mail/sync.js +8 -3
  37. package/dist/mail/testing/fake.d.ts +2 -0
  38. package/dist/mail/testing/fake.js +3 -1
  39. package/dist/mcp/all-profiles.js +8 -18
  40. package/dist/mcp/app-server.js +1 -16
  41. package/dist/mcp/bot/server.js +9 -7
  42. package/dist/mcp/caller.js +2 -1
  43. package/dist/mcp/prompts.js +17 -2
  44. package/dist/mcp/server.js +10 -16
  45. package/dist/mcp/stdio-wire.d.ts +5 -2
  46. package/dist/mcp/stdio-wire.js +39 -12
  47. package/dist/mcp/tool.js +3 -1
  48. package/dist/mcp/tools/messages-photo.js +4 -2
  49. package/dist/meetings/answers.d.ts +35 -27
  50. package/dist/meetings/answers.js +3 -2
  51. package/dist/meetings/cli/index.d.ts +13 -0
  52. package/dist/meetings/cli/index.js +61 -16
  53. package/dist/meetings/cli/management.d.ts +16 -0
  54. package/dist/meetings/cli/management.js +90 -0
  55. package/dist/meetings/cli/search.js +8 -2
  56. package/dist/meetings/hit-query.js +11 -6
  57. package/dist/meetings/index.d.ts +5 -3
  58. package/dist/meetings/index.js +4 -2
  59. package/dist/meetings/item.d.ts +33 -19
  60. package/dist/meetings/item.js +29 -4
  61. package/dist/meetings/mcp/index.d.ts +15 -15
  62. package/dist/meetings/pull.d.ts +27 -2
  63. package/dist/meetings/pull.js +103 -78
  64. package/dist/meetings/read-through.d.ts +74 -0
  65. package/dist/meetings/read-through.js +330 -0
  66. package/dist/meetings/reads.d.ts +1 -0
  67. package/dist/meetings/reads.js +4 -2
  68. package/dist/meetings/result-items.d.ts +31 -0
  69. package/dist/meetings/result-items.js +31 -0
  70. package/dist/meetings/source.d.ts +47 -0
  71. package/dist/meetings/store.d.ts +7 -0
  72. package/dist/meetings/testing/memory.js +8 -1
  73. package/dist/search/service-query.d.ts +63 -0
  74. package/dist/search/service-query.js +57 -0
  75. package/dist/sends/guard.js +7 -1
  76. package/dist/sends/permissions.js +4 -0
  77. package/dist/services/listings.js +2 -1
  78. package/dist/services/message-resolution.js +6 -3
  79. package/dist/services/messages-search.js +3 -4
  80. package/dist/services/server-search.d.ts +2 -1
  81. package/dist/services/server-search.js +36 -32
  82. package/dist/store/sqlite/meetings.js +15 -1
  83. package/dist/store/sqlite/mention-drain.d.ts +4 -1
  84. package/dist/store/sqlite/mention-drain.js +7 -3
  85. package/dist/store/sqlite/messages.js +12 -1
  86. package/dist/store/sqlite/query-filter.d.ts +1 -0
  87. package/dist/store/sqlite/query-filter.js +2 -2
  88. package/dist/store/sqlite/tags.js +1 -1
  89. package/package.json +1 -1
@@ -1,5 +1,6 @@
1
1
  import { type Command } from "commander";
2
2
  import { type ImportFile } from "../import.js";
3
+ import type { MeetingManagement } from "../meeting-management.js";
3
4
  import { type MeetingBudget } from "../pull.js";
4
5
  import type { MeetingSource } from "../source.js";
5
6
  import type { MeetingStore } from "../store.js";
@@ -31,6 +32,18 @@ export interface MeetingCommandDeps {
31
32
  */
32
33
  budgetOf?: (command: Command) => MeetingBudget;
33
34
  now?: () => number;
35
+ /** The owner's zone, in which `meetings list` reads a query's dates on both sides; the computer's without it. */
36
+ timezone?: string;
37
+ /**
38
+ * The service's meeting writes, `createMeetingManagement(scope, ports)`: `meetings create|update|cancel|invitation`
39
+ * are mounted for the ports it has.
40
+ */
41
+ management?: MeetingManagement;
42
+ /**
43
+ * Puts the profile's question before a write to the service: `askBeforeWrite` from `@wirecat/cli-core/cli`, which
44
+ * asks when the command's key is at `ask` and refuses when nobody can answer. Without it the writes refuse.
45
+ */
46
+ askFirst?: (command: Command) => Promise<void>;
34
47
  }
35
48
  export { addMeetingPassageCommand, createMeetingPassageCommand, type MeetingPassageFlags, meetingPassageRequest, } from "./passage.js";
36
49
  export { addMeetingProjectEvidenceCommand } from "./project-evidence.js";
@@ -4,11 +4,14 @@ import { InvalidArgumentError, Option } from "commander";
4
4
  import { EVENT_QUERY } from "../event-query.js";
5
5
  import { exportMeeting } from "../export.js";
6
6
  import { importFiles } from "../import.js";
7
+ import { BACKENDS } from "../index.js";
7
8
  import { MEETING_QUERY } from "../item.js";
8
9
  import { pull } from "../pull.js";
9
10
  import { eventItem } from "../read-answers.js";
10
- import { listed, MEETING_QUERY_GUIDE, MeetingError, meetingDetailsAnswer, meetingPeople, meetingSummaryAnswer, meetingsList, meetingsQuery, meetingTranscriptAnswer, } from "../reads.js";
11
+ import { meetingShowThrough, meetingsListThrough } from "../read-through.js";
12
+ import { listed, MEETING_QUERY_GUIDE, MeetingError, meetingDetailsBody, meetingPeople, meetingSummaryAnswer, meetingsQuery, meetingTranscriptAnswer, } from "../reads.js";
11
13
  import { SAVE_HELP } from "../save-hints.js";
14
+ import { addMeetingManagementCommands } from "./management.js";
12
15
  import { queryWordsAfterOptions } from "./query-options.js";
13
16
  const integer = (text) => {
14
17
  if (!/^[1-9]\d*$/.test(text) || !Number.isSafeInteger(Number(text)))
@@ -29,6 +32,17 @@ const date = (text) => {
29
32
  }
30
33
  };
31
34
  const LOCAL_READ = { remote: "none", local: "read" };
35
+ /** Reads the service; what it returns is kept as `sync` keeps it, which counts as a read (WC-CMD-17). */
36
+ const REMOTE_READ = { remote: "read", local: "read" };
37
+ const backendOf = (value) => {
38
+ if (!BACKENDS.includes(value))
39
+ throw new InvalidArgumentError("expected archive, server or both");
40
+ return value;
41
+ };
42
+ // No commander default: an untyped --backend falls back to the store with a `missing` line, a typed one refuses.
43
+ const backendOption = (command) => command.option("--backend <archive|server|both>", "where to read: the store (archive), the service (server), or both, kept in the store (default: both)", backendOf);
44
+ const BACKEND_HELP = "--backend both asks the service with the part of the query it can filter, keeps what it returns, then runs the " +
45
+ "whole query over the store; each item says found_in archive, server or both. --offline reads the store only.";
32
46
  const LOCAL_WRITE = { remote: "none", local: "write" };
33
47
  const FETCH = { remote: "read", local: "write" };
34
48
  const addMeetingCommandsDefinition = (program, deps) => {
@@ -47,27 +61,50 @@ const addMeetingCommandsDefinition = (program, deps) => {
47
61
  const opts = command.optsWithGlobals();
48
62
  deps.write(value, opts.json ? "json" : opts.jsonl ? "jsonl" : "text");
49
63
  };
50
- const list = queryWordsAfterOptions(group.command("list").description("stored meetings, newest first"))
64
+ const access = (command, backend) => ({
65
+ ...(backend === undefined ? {} : { backend }),
66
+ offline: command.optsWithGlobals().offline === true,
67
+ timezone: timezoneOf(deps.timezone),
68
+ ...(deps.now ? { now: deps.now() } : {}),
69
+ });
70
+ const list = queryWordsAfterOptions(group.command("list").description("meetings, newest first: the service's and the stored ones, kept in the store"))
51
71
  .argument("[query...]", "field:value terms that narrow the list — the fields are below")
52
- .addHelpText("after", `\n${fieldsHelp(MEETING_QUERY, MEETING_QUERY_GUIDE)}`);
53
- annotate(list, { effects: LOCAL_READ, query: defineQuery(MEETING_QUERY), output: { entity: "meeting" } });
54
- output(list)
72
+ .addHelpText("after", `\n${fieldsHelp(MEETING_QUERY, MEETING_QUERY_GUIDE)}\n${BACKEND_HELP}`);
73
+ annotate(list, {
74
+ effects: REMOTE_READ,
75
+ partial: true,
76
+ query: defineQuery(MEETING_QUERY),
77
+ output: { entity: "meeting" },
78
+ });
79
+ backendOption(output(list))
55
80
  .option("--limit <n>", "meetings per page", integer, 100)
56
81
  .option("--page <n>", "page number", integer, 1)
57
82
  .action(async (words, opts, command) => {
58
83
  const query = meetingsQuery(words.join(" "));
59
- print(await meetingsList(deps.store, {
60
- accountId: deps.accountId,
61
- limit: opts.limit,
62
- offset: (opts.page - 1) * opts.limit,
63
- ...(query ? { query } : {}),
64
- }), command);
84
+ await deps.inRun(command, async () => {
85
+ // The standard envelope has no place for the counts; what the reader must know is in `missing` and `meta`.
86
+ const { server: _server, ...answer } = await meetingsListThrough(deps.source, deps.store, {
87
+ accountId: deps.accountId,
88
+ limit: opts.limit,
89
+ offset: (opts.page - 1) * opts.limit,
90
+ ...(query ? { query } : {}),
91
+ }, access(command, opts.backend));
92
+ print(answer, command);
93
+ });
65
94
  });
66
- output(annotate(group.command("show"), { effects: LOCAL_READ, output: { entity: "meeting_details" } })
67
- .description("show a stored meeting")
68
- .argument("<meeting>", "stored meeting id", integer)
69
- .addHelpText("after", SAVE_HELP)).action(async (id, _opts, command) => {
70
- print(await meetingDetailsAnswer(deps.store, id, deps.accountId), command);
95
+ backendOption(output(annotate(group.command("show"), { effects: REMOTE_READ, partial: true, output: { entity: "meeting_details" } })
96
+ .description("show a meeting, read again from the service with its people, transcript and documents")
97
+ .argument("<meeting>", "the stored meeting's number, its meeting: ref, or the service's id (provider_id)")
98
+ .addHelpText("after", `${SAVE_HELP}\n${BACKEND_HELP}`))).action(async (meeting, opts, command) => {
99
+ await deps.inRun(command, async () => {
100
+ const shown = await meetingShowThrough(deps.source, deps.store, deps.accountId, meeting, access(command, opts.backend));
101
+ const { item } = await meetingDetailsBody(deps.store, shown.details);
102
+ print({
103
+ item: shown.foundIn ? { ...item, found_in: shown.foundIn } : item,
104
+ ...(shown.missing ? { missing: shown.missing } : {}),
105
+ ...(shown.meta ? { meta: shown.meta } : {}),
106
+ }, command);
107
+ });
71
108
  });
72
109
  output(annotate(group.command("transcript"), { effects: LOCAL_READ, output: { entity: "meeting_transcript" } })
73
110
  .description("show current meeting transcripts")
@@ -178,6 +215,14 @@ const addMeetingCommandsDefinition = (program, deps) => {
178
215
  now: deps.now?.() ?? Date.now(),
179
216
  }), command);
180
217
  });
218
+ if (deps.management)
219
+ addMeetingManagementCommands(group, {
220
+ management: deps.management,
221
+ print,
222
+ output,
223
+ inRun: deps.inRun,
224
+ ...(deps.askFirst ? { askFirst: deps.askFirst } : {}),
225
+ });
181
226
  const eventList = queryWordsAfterOptions(annotate(program.command("events").description("the owner's stored events"), {
182
227
  effects: { remote: "none", local: "none" },
183
228
  }).command("list"))
@@ -0,0 +1,16 @@
1
+ import { type Command } from "commander";
2
+ import type { MeetingManagement } from "../meeting-management.js";
3
+ export interface MeetingManagementCommandDeps {
4
+ management: MeetingManagement;
5
+ print: (value: unknown, command: Command) => void;
6
+ output: (command: Command) => Command;
7
+ inRun: <T>(command: Command, body: () => Promise<T>) => Promise<T>;
8
+ /** The profile's question before a write reaches the service (`MeetingCommandDeps.askFirst`). */
9
+ askFirst?: (command: Command) => Promise<void>;
10
+ }
11
+ /**
12
+ * `meetings create|update|cancel|invitation` for a service that lets the owner change its meetings: each mounted only
13
+ * where the host's ports have it. A write's key is its path (`meetings.create`), asked first by default; `--dry-run`
14
+ * previews it without reaching the service.
15
+ */
16
+ export declare const addMeetingManagementCommands: (group: Command, deps: MeetingManagementCommandDeps) => void;
@@ -0,0 +1,90 @@
1
+ import { CliError } from "@wirecat/cli-base";
2
+ import { annotate } from "@wirecat/cli-base/commands";
3
+ import { InvalidArgumentError, Option } from "commander";
4
+ const REMOTE_READ = { remote: "read", local: "read" };
5
+ const REMOTE_WRITE = { remote: "write", local: "write" };
6
+ const minutes = (text) => {
7
+ if (!/^[1-9]\d*$/.test(text))
8
+ throw new InvalidArgumentError("expected whole minutes");
9
+ return Number(text);
10
+ };
11
+ const changeOptions = (command) => command
12
+ .option("--title <title>", "the meeting's title")
13
+ .addOption(new Option("--kind <kind>", "an instant or a scheduled meeting").choices(["instant", "scheduled"]))
14
+ .option("--start-time <time>", "when it starts: an ISO time with its offset, 2026-11-20T10:00:00+01:00")
15
+ .option("--duration-minutes <minutes>", "how long it lasts, 1–1440", minutes)
16
+ .option("--timezone <zone>", "its IANA time zone, Europe/Madrid")
17
+ .option("--agenda <text>", "its agenda");
18
+ const changeOf = (flags) => Object.fromEntries(["title", "kind", "startTime", "durationMinutes", "timezone", "agenda"].flatMap((key) => flags[key] === undefined ? [] : [[key, flags[key]]]));
19
+ const meetingOf = (one) => ({
20
+ id: one.id,
21
+ title: one.title,
22
+ kind: one.kind,
23
+ start_time: one.startTime,
24
+ duration_minutes: one.durationMinutes,
25
+ timezone: one.timezone,
26
+ agenda: one.agenda,
27
+ join_url: one.joinUrl,
28
+ });
29
+ const receiptItem = (receipt) => {
30
+ const { change } = receipt;
31
+ return {
32
+ action: receipt.action,
33
+ provider: receipt.scope.provider,
34
+ account: receipt.scope.account,
35
+ ...(receipt.id === undefined ? {} : { id: receipt.id }),
36
+ ...(receipt.occurrenceId === undefined ? {} : { occurrence_id: receipt.occurrenceId }),
37
+ ...(change
38
+ ? {
39
+ change: {
40
+ ...(change.title === undefined ? {} : { title: change.title }),
41
+ ...(change.kind === undefined ? {} : { kind: change.kind }),
42
+ ...(change.startTime === undefined ? {} : { start_time: change.startTime }),
43
+ ...(change.durationMinutes === undefined ? {} : { duration_minutes: change.durationMinutes }),
44
+ ...(change.timezone === undefined ? {} : { timezone: change.timezone }),
45
+ ...(change.agenda === undefined ? {} : { agenda: change.agenda }),
46
+ },
47
+ }
48
+ : {}),
49
+ applied: receipt.applied,
50
+ ...(receipt.meeting ? { meeting: meetingOf(receipt.meeting) } : {}),
51
+ };
52
+ };
53
+ /**
54
+ * `meetings create|update|cancel|invitation` for a service that lets the owner change its meetings: each mounted only
55
+ * where the host's ports have it. A write's key is its path (`meetings.create`), asked first by default; `--dry-run`
56
+ * previews it without reaching the service.
57
+ */
58
+ export const addMeetingManagementCommands = (group, deps) => {
59
+ const { management, print, output, inRun, askFirst } = deps;
60
+ const has = (name) => management.capabilities.includes(name);
61
+ // A write the owner could not be asked about never goes: a host that forgets the question gets a refusal.
62
+ const mutation = async (command) => {
63
+ const dryRun = command.optsWithGlobals().dryRun === true;
64
+ if (!dryRun) {
65
+ if (!askFirst)
66
+ throw new CliError("configuration_error", "this tool cannot ask before it changes a meeting on the service");
67
+ await askFirst(command);
68
+ }
69
+ return { apply: true, dryRun };
70
+ };
71
+ const write = (name) => annotate(group.command(name), { effects: REMOTE_WRITE, offline: false, output: { entity: "meeting_change" } });
72
+ const target = (command) => command.argument("<meeting>", "the service's id of the meeting");
73
+ if (has("create"))
74
+ output(changeOptions(write("create").description("create a meeting on the service"))).action(async (flags, command) => inRun(command, async () => print({ item: receiptItem(await management.create(changeOf(flags), await mutation(command))) }, command)));
75
+ if (has("update"))
76
+ output(changeOptions(target(write("update").description("change a meeting on the service")))).action(async (id, flags, command) => inRun(command, async () => print({ item: receiptItem(await management.update(id, changeOf(flags), await mutation(command))) }, command)));
77
+ if (has("cancel"))
78
+ output(target(write("cancel").description("cancel a meeting on the service")).option("--occurrence-id <id>", "cancel only this occurrence of a repeating meeting")).action(async (id, flags, command) => inRun(command, async () => print({
79
+ item: receiptItem(await management.cancel(id, {
80
+ ...(await mutation(command)),
81
+ ...(flags.occurrenceId === undefined ? {} : { occurrenceId: flags.occurrenceId }),
82
+ })),
83
+ }, command)));
84
+ if (has("invitation"))
85
+ output(target(annotate(group.command("invitation"), {
86
+ effects: REMOTE_READ,
87
+ offline: false,
88
+ output: { entity: "meeting_invitation" },
89
+ }).description("the invitation text the service writes for a meeting"))).action(async (id, _flags, command) => inRun(command, async () => print({ item: { ...(await management.invitation(id)), untrusted: ["invitation"] } }, command)));
90
+ };
@@ -6,14 +6,20 @@ import { meetingHitsList } from "../answers.js";
6
6
  import { validateMeetingHitSearch } from "../search-validation.js";
7
7
  export { validateMeetingHitSearch } from "../search-validation.js";
8
8
  const ZONED = /(?:Z|[+-]\d{2}:?\d{2})$/i;
9
+ // `30m`, `2h`, `7d` ago, as the messenger commands' --since-time reads them and this command's `date>=7d` does.
10
+ const AGO = /^(\d+)(m|h|d)$/;
11
+ const AGO_MS = { m: 60_000, h: 3_600_000, d: 86_400_000 };
9
12
  const moment = (flag, end, readIn) => (value) => {
13
+ const [, amount, unit] = AGO.exec(value.trim()) ?? [];
14
+ if (amount && unit)
15
+ return Date.now() - Number(amount) * (AGO_MS[unit] ?? 0);
10
16
  const zone = timezoneOf();
11
17
  let time;
12
18
  try {
13
19
  time = zonedMoment(value, zone, { start: 0, end: value.length }, { end });
14
20
  }
15
21
  catch {
16
- throw new CliError("validation_error", `${flag} takes an ISO date, or a time with or without an offset`);
22
+ throw new CliError("validation_error", `${flag} takes an ISO date, a time with or without an offset, or 30m, 2h, 7d ago`);
17
23
  }
18
24
  if (!ZONED.test(value.trim()))
19
25
  readIn(zone);
@@ -44,7 +50,7 @@ const createMeetingSearchCommandDefinition = (program) => {
44
50
  .option("--project <project>", "meetings confirmed in this project, by name, key or alias")
45
51
  .option("--tag <name>", "meetings with this tag, by name or alias")
46
52
  .option("--topic-name <name>", "meetings with this topic, by name or alias")
47
- .option("--since-time <time>", "meetings starting at or after this ISO 8601 date or time", moment("--since-time", false, readIn))
53
+ .option("--since-time <time>", "meetings starting at or after this ISO 8601 date or time, or 30m, 2h, 7d ago", moment("--since-time", false, readIn))
48
54
  .option("--until-time <time>", "meetings starting at or before this ISO 8601 date or time; a date alone covers that whole local day", moment("--until-time", true, readIn))
49
55
  .option("--limit <n>", "how many hits, 1 through 1000 (default 100)", integer)
50
56
  .option("--cursor <cursor>", "continue from the previous page's page.next_cursor, with the same query and filters")
@@ -101,13 +101,16 @@ export const liftMeetingFields = (query, request, now, timezone) => {
101
101
  };
102
102
  for (const { node } of lifted) {
103
103
  if (node.field === "date") {
104
- once("since", "--since-time");
105
- once("until", "--until-time");
106
104
  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
- if (range.lower !== undefined)
105
+ // Only the bound the query sets clashes with a flag: `date>=30d --until-time …` is one window.
106
+ if (range.lower !== undefined) {
107
+ once("since", "--since-time");
108
108
  next.since = range.lower + (range.lower_inclusive ? 0 : 1);
109
- if (range.upper !== undefined)
109
+ }
110
+ if (range.upper !== undefined) {
111
+ once("until", "--until-time");
110
112
  next.until = range.upper - (range.upper_inclusive ? 0 : 1);
113
+ }
111
114
  }
112
115
  else {
113
116
  const field = node.field;
@@ -118,9 +121,11 @@ export const liftMeetingFields = (query, request, now, timezone) => {
118
121
  let rest = query;
119
122
  for (const { node } of [...lifted].sort((a, b) => b.node.span.start - a.node.span.start))
120
123
  rest = `${rest.slice(0, node.span.start)}${rest.slice(node.span.end)}`;
124
+ // The parser joins with AND, && or a leading +; a lifted field must not leave its joiner behind.
121
125
  rest = rest
122
- .replace(/^(?:\s*AND\b)+|(?:\bAND\s*)+$/g, "")
123
- .replace(/\bAND(\s+AND\b)+/g, "AND")
126
+ .replace(/(^|\s)\+(?=\s|$)/g, "$1")
127
+ .replace(/^(?:\s*(?:AND\b|&&))+|(?:(?:\bAND|&&)\s*)+$/g, "")
128
+ .replace(/(?:\bAND|&&)(\s+(?:AND\b|&&))+/g, "AND")
124
129
  .trim();
125
130
  if (!rest)
126
131
  throw new CliError("validation_error", "give words to find besides date:, project:, tag: and topic:");
@@ -1,3 +1,4 @@
1
+ export { BACKENDS, type Backend, type QueryTree, type ServiceCalls, type ServiceCapability, type ServiceOperator, serviceCallsOf, } from "../search/service-query.js";
1
2
  export { MEETING_STEPS, type MeetingDetailsItem, type MeetingHitItem, type MeetingItemBody, type MeetingListBody, type MeetingSummaryItem, type MeetingTranscriptItem, meetingDetails, meetingHit, meetingHitsList, meetingSummary, meetingTranscript, } from "./answers.js";
2
3
  export type { MeetingBatchReader } from "./batch.js";
3
4
  export { calendarText, ENTRY_METADATA_KEYS, entryMetadata, withoutLinkQueries } from "./calendar-text.js";
@@ -31,10 +32,11 @@ export { readMeetingProjectEvidence } from "./project-evidence.js";
31
32
  export { type MeetingProjectEvidenceAnswer, type MeetingProjectEvidenceItem, meetingProjectEvidence, meetingProjectEvidenceAnswer, } from "./project-evidence-answer.js";
32
33
  export { MEETING_PROJECT_EVIDENCE_QUERY, type MeetingProjectEvidenceRequest, prepareMeetingProjectEvidence, } from "./project-evidence-query.js";
33
34
  export { type MeetingProviderScope, snapshotMeetingScope } from "./provider.js";
34
- export { type MeetingBudget, type MeetingBudgetStop, type PullOptions, pull, type RunReport } from "./pull.js";
35
+ export { type MeetingBudget, type MeetingBudgetStop, type PullOptions, pull, type RunReport, type SourceMeetingParts, saveSourceMeeting, } from "./pull.js";
35
36
  export { event, eventItem, meetingCounts, meetingCountsItem, meetingLink, meetingLinkItem, meetingParticipants, meetingPassage, meetingReview, meetingReviewItem, meetingSpeaker, meetingSpeakerItem, meetingStats, meetingStatsItem, } from "./read-answers.js";
36
37
  export type { MeetingContextReadCapabilities, MeetingReadBudget, MeetingReadCapabilities, MeetingReadScope, TranscriptContextInput, TranscriptContextPage, TranscriptPage, TranscriptReadScope, TranscriptRowPage, } from "./read-store.js";
37
- export { listed, MeetingError, meetingDetailsAnswer, meetingPeople, meetingSummaryAnswer, meetingTranscriptAnswer, type TranscriptReadOptions, } from "./reads.js";
38
+ export { askServerForList, MEETING_SERVER_BOUNDS, type MeetingListThrough, type MeetingServerAccess, type MeetingServerReport, type MeetingServerSkip, type MeetingShowThrough, meetingShowThrough, meetingsListThrough, } from "./read-through.js";
39
+ export { listed, MeetingError, meetingDetailsAnswer, meetingDetailsBody, meetingPeople, meetingSummaryAnswer, meetingTranscriptAnswer, type TranscriptReadOptions, } from "./reads.js";
38
40
  export { installRecordingArchiveSchedule, parseRecordingArchiveSchedule, planRecordingArchiveSchedule, type RecordingArchiveSchedule, type RecordingArchiveScheduleInput, type RecordingArchiveScheduler, recordingArchiveScheduleWindow, } from "./recording-schedule.js";
39
41
  export type { ArchivedRecording, RecordingArchiveResult, RecordingAsset, RecordingAssetLocator, RecordingCatalog, RecordingOccurrence, RecordingPage, RecordingScope, RecordingWindow, } from "./recording-source.js";
40
42
  export { parseRecordingSyncCheckpoint, type RecordingSyncCheckpoint, type RecordingSyncCheckpointStore, type RecordingSyncEntry, RecordingSyncError, type RecordingSyncLease, type RecordingSyncOptions, type RecordingSyncReceipt, recordingAssetFingerprint, recordingWindows, syncRecordingArchive, } from "./recording-sync.js";
@@ -50,7 +52,7 @@ export { type MeetingHistoryEntry, type MeetingSeriesContext, type MeetingSeries
50
52
  export { createMeetingSeriesInventoryReader } from "./series-inventory.js";
51
53
  export type { MeetingSeriesCandidate, MeetingSeriesInventoryPage, MeetingSeriesInventoryPort, MeetingSeriesInventoryRead, MeetingSeriesInventoryRequest, MeetingSeriesInventoryResult, } from "./series-inventory-types.js";
52
54
  export { validateMeetingSeriesInventoryCursor } from "./series-inventory-validation.js";
53
- export type { MeetingSource, SourceParticipant } from "./source.js";
55
+ export type { FoundMeeting, FoundMeetings, FullMeeting, MeetingFinds, MeetingSource, MeetingTerm, MeetingWindow, SourceParticipant, } from "./source.js";
54
56
  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
57
  export type { ChatInput, ContractCase, EventCandidateFilter, IdentityInput, MeetingDetails, MeetingDocument, MeetingDocumentInput, MeetingDocumentRole, MeetingFilter, MeetingHitSource, MeetingInput, MeetingParticipant, MeetingSave, MeetingStore, NewRecord, ParticipantInput, SearchHit, TranscriptInput, TranscriptLanguageFill, TranscriptRowInput, } from "./store.js";
56
58
  export { MEETING_DOCUMENT_ROLES, READ_BUDGET_EXCEEDED } from "./store.js";
@@ -1,3 +1,4 @@
1
+ export { BACKENDS, serviceCallsOf, } from "../search/service-query.js";
1
2
  export { MEETING_STEPS, meetingDetails, meetingHit, meetingHitsList, meetingSummary, meetingTranscript, } from "./answers.js";
2
3
  export { calendarText, ENTRY_METADATA_KEYS, entryMetadata, withoutLinkQueries } from "./calendar-text.js";
3
4
  export { meetingCueFingerprint } from "./cue-fingerprint.js";
@@ -23,9 +24,10 @@ export { readMeetingProjectEvidence } from "./project-evidence.js";
23
24
  export { meetingProjectEvidence, meetingProjectEvidenceAnswer, } from "./project-evidence-answer.js";
24
25
  export { MEETING_PROJECT_EVIDENCE_QUERY, prepareMeetingProjectEvidence, } from "./project-evidence-query.js";
25
26
  export { snapshotMeetingScope } from "./provider.js";
26
- export { pull } from "./pull.js";
27
+ export { pull, saveSourceMeeting, } from "./pull.js";
27
28
  export { event, eventItem, meetingCounts, meetingCountsItem, meetingLink, meetingLinkItem, meetingParticipants, meetingPassage, meetingReview, meetingReviewItem, meetingSpeaker, meetingSpeakerItem, meetingStats, meetingStatsItem, } from "./read-answers.js";
28
- export { listed, MeetingError, meetingDetailsAnswer, meetingPeople, meetingSummaryAnswer, meetingTranscriptAnswer, } from "./reads.js";
29
+ export { askServerForList, MEETING_SERVER_BOUNDS, meetingShowThrough, meetingsListThrough, } from "./read-through.js";
30
+ export { listed, MeetingError, meetingDetailsAnswer, meetingDetailsBody, meetingPeople, meetingSummaryAnswer, meetingTranscriptAnswer, } from "./reads.js";
29
31
  export { installRecordingArchiveSchedule, parseRecordingArchiveSchedule, planRecordingArchiveSchedule, recordingArchiveScheduleWindow, } from "./recording-schedule.js";
30
32
  export { parseRecordingSyncCheckpoint, RecordingSyncError, recordingAssetFingerprint, recordingWindows, syncRecordingArchive, } from "./recording-sync.js";
31
33
  export { RecordingTransferError, strongRecordingValidator, transferRecording, } from "./recording-transfer.js";
@@ -8,27 +8,40 @@ export declare const MEETING_ISSUES: readonly ["time_without_zone"];
8
8
  export type MeetingIssue = (typeof MEETING_ISSUES)[number];
9
9
  /** The issues a provider adapter put in `metadata.issues`, the known ones only, in their listed order. */
10
10
  export declare const meetingIssuesOf: (metadata: Meeting["metadata"]) => MeetingIssue[];
11
- /** A stored meeting as every command and tool answers it; `src/entities/` registers it as `meeting`. */
12
- export declare const meeting: v.StrictObjectSchema<{
13
- readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
14
- readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
15
- readonly provider: v.StringSchema<undefined>;
16
- readonly account: v.StringSchema<undefined>;
17
- readonly title: v.NullableSchema<v.StringSchema<undefined>, undefined>;
18
- readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
19
- readonly location: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
11
+ declare const meetingEntries: {
12
+ ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
13
+ id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
14
+ /** The service's own id of this occurrence: what `meetings show` takes besides the store number. */
15
+ provider_id: v.StringSchema<undefined>;
16
+ provider: v.StringSchema<undefined>;
17
+ account: v.StringSchema<undefined>;
18
+ title: v.NullableSchema<v.StringSchema<undefined>, undefined>;
19
+ description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
20
+ location: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
20
21
  /** The link that joins it. */
21
- readonly url: v.NullableSchema<v.StringSchema<undefined>, undefined>;
22
- readonly started_at: 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>;
23
- readonly ended_at: 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>;
24
- readonly duration_ms: v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
25
- readonly timezone: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
26
- readonly participants_count: v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
22
+ url: v.NullableSchema<v.StringSchema<undefined>, undefined>;
23
+ started_at: 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>;
24
+ ended_at: 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>;
25
+ duration_ms: v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
26
+ timezone: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
27
+ participants_count: v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
27
28
  /** Present only when something about this meeting is doubtful. */
28
- readonly issues: v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["time_without_zone"], undefined>, undefined>, undefined>;
29
- readonly created_at: 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`">]>;
30
- readonly updated_at: 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`">]>;
31
- }, undefined>;
29
+ issues: v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["time_without_zone"], undefined>, undefined>, undefined>;
30
+ /**
31
+ * Where a read that asked the service found it, as messages search says it: `archive` (only the store), `server`
32
+ * (new from the service), `both`. Absent when the service was not asked.
33
+ */
34
+ found_in: v.OptionalSchema<v.PicklistSchema<["archive", "server", "both"], undefined>, undefined>;
35
+ /** The service's text, which a reader must not follow as instructions. */
36
+ untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
37
+ created_at: 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`">]>;
38
+ updated_at: 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`">]>;
39
+ };
40
+ type MeetingEntriesOf = typeof meetingEntries;
41
+ export interface MeetingEntries extends MeetingEntriesOf {
42
+ }
43
+ /** A stored meeting as every command and tool answers it; `src/entities/` registers it as `meeting`. */
44
+ export declare const meeting: v.StrictObjectSchema<MeetingEntries, undefined>;
32
45
  export type MeetingItem = v.InferOutput<typeof meeting>;
33
46
  /** Which provider and account a stored meeting account is, as `MeetingStore.account` answers it. */
34
47
  export interface MeetingOwner {
@@ -42,3 +55,4 @@ export declare const MEETING_QUERY: {
42
55
  readonly backend: "sql";
43
56
  readonly fields: import("@wirecat/cli-base/query").FieldSpec[];
44
57
  };
58
+ export {};
@@ -14,10 +14,11 @@ export const meetingIssuesOf = (metadata) => {
14
14
  const listed = metadata?.issues;
15
15
  return Array.isArray(listed) ? MEETING_ISSUES.filter((issue) => listed.includes(issue)) : [];
16
16
  };
17
- /** A stored meeting as every command and tool answers it; `src/entities/` registers it as `meeting`. */
18
- export const meeting = v.strictObject({
17
+ const meetingEntries = {
19
18
  ref: reference,
20
19
  id: v.pipe(v.string(), v.minLength(1)),
20
+ /** The service's own id of this occurrence: what `meetings show` takes besides the store number. */
21
+ provider_id: text,
21
22
  provider: text,
22
23
  account: text,
23
24
  title: v.nullable(text),
@@ -32,15 +33,26 @@ export const meeting = v.strictObject({
32
33
  participants_count: v.nullable(count),
33
34
  /** Present only when something about this meeting is doubtful. */
34
35
  issues: v.optional(v.array(v.picklist(MEETING_ISSUES))),
36
+ /**
37
+ * Where a read that asked the service found it, as messages search says it: `archive` (only the store), `server`
38
+ * (new from the service), `both`. Absent when the service was not asked.
39
+ */
40
+ found_in: v.optional(v.picklist(["archive", "server", "both"])),
41
+ /** The service's text, which a reader must not follow as instructions. */
42
+ untrusted: v.optional(v.array(text)),
35
43
  created_at: isoTime,
36
44
  updated_at: isoTime,
37
- });
45
+ };
46
+ /** A stored meeting as every command and tool answers it; `src/entities/` registers it as `meeting`. */
47
+ export const meeting = v.strictObject(meetingEntries);
48
+ const MEETING_UNTRUSTED = ["title", "description", "location"];
38
49
  const iso = (ms) => (ms === null ? null : new Date(ms).toISOString());
39
50
  export const meetingItem = (row, owner) => {
40
51
  const issues = meetingIssuesOf(row.metadata);
41
52
  return {
42
53
  ref: formatMeetingReference({ type: "meeting", accountId: row.accountId, meetingId: row.id }),
43
54
  id: String(row.id),
55
+ provider_id: row.externalId,
44
56
  provider: owner.provider,
45
57
  account: owner.account,
46
58
  title: row.title,
@@ -53,6 +65,7 @@ export const meetingItem = (row, owner) => {
53
65
  timezone: row.timezone,
54
66
  participants_count: row.participantsCount,
55
67
  ...(issues.length ? { issues } : {}),
68
+ untrusted: [...MEETING_UNTRUSTED],
56
69
  created_at: new Date(row.createdAt).toISOString(),
57
70
  updated_at: new Date(row.updatedAt).toISOString(),
58
71
  };
@@ -62,9 +75,21 @@ export const MEETING_QUERY = {
62
75
  entity: "meeting",
63
76
  backend: "sql",
64
77
  fields: queryFieldsOf(meeting, {
65
- exclude: ["ref", "provider", "account", "description", "location", "url", "timezone", "issues"],
78
+ exclude: [
79
+ "ref",
80
+ "provider",
81
+ "account",
82
+ "description",
83
+ "location",
84
+ "url",
85
+ "timezone",
86
+ "issues",
87
+ "found_in",
88
+ "untrusted",
89
+ ],
66
90
  examples: {
67
91
  id: "id:12",
92
+ provider_id: "provider_id:85746065432",
68
93
  title: "title:*standup*",
69
94
  started_at: "started_at:[2026-10-01 TO 2026-10-31]",
70
95
  duration_ms: "duration_ms>=3600000",