export type EditMode = "replace" | "patch" | "hashline" | "vim" | "apply_patch"; /** Setting value for `edit.mode`: an executable mode or `auto` (model-family routing). */ export type EditModeSetting = "auto" | EditMode; /** Fallback executable mode used when automatic routing cannot identify the model. */ export declare const DEFAULT_EDIT_MODE: EditMode; /** Default `edit.mode` setting value. */ export declare const DEFAULT_EDIT_MODE_SETTING: EditModeSetting; export declare const EDIT_MODES: EditMode[]; export declare const EDIT_MODE_SETTINGS: EditModeSetting[]; export declare function normalizeEditMode(mode?: string | null): EditMode | undefined; export type ModelEditFamily = "gpt" | "codex" | "claude" | "deepseek" | "qwen" | "minimax" | "glm" | "kimi" | "unknown"; /** * Detect the model family from a model ID, ignoring the provider prefix so * equivalent models served through different providers route identically * (`openai/gpt-5.4`, `openrouter/openai/gpt-5.4`, `company-gateway/gpt-5.4`). * * Matching only examines the final path segment. A direct family prefix or a * known provider-qualified family name is accepted, while arbitrary token * substrings return `unknown` instead of guessing. */ export declare function detectModelEditFamily(modelId: string | undefined): ModelEditFamily; /** Built-in mode for a detected family; `undefined` for `unknown`. */ export declare function builtinEditModeForFamily(family: ModelEditFamily): EditMode | undefined; export type EditModeSource = "environment" | "model-override" | "setting" | "catalog" | "builtin-family" | "fallback"; export type ResolvedEditModeDetails = { mode: EditMode; source: EditModeSource; modelId?: string; family?: ModelEditFamily; matchedRule?: string; }; /** Raw `edit.modelVariants` match: pattern plus the configured (unvalidated) value. */ export type EditVariantMatch = { pattern: string; value: string; }; export interface EditModeSettingsLike { get(key: "edit.mode"): unknown; /** Legacy accessor: first *valid* matching `edit.modelVariants` value. */ getEditVariantForModel?(model: string | undefined): EditMode | null; /** * Discriminated accessor: first matching `edit.modelVariants` rule with its * raw value. Lets the resolver fail closed on invalid matched values * instead of silently falling through to another mode. */ matchEditVariantForModel?(model: string | undefined): EditVariantMatch | null; } export interface EditModeSessionLike { settings: EditModeSettingsLike; getActiveModelString?: () => string | undefined; /** * Optional model-catalog edit recommendation; beats the built-in family * mapping when present. * * Extension point: production sessions do not wire this yet — the model * catalog does not expose an edit-protocol recommendation (`applyPatchToolType` * is the OpenAI wire representation of an already-selected `apply_patch` * mode, not a mode selector). Catalog metadata generation is deliberately * deferred until the family-based path is proven for arbitrary custom-provider * IDs; when it lands, sessions can expose this hook without a resolver change. */ getCatalogEditMode?: () => EditMode | undefined; } /** * Read the forced edit mode from `GJC_EDIT_VARIANT`/`PI_EDIT_VARIANT`. * The environment force is the emergency kill switch and beats every other * source. Invalid values fail fast; empty and `auto` mean "not forced". */ export declare function resolveForcedEnvEditMode(): EditMode | undefined; /** * Resolve the active edit mode with provenance. * * Precedence: * 1. `GJC_EDIT_VARIANT`/`PI_EDIT_VARIANT` environment force (invalid → throw). * 2. Matching user `edit.modelVariants` rule (matched invalid → throw). * 3. Explicit `edit.mode` setting when it is not `auto`. * 4. Model-catalog edit recommendation, when the session exposes one. * 5. Built-in model-family mapping. * 6. `hashline` fallback. */ export declare function resolveEditModeDetails(session: EditModeSessionLike): ResolvedEditModeDetails; export declare function resolveEditMode(session: EditModeSessionLike): EditMode;