mirror of
https://github.com/luckyyzh/pi-agent-integrated.git
synced 2026-10-03 02:59:35 +00:00
35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
export interface ToolEntry {
|
|
name: string;
|
|
description: string;
|
|
active: boolean;
|
|
}
|
|
|
|
export type ToolPreset = "none" | "default" | "full";
|
|
|
|
export const PRESET_NONE: string[] = [];
|
|
export const PRESET_DEFAULT: string[] = ["read", "bash", "edit", "write"];
|
|
export const PRESET_FULL: string[] = ["bash", "read", "edit", "write", "grep", "find", "ls"];
|
|
|
|
const BUILTIN_TOOL_NAMES = new Set(PRESET_FULL);
|
|
|
|
export function getPresetFromTools(tools: ToolEntry[]): ToolPreset {
|
|
const activeTools = tools.filter((t) => t.active);
|
|
if (activeTools.length === 0) return "none";
|
|
|
|
const active = activeTools
|
|
.map((t) => t.name)
|
|
.filter((name) => BUILTIN_TOOL_NAMES.has(name))
|
|
.sort()
|
|
.join(",");
|
|
|
|
if (active === [...PRESET_DEFAULT].sort().join(",")) return "default";
|
|
if (active === [...PRESET_FULL].sort().join(",")) return "full";
|
|
return "default";
|
|
}
|
|
|
|
export function getToolNamesForPreset(preset: ToolPreset): string[] {
|
|
if (preset === "none") return [...PRESET_NONE];
|
|
if (preset === "full") return [...PRESET_FULL];
|
|
return [...PRESET_DEFAULT];
|
|
}
|