fix(coding-agent): returned ToolInfo[] from getAllTools extension API

The ExtensionAPI getAllTools() wired to session.getAllToolNames(),
returning bare tool-name strings. Upstream @earendil-works/pi-coding-agent
promises ToolInfo[] with sourceInfo, so extensions loaded through the
legacy-pi shim (e.g. gentle-pi) crashed on t.sourceInfo.source at every
session start.

Added SourceInfo/ToolInfo types plus SessionTools.getAllToolInfos(), which
returns { name, description, parameters, sourceInfo } and classifies each
tool as builtin/mcp/sdk/extension. Rewired every getAllTools action site
(interactive, acp, print/rpc, subagent executor) and the example extension.

Fixes #7732
This commit is contained in:
roboomp
2026-08-05 15:42:06 +00:00
parent 1e492d6ff9
commit 83496b8211
11 changed files with 168 additions and 13 deletions
@@ -36,7 +36,7 @@ export default function toolsExtension(pi: ExtensionAPI) {
// Find the last tools-config entry in the current branch
async function restoreFromBranch(ctx: ExtensionContext) {
allTools = pi.getAllTools();
allTools = pi.getAllTools().map(t => t.name);
// Get entries in current branch only
const branchEntries = ctx.sessionManager.getBranch();
@@ -66,7 +66,7 @@ export default function toolsExtension(pi: ExtensionAPI) {
description: "Enable/disable tools",
handler: async (_args, ctx) => {
// Refresh tool list
allTools = pi.getAllTools();
allTools = pi.getAllTools().map(t => t.name);
await ctx.ui.custom((tui, theme, _keybindings, done) => {
// Build settings items for each tool