feat: add Z.ai provider, lightweight web panel, and Discord channel - #15
Open
zarigata wants to merge 6 commits into
Open
feat: add Z.ai provider, lightweight web panel, and Discord channel#15zarigata wants to merge 6 commits into
zarigata wants to merge 6 commits into
Conversation
added 5 commits
April 26, 2026 00:12
- Add 'zai' to ProviderName union and MercuryConfig - Z.ai uses OpenAICompatProvider (OpenAI-compatible API) - Coding Plan endpoint opt-in via ZAI_CODING_PLAN_ENABLED - Defaults to general endpoint https://api.z.ai/api/paas/v4 - Add GLM preferred model list for model catalog - Add 'web-panel' to ChannelType union
- Node.js built-in http server, zero external dependencies - Default disabled, localhost-only (127.0.0.1:3977) - Optional auth token for remote access - Refuses to bind 0.0.0.0 without auth unless WEB_PANEL_ALLOW_REMOTE=true - Rate limiting (60 req/min per IP), 1MB request size limit - Status dashboard, chat interface, command support - No secrets exposed in any response
- Slash commands via discord.js with minimal Gateway intents - Commands: /mercury ask, status, help, budget, memory, permissions - Allowlist-based access control (user IDs, channel IDs, admin IDs) - DMs disabled by default for security - Deferred responses for long-running tasks - Response splitting for Discord's 2000 char limit - Graceful startup if config is missing or incomplete
- Add Z.ai (GLM) row to README provider table - Add Web Panel and Discord rows to README channels table - Add web panel and Discord status to 'mercury status' command - Add Z.ai setup flow to configure/doctor wizard - Add Z.ai API key validation - Create docs/providers/zai.md with Coding Plan compliance notice - Create docs/channels/web-panel.md with security model docs - Create docs/channels/discord.md with bot setup guide - Update .env.example with all new config vars - Update CHANGELOG.md with Unreleased section
- Z.ai config: provider selection, base URL switching, missing key - Z.ai Coding Plan endpoint toggle - Z.ai no secret leakage in baseUrl - Web Panel: defaults, localhost, auth token, no secrets in status - Discord: allowlist checks, admin-only fallback, message splitting - Web Panel: refuses 0.0.0.0 without auth - All 48 tests pass (20 existing + 28 new)
hotheadhacker
requested review from
hotheadhacker and
shehzensidiq
and removed request for
hotheadhacker
April 26, 2026 09:07
… errors discord.js was missing from package.json causing CI failures: - TS2307: Cannot find module 'discord.js' - TS7006: implicit 'any' on SlashCommandBuilder callbacks Added discord.js ^14.18.0 to optionalDependencies (like better-sqlite3) and annotated callback parameters with explicit types.
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.
Summary
This PR adds three new features to Mercury Agent:
node:httpWhat changed
Z.ai Provider (
feat(providers))zaitoProviderNameunion andMercuryConfig.providersOpenAICompatProvider(OpenAI-compatible, no new deps)https://api.z.ai/api/paas/v4)ZAI_CODING_PLAN_ENABLED=truemercury doctorWeb Panel (
feat(web))src/channels/web-panel.ts— HTTP server usingnode:http, zero external depsWEB_PANEL_ENABLED=false)127.0.0.1:3977)0.0.0.0without auth token unlessWEB_PANEL_ALLOW_REMOTE=trueDiscord (
feat(discord))src/channels/discord.ts— Slash command bot viadiscord.js(minimal intents: Guilds only)/mercury ask,status,help,budget,memory,permissionsDISCORD_ALLOWED_USER_IDS,DISCORD_ADMIN_USER_IDSDISCORD_ALLOWED_CHANNEL_IDSDocumentation (
docs)docs/providers/zai.md— Setup, models, Coding Plan compliance noticedocs/channels/web-panel.md— Setup, security model, API endpointsdocs/channels/discord.md— Bot creation, slash commands, access control.env.exampleupdated with all new config varsCHANGELOG.mdupdated with[Unreleased]sectionTests (
test)0.0.0.0without authWhy
How to test
Security considerations
Z.ai Coding Plan compliance note
Files changed
src/utils/config.tszaiprovider,webPanelanddiscordchannel configsrc/providers/registry.tssrc/utils/provider-models.tssrc/types/channel.ts'web-panel'to ChannelTypesrc/channels/web-panel.tssrc/channels/discord.tssrc/channels/registry.tssrc/channels/index.tssrc/index.tstsup.config.tsdiscord.jsto externals.env.exampleREADME.mdCHANGELOG.mddocs/providers/zai.mddocs/channels/web-panel.mddocs/channels/discord.mdsrc/utils/new-features.test.tssrc/channels/new-channels.test.tsTest results
Known limitations
/modelsendpoint availabilitydiscord.jsis the only new dependency (justified: Mercury's channel model requires persistent Gateway connection)Checklist
.env.exampleupdated