import type { Api, Model } from "@earendil-works/pi-ai/compat";
/**
 * Sanitizes outbound OpenAI-compatible request payloads for GitHub Copilot
 * Gemini models so their tool/function JSON Schemas survive translation to
 * Google's GenAI `FunctionDeclaration` schema.
 *
 * Why this exists
 * ---------------
 * `github-copilot` Gemini models (e.g. `gemini-3.1-pro-preview`) are served
 * through Copilot's CAPI gateway at `api.*.githubcopilot.com` using the
 * `openai-completions` API. CAPI receives the OpenAI chat-completions request
 * and translates it into a Google GenAI `GenerateContent` request. During that
 * translation CAPI forwards JSON Schema `anyOf`/`oneOf` verbatim into the Gemini
 * `FunctionDeclaration` schema. Gemini's function-declaration schema rejects an
 * `anyOf`/`oneOf` whose branch is a complex *object* schema, so Google returns
 * HTTP 400 and CAPI relabels it `{"error":{"code":"invalid_request_body"}}`.
 *
 * Atomic's bundled tools (notably the `workflow` tool) use the TypeBox
 * `Type.Union([Type.Object(...), Type.String()])` pattern for fields like
 * `task`, `chain`, and `parallel`, which emit exactly that construct. Because
 * those tools are present in normal chat turns, every Gemini request fails with
 * `400 invalid request body` until the schema is sanitized.
 *
 * What it does
 * ------------
 * Recursively rewrites each tool's `parameters` JSON Schema into the reduced
 * subset that CAPI/Gemini actually honors (`type`, `description`, `enum`,
 * `properties`, `required`, `items`, `nullable`, and scalar-only `anyOf`):
 *  - Resolves `anyOf`/`oneOf` that contain an object/array branch to the most
 *    expressive object/array branch (the core fix), preserving `description`
 *    and collapsing a `"null"` branch into `nullable: true`.
 *  - Converts `const` (and `anyOf` of `const`/`enum` scalars) into `enum`,
 *    which Gemini supports, so `Type.Literal(...)` unions keep their constraint.
 *  - Drops JSON Schema keywords CAPI strips or Gemini rejects (`$schema`,
 *    `$ref`, `$defs`, `patternProperties`, `additionalProperties`, `allOf`,
 *    `not`, `format`, `pattern`, numeric/length bounds, `default`, etc.).
 *  - Filters `required` down to keys still present under `properties`.
 *
 * The transform is gated to GitHub Copilot Gemini models only, so it never
 * changes payloads for any currently-working provider/model.
 */
type JsonObject = {
    [key: string]: JsonValue;
};
type JsonValue = string | number | boolean | null | JsonValue[] | JsonObject;
/**
 * Keywords that are dropped because CAPI strips them before Google and/or
 * Gemini's function schema rejects them. Listing them explicitly keeps the
 * intent auditable; any keyword not in {@link KEPT_SCHEMA_KEYWORDS} and not a
 * union keyword is dropped regardless. Exported so the documented drop-list has
 * a real consumer (and stays linted) without a per-iteration `void` reference.
 */
export declare const DROPPED_SCHEMA_KEYWORDS: Set<string>;
/**
 * Whether this model is a GitHub Copilot Gemini model routed through the
 * OpenAI-completions CAPI path that needs schema sanitization.
 */
export declare function isCopilotGeminiModel(model: Pick<Model<Api>, "provider" | "api" | "id">): boolean;
/**
 * Recursively rewrite a JSON Schema node into the Gemini-compatible subset.
 */
export declare function sanitizeGeminiSchema(schema: JsonValue): JsonValue;
/**
 * Sanitize an outbound provider payload for GitHub Copilot Gemini models.
 *
 * Returns the payload unchanged for any other provider/model, or when the
 * payload has no sanitizable `tools`. Mirrors the `onPayload`
 * `(payload: unknown) => unknown` contract used elsewhere in the SDK wiring.
 */
export declare function sanitizeCopilotGeminiPayload(payload: unknown, model: Pick<Model<Api>, "provider" | "api" | "id">): unknown;
export {};
//# sourceMappingURL=copilot-gemini-payload-sanitizer.d.ts.map