← Catalog

@muzi3/next-step-waiting

Pi extension: wait_for_condition tool — pause and wait for an external action to complete or ask the user whether to continue, with pluggable detectors (shell command polling or sub-agent judgment).

Extension

Install

Install with PiG

pig install npm:@muzi3/next-step-waiting

Install with Pi

pi install npm:@muzi3/next-step-waiting
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./extensions"
  ]
}

README

Written by the package's publisher, shown as published in version 0.1.5 (README.md). PiG does not review it.

@muzi3/next-step-waiting

Pi 扩展:wait_for_condition 工具 —— 让 AI 暂停并等待外部动作完成,或向用户确认「是否继续」,检测器可插拔。

安装

pi install npm:@muzi3/next-step-waiting

工具用法

agent 在需要等待外部动作(登录、手动配置、部署、CI、线下联调、用户操作),或想询问用户「要继续吗」时调用 wait_for_condition,它会弹出等待面板并启动检测器,直到:

  1. 检测器判定完成(detected)
  2. 用户按回车手动继续(manual;等待期间回车优先给面板,编辑器里有草稿也一样)
  3. 用户按 Esc 取消(cancelled),或总超时(timeout)

面板是非抢占式 overlay:等待期间不抢键盘焦点,正文照常滚动/滚轮/选中,官方内置的 ↓ Jump to latest message · End 也可用。

参数

参数类型必填说明
instructionstring是告诉用户要完成什么外部操作,显示在等待面板
checkstring否shell 检测命令,exit 0 = 完成(适合查文件/进程/日志/接口)
checkPromptstring否需要智能判断时的检测任务描述(交给子 agent)
intervalMsnumber否检测间隔。命令默认 3000,子 agent 默认 30000
timeoutMsnumber否总超时。0 = 不限时(默认)

检测器(可插拔)

  • check:周期执行 shell 命令,exit 0 判定完成。单次超时 max(2×间隔, 60s),上限 15min。
  • checkPrompt:spawn 独立 pi --mode json 子进程,用它的工具查证并智能判断(YES/NO)。单次超时 max(2×间隔, 5min),上限 15min。

纯确认模式

check 与 checkPrompt 都不提供时,进入纯确认模式:无检测器,仅等待用户按回车继续或 Esc 取消。 适合 AI 想询问用户「要继续吗」的场景——instruction 写清楚要确认的问题即可。

在 herdr 里标成 blocked

面板建起来时往 pi 的事件总线发 next-step-waiting:blocked(payload { active, toolCallId }),关面板时在 finally 里发 active: false。装了 @muzi3/hc 的 herdr-agent-state,pane 就会标红「在等人」——等外部操作和纯确认都算。

为什么不直接写 OSC 7501、也不靠 ui_prompt_start:状态上报只留 herdr-agent-state 一个出口,两处都写会互相覆盖;面板是 nonCapturing overlay,而常驻 overlay(如 prompt-nav)会把 pi 的等待区间占住,ui_prompt_start 根本不发。

返回 status

  • detected / manual / cancelled / timeout