@wirecat/cli-core 0.350.0 → 0.352.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.
- package/CHANGELOG.md +32 -0
- package/dist/cli/messenger/stored.js +4 -1
- package/dist/domain/models.d.ts +6 -4
- package/dist/meetings/mcp/index.d.ts +15 -15
- package/dist/services/index.d.ts +3 -1
- package/dist/services/index.js +2 -1
- package/dist/services/meeting-project-candidate-matching.d.ts +20 -0
- package/dist/services/meeting-project-candidate-matching.js +30 -28
- package/dist/services/project-gathering-around.d.ts +4 -1
- package/dist/services/project-gathering-around.js +32 -1
- package/dist/services/project-gathering-mentions.d.ts +44 -0
- package/dist/services/project-gathering-mentions.js +60 -0
- package/dist/store/chats.d.ts +7 -2
- package/dist/store/chats.js +4 -0
- package/dist/store/sqlite/chats.d.ts +7 -2
- package/dist/store/sqlite/chats.js +19 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,38 @@ shape of this file.
|
|
|
7
7
|
|
|
8
8
|
## Unreleased
|
|
9
9
|
|
|
10
|
+
## 0.352.0 — 19.10.2026
|
|
11
|
+
|
|
12
|
+
### Changed — may break callers
|
|
13
|
+
|
|
14
|
+
- **A saved chat keeps its membership when the update leaves it out**: `saveChats`, `Delta.chats` and
|
|
15
|
+
`HistoryBatch.chats` no longer take a "left" mark off a chat that comes without `membershipState`. So a late
|
|
16
|
+
community notice for a group the owner left no longer marks it rejoined. A value sets the membership; `null`
|
|
17
|
+
(newly allowed on `ChatUpdate`) clears it. A page of the adapter's `chats`, complete or not, still rejoins the
|
|
18
|
+
chats it names, through `markChatsLeft` (now also takes the mark off the chats its complete list names) or the new
|
|
19
|
+
`rejoinChats`; other states such as "archived" are kept. A client that saves its own chat list must call
|
|
20
|
+
`rejoinChats(key, ids)` for a list that is not complete, or a chat the owner rejoined stays hidden from stored
|
|
21
|
+
reads until the next complete one. **max-cli must do this in the bump that takes this version**: in
|
|
22
|
+
`rememberChats` (`src/record.ts`), `else await db.chats.rejoinChats(key, ids)`; without it a chat rejoined while
|
|
23
|
+
the session list is cut stays "left", is hidden from `max chats list`, and `archive clear --left` deletes it.
|
|
24
|
+
A caller that learns of a rejoin any other way sends `membershipState: null`.
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- **`ChatsStore.rejoinChats(key, ids)`** takes the "left" mark off the chats a messenger's chat list names, from any
|
|
29
|
+
page of it, and says how many.
|
|
30
|
+
|
|
31
|
+
## 0.351.0 — 19.10.2026
|
|
32
|
+
|
|
33
|
+
### Added
|
|
34
|
+
|
|
35
|
+
- **`findEvidenceMentions(vocabulary, result, { exclude })`** names the existing projects, tags and topics whose
|
|
36
|
+
name, key or alias appears in a `gatherProjectEvidence` result's excerpts and their neighbours, each match cited
|
|
37
|
+
and marked when the term belongs to more than one entry; a vocabulary over its budget is skipped, not fatal. The
|
|
38
|
+
project matcher behind `createMeetingProjectCandidateReader` is the same code (`matchVocabularyTerms`).
|
|
39
|
+
- **`storedNeighbours(store)`**: the neighbours port for chat messages and mail; a mail hit carries the emails
|
|
40
|
+
before and after it in its thread. `storedMessageNeighbours` returns nothing for a mail reference.
|
|
41
|
+
|
|
10
42
|
## 0.350.0 — 19.10.2026
|
|
11
43
|
|
|
12
44
|
### Added
|
|
@@ -186,8 +186,11 @@ export const stored = (messenger, { account, store, warn, events, pending, annou
|
|
|
186
186
|
const complete = window.offset === 0 && !page.hasMore && page.items.length > 0;
|
|
187
187
|
await save("chats.list", async (opened) => {
|
|
188
188
|
await opened.chats.saveChats(account, page.items);
|
|
189
|
+
const ids = page.items.map((chat) => chat.id);
|
|
189
190
|
if (complete)
|
|
190
|
-
await opened.chats.markChatsLeft(account,
|
|
191
|
+
await opened.chats.markChatsLeft(account, ids);
|
|
192
|
+
else
|
|
193
|
+
await opened.chats.rejoinChats(account, ids);
|
|
191
194
|
});
|
|
192
195
|
return page;
|
|
193
196
|
},
|
package/dist/domain/models.d.ts
CHANGED
|
@@ -47,11 +47,13 @@ export interface Chat {
|
|
|
47
47
|
providerMetadata?: ProviderMetadata;
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
|
-
* A chat as an adapter saves it. A `title`, `unreadCount`, `lastMessageAt` or `
|
|
51
|
-
* stored value; `null` stores none. So a push that knows only some of them, such as a notice that
|
|
52
|
-
* community, leaves the rest out.
|
|
50
|
+
* A chat as an adapter saves it. A `title`, `unreadCount`, `lastMessageAt`, `participantsCount` or `membershipState`
|
|
51
|
+
* left out keeps the stored value; `null` stores none. So a push that knows only some of them, such as a notice that
|
|
52
|
+
* a group left its community, leaves the rest out.
|
|
53
53
|
*/
|
|
54
|
-
export type ChatUpdate = Omit<Chat, KeptFields> & Partial<Pick<Chat, KeptFields
|
|
54
|
+
export type ChatUpdate = Omit<Chat, KeptFields | "membershipState"> & Partial<Pick<Chat, KeptFields>> & {
|
|
55
|
+
membershipState?: MembershipState | null;
|
|
56
|
+
};
|
|
55
57
|
type KeptFields = "title" | "unreadCount" | "lastMessageAt" | "participantsCount";
|
|
56
58
|
/** A group's switches; `null` where the messenger does not say, or has no such switch. */
|
|
57
59
|
export interface GroupSettings {
|
|
@@ -38,7 +38,6 @@ export declare const meetingTools: ({
|
|
|
38
38
|
max_read_bytes?: undefined;
|
|
39
39
|
cursor?: undefined;
|
|
40
40
|
} | {
|
|
41
|
-
limit?: undefined;
|
|
42
41
|
event_id?: undefined;
|
|
43
42
|
series_id?: undefined;
|
|
44
43
|
page?: undefined;
|
|
@@ -54,11 +53,11 @@ export declare const meetingTools: ({
|
|
|
54
53
|
format?: undefined;
|
|
55
54
|
transcript_id?: undefined;
|
|
56
55
|
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;
|
|
62
61
|
event_id?: undefined;
|
|
63
62
|
series_id?: undefined;
|
|
64
63
|
page?: undefined;
|
|
@@ -76,11 +75,11 @@ export declare const meetingTools: ({
|
|
|
76
75
|
format?: undefined;
|
|
77
76
|
transcript_id?: undefined;
|
|
78
77
|
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;
|
|
84
83
|
event_id?: undefined;
|
|
85
84
|
series_id?: undefined;
|
|
86
85
|
page?: undefined;
|
|
@@ -102,6 +101,7 @@ export declare const meetingTools: ({
|
|
|
102
101
|
minimum: number;
|
|
103
102
|
};
|
|
104
103
|
query?: undefined;
|
|
104
|
+
limit?: undefined;
|
|
105
105
|
scan_limit?: undefined;
|
|
106
106
|
max_read_bytes?: undefined;
|
|
107
107
|
cursor?: undefined;
|
|
@@ -188,7 +188,6 @@ export declare const meetingTools: ({
|
|
|
188
188
|
max_read_bytes?: undefined;
|
|
189
189
|
cursor?: undefined;
|
|
190
190
|
} | {
|
|
191
|
-
limit?: undefined;
|
|
192
191
|
event_id?: undefined;
|
|
193
192
|
series_id?: undefined;
|
|
194
193
|
page?: undefined;
|
|
@@ -204,11 +203,11 @@ export declare const meetingTools: ({
|
|
|
204
203
|
format?: undefined;
|
|
205
204
|
transcript_id?: undefined;
|
|
206
205
|
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;
|
|
212
211
|
event_id?: undefined;
|
|
213
212
|
series_id?: undefined;
|
|
214
213
|
page?: undefined;
|
|
@@ -226,11 +225,11 @@ export declare const meetingTools: ({
|
|
|
226
225
|
format?: undefined;
|
|
227
226
|
transcript_id?: undefined;
|
|
228
227
|
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;
|
|
234
233
|
event_id?: undefined;
|
|
235
234
|
series_id?: undefined;
|
|
236
235
|
page?: undefined;
|
|
@@ -252,6 +251,7 @@ export declare const meetingTools: ({
|
|
|
252
251
|
minimum: number;
|
|
253
252
|
};
|
|
254
253
|
query?: undefined;
|
|
254
|
+
limit?: undefined;
|
|
255
255
|
scan_limit?: undefined;
|
|
256
256
|
max_read_bytes?: undefined;
|
|
257
257
|
cursor?: undefined;
|
|
@@ -338,7 +338,6 @@ export declare const meetingTools: ({
|
|
|
338
338
|
max_read_bytes?: undefined;
|
|
339
339
|
cursor?: undefined;
|
|
340
340
|
} | {
|
|
341
|
-
limit?: undefined;
|
|
342
341
|
event_id?: undefined;
|
|
343
342
|
series_id?: undefined;
|
|
344
343
|
page?: undefined;
|
|
@@ -354,11 +353,11 @@ export declare const meetingTools: ({
|
|
|
354
353
|
format?: undefined;
|
|
355
354
|
transcript_id?: undefined;
|
|
356
355
|
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;
|
|
362
361
|
event_id?: undefined;
|
|
363
362
|
series_id?: undefined;
|
|
364
363
|
page?: undefined;
|
|
@@ -376,11 +375,11 @@ export declare const meetingTools: ({
|
|
|
376
375
|
format?: undefined;
|
|
377
376
|
transcript_id?: undefined;
|
|
378
377
|
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;
|
|
384
383
|
event_id?: undefined;
|
|
385
384
|
series_id?: undefined;
|
|
386
385
|
page?: undefined;
|
|
@@ -402,6 +401,7 @@ export declare const meetingTools: ({
|
|
|
402
401
|
minimum: number;
|
|
403
402
|
};
|
|
404
403
|
query?: undefined;
|
|
404
|
+
limit?: undefined;
|
|
405
405
|
scan_limit?: undefined;
|
|
406
406
|
max_read_bytes?: undefined;
|
|
407
407
|
cursor?: undefined;
|
|
@@ -488,7 +488,6 @@ export declare const meetingTools: ({
|
|
|
488
488
|
max_read_bytes?: undefined;
|
|
489
489
|
cursor?: undefined;
|
|
490
490
|
} | {
|
|
491
|
-
limit?: undefined;
|
|
492
491
|
event_id?: undefined;
|
|
493
492
|
series_id?: undefined;
|
|
494
493
|
page?: undefined;
|
|
@@ -504,11 +503,11 @@ export declare const meetingTools: ({
|
|
|
504
503
|
format?: undefined;
|
|
505
504
|
transcript_id?: undefined;
|
|
506
505
|
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;
|
|
512
511
|
event_id?: undefined;
|
|
513
512
|
series_id?: undefined;
|
|
514
513
|
page?: undefined;
|
|
@@ -526,11 +525,11 @@ export declare const meetingTools: ({
|
|
|
526
525
|
format?: undefined;
|
|
527
526
|
transcript_id?: undefined;
|
|
528
527
|
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;
|
|
534
533
|
event_id?: undefined;
|
|
535
534
|
series_id?: undefined;
|
|
536
535
|
page?: undefined;
|
|
@@ -552,6 +551,7 @@ export declare const meetingTools: ({
|
|
|
552
551
|
minimum: number;
|
|
553
552
|
};
|
|
554
553
|
query?: undefined;
|
|
554
|
+
limit?: undefined;
|
|
555
555
|
scan_limit?: undefined;
|
|
556
556
|
max_read_bytes?: undefined;
|
|
557
557
|
cursor?: undefined;
|
|
@@ -638,7 +638,6 @@ export declare const meetingTools: ({
|
|
|
638
638
|
max_read_bytes?: undefined;
|
|
639
639
|
cursor?: undefined;
|
|
640
640
|
} | {
|
|
641
|
-
limit?: undefined;
|
|
642
641
|
event_id?: undefined;
|
|
643
642
|
series_id?: undefined;
|
|
644
643
|
page?: undefined;
|
|
@@ -654,11 +653,11 @@ export declare const meetingTools: ({
|
|
|
654
653
|
format?: undefined;
|
|
655
654
|
transcript_id?: undefined;
|
|
656
655
|
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;
|
|
662
661
|
event_id?: undefined;
|
|
663
662
|
series_id?: undefined;
|
|
664
663
|
page?: undefined;
|
|
@@ -676,11 +675,11 @@ export declare const meetingTools: ({
|
|
|
676
675
|
format?: undefined;
|
|
677
676
|
transcript_id?: undefined;
|
|
678
677
|
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;
|
|
684
683
|
event_id?: undefined;
|
|
685
684
|
series_id?: undefined;
|
|
686
685
|
page?: undefined;
|
|
@@ -702,6 +701,7 @@ export declare const meetingTools: ({
|
|
|
702
701
|
minimum: number;
|
|
703
702
|
};
|
|
704
703
|
query?: undefined;
|
|
704
|
+
limit?: undefined;
|
|
705
705
|
scan_limit?: undefined;
|
|
706
706
|
max_read_bytes?: undefined;
|
|
707
707
|
cursor?: undefined;
|
package/dist/services/index.d.ts
CHANGED
|
@@ -5,7 +5,9 @@ export { type DownloadedModel, downloadImageModel, downloadTextModel, type Model
|
|
|
5
5
|
export type { ProjectEvidenceItem, ProjectGathering, ProjectGatheringPorts, ProjectGatheringStop, ProjectIndexCatchUp, ProjectSourceFetcher, } from "./project-gathering.js";
|
|
6
6
|
export { gatherProjectEvidence } from "./project-gathering.js";
|
|
7
7
|
export type { ProjectNeighbour, ProjectNeighbourReader } from "./project-gathering-around.js";
|
|
8
|
-
export { storedMessageNeighbours } from "./project-gathering-around.js";
|
|
8
|
+
export { storedMessageNeighbours, storedNeighbours } from "./project-gathering-around.js";
|
|
9
|
+
export type { EvidenceMention, EvidenceMentions } from "./project-gathering-mentions.js";
|
|
10
|
+
export { findEvidenceMentions } from "./project-gathering-mentions.js";
|
|
9
11
|
export type { ProjectFetchState, ProjectGatheringBudgets, ProjectGatheringRequest, ProjectLane, ProjectLaneKind, ProjectUnitState, } from "./project-gathering-request.js";
|
|
10
12
|
import { type AccountService } from "./account.js";
|
|
11
13
|
import { type AdminService } from "./admin.js";
|
package/dist/services/index.js
CHANGED
|
@@ -2,7 +2,8 @@ import { botCheckService } from "../botcheck/service.js";
|
|
|
2
2
|
export { createContextEvidenceReader } from "./context-evidence.js";
|
|
3
3
|
export { downloadImageModel, downloadTextModel, } from "./model-downloads.js";
|
|
4
4
|
export { gatherProjectEvidence } from "./project-gathering.js";
|
|
5
|
-
export { storedMessageNeighbours } from "./project-gathering-around.js";
|
|
5
|
+
export { storedMessageNeighbours, storedNeighbours } from "./project-gathering-around.js";
|
|
6
|
+
export { findEvidenceMentions } from "./project-gathering-mentions.js";
|
|
6
7
|
import { accountService } from "./account.js";
|
|
7
8
|
import { adminService } from "./admin.js";
|
|
8
9
|
import { adminStatisticsService } from "./admin-statistics.js";
|
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
import type { MeetingProjectCandidateInput } from "../meetings/index.js";
|
|
2
2
|
import type { VocabularyCatalog } from "../store/index.js";
|
|
3
|
+
type Entry = VocabularyCatalog["entries"][number];
|
|
4
|
+
export type VocabularyTerm = {
|
|
5
|
+
name: string;
|
|
6
|
+
kind: "canonical" | "key" | "alias";
|
|
7
|
+
aliasId?: string;
|
|
8
|
+
};
|
|
9
|
+
/** Every entry whose name, key or alias stands as whole words in a text, at most 20 matches an entry. */
|
|
10
|
+
export declare const matchVocabularyTerms: <S>(catalog: VocabularyCatalog, texts: readonly {
|
|
11
|
+
text: string;
|
|
12
|
+
source: S;
|
|
13
|
+
}[]) => {
|
|
14
|
+
entry: Entry;
|
|
15
|
+
matches: {
|
|
16
|
+
term: VocabularyTerm;
|
|
17
|
+
source: S;
|
|
18
|
+
ambiguous: boolean;
|
|
19
|
+
}[];
|
|
20
|
+
omitted: number;
|
|
21
|
+
}[];
|
|
3
22
|
export declare const matchProjectCandidates: (catalog: VocabularyCatalog, input: MeetingProjectCandidateInput) => {
|
|
4
23
|
project: {
|
|
5
24
|
reference: string;
|
|
@@ -10,3 +29,4 @@ export declare const matchProjectCandidates: (catalog: VocabularyCatalog, input:
|
|
|
10
29
|
matches: import("../meetings/project-candidates.js").MeetingProjectCandidateMatch[];
|
|
11
30
|
omittedMatches: number;
|
|
12
31
|
}[];
|
|
32
|
+
export {};
|
|
@@ -5,7 +5,8 @@ const termsOf = (entry) => [
|
|
|
5
5
|
...(entry.key ? [{ name: entry.key, kind: "key" }] : []),
|
|
6
6
|
...entry.aliases.map((alias) => ({ name: alias.name, kind: "alias", aliasId: alias.id })),
|
|
7
7
|
];
|
|
8
|
-
|
|
8
|
+
/** Every entry whose name, key or alias stands as whole words in a text, at most 20 matches an entry. */
|
|
9
|
+
export const matchVocabularyTerms = (catalog, texts) => {
|
|
9
10
|
const owners = new Map();
|
|
10
11
|
for (const entry of catalog.entries)
|
|
11
12
|
for (const term of termsOf(entry)) {
|
|
@@ -14,29 +15,11 @@ export const matchProjectCandidates = (catalog, input) => {
|
|
|
14
15
|
ids.add(entry.id);
|
|
15
16
|
owners.set(key, ids);
|
|
16
17
|
}
|
|
17
|
-
const sources =
|
|
18
|
-
...(input.title === undefined
|
|
19
|
-
? []
|
|
20
|
-
: [
|
|
21
|
-
{
|
|
22
|
-
text: normalizedText(input.title),
|
|
23
|
-
source: { kind: "metadata-title", reference: input.reference, fingerprint: null, revision: null },
|
|
24
|
-
},
|
|
25
|
-
]),
|
|
26
|
-
...(input.cues ?? []).map((cue) => ({
|
|
27
|
-
text: normalizedText(cue.text),
|
|
28
|
-
source: {
|
|
29
|
-
kind: "transcript",
|
|
30
|
-
reference: cue.reference,
|
|
31
|
-
fingerprint: cue.fingerprint,
|
|
32
|
-
revision: cue.revision,
|
|
33
|
-
},
|
|
34
|
-
})),
|
|
35
|
-
];
|
|
18
|
+
const sources = texts.map(({ text, source }) => ({ text: normalizedText(text), source }));
|
|
36
19
|
const result = [];
|
|
37
20
|
for (const entry of catalog.entries) {
|
|
38
21
|
const matches = [];
|
|
39
|
-
let
|
|
22
|
+
let omitted = 0;
|
|
40
23
|
const seen = new Set();
|
|
41
24
|
for (const term of termsOf(entry)) {
|
|
42
25
|
const normalized = normalizeVocabularyName(term.name);
|
|
@@ -48,18 +31,37 @@ export const matchProjectCandidates = (catalog, input) => {
|
|
|
48
31
|
if (!pattern.test(text))
|
|
49
32
|
continue;
|
|
50
33
|
if (matches.length === 20) {
|
|
51
|
-
|
|
34
|
+
omitted++;
|
|
52
35
|
continue;
|
|
53
36
|
}
|
|
54
37
|
matches.push({ term, source, ambiguous: (owners.get(normalized)?.size ?? 0) > 1 });
|
|
55
38
|
}
|
|
56
39
|
}
|
|
57
40
|
if (matches.length)
|
|
58
|
-
result.push({
|
|
59
|
-
project: { reference: `project:${entry.id}`, id: entry.id, name: entry.name, key: entry.key },
|
|
60
|
-
matches,
|
|
61
|
-
omittedMatches,
|
|
62
|
-
});
|
|
41
|
+
result.push({ entry, matches, omitted });
|
|
63
42
|
}
|
|
64
|
-
return result.sort((a, b) => Number(a.
|
|
43
|
+
return result.sort((a, b) => Number(a.entry.id) - Number(b.entry.id));
|
|
65
44
|
};
|
|
45
|
+
export const matchProjectCandidates = (catalog, input) => matchVocabularyTerms(catalog, [
|
|
46
|
+
...(input.title === undefined
|
|
47
|
+
? []
|
|
48
|
+
: [
|
|
49
|
+
{
|
|
50
|
+
text: input.title,
|
|
51
|
+
source: { kind: "metadata-title", reference: input.reference, fingerprint: null, revision: null },
|
|
52
|
+
},
|
|
53
|
+
]),
|
|
54
|
+
...(input.cues ?? []).map((cue) => ({
|
|
55
|
+
text: cue.text,
|
|
56
|
+
source: {
|
|
57
|
+
kind: "transcript",
|
|
58
|
+
reference: cue.reference,
|
|
59
|
+
fingerprint: cue.fingerprint,
|
|
60
|
+
revision: cue.revision,
|
|
61
|
+
},
|
|
62
|
+
})),
|
|
63
|
+
]).map(({ entry, matches, omitted }) => ({
|
|
64
|
+
project: { reference: `project:${entry.id}`, id: entry.id, name: entry.name, key: entry.key },
|
|
65
|
+
matches: matches.map(({ term, source, ambiguous }) => ({ term, source, ambiguous })),
|
|
66
|
+
omittedMatches: omitted,
|
|
67
|
+
}));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MessageStore } from "../store/index.js";
|
|
1
2
|
import type { MessagesStore } from "../store/messages.js";
|
|
2
3
|
export interface ProjectNeighbour {
|
|
3
4
|
ref: string;
|
|
@@ -6,7 +7,7 @@ export interface ProjectNeighbour {
|
|
|
6
7
|
text: string;
|
|
7
8
|
found: boolean;
|
|
8
9
|
}
|
|
9
|
-
/** The stored messages next to a hit
|
|
10
|
+
/** The stored messages or emails next to a hit, oldest first, without the hit itself. */
|
|
10
11
|
export interface ProjectNeighbourReader {
|
|
11
12
|
around(ref: string, window: {
|
|
12
13
|
before: number;
|
|
@@ -35,3 +36,5 @@ export declare const attachNeighbours: (items: {
|
|
|
35
36
|
remaining: () => number;
|
|
36
37
|
charge: (bytes: number) => void;
|
|
37
38
|
}, known: (ref: string) => boolean, signal?: AbortSignal) => Promise<void>;
|
|
39
|
+
/** Chat messages next to a hit in its chat, and the emails before and after a mail hit in its thread. */
|
|
40
|
+
export declare const storedNeighbours: (store: Pick<MessageStore, "messages" | "mail" | "accounts">) => ProjectNeighbourReader;
|
|
@@ -4,6 +4,8 @@ import { excerpt } from "./excerpt.js";
|
|
|
4
4
|
export const storedMessageNeighbours = (messages) => ({
|
|
5
5
|
async around(ref, window) {
|
|
6
6
|
const at = parseLocator(ref);
|
|
7
|
+
if (at.provider === "email")
|
|
8
|
+
return [];
|
|
7
9
|
const rows = await messages.around({ provider: at.provider, account: at.account }, at.chat, at.message, window);
|
|
8
10
|
return rows
|
|
9
11
|
.filter((row) => !row.anchor)
|
|
@@ -23,7 +25,7 @@ export const attachNeighbours = async (items, reader, window, budget, known, sig
|
|
|
23
25
|
if (!reader || window.before + window.after === 0)
|
|
24
26
|
return;
|
|
25
27
|
for (const item of items) {
|
|
26
|
-
if (item.kind !== "message")
|
|
28
|
+
if (item.kind !== "message" && item.kind !== "mail")
|
|
27
29
|
continue;
|
|
28
30
|
if (budget.remaining() <= 0) {
|
|
29
31
|
item.around = null;
|
|
@@ -55,3 +57,32 @@ export const attachNeighbours = async (items, reader, window, budget, known, sig
|
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
};
|
|
60
|
+
/** Chat messages next to a hit in its chat, and the emails before and after a mail hit in its thread. */
|
|
61
|
+
export const storedNeighbours = (store) => {
|
|
62
|
+
const messages = storedMessageNeighbours(store.messages);
|
|
63
|
+
return {
|
|
64
|
+
async around(ref, window) {
|
|
65
|
+
const at = parseLocator(ref);
|
|
66
|
+
if (at.provider !== "email")
|
|
67
|
+
return messages.around(ref, window);
|
|
68
|
+
const account = await store.accounts.storedAccount({ provider: at.provider, account: at.account });
|
|
69
|
+
const email = await store.mail.email(account.id, at.message);
|
|
70
|
+
if (!email)
|
|
71
|
+
throw new CliError("not_found", "the hit's email is no longer stored");
|
|
72
|
+
const thread = await store.mail.thread(email.emailThreadId);
|
|
73
|
+
const emails = thread?.emails ?? [];
|
|
74
|
+
const index = emails.findIndex((one) => one.id === email.id);
|
|
75
|
+
if (index < 0)
|
|
76
|
+
return [];
|
|
77
|
+
return [
|
|
78
|
+
...emails.slice(Math.max(0, index - window.before), index),
|
|
79
|
+
...emails.slice(index + 1, index + 1 + window.after),
|
|
80
|
+
].map((one) => ({
|
|
81
|
+
ref: formatLocator({ ...at, message: one.externalId }),
|
|
82
|
+
at: one.sentAt ?? one.receivedAt ?? 0,
|
|
83
|
+
sender: one.fromName ?? one.fromAddress,
|
|
84
|
+
text: [one.subject, one.bodyText ?? one.snippet].filter(Boolean).join(" — "),
|
|
85
|
+
}));
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { VocabularyKind, VocabularyStore } from "../store/index.js";
|
|
2
|
+
import { type VocabularyTerm } from "./meeting-project-candidate-matching.js";
|
|
3
|
+
import type { ProjectGathering } from "./project-gathering.js";
|
|
4
|
+
export interface EvidenceMention {
|
|
5
|
+
target: {
|
|
6
|
+
kind: VocabularyKind;
|
|
7
|
+
id: string;
|
|
8
|
+
reference: string;
|
|
9
|
+
name: string;
|
|
10
|
+
key: string | null;
|
|
11
|
+
};
|
|
12
|
+
matches: {
|
|
13
|
+
term: VocabularyTerm;
|
|
14
|
+
ambiguous: boolean;
|
|
15
|
+
reference: string;
|
|
16
|
+
in: "hit" | "around";
|
|
17
|
+
}[];
|
|
18
|
+
omittedMatches: number;
|
|
19
|
+
}
|
|
20
|
+
export interface EvidenceMentions {
|
|
21
|
+
kind: "evidence_mentions";
|
|
22
|
+
association: "unconfirmed-literal-evidence";
|
|
23
|
+
items: EvidenceMention[];
|
|
24
|
+
vocabularyFingerprints: Partial<Record<VocabularyKind, string>>;
|
|
25
|
+
coverage: {
|
|
26
|
+
texts: "returned-excerpts";
|
|
27
|
+
matching: "unicode-normalized-literal-word-boundaries";
|
|
28
|
+
hasMore: boolean;
|
|
29
|
+
skipped: {
|
|
30
|
+
kind: VocabularyKind;
|
|
31
|
+
code: string;
|
|
32
|
+
reason: string | null;
|
|
33
|
+
}[];
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Which existing projects, tags and topics the returned excerpts and their neighbours name. A name is evidence to
|
|
38
|
+
* review, never membership; the gathered project itself is left out.
|
|
39
|
+
*/
|
|
40
|
+
export declare const findEvidenceMentions: (vocabulary: Pick<VocabularyStore, "vocabulary">, gathering: Pick<ProjectGathering, "items">, options?: {
|
|
41
|
+
exclude?: string | null;
|
|
42
|
+
limit?: number;
|
|
43
|
+
signal?: AbortSignal;
|
|
44
|
+
}) => Promise<EvidenceMentions>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { CliError } from "@wirecat/cli-base";
|
|
2
|
+
import { matchVocabularyTerms } from "./meeting-project-candidate-matching.js";
|
|
3
|
+
const KINDS = ["project", "tag", "topic"];
|
|
4
|
+
/**
|
|
5
|
+
* Which existing projects, tags and topics the returned excerpts and their neighbours name. A name is evidence to
|
|
6
|
+
* review, never membership; the gathered project itself is left out.
|
|
7
|
+
*/
|
|
8
|
+
export const findEvidenceMentions = async (vocabulary, gathering, options = {}) => {
|
|
9
|
+
if (typeof vocabulary?.vocabulary !== "function")
|
|
10
|
+
throw new CliError("configuration_error", "evidence mentions need the store's vocabulary");
|
|
11
|
+
const limit = options.limit ?? 50;
|
|
12
|
+
if (!Number.isSafeInteger(limit) || limit < 1 || limit > 200)
|
|
13
|
+
throw new CliError("validation_error", "limit must be a whole number from 1 to 200", { param: "limit" });
|
|
14
|
+
const texts = gathering.items.flatMap((item) => [
|
|
15
|
+
{ text: `${item.title ?? ""} ${item.text}`, source: { reference: item.ref, in: "hit" } },
|
|
16
|
+
...(item.around ?? []).map((one) => ({ text: one.text, source: { reference: one.ref, in: "around" } })),
|
|
17
|
+
]);
|
|
18
|
+
const items = [];
|
|
19
|
+
const vocabularyFingerprints = {};
|
|
20
|
+
const skipped = [];
|
|
21
|
+
for (const kind of KINDS) {
|
|
22
|
+
options.signal?.throwIfAborted();
|
|
23
|
+
let catalog;
|
|
24
|
+
try {
|
|
25
|
+
catalog = await vocabulary.vocabulary({ kind, signal: options.signal });
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
options.signal?.throwIfAborted();
|
|
29
|
+
if (!(error instanceof CliError))
|
|
30
|
+
throw error;
|
|
31
|
+
const reason = error.details?.reason;
|
|
32
|
+
skipped.push({ kind, code: error.code, reason: typeof reason === "string" ? reason : null });
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
vocabularyFingerprints[kind] = catalog.fingerprint;
|
|
36
|
+
for (const { entry, matches, omitted } of matchVocabularyTerms(catalog, texts)) {
|
|
37
|
+
const reference = `${kind}:${entry.id}`;
|
|
38
|
+
if (reference === options.exclude)
|
|
39
|
+
continue;
|
|
40
|
+
items.push({
|
|
41
|
+
target: { kind, id: entry.id, reference, name: entry.name, key: entry.key },
|
|
42
|
+
matches: matches.map(({ term, source, ambiguous }) => ({ term, ambiguous, ...source })),
|
|
43
|
+
omittedMatches: omitted,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
items.sort((a, b) => b.matches.length - a.matches.length);
|
|
48
|
+
return {
|
|
49
|
+
kind: "evidence_mentions",
|
|
50
|
+
association: "unconfirmed-literal-evidence",
|
|
51
|
+
items: items.slice(0, limit),
|
|
52
|
+
vocabularyFingerprints,
|
|
53
|
+
coverage: {
|
|
54
|
+
texts: "returned-excerpts",
|
|
55
|
+
matching: "unicode-normalized-literal-word-boundaries",
|
|
56
|
+
hasMore: items.length > limit,
|
|
57
|
+
skipped,
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
};
|
package/dist/store/chats.d.ts
CHANGED
|
@@ -17,11 +17,16 @@ export interface ChatsStore {
|
|
|
17
17
|
/** The chats a person is in, newest first — as far as the saved member lists go. */
|
|
18
18
|
chatsWith(key: AccountKey, memberId: Id): Promise<Chat[]>;
|
|
19
19
|
/**
|
|
20
|
-
* Given every chat the account is in, marks the rest `left
|
|
21
|
-
* ever from a complete list: a page or a cut list says nothing about the chats it leaves out.
|
|
20
|
+
* Given every chat the account is in, marks the rest `left`, takes the mark off those it names, and says how many
|
|
21
|
+
* it marked. Only ever from a complete list: a page or a cut list says nothing about the chats it leaves out.
|
|
22
22
|
* Remembers when, so a search can say the store knows the account's whole chat list.
|
|
23
23
|
*/
|
|
24
24
|
markChatsLeft(key: AccountKey, present: Id[]): Promise<number>;
|
|
25
|
+
/**
|
|
26
|
+
* Takes the `left` mark off the chats a messenger's own chat list names, from any page of it: the list holds only
|
|
27
|
+
* chats the account is in. Other states are kept. Says how many it took the mark off.
|
|
28
|
+
*/
|
|
29
|
+
rejoinChats(key: AccountKey, present: Id[]): Promise<number>;
|
|
25
30
|
/**
|
|
26
31
|
* The chat the messenger now names `to` instead of `from`: renamed, or merged into the chat already stored as
|
|
27
32
|
* `to`. Replaying it changes nothing.
|
package/dist/store/chats.js
CHANGED
|
@@ -39,6 +39,10 @@ export const chatsStoreOver = (context) => {
|
|
|
39
39
|
});
|
|
40
40
|
return marked;
|
|
41
41
|
},
|
|
42
|
+
rejoinChats: async (key, present) => {
|
|
43
|
+
const accountKey = findAccountPk(key);
|
|
44
|
+
return accountKey === undefined ? 0 : write(database, () => chatQueries.rejoin(context, accountKey, present));
|
|
45
|
+
},
|
|
42
46
|
rekeyChat: async (key, from, to) => {
|
|
43
47
|
const accountKey = findAccountPk(key);
|
|
44
48
|
if (accountKey === undefined)
|
|
@@ -11,8 +11,13 @@ export declare const upsertChat: (context: StoreContext, accountKey: number, cha
|
|
|
11
11
|
/** Replaces who is in the chat, whole. */
|
|
12
12
|
export declare const writeMembers: (context: StoreContext, key: AccountKey, accountKey: number, chatId: Id, memberIds: Id[]) => void;
|
|
13
13
|
export declare const members: ({ orm }: StoreContext, chatKey: number) => Member[];
|
|
14
|
-
/**
|
|
15
|
-
export declare const
|
|
14
|
+
/** Takes the left mark off the chats `present` names; any other state is kept. Answers how many. */
|
|
15
|
+
export declare const rejoin: ({ orm }: StoreContext, accountKey: number, present: Id[]) => number;
|
|
16
|
+
/**
|
|
17
|
+
* Marks this account's chats that `present` does not name, and rejoins those it names. Only ever given a complete
|
|
18
|
+
* list. Answers how many it marked.
|
|
19
|
+
*/
|
|
20
|
+
export declare const markLeft: (context: StoreContext, accountKey: number, present: Id[]) => number;
|
|
16
21
|
/** The chats marked left, and how many messages they hold. */
|
|
17
22
|
export declare const leftChats: ({ orm }: StoreContext, accountKey: number) => {
|
|
18
23
|
pks: number[];
|
|
@@ -65,9 +65,7 @@ export const upsertChat = (context, accountKey, chat) => {
|
|
|
65
65
|
...(chat.lastMessageAt === undefined ? {} : { lastMessageAt: sql `excluded.last_message_at` }),
|
|
66
66
|
...(chat.participantsCount === undefined ? {} : { participantsCount: sql `excluded.participants_count` }),
|
|
67
67
|
metadata: sql `excluded.metadata`,
|
|
68
|
-
|
|
69
|
-
membershipState: sql `CASE WHEN excluded.membership_state IS NOT NULL THEN excluded.membership_state
|
|
70
|
-
WHEN ${chats.membershipState} = 'left' THEN NULL ELSE ${chats.membershipState} END`,
|
|
68
|
+
...(chat.membershipState === undefined ? {} : { membershipState: sql `excluded.membership_state` }),
|
|
71
69
|
updatedAt: sql `excluded.updated_at`,
|
|
72
70
|
},
|
|
73
71
|
})
|
|
@@ -113,13 +111,27 @@ export const members = ({ orm }, chatKey) => orm
|
|
|
113
111
|
.all();
|
|
114
112
|
const byRecency = [sql `${chats.lastMessageAt} DESC NULLS LAST`, chats.id];
|
|
115
113
|
const notLeft = sql `${chats.membershipState} IS NOT 'left'`;
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
const named = (present) => sql `${chats.externalId} IN (SELECT value FROM json_each(${JSON.stringify(present)}))`;
|
|
115
|
+
/** Takes the left mark off the chats `present` names; any other state is kept. Answers how many. */
|
|
116
|
+
export const rejoin = ({ orm }, accountKey, present) => orm
|
|
118
117
|
.update(chats)
|
|
119
|
-
.set({ membershipState:
|
|
120
|
-
.where(and(eq(chats.accountId, accountKey),
|
|
118
|
+
.set({ membershipState: null })
|
|
119
|
+
.where(and(eq(chats.accountId, accountKey), eq(chats.membershipState, "left"), named(present)))
|
|
121
120
|
.returning({ pk: chats.id })
|
|
122
121
|
.all().length;
|
|
122
|
+
/**
|
|
123
|
+
* Marks this account's chats that `present` does not name, and rejoins those it names. Only ever given a complete
|
|
124
|
+
* list. Answers how many it marked.
|
|
125
|
+
*/
|
|
126
|
+
export const markLeft = (context, accountKey, present) => {
|
|
127
|
+
rejoin(context, accountKey, present);
|
|
128
|
+
return context.orm
|
|
129
|
+
.update(chats)
|
|
130
|
+
.set({ membershipState: "left" })
|
|
131
|
+
.where(and(eq(chats.accountId, accountKey), notLeft, sql `NOT (${named(present)})`))
|
|
132
|
+
.returning({ pk: chats.id })
|
|
133
|
+
.all().length;
|
|
134
|
+
};
|
|
123
135
|
/** The chats marked left, and how many messages they hold. */
|
|
124
136
|
export const leftChats = ({ orm }, accountKey) => {
|
|
125
137
|
const pks = orm
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.352.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",
|