npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@zhin.js/adapter-dingtalk

v6.0.3

Published

Zhin.js DingTalk (钉钉) adapter for Plugin Runtime (HTTP webhook)

Downloads

2,239

Readme

@zhin.js/adapter-dingtalk

Zhin.js 钉钉适配器(Plugin Runtime),通过 Runtime Host HTTP Webhook 收发消息。

功能

  • Webhook 事件接收(httpHostToken POST + HMAC-SHA256 签名验证)
  • Access Token 自动刷新
  • Session Webhook 优先回复 / /robot/send 主动发送
  • 约定式 defineAdapter / definePlugin(无需 usePlugin

安装

pnpm add @zhin.js/adapter-dingtalk

Plugin Runtime

  • @zhin.js/adapter — 约定式薄入口 adapters/dingtalk.tsdefineAdapter
  • 实现:src/endpoint.ts(生命周期/出站/OpenAPI)、src/webhook.ts(验签入站)、src/protocol.ts
  • @zhin.js/coremessageGatewayToken 入站/出站
  • @zhin.js/host-httphttpHostToken 注册 Webhook 路由( legacy host-router/Koa)
  • @zhin.js/plugin-runtimeplugin.tsdefinePlugin
  • 配置经插件 schema.json 落到 plugins.<instanceKey>

入站:gateway.receive({ conversation: ConversationRef, message: { conversation, id }, content: text, sender, metadata })
出站:send({ conversation, payload }) → sessionWebhook 或 /robot/send

前置条件

  1. 钉钉开放平台 创建企业内部应用 / 机器人
  2. 获取 AppKeyAppSecret(可选 RobotCode)
  3. 设置消息接收 URL 为 https://your-domain/dingtalk/webhook
  4. Runtime Host(http)须已 listen,Webhook 才可达

必填字段(endpoints[i]):nameappKeyappSecretwebhookPathrobotCode

最小配置

# zhin.config.yml(Plugin Runtime)
plugins:
  dingtalk:
    apiBaseUrl: https://oapi.dingtalk.com # 可选,顶层共享
    endpoints:
      - name: my-dingtalk-bot
        appKey: ${DINGTALK_APP_KEY}
        appSecret: ${DINGTALK_APP_SECRET}
        robotCode: ${DINGTALK_ROBOT_CODE}
        webhookPath: /dingtalk/webhook   # 可选,默认 /dingtalk/webhook

根插件 zhin.plugins(或项目图)需引用 @zhin.js/adapter-dingtalkinstanceKey: dingtalk)。

环境变量

| 变量 | 说明 | |------|------| | DINGTALK_APP_KEY | 应用 AppKey | | DINGTALK_APP_SECRET | 应用 AppSecret | | DINGTALK_ROBOT_CODE | RobotCode(主动发送 /robot/send) |

消息类型映射

| 钉钉类型 | 入站 content(文本摘要) | 出站 wire | |----------|--------------------------|-----------| | text | 原文 | text | | picture | [image] | picture(需 url) | | file | [file: name] | — | | audio / video | [audio] / [video] | — | | markdown | 原文或 [markdown] | markdown | | link | — | link |

Agent 工具

agent/ 目录保留(get_user、部门、群聊、工作通知等)。Endpoint 在 start 时自注册到 dingtalk-agent-deps

平台权限(platform permit)

plugin.ts 在 generation setup 注册 src/platform-permit.ts checker,并在 dispose 注销;CapabilityIngress 与 ToolSystem 统一经 Core canAccessTool() 消费工具权限。

测试

pnpm --filter @zhin.js/adapter-dingtalk build
pnpm --filter @zhin.js/adapter-dingtalk test