Files
oh-my-pi/packages/coding-agent/src/capability/tool.ts
T
can1357 74344eca1b fix: corrected tool description normalization to prevent undefined field errors
- Added fallback empty string for undefined tool descriptions across all AI providers to prevent runtime errors.
- Made `description` field required in CustomTool interface and normalized tool descriptions in agent-loop.
- Refactored tool normalization in agent-loop by renaming `injectIntentIntoTools()` to `normalizeTools()` with conditional intent injection.
- Added comprehensive description metadata to todo-write tool schema fields for improved clarity.
2026-02-23 17:12:59 +01:00

38 lines
899 B
TypeScript

/**
* Custom Tools Capability
*
* User-defined tools that extend agent capabilities.
*/
import { defineCapability } from ".";
import type { SourceMeta } from "./types";
/**
* A custom tool definition.
*/
export interface CustomTool {
/** Tool name (unique key) */
name: string;
/** Absolute path to tool definition file */
path: string;
/** Tool description */
description: string;
/** Tool implementation (script path or inline) */
implementation?: string;
/** Source level */
level: "user" | "project";
/** Source metadata */
_source: SourceMeta;
}
export const toolCapability = defineCapability<CustomTool>({
id: "tools",
displayName: "Custom Tools",
description: "User-defined tools that extend agent capabilities",
key: tool => tool.name,
validate: tool => {
if (!tool.name) return "Missing name";
if (!tool.path) return "Missing path";
return undefined;
},
});