omp packages

pi-command-timeout0.1.1

Pi extension that gives bash/powershell tool calls a default timeout, so a hung command can never stall a session.

GitHub Actions Published 7 days ago MIT ~474 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

pi-command-timeout

给 pi 的 bash / powershell 工具调用兜底一个默认超时。

pi 的内置 bash 工具默认没有超时:模型不传 timeout 时,一条卡住的命令(等输入、连不上网、读 fifo……) 会把整轮对话无限期挂住。这个扩展在 tool_call 阶段检查参数,缺省就补上默认值。

安装

pi install npm:pi-command-timeout

或临时试用(不写入 settings):

pi -e npm:pi-command-timeout

安装后重启 pi 或 /reload 生效。

行为

模型传的 timeout 实际执行
未传 / null / 0 / 负数 用默认值(默认 120 秒)
正数 原样使用,不覆盖

只作用于 bash 与 powershell 两个内置工具,其他工具不受影响。

配置

环境变量 作用
PI_COMMAND_TIMEOUT_SEC=300 改默认超时(秒),必须是正数
PI_COMMAND_TIMEOUT=off 关闭本扩展(恢复 pi 的“无默认超时”),也接受 0 / false / disabled
PI_COMMAND_TIMEOUT_SEC=600 pi   # 这一轮默认 10 分钟

超时发生后 pi 会返回 Command timed out after N seconds,模型能看到并按需重试或拆分命令。

注意

  • 默认值不设上限,但不要用它替代合理的命令拆分:单条命令跑几十分钟仍然应该显式传 timeout。
  • 长时间构建/测试请自己显式传 timeout,或临时把 PI_COMMAND_TIMEOUT_SEC 调大。

开发

git clone https://github.com/suveng/pi-command-timeout.git
cd pi-command-timeout
pi -e ./            # 以本地包方式加载

源码只有 extensions/command-timeout.ts 一个文件,pi 直接加载 TypeScript,无需编译。

发布

OIDC 可信发布(无长期 token):推一个 v* tag,GitHub Actions 用 OIDC 取短期凭证 npm publish --provenance。

npm version patch --no-git-tag-version
git commit -am "release: v0.1.1"
git tag v0.1.1 && git push --follow-tags

首次发布例外:npm 不允许给还不存在的包预配置 trusted publisher,所以首版必须手工 npm publish --access public,之后用 npm trust github pi-command-timeout --file publish.yml --repository suveng/pi-command-timeout --allow-publish 绑定。

License

MIT