@wirecat/cli-core 0.687.0 → 0.689.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 (99) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/dist/background/daily-archive-timer.d.ts +1 -1
  3. package/dist/cli/documents/index.d.ts +1 -0
  4. package/dist/cli/documents/index.js +1 -0
  5. package/dist/cli/documents/library.d.ts +107 -0
  6. package/dist/cli/documents/library.js +514 -0
  7. package/dist/cli/documents/testing/source-contract.d.ts +11 -6
  8. package/dist/cli/documents/testing/source-contract.js +54 -23
  9. package/dist/cli/documents/testing/source.d.ts +11 -3
  10. package/dist/cli/documents/testing/source.js +15 -10
  11. package/dist/cli/documents/words.d.ts +1 -1
  12. package/dist/cli/envelope.js +2 -3
  13. package/dist/cli/meeting-batch.js +5 -1
  14. package/dist/cli/meeting-passage-text.d.ts +1 -1
  15. package/dist/cli/meeting-passage-text.js +3 -5
  16. package/dist/cli/messenger/conversations-command.js +4 -0
  17. package/dist/cli/messenger/messages-search-command.js +6 -1
  18. package/dist/cli/messenger/search-answers.js +2 -0
  19. package/dist/cli/search-left-out.d.ts +3 -0
  20. package/dist/cli/search-left-out.js +12 -0
  21. package/dist/cli/store-settings.js +23 -4
  22. package/dist/cli/untrusted-marks.d.ts +2 -0
  23. package/dist/cli/untrusted-marks.js +6 -0
  24. package/dist/crm/cli/files.d.ts +68 -0
  25. package/dist/crm/cli/files.js +616 -0
  26. package/dist/crm/cli/index.d.ts +1 -0
  27. package/dist/crm/cli/index.js +3 -0
  28. package/dist/crm/cli/search-all.js +3 -2
  29. package/dist/crm/file-fetch.d.ts +15 -0
  30. package/dist/crm/file-fetch.js +61 -0
  31. package/dist/crm/index.d.ts +1 -0
  32. package/dist/crm/index.js +1 -0
  33. package/dist/crm/testing/files-contract.d.ts +17 -0
  34. package/dist/crm/testing/files-contract.js +142 -0
  35. package/dist/crm/testing/index.d.ts +1 -0
  36. package/dist/crm/testing/index.js +1 -0
  37. package/dist/crm/testing/source.d.ts +5 -0
  38. package/dist/crm/testing/source.js +3 -1
  39. package/dist/documents/index.d.ts +3 -1
  40. package/dist/documents/index.js +2 -0
  41. package/dist/documents/model.d.ts +20 -6
  42. package/dist/documents/model.js +2 -1
  43. package/dist/entities/hit.d.ts +3 -3
  44. package/dist/entities/hit.js +14 -3
  45. package/dist/entities/index.d.ts +1 -1
  46. package/dist/errors/reasons.d.ts +1 -1
  47. package/dist/errors/reasons.js +23 -1
  48. package/dist/files/safe-name.d.ts +2 -1
  49. package/dist/files/safe-name.js +21 -3
  50. package/dist/meetings/mcp/passage.d.ts +6 -2
  51. package/dist/meetings/mcp/passage.js +7 -3
  52. package/dist/resolve.d.ts +1 -1
  53. package/dist/resolve.js +1 -1
  54. package/dist/search/account-list.d.ts +2 -0
  55. package/dist/search/account-list.js +32 -4
  56. package/dist/search/respell.d.ts +10 -0
  57. package/dist/search/respell.js +63 -0
  58. package/dist/search/stem.d.ts +16 -3
  59. package/dist/search/stem.js +32 -4
  60. package/dist/services/documents/file-text.d.ts +13 -0
  61. package/dist/services/documents/file-text.js +33 -0
  62. package/dist/services/documents/plan.d.ts +3 -2
  63. package/dist/services/documents/plan.js +50 -16
  64. package/dist/services/documents/ports.d.ts +2 -2
  65. package/dist/services/documents/sync.js +2 -2
  66. package/dist/services/embeddings-search.js +169 -141
  67. package/dist/services/embeddings.d.ts +8 -0
  68. package/dist/services/message-resolution.d.ts +1 -1
  69. package/dist/services/message-resolution.js +1 -1
  70. package/dist/services/messages-archive-search.js +55 -3
  71. package/dist/services/messages-search.d.ts +2 -1
  72. package/dist/services/messages-search.js +19 -7
  73. package/dist/services/messages.d.ts +8 -0
  74. package/dist/services/metadata.d.ts +1 -1
  75. package/dist/services/named-chat.d.ts +20 -0
  76. package/dist/services/named-chat.js +63 -0
  77. package/dist/services/search-all.d.ts +7 -2
  78. package/dist/services/search-all.js +35 -1
  79. package/dist/store/exports.d.ts +1 -1
  80. package/dist/store/exports.js +1 -1
  81. package/dist/store/search-index.d.ts +2 -0
  82. package/dist/store/search-index.js +1 -0
  83. package/dist/store/sqlite/crm-files.d.ts +3 -0
  84. package/dist/store/sqlite/crm-files.js +2 -0
  85. package/dist/store/sqlite/crm-settings.d.ts +42 -1
  86. package/dist/store/sqlite/crm-settings.js +46 -2
  87. package/dist/store/sqlite/lucene-fields.d.ts +2 -0
  88. package/dist/store/sqlite/lucene-fields.js +6 -2
  89. package/dist/store/sqlite/lucene.js +2 -2
  90. package/dist/store/sqlite/manifest.js +2 -0
  91. package/dist/store/sqlite/migrations.generated.js +20 -0
  92. package/dist/store/sqlite/schema.d.ts +169 -0
  93. package/dist/store/sqlite/schema.js +18 -0
  94. package/dist/store/sqlite/stems.d.ts +2 -0
  95. package/dist/store/sqlite/stems.js +5 -0
  96. package/dist/store/sqlite/vectors.d.ts +26 -1
  97. package/dist/store/sqlite/vectors.js +72 -15
  98. package/dist/store/vectors.js +6 -2
  99. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -5,6 +5,102 @@ 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.689.0 — 17.11.2026
