@wirecat/cli-core 0.347.0 → 0.349.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 (76) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/dist/cli/bot/copy.d.ts +1 -1
  3. package/dist/cli/bot/copy.js +1 -1
  4. package/dist/cli/embedding-choice.js +2 -1
  5. package/dist/cli/envelope.d.ts +4 -0
  6. package/dist/cli/envelope.js +4 -3
  7. package/dist/cli/guide.js +4 -0
  8. package/dist/cli/help/first-screen.js +13 -1
  9. package/dist/cli/help/sections.d.ts +4 -3
  10. package/dist/cli/help/sections.js +5 -10
  11. package/dist/cli/index.d.ts +1 -0
  12. package/dist/cli/index.js +1 -0
  13. package/dist/cli/messenger/backfill-command.js +6 -6
  14. package/dist/cli/messenger/context.d.ts +3 -3
  15. package/dist/cli/messenger/context.js +44 -17
  16. package/dist/cli/messenger/doctor-command.js +3 -3
  17. package/dist/cli/messenger/flooded.js +1 -1
  18. package/dist/cli/messenger/mcp-command.js +1 -1
  19. package/dist/cli/messenger/messages-delete-command.js +2 -1
  20. package/dist/cli/messenger/observed.js +24 -7
  21. package/dist/cli/messenger/schedule-command.js +4 -3
  22. package/dist/cli/messenger/serve-relay.js +1 -0
  23. package/dist/cli/messenger/store-maintenance-command.js +3 -3
  24. package/dist/cli/messenger/stored.js +36 -30
  25. package/dist/cli/program.js +10 -9
  26. package/dist/cli/runs/command.js +3 -2
  27. package/dist/cli/steps.d.ts +4 -0
  28. package/dist/cli/steps.js +9 -0
  29. package/dist/cli/store-settings.js +4 -3
  30. package/dist/context/evidence.d.ts +10 -0
  31. package/dist/domain/models.d.ts +11 -1
  32. package/dist/kit/contract.d.ts +2 -2
  33. package/dist/kit/contract.js +25 -0
  34. package/dist/kit/fake.d.ts +1 -0
  35. package/dist/kit/fake.js +15 -16
  36. package/dist/mcp/meeting-preparation.d.ts +1 -0
  37. package/dist/mcp/meeting-project-candidates.d.ts +1 -0
  38. package/dist/mcp/meeting-series-inventory.d.ts +1 -0
  39. package/dist/mcp/tool.js +2 -0
  40. package/dist/mcp/tools/messages-photo.js +2 -1
  41. package/dist/meetings/mcp/passage.d.ts +1 -0
  42. package/dist/meetings/mcp/project-evidence.d.ts +1 -0
  43. package/dist/meetings/mcp/search.d.ts +1 -0
  44. package/dist/meetings/reads.d.ts +1 -0
  45. package/dist/ports/messenger.d.ts +10 -2
  46. package/dist/runs/recording.js +1 -0
  47. package/dist/runs/scope.d.ts +7 -0
  48. package/dist/runs/scope.js +5 -0
  49. package/dist/services/archive.js +2 -1
  50. package/dist/services/chats.js +3 -2
  51. package/dist/services/context-evidence.d.ts +1 -1
  52. package/dist/services/conversations.js +2 -1
  53. package/dist/services/deps.js +2 -1
  54. package/dist/services/embeddings-maintenance.js +3 -2
  55. package/dist/services/index.d.ts +6 -4
  56. package/dist/services/index.js +1 -0
  57. package/dist/services/project-gathering-around.d.ts +37 -0
  58. package/dist/services/project-gathering-around.js +57 -0
  59. package/dist/services/project-gathering-request.d.ts +13 -1
  60. package/dist/services/project-gathering-request.js +23 -5
  61. package/dist/services/project-gathering.d.ts +15 -1
  62. package/dist/services/project-gathering.js +32 -1
  63. package/dist/services/search-all-meetings.d.ts +3 -4
  64. package/dist/services/search-all.d.ts +8 -1
  65. package/dist/services/search-all.js +1 -1
  66. package/dist/speech/transcribe.js +2 -1
  67. package/dist/store/chats.d.ts +2 -2
  68. package/dist/store/sqlite/chats.d.ts +2 -2
  69. package/dist/store/sqlite/chats.js +7 -7
  70. package/dist/store/sqlite/context-evidence.d.ts +4 -1
  71. package/dist/store/sqlite/context-evidence.js +12 -0
  72. package/dist/store/store.d.ts +2 -1
  73. package/dist/store/store.js +5 -1
  74. package/dist/store/types.d.ts +2 -2
  75. package/package.json +3 -3
  76. package/parity.json +2 -12
