Skip to content

feat(dingtalk): QR-code device-flow authorization for setup wizard#11574

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-e52e6172
Apr 17, 2026
Merged

feat(dingtalk): QR-code device-flow authorization for setup wizard#11574
teknium1 merged 2 commits into
mainfrom
hermes/hermes-e52e6172

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Salvages #8345 (meng93 — authorship preserved) + 15 new regression tests + an OpenClaw branding disclosure.

Adds QR-code device-flow authorization to hermes gateway setup for DingTalk, eliminating the manual developer-console workflow. Users scan a QR with the DingTalk mobile app and Client ID / Client Secret are returned automatically.

Why this path

Per design discussion with @teknium1:

  • Tested source="hermes" live (option B): DingTalk's /app/registration/begin accepts any source at the API layer but the returned verification_uri_complete is hardcoded to https://open-dev.dingtalk.com/openapp/registration/openClaw?user_code=.... Confirmed against the real endpoint — we cannot use our own source string until DingTalk-Real-AI registers a Hermes template server-side. Issue Feature: Switchable Agent Modes — Named Profiles with Tool Restrictions, Personas & Per-Project Config (inspired by Roo Code) #482 on their repo (filed today asking about Hermes support) has no official response yet.
  • Going with openClaw identity for now (option C): Takes the onboarding win. Nous will follow up with Alibaba/DingTalk-Real-AI via a direct channel to register a Hermes-specific source so we can eventually swap the token. The disclosure below makes the interim UX honest with users.

What's in

meng93's commit (0bbb6f0) — cherry-picked with authorship preserved:

  • hermes_cli/dingtalk_auth.py (new, 292 lines) — three-step device flow (init → begin → poll) + compact half-block QR renderer + auto-install of qrcode pip dep.
  • hermes_cli/gateway.py — rewrites _setup_dingtalk() to offer QR scan (default) or manual credential entry, plus dispatch wiring in gateway_setup().
  • gateway/config.py — env-var → PlatformConfig bridge for DINGTALK_CLIENT_ID, DINGTALK_CLIENT_SECRET, and optional DINGTALK_HOME_CHANNEL (matches the pattern used by other platforms).

Intentionally dropped from meng93's PR:

My follow-up (b7ba865):

  • 15 regression tests in tests/hermes_cli/test_dingtalk_auth.py covering _api_post error paths, begin_registration chaining + missing-field errors, polling loop success/failure/callback, QR renderer fallback, and env-var config overrides.
  • One-line disclosure in dingtalk_qr_auth():
    Note: the scan page is branded 'OpenClaw' — DingTalk's
          ecosystem onboarding bridge. Safe to use.
    
  • Added meng93 to scripts/release.py AUTHOR_MAP.

Tests

  • tests/hermes_cli/test_dingtalk_auth.py15 passed (new)
  • tests/hermes_cli/test_dingtalk_auth.py + test_dingtalk.py + test_config.py85 passed combined
  • E2E against real oapi.dingtalk.com — loaded module from worktree, called begin_registration() live, got a real device_code + verification_uri_complete back. Didn't complete the QR scan (requires a human + DingTalk mobile app) but the full protocol up to QR display works.

Authorship

Commit 0bbb6f0a preserves meng93 <yiweimeng.dlut@hotmail.com> as author. Merge with --rebase to keep attribution.

PRs #9610 and #10004 ship word-for-word identical dingtalk_auth.py code — they're copies of meng93's earlier submission (meng93: Apr 12, audanye-sudo: Apr 14, PeterGuy326: Apr 15). On merge they'll be closed with credit to all three, with primary credit to meng93 as the original author.

Follow-ups (post-merge)

  1. @teknium1 to reach out to DingTalk-Real-AI via their Alibaba contact to register hermes as a sanctioned source token.
  2. When sanctioned, flip REGISTRATION_SOURCE default from openClawhermes and remove the disclosure. The DINGTALK_REGISTRATION_SOURCE env var already exists as an escape hatch.

Closes

Closes #8345, #9610, #10004 on merge.

meng93 and others added 2 commits April 17, 2026 05:02
- feat: support one-click QR scan to create DingTalk bot and establish connection
- fix(gateway): wrap blocking DingTalkStreamClient.start() with asyncio.to_thread()
- fix(gateway): extract message fields from CallbackMessage payload instead of ChatbotMessage
- fix(gateway): add oapi.dingtalk.com to allowed webhook URL domains
Adds 15 regression tests for hermes_cli/dingtalk_auth.py covering:
  * _api_post — network error mapping, errcode-nonzero mapping, success path
  * begin_registration — 2-step chain, missing-nonce/device_code/uri
    error cases
  * wait_for_registration_success — success path, missing-creds guard,
    on_waiting callback invocation
  * render_qr_to_terminal — returns False when qrcode missing, prints
    when available
  * Configuration — BASE_URL default + override, SOURCE default

