Skip to content

Latest commit

 

History

History
576 lines (517 loc) · 16.2 KB

File metadata and controls

576 lines (517 loc) · 16.2 KB

API Report File for "@red-hat-developer-hub/backstage-plugin-boost-backend"

Do not edit this file. It is a report generated by API Extractor.

import type { AgenticProvider } from '@red-hat-developer-hub/backstage-plugin-boost-common';
import type { AgentRecord } from '@red-hat-developer-hub/backstage-plugin-boost-common';
import type { ApprovalRequest } from '@red-hat-developer-hub/backstage-plugin-boost-common';
import { BackendFeature } from '@backstage/backend-plugin-api';
import type { CacheService } from '@backstage/backend-plugin-api';
import type { ConversationDetails } from '@red-hat-developer-hub/backstage-plugin-boost-common';
import type { ConversationMessage } from '@red-hat-developer-hub/backstage-plugin-boost-common';
import type { ConversationSummary } from '@red-hat-developer-hub/backstage-plugin-boost-common';
import type { DatabaseService } from '@backstage/backend-plugin-api';
import type { FeedbackRecord } from '@red-hat-developer-hub/backstage-plugin-boost-common';
import type { HttpAuthService } from '@backstage/backend-plugin-api';
import type { LifecycleStage } from '@red-hat-developer-hub/backstage-plugin-boost-common';
import type { LoggerService } from '@backstage/backend-plugin-api';
import type { McpAuthType } from '@red-hat-developer-hub/backstage-plugin-boost-common';
import type { McpServerRecord } from '@red-hat-developer-hub/backstage-plugin-boost-common';
import type { McpTransport } from '@red-hat-developer-hub/backstage-plugin-boost-common';
import { Permission } from '@backstage/plugin-permission-common';
import type { PermissionsService } from '@backstage/backend-plugin-api';
import type { ProviderDescriptor } from '@red-hat-developer-hub/backstage-plugin-boost-common';
import type { Request as Request_2 } from 'express';
import type { RequestHandler } from 'express';
import type { RootConfigService } from '@backstage/backend-plugin-api';
import { Router } from 'express';
import { ServiceFactory } from '@backstage/backend-plugin-api';
import type { ToolRecord } from '@red-hat-developer-hub/backstage-plugin-boost-common';
import { z } from 'zod';

// @public
export class AdminConfigService {
  constructor(options: AdminConfigServiceOptions);
  getAllOverrides(): Promise<Map<string, unknown>>;
  getOverride(key: BoostConfigKey): Promise<unknown | undefined>;
  removeOverride(key: BoostConfigKey): Promise<void>;
  setOverride(key: BoostConfigKey, value: unknown): Promise<void>;
  validateStoredValues(): Promise<string[]>;
}

// @public
export interface AdminConfigServiceOptions {
  database: DatabaseService;
  logger: LoggerService;
}

// @public
export class AgentLifecycleStore {
  constructor(options: AgentLifecycleStoreOptions);
  delete(id: string): Promise<boolean>;
  get(id: string): Promise<AgentRecord | undefined>;
  list(): Promise<AgentRecord[]>;
  register(agent: {
    id: string;
    name: string;
    description?: string;
    createdBy: string;
  }): Promise<AgentRecord>;
  updateStage(
    id: string,
    stage: LifecycleStage,
  ): Promise<AgentRecord | undefined>;
}

// @public
export interface AgentLifecycleStoreOptions {
  database: DatabaseService;
  logger: LoggerService;
}

// @public
export interface AgentRoutesOptions {
  httpAuth: HttpAuthService;
  logger: LoggerService;
  permissions: PermissionsService;
  store: AgentLifecycleStore;
}

// @public
export function authorizeLifecycleAction(
  permission: Permission,
  _resourceLoader: ResourceLoader,
  options: AuthorizeLifecycleActionOptions,
): RequestHandler;

// @public
export interface AuthorizeLifecycleActionOptions {
  httpAuth: HttpAuthService;
  permissions: PermissionsService;
}

// @public
export class BackendApprovalStore {
  constructor(options: BackendApprovalStoreOptions);
  approve(
    requestId: string,
    resolvedArgs?: string,
  ): Promise<ApprovalRequest | undefined>;
  create(request: ApprovalRequest): Promise<void>;
  delete(requestId: string): Promise<void>;
  get(requestId: string): Promise<ApprovalRequest | undefined>;
  reject(requestId: string): Promise<ApprovalRequest | undefined>;
  static readonly TTL_MS: number;
}

