feat: integrate Pi backend and Pi Web

This commit is contained in:
luckyyzh
2026-07-30 19:37:53 +08:00
commit 7392ab9dd7
1390 changed files with 337197 additions and 0 deletions
+34
View File
@@ -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];
}