Also adds a one-line disclosure in dingtalk_qr_auth() telling users
the scan page will be OpenClaw-branded. Interim measure: DingTalk's
registration portal is hardcoded to route all sources to /openapp/
registration/openClaw, so users see OpenClaw branding regardless of
what 'source' value we send. We keep 'openClaw' as the source token
until DingTalk-Real-AI registers a Hermes-specific template.

Also adds meng93 to scripts/release.py AUTHOR_MAP.
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Supply Chain Risk Detected

This PR contains patterns commonly associated with supply chain attacks. This does not mean the PR is malicious — but these patterns require careful human review before merging.

⚠️ WARNING: Outbound network calls (POST/PUT)

Outbound POST/PUT requests in new code could be data exfiltration. Verify the destination URLs are legitimate.

Matches (first 10):

362:+        resp = requests.post(url, json=payload, timeout=15)

Automated scan triggered by supply-chain-audit. If this is a false positive, a maintainer can approve after manual review.

@teknium1 teknium1 merged commit 13f2d99 into main Apr 17, 2026
7 checks passed
@teknium1 teknium1 deleted the hermes/hermes-e52e6172 branch April 17, 2026 12:08
teknium1 added a commit that referenced this pull request Apr 17, 2026
All three messaging platforms that render QR codes during setup
(Weixin, DingTalk, Feishu) need the `qrcode` package. It wasn't
declared anywhere, so users installing via `pip install hermes-agent[messaging]`
had to manually `pip install qrcode` or hit a rendering error mid-wizard.

Adds `qrcode>=7.0,<9` to:
  * `messaging` extra — used by Weixin (weixin.py:955)
  * `dingtalk` extra  — used by the QR auth flow landed in #11574
  * `feishu` extra    — used by feishu.py:3962

The `all` extra inherits from all three, so it picks up qrcode
transitively — no separate entry needed.

Also updates website/docs/user-guide/messaging/weixin.md to stop
telling users to `pip install qrcode` separately and instead point
at `pip install 'hermes-agent[messaging]'`. The troubleshooting
row for QR render failure keeps `pip install qrcode` as a minimal-
install fallback.

Closes #9431 — reported by zhangzhiqiangcs.
teknium1 added a commit that referenced this pull request Apr 17, 2026
…aging)

#4b1567f4 (anthhub) added qrcode to the messaging extra for Weixin's
QR login. The same package is needed by:

  * hermes_cli/dingtalk_auth.py — QR device-flow auth shipped in #11574
  * gateway/platforms/feishu.py:3962 — Feishu QR login

These extras are independent of [messaging] (users can install
hermes-agent[dingtalk] or hermes-agent[feishu] without [messaging]),
so the dep needs to be declared on each.

Pin matches anthhub's choice (>=7.0,<8) for consistency. The all
extra inherits from all three, so it picks up qrcode transitively.

Adds parallel tests to tests/test_project_metadata.py — same shape
as test_messaging_extra_includes_qrcode_for_weixin_setup.