// @public
export interface BackendApprovalStoreOptions {
  cache: CacheService;
  logger: LoggerService;
}

// @public
export const BOOST_CONFIG_SCHEMA_VERSION = 1;

// @public
export const boostAiProviderServiceFactory: ServiceFactory<
  AgenticProvider,
  'plugin',
  'singleton'
>;

// @public
export const boostConfigFields: {
  readonly 'boost.model.baseUrl': {
    readonly schema: z.ZodString;
    readonly configScope: ConfigScope;
    readonly description: string;
  };
  readonly 'boost.model.name': {
    readonly schema: z.ZodString;
    readonly configScope: ConfigScope;
    readonly description: string;
  };
  readonly 'boost.systemPrompt': {
    readonly schema: z.ZodOptional<z.ZodString>;
    readonly configScope: ConfigScope;
    readonly description: string;
  };
  readonly 'boost.security.mode': {
    readonly schema: z.ZodEnum<
      ['development-only-no-auth', 'plugin-only', 'full']
    >;
    readonly configScope: ConfigScope;
    readonly description: string;
  };
  readonly 'boost.features.agentCreation': {
    readonly schema: z.ZodOptional<z.ZodBoolean>;
    readonly configScope: ConfigScope;
    readonly description: string;
  };
  readonly 'boost.features.skillsMarketplace': {
    readonly schema: z.ZodOptional<z.ZodBoolean>;
    readonly configScope: ConfigScope;
    readonly description: string;
  };
  readonly 'boost.agentApproval.mode': {
    readonly schema: z.ZodOptional<z.ZodEnum<['built-in', 'sonataflow']>>;
    readonly configScope: ConfigScope;
    readonly description: string;
  };
  readonly 'boost.agentApproval.sonataflow.endpoint': {
    readonly schema: z.ZodOptional<z.ZodString>;
    readonly configScope: ConfigScope;
    readonly description: string;
  };
  readonly 'boost.skillsMarketplace.endpoint': {
    readonly schema: z.ZodOptional<z.ZodString>;
    readonly configScope: ConfigScope;
    readonly description: string;
  };
  readonly 'boost.skillsMarketplace.runtimes': {
    readonly schema: z.ZodOptional<
      z.ZodArray<
        z.ZodObject<
          {
            id: z.ZodString;
            name: z.ZodString;
            description: z.ZodOptional<z.ZodString>;
            image: z.ZodString;
            language: z.ZodOptional<z.ZodString>;
            footprint: z.ZodOptional<z.ZodEnum<['small', 'medium', 'large']>>;
            features: z.ZodOptional<z.ZodArray<z.ZodString, 'many'>>;
            status: z.ZodOptional<
              z.ZodEnum<['active', 'deprecated', 'experimental']>
            >;
          },
          'strip',
          z.ZodTypeAny,
          {
            name: string;
            id: string;
            image: string;
            description?: string | undefined;
            status?: 'active' | 'deprecated' | 'experimental' | undefined;
            language?: string | undefined;
            footprint?: 'small' | 'medium' | 'large' | undefined;
            features?: string[] | undefined;
          },
          {
            name: string;
            id: string;
            image: string;
            description?: string | undefined;
            status?: 'active' | 'deprecated' | 'experimental' | undefined;
            language?: string | undefined;
            footprint?: 'small' | 'medium' | 'large' | undefined;
            features?: string[] | undefined;
          }
        >,
        'many'
      >
    >;
    readonly configScope: ConfigScope;
    readonly description: string;
  };
  readonly 'boost.kagenti.auth.tokenExchange.enabled': {
    readonly schema: z.ZodOptional<z.ZodBoolean>;
    readonly configScope: ConfigScope;
    readonly description: string;
  };
  readonly 'boost.kagenti.auth.tokenExchange.audience': {
    readonly schema: z.ZodOptional<z.ZodString>;
    readonly configScope: ConfigScope;
    readonly description: string;
  };
  readonly 'boost.kagenti.auth.tokenExchange.userTokenHeader': {
    readonly schema: z.ZodOptional<z.ZodString>;
    readonly configScope: ConfigScope;
    readonly description: string;
  };
  readonly 'boost.encryptionSecret': {
    readonly schema: z.ZodOptional<z.ZodString>;
    readonly configScope: ConfigScope;
    readonly description: string;
    readonly sensitive: true;
  };
  readonly 'boost.devSpaces.credentials': {
    readonly schema: z.ZodOptional<z.ZodString>;
    readonly configScope: ConfigScope;
    readonly description: string;
    readonly sensitive: true;
  };
};

