import { A as WorkflowDefinition, _t as CredentialType, at as CredentialBindingKey, bt as CredentialTypeRegistry, ct as CredentialInstanceId, ft as CredentialOAuth2AuthDefinition, ht as CredentialSessionService, it as CredentialBinding, lt as CredentialInstanceRecord, nt as McpServerDeclaration, ot as CredentialFieldSchema, p as WorkflowRepository, pt as CredentialRequirement, rt as AnyCredentialType, st as CredentialHealth, ut as CredentialJsonRecord, vt as CredentialTypeDefinition, yt as CredentialTypeId } from "./ItemsInputNormalizer-CFkfNMLt.js";
import { r as AppConfig } from "./CodemationAppContext-K51b7oXe.js";
import { u as LoggerFactory } from "./CodemationWhitelabelConfig-Ca2mCUeC.js";
import { a as CredentialInstanceWithSecretsDto, i as CredentialInstanceDto, l as WorkflowCredentialHealthDto, r as CreateCredentialInstanceRequest, s as UpdateCredentialInstanceRequest } from "./CredentialContractsRegistry-Dgu-rEXi.js";

//#region src/domain/credentials/CredentialTypeRegistryImpl.d.ts
type CredentialTypeSource = "plugin" | "config" | "controlPlane";
declare class CredentialTypeRegistryImpl implements CredentialTypeRegistry {
  private readonly loggers;
  private readonly entries;
  private readonly bySource;
  constructor(loggers: LoggerFactory);
  merge(source: CredentialTypeSource, types: ReadonlyArray<AnyCredentialType>): void;
  mergeDefinitions(source: CredentialTypeSource, definitions: ReadonlyArray<CredentialTypeDefinition>): void;
  clear(source: CredentialTypeSource): void;
  listTypes(): ReadonlyArray<CredentialTypeDefinition>;
  getType(typeId: CredentialTypeId): CredentialTypeDefinition | undefined;
  getCredentialType(typeId: CredentialTypeId): AnyCredentialType | undefined;
  private insert;
  private recordEntry;
  private createUnsupportedSessionFactory;
  private createUnsupportedHealthTester;
}
//#endregion
//#region src/mcp/McpServerCatalog.d.ts
type McpServerDeclarationSource = "plugin" | "config" | "controlPlane";
declare class McpServerCatalog {
  private readonly loggers;
  private readonly entries;
  private readonly bySource;
  private readonly env;
  constructor(loggers: LoggerFactory, appConfig: AppConfig);
  merge(source: McpServerDeclarationSource, declarations: ReadonlyArray<McpServerDeclaration>): void;
  get(id: string): McpServerDeclaration | undefined;
  getAll(): readonly McpServerDeclaration[];
  clear(source: McpServerDeclarationSource): void;
  private validate;
}
//#endregion
//#region src/domain/credentials/WorkflowCredentialNodeResolver.d.ts
type WorkflowCredentialSlotRef = Readonly<{
  workflowId: string;
  nodeId: string;
  nodeName: string;
  requirement: CredentialRequirement;
}>;
/**
 * Resolves credential requirements for workflow node ids, including connection-owned LLM/tool children.
 */
declare class WorkflowCredentialNodeResolver {
  private readonly mcpCatalog?;
  constructor(mcpCatalog?: McpServerCatalog | undefined);
  /**
   * Human-readable label for credential errors (workflow node name or agent › attachment).
   */
  describeCredentialNodeDisplay(workflow: WorkflowDefinition, nodeId: string): string;
  isCredentialNodeIdInWorkflow(workflow: WorkflowDefinition, nodeId: string): boolean;
  findRequirement(workflow: WorkflowDefinition, nodeId: string, slotKey: string): Readonly<{
    nodeName: string;
    requirement: CredentialRequirement;
  }> | undefined;
  listSlots(workflow: WorkflowDefinition): ReadonlyArray<WorkflowCredentialSlotRef>;
  private findDirectRequirement;
  private addRecursiveAgentSlots;
  private addSlotsForRequirements;
  private findRecursiveConnectionNode;
  private buildRecursiveDisplayLabel;
  private collectAncestorToolLabels;
}
//#endregion
//#region src/domain/credentials/CredentialFieldEnvOverlayService.d.ts
declare class CredentialFieldEnvOverlayService {
  private readonly appConfig;
  constructor(appConfig: AppConfig);
  /** True when the field declares an env var and process.env has a non-empty string for it. */
  isFieldResolvedFromEnv(field: CredentialFieldSchema): boolean;
  apply(args: Readonly<{
    definition: CredentialTypeDefinition;
    publicConfig: JsonRecord;
    material: JsonRecord;
  }>): Readonly<{
    resolvedPublicConfig: JsonRecord;
    resolvedMaterial: JsonRecord;
  }>;
}
//#endregion
//#region src/domain/credentials/CredentialSecretCipher.d.ts
/**
 * Schema versions:
 *   1 — key = SHA-256(rawValue)                  (legacy, read-only support retained for migration)
 *   2 — key = HKDF-SHA-256(rawKey32Bytes, ...)   (current)
 *
 * All new encryptions are written as v2. Existing v1 records can still be
 * decrypted so operators can re-encrypt at their own pace (re-bind the
 * credential in the UI, or run the one-shot re-encrypt script).
 */
