/* 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/server' {
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,
};
// AI Service Interfaces
export interface IAISocketContribution {
key: string;
name: string;
type: string;
required?: boolean;
enum?: string[];
default?: any;
}
export interface ICodeJavascriptRequest {
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 ICodeJavascriptResponse {
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;
}
export namespace code {
/**
* Namespace for JavaScript code execution and library management.
*/
export namespace javascript {
/**
* Executes a script in the JavaScript environment.
* @param request The script execution request.
* @returns Promise that resolves to the execution result.
*/
export function executeScript(request: ICodeJavascriptRequest): Promise;
/**
* Installs a library in the JavaScript environment.
* @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 JavaScript environment.
* @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 JavaScript environment context.
* @returns Promise that resolves when the context is reset.
*/
export function resetContext(): Promise;
/**
* Gets code completions for the given context.
* @param context The completion context with text, position, and optional scope.
* @returns Promise that resolves to completions and metadata.
*/
export function getCompletions(context: { text: string; position: number; scope?: string[] }): Promise<{
completions: Array<{
name: string;
type?: string;
doc?: string;
url?: string;
}>;
isIncomplete: boolean;
}>;
/**
* Gets type information for a symbol.
* @param symbol The symbol name to get type info for.
* @param scope Optional scope context.
* @returns Type information or null if not found.
*/
export function getTypeInfo(
symbol: string,
scope?: string[],
): { type?: string; doc?: string; url?: string } | null;
/**
* Gets list of available definition libraries.
* @returns Array of definition library names.
*/
export function getAvailableDefinitions(): string[];
/**
* Gets the current autocomplete configuration.
* @returns The current autocomplete settings.
*/
export function getAutocompleteConfig(): {
includeDefaults: boolean;
includeLibraries: boolean;
enableDynamicLibraries: boolean;
customDefinitions: string[];
};
/**
* Updates the autocomplete configuration.
* @param config Partial configuration to update.
*/
export function updateAutocompleteConfig(config: {
includeDefaults?: boolean;
includeLibraries?: boolean;
enableDynamicLibraries?: boolean;
customDefinitions?: string[];
}): void;
/**
* Gets the raw Tern definitions for debugging and inspection.
* @returns The combined Tern definition object.
*/
export function getTernDefinitions(): unknown;
}
}
/**
* Namespace for AI services. Provides access to AI workflow, and node registry functionality.
*/
export namespace ai {
/**
* 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;
}
}
// ── Gateway SPI ──
/** Configuration returned by a gateway provider. */
export interface IGatewayConfig {
config?: Record | null;
hash: string;
}
/** Health/status of a gateway. */
export interface IGatewayStatus {
healthy: boolean;
version?: string;
uptime?: number;
}
/** Status of a messaging channel on the gateway. */
export interface IGatewayChannelStatus {
channel: string;
configured: boolean;
connected: boolean;
enabled: boolean;
accountId?: string;
error?: string;
}
/** A provisioned gateway instance. */
export interface IGatewayInstance {
releaseName: string;
slug: string;
url: string;
status: string;
userId: string;
projectId?: string;
namespace?: string;
replicas: number;
readyReplicas: number;
imageVariant?: string;
}
/** Resource usage metrics for a gateway instance. */
export interface IGatewayResourceUsage {
cpuRequest?: string;
cpuLimit?: string;
cpuActual?: string;
memoryRequest?: string;
memoryLimit?: string;
memoryActual?: string;
storageCapacity?: string;
}
/** Session URL for browser access to a gateway instance. */
export interface IGatewaySessionUrl {
sessionUrl: string;
expiresAt: number;
}
/** WebSocket chat connection details. */
export interface IGatewayChatConnection {
url: string;
wsUrl: string;
token: string;
proxyToken: string;
expiresAt?: number;
}
/** Input for provisioning a new gateway instance. */
export interface IProvisionGatewayInput {
userId: string;
userName?: string;
email?: string;
imageVariant?: string;
tier?: string;
workspaceEnabled?: boolean;
workspaceSize?: string;
persistenceEnabled?: boolean;
}
/** Agent detail from the gateway. */
export interface IGatewayAgentDetail {
id: string;
name?: string;
isDefault: boolean;
workspace?: string;
heartbeat?: { enabled: boolean; every?: string };
sessions?: { count: number };
files?: Array<{ name: string; path: string; missing: boolean; size?: number }>;
}
/**
* Service interface for interacting with a gateway's configuration and agents.
* Extensions implement this to provide gateway functionality.
*/
export interface IGatewayService {
getConfig(projectId: string, userId: string): Promise;
updateConfig(projectId: string, userId: string, patch: Record): Promise;
replaceConfig(projectId: string, userId: string, config: Record): Promise;
getStatus(projectId: string, userId: string): Promise;
getModels(projectId: string, userId: string): Promise;
getUsage(projectId: string, userId: string): Promise;
listAgents(projectId: string, userId: string): Promise;
getAgentDetail(projectId: string, userId: string, agentId: string): Promise;
createAgent(
projectId: string,
userId: string,
name: string,
workspace?: string,
): Promise<{ ok: boolean; agentId: string }>;
updateAgent(
projectId: string,
userId: string,
agentId: string,
params: { name?: string; model?: string },
): Promise<{ ok: boolean; agentId: string }>;
deleteAgent(projectId: string, userId: string, agentId: string): Promise<{ ok: boolean; agentId: string }>;
listSessions(projectId: string, userId: string): Promise;
setAgentFile(projectId: string, userId: string, agentId: string, name: string, content: string): Promise;
}
/** Service interface for managing messaging channels on a gateway. */
export interface IGatewayChannelService {
connectChannel(
projectId: string,
userId: string,
channel: string,
credentials: Record,
): Promise;
disconnectChannel(projectId: string, userId: string, channel: string, accountId?: string): Promise;
getChannelsStatus(projectId: string, userId: string, probe?: boolean): Promise;
}
/** Service interface for managing gateway instance lifecycle. */
export interface IGatewayInstanceService {
provisionInstance(projectId: string, req: IProvisionGatewayInput): Promise;
stopInstance(projectId: string, userId: string): Promise;
startInstance(projectId: string, userId: string): Promise;
deleteInstance(projectId: string, userId: string, deletePVCs?: boolean): Promise;
getInstanceStatus(projectId: string, userId: string): Promise;
listInstances(projectId: string): Promise;
getResourceUsage(projectId: string, userId: string): Promise;
generateSessionUrl(
projectId: string,
userId: string,
agentId?: string,
workspaceId?: number,
): Promise;
getChatConnection(projectId: string, userId: string): Promise;
}
/** A registered gateway provider returned by an extension. */
export interface IGatewayProvider {
/** Unique identifier for this gateway type (e.g. 'openclaw', 'custom'). */
id: string;
/** Human-readable display name. */
displayName: string;
/** Gateway config/agent/model service. */
gatewayService: IGatewayService;
/** Channel management service. */
channelService: IGatewayChannelService;
/** Instance lifecycle service. */
instanceService: IGatewayInstanceService;
}
/**
* Namespace for gateway provider registration.
* Extensions call `registerProvider` during activation;
* the host queries registered providers at runtime.
*/
export namespace gateway {
/** Register a gateway provider. Returns a disposable to unregister. */
export function registerProvider(provider: IGatewayProvider): Disposable;
/** Get a registered gateway provider by id. */
export function getProvider(id: string): IGatewayProvider | undefined;
/** Get all registered gateway providers. */
export function getProviders(): IGatewayProvider[];
}
}