Skip to content

Commit e6cfe75

Browse files
committed
test(telegram): drive best-effort cron delivery
1 parent 7aad7ef commit e6cfe75

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

‎.agents/skills/telegram-e2e-userbot/scripts/run-mock-sut-user-e2e.mjs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,7 @@ async function runCronScenarioAction({
691691
gatewayEnv,
692692
cronDeliveryTarget,
693693
message,
694+
bestEffort,
694695
isStopped,
695696
}) {
696697
let jobId;
@@ -717,6 +718,7 @@ async function runCronScenarioAction({
717718
"telegram",
718719
"--to",
719720
cronDeliveryTarget,
721+
...(bestEffort ? ["--best-effort-deliver"] : []),
720722
"--json",
721723
"--keep-after-run",
722724
],
@@ -1324,6 +1326,7 @@ async function driveWithTelegramProxy(args, repoRoot, creds) {
13241326
gatewayEnv: controlEnv,
13251327
cronDeliveryTarget: selectedChatTarget.cronDeliveryTarget,
13261328
message: action.message,
1329+
bestEffort: action.bestEffort,
13271330
isStopped: () => controlsStopped,
13281331
}).then(
13291332
(result) => {

‎.agents/skills/telegram-e2e-userbot/scripts/scenario.mjs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const ACTION_KEYS = {
99
restartGateway: new Set(["type", "atMs", "graceMs"]),
1010
patchConfig: new Set(["type", "atMs", "patch"]),
1111
systemEvent: new Set(["type", "atMs", "text"]),
12-
cron: new Set(["type", "atMs", "message"]),
12+
cron: new Set(["type", "atMs", "message", "bestEffort"]),
1313
command: new Set(["type", "atMs", "argv", "cwd", "timeoutMs"]),
1414
telegramApiHold: new Set(["type", "atMs", "method", "skip"]),
1515
telegramApiWaitHeld: new Set(["type", "atMs", "method", "timeoutMs"]),
@@ -77,10 +77,14 @@ export function parseScenario(value) {
7777
return { type: action.type, atMs, text: nonEmptyString(action.text, `${label}.text`) };
7878
}
7979
if (action.type === "cron") {
80+
if (action.bestEffort !== undefined && typeof action.bestEffort !== "boolean") {
81+
throw new Error(`${label}.bestEffort must be a boolean.`);
82+
}
8083
return {
8184
type: action.type,
8285
atMs,
8386
message: nonEmptyString(action.message, `${label}.message`),
87+
...(action.bestEffort === true ? { bestEffort: true } : {}),
8488
};
8589
}
8690
if (action.type === "command") {

‎.agents/skills/telegram-e2e-userbot/scripts/scenario.test.mjs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ test("normalizes Telegram and gateway actions", () => {
2020
},
2121
{ type: "patchConfig", atMs: 750, patch: { channels: { telegram: { historyLimit: 9 } } } },
2222
{ type: "systemEvent", atMs: 900, text: "heartbeat proof" },
23-
{ type: "cron", atMs: 950, message: "deliver the schedule" },
23+
{ type: "cron", atMs: 950, message: "deliver the schedule", bestEffort: true },
2424
{ type: "command", atMs: 975, argv: ["node", "--version"], cwd: "repo" },
2525
{ type: "telegramApiHold", atMs: 980, method: "sendMessage", skip: 1 },
2626
{ type: "telegramApiWaitHeld", atMs: 990, method: "sendMessage" },
@@ -48,7 +48,7 @@ test("normalizes Telegram and gateway actions", () => {
4848
patch: { channels: { telegram: { historyLimit: 9 } } },
4949
},
5050
{ type: "systemEvent", atMs: 900, text: "heartbeat proof" },
51-
{ type: "cron", atMs: 950, message: "deliver the schedule" },
51+
{ type: "cron", atMs: 950, message: "deliver the schedule", bestEffort: true },
5252
{
5353
type: "command",
5454
atMs: 975,
@@ -113,6 +113,10 @@ test("rejects fields and action types outside the closed schema", () => {
113113
() => parseScenario({ actions: [{ type: "restartGateway", atMs: -1 }] }),
114114
/atMs must be a non-negative integer/u,
115115
);
116+
assert.throws(
117+
() => parseScenario({ actions: [{ type: "cron", message: "deliver", bestEffort: "yes" }] }),
118+
/bestEffort must be a boolean/u,
119+
);
116120
});
117121

118122
test("validates the recorder-ready artifact as a closed shape", () => {

0 commit comments

Comments
 (0)