mirror of
https://github.com/luckyyzh/pi-agent-integrated.git
synced 2026-10-03 02:59:35 +00:00
feat: integrate Pi backend and Pi Web
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
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];
|
||||
}
|
||||
Reference in New Issue
Block a user