import { CancellationToken } from "../../../../../../base/common/cancellation.js"; import { ResolveSessionConfigResult } from "../../../../../../platform/agentHost/common/state/protocol/commands.js"; import { Event, URI } from "../../../../../../sessions/sessions.web.main.internal.js"; export declare const IAgentHostUntitledProvisionalSessionService: import("../../../../../../platform/instantiation/common/instantiation.js").ServiceIdentifier; /** * LM contract: maintain one backend provisional session per untitled chat UI * resource, and bridge it to the real chat UI resource before the first agent * invocation. The contract is about backend `SessionState.config.values`, not * UI rendering state. */ export interface IAgentHostUntitledProvisionalSessionService { readonly _serviceBrand: undefined; /** * Fires for the chat UI resource whose backend provisional mapping changed. * Picker listeners must re-read {@link get} and attach to the returned * backend URI, if any. */ readonly onDidChange: Event; /** * Read the backend provisional URI currently mapped from `sessionResource`. * Returns `undefined` for resources that have not been provisioned or were * already disposed/rebound away. */ get(sessionResource: URI): URI | undefined; /** Working directories used to create the current provisional generation. */ getProvisionalWorkingDirectories(sessionResource: URI): readonly URI[] | undefined; /** * Initial config the editor window applies to every new Agent Host session. * Returns `undefined` in the Agents window, where the sessions provider owns * the initial config supplied on the request. */ getInitialSessionConfig(): Record | undefined; /** Initial session metadata, including any metadata registered for the resource. */ getInitialSessionMetadata(sessionResource?: URI): Record | undefined; /** Associates creation metadata with a real chat resource until the backend session is created. */ setSessionCreationMetadata(sessionResource: URI, metadata: Record): void; /** Drops creation metadata after the backend session has been created or abandoned. */ clearSessionCreationMetadata(sessionResource: URI): void; /** * Ensure a backend provisional exists for an untitled chat UI resource. * Multiple picker chips may call this concurrently; implementation must keep * one create in flight per resource and return the same backend URI. */ getOrCreate(sessionResource: URI, provider: string, workingDirectory: URI | undefined): Promise; /** * Wait for a pending {@link getOrCreate} for `sessionResource`, then return * the current mapping. Use this before reading/discarding a resource that may * still be racing with picker-triggered provisional creation. */ waitForPending(sessionResource: URI): Promise; /** * Apply a partial config change to the backend provisional for an untitled * chat UI resource. Updates the workbench-owned config cache synchronously * (so a subsequent {@link tryRebind} sees the latest values without a * server roundtrip), creates the provisional if needed, then dispatches * `SessionConfigChanged` on the backend so the agent and other clients * pick up the change. Returns the backend URI on success. */ applyConfigChange(sessionResource: URI, provider: string, workingDirectory: URI | undefined, partial: Record): Promise; /** * Graduates a draft onto its real UI resource, retaining a backend with matching immutable inputs. * Synchronizes the workbench-owned config before invocation; no-ops without a draft or when already bound. */ tryRebind(oldSessionResource: URI, newSessionResource: URI, provider: string, token?: CancellationToken): Promise; /** * Forgets the mapping, deleting its backend only while this service still owns the draft. */ disposeSession(sessionResource: URI): Promise; /** Relinquishes provisional ownership of a materialized session without deleting its backend. */ releaseSession(sessionResource: URI): void; /** * Latest workbench-side re-resolved config (schema + values) for a chat * session, if any. Populated after a value change so dependent properties * refresh without a protocol-level schema-update channel. * * Both the schema and the values matter: `resolveSessionConfig` runs * `validateOrDefault`, which can clamp now-invalid values or inject * derived defaults the consumer should prefer over `state.config.values`. */ getResolvedConfig(sessionResource: URI): ResolveSessionConfigResult | undefined; /** * Re-resolve config on an already-created session's owning host and cache * its schema/values overlay until the connection or session identity changes. */ refreshResolvedConfig(sessionResource: URI, provider: string, workingDirectory: URI | undefined, config: Record | undefined): Promise; }