@wirecat/cli-core 0.614.0 → 0.616.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 +105 -0
- package/dist/background/report/messages.d.ts +108 -0
- package/dist/background/report/messages.js +230 -0
- package/dist/background/report/render.d.ts +41 -5
- package/dist/background/report/render.js +115 -25
- package/dist/background/report/schema.d.ts +7 -1
- package/dist/background/report/schema.js +9 -3
- package/dist/background/report/stored-templates.d.ts +66 -0
- package/dist/background/report/stored-templates.js +85 -0
- package/dist/background/report/templates/morning-digest.email.en.liquid +3 -0
- package/dist/background/report/templates/morning-digest.email.ru.liquid +3 -0
- package/dist/background/report/templates/morning-digest.sample.json +157 -0
- package/dist/background/report/templates/morning-digest.telegram.en.liquid +3 -0
- package/dist/background/report/templates/morning-digest.telegram.ru.liquid +3 -0
- package/dist/background/report/templates/morning-digest.text.en.liquid +3 -0
- package/dist/background/report/templates/morning-digest.text.ru.liquid +3 -0
- package/dist/background/report/templates/schedule-failed.email.en.liquid +12 -0
- package/dist/background/report/templates/schedule-failed.email.ru.liquid +12 -0
- package/dist/background/report/templates/schedule-failed.sample.json +10 -0
- package/dist/background/report/templates/schedule-failed.telegram.en.liquid +9 -0
- package/dist/background/report/templates/schedule-failed.telegram.ru.liquid +9 -0
- package/dist/background/report/templates/schedule-failed.text.en.liquid +9 -0
- package/dist/background/report/templates/schedule-failed.text.ru.liquid +9 -0
- package/dist/background/report/templates/weekly-gaps.email.en.liquid +19 -0
- package/dist/background/report/templates/weekly-gaps.email.ru.liquid +19 -0
- package/dist/background/report/templates/weekly-gaps.sample.json +33 -0
- package/dist/background/report/templates/weekly-gaps.telegram.en.liquid +15 -0
- package/dist/background/report/templates/weekly-gaps.telegram.ru.liquid +15 -0
- package/dist/background/report/templates/weekly-gaps.text.en.liquid +14 -0
- package/dist/background/report/templates/weekly-gaps.text.ru.liquid +14 -0
- package/dist/background/report/view.d.ts +5 -0
- package/dist/background/report/view.js +9 -1
- package/dist/background/schedules.d.ts +13 -2
- package/dist/background/schedules.js +128 -30
- package/dist/cli/help/sections.js +1 -0
- package/dist/cli/index.d.ts +2 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/schedule/schedule-command.d.ts +2 -0
- package/dist/cli/schedule/schedule-command.js +21 -2
- package/dist/cli/shared-command-exports.d.ts +1 -0
- package/dist/cli/shared-command-exports.js +2 -0
- package/dist/cli/templates-command.d.ts +16 -0
- package/dist/cli/templates-command.js +266 -0
- package/dist/domain/links.d.ts +1 -1
- package/dist/domain/links.js +1 -1
- package/dist/entities/fact.d.ts +4 -0
- package/dist/entities/fact.js +2 -1
- package/dist/entities/fields.d.ts +5 -0
- package/dist/entities/fields.js +3 -0
- package/dist/entities/index.d.ts +21 -1
- package/dist/entities/index.js +3 -1
- package/dist/entities/list-results.d.ts +4 -2
- package/dist/entities/list-results.js +4 -2
- package/dist/entities/memory.d.ts +4 -0
- package/dist/entities/memory.js +2 -1
- package/dist/entities/template.d.ts +11 -0
- package/dist/entities/template.js +12 -0
- package/dist/errors/reasons.js +13 -0
- package/dist/meetings/mcp/index.d.ts +15 -15
- package/dist/services/metadata.d.ts +1 -1
- package/dist/store/exports.d.ts +2 -0
- package/dist/store/exports.js +2 -0
- package/dist/store/index.d.ts +4 -2
- package/dist/store/index.js +1 -0
- package/dist/store/people.d.ts +7 -0
- package/dist/store/people.js +4 -0
- package/dist/store/source-review.d.ts +21 -0
- package/dist/store/sqlite/accounts.d.ts +3 -1
- package/dist/store/sqlite/accounts.js +10 -3
- package/dist/store/sqlite/added-sources.d.ts +16 -0
- package/dist/store/sqlite/added-sources.js +22 -0
- package/dist/store/sqlite/facts.js +3 -2
- package/dist/store/sqlite/imported-documents.js +3 -2
- package/dist/store/sqlite/knowledge.js +6 -4
- package/dist/store/sqlite/manifest.js +1 -0
- package/dist/store/sqlite/memories.js +5 -4
- package/dist/store/sqlite/mention-drain.js +9 -1
- package/dist/store/sqlite/merged-persons.d.ts +24 -0
- package/dist/store/sqlite/merged-persons.js +59 -0
- package/dist/store/sqlite/migrations.generated.js +8 -0
- package/dist/store/sqlite/notes.js +5 -4
- package/dist/store/sqlite/person-links.d.ts +10 -1
- package/dist/store/sqlite/person-links.js +14 -6
- package/dist/store/sqlite/person-merges.d.ts +39 -0
- package/dist/store/sqlite/person-merges.js +136 -0
- package/dist/store/sqlite/person-preparation.js +11 -8
- package/dist/store/sqlite/person-resolution.js +2 -1
- package/dist/store/sqlite/person-scope.js +2 -1
- package/dist/store/sqlite/relation-list.js +3 -2
- package/dist/store/sqlite/reported-relations.js +6 -3
- package/dist/store/sqlite/schema/templates.d.ts +242 -0
- package/dist/store/sqlite/schema/templates.js +23 -0
- package/dist/store/sqlite/schema.d.ts +1 -0
- package/dist/store/sqlite/schema.js +1 -0
- package/dist/store/sqlite/source-review.d.ts +20 -1
- package/dist/store/sqlite/source-review.js +74 -3
- package/dist/store/sqlite/task-board.d.ts +6 -1
- package/dist/store/sqlite/task-board.js +22 -4
- package/dist/store/sqlite/templates.d.ts +38 -0
- package/dist/store/sqlite/templates.js +69 -0
- package/dist/store/sqlite/work-tasks.js +8 -9
- package/dist/store/store.d.ts +3 -0
- package/dist/store/store.js +5 -0
- package/dist/store/types.d.ts +2 -0
- package/package.json +4 -4
- package/parity.json +19 -0
package/dist/cli/index.d.ts
CHANGED
|
@@ -133,10 +133,11 @@ export { type DeclaredSetting, type SettingRow, settingRows, withSettingDefaults
|
|
|
133
133
|
export { type Config, type Configuration, count, first, flag, fromFile, type GlobalFlags, NONE_NAMED, namedProfile, type ProfileKind, plain, type ResolveOptions, type Settings, type SettingsExtension, type SettingsExtensionContext, type Source, settingsFor, } from "./settings.js";
|
|
134
134
|
export { type PermissionAnswer, readSetupAnswers, type SetupAnswers, setupPermissionCeiling } from "./setup-answers.js";
|
|
135
135
|
export { AGENTS, type Agent, agentFor, screenFor } from "./setup-screen.js";
|
|
136
|
-
export { accountCommand, addMeetingBatchCommand, addMeetingPreparationCommand, addMeetingProjectCandidatesCommand, addMeetingSeriesInventoryCommand, appDoctorCommand, appMcpCommand, attachmentsCommand, botAdminsCommand, botCommand, botMcpCommand, botMembersCommand, botMessagesCommand, callsCommand, chatsCommand, commandsCommand, completeCommand, configCommand, contactsCommand, conversationsCommand, deleteCommand, doctorCommand, editCommand, floodCommand, forwardCommand, generatedApiCommand, guideCommand, imagesCommand, inboxCommand, markReadCommand, mcpCommand, mentionsCommand, messagesCommand, metadataCommand, modelCatalogueCommand, modelsCommand, pinCommand, pollsCommand, projectsCommand, reactionsCommand, recipientsCommand, repliesCommand, reviewCommand, runsCommand, scheduleCommand, scheduleCommandFor, searchCommand, searchesCommand, sendCommand, sendsCommand, serveCommand, serverCommand, skillCommand, starCommands, statsCommand, stickersCommand, storeCommand, tagsCommand, tasksCommand, tasksStatsCommand, topicsCommand, unpinCommand, upgradeCommand, watchCommand, } from "./shared-command-exports.js";
|
|
136
|
+
export { accountCommand, addMeetingBatchCommand, addMeetingPreparationCommand, addMeetingProjectCandidatesCommand, addMeetingSeriesInventoryCommand, appDoctorCommand, appMcpCommand, attachmentsCommand, botAdminsCommand, botCommand, botMcpCommand, botMembersCommand, botMessagesCommand, callsCommand, chatsCommand, commandsCommand, completeCommand, configCommand, contactsCommand, conversationsCommand, deleteCommand, doctorCommand, editCommand, floodCommand, forwardCommand, generatedApiCommand, guideCommand, imagesCommand, inboxCommand, markReadCommand, mcpCommand, mentionsCommand, messagesCommand, metadataCommand, modelCatalogueCommand, modelsCommand, pinCommand, pollsCommand, projectsCommand, reactionsCommand, recipientsCommand, repliesCommand, reviewCommand, runsCommand, scheduleCommand, scheduleCommandFor, searchCommand, searchesCommand, sendCommand, sendsCommand, serveCommand, serverCommand, skillCommand, starCommands, statsCommand, stickersCommand, storeCommand, tagsCommand, tasksCommand, tasksStatsCommand, templatesCommand, topicsCommand, unpinCommand, upgradeCommand, watchCommand, } from "./shared-command-exports.js";
|
|
137
137
|
export { assertSharedContracts, customizeSharedCommand, hasSharedContract, overrideSharedContract, type SharedContractOverride, sharedContractOverrides, sharedContracts, } from "./shared-contracts.js";
|
|
138
138
|
export { runnable, withSafety } from "./steps.js";
|
|
139
139
|
export { type StoreInfo, sharedStoreCommand, storeInfo, storeInfoCommand } from "./store-info.js";
|
|
140
140
|
export { type RecoveryCheck, type RecoveryRun, recoveryNotes, storeRecoverCommand, storeRecoveryCheck, storeRecoveryRun, } from "./store-recover.js";
|
|
141
141
|
export { changeStoreSetting, isStoreSetting, STORE_SETTINGS, storeSettings } from "./store-settings.js";
|
|
142
|
+
export type { TemplatesOptions } from "./templates-command.js";
|
|
142
143
|
export { restartServers, type UpgradeContext } from "./upgrade-command.js";
|
package/dist/cli/index.js
CHANGED
|
@@ -123,7 +123,7 @@ export { settingRows, withSettingDefaults } from "./setting-defaults.js";
|
|
|
123
123
|
export { count, first, flag, fromFile, NONE_NAMED, namedProfile, plain, settingsFor, } from "./settings.js";
|
|
124
124
|
export { readSetupAnswers, setupPermissionCeiling } from "./setup-answers.js";
|
|
125
125
|
export { AGENTS, agentFor, screenFor } from "./setup-screen.js";
|
|
126
|
-
export { accountCommand, addMeetingBatchCommand, addMeetingPreparationCommand, addMeetingProjectCandidatesCommand, addMeetingSeriesInventoryCommand, appDoctorCommand, appMcpCommand, attachmentsCommand, botAdminsCommand, botCommand, botMcpCommand, botMembersCommand, botMessagesCommand, callsCommand, chatsCommand, commandsCommand, completeCommand, configCommand, contactsCommand, conversationsCommand, deleteCommand, doctorCommand, editCommand, floodCommand, forwardCommand, generatedApiCommand, guideCommand, imagesCommand, inboxCommand, markReadCommand, mcpCommand, mentionsCommand, messagesCommand, metadataCommand, modelCatalogueCommand, modelsCommand, pinCommand, pollsCommand, projectsCommand, reactionsCommand, recipientsCommand, repliesCommand, reviewCommand, runsCommand, scheduleCommand, scheduleCommandFor, searchCommand, searchesCommand, sendCommand, sendsCommand, serveCommand, serverCommand, skillCommand, starCommands, statsCommand, stickersCommand, storeCommand, tagsCommand, tasksCommand, tasksStatsCommand, topicsCommand, unpinCommand, upgradeCommand, watchCommand, } from "./shared-command-exports.js";
|
|
126
|
+
export { accountCommand, addMeetingBatchCommand, addMeetingPreparationCommand, addMeetingProjectCandidatesCommand, addMeetingSeriesInventoryCommand, appDoctorCommand, appMcpCommand, attachmentsCommand, botAdminsCommand, botCommand, botMcpCommand, botMembersCommand, botMessagesCommand, callsCommand, chatsCommand, commandsCommand, completeCommand, configCommand, contactsCommand, conversationsCommand, deleteCommand, doctorCommand, editCommand, floodCommand, forwardCommand, generatedApiCommand, guideCommand, imagesCommand, inboxCommand, markReadCommand, mcpCommand, mentionsCommand, messagesCommand, metadataCommand, modelCatalogueCommand, modelsCommand, pinCommand, pollsCommand, projectsCommand, reactionsCommand, recipientsCommand, repliesCommand, reviewCommand, runsCommand, scheduleCommand, scheduleCommandFor, searchCommand, searchesCommand, sendCommand, sendsCommand, serveCommand, serverCommand, skillCommand, starCommands, statsCommand, stickersCommand, storeCommand, tagsCommand, tasksCommand, tasksStatsCommand, templatesCommand, topicsCommand, unpinCommand, upgradeCommand, watchCommand, } from "./shared-command-exports.js";
|
|
127
127
|
export { assertSharedContracts, customizeSharedCommand, hasSharedContract, overrideSharedContract, sharedContractOverrides, sharedContracts, } from "./shared-contracts.js";
|
|
128
128
|
export { runnable, withSafety } from "./steps.js";
|
|
129
129
|
export { sharedStoreCommand, storeInfo, storeInfoCommand } from "./store-info.js";
|
|
@@ -44,6 +44,8 @@ export declare const scheduleLimitsOf: (config: {
|
|
|
44
44
|
schedule_model_codex?: unknown;
|
|
45
45
|
schedule_lean_start?: unknown;
|
|
46
46
|
}) => ScheduleLimits;
|
|
47
|
+
/** The language a report is rendered in: the store's `owner_languages`, first one; Russian when it cannot be read. */
|
|
48
|
+
export declare const ownerLanguageOf: (env: NodeJS.ProcessEnv) => Promise<string>;
|
|
47
49
|
/**
|
|
48
50
|
* Runs the CLI's own commands, or an agent, later or on a timer — through systemd (Linux), launchd
|
|
49
51
|
* (macOS) or Task Scheduler (Windows). Every timer runs `schedule exec <file>`; the schedule file holds
|
|
@@ -4,6 +4,8 @@ import { CliError, resolvePaths, writeSecurely } from "@wirecat/cli-base";
|
|
|
4
4
|
import { annotate } from "@wirecat/cli-base/commands";
|
|
5
5
|
import { Argument, Command, Option } from "commander";
|
|
6
6
|
import { parseRoute, ROUTE_HELP, routeText } from "../../background/deliver.js";
|
|
7
|
+
import { REPORT_CHANNELS } from "../../background/report/render.js";
|
|
8
|
+
import { keyOfKind } from "../../background/report/stored-templates.js";
|
|
7
9
|
import { describeWhen, findProgram, lastRun, listSchedules, NOTIFY_WHEN, notifyOf, readSchedule, recordSkip, runSchedule, SCHEDULE_DEFAULTS, SKIP_REASONS, scheduleFile, scheduleName, spentToday, timerFor, } from "../../background/schedules.js";
|
|
8
10
|
import { thisMachine } from "../../background/system.js";
|
|
9
11
|
import { locationVariables } from "../../background/units.js";
|
|
@@ -13,7 +15,7 @@ import { readOnlyLockOf } from "../../ports/app.js";
|
|
|
13
15
|
import { aheadOf } from "../../services/moment.js";
|
|
14
16
|
import { openCache } from "../../store/open.js";
|
|
15
17
|
import { storePath } from "../../store/path.js";
|
|
16
|
-
import { ownerLanguages } from "../../store/store.js";
|
|
18
|
+
import { ownerLanguages, storedTemplateBodies } from "../../store/store.js";
|
|
17
19
|
import { environmentOf, setExitCode } from "../context.js";
|
|
18
20
|
import { grantsAuthority, LOCAL_READ, LOCAL_WRITE, REMOTE_WRITE } from "../effects.js";
|
|
19
21
|
import { itemOf, listOf, renderAnswer, snakeKeys } from "../envelope.js";
|
|
@@ -157,7 +159,7 @@ const runCapOf = (argv) => {
|
|
|
157
159
|
return Number.isFinite(cap) ? cap : null;
|
|
158
160
|
};
|
|
159
161
|
/** The language a report is rendered in: the store's `owner_languages`, first one; Russian when it cannot be read. */
|
|
160
|
-
const ownerLanguageOf = async (env) => {
|
|
162
|
+
export const ownerLanguageOf = async (env) => {
|
|
161
163
|
const path = storePath(env);
|
|
162
164
|
if (!existsSync(path))
|
|
163
165
|
return "ru";
|
|
@@ -170,6 +172,20 @@ const ownerLanguageOf = async (env) => {
|
|
|
170
172
|
database.close();
|
|
171
173
|
}
|
|
172
174
|
};
|
|
175
|
+
/** The templates the owner saved for a report, read without migrating the store; none when there is no store. */
|
|
176
|
+
const reportTemplatesOf = (env) => async (kind, language) => {
|
|
177
|
+
const path = storePath(env);
|
|
178
|
+
if (!existsSync(path))
|
|
179
|
+
return {};
|
|
180
|
+
const database = await openCache(path);
|
|
181
|
+
try {
|
|
182
|
+
const bodies = storedTemplateBodies(database, keyOfKind(kind), language);
|
|
183
|
+
return Object.fromEntries(REPORT_CHANNELS.flatMap((channel) => (channel in bodies ? [[channel, bodies[channel]]] : [])));
|
|
184
|
+
}
|
|
185
|
+
finally {
|
|
186
|
+
database.close();
|
|
187
|
+
}
|
|
188
|
+
};
|
|
173
189
|
/**
|
|
174
190
|
* Runs the CLI's own commands, or an agent, later or on a timer — through systemd (Linux), launchd
|
|
175
191
|
* (macOS) or Task Scheduler (Windows). Every timer runs `schedule exec <file>`; the schedule file holds
|
|
@@ -446,6 +462,7 @@ export const scheduleCommandFor = ({ app, context: contextOf, newMail, agentInpu
|
|
|
446
462
|
timer: timer(),
|
|
447
463
|
agentRuns,
|
|
448
464
|
ownerLanguage: ownerLanguageOf,
|
|
465
|
+
reportTemplates: reportTemplatesOf,
|
|
449
466
|
...(agentInput ? { agentInput } : {}),
|
|
450
467
|
...(signal ? { signal } : {}),
|
|
451
468
|
}));
|
|
@@ -483,8 +500,10 @@ export const scheduleCommandFor = ({ app, context: contextOf, newMail, agentInpu
|
|
|
483
500
|
timer: timer(),
|
|
484
501
|
agentRuns,
|
|
485
502
|
ownerLanguage: ownerLanguageOf,
|
|
503
|
+
reportTemplates: reportTemplatesOf,
|
|
486
504
|
...(agentInput ? { agentInput } : {}),
|
|
487
505
|
untilUnlocked: true,
|
|
506
|
+
skipRepeatedInput: true,
|
|
488
507
|
...(signal ? { signal } : {}),
|
|
489
508
|
}));
|
|
490
509
|
if (last.exitCode !== 0)
|
|
@@ -815,3 +815,4 @@ export declare const runsCommand: (app: import("./entry.js").AppIdentity) => imp
|
|
|
815
815
|
export declare const skillCommand: (app: import("./entry.js").AppIdentity, skill: URL) => import("commander").Command;
|
|
816
816
|
export declare const upgradeCommand: (app: import("./entry.js").AppIdentity, packageName: string, contextFor: (command: import("commander").Command) => import("./upgrade-command.js").UpgradeContext) => import("commander").Command;
|
|
817
817
|
export declare const modelCatalogueCommand: (app: import("./entry.js").AppIdentity, options: import("./model-catalogue-command.js").ModelCatalogueOptions) => import("commander").Command;
|
|
818
|
+
export declare const templatesCommand: (app: import("./entry.js").AppIdentity, options: import("./templates-command.js").TemplatesOptions) => import("commander").Command;
|
|
@@ -121,4 +121,6 @@ export const runsCommand = sharedCommand(runsCommandDefinition);
|
|
|
121
121
|
export const skillCommand = sharedCommand(skillCommandDefinition);
|
|
122
122
|
export const upgradeCommand = sharedCommand(upgradeCommandDefinition);
|
|
123
123
|
import { modelCatalogueCommand as modelCatalogueDefinition } from "./model-catalogue-command.js";
|
|
124
|
+
import { templatesCommand as templatesDefinition } from "./templates-command.js";
|
|
124
125
|
export const modelCatalogueCommand = sharedCommand(modelCatalogueDefinition);
|
|
126
|
+
export const templatesCommand = sharedCommand(templatesDefinition);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import type { AppIdentity } from "../ports/app.js";
|
|
3
|
+
import { type Body } from "./envelope.js";
|
|
4
|
+
export interface TemplatesOptions {
|
|
5
|
+
env: () => NodeJS.ProcessEnv;
|
|
6
|
+
output: (answer: Body, command: Command) => void;
|
|
7
|
+
diagnostic: (line: string) => void;
|
|
8
|
+
/** Opens `path` in the owner's editor and returns when it closes; `$VISUAL` or `$EDITOR` when absent. */
|
|
9
|
+
editor?: (path: string, env: NodeJS.ProcessEnv) => void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* `templates`: the owner's own templates for the messages WireCat sends him, kept in the shared store over the ones
|
|
13
|
+
* cli-core ships. The platform rules (escaping, the tags each channel keeps, links only to the report's own, the
|
|
14
|
+
* Telegram size) stay in code and run after every render, so a template cannot break them.
|
|
15
|
+
*/
|
|
16
|
+
export declare const templatesCommand: (app: AppIdentity, options: TemplatesOptions) => Command;
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { CliError, resolvePaths } from "@wirecat/cli-base";
|
|
6
|
+
import { annotate } from "@wirecat/cli-base/commands";
|
|
7
|
+
import { queryFieldsOf } from "@wirecat/cli-base/query";
|
|
8
|
+
import { Command, Option } from "commander";
|
|
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";
|
|
11
|
+
import { template } from "../entities/index.js";
|
|
12
|
+
import { agentOf } from "../runs/run-context.js";
|
|
13
|
+
import { openStore } from "../store/store.js";
|
|
14
|
+
import { grantsAuthority, LOCAL_READ, LOCAL_WRITE } from "./effects.js";
|
|
15
|
+
import { itemOf, listOf } from "./envelope.js";
|
|
16
|
+
import { queryTerms, withQuery } from "./list-query.js";
|
|
17
|
+
import { ownerLanguageOf } from "./schedule/schedule-command.js";
|
|
18
|
+
const withStore = async (env, work) => {
|
|
19
|
+
const store = await openStore({ env });
|
|
20
|
+
try {
|
|
21
|
+
return await work(store);
|
|
22
|
+
}
|
|
23
|
+
finally {
|
|
24
|
+
await store.close();
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const systemEditor = (path, env) => {
|
|
28
|
+
const editor = env.VISUAL?.trim() || env.EDITOR?.trim();
|
|
29
|
+
if (!editor)
|
|
30
|
+
throw new CliError("validation_error", "set VISUAL or EDITOR, or pass the template with --file", {
|
|
31
|
+
reason: "template.no-editor",
|
|
32
|
+
});
|
|
33
|
+
const [program = editor, ...args] = editor.split(/\s+/);
|
|
34
|
+
const ran = spawnSync(program, [...args, path], { stdio: "inherit", env });
|
|
35
|
+
if (ran.status !== 0)
|
|
36
|
+
throw new CliError("validation_error", `the editor exited with ${ran.status ?? ran.signal}; nothing was saved`);
|
|
37
|
+
};
|
|
38
|
+
const channelOption = () => new Option("--channel <channel>", "telegram (Bot API HTML), email (HTML with inline styles) or text")
|
|
39
|
+
.choices(REPORT_CHANNELS)
|
|
40
|
+
.makeOptionMandatory();
|
|
41
|
+
const localeOption = () => new Option("--locale <code>", "the template's language, ISO 639-1; the owner's first language if not given");
|
|
42
|
+
const TEMPLATES_QUERY = {
|
|
43
|
+
entity: "template",
|
|
44
|
+
backend: "native",
|
|
45
|
+
fields: queryFieldsOf(template, {
|
|
46
|
+
native: ["key", "channel", "language", "source"],
|
|
47
|
+
exclude: ["about", "renders", "updated_at", "updated_by"],
|
|
48
|
+
examples: { key: 'key:"report/morning-digest"', channel: "channel:telegram", language: "language:en" },
|
|
49
|
+
}).map((field) => ({
|
|
50
|
+
...field,
|
|
51
|
+
operators: field.operators.filter((operator) => operator === "term" || operator === "phrase"),
|
|
52
|
+
})),
|
|
53
|
+
};
|
|
54
|
+
const matching = (rows, terms) => rows.filter((row) => [...terms].every(([field, value]) => String(row[field]).toLowerCase() === value.toLowerCase()));
|
|
55
|
+
/** 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);
|
|
58
|
+
if (!known)
|
|
59
|
+
throw new CliError("validation_error", `no template ${key}; the keys are ${TEMPLATE_KEYS.map((one) => one.key).join(", ")}`, {
|
|
60
|
+
reason: "template.unknown-key",
|
|
61
|
+
});
|
|
62
|
+
const language = (given.locale ?? (await ownerLanguageOf(env))).trim().toLowerCase();
|
|
63
|
+
const languages = shippedLanguages(known.kind);
|
|
64
|
+
if (!languages.includes(language))
|
|
65
|
+
throw new CliError("validation_error", `${key} has templates in ${languages.join(", ")}; a ${language} one would never be used`, { reason: "template.unknown-language" });
|
|
66
|
+
return { address: { key, channel: given.channel, language }, kind: known.kind, channel: given.channel };
|
|
67
|
+
};
|
|
68
|
+
const refuseAgent = (env) => {
|
|
69
|
+
// A template decides what every later digest says to the owner; an agent could make it hide or invent things.
|
|
70
|
+
if (agentOf(env))
|
|
71
|
+
throw new CliError("permission_error", "only the owner changes a message template, not an agent", {
|
|
72
|
+
reason: "template.owner-only",
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
const stateOf = (app, env) => resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state;
|
|
76
|
+
const historyOf = (store, address) => store.templates.history(address).map((entry) => ({
|
|
77
|
+
id: entry.id,
|
|
78
|
+
saved_at: new Date(entry.savedAt).toISOString(),
|
|
79
|
+
saved_by: entry.savedBy,
|
|
80
|
+
replaced_at: new Date(entry.replacedAt).toISOString(),
|
|
81
|
+
chars: entry.body.length,
|
|
82
|
+
}));
|
|
83
|
+
/**
|
|
84
|
+
* `templates`: the owner's own templates for the messages WireCat sends him, kept in the shared store over the ones
|
|
85
|
+
* cli-core ships. The platform rules (escaping, the tags each channel keeps, links only to the report's own, the
|
|
86
|
+
* Telegram size) stay in code and run after every render, so a template cannot break them.
|
|
87
|
+
*/
|
|
88
|
+
export const templatesCommand = (app, options) => {
|
|
89
|
+
const editor = options.editor ?? systemEditor;
|
|
90
|
+
const templates = annotate(new Command("templates"), { effects: LOCAL_READ })
|
|
91
|
+
.summary("the templates of the messages sent to you; edit, preview, reset")
|
|
92
|
+
.description("the templates of the digest and the other messages sent to you, per channel and language; edit, preview, reset");
|
|
93
|
+
withQuery(annotate(templates.command("list"), {
|
|
94
|
+
effects: LOCAL_READ,
|
|
95
|
+
examples: [`${app.command} templates list`, `${app.command} templates list channel:telegram language:en`],
|
|
96
|
+
}), TEMPLATES_QUERY)
|
|
97
|
+
.summary("every template, and whether yours or the shipped one applies")
|
|
98
|
+
.description("every template key, channel and language, and whether yours or the shipped one applies")
|
|
99
|
+
.action(async function (words) {
|
|
100
|
+
const terms = queryTerms(words, TEMPLATES_QUERY, "templates list");
|
|
101
|
+
const env = options.env();
|
|
102
|
+
const stored = await withStore(env, (store) => store.templates.list());
|
|
103
|
+
const items = TEMPLATE_KEYS.flatMap((known) => REPORT_CHANNELS.flatMap((channel) => shippedLanguages(known.kind).map((language) => {
|
|
104
|
+
const row = stored.find((one) => one.key === known.key && one.channel === channel && one.language === language);
|
|
105
|
+
return {
|
|
106
|
+
key: known.key,
|
|
107
|
+
channel,
|
|
108
|
+
language,
|
|
109
|
+
about: known.about,
|
|
110
|
+
renders: true,
|
|
111
|
+
source: row ? "stored" : "default",
|
|
112
|
+
updated_at: row ? new Date(row.updatedAt).toISOString() : null,
|
|
113
|
+
updated_by: row?.updatedBy ?? null,
|
|
114
|
+
};
|
|
115
|
+
})));
|
|
116
|
+
const found = matching(items, terms);
|
|
117
|
+
options.output(listOf("templates list", { items: found, limit: found.length, has_more: false }), this);
|
|
118
|
+
});
|
|
119
|
+
annotate(templates.command("show"), {
|
|
120
|
+
effects: LOCAL_READ,
|
|
121
|
+
examples: [`${app.command} templates show report/morning-digest --channel telegram`],
|
|
122
|
+
})
|
|
123
|
+
.summary("the template that applies, and the bodies your changes replaced")
|
|
124
|
+
.description("the template that applies, yours or the shipped one, and the bodies your changes replaced")
|
|
125
|
+
.argument("<key>", "the template, such as report/morning-digest")
|
|
126
|
+
.addOption(channelOption())
|
|
127
|
+
.addOption(localeOption())
|
|
128
|
+
.action(async function (key, given) {
|
|
129
|
+
const env = options.env();
|
|
130
|
+
const { address, kind, channel } = await addressOf(key, given, env);
|
|
131
|
+
const item = await withStore(env, (store) => {
|
|
132
|
+
const row = store.templates.get(address);
|
|
133
|
+
return {
|
|
134
|
+
...address,
|
|
135
|
+
source: row ? "stored" : "default",
|
|
136
|
+
body: row?.body ?? defaultTemplate(kind, channel, address.language),
|
|
137
|
+
updated_at: row ? new Date(row.updatedAt).toISOString() : null,
|
|
138
|
+
updated_by: row?.updatedBy ?? null,
|
|
139
|
+
history: historyOf(store, address),
|
|
140
|
+
};
|
|
141
|
+
});
|
|
142
|
+
options.output(itemOf(item), this);
|
|
143
|
+
});
|
|
144
|
+
grantsAuthority(annotate(templates.command("edit"), {
|
|
145
|
+
effects: LOCAL_WRITE,
|
|
146
|
+
examples: [
|
|
147
|
+
`${app.command} templates edit report/morning-digest --channel telegram`,
|
|
148
|
+
`${app.command} templates edit report/morning-digest --channel text --file digest.text.liquid`,
|
|
149
|
+
`${app.command} templates edit report/morning-digest --channel telegram --undo`,
|
|
150
|
+
],
|
|
151
|
+
}))
|
|
152
|
+
.summary("change a template in $EDITOR or from --file; checked before it is saved")
|
|
153
|
+
.description("change a template in $EDITOR or from --file; it is checked first, and a failed check saves nothing and says why")
|
|
154
|
+
.argument("<key>", "the template, such as report/morning-digest")
|
|
155
|
+
.addOption(channelOption())
|
|
156
|
+
.addOption(localeOption())
|
|
157
|
+
.option("--file <file>", "take the new template from this file instead of opening an editor")
|
|
158
|
+
.addOption(new Option("--undo", "put back the body your last change replaced; twice is back where you were").conflicts("file"))
|
|
159
|
+
.action(async function (key, given) {
|
|
160
|
+
const env = options.env();
|
|
161
|
+
refuseAgent(env);
|
|
162
|
+
const { address, kind, channel } = await addressOf(key, given, env);
|
|
163
|
+
const { current, previous } = await withStore(env, (store) => ({
|
|
164
|
+
current: store.templates.get(address)?.body,
|
|
165
|
+
previous: store.templates.history(address, 1)[0]?.body,
|
|
166
|
+
}));
|
|
167
|
+
const effective = current ?? defaultTemplate(kind, channel, address.language);
|
|
168
|
+
let draft;
|
|
169
|
+
let body;
|
|
170
|
+
if (given.undo) {
|
|
171
|
+
if (previous === undefined)
|
|
172
|
+
throw new CliError("validation_error", `${key} ${channel} ${address.language} has no earlier body to put back`, {
|
|
173
|
+
reason: "template.no-history",
|
|
174
|
+
});
|
|
175
|
+
body = previous;
|
|
176
|
+
}
|
|
177
|
+
else if (given.file !== undefined) {
|
|
178
|
+
body = readFileSync(given.file, "utf8");
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
draft = join(mkdtempSync(join(tmpdir(), "wirecat-template-")), `${key.replace("/", "-")}.${channel}.${address.language}.liquid`);
|
|
182
|
+
writeFileSync(draft, effective, { mode: 0o600 });
|
|
183
|
+
editor(draft, env);
|
|
184
|
+
body = readFileSync(draft, "utf8");
|
|
185
|
+
}
|
|
186
|
+
if (body === effective) {
|
|
187
|
+
if (draft)
|
|
188
|
+
rmSync(join(draft, ".."), { recursive: true, force: true });
|
|
189
|
+
options.diagnostic(`${key} ${channel} ${address.language} is unchanged; nothing saved`);
|
|
190
|
+
options.output(itemOf({ ...address, changed: false }), this);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const checks = await checkTemplateSave({
|
|
194
|
+
kind,
|
|
195
|
+
channel,
|
|
196
|
+
language: address.language,
|
|
197
|
+
body,
|
|
198
|
+
state: stateOf(app, env),
|
|
199
|
+
now: Date.now(),
|
|
200
|
+
});
|
|
201
|
+
const problems = checks.flatMap((check) => check.problems.map((problem) => `${check.against}: ${problem}`));
|
|
202
|
+
if (problems.length > 0)
|
|
203
|
+
throw new CliError("validation_error", `the template was not saved — ${problems.join("; ")}${draft ? `. Your text is in ${draft}; fix it and run again with --file ${draft}` : ""}`, { reason: "template.check-failed" });
|
|
204
|
+
const saved = await withStore(env, (store) => store.templates.save(address, body, app.command));
|
|
205
|
+
if (draft)
|
|
206
|
+
rmSync(join(draft, ".."), { recursive: true, force: true });
|
|
207
|
+
options.diagnostic(`saved ${key} ${channel} ${address.language}; checked against ${checks.map((check) => check.against).join(" and ")}`);
|
|
208
|
+
options.output(itemOf({
|
|
209
|
+
...address,
|
|
210
|
+
changed: true,
|
|
211
|
+
updated_at: new Date(saved.updatedAt).toISOString(),
|
|
212
|
+
updated_by: saved.updatedBy,
|
|
213
|
+
checked_against: checks.map((check) => check.against),
|
|
214
|
+
}), this);
|
|
215
|
+
});
|
|
216
|
+
annotate(templates.command("preview"), {
|
|
217
|
+
effects: LOCAL_READ,
|
|
218
|
+
examples: [
|
|
219
|
+
`${app.command} templates preview report/morning-digest --channel telegram`,
|
|
220
|
+
`${app.command} templates preview report/morning-digest --channel email --file draft.liquid`,
|
|
221
|
+
],
|
|
222
|
+
})
|
|
223
|
+
.summary("what would be sent on that channel; saves nothing")
|
|
224
|
+
.description("what would be sent on that channel, from the last real report or a synthetic one when there is none; saves nothing")
|
|
225
|
+
.argument("<key>", "the template, such as report/morning-digest")
|
|
226
|
+
.addOption(channelOption())
|
|
227
|
+
.addOption(localeOption())
|
|
228
|
+
.option("--file <file>", "preview this draft instead of the template that applies")
|
|
229
|
+
.action(async function (key, given) {
|
|
230
|
+
const env = options.env();
|
|
231
|
+
const { address, kind, channel } = await addressOf(key, given, env);
|
|
232
|
+
const stored = given.file === undefined ? await withStore(env, (store) => store.templates.get(address)?.body) : undefined;
|
|
233
|
+
const body = given.file === undefined ? stored : readFileSync(given.file, "utf8");
|
|
234
|
+
const { against, view } = previewView(stateOf(app, env), kind, address.language, Date.now());
|
|
235
|
+
const rendering = await renderReport(view, channel, body === undefined ? {} : { template: body });
|
|
236
|
+
const problems = body === undefined ? [] : (await checkTemplate(view, channel, body)).problems;
|
|
237
|
+
options.output(itemOf({
|
|
238
|
+
...address,
|
|
239
|
+
template: given.file === undefined ? (stored === undefined ? "default" : "stored") : given.file,
|
|
240
|
+
against,
|
|
241
|
+
template_failed: rendering.templateFailed,
|
|
242
|
+
problems,
|
|
243
|
+
text: rendering.text,
|
|
244
|
+
}), this);
|
|
245
|
+
});
|
|
246
|
+
grantsAuthority(annotate(templates.command("reset"), {
|
|
247
|
+
effects: LOCAL_WRITE,
|
|
248
|
+
examples: [`${app.command} templates reset report/morning-digest --channel telegram`],
|
|
249
|
+
}))
|
|
250
|
+
.summary("go back to the shipped template; edit --undo brings yours back")
|
|
251
|
+
.description("go back to the shipped template; yours is kept in the history, and edit --undo brings it back")
|
|
252
|
+
.argument("<key>", "the template, such as report/morning-digest")
|
|
253
|
+
.addOption(channelOption())
|
|
254
|
+
.addOption(localeOption())
|
|
255
|
+
.action(async function (key, given) {
|
|
256
|
+
const env = options.env();
|
|
257
|
+
refuseAgent(env);
|
|
258
|
+
const { address } = await addressOf(key, given, env);
|
|
259
|
+
const changed = await withStore(env, (store) => store.templates.reset(address));
|
|
260
|
+
options.diagnostic(changed
|
|
261
|
+
? `${key} ${address.channel} ${address.language} uses the shipped template again`
|
|
262
|
+
: `${key} ${address.channel} ${address.language} already uses the shipped template`);
|
|
263
|
+
options.output(itemOf({ ...address, changed }), this);
|
|
264
|
+
});
|
|
265
|
+
return templates;
|
|
266
|
+
};
|
package/dist/domain/links.d.ts
CHANGED
package/dist/domain/links.js
CHANGED
|
@@ -4,7 +4,7 @@ export const DEFAULT_LINK_CONFIG = { base: "https://wirecat.dev/o", enabled: tru
|
|
|
4
4
|
const APP_PREFIX = "wirecat://open";
|
|
5
5
|
const MAX_PATH = 512;
|
|
6
6
|
const MAX_SEGMENTS = 6;
|
|
7
|
-
const TASK_FILTERS = ["overdue", "today", "tomorrow"];
|
|
7
|
+
const TASK_FILTERS = ["overdue", "today", "tomorrow", "undated"];
|
|
8
8
|
const DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
9
9
|
const DATE_TIME = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})$/;
|
|
10
10
|
const isMoment = (text, pattern) => pattern.test(text) && !Number.isNaN(Date.parse(text));
|
package/dist/entities/fact.d.ts
CHANGED
|
@@ -40,6 +40,10 @@ export declare const fact: v.StrictObjectSchema<{
|
|
|
40
40
|
readonly tool: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
41
41
|
readonly missing: v.BooleanSchema<undefined>;
|
|
42
42
|
}, undefined>, undefined>, undefined>;
|
|
43
|
+
readonly source_review: v.OptionalSchema<v.NullableSchema<v.StrictObjectSchema<{
|
|
44
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
45
|
+
readonly cause: v.PicklistSchema<readonly ["changed", "outdated", "deleted", "contradicted"], undefined>;
|
|
46
|
+
}, undefined>, undefined>, undefined>;
|
|
43
47
|
readonly created_at: 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`">]>;
|
|
44
48
|
readonly updated_at: 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`">]>;
|
|
45
49
|
}, undefined>;
|
package/dist/entities/fact.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import { FACT_STATUSES, FACT_TYPES, MEMORY_SCOPES } from "../domain/knowledge.js";
|
|
3
|
-
import { author, evidenceSource, id, reference, text, time } from "./fields.js";
|
|
3
|
+
import { author, evidenceSource, id, reference, sourceReview, text, time } from "./fields.js";
|
|
4
4
|
export const fact = v.strictObject({
|
|
5
5
|
ref: reference,
|
|
6
6
|
id,
|
|
@@ -26,6 +26,7 @@ export const fact = v.strictObject({
|
|
|
26
26
|
evidence: v.array(reference),
|
|
27
27
|
/** With `--sources`: each piece of evidence read back. */
|
|
28
28
|
sources: v.optional(v.array(evidenceSource)),
|
|
29
|
+
source_review: v.optional(sourceReview),
|
|
29
30
|
created_at: time,
|
|
30
31
|
updated_at: time,
|
|
31
32
|
});
|
|
@@ -21,6 +21,11 @@ export declare const evidenceSource: v.StrictObjectSchema<{
|
|
|
21
21
|
readonly tool: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
22
22
|
readonly missing: v.BooleanSchema<undefined>;
|
|
23
23
|
}, undefined>;
|
|
24
|
+
/** The open review of a memory's or fact's sources, when one waits for the owner (`memory_source_review`). */
|
|
25
|
+
export declare const sourceReview: v.NullableSchema<v.StrictObjectSchema<{
|
|
26
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
27
|
+
readonly cause: v.PicklistSchema<readonly ["changed", "outdated", "deleted", "contradicted"], undefined>;
|
|
28
|
+
}, undefined>, undefined>;
|
|
24
29
|
export declare const author: v.StrictObjectSchema<{
|
|
25
30
|
readonly type: v.PicklistSchema<["person", "bot"], undefined>;
|
|
26
31
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
package/dist/entities/fields.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isoTime, reference } from "@wirecat/cli-base/standards";
|
|
2
2
|
import * as v from "valibot";
|
|
3
|
+
import { SOURCE_REVIEW_CAUSES } from "../store/source-review.js";
|
|
3
4
|
export { reference };
|
|
4
5
|
export const text = v.string();
|
|
5
6
|
export const id = v.pipe(v.string(), v.minLength(1));
|
|
@@ -21,6 +22,8 @@ export const evidenceSource = v.strictObject({
|
|
|
21
22
|
tool: v.nullable(text),
|
|
22
23
|
missing: v.boolean(),
|
|
23
24
|
});
|
|
25
|
+
/** The open review of a memory's or fact's sources, when one waits for the owner (`memory_source_review`). */
|
|
26
|
+
export const sourceReview = v.nullable(v.strictObject({ id, cause: v.picklist(SOURCE_REVIEW_CAUSES) }));
|
|
24
27
|
export const author = v.strictObject({
|
|
25
28
|
type: v.picklist(["person", "bot"]),
|
|
26
29
|
id,
|
package/dist/entities/index.d.ts
CHANGED
|
@@ -84,13 +84,14 @@ import { tagging } from "./tagging.js";
|
|
|
84
84
|
import { task } from "./task.js";
|
|
85
85
|
import { taskPair } from "./task-pair.js";
|
|
86
86
|
import { taskAnalysis, taskAnalysisMark, taskCard, taskCategories, taskClosed, taskCreated, taskLinks, taskMerge, taskScan, taskSimilar, taskUnmerge } from "./task-results.js";
|
|
87
|
+
import { template } from "./template.js";
|
|
87
88
|
import { topic } from "./topic.js";
|
|
88
89
|
/**
|
|
89
90
|
* One schema per thing a command can answer with. A command returns an entity or one of its views — a
|
|
90
91
|
* subset of its fields, never a renamed one. Commands move onto these one by one; until then, a schema
|
|
91
92
|
* is the target, not a description of today's output.
|
|
92
93
|
*/
|
|
93
|
-
export { account, accountChange, accountPrivacy, accountPrivacyChange, accountProfile, accountSession, adminReport, agenda, analysisConsent, analysisConsentRevocation, attachment, attachmentBytes, attachmentExtraction, attachmentTextChange, automaticTags, botAdmin, botMenuEntry, botProfile, botSeenChat, botTemplate, botWebhook, cachedChatMetadata, callRecord, chart, chat, chatAdminChange, chatArchive, chatCoverage, chatEvent, chatFolderChange, chatFolderOrder, chatFolderRemoval, chatGroupChange, chatInspection, chatInvite, chatInviteChange, chatMembersChange, chatMembersFetch, chatMetadata, chatMetadataRefresh, chatModeration, chatMuting, chatPin, chatRead, chatRemoval, chatRequestChange, chatRules, chatSender, chatStats, chatTracking, chatUnread, contact, contactActivity, contactAlias, contactCheck, contactContext, contactImport, contactLookup, contactNote, contactNoteRemoval, contactPreparation, contactStateChange, contactSync, contactUpdate, conversation, conversationBatch, conversationBatchStatus, conversationBuildResult, conversationChange, conversationDetails, conversationEmbedding, conversationEmbeddingStatus, conversationHit, conversationPreparation, conversationReadiness, counterRefresh, counters, document, documentLink, endedAccountSessions, evidence, evidencePacket, fact, folder, hit, identity, imageEmbedding, inviteLink, job, joinRequest, linkedPerson, mailCounts, mediaArchive, mediaArchiveCheck, mediaArchiveMove, mediaArchiveTimer, meeting, meetingProjectCandidates, meetingSeriesInventory, member, memory, mention, mentionDecision, mentionDetails, mentionDomain, mentionRebuild, message, messageContext, messageCounts, messageDeletion, messageDownload, messageEvent, messageLink, messageLinks, messagePin, messageStar, messageSync, messageTranscript, messageWrite, model, modelKey, note, officialStats, organization, person, place, poll, pollChange, pollVote, project, ranking, reaction, reactionChange, recipient, recipientAdded, recipientChange, recipientOff, recipientRemoved, recordedRun, reference, relationship, reminder, removedModelKey, responseTimes, retention, runDetails, runHit, runLocation, savedSearch, scheduledJob, searchHistoryClear, sendAttempt, serveSummary, stickerInventory, storeBackup, storeChatStatus, storeCheck, storeClear, storeCopyRemoval, storeDecrypt, storedModelKey, storeExport, storeGapPlan, storeGapRepair, storeInfo, storeJobCancel, storeJobClear, storeJobDetails, storeJobRetry, storeMigration, storeReindex, storeRepair, storeReset, storeRestore, storeTable, tagChange, tagging, task, taskAnalysis, taskAnalysisMark, taskCard, taskCategories, taskClosed, taskCreated, taskLinks, taskMerge, taskPair, taskScan, taskSimilar, taskStats, taskUnmerge, topic, topicIcon, trackedChat, trackedChatHistory, waitingChats, watchedMessage, watchItem, };
|
|
94
|
+
export { account, accountChange, accountPrivacy, accountPrivacyChange, accountProfile, accountSession, adminReport, agenda, analysisConsent, analysisConsentRevocation, attachment, attachmentBytes, attachmentExtraction, attachmentTextChange, automaticTags, botAdmin, botMenuEntry, botProfile, botSeenChat, botTemplate, botWebhook, cachedChatMetadata, callRecord, chart, chat, chatAdminChange, chatArchive, chatCoverage, chatEvent, chatFolderChange, chatFolderOrder, chatFolderRemoval, chatGroupChange, chatInspection, chatInvite, chatInviteChange, chatMembersChange, chatMembersFetch, chatMetadata, chatMetadataRefresh, chatModeration, chatMuting, chatPin, chatRead, chatRemoval, chatRequestChange, chatRules, chatSender, chatStats, chatTracking, chatUnread, contact, contactActivity, contactAlias, contactCheck, contactContext, contactImport, contactLookup, contactNote, contactNoteRemoval, contactPreparation, contactStateChange, contactSync, contactUpdate, conversation, conversationBatch, conversationBatchStatus, conversationBuildResult, conversationChange, conversationDetails, conversationEmbedding, conversationEmbeddingStatus, conversationHit, conversationPreparation, conversationReadiness, counterRefresh, counters, document, documentLink, endedAccountSessions, evidence, evidencePacket, fact, folder, hit, identity, imageEmbedding, inviteLink, job, joinRequest, linkedPerson, mailCounts, mediaArchive, mediaArchiveCheck, mediaArchiveMove, mediaArchiveTimer, meeting, meetingProjectCandidates, meetingSeriesInventory, member, memory, mention, mentionDecision, mentionDetails, mentionDomain, mentionRebuild, message, messageContext, messageCounts, messageDeletion, messageDownload, messageEvent, messageLink, messageLinks, messagePin, messageStar, messageSync, messageTranscript, messageWrite, model, modelKey, note, officialStats, organization, person, place, poll, pollChange, pollVote, project, ranking, reaction, reactionChange, recipient, recipientAdded, recipientChange, recipientOff, recipientRemoved, recordedRun, reference, relationship, reminder, removedModelKey, responseTimes, retention, runDetails, runHit, runLocation, savedSearch, scheduledJob, searchHistoryClear, sendAttempt, serveSummary, stickerInventory, storeBackup, storeChatStatus, storeCheck, storeClear, storeCopyRemoval, storeDecrypt, storedModelKey, storeExport, storeGapPlan, storeGapRepair, storeInfo, storeJobCancel, storeJobClear, storeJobDetails, storeJobRetry, storeMigration, storeReindex, storeRepair, storeReset, storeRestore, storeTable, tagChange, tagging, task, taskAnalysis, taskAnalysisMark, taskCard, taskCategories, taskClosed, taskCreated, taskLinks, taskMerge, taskPair, taskScan, taskSimilar, taskStats, taskUnmerge, template, topic, topicIcon, trackedChat, trackedChatHistory, waitingChats, watchedMessage, watchItem, };
|
|
94
95
|
export declare const ENTITIES: {
|
|
95
96
|
readonly meeting_ingestion: v.StrictObjectSchema<{
|
|
96
97
|
readonly meetings: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
@@ -4189,6 +4190,7 @@ export declare const ENTITIES: {
|
|
|
4189
4190
|
readonly failing_since: v.OptionalSchema<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>;
|
|
4190
4191
|
readonly failures: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
4191
4192
|
readonly cost_usd: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
4193
|
+
readonly input_hash: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
4192
4194
|
readonly skipped: v.OptionalSchema<v.StrictObjectSchema<{
|
|
4193
4195
|
readonly at: 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`">]>;
|
|
4194
4196
|
readonly why: v.StringSchema<undefined>;
|
|
@@ -5291,6 +5293,10 @@ export declare const ENTITIES: {
|
|
|
5291
5293
|
readonly tool: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
5292
5294
|
readonly missing: v.BooleanSchema<undefined>;
|
|
5293
5295
|
}, undefined>, undefined>, undefined>;
|
|
5296
|
+
readonly source_review: v.OptionalSchema<v.NullableSchema<v.StrictObjectSchema<{
|
|
5297
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
5298
|
+
readonly cause: v.PicklistSchema<readonly ["changed", "outdated", "deleted", "contradicted"], undefined>;
|
|
5299
|
+
}, undefined>, undefined>, undefined>;
|
|
5294
5300
|
readonly created_at: 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`">]>;
|
|
5295
5301
|
readonly updated_at: 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`">]>;
|
|
5296
5302
|
}, undefined>;
|
|
@@ -5326,6 +5332,10 @@ export declare const ENTITIES: {
|
|
|
5326
5332
|
readonly missing: v.BooleanSchema<undefined>;
|
|
5327
5333
|
}, undefined>, undefined>, undefined>;
|
|
5328
5334
|
readonly last_verified_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>;
|
|
5335
|
+
readonly source_review: v.OptionalSchema<v.NullableSchema<v.StrictObjectSchema<{
|
|
5336
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
5337
|
+
readonly cause: v.PicklistSchema<readonly ["changed", "outdated", "deleted", "contradicted"], undefined>;
|
|
5338
|
+
}, undefined>, undefined>, undefined>;
|
|
5329
5339
|
readonly created_at: 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`">]>;
|
|
5330
5340
|
readonly updated_at: 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`">]>;
|
|
5331
5341
|
}, undefined>;
|
|
@@ -11897,6 +11907,16 @@ export declare const ENTITIES: {
|
|
|
11897
11907
|
readonly mean_open_age_ms: v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
11898
11908
|
}, undefined>, undefined>;
|
|
11899
11909
|
}, undefined>;
|
|
11910
|
+
readonly template: v.StrictObjectSchema<{
|
|
11911
|
+
readonly key: v.StringSchema<undefined>;
|
|
11912
|
+
readonly channel: v.PicklistSchema<["telegram", "email", "text"], undefined>;
|
|
11913
|
+
readonly language: v.StringSchema<undefined>;
|
|
11914
|
+
readonly about: v.StringSchema<undefined>;
|
|
11915
|
+
readonly renders: v.BooleanSchema<undefined>;
|
|
11916
|
+
readonly source: v.PicklistSchema<["stored", "default"], undefined>;
|
|
11917
|
+
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>;
|
|
11918
|
+
readonly updated_by: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
11919
|
+
}, undefined>;
|
|
11900
11920
|
};
|
|
11901
11921
|
export type EntityName = keyof typeof ENTITIES;
|
|
11902
11922
|
/** Every entity as a JSON Schema 2020-12 `$defs` entry, for bundling into an MCP tool's `outputSchema`. */
|
package/dist/entities/index.js
CHANGED
|
@@ -92,13 +92,14 @@ import { tagging } from "./tagging.js";
|
|
|
92
92
|
import { task } from "./task.js";
|
|
93
93
|
import { taskPair } from "./task-pair.js";
|
|
94
94
|
import { taskAnalysis, taskAnalysisMark, taskAnalysisMarkMoved, taskCard, taskCategories, taskClosed, taskCreated, taskLinks, taskMerge, taskReview, taskScan, taskSimilar, taskUnmerge, } from "./task-results.js";
|
|
95
|
+
import { template } from "./template.js";
|
|
95
96
|
import { topic } from "./topic.js";
|
|
96
97
|
/**
|
|
97
98
|
* One schema per thing a command can answer with. A command returns an entity or one of its views — a
|
|
98
99
|
* subset of its fields, never a renamed one. Commands move onto these one by one; until then, a schema
|
|
99
100
|
* is the target, not a description of today's output.
|
|
100
101
|
*/
|
|
101
|
-
export { account, accountChange, accountPrivacy, accountPrivacyChange, accountProfile, accountSession, adminReport, agenda, analysisConsent, analysisConsentRevocation, attachment, attachmentBytes, attachmentExtraction, attachmentTextChange, automaticTags, botAdmin, botMenuEntry, botProfile, botSeenChat, botTemplate, botWebhook, cachedChatMetadata, callRecord, chart, chat, chatAdminChange, chatArchive, chatCoverage, chatEvent, chatFolderChange, chatFolderOrder, chatFolderRemoval, chatGroupChange, chatInspection, chatInvite, chatInviteChange, chatMembersChange, chatMembersFetch, chatMetadata, chatMetadataRefresh, chatModeration, chatMuting, chatPin, chatRead, chatRemoval, chatRequestChange, chatRules, chatSender, chatStats, chatTracking, chatUnread, contact, contactActivity, contactAlias, contactCheck, contactContext, contactImport, contactLookup, contactNote, contactNoteRemoval, contactPreparation, contactStateChange, contactSync, contactUpdate, conversation, conversationBatch, conversationBatchStatus, conversationBuildResult, conversationChange, conversationDetails, conversationEmbedding, conversationEmbeddingStatus, conversationHit, conversationPreparation, conversationReadiness, counterRefresh, counters, document, documentLink, endedAccountSessions, evidence, evidencePacket, fact, folder, hit, identity, imageEmbedding, inviteLink, job, joinRequest, linkedPerson, mailCounts, mediaArchive, mediaArchiveCheck, mediaArchiveMove, mediaArchiveTimer, meeting, meetingProjectCandidates, meetingSeriesInventory, member, memory, mention, mentionDecision, mentionDetails, mentionDomain, mentionRebuild, message, messageContext, messageCounts, messageDeletion, messageDownload, messageEvent, messageLink, messageLinks, messagePin, messageStar, messageSync, messageTranscript, messageWrite, model, modelKey, note, officialStats, organization, person, place, poll, pollChange, pollVote, project, ranking, reaction, reactionChange, recipient, recipientAdded, recipientChange, recipientOff, recipientRemoved, recordedRun, reference, relationship, reminder, removedModelKey, responseTimes, retention, runDetails, runHit, runLocation, savedSearch, scheduledJob, searchHistoryClear, sendAttempt, serveSummary, stickerInventory, storeBackup, storeChatStatus, storeCheck, storeClear, storeCopyRemoval, storeDecrypt, storedModelKey, storeExport, storeGapPlan, storeGapRepair, storeInfo, storeJobCancel, storeJobClear, storeJobDetails, storeJobRetry, storeMigration, storeReindex, storeRepair, storeReset, storeRestore, storeTable, tagChange, tagging, task, taskAnalysis, taskAnalysisMark, taskCard, taskCategories, taskClosed, taskCreated, taskLinks, taskMerge, taskPair, taskScan, taskSimilar, taskStats, taskUnmerge, topic, topicIcon, trackedChat, trackedChatHistory, waitingChats, watchedMessage, watchItem, };
|
|
102
|
+
export { account, accountChange, accountPrivacy, accountPrivacyChange, accountProfile, accountSession, adminReport, agenda, analysisConsent, analysisConsentRevocation, attachment, attachmentBytes, attachmentExtraction, attachmentTextChange, automaticTags, botAdmin, botMenuEntry, botProfile, botSeenChat, botTemplate, botWebhook, cachedChatMetadata, callRecord, chart, chat, chatAdminChange, chatArchive, chatCoverage, chatEvent, chatFolderChange, chatFolderOrder, chatFolderRemoval, chatGroupChange, chatInspection, chatInvite, chatInviteChange, chatMembersChange, chatMembersFetch, chatMetadata, chatMetadataRefresh, chatModeration, chatMuting, chatPin, chatRead, chatRemoval, chatRequestChange, chatRules, chatSender, chatStats, chatTracking, chatUnread, contact, contactActivity, contactAlias, contactCheck, contactContext, contactImport, contactLookup, contactNote, contactNoteRemoval, contactPreparation, contactStateChange, contactSync, contactUpdate, conversation, conversationBatch, conversationBatchStatus, conversationBuildResult, conversationChange, conversationDetails, conversationEmbedding, conversationEmbeddingStatus, conversationHit, conversationPreparation, conversationReadiness, counterRefresh, counters, document, documentLink, endedAccountSessions, evidence, evidencePacket, fact, folder, hit, identity, imageEmbedding, inviteLink, job, joinRequest, linkedPerson, mailCounts, mediaArchive, mediaArchiveCheck, mediaArchiveMove, mediaArchiveTimer, meeting, meetingProjectCandidates, meetingSeriesInventory, member, memory, mention, mentionDecision, mentionDetails, mentionDomain, mentionRebuild, message, messageContext, messageCounts, messageDeletion, messageDownload, messageEvent, messageLink, messageLinks, messagePin, messageStar, messageSync, messageTranscript, messageWrite, model, modelKey, note, officialStats, organization, person, place, poll, pollChange, pollVote, project, ranking, reaction, reactionChange, recipient, recipientAdded, recipientChange, recipientOff, recipientRemoved, recordedRun, reference, relationship, reminder, removedModelKey, responseTimes, retention, runDetails, runHit, runLocation, savedSearch, scheduledJob, searchHistoryClear, sendAttempt, serveSummary, stickerInventory, storeBackup, storeChatStatus, storeCheck, storeClear, storeCopyRemoval, storeDecrypt, storedModelKey, storeExport, storeGapPlan, storeGapRepair, storeInfo, storeJobCancel, storeJobClear, storeJobDetails, storeJobRetry, storeMigration, storeReindex, storeRepair, storeReset, storeRestore, storeTable, tagChange, tagging, task, taskAnalysis, taskAnalysisMark, taskCard, taskCategories, taskClosed, taskCreated, taskLinks, taskMerge, taskPair, taskScan, taskSimilar, taskStats, taskUnmerge, template, topic, topicIcon, trackedChat, trackedChatHistory, waitingChats, watchedMessage, watchItem, };
|
|
102
103
|
export const ENTITIES = {
|
|
103
104
|
sync_progress: syncProgress,
|
|
104
105
|
deal,
|
|
@@ -380,6 +381,7 @@ export const ENTITIES = {
|
|
|
380
381
|
tracked_chat_history: trackedChatHistory,
|
|
381
382
|
chat_tracking: chatTracking,
|
|
382
383
|
task_stats: taskStats,
|
|
384
|
+
template,
|
|
383
385
|
};
|
|
384
386
|
/** Every entity as a JSON Schema 2020-12 `$defs` entry, for bundling into an MCP tool's `outputSchema`. */
|
|
385
387
|
export const entityDefinitions = () => Object.fromEntries(Object.entries(ENTITIES).map(([name, schema]) => {
|
|
@@ -62,11 +62,13 @@ export declare const scheduledJob: v.StrictObjectSchema<{
|
|
|
62
62
|
readonly failing_since: v.OptionalSchema<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>;
|
|
63
63
|
readonly failures: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
64
64
|
readonly cost_usd: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
65
|
-
|
|
65
|
+
readonly input_hash: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
66
|
+
/** The last time a run did not start, and why: the day's cost cap, too little new mail, or the same input. */
|
|
66
67
|
readonly skipped: v.OptionalSchema<v.StrictObjectSchema<{
|
|
67
68
|
readonly at: 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`">]>;
|
|
68
69
|
readonly why: v.StringSchema<undefined>;
|
|
69
|
-
/** A dotted id for `why`, so a client can translate it: `cost.day-cap`, `mail.none-new`, `mail.below-threshold
|
|
70
|
+
/** A dotted id for `why`, so a client can translate it: `cost.day-cap`, `mail.none-new`, `mail.below-threshold`,
|
|
71
|
+
* `mail.same-input`. */
|
|
70
72
|
readonly reason: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
|
|
71
73
|
}, undefined>, undefined>;
|
|
72
74
|
/** How the run's result went along each route; `reason` a dotted id, `error` the sending CLI's code and reason id. */
|