// @public
export type BoostConfigKey = keyof typeof boostConfigFields;

// @public
const boostPlugin: BackendFeature;
export default boostPlugin;

// @public
export interface ChatRoutesOptions {
  conversationAgentCache: ConversationAgentCache;
  httpAuth: HttpAuthService;
  logger: LoggerService;
  permissions: PermissionsService;
  providerManager: ProviderManager;
  rateLimiter: RateLimiter;
}

// @public
export interface ConfigFieldMeta<T extends z.ZodTypeAny = z.ZodTypeAny> {
  configScope: ConfigScope;
  description: string;
  schema: T;
  sensitive?: boolean;
}

// @public
export type ConfigScope = 'yaml-only' | 'db-overridable' | 'db-only';

// @public
export class ConversationAgentCache {
  constructor(options: ConversationAgentCacheOptions);
  delete(conversationId: string): Promise<void>;
  get(conversationId: string): Promise<string | undefined>;
  set(conversationId: string, providerId: string): Promise<void>;
}

// @public
export interface ConversationAgentCacheOptions {
  cache: CacheService;
  logger: LoggerService;
}

// @public
export class ConversationRegistry {
  constructor(options: ConversationRegistryOptions);
  delete(responseId: string): Promise<void>;
  get(responseId: string): Promise<string | undefined>;
  set(responseId: string, conversationId: string): Promise<void>;
}

// @public
export interface ConversationRegistryOptions {
  cache: CacheService;
  logger: LoggerService;
}

// @public
export interface ConversationRoutesOptions {
  httpAuth: HttpAuthService;
  logger: LoggerService;
  permissions: PermissionsService;
  store: ConversationStore;
}

// @public
export class ConversationStore {
  constructor(options: ConversationStoreOptions);
  addFeedback(feedback: {
    id: string;
    sessionId: string;
    messageId: string;
    sentiment: 'positive' | 'negative';
    reason?: string;
    createdBy: string;
  }): Promise<FeedbackRecord>;
  addMessage(message: {
    id: string;
    sessionId: string;
    role: 'user' | 'assistant' | 'system';
    content: string;
  }): Promise<ConversationMessage>;
  createSession(session: {
    id: string;
    title: string;
    providerId: string;
    createdBy: string;
  }): Promise<ConversationSummary>;
  deleteSession(sessionId: string): Promise<boolean>;
  getSession(sessionId: string): Promise<ConversationDetails | undefined>;
  listAllSessions(providerId?: string): Promise<ConversationSummary[]>;
  listFeedback(sessionId: string): Promise<FeedbackRecord[]>;
  listSessions(
    createdBy: string,
    providerId?: string,
  ): Promise<ConversationSummary[]>;
  searchSessions(
    createdBy: string,
    keyword: string,
    providerId?: string,
  ): Promise<ConversationSummary[]>;
}

// @public
export interface ConversationStoreOptions {
  database: DatabaseService;
  logger: LoggerService;
}

// @public
export function createAgentResourceLoader(): ResourceLoader;

// @public
export function createAgentRoutes(options: AgentRoutesOptions): Router;

// @public
export function createChatRoutes(options: ChatRoutesOptions): Router;

// @public
export function createConversationRoutes(
  options: ConversationRoutesOptions,
): Router;

// @public
export function createKagentiAdminRoutes(
  options: KagentiAdminRoutesOptions,
): Router;

// @public
export function createMcpServerRoutes(options: McpServerRoutesOptions): Router;

// @public
export function createSkillsRoutes(options: SkillsRoutesOptions): Router;

// @public
export function createToolResourceLoader(): ResourceLoader;

// @public
export function createToolRoutes(options: ToolRoutesOptions): Router;

// @public
export class DocumentSyncService {
  constructor(options: DocumentSyncServiceOptions);
  deleteHash(documentId: string): Promise<void>;
  getHash(documentId: string): Promise<string | undefined>;
  hasChanged(documentId: string, currentHash: string): Promise<boolean>;
  setHash(documentId: string, hash: string): Promise<void>;
  static readonly TTL_MS: number;
}

