Skip to content

Convert Bobby to Clawd: Telegram/OpenClaw integration#19

Open
jmsunseri wants to merge 45 commits intopebble-dev:mainfrom
jmsunseri:clawd
Open

Convert Bobby to Clawd: Telegram/OpenClaw integration#19
jmsunseri wants to merge 45 commits intopebble-dev:mainfrom
jmsunseri:clawd

Conversation

@jmsunseri
Copy link

  • Add Telegram authentication infrastructure (session storage, client, login flow)
  • Create OpenClaw session handler with OpenAI tool format support
  • Add API endpoints for Telegram auth flow
  • Update phone settings app with Telegram connection UI
  • Remove Gemini fallback and unused code (weather, maps, currency, verifier)
  • Remove Discord feedback integration
  • Add GitHub issues link and OpenClaw setup instructions to settings

jmsunseri and others added 30 commits March 13, 2026 14:35
- Add Telegram authentication infrastructure (session storage, client, login flow)
- Create OpenClaw session handler with OpenAI tool format support
- Add API endpoints for Telegram auth flow
- Update phone settings app with Telegram connection UI
- Remove Gemini fallback and unused code (weather, maps, currency, verifier)
- Remove Discord feedback integration
- Add GitHub issues link and OpenClaw setup instructions to settings

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit eliminates the need for a backend server by moving all
Telegram communication directly to the phone app using GramJS (MTProto).

Key changes:
- Add Telegram client infrastructure (app/src/pkjs/telegram/)
  - client.js: GramJS initialization and connection management
  - auth.js: Phone number + verification code authentication
  - session.js: localStorage-based session persistence
  - messages.js: Send/receive messages to OpenClaw bot
- Add tool definitions and local execution (app/src/pkjs/tools/)
  - definitions.js: OpenAI-format tool definitions ported from Go
  - executor.js: Local tool execution (alarms, reminders, time, wikipedia)
- Update session.js to use Telegram instead of WebSocket
- Update config.json with Telegram auth UI
- Update custom_config.js for new auth flow
- Remove all backend service code (service/ directory)
- Remove Dockerfile and GitHub workflow for backend
- Update README.md with new architecture docs

New architecture:
Watch App → Phone App (pkjs) → Telegram MTProto → OpenClaw Bot

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
OpenClaw can do web searching on its own, so we don't need a
separate Wikipedia tool in the client.

- Remove wikipedia tool definition from definitions.js
- Remove executeWikipedia and helper functions from executor.js
- Update README tool list

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds a "Login with QR Code" button in settings that:
- Generates a Telegram login token
- Displays a QR code (via external QR service)
- Polls for login confirmation
- Easier for emulator debugging - scan from phone

Also reorganizes the login UI with QR as primary option
and phone number as alternative.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Removed features (no longer work without backend):
- Quota screen (Rebble subscription check)
- Feedback screen (sent to backend)
- Report thread feature

Renamed Bobby → Clawd:
- App name in package.json and display name
- All text references (about, legal, consent, etc.)
- Log macros (BOBBY_LOG → CLAWD_LOG)
- Status bar functions (bobby_* → clawd_*)
- Menu item labels

Updated consent screen:
- Renamed gemini_consent → openclaw_consent
- Updated text to clarify data handling with OpenClaw

Updated about.txt to credit original Bobby project:
- Credits Katharine Berry as original author
- Notes this is a fork for OpenClaw

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove ConversationActionTypeSendFeedback enum and handlers
- Remove MESSAGE_KEY_ACTION_FEEDBACK_SENT handling
- Remove QUOTA_*, FEEDBACK_*, REPORT_* message keys from package.json
- Remove feedback_blurb, report_blurb resources and menu icons
- Remove unused quota/feedback handling from emulator_main.js
- Clean up urls.js to remove unused URL exports
- Remove report conversation action from session_window
- Delete unused usage_layer.c/.h and menu icon files

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
With the Go backend removed, the app/ subdirectory is no longer needed.
This restructures the project as a standard Pebble app with package.json,
resources/, and src/ at the root level.

