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

@unieai/uad-user-questions

v0.1.8

Published

Abstract user-questions seam (ctx.userQuestions) for asking the human during agent runs

Readme

@unieai/uad-user-questions

English | 中文

用户交互 Service Definition。它定义 ctx.userQuestions,供面向模型的工具或权限插件在需要暂停工作并询问人类决定时使用。

服务:UserQuestionService(ctx 键:userQuestions

公开 API

  • ctx.userQuestions.registerProvider(provider): () => void 注册 UI 侧提供方。同一上下文中只能有一个活跃提供方;dispose(资源释放)会将其注销。
  • ctx.userQuestions.ask(request): Promise<AskUserQuestionAnswer> 向活跃提供方提问并等待回答。

关键类型

  • AskUserQuestionRequest{ questions: [{ id, question, detail?, header?, options?, multiSelect?, intent? }], agent?, signal? }detail 提供辅助文本,提供方会将其随问题一起渲染,而不会将其变成选项标签。如提供 agent,它必须与注册表中的存活运行时根 agent(智能体)是同一对象。
  • AskUserQuestionOption{ label, description? }
  • AskUserQuestionIntent{ kind: 'plan-review', approve };即下文的带标签呈现意图。
  • AskUserQuestionAnswer{ answers: [{ id, selected, custom? }] }
  • UserQuestionProvider:包含 ask(request) 的 UI 实现。
  • UserQuestionErrorHarnessError 的子类,包含 EMPTY_QUESTIONSBAD_INTENTNO_PROVIDERDUPLICATE_PROVIDERASK_ABORTEDCALLER_NOT_LIVEDELEGATED_CALLER 等代码。

对于单选题,custom 会覆盖选中的选项,且 selected 为空。对于多选题,custom 可以补充 selected 中的标签。UI 可以把跳过的条目保留为 { id, selected: [] },既维持现有回答形态,也保留该批次中的其他回答。

请求包含 agent 时,ask() 会通过当前 AgentRegistry 验证该 agent 与注册表中的存活实例是同一对象,并且只允许运行时根调用。持久谱系不构成权限依据:带有历史委托深度的会话恢复为新的运行时根后可以提问;归属于另一个 agent 的存活子级即使持久化记录的委托深度为零也会被拒绝。不含 agent 的程序化请求继续沿用现有提供方路径。

呈现意图

intent 声明某个问题本身就是一种已知决策,因此认识该标签的 UI 可以照此呈现——plan-review 表示 detail 是一份待审阅的计划,dsh-plan-mode 会在 exit_plan_mode 的问题上设置它。意图只改变呈现:遵循它的 UI 回答的仍是通用 UI 会发送的那些选项标签,不认识该标签的 UI 渲染通用选项列表,因此调用方两种情况下读到的回答字段相同。approve 指名表示批准的标签,而不依赖选项顺序。有两项断言无法通过类型表达,ask() 会以 BAD_INTENT 拒绝它们:approve 未命中该问题自身的任一选项,以及意图落在没有 detail 的问题上——而 detail 正是它自称在审阅的东西。

职责

这是 Service Definition 包。@unieai/uad-tool-ask-user 等 Consumer 依赖此服务;Web 宿主运行时提供随产品交付的 Service Provider。循环保持不变:工具调用等待 Promise,工具结果随后恢复正常的 agent loop(智能体循环)。

模型体验

间接地,通过 dsh-tool-ask-user:它会将成功的提供方回答保留为紧凑 JSON,或返回以下失败之一:Error: ask_user_question was aborted before the user answeredError: ask_user_question requires at least one questionError: human interaction requires the exact live calling agent when an agent is suppliedError: human interaction is unavailable while the calling agent is owned by another live agent; include the unresolved question or decision in the child agent's final resultError: no user-questions provider is registeredError: <message>。等待人类回答不会增加 token。

KV Cache 影响

不会直接使 KV Cache 失效;请求前缀的任何变更均由上述消费方负责。

已知限制与暂缓事项

  • 每个上下文只能有一个提供方:不支持路由或扇出到多个 UI;第二次注册会抛出 DUPLICATE_PROVIDER,未注册任何提供方时,ask() 会抛出 NO_PROVIDER,而不会降级。
  • 词汇仅包含问题表单形态:可供选择的选项加可选的自定义文本;更丰富的交互形态(文件选择器、diff 预览确认)尚无 seam 词汇。