Skip to content

fix(ton-bridge): replace inlineKeyboard URL buttons with embedded text links - #34

Merged
xlabtg merged 3 commits into
xlabtg:mainfrom
konard:issue-33-8708bcfeeef2
Mar 23, 2026
Merged

fix(ton-bridge): replace inlineKeyboard URL buttons with embedded text links#34
xlabtg merged 3 commits into
xlabtg:mainfrom
konard:issue-33-8708bcfeeef2

Conversation

@konard

@konard konard commented Mar 23, 2026

Copy link
Copy Markdown

Problem

All three TON Bridge tools (ton_bridge_open, ton_bridge_about, ton_bridge_custom_message) crash with:

TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
    at Buffer.from (node:buffer:348:9)

Root cause

The agent's TelegramBridge.sendMessage implementation iterates over inlineKeyboard buttons and calls Buffer.from(button.callback_data) to serialize button data. The TON Bridge plugin passes URL buttons ({ text, url }) which don't have callback_data — so Buffer.from(undefined) is called, causing the crash.

The SDK documentation (CONTRIBUTING.md, references/patterns.md) only shows callback_data buttons in inlineKeyboard examples. No other plugin in the repo uses URL buttons — only callback_data buttons are supported.

Fix

Replace inlineKeyboard URL buttons with the Mini App link embedded directly in the message text via a new buildMessageWithLink() helper. The https://t.me/TONBridge_robot?startapp deep link renders as a tappable link in Telegram messages across DMs, groups, and channels.

Before (crashes):

await sdk.telegram.sendMessage(context.chatId, text, {
  inlineKeyboard: [[{ text: buttonText, url }]],  // ← URL button unsupported
});

After (works):

const fullText = buildMessageWithLink(text, buttonText, url);
await sdk.telegram.sendMessage(context.chatId, fullText);

Tests

All 28 tests pass. Updated tests verify:

  • Link is embedded in message text (not in inlineKeyboard)
  • No inlineKeyboard options passed to sendMessage
  • Custom button text and startParam still appear correctly in the message
  • Fallback chains for missing params still work

Fixes #33

🤖 Generated with Claude Code

konard and others added 2 commits March 23, 2026 21:23
Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: xlabtg#33
…t links

The agent's TelegramBridge.sendMessage only supports callback_data buttons
in inlineKeyboard. URL buttons ({ text, url }) cause Buffer.from(undefined)
because the agent code expects callback_data on every button. This fixes
all three tools (ton_bridge_open, ton_bridge_about, ton_bridge_custom_message)
by embedding the Mini App deep link directly in the message text instead.

Fixes xlabtg#33

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@konard konard changed the title [WIP] Errors when working with TON Bridge tools fix(ton-bridge): replace inlineKeyboard URL buttons with embedded text links Mar 23, 2026
@konard
konard marked this pull request as ready for review March 23, 2026 21:30
@konard

konard commented Mar 23, 2026

Copy link
Copy Markdown
Author

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $2.652093
  • Calculated by Anthropic: $1.778211 USD
  • Difference: $-0.873882 (-32.95%)

🤖 Models used:

  • Tool: Claude
  • Requested: opus
  • Main model: Claude Opus 4.6 (claude-opus-4-6)
  • Additional models:
    • Claude Haiku 4.5 (claude-haiku-4-5-20251001)

📎 Log file uploaded as Gist (1207KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard

konard commented Mar 23, 2026

Copy link
Copy Markdown
Author

✅ Ready to merge

This pull request is now ready to be merged:

  • All CI checks have passed
  • No merge conflicts
  • No pending changes

Monitored by hive-mind with --auto-restart-until-mergeable flag

@xlabtg
xlabtg merged commit 8551592 into xlabtg:main Mar 23, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Errors when working with TON Bridge tools

2 participants