declare class CredentialSecretCipher {
  private readonly appConfig;
  private static readonly algorithm;
  private static readonly currentSchemaVersion;
  private static readonly ivLength;
  private static readonly HKDF_SALT;
  private static readonly HKDF_INFO;
  constructor(appConfig: AppConfig);
  encrypt(value: JsonRecord): Readonly<{
    encryptedJson: string;
    encryptionKeyId: string;
    schemaVersion: number;
  }>;
  decrypt(record: Readonly<{
    encryptedJson: string;
    encryptionKeyId: string;
    schemaVersion: number;
  }>): JsonRecord;
  /**
   * Current (v2) key derivation: HKDF-SHA-256 with a fixed application salt and info label.
   * Input must be a base64-encoded 32-byte value (`CODEMATION_CREDENTIALS_MASTER_KEY`).
   */
  private resolveKeyMaterialV2;
  /**
   * Legacy (v1) key derivation: SHA-256 of the raw env string.
   * Retained for decrypt-side backward compatibility only.
   */
  private resolveKeyMaterialV1;
  /**
   * Validates and returns the raw 32-byte key material from the env var.
   * Throws if the env var is absent or does not decode to exactly 32 bytes.
   */
  private resolveBase64Key32Bytes;
  private resolveKeyId;
}
//#endregion
//#region src/domain/credentials/CredentialMaterialResolver.d.ts
declare class CredentialMaterialResolver {
  private readonly credentialStore;
  private readonly credentialSecretCipher;
  private readonly appConfig;
  constructor(credentialStore: CredentialStore, credentialSecretCipher: CredentialSecretCipher, appConfig: AppConfig);
  resolveMaterial(instance: CredentialInstanceRecord$1): Promise<JsonRecord>;
  private resolveEnvMaterial;
}
//#endregion
//#region src/domain/credentials/CredentialOAuth2ScopeResolver.d.ts
declare class CredentialOAuth2ScopeResolver {
  resolveRequestedScopes(auth: CredentialOAuth2AuthDefinition, publicConfig: JsonRecord): ReadonlyArray<string>;
  private resolveString;
  private resolveScopeList;
  private dedupe;
}
//#endregion
//#region src/domain/credentials/CredentialInstanceService.d.ts
declare class CredentialInstanceService {
  private readonly credentialStore;
  private readonly credentialTypeRegistry;
  private readonly credentialSecretCipher;
  private readonly credentialFieldEnvOverlayService;
  private readonly credentialMaterialResolver;
  private readonly credentialOAuth2ScopeResolver;
  private readonly credentialSessionService;
  constructor(credentialStore: CredentialStore, credentialTypeRegistry: CredentialTypeRegistryImpl, credentialSecretCipher: CredentialSecretCipher, credentialFieldEnvOverlayService: CredentialFieldEnvOverlayService, credentialMaterialResolver: CredentialMaterialResolver, credentialOAuth2ScopeResolver: CredentialOAuth2ScopeResolver, credentialSessionService: MutableCredentialSessionService);
  listInstances(): Promise<ReadonlyArray<CredentialInstanceDto>>;
  getInstance(instanceId: CredentialInstanceId): Promise<CredentialInstanceDto | undefined>;
  getInstanceWithSecrets(instanceId: CredentialInstanceId): Promise<CredentialInstanceWithSecretsDto | undefined>;
  create(request: CreateCredentialInstanceRequest): Promise<CredentialInstanceDto>;
  update(instanceId: CredentialInstanceId, request: UpdateCredentialInstanceRequest): Promise<CredentialInstanceDto>;
  delete(instanceId: CredentialInstanceId): Promise<void>;
  disconnectOAuth2(instanceId: CredentialInstanceId): Promise<CredentialInstanceDto>;
  requireInstance(instanceId: CredentialInstanceId): Promise<CredentialInstanceRecord$1>;
  private createSecretRef;
  private createSecretMaterial;
  private validateRequestFields;
  private stripEnvManagedFieldValues;
  private assertRequiredFields;
  private assertRequiredEnvFields;
  private requireCredentialType;
  markOAuth2Connected(instanceId: CredentialInstanceId, connectedAt: string): Promise<void>;
  private toDto;
  private toOAuth2ConnectionDto;
}
//#endregion
//#region src/domain/credentials/CredentialBindingService.d.ts
declare class CredentialBindingService {
  private readonly credentialStore;
  private readonly credentialInstanceService;
  private readonly workflowRepository;
  private readonly credentialSessionService;
  private readonly workflowCredentialNodeResolver;
  private readonly logger;
  constructor(credentialStore: CredentialStore, credentialInstanceService: CredentialInstanceService, workflowRepository: WorkflowRepository, credentialSessionService: MutableCredentialSessionService, workflowCredentialNodeResolver: WorkflowCredentialNodeResolver, loggerFactory: LoggerFactory);
  upsertBinding(args: Readonly<{
    workflowId: string;
    nodeId: string;
    slotKey: string;
    instanceId: CredentialInstanceId;
  }>): Promise<CredentialBinding>;
  assertRequiredCredentialsBound(workflowId: string): Promise<void>;
  listWorkflowHealth(workflowId: string): Promise<WorkflowCredentialHealthDto>;
  private requireWorkflow;
  private requireRequirement;
  private toBindingKeyString;
}
//#endregion
//#region src/domain/credentials/CredentialServices.d.ts
type JsonRecord = CredentialJsonRecord;
type CredentialSecretRef = Readonly<{
  kind: "db";
} | {
  kind: "env";
  envByField: Readonly<Record<string, string>>;
} | {
  kind: "code";
  value: JsonRecord;
}>;
/**
 * Persisted credential instance for the host store (stricter `CredentialSecretRef` than core's envelope).
 */
