/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import { z } from 'zod'; /** * Zod schema for validating a file context from the IDE. */ export declare const FileSchema: z.ZodObject<{ path: z.ZodString; timestamp: z.ZodNumber; isActive: z.ZodOptional; selectedText: z.ZodOptional; cursor: z.ZodOptional>; }, "strip", z.ZodTypeAny, { path: string; timestamp: number; isActive?: boolean | undefined; selectedText?: string | undefined; cursor?: { line: number; character: number; } | undefined; }, { path: string; timestamp: number; isActive?: boolean | undefined; selectedText?: string | undefined; cursor?: { line: number; character: number; } | undefined; }>; export type File = z.infer; export declare const IdeContextSchema: z.ZodObject<{ workspaceState: z.ZodOptional; selectedText: z.ZodOptional; cursor: z.ZodOptional>; }, "strip", z.ZodTypeAny, { path: string; timestamp: number; isActive?: boolean | undefined; selectedText?: string | undefined; cursor?: { line: number; character: number; } | undefined; }, { path: string; timestamp: number; isActive?: boolean | undefined; selectedText?: string | undefined; cursor?: { line: number; character: number; } | undefined; }>, "many">>; isTrusted: z.ZodOptional; }, "strip", z.ZodTypeAny, { openFiles?: { path: string; timestamp: number; isActive?: boolean | undefined; selectedText?: string | undefined; cursor?: { line: number; character: number; } | undefined; }[] | undefined; isTrusted?: boolean | undefined; }, { openFiles?: { path: string; timestamp: number; isActive?: boolean | undefined; selectedText?: string | undefined; cursor?: { line: number; character: number; } | undefined; }[] | undefined; isTrusted?: boolean | undefined; }>>; }, "strip", z.ZodTypeAny, { workspaceState?: { openFiles?: { path: string; timestamp: number; isActive?: boolean | undefined; selectedText?: string | undefined; cursor?: { line: number; character: number; } | undefined; }[] | undefined; isTrusted?: boolean | undefined; } | undefined; }, { workspaceState?: { openFiles?: { path: string; timestamp: number; isActive?: boolean | undefined; selectedText?: string | undefined; cursor?: { line: number; character: number; } | undefined; }[] | undefined; isTrusted?: boolean | undefined; } | undefined; }>; export type IdeContext = z.infer; /** * Zod schema for validating the 'ide/contextUpdate' notification from the IDE. */ export declare const IdeContextNotificationSchema: z.ZodObject<{ jsonrpc: z.ZodLiteral<"2.0">; method: z.ZodLiteral<"ide/contextUpdate">; params: z.ZodObject<{ workspaceState: z.ZodOptional; selectedText: z.ZodOptional; cursor: z.ZodOptional>; }, "strip", z.ZodTypeAny, { path: string; timestamp: number; isActive?: boolean | undefined; selectedText?: string | undefined; cursor?: { line: number; character: number; } | undefined; }, { path: string; timestamp: number; isActive?: boolean | undefined; selectedText?: string | undefined; cursor?: { line: number; character: number; } | undefined; }>, "many">>; isTrusted: z.ZodOptional; }, "strip", z.ZodTypeAny, { openFiles?: { path: string; timestamp: number; isActive?: boolean | undefined; selectedText?: string | undefined; cursor?: { line: number; character: number; } | undefined; }[] | undefined; isTrusted?: boolean | undefined; }, { openFiles?: { path: string; timestamp: number; isActive?: boolean | undefined; selectedText?: string | undefined; cursor?: { line: number; character: number; } | undefined; }[] | undefined; isTrusted?: boolean | undefined; }>>; }, "strip", z.ZodTypeAny, { workspaceState?: { openFiles?: { path: string; timestamp: number; isActive?: boolean | undefined; selectedText?: string | undefined; cursor?: { line: number; character: number; } | undefined; }[] | undefined; isTrusted?: boolean | undefined; } | undefined; }, { workspaceState?: { openFiles?: { path: string; timestamp: number; isActive?: boolean | undefined; selectedText?: string | undefined; cursor?: { line: number; character: number; } | undefined; }[] | undefined; isTrusted?: boolean | undefined; } | undefined; }>; }, "strip", z.ZodTypeAny, { params: { workspaceState?: { openFiles?: { path: string; timestamp: number; isActive?: boolean | undefined; selectedText?: string | undefined; cursor?: { line: number; character: number; } | undefined; }[] | undefined; isTrusted?: boolean | undefined; } | undefined; }; jsonrpc: "2.0"; method: "ide/contextUpdate"; }, { params: { workspaceState?: { openFiles?: { path: string; timestamp: number; isActive?: boolean | undefined; selectedText?: string | undefined; cursor?: { line: number; character: number; } | undefined; }[] | undefined; isTrusted?: boolean | undefined; } | undefined; }; jsonrpc: "2.0"; method: "ide/contextUpdate"; }>; export declare const IdeDiffAcceptedNotificationSchema: z.ZodObject<{ jsonrpc: z.ZodLiteral<"2.0">; method: z.ZodLiteral<"ide/diffAccepted">; params: z.ZodObject<{ filePath: z.ZodString; content: z.ZodString; }, "strip", z.ZodTypeAny, { filePath: string; content: string; }, { filePath: string; content: string; }>; }, "strip", z.ZodTypeAny, { params: { filePath: string; content: string; }; jsonrpc: "2.0"; method: "ide/diffAccepted"; }, { params: { filePath: string; content: string; }; jsonrpc: "2.0"; method: "ide/diffAccepted"; }>; export declare const IdeDiffRejectedNotificationSchema: z.ZodObject<{ jsonrpc: z.ZodLiteral<"2.0">; method: z.ZodLiteral<"ide/diffRejected">; params: z.ZodObject<{ filePath: z.ZodString; }, "strip", z.ZodTypeAny, { filePath: string; }, { filePath: string; }>; }, "strip", z.ZodTypeAny, { params: { filePath: string; }; jsonrpc: "2.0"; method: "ide/diffRejected"; }, { params: { filePath: string; }; jsonrpc: "2.0"; method: "ide/diffRejected"; }>; /** * This is defined for backwards compatibility only. Newer extension versions * will only send IdeDiffRejectedNotificationSchema. * * A notification that a diff has been closed in the IDE. */ export declare const IdeDiffClosedNotificationSchema: z.ZodObject<{ jsonrpc: z.ZodLiteral<"2.0">; method: z.ZodLiteral<"ide/diffClosed">; params: z.ZodObject<{ filePath: z.ZodString; content: z.ZodOptional; }, "strip", z.ZodTypeAny, { filePath: string; content?: string | undefined; }, { filePath: string; content?: string | undefined; }>; }, "strip", z.ZodTypeAny, { params: { filePath: string; content?: string | undefined; }; jsonrpc: "2.0"; method: "ide/diffClosed"; }, { params: { filePath: string; content?: string | undefined; }; jsonrpc: "2.0"; method: "ide/diffClosed"; }>; export declare const CloseDiffResponseSchema: z.ZodEffects; }, "strip", z.ZodTypeAny, { text: string; type: "text"; }, { text: string; type: "text"; }>, "many">; }, "strip", z.ZodTypeAny, { content: { text: string; type: "text"; }[]; }, { content: { text: string; type: "text"; }[]; }>, { content?: string | undefined; }, { content: { text: string; type: "text"; }[]; }>; export type DiffUpdateResult = { status: 'accepted'; content?: string; } | { status: 'rejected'; content: undefined; }; type IdeContextSubscriber = (ideContext: IdeContext | undefined) => void; /** * Creates a new store for managing the IDE's context. * This factory function encapsulates the state and logic, allowing for the creation * of isolated instances, which is particularly useful for testing. * * @returns An object with methods to interact with the IDE context. */ export declare function createIdeContextStore(): { setIdeContext: (newIdeContext: IdeContext) => void; getIdeContext: () => IdeContext | undefined; subscribeToIdeContext: (subscriber: IdeContextSubscriber) => () => void; clearIdeContext: () => void; }; /** * The default, shared instance of the IDE context store for the application. */ export declare const ideContext: { setIdeContext: (newIdeContext: IdeContext) => void; getIdeContext: () => IdeContext | undefined; subscribeToIdeContext: (subscriber: IdeContextSubscriber) => () => void; clearIdeContext: () => void; }; export {};