@wirecat/cli-core 0.623.0 → 0.624.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 +65 -0
- package/dist/background/backfill.d.ts +1 -1
- package/dist/background/backfill.js +1 -1
- package/dist/background/daily-archive-timer.d.ts +1 -1
- package/dist/background/report/stored-templates.d.ts +21 -3
- package/dist/background/report/stored-templates.js +34 -6
- package/dist/background/schedules.d.ts +10 -20
- package/dist/background/schedules.js +8 -162
- package/dist/background/timers.d.ts +19 -0
- package/dist/background/timers.js +175 -0
- package/dist/background/when.d.ts +28 -7
- package/dist/background/when.js +55 -11
- package/dist/calendar/prepare.d.ts +14 -0
- package/dist/cli/app-doctor-command.js +2 -1
- package/dist/cli/envelope.d.ts +28 -0
- package/dist/cli/index.d.ts +3 -2
- package/dist/cli/index.js +3 -2
- package/dist/cli/schedule/schedule-command.d.ts +100 -3
- package/dist/cli/schedule/schedule-command.js +276 -118
- package/dist/cli/templates-command.js +45 -20
- package/dist/domain/display-names.d.ts +5 -2
- package/dist/domain/display-names.js +13 -4
- package/dist/domain/person-kinds.d.ts +9 -0
- package/dist/domain/person-kinds.js +67 -0
- package/dist/entities/index.d.ts +2 -1
- package/dist/entities/list-results.d.ts +2 -0
- package/dist/entities/list-results.js +2 -0
- package/dist/entities/template.d.ts +1 -1
- package/dist/entities/template.js +1 -1
- package/dist/mcp/surface.js +23 -2
- package/dist/meetings/mcp/index.d.ts +15 -15
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +1 -1
- package/dist/services/search-harder.d.ts +6 -1
- package/dist/services/search-harder.js +9 -2
- package/dist/store/index.d.ts +2 -1
- package/dist/store/index.js +2 -0
- package/dist/store/people.d.ts +3 -3
- package/dist/store/sqlite/people-list.d.ts +23 -8
- package/dist/store/sqlite/people-list.js +189 -65
- package/package.json +2 -2
- package/parity.json +29 -0
|
@@ -2,19 +2,20 @@ import { spawnSync } from "node:child_process";
|
|
|
2
2
|
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { join } from "node:path";
|
|
5
|
-
import { CliError
|
|
5
|
+
import { CliError } from "@wirecat/cli-base";
|
|
6
6
|
import { annotate } from "@wirecat/cli-base/commands";
|
|
7
7
|
import { queryFieldsOf } from "@wirecat/cli-base/query";
|
|
8
8
|
import { Command, Option } from "commander";
|
|
9
9
|
import { checkTemplate, defaultTemplate, REPORT_CHANNELS, renderReport, } from "../background/report/render.js";
|
|
10
|
-
import { checkTemplateSave, previewView, shippedLanguages, TEMPLATE_KEYS, templateKeyOf, } from "../background/report/stored-templates.js";
|
|
10
|
+
import { checkTemplateSave, previewView, reportKeyOf, reportKeysOf, shippedLanguages, TEMPLATE_KEYS, templateKeyOf, } from "../background/report/stored-templates.js";
|
|
11
|
+
import { listSchedules } from "../background/schedules.js";
|
|
11
12
|
import { template } from "../entities/index.js";
|
|
12
13
|
import { agentOf } from "../runs/run-context.js";
|
|
13
14
|
import { openStore } from "../store/store.js";
|
|
14
15
|
import { grantsAuthority, LOCAL_READ, LOCAL_WRITE } from "./effects.js";
|
|
15
16
|
import { itemOf, listOf } from "./envelope.js";
|
|
16
17
|
import { queryTerms, withQuery } from "./list-query.js";
|
|
17
|
-
import { ownerLanguageOf } from "./schedule/schedule-command.js";
|
|
18
|
+
import { ownerLanguageOf, scheduleState } from "./schedule/schedule-command.js";
|
|
18
19
|
const withStore = async (env, work) => {
|
|
19
20
|
const store = await openStore({ env });
|
|
20
21
|
try {
|
|
@@ -53,18 +54,32 @@ const TEMPLATES_QUERY = {
|
|
|
53
54
|
};
|
|
54
55
|
const matching = (rows, terms) => rows.filter((row) => [...terms].every(([field, value]) => String(row[field]).toLowerCase() === value.toLowerCase()));
|
|
55
56
|
/** The key, its message kind and the language, refused when cli-core ships no template in that language. */
|
|
56
|
-
const addressOf = async (key, given, env) => {
|
|
57
|
-
const known = templateKeyOf(key)
|
|
57
|
+
const addressOf = async (key, given, env, state) => {
|
|
58
|
+
const known = templateKeyOf(key) ??
|
|
59
|
+
reportKeyOf(key, [
|
|
60
|
+
...listSchedules(state, { kind: "agent" }).map((one) => one.name),
|
|
61
|
+
// A removed schedule's templates stay in the store, and must still be shown and reset.
|
|
62
|
+
...(await withStore(env, (store) => store.templates.list())).flatMap((row) => row.key.startsWith("report/") ? [row.key.slice("report/".length)] : []),
|
|
63
|
+
]);
|
|
58
64
|
if (!known)
|
|
59
|
-
throw new CliError("validation_error", `no template ${key}; the keys are ${TEMPLATE_KEYS.map((one) => one.key).join(", ")}`, {
|
|
65
|
+
throw new CliError("validation_error", `no template ${key}; the keys are ${TEMPLATE_KEYS.map((one) => one.key).join(", ")}, or report/<schedule> for an agent schedule's digest`, {
|
|
60
66
|
reason: "template.unknown-key",
|
|
61
67
|
});
|
|
62
68
|
const language = (given.locale ?? (await ownerLanguageOf(env))).trim().toLowerCase();
|
|
63
69
|
const languages = shippedLanguages(known.kind);
|
|
64
70
|
if (!languages.includes(language))
|
|
65
71
|
throw new CliError("validation_error", `${key} has templates in ${languages.join(", ")}; a ${language} one would never be used`, { reason: "template.unknown-language" });
|
|
66
|
-
return {
|
|
72
|
+
return {
|
|
73
|
+
address: { key, channel: given.channel, language },
|
|
74
|
+
kind: known.kind,
|
|
75
|
+
channel: given.channel,
|
|
76
|
+
...(known.schedule ? { schedule: known.schedule } : {}),
|
|
77
|
+
};
|
|
67
78
|
};
|
|
79
|
+
/** The stored body that applies to `address`: its own, else the one its digest falls back to; undefined for shipped. */
|
|
80
|
+
const appliedBody = (store, address, kind, schedule) => reportKeysOf(kind, schedule)
|
|
81
|
+
.map((key) => store.templates.get({ ...address, key })?.body)
|
|
82
|
+
.find((body) => body !== undefined);
|
|
68
83
|
const refuseAgent = (env) => {
|
|
69
84
|
// A template decides what every later digest says to the owner; an agent could make it hide or invent things.
|
|
70
85
|
if (agentOf(env))
|
|
@@ -72,7 +87,7 @@ const refuseAgent = (env) => {
|
|
|
72
87
|
reason: "template.owner-only",
|
|
73
88
|
});
|
|
74
89
|
};
|
|
75
|
-
const stateOf = (app, env) =>
|
|
90
|
+
const stateOf = (app, env) => scheduleState({ app, env });
|
|
76
91
|
const historyOf = (store, address) => store.templates.history(address).map((entry) => ({
|
|
77
92
|
id: entry.id,
|
|
78
93
|
saved_at: new Date(entry.savedAt).toISOString(),
|
|
@@ -100,15 +115,21 @@ export const templatesCommand = (app, options) => {
|
|
|
100
115
|
const terms = queryTerms(words, TEMPLATES_QUERY, "templates list");
|
|
101
116
|
const env = options.env();
|
|
102
117
|
const stored = await withStore(env, (store) => store.templates.list());
|
|
103
|
-
const
|
|
104
|
-
const
|
|
118
|
+
const own = [...new Set(stored.map((one) => one.key))].flatMap((key) => {
|
|
119
|
+
const known = reportKeyOf(key, [key.slice("report/".length)]);
|
|
120
|
+
return known?.schedule ? [known] : [];
|
|
121
|
+
});
|
|
122
|
+
const items = [...TEMPLATE_KEYS, ...own].flatMap((known) => REPORT_CHANNELS.flatMap((channel) => shippedLanguages(known.kind).map((language) => {
|
|
123
|
+
const rowOf = (key) => stored.find((one) => one.key === key && one.channel === channel && one.language === language);
|
|
124
|
+
const row = rowOf(known.key);
|
|
125
|
+
const inherited = !row && "schedule" in known && reportKeysOf(known.kind, known.schedule).some((key) => rowOf(key));
|
|
105
126
|
return {
|
|
106
127
|
key: known.key,
|
|
107
128
|
channel,
|
|
108
129
|
language,
|
|
109
130
|
about: known.about,
|
|
110
131
|
renders: true,
|
|
111
|
-
source: row ? "stored" : "default",
|
|
132
|
+
source: row ? "stored" : inherited ? "inherited" : "default",
|
|
112
133
|
updated_at: row ? new Date(row.updatedAt).toISOString() : null,
|
|
113
134
|
updated_by: row?.updatedBy ?? null,
|
|
114
135
|
};
|
|
@@ -127,13 +148,14 @@ export const templatesCommand = (app, options) => {
|
|
|
127
148
|
.addOption(localeOption())
|
|
128
149
|
.action(async function (key, given) {
|
|
129
150
|
const env = options.env();
|
|
130
|
-
const { address, kind, channel } = await addressOf(key, given, env);
|
|
151
|
+
const { address, kind, channel, schedule } = await addressOf(key, given, env, stateOf(app, env));
|
|
131
152
|
const item = await withStore(env, (store) => {
|
|
132
153
|
const row = store.templates.get(address);
|
|
154
|
+
const applied = appliedBody(store, address, kind, schedule);
|
|
133
155
|
return {
|
|
134
156
|
...address,
|
|
135
|
-
source: row ? "stored" : "default",
|
|
136
|
-
body:
|
|
157
|
+
source: row ? "stored" : applied === undefined ? "default" : "inherited",
|
|
158
|
+
body: applied ?? defaultTemplate(kind, channel, address.language),
|
|
137
159
|
updated_at: row ? new Date(row.updatedAt).toISOString() : null,
|
|
138
160
|
updated_by: row?.updatedBy ?? null,
|
|
139
161
|
history: historyOf(store, address),
|
|
@@ -159,9 +181,9 @@ export const templatesCommand = (app, options) => {
|
|
|
159
181
|
.action(async function (key, given) {
|
|
160
182
|
const env = options.env();
|
|
161
183
|
refuseAgent(env);
|
|
162
|
-
const { address, kind, channel } = await addressOf(key, given, env);
|
|
184
|
+
const { address, kind, channel, schedule } = await addressOf(key, given, env, stateOf(app, env));
|
|
163
185
|
const { current, previous } = await withStore(env, (store) => ({
|
|
164
|
-
current: store
|
|
186
|
+
current: appliedBody(store, address, kind, schedule),
|
|
165
187
|
previous: store.templates.history(address, 1)[0]?.body,
|
|
166
188
|
}));
|
|
167
189
|
const effective = current ?? defaultTemplate(kind, channel, address.language);
|
|
@@ -197,6 +219,7 @@ export const templatesCommand = (app, options) => {
|
|
|
197
219
|
body,
|
|
198
220
|
state: stateOf(app, env),
|
|
199
221
|
now: Date.now(),
|
|
222
|
+
...(schedule ? { schedule } : {}),
|
|
200
223
|
});
|
|
201
224
|
const problems = checks.flatMap((check) => check.problems.map((problem) => `${check.against}: ${problem}`));
|
|
202
225
|
if (problems.length > 0)
|
|
@@ -228,10 +251,12 @@ export const templatesCommand = (app, options) => {
|
|
|
228
251
|
.option("--file <file>", "preview this draft instead of the template that applies; - reads stdin")
|
|
229
252
|
.action(async function (key, given) {
|
|
230
253
|
const env = options.env();
|
|
231
|
-
const { address, kind, channel } = await addressOf(key, given, env);
|
|
232
|
-
const stored = given.file === undefined
|
|
254
|
+
const { address, kind, channel, schedule } = await addressOf(key, given, env, stateOf(app, env));
|
|
255
|
+
const stored = given.file === undefined
|
|
256
|
+
? await withStore(env, (store) => appliedBody(store, address, kind, schedule))
|
|
257
|
+
: undefined;
|
|
233
258
|
const body = given.file === undefined ? stored : readFileSync(given.file === "-" ? 0 : given.file, "utf8");
|
|
234
|
-
const { against, view } = previewView(stateOf(app, env), kind, address.language, Date.now());
|
|
259
|
+
const { against, view } = previewView(stateOf(app, env), kind, address.language, Date.now(), schedule);
|
|
235
260
|
const rendering = await renderReport(view, channel, body === undefined ? {} : { template: body });
|
|
236
261
|
const problems = body === undefined ? [] : (await checkTemplate(view, channel, body)).problems;
|
|
237
262
|
options.output(itemOf({
|
|
@@ -255,7 +280,7 @@ export const templatesCommand = (app, options) => {
|
|
|
255
280
|
.action(async function (key, given) {
|
|
256
281
|
const env = options.env();
|
|
257
282
|
refuseAgent(env);
|
|
258
|
-
const { address } = await addressOf(key, given, env);
|
|
283
|
+
const { address } = await addressOf(key, given, env, stateOf(app, env));
|
|
259
284
|
const changed = await withStore(env, (store) => store.templates.reset(address));
|
|
260
285
|
options.diagnostic(changed
|
|
261
286
|
? `${key} ${address.channel} ${address.language} uses the shipped template again`
|
|
@@ -5,8 +5,9 @@ export interface NameFallbacks {
|
|
|
5
5
|
email?: string | null;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
|
-
* A name as it is shown: no wrapping quotes, no repeated or edge spaces. One with no letter or digit (`!`, `!$`)
|
|
9
|
-
* way to the username, then the phone, then the email; the stored name
|
|
8
|
+
* A name as it is shown: no wrapping quotes, no repeated or edge spaces. One with no letter or digit (`!`, `!$`), or a
|
|
9
|
+
* placeholder such as `null` or «Без имени», gives way to the username, then the phone, then the email; the stored name
|
|
10
|
+
* stays as it came.
|
|
10
11
|
*/
|
|
11
12
|
export declare const displayName: (name: string | null | undefined, fallbacks?: NameFallbacks) => string | null;
|
|
12
13
|
/**
|
|
@@ -14,3 +15,5 @@ export declare const displayName: (name: string | null | undefined, fallbacks?:
|
|
|
14
15
|
* `ivan IVANOV` give one key. `null` for a name with no letter or digit, which matches nobody.
|
|
15
16
|
*/
|
|
16
17
|
export declare const nameKey: (name: string | null | undefined) => string | null;
|
|
18
|
+
/** Whether a shown name has anything to read: not null, not only punctuation. */
|
|
19
|
+
export declare const isReadable: (shown: string | null) => boolean;
|
|
@@ -9,6 +9,8 @@ const QUOTES = [
|
|
|
9
9
|
["`", "`"],
|
|
10
10
|
];
|
|
11
11
|
const READABLE = /[\p{L}\p{N}]/u;
|
|
12
|
+
/** What a source writes when it has no name: no name at all. */
|
|
13
|
+
const PLACEHOLDERS = new Set(["null", "undefined", "none", "без имени", "deleted account", "удалённый аккаунт"]);
|
|
12
14
|
const unquoted = (text) => {
|
|
13
15
|
let at = text.replace(/\s+/gu, " ").trim();
|
|
14
16
|
for (;;) {
|
|
@@ -23,11 +25,13 @@ const given = (value) => {
|
|
|
23
25
|
return text === "" ? undefined : text;
|
|
24
26
|
};
|
|
25
27
|
/**
|
|
26
|
-
* A name as it is shown: no wrapping quotes, no repeated or edge spaces. One with no letter or digit (`!`, `!$`)
|
|
27
|
-
* way to the username, then the phone, then the email; the stored name
|
|
28
|
+
* A name as it is shown: no wrapping quotes, no repeated or edge spaces. One with no letter or digit (`!`, `!$`), or a
|
|
29
|
+
* placeholder such as `null` or «Без имени», gives way to the username, then the phone, then the email; the stored name
|
|
30
|
+
* stays as it came.
|
|
28
31
|
*/
|
|
29
32
|
export const displayName = (name, fallbacks = {}) => {
|
|
30
|
-
const
|
|
33
|
+
const unwrapped = typeof name === "string" ? unquoted(name) : "";
|
|
34
|
+
const cleaned = PLACEHOLDERS.has(unwrapped.toLowerCase()) ? "" : unwrapped;
|
|
31
35
|
if (READABLE.test(cleaned))
|
|
32
36
|
return cleaned;
|
|
33
37
|
const username = given(fallbacks.username);
|
|
@@ -43,8 +47,13 @@ export const displayName = (name, fallbacks = {}) => {
|
|
|
43
47
|
export const nameKey = (name) => {
|
|
44
48
|
if (typeof name !== "string")
|
|
45
49
|
return null;
|
|
46
|
-
const
|
|
50
|
+
const unwrapped = unquoted(name);
|
|
51
|
+
if (PLACEHOLDERS.has(unwrapped.toLowerCase()))
|
|
52
|
+
return null;
|
|
53
|
+
const words = foldName(unwrapped)
|
|
47
54
|
.split(/[^\p{L}\p{N}]+/u)
|
|
48
55
|
.filter((word) => word !== "");
|
|
49
56
|
return words.length === 0 ? null : words.sort().join(" ");
|
|
50
57
|
};
|
|
58
|
+
/** Whether a shown name has anything to read: not null, not only punctuation. */
|
|
59
|
+
export const isReadable = (shown) => shown !== null && READABLE.test(shown);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** What a person in the store is, for a list that shows the useful ones and keeps the noise apart. */
|
|
2
|
+
export declare const PERSON_KINDS: readonly ["person", "organization", "automated", "unsorted"];
|
|
3
|
+
export type PersonKind = (typeof PERSON_KINDS)[number];
|
|
4
|
+
/** What decided a kind, besides the ties that make someone a `person`. */
|
|
5
|
+
export type KindSignal = "bot" | "no-reply" | "bulk-mail" | "bulk-never-replied" | "automated-name" | "organization" | "role-address" | "company-name" | "no-tie" | "no-name";
|
|
6
|
+
/** A sender that is a program: «Notifications», «Рассылка», «no-reply». */
|
|
7
|
+
export declare const isAutomatedName: (name: string | null) => boolean;
|
|
8
|
+
/** A legal form or a word only a business calls itself: «ООО Ромашка», «CZECH AIRLINES», «OpenWeather Team». */
|
|
9
|
+
export declare const isCompanyName: (name: string | null) => boolean;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/** What a person in the store is, for a list that shows the useful ones and keeps the noise apart. */
|
|
2
|
+
export const PERSON_KINDS = ["person", "organization", "automated", "unsorted"];
|
|
3
|
+
const AUTOMATED_WORDS = new Set([
|
|
4
|
+
"noreply",
|
|
5
|
+
"notification",
|
|
6
|
+
"notifications",
|
|
7
|
+
"newsletter",
|
|
8
|
+
"newsletters",
|
|
9
|
+
"digest",
|
|
10
|
+
"alerts",
|
|
11
|
+
"mailer",
|
|
12
|
+
"robot",
|
|
13
|
+
]);
|
|
14
|
+
const AUTOMATED_STEMS = ["уведомлени", "рассылк", "оповещени", "noreply", "donotreply", "робот"];
|
|
15
|
+
const LEGAL_FORMS = new Set(["ооо", "оао", "зао", "пао", "ао", "ип", "llc", "ltd", "limited", "inc", "corp", "gmbh"]);
|
|
16
|
+
const COMPANY_WORDS = new Set([
|
|
17
|
+
"airlines",
|
|
18
|
+
"airways",
|
|
19
|
+
"bank",
|
|
20
|
+
"банк",
|
|
21
|
+
"hotel",
|
|
22
|
+
"hotels",
|
|
23
|
+
"отель",
|
|
24
|
+
"гостиница",
|
|
25
|
+
"hostel",
|
|
26
|
+
"хостел",
|
|
27
|
+
"апартаменты",
|
|
28
|
+
"team",
|
|
29
|
+
"support",
|
|
30
|
+
"поддержка",
|
|
31
|
+
"service",
|
|
32
|
+
"services",
|
|
33
|
+
"сервис",
|
|
34
|
+
"служба",
|
|
35
|
+
"shop",
|
|
36
|
+
"store",
|
|
37
|
+
"магазин",
|
|
38
|
+
"company",
|
|
39
|
+
"компания",
|
|
40
|
+
"agency",
|
|
41
|
+
"агентство",
|
|
42
|
+
"restaurant",
|
|
43
|
+
"ресторан",
|
|
44
|
+
"clinic",
|
|
45
|
+
"клиника",
|
|
46
|
+
"delivery",
|
|
47
|
+
"доставка",
|
|
48
|
+
]);
|
|
49
|
+
const wordsOf = (name) => name
|
|
50
|
+
.toLowerCase()
|
|
51
|
+
.split(/[^\p{L}\p{N}-]+/u)
|
|
52
|
+
.filter((word) => word !== "");
|
|
53
|
+
/** A sender that is a program: «Notifications», «Рассылка», «no-reply». */
|
|
54
|
+
export const isAutomatedName = (name) => {
|
|
55
|
+
if (name === null)
|
|
56
|
+
return false;
|
|
57
|
+
return wordsOf(name).some((word) => {
|
|
58
|
+
const bare = word.includes("-") ? word.replaceAll("-", "") : word;
|
|
59
|
+
return AUTOMATED_WORDS.has(bare) || AUTOMATED_STEMS.some((stem) => bare.startsWith(stem));
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
/** A legal form or a word only a business calls itself: «ООО Ромашка», «CZECH AIRLINES», «OpenWeather Team». */
|
|
63
|
+
export const isCompanyName = (name) => {
|
|
64
|
+
if (name === null)
|
|
65
|
+
return false;
|
|
66
|
+
return wordsOf(name.replaceAll(".", "")).some((word) => LEGAL_FORMS.has(word) || COMPANY_WORDS.has(word));
|
|
67
|
+
};
|
package/dist/entities/index.d.ts
CHANGED
|
@@ -4199,6 +4199,7 @@ export declare const ENTITIES: {
|
|
|
4199
4199
|
readonly name: v.StringSchema<undefined>;
|
|
4200
4200
|
readonly kind: v.PicklistSchema<["command", "agent"], undefined>;
|
|
4201
4201
|
readonly when: v.StringSchema<undefined>;
|
|
4202
|
+
readonly paused: v.OptionalSchema<v.LiteralSchema<true, undefined>, undefined>;
|
|
4202
4203
|
readonly notify: v.OptionalSchema<v.PicklistSchema<["always", "failures", "never"], undefined>, undefined>;
|
|
4203
4204
|
readonly deliver_to: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
4204
4205
|
readonly last: v.NullableSchema<v.StrictObjectSchema<{
|
|
@@ -11941,7 +11942,7 @@ export declare const ENTITIES: {
|
|
|
11941
11942
|
readonly language: v.StringSchema<undefined>;
|
|
11942
11943
|
readonly about: v.StringSchema<undefined>;
|
|
11943
11944
|
readonly renders: v.BooleanSchema<undefined>;
|
|
11944
|
-
readonly source: v.PicklistSchema<["stored", "default"], undefined>;
|
|
11945
|
+
readonly source: v.PicklistSchema<["stored", "inherited", "default"], undefined>;
|
|
11945
11946
|
readonly updated_at: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
|
|
11946
11947
|
readonly updated_by: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
11947
11948
|
}, undefined>;
|
|
@@ -48,6 +48,8 @@ export declare const scheduledJob: v.StrictObjectSchema<{
|
|
|
48
48
|
readonly name: v.StringSchema<undefined>;
|
|
49
49
|
readonly kind: v.PicklistSchema<["command", "agent"], undefined>;
|
|
50
50
|
readonly when: v.StringSchema<undefined>;
|
|
51
|
+
/** Kept without its timer: `schedule run` runs it, `schedule resume` puts it back on its timer. */
|
|
52
|
+
readonly paused: v.OptionalSchema<v.LiteralSchema<true, undefined>, undefined>;
|
|
51
53
|
/** When a finished run shows a desktop notice: `always`, `failures` or `never`; the default is shown, not left out. */
|
|
52
54
|
readonly notify: v.OptionalSchema<v.PicklistSchema<["always", "failures", "never"], undefined>, undefined>;
|
|
53
55
|
/** Where a run's result is sent after it: `telegram-bot:<profile>/<chat>` or `email:<profile>/<address>`. */
|
|
@@ -32,6 +32,8 @@ export const scheduledJob = v.strictObject({
|
|
|
32
32
|
name: text,
|
|
33
33
|
kind: v.picklist(["command", "agent"]),
|
|
34
34
|
when: text,
|
|
35
|
+
/** Kept without its timer: `schedule run` runs it, `schedule resume` puts it back on its timer. */
|
|
36
|
+
paused: v.optional(v.literal(true)),
|
|
35
37
|
/** When a finished run shows a desktop notice: `always`, `failures` or `never`; the default is shown, not left out. */
|
|
36
38
|
notify: v.optional(v.picklist(["always", "failures", "never"])),
|
|
37
39
|
/** Where a run's result is sent after it: `telegram-bot:<profile>/<chat>` or `email:<profile>/<address>`. */
|
|
@@ -5,7 +5,7 @@ export declare const template: v.StrictObjectSchema<{
|
|
|
5
5
|
readonly language: v.StringSchema<undefined>;
|
|
6
6
|
readonly about: v.StringSchema<undefined>;
|
|
7
7
|
readonly renders: v.BooleanSchema<undefined>;
|
|
8
|
-
readonly source: v.PicklistSchema<["stored", "default"], undefined>;
|
|
8
|
+
readonly source: v.PicklistSchema<["stored", "inherited", "default"], undefined>;
|
|
9
9
|
readonly updated_at: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
|
|
10
10
|
readonly updated_by: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
11
11
|
}, undefined>;
|
|
@@ -6,7 +6,7 @@ export const template = v.strictObject({
|
|
|
6
6
|
language: text,
|
|
7
7
|
about: text,
|
|
8
8
|
renders: v.boolean(),
|
|
9
|
-
source: v.picklist(["stored", "default"]),
|
|
9
|
+
source: v.picklist(["stored", "inherited", "default"]),
|
|
10
10
|
updated_at: v.nullable(time),
|
|
11
11
|
updated_by: v.nullable(text),
|
|
12
12
|
});
|
package/dist/mcp/surface.js
CHANGED
|
@@ -9,6 +9,27 @@ import { agentArguments } from "./text.js";
|
|
|
9
9
|
import { answered, commandOf, entryRunner, failed, inputOf, outputSchemaOf, READ, syncAllowedFor, UNTRUSTED, UNTRUSTED_NEUTRAL, WRITE, } from "./tool.js";
|
|
10
10
|
const MATCHES = 8;
|
|
11
11
|
const ANSWER = answerSchema();
|
|
12
|
+
// The listing shows an agent only what it acts on; the server still checks every answer against the full envelope,
|
|
13
|
+
// and tools_search gives each command's full answer. meta.ranking alone took 2,800 characters of every connect.
|
|
14
|
+
const agentAnswer = (prefix, writes) => {
|
|
15
|
+
const meta = v.pipe(v.looseObject({}), v.description(`run facts; ${prefix}_tools_search shows the full answer`));
|
|
16
|
+
const next = v.optional(v.pipe(v.array(v.looseObject({})), v.description("steps to run next: command and args")));
|
|
17
|
+
return v.looseObject(writes
|
|
18
|
+
? { item: v.optional(v.unknown()), next, meta }
|
|
19
|
+
: {
|
|
20
|
+
items: v.optional(v.array(v.unknown())),
|
|
21
|
+
item: v.optional(v.unknown()),
|
|
22
|
+
page: v.optional(v.looseObject({ has_more: v.boolean() })),
|
|
23
|
+
next,
|
|
24
|
+
missing: v.optional(v.array(v.looseObject({ field: v.string(), why: v.string() }))),
|
|
25
|
+
meta,
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
const listedAs = (prefix, writes) => {
|
|
29
|
+
const checked = toStandardJsonSchema(ANSWER);
|
|
30
|
+
const shown = toStandardJsonSchema(agentAnswer(prefix, writes))["~standard"].jsonSchema;
|
|
31
|
+
return { "~standard": { ...checked["~standard"], jsonSchema: shown } };
|
|
32
|
+
};
|
|
12
33
|
export const normal = (command) => command
|
|
13
34
|
.trim()
|
|
14
35
|
.toLowerCase()
|
|
@@ -152,7 +173,7 @@ isMessenger) => {
|
|
|
152
173
|
arguments: v.optional(v.pipe(v.record(v.string(), v.unknown()), v.description("that command's arguments"))),
|
|
153
174
|
});
|
|
154
175
|
server.registerTool(`${prefix}_read`, {
|
|
155
|
-
outputSchema:
|
|
176
|
+
outputSchema: listedAs(prefix, false),
|
|
156
177
|
title: "Run a reading command",
|
|
157
178
|
description: `Run one command that only reads, with the arguments ${prefix}_tools_search showed. ${untrusted}`,
|
|
158
179
|
inputSchema: toStandardJsonSchema(call),
|
|
@@ -160,7 +181,7 @@ isMessenger) => {
|
|
|
160
181
|
}, runner(false));
|
|
161
182
|
if (Object.values(commands).some((one) => one.writes))
|
|
162
183
|
server.registerTool(`${prefix}_write`, {
|
|
163
|
-
outputSchema:
|
|
184
|
+
outputSchema: listedAs(prefix, true),
|
|
164
185
|
title: "Run a writing command",
|
|
165
186
|
description: `Run one command that changes something — ${messenger ? "sends, edits, deletes, joins" : "creates, edits, deletes"} — with the arguments ${prefix}_tools_search showed. ${untrusted}`,
|
|
166
187
|
inputSchema: toStandardJsonSchema(call),
|
|
@@ -38,7 +38,6 @@ export declare const meetingTools: ({
|
|
|
38
38
|
max_read_bytes?: undefined;
|
|
39
39
|
cursor?: undefined;
|
|
40
40
|
} | {
|
|
41
|
-
limit?: undefined;
|
|
42
41
|
event_id?: undefined;
|
|
43
42
|
series_id?: undefined;
|
|
44
43
|
page?: undefined;
|
|
@@ -54,11 +53,11 @@ export declare const meetingTools: ({
|
|
|
54
53
|
format?: undefined;
|
|
55
54
|
transcript_id?: undefined;
|
|
56
55
|
query?: undefined;
|
|
56
|
+
limit?: undefined;
|
|
57
57
|
scan_limit?: undefined;
|
|
58
58
|
max_read_bytes?: undefined;
|
|
59
59
|
cursor?: undefined;
|
|
60
60
|
} | {
|
|
61
|
-
limit?: undefined;
|
|
62
61
|
event_id?: undefined;
|
|
63
62
|
series_id?: undefined;
|
|
64
63
|
page?: undefined;
|
|
@@ -76,11 +75,11 @@ export declare const meetingTools: ({
|
|
|
76
75
|
format?: undefined;
|
|
77
76
|
transcript_id?: undefined;
|
|
78
77
|
query?: undefined;
|
|
78
|
+
limit?: undefined;
|
|
79
79
|
scan_limit?: undefined;
|
|
80
80
|
max_read_bytes?: undefined;
|
|
81
81
|
cursor?: undefined;
|
|
82
82
|
} | {
|
|
83
|
-
limit?: undefined;
|
|
84
83
|
event_id?: undefined;
|
|
85
84
|
series_id?: undefined;
|
|
86
85
|
page?: undefined;
|
|
@@ -102,6 +101,7 @@ export declare const meetingTools: ({
|
|
|
102
101
|
minimum: number;
|
|
103
102
|
};
|
|
104
103
|
query?: undefined;
|
|
104
|
+
limit?: undefined;
|
|
105
105
|
scan_limit?: undefined;
|
|
106
106
|
max_read_bytes?: undefined;
|
|
107
107
|
cursor?: undefined;
|
|
@@ -188,7 +188,6 @@ export declare const meetingTools: ({
|
|
|
188
188
|
max_read_bytes?: undefined;
|
|
189
189
|
cursor?: undefined;
|
|
190
190
|
} | {
|
|
191
|
-
limit?: undefined;
|
|
192
191
|
event_id?: undefined;
|
|
193
192
|
series_id?: undefined;
|
|
194
193
|
page?: undefined;
|
|
@@ -204,11 +203,11 @@ export declare const meetingTools: ({
|
|
|
204
203
|
format?: undefined;
|
|
205
204
|
transcript_id?: undefined;
|
|
206
205
|
query?: undefined;
|
|
206
|
+
limit?: undefined;
|
|
207
207
|
scan_limit?: undefined;
|
|
208
208
|
max_read_bytes?: undefined;
|
|
209
209
|
cursor?: undefined;
|
|
210
210
|
} | {
|
|
211
|
-
limit?: undefined;
|
|
212
211
|
event_id?: undefined;
|
|
213
212
|
series_id?: undefined;
|
|
214
213
|
page?: undefined;
|
|
@@ -226,11 +225,11 @@ export declare const meetingTools: ({
|
|
|
226
225
|
format?: undefined;
|
|
227
226
|
transcript_id?: undefined;
|
|
228
227
|
query?: undefined;
|
|
228
|
+
limit?: undefined;
|
|
229
229
|
scan_limit?: undefined;
|
|
230
230
|
max_read_bytes?: undefined;
|
|
231
231
|
cursor?: undefined;
|
|
232
232
|
} | {
|
|
233
|
-
limit?: undefined;
|
|
234
233
|
event_id?: undefined;
|
|
235
234
|
series_id?: undefined;
|
|
236
235
|
page?: undefined;
|
|
@@ -252,6 +251,7 @@ export declare const meetingTools: ({
|
|
|
252
251
|
minimum: number;
|
|
253
252
|
};
|
|
254
253
|
query?: undefined;
|
|
254
|
+
limit?: undefined;
|
|
255
255
|
scan_limit?: undefined;
|
|
256
256
|
max_read_bytes?: undefined;
|
|
257
257
|
cursor?: undefined;
|
|
@@ -338,7 +338,6 @@ export declare const meetingTools: ({
|
|
|
338
338
|
max_read_bytes?: undefined;
|
|
339
339
|
cursor?: undefined;
|
|
340
340
|
} | {
|
|
341
|
-
limit?: undefined;
|
|
342
341
|
event_id?: undefined;
|
|
343
342
|
series_id?: undefined;
|
|
344
343
|
page?: undefined;
|
|
@@ -354,11 +353,11 @@ export declare const meetingTools: ({
|
|
|
354
353
|
format?: undefined;
|
|
355
354
|
transcript_id?: undefined;
|
|
356
355
|
query?: undefined;
|
|
356
|
+
limit?: undefined;
|
|
357
357
|
scan_limit?: undefined;
|
|
358
358
|
max_read_bytes?: undefined;
|
|
359
359
|
cursor?: undefined;
|
|
360
360
|
} | {
|
|
361
|
-
limit?: undefined;
|
|
362
361
|
event_id?: undefined;
|
|
363
362
|
series_id?: undefined;
|
|
364
363
|
page?: undefined;
|
|
@@ -376,11 +375,11 @@ export declare const meetingTools: ({
|
|
|
376
375
|
format?: undefined;
|
|
377
376
|
transcript_id?: undefined;
|
|
378
377
|
query?: undefined;
|
|
378
|
+
limit?: undefined;
|
|
379
379
|
scan_limit?: undefined;
|
|
380
380
|
max_read_bytes?: undefined;
|
|
381
381
|
cursor?: undefined;
|
|
382
382
|
} | {
|
|
383
|
-
limit?: undefined;
|
|
384
383
|
event_id?: undefined;
|
|
385
384
|
series_id?: undefined;
|
|
386
385
|
page?: undefined;
|
|
@@ -402,6 +401,7 @@ export declare const meetingTools: ({
|
|
|
402
401
|
minimum: number;
|
|
403
402
|
};
|
|
404
403
|
query?: undefined;
|
|
404
|
+
limit?: undefined;
|
|
405
405
|
scan_limit?: undefined;
|
|
406
406
|
max_read_bytes?: undefined;
|
|
407
407
|
cursor?: undefined;
|
|
@@ -488,7 +488,6 @@ export declare const meetingTools: ({
|
|
|
488
488
|
max_read_bytes?: undefined;
|
|
489
489
|
cursor?: undefined;
|
|
490
490
|
} | {
|
|
491
|
-
limit?: undefined;
|
|
492
491
|
event_id?: undefined;
|
|
493
492
|
series_id?: undefined;
|
|
494
493
|
page?: undefined;
|
|
@@ -504,11 +503,11 @@ export declare const meetingTools: ({
|
|
|
504
503
|
format?: undefined;
|
|
505
504
|
transcript_id?: undefined;
|
|
506
505
|
query?: undefined;
|
|
506
|
+
limit?: undefined;
|
|
507
507
|
scan_limit?: undefined;
|
|
508
508
|
max_read_bytes?: undefined;
|
|
509
509
|
cursor?: undefined;
|
|
510
510
|
} | {
|
|
511
|
-
limit?: undefined;
|
|
512
511
|
event_id?: undefined;
|
|
513
512
|
series_id?: undefined;
|
|
514
513
|
page?: undefined;
|
|
@@ -526,11 +525,11 @@ export declare const meetingTools: ({
|
|
|
526
525
|
format?: undefined;
|
|
527
526
|
transcript_id?: undefined;
|
|
528
527
|
query?: undefined;
|
|
528
|
+
limit?: undefined;
|
|
529
529
|
scan_limit?: undefined;
|
|
530
530
|
max_read_bytes?: undefined;
|
|
531
531
|
cursor?: undefined;
|
|
532
532
|
} | {
|
|
533
|
-
limit?: undefined;
|
|
534
533
|
event_id?: undefined;
|
|
535
534
|
series_id?: undefined;
|
|
536
535
|
page?: undefined;
|
|
@@ -552,6 +551,7 @@ export declare const meetingTools: ({
|
|
|
552
551
|
minimum: number;
|
|
553
552
|
};
|
|
554
553
|
query?: undefined;
|
|
554
|
+
limit?: undefined;
|
|
555
555
|
scan_limit?: undefined;
|
|
556
556
|
max_read_bytes?: undefined;
|
|
557
557
|
cursor?: undefined;
|
|
@@ -638,7 +638,6 @@ export declare const meetingTools: ({
|
|
|
638
638
|
max_read_bytes?: undefined;
|
|
639
639
|
cursor?: undefined;
|
|
640
640
|
} | {
|
|
641
|
-
limit?: undefined;
|
|
642
641
|
event_id?: undefined;
|
|
643
642
|
series_id?: undefined;
|
|
644
643
|
page?: undefined;
|
|
@@ -654,11 +653,11 @@ export declare const meetingTools: ({
|
|
|
654
653
|
format?: undefined;
|
|
655
654
|
transcript_id?: undefined;
|
|
656
655
|
query?: undefined;
|
|
656
|
+
limit?: undefined;
|
|
657
657
|
scan_limit?: undefined;
|
|
658
658
|
max_read_bytes?: undefined;
|
|
659
659
|
cursor?: undefined;
|
|
660
660
|
} | {
|
|
661
|
-
limit?: undefined;
|
|
662
661
|
event_id?: undefined;
|
|
663
662
|
series_id?: undefined;
|
|
664
663
|
page?: undefined;
|
|
@@ -676,11 +675,11 @@ export declare const meetingTools: ({
|
|
|
676
675
|
format?: undefined;
|
|
677
676
|
transcript_id?: undefined;
|
|
678
677
|
query?: undefined;
|
|
678
|
+
limit?: undefined;
|
|
679
679
|
scan_limit?: undefined;
|
|
680
680
|
max_read_bytes?: undefined;
|
|
681
681
|
cursor?: undefined;
|
|
682
682
|
} | {
|
|
683
|
-
limit?: undefined;
|
|
684
683
|
event_id?: undefined;
|
|
685
684
|
series_id?: undefined;
|
|
686
685
|
page?: undefined;
|
|
@@ -702,6 +701,7 @@ export declare const meetingTools: ({
|
|
|
702
701
|
minimum: number;
|
|
703
702
|
};
|
|
704
703
|
query?: undefined;
|
|
704
|
+
limit?: undefined;
|
|
705
705
|
scan_limit?: undefined;
|
|
706
706
|
max_read_bytes?: undefined;
|
|
707
707
|
cursor?: undefined;
|
package/dist/services/index.d.ts
CHANGED
|
@@ -215,7 +215,7 @@ export { RESOURCES_SEARCHED, type SearchAllFound, type SearchAllItem, type Searc
|
|
|
215
215
|
export { type MeetingSearchCoverage, type MeetingSearchCursor, type ResourceWithMeetings, type SearchAllIncludingMeetingsFound, type SearchAllIncludingMeetingsRequest, searchAllIncludingMeetings, } from "./search-all-deprecated.js";
|
|
216
216
|
export { type MeetingAccountCoverage, type MeetingSearchItem, MOST_HITS_PER_MEETING, } from "./search-all-meetings.js";
|
|
217
217
|
export { CATCH_UP_BOUNDS, type CatchUpOptions, type CatchUpResult, catchUpSearch, validateCatchUp, } from "./search-catchup.js";
|
|
218
|
-
export { HARDER_MODELS, HARDER_REASON_IDS, type HarderOptions, type HarderReasonId, type HarderResult, readHarderSetting, writeHarderSetting, } from "./search-harder.js";
|
|
218
|
+
export { HARDER_MODELS, HARDER_REASON_IDS, type HarderOptions, type HarderReasonId, type HarderResult, harderRanking, readHarderSetting, writeHarderSetting, } from "./search-harder.js";
|
|
219
219
|
export { accountsOfKind, groupLockOf, listContextOf, type SearchKind } from "./search-kind.js";
|
|
220
220
|
export type { SearchRefreshed, SyncOptions } from "./search-refresh.js";
|
|
221
221
|
export { SYNC_BOUNDS, SYNC_KEY } from "./search-refresh.js";
|
package/dist/services/index.js
CHANGED
|
@@ -166,7 +166,7 @@ export { RESOURCES_SEARCHED, searchAll, } from "./search-all.js";
|
|
|
166
166
|
export { searchAllIncludingMeetings, } from "./search-all-deprecated.js";
|
|
167
167
|
export { MOST_HITS_PER_MEETING, } from "./search-all-meetings.js";
|
|
168
168
|
export { CATCH_UP_BOUNDS, catchUpSearch, validateCatchUp, } from "./search-catchup.js";
|
|
169
|
-
export { HARDER_MODELS, HARDER_REASON_IDS, readHarderSetting, writeHarderSetting, } from "./search-harder.js";
|
|
169
|
+
export { HARDER_MODELS, HARDER_REASON_IDS, harderRanking, readHarderSetting, writeHarderSetting, } from "./search-harder.js";
|
|
170
170
|
export { accountsOfKind, groupLockOf, listContextOf } from "./search-kind.js";
|
|
171
171
|
export { SYNC_BOUNDS, SYNC_KEY } from "./search-refresh.js";
|
|
172
172
|
export { SERVER_BOUNDS, SERVER_SEARCH_KEY, } from "./server-search.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type KeyringStore } from "@wirecat/cli-base";
|
|
2
|
+
import type { Ranking } from "@wirecat/cli-base/standards";
|
|
2
3
|
import * as v from "valibot";
|
|
3
|
-
import { type ModelAdapter } from "../models/index.js";
|
|
4
|
+
import { type ModelAdapter, type ModelUsage } from "../models/index.js";
|
|
4
5
|
import type { AppIdentity } from "../ports/app.js";
|
|
5
6
|
import { type EnrichmentProvider } from "./enrichment-setting.js";
|
|
6
7
|
/**
|
|
@@ -34,10 +35,14 @@ export interface HarderResult {
|
|
|
34
35
|
/** Hits sent to the model; 0 when nothing left this machine. */
|
|
35
36
|
sent: number;
|
|
36
37
|
cost_usd: number | null;
|
|
38
|
+
/** Tokens as the provider reported them; absent when nothing came back. */
|
|
39
|
+
usage?: ModelUsage;
|
|
37
40
|
ms: number;
|
|
38
41
|
reason?: string;
|
|
39
42
|
reason_id?: HarderReasonId;
|
|
40
43
|
}
|
|
44
|
+
/** The result as the answer's `meta.ranking`: the same facts, with the reason as its code alone. */
|
|
45
|
+
export declare const harderRanking: ({ reason: _reason, ...rest }: HarderResult) => Ranking;
|
|
41
46
|
export interface HarderOptions {
|
|
42
47
|
/** The tool whose keyring entry holds the key; without it only the environment's key is read. */
|
|
43
48
|
app?: AppIdentity;
|