import { URI } from "../../../../../../base/common/uri.js"; import { IConfigurationService } from "../../../../../../platform/configuration/common/configuration.service.js"; import { IWorkspaceContextService } from "../../../../../../platform/workspace/common/workspace.service.js"; import { type IAgentConnection } from "../../../../../../platform/agentHost/common/agentService.js"; import { IAgentHostService } from "../../../../../../platform/agentHost/common/agentService.service.js"; import { IAgentHostConnectionsService } from "../../../../../../platform/agentHost/common/agentHostConnectionsService.service.js"; import { type ChatConfigState, type ChatState, type RootState, type SessionConfigState, type SessionState } from "../../../../../../platform/agentHost/common/state/sessionState.js"; import { ResolveSessionConfigResult } from "../../../../../../platform/agentHost/common/state/protocol/commands.js"; import { type ISessionSandboxState } from "../../../../../../platform/agentHost/common/meta/agentSandboxStateMeta.js"; import { IAgentHostSessionWorkingDirectoryResolver } from "./agentHostSessionWorkingDirectoryResolver.service.js"; import { IAgentHostUntitledProvisionalSessionService } from "./agentHostUntitledProvisionalSessionService.service.js"; /** * Services needed to apply a session-config change to an agent-host-backed chat * session from the editor window. */ export interface IApplyAgentHostSessionConfigServices { readonly agentHostService: IAgentHostService; readonly connectionsService: IAgentHostConnectionsService; readonly provisionalService: IAgentHostUntitledProvisionalSessionService; readonly workingDirectoryResolver: IAgentHostSessionWorkingDirectoryResolver; readonly workspaceContextService: IWorkspaceContextService; readonly configurationService: IConfigurationService; } /** * The backend chat `sessionResource` names, from its session's chat catalog: the * session's default chat, or the peer chat its fragment names. */ export declare function getAgentHostBackendChat(sessionResource: URI, state: SessionState): string | undefined; /** * The backend chats whose config applies to `backendChat`: the chat and, for a * subagent (which has no config of its own), the chats that spawned it, as * recorded in its session's chat catalog. */ export declare function getAgentHostChatConfigChain(state: SessionState, backendChat: string | undefined): readonly string[]; /** * The agent provider backing `backendChat` when it differs from its session's * (a chat on its session's agent reads `undefined`). */ export declare function getAgentHostChatOwnAgent(state: SessionState, backendChat: string | undefined): string | undefined; /** * Whether the host publishes each chat's complete config values: only while its * chats may use their own agents (root `multipleChatProviders.enabled`). Older * hosts, and hosts with the setting off, publish the values a chat set itself, as * an overlay on its session's. The host must also declare the key in its root * schema: an older host keeps the value this client mirrors to it without * supporting the feature. */ export declare function hostPublishesCompleteChatConfig(rootState: RootState | Error | undefined): boolean; /** * A chat's effective config (see {@link getEffectiveChatConfig}), read as its * host publishes it: complete values, or an overlay on its session's (see * {@link hostPublishesCompleteChatConfig}). */ export declare function getAgentHostEffectiveChatConfig(session: SessionConfigState, chat: ChatConfigState | undefined, completeValues: boolean): SessionConfigState; /** * A chat's effective config (see {@link getAgentHostEffectiveChatConfig}), from * the config of the chat or, for a subagent, of the chat that spawned it. * `readChat` supplies each chat's state. * * A chat whose agent differs from its session's has its own schema in its * state and never uses the session's config: until its state is known it has * none. */ export declare function getAgentHostChatConfig(state: SessionState, backendChat: string | undefined, readChat: (chat: string) => ChatState | Error | undefined, completeValues: boolean): SessionConfigState | undefined; /** * The sandbox state the host applied for a chat (a subagent runs in the * runtime of the chat that spawned it), or for its session when it reports * none for the chat. */ export declare function readAgentHostChatSandboxState(state: SessionState, backendChat: string | undefined): ISessionSandboxState | undefined; /** * Whether the host behind `rootState` applies a session config write to its session's default chat, replacing the * value the default chat set itself: only while its chats may use their own agents. Otherwise, as on older hosts, the * default chat's own value overrides the session's, so a client writes the default chat itself. */ export declare function hostAppliesSessionConfigToDefaultChat(rootState: RootState | Error | undefined): boolean; /** * Sends a config change for a chat: the properties the session's schema lets a * chat set go to the chat (for a subagent, to its nearest spawning chat that is * not one, as the host does), everything else to its session, in that order. * The session's config is its default chat's: on a host that applies session * writes to its default chat (see {@link hostAppliesSessionConfigToDefaultChat}), * a property the session may set too is written to the session for that chat; * an older host gets it on the default chat, as before. * * A patch with both kinds becomes two actions, which the host applies or * rejects independently; each is reconciled on its own echo. That is safe * because the two halves are different properties with no write-time * dependency between them (validation of either reads only the effective * values already applied), and pickers send one property at a time. */ export declare function dispatchAgentHostConfigChange(connection: Pick, backendSession: URI, backendChat: string | undefined, state: SessionState | undefined, partial: Record, chatConfig?: SessionConfigState): void; /** The effective config of the chat `sessionResource` names. */ export declare function getAgentHostSessionConfig(sessionResource: URI, provisionalService: IAgentHostUntitledProvisionalSessionService, connectionsService: IAgentHostConnectionsService): ResolveSessionConfigResult | undefined; /** * Applies a partial session-config change (e.g. `autoApprove` and/or `mode`) to * the agent-host session backing `sessionResource` in the editor window. This is * the editor-window analogue of the Agents-window provider `setSessionConfigValue` * path — it routes untitled sessions through the provisional service, and existing * sessions through `chat/configChanged` for the properties the chat may set for * itself and `session/configChanged` for the rest, matching how the agent-host * chat-input pickers apply changes. * * An elevated `autoApprove` value is clamped back to `default` when enterprise * policy disables global auto-approval, mirroring the pickers. * * @returns `true` when `sessionResource` is agent-host-backed and the change was * dispatched, `false` otherwise (so callers can fall back). */ export declare function applyAgentHostSessionConfigChange(sessionResource: URI, config: Readonly>, services: IApplyAgentHostSessionConfigServices): Promise;