type CredentialInstanceRecord$1<TPublicConfig extends JsonRecord = JsonRecord> = Readonly<Omit<CredentialInstanceRecord<TPublicConfig>, "secretRef"> & {
  secretRef: CredentialSecretRef;
}>;
type CredentialSecretMaterialRecord = Readonly<{
  instanceId: CredentialInstanceId;
  encryptedJson: string;
  encryptionKeyId: string;
  schemaVersion: number;
  updatedAt: string;
}>;
type CredentialOAuth2MaterialMetadata = Readonly<{
  providerId: string;
  connectedEmail?: string;
  connectedAt?: string;
  scopes: ReadonlyArray<string>;
  updatedAt: string;
}>;
type CredentialOAuth2MaterialRecord = Readonly<{
  instanceId: CredentialInstanceId;
} & CredentialSecretMaterialRecord & CredentialOAuth2MaterialMetadata>;
type CredentialOAuth2StateRecord = Readonly<{
  state: string;
  instanceId: CredentialInstanceId;
  codeVerifier?: string;
  providerId?: string;
  requestedScopes: ReadonlyArray<string>;
  createdAt: string;
  expiresAt: string;
}>;
type CredentialTestRecord = Readonly<{
  testId: string;
  instanceId: CredentialInstanceId;
  health: CredentialHealth;
  testedAt: string;
  expiresAt?: string;
}>;
interface CredentialStore {
  listInstances(): Promise<ReadonlyArray<CredentialInstanceRecord$1>>;
  getInstance(instanceId: CredentialInstanceId): Promise<CredentialInstanceRecord$1 | undefined>;
  saveInstance(args: Readonly<{
    instance: CredentialInstanceRecord$1;
    secretMaterial?: CredentialSecretMaterialRecord;
  }>): Promise<void>;
  deleteInstance(instanceId: CredentialInstanceId): Promise<void>;
  getSecretMaterial(instanceId: CredentialInstanceId): Promise<CredentialSecretMaterialRecord | undefined>;
  createOAuth2State(record: CredentialOAuth2StateRecord): Promise<void>;
  consumeOAuth2State(state: string): Promise<CredentialOAuth2StateRecord | undefined>;
  getOAuth2Material(instanceId: CredentialInstanceId): Promise<CredentialOAuth2MaterialRecord | undefined>;
  saveOAuth2Material(args: Readonly<{
    instanceId: CredentialInstanceId;
    encryptedJson: string;
    encryptionKeyId: string;
    schemaVersion: number;
    metadata: CredentialOAuth2MaterialMetadata;
  }>): Promise<void>;
  deleteOAuth2Material(instanceId: CredentialInstanceId): Promise<void>;
  upsertBinding(binding: CredentialBinding): Promise<void>;
  getBinding(key: CredentialBindingKey): Promise<CredentialBinding | undefined>;
  listBindingsByWorkflowId(workflowId: string): Promise<ReadonlyArray<CredentialBinding>>;
  saveTestResult(record: CredentialTestRecord): Promise<void>;
  getLatestTestResult(instanceId: CredentialInstanceId): Promise<CredentialTestRecord | undefined>;
  getLatestTestResults(instanceIds: ReadonlyArray<CredentialInstanceId>): Promise<ReadonlyMap<CredentialInstanceId, CredentialTestRecord>>;
}
type CredentialType$1<TPublicConfig extends JsonRecord = JsonRecord, TMaterial extends JsonRecord = JsonRecord, TSession = unknown> = CredentialType<TPublicConfig, TMaterial, TSession>;
type MutableCredentialSessionService = CredentialSessionService & Readonly<{
  evictInstance(instanceId: CredentialInstanceId): void;
  evictBinding(bindingKey: CredentialBindingKey): void;
}>;
//#endregion
export { CredentialSecretCipher as a, CredentialInstanceService as i, CredentialType$1 as n, McpServerCatalog as o, CredentialBindingService as r, CredentialStore as t };
//# sourceMappingURL=CredentialServices-B3wPyp2y.d.ts.map