feat(line): add LINE Messaging API platform plugin#21020
Closed
perng wants to merge 1 commit intoNousResearch:mainfrom
Closed
feat(line): add LINE Messaging API platform plugin#21020perng wants to merge 1 commit intoNousResearch:mainfrom
perng wants to merge 1 commit intoNousResearch:mainfrom
Conversation
Adds a LINE platform adapter under plugins/platforms/line/ so Hermes
Agent can be run as a LINE bot (the dominant messaging app in Taiwan,
Japan, and Thailand).
Adapter is modeled on the openclaw line extension and the existing
teams/irc plugins:
- aiohttp webhook server at /line/webhook with HMAC-SHA256 + base64
signature verification (constant-time comparison, 64 KB body cap)
- chat-id resolution for user / group / room sources
- outbound sends via the LINE Messaging API: reply token preferred
(50s TTL cap, single-use), automatic fallback to push when the
token is absent, expired, or rejected
- 5-message-per-call batching as the LINE API requires
- inbound image attachments fetched from api-data.line.me/.../content
and cached via cache_image_from_bytes
- send_typing wired to LINE's chat/loading/start ("loading animation")
endpoint; skipped for group/room IDs which the API rejects
- self-message filter via /v2/bot/info userId, plus dedup cache
- LINE_ALLOWED_USERS / LINE_ALLOW_ALL_USERS access control
- interactive_setup() for hermes setup line
Also includes:
- tests/gateway/test_line_adapter.py — 27 tests covering signature
validation, source resolution, reply-token TTL, push fallback,
message batching, and the loading-animation indicator
- scripts/line_adapter_test.py — standalone runner that boots only
the adapter (no full gateway) for local webhook testing
Verified end-to-end against a real LINE channel in 1:1 DM and group
chat.
Closes NousResearch#6081
Refs NousResearch#16611
Author
|
Closing — re-opening from a properly named branch (feat/line-adapter) per the contributing guideline. |
14 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds a LINE Messaging API platform adapter under
plugins/platforms/line/so Hermes Agent can be run as a LINE bot. LINE is the dominant messaging app in Taiwan, Japan, and Thailand, and there is currently no gateway option for users in those markets.The adapter is modeled on the existing teams/irc plugins and the OpenClaw
extensions/linechannel, and uses the plugin path (plugins/platforms/line/) pergateway/platforms/ADDING_A_PLATFORM.md— no edits to core files needed;Platform("line")is auto-discovered via the bundled-plugin scan ingateway/config.py.Related Issue
Fixes #6081
Refs #16611
Type of Change
Changes Made
plugins/platforms/line/adapter.py—LineAdapter(BasePlatformAdapter):/line/webhook, HMAC-SHA256 + base64X-Line-Signatureverification (constant-timehmac.compare_digest, 64 KB body cap)user/group/roomsourcesapi-data.line.me/.../contentand cached viacache_image_from_bytessend_typingwired to LINE'schat/loading/start("loading animation") endpoint; skipped client-side for group/room IDs which the API rejects/v2/bot/infouserId, plusMessageDeduplicatorLINE_ALLOWED_USERS/LINE_ALLOW_ALL_USERSaccess control (wired throughregister_platform)interactive_setup()forhermes setup lineplugins/platforms/line/plugin.yaml+__init__.py— auto-discoverytests/gateway/test_line_adapter.py— 27 tests (signature validation, source resolution, reply-token TTL, push fallback, message batching, loading-animation indicator, register metadata)scripts/line_adapter_test.py— standalone runner that boots only the adapter (no full gateway) for quick local webhook testingHow to Test
Unit tests:
pytest tests/gateway/test_line_adapter.py -v # → 27 passedLive channel:
LINE_CHANNEL_ACCESS_TOKEN+LINE_CHANNEL_SECRET.~/.hermes/.env:~/.hermes/config.yaml:cloudflared tunnel --url http://localhost:3979(or ngrok).https://<tunnel>/line/webhookand click Verify in the LINE console.hermes --gateway→ message your bot from the LINE app.Verified end-to-end against a real LINE channel in 1:1 DM and group chat with
gemini-3-flash-preview.Checklist
Code
pytest tests/gateway/test_line_adapter.py -vand all 27 tests passDocumentation & Housekeeping
plugin.yamldescribe configuration; follows thegateway/platforms/ADDING_A_PLATFORM.mdplugin pathcli-config.yaml.example; standardplatforms.<name>.{enabled, extra}shapeNotes for reviewers
Relationship to #16611: That issue references
leepoweii/hermes-agent@feat/line-adapter, which uses the built-in path (gateway/platforms/line.py+ edits toPlatformenum + setup wizard) and adds a PENDING/READY/DELIVERED postback Quick Reply state machine for slow LLM responses. This PR uses the plugin path (recommended inADDING_A_PLATFORM.md) and handles the 60-second reply-token deadline by capping internal token validity at 50s and falling back to push — simpler, no postback UX, but functionally correct for the deadline. Maintainers may prefer the leepoweii approach for #16611; happy to defer to whichever you want to land.LINE_PORTdefault: 3979 (Teams uses 3978). Override withextra.portinconfig.yamlorLINE_PORTenv var.