feat(surface): add showThinking capability for platform-aware thinking visibility

- Add showThinking to SurfaceCapabilities type
- Set showThinking=true for CLI, Web, API (user toggleable)
- Set showThinking=false for WhatsApp, Telegram (locked to hide)
- Messaging platforms never show thinking/reasoning output

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Artur Do Lago
2026-01-11 12:45:22 +01:00
parent aa17f25388
commit 97e3f275fb
3 changed files with 18 additions and 27 deletions
+1 -1
View File
@@ -1355,7 +1355,7 @@ export namespace Server {
capabilities: ["memory", "messaging", "calendar", "contacts", "notifications"],
gateway: {
telegram: false, // Zee uses WhatsApp
whatsapp: WhatsAppGateway.isConnected(),
whatsapp: WhatsAppGateway.getInstance() !== null,
},
},
{
+8 -12
View File
@@ -1,7 +1,7 @@
/**
* Messaging Surface Adapter
*
* Unified adapter for messaging platforms (WhatsApp, Telegram, Discord).
* Unified adapter for messaging platforms (WhatsApp, Telegram).
* Handles non-streaming (message batching) and automatic permission resolution.
*/
@@ -37,7 +37,7 @@ import {
*/
export interface MessagingPlatformHandler {
/** Platform identifier */
readonly platform: 'whatsapp' | 'telegram' | 'discord';
readonly platform: 'whatsapp' | 'telegram';
/** Connect to the platform */
connect(): Promise<void>;
@@ -77,7 +77,7 @@ export type PlatformMessage = {
groupName?: string;
replyToId?: string;
wasMentioned?: boolean;
platform: 'whatsapp' | 'telegram' | 'discord';
platform: 'whatsapp' | 'telegram';
};
// =============================================================================
@@ -96,6 +96,7 @@ const MESSAGING_CAPABILITIES: SurfaceCapabilities = {
messageEditing: false, // Limited editing support
maxMessageLength: 4096, // Default, varies by platform
supportedMediaTypes: ['image/*', 'video/*', 'audio/*', 'application/pdf'],
showThinking: false, // Thinking output is never shown on messaging platforms
};
// Platform-specific capability overrides
@@ -104,16 +105,13 @@ const PLATFORM_CAPABILITIES: Record<string, Partial<SurfaceCapabilities>> = {
maxMessageLength: 65536,
reactions: true,
messageEditing: false,
showThinking: false, // Locked: never show thinking on WhatsApp
},
telegram: {
maxMessageLength: 4096,
reactions: true,
messageEditing: true,
},
discord: {
maxMessageLength: 2000,
reactions: true,
messageEditing: true,
showThinking: false, // Locked: never show thinking on Telegram
},
};
@@ -185,7 +183,7 @@ class MessageBatcher {
/**
* Unified messaging surface adapter.
*
* Handles WhatsApp, Telegram, and Discord with a common interface.
* Handles WhatsApp and Telegram with a common interface.
*/
export class MessagingSurface extends BaseSurface implements Surface {
readonly id: string;
@@ -221,7 +219,6 @@ export class MessagingSurface extends BaseSurface implements Surface {
const names: Record<string, string> = {
whatsapp: 'WhatsApp',
telegram: 'Telegram',
discord: 'Discord',
};
return names[platform] || platform;
}
@@ -472,9 +469,8 @@ export class MessagingSurface extends BaseSurface implements Surface {
* Create a messaging surface with a platform handler.
*
* Platform handlers must be provided by the application:
* - WhatsApp: Use @whiskeysockets/baileys
* - WhatsApp: Use whatsapp-web.js (or @whiskeysockets/baileys)
* - Telegram: Use telegraf
* - Discord: Use discord.js
*
* @example
* ```typescript
+9 -14
View File
@@ -254,6 +254,8 @@ export type SurfaceCapabilities = {
maxMessageLength: number;
/** Supported media types */
supportedMediaTypes: string[];
/** Whether thinking/reasoning output can be shown (false = always hidden, true = user toggleable) */
showThinking?: boolean;
};
/**
@@ -270,13 +272,14 @@ export const DEFAULT_CAPABILITIES: SurfaceCapabilities = {
messageEditing: false,
maxMessageLength: 0,
supportedMediaTypes: [],
showThinking: false,
};
// =============================================================================
// Surface Type
// =============================================================================
export type SurfaceType = "cli" | "web" | "api" | "whatsapp" | "telegram" | "discord";
export type SurfaceType = "cli" | "web" | "api" | "whatsapp" | "telegram";
// =============================================================================
// Surface Adapter Interface
@@ -324,6 +327,7 @@ export const CLI_CAPABILITIES: SurfaceCapabilities = {
messageEditing: false,
maxMessageLength: 0,
supportedMediaTypes: [],
showThinking: true,
};
export const WEB_CAPABILITIES: SurfaceCapabilities = {
@@ -337,6 +341,7 @@ export const WEB_CAPABILITIES: SurfaceCapabilities = {
messageEditing: true,
maxMessageLength: 0,
supportedMediaTypes: ["image/*", "application/pdf", "text/*"],
showThinking: true,
};
export const WHATSAPP_CAPABILITIES: SurfaceCapabilities = {
@@ -350,6 +355,7 @@ export const WHATSAPP_CAPABILITIES: SurfaceCapabilities = {
messageEditing: false,
maxMessageLength: 65536,
supportedMediaTypes: ["image/*", "audio/*", "video/*", "application/pdf"],
showThinking: false,
};
export const TELEGRAM_CAPABILITIES: SurfaceCapabilities = {
@@ -363,19 +369,7 @@ export const TELEGRAM_CAPABILITIES: SurfaceCapabilities = {
messageEditing: true,
maxMessageLength: 4096,
supportedMediaTypes: ["image/*", "audio/*", "video/*", "application/*"],
};
export const DISCORD_CAPABILITIES: SurfaceCapabilities = {
streaming: false,
interactivePrompts: true,
richText: true,
media: true,
threading: true,
typingIndicators: true,
reactions: true,
messageEditing: true,
maxMessageLength: 2000,
supportedMediaTypes: ["image/*", "audio/*", "video/*"],
showThinking: false,
};
export const API_CAPABILITIES: SurfaceCapabilities = {
@@ -389,4 +383,5 @@ export const API_CAPABILITIES: SurfaceCapabilities = {
messageEditing: false,
maxMessageLength: 0,
supportedMediaTypes: ["*/*"],
showThinking: true,
};