@wirecat/cli-core 0.748.0 → 0.749.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
CHANGED
|
@@ -5,6 +5,18 @@ 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.749.0 — 24.11.2026
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **One bad part no longer costs the whole report.** A section, item or health entry that fails the check is left
|
|
13
|
+
out, and the rest is delivered with a last line saying how many were left out ("⚠️ Не показано из-за ошибки
|
|
14
|
+
формата: 2"). `last.json` names them under `report.dropped`, with the reason `report.items-dropped`. Only the
|
|
15
|
+
document's own fields (the JSON, `kind`, `date`, the `sections` list, `tasks`, `scope`) still refuse it. The owner's
|
|
16
|
+
morning digest was lost whole on 2026-11-17 (two meetings) and 2026-11-21..24 (one reply).
|
|
17
|
+
- **A time without an offset is read as local time.** An agent writes a meeting's hour as `2026-11-17T10:00:00`; that
|
|
18
|
+
was refused.
|
|
19
|
+
|
|
8
20
|
## 0.748.0 — 24.11.2026
|
|
9
21
|
|
|
10
22
|
### Added
|
|
@@ -7,6 +7,7 @@ export type ReportChannel = (typeof REPORT_CHANNELS)[number];
|
|
|
7
7
|
export type MessageView = ReportView | GapsView | NoticeView;
|
|
8
8
|
export declare const REPORT_REASONS: {
|
|
9
9
|
readonly invalid: "delivery.report-invalid";
|
|
10
|
+
readonly dropped: "report.items-dropped";
|
|
10
11
|
readonly templateFailed: "report.template-failed";
|
|
11
12
|
readonly templateTags: "report.template-tags";
|
|
12
13
|
};
|
|
@@ -58,6 +59,8 @@ export interface ReportRun {
|
|
|
58
59
|
leaks: number;
|
|
59
60
|
/** The path of the first field that failed the check; nothing was shown. */
|
|
60
61
|
invalid?: string;
|
|
62
|
+
/** The sections, items and health entries left out because they failed the check; the rest was shown. */
|
|
63
|
+
dropped?: string[];
|
|
61
64
|
reasons?: string[];
|
|
62
65
|
}
|
|
63
66
|
export interface PreparedReport {
|
|
@@ -10,6 +10,7 @@ const DEFAULT_LANGUAGE = "en";
|
|
|
10
10
|
const LIMITS = { parse: 65_536, memory: 4_000_000, milliseconds: 1_000 };
|
|
11
11
|
export const REPORT_REASONS = {
|
|
12
12
|
invalid: "delivery.report-invalid",
|
|
13
|
+
dropped: "report.items-dropped",
|
|
13
14
|
templateFailed: "report.template-failed",
|
|
14
15
|
templateTags: "report.template-tags",
|
|
15
16
|
};
|
|
@@ -307,6 +308,24 @@ const INVALID_LINES = {
|
|
|
307
308
|
ru: "Сводка не собралась: ошибка формата. Подробности в WireCat.",
|
|
308
309
|
en: "The report could not be built: format error. Details in WireCat.",
|
|
309
310
|
};
|
|
311
|
+
const DROPPED_LINES = {
|
|
312
|
+
ru: (count) => `⚠️ Не показано из-за ошибки формата: ${count}. Подробности в WireCat.`,
|
|
313
|
+
en: (count) => `⚠️ Left out for a format error: ${count}. Details in WireCat.`,
|
|
314
|
+
};
|
|
315
|
+
/** The line after a report that lost parts to the check, so a short digest is never read as a whole one. */
|
|
316
|
+
const withDropped = (rendered, line) => {
|
|
317
|
+
if (!line)
|
|
318
|
+
return rendered;
|
|
319
|
+
const last = rendered.telegram.at(-1) ?? "";
|
|
320
|
+
const note = escapeHtml(line);
|
|
321
|
+
const joined = last ? `${last}\n\n${note}` : note;
|
|
322
|
+
const telegram = fits(joined) ? [...rendered.telegram.slice(0, -1), joined] : [...rendered.telegram, note];
|
|
323
|
+
const paragraph = `<p>${note}</p>`;
|
|
324
|
+
const email = rendered.email.trimEnd().endsWith("</div>")
|
|
325
|
+
? rendered.email.replace(/<\/div>\s*$/, `${paragraph}\n</div>`)
|
|
326
|
+
: `${rendered.email}${paragraph}`;
|
|
327
|
+
return { telegram, email, text: `${rendered.text}\n\n${line}`, terminal: `${rendered.terminal}\n\n${line}` };
|
|
328
|
+
};
|
|
310
329
|
/**
|
|
311
330
|
* A run's answer rendered for every route, or `undefined` when it is not a report. An invalid report becomes one
|
|
312
331
|
* line in the owner's language and is never shown raw.
|
|
@@ -352,16 +371,23 @@ export const prepareReport = async (answer, { language, now, timeZone, templates
|
|
|
352
371
|
...(renderings.some((one) => one.templateTags > 0) ? [REPORT_REASONS.templateTags] : []),
|
|
353
372
|
];
|
|
354
373
|
const title = text.text.split("\n")[0] ?? "";
|
|
374
|
+
const { dropped } = parsed;
|
|
375
|
+
if (dropped.length)
|
|
376
|
+
reasons.push(REPORT_REASONS.dropped);
|
|
377
|
+
const lineOf = DROPPED_LINES[shipped] ?? DROPPED_LINES[DEFAULT_LANGUAGE];
|
|
378
|
+
const shown = withDropped({ telegram: telegram.parts, email: email.text, text: text.text, terminal: terminal.text }, dropped.length ? lineOf(dropped.length) : undefined);
|
|
355
379
|
return {
|
|
356
|
-
|
|
357
|
-
email: email.text,
|
|
358
|
-
text: text.text,
|
|
359
|
-
terminal: terminal.text,
|
|
380
|
+
...shown,
|
|
360
381
|
document: `${JSON.stringify(reportDocument(parsed.report), null, 2)}\n`,
|
|
361
382
|
subject: title,
|
|
362
383
|
notice: [title, parsed.report.summary].filter(Boolean).join("\n"),
|
|
363
384
|
invalid: false,
|
|
364
|
-
run: {
|
|
385
|
+
run: {
|
|
386
|
+
language: shipped,
|
|
387
|
+
leaks: parsed.leaks,
|
|
388
|
+
...(dropped.length ? { dropped } : {}),
|
|
389
|
+
...(reasons.length ? { reasons } : {}),
|
|
390
|
+
},
|
|
365
391
|
};
|
|
366
392
|
};
|
|
367
393
|
const templateOf = (templates, channel) => {
|
|
@@ -100,13 +100,14 @@ export declare const isReportAnswer: (answer: string) => boolean;
|
|
|
100
100
|
export type ParsedReport = {
|
|
101
101
|
report: Report;
|
|
102
102
|
leaks: number;
|
|
103
|
+
dropped: string[];
|
|
103
104
|
} | {
|
|
104
105
|
invalid: string;
|
|
105
106
|
};
|
|
106
107
|
/**
|
|
107
108
|
* A run's answer as a report: one JSON object, bare or as the only fenced `json` block. Text that is neither is not a
|
|
108
|
-
* report (`undefined`) and keeps the Markdown path; a JSON answer
|
|
109
|
-
* of the first field that failed, and is never shown
|
|
109
|
+
* report (`undefined`) and keeps the Markdown path; a JSON answer whose own fields fail the check is `invalid`, with
|
|
110
|
+
* the path of the first field that failed, and is never shown; a part that fails is left out and named in `dropped`. `trusted` is a document a command built from the store: its
|
|
110
111
|
* strings are the owner's data, such as a CRM title `follow_up`, and lose nothing to the leak patterns.
|
|
111
112
|
*/
|
|
112
113
|
export declare const parseReport: (answer: string, trusted?: boolean) => ParsedReport | undefined;
|
|
@@ -46,7 +46,8 @@ export const withoutLeaks = (text) => {
|
|
|
46
46
|
class Invalid extends Error {
|
|
47
47
|
}
|
|
48
48
|
const DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
49
|
-
|
|
49
|
+
// No offset is the machine's local time, as `Date.parse` reads it: agents write a meeting's "10:00" that way.
|
|
50
|
+
const DATE_TIME = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?$/;
|
|
50
51
|
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
51
52
|
const oneOf = (values, value, at) => {
|
|
52
53
|
if (!values.includes(value))
|
|
@@ -139,10 +140,26 @@ const tasksOf = (value) => {
|
|
|
139
140
|
const cut = (text, limit) => (text.length <= limit ? text : `${text.slice(0, limit - 1).trimEnd()}…`);
|
|
140
141
|
/**
|
|
141
142
|
* Checks a parsed document and keeps what the renderers may show. Any agent string loses what `withoutLeaks` finds
|
|
142
|
-
* and is cut to its limit; a required field left empty by that
|
|
143
|
+
* and is cut to its limit; a required field left empty by that fails its item, as a missing one does. A section,
|
|
144
|
+
* item or health entry that fails is left out and named in `dropped`: one undated reply must not cost the whole
|
|
145
|
+
* digest. Only the document's own fields (format, kind, date, the sections list, tasks, scope) refuse it.
|
|
143
146
|
*/
|
|
144
147
|
const checked = (document, trusted) => {
|
|
145
148
|
let leaks = 0;
|
|
149
|
+
const dropped = [];
|
|
150
|
+
const kept = (list, at, check) => list.flatMap((one, index) => {
|
|
151
|
+
const before = leaks;
|
|
152
|
+
try {
|
|
153
|
+
return [check(one, at(index))];
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
if (!(error instanceof Invalid))
|
|
157
|
+
throw error;
|
|
158
|
+
leaks = before;
|
|
159
|
+
dropped.push(error.message);
|
|
160
|
+
return [];
|
|
161
|
+
}
|
|
162
|
+
});
|
|
146
163
|
const text = (value, field, at) => {
|
|
147
164
|
if (value === undefined || value === null)
|
|
148
165
|
return null;
|
|
@@ -163,15 +180,13 @@ const checked = (document, trusted) => {
|
|
|
163
180
|
throw new Invalid("date");
|
|
164
181
|
if (!Array.isArray(document.sections))
|
|
165
182
|
throw new Invalid("sections");
|
|
166
|
-
const sections = document.sections
|
|
167
|
-
const at = `sections[${s}]`;
|
|
183
|
+
const sections = kept(document.sections, (s) => `sections[${s}]`, (section, at) => {
|
|
168
184
|
if (!isObject(section) || !Array.isArray(section.items))
|
|
169
185
|
throw new Invalid(at);
|
|
170
186
|
return {
|
|
171
187
|
kind: oneOf(SECTION_KINDS, section.kind, `${at}.kind`),
|
|
172
188
|
more: section.more === undefined || section.more === null ? 0 : whole(section.more, `${at}.more`),
|
|
173
|
-
items: section.items.
|
|
174
|
-
const where = `${at}.items[${i}]`;
|
|
189
|
+
items: kept(section.items, (i) => `${at}.items[${i}]`, (item, where) => {
|
|
175
190
|
if (!isObject(item))
|
|
176
191
|
throw new Invalid(where);
|
|
177
192
|
const type = oneOf(ITEM_TYPES, item.type, `${where}.type`);
|
|
@@ -211,8 +226,7 @@ const checked = (document, trusted) => {
|
|
|
211
226
|
date: document.date,
|
|
212
227
|
summary: text(document.summary, "summary", "summary"),
|
|
213
228
|
sections,
|
|
214
|
-
health: health
|
|
215
|
-
const at = `health[${h}]`;
|
|
229
|
+
health: kept(health, (h) => `health[${h}]`, (entry, at) => {
|
|
216
230
|
if (!isObject(entry))
|
|
217
231
|
throw new Invalid(at);
|
|
218
232
|
const reason = entry.reason === undefined || entry.reason === null
|
|
@@ -238,6 +252,7 @@ const checked = (document, trusted) => {
|
|
|
238
252
|
tasks: tasksOf(document.tasks),
|
|
239
253
|
},
|
|
240
254
|
leaks,
|
|
255
|
+
dropped,
|
|
241
256
|
};
|
|
242
257
|
};
|
|
243
258
|
/**
|
|
@@ -282,8 +297,8 @@ export const isReportAnswer = (answer) => {
|
|
|
282
297
|
};
|
|
283
298
|
/**
|
|
284
299
|
* A run's answer as a report: one JSON object, bare or as the only fenced `json` block. Text that is neither is not a
|
|
285
|
-
* report (`undefined`) and keeps the Markdown path; a JSON answer
|
|
286
|
-
* of the first field that failed, and is never shown
|
|
300
|
+
* report (`undefined`) and keeps the Markdown path; a JSON answer whose own fields fail the check is `invalid`, with
|
|
301
|
+
* the path of the first field that failed, and is never shown; a part that fails is left out and named in `dropped`. `trusted` is a document a command built from the store: its
|
|
287
302
|
* strings are the owner's data, such as a CRM title `follow_up`, and lose nothing to the leak patterns.
|
|
288
303
|
*/
|
|
289
304
|
export const parseReport = (answer, trusted = false) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.749.0",
|
|
4
4
|
"description": "The messenger-neutral half of a messaging CLI: domain model, message locators, rendering, name resolution, the SQLite seam, the command skeleton and shared read commands, the send guard, run records and the message store",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Viacheslav Ptsarev",
|