diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 7136b79bd03..193de7f5c23 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -2,6 +2,14 @@ ## [Unreleased] +### Added + +- Exported `convertToPng` for extension authors. + +### Changed + +- Changed `pi.getAllTools()` to return full readonly tool definitions with source metadata. + ## [0.76.0] - 2026-05-27 ### New Features diff --git a/packages/coding-agent/docs/extensions.md b/packages/coding-agent/docs/extensions.md index ce922f2aeaf..40f54cd6f6f 100644 --- a/packages/coding-agent/docs/extensions.md +++ b/packages/coding-agent/docs/extensions.md @@ -139,7 +139,7 @@ To share extensions via npm or git as pi packages, see [packages.md](packages.md | Package | Purpose | |---------|---------| -| `@earendil-works/pi-coding-agent` | Extension types (`ExtensionAPI`, `ExtensionContext`, events) | +| `@earendil-works/pi-coding-agent` | Extension types (`ExtensionAPI`, `ExtensionContext`, events) and utilities (`convertToPng`, `resizeImage`) | | `typebox` | Schema definitions for tool parameters | | `@earendil-works/pi-ai` | AI utilities (`StringEnum` for Google-compatible enums) | | `@earendil-works/pi-tui` | TUI components for custom rendering | @@ -1489,8 +1489,12 @@ const active = pi.getActiveTools(); const all = pi.getAllTools(); // [{ // name: "read", +// label: "Read", // description: "Read file contents...", -// parameters: ..., +// parameters: ..., +// execute: async (...), +// renderCall: (...), +// renderResult: (...), // sourceInfo: { path: "", source: "builtin", scope: "temporary", origin: "top-level" } // }, ...] const names = all.map(t => t.name); @@ -1499,7 +1503,7 @@ const extensionTools = all.filter((t) => t.sourceInfo.source !== "builtin" && t. pi.setActiveTools(["read", "bash"]); // Switch to read-only ``` -`pi.getAllTools()` returns `name`, `description`, `parameters`, and `sourceInfo`. +`pi.getAllTools()` returns full tool definitions with `sourceInfo`. Tool items are readonly as a type-level hint; nested schemas are not frozen. Typical `sourceInfo.source` values: - `builtin` for built-in tools diff --git a/packages/coding-agent/src/core/agent-session.ts b/packages/coding-agent/src/core/agent-session.ts index d2835b7b088..15f6a6fb47f 100644 --- a/packages/coding-agent/src/core/agent-session.ts +++ b/packages/coding-agent/src/core/agent-session.ts @@ -759,13 +759,11 @@ export class AgentSession { } /** - * Get all configured tools with name, description, parameter schema, and source metadata. + * Get all configured tools with readonly definitions and source metadata. */ getAllTools(): ToolInfo[] { return Array.from(this._toolDefinitions.values()).map(({ definition, sourceInfo }) => ({ - name: definition.name, - description: definition.description, - parameters: definition.parameters, + ...definition, sourceInfo, })); } diff --git a/packages/coding-agent/src/core/extensions/types.ts b/packages/coding-agent/src/core/extensions/types.ts index 58b85227378..865e9660411 100644 --- a/packages/coding-agent/src/core/extensions/types.ts +++ b/packages/coding-agent/src/core/extensions/types.ts @@ -1211,7 +1211,7 @@ export interface ExtensionAPI { /** Get the list of currently active tool names. */ getActiveTools(): string[]; - /** Get all configured tools with parameter schema and source metadata. */ + /** Get all configured tools with readonly definitions and source metadata. */ getAllTools(): ToolInfo[]; /** Set the active tools by name. */ @@ -1422,8 +1422,8 @@ export type GetSessionNameHandler = () => string | undefined; export type GetActiveToolsHandler = () => string[]; -/** Tool info with name, description, parameter schema, and source metadata */ -export type ToolInfo = Pick & { +/** Tool definition with source metadata. Readonly is a type-level hint; nested schemas are not frozen. */ +export type ToolInfo = Readonly & { sourceInfo: SourceInfo; }; diff --git a/packages/coding-agent/src/index.ts b/packages/coding-agent/src/index.ts index 8627bdcdb95..97533893065 100644 --- a/packages/coding-agent/src/index.ts +++ b/packages/coding-agent/src/index.ts @@ -349,6 +349,7 @@ export { // Clipboard utilities export { copyToClipboard } from "./utils/clipboard.ts"; export { parseFrontmatter, stripFrontmatter } from "./utils/frontmatter.ts"; +export { convertToPng } from "./utils/image-convert.ts"; export { formatDimensionNote, type ResizedImage, resizeImage } from "./utils/image-resize.ts"; // Shell utilities export { getShellConfig } from "./utils/shell.ts";