feat(drainage): execute frontend actions

This commit is contained in:
2026-07-13 17:26:03 +08:00
parent c2e1c937ae
commit 0b7e827024
8 changed files with 171 additions and 8 deletions
+5 -1
View File
@@ -4,24 +4,28 @@ import type {
AgentModelOption
} from "./client";
import { parseUiRegistry, type UIRegistry } from "../ui-envelope";
import { parseFrontendActionRegistry, type FrontendActionRegistry } from "../frontend-action";
export const agentBootstrapKey = ["agent", "bootstrap"] as const;
export const agentSessionsKey = ["agent", "sessions"] as const;
export type AgentBootstrapData = {
registry: UIRegistry | null;
frontendActionRegistry?: FrontendActionRegistry | null;
models: AgentModelOption[];
defaultModel: string;
};
export async function fetchAgentBootstrap(client: AgentApiClient): Promise<AgentBootstrapData> {
const [rawRegistry, modelsResponse] = await Promise.all([
const [rawRegistry, rawFrontendActionRegistry, modelsResponse] = await Promise.all([
client.getUiRegistry(),
typeof client.getFrontendActionRegistry === "function" ? client.getFrontendActionRegistry() : Promise.resolve(undefined),
client.getModels()
]);
return {
registry: parseUiRegistry(rawRegistry),
...(rawFrontendActionRegistry === undefined ? {} : { frontendActionRegistry: parseFrontendActionRegistry(rawFrontendActionRegistry) }),
models: modelsResponse.models,
defaultModel: modelsResponse.defaultModel
};