import type { Tracer } from "@opentelemetry/api";
import type { ModelMessage } from "ai";
import type { EditorClientMethods, IApiV3Dto } from "@superblocksteam/library-shared/types";
import type { ISocketClient, PluginExecutionVersions } from "@superblocksteam/shared";
import type { ITokenManager } from "@superblocksteam/util";
import type { DraftInterface } from "../draft-interface.js";
import type { AutoConnectingRpcClient } from "../server-rpc/index.js";
import type { Logger } from "../util/logger.js";
import type { IOperationQueue } from "../util/operation-queue.js";
import type { datasourceSdkClassByType } from "./const.js";
import type { AiServiceFeatureFlags } from "./features.js";
import type { RetryConfigOptions } from "./llm/stream/config.js";
import type { StreamObserver } from "./llm/stream/observer.js";
import type { LLMProviderSettings } from "./llm/types.js";
import type { TemplateRenderer } from "./template-renderer.js";
export interface AiServiceConfig {
    superblocksBaseUrl: string;
    appRootDirPath: string;
    applicationId: string;
    organizationId: string;
    fsOperationQueue: IOperationQueue;
    draftInterface: DraftInterface;
    tracer: Tracer;
    logger: Logger;
    rpcClient: AutoConnectingRpcClient;
    features: AiServiceFeatureFlags;
    templateRenderer?: TemplateRenderer;
    tokenManager?: ITokenManager;
    retryOptions?: RetryConfigOptions;
    /** Plugin execution versions from the organization, used to determine which plugin versions to use */
    pluginExecutionVersions?: PluginExecutionVersions;
    providerSettings?: Partial<LLMProviderSettings>;
    /** Optional extra observers attached to each LLM stream session (eval/debug instrumentation). */
    streamObservers?: StreamObserver[];
}
export interface AiServiceEvents {
    generationStarted: [];
    generationCompleted: [hasDraft: boolean];
    generationFailed: [error: Error];
}
type ExtractColonPrefixedPathSegments<S extends string> = S extends `${string}:${infer Param}/${infer Rest}` ? Param | ExtractColonPrefixedPathSegments<`/${Rest}`> : S extends `${string}:${infer Param}` ? Param : never;
export type PathParams<S extends string> = {
    [K in ExtractColonPrefixedPathSegments<S>]: string;
};
export type TransformerInputItem<S extends string> = {
    pathParams: Readonly<PathParams<S>>;
    content: string;
    fileName: string;
};
export type TransformerOutputItem<S extends string> = {
    pathParams: PathParams<S>;
    content: string;
};
export type TransformerIOSpec = Readonly<{
    [K in string]: string;
}>;
export type TransformerInput<T extends TransformerIOSpec> = {
    [K in keyof T]: ReadonlyArray<TransformerInputItem<T[K]>>;
};
export type TransformerOutput<T extends TransformerIOSpec> = {
    [K in keyof T]: ReadonlyArray<TransformerOutputItem<T[K]>>;
};
export type FileArtifact = {
    type: "file";
    filePath: string;
    content: string;
};
export type ChangeInfo = {
    name: string;
    filePath: string;
    type: "api" | "page" | "dependency" | "theme";
    action: "create" | "edit" | "delete" | "transient";
    status: "pending" | "ready" | "error" | "validated";
};
export type Annotation = {
    keyPath: string;
    content: Record<string, any>;
};
export type AnthropicErrorType = "overloaded_error" | "invalid_request_error" | "authentication_error" | "permission_error" | "not_found_error" | "request_too_large" | "rate_limit_error" | "api_error";
export type BedrockErrorType = "AccessDeniedException" | "IncompleteSignature" | "InternalFailure" | "InvalidAction" | "InvalidClientTokenId" | "NotAuthorized" | "RequestExpired" | "ServiceUnavailable" | "ThrottlingException" | "UnrecognizedClientException" | "ValidationError" | "ResourceNotFound";
export type ProviderErrorType = AnthropicErrorType | BedrockErrorType | "unknown";
export type StandardizedError = {
    type: "rate_limit" | "validation_error" | "auth_error" | "not_found" | "api_error" | "timeout" | "overloaded" | "unknown";
    providerName?: string;
    message?: string;
    originalError?: unknown;
};
export declare class ProviderError implements Error {
    name: string;
    provider?: string;
    message: string;
    response: unknown;
    constructor(response: unknown, provider?: string);
    toJSON(): {
        name: string;
        provider: string | undefined;
        message: string;
        response: unknown;
    };
}
export type ProviderErrorResponse = {
    type: ProviderErrorType;
    name: string;
    url: string;
    requestBodyValues: {
        messages: ModelMessage[];
    };
    statusCode: number;
    isRetryable: boolean;
    data: ProviderErrorData;
};
type ProviderErrorData = {
    type: "error";
    error: {
        type: ProviderErrorType;
        message: string;
    };
};
export declare function parseErrorResponse(response: unknown): ProviderErrorResponse | undefined;
export declare function normalizeProviderError(error: {
    type: ProviderErrorType;
    response: unknown;
}, providerName?: string): StandardizedError;
export type AnthropicApiError = {
    errors?: AnthropicApiErrorObject[];
    name?: string;
    reason?: string;
    lastError?: AnthropicApiErrorObject;
};
export type AnthropicApiErrorObject = {
    data: {
        type: string;
        error: {
            type: string;
            message: string;
        };
    };
    isRetryable: boolean;
    name: string;
    requestBodyValues: any;
    responseBody: string;
    responseHeaders: Record<string, string>;
    status: number;
    url: string;
};
export declare class NpmInstallError extends Error {
    constructor(message: string);
}
export interface SdkIntegrationColumn {
    name: string;
    type: string;
    [key: string]: any;
}
export interface SdkIntegrationTable {
    type: string;
    name: string;
    schema: string;
    columns: SdkIntegrationColumn[];
    [key: string]: any;
}
export type SdkIntegrationType = keyof typeof datasourceSdkClassByType;
export interface SdkIntegration {
    name: string;
    id: string;
    type: SdkIntegrationType;
    metadata: Record<string, any>;
}
export interface DatabaseSdkIntegration extends Omit<SdkIntegration, "type"> {
    type: SdkIntegrationType;
    metadata: {
        schema: {
            tables: SdkIntegrationTable[];
        };
    };
}
export type DatasourceSdkClass = (typeof datasourceSdkClassByType)[SdkIntegrationType];
export type EditorClient = ISocketClient<EditorClientMethods>;
export type UserChange = {
    type: "addPage";
    path: string;
} | {
    type: "deletePage";
    path: string;
} | {
    type: "apiUpdate";
    apiName: string;
} | {
    type: "apiDelete";
    apiName: string;
} | {
    type: "fileChanged";
    filePath: string;
};
export type ApiUpdate = {
    author: "clark" | "user";
    payload: IApiV3Dto;
};
export {};
//# sourceMappingURL=types.d.ts.map