charness 3.10.0 → 3.11.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 +29 -0
- package/README.md +2 -1
- package/agent-plugin/skills/charness-manager/SKILL.md +6 -5
- package/dist/bot.d.ts.map +1 -1
- package/dist/bot.js +176 -135
- package/dist/bot.js.map +1 -1
- package/dist/connectors/telegram/commands/botCore.d.ts +1 -0
- package/dist/connectors/telegram/commands/botCore.d.ts.map +1 -1
- package/dist/connectors/telegram/commands/claudeAccounts.js +3 -3
- package/dist/connectors/telegram/commands/claudeAccounts.js.map +1 -1
- package/dist/connectors/telegram/commands/runners.d.ts.map +1 -1
- package/dist/connectors/telegram/commands/runners.js +11 -5
- package/dist/connectors/telegram/commands/runners.js.map +1 -1
- package/dist/connectors/telegram/foldedMessage.d.ts +24 -0
- package/dist/connectors/telegram/foldedMessage.d.ts.map +1 -0
- package/dist/connectors/telegram/foldedMessage.js +39 -0
- package/dist/connectors/telegram/foldedMessage.js.map +1 -0
- package/dist/connectors/telegram/inbound.d.ts +24 -1
- package/dist/connectors/telegram/inbound.d.ts.map +1 -1
- package/dist/connectors/telegram/inbound.js +77 -1
- package/dist/connectors/telegram/inbound.js.map +1 -1
- package/dist/connectors/telegram/renderAgentHtml.d.ts +15 -0
- package/dist/connectors/telegram/renderAgentHtml.d.ts.map +1 -1
- package/dist/connectors/telegram/renderAgentHtml.js +11 -1
- package/dist/connectors/telegram/renderAgentHtml.js.map +1 -1
- package/dist/connectors/telegram/unpinMessages.d.ts +12 -0
- package/dist/connectors/telegram/unpinMessages.d.ts.map +1 -0
- package/dist/connectors/telegram/unpinMessages.js +44 -0
- package/dist/connectors/telegram/unpinMessages.js.map +1 -0
- package/dist/i18n/de.d.ts.map +1 -1
- package/dist/i18n/de.js +11 -3
- package/dist/i18n/de.js.map +1 -1
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +11 -3
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/es.d.ts.map +1 -1
- package/dist/i18n/es.js +11 -3
- package/dist/i18n/es.js.map +1 -1
- package/dist/i18n/fr.d.ts.map +1 -1
- package/dist/i18n/fr.js +11 -3
- package/dist/i18n/fr.js.map +1 -1
- package/dist/i18n/hi.d.ts.map +1 -1
- package/dist/i18n/hi.js +11 -3
- package/dist/i18n/hi.js.map +1 -1
- package/dist/i18n/ja.d.ts.map +1 -1
- package/dist/i18n/ja.js +11 -3
- package/dist/i18n/ja.js.map +1 -1
- package/dist/i18n/ka.d.ts.map +1 -1
- package/dist/i18n/ka.js +11 -3
- package/dist/i18n/ka.js.map +1 -1
- package/dist/i18n/pt.d.ts.map +1 -1
- package/dist/i18n/pt.js +11 -3
- package/dist/i18n/pt.js.map +1 -1
- package/dist/i18n/ru.d.ts.map +1 -1
- package/dist/i18n/ru.js +11 -3
- package/dist/i18n/ru.js.map +1 -1
- package/dist/i18n/uk.d.ts.map +1 -1
- package/dist/i18n/uk.js +11 -3
- package/dist/i18n/uk.js.map +1 -1
- package/dist/i18n/uz.d.ts.map +1 -1
- package/dist/i18n/uz.js +11 -3
- package/dist/i18n/uz.js.map +1 -1
- package/dist/i18n/zh.d.ts.map +1 -1
- package/dist/i18n/zh.js +11 -3
- package/dist/i18n/zh.js.map +1 -1
- package/dist/outputTrace.d.ts +6 -0
- package/dist/outputTrace.d.ts.map +1 -1
- package/dist/outputTrace.js +13 -0
- package/dist/outputTrace.js.map +1 -1
- package/dist/runnerUtility/guiAgentHeal.js +2 -2
- package/dist/runnerUtility/guiAgentHeal.js.map +1 -1
- package/dist/runnerUtility/isolatedCommand.d.ts +0 -2
- package/dist/runnerUtility/isolatedCommand.d.ts.map +1 -1
- package/dist/runnerUtility/isolatedCommand.js +4 -11
- package/dist/runnerUtility/isolatedCommand.js.map +1 -1
- package/dist/scheduler/checkRun.d.ts +9 -10
- package/dist/scheduler/checkRun.d.ts.map +1 -1
- package/dist/scheduler/checkRun.js +8 -16
- package/dist/scheduler/checkRun.js.map +1 -1
- package/dist/scheduler/checkStatus.d.ts +2 -5
- package/dist/scheduler/checkStatus.d.ts.map +1 -1
- package/dist/scheduler/checkStatus.js +6 -11
- package/dist/scheduler/checkStatus.js.map +1 -1
- package/dist/scheduler/delivery.d.ts +79 -37
- package/dist/scheduler/delivery.d.ts.map +1 -1
- package/dist/scheduler/delivery.js +117 -68
- package/dist/scheduler/delivery.js.map +1 -1
- package/dist/scheduler/mcpSurface.d.ts +6 -2
- package/dist/scheduler/mcpSurface.d.ts.map +1 -1
- package/dist/scheduler/mcpSurface.js +39 -15
- package/dist/scheduler/mcpSurface.js.map +1 -1
- package/dist/scheduler/recurrence.d.ts +32 -0
- package/dist/scheduler/recurrence.d.ts.map +1 -1
- package/dist/scheduler/recurrence.js +56 -18
- package/dist/scheduler/recurrence.js.map +1 -1
- package/dist/scheduler/scheduleText.d.ts +7 -0
- package/dist/scheduler/scheduleText.d.ts.map +1 -0
- package/dist/scheduler/scheduleText.js +55 -0
- package/dist/scheduler/scheduleText.js.map +1 -0
- package/dist/scheduler/store.d.ts +8 -2
- package/dist/scheduler/store.d.ts.map +1 -1
- package/dist/scheduler/store.js +25 -4
- package/dist/scheduler/store.js.map +1 -1
- package/dist/scheduler/types.d.ts +4 -10
- package/dist/scheduler/types.d.ts.map +1 -1
- package/dist/scheduler/workerWatch.d.ts +24 -9
- package/dist/scheduler/workerWatch.d.ts.map +1 -1
- package/dist/scheduler/workerWatch.js +29 -11
- package/dist/scheduler/workerWatch.js.map +1 -1
- package/dist/utils/claudeUsage.d.ts +3 -0
- package/dist/utils/claudeUsage.d.ts.map +1 -1
- package/dist/utils/claudeUsage.js +8 -1
- package/dist/utils/claudeUsage.js.map +1 -1
- package/dist/utils/claudeUsageRefresher.d.ts +27 -3
- package/dist/utils/claudeUsageRefresher.d.ts.map +1 -1
- package/dist/utils/claudeUsageRefresher.js +113 -14
- package/dist/utils/claudeUsageRefresher.js.map +1 -1
- package/dist/utils/forwardedMark.d.ts +54 -0
- package/dist/utils/forwardedMark.d.ts.map +1 -0
- package/dist/utils/forwardedMark.js +80 -0
- package/dist/utils/forwardedMark.js.map +1 -0
- package/dist/utils/limitHeldPrompts.d.ts +8 -2
- package/dist/utils/limitHeldPrompts.d.ts.map +1 -1
- package/dist/utils/limitHeldPrompts.js +11 -4
- package/dist/utils/limitHeldPrompts.js.map +1 -1
- package/dist/utils/messageContext.d.ts +54 -0
- package/dist/utils/messageContext.d.ts.map +1 -0
- package/dist/utils/messageContext.js +58 -0
- package/dist/utils/messageContext.js.map +1 -0
- package/dist/utils/openCodeUsage.d.ts +10 -3
- package/dist/utils/openCodeUsage.d.ts.map +1 -1
- package/dist/utils/openCodeUsage.js +19 -5
- package/dist/utils/openCodeUsage.js.map +1 -1
- package/dist/utils/replyQuote.d.ts +11 -26
- package/dist/utils/replyQuote.d.ts.map +1 -1
- package/dist/utils/replyQuote.js +9 -31
- package/dist/utils/replyQuote.js.map +1 -1
- package/dist/utils/stripControlCharacters.d.ts +8 -0
- package/dist/utils/stripControlCharacters.d.ts.map +1 -0
- package/dist/utils/stripControlCharacters.js +16 -0
- package/dist/utils/stripControlCharacters.js.map +1 -0
- package/dist/utils/telegramError.d.ts +6 -0
- package/dist/utils/telegramError.d.ts.map +1 -1
- package/dist/utils/telegramError.js +30 -0
- package/dist/utils/telegramError.js.map +1 -1
- package/dist/utils/topicRequest.d.ts +13 -0
- package/dist/utils/topicRequest.d.ts.map +1 -1
- package/dist/utils/topicRequest.js +10 -0
- package/dist/utils/topicRequest.js.map +1 -1
- package/dist/utils/usageRefreshBudget.d.ts.map +1 -1
- package/dist/utils/usageRefreshBudget.js +4 -10
- package/dist/utils/usageRefreshBudget.js.map +1 -1
- package/dist/utils/waitUpTo.d.ts +8 -0
- package/dist/utils/waitUpTo.d.ts.map +1 -0
- package/dist/utils/waitUpTo.js +20 -0
- package/dist/utils/waitUpTo.js.map +1 -0
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ exports.unboundDeliveryError = void 0;
|
|
|
4
4
|
exports.prependScheduledRunMarker = prependScheduledRunMarker;
|
|
5
5
|
exports.buildFireAnnouncement = buildFireAnnouncement;
|
|
6
6
|
exports.buildCheckFailedAnnouncement = buildCheckFailedAnnouncement;
|
|
7
|
+
exports.buildCheckRecoveredText = buildCheckRecoveredText;
|
|
7
8
|
exports.clearCheckStatusLine = clearCheckStatusLine;
|
|
8
9
|
exports.createScheduleDelivery = createScheduleDelivery;
|
|
9
10
|
const i18n_1 = require("../i18n");
|
|
@@ -13,16 +14,17 @@ const checkRun_1 = require("./checkRun");
|
|
|
13
14
|
const checkStatus_1 = require("./checkStatus");
|
|
14
15
|
const deliveryKind_1 = require("./deliveryKind");
|
|
15
16
|
const recurrence_1 = require("./recurrence");
|
|
17
|
+
const scheduleText_1 = require("./scheduleText");
|
|
18
|
+
const workerWatch_1 = require("./workerWatch");
|
|
16
19
|
const postToSession_1 = require("../postToSession");
|
|
17
20
|
/**
|
|
18
21
|
* @description Scheduler delivery (plan S4): the real `deliver(job, fireContext)`
|
|
19
22
|
* callback the engine (S3) invokes at fire time. The flow is locked by the plan:
|
|
20
23
|
*
|
|
21
|
-
* 1. announce — post a
|
|
22
|
-
* schedule
|
|
23
|
-
*
|
|
24
|
-
* default
|
|
25
|
-
* and the flow continues — the announcement is already visible.
|
|
24
|
+
* 1. announce — post a SILENT message into the topic: «⏰ Scheduled: <name> ·
|
|
25
|
+
* <human schedule>» (+ a "missed at HH:MM" note for a catch-up run), with the
|
|
26
|
+
* prompt folded under it (an agent instruction, not something to read by
|
|
27
|
+
* default). Never pinned: a scheduled run is ordinary output.
|
|
26
28
|
* 3–4. post the prefixed prompt to the session ({@link postToSession}, shared
|
|
27
29
|
* with the Jira connector): ensure a session (starting one with the job's
|
|
28
30
|
* `lastAdapterName` snapshot as the adapter fallback — a topic that never
|
|
@@ -31,19 +33,21 @@ const postToSession_1 = require("../postToSession");
|
|
|
31
33
|
* unbound topic → outcome `failed` with a distinct error string the engine
|
|
32
34
|
* records (S8 turns that into a pause).
|
|
33
35
|
*
|
|
34
|
-
* A REMINDER record (`deliveryKind: 'reminder'`)
|
|
35
|
-
* delivery IS the announcement plus its pin, which is what pierces a
|
|
36
|
-
* Steps 3–4 are skipped entirely, so a reminder
|
|
37
|
-
* General — there is no session to ensure,
|
|
38
|
-
* tell about the run.
|
|
36
|
+
* A REMINDER record (`deliveryKind: 'reminder'`) is the one thing still pinned:
|
|
37
|
+
* its whole delivery IS the announcement plus its pin, which is what pierces a
|
|
38
|
+
* muted topic, and it stops there. Steps 3–4 are skipped entirely, so a reminder
|
|
39
|
+
* fires in an unbound topic and in General — there is no session to ensure,
|
|
40
|
+
* nothing to interrupt, and no agent to tell about the run.
|
|
39
41
|
*
|
|
40
42
|
* A CHECK record (`deliveryKind: 'check'`) runs its command FIRST and decides
|
|
41
43
|
* from the result and its persisted failing flag: a pass after a pass, or a
|
|
42
44
|
* failure after a failure, posts nothing; a pass after a failure posts one
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
45
|
+
* "is back to normal" line; the first failure posts a one-sentence silent notice
|
|
46
|
+
* (never the command; a worker watch says "finished" or "silent", any other check
|
|
47
|
+
* folds the output under "fired") and then wakes the agent through steps 3–4 with
|
|
48
|
+
* the command, the failure details and the output ahead of the job's prompt. An
|
|
49
|
+
* unbound topic fails with the same distinct error as a prompt job, so it is
|
|
50
|
+
* paused the same way.
|
|
47
51
|
*
|
|
48
52
|
* It owns NO bot.ts import: every side effect is injected via
|
|
49
53
|
* {@link ScheduleDeliveryDeps} (announce / pin / busy probe / ensure-session /
|
|
@@ -67,35 +71,35 @@ function prependScheduledRunMarker(jobName, prompt, options = {}) {
|
|
|
67
71
|
return `[Scheduled run "${jobName}"${dueNote}]\n${prompt}`;
|
|
68
72
|
}
|
|
69
73
|
/**
|
|
70
|
-
* @description Build the visible fire
|
|
71
|
-
*
|
|
72
|
-
* reminder leads with its own text (the pin notification previews it, so the
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* instant) for a `catch-up` fire, empty for an `on-time` run — so a replayed run
|
|
76
|
-
* is annotated identically whichever kind it is.
|
|
74
|
+
* @description Build the visible fire announcement via i18n, per delivery kind. A prompt job says «⏰ Scheduled: <name> ·
|
|
75
|
+
* <schedule>» and folds its prompt under it: the prompt is an instruction for the agent, not something a person reads by
|
|
76
|
+
* default. A reminder leads with its own text (the pin notification previews it, so the operator reads the reminder
|
|
77
|
+
* without opening the topic) and carries nothing folded. Both interpolate the SAME `{missedNote}` — the catch-up annotation
|
|
78
|
+
* (host-local HH:MM of the missed instant) for a `catch-up` fire, empty for an `on-time` run.
|
|
77
79
|
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* {@link getReminderScheduleText} — the very same words its `/reminders` list row
|
|
82
|
-
* and card show, because describing one reminder two different ways is a defect.
|
|
80
|
+
* A reminder's `{schedule}` is always the LOCALIZED {@link getReminderScheduleText} — the very same words its `/reminders`
|
|
81
|
+
* list row and card show, because describing one reminder two different ways is a defect. A prompt job's goes through
|
|
82
|
+
* {@link getAnnouncedScheduleText}, which counts the next run from `nowMs` where nothing phrases the shape.
|
|
83
83
|
*/
|
|
84
|
-
function buildFireAnnouncement(job, fireContext) {
|
|
84
|
+
function buildFireAnnouncement(job, fireContext, nowMs) {
|
|
85
85
|
const missedNote = getMissedNote(fireContext);
|
|
86
86
|
if ((0, deliveryKind_1.checkIsReminderSchedule)(job)) {
|
|
87
|
-
return
|
|
88
|
-
text:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
return {
|
|
88
|
+
text: (0, i18n_1.t)('reminders.fired', {
|
|
89
|
+
text: job.prompt,
|
|
90
|
+
schedule: (0, reminderScheduleText_1.getReminderScheduleText)(job.spec),
|
|
91
|
+
missedNote,
|
|
92
|
+
}),
|
|
93
|
+
};
|
|
92
94
|
}
|
|
93
|
-
return
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
return {
|
|
96
|
+
text: (0, i18n_1.t)('schedule.fired', {
|
|
97
|
+
name: job.name,
|
|
98
|
+
schedule: (0, scheduleText_1.getAnnouncedScheduleText)(job.spec, nowMs),
|
|
99
|
+
missedNote,
|
|
100
|
+
}),
|
|
101
|
+
foldedDetail: job.prompt,
|
|
102
|
+
};
|
|
99
103
|
}
|
|
100
104
|
/** @description The catch-up note of a fire, empty for an on-time run. */
|
|
101
105
|
function getMissedNote(fireContext) {
|
|
@@ -103,32 +107,73 @@ function getMissedNote(fireContext) {
|
|
|
103
107
|
? (0, i18n_1.t)('schedule.missedNote', { time: (0, localClock_1.formatLocalClock)(fireContext.missedAtMs) })
|
|
104
108
|
: '';
|
|
105
109
|
}
|
|
106
|
-
/**
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
110
|
+
/**
|
|
111
|
+
* @description The topic notice of a check's first failure, in one sentence and never with the command (that goes to the
|
|
112
|
+
* agent's prompt only). A worker watch (a check with a status source of a worker's run directory) says what happened to
|
|
113
|
+
* the worker: finished (its process is gone) or silent for {@link workerWatchSilenceMinutes} minutes. Any other check — and a
|
|
114
|
+
* worker watch that failed some other way, a timeout say — says it fired, with what failed and the output tail folded under
|
|
115
|
+
* it, because the failure is the only thing a person can use to tell why.
|
|
116
|
+
*/
|
|
117
|
+
function buildCheckFailedAnnouncement(input) {
|
|
118
|
+
const { job, result, failure } = input;
|
|
119
|
+
if (job.statusWorkerRunDir !== undefined) {
|
|
120
|
+
const workerEnd = (0, workerWatch_1.getWorkerWatchEnd)(result);
|
|
121
|
+
const name = (0, checkStatus_1.getCheckShownName)(job.name);
|
|
122
|
+
if (workerEnd === 'finished') {
|
|
123
|
+
return { text: (0, i18n_1.t)('schedule.workerFinished', { name, elapsed: (0, checkStatus_1.getCheckStatusElapsedText)(input.nowMs - Date.parse(job.createdAt)) }) };
|
|
124
|
+
}
|
|
125
|
+
if (workerEnd === 'silent')
|
|
126
|
+
return { text: (0, i18n_1.t)('schedule.workerSilent', { name, minutes: workerWatch_1.workerWatchSilenceMinutes }) };
|
|
127
|
+
}
|
|
128
|
+
const outputTail = (0, checkRun_1.getOutputTail)(result.output.trim(), checkRun_1.checkAlertOutputMaxChars);
|
|
129
|
+
return {
|
|
130
|
+
text: (0, i18n_1.t)('schedule.checkFired', { name: job.name }),
|
|
131
|
+
foldedDetail: outputTail === '' ? failure : `${failure}\n\n${outputTail}`,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* @description The line for a check that passes again, in the words of its failure notice: a worker watch speaks of the worker
|
|
136
|
+
* (and its shown name, without the recipe's `watch `), any other check of the check.
|
|
137
|
+
*/
|
|
138
|
+
function buildCheckRecoveredText(job) {
|
|
139
|
+
return job.statusWorkerRunDir !== undefined
|
|
140
|
+
? (0, i18n_1.t)('schedule.workerResumed', { name: (0, checkStatus_1.getCheckShownName)(job.name) })
|
|
141
|
+
: (0, i18n_1.t)('schedule.checkRecovered', { name: job.name });
|
|
116
142
|
}
|
|
117
143
|
/**
|
|
118
|
-
* @description
|
|
119
|
-
* logs — the announcement is already visible
|
|
144
|
+
* @description A REMINDER's step 1–2: post the announcement and pin it (notifying: the pin is what pierces a muted topic);
|
|
145
|
+
* a pin failure only logs — the announcement is already visible. The only pin the scheduler still makes.
|
|
120
146
|
*/
|
|
121
|
-
async function
|
|
147
|
+
async function announceAndPinReminder(deps, job, text) {
|
|
122
148
|
const messageId = await deps.announce(job.threadKey, text);
|
|
123
149
|
if (messageId === null)
|
|
124
|
-
return
|
|
150
|
+
return;
|
|
125
151
|
try {
|
|
126
|
-
await deps.pin(job.threadKey, messageId
|
|
127
|
-
return messageId;
|
|
152
|
+
await deps.pin(job.threadKey, messageId);
|
|
128
153
|
}
|
|
129
154
|
catch (error) {
|
|
130
155
|
console.warn(`[scheduler] pin announcement for job ${job.id} failed:`, error instanceof Error ? error.message : error);
|
|
131
|
-
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* @description Earlier versions pinned every check alert and remembered the pinned ids on the job. They are released at the
|
|
160
|
+
* job's next run: unpinned, then forgotten (in that order — a crash in between repeats the harmless unpin). Only the ids that
|
|
161
|
+
* ARE released are forgotten: one Telegram did not answer for stays on the job and is tried again at the next run, so no old
|
|
162
|
+
* alert stays pinned for good. Never rejects — a check must run whatever happens to an old pin. A job that never runs again
|
|
163
|
+
* (paused) keeps them until `schedule_cancel`, which releases them too.
|
|
164
|
+
*/
|
|
165
|
+
async function releaseLegacyAlertPins(deps, job) {
|
|
166
|
+
const messageIds = job.alertPinMessageIds ?? [];
|
|
167
|
+
if (messageIds.length === 0)
|
|
168
|
+
return;
|
|
169
|
+
try {
|
|
170
|
+
const stillPinnedIds = await deps.unpinMessages(job.threadKey, messageIds);
|
|
171
|
+
const releasedIds = messageIds.filter((messageId) => !stillPinnedIds.includes(messageId));
|
|
172
|
+
if (releasedIds.length > 0)
|
|
173
|
+
await deps.clearAlertPins(job.id, releasedIds);
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
console.warn(`[scheduler] releasing the old alert pins of job ${job.id} failed:`, error instanceof Error ? error.message : error);
|
|
132
177
|
}
|
|
133
178
|
}
|
|
134
179
|
/**
|
|
@@ -203,7 +248,8 @@ async function updateCheckStatus(deps, job) {
|
|
|
203
248
|
if (job.statusWorkerRunDir === undefined && job.statusCommand === undefined)
|
|
204
249
|
return;
|
|
205
250
|
try {
|
|
206
|
-
|
|
251
|
+
// The job's last run: its line would be deleted at once by the finished check, so none is posted and the existing one goes.
|
|
252
|
+
if (!deps.checkIsStatusShown(job.threadKey) || (0, recurrence_1.checkIsFinalRun)(job.spec)) {
|
|
207
253
|
await clearCheckStatusLine(deps, job);
|
|
208
254
|
return;
|
|
209
255
|
}
|
|
@@ -228,13 +274,14 @@ async function updateCheckStatus(deps, job) {
|
|
|
228
274
|
}
|
|
229
275
|
/**
|
|
230
276
|
* @description The check flow: run the command, then stay quiet, post the
|
|
231
|
-
* "
|
|
277
|
+
* "back to normal" line, or raise the alert and wake the agent. The failing flag is
|
|
232
278
|
* stored BEFORE the agent is woken, so a restart mid-delivery cannot raise the
|
|
233
279
|
* same alert twice.
|
|
234
280
|
*/
|
|
235
|
-
async function deliverCheck(deps, job
|
|
281
|
+
async function deliverCheck(deps, job) {
|
|
236
282
|
const timeoutSec = job.checkTimeoutSec ?? checkRun_1.defaultCheckTimeoutSec;
|
|
237
283
|
const command = job.checkCommand ?? '';
|
|
284
|
+
await releaseLegacyAlertPins(deps, job);
|
|
238
285
|
const result = await deps.runCheck(job.threadKey, command, timeoutSec * 1000);
|
|
239
286
|
if (!result) {
|
|
240
287
|
// A binding that went without `/unbind` (the unbind itself clears the line when it parks the job — `unbindPause.ts`): the
|
|
@@ -252,7 +299,7 @@ async function deliverCheck(deps, job, fireContext) {
|
|
|
252
299
|
}
|
|
253
300
|
if (decision === 'recovered') {
|
|
254
301
|
await deps.setCheckFailing(job.id, false);
|
|
255
|
-
await deps.announce(job.threadKey, (
|
|
302
|
+
await deps.announce(job.threadKey, buildCheckRecoveredText(job), { isSilent: true });
|
|
256
303
|
await updateCheckStatus(deps, job);
|
|
257
304
|
return { status: 'delivered' };
|
|
258
305
|
}
|
|
@@ -260,9 +307,8 @@ async function deliverCheck(deps, job, fireContext) {
|
|
|
260
307
|
await clearCheckStatusLine(deps, job);
|
|
261
308
|
await deps.setCheckFailing(job.id, true);
|
|
262
309
|
const failure = (0, checkRun_1.describeCheckFailure)(result, timeoutSec);
|
|
263
|
-
const
|
|
264
|
-
|
|
265
|
-
await deps.recordAlertPin(job.id, alertPinId);
|
|
310
|
+
const alert = buildCheckFailedAnnouncement({ job, result, failure, nowMs: deps.now() });
|
|
311
|
+
await deps.announce(job.threadKey, alert.text, { isSilent: true, foldedDetail: alert.foldedDetail });
|
|
266
312
|
return deliverToAgent(deps, job, (0, checkRun_1.buildCheckFailurePrompt)({ name: job.name, command, failure, output: result.output, prompt: job.prompt }));
|
|
267
313
|
}
|
|
268
314
|
/**
|
|
@@ -272,17 +318,20 @@ async function deliverCheck(deps, job, fireContext) {
|
|
|
272
318
|
function createScheduleDelivery(deps) {
|
|
273
319
|
return async (job, fireContext) => {
|
|
274
320
|
if ((0, deliveryKind_1.checkIsCheckSchedule)(job))
|
|
275
|
-
return deliverCheck(deps, job
|
|
276
|
-
// Read before the paced announce
|
|
321
|
+
return deliverCheck(deps, job);
|
|
322
|
+
// Read before the paced announce, which can take a while under load:
|
|
277
323
|
// a run held over a usage-limit wait says when it was due (R27).
|
|
278
324
|
const dueAtMs = fireContext.kind === 'catch-up' && fireContext.missedAtMs !== undefined ? fireContext.missedAtMs : deps.now();
|
|
279
|
-
// 1
|
|
280
|
-
|
|
281
|
-
// A reminder is done
|
|
325
|
+
// 1. announce
|
|
326
|
+
const announcement = buildFireAnnouncement(job, fireContext, deps.now());
|
|
327
|
+
// A reminder is done after its announcement and its pin, with no agent involved at
|
|
282
328
|
// all. Returning before `ensureSession` is also what lets it fire in an
|
|
283
329
|
// unbound topic and in General — there is no session to fail to ensure.
|
|
284
|
-
if ((0, deliveryKind_1.checkIsReminderSchedule)(job))
|
|
330
|
+
if ((0, deliveryKind_1.checkIsReminderSchedule)(job)) {
|
|
331
|
+
await announceAndPinReminder(deps, job, announcement.text);
|
|
285
332
|
return { status: 'delivered' };
|
|
333
|
+
}
|
|
334
|
+
await deps.announce(job.threadKey, announcement.text, { isSilent: true, foldedDetail: announcement.foldedDetail });
|
|
286
335
|
// 3–4. wake the agent with the prompt. A run held over a usage-limit wait
|
|
287
336
|
// reaches the agent later: it says when it was due (R27).
|
|
288
337
|
return deliverToAgent(deps, job, prependScheduledRunMarker(job.name, job.prompt), {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delivery.js","sourceRoot":"","sources":["../../src/scheduler/delivery.ts"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E,MAAM,EAAE,WAAW,EAAE,CAAC;QACjC,CAAC;QACD,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,YAAY,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC;QAEnH,0EAA0E;QAC1E,0DAA0D;QAC1D,OAAO,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,yBAAyB,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE;YAChF,QAAQ,EAAE,yBAAyB,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC;SACvE,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -186,8 +186,12 @@ export interface SchedulerMcpDeps {
|
|
|
186
186
|
getThreadsForDirectory: (directory: string) => string[];
|
|
187
187
|
/** Last-used adapter name for a thread, for the `lastAdapterName` snapshot. */
|
|
188
188
|
getThreadAdapterName: (threadKey: string) => string | undefined;
|
|
189
|
-
/**
|
|
190
|
-
|
|
189
|
+
/**
|
|
190
|
+
* Unpin these messages of the thread — the old alert pins of a cancelled check — and resolve with the ids that are STILL
|
|
191
|
+
* pinned and worth another try (Telegram did not answer, asked to slow down, failed). A message that is gone, was never
|
|
192
|
+
* pinned or cannot be unpinned any more is final: it is not in the list. Never rejects.
|
|
193
|
+
*/
|
|
194
|
+
unpinMessages: (threadKey: string, messageIds: readonly number[]) => Promise<number[]>;
|
|
191
195
|
/** Delete a message of the thread (best-effort: one that is gone or too old to delete is skipped) — a cancelled check's status line. */
|
|
192
196
|
deleteMessage: (threadKey: string, messageId: number) => Promise<void>;
|
|
193
197
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcpSurface.d.ts","sourceRoot":"","sources":["../../src/scheduler/mcpSurface.ts"],"names":[],"mappings":"AAKA,OA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C;CACnG;AAED,6EAA6E;AAC7E,MAAM,WAAW,wCAAwC;IACvD,QAAQ,CAAC,EAAE,MAAM,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,uCAAuC,CACrD,OAAO,GAAE,wCAA6C,GACrD,iCAAiC,CAsGnC;AA2ID;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,gBAAgB,GAAG,kBAAkB,CAqNnF"}
|
|
@@ -30,6 +30,7 @@ const botSkills_1 = require("../utils/botSkills");
|
|
|
30
30
|
const claudeProfiles_1 = require("../utils/claudeProfiles");
|
|
31
31
|
const claudeUsage_1 = require("../utils/claudeUsage");
|
|
32
32
|
const isoTimestamp_1 = require("../utils/isoTimestamp");
|
|
33
|
+
const localClock_1 = require("../utils/localClock");
|
|
33
34
|
const messageSendService_1 = require("../utils/messageSendService");
|
|
34
35
|
const utils_1 = require("../utils");
|
|
35
36
|
const checkRun_1 = require("./checkRun");
|
|
@@ -149,7 +150,7 @@ function buildRemoteRunInstruction(runnerLines, shownCount) {
|
|
|
149
150
|
}
|
|
150
151
|
const orchestrationInstructionHead = '• You orchestrate detached workers (a `claude -p` / `opencode run` builder, reviewer, researcher) →';
|
|
151
152
|
/** What the worker-watch recipe says once a tool is named: shared by both wordings of the Telegram bullet. */
|
|
152
|
-
const workerWatchRecipeText =
|
|
153
|
+
const workerWatchRecipeText = 'its description has the recipe (checkCommand, cron, status arguments); never `kill -0` alone: it never fires on a hung worker.';
|
|
153
154
|
/**
|
|
154
155
|
* The orchestration bullet of a conversation on a tracker, which has no scheduling tools: only the manager-skill hint, so
|
|
155
156
|
* with the bot's skills off (`/bot_skills`) there is nothing left of it and `null` drops it.
|
|
@@ -181,7 +182,7 @@ When to use it:
|
|
|
181
182
|
• You want to deliver SEVERAL discrete messages (each its own message, e.g. a per-item news digest) → send_messages_to_user; an item may attach ONE file (the text becomes its caption).
|
|
182
183
|
${compactConversationInstruction}
|
|
183
184
|
${isTodoToolOffered ? `${todoInstruction}\n` : ''}• You need to review or remove scheduled jobs → schedule_list / schedule_cancel.
|
|
184
|
-
• You need a watchdog — keep an eye on a service, build, deploy, disk, URL… → schedule_create with \`checkCommand\` (cron): the bot runs it in this folder, stays silent while it exits 0, and on the first failure
|
|
185
|
+
• You need a watchdog — keep an eye on a service, build, deploy, disk, URL… → schedule_create with \`checkCommand\` (cron): the bot runs it in this folder, stays silent while it exits 0, and on the first failure posts a notice and wakes you with \`prompt\` + the exit code and output tail. Checks survive restarts and crashes. NEVER build your own watcher (background loop, nohup, sleep loop, tmux pane, shell crontab): it dies with your session or a restart, silently.
|
|
185
186
|
${buildTelegramOrchestrationInstruction(isBotSkillsEnabled)}
|
|
186
187
|
${answerRequestInstruction} The requester may not see your plain text: anything they must read goes through answer_request — yet your plain text is relayed into the topic too, so end the turn WITHOUT a recap of what you answered (it would show twice).
|
|
187
188
|
${claudeProfilesInstruction}${remoteRunInstructionText === null ? '' : `\n${remoteRunInstructionText}`}
|
|
@@ -489,7 +490,7 @@ const scheduleCreateShape = {
|
|
|
489
490
|
.optional()
|
|
490
491
|
.describe('Makes the job a WATCHDOG CHECK: a shell command (run with /bin/sh -c in the bound folder) the bot ' +
|
|
491
492
|
'executes at every fire instead of waking you. Exit 0 = healthy, nothing is posted. The first ' +
|
|
492
|
-
'non-zero exit or timeout
|
|
493
|
+
'non-zero exit or timeout tells the topic in one line (never the command) and wakes you with `prompt` plus the exit ' +
|
|
493
494
|
'code and output tail; later failures stay silent until a run passes again (the topic is told). ' +
|
|
494
495
|
'Keep it a quick probe, e.g. `systemctl --user is-active myapp`, `curl -fsS -m 10 http://127.0.0.1:8080/health`, ' +
|
|
495
496
|
'`test $(df --output=pcent / | tail -1 | tr -dc 0-9) -lt 90`; a detached worker: the recipe in the tool description.'),
|
|
@@ -528,7 +529,7 @@ const scheduleCreateShape = {
|
|
|
528
529
|
isPinSilent: zod_1.z
|
|
529
530
|
.boolean()
|
|
530
531
|
.optional()
|
|
531
|
-
.describe('
|
|
532
|
+
.describe('DEPRECATED, has no effect: scheduled messages and check alerts are never pinned. Do not pass it.'),
|
|
532
533
|
threadKey: threadKeyArgSchema,
|
|
533
534
|
};
|
|
534
535
|
const scheduleCreateInput = (0, strictToolInput_1.createStrictToolInput)(scheduleCreateShape);
|
|
@@ -713,6 +714,25 @@ function summarizeRecord(record) {
|
|
|
713
714
|
const statusNote = hasStatusSource ? `; status every ${record.statusEveryMinutes ?? checkStatus_1.defaultCheckStatusEveryMinutes} min` : '';
|
|
714
715
|
return `${record.name} (id: ${record.id}) — ${(0, recurrence_1.describeSchedule)(record.spec)}${checkNote}${statusNote}; next run: ${next}${pausedNote}`;
|
|
715
716
|
}
|
|
717
|
+
/**
|
|
718
|
+
* The `schedule_create` confirmation, which also lands in the topic as a tool result: one line a person reads, with WHAT and
|
|
719
|
+
* WHEN («Scheduled "Nightly build": daily at 02:00; next: 2026-06-07 02:00» / «Scheduled "API health": checks every 5m; next:
|
|
720
|
+
* …») and, on the next, the id the agent needs to cancel it. The «next» stamp is the instance-local time, so a schedule that
|
|
721
|
+
* was read in the wrong timezone shows at once; a cron nothing phrases shows only that (never the raw expression), and a
|
|
722
|
+
* one-shot's phrase already is its time. The command and the status rhythm are in `schedule_list`.
|
|
723
|
+
*/
|
|
724
|
+
function summarizeCreated(record) {
|
|
725
|
+
const isCheck = (0, deliveryKind_1.checkIsCheckSchedule)(record);
|
|
726
|
+
const phrase = (0, recurrence_1.describePhrasedSchedule)(record.spec);
|
|
727
|
+
const parts = [];
|
|
728
|
+
if (phrase !== null)
|
|
729
|
+
parts.push(isCheck ? `checks ${phrase}` : phrase);
|
|
730
|
+
else if (isCheck)
|
|
731
|
+
parts.push('checks');
|
|
732
|
+
if (record.spec.kind === 'cron' && record.nextRunAt !== null)
|
|
733
|
+
parts.push(`next: ${(0, localClock_1.formatLocalDateAndClock)(record.nextRunAt)}`);
|
|
734
|
+
return `Scheduled "${record.name}": ${parts.join('; ')}\nid: ${record.id}`;
|
|
735
|
+
}
|
|
716
736
|
// ─── tool handlers (scope-bound) ─────────────────────────────────────
|
|
717
737
|
/**
|
|
718
738
|
* @description Register the three scoped tools onto a fresh {@link McpServer}.
|
|
@@ -723,8 +743,8 @@ function summarizeRecord(record) {
|
|
|
723
743
|
function registerSchedulerTools(server, deps, scope) {
|
|
724
744
|
server.registerTool('schedule_create', {
|
|
725
745
|
title: 'Create a scheduled prompt',
|
|
726
|
-
description: 'Schedule a prompt to be delivered to this topic later.
|
|
727
|
-
'forwards the prompt to the agent
|
|
746
|
+
description: 'Schedule a prompt to be delivered to this topic later. At fire time the bot posts a short silent line ' +
|
|
747
|
+
'(name and schedule, the prompt folded under it) and forwards the prompt to the agent. The line is never pinned.\n\n' +
|
|
728
748
|
'Pick exactly ONE mode:\n' +
|
|
729
749
|
'• one-shot (run once at a time): pass onceAt (ISO 8601); omit cron and repeatCount.\n' +
|
|
730
750
|
'• recurring: pass cron (5-field); omit onceAt.\n' +
|
|
@@ -743,9 +763,9 @@ function registerSchedulerTools(server, deps, scope) {
|
|
|
743
763
|
'background loop, nohup, a sleep loop, a tmux pane, a shell crontab) — it dies with your session ' +
|
|
744
764
|
'or a restart and then fails silently.\n\n' +
|
|
745
765
|
`A DETACHED WORKER you launched (a \`claude -p\` / \`opencode run\` process): cron \`${workerWatch_1.workerWatchCheckCron}\`, ` +
|
|
746
|
-
`\`${workerWatch_1.
|
|
747
|
-
|
|
748
|
-
'signal (
|
|
766
|
+
`\`${workerWatch_1.workerWatchStatusArguments}\`, checkCommand \`${workerWatch_1.workerWatchCheckCommand}\` with its PID and run dir — it fails when ` +
|
|
767
|
+
`the worker exits OR nothing in its run dir changed for ${workerWatch_1.workerWatchSilenceMinutes} min, so the first failure is also the "worker finished" ` +
|
|
768
|
+
'signal (the topic then reads «worker finished» or «worker silent», never the command). Never `kill -0` alone: it stays green ' +
|
|
749
769
|
'while a worker hangs. The status arguments make the BOT post a silent status line into the topic every ' +
|
|
750
770
|
`${workerWatch_1.workerWatchStatusEveryMinutes} min while the worker lives (works N min, its last action), so the topic never looks frozen — ` +
|
|
751
771
|
'without waking you or spending tokens: never arm a schedule of your own for status lines. One check per worker run; ' +
|
|
@@ -792,7 +812,6 @@ function registerSchedulerTools(server, deps, scope) {
|
|
|
792
812
|
createdBy: 'agent',
|
|
793
813
|
nowMs,
|
|
794
814
|
lastAdapterName: deps.getThreadAdapterName(resolved.threadKey),
|
|
795
|
-
isPinSilent: args.isPinSilent,
|
|
796
815
|
...(checkCommand
|
|
797
816
|
? { deliveryKind: 'check', checkCommand, checkTimeoutSec: args.checkTimeoutSeconds }
|
|
798
817
|
: {}),
|
|
@@ -807,7 +826,7 @@ function registerSchedulerTools(server, deps, scope) {
|
|
|
807
826
|
const record = created.record;
|
|
808
827
|
deps.armJob(record);
|
|
809
828
|
const noteSuffix = notes.map((note) => `\n\nℹ️ ${note}`).join('');
|
|
810
|
-
return textResult(
|
|
829
|
+
return textResult(`${summarizeCreated(record)}${noteSuffix}`);
|
|
811
830
|
});
|
|
812
831
|
server.registerTool('schedule_list', {
|
|
813
832
|
title: 'List scheduled prompts',
|
|
@@ -841,8 +860,8 @@ function registerSchedulerTools(server, deps, scope) {
|
|
|
841
860
|
server.registerTool('schedule_cancel', {
|
|
842
861
|
title: 'Cancel a scheduled prompt',
|
|
843
862
|
description: 'Cancel (delete) a scheduled prompt by its id. Only schedules owned by this topic can be cancelled. Cancelling a ' +
|
|
844
|
-
'watchdog check also
|
|
845
|
-
'
|
|
863
|
+
'watchdog check also deletes its status line — cancel a worker watch once its wake is handled, so a finished worker ' +
|
|
864
|
+
'leaves no status line behind.',
|
|
846
865
|
inputSchema: scheduleCancelInput,
|
|
847
866
|
}, async (args) => {
|
|
848
867
|
const resolved = resolveTargetThreadKey(scope, args.threadKey, deps.getThreadsForDirectory);
|
|
@@ -860,10 +879,15 @@ function registerSchedulerTools(server, deps, scope) {
|
|
|
860
879
|
await deps.store.removeSchedule(args.id);
|
|
861
880
|
deps.disarmJob(args.id);
|
|
862
881
|
const cleanedUp = [];
|
|
882
|
+
// Nothing pins a check alert any more, but a job made by an earlier version may still carry the ids of the ones it pinned.
|
|
863
883
|
const alertPins = record.alertPinMessageIds ?? [];
|
|
864
884
|
if (alertPins.length > 0) {
|
|
865
|
-
await deps.unpinMessages(record.threadKey, alertPins);
|
|
866
|
-
|
|
885
|
+
const stillPinned = await deps.unpinMessages(record.threadKey, alertPins);
|
|
886
|
+
const unpinnedCount = alertPins.length - stillPinned.length;
|
|
887
|
+
if (unpinnedCount > 0)
|
|
888
|
+
cleanedUp.push(`its ${unpinnedCount} pinned alert(s) unpinned`);
|
|
889
|
+
if (stillPinned.length > 0)
|
|
890
|
+
cleanedUp.push(`${stillPinned.length} pinned alert(s) could not be unpinned (Telegram did not answer — unpin by hand)`);
|
|
867
891
|
}
|
|
868
892
|
// A "⏳ works …" line left under a cancelled watch would be wrong: the watch no longer says anything.
|
|
869
893
|
if (record.statusMessageId !== undefined) {
|