/** @file Shared TypeBox parameter schemas for Pi web tools. */ import { Type } from "typebox"; import { OUTPUT_FORMATS, SCRAPE_MODES } from "../../defaults.ts"; import { StringEnum } from "../../types.ts"; export const scrapeModeSchema = StringEnum(SCRAPE_MODES); export const outputFormatSchema = StringEnum(OUTPUT_FORMATS); export const scrapeModeOptionSchema = { mode: Type.Optional(scrapeModeSchema), } as const; export const sessionOptionSchema = { sessionId: Type.Optional(Type.Unsafe({})), saveSession: Type.Optional(Type.Unsafe({})), clearSession: Type.Optional(Type.Unsafe({})), } as const; export const modelProviderOptionSchema = { provider: Type.Optional(Type.Unsafe({ description: "Model/auto/off" })), } as const; export const scrapeOutputOptionSchema = { ...scrapeModeOptionSchema, format: Type.Optional(outputFormatSchema), ...sessionOptionSchema, stealth: Type.Optional(Type.Unsafe({})), autoWait: Type.Optional(Type.Unsafe({})), browserBackend: Type.Optional( Type.Unsafe<"cloak" | "playwright">({ enum: ["cloak", "playwright"] }), ), } as const; export function urlProperty(): ReturnType> { return Type.Unsafe({}); }