@wirecat/cli-core 0.686.0 → 0.688.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 +114 -0
- package/dist/background/daily-archive-timer.d.ts +1 -1
- package/dist/cli/account-remove.js +21 -3
- package/dist/cli/documents/testing/source-contract.js +18 -9
- package/dist/cli/documents/words.d.ts +1 -1
- package/dist/cli/envelope.js +2 -3
- package/dist/cli/meeting-batch.js +5 -1
- package/dist/cli/meeting-passage-text.d.ts +1 -1
- package/dist/cli/meeting-passage-text.js +3 -5
- package/dist/cli/messenger/conversations-command.js +4 -0
- package/dist/cli/messenger/messages-search-command.js +6 -1
- package/dist/cli/messenger/search-answers.js +2 -0
- package/dist/cli/messenger/store-maintenance-command.js +3 -2
- package/dist/cli/search-left-out.d.ts +3 -0
- package/dist/cli/search-left-out.js +12 -0
- package/dist/cli/store-settings.js +23 -4
- package/dist/cli/untrusted-marks.d.ts +2 -0
- package/dist/cli/untrusted-marks.js +6 -0
- package/dist/crm/cli/files.d.ts +68 -0
- package/dist/crm/cli/files.js +616 -0
- package/dist/crm/cli/index.d.ts +1 -0
- package/dist/crm/cli/index.js +3 -0
- package/dist/crm/cli/search-all.js +3 -2
- package/dist/crm/file-fetch.d.ts +15 -0
- package/dist/crm/file-fetch.js +61 -0
- package/dist/crm/files.d.ts +16 -0
- package/dist/crm/files.js +56 -0
- package/dist/crm/foreign-contacts.d.ts +16 -4
- package/dist/crm/foreign-contacts.js +8 -4
- package/dist/crm/index.d.ts +3 -1
- package/dist/crm/index.js +3 -0
- package/dist/crm/source.d.ts +37 -0
- package/dist/crm/source.js +2 -1
- package/dist/crm/testing/files-contract.d.ts +17 -0
- package/dist/crm/testing/files-contract.js +142 -0
- package/dist/crm/testing/index.d.ts +2 -1
- package/dist/crm/testing/index.js +2 -1
- package/dist/crm/testing/source.d.ts +36 -1
- package/dist/crm/testing/source.js +55 -1
- package/dist/crm/values.d.ts +2 -1
- package/dist/crm/values.js +4 -2
- package/dist/entities/hit.d.ts +3 -3
- package/dist/entities/hit.js +14 -3
- package/dist/entities/index.d.ts +1 -1
- package/dist/errors/reasons.js +12 -1
- package/dist/files/safe-name.d.ts +2 -1
- package/dist/files/safe-name.js +21 -3
- package/dist/meetings/cli/index.d.ts +1 -1
- package/dist/meetings/cli/index.js +10 -6
- package/dist/meetings/mcp/index.d.ts +15 -15
- package/dist/meetings/mcp/passage.d.ts +6 -2
- package/dist/meetings/mcp/passage.js +7 -3
- package/dist/meetings/read-through.d.ts +2 -0
- package/dist/meetings/read-through.js +7 -2
- package/dist/meetings/source.d.ts +2 -2
- package/dist/oauth/storage.js +21 -4
- package/dist/search/lucene/resolved.d.ts +2 -0
- package/dist/search/respell.d.ts +10 -0
- package/dist/search/respell.js +63 -0
- package/dist/search/stem.d.ts +16 -3
- package/dist/search/stem.js +32 -4
- package/dist/services/documents/plan.js +26 -5
- package/dist/services/documents/sync.js +4 -1
- package/dist/services/embeddings-search.js +190 -140
- package/dist/services/embeddings.d.ts +8 -0
- package/dist/services/messages-archive-search.js +55 -3
- package/dist/services/messages-search.d.ts +2 -1
- package/dist/services/messages-search.js +19 -7
- package/dist/services/messages.d.ts +8 -0
- package/dist/services/metadata.d.ts +1 -1
- package/dist/services/named-chat.d.ts +20 -0
- package/dist/services/named-chat.js +63 -0
- package/dist/services/search-all.d.ts +7 -2
- package/dist/services/search-all.js +35 -1
- package/dist/store/accounts.d.ts +2 -1
- package/dist/store/exports.d.ts +2 -1
- package/dist/store/exports.js +2 -1
- package/dist/store/recover.js +2 -0
- package/dist/store/search-index.d.ts +2 -0
- package/dist/store/search-index.js +1 -0
- package/dist/store/sqlite/account-purge.js +1 -0
- package/dist/store/sqlite/crm-files.d.ts +70 -0
- package/dist/store/sqlite/crm-files.js +174 -0
- package/dist/store/sqlite/crm-settings.d.ts +42 -1
- package/dist/store/sqlite/crm-settings.js +46 -2
- package/dist/store/sqlite/lucene-fields.d.ts +2 -0
- package/dist/store/sqlite/lucene-fields.js +6 -2
- package/dist/store/sqlite/lucene.js +13 -7
- package/dist/store/sqlite/manifest.js +2 -0
- package/dist/store/sqlite/migrations.generated.js +17 -0
- package/dist/store/sqlite/schema.d.ts +329 -0
- package/dist/store/sqlite/schema.js +28 -0
- package/dist/store/sqlite/stems.d.ts +2 -0
- package/dist/store/sqlite/stems.js +5 -0
- package/dist/store/store.d.ts +3 -0
- package/dist/store/store.js +5 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,120 @@ 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.688.0 — 17.11.2026
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **`files list`, `files download` and `files sync` in every CRM CLI** whose adapter has `files`
|
|
13
|
+
(`addCrmCommands(program, { files: true })`). `files list --deal|--lead|--person|--organization <id>` reads a
|
|
14
|
+
record's files live; `files download <id>` saves one under the state folder (folders 700, file 600) or `--dir`, at
|
|
15
|
+
most 100 MB unless `--max-size` (up to 2048), and reads its text; `files sync` prefetches the files of your own deals
|
|
16
|
+
and leads changed in the last `files.days`, within per-run limits, and goes on where it stopped. A colleague's record
|
|
17
|
+
counts toward the day's limit of 100.
|
|
18
|
+
- **CRM file limits** as owner-only store settings `crm.<provider>:<account>.files.max_files`, `max_file_mb`,
|
|
19
|
+
`max_run_mb`, `run_minutes`, `days` and `max_total_mb`; a value outside its range is refused. The account's folder
|
|
20
|
+
is kept under `max_total_mb` by dropping the oldest files whose text is kept.
|
|
21
|
+
- **`search all` finds the text of downloaded CRM files** (`crm_file` hits, also under `--only crm`): a limited profile
|
|
22
|
+
only those of records assigned to it, in the CRM CLI's and in memo's and tg's `search all` alike.
|
|
23
|
+
- **`fetchCrmFile`** for adapters: a file link fetched over https from the account's own hosts only, never naming the
|
|
24
|
+
link in an error; **`crmFilesContract`** in `@wirecat/cli-core/crm/testing`.
|
|
25
|
+
- **`search messages` helps a query of plain words the way `search conversations` does.** A word no message holds is
|
|
26
|
+
searched beside its Latin spelling or nearest known spellings (a note says so). Without `chat:`, a word
|
|
27
|
+
the messages show is a name in one private chat has that chat's hits first, searched without the name
|
|
28
|
+
(a note says so). A query with fields, quotes, groups or operators is searched exactly as written.
|
|
29
|
+
- **`search conversations` over every chat searches first the private chat a name in the query points to.** The name
|
|
30
|
+
is learned from the messages, with no list of nicknames: the private chat that holds most of a word's uses, at least
|
|
31
|
+
twice as many as any other private chat, and writes it with a capital letter nearly every time («Петька, привет»).
|
|
32
|
+
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.
|
|
33
|
+
- **`search conversations` respells a query word that no message holds.** It searches the word's Latin spelling
|
|
34
|
+
(«ноксвел» → `noxvel`) or the nearest known spellings of that, and only when there are none, the word's own nearest
|
|
35
|
+
known spellings, up to two edits. A word any message holds is never respelled. A note says what was searched instead.
|
|
36
|
+
|
|
37
|
+
### Changed — may break callers
|
|
38
|
+
|
|
39
|
+
- **memo's, tg's and the MCP's `search all` apply each CRM copy's viewer rule to deals and leads too**, taking the
|
|
40
|
+
user that copy's own sync signed in as: a non-admin copy's colleagues' deals no longer show there, as they never
|
|
41
|
+
did in the CRM CLI. A copy with no recorded own user shows none of its deals and leads there; a copy whose sync
|
|
42
|
+
recorded no list of who may read it shows only its own user's.
|
|
43
|
+
- **`search all` has a new hit kind, `crm_file`**, in every CLI: a caller that switches over `kind` gets it.
|
|
44
|
+
- **`safeName` cuts a name to 200 bytes**, its extension kept, for every download that uses it.
|
|
45
|
+
|
|
46
|
+
### Fixed
|
|
47
|
+
|
|
48
|
+
- **`meetings batch --format text|markdown` marks other people's text in a scheduled agent's run.** Transcript cues
|
|
49
|
+
and search hit excerpts and titles were printed with no untrusted marks; only JSON carried them. The report a host
|
|
50
|
+
formats with `formatMeetingBatch` now comes marked, so a host needs no change.
|
|
51
|
+
- **`callMeetingPassageTool` takes how the host prints a passage in this run.** Pass
|
|
52
|
+
`(result, format) => passageForRun(command, result, format)` as its new last argument, and the `meeting_passage`
|
|
53
|
+
text carries the same marks as `meetings passage` in a scheduled agent's run. Without it the text stays unmarked.
|
|
54
|
+
- **`search conversations --chat` no longer stops at 20 word hits.** The per-chat share that keeps a large group from
|
|
55
|
+
filling the list across chats also applied inside one chat, so a word used often there found only 20 messages.
|
|
56
|
+
- **A message search for «домен» no longer finds «дом» and «дома».** Snowball cuts some words to another word's stem.
|
|
57
|
+
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
|
|
58
|
+
stem itself («доменов» → «домен»), the search keeps the word whole. The stems stored for messages do not change.
|
|
59
|
+
- **A message search for a word of 4 letters or more also finds the longer words it begins, as grep does.** Snowball
|
|
60
|
+
stems some forms of one word apart («журнал» → «журна», «журналом» → «журнал»), so a search found only the
|
|
61
|
+
forms that shared the typed word's stem. Quotes keep the old match: the word and its stem's forms only. The note now
|
|
62
|
+
says what was searched: `квартира → квартира… and words stemmed to квартир`.
|
|
63
|
+
|
|
64
|
+
## 0.687.0 — 16.11.2026
|
|
65
|
+
|
|
66
|
+
### Added
|
|
67
|
+
|
|
68
|
+
- **CRM client files in the store (store version 68).** `crm_files` keeps each downloaded file of a deal, lead,
|
|
69
|
+
contact or company with its owner record, the record's assignee at download, the local path and the extracted
|
|
70
|
+
text, in its own word index `crm_file_words`; never a download link. `store.crmFiles` saves, lists and finds them,
|
|
71
|
+
a limited profile only those of records assigned to its user: a deal's or lead's as the copy assigns it now, so a
|
|
72
|
+
reassigned deal's files go with it. `store rebuild`, `store recover` and the
|
|
73
|
+
integrity check know the new index; an account's purge removes its rows.
|
|
74
|
+
- **`CrmSource.files(owner)`** (`@wirecat/cli-core/crm`): one record's files read live with the record's assignee,
|
|
75
|
+
each with an `open()` that keeps the tokened link inside the adapter; `crmFileId` and `parseCrmFileId` for the opaque
|
|
76
|
+
file id.
|
|
77
|
+
- **`withoutFileLinks(body)`** replaces every file link in a CRM answer with `[link removed]`, for `api call`: the
|
|
78
|
+
download keys (every `…Machine`, `DOWNLOAD_URL`, `publicUrl`, `CALL_RECORD_URL` and the like, amoCRM's
|
|
79
|
+
`_links.download`), a webhook, `auth`, `access_token`, `api_token` and `X-Amz-Signature` anywhere, and a portal
|
|
80
|
+
path with `token`. `crmValuesOf` applies it to every custom value, so a file field's
|
|
81
|
+
link reaches neither the store nor an answer.
|
|
82
|
+
- **`fakeCrmSource({ files })`** and `FAKE_FILE_TOKEN` in `@wirecat/cli-core/crm/testing`.
|
|
83
|
+
|
|
84
|
+
### Changed — may break callers
|
|
85
|
+
|
|
86
|
+
- **The daily limit on other people's records covers deals and leads.** `foreignContacts(...).spend` takes any CRM
|
|
87
|
+
kind and a record with only `externalId` and `assignee`; a deal or lead is the sign-in's own when assigned to its
|
|
88
|
+
user. The refusal says "records that are not yours" instead of "contacts and companies".
|
|
89
|
+
- **`account remove --delete-data` lists and deletes the CRM files the CLI downloaded** under its state folder
|
|
90
|
+
(`store.crmFiles.savedPaths`), in `--dry-run` and the confirmation too; a copy saved elsewhere stays.
|
|
91
|
+
|
|
92
|
+
### Fixed
|
|
93
|
+
|
|
94
|
+
- **A document the sign-in may not read (403) is skipped as a gone one (404) is**, listed among the skipped files with
|
|
95
|
+
the provider's reason. Before, it stayed pending with its error on every sync: the pass never completed, the change
|
|
96
|
+
cursor did not move, and later changes were not read.
|
|
97
|
+
- **A documents sync takes the start token, each root's own metadata in a full walk and each page of changes from the
|
|
98
|
+
request budget**, as it does a listing. Before, they were free, so under the MCP's 45 s deadline a provider with
|
|
99
|
+
slow reads ended the first run at the deadline itself, with no time to answer. A root's metadata is kept on the walk, so a run stopped before the
|
|
100
|
+
root's listing does not read it again.
|
|
101
|
+
- **`documentSourceContract`'s fault cases follow**: the 403 case requires the pass to complete and the next pass to
|
|
102
|
+
run, and the deadline case requires each run to leave the budget's answer reserve.
|
|
103
|
+
- **`search conversations` across several chats gives each chat a share**, so a large group no longer fills the
|
|
104
|
+
results with near matches and hides a small chat's clear answer. The meaning half reads the 500 nearest
|
|
105
|
+
conversations and ranks each chat's best 20 by how far they lead that chat's 20th best; the word half reads at most
|
|
106
|
+
20 messages per chat. On a test store of 10 chats (4 large groups) with 40 questions, a key message reached the top
|
|
107
|
+
20 for 19 questions instead of 10, and the top 5 for 11 instead of 8, at about 0.7 s more per query. One chat
|
|
108
|
+
(`--chat`) is searched as before. `QueryExecution` takes `perChat`, the most hits a page takes from one chat.
|
|
109
|
+
- **`meetings list` and `meetings show` stop when the run is stopped.** A read of the service that the run's stop
|
|
110
|
+
signal cut short was taken as a failed service and answered from the store. Now the stop is the answer, and the
|
|
111
|
+
service's `find` and `get` receive the signal as a new last argument. A host passes `signal` in
|
|
112
|
+
`addMeetingCommands`' deps; `MeetingServerAccess.signal` carries it for a direct call.
|
|
113
|
+
- **A sign-in with `storage: "keyring"` stops before the browser when the keyring does not answer.** #3041 made the
|
|
114
|
+
check before a sign-in read an unreachable keyring as "no old entry", so the browser opened and the save failed
|
|
115
|
+
after it. That holds only where the save can fall back to the file; with keyring-only storage the check fails up
|
|
116
|
+
front again, with cli-base's `keyring.unreachable`.
|
|
117
|
+
- **A sign-in store passes cli-base's own keyring errors through.** `credentialStorage` turned every failed read
|
|
118
|
+
into `oauth.not-saved`. A `CliError` from cli-base, such as `keyring.unreachable` (the keyring failed and the file
|
|
119
|
+
holds no entry), now reaches the answer with its own words. Before a sign-in, an old entry that cannot be read for
|
|
120
|
+
`keyring.unreachable` counts as no old entry, so a sign-in on a machine with no keyring still saves to the file.
|
|
121
|
+
|
|
8
122
|
## 0.686.0 — 16.11.2026
|
|
9
123
|
|
|
10
124
|
### 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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync, rmSync } from "node:fs";
|
|
1
|
+
import { existsSync, lstatSync, rmSync } from "node:fs";
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import { resolve as absolute, isAbsolute, join, sep } from "node:path";
|
|
4
4
|
import { CliError, Credentials, isMovedRun, resolvePaths, saveConfigFile, } from "@wirecat/cli-base";
|
|
@@ -208,6 +208,19 @@ export const accountRemoveCommand = (app, removal, options = {}) => logsInOrOut(
|
|
|
208
208
|
// The tool's own sign-out deletes its session where the run's state folder says; here that folder is the owner's.
|
|
209
209
|
const signsOut = !(movedFolders && inOwners(state));
|
|
210
210
|
const removed = signsOut ? [signIn] : [];
|
|
211
|
+
// Single files, removed without `recursive`: a path the store names is never a folder to empty.
|
|
212
|
+
const crmFiles = new Set();
|
|
213
|
+
const crmFilesOf = async (key, root, guard) => {
|
|
214
|
+
const store = await openStore({ env, command: app.command });
|
|
215
|
+
try {
|
|
216
|
+
// Only what the CLI downloaded into its state folder; a copy saved with --dir elsewhere is the owner's.
|
|
217
|
+
const saved = (await store.crmFiles.savedPaths(key)).map((path) => absolute(path));
|
|
218
|
+
return guard(saved.filter((path) => within(path, root))).filter((path) => existsSync(path) && lstatSync(path).isFile());
|
|
219
|
+
}
|
|
220
|
+
finally {
|
|
221
|
+
await store.close();
|
|
222
|
+
}
|
|
223
|
+
};
|
|
211
224
|
const kept = [...ownersKept, ...(signsOut ? [] : [{ ...signIn, reason: ownersReason }])];
|
|
212
225
|
// An entry the environment supplies is not this tool's to remove.
|
|
213
226
|
const saved = (store, name) => (store.read(name)?.source ?? "environment") !== "environment";
|
|
@@ -233,8 +246,13 @@ export const accountRemoveCommand = (app, removal, options = {}) => logsInOrOut(
|
|
|
233
246
|
removed.push({ kind: "file", target: file });
|
|
234
247
|
if (accountName && storeHere && ownersStore)
|
|
235
248
|
kept.push({ kind: "store", target: accountName, reason: ownersReason });
|
|
236
|
-
else if (accountName && storeHere)
|
|
249
|
+
else if (accountName && storeHere && account) {
|
|
237
250
|
removed.push({ kind: "store", target: accountName });
|
|
251
|
+
for (const file of await crmFilesOf(account, state, theRun)) {
|
|
252
|
+
removed.push({ kind: "file", target: file });
|
|
253
|
+
crmFiles.add(file);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
238
256
|
else
|
|
239
257
|
kept.push({
|
|
240
258
|
kind: "store",
|
|
@@ -316,7 +334,7 @@ export const accountRemoveCommand = (app, removal, options = {}) => logsInOrOut(
|
|
|
316
334
|
await removeSchedules(app, system, state, schedules, env);
|
|
317
335
|
for (const entry of removed)
|
|
318
336
|
if (entry.kind === "file")
|
|
319
|
-
rmSync(entry.target, { recursive: true, force: true });
|
|
337
|
+
rmSync(entry.target, crmFiles.has(entry.target) ? { force: true } : { recursive: true, force: true });
|
|
320
338
|
if (removal.forgetConfig && !ownersConfig)
|
|
321
339
|
for (const target of removal.forgetConfig(profile, hooks))
|
|
322
340
|
removed.push({ kind: "config", target });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { isCliError } from "@wirecat/cli-base";
|
|
3
|
-
import { runBudget } from "../../../background/budget.js";
|
|
3
|
+
import { ANSWER_RESERVE_MS, runBudget } from "../../../background/budget.js";
|
|
4
4
|
import { DEFAULT_AGENT_COOPERATIVE_MS } from "../../execution.js";
|
|
5
5
|
const MAX_ENTRIES = 500;
|
|
6
6
|
const walk = async ({ source, root, isFolder }) => {
|
|
@@ -45,19 +45,22 @@ const watched = (source, before) => new Proxy(source, {
|
|
|
45
45
|
},
|
|
46
46
|
});
|
|
47
47
|
/**
|
|
48
|
-
* Syncs until the
|
|
49
|
-
*
|
|
48
|
+
* Syncs until the pass is complete, and gives the last call's answer and ids, every file the calls skipped, and how
|
|
49
|
+
* many reads they made.
|
|
50
50
|
*/
|
|
51
51
|
const finish = async (sync) => {
|
|
52
52
|
let reads = 0;
|
|
53
|
+
const skipped = new Set();
|
|
53
54
|
for (let call = 1; call <= MOST_SYNCS; call++) {
|
|
54
55
|
const { result, saved } = await sync({
|
|
55
56
|
wrap: (source) => watched(source, () => {
|
|
56
57
|
reads++;
|
|
57
58
|
}),
|
|
58
59
|
});
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
for (const one of result.skipped)
|
|
61
|
+
skipped.add(one.id);
|
|
62
|
+
if (result.complete && result.pending === 0)
|
|
63
|
+
return { result, saved: [...saved].sort(), skipped, reads };
|
|
61
64
|
}
|
|
62
65
|
throw new assert.AssertionError({ message: `the sync is still unfinished after ${MOST_SYNCS} calls` });
|
|
63
66
|
};
|
|
@@ -207,11 +210,17 @@ const faultCases = (make) => [
|
|
|
207
210
|
const sync = fixture.faults?.sync;
|
|
208
211
|
if (!sync)
|
|
209
212
|
return;
|
|
210
|
-
|
|
213
|
+
// A refused file is skipped as a gone one is, so the pass completes and its change cursor moves on.
|
|
214
|
+
const { saved, skipped } = await finish(sync);
|
|
211
215
|
assert.ok(!saved.includes(id), `the sync does not hold ${id}, which answers ${status}`);
|
|
212
216
|
assert.ok(saved.length > 0, `the sync imports the documents that still answer beside ${id}`);
|
|
213
217
|
if (status === 403)
|
|
214
|
-
assert.ok(
|
|
218
|
+
assert.ok(skipped.has(id), `the sync names ${id} among its skipped files with the reason`);
|
|
219
|
+
if (!fixture.change)
|
|
220
|
+
return;
|
|
221
|
+
await fixture.change();
|
|
222
|
+
// Throws when the refused file holds the next pass too.
|
|
223
|
+
await finish(sync);
|
|
215
224
|
},
|
|
216
225
|
})),
|
|
217
226
|
{
|
|
@@ -293,8 +302,8 @@ const faultCases = (make) => [
|
|
|
293
302
|
clock += SLOW_CALL_MS;
|
|
294
303
|
}),
|
|
295
304
|
});
|
|
296
|
-
assert.ok(clock <= deadline.endsAt, `sync ${call}
|
|
297
|
-
if (
|
|
305
|
+
assert.ok(clock <= deadline.endsAt - ANSWER_RESERVE_MS, `sync ${call} left time to answer before its deadline: ended ${clock - deadline.endsAt} ms from it`);
|
|
306
|
+
if (result.complete && result.pending === 0) {
|
|
298
307
|
assert.ok(stopped, "a slow provider's tree takes more than one run under the deadline");
|
|
299
308
|
assert.deepEqual([...saved].sort(), expected.saved, "the runs together hold what one whole sync does");
|
|
300
309
|
return;
|
|
@@ -56,8 +56,8 @@ export interface CopyAge {
|
|
|
56
56
|
}
|
|
57
57
|
export declare const ageOf: (lastSync: string | undefined, now?: number) => CopyAge;
|
|
58
58
|
export declare const staleCopy: (provider: string, lastSync: string | undefined, now?: number) => {
|
|
59
|
-
missing?: undefined;
|
|
60
59
|
next?: undefined;
|
|
60
|
+
missing?: undefined;
|
|
61
61
|
meta?: undefined;
|
|
62
62
|
} | {
|
|
63
63
|
missing: {
|
package/dist/cli/envelope.js
CHANGED
|
@@ -10,7 +10,7 @@ import { environmentOf, setExitCode } from "./context.js";
|
|
|
10
10
|
import { largeAnswerSteps, SOFT_OUTPUT_BYTES } from "./output-budget.js";
|
|
11
11
|
import { withoutProviderRefs } from "./provider-refs.js";
|
|
12
12
|
import { nextStep, rootOf, runnable, stepLine, withLines, withSafety } from "./steps.js";
|
|
13
|
-
import {
|
|
13
|
+
import { runMarkOf, untrustedFieldsOf, withFieldsMarked, withUntrustedMarked } from "./untrusted-marks.js";
|
|
14
14
|
/** Every answer: a list or one thing, with items of `item` — any value where the command declares no entity. */
|
|
15
15
|
export const answerSchema = (item = v.unknown()) => v.union([listEnvelopeSchema(item), itemEnvelopeSchema(item)]);
|
|
16
16
|
const capped = (steps) => (steps.length > 0 ? { next: steps.slice(0, MAX_NEXT_STEPS) } : {});
|
|
@@ -185,8 +185,7 @@ export const renderAnswer = (command, { renderer, format, streams, compact, full
|
|
|
185
185
|
const root = rootOf(command);
|
|
186
186
|
const runnableSteps = runnable(root, body.next);
|
|
187
187
|
const next = environmentOf(command).agent ? runnableSteps : withLines(root, runnableSteps);
|
|
188
|
-
const
|
|
189
|
-
const mark = app ? untrustedMarkOf(app, env ?? process.env) : undefined;
|
|
188
|
+
const mark = runMarkOf(command);
|
|
190
189
|
const declared = untrustedFieldsOf(command);
|
|
191
190
|
const shown = mark === undefined ? body : withUntrustedMarked(declared ? withFieldsMarked(body, declared, mark) : body, mark);
|
|
192
191
|
const kept = withoutProviderRefs({ ...shown, ...(next.length > 0 ? { next } : {}) });
|
|
@@ -12,6 +12,7 @@ import { answerEntity } from "./answer-entity.js";
|
|
|
12
12
|
import { destroysNothing } from "./effects.js";
|
|
13
13
|
import { answerSchema, itemOf, listOf } from "./envelope.js";
|
|
14
14
|
import { pagingOf } from "./paging.js";
|
|
15
|
+
import { runMarkOf, withUntrustedMarked } from "./untrusted-marks.js";
|
|
15
16
|
const INDEX_BYTES = 4194304;
|
|
16
17
|
const parse = (command, args) => {
|
|
17
18
|
command
|
|
@@ -148,6 +149,9 @@ export const addMeetingBatchCommand = (program, deps) => {
|
|
|
148
149
|
fields,
|
|
149
150
|
failureContext: failureContext(),
|
|
150
151
|
});
|
|
152
|
+
// The host formats text and Markdown from the report; JSON is marked by `renderAnswer`.
|
|
153
|
+
const mark = format === "json" ? undefined : runMarkOf(action);
|
|
154
|
+
const shown = mark === undefined ? report : withUntrustedMarked(report, mark);
|
|
151
155
|
const issues = report.items
|
|
152
156
|
.filter((item) => !item.complete)
|
|
153
157
|
.map((item) => ({
|
|
@@ -167,7 +171,7 @@ export const addMeetingBatchCommand = (program, deps) => {
|
|
|
167
171
|
...(issues.length ? { issues } : {}),
|
|
168
172
|
...(report.output_limited ? { truncated: true } : {}),
|
|
169
173
|
},
|
|
170
|
-
}),
|
|
174
|
+
}), shown, format);
|
|
171
175
|
});
|
|
172
176
|
destroysNothing(command);
|
|
173
177
|
annotate(command, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Command } from "commander";
|
|
2
2
|
import type { MeetingPassageOutputFormat, MeetingPassageResult } from "../meetings/index.js";
|
|
3
3
|
/**
|
|
4
|
-
* The passage as the host prints it from `meetings passage`'s `output
|
|
4
|
+
* The passage as the host prints it from `meetings passage`'s `output`, or as `callMeetingPassageTool` answers it: in a scheduled agent's run, text and Markdown
|
|
5
5
|
* are formatted again from the marked cues. The meetings module cannot read the run's mark; JSON is marked by
|
|
6
6
|
* `renderAnswer`.
|
|
7
7
|
*/
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { formatMeetingPassage } from "../services/meeting-passage-format.js";
|
|
2
|
-
import {
|
|
3
|
-
import { untrustedMarkOf, withUntrustedMarked } from "./untrusted-marks.js";
|
|
2
|
+
import { runMarkOf, withUntrustedMarked } from "./untrusted-marks.js";
|
|
4
3
|
/**
|
|
5
|
-
* The passage as the host prints it from `meetings passage`'s `output
|
|
4
|
+
* The passage as the host prints it from `meetings passage`'s `output`, or as `callMeetingPassageTool` answers it: in a scheduled agent's run, text and Markdown
|
|
6
5
|
* are formatted again from the marked cues. The meetings module cannot read the run's mark; JSON is marked by
|
|
7
6
|
* `renderAnswer`.
|
|
8
7
|
*/
|
|
9
8
|
export const passageForRun = (command, result, format) => {
|
|
10
|
-
const
|
|
11
|
-
const mark = app ? untrustedMarkOf(app, env ?? process.env) : undefined;
|
|
9
|
+
const mark = runMarkOf(command);
|
|
12
10
|
if (mark === undefined || format === "json")
|
|
13
11
|
return result;
|
|
14
12
|
return { ...result, content: formatMeetingPassage(withUntrustedMarked(result.packet, mark), format) };
|
|
@@ -626,6 +626,10 @@ export const conversationsSearchCommand = (messenger) => syncOptions(boundOption
|
|
|
626
626
|
if (refreshed)
|
|
627
627
|
for (const note of leftNotes(refreshed, rootOf(this)))
|
|
628
628
|
context.renderer.note(note);
|
|
629
|
+
for (const [word, forms] of Object.entries(found.respelled ?? {}))
|
|
630
|
+
context.renderer.note(`no message holds «${word}»: searched ${forms.map((form) => `«${form}»`).join(", ")} instead`);
|
|
631
|
+
if (found.named)
|
|
632
|
+
context.renderer.note(`«${found.named.word}» is a name in chat ${found.named.title ?? found.named.chatId} (${found.named.chatId}): its hits come first`);
|
|
629
633
|
if (found.words === "out-of-time")
|
|
630
634
|
context.renderer.note("the word half ran out of time, so these are by meaning alone; --timeout gives it longer");
|
|
631
635
|
renderAnswer(this, context, foundConversations("search conversations", found, limit, messenger, chat, window.meta), () => found.hits.map((hit) => `${hitLine(hit)}\n`).join(""));
|
|
@@ -7,6 +7,7 @@ import { syncsOneChat } from "../../ports/traits.js";
|
|
|
7
7
|
import { renderMessages } from "../../render/messages.js";
|
|
8
8
|
import { renderThreadLinks } from "../../render/thread-context.js";
|
|
9
9
|
import { searchTimeLimit } from "../../search/lucene/types.js";
|
|
10
|
+
import { START_LETTERS } from "../../search/stem.js";
|
|
10
11
|
import { environmentOf } from "../context.js";
|
|
11
12
|
import { REMOTE_READ } from "../effects.js";
|
|
12
13
|
import { renderAnswer } from "../envelope.js";
|
|
@@ -133,6 +134,10 @@ const searchAction = (messenger) => async function (given) {
|
|
|
133
134
|
const { command } = messenger.app;
|
|
134
135
|
for (const { from, to } of found.corrections)
|
|
135
136
|
context.renderer.note(`${from} → ${to.join(", ")}`);
|
|
137
|
+
for (const [word, forms] of Object.entries(found.respelled ?? {}))
|
|
138
|
+
context.renderer.note(`no message holds «${word}»: also searched ${forms.map((form) => `«${form}»`).join(", ")}`);
|
|
139
|
+
if (found.named)
|
|
140
|
+
context.renderer.note(`«${found.named.word}» is a name in chat ${found.named.title ?? found.named.chatId} (${found.named.chatId}): its hits come first`);
|
|
136
141
|
for (const { source, reason } of found.skipped ?? [])
|
|
137
142
|
context.renderer.note(`${source} not searched: ${reason}`);
|
|
138
143
|
if (found.meaningSkipped)
|
|
@@ -145,7 +150,7 @@ const searchAction = (messenger) => async function (given) {
|
|
|
145
150
|
const stemming = found.query?.stemming;
|
|
146
151
|
const forms = (stemming?.applied ? stemming.terms : []).filter(({ stemmer }) => stemmer !== "none");
|
|
147
152
|
if (forms.length > 0)
|
|
148
|
-
context.renderer.note(`also found other forms: ${forms.map(({ word, stem, stemmer }) => `${word} → ${stem}
|
|
153
|
+
context.renderer.note(`also found other forms: ${forms.map(({ word, stem, stemmer }) => `${word} → ${[...word].length >= START_LETTERS ? `${word}… and ` : ""}words stemmed to ${stem} (${stemmer})`).join(", ")} — --exact for the exact words only`);
|
|
149
154
|
if (stemming?.applied === false)
|
|
150
155
|
context.renderer.note(stemming.reason === "building"
|
|
151
156
|
? `other forms of words are not searched yet: the stems are ${Math.floor((stemming.done / Math.max(stemming.total, 1)) * 100)}% built — \`${command} store migrate\` finishes them`
|
|
@@ -295,6 +295,8 @@ const ALL_HIT_UNTRUSTED = {
|
|
|
295
295
|
// A CRM's copy is typed by the CRM's users; the owner's own deal is his, but one rule keeps a hit's marking simple.
|
|
296
296
|
deal: ["title", "excerpt"],
|
|
297
297
|
lead: ["title", "excerpt"],
|
|
298
|
+
// A client's file: its name and every word of it are someone else's.
|
|
299
|
+
crm_file: ["title", "excerpt"],
|
|
298
300
|
...BUSINESS_UNTRUSTED,
|
|
299
301
|
};
|
|
300
302
|
export const allHitItem = (item) => item.kind === "meeting"
|
|
@@ -16,7 +16,7 @@ import { migrate } from "../../store/migrations.js";
|
|
|
16
16
|
import { openCache } from "../../store/open.js";
|
|
17
17
|
import { storePath } from "../../store/path.js";
|
|
18
18
|
import { deleteCopy, repairStore } from "../../store/repair.js";
|
|
19
|
-
import { drainNoteIndex, dropAllUnusedVectors, fillSearchIndex, fillStems, involvementStoreOver, noteIndexState, openSqlite, openStore, orphanPointers, pendingNormalization, resetAttachmentWords, resetNoteIndex, resetSearchIndex, resetStems, rollBack, searchIndexState, stemmerCache, stemsState, vectorIndexCounts, } from "../../store/store.js";
|
|
19
|
+
import { drainNoteIndex, dropAllUnusedVectors, fillSearchIndex, fillStems, involvementStoreOver, noteIndexState, openSqlite, openStore, orphanPointers, pendingNormalization, resetAttachmentWords, resetCrmFileWords, resetNoteIndex, resetSearchIndex, resetStems, rollBack, searchIndexState, stemmerCache, stemsState, vectorIndexCounts, } from "../../store/store.js";
|
|
20
20
|
import { environmentOf, outputFor } from "../context.js";
|
|
21
21
|
import { destroysNothing, grantsAuthority, LOCAL_READ, LOCAL_WRITE } from "../effects.js";
|
|
22
22
|
import { itemOf, renderAnswer, snakeKeys } from "../envelope.js";
|
|
@@ -326,6 +326,7 @@ const inspect = (path) => reading(path, (database) => {
|
|
|
326
326
|
...(wordIndex ? [[WORD_INDEX, indexIntegrity(database, WORD_INDEX, 0)]] : []),
|
|
327
327
|
...(stems ? [["message_stems", indexIntegrity(database, "message_stems", 0)]] : []),
|
|
328
328
|
...(schema.version > 0 ? [["attachment_words", indexIntegrity(database, "attachment_words", 0)]] : []),
|
|
329
|
+
...(schema.version >= 68 ? [["crm_file_words", indexIntegrity(database, "crm_file_words", 0)]] : []),
|
|
329
330
|
]);
|
|
330
331
|
const size = bytesOf(path) + bytesOf(`${path}-wal`);
|
|
331
332
|
const { bavail, bsize } = statfsSync(dirname(path));
|
|
@@ -530,7 +531,7 @@ const reindexCommand = (owner) => destroysNothing(annotate(new Command("rebuild"
|
|
|
530
531
|
throw new CliError("validation_error", `the store is behind this build — \`${lineOf(this, "store migrate")}\` first`);
|
|
531
532
|
}
|
|
532
533
|
resetSearchIndex(database);
|
|
533
|
-
const fileTexts = resetAttachmentWords(database);
|
|
534
|
+
const fileTexts = resetAttachmentWords(database) + resetCrmFileWords(database);
|
|
534
535
|
const words = buildWordIndex(database, (note) => renderer.note(note));
|
|
535
536
|
return {
|
|
536
537
|
path,
|
|
@@ -11,6 +11,7 @@ declare const LIST_KEYS: {
|
|
|
11
11
|
readonly notes: "notes.list";
|
|
12
12
|
readonly events: "events.list";
|
|
13
13
|
readonly meetings: "meetings.list";
|
|
14
|
+
readonly crm_file: "files.list";
|
|
14
15
|
};
|
|
15
16
|
export type SearchedKind = keyof typeof LIST_KEYS;
|
|
16
17
|
export interface LeftOut<K extends SearchedKind> {
|
|
@@ -30,4 +31,6 @@ export declare const deniedKindsOf: <K extends SearchedKind>(permissions: Readon
|
|
|
30
31
|
* server's own stricter ones.
|
|
31
32
|
*/
|
|
32
33
|
export declare const deniedKinds: <K extends SearchedKind>(command: Command, app: AppIdentity, kinds: readonly K[]) => LeftOut<K>[];
|
|
34
|
+
/** The level the profile, `--permission` and an MCP server's own levels give `key` for this run. */
|
|
35
|
+
export declare const commandLevel: (command: Command, app: AppIdentity, key: PermissionKey) => Level;
|
|
33
36
|
export {};
|
|
@@ -12,6 +12,7 @@ const LIST_KEYS = {
|
|
|
12
12
|
notes: "notes.list",
|
|
13
13
|
events: "events.list",
|
|
14
14
|
meetings: "meetings.list",
|
|
15
|
+
crm_file: "files.list",
|
|
15
16
|
};
|
|
16
17
|
/**
|
|
17
18
|
* The kinds whose list `permissions` deny, for a CLI with levels of its own, such as memo's: `by` names who denies in
|
|
@@ -36,3 +37,14 @@ export const deniedKinds = (command, app, kinds) => {
|
|
|
36
37
|
});
|
|
37
38
|
return deniedKindsOf(permissions, kinds, `profile ${profile}`, environment.permissionDefaults);
|
|
38
39
|
};
|
|
40
|
+
/** The level the profile, `--permission` and an MCP server's own levels give `key` for this run. */
|
|
41
|
+
export const commandLevel = (command, app, key) => {
|
|
42
|
+
const environment = environmentOf(command);
|
|
43
|
+
const resolve = environment.resolveSettings ?? settingsFor(app).resolveSettings;
|
|
44
|
+
const { permissions } = resolve(withAgentLevels(command, command.optsWithGlobals()), {
|
|
45
|
+
env: environment.env ?? process.env,
|
|
46
|
+
needsProfile: false,
|
|
47
|
+
readOnly: true,
|
|
48
|
+
});
|
|
49
|
+
return levelFor(permissions, key, environment.permissionDefaults).level;
|
|
50
|
+
};
|
|
@@ -9,7 +9,7 @@ import { DEFAULT_STEMMERS, parseStemmers } from "../search/stem.js";
|
|
|
9
9
|
import { openCache } from "../store/open.js";
|
|
10
10
|
import { storePath } from "../store/path.js";
|
|
11
11
|
import { applyTaskCategoryEdits, editsFrom, readTaskCategoryEdits, sharedConfigPath, writeTaskCategoryEdits, } from "../store/shared-config.js";
|
|
12
|
-
import { accountGroupsOf, crmSettingsOf, DEFAULT_AGENT_CLOSE, DEFAULT_FIRST_PASS_PER_CHAT, DEFAULT_OWNER_LANGUAGES, firstPassPerChatOf, openStore, parseCrmSetting, parseCrmSettingValue, parseOwnerLanguages, saveCrmSetting, savedAgentClose, savedFirstPassPerChat, savedOwnerLanguages, savedPhoneCountries, savedStemmers, savedTaskCategories, saveOwnerLanguages, saveStorePhoneCountries, stemmersOrigin, } from "../store/store.js";
|
|
12
|
+
import { accountGroupsOf, CRM_FILE_LIMITS, crmSettingsOf, DEFAULT_AGENT_CLOSE, DEFAULT_FIRST_PASS_PER_CHAT, DEFAULT_OWNER_LANGUAGES, firstPassPerChatOf, openStore, parseCrmSetting, parseCrmSettingValue, parseOwnerLanguages, saveCrmSetting, savedAgentClose, savedFirstPassPerChat, savedOwnerLanguages, savedPhoneCountries, savedStemmers, savedTaskCategories, saveOwnerLanguages, saveStorePhoneCountries, stemmersOrigin, } from "../store/store.js";
|
|
13
13
|
const SCRIPTS = {
|
|
14
14
|
"search_stemmers.cyrillic": "cyrillic",
|
|
15
15
|
"search_stemmers.latin": "latin",
|
|
@@ -34,9 +34,19 @@ export const STORE_SETTINGS = [
|
|
|
34
34
|
const GROUP_PREFIX = `${ACCOUNT_GROUPS_SETTING}.`;
|
|
35
35
|
/**
|
|
36
36
|
* A CRM account's: whether what it reports is a relationship or waits for review, what its company types mean, whose
|
|
37
|
-
* deals and leads its sync copies, which stages open a task,
|
|
37
|
+
* deals and leads its sync copies, which stages open a task, whether activities and tasks are read, and the limits
|
|
38
|
+
* of downloading its files.
|
|
38
39
|
*/
|
|
39
|
-
const CRM_SETTINGS = [
|
|
40
|
+
const CRM_SETTINGS = [
|
|
41
|
+
"links",
|
|
42
|
+
"company-types",
|
|
43
|
+
"scope",
|
|
44
|
+
"unassigned",
|
|
45
|
+
"self",
|
|
46
|
+
"stage-tasks",
|
|
47
|
+
"activities",
|
|
48
|
+
...Object.keys(CRM_FILE_LIMITS).map((name) => `files.${name}`),
|
|
49
|
+
].map((name) => `crm.<provider>:<account>.${name}`);
|
|
40
50
|
/**
|
|
41
51
|
* The store settings a CLI offers. Phone countries, task rules and account groups belong to messages; a CLI that is
|
|
42
52
|
* not a messenger would change them for tg and MAX without reading them itself.
|
|
@@ -51,7 +61,13 @@ export const offersStoreSetting = (app, setting) => app.messenger !== false || s
|
|
|
51
61
|
*/
|
|
52
62
|
export const isOwnerOnlyStoreSetting = (setting) => {
|
|
53
63
|
const name = parseCrmSetting(setting)?.name;
|
|
54
|
-
return name === "scope" ||
|
|
64
|
+
return (name === "scope" ||
|
|
65
|
+
name === "self" ||
|
|
66
|
+
name === "unassigned" ||
|
|
67
|
+
name === "stage-tasks" ||
|
|
68
|
+
name === "activities" ||
|
|
69
|
+
// An agent must not lift the limits on what it may download.
|
|
70
|
+
name?.startsWith("files.") === true);
|
|
55
71
|
};
|
|
56
72
|
export const isStoreSetting = (setting) => setting in SCRIPTS ||
|
|
57
73
|
setting === OWNER_LANGUAGES ||
|
|
@@ -277,8 +293,11 @@ const CRM_DEFAULTS = {
|
|
|
277
293
|
self: "",
|
|
278
294
|
"stage-tasks": {},
|
|
279
295
|
activities: "off",
|
|
296
|
+
...Object.fromEntries(Object.entries(CRM_FILE_LIMITS).map(([name, range]) => [`files.${name}`, range.default])),
|
|
280
297
|
};
|
|
281
298
|
const crmNote = (name, now) => {
|
|
299
|
+
if (name.startsWith("files."))
|
|
300
|
+
return `store-wide — files sync and files download of that account keep to it from the next run`;
|
|
282
301
|
if (name === "links")
|
|
283
302
|
return `store-wide — the next sync of that account writes what it reports as ${now === "review" ? "proposals for the owner to review" : "reported relationships"}; relationships already stored stay`;
|
|
284
303
|
if (name === "company-types")
|
|
@@ -5,6 +5,8 @@ import { type AppIdentity } from "../ports/app.js";
|
|
|
5
5
|
* agent's own start, so a command the agent runs cannot name another, and only a locked run has one.
|
|
6
6
|
*/
|
|
7
7
|
export declare const untrustedMarkOf: (app: AppIdentity, env: NodeJS.ProcessEnv) => string | undefined;
|
|
8
|
+
/** `untrustedMarkOf` for the app and environment the command runs in. */
|
|
9
|
+
export declare const runMarkOf: (command: Command) => string | undefined;
|
|
8
10
|
/** Other people's text between the run's markers, with every bracket and the mark taken out, so it can close none. */
|
|
9
11
|
export declare const marked: (text: string, mark: string, source: string, id?: string) => string;
|
|
10
12
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ancestorValue, envName, readOnlyLockOf } from "../ports/app.js";
|
|
2
|
+
import { environmentOf } from "./context.js";
|
|
2
3
|
const OPEN = "⟦";
|
|
3
4
|
const CLOSE = "⟧";
|
|
4
5
|
/**
|
|
@@ -11,6 +12,11 @@ export const untrustedMarkOf = (app, env) => {
|
|
|
11
12
|
const mark = ancestorValue(envName(app, "UNTRUSTED_MARK"), env);
|
|
12
13
|
return mark && /^[0-9a-f]{16}$/.test(mark) ? mark : undefined;
|
|
13
14
|
};
|
|
15
|
+
/** `untrustedMarkOf` for the app and environment the command runs in. */
|
|
16
|
+
export const runMarkOf = (command) => {
|
|
17
|
+
const { app, env } = environmentOf(command);
|
|
18
|
+
return app ? untrustedMarkOf(app, env ?? process.env) : undefined;
|
|
19
|
+
};
|
|
14
20
|
/** Other people's text between the run's markers, with every bracket and the mark taken out, so it can close none. */
|
|
15
21
|
export const marked = (text, mark, source, id) => {
|
|
16
22
|
const inside = text.replaceAll(OPEN, "").replaceAll(CLOSE, "").replaceAll(mark, "");
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { AppIdentity } from "../../ports/app.js";
|
|
3
|
+
import type { CrmFileLimits, CrmFileRow } from "../../store/store.js";
|
|
4
|
+
import type { CrmOpenableFile } from "../source.js";
|
|
5
|
+
import type { CrmRun, CrmWithin } from "./index.js";
|
|
6
|
+
/** `files download`'s own cap, and the most `--max-size` takes: Bitrix24's own largest file. */
|
|
7
|
+
export declare const DOWNLOAD_MB = 100;
|
|
8
|
+
export declare const MOST_DOWNLOAD_MB = 2048;
|
|
9
|
+
/** Where `files sync` is in its round, a sync state `config` never sets. */
|
|
10
|
+
export declare const FILES_ROUND = "crm:files-round";
|
|
11
|
+
export declare const FILES_DOWNLOAD_KEY = "files.download";
|
|
12
|
+
declare const SKIP_REASONS: readonly ["too-large", "run-files", "run-mb", "deadline", "disk-full", "unavailable"];
|
|
13
|
+
type SkipReason = (typeof SKIP_REASONS)[number];
|
|
14
|
+
export interface CrmFileContext {
|
|
15
|
+
app: AppIdentity;
|
|
16
|
+
run: CrmRun;
|
|
17
|
+
now: () => number;
|
|
18
|
+
signal?: AbortSignal;
|
|
19
|
+
}
|
|
20
|
+
export interface Downloaded {
|
|
21
|
+
row: CrmFileRow;
|
|
22
|
+
textStatus: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* One file saved and read: under the account's folder (folders 700, file 600) or `dir`, its text through
|
|
26
|
+
* `extractText`, its row stored. A cut-off or refused download keeps no part, and no error names the link.
|
|
27
|
+
*/
|
|
28
|
+
export declare const downloadCrmFile: (context: CrmFileContext, file: CrmOpenableFile, assignee: string | null, { capBytes, capMb, flag, dir, limits, }: {
|
|
29
|
+
capBytes: number;
|
|
30
|
+
capMb: number;
|
|
31
|
+
flag: boolean;
|
|
32
|
+
dir?: string;
|
|
33
|
+
limits: CrmFileLimits;
|
|
34
|
+
}) => Promise<Downloaded>;
|
|
35
|
+
export interface CrmFileCommandOptions {
|
|
36
|
+
within: CrmWithin;
|
|
37
|
+
example: (command: Command, ...lines: string[]) => Command;
|
|
38
|
+
app: AppIdentity;
|
|
39
|
+
/** The CRM has leads: `--lead` is offered. True when absent. */
|
|
40
|
+
leads?: boolean;
|
|
41
|
+
now: () => number;
|
|
42
|
+
}
|
|
43
|
+
/** `files list`, `files download` and `files sync` (NEED-2701 C, NEED-2708 B). */
|
|
44
|
+
export declare const addCrmFileCommands: (program: Command, options: CrmFileCommandOptions) => void;
|
|
45
|
+
export interface FilesSyncReport {
|
|
46
|
+
owners: number;
|
|
47
|
+
downloaded: {
|
|
48
|
+
id: string;
|
|
49
|
+
name: string;
|
|
50
|
+
size: number;
|
|
51
|
+
path: string;
|
|
52
|
+
text_status: string;
|
|
53
|
+
}[];
|
|
54
|
+
skipped: {
|
|
55
|
+
id: string;
|
|
56
|
+
name: string;
|
|
57
|
+
size: number | null;
|
|
58
|
+
reason: SkipReason;
|
|
59
|
+
}[];
|
|
60
|
+
complete: boolean;
|
|
61
|
+
stopped?: SkipReason;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* One `files sync` run: the files of the sign-in's own deals and leads changed since the last complete round, and at
|
|
65
|
+
* most `files.days` back, newest first, under the run's limits. It stops at the first run limit and saves its place.
|
|
66
|
+
*/
|
|
67
|
+
export declare const syncFiles: (context: CrmFileContext, outOfTime: () => boolean, deadline?: (ms: number) => AbortSignal) => Promise<FilesSyncReport>;
|
|
68
|
+
export {};
|