You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
885 B
25 lines
885 B
import { z } from "zod";
|
|
|
|
export const documentConfigSchema = z.object({
|
|
approvalRequiredActions: z.array(z.enum(["create", "update", "delete"])).default(["delete"]),
|
|
defaultType: z.enum(["memory", "document"]).default("document"),
|
|
maxContentLength: z.number().int().positive().max(100000).default(50000),
|
|
listPageSize: z.number().int().positive().max(100).default(20),
|
|
});
|
|
|
|
export type DocumentToolConfig = z.infer<typeof documentConfigSchema>;
|
|
|
|
export const DEFAULT_DOCUMENT_CONFIG: DocumentToolConfig = {
|
|
approvalRequiredActions: ["delete"],
|
|
defaultType: "document",
|
|
maxContentLength: 50000,
|
|
listPageSize: 20,
|
|
};
|
|
|
|
export function parseDocumentConfig(raw: unknown): DocumentToolConfig {
|
|
const parsed = documentConfigSchema.safeParse(raw);
|
|
if (!parsed.success) {
|
|
throw new Error(`Invalid document config: ${parsed.error.message}`);
|
|
}
|
|
return parsed.data;
|
|
}
|
|
|