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

@stars-w/dsh-shell-callback

v0.1.1

Published

命令执行回调桥:bash_cb 工具以回调方式返回命令结果,会话不再阻塞等待

Readme

@dsh-external/dsh-shell-callback

命令执行回调桥:bash_cb 工具以回调方式返回命令结果,DSH 会话不再阻塞等待命令执行。

License GitCode

要解决的问题

内置 bash 工具的前台路径会 await ctx.shell.run(...) 阻塞整个回合直到命令退出(或超时被杀);后台路径虽然立即返回 job id,但完成通知不带输出,模型还要再 job_output 轮询/按设定时间 wait。本插件把命令执行对接上 bash/shell 后台执行已有的结算回调机制ctx.jobs.onJobDone),会话不再"按设定时间傻等"。

安装

方式一:从 GitCode 安装(推荐)

git clone https://gitcode.com/wy_stars/dsh-shell-callback.git
bash dsh-shell-callback/scripts/build.sh   # junction 运行期依赖 + 语法门禁

然后在 dsh-super-injector 环境中注入:

  • dev_inject_plugin <dsh-shell-callback 目录> — 运行时注入,立即生效
  • dev_install_package <dsh-shell-callback 目录> — 固化到 profile(重启后仍生效)

方式二:dsh-super-injector 工具管线

dev_build_plugin <目录>      # 构建 + npm pack
dev_inject_plugin <目录>     # junction + loader.create
dev_reload_package dsh-shell-callback  # 热重载
dev_uninject_plugin dsh-shell-callback # 卸载

工作原理

  1. 模型调用 bash_cb:命令经 ctx.shell.start 注册为无主 background job,工具立即返回 job id,回合不阻塞。
  2. 命令结束时 jobs-local 结算 → onJobDone 回调把完整输出(stdout/stderr/退出码/超时标记)构造成会话消息:会话空闲则 agent.followup 直接唤醒,忙碌则 agent.inject 排队进下一步。
  3. job_output / job_kill / job_list 对返回的 job id 全部可用(无主 job 对 owner 会话开放访问);可选 timeout_ms 到点杀进程树,回调仍投递已收集的部分输出。

为什么是无主 job(关键设计)

agent 预设内的 tool-jobs 完成通知监听器对无主 job 直接 returnowner === void 0),因此本插件(注册在宿主组合 global 层)的回调是唯一通知者,不会出现双通知。global 层 attachController 使无主 job 的 start 通过 servesOwner 前置检查。

工具面

| 参数 | 说明 | | --- | --- | | command | 要执行的 bash 命令 | | description | 5–10 词的主动语态描述(显示在 UI) | | workdir | 可选;默认会话工作区,相对路径按会话 cwd 解析 | | timeout_ms | 可选;最长运行时间(毫秒),超时杀进程树并回调部分输出 |

构建

纯 ESM JS,无 TypeScript 编译步骤;构建门禁只做运行期依赖 junction + 语法校验:

bash scripts/build.sh          # junction @deepseek-ai/dsh-tools、dsh-llm + node --check

运行期依赖解析:lib/index.js@deepseek-ai/* 导入经本目录 node_modules 的 junction 指向 DSH 部署目录的已编译包(默认 /usr/local/lib/node_modules/@deepseek-ai/dsh/node_modules,可用 DSH_DEPLOY_MODULES 覆盖);其嵌套依赖由部署目录自身解析。

已验证行为

  • bash_cb 立即返回 job id,回合不阻塞;回调消息携带完整输出送达会话
  • timeout_ms 准点杀进程树,回调投递部分输出 + 超时标记
  • job_kill 取消后结算为 killed,无重复回调
  • 热重载/卸载时所有注册经 ctx.effect 自动清理(工具无重名冲突)

已知取舍

  • 无唤醒预算(tool-jobs 有 3 次上限):每次回调都携带完整结果、job 只结算一次,通知风暴自限;若模型连续起 N 个 job 后空闲,会收到 N 次各携结果的唤醒,这是预期行为。
  • 若模型在 job 运行中多次 job_output,结算回调只携带增量(与 job_output 的单游标语义一致)。
  • 卸载插件时运行中的 job 不受影响(jobs 注册表与 shell 执行器独立存活),但结算回调消失——残留 job 仍可 job_output/job_kill,或随会话/服务回收。

License

BSD-3-Clause