- Move all files from app/ to root
- Update GitHub workflow to build from root instead of app/
- Merge app/.gitignore into root .gitignore
- Update workflow path triggers for new structure

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove Wikipedia from feature list (tool removed)
- Update project structure to reflect files at root level
- Fix file path references (app/src -> src)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- bmalloc: Never return NULL - loop until allocation succeeds
  (callers don't check for NULL)
- conversation.c: Ensure null termination after strncpy for thread_id
- conversation_manager.c: Add null checks for all dict_find() calls
  before dereferencing, preventing crashes on malformed messages
- image_manager.c: Properly clean up on allocation failure - free
  metadata if data allocation fails

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix DICT_GET macros for void functions (remove return value parameter)
- Fix optional chaining syntax (?.) not supported in older JavaScript
  environments used by Pebble SDK

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Bundle GramJS library (telegram npm package) with browser polyfills
- Create scripts/ directory with build tools for regenerating bundle
- Update custom_config.js to dynamically load GramJS in Clay settings
- Update index.js to require the Telegram bundle
- Move resources to resources/data/ for CloudPebble compatibility

The Telegram bundle enables direct communication with Telegram's MTProto
protocol, eliminating the need for a backend server. Users can connect
directly to their OpenClaw bot instance.

Co-Authored-By: Claude <noreply@anthropic.com>
- Move all resources to resources/data/ directory
- Update package.json to reference data/... paths
- Restore PNG files that were accidentally deleted

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
This breaks the git rename history to help CloudPebble properly
locate resource files without confusion from rename metadata.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Rename all resource files to include path in filename (e.g., icons/clock.pdc -> icons_clock.pdc)
and place them in the root of resources directory. Remove 'data' from paths.

Co-Authored-By: Claude <noreply@anthropic.com>
- Add Babel transpilation step to build process
- Include regenerator-runtime polyfill for async/await
- Target ES5 for older JavaScript parsers in CloudPebble/Pebble SDK

Co-Authored-By: Claude <noreply@anthropic.com>
The CloudPebble emulator (emery) needs access to the same resources as basalt.

Co-Authored-By: Claude <noreply@anthropic.com>
jmsunseri and others added 5 commits March 16, 2026 01:20
Co-Authored-By: Claude <noreply@anthropic.com>
The bundle is too large for webpack 1.x and needs alternative loading method.

Co-Authored-By: Claude <noreply@anthropic.com>
Let CloudPebble's webpack handle bundling. Remove pre-built bundle.

Co-Authored-By: Claude <noreply@anthropic.com>
telegram package requires Node.js built-ins that need polyfills.

Co-Authored-By: Claude <noreply@anthropic.com>
- Remove Babel transpilation from build-gramjs.js (esbuild output works
  with webpack 1.x when loaded via eval trick)
- Remove unused loadGramJS function and CDN loading code from custom_config.js
- Remove unused node polyfill dependencies from root package.json
- Clean up babel dependencies from scripts/package.json
- Add telegram-bundle.js (now built without Babel)
- Update comments in index.js to clarify eval trick purpose

The eval('require') trick is still needed because webpack 1.x's parser
can't handle ES6+ syntax, but the runtime may support it since pkjs
runs on iOS JavaScriptCore and Android WebView.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
jmsunseri and others added 10 commits March 16, 2026 15:10
- Add back Babel transpilation targeting ES5 (Node 0.10 compatible)
- Rebuild bundle with esbuild + Babel pipeline
- Update README with build process details

The CI environment requires ES5 syntax. Local builds worked but
CI failed because webpack 1.x's parser couldn't handle ES6+.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The `[n]` array notation in messageKeys was not generating base keys
that C code could index into. Changed to explicit key listings so
MESSAGE_KEY_WEATHER_WIDGET_MULTI_HIGH + i pattern works correctly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Created prune-telegram-bundle.js to strip unused TL schema definitions
- Use minimal entry point for better tree-shaking
- Reduced bundle from 1.5MB to 1.3MB (9.5% reduction)
- Kept only essential Telegram API methods for auth/messaging

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace eval('require') with direct require so webpack parses the bundle
at build time. This surfaces any webpack issues during build rather than
pushing them to CI or runtime.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Modified emulator_session.js to attempt using the real Telegram
connection first, falling back to prerecorded responses only when
Telegram is not configured. This allows testing actual AI responses
in the emulator when Telegram credentials are set up.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Emulator now uses the real session.js which shows a "Not connected
to Telegram" error when Telegram isn't configured. This matches the
real device behavior and allows testing with actual Telegram/AI
responses when configured.

Removed prerecorded.js since it's no longer needed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Added TELEGRAM_CONNECTED message key to notify watch of connection state
- Watch stores Telegram status in persistent storage
- Phone app sends status at startup and when configuration changes
- Emulator now shows proper error when Telegram not configured
- Removed prerecorded responses in favor of real error messages

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When user tries to use Clawd without Telegram configured, show
a screen directing them to configure Telegram in the app settings
instead of starting a session that would fail.

- Check Telegram status before starting session
- Show result window with configuration instructions if not connected
- Works for all entry points: microphone, sample prompts, quick launch

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The emulator no longer needs separate entry files since:
- Prerecorded responses are gone (now uses real Telegram or shows error)
- Timeline token is only requested on real devices

Simplified index.js to handle both emulator and real devices:
- Check platform and skip timeline token in emulator
- Use same session code for both

Deleted:
- src/pkjs/emulator/emulator_main.js
- src/pkjs/emulator/emulator_session.js
- src/pkjs/emulator/ directory

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Added word wrap overflow mode for text layers
- Reduced text font size (18pt instead of 24pt bold)
- Added margins (5px) to prevent text from touching edges
- Made image optional (NULL for Telegram setup screen)
- Better handles longer messages like the Telegram config prompt

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant