diff --git a/CHANGELOG.md b/CHANGELOG.md index f1754b259ae..09409774fef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -101,6 +101,7 @@ Docs: https://docs.openclaw.ai - Docs/plugins: add the community DingTalk plugin listing to the docs catalog. (#29913) Thanks @sliverp. - Docs/plugins: add the community QQbot plugin listing to the docs catalog. (#29898) Thanks @sliverp. - Docs/plugins: add the community wecom plugin listing to the docs catalog. (#29905) Thanks @sliverp. +- Telegram/message tool: add `asDocument` as a user-facing alias for `forceDocument` on image and GIF sends, while preserving explicit `forceDocument` precedence when both flags are present. (#52461) Thanks @bakhtiersizhaev. ### Fixes diff --git a/extensions/telegram/src/action-runtime.ts b/extensions/telegram/src/action-runtime.ts index 1d1219d05a5..8d54fe20b76 100644 --- a/extensions/telegram/src/action-runtime.ts +++ b/extensions/telegram/src/action-runtime.ts @@ -354,7 +354,10 @@ export async function handleTelegramAction( quoteText: quoteText ?? undefined, asVoice: readBooleanParam(params, "asVoice"), silent: readBooleanParam(params, "silent"), - forceDocument: readBooleanParam(params, "forceDocument") ?? false, + forceDocument: + readBooleanParam(params, "forceDocument") ?? + readBooleanParam(params, "asDocument") ?? + false, }); return jsonResult({ ok: true, diff --git a/extensions/telegram/src/channel-actions.ts b/extensions/telegram/src/channel-actions.ts index c530ad92862..5012979d4c8 100644 --- a/extensions/telegram/src/channel-actions.ts +++ b/extensions/telegram/src/channel-actions.ts @@ -111,7 +111,7 @@ function describeTelegramMessageTool({ if (discovery.buttonsEnabled) { schema.push({ properties: { - buttons: Type.Optional(createMessageToolButtonsSchema()), + buttons: createMessageToolButtonsSchema(), }, }); } diff --git a/src/agents/tools/message-tool.ts b/src/agents/tools/message-tool.ts index 27386a62ebd..d5fc6e58833 100644 --- a/src/agents/tools/message-tool.ts +++ b/src/agents/tools/message-tool.ts @@ -122,6 +122,12 @@ function buildSendSchema(options: { includeInteractive: boolean }) { description: "Send image/GIF as document to avoid Telegram compression (Telegram only).", }), ), + asDocument: Type.Optional( + Type.Boolean({ + description: + "Send image/GIF as document to avoid Telegram compression. Alias for forceDocument (Telegram only).", + }), + ), interactive: Type.Optional(interactiveMessageSchema), }; if (!options.includeInteractive) { diff --git a/src/channels/plugins/actions/actions.test.ts b/src/channels/plugins/actions/actions.test.ts index 934c74050dc..22d6ed3b7c2 100644 --- a/src/channels/plugins/actions/actions.test.ts +++ b/src/channels/plugins/actions/actions.test.ts @@ -737,6 +737,37 @@ describe("telegramMessageActions", () => { asVoice: true, }), }, + { + name: "media-only send preserves asDocument", + action: "send" as const, + params: { + to: "123", + media: "https://example.com/photo.jpg", + asDocument: true, + }, + expectedPayload: expect.objectContaining({ + action: "sendMessage", + to: "123", + media: "https://example.com/photo.jpg", + asDocument: true, + }), + }, + { + name: "explicit forceDocument false beats asDocument alias", + action: "send" as const, + params: { + to: "123", + media: "https://example.com/photo.jpg", + forceDocument: false, + asDocument: true, + }, + expectedPayload: expect.objectContaining({ + action: "sendMessage", + to: "123", + media: "https://example.com/photo.jpg", + forceDocument: false, + }), + }, { name: "silent send forwards silent flag", action: "send" as const, diff --git a/src/infra/outbound/message-action-runner.ts b/src/infra/outbound/message-action-runner.ts index e6ab94781ab..e7b37829981 100644 --- a/src/infra/outbound/message-action-runner.ts +++ b/src/infra/outbound/message-action-runner.ts @@ -472,7 +472,8 @@ async function handleSendAction(ctx: ResolvedActionContext): Promise