// @public
export interface DocumentSyncServiceOptions {
  cache: CacheService;
  logger: LoggerService;
}

// @public
export function isDbWritable(key: BoostConfigKey): boolean;

// @public
export function isDeletableStage(stage: LifecycleStage): boolean;

// @public
export function isSensitiveField(key: BoostConfigKey): boolean;

// @public
export function isValidToolTransition(
  from: LifecycleStage,
  to: LifecycleStage,
): boolean;

// @public
export function isValidTransition(
  from: LifecycleStage,
  to: LifecycleStage,
): boolean;

// @public
export interface KagentiAdminRoutesOptions {
  httpAuth: HttpAuthService;
  logger: LoggerService;
  permissions: PermissionsService;
}

// @public
export interface McpServerRoutesOptions {
  httpAuth: HttpAuthService;
  logger: LoggerService;
  permissions: PermissionsService;
  store: McpServerStore;
}

// @public
export class McpServerStore {
  constructor(options: McpServerStoreOptions);
  create(server: {
    id: string;
    name: string;
    url: string;
    transport: McpTransport;
    authType: McpAuthType;
    description?: string;
  }): Promise<McpServerRecord>;
  delete(id: string): Promise<boolean>;
  get(id: string): Promise<McpServerRecord | undefined>;
  list(): Promise<McpServerRecord[]>;
  update(
    id: string,
    fields: {
      name?: string;
      url?: string;
      transport?: McpTransport;
      authType?: McpAuthType;
      description?: string;
    },
  ): Promise<McpServerRecord | undefined>;
}

// @public
export interface McpServerStoreOptions {
  database: DatabaseService;
  logger: LoggerService;
}

// @public
export class ProviderManager {
  getActiveProvider(): AgenticProvider;
  getRegisteredProviders(): ProviderDescriptor[];
  hasProvider(): boolean;
  registerProvider(provider: AgenticProvider): void;
  switchProvider(providerId: string): void;
}

// @public
export class RateLimiter {
  constructor(options: RateLimiterOptions);
  consume(identity: string): Promise<{
    allowed: boolean;
    remaining: number;
    retryAfterMs?: number;
  }>;
}

// @public
export interface RateLimiterOptions {
  cache: CacheService;
  logger: LoggerService;
  maxRequests?: number;
  windowMs?: number;
}

// @public
export type ResourceLoader = (req: Request_2) => Promise<
  | {
      createdBy?: string;
      lifecycleStage?: string;
    }
  | undefined
>;

// @public
export class RuntimeConfigResolver {
  constructor(options: RuntimeConfigResolverOptions);
  invalidate(): Promise<void>;
  resolve(key: BoostConfigKey): Promise<unknown | undefined>;
  resolveAll(): Promise<Map<string, unknown>>;
}

// @public
export interface RuntimeConfigResolverOptions {
  adminConfigService: AdminConfigService;
  cache: CacheService;
  config: RootConfigService;
  logger: LoggerService;
}

// @public
export type SecurityMode = 'development-only-no-auth' | 'plugin-only' | 'full';

// @public
export interface SkillsRoutesOptions {
  config: RootConfigService;
  httpAuth: HttpAuthService;
  logger: LoggerService;
  permissions: PermissionsService;
}

// @public
export class ToolLifecycleStore {
  constructor(options: ToolLifecycleStoreOptions);
  delete(id: string): Promise<boolean>;
  get(id: string): Promise<ToolRecord | undefined>;
  list(): Promise<ToolRecord[]>;
  register(tool: {
    id: string;
    name: string;
    description?: string;
    createdBy: string;
  }): Promise<ToolRecord>;
  updateStage(
    id: string,
    stage: LifecycleStage,
  ): Promise<ToolRecord | undefined>;
}

// @public
export interface ToolLifecycleStoreOptions {
  database: DatabaseService;
  logger: LoggerService;
}

// @public
export interface ToolRoutesOptions {
  httpAuth: HttpAuthService;
  logger: LoggerService;
  permissions: PermissionsService;
  store: ToolLifecycleStore;
}

// @public
export function validateConfigValue(
  key: BoostConfigKey,
  value: unknown,
): unknown;

// @public
export function validateSecurityMode(
  mode: string | undefined,
  logger: LoggerService,
): SecurityMode;