@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
@@ -38,6 +38,7 @@ export declare const meetingTools: ({
38
38
  max_read_bytes?: undefined;
39
39
  cursor?: undefined;
40
40
  } | {
41
+ limit?: undefined;
41
42
  event_id?: undefined;
42
43
  series_id?: undefined;
43
44
  page?: undefined;
@@ -53,11 +54,11 @@ export declare const meetingTools: ({
53
54
  format?: undefined;
54
55
  transcript_id?: undefined;
55
56
  query?: undefined;
56
- limit?: undefined;
57
57
  scan_limit?: undefined;
58
58
  max_read_bytes?: undefined;
59
59
  cursor?: undefined;
60
60
  } | {
61
+ limit?: undefined;
61
62
  event_id?: undefined;
62
63
  series_id?: undefined;
63
64
  page?: undefined;
@@ -75,11 +76,11 @@ export declare const meetingTools: ({
75
76
  format?: undefined;
76
77
  transcript_id?: undefined;
77
78
  query?: undefined;
78
- limit?: undefined;
79
79
  scan_limit?: undefined;
80
80
  max_read_bytes?: undefined;
81
81
  cursor?: undefined;
82
82
  } | {
83
+ limit?: undefined;
83
84
  event_id?: undefined;
84
85
  series_id?: undefined;
85
86
  page?: undefined;
@@ -101,7 +102,6 @@ export declare const meetingTools: ({
101
102
  minimum: number;
102
103
  };
103
104
  query?: undefined;
104
- limit?: undefined;
105
105
  scan_limit?: undefined;
106
106
  max_read_bytes?: undefined;
107
107
  cursor?: undefined;
@@ -188,6 +188,7 @@ export declare const meetingTools: ({
188
188
  max_read_bytes?: undefined;
189
189
  cursor?: undefined;
190
190
  } | {
191
+ limit?: undefined;
191
192
  event_id?: undefined;
192
193
  series_id?: undefined;
193
194
  page?: undefined;
@@ -203,11 +204,11 @@ export declare const meetingTools: ({
203
204
  format?: undefined;
204
205
  transcript_id?: undefined;
205
206
  query?: undefined;
206
- limit?: undefined;
207
207
  scan_limit?: undefined;
208
208
  max_read_bytes?: undefined;
209
209
  cursor?: undefined;
210
210
  } | {
211
+ limit?: undefined;
211
212
  event_id?: undefined;
212
213
  series_id?: undefined;
213
214
  page?: undefined;
@@ -225,11 +226,11 @@ export declare const meetingTools: ({
225
226
  format?: undefined;
226
227
  transcript_id?: undefined;
227
228
  query?: undefined;
228
- limit?: undefined;
229
229
  scan_limit?: undefined;
230
230
  max_read_bytes?: undefined;
231
231
  cursor?: undefined;
232
232
  } | {
233
+ limit?: undefined;
233
234
  event_id?: undefined;
234
235
  series_id?: undefined;
235
236
  page?: undefined;
@@ -251,7 +252,6 @@ export declare const meetingTools: ({
251
252
  minimum: number;
252
253
  };
253
254
  query?: undefined;
254
- limit?: undefined;
255
255
  scan_limit?: undefined;
256
256
  max_read_bytes?: undefined;
257
257
  cursor?: undefined;
@@ -338,6 +338,7 @@ export declare const meetingTools: ({
338
338
  max_read_bytes?: undefined;
339
339
  cursor?: undefined;
340
340
  } | {
341
+ limit?: undefined;
341
342
  event_id?: undefined;
342
343
  series_id?: undefined;
343
344
  page?: undefined;
@@ -353,11 +354,11 @@ export declare const meetingTools: ({
353
354
  format?: undefined;
354
355
  transcript_id?: undefined;
355
356
  query?: undefined;
356
- limit?: undefined;
357
357
  scan_limit?: undefined;
358
358
  max_read_bytes?: undefined;
359
359
  cursor?: undefined;
360
360
  } | {
361
+ limit?: undefined;
361
362
  event_id?: undefined;
362
363
  series_id?: undefined;
363
364
  page?: undefined;
@@ -375,11 +376,11 @@ export declare const meetingTools: ({
375
376
  format?: undefined;
376
377
  transcript_id?: undefined;
377
378
  query?: undefined;
378
- limit?: undefined;
379
379
  scan_limit?: undefined;
380
380
  max_read_bytes?: undefined;
381
381
  cursor?: undefined;
382
382
  } | {
383
+ limit?: undefined;
383
384
  event_id?: undefined;
384
385
  series_id?: undefined;
385
386
  page?: undefined;
@@ -401,7 +402,6 @@ export declare const meetingTools: ({
401
402
  minimum: number;
402
403
  };
403
404
  query?: undefined;
404
- limit?: undefined;
405
405
  scan_limit?: undefined;
406
406
  max_read_bytes?: undefined;
407
407
  cursor?: undefined;
@@ -488,6 +488,7 @@ export declare const meetingTools: ({
488
488
  max_read_bytes?: undefined;
489
489
  cursor?: undefined;
490
490
  } | {
491
+ limit?: undefined;
491
492
  event_id?: undefined;
492
493
  series_id?: undefined;
493
494
  page?: undefined;
@@ -503,11 +504,11 @@ export declare const meetingTools: ({
503
504
  format?: undefined;
504
505
  transcript_id?: undefined;
505
506
  query?: undefined;
506
- limit?: undefined;
507
507
  scan_limit?: undefined;
508
508
  max_read_bytes?: undefined;
509
509
  cursor?: undefined;
510
510
  } | {
511
+ limit?: undefined;
511
512
  event_id?: undefined;
512
513
  series_id?: undefined;
513
514
  page?: undefined;
@@ -525,11 +526,11 @@ export declare const meetingTools: ({
525
526
  format?: undefined;
526
527
  transcript_id?: undefined;
527
528
  query?: undefined;
528
- limit?: undefined;
529
529
  scan_limit?: undefined;
530
530
  max_read_bytes?: undefined;
531
531
  cursor?: undefined;
532
532
  } | {
533
+ limit?: undefined;
533
534
  event_id?: undefined;
534
535
  series_id?: undefined;
535
536
  page?: undefined;
@@ -551,7 +552,6 @@ export declare const meetingTools: ({
551
552
  minimum: number;
552
553
  };
553
554
  query?: undefined;
554
- limit?: undefined;
555
555
  scan_limit?: undefined;
556
556
  max_read_bytes?: undefined;
557
557
  cursor?: undefined;
@@ -638,6 +638,7 @@ export declare const meetingTools: ({
638
638
  max_read_bytes?: undefined;
639
639
  cursor?: undefined;
640
640
  } | {
641
+ limit?: undefined;
641
642
  event_id?: undefined;
642
643
  series_id?: undefined;
643
644
  page?: undefined;
@@ -653,11 +654,11 @@ export declare const meetingTools: ({
653
654
  format?: undefined;
654
655
  transcript_id?: undefined;
655
656
  query?: undefined;
656
- limit?: undefined;
657
657
  scan_limit?: undefined;
658
658
  max_read_bytes?: undefined;
659
659
  cursor?: undefined;
660
660
  } | {
661
+ limit?: undefined;
661
662
  event_id?: undefined;
662
663
  series_id?: undefined;
663
664
  page?: undefined;
@@ -675,11 +676,11 @@ export declare const meetingTools: ({
675
676
  format?: undefined;
676
677
  transcript_id?: undefined;
677
678
  query?: undefined;
678
- limit?: undefined;
679
679
  scan_limit?: undefined;
680
680
  max_read_bytes?: undefined;
681
681
  cursor?: undefined;
682
682
  } | {
683
+ limit?: undefined;
683
684
  event_id?: undefined;
684
685
  series_id?: undefined;
685
686
  page?: undefined;
@@ -701,7 +702,6 @@ export declare const meetingTools: ({
701
702
  minimum: number;
702
703
  };
703
704
  query?: undefined;
704
- limit?: undefined;
705
705
  scan_limit?: undefined;
706
706
  max_read_bytes?: undefined;
707
707
  cursor?: undefined;
@@ -1,5 +1,6 @@
1
- import type { MeetingSource } from "./source.js";
2
- import type { MeetingStore } from "./store.js";
1
+ import type { Meeting, SourceChatLine, SourceMeeting, SummaryContent, TranscriptLine } from "./model.js";
2
+ import type { MeetingSource, SourceParticipant } from "./source.js";
3
+ import type { MeetingDetails, MeetingDocumentInput, MeetingInput, MeetingSave, MeetingStore } from "./store.js";
3
4
  export interface RunReport {
4
5
  meetings: number;
5
6
  participants: number;
@@ -31,4 +32,28 @@ export interface PullOptions {
31
32
  /** Asked before each meeting; a stop keeps what is saved and moves the cursor to the first meeting not reached. */
32
33
  budget?: MeetingBudget;
33
34
  }
35
+ /** What was read of one meeting besides the meeting itself; `undefined` is not read, `null` is unavailable. */
36
+ export interface SourceMeetingParts {
37
+ participants?: SourceParticipant[] | null;
38
+ transcript?: TranscriptLine[] | null;
39
+ chat?: SourceChatLine[] | null;
40
+ summary?: SummaryContent | null;
41
+ files?: NonNullable<MeetingSave["attachments"]> | null;
42
+ documents?: MeetingDocumentInput[] | null;
43
+ }
44
+ /**
45
+ * The meetings row of a meeting the service returned. With `kept`, the stored row, a field the record leaves empty
46
+ * keeps the stored value and the metadata merges: a live read's record may be thinner than what sync stored.
47
+ */
48
+ export declare const sourceMeetingInput: (m: SourceMeeting, accountId: number, participantsCount: number | null | undefined, kept?: Meeting) => MeetingInput;
49
+ /**
50
+ * Saves one meeting as `meetings sync` does, keyed by its occurrence id, and links its event: `sync` and the reads that
51
+ * keep what the service returned write the same row. It never moves the sync's cursor. A live read passes `kept`, the
52
+ * stored row, so a thinner record does not empty what sync stored (`sourceMeetingInput`).
53
+ */
54
+ export declare const saveSourceMeeting: (source: Pick<MeetingSource, "provider" | "name" | "transcriptFormat" | "createsEvents">, store: MeetingStore, m: SourceMeeting, parts: SourceMeetingParts, { accountId, now, kept }: {
55
+ accountId: number;
56
+ now: number;
57
+ kept?: Meeting;
58
+ }) => Promise<MeetingDetails>;
34
59
  export declare const pull: (source: MeetingSource, store: MeetingStore, options: PullOptions) => Promise<RunReport>;
@@ -17,6 +17,107 @@ const participantInput = (p, provider, occurrenceId, position, accountId) => {
17
17
  },
18
18
  };
19
19
  };
20
+ const participantInputs = (provider, occurrenceId, list, accountId) => list.map((p, i) => participantInput(p, provider, occurrenceId, i, accountId));
21
+ /**
22
+ * The meetings row of a meeting the service returned. With `kept`, the stored row, a field the record leaves empty
23
+ * keeps the stored value and the metadata merges: a live read's record may be thinner than what sync stored.
24
+ */
25
+ export const sourceMeetingInput = (m, accountId, participantsCount, kept) => {
26
+ const startedAt = timestamp(m.occurrence.startedAt);
27
+ const given = m.occurrence.endedAt === null ? null : timestamp(m.occurrence.endedAt);
28
+ if (given !== null && given < startedAt)
29
+ throw new Error("Meeting ends before it starts");
30
+ const keptEnd = kept?.endedAt ?? null;
31
+ const endedAt = given ?? (keptEnd !== null && keptEnd >= startedAt ? keptEnd : null);
32
+ const count = participantsCount === null && kept ? kept.participantsCount : participantsCount;
33
+ const metadata = kept?.metadata && m.metadata ? { ...kept.metadata, ...m.metadata } : (m.metadata ?? kept?.metadata ?? null);
34
+ const meeting = {
35
+ accountId,
36
+ externalId: m.occurrence.id,
37
+ title: m.occurrence.title,
38
+ description: m.description ?? kept?.description ?? null,
39
+ location: m.location ?? kept?.location ?? null,
40
+ joinUrl: m.joinUrl ?? m.series?.joinUrl ?? kept?.joinUrl ?? null,
41
+ startedAt,
42
+ endedAt,
43
+ durationMs: endedAt === null ? null : endedAt - startedAt,
44
+ timezone: m.timezone ?? kept?.timezone ?? null,
45
+ hostIdentityId: kept?.hostIdentityId ?? null,
46
+ ...(count === undefined ? {} : { participantsCount: count }),
47
+ metadata,
48
+ deletedAt: null,
49
+ };
50
+ if (m.series)
51
+ meeting.series = {
52
+ externalId: m.series.id,
53
+ title: m.series.title,
54
+ description: null,
55
+ kind: m.series.kind ?? null,
56
+ recurrence: m.series.recurrence ?? null,
57
+ hostIdentityId: null,
58
+ joinUrl: m.series.joinUrl ?? null,
59
+ metadata: null,
60
+ deletedAt: null,
61
+ };
62
+ return meeting;
63
+ };
64
+ /**
65
+ * Saves one meeting as `meetings sync` does, keyed by its occurrence id, and links its event: `sync` and the reads that
66
+ * keep what the service returned write the same row. It never moves the sync's cursor. A live read passes `kept`, the
67
+ * stored row, so a thinner record does not empty what sync stored (`sourceMeetingInput`).
68
+ */
69
+ export const saveSourceMeeting = async (source, store, m, parts, { accountId, now, kept }) => {
70
+ const id = m.occurrence.id;
71
+ const { participants: sourceParticipants, transcript: lines, chat, summary } = parts;
72
+ const participants = participantInputs(source.provider, id, sourceParticipants ?? [], accountId);
73
+ const meeting = sourceMeetingInput(m, accountId, sourceParticipants === undefined ? undefined : (sourceParticipants?.length ?? null), kept);
74
+ const linked = sourceParticipants !== undefined;
75
+ const format = source.transcriptFormat ?? null;
76
+ const transcripts = lines && linked ? [await transcriptInput(lines, participants, source.name, undefined, format)] : undefined;
77
+ const details = await store.saveMeeting({
78
+ meeting,
79
+ participants: sourceParticipants ? participants : undefined,
80
+ transcripts,
81
+ chat: chat?.map((line) => ({
82
+ externalId: null,
83
+ sentAt: timestamp(line.sentAt),
84
+ senderParticipantPosition: speakerPosition(line.sender, participants),
85
+ senderName: line.sender,
86
+ recipient: null,
87
+ text: line.text,
88
+ normalizedText: null,
89
+ metadata: null,
90
+ })),
91
+ summaries: summary
92
+ ? [
93
+ {
94
+ ...summary,
95
+ source: summary.source ?? source.name,
96
+ content: summary.content ?? null,
97
+ docUrl: summary.docUrl ?? null,
98
+ externalCreatedAt: summary.externalCreatedAt ?? null,
99
+ externalUpdatedAt: summary.externalUpdatedAt ?? null,
100
+ metadata: summary.metadata ?? null,
101
+ },
102
+ ]
103
+ : undefined,
104
+ attachments: parts.files ?? undefined,
105
+ documents: parts.documents ?? undefined,
106
+ now,
107
+ });
108
+ // Without participants the rows cannot be linked: they are saved only when the meeting has no current
109
+ // transcript to downgrade, under a distinct hash so the retry that reads participants is not a replay.
110
+ if (lines &&
111
+ !linked &&
112
+ !details.transcripts.some((t) => t.transcript.source === source.name && t.transcript.supersededAt === null))
113
+ await store.saveMeeting({
114
+ meeting,
115
+ transcripts: [await transcriptInput(lines, [], source.name, `${JSON.stringify(lines)}\nunlinked`, format)],
116
+ now,
117
+ });
118
+ await linkEvent(store, details, now, { create: source.createsEvents !== false });
119
+ return details;
120
+ };
20
121
  /** A start that does not parse sorts last; its own save reports it. */
21
122
  const startOf = (m) => {
22
123
  const at = Date.parse(m.occurrence.startedAt);
@@ -84,7 +185,7 @@ export const pull = async (source, store, options) => {
84
185
  };
85
186
  try {
86
187
  const sourceParticipants = await read("participants", () => source.participants(id));
87
- const participants = (sourceParticipants ?? []).map((p, i) => participantInput(p, source.provider, id, i, options.accountId));
188
+ const participants = participantInputs(source.provider, id, sourceParticipants ?? [], options.accountId);
88
189
  const names = new Map();
89
190
  for (const p of participants)
90
191
  if (p.displayName !== null) {
@@ -100,83 +201,7 @@ export const pull = async (source, store, options) => {
100
201
  const attachments = await read("files", () => source.files(id));
101
202
  const listDocuments = source.documents?.bind(source);
102
203
  const documents = listDocuments ? await read("documents", () => listDocuments(id)) : undefined;
103
- const startedAt = timestamp(m.occurrence.startedAt);
104
- const endedAt = m.occurrence.endedAt === null ? null : timestamp(m.occurrence.endedAt);
105
- if (endedAt !== null && endedAt < startedAt)
106
- throw new Error("Meeting ends before it starts");
107
- const meeting = {
108
- accountId: options.accountId,
109
- externalId: id,
110
- title: m.occurrence.title,
111
- description: m.description ?? null,
112
- location: m.location ?? null,
113
- joinUrl: m.joinUrl ?? m.series?.joinUrl ?? null,
114
- startedAt,
115
- endedAt,
116
- durationMs: endedAt === null ? null : endedAt - startedAt,
117
- timezone: m.timezone ?? null,
118
- hostIdentityId: null,
119
- ...(sourceParticipants === undefined ? {} : { participantsCount: sourceParticipants?.length ?? null }),
120
- metadata: m.metadata ?? null,
121
- deletedAt: null,
122
- };
123
- if (m.series)
124
- meeting.series = {
125
- externalId: m.series.id,
126
- title: m.series.title,
127
- description: null,
128
- kind: m.series.kind ?? null,
129
- recurrence: m.series.recurrence ?? null,
130
- hostIdentityId: null,
131
- joinUrl: m.series.joinUrl ?? null,
132
- metadata: null,
133
- deletedAt: null,
134
- };
135
- const linked = sourceParticipants !== undefined;
136
- const format = source.transcriptFormat ?? null;
137
- const transcripts = lines && linked ? [await transcriptInput(lines, participants, source.name, undefined, format)] : undefined;
138
- const details = await store.saveMeeting({
139
- meeting,
140
- participants: sourceParticipants ? participants : undefined,
141
- transcripts,
142
- chat: chat?.map((line) => ({
143
- externalId: null,
144
- sentAt: timestamp(line.sentAt),
145
- senderParticipantPosition: speakerPosition(line.sender, participants),
146
- senderName: line.sender,
147
- recipient: null,
148
- text: line.text,
149
- normalizedText: null,
150
- metadata: null,
151
- })),
152
- summaries: summary
153
- ? [
154
- {
155
- ...summary,
156
- source: summary.source ?? source.name,
157
- content: summary.content ?? null,
158
- docUrl: summary.docUrl ?? null,
159
- externalCreatedAt: summary.externalCreatedAt ?? null,
160
- externalUpdatedAt: summary.externalUpdatedAt ?? null,
161
- metadata: summary.metadata ?? null,
162
- },
163
- ]
164
- : undefined,
165
- attachments: attachments ?? undefined,
166
- documents: documents ?? undefined,
167
- now,
168
- });
169
- // Without participants the rows cannot be linked: they are saved only when the meeting has no current
170
- // transcript to downgrade, under a distinct hash so the retry that reads participants is not a replay.
171
- if (lines &&
172
- !linked &&
173
- !details.transcripts.some((t) => t.transcript.source === source.name && t.transcript.supersededAt === null))
174
- await store.saveMeeting({
175
- meeting,
176
- transcripts: [await transcriptInput(lines, [], source.name, `${JSON.stringify(lines)}\nunlinked`, format)],
177
- now,
178
- });
179
- await linkEvent(store, details, now, { create: source.createsEvents !== false });
204
+ await saveSourceMeeting(source, store, m, { participants: sourceParticipants, transcript: lines, chat, summary, files: attachments, documents }, { accountId: options.accountId, now });
180
205
  for (const p of participants)
181
206
  if (p.identity.phone)
182
207
  callers.add(p.identity.externalId);
@@ -0,0 +1,74 @@
1
+ import { type QueryAst } from "@wirecat/cli-base/query";
2
+ import type { Meta, Missing } from "@wirecat/cli-base/standards";
3
+ import { type Backend } from "../search/service-query.js";
4
+ import type { MeetingItem } from "./item.js";
5
+ import { type MeetingList } from "./reads.js";
6
+ import type { MeetingSource } from "./source.js";
7
+ import type { MeetingDetails, MeetingFilter, MeetingStore } from "./store.js";
8
+ /**
9
+ * `meetings list` asks at most `calls` calls of `find`, each up to `pages` pages; past either the answer says it is not
10
+ * complete. The same three calls as messages search.
11
+ */
12
+ export declare const MEETING_SERVER_BOUNDS: {
13
+ calls: number;
14
+ pages: number;
15
+ };
16
+ export type MeetingServerSkip = "unsupported" | "offline" | "unreachable" | "not_signed_in" | "refused" | "failed" | "no_upcoming";
17
+ /** What asking the service did, as messages search's `server` says it. */
18
+ export interface MeetingServerReport {
19
+ backend: "server" | "both";
20
+ skipped: MeetingServerSkip | null;
21
+ calls: number;
22
+ returned: number;
23
+ /** Meetings the store did not hold before this read. */
24
+ new: number;
25
+ /** Meetings the service returned that could not be kept, so the store's answer cannot have them. */
26
+ failed: number;
27
+ complete: boolean;
28
+ }
29
+ /**
30
+ * Where a read may look and what stops it asking the service; `backend` as typed, so its absence means `both`.
31
+ * `timezone` and `now` read the query's dates the same way on both sides: the service's window and the store's query.
32
+ */
33
+ export interface MeetingServerAccess {
34
+ backend?: Backend;
35
+ offline?: boolean;
36
+ now?: number;
37
+ timezone?: string;
38
+ }
39
+ type FoundIn = NonNullable<MeetingItem["found_in"]>;
40
+ interface ServerStep {
41
+ report: MeetingServerReport;
42
+ /** Store meeting id → whether the store held it before the service returned it. */
43
+ found: Map<number, Exclude<FoundIn, "archive">>;
44
+ missing: Missing[];
45
+ /** What the host's `meta` says of it: not complete when the service could not be read, cut at the call cap. */
46
+ meta?: Partial<Meta>;
47
+ }
48
+ /**
49
+ * Asks the service for the meetings a `meetings list` query may match and keeps them, so the store query that runs
50
+ * next sees them. The service gets only what it can filter (`serviceCallsOf`): a wider set, never a narrower one.
51
+ * Without a typed `--backend server`, a service that cannot be asked leaves the store's answer and a `missing` line.
52
+ */
53
+ export declare const askServerForList: (source: MeetingSource | undefined, store: MeetingStore, accountId: number, query: QueryAst | undefined, access: MeetingServerAccess) => Promise<ServerStep | undefined>;
54
+ /** `meetings list` with the service asked first, as `--backend` says; the store's query and paging decide. */
55
+ export type MeetingListThrough = MeetingList & {
56
+ server?: MeetingServerReport;
57
+ meta?: Partial<Meta>;
58
+ };
59
+ export declare const meetingsListThrough: (source: MeetingSource | undefined, store: MeetingStore, filter: MeetingFilter & {
60
+ accountId: number;
61
+ }, access: MeetingServerAccess) => Promise<MeetingListThrough>;
62
+ export interface MeetingShowThrough {
63
+ details: MeetingDetails;
64
+ foundIn?: FoundIn;
65
+ server?: MeetingServerReport;
66
+ missing?: Missing[];
67
+ meta?: Partial<Meta>;
68
+ }
69
+ /**
70
+ * `meetings show`: the stored meeting `meeting` names (store number first, then `meeting:` ref, then the service's
71
+ * id), read again from the service with its people, transcript and Drive documents and kept, as `--backend` says.
72
+ */
73
+ export declare const meetingShowThrough: (source: MeetingSource | undefined, store: MeetingStore, accountId: number, meeting: string, access: MeetingServerAccess) => Promise<MeetingShowThrough>;
74
+ export {};