/* eslint-disable no-use-before-define */ /* eslint-disable import/export */ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable import/no-extraneous-dependencies */ /// /// declare module 'cdeops/client' { import { OrganizationResource, RelativePattern, GlobPattern, LogLevel, Uri as URI, Unsubscribable, Subscribable, Workspace, ConfigurationTarget, OrganizationConfiguration, configuration, organization, } from 'cdeops'; export { OrganizationResource, RelativePattern, GlobPattern, URI, LogLevel, Unsubscribable, Subscribable, Workspace, ConfigurationTarget, OrganizationConfiguration, configuration, organization, commands, }; // AI Service Interfaces export interface IAISocketContribution { key: string; name: string; type: string; required?: boolean; enum?: string[]; default?: any; } export interface IAIWorkerRequest { script: string; args: any[]; timeout?: number; context?: Record; } export interface IAIWorkflowNode { id: string; type: string; position: { x: number; y: number }; data: Record; } export interface IAIWorkflowEdge { id: string; source: string; target: string; sourceOutput: string; targetInput: string; } export interface IAIWorkerResponse { result: any; error?: string; executionTime: number; memoryUsage?: number; } export interface IAIWorkflowConfig { id: string; name: string; description?: string; nodes: IAIWorkflowNode[]; edges: IAIWorkflowEdge[]; metadata: { organizationId: string; workflowId: string; workflowVersionId: string; }; } export interface IAINodeContribution { id: string; label: string; description: string; icon: string; category: string; inputs: IAISocketContribution[]; outputs: IAISocketContribution[]; machine: any; // XState machine } export interface DocumentFilter { /** A language id, such as `typescript` or `*`. */ language?: string; /** A URI scheme, such as `file` or `untitled`. */ scheme?: string; /** A glob pattern, such as `*.{ts,js}`. */ pattern?: string; /** A base URI (e.g. root URI of a workspace folder) that the document must be within. */ baseUri?: URL | string; } /** * A document selector is the combination of one or many document filters. * A document matches the selector if any of the given filters matches. * If the filter is a string and not a {@link DocumentFilter}, it will be treated as a language id. * * @example let sel: DocumentSelector = [{ language: 'typescript' }, { language: 'json', pattern: '**∕tsconfig.json' }]; */ export type DocumentSelector = (string | DocumentFilter)[]; /** * A panel view created by {@link sourcegraph.app.createPanelView}. */ export interface PanelView extends Unsubscribable { /** * The title of the panel view. */ title: string; /** * The content to show in the panel view. Markdown is supported. */ content: string; /** * The priority of this panel view. A higher value means that the item is shown near the beginning (usually * the left side). */ priority: number; /** * Display the results of the location provider (with the given ID) in this panel below the * {@link PanelView#contents}. * * Experimental. Subject to change or removal without notice. * * @internal */ component: { locationProvider: string } | null; } /** * A style for a {@link TextDocumentDecoration}. */ export interface ThemableDecorationStyle { /** The CSS background-color property value for the line. */ backgroundColor?: string; /** The CSS border property value for the line. */ border?: string; /** The CSS border-color property value for the line. */ borderColor?: string; /** The CSS border-width property value for the line. */ borderWidth?: string; } /** * A text document decoration changes the appearance of a range in the document and/or adds other content to * it. */ export interface TextDocumentDecoration extends ThemableDecorationStyle { /** * The range that the decoration applies to. Currently, decorations are * only applied only on the start line, and the entire line. Multiline * and intra-line ranges are not supported. */ range: Range; /** * If true, the decoration applies to all lines in the range (inclusive), even if not all characters on the * line are included. */ isWholeLine?: boolean; /** Content to display after the range. */ after?: DecorationAttachmentRenderOptions; /** Overwrite style for light themes. */ light?: ThemableDecorationStyle; /** Overwrite style for dark themes. */ dark?: ThemableDecorationStyle; } /** * A style for {@link BadgeAttachmentRenderOptions}. */ export interface ThemableBadgeAttachmentStyle { /** * The icon (a base64-encoded image icon) to display next to the wrapped value. * * @deprecated Use {@link BadgeAttachmentRenderOptions#kind} to pick a predefined icon */ icon?: string; /** * The CSS background-color property value for the attachment. * * @deprecated Use {@link BadgeAttachmentRenderOptions#kind} to pick a predefined icon */ backgroundColor?: string; /** * The CSS color property value for the attachment. * * @deprecated Use {@link BadgeAttachmentRenderOptions#kind} to pick a predefined icon */ color?: string; } /** An attachment adds content to a hover tooltip or result in a locations panel. */ export interface BadgeAttachmentRenderOptions extends ThemableBadgeAttachmentStyle { /** Predefined icons for badge attachments */ kind: 'info' | 'error' | 'warning'; /** Tooltip text to display when hovering over the attachment. */ hoverMessage?: string; /** If set, the attachment becomes a link with this destination URL. */ linkURL?: string; /** * Overwrite style for light themes. * * @deprecated Use {@link BadgeAttachmentRenderOptions#kind} to pick a predefined icon */ light?: ThemableBadgeAttachmentStyle; /** * Overwrite style for dark themes. * * @deprecated Use {@link BadgeAttachmentRenderOptions#kind} to pick a predefined icon */ dark?: ThemableBadgeAttachmentStyle; } /** * A wrapper around a providable type (currently hover and locations) with additional * context to enable displaying badges next to the wrapped result value in the UI. */ export type Badged = T & { badge?: BadgeAttachmentRenderOptions; }; /** * A hover represents additional information for a symbol or word. Hovers are rendered in a tooltip-like * widget. */ export interface Hover { /** * The contents of this hover. */ contents: MarkupContent; /** * The range to which this hover applies. When missing, the editor will use the range at the current * position or the current position itself. */ range?: Range; /** * Alerts that should be shown in this hover. */ alerts?: Badged[]; } export interface HoverAlert { /** * Text content to be shown on hovers. Since the alert is displayed inline, * multiparagraph content will be rendered on one line. It's recommended to * provide a brief message here, and place futher details in the badge or * provide a link. */ summary: MarkupContent; /** * When an alert has a dismissal type, dismissing it will prevent all alerts * of that type from being shown. If no type is provided, the alert is not * dismissible. */ type?: string; } export interface ContextValues { [key: string]: string | number | boolean | null; } /** * Internal API for Cdeops extensions. ost of those wil be removed for the beta release of Cdeops * extensions. They are necessary now due to limitations in the extension API and its implementation tha will * be addressed in the beta release. * * @internal * @hidden */ export namespace internal { /** * Returns a promise that resolve when all pending messages have been sent to the client. * It helps enforce serialization of messages. * * @internal */ export function sync(): Promise; /** * Updates context values for use in context expressions and contribution labels. * * @param updates The updates to apply to the context. If a context property's value is null, it is deleted from the * context. */ export function updateContext(updates: ContextValues): void; export const cdeopsURL: URI; export const clientApplication: 'cdeops' | 'other'; /** * Server api */ export const serverApi: any; /** * gql */ export const gql: any; } /** * The extension context is passed to the extension's activate function and contains utilities for * extension lifecycle. */ export interface ExtensionContext { /** * An object that maintains subscriptions to resources that should be freed when the extension is * deactivated. * * When an extension is deactivated, first its exported `deactivate` function is called (if one exists). * The `deactivate` function may be async, in which case deactivation blocks on it finishing. Next, * regardless of whether the `deactivate` function finished successfully or rejected with an error, all * unsubscribables passed to {@link ExtensionContext#subscriptions#add} are unsubscribed from. * * (An extension is deactivated when the user disables it, or after an arbitary time period if * activationEvents no longer evaluated to true.) */ subscriptions: { /** * Mark a resource's teardown function to be called when the extension is deactivated. * * @param unsubscribable An {@link Unsubscribable} that frees (unsubscribes from) a resource, or a * plan function that deos the same. Async functions are not supported. (If deactivation requires * async operations, make the `deactivate` function async; that is supported.) */ add: (unsubscribe: Unsubscribable | (() => void)) => void; }; } /** * Namespace for dealing with commands. In short, a command is a function with a * unique identifier. The function is sometimes also called _command handler_. * * Commands can be added to the editor using the [registerCommand](#commands.registerCommand) * and [registerTextEditorCommand](#commands.registerTextEditorCommand) functions. Commands * can be executed [manually](#commands.executeCommand) or from a UI gesture. Those are: * * * palette - Use the `commands`-section in `package.json` to make a command show in * the [command palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette). * * keybinding - Use the `keybindings`-section in `package.json` to enable * [keybindings](https://code.visualstudio.com/docs/getstarted/keybindings#_customizing-shortcuts) * for your extension. * * Commands from other extensions and from the editor itself are accessible to an extension. However, * when invoking an editor command not all argument types are supported. * * This is a sample that registers a command handler and adds an entry for that command to the palette. First * register a command handler with the identifier `extension.sayHello`. * ```javascript * commands.registerCommand('extension.sayHello', () => { * window.showInformationMessage('Hello World!'); * }); * ``` * Second, bind the command identifier to a title under which it will show in the palette (`package.json`). * ```json * { * "contributes": { * "commands": [{ * "command": "extension.sayHello", * "title": "Hello World" * }] * } * } * ``` */ export namespace commands { /** * Registers a command that can be invoked via a keyboard shortcut, * a menu item, an action, or directly. * * Registering a command with an existing command identifier twice * will cause an error. * * @param command A unique identifier for the command. * @param callback A command handler function. * @param thisArg The `this` context used when invoking the handler function. * @return Disposable which unregisters this command on disposal. */ export function registerCommand(command: string, callback: (...args: any[]) => any, thisArg?: any): Disposable; /** * Registers a text editor command that can be invoked via a keyboard shortcut, * a menu item, an action, or directly. * * Text editor commands are different from ordinary [commands](#commands.registerCommand) as * they only execute when there is an active editor when the command is called. Also, the * command handler of an editor command has access to the active editor and to an * [edit](#TextEditorEdit)-builder. * * @param command A unique identifier for the command. * @param callback A command handler function with access to an [editor](#TextEditor) and an [edit](#TextEditorEdit). * @param thisArg The `this` context used when invoking the handler function. * @return Disposable which unregisters this command on disposal. */ export function registerTextEditorCommand( command: string, callback: (textEditor: TextEditor, edit: TextEditorEdit, ...args: any[]) => void, thisArg?: any, ): Disposable; /** * Executes the command denoted by the given command identifier. * * * *Note 1:* When executing an editor command not all types are allowed to * be passed as arguments. Allowed are the primitive types `string`, `boolean`, * `number`, `undefined`, and `null`, as well as [`Position`](#Position), [`Range`](#Range), [`Uri`](#Uri) and [`Location`](#Location). * * *Note 2:* There are no restrictions when executing commands that have been contributed * by extensions. * * @param command Identifier of the command to execute. * @param rest Parameters passed to the command function. * @return A promise that resolves to the returned value of the given command. `undefined` when * the command handler function doesn't return anything. */ export function executeCommand(command: string, ...rest: any[]): Promise; /** * Retrieve the list of all available commands. Commands starting an underscore are * treated as internal commands. * * @param filterInternal Set `true` to not see internal commands (starting with an underscore) * @return Promise that resolves to a list of command ids. */ export function getCommands(filterInternal?: boolean): Promise; } /** * Namespace for AI services. Provides access to AI worker, workflow, and node registry functionality. */ export namespace ai { /** * AI Worker service for executing scripts and managing libraries. */ export namespace worker { /** * Executes a script in the AI worker. * @param request The script execution request. * @returns Promise that resolves to the execution result. */ export function executeScript(request: IAIWorkerRequest): Promise; /** * Installs a library in the AI worker. * @param url The URL of the library to install. * @param accessors The accessor names for the library. * @returns Promise that resolves when the library is installed. */ export function installLibrary(url: string, accessors: string[]): Promise; /** * Uninstalls libraries from the AI worker. * @param accessors The accessor names to uninstall. * @returns Promise that resolves to the uninstall result. */ export function uninstallLibrary(accessors: string[]): Promise<{ success: boolean; error?: string }>; /** * Resets the AI worker context. * @returns Promise that resolves when the context is reset. */ export function resetContext(): Promise; } /** * AI Workflow service for managing and executing workflows. */ export namespace workflow { /** * Creates a new AI workflow. * @param config The workflow configuration. * @returns Promise that resolves to the workflow ID. */ export function createWorkflow(config: IAIWorkflowConfig): Promise; /** * Runs an AI workflow. * @param workflowId The ID of the workflow to run. * @param inputId The ID of the input node. * @param inputs Optional input data. * @returns Promise that resolves to the workflow result. */ export function runWorkflow( workflowId: string, inputId: string, inputs?: Record, ): Promise; /** * Stops a running AI workflow. * @param workflowId The ID of the workflow to stop. * @returns Promise that resolves when the workflow is stopped. */ export function stopWorkflow(workflowId: string): Promise; /** * Gets the state of an AI workflow. * @param workflowId The ID of the workflow. * @returns Promise that resolves to the workflow state. */ export function getWorkflowState(workflowId: string): Promise; } /** * AI Node Registry service for managing AI node contributions. */ export namespace nodeRegistry { /** * Registers an AI node. * @param node The node contribution to register. * @param extensionId The ID of the extension registering the node. * @returns Promise that resolves when the node is registered. */ export function registerNode(node: IAINodeContribution, extensionId: string): Promise; /** * Unregisters an AI node. * @param nodeId The ID of the node to unregister. * @param extensionId The ID of the extension that registered the node. * @returns Promise that resolves when the node is unregistered. */ export function unregisterNode(nodeId: string, extensionId: string): Promise; /** * Gets all registered AI nodes. * @returns Promise that resolves to an array of registered nodes. */ export function getNodes(): Promise; /** * Gets a specific AI node by ID. * @param nodeId The ID of the node to retrieve. * @returns Promise that resolves to the node or undefined if not found. */ export function getNodeById(nodeId: string): Promise; } } }