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

pi-dsml

v0.0.1

Published

Pi package: recovers DeepSeek DSML tool calls that arrive as plain assistant text and executes them as real tool calls.

Readme

pi-dsml

A pi package that executes DeepSeek DSML tool calls which arrive as plain assistant text.

The problem

Some gateways serve DeepSeek models without native tool calling. The model falls back to its own DSML grammar and writes the call into the response body:

I'll check the project setup first.

<||DSML|| calls>
<||DSML|| invoke name="bash">
<||DSML|| parameter name="command" string="true">ls -la</||DSML|| parameter>
</||DSML|| invoke>
</||DSML|| calls>

Pi receives a message with text blocks and no toolCall blocks, so it runs nothing — while the model carries on as if the tool had answered. The turn derails from there.

pi-dsml parses that text back into real tool calls at message_end, which is early enough that pi's agent loop still executes them.

Install

pi install npm:pi-dsml

Or, for local development:

pi -e /path/to/pi-dsml/extensions/index.ts

Grammar coverage

Both the documented form and the mangled form real gateways emit:

| | Block | Invoke | Parameter | |---|---|---|---| | Canonical | <|DSML|tool_calls> | <|DSML|invoke name="x"> | <|DSML|parameter name="k" string="true"> | | Mangled | <||DSML|| calls> | <||DSML|| invoke name="x"> | <||DSML|| parameter name="k" string="true"> |

The mangled form comes from re-decoding the special tokens: bars double up, a space appears where tool_ should be, and the block tag is left as a bare calls. <|end▁of▁sentence|> is stripped too.

Per the spec, string="true" means a raw string and string="false" means a JSON value (number, boolean, array, object).

Behaviour

  • Unknown tool names are recovered as-is. Models sometimes invent names (read_file, explore, Bash). Pi answers those with its own Tool X not found result, which the model reads and corrects on the next turn — a better feedback loop than silently dropping the call.
  • Messages that already have native tool calls only get the leaked text cleaned up; the parsed copies are discarded so nothing runs twice.
  • Fenced code is never touched, so documenting the grammar cannot trigger an execution.
  • Truncated blocks still yield whatever complete calls arrived before the cut.
  • Thinking blocks are cleaned the same way as text.
  • While streaming, a markdown transformer hides DSML spans behind ⟨tool call⟩, so the terminal does not fill with raw markers.

Text with no DSML in it short-circuits immediately, so models with working native tool calls pay nothing.

Configuration

Everything has a default; the file is optional. Create ~/.pi/agent/extensions/pi-dsml.json:

{
  "enabled": true,
  "models": ["deepseek"],
  "hideWhileStreaming": true,
  "debug": false
}

| Key | Default | Meaning | |---|---|---| | enabled | true | Turn the extension off without uninstalling it. | | models | (unset) | Case-insensitive regex fragments. When set, only matching model ids are touched; unset means every model. | | hideWhileStreaming | true | Register the display-only markdown transformer. | | debug | false | Log [pi-dsml] recovered=… stripped=… to stderr. PI_DSML_DEBUG=1 does the same. |

Development

npm install
npm run check   # tsc --noEmit + vitest

test/replay.test.ts replays the real leaked messages found in ~/.pi/agent/sessions, and skips itself when that history is not present.

License

MIT