import { type GitLabDuoWorkflowNamespaceSelection } from "@oh-my-pi/pi-catalog/discovery/gitlab-duo-workflow"; import type { AssistantMessage, Context, FetchImpl, Model, ProviderSessionState, StreamFunction, StreamOptions, Tool, ToolChoice, ToolResultMessage } from "../types"; import { AssistantMessageEventStream } from "../utils/event-stream"; export declare const GITLAB_DUO_WORKFLOW_PROVIDER_ID = "gitlab-duo-agent"; export declare const GITLAB_DUO_WORKFLOW_API = "gitlab-duo-agent"; export declare const GITLAB_DUO_WORKFLOW_DEFINITION = "ambient"; export type GitLabDuoWorkflowDefinition = "ambient" | (string & {}); export declare const GITLAB_DUO_WORKFLOW_CLIENT_CAPABILITIES: readonly ["incremental_streaming", "read_file_chunked", "shell_command", "command_timeout", "tool_call_approval"]; export interface GitLabMcpToolArgs { name?: string; tool_name?: string; toolName?: string; providerIdentifier?: string; provider_identifier?: string; toolCallId?: string; tool_call_id?: string; args?: Record | string; arguments?: Record | string; } export interface GitLabPlainTextResponse { response?: string; error?: string; } export type PlainTextResponse = GitLabPlainTextResponse; export interface GitLabDuoWorkflowOptions extends StreamOptions { rootNamespaceId?: string; namespaceId?: string; projectId?: string; projectPath?: string; workflowDefinition?: GitLabDuoWorkflowDefinition; workflowId?: string; workflowToken?: string; cwd?: string; webSocketFactory?: GitLabDuoWorkflowWebSocketFactory; /** Idle WebSocket deadline (ms) before aborting and resuming; defaults to {@link GITLAB_DUO_WORKFLOW_IDLE_TIMEOUT_MS}. */ idleTimeoutMs?: number; /** * Tool-choice override forwarded from the stream layer. Only `"none"` is * acted on: a side-request (e.g. handoff) keeps tool definitions in the cache * prefix but disables tool use, so the provider must not advertise them to Duo. */ toolChoice?: ToolChoice; } export interface GitLabDuoWorkflowWebSocketLike { readyState?: number; binaryType?: string; onopen: ((event: Event) => void) | null; onmessage: ((event: MessageEvent) => void) | null; onerror: ((event: Event) => void) | null; onclose: ((event: CloseEvent) => void) | null; send(data: string): void; close(code?: number, reason?: string): void; } export interface GitLabDuoWorkflowWebSocketFactoryOptions { headers: Record; protocols?: string[]; } export type GitLabDuoWorkflowWebSocketFactory = (url: string, options: GitLabDuoWorkflowWebSocketFactoryOptions) => GitLabDuoWorkflowWebSocketLike; export interface GitLabDirectAccessResponse { token?: string; access_token?: string; jwt?: string; workflow_token?: string; duo_workflow_access_token?: string; duo_workflow_service?: { token?: string; base_url?: string; headers?: Record; }; gitlab_rails?: { token?: string; }; [key: string]: unknown; } interface GitLabDuoWorkflowCreateBodyOptions { projectId?: string; goal?: string; workflowDefinition?: GitLabDuoWorkflowDefinition; } interface GitLabDuoWorkflowStartMetadataOptions { projectId?: string; projectPath?: string; namespaceId?: string; rootNamespaceId?: string; workflowDefinition?: GitLabDuoWorkflowDefinition; inlineFlow?: boolean; } export interface GitLabMcpToolDefinition { name: string; originalToolName: string; serverName: string; description: string; inputSchema: string; isApproved: boolean; } export interface GitLabDuoWorkflowAdditionalContextItem { id: string; category: "agent_user_environment" | "user_rule"; content: string; metadata: { title: string; enabled: boolean; subType: "snippet"; icon: string; secondaryText: string; subTypeLabel: string; }; } export interface GitLabDuoWorkflowStartRequest { workflowID: string; clientVersion: "1.0"; workflowDefinition: GitLabDuoWorkflowDefinition; goal: string; workflowMetadata: string; additional_context: readonly GitLabDuoWorkflowAdditionalContextItem[]; approval?: { approval?: Record; rejection?: { message?: string; }; }; clientCapabilities: readonly (typeof GITLAB_DUO_WORKFLOW_CLIENT_CAPABILITIES)[number][]; mcpTools: GitLabMcpToolDefinition[]; preapproved_tools: string[]; flowConfigSchemaVersion?: "v1"; flowConfigId?: string; flowVersion?: string; flowConfig?: GitLabDuoWorkflowInlineFlowConfig; } export interface GitLabDuoWorkflowInlineFlowComponent { name: string; type: "AgentComponent"; prompt_id: string; toolset: string[]; inputs: { from: string; as: string; }[]; ui_log_events: string[]; } export interface GitLabDuoWorkflowInlineFlowPrompt { name: string; prompt_id: string; unit_primitives: string[]; prompt_template: { system: string; user: string; placeholder: string; }; } export interface GitLabDuoWorkflowInlineFlowConfig { version: "v1"; environment: "ambient"; flow: { entry_point: string; }; components: GitLabDuoWorkflowInlineFlowComponent[]; routers: { from: string; to: string; }[]; prompts: GitLabDuoWorkflowInlineFlowPrompt[]; } export interface GitLabDuoWorkflowActionResponse { actionResponse: { requestID: string; plainTextResponse?: GitLabPlainTextResponse; }; } interface GitLabDuoWorkflowActionDescriptor { requestID: string; name: string; args: unknown; } export interface GitLabDuoWorkflowActiveSession { workflowId: string; startPayload: GitLabDuoWorkflowStartRequest; ws: GitLabDuoWorkflowWebSocketLike; stop?: () => void; pendingActions?: GitLabDuoWorkflowActionDescriptor[]; checkpointAgentContentByKey?: Record; checkpointAgentContentSignatures?: Record; paused?: boolean; pauseBuffer?: unknown[]; lastToolBoundaryContentLength?: number; } export interface GitLabDuoWorkflowProviderSessionState extends ProviderSessionState { active?: GitLabDuoWorkflowActiveSession; } export interface GitLabDuoWorkflowStreamState { stream: AssistantMessageEventStream; output: AssistantMessage; activeTextIndex?: number; activeThinkingIndex?: number; activeCheckpointMessageKey?: string; started: boolean; checkpointAgentContentByKey?: Record; checkpointAgentContentSignatures?: Record; pauseRequested?: boolean; stepLimitRequested?: boolean; retryableErrorRequested?: boolean; lastCheckpointContentLength?: number; stalledRequested?: boolean; providerSessionState?: GitLabDuoWorkflowProviderSessionState; lastApprovalStatus?: string; goalOverflowMessage?: string; } type GitLabDuoWorkflowSocketResult = "closed" | "terminal" | "approval" | "action" | "pause" | "timeout" | "step_limit" | "retryable_error" | "stalled"; export interface GitLabAvailableModel { name?: string | null; ref?: string | null; } export interface GitLabAvailableModelsPayload { pinnedModel?: GitLabAvailableModel | null; selectedModel?: GitLabAvailableModel | null; defaultModel?: GitLabAvailableModel | null; selectableModels?: GitLabAvailableModel[] | null; } export declare const streamGitLabDuoWorkflow: StreamFunction<"gitlab-duo-agent">; export declare function buildGitLabDuoWorkflowDirectAccessBody(rootNamespaceId: string, projectId?: string, workflowDefinition?: GitLabDuoWorkflowDefinition): Record; export declare function buildGitLabDuoWorkflowCreateBody(namespaceId?: string, options?: GitLabDuoWorkflowCreateBodyOptions): Record; export declare function buildGitLabDuoWorkflowStopBody(): Record; export declare function buildGitLabDuoWorkflowWebSocketUrl(baseUrl: string, options?: { projectId?: string; namespaceId?: string; rootNamespaceId?: string; selectedModelIdentifier?: string; workflowDefinition?: GitLabDuoWorkflowDefinition; serviceEndpoint?: boolean; }): string; export declare function buildGitLabDuoWorkflowWebSocketHeaders(options: { token: string; baseUrl?: string; projectId?: string; namespaceId?: string; rootNamespaceId?: string; extraHeaders?: Record; }): Record; export declare function buildGitLabDuoWorkflowStartRequest(workflowId: string, model: Model<"gitlab-duo-agent">, context: Context, tools?: Tool[] | undefined, availableModels?: GitLabAvailableModelsPayload | null, metadataOptions?: GitLabDuoWorkflowStartMetadataOptions): GitLabDuoWorkflowStartRequest; export declare function buildGitLabDuoWorkflowInlineFlowConfig(systemPrompt: string): GitLabDuoWorkflowInlineFlowConfig; export declare function buildGitLabDuoWorkflowClientAdditionalContext(): GitLabDuoWorkflowAdditionalContextItem[]; export declare function buildGitLabDuoWorkflowMcpTools(tools: Tool[] | undefined): GitLabMcpToolDefinition[]; export declare function selectGitLabDuoWorkflowModelRef(selectedModel: string, availableModels?: GitLabAvailableModelsPayload | null): string; export declare function buildGitLabPlainTextFromToolResult(toolResult: ToolResultMessage): GitLabPlainTextResponse; export declare function gitLabDuoWorkflowErrorText(error: unknown): string; export declare function buildGitLabDuoWorkflowSettingsBody(): Record; export declare function runGitLabDuoWorkflowSocket(ws: GitLabDuoWorkflowWebSocketLike, startPayload: GitLabDuoWorkflowStartRequest, state: GitLabDuoWorkflowStreamState, options: GitLabDuoWorkflowOptions, resumeResponse?: GitLabDuoWorkflowActionResponse | readonly GitLabDuoWorkflowActionResponse[], replayMessages?: readonly unknown[]): Promise; export declare function buildGitLabDuoWorkflowApprovalStartRequest(startPayload: GitLabDuoWorkflowStartRequest): GitLabDuoWorkflowStartRequest; export declare function describeGitLabDuoWorkflowSocketEvent(event: unknown): string; export declare function traceGitLabDuoWorkflow(event: string, data?: Record): void; export declare function extractGitLabWorkflowToken(payload: GitLabDirectAccessResponse): string | undefined; export declare function resolveGitLabDuoWorkflowNamespaceSelection(model: Model<"gitlab-duo-agent">, options: GitLabDuoWorkflowOptions, apiKey: string, baseUrl: string, fetchImpl: FetchImpl): Promise; export declare function resolveGitLabDuoWorkflowRootNamespaceId(model: Model<"gitlab-duo-agent">, options: GitLabDuoWorkflowOptions, apiKey: string, baseUrl: string, fetchImpl: FetchImpl): Promise; export {};