From 4e550a873ea050d646ddb157d8695e29611a0c0e Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 5 Apr 2026 13:54:27 +0100 Subject: [PATCH] fix(agents): restore tool display summary typing --- src/agents/bash-tools.exec.ts | 6 +++--- src/agents/bash-tools.process.ts | 5 +++-- src/agents/tools/common.ts | 10 ++++++++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/agents/bash-tools.exec.ts b/src/agents/bash-tools.exec.ts index e182f449b60..ea2bece30e3 100644 --- a/src/agents/bash-tools.exec.ts +++ b/src/agents/bash-tools.exec.ts @@ -1,6 +1,6 @@ import fs from "node:fs/promises"; import path from "node:path"; -import type { AgentTool, AgentToolResult } from "@mariozechner/pi-agent-core"; +import type { AgentToolResult } from "@mariozechner/pi-agent-core"; import { analyzeShellCommand } from "../infra/exec-approvals-analysis.js"; import { type ExecHost, @@ -53,7 +53,7 @@ import { } from "./bash-tools.shared.js"; import { assertSandboxPath } from "./sandbox-paths.js"; import { EXEC_TOOL_DISPLAY_SUMMARY } from "./tool-description-presets.js"; -import { failedTextResult, textResult } from "./tools/common.js"; +import { type AgentToolWithMeta, failedTextResult, textResult } from "./tools/common.js"; export type { BashSandboxConfig } from "./bash-tools.shared.js"; export type { @@ -1168,7 +1168,7 @@ export function describeExecTool(params?: { agentId?: string; hasCronTool?: bool export function createExecTool( defaults?: ExecToolDefaults, // oxlint-disable-next-line typescript/no-explicit-any -): AgentTool { +): AgentToolWithMeta { const defaultBackgroundMs = clampWithDefault( defaults?.backgroundMs ?? readEnvInt("PI_BASH_YIELD_MS"), 10_000, diff --git a/src/agents/bash-tools.process.ts b/src/agents/bash-tools.process.ts index 3750d4941bf..cd06c28fcdd 100644 --- a/src/agents/bash-tools.process.ts +++ b/src/agents/bash-tools.process.ts @@ -1,4 +1,4 @@ -import type { AgentTool, AgentToolResult } from "@mariozechner/pi-agent-core"; +import type { AgentToolResult } from "@mariozechner/pi-agent-core"; import { Type } from "@sinclair/typebox"; import { formatDurationCompact } from "../infra/format-time/format-duration.ts"; import { getDiagnosticSessionState } from "../logging/diagnostic-session-state.js"; @@ -19,6 +19,7 @@ import { deriveSessionName, pad, sliceLogLines, truncateMiddle } from "./bash-to import { recordCommandPoll, resetCommandPollCount } from "./command-poll-backoff.js"; import { encodeKeySequence, encodePaste, hasCursorModeSensitiveKeys } from "./pty-keys.js"; import { PROCESS_TOOL_DISPLAY_SUMMARY } from "./tool-description-presets.js"; +import type { AgentToolWithMeta } from "./tools/common.js"; export type ProcessToolDefaults = { cleanupMs?: number; @@ -133,7 +134,7 @@ export function describeProcessTool(params?: { hasCronTool?: boolean }): string export function createProcessTool( defaults?: ProcessToolDefaults, // oxlint-disable-next-line typescript/no-explicit-any -): AgentTool { +): AgentToolWithMeta { if (defaults?.cleanupMs !== undefined) { setJobTtlMs(defaults.cleanupMs); } diff --git a/src/agents/tools/common.ts b/src/agents/tools/common.ts index cff6d62a7a3..a56a9ec7a3c 100644 --- a/src/agents/tools/common.ts +++ b/src/agents/tools/common.ts @@ -1,16 +1,22 @@ import fs from "node:fs/promises"; import type { AgentTool, AgentToolResult } from "@mariozechner/pi-agent-core"; +import type { TSchema } from "@sinclair/typebox"; import { detectMime } from "../../media/mime.js"; import { readSnakeCaseParamRaw } from "../../param-key.js"; import type { ImageSanitizationLimits } from "../image-sanitization.js"; import { sanitizeToolResultImages } from "../tool-images.js"; -// oxlint-disable-next-line typescript/no-explicit-any -export type AnyAgentTool = AgentTool & { +export type AgentToolWithMeta = AgentTool< + TParameters, + TResult +> & { ownerOnly?: boolean; displaySummary?: string; }; +// oxlint-disable-next-line typescript/no-explicit-any +export type AnyAgentTool = AgentToolWithMeta; + export type StringParamOptions = { required?: boolean; trim?: boolean;