import { z } from "zod"; /** * Test-only AI seam bodies (TASK-0122 — `INTERNAL_TEST_SEAM`). * * - `MockFailDto`: arm a deterministic provider outage on the NEXT mock * chat call (mid-stream, after `deltas` deltas — see `armMockFailures`). * `status` must be a retryable one (429/5xx): a 4xx would be non-retryable * and the panel would show a dead-end banner, which is not what the E2E * error-state spec exercises. * - `AiUsageLimitsDto`: set (or clear, via `null`) the per-workspace * `usageLimits.aiMonthlyTokens` — the monthly token budget the AI budget * guard enforces (a value < 2×maxOutputTokens trips the pre-stream 402 * on a fresh workspace). No PUBLIC API writes this column, which is why * the seam exists. */ export const MockFailDto = z.object({ status: z.union([z.literal(429), z.literal(500), z.literal(502), z.literal(503), z.literal(504)]).default(500), deltas: z.number().int().min(0).max(100).default(2) }); export type MockFailInput = z.infer; export const AiUsageLimitsDto = z.object({ aiMonthlyTokens: z.number().int().min(0).max(1_000_000_000).nullable().default(null) }); export type AiUsageLimitsInput = z.infer; /** * TASK-0123: arm the NEXT mock WRITING call to append a forged blockId the * prompt never contained (the "unknown ID → drop + note" validation seam). */ export const MockUnknownBlockIdDto = z.object({ unknownId: z.string().min(1).max(100) }); export type MockUnknownBlockIdInput = z.infer; /** * TASK-0124: arm the NEXT mock DATABASE-GENERATION call to emit a * deliberately invalid tool call (the "zod/engine validation fails → retry * once → 422, no partial write" seam). `action` selects which feature's * invalid shape to emit (default `generate`). */ export const MockDbInvalidDto = z.object({ action: z.enum(["generate", "extract", "formula"]).default("generate") }); export type MockDbInvalidInput = z.infer; /** * TASK-0126: arm the NEXT mock PAGE-GENERATION call for a workspace: * - `failStep` (1-based): inject a plan step that references an unknown ref * (the executor's step-failure → rollback path); * - `slowMs`: make the plan fetch take this long (the service's total-timeout * watchdog fires → the `ai_timeout` path). * Both optional; omit to arm neither (a no-op arming). */ export const MockGenerateSeamDto = z.object({ failStep: z.number().int().min(1).max(50).optional(), slowMs: z.number().int().min(1).max(600_000).optional() }); export type MockGenerateSeamInput = z.infer; /** * T-172…T-175 (A-010): arm the mock ASSISTANT calls for `workspaceId` to * emit a deliberately INVALID tool call (`hostile` → retry-once → 422, no * write) and/or a forged candidate id (`forgeId` → the no-fabricated-refs * drop path). Both flags optional; omit both = no-op arming. */ export const MockAssistantDto = z.object({ hostile: z.boolean().default(false), forgeId: z.boolean().default(false) }); export type MockAssistantInput = z.infer;