

























@@ -47,6 +47,7 @@ type TelegramQaScenarioId =
4747| "telegram-tools-compact-command"
4848| "telegram-whoami-command"
4949| "telegram-context-command"
50+| "telegram-current-session-status-tool"
5051| "telegram-mentioned-message-reply"
5152| "telegram-mention-gating";
5253@@ -208,6 +209,7 @@ type TelegramMessage = {
208209209210type TelegramUpdate = {
210211update_id: number;
212+edited_message?: TelegramMessage;
211213message?: TelegramMessage;
212214};
213215@@ -270,6 +272,17 @@ const TELEGRAM_QA_SCENARIOS: TelegramQaScenarioDefinition[] = [
270272expectedTextIncludes: ["/context list", "Inline shortcut"],
271273}),
272274},
275+{
276+id: "telegram-current-session-status-tool",
277+title: "Telegram current session_status tool call",
278+defaultEnabled: false,
279+timeoutMs: 60_000,
280+buildRun: (sutUsername) => ({
281+expectReply: true,
282+input: `@${sutUsername} Telegram current session_status QA check. Call session_status with sessionKey set to current, then reply with the exact QA marker and resolved session key.`,
283+expectedTextIncludes: ["QA-TELEGRAM-CURRENT-SESSION-OK", ":telegram:group:"],
284+}),
285+},
273286{
274287id: "telegram-mentioned-message-reply",
275288title: "Telegram mentioned message gets a reply",
@@ -471,7 +484,7 @@ function detectMediaKinds(message: TelegramMessage) {
471484}
472485473486function normalizeTelegramObservedMessage(update: TelegramUpdate): TelegramObservedMessage | null {
474-const message = update.message;
487+const message = update.message ?? update.edited_message;
475488if (!message?.from?.id) {
476489return null;
477490}
@@ -608,7 +621,7 @@ async function flushTelegramUpdates(token: string) {
608621{
609622 offset,
610623timeout: 0,
611-allowed_updates: ["message"],
624+allowed_updates: ["message", "edited_message"],
612625},
61362615_000,
614627);
@@ -653,10 +666,12 @@ async function waitForObservedMessage(params: {
653666observedMessages: TelegramObservedMessage[];
654667observationScenarioId: string;
655668observationScenarioTitle: string;
669+expectedTextIncludes?: string[];
656670}) {
657671const startedAt = Date.now();
658672let offset = params.initialOffset;
659673let lastPollingError: unknown;
674+let lastExpectedMismatch: Error | undefined;
660675while (Date.now() - startedAt < params.timeoutMs) {
661676const remainingMs = Math.max(
6626771_000,
@@ -671,7 +686,7 @@ async function waitForObservedMessage(params: {
671686{
672687 offset,
673688timeout: timeoutSeconds,
674-allowed_updates: ["message"],
689+allowed_updates: ["message", "edited_message"],
675690},
676691timeoutSeconds * 1000 + 5_000,
677692);
@@ -703,10 +718,23 @@ async function waitForObservedMessage(params: {
703718};
704719params.observedMessages.push(observedMessage);
705720if (matchedScenario) {
721+try {
722+assertTelegramScenarioReply({
723+expectedTextIncludes: params.expectedTextIncludes,
724+message: observedMessage,
725+});
726+} catch (error) {
727+lastExpectedMismatch =
728+error instanceof Error ? error : new Error(formatErrorMessage(error));
729+continue;
730+}
706731return { message: observedMessage, nextOffset: offset, observedAtMs: batchObservedAtMs };
707732}
708733}
709734}
735+if (lastExpectedMismatch) {
736+throw lastExpectedMismatch;
737+}
710738const timeoutMessage = `timed out after ${params.timeoutMs}ms waiting for Telegram message`;
711739if (lastPollingError) {
712740throw new Error(
@@ -1332,6 +1360,9 @@ export async function runTelegramQaLive(params: {
13321360 observedMessages,
13331361observationScenarioId: scenario.id,
13341362observationScenarioTitle: scenario.title,
1363+expectedTextIncludes: scenarioRun.expectReply
1364+ ? scenarioRun.expectedTextIncludes
1365+ : undefined,
13351366predicate: (message) =>
13361367matchesTelegramScenarioReply({
13371368allowAnySutReply: scenarioRun.allowAnySutReply,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。