Hosts

Pi

registerPiTools puts every tool on Pi with its prompt snippet and guidelines. And throws on failure because older Pi only listens to throws
IDpi02 / 04@earendil-works/pi-coding-agent
Host / Pi

Pi extension

Pi's registerTool with the prompt snippet and guidelines filled in.

label
Text Slug
prompt
snippet, 1 rule
parameters
text, separator
failure
thrown

Access

Importimport { registerPiTools } from "@agntn/tools/pi"
Peer@earendil-works/pi-coding-agent >=0.84.2 <1
Failsthrown
tspackages/pi/extensions/mypackage.ts
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
import { registerPiTools } from "@agntn/tools/pi";
import { tools } from "../../../src/tools.ts";

export default function (pi: ExtensionAPI) {
  registerPiTools(pi, tools);
}

Pi gets name, label from title, the description, promptSnippet and promptGuidelines when you set them, and the schema as parameters. Same JSON Schema every other host gets. Pi's own validator checks it, then the core checks it again, because a second check costs nothing and a missing one costs an afternoon.

Failures

Up to 0.98, Pi reads a returned object as a success no matter what's in it. A tool that returns isError: true would look fine to the model. So by default the adapter throws the result's text when isError is set, and Pi records an error.

On Pi 0.99 or newer you can keep the result as it is:

ts
registerPiTools(pi, tools, { failures: "return" });

That keeps details on a failure too. Only do it with a peer range of >=0.99.0, since Pi doesn't check peer ranges when it installs a package.

Renderers

Pass Pi's own renderCall and renderResult per tool through renderers. They reach Pi unchanged:

ts
registerPiTools(pi, tools, {
  renderers: { books_text: { renderResult: preview } },
});

Handy when a tool returns a lot of text and you want the collapsed row to stay short.