import { Disposable } from "../../../../../../base/common/lifecycle.js"; import { IObservable } from "../../../../../../base/common/observable.js"; import { IAgentConnection } from "../../../../../../platform/agentHost/common/agentService.js"; import { type ILocalModelConsent, type ILocalModelFamilyV1, type ILocalModelLoadV1, type ILocalModelOfferV1, type ILocalModelStatusV1 } from "../../../../../../platform/agentHost/common/localModel.js"; import { ICommandService } from "../../../../../../platform/commands/common/commands.service.js"; import { IConfigurationService } from "../../../../../../platform/configuration/common/configuration.service.js"; import { IContextKeyService } from "../../../../../../platform/contextkey/common/contextkey.service.js"; import { IDialogService } from "../../../../../../platform/dialogs/common/dialogs.service.js"; import { ITelemetryService } from "../../../../../../platform/telemetry/common/telemetry.service.js"; import { ILocalModelInteractionHandler } from "../../../../../services/agentHost/common/localModelService.js"; /** Opens the most relevant chat input's model picker on the On This Device tab, at the detail page of the family given as the only argument. */ export declare const LOCAL_MODEL_SHOW_DETAILS_COMMAND_ID = "workbench.action.chat.localModel.showDetails"; /** Whether any on-device model UI may show: the opt-in setting is on and AI features are enabled; each surface adds its own conditions. */ export declare function observeLocalModelUiEnabled(configurationService: IConfigurationService, contextKeyService: IContextKeyService): IObservable; /** Opens the Settings editor at `chat.copilot.localModel.llamaServerPath`. */ export declare function openLocalModelServerPathSetting(commandService: ICommandService): Promise; export type LocalModelFlowStep = "consentShown" | "consentAccepted" | "consentCancelled" | "readyOfferShown" | "readyOfferAction"; /** What setup acquires: the model is downloaded (`modelOnly`), or its files on this device are used (`none`). */ export type LocalModelEntryPath = "modelOnly" | "none"; export type LocalModelReadyOfferAction = "useWithAuto" | "newAutoChat" | "switchDirect" | "useAuto" | "notNow"; export type LocalModelCurrentModelKind = "auto" | "server" | "other"; /** The `localModel.flow` event. Fields that don't apply to a step are omitted. */ export interface ILocalModelFlowEvent { readonly step: LocalModelFlowStep; readonly entryPath?: LocalModelEntryPath; readonly action?: LocalModelReadyOfferAction; readonly currentModelKind?: LocalModelCurrentModelKind; } /** Logs one `localModel.flow` event. */ export declare function logLocalModelFlow(telemetryService: ITelemetryService, event: ILocalModelFlowEvent): void; /** Formats a size the way the picker and dialogs show it, e.g. "56.7 GB". */ export declare function formatLocalModelBytes(bytes: number): string; /** Formats a remaining duration, e.g. "35 min" or "2 hr 5 min". */ export declare function formatLocalModelDuration(ms: number): string; /** The load of `family`'s model, while it is the active model and its server starts. */ export declare function getLocalModelLoad(status: Pick, family: Pick): ILocalModelLoadV1 | undefined; /** The step of a load that its text and announcements follow: `loading`, `warmingUp`, or a retry's reason through both steps, so it is said once. */ export declare function getLocalModelLoadStepKey(load: ILocalModelLoadV1): string; /** Whether `family`'s running swap reloads its own model, e.g. for a new context size. */ export declare function isLocalModelReload(status: Pick, family: Pick): boolean; /** The number of responses a drain of `family`'s operation waits for, or `undefined` when none run (the model is then unloading, as part of loading the next). */ export declare function getLocalModelDrainingStreams(status: Pick, family: Pick): number | undefined; /** How far a model load is, estimated from the last comparable load. */ export interface ILocalModelLoadProgress { /** At most 95 until the model is ready; `undefined` for a first load, which has no estimate. */ readonly percent: number | undefined; /** E.g. "20 s" or "2 min", counting down a second at a time under a minute, while the estimate hasn't run out. */ readonly remaining: string | undefined; /** The load takes longer than the last comparable one: it reads as almost done while the bar holds. */ readonly overdue: boolean; } /** The estimated progress of `load` at `now` against the last comparable load's duration, capped at 95% until the model is ready. */ export declare function getLocalModelLoadProgress(load: ILocalModelLoadV1, now: number): ILocalModelLoadProgress; /** * Runs `tick` at each whole second of the estimated load's time remaining, however late a timer fires; stops once the * estimate runs out, there is no estimated load, or when disposed. */ export declare class LocalModelLoadTicker extends Disposable { private readonly _getLoad; private readonly _tick; private readonly _timer; constructor(_getLoad: () => ILocalModelLoadV1 | undefined, _tick: () => void); private _schedule; } /** What a consent button on a model's detail page means: agreeing to download (or set up) the model. */ export type LocalModelConsentChoice = "accept"; /** A license the user can open; only a plain public `https:` URL. */ export interface ILocalModelLicenseLink { readonly name: string; readonly url: string; } /** The download consent a model's detail page shows, built purely from status; it covers only the model (llama.cpp is asked for only to load it). */ export interface ILocalModelSetUpConsent { /** `notEnoughDisk` explains why the download can't start; only `consent` leads to a request. */ readonly kind: "consent" | "notEnoughDisk"; readonly title: string; /** One paragraph each. */ readonly details: readonly string[]; readonly license?: ILocalModelLicenseLink; /** The first is the primary button. */ readonly buttons: readonly { readonly label: string; readonly choice: LocalModelConsentChoice; }[]; readonly entryPath: LocalModelEntryPath; } /** The setup entry path (whether the model is downloaded or its files on this device are used), for telemetry. */ export declare function getLocalModelEntryPath(family: Pick): LocalModelEntryPath; /** The offer's license as a link, only for a plain public `https:` URL. */ export declare function getLocalModelLicenseLink(offer: ILocalModelOfferV1 | undefined): ILocalModelLicenseLink | undefined; /** * Builds the download consent of `family`'s detail page: what is downloaded or reused, from where, under which license, * fit and disk space; without a qualified llama.cpp it says loading needs one. Its buttons are the consent. */ export declare function buildLocalModelSetUpConsent(status: ILocalModelStatusV1, family: ILocalModelFamilyV1): ILocalModelSetUpConsent; /** What agreeing to the download consent sends. */ export interface ILocalModelSetUpAgreement { /** The consent over exactly the facts {@link buildLocalModelSetUpConsent} showed for the same status. */ readonly consent: ILocalModelConsent; /** The entry path agreed to, for telemetry. */ readonly entryPath: LocalModelEntryPath; } /** The consent for `family` as the page showed it, so the scope covers exactly what the user saw; the host compares it with its own projection. */ export declare function getLocalModelSetUpAgreement(family: ILocalModelFamilyV1): ILocalModelSetUpAgreement; /** The on-device model confirmations that stay dialogs: Stop Now and Remove. Loading another model needs none (the notice can cancel it); setup consent is given on the model's detail page. */ export declare class LocalModelSetupFlow implements ILocalModelInteractionHandler { private readonly _dialogService; constructor(_dialogService: IDialogService); confirmStopNow(_connection: IAgentConnection, status: ILocalModelStatusV1): Promise; confirmRemove(_connection: IAgentConnection, _status: ILocalModelStatusV1, family: ILocalModelFamilyV1): Promise; }