/** * Zod schemas for runtime validation. * These are the single source of truth for data structures. * Types are inferred from schemas using z.infer. */ import { z } from "zod"; export declare const QuotaStatusScreenSchema: z.ZodEnum<{ active: "active"; overview: "overview"; resets: "resets"; }>; export declare const PluginConfigSchema: z.ZodObject<{ codexMode: z.ZodOptional; requestTransformMode: z.ZodOptional>; codexTuiV2: z.ZodOptional; codexTuiColorProfile: z.ZodOptional>; codexTuiGlyphMode: z.ZodOptional>; maskEmail: z.ZodOptional; maskEmailInQuotaDetails: z.ZodOptional; quotaDisplay: z.ZodOptional>; beginnerSafeMode: z.ZodOptional; fastSession: z.ZodOptional; fastSessionStrategy: z.ZodOptional>; rotationStrategy: z.ZodOptional>; modelAccountPools: z.ZodOptional>>; modelAccountPoolModes: z.ZodOptional>>; fastSessionMaxInputItems: z.ZodOptional; retryProfile: z.ZodOptional>; retryBudgetOverrides: z.ZodOptional; network: z.ZodOptional; server: z.ZodOptional; rateLimitShort: z.ZodOptional; rateLimitGlobal: z.ZodOptional; emptyResponse: z.ZodOptional; }, z.core.$strip>>; retryAllAccountsRateLimited: z.ZodOptional; retryAllAccountsMaxWaitMs: z.ZodOptional; retryAllAccountsMaxRetries: z.ZodOptional; unsupportedCodexPolicy: z.ZodOptional>; fallbackOnUnsupportedCodexModel: z.ZodOptional; fallbackToGpt52OnUnsupportedGpt53: z.ZodOptional; unsupportedCodexFallbackChain: z.ZodOptional>>; tokenRefreshSkewMs: z.ZodOptional; rateLimitToastDebounceMs: z.ZodOptional; toastDurationMs: z.ZodOptional; accountToasts: z.ZodOptional; perProjectAccounts: z.ZodOptional; credentialSnapshots: z.ZodOptional; credentialSnapshotsMaxCount: z.ZodOptional; sessionRecovery: z.ZodOptional; autoResume: z.ZodOptional; autoUpdate: z.ZodOptional; parallelProbing: z.ZodOptional; parallelProbingMaxConcurrency: z.ZodOptional; emptyResponseMaxRetries: z.ZodOptional; emptyResponseRetryDelayMs: z.ZodOptional; pidOffsetEnabled: z.ZodOptional; fetchTimeoutMs: z.ZodOptional; streamStallTimeoutMs: z.ZodOptional; quotaNotifications: z.ZodOptional; autoProtectCredits: z.ZodOptional; intervalMs: z.ZodOptional; notifyEveryCheck: z.ZodOptional; thresholds: z.ZodOptional>; }, z.core.$strip>>; quotaStatus: z.ZodOptional, z.ZodArray>]>>; rotateMs: z.ZodOptional; layout: z.ZodOptional>; accountNames: z.ZodOptional>; order: z.ZodOptional>; multipliers: z.ZodOptional; allotment: z.ZodOptional; resetTimes: z.ZodOptional, z.ZodBoolean]>>; resetCredits: z.ZodOptional; recovery: z.ZodOptional; accounts: z.ZodOptional; rows: z.ZodOptional; showFor: z.ZodOptional>; }, z.core.$strip>>; }, z.core.$strip>; export type PluginConfigFromSchema = z.infer; /** * Source of the accountId used for ChatGPT requests. */ export declare const AccountIdSourceSchema: z.ZodEnum<{ token: "token"; id_token: "id_token"; org: "org"; manual: "manual"; }>; export type AccountIdSourceFromSchema = z.infer; /** * Cooldown reason for temporary account suspension. */ export declare const CooldownReasonSchema: z.ZodEnum<{ "auth-failure": "auth-failure"; "network-error": "network-error"; }>; export type CooldownReasonFromSchema = z.infer; /** * Last switch reason for account rotation tracking. */ export declare const SwitchReasonSchema: z.ZodEnum<{ "rate-limit": "rate-limit"; initial: "initial"; rotation: "rotation"; }>; export type SwitchReasonFromSchema = z.infer; /** * Rate limit state - maps model family to reset timestamp. */ export declare const RateLimitStateV3Schema: z.ZodRecord>; export type RateLimitStateV3FromSchema = z.infer; /** * Account metadata V3 - current storage format. */ export declare const AccountMetadataV3Schema: z.ZodObject<{ accountId: z.ZodOptional; accountUserId: z.ZodOptional; organizationId: z.ZodOptional; accountIdSource: z.ZodOptional>; accountLabel: z.ZodOptional; planType: z.ZodOptional; accountTags: z.ZodPipe>, z.ZodTransform>; accountNote: z.ZodPipe, z.ZodTransform>; email: z.ZodOptional; refreshToken: z.ZodString; accessToken: z.ZodOptional; expiresAt: z.ZodOptional; oauthScope: z.ZodOptional; tokenRotatedAt: z.ZodOptional; enabled: z.ZodOptional; addedAt: z.ZodNumber; lastUsed: z.ZodNumber; lastSwitchReason: z.ZodOptional>; rateLimitResetTimes: z.ZodOptional>>; coolingDownUntil: z.ZodOptional; quotaExhaustedUntil: z.ZodOptional; quotaExhaustedStampAt: z.ZodOptional; quotaExhaustedClearedAt: z.ZodOptional; cooldownReason: z.ZodOptional>; }, z.core.$strip>; export type AccountMetadataV3FromSchema = z.infer; export declare const ActiveIndexByFamilySchema: z.ZodObject<{ "gpt-5-codex": z.ZodOptional>; "codex-max": z.ZodOptional>; codex: z.ZodOptional>; "gpt-6-astra": z.ZodOptional>; "gpt-daybreak-blue": z.ZodOptional>; "gpt-daybreak-red": z.ZodOptional>; "gpt-5.6-cyber": z.ZodOptional>; "gpt-5.6-sol": z.ZodOptional>; "gpt-5.6-terra": z.ZodOptional>; "gpt-5.6-luna": z.ZodOptional>; "gpt-5.4": z.ZodOptional>; "gpt-5.4-mini": z.ZodOptional>; "gpt-5.4-pro": z.ZodOptional>; "gpt-5.2": z.ZodOptional>; "gpt-5.1": z.ZodOptional>; }, z.core.$strip>; export type ActiveIndexByFamilyFromSchema = z.infer; /** * Account storage V3 - current storage format with per-family active indices. */ export declare const AccountStorageV3Schema: z.ZodObject<{ version: z.ZodLiteral<3>; accounts: z.ZodArray; accountUserId: z.ZodOptional; organizationId: z.ZodOptional; accountIdSource: z.ZodOptional>; accountLabel: z.ZodOptional; planType: z.ZodOptional; accountTags: z.ZodPipe>, z.ZodTransform>; accountNote: z.ZodPipe, z.ZodTransform>; email: z.ZodOptional; refreshToken: z.ZodString; accessToken: z.ZodOptional; expiresAt: z.ZodOptional; oauthScope: z.ZodOptional; tokenRotatedAt: z.ZodOptional; enabled: z.ZodOptional; addedAt: z.ZodNumber; lastUsed: z.ZodNumber; lastSwitchReason: z.ZodOptional>; rateLimitResetTimes: z.ZodOptional>>; coolingDownUntil: z.ZodOptional; quotaExhaustedUntil: z.ZodOptional; quotaExhaustedStampAt: z.ZodOptional; quotaExhaustedClearedAt: z.ZodOptional; cooldownReason: z.ZodOptional>; }, z.core.$strip>>; activeIndex: z.ZodNumber; activeIndexByFamily: z.ZodOptional>; "codex-max": z.ZodOptional>; codex: z.ZodOptional>; "gpt-6-astra": z.ZodOptional>; "gpt-daybreak-blue": z.ZodOptional>; "gpt-daybreak-red": z.ZodOptional>; "gpt-5.6-cyber": z.ZodOptional>; "gpt-5.6-sol": z.ZodOptional>; "gpt-5.6-terra": z.ZodOptional>; "gpt-5.6-luna": z.ZodOptional>; "gpt-5.4": z.ZodOptional>; "gpt-5.4-mini": z.ZodOptional>; "gpt-5.4-pro": z.ZodOptional>; "gpt-5.2": z.ZodOptional>; "gpt-5.1": z.ZodOptional>; }, z.core.$strip>>; }, z.core.$strip>; export type AccountStorageV3FromSchema = z.infer; /** * Legacy V1 account metadata for migration support. */ export declare const AccountMetadataV1Schema: z.ZodObject<{ accountId: z.ZodOptional; accountUserId: z.ZodOptional; organizationId: z.ZodOptional; accountIdSource: z.ZodOptional>; accountLabel: z.ZodOptional; accountTags: z.ZodPipe>, z.ZodTransform>; accountNote: z.ZodPipe, z.ZodTransform>; email: z.ZodOptional; refreshToken: z.ZodString; accessToken: z.ZodOptional; expiresAt: z.ZodOptional; oauthScope: z.ZodOptional; enabled: z.ZodOptional; addedAt: z.ZodNumber; lastUsed: z.ZodNumber; lastSwitchReason: z.ZodOptional>; rateLimitResetTime: z.ZodOptional; coolingDownUntil: z.ZodOptional; cooldownReason: z.ZodOptional>; }, z.core.$strip>; export type AccountMetadataV1FromSchema = z.infer; /** * Legacy V1 storage format for migration support. */ export declare const AccountStorageV1Schema: z.ZodObject<{ version: z.ZodLiteral<1>; accounts: z.ZodArray; accountUserId: z.ZodOptional; organizationId: z.ZodOptional; accountIdSource: z.ZodOptional>; accountLabel: z.ZodOptional; accountTags: z.ZodPipe>, z.ZodTransform>; accountNote: z.ZodPipe, z.ZodTransform>; email: z.ZodOptional; refreshToken: z.ZodString; accessToken: z.ZodOptional; expiresAt: z.ZodOptional; oauthScope: z.ZodOptional; enabled: z.ZodOptional; addedAt: z.ZodNumber; lastUsed: z.ZodNumber; lastSwitchReason: z.ZodOptional>; rateLimitResetTime: z.ZodOptional; coolingDownUntil: z.ZodOptional; cooldownReason: z.ZodOptional>; }, z.core.$strip>>; activeIndex: z.ZodNumber; }, z.core.$strip>; export type AccountStorageV1FromSchema = z.infer; /** * Minimal V2 detection schema. * * V2 was an intermediate account-storage format used by legacy 4.x builds * that never shipped a documented shape. We only validate enough to recognise * `version: 2` files so the loader can surface a typed `UNKNOWN_V2_FORMAT` * error instead of silently discarding credentials. Do not extend this * schema without evidence of the real V2 shape. */ export declare const AccountStorageV2DetectionSchema: z.ZodObject<{ version: z.ZodLiteral<2>; accounts: z.ZodOptional>>; }, z.core.$strip>; export type AccountStorageV2DetectionFromSchema = z.infer; /** * Union of V1 and V3 storage formats for migration detection. * V2 is intentionally excluded: it is detected separately and rejected with a * typed StorageError so users with a V2 file are told how to recover instead * of having their credentials silently discarded. */ export declare const AnyAccountStorageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{ version: z.ZodLiteral<1>; accounts: z.ZodArray; accountUserId: z.ZodOptional; organizationId: z.ZodOptional; accountIdSource: z.ZodOptional>; accountLabel: z.ZodOptional; accountTags: z.ZodPipe>, z.ZodTransform>; accountNote: z.ZodPipe, z.ZodTransform>; email: z.ZodOptional; refreshToken: z.ZodString; accessToken: z.ZodOptional; expiresAt: z.ZodOptional; oauthScope: z.ZodOptional; enabled: z.ZodOptional; addedAt: z.ZodNumber; lastUsed: z.ZodNumber; lastSwitchReason: z.ZodOptional>; rateLimitResetTime: z.ZodOptional; coolingDownUntil: z.ZodOptional; cooldownReason: z.ZodOptional>; }, z.core.$strip>>; activeIndex: z.ZodNumber; }, z.core.$strip>, z.ZodObject<{ version: z.ZodLiteral<3>; accounts: z.ZodArray; accountUserId: z.ZodOptional; organizationId: z.ZodOptional; accountIdSource: z.ZodOptional>; accountLabel: z.ZodOptional; planType: z.ZodOptional; accountTags: z.ZodPipe>, z.ZodTransform>; accountNote: z.ZodPipe, z.ZodTransform>; email: z.ZodOptional; refreshToken: z.ZodString; accessToken: z.ZodOptional; expiresAt: z.ZodOptional; oauthScope: z.ZodOptional; tokenRotatedAt: z.ZodOptional; enabled: z.ZodOptional; addedAt: z.ZodNumber; lastUsed: z.ZodNumber; lastSwitchReason: z.ZodOptional>; rateLimitResetTimes: z.ZodOptional>>; coolingDownUntil: z.ZodOptional; quotaExhaustedUntil: z.ZodOptional; quotaExhaustedStampAt: z.ZodOptional; quotaExhaustedClearedAt: z.ZodOptional; cooldownReason: z.ZodOptional>; }, z.core.$strip>>; activeIndex: z.ZodNumber; activeIndexByFamily: z.ZodOptional>; "codex-max": z.ZodOptional>; codex: z.ZodOptional>; "gpt-6-astra": z.ZodOptional>; "gpt-daybreak-blue": z.ZodOptional>; "gpt-daybreak-red": z.ZodOptional>; "gpt-5.6-cyber": z.ZodOptional>; "gpt-5.6-sol": z.ZodOptional>; "gpt-5.6-terra": z.ZodOptional>; "gpt-5.6-luna": z.ZodOptional>; "gpt-5.4": z.ZodOptional>; "gpt-5.4-mini": z.ZodOptional>; "gpt-5.4-pro": z.ZodOptional>; "gpt-5.2": z.ZodOptional>; "gpt-5.1": z.ZodOptional>; }, z.core.$strip>>; }, z.core.$strip>], "version">; export type AnyAccountStorageFromSchema = z.infer; /** * Schema for a single Codex CLI account entry. * * This file is produced by a separate process (the Codex CLI) and lives on * disk at a known path. It is a cross-trust-boundary input: the file could be * stale, truncated, tampered with, or produced by a mismatched Codex CLI * version. All fields are therefore `optional` at the schema level — we * extract only the fields we need and let `catchall(z.unknown())` preserve * any extra fields without rejection. * * Security note (audit top-20 #11): never trust field shapes via ad-hoc * property checks before validating through this schema. The wrapper * `CodexCliAccountsSchema` must be applied at the JSON-parse boundary. */ export declare const CodexCliAccountEntrySchema: z.ZodObject<{ email: z.ZodOptional; accountId: z.ZodOptional; auth: z.ZodOptional; refresh_token: z.ZodOptional; id_token: z.ZodOptional; }, z.core.$catchall>>; }, z.core.$catchall>>; }, z.core.$catchall>; export type CodexCliAccountEntryFromSchema = z.infer; /** * Schema for the full Codex CLI accounts file. * * Applied at the JSON-parse boundary in `lib/accounts.ts:getCodexCliTokenCache`. * A validation failure causes the loader to warn+skip (treat cache as empty) * rather than throwing — a malformed or attacker-controlled Codex CLI file * must never take down the host plugin. */ export declare const CodexCliAccountsSchema: z.ZodObject<{ accounts: z.ZodOptional; accountId: z.ZodOptional; auth: z.ZodOptional; refresh_token: z.ZodOptional; id_token: z.ZodOptional; }, z.core.$catchall>>; }, z.core.$catchall>>; }, z.core.$catchall>>>; }, z.core.$catchall>; export type CodexCliAccountsFromSchema = z.infer; /** * Token failure reason codes. */ export declare const TokenFailureReasonSchema: z.ZodEnum<{ unknown: "unknown"; http_error: "http_error"; invalid_response: "invalid_response"; network_error: "network_error"; missing_refresh: "missing_refresh"; }>; export type TokenFailureReasonFromSchema = z.infer; /** * Successful token exchange result. */ export declare const TokenSuccessSchema: z.ZodObject<{ type: z.ZodLiteral<"success">; access: z.ZodString; refresh: z.ZodString; expires: z.ZodNumber; idToken: z.ZodOptional; scope: z.ZodOptional; multiAccount: z.ZodOptional; }, z.core.$strip>; export type TokenSuccessFromSchema = z.infer; /** * Failed token exchange result. */ export declare const TokenFailureSchema: z.ZodObject<{ type: z.ZodLiteral<"failed">; reason: z.ZodOptional>; statusCode: z.ZodOptional; message: z.ZodOptional; }, z.core.$strip>; export type TokenFailureFromSchema = z.infer; /** * Token result - discriminated union of success/failure. */ export declare const TokenResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"success">; access: z.ZodString; refresh: z.ZodString; expires: z.ZodNumber; idToken: z.ZodOptional; scope: z.ZodOptional; multiAccount: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"failed">; reason: z.ZodOptional>; statusCode: z.ZodOptional; message: z.ZodOptional; }, z.core.$strip>], "type">; export type TokenResultFromSchema = z.infer; /** * OAuth token response from OpenAI. */ export declare const OAuthTokenResponseSchema: z.ZodObject<{ access_token: z.ZodString; refresh_token: z.ZodOptional; expires_in: z.ZodNumber; id_token: z.ZodOptional; token_type: z.ZodOptional; scope: z.ZodOptional; }, z.core.$strip>; export type OAuthTokenResponseFromSchema = z.infer; /** * Safely parse plugin configuration with detailed error logging. * Returns null on failure, allowing graceful degradation. */ export declare function safeParsePluginConfig(data: unknown): PluginConfigFromSchema | null; /** * Safely parse account storage (any version). * Returns null on failure, allowing graceful degradation. */ export declare function safeParseAccountStorage(data: unknown): AnyAccountStorageFromSchema | null; /** * Safely parse V3 account storage specifically. * Returns null on failure. */ export declare function safeParseAccountStorageV3(data: unknown): AccountStorageV3FromSchema | null; /** * Safely parse token result. * Returns null on failure. */ export declare function safeParseTokenResult(data: unknown): TokenResultFromSchema | null; /** * Safely parse OAuth token response from API. * Returns null on failure. */ export declare function safeParseOAuthTokenResponse(data: unknown): OAuthTokenResponseFromSchema | null; /** * Get validation errors as a flat array of strings. * Useful for logging and error messages. */ export declare function getValidationErrors(schema: z.ZodType, data: unknown): string[]; /** * JWT payload schema. * * The JWT is produced by the OAuth provider (ChatGPT backend) and decoded on * the client. Unknown claims are preserved via `catchall(z.unknown())` so we * never reject a valid-but-unfamiliar token, but the claims we actually read * (account/member ids, email, organization hints) are shape-checked. A failed parse * causes callers to treat the JWT as opaque (same behavior as an undecodable * JWT) instead of blindly casting arbitrary JSON into our `JWTPayload` type. */ export declare const JWTPayloadSchema: z.ZodObject<{ "https://api.openai.com/auth": z.ZodOptional; chatgpt_account_user_id: z.ZodOptional; organizations: z.ZodOptional; email: z.ZodOptional; chatgpt_user_email: z.ZodOptional; }, z.core.$catchall>>; organizations: z.ZodOptional; orgs: z.ZodOptional; accounts: z.ZodOptional; workspaces: z.ZodOptional; teams: z.ZodOptional; email: z.ZodOptional; preferred_username: z.ZodOptional; }, z.core.$catchall>; export type JWTPayloadFromSchema = z.infer; /** * Safely parse a decoded JWT payload. * Returns null on failure so callers can treat the token as opaque. */ export declare function safeParseJWTPayload(data: unknown): JWTPayloadFromSchema | null; /** * Cache metadata for Codex instructions fetched from GitHub. * * File lives at `~/.opencode/cache/-instructions-meta.json` and is * read at startup and after stale-while-revalidate refreshes. The file can be * corrupted, truncated, or produced by a different plugin version, so the * schema is strict: invalid files fall back to "no cached metadata" (the * same state as a missing file) and force a fresh fetch. */ export declare const CacheMetadataSchema: z.ZodObject<{ etag: z.ZodNullable; tag: z.ZodString; lastChecked: z.ZodNumber; url: z.ZodString; }, z.core.$strip>; export type CacheMetadataFromSchema = z.infer; export declare function safeParseCacheMetadata(data: unknown): CacheMetadataFromSchema | null; /** * Cache metadata for the OpenCode codex prompt fetched from GitHub. * * File lives at `~/.opencode/cache/opencode-codex-meta.json`. Same trust * considerations as `CacheMetadataSchema`; fall back to empty cache on * parse failure instead of crashing the prompt fetcher. */ export declare const OpenCodeCodexCacheMetaSchema: z.ZodObject<{ etag: z.ZodString; lastFetch: z.ZodOptional; lastChecked: z.ZodNumber; sourceUrl: z.ZodOptional; }, z.core.$strip>; export type OpenCodeCodexCacheMetaFromSchema = z.infer; export declare function safeParseOpenCodeCodexCacheMeta(data: unknown): OpenCodeCodexCacheMetaFromSchema | null; /** * Boolean env-var parser. * * Historical semantics (kept verbatim for backward compatibility with the * pre-RC-9 `parseBooleanEnv` helper): the literal string `"1"` is truthy, any * other non-empty string (including `"0"`, `"yes"`, `"true"`) is falsy, and * `undefined` remains `undefined` so callers can fall back to the config * file / hard-coded default. The schema does not throw on invalid input; * boolean env vars are a process boundary but one where permissive parsing * is the documented contract. */ export declare const EnvBooleanSchema: z.ZodPipe, z.ZodTransform>; /** * Numeric env-var parser. * * Accepts any string that coerces to a finite JS number. Non-finite values * (empty string, `"abc"`, `"NaN"`, `"Infinity"` treated as non-finite) fall * back to undefined so callers can apply config-file / hard-coded defaults * instead of silently using a poisoned value. */ export declare const EnvNumberSchema: z.ZodPipe, z.ZodTransform>; /** * Factory for an integer env-var parser with an inclusive lower bound. * * Same fallback contract as {@link EnvNumberSchema} — unacceptable input * becomes undefined so the caller falls back to the config file / default — * but it additionally rejects non-integers and values below `min` instead of * leaving them for a resolver to clamp. Clamping is the wrong default when * the bound is load-bearing: `CODEX_AUTH_CREDENTIAL_SNAPSHOTS_MAX_COUNT=-5` * floored to `0` would mean "keep every snapshot", the unbounded-growth case * the bound exists to rule out. */ export declare function makeEnvIntegerSchema(min: number): z.ZodPipe, z.ZodTransform>, z.ZodTransform>; /** * Factory for a string-enum env-var parser. * * Produces a Zod schema that trims+lower-cases the raw env value and accepts * it only when it is a member of `allowed`. Any other value becomes * undefined so the caller falls back to the config file / default. */ export declare function makeEnvEnumSchema(allowed: ReadonlySet | readonly T[]): z.ZodPipe, z.ZodTransform | undefined, string | undefined>>; export declare const AccountIdOverrideSchema: z.ZodPipe, z.ZodTransform>; /** * Parse an env-var value through the account-id override schema. * Returns `undefined` on any validation failure. */ export declare function parseAccountIdOverride(value: string | undefined): string | undefined; //# sourceMappingURL=schemas.d.ts.map