9
+
10
+ ### Added
11
+
12
+ - **A document source without a change feed** (Yandex Disk, WebDAV, S3): `FeedlessDocumentSource`, a
13
+ `DocumentSource` without `startToken` and `changes`, which `syncDocuments` also takes. Every sync then walks the
14
+ selected folders in full, saves only the files that changed since the last pass, and removes the ones a finished
15
+ pass no longer found; an interrupted pass keeps what is held and goes on from its saved walk, and a chosen folder
16
+ that is gone is skipped as unavailable. `feedOf(source)` tells the two apart. `documentSourceContract` checks it
17
+ with the fixture's `change` and new `remove`, and `fakeDocumentSource` takes `feed: false`. See
18
+ [Documents](docs/dev/DOCUMENTS.md#a-source-without-a-change-feed).
19
+ - **A source that addresses files by path** gets the file the sync last listed: `metadata(id, known)`,
20
+ `children(id, folder)`, `childrenPage(id, cursor, folder)`, `content(id, maxChars, file)` and `bytes(id, file)`.
21
+ The arguments are optional, so an existing source is unchanged.
22
+ - **`documentLibraryCommands` mounts the whole shared documents set over a CLI's source** (`@wirecat/cli-core/documents/cli`):
23
+ `folders`, `sync`, `status`, `documents`, `search`, `catalog` and the knowledge groups, with the profile's files under
24
+ the CLI's state folder (`documentProfile`: chosen folders, sync state, walk, snapshots and the profile lock), the
25
+ shared store, and `claimDocumentAccount`, which keeps one provider account to one profile. The CLI gives its
26
+ source, how it files a document (`ingestion`), its words, a `documents list` row and an optional `folders browse`.
27
+ It is what notion-cli's `src/library.ts` and `src/commands/library.ts` did, so a new documents CLI writes only its
28
+ source. `folders add` keeps each chosen folder's metadata, which a path-addressed source reads before the first sync.
29
+ - **`fileText(bytes, file, command)` and `readableFile(file)`** (`@wirecat/cli-core/documents`): the text of a
30
+ downloaded PDF, docx, xlsx, CSV, TSV, text or Markdown file through cli-core's readers, or a `validation_error` that
31
+ says why there is none. drive-cli's `readFile` and `supported`, for every file source.
32
+
33
+ ### Changed — may break callers
34
+
35
+ - **Store version 69: `search conversations` reads each chat's readiness instead of counting it on every search.**
36
+ The counts it reports (messages new, edited or deleted since the build; chunks with current, stale and missing
37
+ vectors) are saved per chat and model in `conversation_readiness` the first time they are counted. Triggers drop a
38
+ chat's row when its messages, revisions or build change, and a model's rows when its vectors
39
+ change, so the next read counts again. Forward-only; `minCompatible` stays 56.
40
+
41
+ ### Fixed
42
+
43
+ - `--source documents` names every documents account (Google Drive, Notion) beside the imports that hold documents.
44
+ Drive and Notion accounts are stored and searched as notes folders, so the word missed them before.
45
+ - A search whose `--source` is one word that names no account in the store fails with the words that do name
46
+ something. Beside other entries, or in a group, the word stays a skipped entry the answer reports, as before.
47
+
48
+ ## 0.688.0 — 17.11.2026
49
+
50
+ ### Added
51
+
52
+ - **`files list`, `files download` and `files sync` in every CRM CLI** whose adapter has `files`
53
+ (`addCrmCommands(program, { files: true })`). `files list --deal|--lead|--person|--organization <id>` reads a
54
+ record's files live; `files download <id>` saves one under the state folder (folders 700, file 600) or `--dir`, at
55
+ most 100 MB unless `--max-size` (up to 2048), and reads its text; `files sync` prefetches the files of your own deals
56
+ and leads changed in the last `files.days`, within per-run limits, and goes on where it stopped. A colleague's record
57
+ counts toward the day's limit of 100.
58
+ - **CRM file limits** as owner-only store settings `crm.<provider>:<account>.files.max_files`, `max_file_mb`,
59
+ `max_run_mb`, `run_minutes`, `days` and `max_total_mb`; a value outside its range is refused. The account's folder
60
+ is kept under `max_total_mb` by dropping the oldest files whose text is kept.
61
+ - **`search all` finds the text of downloaded CRM files** (`crm_file` hits, also under `--only crm`): a limited profile
62
+ only those of records assigned to it, in the CRM CLI's and in memo's and tg's `search all` alike.
63
+ - **`fetchCrmFile`** for adapters: a file link fetched over https from the account's own hosts only, never naming the
64
+ link in an error; **`crmFilesContract`** in `@wirecat/cli-core/crm/testing`.
65
+ - **`search messages` helps a query of plain words the way `search conversations` does.** A word no message holds is
66
+ searched beside its Latin spelling or nearest known spellings (a note says so). Without `chat:`, a word
67
+ the messages show is a name in one private chat has that chat's hits first, searched without the name
68
+ (a note says so). A query with fields, quotes, groups or operators is searched exactly as written.
69
+ - **`search conversations` over every chat searches first the private chat a name in the query points to.** The name
70
+ is learned from the messages, with no list of nicknames: the private chat that holds most of a word's uses, at least
71
+ twice as many as any other private chat, and writes it with a capital letter nearly every time («Петька, привет»).
72
+ That chat is searched without the name and its hits come first; a note says so. An ordinary word, spread over many chats in lower case, names none.
73
+ - **`search conversations` respells a query word that no message holds.** It searches the word's Latin spelling
74
+ («ноксвел» → `noxvel`) or the nearest known spellings of that, and only when there are none, the word's own nearest
75
+ known spellings, up to two edits. A word any message holds is never respelled. A note says what was searched instead.
76
+
77
+ ### Changed — may break callers
78
+
79
+ - **memo's, tg's and the MCP's `search all` apply each CRM copy's viewer rule to deals and leads too**, taking the
80
+ user that copy's own sync signed in as: a non-admin copy's colleagues' deals no longer show there, as they never
81
+ did in the CRM CLI. A copy with no recorded own user shows none of its deals and leads there; a copy whose sync
82
+ recorded no list of who may read it shows only its own user's.
83
+ - **`search all` has a new hit kind, `crm_file`**, in every CLI: a caller that switches over `kind` gets it.
84
+ - **`safeName` cuts a name to 200 bytes**, its extension kept, for every download that uses it.
85
+
86
+ ### Fixed
87
+
88
+ - **`meetings batch --format text|markdown` marks other people's text in a scheduled agent's run.** Transcript cues
89
+ and search hit excerpts and titles were printed with no untrusted marks; only JSON carried them. The report a host
90
+ formats with `formatMeetingBatch` now comes marked, so a host needs no change.
91
+ - **`callMeetingPassageTool` takes how the host prints a passage in this run.** Pass
92
+ `(result, format) => passageForRun(command, result, format)` as its new last argument, and the `meeting_passage`
93
+ text carries the same marks as `meetings passage` in a scheduled agent's run. Without it the text stays unmarked.
94
+ - **`search conversations --chat` no longer stops at 20 word hits.** The per-chat share that keeps a large group from
95
+ filling the list across chats also applied inside one chat, so a word used often there found only 20 messages.
96
+ - **A message search for «домен» no longer finds «дом» and «дома».** Snowball cuts some words to another word's stem.
97
+ When a query word's stem is under 4 letters, drops 2 or more letters, and the stored stems show the whole word is a
98
+ stem itself («доменов» → «домен»), the search keeps the word whole. The stems stored for messages do not change.
99
+ - **A message search for a word of 4 letters or more also finds the longer words it begins, as grep does.** Snowball
100
+ stems some forms of one word apart («журнал» → «журна», «журналом» → «журнал»), so a search found only the
101
+ forms that shared the typed word's stem. Quotes keep the old match: the word and its stem's forms only. The note now
102
+ says what was searched: `квартира → квартира… and words stemmed to квартир`.
103
+
8
104
  ## 0.687.0 — 16.11.2026
9
105
 
10
106
  ### Added
@@ -24,12 +24,12 @@ export interface DailyArchiveTimerInput {
24
24
  }
25
25
  export declare const dailyArchiveTimer: (input: DailyArchiveTimerInput) => DailyArchiveTimer;
26
26
  export declare const manageDailyArchiveTimer: (plan: DailyArchiveTimer, action: "install" | "start" | "stop" | "status" | "uninstall", system: Pick<ServerSystem, "platform" | "run">, env: NodeJS.ProcessEnv, signal?: AbortSignal) => Promise<{
27
+ action?: undefined;
27
28
  name: string;
28
29
  installed: boolean;
29
30
  active: boolean;
30
31
  servicePath: string;
31
32
  timerPath: string;
32
- action?: undefined;
33
33
  } | {
34
34
  active?: undefined;
35
35
  name: string;
@@ -34,3 +34,4 @@ export interface DocumentCommands<S> {
34
34
  * when given, `mirrors`, in that order. Answers the `documents` group, for the CLI's live subcommands.
35
35
  */
36
36
  export declare const addDocumentCommands: <S>(program: Command, options: DocumentCommands<S>) => Command;
37
+ export { claimDocumentAccount, type DocumentLibraryOptions, type DocumentLibraryTools, type DocumentSourceRun, type DocumentWarning, documentLibraryCommands, documentProfile, } from "./library.js";
@@ -30,3 +30,4 @@ export const addDocumentCommands = (program, options) => {
30
30
  addDocumentMirrorCommands(program, { ...shared, ...options.mirrors });
31
31
  return documents;
32
32
  };
33
+ export { claimDocumentAccount, documentLibraryCommands, documentProfile, } from "./library.js";
@@ -0,0 +1,107 @@
1
+ import { type ErrorCode } from "@wirecat/cli-base";
2
+ import { Command } from "commander";
3
+ import type { Deadline } from "../../background/budget.js";
4
+ import { type documentIngestion, type FeedlessDocumentSource, type SourceContent, type SourceFile, type SourceStatePort } from "../../documents.js";
5
+ import type { ProviderEntry } from "../../domain/providers.js";
6
+ import type { AppIdentity } from "../../ports/app.js";
7
+ import type { EventSink } from "../../runs/events.js";
8
+ import type { MessageStore } from "../../store/index.js";
9
+ import { baseContext } from "../context.js";
10
+ import { type Body } from "../envelope.js";
11
+ import { ProfileTokenStore } from "../profile-token.js";
12
+ import type { DocumentKnowledgePort } from "./knowledge.js";
13
+ import type { DocumentWords } from "./words.js";
14
+ type Resolve = Parameters<typeof baseContext>[1];
15
+ type Ingestion<M extends SourceFile> = ReturnType<typeof documentIngestion<M>>;
16
+ /** Something a source met on its way and went on past: one per file, gathered into the answer's issues. */
17
+ export interface DocumentWarning {
18
+ id?: string;
19
+ code: ErrorCode;
20
+ reason: string;
21
+ message: string;
22
+ }
23
+ /** What a run gives the CLI's source beside the request log. */
24
+ export interface DocumentSourceRun {
25
+ deadline?: Deadline;
26
+ warn(warning: DocumentWarning): void;
27
+ }
28
+ export interface DocumentLibraryOptions<M extends SourceFile> {
29
+ app: AppIdentity;
30
+ /** The CLI's settings, as `baseContext` reads them: `configuration.resolveSettings`. */
31
+ resolveSettings: Resolve;
32
+ provider: ProviderEntry;
33
+ words: DocumentWords;
34
+ /** The service's name in messages: "Yandex Disk". */
35
+ service: string;
36
+ /** The provider's adapter for one run, built inside cli-core's run so its requests are recorded. */
37
+ source(command: Command, events: EventSink, run: DocumentSourceRun): FeedlessDocumentSource<M>;
38
+ /** How the CLI files a document in the shared store: its catalog entry and front matter. */
39
+ ingestion(store: MessageStore): Ingestion<M>;
40
+ /** A file or folder id from what the user typed: an id, a link, a path. */
41
+ idOf(input: string): string;
42
+ /** The folder `folders add` names, read live; refuse one the account cannot use. Defaults to `metadata(idOf(input))`. */
43
+ folder?(source: FeedlessDocumentSource<M>, input: string): Promise<M>;
44
+ isFolder(file: M): boolean;
45
+ isDocument?(file: M): boolean;
46
+ /** Why a file is kept by name only (an unsupported type, too large); undefined reads it. */
47
+ skipReason?(file: M): string | undefined;
48
+ /** One row of `documents list`. */
49
+ row(file: M, reference: string): object;
50
+ /** The longest text the store keeps of one document. */
51
+ textLimit: number;
52
+ /** The entries one sync walks before it stops and saves. */
53
+ maxEntries: number;
54
+ /** What `sync` says it covers. */
55
+ coverage: string;
56
+ /** The accounts a document names, for `identities list`; none when the provider shows none. */
57
+ people?: DocumentKnowledgePort["people"];
58
+ /** The CLI's own `folders browse`. */
59
+ browse?(folders: Command, tools: DocumentLibraryTools<M>): void;
60
+ }
61
+ /** What the CLI's own commands beside the shared ones may use, for the running command. */
62
+ export interface DocumentLibraryTools<M extends SourceFile> {
63
+ env(): NodeJS.ProcessEnv;
64
+ profile(): string;
65
+ output(body: Body): void;
66
+ roots(): string[];
67
+ /** Runs `body` with the provider's source inside cli-core's run. */
68
+ withSource<T>(body: (source: FeedlessDocumentSource<M>) => Promise<T>): Promise<T>;
69
+ }
70
+ interface Folders<M extends SourceFile> {
71
+ roots: string[];
72
+ /** Each chosen folder as `folders add` read it: a source that addresses by path finds it before the first sync. */
73
+ files?: Record<string, M>;
74
+ /** When the choice last changed: a sync before it copied another scope. */
75
+ changed_at?: string;
76
+ }
77
+ /**
78
+ * One profile's document files under the CLI's state folder: the chosen folders, the sync's checkpoint, its walk and
79
+ * one snapshot per document, each a private file.
80
+ */
81
+ export declare const documentProfile: <M extends SourceFile>(app: AppIdentity, env: NodeJS.ProcessEnv, profile: string) => {
82
+ dir: string;
83
+ folders: () => Folders<M>;
84
+ saveFolders: (roots: string[], files: Record<string, M>) => void;
85
+ state: (principal: string) => SourceStatePort<M>;
86
+ synced: () => boolean;
87
+ walkUnderWay: () => boolean;
88
+ snapshot: (id: string) => SourceContent<M> | undefined;
89
+ /**
90
+ * The lock a sync and every write to the local copy take, so a tag added during a sync is not lost. A second
91
+ * holder is refused at once: waiting would hold an agent's tool call for the length of a sync.
92
+ */
93
+ locked: <T>(fn: (assertHeld: () => void) => Promise<T>) => Promise<T>;
94
+ };
95
+ /**
96
+ * Takes a provider account for a profile before its copy is written. One account is one collection in the shared
97
+ * store, so two profiles on it would each remove the other's documents; and a profile's copy stays with the account
98
+ * it was synced from.
99
+ */
100
+ export declare const claimDocumentAccount: (app: AppIdentity, env: NodeJS.ProcessEnv, profile: string, account: string, tokens: Pick<ProfileTokenStore, "read">) => void;
101
+ /**
102
+ * cli-core's shared `folders`, `sync`, `status`, `documents`, `search`, `catalog` and knowledge groups over a CLI's
103
+ * document source, its files under the CLI's state folder and the shared store. The CLI gives the source, how it
104
+ * files a document and its words. Returned as commands to add to the program.
105
+ */
106
+ export declare const documentLibraryCommands: <M extends SourceFile>(options: DocumentLibraryOptions<M>) => Command[];
107
+ export {};