/** Opt-in for on-device models. Startup key: toggling it restarts the Copilot client. */ export declare const LocalModelEnabledSettingId = "chat.copilot.localModel.enabled"; /** Whether Auto may route turns to the active on-device model. Read live at dispatch. Off unless the user turns it on. */ export declare const LocalModelUseInAutoSettingId = "chat.copilot.localModel.useInAuto"; /** The agreed safety disclosure for on-device models (the Copilot CLI and app show the same text), shown wherever the user opts in. */ export declare function getLocalModelSafetyDisclosure(): string; /** Absolute path to the user's `llama-server`, the only one VS Code runs. Explicit: probe failures are shown, never bypassed. */ export declare const LocalModelLlamaServerPathSettingId = "chat.copilot.localModel.llamaServerPath"; /** * Root config key the client writes an {@link ILocalModelRequest} to. The host claims the request's nonce and clears the * key before acting, so a repeated identical gesture still lands. The settings themselves are forwarded as the * `CopilotCliConfigKey.LocalModel*` root config keys. */ export declare const LOCAL_MODEL_REQUEST_KEY = "vscode.localModel.request"; /** Root transient value carrying the host's {@link ILocalModelStatusV1}. Absent when the host has no provider. */ export declare const LOCAL_MODEL_STATUS_KEY = "vscode.localModel.status"; /** Namespaced `_meta` key on turn usage ({@link ILocalTurnExecution}) and on direct-selection model rows ({@link ILocalModelRowMetaV1}). */ export declare const LOCAL_MODEL_META_KEY = "vscode.localModel"; /** Name of the sentinel BYOK provider whose rows select an on-device model; generic session code strips it from the additive BYOK merge so its rows stay replaceable. */ export declare const LOCAL_MODEL_SENTINEL_PROVIDER_NAME = "vscode-on-device"; /** Placeholder for the GPU memory figure in the setting description until the shipping model's requirement is known. */ export declare const LOCAL_MODEL_MIN_GPU_MEMORY_GB_PLACEHOLDER = 64; export declare const localModelDeviceConfidences: readonly [ "measured", "estimated", "unknown" ]; export type LocalModelDeviceConfidence = typeof localModelDeviceConfidences[number]; /** * The GPU vendor of the device the host judges models against, from its PCI * vendor id (`nvidia` 0x10DE, `amd` 0x1002/0x1022, `intel` 0x8086, `apple` * 0x106B, `qualcomm`; anything else `other`). */ export declare const localModelDeviceVendors: readonly [ "nvidia", "amd", "intel", "apple", "qualcomm", "other" ]; export type LocalModelDeviceVendor = typeof localModelDeviceVendors[number]; export declare const localModelCatalogStates: readonly [ "loading", "ready", "empty", "unavailable" ]; export type LocalModelCatalogState = typeof localModelCatalogStates[number]; /** The state of the Azure ML registry query behind the catalog. */ export declare const localModelPublicRegistryStates: readonly [ "loading", "ready", "empty", "unavailable" ]; export type LocalModelPublicRegistryState = typeof localModelPublicRegistryStates[number]; export declare const localModelFitClasses: readonly [ "full", "near" ]; export type LocalModelFitClass = typeof localModelFitClasses[number]; export declare const localModelServerStates: readonly [ "stopped", "starting", "ready", "stopping", "error" ]; export type LocalModelServerState = typeof localModelServerStates[number]; export declare const localModelServingProfiles: readonly [ "full-gpu", "near-fit" ]; export type LocalModelServingProfile = typeof localModelServingProfiles[number]; export declare const localModelOperationKinds: readonly [ "setup", "update", "remove", "swap" ]; export type LocalModelOperationKind = typeof localModelOperationKinds[number]; export declare const localModelOperationStates: readonly [ "running", "paused", "error" ]; export type LocalModelOperationState = typeof localModelOperationStates[number]; /** `consentChanged`: the resolved content or consent scope changed while paused, so the user must agree again. */ export declare const localModelPausedReasons: readonly [ "user", "quit", "diskFull", "network", "consentChanged" ]; export type LocalModelPausedReason = typeof localModelPausedReasons[number]; export declare const localModelOperationPhases: readonly [ "resolving", "checkingDevice", "downloading", "verifying", "placing", "draining", "loading" ]; export type LocalModelOperationPhase = typeof localModelOperationPhases[number]; /** `getLlamaCpp` opens the page on getting a llama.cpp build; `openSettings` opens `chat.copilot.localModel.llamaServerPath`. */ export declare const localModelErrorActions: readonly [ "retry", "stopPrevious", "openSettings", "getLlamaCpp" ]; export type LocalModelErrorAction = typeof localModelErrorActions[number]; /** A user-facing failure; `message` is localized by the host. `code` stays an open string so a newer host's codes reach older clients, which show `message`. */ export interface ILocalModelErrorV1 { readonly code: string; readonly message: string; readonly actions: readonly LocalModelErrorAction[]; } /** Static capability of the selected GPU device. Dynamic availability is never published. */ export interface ILocalModelDeviceV1 { readonly id?: string; readonly capacityBytes?: number; readonly confidence: LocalModelDeviceConfidence; /** The vendor of the GPU the device probe selected; absent when it found none. Families are listed only for an `nvidia` device. */ readonly vendor?: LocalModelDeviceVendor; } /** The llama.cpp runtime: the `llama-server` of `chat.copilot.localModel.llamaServerPath`, which VS Code never installs; empty until one qualifies. */ export interface ILocalModelRuntimeV1 { /** Version string as reported by `llama-server --version`; present exactly when the setting's `llama-server` qualified. */ readonly version?: string; /** GPU backend the probe found (for example `vulkan` or `metal`). */ readonly backend?: string; } export interface ILocalModelCatalogV1 { readonly state: LocalModelCatalogState; readonly registries: { readonly azureml: LocalModelPublicRegistryState; }; } /** What can be downloaded now from the Azure ML registry. */ export interface ILocalModelOfferV1 { readonly fit: LocalModelFitClass; readonly requiredGpuBytes: number; readonly downloadBytes: number; readonly peakDiskBytes: number; readonly licenseName?: string; /** Public `https:` URL only. */ readonly licenseUrl?: string; } /** * A completed install: files verified, manifest recorded, servable. Files on disk that aren't set up yet are reported * through {@link ILocalModelFamilyV1.entry} instead, so `requiresSetup` never reads as `installed`. */ export interface ILocalModelInstallV1 { readonly contentId: string; readonly adopted: boolean; readonly owned: boolean; /** * Selection id of this family's direct-selection model row: `vscode-on-device/`, the alias being the * `llama-server` `--alias`. Clients match the model row's `id` against it; never build these strings themselves. */ readonly modelId: string; /** A newer build of the same model. */ readonly update?: { readonly contentId: string; readonly downloadBytes: number; }; } /** At most one operation per family. */ export interface ILocalModelOperationV1 { readonly id: string; readonly kind: LocalModelOperationKind; readonly state: LocalModelOperationState; readonly pausedReason?: LocalModelPausedReason; readonly resumeOnStartup: boolean; readonly phase?: LocalModelOperationPhase; readonly completedBytes?: number; readonly totalBytes?: number; readonly bytesPerSecond?: number; readonly error?: ILocalModelErrorV1; } /** What is already on this device for a family not installed yet; drives the setup entry paths and consent text. Setup never needs llama.cpp. */ export interface ILocalModelEntryV1 { /** The model files are already on this device (VS Code-owned, or adoptable from the Copilot CLI/app). */ readonly modelFilesPresent: boolean; /** Disk preflight for setup when the status was published; `volume` is the target volume's display name. The host re-checks before acting. */ readonly disk?: { readonly volume: string; readonly availableBytes: number; readonly requiredBytes: number; }; } /** One selectable context size of an installed family. */ export interface ILocalModelContextOptionV1 { readonly tokens: number; /** Estimated GPU memory of the whole model served at this size (weights + draft + KV + fixed buffers). */ readonly gpuBytes: number; } /** Present on installed families. */ export interface ILocalModelContextV1 { /** The selected size; the next/current load uses it. Normally one of {@link options}. */ readonly tokens: number; /** Ascending by {@link ILocalModelContextOptionV1.tokens}; a `setContextSize` request must name one of them. */ readonly options: readonly ILocalModelContextOptionV1[]; } /** Present on {@link ILocalModelActiveV1} while `server === 'starting'`. */ export interface ILocalModelLoadV1 { /** `loading`: the server was spawned and loads the model (`/health` answers 503); `warmingUp`: it is healthy and serves the warm-up request. */ readonly step: "loading" | "warmingUp"; /** Epoch ms when this load started (host and client share the machine). */ readonly startedAt: number; /** Duration of the last comparable load (same contentId, context size and device), when known. */ readonly expectedMs?: number; /** Present when this attempt retries a start that failed, e.g. without the DFlash draft after speculative decoding crashed this llama.cpp build. */ readonly retry?: LocalModelLoadRetryReason; } /** The steps of {@link ILocalModelLoadV1}. */ export declare const localModelLoadSteps: readonly [ "loading", "warmingUp" ]; /** Why this load attempt is a retry of a failed one. */ export declare const localModelLoadRetryReasons: readonly [ "withoutSpeculativeDecoding" ]; export type LocalModelLoadRetryReason = typeof localModelLoadRetryReasons[number]; /** Present on a family only when the device's total GPU memory can't hold it at its selected context. */ export interface ILocalModelMemoryWarningV1 { readonly requiredBytes: number; readonly capacityBytes: number; } /** Per-family usage accounting, used in confirmation text. */ export interface ILocalModelUsageV1 { /** Running responses: agent turns that used the loaded model and have not ended (also while they run a tool), plus requests of no such turn. */ readonly runningStreams: number; readonly boundDirectChats: number; readonly liveAutoRoutes: number; } export interface ILocalModelFamilyV1 { /** `capiId`, lowercased. */ readonly familyId: string; readonly capiId: string; /** `capiId` is a known Auto-admitted id; otherwise the family is direct-selection only. */ readonly autoCapable: boolean; /** `displayName` tag (or temporary override), already sanitized by the host. */ readonly displayName: string; /** Absent if not offerable (no longer fits, not in the catalog, ...). */ readonly offer?: ILocalModelOfferV1; /** Present when setup has completed. Always manageable, even without an offer. */ readonly install?: ILocalModelInstallV1; readonly operation?: ILocalModelOperationV1; /** Present while not installed: what setup would reuse from this device. */ readonly entry?: ILocalModelEntryV1; /** Present on installed families: the selected context size and the selectable ones. */ readonly context?: ILocalModelContextV1; /** Present only when the device's total GPU memory can't hold the family at its selected context. */ readonly memoryWarning?: ILocalModelMemoryWarningV1; readonly usage: ILocalModelUsageV1; /** `${familyId}:${contentId}` of the last install/update that reached ready; drives the one-time ready offer. */ readonly readyOfferId?: string; readonly consentGiven: boolean; } /** The single active model's serving state. */ export interface ILocalModelActiveV1 { readonly familyId: string; readonly contentId: string; readonly servingGeneration: number; readonly server: LocalModelServerState; readonly profile?: LocalModelServingProfile; readonly contextTokens?: number; /** Passed the Auto performance gate. */ readonly autoEligible?: boolean; /** Present when the preset uses a DFlash draft: whether it serves with speculative decoding (`false` once this build crashed with it). */ readonly dflashSupported?: boolean; /** Set while a user-initiated stop or swap waits for running responses; a turn that used the model keeps it until the turn ends. */ readonly drain?: { readonly runningStreams: number; }; /** Present while {@link server} is `starting`: the load's step and its expected duration. */ readonly load?: ILocalModelLoadV1; /** `familyId` being loaded next: another family while this one is still active, or this family again when it reloads (a new context size). */ readonly swapTo?: string; /** Present while {@link server} is `error` (crash, owned elsewhere, orphan, memory busy, ...). */ readonly error?: ILocalModelErrorV1; } /** Provider-neutral status projection. */ export interface ILocalModelStatusV1 { readonly schemaVersion: 1; readonly device: ILocalModelDeviceV1; readonly runtime: ILocalModelRuntimeV1; readonly catalog: ILocalModelCatalogV1; /** Offerable, installed or busy families, on an NVIDIA device only ({@link ILocalModelDeviceV1.vendor}); empty means nothing is shown. */ readonly families: readonly ILocalModelFamilyV1[]; /** Absent when no model is active. */ readonly active?: ILocalModelActiveV1; readonly useInAuto: boolean; } /** Readiness of one family, for the picker and context keys. */ export type LocalModelReadiness = "preparing" | "paused" | "error" | "ready" | "installed" | "requiresSetup"; /** * Derives a family's readiness, in order: a running, paused or failed operation gives `preparing`, `paused` or `error`; * an installed active family gives `error` or `ready` from its server; another install gives `installed`; an offer or * model files on this device give `requiresSetup`. `undefined` for a family that should not be listed. */ export declare function deriveLocalModelReadiness(family: ILocalModelFamilyV1, status: Pick): LocalModelReadiness | undefined; /** Actions a client may request. `setContextSize` on the active loaded family reloads it after running responses finish, reported as a `swap`. */ export declare const localModelActions: readonly [ "setUp", "cancel", "pause", "resume", "retry", "makeActive", "start", "stop", "stopNow", "update", "remove", "stopPrevious", "refreshCatalog", "setContextSize" ]; export type LocalModelAction = typeof localModelActions[number]; /** Actions that must carry {@link ILocalModelRequest.familyId}. */ export declare const localModelFamilyActions: readonly LocalModelAction[]; /** Actions that must carry {@link ILocalModelRequest.contextTokens}. */ export declare const localModelContextActions: readonly LocalModelAction[]; /** Actions that must carry {@link ILocalModelRequest.operationId}. */ export declare const localModelOperationActions: readonly LocalModelAction[]; /** Actions that must carry {@link ILocalModelRequest.consent}. */ export declare const localModelConsentActions: readonly LocalModelAction[]; /** What the user agreed to: a model download (`setUp`). */ export interface ILocalModelConsent { /** Fingerprint from {@link computeLocalModelConsentScope}; the host recomputes it before acting or resuming and pauses with `consentChanged` on a mismatch. */ readonly scope: string; } /** The value a client writes to {@link LOCAL_MODEL_REQUEST_KEY}. */ export interface ILocalModelRequest { /** Fresh per gesture; the host ignores nonces it has already seen. */ readonly nonce: string; readonly action: LocalModelAction; readonly familyId?: string; readonly operationId?: string; readonly consent?: ILocalModelConsent; /** `setContextSize`: the selected {@link ILocalModelContextOptionV1.tokens}. */ readonly contextTokens?: number; } /** Upper bound for a context size crossing the wire (16M tokens). */ export declare const MAX_LOCAL_MODEL_CONTEXT_TOKENS: number; /** A positive integer context size no larger than {@link MAX_LOCAL_MODEL_CONTEXT_TOKENS}. */ export declare function isLocalModelContextTokens(value: unknown): value is number; /** Validates an untrusted request value, including the targets each action requires. */ export declare function isLocalModelRequest(value: unknown): value is ILocalModelRequest; /** * Fingerprints exactly what a model download consent shows (the offer's sizes and license, and whether model files are * reused), excluding dynamic values. Shared by client and host, so both must call it on the same projection. */ export declare function computeLocalModelConsentScope({ family }: { readonly family: Pick; }): string; /** How one turn actually executed, persisted on turn usage under {@link LOCAL_MODEL_META_KEY}. */ export declare const localTurnExecutions: readonly [ "local", "fallback", "mixed", "unknown" ]; export type LocalTurnExecutionKind = typeof localTurnExecutions[number]; export interface ILocalTurnExecution { readonly execution: LocalTurnExecutionKind; /** Why the local model did not answer, e.g. `staleModel` or `slotsFull`. */ readonly fallbackReason?: string; /** The cloud model that answered instead. */ readonly fallbackModel?: string; /** The serving family, from the request's serving lease (never the current active model). */ readonly familyId?: string; } /** `_meta[LOCAL_MODEL_META_KEY]` on a direct-selection model row. */ export interface ILocalModelRowMetaV1 { readonly familyId: string; readonly contentId: string; readonly active: boolean; }