Refs #9431.
teknium1 added a commit that referenced this pull request Apr 17, 2026
…aging) (#11627)

#4b1567f4 (anthhub) added qrcode to the messaging extra for Weixin's
QR login. The same package is needed by:

  * hermes_cli/dingtalk_auth.py — QR device-flow auth shipped in #11574
  * gateway/platforms/feishu.py:3962 — Feishu QR login

These extras are independent of [messaging] (users can install
hermes-agent[dingtalk] or hermes-agent[feishu] without [messaging]),
so the dep needs to be declared on each.

Pin matches anthhub's choice (>=7.0,<8) for consistency. The all
extra inherits from all three, so it picks up qrcode transitively.

Adds parallel tests to tests/test_project_metadata.py — same shape
as test_messaging_extra_includes_qrcode_for_weixin_setup.

Refs #9431.
teknium1 added a commit that referenced this pull request Apr 18, 2026
Fills documentation gaps that accumulated as features merged ahead of their
docs updates. All additions are verified against code and the originating PRs.

Providers:
- Ollama Cloud (#10782) — new provider section, env vars, quickstart/fallback rows
- xAI Grok Responses API + TTS (#10783) — provider note, TTS table + config
- Google Gemini CLI OAuth (#11270) — quickstart/fallback/cli-commands entries
- NVIDIA NIM (#11774) — NVIDIA_API_KEY / NVIDIA_BASE_URL in env-vars reference
- HERMES_INFERENCE_PROVIDER enum updated

Messaging:
- DISCORD_ALLOWED_ROLES (#11608) — env-vars, discord.md access control section
- DingTalk QR device-flow (#11574) — wizard path in Option A + openClaw disclosure
- Feishu document comment intelligent reply (#11898) — full section + 3-tier access control + CLI

Skills / commands:
- concept-diagrams skill (#11363) — optional-skills-catalog entry
- /gquota (#11270) — slash-commands reference

Build: docusaurus build passes, ascii-guard lint 0 errors.
teknium1 added a commit that referenced this pull request Apr 18, 2026
Fills documentation gaps that accumulated as features merged ahead of their
docs updates. All additions are verified against code and the originating PRs.

Providers:
- Ollama Cloud (#10782) — new provider section, env vars, quickstart/fallback rows
- xAI Grok Responses API + TTS (#10783) — provider note, TTS table + config
- Google Gemini CLI OAuth (#11270) — quickstart/fallback/cli-commands entries
- NVIDIA NIM (#11774) — NVIDIA_API_KEY / NVIDIA_BASE_URL in env-vars reference
- HERMES_INFERENCE_PROVIDER enum updated

Messaging:
- DISCORD_ALLOWED_ROLES (#11608) — env-vars, discord.md access control section
- DingTalk QR device-flow (#11574) — wizard path in Option A + openClaw disclosure
- Feishu document comment intelligent reply (#11898) — full section + 3-tier access control + CLI

Skills / commands:
- concept-diagrams skill (#11363) — optional-skills-catalog entry
- /gquota (#11270) — slash-commands reference

Build: docusaurus build passes, ascii-guard lint 0 errors.
@meng93

meng93 commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

@teknium1 Hi! The follow-up items you outlined in this PR have now been fully implemented.

1. Registration source switch → PR #12907

Now that the Hermes source token has been officially sanctioned by DingTalk-Real-AI, this PR flips the DINGTALK_REGISTRATION_SOURCE default from openClaw to HERMES, updates the user-facing disclosure copy, and adds source normalization logic. The env var escape hatch remains fully intact.

2. New platform capabilities → PR #12769

Adds several missing capabilities to the DingTalk adapter:

  • Proactive messaging (text / markdown / card)
  • Full media pipeline (image / file / audio / video upload & send)
  • Global card API QPS throttle (20 QPS token bucket) + per-card 800ms edit debounce
  • Per-session inbound serialization queue
  • Quoted-reply extraction (with forward-compatible interactiveCard handling)
  • Fix for cross-adapter websockets monkey-patch conflict

Both PRs are tested and ready to go. Would love to get these merged soon so DingTalk users can benefit from the sanctioned Hermes identity and the full feature set as quickly as possible. 🚀

Again, really appreciate your original design on this PR — the clear follow-up checklist and the DINGTALK_REGISTRATION_SOURCE env var escape hatch made the transition incredibly smooth. Great engineering foresight! 👏

ulasbilgen pushed a commit to ulasbilgen/hermes-adhd-agent that referenced this pull request May 1, 2026
…aging) (NousResearch#11627)

#30ab7d40 (anthhub) added qrcode to the messaging extra for Weixin's
QR login. The same package is needed by:

  * hermes_cli/dingtalk_auth.py — QR device-flow auth shipped in NousResearch#11574
  * gateway/platforms/feishu.py:3962 — Feishu QR login

These extras are independent of [messaging] (users can install
hermes-agent[dingtalk] or hermes-agent[feishu] without [messaging]),
so the dep needs to be declared on each.

Pin matches anthhub's choice (>=7.0,<8) for consistency. The all
extra inherits from all three, so it picks up qrcode transitively.

Adds parallel tests to tests/test_project_metadata.py — same shape
as test_messaging_extra_includes_qrcode_for_weixin_setup.

Refs NousResearch#9431.
ulasbilgen pushed a commit to ulasbilgen/hermes-adhd-agent that referenced this pull request May 1, 2026
)

Fills documentation gaps that accumulated as features merged ahead of their
docs updates. All additions are verified against code and the originating PRs.

Providers:
- Ollama Cloud (NousResearch#10782) — new provider section, env vars, quickstart/fallback rows
- xAI Grok Responses API + TTS (NousResearch#10783) — provider note, TTS table + config
- Google Gemini CLI OAuth (NousResearch#11270) — quickstart/fallback/cli-commands entries
- NVIDIA NIM (NousResearch#11774) — NVIDIA_API_KEY / NVIDIA_BASE_URL in env-vars reference
- HERMES_INFERENCE_PROVIDER enum updated

Messaging:
- DISCORD_ALLOWED_ROLES (NousResearch#11608) — env-vars, discord.md access control section
- DingTalk QR device-flow (NousResearch#11574) — wizard path in Option A + openClaw disclosure
- Feishu document comment intelligent reply (NousResearch#11898) — full section + 3-tier access control + CLI

Skills / commands:
- concept-diagrams skill (NousResearch#11363) — optional-skills-catalog entry
- /gquota (NousResearch#11270) — slash-commands reference

Build: docusaurus build passes, ascii-guard lint 0 errors.
aj-nt pushed a commit to aj-nt/hermes-agent that referenced this pull request May 1, 2026
…aging) (NousResearch#11627)

#2e399644 (anthhub) added qrcode to the messaging extra for Weixin's
QR login. The same package is needed by:

  * hermes_cli/dingtalk_auth.py — QR device-flow auth shipped in NousResearch#11574
  * gateway/platforms/feishu.py:3962 — Feishu QR login

These extras are independent of [messaging] (users can install
hermes-agent[dingtalk] or hermes-agent[feishu] without [messaging]),
so the dep needs to be declared on each.

Pin matches anthhub's choice (>=7.0,<8) for consistency. The all
extra inherits from all three, so it picks up qrcode transitively.

Adds parallel tests to tests/test_project_metadata.py — same shape
as test_messaging_extra_includes_qrcode_for_weixin_setup.

Refs NousResearch#9431.
aj-nt pushed a commit to aj-nt/hermes-agent that referenced this pull request May 1, 2026
)

Fills documentation gaps that accumulated as features merged ahead of their
docs updates. All additions are verified against code and the originating PRs.

Providers:
- Ollama Cloud (NousResearch#10782) — new provider section, env vars, quickstart/fallback rows
- xAI Grok Responses API + TTS (NousResearch#10783) — provider note, TTS table + config
- Google Gemini CLI OAuth (NousResearch#11270) — quickstart/fallback/cli-commands entries
- NVIDIA NIM (NousResearch#11774) — NVIDIA_API_KEY / NVIDIA_BASE_URL in env-vars reference
- HERMES_INFERENCE_PROVIDER enum updated

Messaging:
- DISCORD_ALLOWED_ROLES (NousResearch#11608) — env-vars, discord.md access control section
- DingTalk QR device-flow (NousResearch#11574) — wizard path in Option A + openClaw disclosure
- Feishu document comment intelligent reply (NousResearch#11898) — full section + 3-tier access control + CLI

Skills / commands:
- concept-diagrams skill (NousResearch#11363) — optional-skills-catalog entry
- /gquota (NousResearch#11270) — slash-commands reference

Build: docusaurus build passes, ascii-guard lint 0 errors.
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
…aging) (NousResearch#11627)

#4b1567f4 (anthhub) added qrcode to the messaging extra for Weixin's
QR login. The same package is needed by:

  * hermes_cli/dingtalk_auth.py — QR device-flow auth shipped in NousResearch#11574
  * gateway/platforms/feishu.py:3962 — Feishu QR login

These extras are independent of [messaging] (users can install
hermes-agent[dingtalk] or hermes-agent[feishu] without [messaging]),
so the dep needs to be declared on each.

Pin matches anthhub's choice (>=7.0,<8) for consistency. The all
extra inherits from all three, so it picks up qrcode transitively.

Adds parallel tests to tests/test_project_metadata.py — same shape
as test_messaging_extra_includes_qrcode_for_weixin_setup.

Refs NousResearch#9431.
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
)

Fills documentation gaps that accumulated as features merged ahead of their
docs updates. All additions are verified against code and the originating PRs.

Providers:
- Ollama Cloud (NousResearch#10782) — new provider section, env vars, quickstart/fallback rows
- xAI Grok Responses API + TTS (NousResearch#10783) — provider note, TTS table + config
- Google Gemini CLI OAuth (NousResearch#11270) — quickstart/fallback/cli-commands entries
- NVIDIA NIM (NousResearch#11774) — NVIDIA_API_KEY / NVIDIA_BASE_URL in env-vars reference
- HERMES_INFERENCE_PROVIDER enum updated

Messaging:
- DISCORD_ALLOWED_ROLES (NousResearch#11608) — env-vars, discord.md access control section
- DingTalk QR device-flow (NousResearch#11574) — wizard path in Option A + openClaw disclosure
- Feishu document comment intelligent reply (NousResearch#11898) — full section + 3-tier access control + CLI

Skills / commands:
- concept-diagrams skill (NousResearch#11363) — optional-skills-catalog entry
- /gquota (NousResearch#11270) — slash-commands reference

Build: docusaurus build passes, ascii-guard lint 0 errors.
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
…aging) (NousResearch#11627)

#4b1567f4 (anthhub) added qrcode to the messaging extra for Weixin's
QR login. The same package is needed by:

  * hermes_cli/dingtalk_auth.py — QR device-flow auth shipped in NousResearch#11574
  * gateway/platforms/feishu.py:3962 — Feishu QR login

These extras are independent of [messaging] (users can install
hermes-agent[dingtalk] or hermes-agent[feishu] without [messaging]),
so the dep needs to be declared on each.

Pin matches anthhub's choice (>=7.0,<8) for consistency. The all
extra inherits from all three, so it picks up qrcode transitively.

Adds parallel tests to tests/test_project_metadata.py — same shape
as test_messaging_extra_includes_qrcode_for_weixin_setup.

Refs NousResearch#9431.
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
)

Fills documentation gaps that accumulated as features merged ahead of their
docs updates. All additions are verified against code and the originating PRs.

Providers:
- Ollama Cloud (NousResearch#10782) — new provider section, env vars, quickstart/fallback rows
- xAI Grok Responses API + TTS (NousResearch#10783) — provider note, TTS table + config
- Google Gemini CLI OAuth (NousResearch#11270) — quickstart/fallback/cli-commands entries
- NVIDIA NIM (NousResearch#11774) — NVIDIA_API_KEY / NVIDIA_BASE_URL in env-vars reference
- HERMES_INFERENCE_PROVIDER enum updated

Messaging:
- DISCORD_ALLOWED_ROLES (NousResearch#11608) — env-vars, discord.md access control section
- DingTalk QR device-flow (NousResearch#11574) — wizard path in Option A + openClaw disclosure
- Feishu document comment intelligent reply (NousResearch#11898) — full section + 3-tier access control + CLI

Skills / commands:
- concept-diagrams skill (NousResearch#11363) — optional-skills-catalog entry
- /gquota (NousResearch#11270) — slash-commands reference

Build: docusaurus build passes, ascii-guard lint 0 errors.
Egavasyug pushed a commit to Egavasyug/hermes-agent that referenced this pull request Jun 10, 2026
…aging) (NousResearch#11627)

#367e9557 (anthhub) added qrcode to the messaging extra for Weixin's
QR login. The same package is needed by:

  * hermes_cli/dingtalk_auth.py — QR device-flow auth shipped in NousResearch#11574
  * gateway/platforms/feishu.py:3962 — Feishu QR login

These extras are independent of [messaging] (users can install
hermes-agent[dingtalk] or hermes-agent[feishu] without [messaging]),
so the dep needs to be declared on each.

Pin matches anthhub's choice (>=7.0,<8) for consistency. The all
extra inherits from all three, so it picks up qrcode transitively.

Adds parallel tests to tests/test_project_metadata.py — same shape
as test_messaging_extra_includes_qrcode_for_weixin_setup.

Refs NousResearch#9431.
Egavasyug pushed a commit to Egavasyug/hermes-agent that referenced this pull request Jun 10, 2026
)

Fills documentation gaps that accumulated as features merged ahead of their
docs updates. All additions are verified against code and the originating PRs.

Providers:
- Ollama Cloud (NousResearch#10782) — new provider section, env vars, quickstart/fallback rows
- xAI Grok Responses API + TTS (NousResearch#10783) — provider note, TTS table + config
- Google Gemini CLI OAuth (NousResearch#11270) — quickstart/fallback/cli-commands entries
- NVIDIA NIM (NousResearch#11774) — NVIDIA_API_KEY / NVIDIA_BASE_URL in env-vars reference
- HERMES_INFERENCE_PROVIDER enum updated

Messaging:
- DISCORD_ALLOWED_ROLES (NousResearch#11608) — env-vars, discord.md access control section
- DingTalk QR device-flow (NousResearch#11574) — wizard path in Option A + openClaw disclosure
- Feishu document comment intelligent reply (NousResearch#11898) — full section + 3-tier access control + CLI

Skills / commands:
- concept-diagrams skill (NousResearch#11363) — optional-skills-catalog entry
- /gquota (NousResearch#11270) — slash-commands reference

Build: docusaurus build passes, ascii-guard lint 0 errors.
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.

2 participants