@wirecat/cli-core 0.640.0 → 0.642.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 +80 -0
- package/dist/analysis/provider.d.ts +1 -1
- package/dist/analysis/provider.js +2 -1
- package/dist/attachments/gateway-ocr.js +13 -8
- package/dist/background/schedules.d.ts +5 -1
- package/dist/background/schedules.js +28 -3
- package/dist/calendar/mcp/index.d.ts +12 -12
- package/dist/cli/ai-model-command.js +6 -3
- package/dist/cli/analysis-choice.js +20 -4
- package/dist/cli/enrichment-consents-command.js +2 -0
- package/dist/cli/local-only-command.d.ts +10 -0
- package/dist/cli/local-only-command.js +103 -0
- package/dist/cli/messenger/backfill-command.js +16 -1
- package/dist/cli/messenger/conversations-command.js +1 -1
- package/dist/cli/messenger/replies-consents-command.js +12 -6
- package/dist/cli/messenger/search-answers.js +2 -0
- package/dist/cli/model-catalogue-command.js +2 -0
- package/dist/cli/search-harder-consents-command.js +16 -1
- package/dist/cli/store-settings.d.ts +4 -1
- package/dist/cli/store-settings.js +26 -9
- package/dist/crm/cli/csv.js +2 -0
- package/dist/crm/cli/index.js +8 -2
- package/dist/crm/cli/search-all.js +4 -4
- package/dist/crm/stage-tasks.d.ts +8 -0
- package/dist/crm/stage-tasks.js +42 -0
- package/dist/documents.d.ts +1 -1
- package/dist/documents.js +1 -1
- package/dist/domain/crm.d.ts +6 -0
- package/dist/embeddings/remote.d.ts +2 -1
- package/dist/embeddings/remote.js +5 -3
- package/dist/entities/deal.d.ts +6 -0
- package/dist/entities/deal.js +3 -0
- package/dist/entities/index.d.ts +4 -0
- package/dist/errors/reasons.js +8 -0
- package/dist/meetings/mcp/index.d.ts +15 -15
- package/dist/models/ai.d.ts +16 -3
- package/dist/models/ai.js +19 -13
- package/dist/models/endpoint.d.ts +5 -0
- package/dist/models/endpoint.js +13 -0
- package/dist/models/index.d.ts +4 -0
- package/dist/models/index.js +9 -1
- package/dist/models/local-only.d.ts +17 -0
- package/dist/models/local-only.js +42 -0
- package/dist/models/purpose.d.ts +24 -0
- package/dist/models/purpose.js +26 -0
- package/dist/replies/rendering.js +10 -10
- package/dist/runs/events.d.ts +9 -1
- package/dist/runs/events.js +5 -1
- package/dist/runs/log-events.js +2 -0
- package/dist/services/deal-context.js +17 -0
- package/dist/services/embeddings-maintenance.js +4 -1
- package/dist/services/enrichment.d.ts +1 -1
- package/dist/services/enrichment.js +27 -0
- package/dist/services/meeting-model.js +1 -1
- package/dist/services/message-resolution.d.ts +1 -1
- package/dist/services/message-resolution.js +2 -2
- package/dist/services/messages-search.js +12 -5
- package/dist/services/search-all.d.ts +10 -3
- package/dist/services/search-all.js +10 -4
- package/dist/services/search-harder.d.ts +11 -1
- package/dist/services/search-harder.js +38 -5
- package/dist/speech/openai.js +2 -0
- package/dist/speech/transcribe.d.ts +5 -2
- package/dist/speech/transcribe.js +14 -5
- package/dist/store/index.d.ts +1 -1
- package/dist/store/sqlite/crm-rows.js +2 -0
- package/dist/store/sqlite/crm-settings.d.ts +26 -1
- package/dist/store/sqlite/crm-settings.js +104 -1
- package/dist/store/sqlite/crm.d.ts +12 -0
- package/dist/store/sqlite/crm.js +4 -1
- package/dist/store/sqlite/deals.d.ts +28 -5
- package/dist/store/sqlite/deals.js +158 -14
- package/dist/store/sqlite/lucene-fields.js +56 -3
- package/dist/store/sqlite/tasks.js +9 -8
- package/dist/tasks/model.d.ts +6 -2
- package/dist/tasks/service.d.ts +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,86 @@ 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.642.0 — 11.11.2026
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **Local only: one switch that keeps every model call on this computer.** `models local-only set on|off` and
|
|
13
|
+
`models local-only show` (in memo): with it on, the model gateway, remote embeddings and OpenAI transcription refuse
|
|
14
|
+
any address that is not `localhost`, `127.x.x.x` or `[::1]` before anything is sent (`local-only.refused`), and the
|
|
15
|
+
setting commands refuse to save one. `show` lists each feature, where its data goes and whether it is refused. Off by
|
|
16
|
+
default; only the owner turns it off. See
|
|
17
|
+
[ai-providers.md, "Local only"](docs/search/ai-providers.md#local-only).
|
|
18
|
+
- **Linking, reply drafts and attachment OCR use the shared AI model** when `models.analysis`, `models.replies` or
|
|
19
|
+
`models.ocr` are not set (`off` stays off), with the key kept for its address (`purposeModel`, `sharedModel`).
|
|
20
|
+
- **`models search-consents set --timeout <duration>`.** Search harder waits 60 s for a model on this computer and 5 s
|
|
21
|
+
for a hosted one unless the owner sets the limit; `show` gives `timeout_s`.
|
|
22
|
+
|
|
23
|
+
### Changed — may break callers
|
|
24
|
+
|
|
25
|
+
- **Plain http is allowed only to this computer,, for every model call.** Enrichment, search harder,
|
|
26
|
+
linking, reply drafts, attachment OCR and remote embeddings refused nothing but credentials in the address, so a
|
|
27
|
+
`http://` address on another machine sent records across the network unencrypted. They now refuse it, as `models ai`
|
|
28
|
+
already did (`model.address-refused`); use https, or run the model on this computer. A saved setting with such an
|
|
29
|
+
address still reads, and its feature says why it sends nothing.
|
|
30
|
+
- **Voice messages are heard by the downloaded model first.** `auto` asked the messenger's speech service first; it now
|
|
31
|
+
uses the local model when it is downloaded and asks the messenger only when it is not, and never under local only.
|
|
32
|
+
- **An OpenAI-compatible server on this computer needs no key** in `models ai`; one may still be stored for it.
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
|
|
36
|
+
- **A daily or one-off schedule sits out a wait the provider asked for.** A timer run that failed with `rate_limited` and a `retry.after_ms` failed for the day. `schedule exec` now waits that long, if it is at most six hours, and runs once more; `last.json` keeps the wait as `retryAfterMs`. A run by hand and a schedule that repeats still fail at once.
|
|
37
|
+
|
|
38
|
+
## 0.641.0 — 11.11.2026
|
|
39
|
+
|
|
40
|
+
### Added
|
|
41
|
+
|
|
42
|
+
- **A deal or a lead keeps the person and company its CRM holds on the item itself.** A lead often has no contact or
|
|
43
|
+
company linked yet; its own name and company were all it said of who it is, and they were dropped. `CrmItem` takes
|
|
44
|
+
`contactName` and `companyName`, the store keeps them, `deals show` and `leads show` answer them as `contact_name`
|
|
45
|
+
and `company_name` (marked untrusted, as a CRM's users or a web form wrote them), the CSV export has both columns, and
|
|
46
|
+
`search all` finds the item by them, the name as a contact and the company as a company. See
|
|
47
|
+
[ARCHITECTURE.md](docs/dev/ARCHITECTURE.md).
|
|
48
|
+
- **A deal or lead entering a stage opens a local task.** The owner's setting `crm.<provider>:<account>.stage-tasks`
|
|
49
|
+
maps a stage to a task, `{"<stage id>": {"title": "…", "due_days": 2}}`, a lead's stage as `lead:<stage id>`. After
|
|
50
|
+
each CRM `sync`, every move into such a stage since the last sync opens one task, due that many days later, whose
|
|
51
|
+
description names the deal, the stage and the responsible user. A move counts once: a dismissed task never comes
|
|
52
|
+
back, and entering the stage again opens a new one. Moves made before the setting was first saved, and a new row's
|
|
53
|
+
first stage, open none. The sync answer's `stage_tasks` says how many it opened, a deal's context lists them, and
|
|
54
|
+
an agent cannot change the setting. See
|
|
55
|
+
[KNOWLEDGE.md, "Relationships a source reports"](docs/dev/KNOWLEDGE.md#relationships-a-source-reports).
|
|
56
|
+
- **`NewTask.title` and `description`.** A rule that knows what to do gives its task a title and a description.
|
|
57
|
+
- **A part inside a word in chat messages.** `*договор*` without a field, or under `text:` or `exact:`, finds «Договор», «ДОГОВОРЫ» and «переговоры» through the store's index of three-letter pieces of message text, which every store already has. A large archive no longer refuses it, and it works inside `AND`/`OR`/`NOT`, groups, and with `chat:` and `date:`. Case does not matter, and ё and е are one letter; other letters match as typed. The part needs three letters in a row. `*вор`, `*дог*вор` and `*гов?р*` use the same index and are then checked word by word; a part found in too many messages is `query.too-large`, which `chat:`, `date:` or `*part*` avoid. Mail, transcripts and file text keep the word list and its `word*` hint.
|
|
58
|
+
- **A run's log keeps the progress of `messages sync`.** Each progress line is also a `sync.progress` event with its counts, whatever the output format, so `runs show` tells what a desktop app's bar showed and when ([reference](docs/REFERENCE.md)).
|
|
59
|
+
|
|
60
|
+
### Changed — may break callers
|
|
61
|
+
|
|
62
|
+
- **`Deal` has two more fields, `contactName` and `companyName` (`string | null`).** A caller that builds a whole
|
|
63
|
+
`Deal` adds both; the `deal` and `lead` entities require `contact_name` and `company_name`. The CSV export of deals
|
|
64
|
+
and leads has the two new columns after `organization`, so a reader that takes columns by position moves past them.
|
|
65
|
+
- **`*part*` in chat-message text no longer folds й/и or accents.** Through the word list, `*мои*` also found «мой» and `*cafe*` found «café»; through the trigram index the part matches as typed, except case and ё/е. Write the letter as the text has it, or search the whole word (`мой`), which still folds them.
|
|
66
|
+
- **CRM search no longer matches inside a word.** `cement` no longer finds `replacement`, nor «кто» «Вектор». A query
|
|
67
|
+
word shorter than four letters matches only a whole word.
|
|
68
|
+
- **`search all stage:won` skips deals and leads with the reason** instead of finding none and calling the answer
|
|
69
|
+
complete; so do `status:` and `pipeline:`. `deals list stage:<name>` lists them by stage.
|
|
70
|
+
|
|
71
|
+
### Fixed
|
|
72
|
+
|
|
73
|
+
- **A search over chats and mail together says when mail was left out.** Mail refused for a reason other than a messenger field (such as `*word*` over a large mailbox) used to drop out silently, so the answer looked complete; it is now listed under `skipped` with the reason.
|
|
74
|
+
- **`to:`, `cc:` and `bcc:` name themselves when nobody matches.** The error said `from:owner — nobody matches` for `to:owner`.
|
|
75
|
+
- **`list:` in a search without a mail account is refused** as `subject:` and `to:` are (`query.unsupported-field`, "list: is a mail field"), instead of finding nothing.
|
|
76
|
+
- **`search all` finds deals and leads by any form of a word, and by their company and contacts.** A query word
|
|
77
|
+
matches a stored word it begins or one of the same stem, so «поставки цемента» finds «Поставка цемента» and
|
|
78
|
+
`repairs` finds `Forklift repair`. A deal's or a lead's company name and its contacts' names, e-mails and phones are
|
|
79
|
+
searched too, never the owner's, and a CRM copy only by what its own CRM holds of them, so a locked profile learns
|
|
80
|
+
nothing of a person's other accounts; `+79161234567` finds `+7 916 123-45-67`. `found_by` stays `title` when the title
|
|
81
|
+
matched and is `words` when only the company or a contact did. `deals.find` gives each hit's `matched` parts. See
|
|
82
|
+
[ARCHITECTURE.md](docs/dev/ARCHITECTURE.md).
|
|
83
|
+
- **A misspelt CRM search is corrected once.** When nothing matches as typed, a word is corrected to the nearest
|
|
84
|
+
stored words, as messages search does, and those hits carry `match: "corrected"` and `corrections`. `--exact` turns
|
|
85
|
+
forms, word beginnings and correction off.
|
|
86
|
+
- **`messages sync --all` reports progress while a chat is read.** Its progress line on stderr came only when a chat was finished, so a chat of many paced pages showed the same count for minutes, and a desktop app's bar stood still at the first chat. Every page now updates `fetched`, with the chat totals of `--all`.
|
|
87
|
+
|
|
8
88
|
## 0.640.0 — 11.11.2026
|
|
9
89
|
|
|
10
90
|
### Added
|
|
@@ -10,4 +10,4 @@ export interface AnalysisResponse {
|
|
|
10
10
|
}
|
|
11
11
|
export type AnalysisRequest = (system: string, input: string, maxTokens: number) => Promise<AnalysisResponse>;
|
|
12
12
|
export declare const providerIdentity: (target: AnalysisProvider) => string;
|
|
13
|
-
export declare const openAnalysis: (target: AnalysisProvider, signal?: AbortSignal) => AnalysisRequest;
|
|
13
|
+
export declare const openAnalysis: (target: AnalysisProvider, signal?: AbortSignal, env?: NodeJS.ProcessEnv) => AnalysisRequest;
|
|
@@ -2,11 +2,12 @@ import { CliError } from "@wirecat/cli-base";
|
|
|
2
2
|
import { modelGateway } from "../models/index.js";
|
|
3
3
|
import { endpoint } from "./settings.js";
|
|
4
4
|
export const providerIdentity = (target) => `${target.provider}:${target.baseUrl.replace(/\/+$/, "")}`;
|
|
5
|
-
export const openAnalysis = (target, signal) => {
|
|
5
|
+
export const openAnalysis = (target, signal, env) => {
|
|
6
6
|
if (!endpoint(target.baseUrl))
|
|
7
7
|
throw new CliError("validation_error", "invalid analysis endpoint");
|
|
8
8
|
const gateway = modelGateway({
|
|
9
9
|
signal,
|
|
10
|
+
...(env ? { env } : {}),
|
|
10
11
|
resolve: () => target,
|
|
11
12
|
key: () => target.apiKey,
|
|
12
13
|
// The analysis command checks per-chat consent before each batch.
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { CliError } from "@wirecat/cli-base";
|
|
3
|
-
import {
|
|
4
|
-
import { modelGateway
|
|
3
|
+
import { aiImagesAllowed, aiLeavesComputer } from "../models/ai.js";
|
|
4
|
+
import { modelGateway } from "../models/index.js";
|
|
5
|
+
import { purposeModel } from "../models/purpose.js";
|
|
5
6
|
export const gatewayOcr = ({ app, settings, env, keyring, enabled, signal, fetch, key, }) => {
|
|
6
7
|
if (!enabled)
|
|
7
8
|
throw new CliError("permission_error", "API OCR needs an explicit OCR request");
|
|
8
|
-
const
|
|
9
|
-
if (!
|
|
10
|
-
throw new CliError("configuration_error", "set models.ocr.provider and models.ocr.model before API OCR");
|
|
11
|
-
|
|
9
|
+
const chosen = purposeModel(settings, "ocr", { app, env, keyring });
|
|
10
|
+
if (!chosen)
|
|
11
|
+
throw new CliError("configuration_error", "set models.ocr.provider and models.ocr.model, or choose an AI model with `models ai set`, before API OCR");
|
|
12
|
+
// The shared model's yes to pictures was given for it alone, at its address; a model elsewhere needs it here too.
|
|
13
|
+
if (chosen.shared && aiLeavesComputer(chosen.shared) && !aiImagesAllowed(chosen.shared))
|
|
14
|
+
throw new CliError("permission_error", "the AI model may not read pictures: allow it with `models ai set … --allow-remote`; nothing was sent", { reason: "ai.images-not-allowed" });
|
|
15
|
+
const { target } = chosen;
|
|
16
|
+
const { baseUrl } = target;
|
|
12
17
|
const identity = createHash("sha256")
|
|
13
18
|
.update(JSON.stringify([target.provider, target.model, baseUrl.replace(/\/+$/, "")]))
|
|
14
19
|
.digest("hex")
|
|
@@ -16,8 +21,8 @@ export const gatewayOcr = ({ app, settings, env, keyring, enabled, signal, fetch
|
|
|
16
21
|
const gateway = modelGateway({
|
|
17
22
|
resolve: () => target,
|
|
18
23
|
consent: () => enabled,
|
|
19
|
-
key: key ??
|
|
20
|
-
|
|
24
|
+
key: key ?? chosen.key,
|
|
25
|
+
env,
|
|
21
26
|
...(signal === undefined ? {} : { signal }),
|
|
22
27
|
...(fetch === undefined ? {} : { fetch }),
|
|
23
28
|
});
|
|
@@ -69,6 +69,8 @@ export interface LastRun {
|
|
|
69
69
|
reason?: string;
|
|
70
70
|
/** The `code` of the error the run printed, as run records keep it. */
|
|
71
71
|
errorCode?: string;
|
|
72
|
+
/** How long the CLI asked to wait before it is tried again (`retry.after_ms` of a `rate_limited` error). */
|
|
73
|
+
retryAfterMs?: number;
|
|
72
74
|
/** The first failure of the failures in a row, so "failing since" survives every retry. */
|
|
73
75
|
failingSince?: string;
|
|
74
76
|
/** Failed runs in a row; absent once a run succeeds. */
|
|
@@ -104,6 +106,7 @@ export type SkipReason = (typeof SKIP_REASONS)[keyof typeof SKIP_REASONS];
|
|
|
104
106
|
export declare const failureOf: (stderr: string, exitCode: number) => {
|
|
105
107
|
reason: string;
|
|
106
108
|
errorCode?: string;
|
|
109
|
+
retryAfterMs?: number;
|
|
107
110
|
};
|
|
108
111
|
/** The one-line reason `failureOf` keeps, for a timer that reads a run's stderr itself. */
|
|
109
112
|
export declare const reasonOf: (stderr: string, exitCode?: number) => string;
|
|
@@ -162,7 +165,8 @@ export declare const CREDENTIALS_UNREACHABLE = "credentials.unreachable";
|
|
|
162
165
|
*
|
|
163
166
|
* `untilUnlocked` is for the timer's run: a timer that catches up at boot runs before the login unlocks the
|
|
164
167
|
* keyring, so a run that fails for that reason is tried again, a minute then up to 15 minutes apart, for up to
|
|
165
|
-
* 12 hours. A
|
|
168
|
+
* 12 hours. A run the provider asked to wait (`rate_limited` with `retry.after_ms`, up to 6 hours) waits that long
|
|
169
|
+
* and runs once more. A schedule that repeats every few minutes is left to its next tick; a run by hand fails at once.
|
|
166
170
|
*/
|
|
167
171
|
export declare const runSchedule: (app: AppIdentity, system: ServerSystem, env: NodeJS.ProcessEnv, file: string, { now, timer, signal, killAfterMs, untilUnlocked, wait, agentRuns, agentInput, ownerLanguage, reportTemplates, skipRepeatedInput, routes: chosen, }?: {
|
|
168
172
|
now?: () => Date;
|
|
@@ -82,9 +82,15 @@ const REASON_ID = /^[a-z0-9][a-z0-9.-]{0,79}$/;
|
|
|
82
82
|
export const failureOf = (stderr, exitCode) => {
|
|
83
83
|
for (const line of stderr.split("\n").reverse()) {
|
|
84
84
|
try {
|
|
85
|
-
const { code, reason } = JSON.parse(line).error ??
|
|
85
|
+
const { code, reason, retry } = JSON.parse(line).error ??
|
|
86
|
+
{};
|
|
86
87
|
if (errorCodes.includes(code) && typeof reason === "string" && REASON_ID.test(reason)) {
|
|
87
|
-
|
|
88
|
+
const after = retry?.after_ms;
|
|
89
|
+
return {
|
|
90
|
+
reason: `${code} (${reason})`,
|
|
91
|
+
errorCode: code,
|
|
92
|
+
...(code === "rate_limited" && typeof after === "number" && after > 0 ? { retryAfterMs: after } : {}),
|
|
93
|
+
};
|
|
88
94
|
}
|
|
89
95
|
}
|
|
90
96
|
catch { }
|
|
@@ -282,6 +288,9 @@ const LOCKED_FIRST_WAIT_MS = 60_000;
|
|
|
282
288
|
const LOCKED_LONGEST_WAIT_MS = 15 * 60_000;
|
|
283
289
|
/** A night's catch-up waits for the morning's login; past that the run fails as it is. */
|
|
284
290
|
const LOCKED_GIVE_UP_MS = 12 * 60 * 60_000;
|
|
291
|
+
/** A wait the provider asked for that a daily run sits out and then runs once more; a longer one fails for the day. */
|
|
292
|
+
const RATE_LIMITED_WAIT_AT_MOST_MS = 6 * 60 * 60_000;
|
|
293
|
+
const RATE_LIMITED_MARGIN_MS = 30_000;
|
|
285
294
|
const lockedOut = (last) => last.reason?.endsWith(`(${CREDENTIALS_UNREACHABLE})`) === true;
|
|
286
295
|
const pause = (ms, signal) => new Promise((resolve) => {
|
|
287
296
|
if (signal?.aborted)
|
|
@@ -301,7 +310,8 @@ const pause = (ms, signal) => new Promise((resolve) => {
|
|
|
301
310
|
*
|
|
302
311
|
* `untilUnlocked` is for the timer's run: a timer that catches up at boot runs before the login unlocks the
|
|
303
312
|
* keyring, so a run that fails for that reason is tried again, a minute then up to 15 minutes apart, for up to
|
|
304
|
-
* 12 hours. A
|
|
313
|
+
* 12 hours. A run the provider asked to wait (`rate_limited` with `retry.after_ms`, up to 6 hours) waits that long
|
|
314
|
+
* and runs once more. A schedule that repeats every few minutes is left to its next tick; a run by hand fails at once.
|
|
305
315
|
*/
|
|
306
316
|
export const runSchedule = async (app, system, env, file, { now = () => new Date(), timer, signal, killAfterMs = KILL_AFTER_MS, untilUnlocked = false, wait = pause, agentRuns = [], agentInput, ownerLanguage = async () => "ru", reportTemplates, skipRepeatedInput = false, routes: chosen, } = {}) => {
|
|
307
317
|
const schedule = readSchedule(file);
|
|
@@ -339,6 +349,21 @@ export const runSchedule = async (app, system, env, file, { now = () => new Date
|
|
|
339
349
|
break;
|
|
340
350
|
last = again;
|
|
341
351
|
}
|
|
352
|
+
const asked = last.errorCode === "rate_limited" ? last.retryAfterMs : undefined;
|
|
353
|
+
if (retries && asked !== undefined && asked <= RATE_LIMITED_WAIT_AT_MOST_MS && !signal?.aborted) {
|
|
354
|
+
await wait(asked + RATE_LIMITED_MARGIN_MS, signal);
|
|
355
|
+
if (!signal?.aborted) {
|
|
356
|
+
const again = await attemptSchedule(app, system, env, schedule, folder, {
|
|
357
|
+
now,
|
|
358
|
+
signal,
|
|
359
|
+
killAfterMs,
|
|
360
|
+
agentRuns,
|
|
361
|
+
agentInput,
|
|
362
|
+
});
|
|
363
|
+
if (!("repeated" in again))
|
|
364
|
+
last = again;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
342
367
|
const { exitCode, output } = last;
|
|
343
368
|
const errors = agent ? output.replace(/\.md$/, ".log") : output;
|
|
344
369
|
if (agent && exitCode === 0)
|
|
@@ -10,13 +10,13 @@ export declare const calendarTools: ({
|
|
|
10
10
|
inputSchema: {
|
|
11
11
|
type: string;
|
|
12
12
|
properties: {
|
|
13
|
-
limit?: undefined;
|
|
14
13
|
account_id: {
|
|
15
14
|
type: string;
|
|
16
15
|
minimum: number;
|
|
17
16
|
};
|
|
18
17
|
query?: undefined;
|
|
19
18
|
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;
|
|
49
48
|
query?: undefined;
|
|
50
49
|
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;
|
|
62
61
|
query?: undefined;
|
|
63
62
|
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;
|
|
84
83
|
account_id: {
|
|
85
84
|
type: string;
|
|
86
85
|
minimum: number;
|
|
87
86
|
};
|
|
88
87
|
query?: undefined;
|
|
89
88
|
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;
|
|
119
118
|
query?: undefined;
|
|
120
119
|
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;
|
|
132
131
|
query?: undefined;
|
|
133
132
|
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;
|
|
154
153
|
account_id: {
|
|
155
154
|
type: string;
|
|
156
155
|
minimum: number;
|
|
157
156
|
};
|
|
158
157
|
query?: undefined;
|
|
159
158
|
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;
|
|
189
188
|
query?: undefined;
|
|
190
189
|
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;
|
|
202
201
|
query?: undefined;
|
|
203
202
|
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;
|
|
224
223
|
account_id: {
|
|
225
224
|
type: string;
|
|
226
225
|
minimum: number;
|
|
227
226
|
};
|
|
228
227
|
query?: undefined;
|
|
229
228
|
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;
|
|
259
258
|
query?: undefined;
|
|
260
259
|
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;
|
|
272
271
|
query?: undefined;
|
|
273
272
|
timezone?: undefined;
|
|
273
|
+
limit?: undefined;
|
|
274
274
|
page?: undefined;
|
|
275
275
|
event?: undefined;
|
|
276
276
|
account_id?: undefined;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
2
|
import { annotate } from "@wirecat/cli-base/commands";
|
|
3
3
|
import { Command } from "commander";
|
|
4
|
-
import { AI_PROVIDERS, aiBaseUrl, aiImagesAllowed, aiKeys,
|
|
4
|
+
import { AI_PROVIDERS, aiBaseUrl, aiImagesAllowed, aiKeys, aiLeavesComputer, aiOrigin, aiSettingOf, aiSettingPath, aiTakesKey, checkAi, readAiSetting, writeAiSetting, } from "../models/ai.js";
|
|
5
|
+
import { localOnly, localOnlyRefusal } from "../models/local-only.js";
|
|
5
6
|
import { agentOf } from "../runs/run-context.js";
|
|
6
7
|
import { readSecret } from "../terminal/prompt.js";
|
|
7
8
|
import { environmentOf } from "./context.js";
|
|
@@ -19,7 +20,7 @@ const view = (app, options, setting) => {
|
|
|
19
20
|
images: false,
|
|
20
21
|
key: { stored: false, source: null },
|
|
21
22
|
};
|
|
22
|
-
const key =
|
|
23
|
+
const key = aiTakesKey(setting) ? aiKeys(app, options.env(), options.keyring).read(aiOrigin(setting)) : undefined;
|
|
23
24
|
return {
|
|
24
25
|
provider: setting.provider,
|
|
25
26
|
model: setting.model,
|
|
@@ -90,8 +91,10 @@ export const aiModelCommand = (app, options) => {
|
|
|
90
91
|
baseUrl: given.baseUrl,
|
|
91
92
|
allowImages: given.allowRemote,
|
|
92
93
|
});
|
|
94
|
+
if (aiLeavesComputer(setting) && localOnly(env))
|
|
95
|
+
throw localOnlyRefusal("what WireCat sends to its AI model", new URL(aiBaseUrl(setting)).host);
|
|
93
96
|
if (given.secretStdin) {
|
|
94
|
-
if (!
|
|
97
|
+
if (!aiTakesKey(setting))
|
|
95
98
|
throw new CliError("validation_error", "Ollama on this computer takes no key");
|
|
96
99
|
const input = options.stdin?.();
|
|
97
100
|
const secret = (await readSecret("API key: ", input ? { input } : {})).trim();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
|
-
import { endpoint } from "../analysis/settings.js";
|
|
3
2
|
import { embeddingKeys, endpointKeyName } from "../embeddings/keys.js";
|
|
3
|
+
import { sharedModel } from "../models/ai.js";
|
|
4
|
+
import { refuseModelAddress } from "../models/local-only.js";
|
|
4
5
|
export const analysisChoice = (options, app, settings, env, keyring) => {
|
|
5
6
|
const configured = { ...settings.models?.default, ...settings.models?.analysis };
|
|
6
7
|
// `off` and no provider both leave the linking to the agent.
|
|
@@ -8,8 +9,24 @@ export const analysisChoice = (options, app, settings, env, keyring) => {
|
|
|
8
9
|
const override = (options.analysisProvider !== undefined && options.analysisProvider !== saved) ||
|
|
9
10
|
(options.baseUrl !== undefined && options.baseUrl.replace(/\/+$/, "") !== configured.base_url?.replace(/\/+$/, ""));
|
|
10
11
|
const provider = options.analysisProvider ?? (saved !== "agent" ? saved : options.baseUrl ? "openai" : "agent");
|
|
12
|
+
// Nothing configured for linking (not `off`): the AI model the owner chose for every tool.
|
|
13
|
+
const shared = provider === "agent" && configured.provider === undefined && options.analysisProvider === undefined
|
|
14
|
+
? sharedModel({ app, env, keyring })
|
|
15
|
+
: undefined;
|
|
16
|
+
if (shared) {
|
|
17
|
+
const { target, key } = shared;
|
|
18
|
+
refuseModelAddress(env, target.baseUrl, "chat messages");
|
|
19
|
+
if (target.provider !== "openai" && target.provider !== "anthropic")
|
|
20
|
+
throw new CliError("validation_error", "analysis provider must be agent, openai or anthropic");
|
|
21
|
+
return {
|
|
22
|
+
provider: target.provider,
|
|
23
|
+
model: options.model ?? target.model,
|
|
24
|
+
baseUrl: target.baseUrl,
|
|
25
|
+
...(key ? { apiKey: key } : {}),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
11
28
|
if (provider === "agent")
|
|
12
|
-
throw new CliError("validation_error", "models.analysis.provider is off or not set, so the agent links the chat: use your linking skill, or set
|
|
29
|
+
throw new CliError("validation_error", "models.analysis.provider is off or not set and no AI model is chosen, so the agent links the chat: use your linking skill, choose a model with `memo models ai set`, or set models.analysis.provider to openai or anthropic to use --analyze");
|
|
13
30
|
if (provider !== "openai" && provider !== "anthropic")
|
|
14
31
|
throw new CliError("validation_error", "analysis provider must be agent, openai or anthropic");
|
|
15
32
|
const model = options.model ?? (override ? undefined : configured.model);
|
|
@@ -17,8 +34,7 @@ export const analysisChoice = (options, app, settings, env, keyring) => {
|
|
|
17
34
|
throw new CliError("validation_error", "set models.analysis.model or give --model before --analyze");
|
|
18
35
|
const customUrl = options.baseUrl ?? (override ? undefined : configured.base_url);
|
|
19
36
|
const baseUrl = customUrl ?? (provider === "anthropic" ? "https://api.anthropic.com" : "https://api.openai.com/v1");
|
|
20
|
-
|
|
21
|
-
throw new CliError("validation_error", "use an HTTP/S analysis endpoint without credentials, query or fragment");
|
|
37
|
+
refuseModelAddress(env, baseUrl, "chat messages");
|
|
22
38
|
const keyName = customUrl === undefined ? provider : endpointKeyName(baseUrl);
|
|
23
39
|
const apiKey = embeddingKeys(app, env, keyring).read(keyName)?.key;
|
|
24
40
|
if (!apiKey && customUrl === undefined)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
2
|
import { annotate } from "@wirecat/cli-base/commands";
|
|
3
3
|
import { Command } from "commander";
|
|
4
|
+
import { refuseModelAddress } from "../models/local-only.js";
|
|
4
5
|
import { agentOf } from "../runs/run-context.js";
|
|
5
6
|
import { enrichmentState } from "../services/enrichment.js";
|
|
6
7
|
import { ENRICHMENT_PROVIDERS, enrichmentEndpoint, isEnrichmentProvider, readEnrichmentSetting, writeEnrichmentSetting, } from "../services/enrichment-setting.js";
|
|
@@ -65,6 +66,7 @@ export const enrichmentConsentsCommand = (app, options) => {
|
|
|
65
66
|
model: given.model,
|
|
66
67
|
...(given.baseUrl === undefined ? {} : { base_url: given.baseUrl }),
|
|
67
68
|
};
|
|
69
|
+
refuseModelAddress(env, enrichmentEndpoint(chosen), "records to enrich");
|
|
68
70
|
const state = await withStore(env, (store) => enrichmentState(store, env, chosen, { app, ...(options.keyring ? { keyring: options.keyring } : {}) }));
|
|
69
71
|
const consent = consentWording(app.command, state);
|
|
70
72
|
if (!given.yes) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import type { AppIdentity } from "../ports/app.js";
|
|
3
|
+
import { type Body } from "./envelope.js";
|
|
4
|
+
export interface LocalOnlyCommandOptions {
|
|
5
|
+
env: () => NodeJS.ProcessEnv;
|
|
6
|
+
output: (answer: Body, command: Command) => void;
|
|
7
|
+
diagnostic: (line: string) => void;
|
|
8
|
+
}
|
|
9
|
+
/** `models local-only`: one switch that keeps every model call on this computer, and where each feature sends data. */
|
|
10
|
+
export declare const localOnlyCommand: (app: AppIdentity, options: LocalOnlyCommandOptions) => Command;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { CliError } from "@wirecat/cli-base";
|
|
2
|
+
import { annotate } from "@wirecat/cli-base/commands";
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
import { chosenTextModel } from "../embeddings/models.js";
|
|
5
|
+
import { aiBaseUrl, aiLeavesComputer, aiSettingPath, readAiSetting } from "../models/ai.js";
|
|
6
|
+
import { onThisComputer } from "../models/endpoint.js";
|
|
7
|
+
import { readLocalOnly, writeLocalOnly } from "../models/local-only.js";
|
|
8
|
+
import { agentOf } from "../runs/run-context.js";
|
|
9
|
+
import { enrichmentEndpoint, readEnrichmentSetting } from "../services/enrichment-setting.js";
|
|
10
|
+
import { readHarderSetting } from "../services/search-harder.js";
|
|
11
|
+
import { environmentOf } from "./context.js";
|
|
12
|
+
import { grantsAuthority, LOCAL_READ, LOCAL_WRITE } from "./effects.js";
|
|
13
|
+
import { itemOf } from "./envelope.js";
|
|
14
|
+
const placeOf = (address) => (onThisComputer(address) ? "this-computer" : "elsewhere");
|
|
15
|
+
const read = (get) => {
|
|
16
|
+
try {
|
|
17
|
+
return get();
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const features = (command, env, on) => {
|
|
24
|
+
const ai = read(() => readAiSetting(aiSettingPath(env)));
|
|
25
|
+
const aiAddress = ai ? aiBaseUrl(ai) : null;
|
|
26
|
+
const aiWhere = ai ? (aiLeavesComputer(ai) ? "elsewhere" : "this-computer") : "off";
|
|
27
|
+
const enrichment = read(() => readEnrichmentSetting(env));
|
|
28
|
+
const enrichmentAddress = enrichment ? enrichmentEndpoint(enrichment) : null;
|
|
29
|
+
const harder = read(() => readHarderSetting(env));
|
|
30
|
+
const harderAddress = harder ? enrichmentEndpoint(harder) : null;
|
|
31
|
+
const blocked = (where) => on && where === "elsewhere";
|
|
32
|
+
const one = (id, title, where, address, note) => ({
|
|
33
|
+
id,
|
|
34
|
+
title,
|
|
35
|
+
where,
|
|
36
|
+
address,
|
|
37
|
+
refused: blocked(where),
|
|
38
|
+
note,
|
|
39
|
+
});
|
|
40
|
+
return [
|
|
41
|
+
one("ai_model", "AI model", aiWhere, aiAddress, `\`${command} models ai set\` chooses it`),
|
|
42
|
+
one("enrichment", "Rewrite records for better search", enrichmentAddress ? placeOf(enrichmentAddress) : "off", enrichmentAddress, `\`${command} models consents\``),
|
|
43
|
+
one("search_harder", "Search harder", harderAddress ? placeOf(harderAddress) : "off", harderAddress, `\`${command} models search-consents\``),
|
|
44
|
+
one("search_by_meaning", "Search by meaning and picture search", "this-computer", null, `the text model ${chosenTextModel(env).id}; a profile that sets embeddingProvider openai sends text out`),
|
|
45
|
+
...[
|
|
46
|
+
["chat_linking", "Chat linking (--analyze)", "analysis"],
|
|
47
|
+
["replies", "Reply drafts", "replies"],
|
|
48
|
+
["attachment_ocr", "Picture text in attachments (--ocr)", "ocr"],
|
|
49
|
+
].map(([id, title, purpose]) => one(id, title, aiWhere, aiAddress, `the AI model, unless a messenger profile sets models.${purpose}; that address is checked when it is called`)),
|
|
50
|
+
one("voice_messages", "Voice messages", on ? "this-computer" : "elsewhere", null, on
|
|
51
|
+
? "the downloaded speech model only"
|
|
52
|
+
: "the downloaded speech model first, else the messenger's own service; OpenAI only when asked by name"),
|
|
53
|
+
one("digest", "Digest", "agent", null, "runs Claude Code or Codex: local only if that agent runs a local model"),
|
|
54
|
+
one("agents", "Agents over MCP", "agent", null, "whatever the agent reads goes to the agent's model"),
|
|
55
|
+
];
|
|
56
|
+
};
|
|
57
|
+
const state = (command, env) => {
|
|
58
|
+
const setting = readLocalOnly(env);
|
|
59
|
+
const on = setting?.on === true;
|
|
60
|
+
return { on, since: on ? (setting?.at ?? null) : null, features: features(command, env, on) };
|
|
61
|
+
};
|
|
62
|
+
/** `models local-only`: one switch that keeps every model call on this computer, and where each feature sends data. */
|
|
63
|
+
export const localOnlyCommand = (app, options) => {
|
|
64
|
+
const local = annotate(new Command("local-only"), { effects: LOCAL_READ }).description("keep every model call on this computer: refuse any address that is not, in every WireCat tool");
|
|
65
|
+
annotate(local.command("show"), {
|
|
66
|
+
effects: LOCAL_READ,
|
|
67
|
+
output: { entity: "local_only" },
|
|
68
|
+
examples: [`${app.command} models local-only show`],
|
|
69
|
+
})
|
|
70
|
+
.summary("whether local only is on, and where each feature sends data")
|
|
71
|
+
.description("whether local only is on, and for each feature whether its data stays on this computer")
|
|
72
|
+
.action(function () {
|
|
73
|
+
options.output(itemOf(state(app.command, options.env())), this);
|
|
74
|
+
});
|
|
75
|
+
grantsAuthority(annotate(local.command("set"), {
|
|
76
|
+
effects: LOCAL_WRITE,
|
|
77
|
+
mcp: false,
|
|
78
|
+
output: { entity: "local_only" },
|
|
79
|
+
examples: [`${app.command} models local-only set on`, `${app.command} models local-only set off`],
|
|
80
|
+
}))
|
|
81
|
+
.description("turn local only on or off; only you turn it off")
|
|
82
|
+
.argument("<state>", "on or off")
|
|
83
|
+
.option("--from-app", "you did this in WireCat Desktop")
|
|
84
|
+
.action(function (given) {
|
|
85
|
+
if (given !== "on" && given !== "off")
|
|
86
|
+
throw new CliError("validation_error", "say on or off");
|
|
87
|
+
const env = options.env();
|
|
88
|
+
// An agent that turned it off would let records out for the owner; turning it on only refuses more.
|
|
89
|
+
if (given === "off" && (environmentOf(this).agent || agentOf(env)) && !this.opts().fromApp)
|
|
90
|
+
throw new CliError("permission_error", "only the owner turns local only off, not an agent", {
|
|
91
|
+
reason: "local-only.owner-only",
|
|
92
|
+
});
|
|
93
|
+
const before = readLocalOnly(env)?.on === true;
|
|
94
|
+
if (before !== (given === "on"))
|
|
95
|
+
writeLocalOnly(env, given === "on");
|
|
96
|
+
const now = state(app.command, env);
|
|
97
|
+
const out = now.features.filter((one) => one.refused).map((one) => one.title);
|
|
98
|
+
if (given === "on" && out.length)
|
|
99
|
+
options.diagnostic(`local only is on; these now refuse to send until they use this computer: ${out.join(", ")}`);
|
|
100
|
+
options.output(itemOf({ ...now, changed: before !== (given === "on") }), this);
|
|
101
|
+
});
|
|
102
|
+
return local;
|
|
103
|
+
};
|
|
@@ -7,6 +7,7 @@ import { Command } from "commander";
|
|
|
7
7
|
import { parseDuration } from "../../domain/duration.js";
|
|
8
8
|
import { isCliFailure } from "../../errors/failures.js";
|
|
9
9
|
import { envName } from "../../ports/app.js";
|
|
10
|
+
import { runEvent } from "../../runs/scope.js";
|
|
10
11
|
import { FETCHING } from "../../services/archive.js";
|
|
11
12
|
import { JOBS_QUERY, jobItems } from "../../services/job-query.js";
|
|
12
13
|
import { dateWindow } from "../../services/moment.js";
|
|
@@ -172,6 +173,8 @@ export const syncCommand = (messenger) => {
|
|
|
172
173
|
const stop = stopOnSignal(this);
|
|
173
174
|
// A background job keeps its log as it was; its progress is the job file.
|
|
174
175
|
const progress = syncProgress(stepLines(context.streams.diagnostic, !jobId && context.format !== "pretty"));
|
|
176
|
+
// One chat of --all can take minutes of paced pages: its pages move the count, not only its end.
|
|
177
|
+
let walked = { chats: 0, done: 0, fetched: 0 };
|
|
175
178
|
try {
|
|
176
179
|
const options = {
|
|
177
180
|
limit,
|
|
@@ -189,8 +192,13 @@ export const syncCommand = (messenger) => {
|
|
|
189
192
|
updateJob(jobs, jobId, { progress: { ...page, at: new Date().toISOString() } });
|
|
190
193
|
if (chat !== undefined)
|
|
191
194
|
progress({ chats: null, chats_done: null, fetched: page.fetched });
|
|
195
|
+
else
|
|
196
|
+
progress({ chats: walked.chats, chats_done: walked.done, fetched: walked.fetched + page.fetched });
|
|
197
|
+
},
|
|
198
|
+
onChat: (counts) => {
|
|
199
|
+
walked = counts;
|
|
200
|
+
progress({ chats: counts.chats, chats_done: counts.done, fetched: counts.fetched }, counts.done === 0 || counts.done === counts.chats);
|
|
192
201
|
},
|
|
193
|
-
onChat: ({ chats, done, fetched }) => progress({ chats, chats_done: done, fetched }, done === 0 || done === chats),
|
|
194
202
|
};
|
|
195
203
|
const result = await context.withServices((services) => chat === undefined ? services.archive.fetchAll(options) : services.archive.fetch(chat, options));
|
|
196
204
|
if (jobId)
|
|
@@ -258,6 +266,7 @@ const PROGRESS_EVERY_MS = 500;
|
|
|
258
266
|
/**
|
|
259
267
|
* `messages sync`'s progress for a window to draw a bar by: counts only, because the lines reach a desktop app and
|
|
260
268
|
* its logs — never a chat's id or title. `always` keeps the first and the last line of `--all` through the throttle.
|
|
269
|
+
* The run's log gets the same counts as `sync.progress`, whatever the output format.
|
|
261
270
|
*/
|
|
262
271
|
const syncProgress = (emit) => {
|
|
263
272
|
let last = Number.NEGATIVE_INFINITY;
|
|
@@ -267,6 +276,12 @@ const syncProgress = (emit) => {
|
|
|
267
276
|
return;
|
|
268
277
|
last = now;
|
|
269
278
|
emit({ event: "progress", step: "sync", ...counts });
|
|
279
|
+
runEvent({
|
|
280
|
+
event: "progress",
|
|
281
|
+
operation: "sync.progress",
|
|
282
|
+
kind: "progress",
|
|
283
|
+
counts: Object.fromEntries(Object.entries(counts).filter((entry) => entry[1] !== null)),
|
|
284
|
+
});
|
|
270
285
|
};
|
|
271
286
|
};
|
|
272
287
|
/**
|