Files
DeepTutor/web/lib/tools-settings.ts
Bingxi Zhao (Frank) acd0d9329d feat(capabilities): unify infra, merge Animator into Visualize, split settings UI
Capability infrastructure:
- New capabilities/_shared.emit_capability_result helper fills the
  result envelope (label, summary, payload, render hints, UsageTracker
  totals) consistently across modes.
- StatusI18n loads capability status copy from
  capabilities/prompts/{en,zh}/<name>.yaml; legacy main.yaml strings
  removed.
- New capabilities_settings router + service-config module power the
  /settings/capabilities admin page (live capability list, defaults,
  per-capability overrides).

Visualize + Animator merge:
- Visualize's AnalysisAgent now picks one of six render_types:
  svg / chartjs / mermaid / html (text pipeline) or manim_video /
  manim_image (Manim subprocess). The result envelope carries
  render_type so the frontend delegates to the right viewer.
- math_animator capability is folded behind Visualize; the standalone
  MathAnimatorConfigPanel.tsx is removed. The Animator sidebar entry
  is gone, but Manim outputs and existing records remain unaffected.

Settings UI:
- /settings page split into appearance / capabilities / embedding /
  llm / mcp / memory / search / status / tools tabs with a shared
  layout and items index.
- New /settings/tools page lists chat-mountable tools and surfaces
  availability (e.g. gh for github_query) via a new tools router.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 18:06:14 +08:00

36 lines
1.1 KiB
TypeScript

import { apiFetch, apiUrl } from "@/lib/api";
export interface ToolSettingsResponse {
enabled_optional_tools: string[];
}
let cached: Promise<string[]> | null = null;
async function fetchEnabledOptionalTools(): Promise<string[]> {
const res = await apiFetch(apiUrl("/api/v1/tools"));
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const payload = (await res.json()) as ToolSettingsResponse;
return Array.isArray(payload.enabled_optional_tools)
? payload.enabled_optional_tools.slice()
: [];
}
/** Read the user's saved set of enabled toggleable tools.
* Cached at module scope so multiple consumers on the same page share one
* network round-trip; call ``refreshEnabledOptionalTools`` to bust. */
export async function getEnabledOptionalTools(options?: {
force?: boolean;
}): Promise<string[]> {
if (options?.force || cached === null) {
cached = fetchEnabledOptionalTools().catch((err) => {
cached = null;
throw err;
});
}
return cached.then((list) => list.slice());
}
export function invalidateEnabledOptionalToolsCache(): void {
cached = null;
}