File size: 1,008 Bytes
4e23b01 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | import { z } from 'zod';
import { isoDateTimeSchema } from '@moonshot-ai/agent-core-v2/_base/utils/isoDateTime';
export const workspaceIdSchema = z
.string()
.regex(/^wd_[a-z0-9._-]+_[0-9a-f]{12}$/, {
message: 'workspace_id must be a wd_<slug>_<hash12> string',
});
export type WorkspaceId = z.infer<typeof workspaceIdSchema>;
export const workspaceSchema = z.object({
id: workspaceIdSchema,
root: z.string().min(1),
name: z.string().min(1).max(100),
created_at: isoDateTimeSchema,
last_opened_at: isoDateTimeSchema,
session_count: z.number().int().nonnegative(),
});
export type Workspace = z.infer<typeof workspaceSchema>;
export const workspaceCreateSchema = z.object({
root: z.string().min(1),
name: z.string().min(1).max(100).optional(),
});
export type WorkspaceCreate = z.infer<typeof workspaceCreateSchema>;
export const workspaceUpdateSchema = z.object({
name: z.string().min(1).max(100),
});
export type WorkspaceUpdate = z.infer<typeof workspaceUpdateSchema>;
|