@wirecat/cli-core 0.631.0 → 0.632.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/dist/calendar/mcp/index.d.ts +12 -12
  3. package/dist/cli/messenger/context.d.ts +2 -0
  4. package/dist/cli/messenger/reply-stats-command.js +1 -1
  5. package/dist/cli/messenger/serve-relay.d.ts +1 -0
  6. package/dist/cli/messenger/stats-answers.d.ts +5 -2
  7. package/dist/cli/messenger/stats-answers.js +8 -2
  8. package/dist/cli/messenger/tasks-command.js +5 -3
  9. package/dist/domain/test-data.d.ts +15 -0
  10. package/dist/domain/test-data.js +18 -0
  11. package/dist/entities/chat-stats.d.ts +2 -0
  12. package/dist/entities/chat-stats.js +2 -0
  13. package/dist/entities/index.d.ts +1 -0
  14. package/dist/errors/reasons.js +9 -0
  15. package/dist/kit/seed.js +6 -7
  16. package/dist/search/lucene/registry.js +11 -0
  17. package/dist/services/proposals/kinds/identity-split.d.ts +4 -0
  18. package/dist/services/proposals/kinds/identity-split.js +65 -0
  19. package/dist/services/proposals/registry.js +2 -0
  20. package/dist/services/reply-stats.js +11 -3
  21. package/dist/services/task-stats.d.ts +7 -2
  22. package/dist/services/task-stats.js +53 -20
  23. package/dist/services/tasks.d.ts +1 -0
  24. package/dist/services/tasks.js +16 -4
  25. package/dist/store/decisions.js +3 -1
  26. package/dist/store/drivers/bun-sqlite.js +2 -0
  27. package/dist/store/drivers/node-sqlite.js +2 -0
  28. package/dist/store/identity-splits.d.ts +60 -0
  29. package/dist/store/identity-splits.js +5 -0
  30. package/dist/store/index.d.ts +2 -0
  31. package/dist/store/index.js +2 -0
  32. package/dist/store/people.d.ts +23 -0
  33. package/dist/store/people.js +6 -0
  34. package/dist/store/sqlite/accounts.js +4 -0
  35. package/dist/store/sqlite/crm-contacts.js +5 -1
  36. package/dist/store/sqlite/identity-link-rows.d.ts +5 -0
  37. package/dist/store/sqlite/identity-link-rows.js +5 -3
  38. package/dist/store/sqlite/identity-split-proposals.d.ts +29 -0
  39. package/dist/store/sqlite/identity-split-proposals.js +195 -0
  40. package/dist/store/sqlite/lucene-fields.js +3 -0
  41. package/dist/store/sqlite/person-doubts.d.ts +36 -0
  42. package/dist/store/sqlite/person-doubts.js +229 -0
  43. package/dist/store/sqlite/proposed-actions.js +6 -0
  44. package/dist/store/sqlite/reply-times.d.ts +3 -1
  45. package/dist/store/sqlite/reply-times.js +11 -6
  46. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,43 @@ Notable changes to `@wirecat/cli-core` (`@wirecat/cli-messaging` up to 0.261.0,
5
5
  minor version may break callers, and says how under "Changed — may break callers". `pnpm docs:check` checks the
6
6
  shape of this file.
7
7
 
8
+ ## 0.632.0 — 10.11.2026
9
+
10
+ ### Added
11
+
12
+ - **`PeopleStore.doubts` lists people that may be wrong**, a page at a time, the owner first, each with a plain reason,
13
+ the identities in doubt, the evidence and the owner's commands that would fix it: the owner's person holding an
14
+ identity under another name (spelling and script aside; what the owner linked by hand never counts), test data (the
15
+ contract seed's people, an address at a reserved domain such as `.test` or `example.com`), an identity joined by an
16
+ address that a person of another name has, and one person with different names and no phone or address in common.
17
+ It reads only the people with more than one identity and one pass over identities: about 0.1 s on a store of 150k
18
+ people.
19
+ - **An agent's unlink or unmerge waits for the owner.** `PeopleStore.proposeSplit` stores an `identity_split`
20
+ proposal (the identities that leave, all of one person, or a `merge:<to>-<from>`) with its reason;
21
+ `decideSplit` is the owner's alone and carries it out as the owner's own unlink, split or undo of the merge, refused
22
+ with `identity.stale` when the person changed since. `splitProposals` lists them, and the shared review
23
+ (`proposalRegistry`) shows and decides them as kind `identity_split`, owner-only. Proposing an open split again
24
+ renews it after the person changed. A split the owner turned down is not proposed again while its identities stay
25
+ on that person, and `doubts` leaves them out. Removing a CRM contact or erasing an identity deletes the splits that
26
+ name it. No store migration: older builds see the kind as a plain action, and one they approve is never carried
27
+ out (`splitProposals` shows it as `dropped`).
28
+ - `SEED_PEOPLE`, `RESERVED_ADDRESS_GLOBS` and `SEED_ID_GLOBS` in the domain, which the contract seed now uses.
29
+ - **`muted:` in the query language.** `muted:true` matches messages in chats the owner muted, until the mute runs
30
+ out; `muted:false` matches every other chat, so `stats messages show 'muted:false date>=30d'` counts only what the
31
+ sync still reads. A messenger that keeps no mute state counts its chats as not muted. `stats messages responses`
32
+ and `stats messages waiting` take it too.
33
+ - **`stats tasks show` can count every account at once.** A `Messenger` that sets `accountsOf(command)` gets one answer
34
+ across the accounts it returns, when the command names none: memo uses it so `memo stats tasks show` needs no
35
+ `--source`. The answer lists them in `accounts`, and each chat row's `chat` names its own account. `--chat` and a
36
+ `chat:` naming one chat are then refused, since a chat belongs to one account.
37
+
38
+ ### Fixed
39
+
40
+ - **A test can no longer reach the owner's real store through `openCache` either.** The refusal of 0.560.0 covered
41
+ `openStore` and `openSqlite`; `openCache` and `openFile`, which first-run, store settings, schedules and store
42
+ backups use, opened the file without it. The check now sits in both SQLite drivers, so every opening under vitest
43
+ refuses a file in the owner's WireCat folder.
44
+
8
45
  ## 0.631.0 — 10.11.2026
9
46
 
10
47
  ### Added
@@ -10,13 +10,13 @@ export declare const calendarTools: ({
10
10
  inputSchema: {
11
11
  type: string;
12
12
  properties: {
13
+ limit?: undefined;
13
14
  account_id: {
14
15
  type: string;
15
16
  minimum: number;
16
17
  };
17
18
  query?: undefined;
18
19
  timezone?: undefined;
19
- limit?: undefined;
20
20
  page?: undefined;
21
21
  event?: undefined;
22
22
  } | {
@@ -45,9 +45,9 @@ export declare const calendarTools: ({
45
45
  };
46
46
  event?: undefined;
47
47
  } | {
48
+ limit?: undefined;
48
49
  query?: undefined;
49
50
  timezone?: undefined;
50
- limit?: undefined;
51
51
  page?: undefined;
52
52
  event: {
53
53
  type: string;
@@ -58,9 +58,9 @@ export declare const calendarTools: ({
58
58
  minimum: number;
59
59
  };
60
60
  } | {
61
+ limit?: undefined;
61
62
  query?: undefined;
62
63
  timezone?: undefined;
63
- limit?: undefined;
64
64
  page?: undefined;
65
65
  event?: undefined;
66
66
  account_id?: undefined;
@@ -80,13 +80,13 @@ export declare const calendarTools: ({
80
80
  inputSchema: {
81
81
  type: string;
82
82
  properties: {
83
+ limit?: undefined;
83
84
  account_id: {
84
85
  type: string;
85
86
  minimum: number;
86
87
  };
87
88
  query?: undefined;
88
89
  timezone?: undefined;
89
- limit?: undefined;
90
90
  page?: undefined;
91
91
  event?: undefined;
92
92
  } | {
@@ -115,9 +115,9 @@ export declare const calendarTools: ({
115
115
  };
116
116
  event?: undefined;
117
117
  } | {
118
+ limit?: undefined;
118
119
  query?: undefined;
119
120
  timezone?: undefined;
120
- limit?: undefined;
121
121
  page?: undefined;
122
122
  event: {
123
123
  type: string;
@@ -128,9 +128,9 @@ export declare const calendarTools: ({
128
128
  minimum: number;
129
129
  };
130
130
  } | {
131
+ limit?: undefined;
131
132
  query?: undefined;
132
133
  timezone?: undefined;
133
- limit?: undefined;
134
134
  page?: undefined;
135
135
  event?: undefined;
136
136
  account_id?: undefined;
@@ -150,13 +150,13 @@ export declare const calendarTools: ({
150
150
  inputSchema: {
151
151
  type: string;
152
152
  properties: {
153
+ limit?: undefined;
153
154
  account_id: {
154
155
  type: string;
155
156
  minimum: number;
156
157
  };
157
158
  query?: undefined;
158
159
  timezone?: undefined;
159
- limit?: undefined;
160
160
  page?: undefined;
161
161
  event?: undefined;
162
162
  } | {
@@ -185,9 +185,9 @@ export declare const calendarTools: ({
185
185
  };
186
186
  event?: undefined;
187
187
  } | {
188
+ limit?: undefined;
188
189
  query?: undefined;
189
190
  timezone?: undefined;
190
- limit?: undefined;
191
191
  page?: undefined;
192
192
  event: {
193
193
  type: string;
@@ -198,9 +198,9 @@ export declare const calendarTools: ({
198
198
  minimum: number;
199
199
  };
200
200
  } | {
201
+ limit?: undefined;
201
202
  query?: undefined;
202
203
  timezone?: undefined;
203
- limit?: undefined;
204
204
  page?: undefined;
205
205
  event?: undefined;
206
206
  account_id?: undefined;
@@ -220,13 +220,13 @@ export declare const calendarTools: ({
220
220
  inputSchema: {
221
221
  type: string;
222
222
  properties: {
223
+ limit?: undefined;
223
224
  account_id: {
224
225
  type: string;
225
226
  minimum: number;
226
227
  };
227
228
  query?: undefined;
228
229
  timezone?: undefined;
229
- limit?: undefined;
230
230
  page?: undefined;
231
231
  event?: undefined;
232
232
  } | {
@@ -255,9 +255,9 @@ export declare const calendarTools: ({
255
255
  };
256
256
  event?: undefined;
257
257
  } | {
258
+ limit?: undefined;
258
259
  query?: undefined;
259
260
  timezone?: undefined;
260
- limit?: undefined;
261
261
  page?: undefined;
262
262
  event: {
263
263
  type: string;
@@ -268,9 +268,9 @@ export declare const calendarTools: ({
268
268
  minimum: number;
269
269
  };
270
270
  } | {
271
+ limit?: undefined;
271
272
  query?: undefined;
272
273
  timezone?: undefined;
273
- limit?: undefined;
274
274
  page?: undefined;
275
275
  event?: undefined;
276
276
  account_id?: undefined;
@@ -201,6 +201,8 @@ export interface Messenger extends ServiceMessenger {
201
201
  * profile and mounts the local task builders with `--provider --account`.
202
202
  */
203
203
  accountOf?: (command: Command) => AccountKey | undefined;
204
+ /** Every account a read covers when the command names none: memo's `stats tasks show` without `--source`. */
205
+ accountsOf?: (command: Command) => readonly AccountKey[] | undefined;
204
206
  /**
205
207
  * Whether a stored chat may hold a message the messenger deleted without naming its chat. When
206
208
  * unset, the store applies Telegram's rule.
@@ -4,7 +4,7 @@ import { LOCAL_READ } from "../effects.js";
4
4
  import { renderAnswer } from "../envelope.js";
5
5
  import { messengerContext } from "./context.js";
6
6
  import { refuseJsonl, responsesAnswer, waitingAnswer } from "./stats-answers.js";
7
- const QUERY = "date:, chat: and kind: terms, AND-ed — date>=30d, date:[60d TO 30d]; none reads all time";
7
+ const QUERY = "date:, chat:, kind: and muted: terms, AND-ed — date>=30d, date:[60d TO 30d], muted:false; none reads all time";
8
8
  const GUIDE = "Guide: https://github.com/WireCatLabs/cli-core/blob/main/docs/rankings.md#reply-times-and-chats-waiting-on-you";
9
9
  const minutes = (ms) => (ms === null ? "—" : `${Math.round(ms / 60_000)} min`);
10
10
  export const replyResponsesCommand = (messenger) => annotate(new Command("responses"), { effects: LOCAL_READ, output: { entity: "response_times" } })
@@ -91,6 +91,7 @@ export declare const serveRelay: (command: Command, messenger: Messenger) => {
91
91
  adminRights?: readonly import("../../domain/models.js").AdminRight[];
92
92
  pickAdminRights?: boolean;
93
93
  accountOf?: (command: Command) => import("../../store/types.js").AccountKey | undefined;
94
+ accountsOf?: (command: Command) => readonly import("../../store/types.js").AccountKey[] | undefined;
94
95
  deletedWithoutChat?: import("../../store/types.js").DeletionScope;
95
96
  officialStats?: boolean;
96
97
  tracksMembers?: boolean;
@@ -71,8 +71,11 @@ export declare const refuseJsonl: (format: string) => void;
71
71
  export declare const chatStatsAnswer: (stats: ChatStats, account: AccountKey, meta?: Partial<Meta>) => ItemBody<Of<"chat_stats">>;
72
72
  /** Said where the store has kept no join, leave or other chat event for the chat: a 0 would read as nobody joined. */
73
73
  export declare const MEMBERS_UNRECORDED = "joins and leaves are not recorded for this chat yet, so they are not counted";
74
- /** `stats tasks show`, CLI and MCP alike. A row of `--by chat` also names its chat as `chat`, as it always has. */
75
- export declare const taskStatsAnswer: (stats: TaskStats, account: AccountKey) => ItemBody<Of<"task_stats">>;
74
+ /**
75
+ * `stats tasks show`, CLI and MCP alike. A row of `--by chat` also names its chat as `chat`, as it always has;
76
+ * `account` is the one account read, and an answer across several names each row's own.
77
+ */
78
+ export declare const taskStatsAnswer: (stats: TaskStats, account: AccountKey | undefined) => ItemBody<Of<"task_stats">>;
76
79
  export declare const responsesAnswer: (found: ReplyTimes) => ItemBody<Of<"response_times">>;
77
80
  export declare const waitingAnswer: (found: Waiting) => ItemBody<Of<"waiting_chats">>;
78
81
  export {};
@@ -1,5 +1,6 @@
1
1
  import { CliError } from "@wirecat/cli-base";
2
2
  import { formatLocator } from "../../domain/locator.js";
3
+ import { taskAccount } from "../../services/task-rules.js";
3
4
  import { itemOf, listOf } from "../envelope.js";
4
5
  import { nextStep } from "../steps.js";
5
6
  import { chatRef, contactRef } from "./chat-answers.js";
@@ -410,15 +411,20 @@ export const chatStatsAnswer = (stats, account, meta) => {
410
411
  };
411
412
  /** Said where the store has kept no join, leave or other chat event for the chat: a 0 would read as nobody joined. */
412
413
  export const MEMBERS_UNRECORDED = "joins and leaves are not recorded for this chat yet, so they are not counted";
413
- /** `stats tasks show`, CLI and MCP alike. A row of `--by chat` also names its chat as `chat`, as it always has. */
414
+ /**
415
+ * `stats tasks show`, CLI and MCP alike. A row of `--by chat` also names its chat as `chat`, as it always has;
416
+ * `account` is the one account read, and an answer across several names each row's own.
417
+ */
414
418
  export const taskStatsAnswer = (stats, account) => itemOf({
419
+ ...(stats.accounts ? { accounts: stats.accounts.map(taskAccount) } : {}),
415
420
  open: stats.open,
416
421
  created: stats.created,
417
422
  closed: stats.closed,
418
423
  median_close_ms: stats.medianCloseMs ?? null,
419
424
  mean_open_age_ms: stats.meanOpenAgeMs ?? null,
420
425
  rows: stats.rows.map((row) => {
421
- const chat = stats.by === "chat" ? chatRef(account, row.group) : undefined;
426
+ const own = row.account ?? account;
427
+ const chat = stats.by === "chat" && own ? chatRef(own, row.group) : undefined;
422
428
  return {
423
429
  ...(chat === undefined ? {} : { chat }),
424
430
  key: chat ?? (stats.by === "project" ? `project:${row.group}` : row.group),
@@ -566,6 +566,7 @@ export const tasksStatsCommand = (messenger) => {
566
566
  const { by, chat, type, timezone } = this.opts();
567
567
  refuseJsonl(context.format);
568
568
  const query = listQuery(typedQuery(words), TASK_STATS_QUERY, "stats tasks show");
569
+ const accounts = messenger.accountsOf?.(this);
569
570
  const { stats, account } = await context.withServices(async (services) => ({
570
571
  stats: await services.tasks.stats({
571
572
  ...(by === undefined ? {} : { by }),
@@ -573,16 +574,17 @@ export const tasksStatsCommand = (messenger) => {
573
574
  ...(type === undefined ? {} : { kind: type }),
574
575
  ...(query === undefined ? {} : { query }),
575
576
  ...(timezone === undefined ? {} : { timezone }),
577
+ ...(accounts === undefined ? {} : { accounts }),
576
578
  }),
577
- account: await services.messages.reader(),
579
+ account: accounts === undefined ? await services.messages.reader() : undefined,
578
580
  }));
579
581
  if (stats.rows.length === 0)
580
582
  context.renderer.note("no tasks yet");
581
583
  renderAnswer(this, context, taskStatsAnswer(stats, account), () => stats.rows.length === 0
582
584
  ? ""
583
585
  : `${stats.rows
584
- .map(({ group, name, open, created, closed, oldestOpenAt, medianCloseMs }) => [
585
- name ? `${name} (${group})` : group,
586
+ .map(({ group, account: own, name, open, created, closed, oldestOpenAt, medianCloseMs }) => [
587
+ `${name ? `${name} (${group})` : group}${own ? ` ${own.provider}:${own.account}` : ""}`,
586
588
  `${open} open`,
587
589
  `${created} created`,
588
590
  `${closed} closed`,
@@ -0,0 +1,15 @@
1
+ /** The people the shared contract seed (`src/kit/seed.ts`) makes, so a test run that reached a real store shows. */
2
+ export declare const SEED_PEOPLE: readonly [{
3
+ readonly name: "Owner";
4
+ readonly username: "owner";
5
+ }, {
6
+ readonly name: "Ann Lee";
7
+ readonly username: "ann";
8
+ }, {
9
+ readonly name: "Bob Ray";
10
+ readonly username: null;
11
+ }];
12
+ /** Domains no real mailbox has (RFC 2606 and RFC 6761), as SQLite `GLOB` patterns over a lower-cased address. */
13
+ export declare const RESERVED_ADDRESS_GLOBS: readonly ["*@example.com", "*@example.net", "*@example.org", "*.example", "*.test", "*.invalid", "*.localhost"];
14
+ /** Ids made by the seed's `wordIds`; numeric ids are real for some providers, so `digitIds` are not counted. */
15
+ export declare const SEED_ID_GLOBS: readonly ["person-[0-9]*"];
@@ -0,0 +1,18 @@
1
+ /** The people the shared contract seed (`src/kit/seed.ts`) makes, so a test run that reached a real store shows. */
2
+ export const SEED_PEOPLE = [
3
+ { name: "Owner", username: "owner" },
4
+ { name: "Ann Lee", username: "ann" },
5
+ { name: "Bob Ray", username: null },
6
+ ];
7
+ /** Domains no real mailbox has (RFC 2606 and RFC 6761), as SQLite `GLOB` patterns over a lower-cased address. */
8
+ export const RESERVED_ADDRESS_GLOBS = [
9
+ "*@example.com",
10
+ "*@example.net",
11
+ "*@example.org",
12
+ "*.example",
13
+ "*.test",
14
+ "*.invalid",
15
+ "*.localhost",
16
+ ];
17
+ /** Ids made by the seed's `wordIds`; numeric ids are real for some providers, so `digitIds` are not counted. */
18
+ export const SEED_ID_GLOBS = ["person-[0-9]*"];
@@ -67,6 +67,8 @@ export declare const chatStats: v.StrictObjectSchema<{
67
67
  * tasks opened and closed in the query's period, every task without one.
68
68
  */
69
69
  export declare const taskStats: v.StrictObjectSchema<{
70
+ /** Every account counted, `provider:account`, when the answer reads several (memo without `--source`). */
71
+ readonly accounts: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
70
72
  /** Open tasks across every row. */
71
73
  readonly open: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
72
74
  readonly created: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
@@ -60,6 +60,8 @@ const ms = v.nullable(v.pipe(v.number(), v.minValue(0)));
60
60
  * tasks opened and closed in the query's period, every task without one.
61
61
  */
62
62
  export const taskStats = v.strictObject({
63
+ /** Every account counted, `provider:account`, when the answer reads several (memo without `--source`). */
64
+ accounts: v.optional(v.array(text)),
63
65
  /** Open tasks across every row. */
64
66
  open: count,
65
67
  created: count,
@@ -11929,6 +11929,7 @@ export declare const ENTITIES: {
11929
11929
  readonly tracked: v.BooleanSchema<undefined>;
11930
11930
  }, undefined>;
11931
11931
  readonly task_stats: v.StrictObjectSchema<{
11932
+ readonly accounts: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
11932
11933
  readonly open: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
11933
11934
  readonly created: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
11934
11935
  readonly closed: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
@@ -391,6 +391,14 @@ const OTHERS = [
391
391
  "conflict",
392
392
  "the people a merge or a proposed link names changed since; undo the later merge, or propose the link again",
393
393
  ],
394
+ ["identity.no-merge", "not_found", "nothing of that person is merged into the other; people show lists the merges"],
395
+ validation("identity.several-persons", "the identities that leave a person are all of that one person"),
396
+ validation("identity.nothing-left", "a split leaves at least one identity with the person"),
397
+ [
398
+ "identity.kept-together",
399
+ "conflict",
400
+ "the owner kept these identities together by turning down their split; only the owner splits them",
401
+ ],
394
402
  [
395
403
  "identity.rejected",
396
404
  "conflict",
@@ -402,6 +410,7 @@ const OTHERS = [
402
410
  validation("identity.owner", "one side is the owner's person, and only the owner joins anyone to themselves"),
403
411
  validation("identity.shared-email", "more than six people share the address, so it proposes no one"),
404
412
  validation("identity-link.dedicated-review", "an identity link is staged and decided through the people review"),
413
+ validation("identity-split.dedicated-review", "a split of a person is staged and decided through the people review"),
405
414
  ["transcription.no-key", "authentication_error", "no OpenAI key is set for transcription"],
406
415
  validation("transcription.too-large", "the audio is over the transcription provider's size limit"),
407
416
  [
package/dist/kit/seed.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { SEED_PEOPLE } from "../domain/test-data.js";
1
2
  export const BUSY_PAGE = 3;
2
3
  const BUSY_MESSAGES = 10;
3
4
  /** Ids that are not numbers, so no code may take them for one. */
@@ -12,15 +13,13 @@ const START = Date.parse("2026-09-01T09:00:00.000Z");
12
13
  */
13
14
  export const contractSeed = ({ ids = wordIds, loggedIn = true } = {}) => {
14
15
  const at = (minute) => new Date(START + minute * 60_000);
15
- const owner = {
16
- id: ids("person", 1, at(0)),
17
- name: "Owner",
18
- username: "owner",
16
+ const [owner, ann, bob] = SEED_PEOPLE.map(({ name, username }, index) => ({
17
+ id: ids("person", index + 1, at(0)),
18
+ name,
19
+ username,
19
20
  description: null,
20
21
  lastMessagedAt: null,
21
- };
22
- const ann = { ...owner, id: ids("person", 2, at(0)), name: "Ann Lee", username: "ann" };
23
- const bob = { ...owner, id: ids("person", 3, at(0)), name: "Bob Ray", username: null };
22
+ }));
24
23
  let messageNumber = 0;
25
24
  const message = (chatId, minute, from, text) => {
26
25
  messageNumber += 1;
@@ -189,6 +189,17 @@ export const QUERY_FIELDS = [
189
189
  support: "A1",
190
190
  values: ["private", "saved", "bot", "service", "group", "channel", "unknown"],
191
191
  },
192
+ {
193
+ name: "muted",
194
+ example: "muted:false",
195
+ index: "chats.muted / chats.muted_until",
196
+ aliases: [],
197
+ type: "enum",
198
+ operators: terms,
199
+ normalization: "lowercase; true is a chat the owner muted, until the mute runs out; false is every other chat",
200
+ support: "A1",
201
+ values: ["true", "false"],
202
+ },
192
203
  {
193
204
  name: "has",
194
205
  example: "has:file",
@@ -0,0 +1,4 @@
1
+ import type { MessageStore } from "../../../store/index.js";
2
+ import type { ProposalKind } from "../types.js";
3
+ /** Identities that may not belong to their person; only the owner takes them off. */
4
+ export declare const identitySplitKind: (store: Pick<MessageStore, "people" | "proposedActions">) => ProposalKind;
@@ -0,0 +1,65 @@
1
+ import { IDENTITY_SPLIT_KIND, proposerOfAction } from "../../../store/index.js";
2
+ import { actionStatus, kept, pushed, storedStatus } from "./shared.js";
3
+ const summaryOf = (payload, person) => payload.split === "unmerge"
4
+ ? `undo ${payload.merge}: ${payload.identities.join(", ")} go back to their own person`
5
+ : `${payload.identities.join(", ")} may not be ${person}: they would move to a person of their own`;
6
+ /** An older build approved it as a plain action and split nothing: it shows as turned down, not as done. */
7
+ const dropped = (action) => action.status !== "proposed" &&
8
+ action.status !== "rejected" &&
9
+ typeof action.result?.person !== "string";
10
+ const rowOf = (store) => async (action) => {
11
+ const payload = action.payload;
12
+ const [first] = payload.identities;
13
+ const now = first === undefined
14
+ ? undefined
15
+ : await store.people.personOf({
16
+ provider: first.slice(0, first.indexOf(":")),
17
+ id: first.slice(first.indexOf(":") + 1),
18
+ });
19
+ const person = `person:${now?.uid ?? payload.person}`;
20
+ const summary = summaryOf(payload, person);
21
+ return {
22
+ id: action.id,
23
+ kind: IDENTITY_SPLIT_KIND,
24
+ status: dropped(action) ? "rejected" : actionStatus(action.status),
25
+ project: null,
26
+ subject: person,
27
+ object: null,
28
+ summary: dropped(action)
29
+ ? `not carried out: an older version approved it without splitting; ${summary}`
30
+ : summary,
31
+ proposedBy: proposerOfAction(action),
32
+ reason: action.reason,
33
+ evidence: payload.evidence.slice(0, 5),
34
+ score: null,
35
+ signals: null,
36
+ parts: null,
37
+ createdAt: action.createdAt,
38
+ };
39
+ };
40
+ /** Identities that may not belong to their person; only the owner takes them off. */
41
+ export const identitySplitKind = (store) => ({
42
+ kind: IDENTITY_SPLIT_KIND,
43
+ stored: [IDENTITY_SPLIT_KIND],
44
+ ownerOnly: true,
45
+ list: async (filter) => {
46
+ const status = storedStatus(filter);
47
+ const stored = await store.proposedActions.list({
48
+ kinds: [IDENTITY_SPLIT_KIND],
49
+ ...(status === undefined ? {} : { status }),
50
+ ...pushed(filter),
51
+ });
52
+ return kept(await Promise.all(stored.map(rowOf(store))), filter);
53
+ },
54
+ get: async (id) => rowOf(store)(await store.proposedActions.get(id)),
55
+ decide: async (id, { confirm, by, reason }) => {
56
+ const decided = await store.people.decideSplit(id, { confirm, by, ...(reason === undefined ? {} : { reason }) });
57
+ const person = decided.result?.person;
58
+ return {
59
+ id,
60
+ kind: IDENTITY_SPLIT_KIND,
61
+ status: confirm ? "confirmed" : "rejected",
62
+ made: person === undefined ? [] : [`person:${person}`],
63
+ };
64
+ },
65
+ });
@@ -6,6 +6,7 @@ import { factKind } from "./kinds/fact.js";
6
6
  import { invoiceKind, paymentKind } from "./kinds/finance.js";
7
7
  import { findingsKind } from "./kinds/findings.js";
8
8
  import { identityLinkKind } from "./kinds/identity-link.js";
9
+ import { identitySplitKind } from "./kinds/identity-split.js";
9
10
  import { keyDocumentKind } from "./kinds/key-document.js";
10
11
  import { mailFindingsKind } from "./kinds/mail-findings.js";
11
12
  import { meetingFindingsKind } from "./kinds/meeting-findings.js";
@@ -154,6 +155,7 @@ export const proposalRegistry = (store) => {
154
155
  taskCloseKind(store),
155
156
  sourceReviewKind(store),
156
157
  identityLinkKind(store),
158
+ identitySplitKind(store),
157
159
  ])
158
160
  registry.register(kind);
159
161
  registry.register(actionKind(store, registry.claimed));
@@ -5,15 +5,15 @@ import { calendarKey } from "../domain/calendar.js";
5
5
  import { rankingQuestion } from "../domain/rankings-options.js";
6
6
  import { MESSAGE_PARSING } from "../search/lucene/types.js";
7
7
  import { prepareLucene } from "./messages-search.js";
8
- const FIELDS = ["date", "chat", "kind"];
8
+ const FIELDS = ["date", "chat", "kind", "muted"];
9
9
  /** Per waiting chat, how far back its unanswered messages are counted. */
10
10
  export const WAITING_TAIL = 100;
11
- /** Only AND-ed `date:`, `chat:` and `kind:` terms: each becomes an index bound, so no query reads every message. */
11
+ /** Only AND-ed `date:`, `chat:`, `kind:` and `muted:` terms: each becomes an index bound, so no query reads every message. */
12
12
  const plainOnly = (text, command) => {
13
13
  if (text === undefined)
14
14
  return;
15
15
  const refuse = () => {
16
- throw new CliError("validation_error", `${command} reads date:, chat: and kind: terms, AND-ed — not words, other fields, OR or NOT`, { reason: "query.unsupported-field" });
16
+ throw new CliError("validation_error", `${command} reads date:, chat:, kind: and muted: terms, AND-ed — not words, other fields, OR or NOT`, { reason: "query.unsupported-field" });
17
17
  };
18
18
  const visit = (node) => {
19
19
  if (node.kind === "boolean")
@@ -40,6 +40,14 @@ const scopeOf = (root, accounts) => {
40
40
  scope.chats.push(chat);
41
41
  else if (node.field === "kind")
42
42
  scope.kinds.push(node.value.toLowerCase());
43
+ else if (node.field === "muted") {
44
+ const muted = node.value.toLowerCase() === "true";
45
+ if (scope.muted !== undefined && scope.muted !== muted)
46
+ throw new CliError("validation_error", "muted:true and muted:false cannot both hold", {
47
+ reason: "query.conflict",
48
+ });
49
+ scope.muted = muted;
50
+ }
43
51
  else if (date) {
44
52
  if (date.lower !== undefined) {
45
53
  const lower = date.lower + (date.lower_inclusive ? 0 : 1);
@@ -17,6 +17,8 @@ export interface TaskStatsRequest {
17
17
  export interface TaskStatsGroup {
18
18
  /** The stored chat id, `meeting:<account>/<meeting>`, or the project's store id. */
19
19
  group: string;
20
+ /** The group's account, when the answer reads several. */
21
+ account?: AccountKey;
20
22
  name: string | null;
21
23
  open: number;
22
24
  created: number;
@@ -27,6 +29,8 @@ export interface TaskStatsGroup {
27
29
  }
28
30
  export interface TaskStats {
29
31
  by: TaskStatsBy;
32
+ /** Every account read, when the answer reads several. */
33
+ accounts?: AccountKey[];
30
34
  open: number;
31
35
  created: number;
32
36
  closed: number;
@@ -36,6 +40,7 @@ export interface TaskStats {
36
40
  }
37
41
  /**
38
42
  * `stats tasks show`: `open` is open now, `created` the tasks opened in the period, `closed` those closed in it; the
39
- * other terms of the query narrow all three. `columns` reads the task query's fields on the row `t`.
43
+ * other terms of the query narrow all three. `columns` reads the task query's fields on the row `t`. Given several
44
+ * accounts it reads each one's tasks and counts them together; every row then names its account.
40
45
  */
41
- export declare const taskStatsOf: (store: MessageStore, account: AccountKey, { by, query, timezone, group, kind }: TaskStatsRequest, columns: ColumnMap, now?: number) => Promise<TaskStats>;
46
+ export declare const taskStatsOf: (store: MessageStore, accounts: AccountKey | readonly AccountKey[], { by, query, timezone, group, kind }: TaskStatsRequest, columns: ColumnMap, now?: number) => Promise<TaskStats>;