Commit graph

42 commits

Author SHA1 Message Date
易良
f296eb1a6d
fix(release): run release:version 0.14.2 to sync all package versions (#3026)
The previous version bump commit (bb4376c) only updated the root
package.json but did not run `npm run release:version` to propagate
the version and sandboxImageUri to all workspace packages.

This caused Docker sandbox integration tests to fail in CI with
"manifest unknown" because build_sandbox.js built image 0.14.1
(from packages/cli/package.json) while sandboxConfig.ts expected
image 0.14.2 (from root package.json).

Fixes: https://github.com/QwenLM/qwen-code/actions/runs/24135197272/job/70424966323
2026-04-08 21:33:40 +08:00
tanzhenxin
928a957db1 fix(weixin): add missing iLink-App-Id and iLink-App-ClientVersion headers
The iLink Bot API requires these headers for session authentication.
Without them, getupdates returns errcode -14 (session timeout).

The protocol version (2.0.0) is tracked independently from our channel
version, matching the current official plugin's API compatibility level.

Closes #2908
2026-04-07 15:26:00 +08:00
chinesepowered
ab5006fedc fix(telegram): send only failed chunk as plaintext fallback
The HTML send fallback was sending the entire original text instead of
just the failed chunk, and returning early which skipped remaining
chunks. Now strips HTML from only the failed chunk and continues to
send the remaining chunks.
2026-04-04 15:14:37 -07:00
tanzhenxin
47fac88695 chore: bump version to 0.14.1
Bump version across all packages from 0.14.0 to 0.14.1.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-04-03 16:17:10 +08:00
tanzhenxin
d07861ad5c chore(channels): make plugin-example private and remove from release workflow
- Mark @qwen-code/channel-plugin-example as private in package.json
- Remove publish step from release workflow
- Remove file: to semver rewrite logic in version script
- Use file: reference for @qwen-code/channel-base dependency

This change prevents the example plugin from being published to npm, as it's only intended for internal/development use.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-04-01 20:43:45 +08:00
tanzhenxin
555f92ff21 chore(release): bump version to 0.14.0
- Update all packages from 0.13.x to 0.14.0
- Update sandbox image URI to 0.14.0

This prepares the 0.14.0 release with updated version numbers
across all workspace packages.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-04-01 19:23:49 +08:00
tanzhenxin
46bd05eaf1 fix(channels/telegram): migrate from telegraf to grammy
Replace Telegraf with Grammy as the Telegram Bot framework.

- Replace @telegraf/types with @grammyjs/types in package-lock.json
- Swap telegraf dependency for grammy ^1.41.1 in package.json
- Update TelegramAdapter.ts: Bot instead of Telegraf, .api.* instead
  of .telegram.* calls, .start() instead of .launch(), adjusted event
  subscription syntax (message:text, message:photo, message:document)

Grammy is a more modern and actively maintained Telegram bot framework
for Node.js, improving reliability and reduce legacy dependencies.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-04-01 04:28:14 +00:00
tanzhenxin
f61517c40c chore(channels): add plugin-example to build pipeline and prepublish script
- Add plugin-example to build order in scripts/build.js
- Add prepublishOnly script to auto-build before npm publish

This ensures the plugin-example package is built during the main build process and automatically compiled before publishing to npm.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-04-01 12:22:33 +08:00
tanzhenxin
7bbd5e6471 fix(channels): address PR review — security, bugs, and reliability
- fix: sanitize remote filenames with basename() and isolate uploads
  in UUID subdirs to prevent path traversal and collision (#2-4, #27)
- fix: use crypto.randomInt() for pairing codes instead of Math.random() (#5)
- fix: pass config.sessionScope instead of hardcoded 'user' (#6);
  add per-channel scope overrides via setChannelScope() for startAll (#7)
- fix: removeSession now returns removed session IDs and persists
  when chatId is provided (#8)
- fix: /clear only removes the cleared session from instructedSessions,
  not all sessions (#9)
- fix: DingTalk @mention stripping now removes only the first mention
  instead of all mentions (#10)
- fix: remove dead TELEGRAF_COMMANDS Set and its guard (#13)
- fix: WeChat cursor saved after message processing, not before (#14)
- fix: crash recovery uses time-window counting instead of resettable
  counter to prevent infinite restart loops (#17)
- fix: call channel.disconnect() before exit on crash exhaustion (#18)
2026-03-31 00:57:59 +00:00
tanzhenxin
7251da0152 feat(channels): add dispatch modes and prompt lifecycle hooks
Add three dispatch modes for handling concurrent messages:
- steer (default): cancel current prompt and start new one
- collect: buffer messages and coalesce into follow-up prompt
- followup: queue messages for sequential processing

Introduce onPromptStart/onPromptEnd lifecycle hooks for working
indicators. These fire only when a prompt actually begins processing,
not for buffered (collect mode) or gated/blocked messages.

Refactor Telegram, WeChat, and DingTalk adapters to use the new hooks
instead of overriding handleInbound, simplifying the working indicator
pattern and ensuring correct behavior with dispatch modes.

This enables better UX for async workflows and prevents indicator
leaks when messages are buffered or cancelled.
2026-03-28 06:19:02 +00:00
tanzhenxin
d84675e86f test(channels): add comprehensive test suites for channel adapters
- Add ChannelBase, GroupGate, SenderGate, SessionRouter tests
- Add DingTalk markdown utility tests
- Add Weixin media and send helper tests
- Add CLI channel config-utils and pidfile tests
- Configure vitest for all channel packages
- Exclude test files from TypeScript build

Tests cover attachment handling, block streaming, gating policies,
session routing, markdown conversion, config parsing, and service management.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-27 15:26:39 +00:00
tanzhenxin
39103eea5f docs(channels): document attachments and block streaming features
- Add Attachments interface docs with handling examples
- Document block streaming configuration and behavior
- Update architecture diagrams to show attachment resolution
- Add Attachment type to exported types reference
- Update plugin-example README

Covers new structured attachment support and block streaming
that delivers responses as multiple progressive messages.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-27 14:57:17 +00:00
tanzhenxin
3e0f213ea3 feat(channels): add structured attachment support for file handling
- Add Attachment interface with type, data, filePath, mimeType, fileName
- Resolve attachments in ChannelBase before prompting bridge
- Update DingTalk, Telegram, Weixin adapters to use structured attachments
- Clean up placeholder text when files are received
- Export Attachment type from base package index

This enables proper handling of images and files across all channels,
separating attachment metadata from message text.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-27 14:50:24 +00:00
tanzhenxin
3d24a9c3fe feat(channels): add BlockStreamer for progressive message delivery
- Add BlockStreamer class to split streaming responses into multiple messages
- Configure block streaming with min/max chars and idle coalescing
- Integrate into ChannelBase when blockStreaming: 'on'
- Add comprehensive test coverage (16 tests)

This improves UX by delivering completed paragraphs as separate messages
instead of waiting for the full response.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-27 14:36:40 +00:00
tanzhenxin
f7979aa902 feat(channels): add streaming response hooks to ChannelBase
- Add onResponseChunk hook for progressive text display during streaming
- Add onResponseComplete hook for customizing response delivery
- Update mock plugin channel to support streaming chunks

This enables channels to display AI responses progressively as they stream,
improving user experience with real-time feedback.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-27 14:08:09 +00:00
tanzhenxin
0ca8cf86f6 docs(channels): add README for channel-base package
This provides documentation for the base infrastructure used to build
Qwen Code channel adapters, including architecture overview, quick start
guide, and API reference.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-27 12:31:53 +00:00
tanzhenxin
dea144918b feat(channels): configure channel adapters for compiled distribution
- Update package.json exports to point to dist directory
- Add TypeScript build scripts to each channel adapter
- Include channel adapters in build order

This enables proper TypeScript compilation and distribution of channel
adapter packages.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-27 08:46:54 +00:00
tanzhenxin
a700ce8186 chore(release): add channel packages to release workflow
- Bump channel package versions to 0.13.0
- Add publish steps for @qwen-code/channel-base and @qwen-code/channel-plugin-example
- Update version script to convert file: references to semver for published packages

This enables proper npm publishing of channel packages during the release process.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-27 06:16:22 +00:00
tanzhenxin
c97c548acb feat(channels): make plugin-example package publishable
- Update channel-base to use built dist/ output with proper exports
- Add README with quick start guide and usage instructions
- Add qwen-extension.json manifest for extension discovery
- Add start-server CLI for running the mock WebSocket server
- Update dependencies from local file: to npm version

This enables the plugin-example package to be published and installed
as a standalone extension for testing the channel plugin system.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-27 04:21:56 +00:00
tanzhenxin
987eebd1c4 docs(channels): add plugin developer guide and rename mock to plugin-example
- Add comprehensive developer guide for building channel plugins
- Add user-facing docs for installing/configuring custom channel plugins
- Replace custom-channels.md with new plugins.md
- Rename @qwen-code/channel-mock to @qwen-code/channel-plugin-example
- Add messageId field to Envelope type for response correlation

This provides clear documentation for developers building custom channel
adapters and renames the mock package to better reflect its purpose as
a reference implementation example.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-27 03:19:34 +00:00
tanzhenxin
0f9e4409df feat(channels): add mock channel package for E2E testing
- Add @qwen-code/channel-mock package with MockPluginChannel
- Add createMockServer for programmatic test control via WebSocket
- Refactor integration test to use real WebSocket E2E flow

This enables testing the full channel pipeline (WebSocket → ChannelBase → AcpBridge → agent)
instead of the previous in-process loopback approach.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-26 14:30:33 +00:00
tanzhenxin
8a6ed128ea feat(channels): add ChannelPlugin interface and registry-based factory
Refactor channel system to use a formal plugin interface:

- Add ChannelPlugin interface to @qwen-code/channel-base (channelType,
  displayName, requiredConfigFields, createChannel factory)
- Each built-in adapter (Telegram, WeChat, DingTalk) exports a plugin object
- Replace hardcoded if/else factory with a Map-based channel registry
- Config validation now uses plugin's requiredConfigFields dynamically
- ChannelType changed from fixed union to string for extensibility
- Multi-channel mode now picks model from first channel config

This is the foundation for external plugin support — built-in channels
go through the exact same code path that third-party plugins will use.
2026-03-26 12:34:31 +00:00
tanzhenxin
f3a03d0bdc fix(channels): isolate sessions per chat and serialize prompts per session
Two bugs caused cross-talk between DM and group conversations:

1. Session routing key only used senderId, so the same user in DM and
   group shared one ACP session (and conversation context). Now includes
   chatId: `channelName:senderId:chatId`.

2. Concurrent messages on the same session caused textChunk listener
   pollution in AcpBridge.prompt(), leaking response text across chats.
   Added per-session promise queue in ChannelBase to serialize prompts.
2026-03-26 11:58:03 +00:00
tanzhenxin
9f4dd53198 feat(channels): add DingTalk reply/quote message context support
- Add interfaces for DingTalkRepliedMsg and DingTalkRichTextPart types
- Support both newer text.repliedMsg and legacy quoteMessage formats
- Extract quoted message context with isReplyToBot detection
- Summarize replied content (text, richText, media placeholders)

This enables the bot to understand when users are replying to specific
messages and provides context about what message is being referenced.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-26 09:08:36 +00:00
tanzhenxin
a61189b232 feat(channels): add DingTalk media download support
- Handle richText, picture, file, audio, video message types
- Download media via DingTalk API two-step flow
- Attach images as base64, save other files to temp dir
- Add DingTalkMessageData interface for richer payloads

This enables the DingTalk channel to process media attachments
in incoming messages.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-26 08:49:56 +00:00
tanzhenxin
6c6057cf9c feat(channels): add DingTalk markdown normalization
- Convert tables to pipe-separated plain text (DingTalk doesn't render tables)
- Split long messages into chunks respecting ~3800 char limit
- Handle code fences across chunk boundaries
- Extract title from first markdown line for webhook payload

This ensures markdown content renders correctly in DingTalk's limited renderer.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-26 08:34:34 +00:00
tanzhenxin
217964b849 feat(channels): add reaction feedback and webhook caching for DingTalk
- Cache sessionWebhook by conversationId for reliable message routing
- Show 👀 reaction while processing messages, then recall it
- Use conversationId as chatId instead of webhook URL
- Fix rawData parsing for already-parsed message data

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-26 08:29:27 +00:00
tanzhenxin
92c54ff309 feat(channels): add DingTalk channel adapter
- Add @qwen-code/channel-dingtalk package with stream-based bot integration
- Support clientId/clientSecret authentication for DingTalk
- Add message deduplication and group chat mention handling
- Update ChannelConfig type to include dingtalk channel type

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-26 08:03:43 +00:00
tanzhenxin
1a272a12e9 feat(channels): add reply context support for referenced messages
- Add referencedText field to Envelope for quoted/replied-to messages
- TelegramAdapter extracts text from reply_to_message
- WeixinAdapter extracts text from ref_msg field
- ChannelBase prepends referenced text to agent prompt

This allows the agent to see what message a user is replying to,
providing better context for conversations in both Telegram and WeChat.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-26 03:34:16 +00:00
tanzhenxin
9c001ba61e feat(channels): add shared slash command system
- Add /help, /clear (aliases: /reset, /new), /status commands to ChannelBase
- Commands are handled locally without agent round-trip
- TelegramAdapter skips "Working..." indicator for local commands
- Update docs to reflect new command structure

This provides a consistent command interface across all channel types
(Telegram, WeChat, etc.) with platform-specific extensibility.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-26 03:24:44 +00:00
tanzhenxin
1a605ec973 feat(channels): add crash recovery and gateway mode support
- Add session persistence to SessionRouter for crash recovery
- Add loadSession method to AcpBridge for restoring sessions
- Add ChannelBaseOptions to support external router injection
- Refactor start.ts to support both standalone and gateway modes
- Extract config utilities into separate module

This enables channels to recover sessions after bridge crashes and
supports running multiple channels under a gateway process.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-26 02:55:18 +00:00
tanzhenxin
b37e2110f5 feat(channels): add file and photo support for Telegram and WeChat
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

- Add photo message handling in Telegram adapter with base64 encoding

- Add document/file message handling with temp directory storage

- Extend WeChat adapter to support file downloads from CDN

- Refactor envelope building into reusable buildEnvelope method

- Rename ImageCdnRef to CdnRef for generic media handling

This enables users to send images and files through both Telegram and WeChat channels, with files saved to a temp directory for agent access.
2026-03-25 08:09:21 +00:00
tanzhenxin
4f2b9e9bd8 feat(channels): add multimodal support with image handling
- Add model configuration option for channel-specific model selection
- Support base64-encoded images in prompts via AcpBridge
- Add media utilities for WeChat/Weixin channel
- Update settings schema for model configuration

Enables channels to process images and use custom models.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-25 07:43:48 +00:00
tanzhenxin
24c9b0f333 feat(channels): add WeChat/Weixin channel support
- Add WeixinAdapter with accounts, api, login, monitor, send modules
- Add channel configure command for interactive setup
- Update TelegramAdapter for consistency

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-25 06:54:51 +00:00
tanzhenxin
90236465d3 feat(channels): add group chat support for Telegram
- Add GroupGate class for group access control with three policies:
  disabled (default), allowlist, and open
- Implement mention gating: bot only responds when @mentioned or replied to
  in groups (configurable per-group)
- Extend Envelope type with isGroup, isMentioned, isReplyToBot fields
- Update TelegramAdapter to detect group context and mentions
- Add comprehensive documentation for group chat setup and troubleshooting

This enables using Qwen Code bots in Telegram groups with fine-grained
access control and mention-based activation to prevent noise.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-25 02:04:27 +00:00
tanzhenxin
8753245b5f feat(channels): add DM pairing flow for sender approval
- Add PairingStore for managing pending requests and approved users
- Update SenderGate to support pairing policy with code generation
- Add CLI commands: `qwen channel pairing list/approve`
- Document pairing flow with rules and usage examples

This allows unknown senders to request access via a pairing code
that the bot operator approves through the CLI.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-24 11:37:16 +00:00
tanzhenxin
2867e779b9 refactor(channels): simplify Telegram status tracking and improve event handling
- Add ToolCallEvent interface and emit typed events from AcpBridge
- Refactor sessionUpdate handling into dedicated method
- Simplify TelegramAdapter to use simple 'Working...' message
- Change to non-awaited handler to avoid Telegraf 90s timeout
- Remove console.log statements for cleaner code

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-24 10:18:23 +00:00
tanzhenxin
a5d2fafa3c fix(channels): fix TypeScript build errors
- Use bracket notation for index signature properties
- Add tsconfig.json for channels/base and channels/telegram packages

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-24 06:45:39 +00:00
tanzhenxin
615ccd08f2 feat(channels): add config validation, instructions, and sessionScope support
- Validate required fields (type, token) with clear error messages
- Prepend channel instructions to first prompt of each session
- SessionRouter respects sessionScope (user/thread/single) for routing keys
2026-03-24 06:33:37 +00:00
tanzhenxin
2985201317 feat(channels/telegram): add slash command support
- Local commands: /start (welcome), /help (dynamic list), /reset (clear session)
- Non-local slash commands forwarded to ACP agent as prompts
- AcpBridge captures available_commands_update to populate /help dynamically
- SessionRouter gains hasSession/removeSession for /reset support
2026-03-24 06:33:37 +00:00
tanzhenxin
be838eea01 feat(channels/telegram): format agent markdown as Telegram HTML
Use telegram-markdown-formatter to convert agent markdown responses
to Telegram HTML (bold, italic, code blocks, links). Falls back to
plain text if HTML parsing fails. Also uses the package's built-in
HTML-aware message splitting for long responses.
2026-03-24 06:33:36 +00:00
tanzhenxin
3eedc43238 feat(channels): add Telegram channel integration with ACP bridge
Implements the channels infrastructure for connecting external messaging
platforms to Qwen Code via ACP. Phase 1 supports plain text round-trip:
Telegram user sends message -> AcpBridge -> qwen-code --acp -> response
back to Telegram.

New packages:
- @qwen-code/channel-base: AcpBridge, SessionRouter, SenderGate, ChannelBase
- @qwen-code/channel-telegram: TelegramAdapter using telegraf

CLI: `qwen channel start <name>` reads from settings.json channels config,
spawns ACP agent, connects to Telegram via polling.
2026-03-24 06:33:36 +00:00