@wirecat/cli-core 0.667.0 → 0.668.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.
@@ -92,11 +92,16 @@ const fields = {
92
92
  description: { ...anyText, description: "empty clears it" },
93
93
  attendees: { type: "array", items: text, description: "email addresses; on a change, the whole new list" },
94
94
  repeat: { ...text, description: `how it repeats: ${REPEAT_HELP}; on a change, only with series` },
95
- conference: {
96
- ...text,
97
- description: "a meeting service to make a new meeting link with, one the calendar offers; never replaces a link",
98
- },
99
95
  };
96
+ const conferenceOf = (services) => services.length
97
+ ? {
98
+ conference: {
99
+ ...text,
100
+ enum: [...services],
101
+ description: "a meeting service to make a new meeting link with; never replaces a link",
102
+ },
103
+ }
104
+ : {};
100
105
  const target = {
101
106
  account_id: integer,
102
107
  event: text,
@@ -104,9 +109,10 @@ const target = {
104
109
  };
105
110
  /**
106
111
  * The calendar writes, offered only by a host that has a writer. Over MCP `ask` goes ahead (WC-MCP-7); `deny`,
107
- * `readonly`, `events.notify` and the extra keys still refuse.
112
+ * `readonly`, `events.notify` and the extra keys still refuse. `conference` is offered only with the services the
113
+ * writer declares (`CalendarWriter.conferences`).
108
114
  */
109
- export const calendarWriteTools = [
115
+ export const calendarWriteToolsFor = (conferences = []) => [
110
116
  {
111
117
  name: "event_create",
112
118
  description: "add an event to a calendar, one that repeats with repeat",
@@ -114,6 +120,7 @@ export const calendarWriteTools = [
114
120
  account_id: integer,
115
121
  calendar: text,
116
122
  ...fields,
123
+ ...conferenceOf(conferences),
117
124
  notify,
118
125
  operation_id: operationId("the operation_id a create that ended in outcome_unknown named: a retry finds that event"),
119
126
  },
@@ -127,6 +134,7 @@ export const calendarWriteTools = [
127
134
  properties: {
128
135
  ...target,
129
136
  ...fields,
137
+ ...conferenceOf(conferences),
130
138
  series: flag,
131
139
  following,
132
140
  notify,
@@ -168,9 +176,13 @@ export const calendarWriteTools = [
168
176
  inputSchema: { type: "object", properties, required, additionalProperties: false },
169
177
  annotations: { readOnlyHint: false, destructiveHint: destructive, idempotentHint: false, openWorldHint: true },
170
178
  }));
179
+ /** The write tools of a writer that makes no meeting links. */
180
+ export const calendarWriteTools = calendarWriteToolsFor();
181
+ // Any host's call may name a conference; the account's writer refuses a service it does not offer.
182
+ const ACCEPTED_WRITES = calendarWriteToolsFor(["any"]);
171
183
  const WRITES = new Set(calendarWriteTools.map(({ name }) => name));
172
184
  const argumentsOf = (name, input) => {
173
- const tool = calendarTools.find((one) => one.name === name) ?? calendarWriteTools.find((one) => one.name === name);
185
+ const tool = calendarTools.find((one) => one.name === name) ?? ACCEPTED_WRITES.find((one) => one.name === name);
174
186
  if (!tool)
175
187
  throw new CliError("validation_error", "unknown calendar tool");
176
188
  if (typeof input !== "object" || input === null || Array.isArray(input))
@@ -201,6 +213,7 @@ const argumentsOf = (name, input) => {
201
213
  "operation_id",
202
214
  "repeat",
203
215
  "to_calendar",
216
+ "conference",
204
217
  ].includes(key) &&
205
218
  (typeof value !== "string" || !value.trim()))
206
219
  throw new CliError("validation_error", `${key} must not be empty`);
@@ -1,4 +1,5 @@
1
1
  import assert from "node:assert/strict";
2
+ import { randomUUID } from "node:crypto";
2
3
  import { mkdtempSync } from "node:fs";
3
4
  import { tmpdir } from "node:os";
4
5
  import { join } from "node:path";
@@ -260,9 +261,41 @@ export const calendarWriterContract = (fixture) => {
260
261
  },
261
262
  },
262
263
  ...moveCases(fixture),
264
+ ...conferenceCases(fixture, draft),
263
265
  ];
264
266
  return cases;
265
267
  };
268
+ /** A writer that declares `conferences` returns the new meeting link on the event; its cases are skipped without. */
269
+ const conferenceCases = (fixture, draft) => {
270
+ const ready = async () => {
271
+ const f = await fixture();
272
+ const provider = f.writer.conferences?.[0];
273
+ return provider ? { ...f, provider } : undefined;
274
+ };
275
+ return [
276
+ {
277
+ name: "conference: a create with a meeting service returns the event with its new link",
278
+ run: async () => {
279
+ const f = await ready();
280
+ if (!f)
281
+ return;
282
+ const made = await f.writer.create(f.calendar, { ...draft(f.at), conference: { provider: f.provider, requestId: randomUUID() } }, { id: ID, notify: false });
283
+ assert.match(made.joinUrl ?? "", /^https:\/\//);
284
+ },
285
+ },
286
+ {
287
+ name: "conference: a change that adds one returns the event with its new link and a new etag",
288
+ run: async () => {
289
+ const f = await ready();
290
+ if (!f)
291
+ return;
292
+ const changed = await f.writer.update(f.calendar, f.existing.externalId, { conference: { provider: f.provider, requestId: randomUUID() } }, { scope: "this", etag: f.existing.etag, notify: false });
293
+ assert.match(changed.joinUrl ?? "", /^https:\/\//);
294
+ assert.notEqual(changed.etag, f.existing.etag);
295
+ },
296
+ },
297
+ ];
298
+ };
266
299
  const moveCases = (fixture) => {
267
300
  const ready = async () => {
268
301
  const f = await fixture();
@@ -6,7 +6,7 @@ import * as v from "valibot";
6
6
  import { ENTITIES } from "../entities/index.js";
7
7
  import { failureContext } from "../errors/reasons.js";
8
8
  import { createMeetingPassageCommand, createMeetingSearchCommand, meetingHitSearchRequest, meetingPassageRequest, meetingSearchArguments, meetingSearchMeta, } from "../meetings/cli/index.js";
9
- import { meetingHitsList, parseMeetingReference, } from "../meetings/index.js";
9
+ import { markedPassage, meetingHitsList, parseMeetingReference, } from "../meetings/index.js";
10
10
  import { formatMeetingEvidenceText, formatMeetingPassage } from "../services/meeting-passage-format.js";
11
11
  import { answerEntity } from "./answer-entity.js";
12
12
  import { destroysNothing } from "./effects.js";
@@ -81,7 +81,7 @@ const handlers = (reader, meta, limit) => {
81
81
  return {
82
82
  run: async (ctx) => {
83
83
  ctx.reserveReadBytes(request.max_read_bytes ?? 4194304);
84
- const result = await reader.passage(reference, { ...request, signal: ctx.signal });
84
+ const result = markedPassage(await reader.passage(reference, { ...request, signal: ctx.signal }));
85
85
  const complete = result.packet.coverage.truncated_by === null;
86
86
  return {
87
87
  answer: {
@@ -6797,6 +6797,7 @@ export declare const ENTITIES: {
6797
6797
  readonly speaker_name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
6798
6798
  readonly text: v.StringSchema<undefined>;
6799
6799
  readonly revision: v.PicklistSchema<["current", "superseded"], undefined>;
6800
+ readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
6800
6801
  }, undefined>, undefined>;
6801
6802
  }, undefined>;
6802
6803
  readonly meeting_task_proposal: v.StrictObjectSchema<{
@@ -280,6 +280,7 @@ const OTHERS = [
280
280
  ["meetings.server-unreachable", "network_error", "the meetings service could not be reached"],
281
281
  ["meetings.server-signed-out", "authentication_error", "the meetings service needs a sign-in"],
282
282
  ["meetings.server-refused", "permission_error", "the meetings service refused the request"],
283
+ ["meetings.server-rate-limited", "rate_limited", "the meetings service asked to wait before more requests"],
283
284
  ["meetings.server-failed", "provider_error", "the meetings service could not be read, or what it returned kept"],
284
285
  [
285
286
  "meetings.server-capped",
@@ -155,6 +155,8 @@ declare const meetingDetailsEntries: {
155
155
  readonly mime: v.NullableSchema<v.StringSchema<undefined>, undefined>;
156
156
  readonly size: v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
157
157
  readonly url: v.NullableSchema<v.StringSchema<undefined>, undefined>;
158
+ /** The file on this computer; `null` when it stays on the service or the phone system (pbx over SFTP). */
159
+ readonly local_path: v.NullableSchema<v.StringSchema<undefined>, undefined>;
158
160
  }, undefined>, undefined>;
159
161
  /**
160
162
  * The Drive files the meeting service saved for it, by role. `document` is the stored document (`document:<id>`) once
@@ -101,6 +101,8 @@ const meetingDetailsEntries = {
101
101
  mime: v.nullable(text),
102
102
  size: v.nullable(count),
103
103
  url: v.nullable(text),
104
+ /** The file on this computer; `null` when it stays on the service or the phone system (pbx over SFTP). */
105
+ local_path: v.nullable(text),
104
106
  })),
105
107
  /**
106
108
  * The Drive files the meeting service saved for it, by role. `document` is the stored document (`document:<id>`) once
@@ -210,6 +212,7 @@ export const meetingDetailsItem = (details, owner) => {
210
212
  mime: one.mime,
211
213
  size: one.size,
212
214
  url: one.url,
215
+ local_path: one.localPath,
213
216
  })),
214
217
  documents: (details.documents ?? []).map((one) => ({
215
218
  file_id: one.fileId,
@@ -52,6 +52,8 @@ export interface MeetingCommandDeps {
52
52
  * asks when the command's key is at `ask` and refuses when nobody can answer. Without it the writes refuse.
53
53
  */
54
54
  askFirst?: (command: Command) => Promise<void>;
55
+ /** The run's stop signal; the meeting writes and `meetings invitation` pass it to the service. */
56
+ signal?: () => AbortSignal | undefined;
55
57
  }
56
58
  export { addMeetingPassageCommand, createMeetingPassageCommand, type MeetingPassageFlags, meetingPassageRequest, } from "./passage.js";
57
59
  export { addMeetingProjectEvidenceCommand } from "./project-evidence.js";
@@ -14,6 +14,8 @@ import { listed, MEETING_QUERY_GUIDE, MeetingError, meetingDetailsBody, meetingP
14
14
  import { SAVE_HELP } from "../save-hints.js";
15
15
  import { addMeetingManagementCommands } from "./management.js";
16
16
  import { queryWordsAfterOptions } from "./query-options.js";
17
+ // Whoever sent the invitation wrote these, as on a calendar CLI's `events list`.
18
+ const EVENT_UNTRUSTED = ["title", "description", "location"];
17
19
  const integer = (text) => {
18
20
  if (!/^[1-9]\d*$/.test(text) || !Number.isSafeInteger(Number(text)))
19
21
  throw new InvalidArgumentError("expected a positive integer");
@@ -211,6 +213,7 @@ const addMeetingCommandsDefinition = (program, deps) => {
211
213
  output,
212
214
  inRun: deps.inRun,
213
215
  ...(deps.askFirst ? { askFirst: deps.askFirst } : {}),
216
+ ...(deps.signal ? { signal: deps.signal } : {}),
214
217
  });
215
218
  const eventList = queryWordsAfterOptions(annotate(program.command("events").description("the owner's stored events"), {
216
219
  effects: { remote: "none", local: "none" },
@@ -228,7 +231,7 @@ const addMeetingCommandsDefinition = (program, deps) => {
228
231
  if (query && !deps.store.queryEvents)
229
232
  throw new MeetingError("validation_error", "this store cannot filter events");
230
233
  const events = query ? await deps.store.queryEvents?.(query) : await deps.store.events();
231
- print(listed((events ?? []).map(eventItem)), command);
234
+ print(listed((events ?? []).map((one) => ({ ...eventItem(one), untrusted: [...EVENT_UNTRUSTED] }))), command);
232
235
  });
233
236
  };
234
237
  export { addMeetingPassageCommand, createMeetingPassageCommand, meetingPassageRequest, } from "./passage.js";
@@ -7,6 +7,8 @@ export interface MeetingManagementCommandDeps {
7
7
  inRun: <T>(command: Command, body: () => Promise<T>) => Promise<T>;
8
8
  /** The profile's question before a write reaches the service (`MeetingCommandDeps.askFirst`). */
9
9
  askFirst?: (command: Command) => Promise<void>;
10
+ /** The run's stop signal (`MeetingCommandDeps.signal`), passed to the service so `--timeout` and Ctrl-C end a call. */
11
+ signal?: () => AbortSignal | undefined;
10
12
  }
11
13
  /**
12
14
  * `meetings create|update|cancel|invitation` for a service that lets the owner change its meetings: each mounted only
@@ -98,12 +98,17 @@ const receiptItem = (receipt) => {
98
98
  */
99
99
  export const addMeetingManagementCommands = (group, deps) => {
100
100
  const { management, print, output, inRun, askFirst } = deps;
101
+ const signalled = () => {
102
+ const signal = deps.signal?.();
103
+ return signal ? { signal } : {};
104
+ };
101
105
  const has = (name) => management.capabilities.includes(name);
102
106
  // The question comes after validation, so a change the service cannot take is refused without asking. A write the
103
107
  // owner could not be asked about never goes: a host that forgets the question gets a refusal.
104
108
  const mutation = (command) => ({
105
109
  apply: true,
106
110
  dryRun: command.optsWithGlobals().dryRun === true,
111
+ ...signalled(),
107
112
  confirm: async () => {
108
113
  if (!askFirst)
109
114
  throw new CliError("configuration_error", "this tool cannot ask before it changes a meeting on the service");
@@ -128,5 +133,5 @@ export const addMeetingManagementCommands = (group, deps) => {
128
133
  effects: REMOTE_READ,
129
134
  offline: false,
130
135
  output: { entity: "meeting_invitation" },
131
- }).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)));
136
+ }).description("the invitation text the service writes for a meeting"))).action(async (id, _flags, command) => inRun(command, async () => print({ item: { ...(await management.invitation(id, signalled())), untrusted: ["invitation"] } }, command)));
132
137
  };
@@ -1,7 +1,7 @@
1
1
  import { CliError } from "@wirecat/cli-base";
2
2
  import { annotate, sharedCommand } from "@wirecat/cli-base/commands";
3
3
  import { Option } from "commander";
4
- import { validateMeetingPassage, } from "../passage.js";
4
+ import { markedPassage, validateMeetingPassage, } from "../passage.js";
5
5
  const count = (value) => {
6
6
  if (!/^(0|[1-9]\d*)$/.test(value) || !Number.isSafeInteger(Number(value)))
7
7
  throw new CliError("validation_error", "expected a nonnegative safe integer");
@@ -48,7 +48,7 @@ const addMeetingPassageCommandDefinition = (program, deps) => createMeetingPassa
48
48
  const globals = command.optsWithGlobals();
49
49
  const format = globals.json || globals.jsonl ? "json" : (options.format ?? "text");
50
50
  const input = meetingPassageRequest(reference, { ...options, format }, deps.signal());
51
- const result = await deps.read(reference, input);
51
+ const result = markedPassage(await deps.read(reference, input));
52
52
  input.signal?.throwIfAborted();
53
53
  deps.output(result, format);
54
54
  });
@@ -24,7 +24,7 @@ export { createMeetingContext, type MeetingContextAction, type MeetingContextCha
24
24
  export { createMeetingManagement, type DeclaredMeetingFields, declareMeetingFields, dispatchMeetingMutation, type ManagedMeeting, type ManagedMeetingChange, MEETING_FIELD_KEYS, MEETING_FIELDS, type MeetingChangeRules, type MeetingField, type MeetingFields, type MeetingManagement, type MeetingManagementPorts, type MeetingMutationOptions, type MeetingMutationProposal, type MeetingMutationReceipt, type MeetingOperationOptions, type MeetingProviderContext, type MeetingSetting, meetingFieldFlag, validateMeetingChange, } from "./meeting-management.js";
25
25
  export type { Attachment, ChatLine, Event, EventSeries, JsonValue, Meeting, MeetingSeries, Metadata, Occurrence, Participant, RecordTimes, SourceChatLine, SourceMeeting, Summary, SummaryContent, Transcript, TranscriptLine, TranscriptRow, } from "./model.js";
26
26
  export { type MeetingParticipantCandidate, type MeetingParticipantPage, type MeetingParticipantReader, type MeetingParticipantSearchOptions, type MeetingParticipantSearchStore, normalizeMeetingParticipantQuery, validateMeetingParticipantSearch, } from "./participant-search.js";
27
- export { type MeetingContextCue, type MeetingHitContextOptions, type MeetingHitContextPacket, type MeetingPassageOutputFormat, type MeetingPassageReader, type MeetingPassageRequest, type MeetingPassageResult, meetingHitContextLimits, validateMeetingPassage, } from "./passage.js";
27
+ export { MEETING_CUE_UNTRUSTED, type MeetingContextCue, type MeetingHitContextOptions, type MeetingHitContextPacket, type MeetingPassageOutputFormat, type MeetingPassageReader, type MeetingPassageRequest, type MeetingPassageResult, markedPassage, meetingHitContextLimits, validateMeetingPassage, } from "./passage.js";
28
28
  export { FACT_TYPES, PAYMENT_DIRECTIONS, PAYMENT_STATES, type Payment, paymentTitle, validatePayment, } from "./payment.js";
29
29
  export { type MeetingPreparationContext, type MeetingPreparationContextRequest, type MeetingPreparationContextStore, type PreparationPage, validateMeetingPreparationContext, } from "./preparation-context.js";
30
30
  export type { MeetingPreparationFact, MeetingPreparationKnowledgeRequest, MeetingPreparationKnowledgeStore, } from "./preparation-knowledge.js";
@@ -58,7 +58,7 @@ export { validateMeetingSeriesInventoryCursor } from "./series-inventory-validat
58
58
  export type { FoundMeeting, FoundMeetings, FullMeeting, MeetingFinds, MeetingSource, MeetingTerm, MeetingWindow, SourceParticipant, } from "./source.js";
59
59
  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";
60
60
  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";
61
- export { MEETING_DOCUMENT_ROLES, READ_BUDGET_EXCEEDED } from "./store.js";
61
+ export { MEETING_DOCUMENT_ROLES, READ_BUDGET_EXCEEDED, TRANSCRIPT_WORDS } from "./store.js";
62
62
  export { type MeetingTagChange, type MeetingTagChangeItem, type MeetingTagged, type MeetingTaggingItem, meetingTagChange, meetingTagChangeItem, meetingTagging, meetingTaggingItem, } from "./tag-answers.js";
63
63
  export { meetingTimestamp } from "./timestamp.js";
64
64
  export type { DocumentMeeting, MeetingTranscriptDocumentStore, MeetingTranscriptReceiptStore, MeetingTranscriptStore, TranscriptAppend, TranscriptAppendReceipt, UnlinkedTranscriptInput, } from "./transcript-store.js";
@@ -20,7 +20,7 @@ export { CHAT_MESSAGES_READ, } from "./links.js";
20
20
  export { createMeetingContext, validateMeetingContextChange, } from "./meeting-context.js";
21
21
  export { createMeetingManagement, declareMeetingFields, dispatchMeetingMutation, MEETING_FIELD_KEYS, MEETING_FIELDS, meetingFieldFlag, validateMeetingChange, } from "./meeting-management.js";
22
22
  export { normalizeMeetingParticipantQuery, validateMeetingParticipantSearch, } from "./participant-search.js";
23
- export { meetingHitContextLimits, validateMeetingPassage, } from "./passage.js";
23
+ export { MEETING_CUE_UNTRUSTED, markedPassage, meetingHitContextLimits, validateMeetingPassage, } from "./passage.js";
24
24
  export { FACT_TYPES, PAYMENT_DIRECTIONS, PAYMENT_STATES, paymentTitle, validatePayment, } from "./payment.js";
25
25
  export { validateMeetingPreparationContext, } from "./preparation-context.js";
26
26
  export { readMeetingProjectEvidence } from "./project-evidence.js";
@@ -44,7 +44,7 @@ export { validateMeetingSeriesHistory, } from "./series-history.js";
44
44
  export { createMeetingSeriesInventoryReader } from "./series-inventory.js";
45
45
  export { validateMeetingSeriesInventoryCursor } from "./series-inventory-validation.js";
46
46
  export { aggregateMeetingCounts, aggregateMeetingStats, MEETING_COUNTS_GROUPINGS, NO_SERIES, } from "./stats.js";
47
- export { MEETING_DOCUMENT_ROLES, READ_BUDGET_EXCEEDED } from "./store.js";
47
+ export { MEETING_DOCUMENT_ROLES, READ_BUDGET_EXCEEDED, TRANSCRIPT_WORDS } from "./store.js";
48
48
  export { meetingTagChange, meetingTagChangeItem, meetingTagging, meetingTaggingItem, } from "./tag-answers.js";
49
49
  export { meetingTimestamp } from "./timestamp.js";
50
50
  export { parseTranscriptText, TranscriptTextError } from "./transcript-text.js";
@@ -1,5 +1,5 @@
1
1
  import { CliError, errorObjectOf, isCliError, mcpErrorResult } from "@wirecat/cli-base";
2
- import { validateMeetingPassage } from "../passage.js";
2
+ import { markedPassage, validateMeetingPassage } from "../passage.js";
3
3
  import { agentResult, UNTRUSTED_NEUTRAL } from "./agent-text.js";
4
4
  const count = { type: "integer", minimum: 0, maximum: 999 };
5
5
  export const meetingPassageTool = {
@@ -40,7 +40,7 @@ export const callMeetingPassageTool = async (read, input, signal, failure = {})
40
40
  const reference = args.reference;
41
41
  validateMeetingPassage(reference, options);
42
42
  signal?.throwIfAborted();
43
- const result = await read(reference, options);
43
+ const result = markedPassage(await read(reference, options));
44
44
  signal?.throwIfAborted();
45
45
  return agentResult({ content: [{ type: "text", text: result.content }], structuredContent: result.packet });
46
46
  }
@@ -18,6 +18,7 @@ export interface MeetingContextCue {
18
18
  speaker_name: string | null;
19
19
  text: string;
20
20
  revision: "current" | "superseded";
21
+ untrusted?: string[];
21
22
  }
22
23
  export declare const meetingHitContextLimits: (options?: MeetingHitContextOptions) => {
23
24
  before: number;
@@ -63,5 +64,9 @@ export interface MeetingPassageResult {
63
64
  packet: MeetingHitContextPacket;
64
65
  content: string;
65
66
  }
67
+ /** The cues' speaker names and lines are what people said: each cue names them, as every meeting read does. */
68
+ export declare const MEETING_CUE_UNTRUSTED: string[];
69
+ /** The passage as a command or tool answers it, its cues marked; the reader's own packet stays as its bytes counted. */
70
+ export declare const markedPassage: (result: MeetingPassageResult) => MeetingPassageResult;
66
71
  export type MeetingPassageReader = (reference: string, options: MeetingPassageRequest) => Promise<MeetingPassageResult>;
67
72
  export declare const validateMeetingPassage: (reference: string, options: MeetingPassageRequest) => void;
@@ -14,6 +14,16 @@ export const meetingHitContextLimits = (options = {}) => {
14
14
  throw new CliError("validation_error", "context takes 0–999 surrounding cues, 2–4194304 output bytes and a bounded read budget");
15
15
  return { before, after, bytes, max_read_bytes };
16
16
  };
17
+ /** The cues' speaker names and lines are what people said: each cue names them, as every meeting read does. */
18
+ export const MEETING_CUE_UNTRUSTED = ["speaker_name", "text"];
19
+ /** The passage as a command or tool answers it, its cues marked; the reader's own packet stays as its bytes counted. */
20
+ export const markedPassage = (result) => ({
21
+ ...result,
22
+ packet: {
23
+ ...result.packet,
24
+ items: result.packet.items.map((cue) => ({ ...cue, untrusted: [...MEETING_CUE_UNTRUSTED] })),
25
+ },
26
+ });
17
27
  export const validateMeetingPassage = (reference, options) => {
18
28
  meetingHitContextLimits(options);
19
29
  if (typeof reference !== "string" ||
@@ -190,6 +190,8 @@ export declare const meetingPassage: v.StrictObjectSchema<{
190
190
  readonly speaker_name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
191
191
  readonly text: v.StringSchema<undefined>;
192
192
  readonly revision: v.PicklistSchema<["current", "superseded"], undefined>;
193
+ /** What people said: `speaker_name` and `text`. */
194
+ readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
193
195
  }, undefined>, undefined>;
194
196
  }, undefined>;
195
197
  /** A stored event a meeting belongs to; `id` is what `meetings update --event-id` takes. */
@@ -219,6 +219,8 @@ export const meetingPassage = v.strictObject({
219
219
  speaker_name: v.nullable(text),
220
220
  text,
221
221
  revision,
222
+ /** What people said: `speaker_name` and `text`. */
223
+ untrusted: v.optional(v.array(text)),
222
224
  })),
223
225
  });
224
226
  /** A stored event a meeting belongs to; `id` is what `meetings update --event-id` takes. */
@@ -13,7 +13,7 @@ export declare const MEETING_SERVER_BOUNDS: {
13
13
  calls: number;
14
14
  pages: number;
15
15
  };
16
- export type MeetingServerSkip = "unsupported" | "offline" | "unreachable" | "not_signed_in" | "refused" | "failed" | "no_upcoming";
16
+ export type MeetingServerSkip = "unsupported" | "offline" | "unreachable" | "not_signed_in" | "refused" | "rate_limited" | "failed" | "no_upcoming";
17
17
  /** What asking the service did, as messages search's `server` says it. */
18
18
  export interface MeetingServerReport {
19
19
  backend: "server" | "both";
@@ -16,6 +16,7 @@ const ISSUES = {
16
16
  unreachable: ["network_error", "meetings.server-unreachable"],
17
17
  not_signed_in: ["authentication_error", "meetings.server-signed-out"],
18
18
  refused: ["permission_error", "meetings.server-refused"],
19
+ rate_limited: ["rate_limited", "meetings.server-rate-limited"],
19
20
  failed: ["provider_error", "meetings.server-failed"],
20
21
  };
21
22
  const metaOf = (reason, provider) => {
@@ -28,6 +29,7 @@ const WHY = {
28
29
  unreachable: (provider) => `${provider} could not be reached — the answer is the store's`,
29
30
  not_signed_in: (provider) => `not signed in to ${provider} — the answer is the store's`,
30
31
  refused: (provider) => `${provider} refused the request — the answer is the store's`,
32
+ rate_limited: (provider) => `${provider} asked to wait before more requests — the answer is the store's`,
31
33
  failed: (provider) => `${provider} could not be read — the answer is the store's`,
32
34
  no_upcoming: (provider) => `${provider} lists no meeting before it starts — upcoming ones are not in the answer`,
33
35
  };
@@ -39,6 +41,8 @@ const reasonOf = (error) => {
39
41
  return "refused";
40
42
  if (code === "network_error")
41
43
  return "unreachable";
44
+ if (code === "rate_limited")
45
+ return "rate_limited";
42
46
  return "failed";
43
47
  };
44
48
  const refusal = (reason, provider, error) => error ??
@@ -3,7 +3,7 @@ import { type QueryAst } from "@wirecat/cli-base/query";
3
3
  import { type ListEnvelope } from "@wirecat/cli-base/standards";
4
4
  import { type MeetingDetailsItem, type MeetingItemBody, type MeetingListBody, type MeetingSummaryItem, type MeetingTranscriptItem } from "./answers.js";
5
5
  import { type MeetingItem } from "./item.js";
6
- import { type MeetingParticipantSearchOptions, type MeetingParticipantSearchStore } from "./participant-search.js";
6
+ import { type MeetingParticipantCandidate, type MeetingParticipantSearchOptions, type MeetingParticipantSearchStore } from "./participant-search.js";
7
7
  import type { MeetingDetails, MeetingFilter, MeetingStore } from "./store.js";
8
8
  export declare class MeetingError extends CliError {
9
9
  constructor(code: "validation_error" | "not_found" | "configuration_error", message: string);
@@ -23,23 +23,9 @@ export declare const listed: <T>(items: T[], page?: {
23
23
  export declare const meetingPeople: (store: MeetingStore & Partial<MeetingParticipantSearchStore>, query: string, accountId?: number, options?: Omit<MeetingParticipantSearchOptions, "accountId">) => Promise<{
24
24
  limit: number;
25
25
  hasMore: boolean;
26
- items: {
27
- createdAt: number;
28
- updatedAt: number;
29
- id: number;
30
- meetingId: number;
31
- identityId: number;
32
- displayName: string | null;
33
- email: string | null;
34
- role: string | null;
35
- joinedAt: number | null;
36
- leftAt: number | null;
37
- durationMs: number | null;
38
- sessions: import("./model.js").JsonValue;
39
- externalId: string | null;
40
- metadata: import("./model.js").Metadata;
26
+ items: (Omit<MeetingParticipantCandidate, "person"> & {
41
27
  untrusted: string[];
42
- }[];
28
+ })[];
43
29
  page: number;
44
30
  } | {
45
31
  schema_version: 1;
@@ -75,7 +75,16 @@ export const meetingPeople = async (store, query, accountId, options = {}) => {
75
75
  }
76
76
  if (Object.values(options).some((value) => value !== undefined))
77
77
  throw new MeetingError("configuration_error", "bounded participant lookup needs a selected account and capable store");
78
- return listed((await store.participants(query, accountId)).map((one) => ({ ...one, untrusted: [...PARTICIPANT_UNTRUSTED] })));
78
+ // The bounded path's row, so `untrusted` names keys that are there. This store cannot tell a person link, so no
79
+ // `person`: its null would say the identity is linked to no one.
80
+ return listed((await store.participants(query, accountId)).map((one) => ({
81
+ participant_id: one.id,
82
+ meeting_id: one.meetingId,
83
+ identity_id: one.identityId,
84
+ display_name: one.displayName,
85
+ email: one.email,
86
+ untrusted: [...PARTICIPANT_UNTRUSTED],
87
+ })));
79
88
  };
80
89
  const PAGE_NEXT = STEPS.find((step) => step.id === "page.next");
81
90
  /** Newest first; `filter.query` is a list query `meetingsQuery` validated. The answer pages by `limit`. */
@@ -29,6 +29,12 @@ export interface TranscriptInput extends Omit<NewRecord<Transcript>, "meetingId"
29
29
  driveFileId?: string;
30
30
  }
31
31
  export declare const MEETING_DOCUMENT_ROLES: readonly ["transcript", "recording", "notes"];
32
+ /**
33
+ * What Meet and Gemini put in the name of the Google Doc they save, the words drive finds them by. The English names
34
+ * are the ones in a real Drive; the Russian and Spanish ones are Google's localized forms as best known, not yet seen
35
+ * in one. Drive's files have no field that marks a document as Meet's, so the name is all there is.
36
+ */
37
+ export declare const TRANSCRIPT_WORDS: readonly ["Transcript", "Notes by Gemini", "Транскрипт", "Заметки Gemini", "Transcripción", "Notas de Gemini"];
32
38
  export type MeetingDocumentRole = (typeof MEETING_DOCUMENT_ROLES)[number];
33
39
  /**
34
40
  * A Drive file the meeting service saved for the meeting: its transcript, its recording or its notes (Meet's
@@ -1,3 +1,16 @@
1
1
  export const MEETING_DOCUMENT_ROLES = ["transcript", "recording", "notes"];
2
+ /**
3
+ * What Meet and Gemini put in the name of the Google Doc they save, the words drive finds them by. The English names
4
+ * are the ones in a real Drive; the Russian and Spanish ones are Google's localized forms as best known, not yet seen
5
+ * in one. Drive's files have no field that marks a document as Meet's, so the name is all there is.
6
+ */
7
+ export const TRANSCRIPT_WORDS = [
8
+ "Transcript",
9
+ "Notes by Gemini",
10
+ "Транскрипт",
11
+ "Заметки Gemini",
12
+ "Transcripción",
13
+ "Notas de Gemini",
14
+ ];
2
15
  /** `searchHits`' refusal of a page whose stored text passes `maxReadBytes`; a reader may ask for fewer rows. */
3
16
  export const READ_BUDGET_EXCEEDED = "Meeting search exceeds its stored text byte budget";
@@ -1,5 +1,5 @@
1
1
  import { CliError } from "@wirecat/cli-base";
2
- import { formatMeetingReference, joinKeyOf, MEETING_FINDINGS_KIND, parseMeetingReference, } from "../../meetings/index.js";
2
+ import { formatMeetingReference, joinKeyOf, MEETING_FINDINGS_KIND, parseMeetingReference, TRANSCRIPT_WORDS, } from "../../meetings/index.js";
3
3
  import { fold } from "../normalize.js";
4
4
  import { eventWindow } from "./calendar-events.js";
5
5
  import { COUNTERPART_ROLE, linkKind } from "./link-kinds.js";
@@ -115,6 +115,28 @@ const rowsOf = (context, filter) => {
115
115
  };
116
116
  const ROW_MEETINGS = "r.meetings";
117
117
  const inRowMeetings = (condition) => `EXISTS (SELECT 1 FROM json_each(${ROW_MEETINGS}) rm WHERE ${condition.replaceAll("{m}", "rm.value")})`;
118
+ /** The meeting's own transcript, or a Drive document Meet named as its transcript or Gemini notes, once imported. */
119
+ const MEETING_TRANSCRIPT = `(EXISTS (SELECT 1 FROM meeting_transcripts t WHERE t.meeting_id = {m} AND t.deleted_at IS NULL
120
+ AND t.superseded_at IS NULL)
121
+ OR EXISTS (SELECT 1 FROM links tl JOIN documents td ON td.id = tl.to_id WHERE tl.from_type = 'meeting'
122
+ AND tl.from_id = {m} AND tl.kind = 'attached' AND tl.to_type = 'document' AND tl.role IN ('transcript', 'notes')
123
+ AND td.deleted_at IS NULL))`;
124
+ const literal = (text) => `'${text.replaceAll("'", "''")}'`;
125
+ // LIKE folds ASCII case only, so the lower-cased word also catches a lower-cased Russian title.
126
+ const namedLikeTranscript = (title) => `(${TRANSCRIPT_WORDS.flatMap((word) => [
127
+ `${title} LIKE ${literal(`%${word}%`)}`,
128
+ `instr(${title}, ${literal(word.toLowerCase())}) > 0`,
129
+ ]).join(" OR ")})`;
130
+ /**
131
+ * A calendar entry's attachment carries no role, so an imported Drive document counts by the words drive finds
132
+ * transcripts and Gemini notes by.
133
+ */
134
+ const EVENT_TRANSCRIPT = `EXISTS (SELECT 1 FROM calendar_entries tc JOIN links tl ON tl.from_type = 'calendar_entry'
135
+ AND tl.from_id = tc.id AND tl.kind = 'attached' AND tl.to_type = 'document'
136
+ JOIN documents td ON td.id = tl.to_id WHERE tc.event_id = {e} AND td.deleted_at IS NULL
137
+ AND ${namedLikeTranscript("td.title")})`;
138
+ /** One rule for the row's flag and the `has_transcript` filter. */
139
+ const ROW_TRANSCRIPT = `((r.type = 'event' AND ${EVENT_TRANSCRIPT.replaceAll("{e}", "r.id")}) OR ${inRowMeetings(MEETING_TRANSCRIPT)})`;
118
140
  const PHONE_MEETING = "(SELECT a.provider FROM meetings km JOIN accounts a ON a.id = km.account_id WHERE km.id = {m}) = 'phone'";
119
141
  const KIND = `(CASE
120
142
  WHEN (r.type = 'event' AND EXISTS (SELECT 1 FROM calendar_entries kc WHERE kc.event_id = r.id
@@ -149,8 +171,7 @@ const filtersOf = (database, filter) => {
149
171
  params.push(people, people, people);
150
172
  }
151
173
  if (filter.hasTranscript !== undefined) {
152
- clauses.push(`${filter.hasTranscript ? "" : "NOT "}${inRowMeetings("EXISTS (SELECT 1 FROM meeting_transcripts t WHERE t.meeting_id = {m} AND t.deleted_at IS NULL " +
153
- "AND t.superseded_at IS NULL)")}`);
174
+ clauses.push(`${filter.hasTranscript ? "" : "NOT "}${ROW_TRANSCRIPT}`);
154
175
  }
155
176
  return { sql: clauses.length ? `WHERE ${clauses.join(" AND ")}` : "", params };
156
177
  };
@@ -206,7 +227,8 @@ const hydrate = (database, page) => {
206
227
  const eventIds = page.filter(({ type }) => type === "event").map(({ id }) => id);
207
228
  const meetingIds = [...new Set(page.flatMap(({ meetingIds }) => meetingIds))];
208
229
  const events = new Map(database
209
- .prepare("SELECT * FROM events WHERE id IN (SELECT value FROM json_each(?))")
230
+ .prepare(`SELECT e.*, ${EVENT_TRANSCRIPT.replaceAll("{e}", "e.id")} AS has_transcript FROM events e
231
+ WHERE e.id IN (SELECT value FROM json_each(?))`)
210
232
  .all(ids(eventIds))
211
233
  .map((row) => [Number(row.id), row]));
212
234
  const entries = database
@@ -222,8 +244,7 @@ const hydrate = (database, page) => {
222
244
  .map((row) => [Number(row.id), row.recurrence == null ? null : JSON.parse(String(row.recurrence))]));
223
245
  const meetings = new Map(database
224
246
  .prepare(`SELECT m.*, a.provider, a.external_id AS account,
225
- EXISTS (SELECT 1 FROM meeting_transcripts t WHERE t.meeting_id = m.id AND t.deleted_at IS NULL
226
- AND t.superseded_at IS NULL) AS has_transcript,
247
+ ${MEETING_TRANSCRIPT.replaceAll("{m}", "m.id")} AS has_transcript,
227
248
  EXISTS (SELECT 1 FROM meeting_summaries s WHERE s.meeting_id = m.id) AS has_summary,
228
249
  (EXISTS (SELECT 1 FROM attachments ra WHERE ra.attachable_type = 'meeting' AND ra.attachable_id = m.id
229
250
  AND (ra.kind IN ('audio', 'video') OR ra.mime LIKE 'audio/%' OR ra.mime LIKE 'video/%'))
@@ -358,7 +379,7 @@ const hydrate = (database, page) => {
358
379
  sources,
359
380
  participants: [...participants.values()],
360
381
  hasRecording: held.some((meeting) => Number(meeting.has_recording) === 1),
361
- hasTranscript: held.some((meeting) => Number(meeting.has_transcript) === 1),
382
+ hasTranscript: Number(event?.has_transcript ?? 0) === 1 || held.some((meeting) => Number(meeting.has_transcript) === 1),
362
383
  hasSummary: held.some((meeting) => Number(meeting.has_summary) === 1),
363
384
  documents: [...linked.values()],
364
385
  seriesId: num(event?.event_series_id),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wirecat/cli-core",
3
- "version": "0.667.0",
3
+ "version": "0.668.0",
4
4
  "description": "The messenger-neutral half of a messaging CLI: domain model, message locators, rendering, name resolution, the SQLite seam, the command skeleton and shared read commands, the send guard, run records and the message store",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Viacheslav Ptsarev",
@@ -300,7 +300,7 @@
300
300
  "@types/pngjs": "6.0.5",
301
301
  "@types/ssh2": "1.15.5",
302
302
  "@vitest/coverage-v8": "^5.0.5",
303
- "@wirecat/cli-base": "0.101.0",
303
+ "@wirecat/cli-base": "0.102.1",
304
304
  "@wirecat/cli-core-legacy-tags": "npm:@wirecat/cli-core@0.414.0",
305
305
  "ajv": "8.17.1",
306
306
  "commander": "15.0.0",
@@ -324,7 +324,7 @@
324
324
  },
325
325
  "peerDependencies": {
326
326
  "@napi-rs/canvas": ">=0.1.69 <2",
327
- "@wirecat/cli-base": ">=0.101.0 <1.0.0",
327
+ "@wirecat/cli-base": ">=0.102.1 <1.0.0",
328
328
  "commander": ">=15",
329
329
  "mysql2": "^3.24.6",
330
330
  "pg": "^8.23.1",