53 lines
1.6 KiB
TypeScript
53 lines
1.6 KiB
TypeScript
import { z } from "zod";
|
|
|
|
const MAX_TOKENS = 1_000_000_000_000; // 1 trillion
|
|
|
|
export const registerSchema = z.object({
|
|
name: z.string().min(1).max(100),
|
|
platform: z.string().optional(),
|
|
model: z.string().optional(),
|
|
});
|
|
|
|
export const heartbeatSchema = z.object({
|
|
name: z.string().optional(),
|
|
model: z.string().optional(),
|
|
platform: z.string().optional(),
|
|
});
|
|
|
|
export const taskSchema = z.object({
|
|
summary: z.string().max(500),
|
|
durationMs: z.number().positive(),
|
|
model: z.string().optional(),
|
|
toolsUsed: z.array(z.string()).optional(),
|
|
});
|
|
|
|
export const tokenSchema = z.object({
|
|
inputTokens: z.number().int().nonnegative().max(MAX_TOKENS),
|
|
outputTokens: z.number().int().nonnegative().max(MAX_TOKENS),
|
|
date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
|
|
});
|
|
|
|
export const deviceRegisterSchema = z.object({
|
|
deviceId: z.string().min(1).max(64),
|
|
name: z.string().min(1).max(100).optional(),
|
|
platform: z.string().max(50).optional(),
|
|
browser: z.string().max(100).optional(),
|
|
screen: z.string().max(20).optional(),
|
|
language: z.string().max(10).optional(),
|
|
});
|
|
|
|
export const updateNameSchema = z.object({
|
|
name: z
|
|
.string()
|
|
.min(1)
|
|
.max(30)
|
|
.regex(/^[A-Za-z0-9_-]+$/, "Only alphanumeric, hyphens, and underscores"),
|
|
});
|
|
|
|
export type RegisterInput = z.infer<typeof registerSchema>;
|
|
export type HeartbeatInput = z.infer<typeof heartbeatSchema>;
|
|
export type TaskInput = z.infer<typeof taskSchema>;
|
|
export type TokenInput = z.infer<typeof tokenSchema>;
|
|
export type DeviceRegisterInput = z.infer<typeof deviceRegisterSchema>;
|
|
export type UpdateNameInput = z.infer<typeof updateNameSchema>;
|