@wirecat/cli-core 0.616.0 → 0.618.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 +84 -0
- package/dist/background/backfill.d.ts +21 -0
- package/dist/background/backfill.js +41 -0
- package/dist/background/report/messages.js +4 -1
- package/dist/background/report/view.js +4 -1
- package/dist/background/schedules.d.ts +17 -0
- package/dist/background/schedules.js +21 -8
- package/dist/cli/context.d.ts +5 -0
- package/dist/cli/index.d.ts +3 -2
- package/dist/cli/index.js +3 -2
- package/dist/cli/messenger/serve-command.js +24 -2
- package/dist/cli/messenger/serve-outdated.d.ts +22 -0
- package/dist/cli/messenger/serve-outdated.js +100 -0
- package/dist/cli/schedule/schedule-command.d.ts +9 -0
- package/dist/cli/schedule/schedule-command.js +13 -0
- package/dist/cli/store-recover.js +26 -2
- package/dist/domain/links.d.ts +17 -4
- package/dist/domain/links.js +20 -7
- package/dist/domain/models.d.ts +6 -0
- package/dist/domain/relations.d.ts +15 -0
- package/dist/domain/relations.js +23 -0
- package/dist/errors/reasons.js +7 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/meetings/mcp/index.d.ts +15 -15
- package/dist/services/link-scorers/chat-senders.js +39 -29
- package/dist/services/link-scorers/member-chats.js +4 -3
- package/dist/services/link-scorers/member-dialog.js +5 -7
- package/dist/services/link-scorers/scan.js +17 -8
- package/dist/services/link-scorers/shared.d.ts +6 -2
- package/dist/services/link-scorers/shared.js +6 -2
- package/dist/services/link-scorers/types.d.ts +2 -0
- package/dist/store/migrations.d.ts +1 -1
- package/dist/store/migrations.js +35 -12
- package/dist/store/recover.d.ts +34 -0
- package/dist/store/recover.js +188 -6
- package/dist/store/refill.d.ts +28 -0
- package/dist/store/refill.js +120 -0
- package/dist/store/sqlite/bot-tokens.d.ts +11 -0
- package/dist/store/sqlite/bot-tokens.js +57 -0
- package/dist/store/sqlite/chats.js +2 -0
- package/dist/store/sqlite/clients.d.ts +7 -3
- package/dist/store/sqlite/clients.js +11 -7
- package/dist/store/sqlite/email-index.js +9 -11
- package/dist/store/sqlite/knowledge.js +3 -1
- package/dist/store/sqlite/messages.d.ts +1 -1
- package/dist/store/sqlite/messages.js +3 -1
- package/dist/store/sqlite/note-index.js +9 -7
- package/dist/store/sqlite/notes.d.ts +1 -1
- package/dist/store/sqlite/notes.js +8 -6
- package/dist/store/sqlite/open-store.js +2 -0
- package/dist/store/sqlite/relation-list.js +2 -0
- package/dist/store/sqlite/relation-proposals.d.ts +12 -1
- package/dist/store/sqlite/relation-proposals.js +50 -11
- package/dist/store/sqlite/transaction.d.ts +13 -0
- package/dist/store/sqlite/transaction.js +25 -17
- package/package.json +1 -1
package/dist/domain/links.d.ts
CHANGED
|
@@ -35,6 +35,14 @@ export type DeepLinkTarget = {
|
|
|
35
35
|
type: "sync";
|
|
36
36
|
tool: string;
|
|
37
37
|
account?: string;
|
|
38
|
+
} | {
|
|
39
|
+
type: "person";
|
|
40
|
+
id: string;
|
|
41
|
+
}
|
|
42
|
+
/** A project's store id or its key, as `project:<key>` names it. */
|
|
43
|
+
| {
|
|
44
|
+
type: "project";
|
|
45
|
+
id: string;
|
|
38
46
|
};
|
|
39
47
|
export type LinkForm = "web" | "app";
|
|
40
48
|
export interface LinkConfig {
|
|
@@ -52,10 +60,15 @@ export declare const formatLink: (target: DeepLinkTarget) => string;
|
|
|
52
60
|
*/
|
|
53
61
|
export declare const parseLink: (text: string) => DeepLinkTarget | null;
|
|
54
62
|
/**
|
|
55
|
-
* The
|
|
56
|
-
*
|
|
57
|
-
|
|
58
|
-
|
|
63
|
+
* The refs in the order an item's one link is chosen from: a person or a project names who or what an item is about,
|
|
64
|
+
* not where it happened, so it opens only when nothing else does.
|
|
65
|
+
*/
|
|
66
|
+
export declare const refsForLink: (refs: readonly string[]) => string[];
|
|
67
|
+
/**
|
|
68
|
+
* The target a ref names, or `null` when it names nothing a link opens. A store reference (`msg:`, `chat:`, `task:`,
|
|
69
|
+
* `person:`, `project:`) is read by its own grammar; the kinds that are no reference are written as their path with a
|
|
70
|
+
* colon after the kind: `proposal:fact%3A512`, `tasks:overdue`, `tasks:new/2026-11-07T08%3A00%3A00Z`,
|
|
71
|
+
* `digest:2026-11-08`, `sync:telegram/1001`.
|
|
59
72
|
*/
|
|
60
73
|
export declare const linkTargetOf: (ref: string) => DeepLinkTarget | null;
|
|
61
74
|
/** The `links` section of the shared config, with the default for what is missing or not a usable value. */
|
package/dist/domain/links.js
CHANGED
|
@@ -15,7 +15,9 @@ const partsOf = (target) => {
|
|
|
15
15
|
case "chat":
|
|
16
16
|
return ["chat", target.provider, target.account, target.chat];
|
|
17
17
|
case "task":
|
|
18
|
-
|
|
18
|
+
case "person":
|
|
19
|
+
case "project":
|
|
20
|
+
return [target.type, target.id];
|
|
19
21
|
case "tasks":
|
|
20
22
|
return target.filter === "new" ? ["tasks", "new", target.since] : ["tasks", target.filter];
|
|
21
23
|
case "proposal":
|
|
@@ -37,7 +39,9 @@ const targetOfParts = (parts) => {
|
|
|
37
39
|
case "chat":
|
|
38
40
|
return rest.length === 3 ? { type: "chat", provider: a, account: b, chat: c } : null;
|
|
39
41
|
case "task":
|
|
40
|
-
|
|
42
|
+
case "person":
|
|
43
|
+
case "project":
|
|
44
|
+
return rest.length === 1 ? { type: kind, id: a } : null;
|
|
41
45
|
case "tasks":
|
|
42
46
|
if (rest.length === 1 && TASK_FILTERS.includes(a))
|
|
43
47
|
return { type: "tasks", filter: a };
|
|
@@ -90,12 +94,21 @@ export const parseLink = (text) => {
|
|
|
90
94
|
return targetOfPath(rest);
|
|
91
95
|
};
|
|
92
96
|
const LINK_ONLY = new Set(["tasks", "proposal", "digest", "sync"]);
|
|
93
|
-
const FROM_REFERENCE = new Set(["message", "chat", "task"]);
|
|
97
|
+
const FROM_REFERENCE = new Set(["message", "chat", "task", "person", "project"]);
|
|
98
|
+
const ENTITY_KINDS = new Set(["person", "project"]);
|
|
94
99
|
/**
|
|
95
|
-
* The
|
|
96
|
-
*
|
|
97
|
-
|
|
98
|
-
|
|
100
|
+
* The refs in the order an item's one link is chosen from: a person or a project names who or what an item is about,
|
|
101
|
+
* not where it happened, so it opens only when nothing else does.
|
|
102
|
+
*/
|
|
103
|
+
export const refsForLink = (refs) => [
|
|
104
|
+
...refs.filter((ref) => !ENTITY_KINDS.has(ref.slice(0, ref.indexOf(":")))),
|
|
105
|
+
...refs.filter((ref) => ENTITY_KINDS.has(ref.slice(0, ref.indexOf(":")))),
|
|
106
|
+
];
|
|
107
|
+
/**
|
|
108
|
+
* The target a ref names, or `null` when it names nothing a link opens. A store reference (`msg:`, `chat:`, `task:`,
|
|
109
|
+
* `person:`, `project:`) is read by its own grammar; the kinds that are no reference are written as their path with a
|
|
110
|
+
* colon after the kind: `proposal:fact%3A512`, `tasks:overdue`, `tasks:new/2026-11-07T08%3A00%3A00Z`,
|
|
111
|
+
* `digest:2026-11-08`, `sync:telegram/1001`.
|
|
99
112
|
*/
|
|
100
113
|
export const linkTargetOf = (ref) => {
|
|
101
114
|
const text = ref.trim();
|
package/dist/domain/models.d.ts
CHANGED
|
@@ -22,6 +22,12 @@ export interface Chat {
|
|
|
22
22
|
/** Saving a chat: absent keeps the stored parent, `null` clears it. */
|
|
23
23
|
parentChatId?: Id | null;
|
|
24
24
|
scope?: "personal" | "work";
|
|
25
|
+
/**
|
|
26
|
+
* Saving a chat: `false` keeps it out of search over all chats, as a chat whose messages hold credentials
|
|
27
|
+
* (Telegram's BotFather) should be; a read that names the chat still sees it. Absent keeps the stored
|
|
28
|
+
* mark, and nothing a messenger saves unhides a chat.
|
|
29
|
+
*/
|
|
30
|
+
searchable?: false;
|
|
25
31
|
id: Id;
|
|
26
32
|
title: string | null;
|
|
27
33
|
kind: ChatKind;
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
/** What a person is to an organization; who reports to whom is `reports-to`, and a job title is never a role. */
|
|
2
2
|
export declare const ORGANIZATION_ROLES: readonly ["employee", "contractor", "founder", "owner", "manager", "adviser", "contact"];
|
|
3
3
|
export declare const PROJECT_ROLES: readonly ["owner", "manager", "contributor", "client-contact", "approver"];
|
|
4
|
+
/** How much the owner deals with a person on a project himself, not how active the person is; absent is unknown. */
|
|
5
|
+
export declare const ENGAGEMENT_LEVELS: readonly ["none", "low", "medium", "high"];
|
|
6
|
+
export type Engagement = (typeof ENGAGEMENT_LEVELS)[number];
|
|
7
|
+
export declare const isEngagement: (value: unknown) => value is Engagement;
|
|
8
|
+
/** Only a person's membership of a project takes an engagement level. */
|
|
9
|
+
export declare const checkEngagement: (kind: string, from: string, to: string, level: string) => Engagement;
|
|
10
|
+
export declare const engagementRank: (level: Engagement | null | undefined) => number;
|
|
11
|
+
/** A stable sort by `engagementRank`; links without a level keep their order among themselves. */
|
|
12
|
+
export declare const byEngagement: <T extends {
|
|
13
|
+
engagement?: Engagement | null;
|
|
14
|
+
}>(items: readonly T[]) => T[];
|
|
4
15
|
type End = "person" | "organization" | "project" | "task" | "chat" | "email_thread" | "deal" | "lead";
|
|
5
16
|
interface RelationSpec {
|
|
6
17
|
from: readonly End[];
|
|
@@ -107,6 +118,10 @@ export interface RelationshipColumns {
|
|
|
107
118
|
deletedAt?: number;
|
|
108
119
|
/** A job title beside it (`metadata.position`), never its role. */
|
|
109
120
|
position?: string;
|
|
121
|
+
/** What the role means here, in the owner's words, beside a role from a list (`metadata.roleNote`). */
|
|
122
|
+
roleNote?: string;
|
|
123
|
+
/** A person's on a project (`metadata.engagement`). */
|
|
124
|
+
engagement?: Engagement;
|
|
110
125
|
/** The source's link this owner link overrides (`metadata.overrides`). */
|
|
111
126
|
overrides?: number;
|
|
112
127
|
}
|
package/dist/domain/relations.js
CHANGED
|
@@ -11,6 +11,29 @@ export const ORGANIZATION_ROLES = [
|
|
|
11
11
|
"contact",
|
|
12
12
|
];
|
|
13
13
|
export const PROJECT_ROLES = ["owner", "manager", "contributor", "client-contact", "approver"];
|
|
14
|
+
/** How much the owner deals with a person on a project himself, not how active the person is; absent is unknown. */
|
|
15
|
+
export const ENGAGEMENT_LEVELS = ["none", "low", "medium", "high"];
|
|
16
|
+
export const isEngagement = (value) => typeof value === "string" && ENGAGEMENT_LEVELS.includes(value);
|
|
17
|
+
/** Only a person's membership of a project takes an engagement level. */
|
|
18
|
+
export const checkEngagement = (kind, from, to, level) => {
|
|
19
|
+
if (kind !== "member-of" || from !== "person" || to !== "project")
|
|
20
|
+
throw new CliError("validation_error", "an engagement level is set only on a person's member-of a project", {
|
|
21
|
+
reason: "relationship.engagement-ends",
|
|
22
|
+
});
|
|
23
|
+
if (!isEngagement(level))
|
|
24
|
+
throw new CliError("validation_error", `an engagement level is one of ${ENGAGEMENT_LEVELS.join(", ")}`, {
|
|
25
|
+
reason: "relationship.engagement-unknown",
|
|
26
|
+
});
|
|
27
|
+
return level;
|
|
28
|
+
};
|
|
29
|
+
/** Who the owner deals with most comes first: high, medium, unknown, low, none. */
|
|
30
|
+
const ENGAGEMENT_ORDER = { high: 0, medium: 1, unknown: 2, low: 3, none: 4 };
|
|
31
|
+
export const engagementRank = (level) => ENGAGEMENT_ORDER[level ?? "unknown"];
|
|
32
|
+
/** A stable sort by `engagementRank`; links without a level keep their order among themselves. */
|
|
33
|
+
export const byEngagement = (items) => items
|
|
34
|
+
.map((item, index) => ({ item, index }))
|
|
35
|
+
.sort((a, b) => engagementRank(a.item.engagement) - engagementRank(b.item.engagement) || a.index - b.index)
|
|
36
|
+
.map(({ item }) => item);
|
|
14
37
|
/**
|
|
15
38
|
* Every relationship `knowledge.relate` makes, its ends, its roles and how it reads backwards. An organization may
|
|
16
39
|
* still be a member: owner data from before this list holds such links.
|
package/dist/errors/reasons.js
CHANGED
|
@@ -207,6 +207,11 @@ const OTHERS = [
|
|
|
207
207
|
"recovering the store needs the sqlite3 program, 3.43 or newer, with its .recover command",
|
|
208
208
|
],
|
|
209
209
|
validation("store.recovery-failed", "the recovered store did not pass its check, so the store was left as it was"),
|
|
210
|
+
[
|
|
211
|
+
"serve.outdated",
|
|
212
|
+
"configuration_error",
|
|
213
|
+
"the store or the installed version is newer than this serve; it stopped so its unit starts the installed one",
|
|
214
|
+
],
|
|
210
215
|
validation("store.recovering", "another recovery of the store is running; wait for it to finish"),
|
|
211
216
|
validation("store.changed-during-recovery", "the store was written to during the recovery, so it was left as it was"),
|
|
212
217
|
[
|
|
@@ -385,6 +390,8 @@ const OTHERS = [
|
|
|
385
390
|
validation("relationship.role-built-in", "a built-in role stays on its list"),
|
|
386
391
|
validation("relationship.role-in-use", "relationships still hold that role; change them first (details.count)"),
|
|
387
392
|
validation("relationship.role-unknown", "the role is not one the relationship takes; the message lists them"),
|
|
393
|
+
validation("relationship.engagement-ends", "only a person's member-of a project takes an engagement level"),
|
|
394
|
+
validation("relationship.engagement-unknown", "the engagement level is not none, low, medium or high"),
|
|
388
395
|
validation("ranking.invalid", "the ranking is not valid"),
|
|
389
396
|
validation("ref.malformed", "the reference has a known kind but not its shape"),
|
|
390
397
|
validation("ref.unknown-kind", "the text names no kind of reference"),
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { CRM_KINDS, type CrmDepartment, type CrmField, type CrmItem, type CrmKin
|
|
|
6
6
|
export { DEAL_KINDS, DEAL_ROLES, DEAL_STATUSES, type DealKind, type DealRole, type DealStatus, STAGE_OUTCOMES, type StageOutcome, } from "./domain/deals.js";
|
|
7
7
|
export { FINANCE_REVIEWS, type FinanceReview, INVOICE_DIRECTIONS, INVOICE_STATUSES, type InvoiceDirection, type InvoiceStatus, MONEY_DIRECTIONS, type MoneyDirection, } from "./domain/finance.js";
|
|
8
8
|
export { type FormattedText, type HtmlFormatting, type MarkdownFormatting, type TextSpan, validateFormattedText, } from "./domain/formatting.js";
|
|
9
|
-
export { DEFAULT_LINK_CONFIG, type DeepLinkTarget, formatLink, LINK_VERSION, type LinkConfig, type LinkForm, linkConfigOf, linkFor, linkTargetOf, parseLink, } from "./domain/links.js";
|
|
9
|
+
export { DEFAULT_LINK_CONFIG, type DeepLinkTarget, formatLink, LINK_VERSION, type LinkConfig, type LinkForm, linkConfigOf, linkFor, linkTargetOf, parseLink, refsForLink, } from "./domain/links.js";
|
|
10
10
|
export { formatLocator, isLocator, type MessageLocator, parseLocator } from "./domain/locator.js";
|
|
11
11
|
export { type Markup, parseMarkdown } from "./domain/markdown.js";
|
|
12
12
|
export { parseMarkdownSpans } from "./domain/markdown-spans.js";
|
|
@@ -21,7 +21,7 @@ export type { RankingComponent, RankingInput, RankingMeasure, RankingOptions, Ra
|
|
|
21
21
|
export { rankingOptions } from "./domain/rankings-options.js";
|
|
22
22
|
export { type EnvelopeOptions, type EnvelopeRecord, type EnvelopeSource, envelopeOfJsonl, envelopeOfText, type IngestError, RECORD_ENTITY_TYPES, RECORD_OPERATIONS, RECORDS_ENVELOPE_SCHEMA, RECORDS_SCHEMA_VERSION, type RecordEntityType, type RecordOperation, type RecordRelation, type RecordsEnvelope, } from "./domain/records.js";
|
|
23
23
|
export { canonicalReference, formatReference, looksLikeReference, parseReference, REF_KINDS, type Reference, type RefKindName, type RefKindSpec, } from "./domain/references.js";
|
|
24
|
-
export { inverseOf, isUsable, ORGANIZATION_ROLES, PROJECT_ROLES, RELATION_KINDS, RELATIONS, type RelationKind, ROLE_LISTS, type RoleList, rolesOf, STANDINGS, type Standing, standingOf, usableLink, } from "./domain/relations.js";
|
|
24
|
+
export { byEngagement, ENGAGEMENT_LEVELS, type Engagement, engagementRank, inverseOf, isUsable, ORGANIZATION_ROLES, PROJECT_ROLES, RELATION_KINDS, RELATIONS, type RelationKind, ROLE_LISTS, type RoleList, rolesOf, STANDINGS, type Standing, standingOf, usableLink, } from "./domain/relations.js";
|
|
25
25
|
export { normalizeTag, TAG_TYPES, type TagType } from "./domain/tags.js";
|
|
26
26
|
export { envelopeOfVcard, isVcard, type VcardIssue, type VcardOptions } from "./domain/vcard.js";
|
|
27
27
|
export { type AppErrors, DETAILS as CORE_DETAILS, failureContext, REASONS as CORE_REASONS } from "./errors/reasons.js";
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ export { CRM_KINDS, isItemKind, } from "./domain/crm.js";
|
|
|
5
5
|
export { DEAL_KINDS, DEAL_ROLES, DEAL_STATUSES, STAGE_OUTCOMES, } from "./domain/deals.js";
|
|
6
6
|
export { FINANCE_REVIEWS, INVOICE_DIRECTIONS, INVOICE_STATUSES, MONEY_DIRECTIONS, } from "./domain/finance.js";
|
|
7
7
|
export { validateFormattedText, } from "./domain/formatting.js";
|
|
8
|
-
export { DEFAULT_LINK_CONFIG, formatLink, LINK_VERSION, linkConfigOf, linkFor, linkTargetOf, parseLink, } from "./domain/links.js";
|
|
8
|
+
export { DEFAULT_LINK_CONFIG, formatLink, LINK_VERSION, linkConfigOf, linkFor, linkTargetOf, parseLink, refsForLink, } from "./domain/links.js";
|
|
9
9
|
export { formatLocator, isLocator, parseLocator } from "./domain/locator.js";
|
|
10
10
|
export { parseMarkdown } from "./domain/markdown.js";
|
|
11
11
|
export { parseMarkdownSpans } from "./domain/markdown-spans.js";
|
|
@@ -16,7 +16,7 @@ export { ADDED_ACCOUNT, ADDED_PROVIDER, CRM_OPENS, FOLDER_PROVIDERS, holdsKind,
|
|
|
16
16
|
export { rankingOptions } from "./domain/rankings-options.js";
|
|
17
17
|
export { envelopeOfJsonl, envelopeOfText, RECORD_ENTITY_TYPES, RECORD_OPERATIONS, RECORDS_ENVELOPE_SCHEMA, RECORDS_SCHEMA_VERSION, } from "./domain/records.js";
|
|
18
18
|
export { canonicalReference, formatReference, looksLikeReference, parseReference, REF_KINDS, } from "./domain/references.js";
|
|
19
|
-
export { inverseOf, isUsable, ORGANIZATION_ROLES, PROJECT_ROLES, RELATION_KINDS, RELATIONS, ROLE_LISTS, rolesOf, STANDINGS, standingOf, usableLink, } from "./domain/relations.js";
|
|
19
|
+
export { byEngagement, ENGAGEMENT_LEVELS, engagementRank, inverseOf, isUsable, ORGANIZATION_ROLES, PROJECT_ROLES, RELATION_KINDS, RELATIONS, ROLE_LISTS, rolesOf, STANDINGS, standingOf, usableLink, } from "./domain/relations.js";
|
|
20
20
|
export { normalizeTag, TAG_TYPES } from "./domain/tags.js";
|
|
21
21
|
export { envelopeOfVcard, isVcard } from "./domain/vcard.js";
|
|
22
22
|
export { DETAILS as CORE_DETAILS, failureContext, REASONS as CORE_REASONS } from "./errors/reasons.js";
|
|
@@ -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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { formatReference, parseReference } from "../../domain/references.js";
|
|
2
|
-
import { contactRef, personRefOf, sameAccount } from "./shared.js";
|
|
2
|
+
import { contactRef, personRefOf, remembered, sameAccount } from "./shared.js";
|
|
3
3
|
const WEIGHT = 0.5;
|
|
4
4
|
const LARGE_GROUP_WEIGHT = 0.2;
|
|
5
5
|
const LARGE_GROUP = 30;
|
|
@@ -23,7 +23,8 @@ export const chatSenders = {
|
|
|
23
23
|
id: "chat-senders",
|
|
24
24
|
version: 3,
|
|
25
25
|
spreads: true,
|
|
26
|
-
candidates: async (
|
|
26
|
+
candidates: async (input) => {
|
|
27
|
+
const { project, confirmed, sources, signal } = input;
|
|
27
28
|
if (!project)
|
|
28
29
|
return [];
|
|
29
30
|
const found = [];
|
|
@@ -35,34 +36,43 @@ export const chatSenders = {
|
|
|
35
36
|
if (!key)
|
|
36
37
|
continue;
|
|
37
38
|
signal?.throwIfAborted();
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
for (const message of page.items) {
|
|
41
|
-
if (message.senderId === null || message.senderIsChat)
|
|
42
|
-
continue;
|
|
43
|
-
const id = String(message.senderId);
|
|
44
|
-
senders.set(id, { count: (senders.get(id)?.count ?? 0) + 1, last: String(message.id) });
|
|
45
|
-
}
|
|
46
|
-
const size = Math.max((await store.roster.members(key, reference.chat)).length, senders.size);
|
|
47
|
-
const weight = size > LARGE_GROUP ? LARGE_GROUP_WEIGHT : WEIGHT;
|
|
48
|
-
const where = named(await store.chats.chatTitle(key, reference.chat), chat);
|
|
49
|
-
for (const [id, { count, last }] of senders) {
|
|
50
|
-
if (size > SMALL_CHAT && count < MIN_MESSAGES)
|
|
51
|
-
continue;
|
|
52
|
-
const person = await personRefOf(store, key.provider, id);
|
|
53
|
-
if (!person || person === owner)
|
|
54
|
-
continue;
|
|
55
|
-
found.push({
|
|
56
|
-
from: person,
|
|
57
|
-
to: project.ref,
|
|
58
|
-
kind: "member-of",
|
|
59
|
-
weight,
|
|
60
|
-
why: `wrote ${count} message${count === 1 ? "" : "s"} in ${where} (${size} people) since ${since.slice(0, 10)}`,
|
|
61
|
-
evidence: [chat, formatReference({ ...reference, type: "message", message: last })],
|
|
62
|
-
identity: contactRef(key.provider, id),
|
|
63
|
-
});
|
|
64
|
-
}
|
|
39
|
+
for (const one of await remembered(input, `chat-senders\u0000${chat}`, () => sendersOf(input, chat, reference, key)))
|
|
40
|
+
found.push(one);
|
|
65
41
|
}
|
|
66
42
|
return found;
|
|
67
43
|
},
|
|
68
44
|
};
|
|
45
|
+
const sendersOf = async (input, chat, reference, key) => {
|
|
46
|
+
const { store, project, since, owner } = input;
|
|
47
|
+
if (!project)
|
|
48
|
+
return [];
|
|
49
|
+
const found = [];
|
|
50
|
+
const page = await store.messages.messages(key, reference.chat, { limit: READ_LIMIT, since, outgoing: false });
|
|
51
|
+
const senders = new Map();
|
|
52
|
+
for (const message of page.items) {
|
|
53
|
+
if (message.senderId === null || message.senderIsChat)
|
|
54
|
+
continue;
|
|
55
|
+
const id = String(message.senderId);
|
|
56
|
+
senders.set(id, { count: (senders.get(id)?.count ?? 0) + 1, last: String(message.id) });
|
|
57
|
+
}
|
|
58
|
+
const size = Math.max((await store.roster.members(key, reference.chat)).length, senders.size);
|
|
59
|
+
const weight = size > LARGE_GROUP ? LARGE_GROUP_WEIGHT : WEIGHT;
|
|
60
|
+
const where = named(await store.chats.chatTitle(key, reference.chat), chat);
|
|
61
|
+
for (const [id, { count, last }] of senders) {
|
|
62
|
+
if (size > SMALL_CHAT && count < MIN_MESSAGES)
|
|
63
|
+
continue;
|
|
64
|
+
const person = await personRefOf(input, key.provider, id);
|
|
65
|
+
if (!person || person === owner)
|
|
66
|
+
continue;
|
|
67
|
+
found.push({
|
|
68
|
+
from: person,
|
|
69
|
+
to: project.ref,
|
|
70
|
+
kind: "member-of",
|
|
71
|
+
weight,
|
|
72
|
+
why: `wrote ${count} message${count === 1 ? "" : "s"} in ${where} (${size} people) since ${since.slice(0, 10)}`,
|
|
73
|
+
evidence: [chat, formatReference({ ...reference, type: "message", message: last })],
|
|
74
|
+
identity: contactRef(key.provider, id),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return found;
|
|
78
|
+
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { chatRef, identitiesIn } from "./shared.js";
|
|
1
|
+
import { chatRef, chatsWithOf, identitiesIn } from "./shared.js";
|
|
2
2
|
const WEIGHT = 0.5;
|
|
3
3
|
/** A group or channel where two or more of the project's confirmed person members are members. */
|
|
4
4
|
export const memberChats = {
|
|
5
5
|
id: "member-chats",
|
|
6
6
|
version: 1,
|
|
7
7
|
spreads: true,
|
|
8
|
-
candidates: async (
|
|
8
|
+
candidates: async (input) => {
|
|
9
|
+
const { store, project, confirmed, sources, owner, signal } = input;
|
|
9
10
|
if (!project)
|
|
10
11
|
return [];
|
|
11
12
|
const people = confirmed.people.filter((person) => person !== owner);
|
|
@@ -14,7 +15,7 @@ export const memberChats = {
|
|
|
14
15
|
const members = new Map();
|
|
15
16
|
for (const { person, id } of await identitiesIn(store, people, key.provider)) {
|
|
16
17
|
signal?.throwIfAborted();
|
|
17
|
-
for (const chat of await
|
|
18
|
+
for (const chat of await chatsWithOf(input, key, id)) {
|
|
18
19
|
if (chat.kind !== "group" && chat.kind !== "channel")
|
|
19
20
|
continue;
|
|
20
21
|
const held = members.get(String(chat.id)) ?? new Set();
|
|
@@ -1,25 +1,23 @@
|
|
|
1
|
-
import { chatRef, identitiesIn, projectsOf } from "./shared.js";
|
|
1
|
+
import { chatRef, chatsWithOf, identitiesIn, projectsOf, remembered } from "./shared.js";
|
|
2
2
|
const WEIGHT = 0.6;
|
|
3
3
|
/** A dialog with a person member, divided by how many projects that person is a member of, this one counted. */
|
|
4
4
|
export const memberDialog = {
|
|
5
5
|
id: "member-dialog",
|
|
6
6
|
version: 2,
|
|
7
7
|
spreads: true,
|
|
8
|
-
candidates: async (
|
|
8
|
+
candidates: async (input) => {
|
|
9
|
+
const { store, project, confirmed, sources, owner, signal } = input;
|
|
9
10
|
if (!project)
|
|
10
11
|
return [];
|
|
11
12
|
const people = confirmed.people.filter((person) => person !== owner);
|
|
12
|
-
const projects = new Map();
|
|
13
13
|
const found = [];
|
|
14
14
|
for (const key of sources)
|
|
15
15
|
for (const { person, id } of await identitiesIn(store, people, key.provider)) {
|
|
16
16
|
signal?.throwIfAborted();
|
|
17
|
-
for (const chat of await
|
|
17
|
+
for (const chat of await chatsWithOf(input, key, id)) {
|
|
18
18
|
if (chat.kind !== "dialog")
|
|
19
19
|
continue;
|
|
20
|
-
|
|
21
|
-
projects.set(person, await projectsOf(store, person, project.ref));
|
|
22
|
-
const shared = projects.get(person) ?? 1;
|
|
20
|
+
const shared = await remembered(input, `projects-of\u0000${person}`, () => projectsOf(store, person, project.ref));
|
|
23
21
|
found.push({
|
|
24
22
|
from: chatRef(key, chat.id),
|
|
25
23
|
to: project.ref,
|
|
@@ -10,7 +10,7 @@ import { emailDomain } from "./email-domain.js";
|
|
|
10
10
|
import { mailThread } from "./mail-thread.js";
|
|
11
11
|
import { memberChats } from "./member-chats.js";
|
|
12
12
|
import { memberDialog } from "./member-dialog.js";
|
|
13
|
-
import { sameAccount } from "./shared.js";
|
|
13
|
+
import { personRefOf, sameAccount } from "./shared.js";
|
|
14
14
|
/** A new scorer is one file and one line here. */
|
|
15
15
|
export const SCORERS = [chatTitle, aliasHits, memberChats, memberDialog, chatSenders, mailThread];
|
|
16
16
|
/** What a scan with no project runs: person ↔ person rules. */
|
|
@@ -87,6 +87,7 @@ export const scanProjectLinks = async (store, input) => {
|
|
|
87
87
|
purposes: input.purposes ?? BUILT_IN_PURPOSES,
|
|
88
88
|
owner: owner ? `person:${owner.uid}` : null,
|
|
89
89
|
...(input.signal ? { signal: input.signal } : {}),
|
|
90
|
+
remember: rememberer(),
|
|
90
91
|
};
|
|
91
92
|
const scorers = input.scorers ?? (project ? SCORERS : PERSON_SCORERS);
|
|
92
93
|
const skipped = {
|
|
@@ -106,13 +107,13 @@ export const scanProjectLinks = async (store, input) => {
|
|
|
106
107
|
return held;
|
|
107
108
|
};
|
|
108
109
|
let seeds = scorerInput.confirmed;
|
|
109
|
-
let collected = await collect(
|
|
110
|
+
let collected = await collect(scorerInput, scorers, (scorer) => candidatesOf(scorer, seeds));
|
|
110
111
|
for (let hop = 0; hop < MAX_HOPS && scorers.some((one) => one.spreads); hop++) {
|
|
111
112
|
const grown = await seedsOf(store, seeds, collected.scored, threshold);
|
|
112
113
|
if (!grown)
|
|
113
114
|
break;
|
|
114
115
|
seeds = grown;
|
|
115
|
-
collected = await collect(
|
|
116
|
+
collected = await collect(scorerInput, scorers, (scorer) => candidatesOf(scorer, seeds));
|
|
116
117
|
}
|
|
117
118
|
skipped.nameOnly = collected.nameOnly;
|
|
118
119
|
skipped.unresolved = collected.unresolved;
|
|
@@ -180,7 +181,7 @@ export const scanProjectLinks = async (store, input) => {
|
|
|
180
181
|
return { project: project?.ref ?? null, proposals, skipped };
|
|
181
182
|
};
|
|
182
183
|
/** Every scorer's candidates, combined per pair and scored, highest first. */
|
|
183
|
-
const collect = async (
|
|
184
|
+
const collect = async (input, scorers, candidatesOf) => {
|
|
184
185
|
const pairs = new Map();
|
|
185
186
|
const nameOnly = new Set();
|
|
186
187
|
let unresolved = 0;
|
|
@@ -188,7 +189,7 @@ const collect = async (store, input, scorers, candidatesOf) => {
|
|
|
188
189
|
input.signal?.throwIfAborted();
|
|
189
190
|
for (const candidate of await candidatesOf(scorer)) {
|
|
190
191
|
const key = pairKey(candidate);
|
|
191
|
-
const verdict = await admissible(
|
|
192
|
+
const verdict = await admissible(input, candidate);
|
|
192
193
|
if (verdict === "owner")
|
|
193
194
|
continue;
|
|
194
195
|
if (verdict === "name-only") {
|
|
@@ -254,7 +255,7 @@ const seedsOf = async (store, seeds, scored, threshold) => {
|
|
|
254
255
|
return chats.size + people.size === size ? undefined : { chats: [...chats].sort(), people: [...people].sort() };
|
|
255
256
|
};
|
|
256
257
|
/** A person candidate stands only on an identity that is that person's; a chat only in a source the scan reads. */
|
|
257
|
-
const admissible = async (
|
|
258
|
+
const admissible = async (input, candidate) => {
|
|
258
259
|
if (candidate.from === candidate.to || !Number.isFinite(candidate.weight))
|
|
259
260
|
return "unresolved";
|
|
260
261
|
if (input.project && candidate.to !== input.project.ref && !candidate.to.startsWith("person:"))
|
|
@@ -265,8 +266,7 @@ const admissible = async (store, input, candidate) => {
|
|
|
265
266
|
const identity = candidate.identity === undefined ? undefined : referenceOf(candidate.identity);
|
|
266
267
|
if (identity?.type !== "contact")
|
|
267
268
|
return "name-only";
|
|
268
|
-
|
|
269
|
-
return person !== undefined && `person:${person.uid}` === candidate.from ? "ok" : "name-only";
|
|
269
|
+
return (await personRefOf(input, identity.provider, identity.id)) === candidate.from ? "ok" : "name-only";
|
|
270
270
|
}
|
|
271
271
|
if (candidate.from.startsWith("chat:")) {
|
|
272
272
|
const chat = referenceOf(candidate.from);
|
|
@@ -274,6 +274,15 @@ const admissible = async (store, input, candidate) => {
|
|
|
274
274
|
}
|
|
275
275
|
return "unresolved";
|
|
276
276
|
};
|
|
277
|
+
/** The store does not change under a scan until it writes its proposals, after the last pass. */
|
|
278
|
+
const rememberer = () => {
|
|
279
|
+
const held = new Map();
|
|
280
|
+
return (key, read) => {
|
|
281
|
+
const found = held.get(key) ?? read();
|
|
282
|
+
held.set(key, found);
|
|
283
|
+
return found;
|
|
284
|
+
};
|
|
285
|
+
};
|
|
277
286
|
const referenceOf = (text) => {
|
|
278
287
|
try {
|
|
279
288
|
return parseReference(text);
|