Skip to content
20 linesCodeBlameRaw
1/**
2 * What the agent template pages read: the templates and the workspace's
3 * agents, to say which started from each. Each part that does not answer
4 * comes back null, and the page says so.
5 */
6import type { AgentTemplate, User } from "@g1t/contracts";
7
8import type { StartedAgent } from "./agent-templates";
9import { workspaceAgents } from "./services.server";
10
11export async function loadTemplates(slug: string, viewer: User): Promise<{ templates: AgentTemplate[] | null; agents: StartedAgent[] | null }> {
12 const [templates, agents] = await Promise.all([
13 workspaceAgents.templates().catch(() => null),
14 workspaceAgents
15 .list(slug, viewer)
16 .then((result) => (result.ok ? result.value.map(({ id, handle, display_name, template, archived_at }) => ({ id, handle, display_name, template, archived_at })) : null))
17 .catch(() => null),
18 ]);
19 return { templates, agents };
20}