feat(h5): add LLM intent router admin controls and shadow verification.

Expose shadow/canary router policy in ops admin, add FAQ rule fast-path,
and tighten router defaults (1200ms timeout, 0.65 confidence).
Includes verify-h5-llm-router-shadow for production canary rollout.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-08-01 16:48:01 +08:00
parent 005612029f
commit 43bc8bbc2b
14 changed files with 1391 additions and 80 deletions
+78
View File
@@ -815,3 +815,81 @@ export async function fetchAgentCodeRunHistory(limit = 50) {
`/admin-api/agent-code-run/runs?limit=${limit}`,
);
}
// ─── Unified LLM Providers ────────────────────────────────────────────────────
export type LlmProviderKeyRow = {
id: string;
providerId: string;
providerKind: 'builtin' | 'custom';
providerLabel: string;
name: string;
defaultModel: string;
models: string[];
apiUrl: string | null;
status: 'active' | 'disabled';
isSelected: boolean;
apiKeyMasked: string;
};
export type LlmGlobalSettings = {
keyId: string | null;
keyName: string | null;
providerLabel: string | null;
globalModel: string | null;
availableModels: string[];
};
export type ChatIntentRouterAdminConfig = {
enabled?: boolean;
shadowMode?: boolean;
canaryUserIds?: string;
modelProviderKeyId?: string;
model?: string;
modelApiType?: string;
minConfidence?: string;
memoryResolveEnabled?: boolean;
memoryResolveLimit?: string;
timeoutMs?: string;
fallbackRoute?: string;
};
export type MemoryV2AdminConfigState = {
config: {
chatIntentRouter?: ChatIntentRouterAdminConfig;
[key: string]: unknown;
};
updatedAt: number | null;
updatedBy: string | null;
};
export type MemoryV2RuntimeState = {
source: string;
updatedAt: number | null;
updatedBy: string | null;
fingerprint?: string;
overrides: Record<string, string>;
};
export async function fetchLlmProviderKeys() {
return adminFetch<{ keys: LlmProviderKeyRow[] }>('/admin-api/llm-providers/keys');
}
export async function fetchLlmGlobalSettings() {
return adminFetch<{ global: LlmGlobalSettings }>('/admin-api/llm-providers/global');
}
export async function fetchMemoryV2Config() {
return adminFetch<MemoryV2AdminConfigState>('/admin-api/memory-v2/config');
}
export async function patchMemoryV2Config(patch: Record<string, unknown>) {
return adminFetch<MemoryV2AdminConfigState>('/admin-api/memory-v2/config', {
method: 'PATCH',
body: JSON.stringify(patch),
});
}
export async function fetchMemoryV2Runtime() {
return adminFetch<MemoryV2RuntimeState>('/admin-api/memory-v2/runtime');
}