@tidegap/core 0.18.0 → 0.20.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/README.md +3 -1
- package/dist/agent-snippet.d.ts +30 -0
- package/dist/agent-snippet.js +120 -0
- package/dist/budget.d.ts +0 -12
- package/dist/budget.js +2 -24
- package/dist/channels/commands.d.ts +137 -0
- package/dist/channels/commands.js +377 -0
- package/dist/channels/delivery-codes.d.ts +9 -0
- package/dist/channels/delivery-codes.js +53 -0
- package/dist/channels/digest.d.ts +102 -0
- package/dist/channels/digest.js +146 -0
- package/dist/channels/format.d.ts +127 -0
- package/dist/channels/format.js +407 -0
- package/dist/channels/index.d.ts +15 -0
- package/dist/channels/index.js +15 -0
- package/dist/channels/kinds/command.d.ts +13 -0
- package/dist/channels/kinds/command.js +65 -0
- package/dist/channels/kinds/discord.d.ts +16 -0
- package/dist/channels/kinds/discord.js +67 -0
- package/dist/channels/kinds/email.d.ts +20 -0
- package/dist/channels/kinds/email.js +162 -0
- package/dist/channels/kinds/index.d.ts +8 -0
- package/dist/channels/kinds/index.js +17 -0
- package/dist/channels/kinds/ntfy.d.ts +25 -0
- package/dist/channels/kinds/ntfy.js +163 -0
- package/dist/channels/kinds/pushover.d.ts +11 -0
- package/dist/channels/kinds/pushover.js +77 -0
- package/dist/channels/kinds/shared.d.ts +25 -0
- package/dist/channels/kinds/shared.js +39 -0
- package/dist/channels/kinds/shortcuts.d.ts +9 -0
- package/dist/channels/kinds/shortcuts.js +45 -0
- package/dist/channels/kinds/slack.d.ts +8 -0
- package/dist/channels/kinds/slack.js +57 -0
- package/dist/channels/kinds/telegram.d.ts +4 -0
- package/dist/channels/kinds/telegram.js +26 -0
- package/dist/channels/kinds/webhook.d.ts +30 -0
- package/dist/channels/kinds/webhook.js +177 -0
- package/dist/channels/payload.d.ts +36 -0
- package/dist/channels/payload.js +61 -0
- package/dist/channels/plan.d.ts +24 -0
- package/dist/channels/plan.js +66 -0
- package/dist/channels/registry.d.ts +191 -0
- package/dist/channels/registry.js +125 -0
- package/dist/channels/telegram.d.ts +110 -0
- package/dist/channels/telegram.js +168 -0
- package/dist/channels/types.d.ts +107 -0
- package/dist/channels/types.js +26 -0
- package/dist/claude-tools.d.ts +29 -0
- package/dist/claude-tools.js +49 -0
- package/dist/data/tables.generated.d.ts +6 -0
- package/dist/data/tables.generated.js +37 -0
- package/dist/energy.d.ts +77 -0
- package/dist/energy.js +131 -0
- package/dist/grid.d.ts +19 -2
- package/dist/grid.js +84 -28
- package/dist/handoff.d.ts +152 -0
- package/dist/handoff.js +430 -0
- package/dist/history.d.ts +2 -0
- package/dist/history.js +3 -1
- package/dist/index.d.ts +46 -16
- package/dist/index.js +34 -8
- package/dist/job-cadence.d.ts +76 -0
- package/dist/job-cadence.js +240 -0
- package/dist/jobs.d.ts +173 -0
- package/dist/jobs.js +794 -0
- package/dist/notify.d.ts +2 -0
- package/dist/notify.js +2 -1
- package/dist/paths.d.ts +13 -46
- package/dist/paths.js +51 -219
- package/dist/postpone.d.ts +113 -0
- package/dist/postpone.js +185 -0
- package/dist/providers/anthropic.js +7 -3
- package/dist/providers/base.d.ts +113 -1
- package/dist/providers/base.js +15 -0
- package/dist/providers/budget.d.ts +25 -0
- package/dist/providers/budget.js +57 -0
- package/dist/providers/defaults.js +4 -0
- package/dist/providers/defer.d.ts +16 -0
- package/dist/providers/defer.js +31 -0
- package/dist/providers/gemini.d.ts +1 -0
- package/dist/providers/gemini.js +27 -20
- package/dist/providers/index.d.ts +2 -2
- package/dist/providers/index.js +1 -1
- package/dist/providers/ollama.d.ts +1 -0
- package/dist/providers/ollama.js +26 -22
- package/dist/providers/openai.js +5 -5
- package/dist/providers/timeout.d.ts +18 -0
- package/dist/providers/timeout.js +33 -0
- package/dist/quota.d.ts +7 -2
- package/dist/quota.js +13 -29
- package/dist/readiness.d.ts +169 -0
- package/dist/readiness.js +254 -0
- package/dist/redact.d.ts +42 -0
- package/dist/redact.js +110 -0
- package/dist/region-host.d.ts +30 -0
- package/dist/region-host.js +69 -0
- package/dist/region.d.ts +102 -20
- package/dist/region.js +175 -23
- package/dist/run-session.d.ts +36 -0
- package/dist/run-session.js +72 -0
- package/dist/schedule-job.d.ts +95 -0
- package/dist/schedule-job.js +195 -0
- package/dist/scheduler.d.ts +245 -14
- package/dist/scheduler.js +925 -110
- package/dist/sign.d.ts +8 -1
- package/dist/sign.js +49 -3
- package/dist/storage/sqlite.d.ts +157 -5
- package/dist/storage/sqlite.js +661 -20
- package/dist/task-events.d.ts +102 -0
- package/dist/task-events.js +308 -0
- package/dist/tool-surface.d.ts +31 -2
- package/dist/tool-surface.js +359 -65
- package/dist/types.d.ts +246 -3
- package/dist/types.js +8 -1
- package/dist/zone-time.d.ts +22 -0
- package/dist/zone-time.js +76 -0
- package/package.json +11 -6
- package/dist/aggregator.d.ts.map +0 -1
- package/dist/aggregator.js.map +0 -1
- package/dist/budget.d.ts.map +0 -1
- package/dist/budget.js.map +0 -1
- package/dist/data/tables.generated.d.ts.map +0 -1
- package/dist/data/tables.generated.js.map +0 -1
- package/dist/energy.d.ts.map +0 -1
- package/dist/energy.js.map +0 -1
- package/dist/grid.d.ts.map +0 -1
- package/dist/grid.js.map +0 -1
- package/dist/history.d.ts.map +0 -1
- package/dist/history.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/notify.d.ts.map +0 -1
- package/dist/notify.js.map +0 -1
- package/dist/paths.d.ts.map +0 -1
- package/dist/paths.js.map +0 -1
- package/dist/providers/anthropic.d.ts.map +0 -1
- package/dist/providers/anthropic.js.map +0 -1
- package/dist/providers/base.d.ts.map +0 -1
- package/dist/providers/base.js.map +0 -1
- package/dist/providers/defaults.d.ts.map +0 -1
- package/dist/providers/defaults.js.map +0 -1
- package/dist/providers/gemini.d.ts.map +0 -1
- package/dist/providers/gemini.js.map +0 -1
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/providers/index.js.map +0 -1
- package/dist/providers/ollama.d.ts.map +0 -1
- package/dist/providers/ollama.js.map +0 -1
- package/dist/providers/openai.d.ts.map +0 -1
- package/dist/providers/openai.js.map +0 -1
- package/dist/quota.d.ts.map +0 -1
- package/dist/quota.js.map +0 -1
- package/dist/recommend.d.ts.map +0 -1
- package/dist/recommend.js.map +0 -1
- package/dist/redact.d.ts.map +0 -1
- package/dist/redact.js.map +0 -1
- package/dist/region.d.ts.map +0 -1
- package/dist/region.js.map +0 -1
- package/dist/routing.d.ts.map +0 -1
- package/dist/routing.js.map +0 -1
- package/dist/scheduler.d.ts.map +0 -1
- package/dist/scheduler.js.map +0 -1
- package/dist/select-window.d.ts.map +0 -1
- package/dist/select-window.js.map +0 -1
- package/dist/sign.d.ts.map +0 -1
- package/dist/sign.js.map +0 -1
- package/dist/storage/sqlite.d.ts.map +0 -1
- package/dist/storage/sqlite.js.map +0 -1
- package/dist/tool-surface.d.ts.map +0 -1
- package/dist/tool-surface.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The daily summary (`digest`, integrations plan U15): when it is due and
|
|
3
|
+
* what it says. Pure: the host reads the ledger, calls {@link digestDue} and
|
|
4
|
+
* {@link buildDigest}, and sends the event through the normal channel path.
|
|
5
|
+
*
|
|
6
|
+
* Rules: one summary per local day at `digest_at` (default 09:00, the end of
|
|
7
|
+
* the quiet hours); a day with nothing to report sends nothing; the window
|
|
8
|
+
* starts at the previous summary and covers at most 48 hours.
|
|
9
|
+
*/
|
|
10
|
+
import { localTimeLabel, MORNING_START_H } from "../postpone.js";
|
|
11
|
+
import { problemLine } from "../readiness.js";
|
|
12
|
+
import { messageTitle } from "./format.js";
|
|
13
|
+
/**
|
|
14
|
+
* Ledger meta key: ISO-8601 end of the last summary window. An empty day
|
|
15
|
+
* moves it too, so it is not proof of a send; see {@link DIGEST_SENT_META_KEY}.
|
|
16
|
+
*/
|
|
17
|
+
export const DIGEST_LAST_META_KEY = "notified:digest";
|
|
18
|
+
/** Ledger meta key: ISO-8601 time a summary last reached at least one channel. */
|
|
19
|
+
export const DIGEST_SENT_META_KEY = "digest_sent";
|
|
20
|
+
/** Ledger meta key: the local send time `HH:MM` (absent = {@link DEFAULT_DIGEST_AT}). */
|
|
21
|
+
export const DIGEST_AT_META_KEY = "digest_at";
|
|
22
|
+
/** The default send time: the end of the quiet hours. */
|
|
23
|
+
export const DEFAULT_DIGEST_AT = `${String(MORNING_START_H).padStart(2, "0")}:00`;
|
|
24
|
+
/** The longest window one summary covers (a machine asleep for days sends one summary, not several). */
|
|
25
|
+
export const DIGEST_MAX_WINDOW_MS = 48 * 3_600_000;
|
|
26
|
+
/** The window of the first summary, when no summary was sent before. */
|
|
27
|
+
export const DIGEST_FIRST_WINDOW_MS = 24 * 3_600_000;
|
|
28
|
+
/** Titles listed per section before "and N more". */
|
|
29
|
+
export const DIGEST_LIST_MAX = 10;
|
|
30
|
+
/** `{h, m}` of a valid `HH:MM` (00:00–23:59), else null. */
|
|
31
|
+
export function parseDigestAt(value) {
|
|
32
|
+
if (typeof value !== "string")
|
|
33
|
+
return null;
|
|
34
|
+
const m = /^([01]\d|2[0-3]):([0-5]\d)$/.exec(value.trim());
|
|
35
|
+
return m ? { h: Number(m[1]), m: Number(m[2]) } : null;
|
|
36
|
+
}
|
|
37
|
+
/** The stored send time, or the default when it is absent or invalid. */
|
|
38
|
+
export function digestAt(stored) {
|
|
39
|
+
return parseDigestAt(stored) ? stored.trim() : DEFAULT_DIGEST_AT;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Whether a summary is due at `now` and the window it covers. Due when the
|
|
43
|
+
* local time is at or after today's send time and no summary went out
|
|
44
|
+
* today (local midnight on), so a send time moved later the same day does
|
|
45
|
+
* not send a second one. A spring-forward gap moves the send time to the
|
|
46
|
+
* first valid local minute after it (the `Date` constructor's rule).
|
|
47
|
+
*/
|
|
48
|
+
export function digestDue(now, lastIso, at = DEFAULT_DIGEST_AT) {
|
|
49
|
+
const t = parseDigestAt(digestAt(at));
|
|
50
|
+
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate(), t.h, t.m);
|
|
51
|
+
const last = lastIso !== undefined ? Date.parse(lastIso) : NaN;
|
|
52
|
+
const floor = now.getTime() - DIGEST_MAX_WINDOW_MS;
|
|
53
|
+
const since = new Date(Number.isFinite(last) ? Math.max(last, floor) : now.getTime() - DIGEST_FIRST_WINDOW_MS);
|
|
54
|
+
const midnight = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();
|
|
55
|
+
const due = now.getTime() >= today.getTime() && !(Number.isFinite(last) && last >= midnight);
|
|
56
|
+
return { due, since };
|
|
57
|
+
}
|
|
58
|
+
/** Characters of a run preview a job line quotes. */
|
|
59
|
+
const JOB_PREVIEW_CHARS = 60;
|
|
60
|
+
/** `Mail triage: ok 03:12, "3 messages need a reply..." - next Fri 02:00` (KTD11). */
|
|
61
|
+
export function jobDigestText(job) {
|
|
62
|
+
const { last } = job;
|
|
63
|
+
const when = last.late ? `ran late at ${last.at}` : `${last.outcome} ${last.at}`;
|
|
64
|
+
const preview = last.preview?.replace(/\s+/g, " ").trim();
|
|
65
|
+
const quoted = preview ? `"${preview.length > JOB_PREVIEW_CHARS ? `${preview.slice(0, JOB_PREVIEW_CHARS - 3)}...` : preview}"` : "";
|
|
66
|
+
const next = job.next ? ` - next ${job.next}` : "";
|
|
67
|
+
if (job.runs <= 1) {
|
|
68
|
+
const late = last.late && last.outcome === "failed" ? ` (${last.outcome})` : "";
|
|
69
|
+
return `${job.title}: ${when}${late}${quoted ? `, ${quoted}` : ""}${next}`;
|
|
70
|
+
}
|
|
71
|
+
const failed = job.failed > 0 ? `, ${job.failed} failed` : "";
|
|
72
|
+
const lastText = last.late ? `last ${last.outcome}, ran late at ${last.at}` : `last ${last.outcome} ${last.at}`;
|
|
73
|
+
return `${job.title}: ${job.runs} runs${failed}; ${lastText}${next}`;
|
|
74
|
+
}
|
|
75
|
+
function section(name, records) {
|
|
76
|
+
if (records.length === 0)
|
|
77
|
+
return [];
|
|
78
|
+
const lines = [`${name} (${records.length}):`, ...records.slice(0, DIGEST_LIST_MAX).map((r) => `- ${messageTitle(r)}`)];
|
|
79
|
+
if (records.length > DIGEST_LIST_MAX)
|
|
80
|
+
lines.push(`- and ${records.length - DIGEST_LIST_MAX} more`);
|
|
81
|
+
return lines;
|
|
82
|
+
}
|
|
83
|
+
function grams(records) {
|
|
84
|
+
let sum = 0;
|
|
85
|
+
for (const r of records) {
|
|
86
|
+
const g = r.receipt?.actualCarbonGCo2 ?? r.receipt?.estimatedCarbonGCo2;
|
|
87
|
+
if (typeof g === "number" && Number.isFinite(g))
|
|
88
|
+
sum += g;
|
|
89
|
+
}
|
|
90
|
+
return sum;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The summary event, or null for an empty day: nothing finished, failed or
|
|
94
|
+
* postponed in the window and no open problem. Queued work alone does not
|
|
95
|
+
* make a summary.
|
|
96
|
+
*/
|
|
97
|
+
export function buildDigest(input) {
|
|
98
|
+
const { done, failed, postponed, problems, now } = input;
|
|
99
|
+
const jobs = input.jobs ?? [];
|
|
100
|
+
if (done.length + failed.length + postponed.length + problems.length + jobs.length === 0)
|
|
101
|
+
return null;
|
|
102
|
+
const jobRuns = jobs.reduce((n, j) => n + j.runs, 0);
|
|
103
|
+
const jobFailed = jobs.reduce((n, j) => n + j.failed, 0);
|
|
104
|
+
const doneCount = done.length + jobRuns - jobFailed;
|
|
105
|
+
const failedCount = failed.length + jobFailed;
|
|
106
|
+
const counts = [
|
|
107
|
+
doneCount > 0 ? `${doneCount} done` : "",
|
|
108
|
+
failedCount > 0 ? `${failedCount} failed` : "",
|
|
109
|
+
postponed.length > 0 ? `${postponed.length} postponed` : "",
|
|
110
|
+
].filter(Boolean);
|
|
111
|
+
const title = `Tidegap daily summary${counts.length > 0 ? `: ${counts.join(", ")}` : ""}`;
|
|
112
|
+
const lines = [`Since ${localTimeLabel(input.since, now)}.`];
|
|
113
|
+
// Jobs first, one line each, under the same cap as the task lists (KTD11).
|
|
114
|
+
const printedJobs = jobs.slice(0, DIGEST_LIST_MAX);
|
|
115
|
+
if (jobs.length > 0) {
|
|
116
|
+
lines.push(`Jobs (${jobs.length}):`, ...printedJobs.map((j) => `- ${jobDigestText(j)}`));
|
|
117
|
+
if (jobs.length > DIGEST_LIST_MAX)
|
|
118
|
+
lines.push(`- and ${jobs.length - DIGEST_LIST_MAX} more`);
|
|
119
|
+
}
|
|
120
|
+
lines.push(...section("Done", done), ...section("Failed", failed), ...section("Postponed", postponed));
|
|
121
|
+
const g = grams(done) + jobs.reduce((n, j) => n + (typeof j.grams === "number" && Number.isFinite(j.grams) ? j.grams : 0), 0);
|
|
122
|
+
if (g > 0)
|
|
123
|
+
lines.push(`Carbon of done tasks: ${g < 10 ? g.toFixed(1) : Math.round(g)} g CO2e.`);
|
|
124
|
+
if (problems.length > 0)
|
|
125
|
+
lines.push("Cannot run yet:", ...problems.map(problemLine));
|
|
126
|
+
const w = input.window;
|
|
127
|
+
if (input.queued > 0) {
|
|
128
|
+
const at = w ? ` Next clean window: ${localTimeLabel(new Date(w.start), now)} to ${localTimeLabel(new Date(w.end), now)}.` : "";
|
|
129
|
+
lines.push(`Planned: ${input.queued} queued ${input.queued === 1 ? "task" : "tasks"}.${at}`);
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
kind: "digest",
|
|
133
|
+
title,
|
|
134
|
+
text: lines.join("\n"),
|
|
135
|
+
covers: {
|
|
136
|
+
// Only the titles the summary prints: a task past the cap keeps its own alert.
|
|
137
|
+
taskIds: [
|
|
138
|
+
...[...done.slice(0, DIGEST_LIST_MAX), ...failed.slice(0, DIGEST_LIST_MAX)].map((r) => r.taskId),
|
|
139
|
+
...printedJobs.flatMap((j) => j.coveredTaskIds),
|
|
140
|
+
],
|
|
141
|
+
notReady: problems.length > 0,
|
|
142
|
+
...(w ? { cleanWindow: w.start } : {}),
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=digest.js.map
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Channel message texts and their buttons (KTD10, KTD15, R26, R27). Plain
|
|
3
|
+
* text only. Every title goes through `displayTitle` and control-character
|
|
4
|
+
* stripping; a result preview is the first {@link TELEGRAM_PREVIEW_CHARS}
|
|
5
|
+
* characters, default-redacted, and absent for a task that redacts its
|
|
6
|
+
* receipt (Key Decisions, Q4).
|
|
7
|
+
*
|
|
8
|
+
* Button table, per message:
|
|
9
|
+
*
|
|
10
|
+
* | Message | Buttons |
|
|
11
|
+
* |--------------------|------------------------------------------------------|
|
|
12
|
+
* | task done | [Result] |
|
|
13
|
+
* | task failed | none |
|
|
14
|
+
* | `/queue` listing | per task row: [n Later ▾] [n Run now] [n Cancel], each only when `taskActions` allows it |
|
|
15
|
+
* | `/jobs` listing | none: `/jobs pause|resume|run <n|id>` act on it |
|
|
16
|
+
* | Later ▾ menu | one row per available `postponeOptions` entry: [<label> · <time>] |
|
|
17
|
+
* | clean window | none |
|
|
18
|
+
* | not ready | none |
|
|
19
|
+
* | replies and `/result` | none |
|
|
20
|
+
*/
|
|
21
|
+
import { type PostponeOption, type PostponePreset } from "../postpone.js";
|
|
22
|
+
import { type ReadinessProblem } from "../readiness.js";
|
|
23
|
+
import type { JobRecord, TaskRecord } from "../types.js";
|
|
24
|
+
import { type InlineKeyboard } from "./telegram.js";
|
|
25
|
+
import type { ChannelEvent, CleanWindowEvent, JobPausedNotice } from "./types.js";
|
|
26
|
+
/** Characters of result text a done message previews (Q4). */
|
|
27
|
+
export declare const TELEGRAM_PREVIEW_CHARS = 600;
|
|
28
|
+
/** Most messages one `/result` sends before pointing to `tidegap queue show`. */
|
|
29
|
+
export declare const RESULT_MAX_PARTS = 4;
|
|
30
|
+
/** Tasks one `/queue` lists. */
|
|
31
|
+
export declare const QUEUE_LIST_MAX = 10;
|
|
32
|
+
/** Jobs one `/jobs` lists; the same cap as the digest's lists. */
|
|
33
|
+
export declare const JOBS_LIST_MAX = 10;
|
|
34
|
+
/** A message a host sends: text and optional inline buttons. */
|
|
35
|
+
export interface OutgoingMessage {
|
|
36
|
+
text: string;
|
|
37
|
+
buttons?: InlineKeyboard;
|
|
38
|
+
}
|
|
39
|
+
/** Button actions in `callback_data` (KTD15). */
|
|
40
|
+
export type CallbackActionName = "later" | "cancel" | "run" | "result";
|
|
41
|
+
/** `<action>:<task_id>[:<preset code>]` (KTD15). */
|
|
42
|
+
export declare function encodeCallback(action: CallbackActionName, taskId: string, preset?: PostponePreset): string;
|
|
43
|
+
/**
|
|
44
|
+
* True when every button of a task fits Telegram's 64-byte `callback_data`
|
|
45
|
+
* and `parseCallback` can read it back. A task id that does not (a long
|
|
46
|
+
* custom id) gets no buttons; its commands still work by number or id.
|
|
47
|
+
*/
|
|
48
|
+
export declare function callbackFits(taskId: string): boolean;
|
|
49
|
+
/** The decoding tables, for `parseCallback`. */
|
|
50
|
+
export declare const CALLBACK_ACTIONS: Readonly<Record<string, CallbackActionName>>;
|
|
51
|
+
export declare const CALLBACK_PRESETS: Readonly<Record<string, PostponePreset>>;
|
|
52
|
+
/** True when the task asked for receipt redaction (`redactInReceipt` with patterns): no result text leaves the machine. */
|
|
53
|
+
export declare function isRedactedTask(record: TaskRecord<unknown>): boolean;
|
|
54
|
+
/** The title a message shows: `displayTitle`, one line, at most 80 characters, else the task id. */
|
|
55
|
+
export declare function messageTitle(record: TaskRecord<unknown>): string;
|
|
56
|
+
/** The title a task event's message shows: the job's title for a job occurrence, else {@link messageTitle}. */
|
|
57
|
+
export declare function eventTitle(record: TaskRecord<unknown>, jobTitle?: string): string;
|
|
58
|
+
/**
|
|
59
|
+
* Task done (R26): title, time, where it ran, the preview or the redaction
|
|
60
|
+
* note, and a [Result] button. A job occurrence (`jobTitle`) leads with
|
|
61
|
+
* `<job title>: <result>` (jobs R22).
|
|
62
|
+
*/
|
|
63
|
+
export declare function taskDoneMessage(record: TaskRecord<unknown>, now?: Date, jobTitle?: string): OutgoingMessage;
|
|
64
|
+
/**
|
|
65
|
+
* Task failed: title, time, the first error line, the show command. No
|
|
66
|
+
* buttons. A job occurrence (`jobTitle`) leads with `<job title>: failed`.
|
|
67
|
+
*/
|
|
68
|
+
export declare function taskFailedMessage(record: TaskRecord<unknown>, now?: Date, jobTitle?: string): OutgoingMessage;
|
|
69
|
+
/** The first line of an auto-pause notice (jobs KTD10): `job '<title>' paused after 3 failures: <reason>`. */
|
|
70
|
+
export declare function jobPausedTitle(notice: JobPausedNotice): string;
|
|
71
|
+
/** The auto-pause notice: the sentence, then how to resume. No buttons. */
|
|
72
|
+
export declare function jobPausedMessage(notice: JobPausedNotice): OutgoingMessage;
|
|
73
|
+
/** A clean window starting. No buttons. */
|
|
74
|
+
export declare function cleanWindowMessage(window: CleanWindowEvent, now?: Date): OutgoingMessage;
|
|
75
|
+
/**
|
|
76
|
+
* Tasks will not run (R26): "the tick daemon stopped" for ticker problems,
|
|
77
|
+
* "tasks cannot run" otherwise; `recovered` heads it "running again". No buttons.
|
|
78
|
+
*/
|
|
79
|
+
export declare function notReadyMessage(problems: readonly ReadinessProblem[], recovered?: boolean): OutgoingMessage;
|
|
80
|
+
/** The message for a planned event. */
|
|
81
|
+
export declare function eventMessage(event: ChannelEvent, now?: Date): OutgoingMessage;
|
|
82
|
+
/** `/queue` (R27): numbered tasks and one button row per task. `ids[n-1]` is task n. */
|
|
83
|
+
export declare function queueMessage(records: readonly TaskRecord<unknown>[], now?: Date): OutgoingMessage & {
|
|
84
|
+
ids: string[];
|
|
85
|
+
};
|
|
86
|
+
/** A job's title: one line, at most 80 characters, else the job id. */
|
|
87
|
+
export declare function jobTitle(job: JobRecord): string;
|
|
88
|
+
/** `HH:MM` in `timeZone` when `at` falls on the same day there as `now`, else `Ddd HH:MM`. */
|
|
89
|
+
export declare function zoneTimeLabel(at: Date, now: Date, timeZone: string): string;
|
|
90
|
+
/** The {@link jobNextLabel} of a job whose occurrence is running. */
|
|
91
|
+
export declare const JOB_RUNNING_NOW = "running now";
|
|
92
|
+
/**
|
|
93
|
+
* The next run of a job from its live occurrence: running, the planned
|
|
94
|
+
* hour of a scheduled one, or `~` and the earliest start of a queued one.
|
|
95
|
+
* Undefined without a live occurrence.
|
|
96
|
+
*/
|
|
97
|
+
export declare function jobNextLabel(job: JobRecord, pending: TaskRecord<unknown> | undefined, now: Date): string | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* `/jobs` (R28): counts, then one numbered line per job, active ones first, at most
|
|
100
|
+
* {@link JOBS_LIST_MAX}, then "and N more". Times are in each job's zone.
|
|
101
|
+
* `ids[n-1]` is job n.
|
|
102
|
+
*/
|
|
103
|
+
export declare function jobsMessage(jobs: readonly JobRecord[], taskOf: (id: string) => TaskRecord<unknown> | undefined, now?: Date): OutgoingMessage & {
|
|
104
|
+
ids: string[];
|
|
105
|
+
};
|
|
106
|
+
/** The Later ▾ menu of one task: one button per available option. */
|
|
107
|
+
export declare function laterMenuMessage(record: TaskRecord<unknown>, options: readonly PostponeOption[], now?: Date): OutgoingMessage;
|
|
108
|
+
/** Split text into parts of at most `max` characters, preferring line breaks. */
|
|
109
|
+
export declare function splitMessage(text: string, max?: number): string[];
|
|
110
|
+
/**
|
|
111
|
+
* `/result` and the Result button (R27): no result text for a redacted
|
|
112
|
+
* task; otherwise the result in parts of 4096 characters, at most
|
|
113
|
+
* {@link RESULT_MAX_PARTS}, then a pointer to `tidegap queue show`.
|
|
114
|
+
*/
|
|
115
|
+
export declare function resultMessages(record: TaskRecord<unknown>): OutgoingMessage[];
|
|
116
|
+
/** `/later` grammar (KTD15), quoted by `/help` and the reset-time reply. */
|
|
117
|
+
export declare const LATER_GRAMMAR = "/later <n|id> <1h|tonight|tomorrow|reset [HH:MM]|HH:MM>";
|
|
118
|
+
/** `/jobs` grammar, quoted by `/help` and the usage reply. */
|
|
119
|
+
export declare const JOBS_GRAMMAR = "/jobs [pause|resume|run <n|id>]";
|
|
120
|
+
/** `/help`. */
|
|
121
|
+
export declare const HELP_TEXT: string;
|
|
122
|
+
/** The bot's command menu (`setMyCommands`), parsed from {@link HELP_TEXT}: one source of truth. */
|
|
123
|
+
export declare function telegramCommands(help?: string): {
|
|
124
|
+
command: string;
|
|
125
|
+
description: string;
|
|
126
|
+
}[];
|
|
127
|
+
//# sourceMappingURL=format.d.ts.map
|