import { z } from 'zod'

export const zToolDefinition = z.object({
  key: z.string(),
  kind: z.enum(['command', 'input']),
  label: z.string(),
  target: z.enum(['frontend', 'backend']).optional().default('frontend'),
  inputSchema: z.object({}).loose().optional(),
})

export type ToolDefinition = z.infer<typeof zToolDefinition>

export const zAskCommonInput = z.object({
  tools: z.array(zToolDefinition),
})

export const zAskTaskInput = z.intersection(
  zAskCommonInput,
  z.object({
    task: z.string().min(1),
  }),
)

export type AskTaskInput = z.infer<typeof zAskTaskInput>

export const zAskStepInput = z.intersection(
  zAskCommonInput,
  z.object({
    conversation: z.string(),
    output: z.object({}).loose().optional(),
  }),
)

export type AskStepInput = z.infer<typeof zAskStepInput>
