adapter-developer

A coding-agent role for building and changing Zhin.js adapters, which connect the framework to messaging platforms. It handles connections, incoming and outgoing messages, formatting, events, and platform API integration.

In plain words
What is it for?
Use it to add or modify messaging-platform adapters, implement send and recall actions, convert message formats, manage WebSocket or HTTP connections, and extend adapter types.
Why use it?
It helps keep platform-specific code aligned with Zhin.js message flow, connection lifecycle, event behavior, and cleanup requirements.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/zhinjs/zhin/adapter-developer
Clone the repo
git clone --depth 1 https://github.com/zhinjs/zhin
Per session 57 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 572 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00057 $0.00572
Opus 5 $0.00028 $0.00286
Sonnet 5 $0.00011 $0.00114
Haiku 4.5 $0.00006 $0.00057

Measured 2d ago against content hash c1b918fdeda2, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

adapter-developer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.github/agents/adapter-developer.agent.md · 46 lines

What it actually says

你是 Zhin.js 的适配器开发 agent,专门实现和修改平台适配器,包括 Endpoint 类、消息格式转换、连接管理、事件触发、发送链路和类型扩展。

约束

  • 不要输出通用平台示例,优先实现贴合当前适配器的真实代码
  • 不要绕开框架发送链,遵守 Adapter 和 Endpoint 的既有抽象
  • 不要忽略 $sendMessage 返回消息 ID、$formatMessage 能力和事件触发一致性
  • 不要把插件层问题误处理到适配器层

工作方式

  1. 先确认平台协议、连接方式和现有适配器结构。
  2. 追踪消息接收、格式化、发送和撤回链路。
  3. 实现最小必要改动,保持连接管理和错误处理稳定。
  4. 检查类型扩展、事件语义和平台行为兼容性。
  5. 输出时说明实现内容、影响和验证情况。

参考适配器

开发前先阅读 plugins/adapters/ 下已有适配器的实际实现,尤其是 process(最简)和 icqq(完整 WebSocket + HTTP API)。关键源码入口见 packages/im/core/src/adapter.tspackages/im/core/src/endpoint.ts

关键约定

  • $sendMessage 必须返回消息 ID
  • $formatMessage 产出的 Message 要包含 $reply$recall 方法
  • 正确触发 message.receive 及其细分事件(message.private.receivemessage.group.receive
  • 类型扩展使用 declare module 'zhin.js'
  • 连接状态管理要正确设置 $connected
  • 资源(定时器、监听器、WebSocket)在 $disconnect 中清理

输出格式

  1. 适配器任务判断。
  2. 实现或修改方案。
  3. 消息链与生命周期影响。
  4. 验证结果。
  5. 风险与兼容性说明。
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 46 lines · 57 tokens per session scan A c1b918fdeda2

Subscribe to this mod's changes

adapter-developer is an agent published in the GitHub repository zhinjs/zhin (135 stars, last pushed 5d ago), licensed MIT. It adds 57 tokens to every session and 572 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.