@@ -45,10 +45,10 @@ export const upsertChat = (context, accountKey, chat) => {
45
45
  kind: chat.kind,
46
46
  parentChatId: parent,
47
47
  scope: chat.scope ?? null,
48
- title: chat.title,
49
- unreadCount: chat.unreadCount,
48
+ title: chat.title ?? null,
49
+ unreadCount: chat.unreadCount ?? null,
50
50
  lastMessageAt: toMs(chat.lastMessageAt),
51
- participantsCount: chat.participantsCount,
51
+ participantsCount: chat.participantsCount ?? null,
52
52
  metadata: mergedMetadata(stored?.metadata ?? null, chat.providerMetadata),
53
53
  membershipState: chat.membershipState ?? null,
54
54
  createdAt: now(),
@@ -60,10 +60,10 @@ export const upsertChat = (context, accountKey, chat) => {
60
60
  kind: sql `excluded.kind`,
61
61
  ...(chat.parentChatId === undefined ? {} : { parentChatId: sql `excluded.parent_chat_id` }),
62
62
  scope: sql `coalesce(excluded.scope, ${chats.scope})`,
63
- title: sql `excluded.title`,
64
- unreadCount: sql `excluded.unread_count`,
65
- lastMessageAt: sql `excluded.last_message_at`,
66
- participantsCount: sql `excluded.participants_count`,
63
+ ...(chat.title === undefined ? {} : { title: sql `excluded.title` }),
64
+ ...(chat.unreadCount === undefined ? {} : { unreadCount: sql `excluded.unread_count` }),
65
+ ...(chat.lastMessageAt === undefined ? {} : { lastMessageAt: sql `excluded.last_message_at` }),
66
+ ...(chat.participantsCount === undefined ? {} : { participantsCount: sql `excluded.participants_count` }),
67
67
  metadata: sql `excluded.metadata`,
68
68
  // A chat the list names again has been rejoined; any other state it had is kept.
69
69
  membershipState: sql `CASE WHEN excluded.membership_state IS NOT NULL THEN excluded.membership_state
@@ -1,4 +1,7 @@
1
- import { type ContextEvidenceReader } from "../../context/evidence.js";
1
+ import { type ContextEvidenceReader, type ContextIndex } from "../../context/evidence.js";
2
+ import type { Stemmer, Stemmers } from "../../search/stem.js";
2
3
  import type { StoreContext } from "./open.js";
3
4
  /** No index fills, model loads or record hydration outside the read transaction. */
4
5
  export declare const contextEvidenceOver: ({ database }: Pick<StoreContext, "database">) => ContextEvidenceReader;
6
+ /** The same fills a mail search and the notes search run before reading; a message is indexed when it is saved. */
7
+ export declare const contextIndexOver: ({ database }: Pick<StoreContext, "database">, stemmerFor: (stemmers: Stemmers) => Stemmer) => ContextIndex;
@@ -3,6 +3,8 @@ import { contextCursorScope, contextEvidenceRequest, } from "../../context/evide
3
3
  import { formatLocator } from "../../domain/locator.js";
4
4
  import { NORMALIZER_VERSION, normalize } from "../normalize.js";
5
5
  import { contextDocumentTime, contextDocumentTimeKind, contextDocumentUrl } from "./context-document-source.js";
6
+ import { drainEmailIndex } from "./email-index.js";
7
+ import { drainNoteIndex } from "./note-index.js";
6
8
  import { read } from "./transaction.js";
7
9
  const corpora = {
8
10
  message: {
@@ -163,3 +165,13 @@ export const contextEvidenceOver = ({ database }) => ({
163
165
  });
164
166
  },
165
167
  });
168
+ /** The same fills a mail search and the notes search run before reading; a message is indexed when it is saved. */
169
+ export const contextIndexOver = ({ database }, stemmerFor) => ({
170
+ async catchUp({ kinds, signal }) {
171
+ signal?.throwIfAborted();
172
+ const mail = kinds.includes("mail") ? drainEmailIndex(database, stemmerFor) : 0;
173
+ signal?.throwIfAborted();
174
+ const documents = kinds.includes("document") ? drainNoteIndex(database, stemmerFor) : 0;
175
+ return { mail, documents };
176
+ },
177
+ });
@@ -1,4 +1,4 @@
1
- import type { ContextEvidenceReader } from "../context/evidence.js";
1
+ import type { ContextEvidenceReader, ContextIndex } from "../context/evidence.js";
2
2
  import { type AccountStore } from "./account-store.js";
3
3
  import { type AccountsStore } from "./accounts.js";
4
4
  import { type AttachmentsStore } from "./attachments.js";
@@ -34,6 +34,7 @@ import type { AccountKey } from "./types.js";
34
34
  import { type VectorsStore } from "./vectors.js";
35
35
  export interface MessageStore {
36
36
  readonly contextEvidence?: ContextEvidenceReader;
37
+ readonly contextIndex?: ContextIndex;
37
38
  /** Accounts, account groups and which account each app profile is. */
38
39
  readonly accounts: AccountsStore;
39
40
  /** One account's chats: the list, what left, what is complete, their metadata. */
@@ -16,7 +16,7 @@ import { agentActionsStoreOver } from "./sqlite/agent-actions.js";
16
16
  import * as attachmentTexts from "./sqlite/attachment-texts.js";
17
17
  import { botUpdateStoreOver } from "./sqlite/bot-updates.js";
18
18
  import { catalogStoreOver } from "./sqlite/catalog.js";
19
- import { contextEvidenceOver } from "./sqlite/context-evidence.js";
19
+ import { contextEvidenceOver, contextIndexOver } from "./sqlite/context-evidence.js";
20
20
  import { mailStoreOver } from "./sqlite/emails.js";
21
21
  import { factsStoreOver } from "./sqlite/facts.js";
22
22
  import { involvementStoreOver } from "./sqlite/involvements.js";
@@ -81,6 +81,7 @@ const storeOver = (context) => {
81
81
  mentions: areaOf(() => accountMentionsOver(context), (keyed) => mentionsStoreOver(context, keyed)),
82
82
  };
83
83
  const contextEvidence = once(() => contextEvidenceOver(context));
84
+ const contextIndex = once(() => contextIndexOver(context, stemmerFor));
84
85
  const searches = once(() => searchesStoreOver(context));
85
86
  const queries = once(() => queriesStoreOver(context, stemmerFor));
86
87
  const searchIndex = once(() => searchIndexStoreOver(context));
@@ -101,6 +102,9 @@ const storeOver = (context) => {
101
102
  get contextEvidence() {
102
103
  return contextEvidence();
103
104
  },
105
+ get contextIndex() {
106
+ return contextIndex();
107
+ },
104
108
  meetingVectors: meetingVectorsOver(context),
105
109
  get accounts() {
106
110
  return areas.accounts().whole;
@@ -1,6 +1,6 @@
1
1
  import type { TextRange } from "../conversations/chunks.js";
2
2
  import type { Link } from "../conversations/link.js";
3
- import type { Chat, ChatKind, Id, MessageHit, Provider } from "../domain/models.js";
3
+ import type { Chat, ChatKind, ChatUpdate, Id, MessageHit, Provider } from "../domain/models.js";
4
4
  import type * as imageChunks from "./sqlite/image-chunks.js";
5
5
  import type { Where } from "./sqlite/query-filter.js";
6
6
  export type PictureInput = imageChunks.PictureInput;
@@ -82,7 +82,7 @@ export type MessageFilter = AccountMessageFilter & {
82
82
  chatId?: undefined;
83
83
  });
84
84
  export interface Delta {
85
- chats?: Chat[];
85
+ chats?: ChatUpdate[];
86
86
  people?: PersonFacts[];
87
87
  members?: Map<Id, Id[]>;
88
88
  state?: Record<string, string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wirecat/cli-core",
3
- "version": "0.347.0",
3
+ "version": "0.349.0",
4
4
  "description": "The messenger-neutral half of a messaging CLI: domain model, message locators, rendering, name resolution, the SQLite seam, the command skeleton and shared read commands, the send guard, run records and the message store",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Viacheslav Ptsarev",
@@ -202,7 +202,7 @@
202
202
  "@types/node": "^22.20.4",
203
203
  "@types/pngjs": "6.0.5",
204
204
  "@vitest/coverage-v8": "^5.0.2",
205
- "@wirecat/cli-base": "0.46.0",
205
+ "@wirecat/cli-base": "0.47.0",
206
206
  "commander": "15.0.0",
207
207
  "cspell": "10.3.6",
208
208
  "drizzle-kit": "1.0.0-rc.4",
@@ -222,7 +222,7 @@
222
222
  },
223
223
  "peerDependencies": {
224
224
  "@napi-rs/canvas": ">=0.1.69 <2",
225
- "@wirecat/cli-base": ">=0.45.0 <0.47.0",
225
+ "@wirecat/cli-base": ">=0.47.0 <0.48.0",
226
226
  "commander": ">=15"
227
227
  },
228
228
  "bin": {
package/parity.json CHANGED
@@ -4053,12 +4053,7 @@
4053
4053
  "in": ["tg"],
4054
4054
  "reason": "Telegram asks each client for its own app from my.telegram.org; MAX has no such step; WhatsApp has no application registration"
4055
4055
  },
4056
- "--qr-file": {
4057
- "in": ["tg", "wa"],
4058
- "planned": {
4059
- "max": "max-cli#736, on the cli-core release that exports loginQr"
4060
- }
4061
- },
4056
+ "--qr-file": "all",
4062
4057
  "--sms": {
4063
4058
  "in": ["tg"],
4064
4059
  "reason": "asks Telegram to resend its login code by SMS; MAX has no such choice; WhatsApp links a device by QR or pairing code, never by an SMS code"
@@ -4074,12 +4069,7 @@
4074
4069
  "reason": "Telegram requires an application from my.telegram.org; MAX has no application registration step; WhatsApp has no application registration"
4075
4070
  },
4076
4071
  "--method": "all",
4077
- "--qr-file": {
4078
- "in": ["tg", "wa"],
4079
- "planned": {
4080
- "max": "max-cli#736, on the cli-core release that exports loginQr"
4081
- }
4082
- }
4072
+ "--qr-file": "all"
4083
4073
  }
4084
4074
  },
4085
4075
  "skill": {