import { z } from "zod/v4"; import { toolNameSchema } from "./tool"; /** * Command palette contributions (plan ยง11.1). * * A command is a second door into capabilities the app already declares: * run a tool (the host renders an input form from the tool's schema), * open a surface, or follow a deep link. */ export const commandIdSchema = z .string() .trim() .regex(/^[a-z][a-z0-9-]*$/, "Command ids are lowercase kebab-case.") .max(120); export const appCommandTargetSchema = z.discriminatedUnion("kind", [ z.object({ kind: z.literal("tool"), tool: toolNameSchema }), z.object({ kind: z.literal("surface"), surface: z.literal("home") }), z.object({ kind: z.literal("href"), href: z.string().trim().min(1).max(2000) }), ]); export type AppCommandTarget = z.infer; export const appCommandSchema = z.strictObject({ id: commandIdSchema, name: z.string().trim().min(1).max(120), icon: z.string().trim().max(120).optional(), target: appCommandTargetSchema, }); export type AppCommand = z.infer;