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

@dingpenghui/agnes-image

v1.8.0

Published

DSH plugin for Agnes AI text-to-image generation

Downloads

1,211

Readme

@dingpenghui/agnes-image

DSH 插件:Agnes AI 文生图,注册 generate_image 工具。

能力

  • 调用 POST /v1/images/generations(默认模型 agnes-image-2.5-flash)
  • 结果持久化为 DSH 附件,并在对话中内联渲染图片
  • 支持 1K/2K/3K/4K 分辨率档位与 8 种宽高比
  • 声明了 presentCall / presentResult 卡片投影

配置

- id: tool-agnes-image
  name: '@dingpenghui/agnes-image'
  config:
    model: agnes-image-2.5-flash   # 或 agnes-image-2.1-flash / agnes-image-2.0-flash
    defaultSize: 1K                # 1K | 2K | 3K | 4K
    defaultRatio: 1:1              # 1:1 | 16:9 | 9:16 | 4:3 | 3:4 | 3:2 | 2:3 | 21:9
    persistAttachment: true        # 持久化到附件存储并内联渲染
    ferryContext: true             # PTC 子派发时把图片渡回外层结果
    timeoutMs: 240000              # 单次请求预算
    apiKeyEnv: ''                  # 留空则自动跟随 DSH 配置的 Agnes key
    rateLimitRequestsPerWindow: 6  # 每窗口请求上限(免费档 6);0 关闭主动限速
    rateLimitWindowMs: 60000       # 限速窗口长度
    rateLimitMaxRetries: 4         # 遇 429 的重试次数
    rateLimitBaseDelayMs: 3000     # 首次退避基准(指数增长)

429 自动退避

免费档为每 key 每 60 秒 6 次。插件分两层处理:

  1. 主动限速(滑动窗口):按 key 记录请求时间戳,超出配额时先排队等待,从源头避免撞限流。
  2. 被动退避:万一仍返回 429,按指数退避重试并优先遵循 Retry-After;退避不低于网关 60 秒窗口,否则会在同一窗口内徒劳重试。

若把 rateLimitWindowMs 设得比网关窗口短,主动限速会提前放行而由网关拒绝;此时退避仍会等满 60 秒窗口,但会拖慢响应。建议保持默认 60000。

凭据解析顺序(优先跟随 DSH 已配置的 Agnes key):

  1. 插件配置 apiKeyEnv(显式指定,最高优先级)
  2. DSH llm-pi-ai 设置段中 Agnes provider 声明的 apiKeyEnv(如 AGNESCOM_API_KEY / AGNESCN_API_KEY),按声明顺序
  3. 兼容回退:AGNES_AI_API_KEY → AGNES_API_KEY

引用名在 $DSH_HOME/.credentials.yaml 的 refs 下或同名环境变量中解析,每次调用热解析,轮换 key 无需重启。

工具参数

| 参数 | 类型 | 必填 | 默认 | |------|------|------|------| | prompt | string | ✅ | - | | size | string | ❌ | 配置值(1K) | | ratio | string | ❌ | 配置值(1:1) |

开发

pnpm install
pnpm build                              # -> lib/
npx tsc -p tsconfig.json --noEmit

协议实现位于上层的 _core/,构建时内联进 lib/。

注意

Agnes 的文本图像队列拒绝 stream、format、images,且 n 必须为 1 (HTTP 400 ... is not supported by text image queue / n must be 1)。 本插件只发送 model / prompt / size / ratio,请不要重新加回这些字段。 也正因如此,图生图/图像编辑在本网关不可用。

完整说明见 上级 README;优化记录见 OPTIMIZATION.md。

MIT