@wirecat/cli-core 0.622.0 → 0.623.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 +43 -0
- package/dist/background/budget.d.ts +2 -0
- package/dist/background/daily-archive-timer.d.ts +1 -1
- package/dist/background/schedules.d.ts +2 -9
- package/dist/background/schedules.js +10 -15
- package/dist/background/when.d.ts +28 -0
- package/dist/background/when.js +40 -0
- package/dist/calendar/mcp/index.d.ts +12 -12
- package/dist/cli/messenger/messages-search-command.js +4 -0
- package/dist/cli/program.js +6 -3
- package/dist/cli/schedule/schedule-command.js +14 -8
- package/dist/domain/display-names.d.ts +16 -0
- package/dist/domain/display-names.js +50 -0
- package/dist/errors/reasons.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/meetings/mcp/index.d.ts +15 -15
- package/dist/search/lucene/resolved.d.ts +1 -0
- package/dist/search/lucene/types.d.ts +8 -0
- package/dist/search/lucene/types.js +7 -0
- package/dist/services/messages-combined.js +3 -2
- package/dist/services/messages-discovery.js +3 -2
- package/dist/services/messages-search.js +1 -0
- package/dist/services/messages.d.ts +2 -0
- package/dist/services/people.js +1 -1
- package/dist/store/identity-links.d.ts +3 -3
- package/dist/store/identity-links.js +3 -3
- package/dist/store/index.d.ts +2 -0
- package/dist/store/index.js +1 -0
- package/dist/store/people.d.ts +21 -2
- package/dist/store/people.js +35 -15
- package/dist/store/sqlite/lucene.js +12 -11
- package/dist/store/sqlite/manifest.js +1 -0
- package/dist/store/sqlite/migrations.generated.js +7 -0
- package/dist/store/sqlite/name-traces.d.ts +17 -0
- package/dist/store/sqlite/name-traces.js +112 -0
- package/dist/store/sqlite/notes.js +6 -3
- package/dist/store/sqlite/people-list.d.ts +44 -0
- package/dist/store/sqlite/people-list.js +151 -0
- package/dist/store/sqlite/person-match-scan.js +33 -0
- package/dist/store/sqlite/person-ties.d.ts +14 -0
- package/dist/store/sqlite/person-ties.js +66 -0
- package/dist/store/sqlite/schema.d.ts +16 -0
- package/dist/store/sqlite/schema.js +3 -0
- package/package.json +2 -2
|
@@ -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;
|
|
@@ -22,6 +22,14 @@ export declare const MESSAGE_PARSING: {
|
|
|
22
22
|
/** Further apart than this, two words are rarely about one thing, even in a long message. */
|
|
23
23
|
export declare const MOST_WORDS_APART = 50;
|
|
24
24
|
export declare function searchError(reason: string, span: Span, alternative?: string): never;
|
|
25
|
+
/**
|
|
26
|
+
* A search's time limit: the default keeps agents and MCP to 2 s; a run whose caller set a time limit itself
|
|
27
|
+
* (Desktop's `--timeout 30s`) may use it, less the time to answer.
|
|
28
|
+
*/
|
|
29
|
+
export declare const searchTimeLimit: (deadline: {
|
|
30
|
+
endsAt: number;
|
|
31
|
+
explicit?: true;
|
|
32
|
+
} | undefined, now?: number) => number | undefined;
|
|
25
33
|
/**
|
|
26
34
|
* The search ran out of time, not the query out of bounds: a valid query over a large store. `timeout`, so a caller
|
|
27
35
|
* does not tell the person to fix what they typed.
|
|
@@ -22,6 +22,13 @@ export const MOST_WORDS_APART = 50;
|
|
|
22
22
|
export function searchError(reason, span, alternative) {
|
|
23
23
|
queryError(reason, span, alternative, SEARCH_QUERY);
|
|
24
24
|
}
|
|
25
|
+
/** Time to print a search's own time-limit answer before the run's deadline cuts it. */
|
|
26
|
+
const ANSWER_MS = 1000;
|
|
27
|
+
/**
|
|
28
|
+
* A search's time limit: the default keeps agents and MCP to 2 s; a run whose caller set a time limit itself
|
|
29
|
+
* (Desktop's `--timeout 30s`) may use it, less the time to answer.
|
|
30
|
+
*/
|
|
31
|
+
export const searchTimeLimit = (deadline, now = Date.now()) => deadline?.explicit ? Math.max(QUERY_LIMITS.milliseconds, deadline.endsAt - now - ANSWER_MS) : undefined;
|
|
25
32
|
/**
|
|
26
33
|
* The search ran out of time, not the query out of bounds: a valid query over a large store. `timeout`, so a caller
|
|
27
34
|
* does not tell the person to fix what they typed.
|
|
@@ -30,8 +30,9 @@ export const searchCombined = async (store, account, request, messenger = {}, op
|
|
|
30
30
|
const check = () => {
|
|
31
31
|
if (request.signal?.aborted)
|
|
32
32
|
throw new CliError("validation_error", "search was aborted", { reason: "query.aborted", complete: false });
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
const limitMs = request.timeLimitMs ?? QUERY_LIMITS.milliseconds;
|
|
34
|
+
if (performance.now() - started > limitMs)
|
|
35
|
+
outOfTime(limitMs);
|
|
35
36
|
};
|
|
36
37
|
check();
|
|
37
38
|
const spans = request.ast === undefined && !request.exact && request.text !== undefined
|
|
@@ -87,8 +87,9 @@ export const searchDiscovery = async (store, account, asked, messenger = {}, mea
|
|
|
87
87
|
const check = () => {
|
|
88
88
|
if (request.signal?.aborted)
|
|
89
89
|
throw new CliError("validation_error", "search was aborted", { reason: "query.aborted", complete: false });
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
const limitMs = request.timeLimitMs ?? QUERY_LIMITS.milliseconds;
|
|
91
|
+
if (performance.now() - started > limitMs)
|
|
92
|
+
outOfTime(limitMs);
|
|
92
93
|
};
|
|
93
94
|
const union = new Map();
|
|
94
95
|
let truncated = false;
|
|
@@ -141,6 +141,7 @@ export const prepareLucene = async (store, account, request, messenger) => {
|
|
|
141
141
|
...(request.senders === undefined ? {} : { senders: request.senders }),
|
|
142
142
|
...(selectedChat ? { chat: selectedChat } : {}),
|
|
143
143
|
...(request.signal ? { signal: request.signal } : {}),
|
|
144
|
+
...(request.timeLimitMs === undefined ? {} : { timeLimitMs: request.timeLimitMs }),
|
|
144
145
|
newest: request.newest,
|
|
145
146
|
...(stemmer ? { stemmer } : {}),
|
|
146
147
|
...(unstemmed ? { unstemmed: true } : {}),
|
|
@@ -50,6 +50,8 @@ export interface SearchQuery {
|
|
|
50
50
|
timezone?: string;
|
|
51
51
|
ast?: unknown;
|
|
52
52
|
signal?: AbortSignal;
|
|
53
|
+
/** Longer than the 2 s default when the caller set the run's time limit itself (`searchTimeLimit`). */
|
|
54
|
+
timeLimitMs?: number;
|
|
53
55
|
chat?: string;
|
|
54
56
|
/** A messenger the store holds, or `all` — the same as `in:` in the query. The account it runs as when unset. */
|
|
55
57
|
source?: string;
|
package/dist/services/people.js
CHANGED
|
@@ -139,7 +139,7 @@ export const peopleService = (deps) => {
|
|
|
139
139
|
else if (known.name !== person.name || known.username !== person.username)
|
|
140
140
|
changed += 1;
|
|
141
141
|
}
|
|
142
|
-
await store.people.
|
|
142
|
+
await store.people.saveAddressBook(account, people);
|
|
143
143
|
return {
|
|
144
144
|
added,
|
|
145
145
|
changed,
|
|
@@ -3,10 +3,10 @@ import type { Author } from "./sqlite/memories.js";
|
|
|
3
3
|
import type { IdentityRef } from "./types.js";
|
|
4
4
|
export declare const IDENTITY_LINK_KIND = "identity_link";
|
|
5
5
|
/**
|
|
6
|
-
* Why two people may be one: an agent said so, they share a phone or an address with others,
|
|
7
|
-
* an address another person has.
|
|
6
|
+
* Why two people may be one: an agent said so, they share a phone or an address with others, a meeting guest typed
|
|
7
|
+
* an address another person has, or they have one name and share a phone, an address, a chat or a company's domain.
|
|
8
8
|
*/
|
|
9
|
-
export declare const IDENTITY_LINK_SIGNALS: readonly ["agent", "phone", "email", "guest-email"];
|
|
9
|
+
export declare const IDENTITY_LINK_SIGNALS: readonly ["agent", "phone", "email", "guest-email", "name"];
|
|
10
10
|
export type IdentityLinkSignal = (typeof IDENTITY_LINK_SIGNALS)[number];
|
|
11
11
|
/** An `identity_link` proposal's payload. */
|
|
12
12
|
export interface IdentityLinkPayload {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const IDENTITY_LINK_KIND = "identity_link";
|
|
2
2
|
/**
|
|
3
|
-
* Why two people may be one: an agent said so, they share a phone or an address with others,
|
|
4
|
-
* an address another person has.
|
|
3
|
+
* Why two people may be one: an agent said so, they share a phone or an address with others, a meeting guest typed
|
|
4
|
+
* an address another person has, or they have one name and share a phone, an address, a chat or a company's domain.
|
|
5
5
|
*/
|
|
6
|
-
export const IDENTITY_LINK_SIGNALS = ["agent", "phone", "email", "guest-email"];
|
|
6
|
+
export const IDENTITY_LINK_SIGNALS = ["agent", "phone", "email", "guest-email", "name"];
|
package/dist/store/index.d.ts
CHANGED
|
@@ -77,7 +77,9 @@ export type { FileNoteInput, Link, LinkInput, LinkListFilter, Note, NoteFolder,
|
|
|
77
77
|
export type { Order, OrderDetail, OrderFilter, OrderInput, OrdersStore } from "./sqlite/orders.js";
|
|
78
78
|
export type { OrganizationFilter } from "./sqlite/organization-categories.js";
|
|
79
79
|
export { DEFAULT_OWNER_LANGUAGES, ownerLanguages } from "./sqlite/owner-languages.js";
|
|
80
|
+
export type { ListedPerson, PeopleList, PeopleListOptions, SimilarPerson } from "./sqlite/people-list.js";
|
|
80
81
|
export { mergeId, type PersonMerge, parseMergeId } from "./sqlite/person-merges.js";
|
|
82
|
+
export { ALWAYS_SHOWN, PERSON_TIES, type PersonTie, type ShownBecause, SMALL_GROUP_MEMBERS, } from "./sqlite/person-ties.js";
|
|
81
83
|
export type { PrivateContact, PrivateContactNote } from "./sqlite/private-people.js";
|
|
82
84
|
export type { Product, ProductFilter, ProductInput, ProductsStore, ProductUpdate } from "./sqlite/products.js";
|
|
83
85
|
export { assertGenericAction, PROPOSAL_STATUSES, type ProposalInput, type ProposedAction, type ProposedActionsStore, proposerOfAction, } from "./sqlite/proposed-actions.js";
|
package/dist/store/index.js
CHANGED
|
@@ -39,6 +39,7 @@ export { ORGANIZATION_KINDS, PROJECT_TYPES, SCOPES } from "./sqlite/knowledge.js
|
|
|
39
39
|
export { NOTE_FIELDS, } from "./sqlite/note-search.js";
|
|
40
40
|
export { DEFAULT_OWNER_LANGUAGES, ownerLanguages } from "./sqlite/owner-languages.js";
|
|
41
41
|
export { mergeId, parseMergeId } from "./sqlite/person-merges.js";
|
|
42
|
+
export { ALWAYS_SHOWN, PERSON_TIES, SMALL_GROUP_MEMBERS, } from "./sqlite/person-ties.js";
|
|
42
43
|
export { assertGenericAction, PROPOSAL_STATUSES, proposerOfAction, } from "./sqlite/proposed-actions.js";
|
|
43
44
|
export { waitingPointer, } from "./sqlite/records.js";
|
|
44
45
|
export { fillSearchIndex, resetSearchIndex, searchIndexState, } from "./sqlite/search-index.js";
|
package/dist/store/people.d.ts
CHANGED
|
@@ -3,13 +3,20 @@ import type { PeopleLookup } from "../resolve.js";
|
|
|
3
3
|
import type { IdentityLinkDecision, IdentityLinkFilter, IdentityLinkInput, IdentityLinkRow, MatchScan } from "./identity-links.js";
|
|
4
4
|
import type { ContactFilter } from "./sqlite/identities.js";
|
|
5
5
|
import type { StoreContext } from "./sqlite/open.js";
|
|
6
|
+
import { type PeopleList, type PeopleListOptions, type SimilarPerson } from "./sqlite/people-list.js";
|
|
6
7
|
import type { PersonMerge } from "./sqlite/person-merges.js";
|
|
7
8
|
import { type PersonPreparationRead } from "./sqlite/person-preparation.js";
|
|
9
|
+
import { type ShownBecause } from "./sqlite/person-ties.js";
|
|
8
10
|
import type { PrivateContact, PrivateContactNote } from "./sqlite/private-people.js";
|
|
9
11
|
import type { ProposedAction } from "./sqlite/proposed-actions.js";
|
|
10
12
|
import type { AccountKey, IdentityRef, LinkOptions, PersonFacts, PersonRecord, StoredAccount } from "./types.js";
|
|
11
13
|
export interface AccountPeople {
|
|
12
14
|
savePeople(key: AccountKey, people: PersonFacts[]): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* The account's whole address book: saves them as `savePeople` does and marks them as in the book, a tie to the
|
|
17
|
+
* owner; someone no longer in it loses the mark.
|
|
18
|
+
*/
|
|
19
|
+
saveAddressBook(key: AccountKey, people: PersonFacts[]): Promise<void>;
|
|
13
20
|
/**
|
|
14
21
|
* The people this account has a one-to-one chat with — as far as the saved member lists go —
|
|
15
22
|
* newest conversation first or by name.
|
|
@@ -79,8 +86,8 @@ export interface PeopleStore extends AccountPeople {
|
|
|
79
86
|
decideLink(id: string, decision: IdentityLinkDecision): Promise<ProposedAction>;
|
|
80
87
|
/**
|
|
81
88
|
* One pass of the people matcher: the same address joins people in every scope, a phone exactly two people have
|
|
82
|
-
* joins them, a phone more people share, a role address such as `info
|
|
83
|
-
* proposals. Never over the owner's separation; a pair the owner rejected is proposed again only on new evidence.
|
|
89
|
+
* joins them, a phone more people share, a role address such as `info@`, a meeting guest's typed address, and one
|
|
90
|
+
* name with a shared phone, address, chat or company domain become proposals. Never over the owner's separation; a pair the owner rejected is proposed again only on new evidence.
|
|
84
91
|
*/
|
|
85
92
|
scanMatches(options?: {
|
|
86
93
|
full?: boolean;
|
|
@@ -96,6 +103,18 @@ export interface PeopleStore extends AccountPeople {
|
|
|
96
103
|
add(input: {
|
|
97
104
|
name: string;
|
|
98
105
|
}): Promise<PersonRecord>;
|
|
106
|
+
/**
|
|
107
|
+
* People with their shown name, contact and ties to the owner, a page at a time. By default only those with a tie
|
|
108
|
+
* (a one-to-one chat, a small group, mail the owner wrote, a meeting, a CRM, the address book), the owner, people
|
|
109
|
+
* added by hand and people assigned a task; `all` adds the rest.
|
|
110
|
+
*/
|
|
111
|
+
list(options: PeopleListOptions): Promise<PeopleList>;
|
|
112
|
+
/** People whose names start like the typed one, the same name first: for a form that adds a person. */
|
|
113
|
+
similar(name: string, options?: {
|
|
114
|
+
limit?: number;
|
|
115
|
+
}): Promise<SimilarPerson[]>;
|
|
116
|
+
/** Why each `person:<uid>` is shown by default, as `list` gives it; an empty list for one with no tie. */
|
|
117
|
+
ties(people: readonly string[]): Promise<Record<string, ShownBecause[]>>;
|
|
99
118
|
}
|
|
100
119
|
export declare const accountPeopleOver: (context: StoreContext) => AccountPeople;
|
|
101
120
|
export declare const peopleStoreOver: (context: StoreContext, keyed: AccountPeople) => PeopleStore;
|
package/dist/store/people.js
CHANGED
|
@@ -4,32 +4,46 @@ import { ownerPerson } from "./sqlite/actors.js";
|
|
|
4
4
|
import * as identities from "./sqlite/identities.js";
|
|
5
5
|
import * as identityProposals from "./sqlite/identity-proposals.js";
|
|
6
6
|
import { linkToOwner } from "./sqlite/own-identities.js";
|
|
7
|
+
import { listPeople, similarPeople, } from "./sqlite/people-list.js";
|
|
7
8
|
import * as personLinks from "./sqlite/person-links.js";
|
|
8
9
|
import { RULE, scanMatches } from "./sqlite/person-match-scan.js";
|
|
9
10
|
import * as personMerges from "./sqlite/person-merges.js";
|
|
10
11
|
import { personPreparation } from "./sqlite/person-preparation.js";
|
|
11
12
|
import { personSeenInAccounts } from "./sqlite/person-scope.js";
|
|
13
|
+
import { shownReasons } from "./sqlite/person-ties.js";
|
|
12
14
|
import * as privatePeople from "./sqlite/private-people.js";
|
|
13
15
|
import { write } from "./sqlite/transaction.js";
|
|
14
16
|
export const accountPeopleOver = (context) => {
|
|
15
17
|
const { database } = context;
|
|
16
18
|
const { accountPk, findAccountPk, identityPk } = keysOver(context);
|
|
19
|
+
const save = (key, people) => {
|
|
20
|
+
const accountKey = accountPk(key);
|
|
21
|
+
const saved = [];
|
|
22
|
+
for (const person of people) {
|
|
23
|
+
saved.push(identityPk(accountKey, key.provider, person.id, person.name, person));
|
|
24
|
+
if (person.email)
|
|
25
|
+
personLinks.noteAddress(context, { provider: key.provider, id: person.id }, person.email);
|
|
26
|
+
}
|
|
27
|
+
// Every address of the batch is noted before any joins, so one shared by the whole batch is seen as shared.
|
|
28
|
+
for (const person of people) {
|
|
29
|
+
if (!person.email)
|
|
30
|
+
continue;
|
|
31
|
+
const held = personLinks.joinByAddress(context, { provider: key.provider, id: person.id }, person.email, key.provider);
|
|
32
|
+
if (held)
|
|
33
|
+
identityProposals.openIdentityLink(context, { ...held, joins: "person", signal: "email", by: RULE });
|
|
34
|
+
}
|
|
35
|
+
return saved;
|
|
36
|
+
};
|
|
17
37
|
return {
|
|
18
|
-
savePeople: async (key, people) =>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (!person.email)
|
|
28
|
-
continue;
|
|
29
|
-
const held = personLinks.joinByAddress(context, { provider: key.provider, id: person.id }, person.email, key.provider);
|
|
30
|
-
if (held)
|
|
31
|
-
identityProposals.openIdentityLink(context, { ...held, joins: "person", signal: "email", by: RULE });
|
|
32
|
-
}
|
|
38
|
+
savePeople: async (key, people) => {
|
|
39
|
+
write(database, () => save(key, people));
|
|
40
|
+
},
|
|
41
|
+
saveAddressBook: async (key, people) => write(database, () => {
|
|
42
|
+
const saved = JSON.stringify(save(key, people));
|
|
43
|
+
database
|
|
44
|
+
.prepare("UPDATE account_identities SET address_book = CASE WHEN identity_id IN (SELECT value FROM json_each(?)) " +
|
|
45
|
+
"THEN 1 END WHERE account_id = ? AND (address_book = 1 OR identity_id IN (SELECT value FROM json_each(?)))")
|
|
46
|
+
.run(saved, accountPk(key), saved);
|
|
33
47
|
}),
|
|
34
48
|
contacts: async (key, options) => {
|
|
35
49
|
const accountKey = findAccountPk(key);
|
|
@@ -110,5 +124,11 @@ export const peopleStoreOver = (context, keyed) => {
|
|
|
110
124
|
scanMatches: async (options) => scanMatches(context, options),
|
|
111
125
|
linkProposals: async (filter) => identityProposals.identityLinkRows(context, filter),
|
|
112
126
|
linkToOwner: async (identity) => linkToOwner(context, identity),
|
|
127
|
+
list: async (options) => listPeople(database, options),
|
|
128
|
+
similar: async (name, { limit = 8 } = {}) => similarPeople(database, name, limit),
|
|
129
|
+
ties: async (people) => {
|
|
130
|
+
const reasons = shownReasons(database);
|
|
131
|
+
return Object.fromEntries(people.map((ref) => [ref, reasons.get(Number(ref.replace(/^person:/, ""))) ?? []]));
|
|
132
|
+
},
|
|
113
133
|
};
|
|
114
134
|
};
|
|
@@ -56,18 +56,18 @@ export const matchingPks = (context, execution, cap) => inTime(() => {
|
|
|
56
56
|
.all(...ranked.params, ...where.params, cap + 1);
|
|
57
57
|
check();
|
|
58
58
|
return rows.map(({ id }) => Number(id));
|
|
59
|
-
});
|
|
60
|
-
const timeLimited = (error) => {
|
|
59
|
+
}, execution.timeLimitMs);
|
|
60
|
+
const timeLimited = (limitMs) => (error) => {
|
|
61
61
|
if (error instanceof TimeLimitReached)
|
|
62
|
-
outOfTime();
|
|
62
|
+
outOfTime(limitMs);
|
|
63
63
|
throw error;
|
|
64
64
|
};
|
|
65
|
-
const inTime = (work) => {
|
|
65
|
+
const inTime = (work, limitMs) => {
|
|
66
66
|
try {
|
|
67
67
|
return work();
|
|
68
68
|
}
|
|
69
69
|
catch (error) {
|
|
70
|
-
return timeLimited(error);
|
|
70
|
+
return timeLimited(limitMs)(error);
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
const compileQuery = (context, execution, boundedAttachments = false) => {
|
|
@@ -77,7 +77,8 @@ const compileQuery = (context, execution, boundedAttachments = false) => {
|
|
|
77
77
|
if (mail && (execution.conversationIds || execution.conversationSince !== undefined))
|
|
78
78
|
throw new CliError("validation_error", "mail has no conversations to search within");
|
|
79
79
|
const started = context.now();
|
|
80
|
-
const
|
|
80
|
+
const limitMs = execution.timeLimitMs ?? QUERY_LIMITS.milliseconds;
|
|
81
|
+
const until = Date.now() + limitMs;
|
|
81
82
|
const budget = { work: 0 };
|
|
82
83
|
let states = 0, expansions = 0;
|
|
83
84
|
const patterns = new Map();
|
|
@@ -85,8 +86,8 @@ const compileQuery = (context, execution, boundedAttachments = false) => {
|
|
|
85
86
|
const check = () => {
|
|
86
87
|
if (execution.signal?.aborted)
|
|
87
88
|
throw new CliError("validation_error", "search was aborted", { reason: "query.aborted", complete: false });
|
|
88
|
-
if (context.now() - started >
|
|
89
|
-
outOfTime();
|
|
89
|
+
if (context.now() - started > limitMs)
|
|
90
|
+
outOfTime(limitMs);
|
|
90
91
|
};
|
|
91
92
|
const patternOf = (pattern, node) => {
|
|
92
93
|
check();
|
|
@@ -455,14 +456,14 @@ export const withQuerySelection = (context, execution, consume) => {
|
|
|
455
456
|
throw new Error("query selection consumers must run synchronously");
|
|
456
457
|
check();
|
|
457
458
|
return result;
|
|
458
|
-
}));
|
|
459
|
+
}), execution.timeLimitMs);
|
|
459
460
|
};
|
|
460
461
|
const runQuery = (context, execution, by) => {
|
|
461
462
|
try {
|
|
462
|
-
return runCompiled(context, execution, by).catch(timeLimited);
|
|
463
|
+
return runCompiled(context, execution, by).catch(timeLimited(execution.timeLimitMs));
|
|
463
464
|
}
|
|
464
465
|
catch (error) {
|
|
465
|
-
return timeLimited(error);
|
|
466
|
+
return timeLimited(execution.timeLimitMs)(error);
|
|
466
467
|
}
|
|
467
468
|
};
|
|
468
469
|
const runCompiled = async (context, execution, by) => {
|
|
@@ -124,6 +124,7 @@ export const MANIFEST = [
|
|
|
124
124
|
{ name: "20261108104701_version-58-enrichments-deletes", version: 58, minCompatible: 56 },
|
|
125
125
|
{ name: "20261108165309_version-59-templates", version: 59, minCompatible: 56 },
|
|
126
126
|
{ name: "20261108190101_version-60-base-stages", version: 60, minCompatible: 56 },
|
|
127
|
+
{ name: "20261109170741_version-61-people-ties", version: 61, minCompatible: 56 },
|
|
127
128
|
];
|
|
128
129
|
export const generatedMigrations = (manifest = MANIFEST, generated = GENERATED) => {
|
|
129
130
|
const migrations = [];
|
|
@@ -1224,5 +1224,12 @@ export const GENERATED = [
|
|
|
1224
1224
|
"ALTER TABLE `pipeline_stages` ADD `base_confirmed` integer DEFAULT 0 NOT NULL;",
|
|
1225
1225
|
"CREATE INDEX `pipeline_stages_by_base_stage_id` ON `pipeline_stages` (`base_stage_id`);"
|
|
1226
1226
|
]
|
|
1227
|
+
},
|
|
1228
|
+
{
|
|
1229
|
+
"name": "20261109170741_version-61-people-ties",
|
|
1230
|
+
"statements": [
|
|
1231
|
+
"ALTER TABLE `account_identities` ADD `address_book` integer;",
|
|
1232
|
+
"CREATE INDEX `account_identities_in_address_book` ON `account_identities` (`identity_id`) WHERE address_book = 1;"
|
|
1233
|
+
]
|
|
1227
1234
|
}
|
|
1228
1235
|
];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CacheDatabase } from "../driver.js";
|
|
2
|
+
/** People, owner aside, by the name they share once case, quotes and word order are set aside. */
|
|
3
|
+
export declare const peopleByNameKey: (database: CacheDatabase) => Map<string, {
|
|
4
|
+
people: number[];
|
|
5
|
+
name: string;
|
|
6
|
+
}>;
|
|
7
|
+
/** What two people with one name share: the proof that they may be one, named to the owner. */
|
|
8
|
+
export interface SharedTrace {
|
|
9
|
+
/** An identity of each side that holds it. */
|
|
10
|
+
identity: number;
|
|
11
|
+
with: number;
|
|
12
|
+
kind: "chat" | "email" | "email-domain" | "phone";
|
|
13
|
+
evidence: string[];
|
|
14
|
+
reason: string;
|
|
15
|
+
}
|
|
16
|
+
/** The first trace two people share, strongest first: a phone, an address, a chat, a company's domain. */
|
|
17
|
+
export declare const sharedTrace: (database: CacheDatabase, a: number, b: number, name: string) => SharedTrace | undefined;
|