import { Disposable } from "../../../../../../base/common/lifecycle.js"; import { type IExtUri } from "../../../../../../base/common/resources.js"; import { URI } from "../../../../../../base/common/uri.js"; import { IUriIdentityService } from "../../../../../../platform/uriIdentity/common/uriIdentity.service.js"; import { IWorkspaceContextService } from "../../../../../../platform/workspace/common/workspace.service.js"; import { RootState, type ISessionFolderPickerDecision } from "../../../../../../platform/agentHost/common/state/sessionState.js"; import { IChatService } from "../../../common/chatService/chatService.service.js"; import { IAgentHostNewSessionFolderService } from "./agentHostNewSessionFolderService.service.js"; /** * Computes the ordered working-directory set for a new agent-host session: * `[primary, …otherWorkspaceFolders]`, with the primary at index 0. The other * workspace folders are included only when the primary is itself a workspace * folder and `provider` advertises the `multipleWorkingDirectories` capability * in `rootState`; otherwise (single-folder workspace, a standalone primary, * unadvertised capability, or an unavailable root state) just `[primary]` is * returned. Support is opt-in per the {@link AgentCapabilities} convention, and * the node-side guard remains the authoritative backstop. Returns `undefined` * when no primary was chosen. */ export declare function computeWorkingDirectories(primary: URI | undefined, workspaceFolders: readonly URI[], rootState: RootState | Error | undefined, provider: string): readonly URI[] | undefined; export declare function supportsMultipleWorkingDirectories(rootState: RootState | Error | undefined, provider: string): boolean; /** * Whether `provider` pins its first working directory as a fixed process root * (`multipleWorkingDirectories.immutablePrimary`). Agents without it treat every * working directory as an equal peer. */ export declare function hasImmutablePrimaryWorkingDirectory(rootState: RootState | Error | undefined, provider: string): boolean; /** * The change a chat widget should apply to the multi-root Folder picker for the * harness-owned {@link ISessionFolderPickerDecision}. `noop` means retain the * current state (used when a decision transiently disappears during provisional * recreation of the *same* session, so the chip does not flash); `apply` carries * the new visibility value (the picker is hidden by default and only revealed * when the decision says so), the session resource now being tracked, and — only * when the harness pins a primary the user hasn't overridden — the folder to * auto-select. */ export type FolderPickerDecisionUpdate = { readonly kind: "noop"; } | { readonly kind: "apply"; readonly visible: boolean; readonly trackedSessionResource: URI | undefined; readonly selectPrimary: URI | undefined; }; /** * Pure resolution of {@link FolderPickerDecisionUpdate} from a widget's current * inputs. Extracted from the widget so the hidden-by-default reveal, tri-state * retain, auto-select gating, after-start suppression, and Agents-window gate are * unit-testable without a live chat widget. * * The picker is hidden until a decision affirmatively reveals it (a decision with * `hidden: false`), so it never flashes visible-then-hidden while the decision is * still resolving. * * @param sessionResource the widget's current session, or `undefined`. * @param agentHostProviderId the locked Agent Host provider, or `undefined` for a non-Agent-Host widget. * @param decision the harness decision for `sessionResource`, or `undefined` when not (yet) known. * @param previousTrackedSessionResource the session the current visibility value reflects. * @param isSessionsWindow whether the widget lives in the Agents window (which owns folder choice). * @param sessionIsEmpty whether the session has no requests yet (its working directory isn't fixed). * @param currentSelectedFolder the folder already chosen for `sessionResource`, if any. * @param folderExtUri provider-aware comparator (from `IUriIdentityService.extUri`) used to * decide whether the pinned primary is already selected, so casing is honored per the folder's * actual filesystem instead of assumed. */ export declare function resolveFolderPickerDecisionUpdate(sessionResource: URI | undefined, agentHostProviderId: string | undefined, decision: ISessionFolderPickerDecision | undefined, previousTrackedSessionResource: URI | undefined, isSessionsWindow: boolean, sessionIsEmpty: boolean, currentSelectedFolder: URI | undefined, folderExtUri: IExtUri): FolderPickerDecisionUpdate; /** * Computes the working-directory set a session should have for the current * workspace, as `[primary, ...secondaries]`. * * A secondary is kept only while it remains a workspace folder, so folders the * user removed drop out. Folders the user added are appended. The primary is * never dropped, even when it is no longer a workspace folder — an agent's * process root is fixed once the session starts. * * Ordering is stable rather than meaningful: retained secondaries keep their * existing order and newly added folders follow workspace order, so an * unchanged workspace always recomputes an identical set. */ export declare function computeDesiredWorkingDirectories(primary: URI, currentWorkingDirectories: readonly URI[], workspaceFolders: readonly URI[], extUri?: IExtUri): readonly URI[]; export declare class AgentHostNewSessionFolderService extends Disposable implements IAgentHostNewSessionFolderService { private readonly _workspaceContextService; private readonly _uriIdentityService; readonly _serviceBrand: undefined; private readonly _folders; /** * The most recently chosen folder in this window. Window-level "sticky" * default that, unlike {@link _folders}, is not cleared on session * disposal so a new chat can default to the user's last folder choice. */ private _defaultFolder; private readonly _onDidChangeFolder; readonly onDidChangeFolder: import("../../../../../../base/common/event.js").Event; constructor(chatService: IChatService, _workspaceContextService: IWorkspaceContextService, _uriIdentityService: IUriIdentityService); getFolder(sessionResource: URI): URI | undefined; setFolder(sessionResource: URI, folder: URI): void; clear(sessionResource: URI): void; getDefaultFolder(): URI | undefined; resolveNewSessionPrimary(sessionResource: URI): URI | undefined; }