Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

subagents-test.ts

38 lines1.1 KB

1import { toolDefinition } from '@tanstack/ai'
2import { z } from 'zod'
3​
4/**
5 * Shared by `/api/subagents-test` (server) and `/subagents-test` (client).
6 * The client needs the definition to render the child's approval.
7 */
8export const deleteLogs = toolDefinition({
9 name: 'deleteLogs',
10 description: 'Delete old log files',
11 needsApproval: true,
12 inputSchema: z.object({ folder: z.string() }),
13})
14​
15export const lookupFacts = toolDefinition({
16 name: 'lookupFacts',
17 description: 'Look up facts about a topic',
18 inputSchema: z.object({ topic: z.string() }),
19})
20​
21export type SubagentScenario = 'route' | 'approval' | 'tool' | 'brief'
22​
23/** The user message for each scenario. It matches `fixtures/subagents`. */
24export const SUBAGENT_PROMPTS: Record<SubagentScenario, string> = {
25 route: '[subagent-route] research squids',
26 approval: '[subagent-approval] clean up the old logs',
27 tool: '[subagent-tool] research squids',
28 brief: '[subagent-brief] compare squid facts',
30​
31export function isSubagentScenario(value: unknown): value is SubagentScenario {
32 return (
33 value === 'route' ||
34 value === 'approval' ||
35 value === 'tool' ||
36 value === 'brief'
37 )