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

@xfcodeai/dsh-agent-tool-presentation

v0.1.5-rc.5

Published

Agent-plane presentation selector: composes one agent's tools as PTC mode, native, or both

Downloads

235

Readme


description: "面向用户与维护者的 agent(智能体)平面呈现选择器说明,用于选择、配置或调试 agent preset 的模型看到其工具的哪种形态。" kind: "package-reference"

@xfcodeai/dsh-agent-tool-presentation

English | 中文

概述

在 agent preset 中使用 dsh-agent-tool-presentation,可固定模型看到全部原生工具 schema、只有带生成 SDK 的 run_code,还是同时看到两种形态。每个 preset 可独立选择,因此 native 与 PTC agent 可以共享同一进程,而不共享工具目录。选择 ptc 或 both 需要兼容的代码运行时;没有该运行时的部署会在挂载时拒绝 preset,不会等到收到第一条提示词。使用本包时 mode 字段为必填;省略本包则沿用部署默认值。

目录


使用本包

把这一行加入 agent preset,以固定每个加入该 preset 的 agent 看到其工具的方式。native 以函数定义的形式呈现每个可见工具 schema;ptc 只呈现 run_code 传输、一份生成的 SDK 以及「只有 run_code 可被直接调用」这条规则;both 同时呈现两种形态。未作声明的 agent 会拿到 dsh-tools 那一行上的部署级 mode。

把这一行加入 preset

- name: '@xfcodeai/dsh-agent-tool-presentation'
  config:
    mode: ptc

| 字段 | 默认值 | 含义 | |---|---|---| | mode | 必填 | native——每个 schema;ptc——run_code 加生成 SDK;both——两种形态 |

生成的配置目录是每个受支持字段的穷尽式真源。mode 是必填而非有默认值,因为不带这一行的 preset 会继承部署默认值。

PTC 模式需要什么

选择 ptc 或 both 需要已组合的代码运行时(ctx.codeRuntime),且其语言有已注册的 SDK 渲染器——TypeScript 运行时经 dsh-code-runtime-worker-thread 交付,TypeScript 与 Python 的 SDK 渲染器都内置在 dsh-tools 中。针对未组装此类运行时的部署选择 PTC 模式的 preset 会拒绝挂载并点名这一行,使失败落在操作者可以行动的地方,而不是落在会话的第一次请求上。

每个 agent 只声明一次呈现方式

一个 agent 只声明一次呈现方式。同一份组装里的第二次声明会被拒绝而不是合并:对「模型看到哪种形态」给出两个答案是矛盾,不是覆盖。


理解实现

本节解释该包如何实现上述行为;可观察约定已在使用本包中完整说明。

设计理念

工具注册表搬不进 preset:它的消费方全在宿主平面——agent loop(智能体循环)读它的调度器,API proxy 读它的展示转换器,每个工具插件都往里注册——而一个服务只有在所有消费方一起下沉时才能下沉。preset 能拥有的是这份注册表的呈现方式。ctx.tools.presentAs() 为挂载作用域声明它,而挂载作用域就是 preset 的常驻挂载,因此该声明覆盖每个加入该 preset 的 agent,一个 PTC mode preset 可以与多个 native preset 同进程并存。每个组合一行,而不是每个会话一行。

源码地图

| 文件 | 职责 | |---|---| | src/index.ts | 插件入口:mode 配置、把 ctx.tools.presentAs 接到挂载作用域的 apply | | — | 不发布运行时不变式伴生入口;本包只对 ctx.tools 发起一次 scoped 调用,不持有自己的事件或快照;它建立的是「某个 agent 的组装采用哪种呈现方式」这一关系,该关系由工具注册表持有,dsh-tools 会在工具注册表中观察该关系。 |

行为说明

native 立即生效。PTC 模式则等待 ctx.codeRuntime——这是一个宿主平面服务:针对未组装运行时的部署选择 PTC mode 的 preset 会让这一行停在 pending,dsh-agent-presets 会指名此 id 拒绝挂载。presentAs 本身就是 effect,因此该声明随这一行撤销,无需第二个包装层拥有它。


进一步探索

包级约定对大多数消费方已经足够;需要周边领域时再阅读以下页面。


模型体验

通过在 dsh-tools 中选择的工具呈现方式间接影响——这一行只在 dsh-tools 拥有的两种投影之间选择,本身不注册任何提示词、schema 或结果。

KV Cache 影响

没有直接的失效影响;呈现方式在 agent 组装时即固定,因此其请求前缀在该会话的整个生命周期内保持稳定。

已知限制与延期工作

这些限制说明这一行何时需要特别留意。它们是当前包约束,不是任务积压。

  • 运行时仍在宿主平面——preset 可以选择 PTC mode,却无法自带它所需的 TypeScript 运行时;未组装运行时的部署也就无法组装任何 PTC 模式的 preset。

开发备注

无。